versadac  1
versadac - Scalable Recorder Firmware
fb_dre.h
1 /*******************************************************************************
2 FILE : fb_dre.h
3 AUTHOR : Karl Wakeham
4 SYSTEM : VxWorks on ARM
5 DESCRIPTION : Data Recording Engine header file
6 *******************************************************************************/
7 #ifndef __FB_DRE_H
8 #define __FB_DRE_H
9 
10 #ifndef NULL
11 #define NULL (0)
12 #endif
13 
14 #include "stdtypes.h"
15 #include "dre_msg.h"
16 #include "OSTask.h"
17 #include "dre.h"
18 #include "sr_group_interface.h"
19 
20 #define BATCH_SUPPORTED (1)
21 
22 #ifdef BATCH_SUPPORTED
23 #include "batch_interface.h"
24 #endif
25 
26 #define DRE_INST_TYPE 62 // versadac
27 #define MAX_NO_OF_ALARMS_PER_POINT 2
28 
29 #define DRE_ALM_OFF 0 // inavtive
30 #define DRE_PNT_ALM_ON_ACK 1 // active and acknowledged
31 #define DRE_PNT_ALM_ON_NO_ACK_1 2 // safe but unacknowledged
32 #define DRE_PNT_ALM_ON_NO_ACK_2 3 // active but unacknowledged
33 
34 class DreTask;
35 
36 // Minmax data structure. One per group is needed.
37 typedef struct {
38  bool bEnabled; // Other fields are only valid if this is TRUE
39  bool bReset; // Used to indicate start of min-max interval
40  uint8 *auMinStatus; // One per point in the group
41  uint8 *auMaxStatus; // Ditto
42  double *adMinValue; // Ditto
43  double *adMaxValue; // Ditto
44 } DRE_MINMAX_T;
45 
46 class fb_dre
47 {
48  public:
49 
50  fb_dre();
51  ~fb_dre();
52 
53  // Private methods
54  static uint32 niceFactor(uint32 z_period, uint32 z_ticksPerSec);
55  static void emptyDreHistory();
56 
57  void kill();
58  void recreate();
59  void update();
60  void start();
61  void sendEmptyAllGroups();
62  bool sendEmptyAllGroupsAndWait();
63  void sendTimeChangedMessage(double z_prevTicks);
64  uint8 getCurrentStatus(uint8 z_group);
65 
66 #if(0)
67  // HISTORY ERASE NOT SUPPORTED IN THE NANO
68  void sendHistoryEraseMessage(char * z_messageKey);
69 #endif
70 
71  private:
72 
73 #ifdef BATCH_SUPPORTED
74  void genBatchHdr( uint16 z_group, uint8 z_start);
75  void sendBatchStart( uint16 z_group );
76  void sendBatchStop( uint16 z_group );
77 #endif
78 
79  void disableMinmax(uint16 z_group);
80  void prodDreTask();
81  void sendAlarmIfChange();
82  void genHistHdr();
83  void sendRecStatus();
84  void sendSync();
85  void genPtHdr(uint16 z_uPt);
86  void genRefAlm();
87  void genRefPV();
88  void sendSample();
89  void genSegHdrs();
90  void sendStop(double z_time);
91  void sendGroupSlowedMessage(double z_time, uint8 z_group, uint32 z_factor);
92  void updateABSelects();
93 
94 #if(0)
95  // MINMAX NOT SUPPORTED IN THE NANO
96  void updateMinmax();
97 #endif
98 
99 #ifdef BATCH_SUPPORTED
100  batch_data_t *m_batch_data;
101 #endif
102 
103  char * m_directory;
104  sint32 m_memSizeGuide;
105  uint32 m_fileSizeGuide;
106  uint32 m_blockSizeGuide;
107  uint16 m_minFlushPeriod;
108 
109  bool **m_pColourBSelects;
110  bool **m_pColourBGroupSelects;
111 
112  bool **m_pSpanZoneBSelects;
113  bool **m_pSpanZoneBGroupSelects;
114 
115  bool **m_pRecordSpeedBGroupSelects;
116 
117 
118  // Input data
119  bool *m_pGroups;
120  queue *m_pDreQueue;
121  pv_t *m_pPVs;
122 
123  bool *m_pZoneB;
124  bool *m_pColourB;
125  int32 m_tzOffset;
126  bool m_onOff;
127  bool m_useDst;
128  bool *m_rec_suspend;
129  bool *m_rec_job_wired;
130  bool *m_pSpeedB;
131  bool *m_pbLostMsg;
132  uint8 m_trdUnits;
133 
134  uc_string_20 m_areaName;
135  uc_string_20 m_dstStart;
136  uc_string_20 m_dstEnd;
137  uc_string_20 m_timezone;
138  uc_string_5 m_language;
139  uc_string_5 m_country;
140 
141  // Input copies, for detection of change
142  uint8 m_oldTrdUnits;
143  bool m_oldUseDst;
144  int32 m_oldTzOffset;
145  uc_string_5 m_oldLanguage;
146  uc_string_5 m_oldCountry;
147  uc_string_5 m_oldTimezone;
148  uc_string_20 m_oldDstStart;
149  uc_string_20 m_oldDstEnd;
150 
151  // Configuration parameters
152  uint16 m_version; // Function block version
153  uint16 m_maxGps; // maximum number of groups
154  uint16 m_numGps; // Total number of groups
155  uint16 m_numModules; // Number of modules
156  uint16 m_numMPts; // Total number of module channels
157  uint16 m_numVPts; // Total number of virtual channels
158  uint16 m_numAllPts; // Toal of channels and Vchannels
159  uint16 m_numAlmsPerPt; // Maximum number of alarms per point
160  uc_char m_acAreaNameDflt[DRE_UHH_INSTR_NAME_L+1]; // Dflt area
161  bool m_bWhenRecordingDisabledRecordText;
162  bool m_bHistoryEraseFromUpdateAllowed;
163 
164  // Configuration derived parameters
165  uint32 m_numAlms; // Total number of alarms
166  bool m_bHighCompress; // Whether high compression is used
167  bool m_double; // Store data as double precision
168  uint8 m_bytes; // Number of bytes to store
169 
170  // Private statics
171  static DreTask *pTheTask;
172  static uint16 m_serialNumber;
173 
174  // Messages stuff
175  uint32 m_maxMsgSize;
176  uint8 *m_auMsg;
177  DRE_MSG_LOST_DATA_T m_lostData;
178  exchange_id m_dreExchange;
179  DRE_INST_HDR_T m_dreInstHdr;
180 
181  // Stuff used during update
182  bool m_bRecording;
183  double m_time;
184  sint32 m_timeSegment;
185  uint8 m_group;
186  uint8 m_fastestGroup;
187  uint32 m_fastestUpdatePeriod;
188  uint32 m_checkOverflowPeriod;
189  bool *m_abOldAckReqd;
190  bool *m_abOldAlarm;
191  bool m_bFirstQueueOverflow;
192  bool m_bRequestEraseHistory; // Asynchronous request for history erase.
193  bool m_bEraseHistory; // Latched copy of history erase for each update.
194  bool m_bOldEraseHistory; // Change detection of history erase.
195  sint32 m_eraseHistoryResult;
196 
197  // The following are required for each group
198  uint32 *m_auUpdateFactor;
199  uint32 *m_auUpdatePeriod;
200  bool *m_abUpdatePeriodBActive;
201  double *m_adNextUpdateTime;
202  bool *m_abRecEnabled; // Last read values of m_rec_enbl inputs
203  uint8 *m_auRecStatus; // Current recording statuses
204  uint8 *m_auRecStatusSent; // Recording statuses successfully queued
205  DRE_MINMAX_T *m_aMinmax;
206  uint8 *m_mac;
207  bool *m_pGroupRec;
208  bool m_groupQAttached;
209  process_id m_id;
210 };
211 
212 #endif // __FB_DRE_H
Definition: stdtypes.h:204
Definition: stdtypes.h:155
Definition: dre_task.h:25
Definition: dre_msg.h:308
Definition: fb_dre.h:37
Definition: stdtypes.h:223
Definition: stdtypes.h:213
Definition: fb_dre.h:46
Definition: dre_msg.h:226