versadac  1
versadac - Scalable Recorder Firmware
dre_task.h
1 /*****************************************************************************
2 FILE : dre_task.h
3 AUTHOR : Dave Storey
4 SYSTEM : GNU C++ for ARM
5 DESCRIPTION : Data Recording Engine task class declaration
6 *****************************************************************************/
7 
8 #ifndef __DRE_TASK_H
9 #define __DRE_TASK_H
10 
11 #include "dre_msg.h"
12 #include "dre_hist.h"
13 #include "OSTask.h"
14 
15 #define DRE_TASK_NAME ((char*)"DRET")
16 
17 extern "C"
18 {
19  #include "dre.h"
20 }
21 
22 class DreFile;
23 class DreHistMgr;
24 
25 class DreTask : public OSRunnableTask
26 {
27  public:
28 
29  DreTask(const char *z_szDirectory, sint32 z_nMemSizeGuide, uint32 z_uFileSizeGuide, uint32 z_uBlockSizeGuide);
30  ~DreTask();
31 
32  void runTask();
33 
34  // NB attach() is public, and can be called from another task,
35  // but detach() is private, and can only be called via a message.
36  bool attach(DRE_INST_HDR_T *z_pDreInstHdr, queue_id z_QueueId, uint16 z_uMaxMsgSize, uint16 z_uNumGroups);
37 
38  bool queueOverflow(){return m_bQueueOverflow;}
39  void setQueueOverflow(){m_bQueueOverflow = TRUE;}
40  bool isAttached(){return m_bAttached;}
41  bool isRunning(){return m_bRunning;}
42  void setSizeGuides(sint32 z_nMem, uint32 z_uBlock, uint32 z_uFile);
43 
44  private:
45 
46  static uint8 s_uPriority;
47  static uint16 s_uStack;
48 
49  const char *m_szDirectory; // Directory for history files
50  bool m_bQueueOverflow; // TRUE if DRE queue overflowed
51  bool m_bRunning; // TRUE while task is running normally
52  queue_id m_QueueId; // Id for the DRE queue
53  bool m_bAttached; // TRUE while attached to the DRE queue
54  uint16 m_uMsgMax;
55  uint8 *m_auMsgBuf;
56  uint16 m_uWakeup; // Wake-up period, in scos ticks
57 
58  DreHistMgr *m_pHistMgr; // The instrument history manager
59  bool m_bHistLocked; // History is locked
60  bool m_bPendingDetach; // Detach pending during history lock
61  bool m_bPendingKill; // Kill pending during history lock
62 
63  uint16 m_uNumGroups; // Number of groups being recorded
64  DreFile *m_pFiles; // List of active files
65  DreFile **m_apFiles; // File table, for faster access
66  uint8 *m_auRecStatus; // Recording statuses for each group
67  sint32 m_nMemSizeGuide; // Memory size guide (-ve means free space)
68  uint32 m_uFileSizeGuide; // File size guide
69  uint32 m_uBlockSizeGuide; // UHH block size guide
70  uint8 m_uSampPerTrunc; // Samples per truncation count
71  uint16 m_uQServicePerFlush;// Queue services per periodic flush
72  uint16 m_uSerialNumber;
73 
74  uint32 m_uInstrId; // Instrument Id (derived from MAC address)
75 
76  DRE_INST_HDR_T *m_pDreInstHdr;
77 
78  // Private methods
79  void checkSlicing(DreFile *z_pFile, double z_dTime);
80  void checkSlicingAll(double z_dTime);
81  bool checkTruncation();
82  void clearHistory();
83  void detach(); // See comments for attach(), above.
84  void kill();
85  void lockHistory();
86  void msgHistory(DRE_HIST_HDR_T *z_pMsg);
87  void msgRecStatus(DRE_MSG_RECSTATUS_T *z_pMsg);
88  void serviceQueue(bool z_bFlushFiles = FALSE); // Services the DRE queue
89  bool serviceQueueMsg(); // Services a msg from the DRE queue
90  void stop();
91  void unlockHistory();
92  void xArchive(uint32 *z_auMsg); // Exchange message - archive category
93  void xBatch(uint32 *z_auMsg); // Exchange message - batch category
94  void xGeneral(uint32 *z_auMsg); // Exchange message - general category
95  uint16 numGroupsEnabled();
96 
97  exchange_id m_xid;
98  int m_tid;
99  process_id m_id;
100 };
101 
102 #endif // __DRE_TASK_H
Definition: ostask.h:16
Definition: dre_msg.h:297
Definition: dre_msg.h:51
Definition: dre_file.h:20
Definition: stdtypes.h:189
Definition: dre_task.h:25
Definition: stdtypes.h:223
Definition: dre_hmgr.h:24
Definition: stdtypes.h:213
Definition: dre_msg.h:226