CARMA C++
scanner.h
1 #ifndef scanner_h
2 #define scanner_h
3 
4 #include "carma/szaarrayutils/rtcnetcoms.h"
5 #include "carma/szaarrayutils/szaregs.h"
6 
7 /*
8  * Scanner information that is shared between sun control program and
9  * VxWorks tasks.
10  */
11 #include "carma/szautil/SzaPorts.h"
12 
13 /*
14  * Enumerate control-program -> scanner-task message types.
15  */
16 typedef enum {
17  SCAN_GREETING /* Sent by a client on connecting to the scanner task */
18 } CpToScanner;
19 
20 /*
21  * Enumerate scanner-task -> control-program message types.
22  */
23 typedef enum {
24  SCAN_DATA_MSG /* A message containing register values */
25 } ScannerToCp;
26 
27 /*
28  * Determine the max number of register snapshots to be buffered when
29  * the scanner capture rate exceeds the network bandwidth.
30  */
31 enum {SCAN_MAX_FRAME=100};
32 
33 /*
34  * Set the size of the scanner network read-buffer.
35  */
36 enum {SCAN_MAX_CMD_SIZE=100};
37 
38 // Deprecated -- calculations assuming every register is an unsigned
39 // int type
40 
41 /*
42  * The network buffer that is used to communicate register frames
43  * to the control program has size:
44  * sizeof(unsigned) * (SCAN_HEADER_DIM + regmap->narchive)
45  */
46 #define SCAN_HEADER_DIM ((NET_PREFIX_LEN+sizeof(unsigned)-1)/sizeof(unsigned))
47 #define SCAN_HEADER_PAD (SCAN_HEADER_DIM * sizeof(unsigned) - NET_PREFIX_LEN)
48 #define SCAN_BUFF_SIZE(nreg) (sizeof(unsigned) * (SCAN_HEADER_DIM + (nreg)))
49 
50 // Calculations for register maps which can consist of variable-size
51 // types
52 
53 /*
54  * The network buffer that is used to communicate register frames
55  * to the control program has size:
56  *
57  * sizeof(unsigned) * (SCAN_HEADER_DIM + regmap->narchive)
58  */
59 
60 #define SCAN_BUFF_BYTE_SIZE(nByte) (sizeof(unsigned) * SCAN_HEADER_DIM + nByte)
61 
62 /*
63  * Set limits on the allowable integration intervals. Intervals
64  * are specified as power of 2 multipliers of the basic
65  * (12.8us x 2^SCAN_BASE_HARDWARE_INTERVAL)
66  * second sampling time.
67  */
68 enum {
69  SCAN_BASE_HARDWARE_INTERVAL = 5, /* Hardware basis interval */
70  SCAN_MIN_HARDWARE_INTERVAL = 5, /* Prevent high-frequency interrupts */
71  SCAN_MAX_HARDWARE_INTERVAL = 12, /* Prevent hardware overflow */
72  SCAN_DEF_HARDWARE_INTERVAL = 11 /* The default interval [0.84 seconds] */
73 };
74 
75 /*-----------------------------------------------------------------------
76  * VxWorks-specific definitions.
77  */
78 #ifdef VXW
79 
80 TASK_NEW_FN(new_Scanner);
81 TASK_DEL_FN(del_Scanner);
82 TASK_INI_FN(ini_Scanner);
83 TASK_TST_FN(tst_Scanner);
84 TASK_END_FN(end_Scanner);
85 
86 int sza_scanner_task(void *resources);
87 
88  /* The max number of queued messages on the scanner message queue */
89 
90 #define SCAN_SMQ_LEN 100
91 
92  /* Timeout for sends to the scanner message queue - clock ticks */
93 
94 #define SCAN_SMQ_TIMEOUT 60
95 
96  /* Name the IP network interface for use in ifAddrGet() and ifAddrSet() */
97 
98 #define SCAN_IP_INTERFACE "ei0"
99 
100 /*
101  * Set the name of the I/O system binary semaphore that is used by
102  * the system timing generator to trigger frame acquisition.
103  */
104 #define SCAN_STROBE_DEVICE "/sem/strobe"
105 
106 /* Forward a network command to the scanner task */
107 
108 TASK_FWD_FN(forward_scanner_netcmd);
109 /*
110  * Network commands forwarded from the control program to this task by
111  * the controller task, are passed in a container of the following type.
112  */
113 typedef struct {
114  NetCmdId id; /* The type of command contained in 'cmd' */
115  RtcNetCmd cmd; /* The body of the command */
116 } ScanNetCmd;
117 
118 /*
119  * A structure of the following type is used by all tasks that
120  * send messages to the scanner task over its message queue. It
121  * contains the type and contents of the message.
122  */
123 typedef struct {
124 /*
125  * Enumerate the message type.
126  */
127  enum { /* The type of message */
128  SCAN_SHUTDOWN, /* Shutdown the scanner task */
129  SCAN_HEARTBEAT, /* Report task status to controller */
130  SCAN_GRABBER, /* Scan the frame grabber for a new image. */
131  SCAN_SETREG_DONE, /* A setreg command is done -- forwarded by the
132  probe task */
133  SCAN_TV_OFFSET_DONE,/* A tv_offset command is done -- forwarded by
134  the tracker task */
135  SCAN_NET_CMD /* A forwarded network command */
136  } type;
137 /*
138  * Describe the contents of each message type.
139  */
140  union { /* A union of all message-type message-contents */
141  ScanNetCmd net; /* SCAN_NET_CMD */
142  unsigned setreg_seq; /* SCAN_SETREG_DONE */
143  unsigned tv_offset_seq;/* SCAN_TV_OFFSET_DONE */
144  } body;
145 } ScannerMessage;
146 
147 /*
148  * Function used to send the scanner task messages via its message
149  * queue.
150  */
151 int scanner_send_message(ScannerMessage *msg, size_t size);
152 
153 /*-----------------------------------------------------------------------
154  * Host-specific definitions.
155  */
156 #else
157 
158 #endif
159 
160 #endif