CARMA C++
scheduler.h
1 #ifndef scheduler_h
2 #define scheduler_h
3 
4 #include "astrom.h"
5 #include "hash.h"
6 
7 #include "carma/szaarrayutils/control.h"
8 
9 /*
10  * Warning: The facilities in this file are only for use by functions
11  * called by the scheduler thread. They can not be safely called by
12  * other threads. See szacontrol.h for thread-safe scheduler facitities.
13  */
14 
15 /*
16  * Compile a script.
17  */
18 Script *sch_compile_schedule(Scheduler *sch, char *dir, char *filename,
19  InputStream *arguments);
20 /*
21  * Queue a schedule for subsequent execution.
22  */
23 int sch_queue_schedule(Scheduler *sch, Script *sc);
24 
25 /*
26  * Abort the currently running schedule.
27  */
28 int sch_abort_schedule(Scheduler *sch);
29 
30 /*
31  * Temporarily suspend execution of the currently running schedule.
32  */
33 int sch_suspend_schedule(Scheduler *sch);
34 
35 /*
36  * Resume execution of the currently running schedule, assuming that
37  * it has previously been suspended.
38  */
39 int sch_resume_schedule(Scheduler *sch);
40 
41 /*
42  * Move the schedule at position 'n' in the schedule queue to
43  * queue position n+dn.
44  */
45 int sch_move_schedule(Scheduler *sch, unsigned n, int dn);
46 
47 /*
48  * Remove and discard the schedule at position 'n' in the
49  * schedule queue.
50  */
51 int sch_remove_schedule(Scheduler *sch, unsigned n);
52 
53 
54 /*
55  * When a schedule is no longer needed, call this function to discard
56  * it. When actually be returned to the schedule pool until all users have
57  * finished with it.
58  */
59 Script *sch_discard_schedule(Scheduler *sch, Script *sc);
60 
61 /*
62  * When a script pointer is newly recorded for subsequent use, the following
63  * function should be called to make sure that another user doesn't
64  * delete it when calling sch_discard_script(). It increments a reference
65  * count which later gets decremented by sch_discard_script().
66  */
67 Script *sch_reference_schedule(Script *sc);
68 
69 /*
70  * Specify a schedule to be executed whenever the real-time controller
71  * is restarted.
72  */
73 int sch_change_init_script(Scheduler *sch, Script *sc);
74 
75 /*
76  * Get a readonly alias to the site configuration object.
77  */
78 sza::array::Site *sch_Site(Scheduler *sch);
79 
80 /*
81  * The following calls allow a schedule to wait until an interactive
82  * user send a trigger command. The interactive user calls a command
83  * that invokes sch_add_trigger(), while the schedule polls on
84  * calls to sch_read_trigger() until the trigger count is non-zero.
85  * Note that each call to sch_add_trigger() increments a trigger counter,
86  * whereas each call to sch_read_trigger() decrements this counter except
87  * when it is zero.
88  */
89 int sch_add_trigger(Scheduler *sch);
90 int sch_read_trigger(Scheduler *sch);
91 
92 // The following command tells the real-time controller that the
93 // initialization script has ended.
94 
95 int sch_init_ended_send(Scheduler *sch);
96 
97 // The following functions allow one to command new phase-shifter
98 // positions, then check on their progress. Both sch_pshifter_send
99 // and sch_polwalsh_send will generate a NET_PHASE_DONE message in
100 // response.
101 
102 int sch_pshifter_send(Scheduler *sch, unsigned antennas, int half,
103  unsigned posn);
104 int sch_polwalsh_send(Scheduler *sch, unsigned antennas, int half,
105  unsigned walshstep);
106 /*
107  * The following functions allow one to command new frame from the frame grabber
108  * then check on it's reception status by the grabber thread
109  */
110 int sch_grab_send(Scheduler *sch);
111 unsigned int sch_grab_done(Scheduler *sch);
112 /*
113  * The following functions allow one to send long-duration commands
114  * to the channelizer, and check on their combined completion status.
115  */
116 int sch_chzr_send_power(Scheduler *sch, unsigned bands, unsigned antennas,
117  double power);
118 int sch_chzr_send_zero(Scheduler *sch, unsigned bands, unsigned antennas);
119 unsigned int sch_chzr_done(Scheduler *sch);
120 
121 /*
122  * CalTert positioning commands require a sequence number. This should
123  * be obtained from the return value of sch_next_caltert_seq(). The
124  * sch_caltert_done() function returns a bitmask in which the bit for
125  * the corresponding antennas will be non-zero when the caltert
126  * command for which a sequence number was obtained has completed.
127  */
128 unsigned sch_next_caltert_seq(Script* sc, Scheduler *sch);
129 unsigned sch_caltert_done(Scheduler *sch);
130 
131 /*
132  * The newFrame command requires a sequence number
133  */
134 unsigned sch_next_frame_seq(Script* sc, Scheduler *sch);
135 unsigned sch_frame_done(Scheduler *sch);
136 
140 unsigned sch_next_noise_seq(Script* sc, Scheduler *sch);
141 unsigned sch_noise_done(Scheduler *sch);
142 
146 unsigned sch_next_can_seq(Script* sc, Scheduler *sch);
147 unsigned sch_can_done(Scheduler *sch);
148 
152 unsigned sch_next_IFMod_seq(Script* sc, Scheduler *sch);
153 unsigned sch_IFMod_done(Scheduler *sch);
154 
155 /*
156  * Many tracker commands require a sequence number. This should be
157  * obtained from the return value of sch_next_pmac_seq().
158  * The sch_pmac_done() function returns non-zero whenever the last
159  * tracker command for which a sequence number was obtained has
160  * completed.
161  */
162 unsigned sch_next_pmac_seq(Script* sc, Scheduler *sch, unsigned antennas);
163 unsigned sch_pmac_done(Scheduler *sch);
164 
165 /*
166  * The sch_tv_offset_done() function returns non-zero whenever the last
167  * tracker command for which a sequence number was obtained has
168  * completed.
169  */
170 unsigned sch_next_tv_offset_seq(Script* sc, Scheduler *sch);
171 unsigned int sch_tv_offset_done(Scheduler *sch);
172 
173 /*
174  * When a mark command is sent to the scanner, it is accompanied by
175  * a uniq sequence number, returned by sch_next_pmac_seq(). When
176  * the effects of this command have been seen by the archiver and
177  * recorded in the archive, the archiver tells the scheduler that
178  * the transaction has been completed, and thereafter, unless another
179  * mark command has been issued, sch_pmac_done() returns true.
180  */
181 unsigned sch_next_mark_seq(Script* sc, Scheduler *sch);
182 unsigned int sch_mark_done(Scheduler *sch);
183 
184 /*
185  * When a setreg command is sent to the probe, it is accompanied by
186  * a uniq sequence number, returned by sch_next_setreg_seq(), and
187  * forwarded to the scanner. When the effects of this command have been seen
188  * by the archiver and recorded in the archive, the archiver tells the
189  * scheduler that the transaction has been completed, and thereafter, unless
190  * another setreg command has been issued, sch_setreg_done() returns true.
191  */
192 unsigned sch_next_setreg_seq(Script* sc, Scheduler *sch);
193 unsigned int sch_setreg_done(Scheduler *sch);
194 
195 /*
196  * When a tv_offset command is issued, it is accompanied by a unique
197  * sequence number, returned by sch_next_offset_seq(), and forwarded
198  * to the tracker. When the effects of this command have been seen by
199  * the archiver and recorded in the archive, the archiver tells the
200  * scheduler that the transaction has been completed, and thereafter,
201  * unless another setreg command has been issued, sch_offset_done()
202  * returns true. */
203 unsigned sch_next_offset_seq(Script* sc, Scheduler *sch);
204 unsigned int sch_offset_done(Scheduler *sch);
205 /*
206  * When a grab command is sent to the scanner, it is accompanied by
207  * a uniq sequence number, returned by sch_next_grab_seq(). When
208  * the effects of this command have been seen by the grabber
209  * the transaction has been completed, and thereafter, unless another
210  * mark command has been issued, sch_grab_done() returns true.
211  */
212 unsigned sch_next_grab_seq(Script* sc, Scheduler *sch);
213 unsigned int sch_grab_done(Scheduler *sch);
214 
215 /*
216  * Set/get the default elevation of the local horizon.
217  */
218 int sch_set_horizon(Scheduler *sch, double angle);
219 double sch_get_horizon(Scheduler *sch);
220 
221 /* Add to the list of signal names recognized by the scheduler. */
222 
223 Symbol *sch_add_signal(Scheduler *sch, char *name);
224 
225 /* Send a signal to the currently running schedule */
226 
227 int sch_signal_schedule(Scheduler *sch, Symbol *sig);
228 
229 /* Lookup the symbol table entry of a given signal */
230 
231 Symbol *sch_lookup_signal(Scheduler *sch, char *name);
232 
233 /*
234  * In order for szascript to be able to implement functions that
235  * query the last values that were given to pertinent configuration
236  * parameters, the scheduler uses a container of the following type
237  * to cache the last values of these parameters.
238  */
239 typedef struct {
240  struct { /* Archive command parameters */
241  unsigned combine; /* The last value of "archive combine=" */
242  unsigned filter; /* True if archive filtering is turned on */
243  } archive;
244 } SchedCache;
245 
246 SchedCache *sch_sched_cache(Scheduler *sch);
247 
248 int pack_scheduler_auto_dir(SchedulerMessage *msg, char *dir);
249 int pack_scheduler_auto_poll(SchedulerMessage *msg, long ms);
250 int pack_scheduler_auto_state(SchedulerMessage *msg, int on);
251 
252 int sch_send_paging_state(Scheduler *sch, int allow,
253  ListNode *client = 0,
254  unsigned mask = sza::array::PAGE_ENABLE,
255  char* msg=0);
256 
257 int sch_send_antenna_selection(Scheduler *sch, ListNode *client);
258 
259 int sch_sendPagerCondition(Scheduler *sch, ListNode *client,
260  unsigned mode, sza::util::PagerMonitor::RegSpec* regSpec);
261 
262 int sch_sendCmdTimeoutConfiguration(Scheduler *sch, ListNode *client,
263  unsigned seconds);
264 
265 int sch_sendCmdTimeoutConfiguration(Scheduler *sch, ListNode *client,
266  bool enable);
267 
268 int sch_sendArrayConfiguration(Scheduler* sch, ListNode* node,
269  unsigned mode, unsigned array, unsigned config);
270 
271 int sch_sendAddArrayAntenna(Scheduler* sch, ListNode* client,
272  unsigned array, unsigned iPad,
273  unsigned antType, int iAnt);
274 
275 int sch_sendRemArrayAntenna(Scheduler* sch, ListNode* client,
276  unsigned array, unsigned iPad);
277 
278 #endif
279 
A struct for handling information about a single register.
Definition: PagerMonitor.h:45