milk  1.01
Modular Image processing Library toolKit
function_parameters.h
Go to the documentation of this file.
1 
10 #ifndef FUNCTION_PARAMETERS_H
11 
12 #define FUNCTION_PARAMETERS_H
13 
14 
15 
16 
17 
18 #define STRINGMAXLEN_FPS_LOGMSG 1000
19 #define STRINGMAXLEN_FPS_CMDLINE 1000
20 
21 
22 
23 #define NB_FPS_MAX 100
24 
25 #define MAXNBLEVELS 20
26 
27 #define FPSCONNECT_SIMPLE 0
28 #define FPSCONNECT_CONF 1
29 #define FPSCONNECT_RUN 2
30 
31 
32 // CMCODE type is uint32_t
33 #define FPSCMDCODE_CONFSTART 0x00000001 // start configuration process
34 #define FPSCMDCODE_CONFSTOP 0x00000002 // stop configuration process
35 #define FPSCMDCODE_FPSINIT 0x00000004 // initialize FPS if does not exist
36 #define FPSCMDCODE_FPSINITCREATE 0x00000008 // (re-)create FPS even if it exists
37 #define FPSCMDCODE_RUNSTART 0x00000010 // start run process
38 #define FPSCMDCODE_RUNSTOP 0x00000020 // stop run process
39 #define FPSCMDCODE_TMUXSTART 0x00000100 // start tmux sessions
40 #define FPSCMDCODE_TMUXSTOP 0x00000200 // stop tmux sessions
41 
42 
43 // function can use this structure to expose parameters for external control or monitoring
44 // the structure describes how user can interact with parameter, so it allows for control GUIs to connect to parameters
45 
46 #define FUNCTION_PARAMETER_KEYWORD_STRMAXLEN 64
47 #define FUNCTION_PARAMETER_KEYWORD_MAXLEVEL 20
48 
49 // Note that notation allows parameter to have more than one type
50 // ... to be used with caution: most of the time, use type exclusively
51 // type is uint32_t
52 
53 #define FPTYPE_UNDEF 0x00000001
54 #define FPTYPE_INT32 0x00000002
55 #define FPTYPE_UINT32 0x00000004
56 #define FPTYPE_INT64 0x00000008
57 #define FPTYPE_UINT64 0x00000010
58 #define FPTYPE_FLOAT32 0x00000020
59 #define FPTYPE_FLOAT64 0x00000040
60 
61 #define FPTYPE_PID 0x00000080
62 #define FPTYPE_TIMESPEC 0x00000100
63 
64 #define FPTYPE_FILENAME 0x00000200 // generic filename
65 #define FPTYPE_FITSFILENAME 0x00000400 // FITS file
66 #define FPTYPE_EXECFILENAME 0x00000800 // executable file
67 
68 #define FPTYPE_DIRNAME 0x00001000 // directory name
69 #define FPTYPE_STREAMNAME 0x00002000 // stream name -> process may load from shm if required. See loading stream section below and associated flags
70 #define FPTYPE_STRING 0x00004000 // generic string
71 #define FPTYPE_ONOFF 0x00008000 // uses ONOFF bit flag, string[0] and string[1] for OFF and ON descriptions respectively. setval saves ONOFF as integer
72 #define FPTYPE_PROCESS 0x00010000
73 
74 
75 #define FPTYPE_FPSNAME 0x00020000 // connection to another FPS
76 
77 
78 
79 #define FUNCTION_PARAMETER_DESCR_STRMAXLEN 64
80 #define FUNCTION_PARAMETER_STRMAXLEN 64
81 
82 
83 
84 // STATUS FLAGS
85 
86 // parameter use and visibility
87 #define FPFLAG_ACTIVE 0x0000000000000001 // is this entry registered ?
88 #define FPFLAG_USED 0x0000000000000002 // is this entry used ? if not, skip all checks
89 #define FPFLAG_VISIBLE 0x0000000000000004 // is this entry visible (=displayed) ?
90 
91 // write permission
92 #define FPFLAG_WRITE 0x0000000000000010 // is value writable when neither CONF and RUN are active
93 #define FPFLAG_WRITECONF 0x0000000000000020 // can user change value at configuration time ?
94 #define FPFLAG_WRITERUN 0x0000000000000040 // can user change value at run time ?
95 #define FPFLAG_WRITESTATUS 0x0000000000000080 // current write status (computed from above flags)
96 
97 // logging and saving
98 #define FPFLAG_LOG 0x0000000000000100 // log on change
99 #define FPFLAG_SAVEONCHANGE 0x0000000000000200 // save to disk on change
100 #define FPFLAG_SAVEONCLOSE 0x0000000000000400 // save to disk on close
101 
102 // special types
103 #define FPFLAG_IMPORTED 0x0000000000001000 // is this entry imported from another parameter ?
104 #define FPFLAG_FEEDBACK 0x0000000000002000 // is there a separate current value feedback ?
105 #define FPFLAG_ONOFF 0x0000000000004000 // bit controlled under TYPE_ONOFF
106 
107 // parameter testing
108 #define FPFLAG_CHECKINIT 0x0000000000010000 // should parameter be initialized prior to function start ?
109 #define FPFLAG_MINLIMIT 0x0000000000020000 // enforce min limit
110 #define FPFLAG_MAXLIMIT 0x0000000000040000 // enforce max limit
111 #define FPFLAG_ERROR 0x0000000000080000 // is current parameter value OK ?
112 
113 
114 
115 // if FPTYPE_STREAMNAME
116 // STREAM FLAGS: actions and tests related to streams
117 
118 // The stream location may be in :
119 // --- convention : this is downstream ---
120 // [a]-LOCALMEM local process memory
121 // [b]-SHAREMEM system shared memory .. which may itself be a link to another shared memory
122 // [c]-CONFFITS fits file in conf: a file ./conf/shmim.<stream>.fits, which may itself be a link to another FITS file
123 // [d]-CONFNAME name of fits file configuration: a file ./conf/shmim.<stream>.fname.conf contains the name of the disk file to be loaded as the stream, relative to current running directory
124 // --- convention : this is upstream ---
125 
126 
127 // what is the source from which a stream was successfully loaded
128 #define STREAM_LOAD_SOURCE_NOTFOUND 0
129 #define STREAM_LOAD_SOURCE_NOTFOUND_STRING "STREAM_LOAD_SOURCE_NOTFOUND"
130 
131 #define STREAM_LOAD_SOURCE_LOCALMEM 1
132 #define STREAM_LOAD_SOURCE_LOCALMEM_STRING "STREAM_LOAD_SOURCE_LOCALMEM"
133 
134 #define STREAM_LOAD_SOURCE_SHAREMEM 2
135 #define STREAM_LOAD_SOURCE_SHAREMEM_STRING "STREAM_LOAD_SOURCE_SHAREMEM"
136 
137 #define STREAM_LOAD_SOURCE_CONFFITS 3
138 #define STREAM_LOAD_SOURCE_CONFFITS_STRING "STREAM_LOAD_SOURCE_CONFFITS"
139 
140 #define STREAM_LOAD_SOURCE_CONFNAME 4
141 #define STREAM_LOAD_SOURCE_CONFNAME_STRING "STREAM_LOAD_SOURCE_CONFNAME"
142 
143 #define STREAM_LOAD_SOURCE_NULL 5
144 #define STREAM_LOAD_SOURCE_NULL_STRING "STREAM_LOAD_SOURCE_NULL"
145 
146 #define STREAM_LOAD_SOURCE_EXITFAILURE -1
147 #define STREAM_LOAD_SOURCE_EXITFAILURE_STRING "STREAM_LOAD_SOURCE_EXITFAILURE"
148 
149 //
150 // The default policy is to look for the source location first in [a], then [b], etc..., until [d]
151 // Once source location is found, the downstream locations are updated. For example: search[a]; search[b], find[c]->update[b]->update[a]
152 //
153 //
154 //
155 // Important scripts (should be in PATH):
156 // - milkstreamlink : build sym link between streams
157 // - milkFits2shm : smart loading/updating of FITS to SHM
158 //
159 // loading CONF to SHM must use script milkFits2shm
160 //
161 //
162 
163 
164 // STREAM LOADING POLICY FLAGS
165 // These flags modify the default stream load policy
166 // Default load policy: FORCE flags = 0, SKIPSEARCH flags = 0, UPDATE flags = 0
167 //
168 // FORCE flags will force a location to be used and all downstream locations to be updated
169 // if the FORCE location does not exist, it will fail
170 // only one such flag should be specified. If several force flags are specified, the first one ((a) over (b)) will be considered
171 #define FPFLAG_STREAM_LOAD_FORCE_LOCALMEM 0x0000000000100000
172 #define FPFLAG_STREAM_LOAD_FORCE_SHAREMEM 0x0000000000200000
173 #define FPFLAG_STREAM_LOAD_FORCE_CONFFITS 0x0000000000400000
174 #define FPFLAG_STREAM_LOAD_FORCE_CONFNAME 0x0000000000800000
175 
176 // SKIPSEARCH flags will skip search location
177 // multiple such flags can be specified
178 //
179 // Note that the FORCE flags have priority over the SKIPSEARCH flags
180 // If a FORCE flag is active, the SKIPSEARCH flags will be ignored
181 //
182 #define FPFLAG_STREAM_LOAD_SKIPSEARCH_LOCALMEM 0x0000000001000000
183 #define FPFLAG_STREAM_LOAD_SKIPSEARCH_SHAREMEM 0x0000000002000000
184 #define FPFLAG_STREAM_LOAD_SKIPSEARCH_CONFFITS 0x0000000004000000
185 #define FPFLAG_STREAM_LOAD_SKIPSEARCH_CONFNAME 0x0000000008000000
186 
187 // UPDATE flags will update upstream locations
188 #define FPFLAG_STREAM_LOAD_UPDATE_SHAREMEM 0x0000000010000000
189 #define FPFLAG_STREAM_LOAD_UPDATE_CONFFITS 0x0000000020000000
190 
191 
192 
193 
194 // Additionally, the following flags specify what to do if stream properties do not match the required properties
195 //
196 
197 
198 #define FPFLAG_FILE_CONF_REQUIRED 0x0000000040000000 // file must exist for CONF process to proceed
199 #define FPFLAG_FILE_RUN_REQUIRED 0x0000000080000000 // file must exist for RUN process to proceed
200 // note: we can reuse same codes
201 
202 #define FPFLAG_FPS_CONF_REQUIRED 0x0000000040000000 // file must exist for CONF process to proceed
203 #define FPFLAG_FPS_RUN_REQUIRED 0x0000000080000000 // file must exist for RUN process to proceed
204 
205 #define FPFLAG_STREAM_CONF_REQUIRED 0x0000000040000000 // stream has to be in MEM for CONF process to proceed
206 #define FPFLAG_STREAM_RUN_REQUIRED 0x0000000080000000 // stream has to be in MEM for RUN process to proceed
207 
208 
209 
210 
211 // Additional notes on load functions in AOloopControl_IOtools
212 //
213 /* AOloopControl_IOtools_2Dloadcreate_shmim( const char *name,
214  const char *fname,
215  long xsize,
216  long ysize,
217  float DefaultValue)
218 */
219 //
220 
221 
222 
223 
224 #define FPFLAG_STREAM_ENFORCE_DATATYPE 0x0000000100000000 // enforce stream datatype
225 // stream type requirement: one of the following tests must succeed (OR) if FPFLAG_STREAM_ENFORCE_DATATYPE
226 // If creating image, the first active entry is used
227 #define FPFLAG_STREAM_TEST_DATATYPE_UINT8 0x0000000200000000 // test if stream of type UINT8 (OR test)
228 #define FPFLAG_STREAM_TEST_DATATYPE_INT8 0x0000000400000000 // test if stream of type INT8 (OR test)
229 #define FPFLAG_STREAM_TEST_DATATYPE_UINT16 0x0000000800000000 // test if stream of type UINT16 (OR test)
230 #define FPFLAG_STREAM_TEST_DATATYPE_INT16 0x0000001000000000 // test if stream of type INT16 (OR test)
231 #define FPFLAG_STREAM_TEST_DATATYPE_UINT32 0x0000002000000000 // test if stream of type UINT32 (OR test)
232 #define FPFLAG_STREAM_TEST_DATATYPE_INT32 0x0000004000000000 // test if stream of type INT32 (OR test)
233 #define FPFLAG_STREAM_TEST_DATATYPE_UINT64 0x0000008000000000 // test if stream of type UINT64 (OR test)
234 #define FPFLAG_STREAM_TEST_DATATYPE_INT64 0x0000010000000000 // test if stream of type INT64 (OR test)
235 #define FPFLAG_STREAM_TEST_DATATYPE_HALF 0x0000020000000000 // test if stream of type HALF (OR test)
236 #define FPFLAG_STREAM_TEST_DATATYPE_FLOAT 0x0000040000000000 // test if stream of type FLOAT (OR test)
237 #define FPFLAG_STREAM_TEST_DATATYPE_DOUBLE 0x0000080000000000 // test if stream of type DOUBLE (OR test)
238 
239 #define FPFLAG_STREAM_ENFORCE_1D 0x0000100000000000 // enforce 1D image
240 #define FPFLAG_STREAM_ENFORCE_2D 0x0000200000000000 // enforce 2D image
241 #define FPFLAG_STREAM_ENFORCE_3D 0x0000400000000000 // enforce 3D image
242 #define FPFLAG_STREAM_ENFORCE_XSIZE 0x0008000000000000 // enforce X size
243 #define FPFLAG_STREAM_ENFORCE_YSIZE 0x0010000000000000 // enforce Y size
244 #define FPFLAG_STREAM_ENFORCE_ZSIZE 0x0020000000000000 // enforce Z size
245 
246 #define FPFLAG_CHECKSTREAM 0x0040000000000000 // check and display stream status in GUI
247 #define FPFLAG_STREAM_MEMLOADREPORT 0x0080000000000000 // Write stream load report (for debugging)
248 
249 
250 
251 
252 
253 
254 
255 
256 // PRE-ASSEMBLED DEFAULT FLAGS
257 
258 // input parameter (used as default when adding entry)
259 #define FPFLAG_DEFAULT_INPUT FPFLAG_ACTIVE|FPFLAG_USED|FPFLAG_VISIBLE|FPFLAG_WRITE|FPFLAG_WRITECONF|FPFLAG_SAVEONCHANGE|FPFLAG_FEEDBACK
260 #define FPFLAG_DEFAULT_OUTPUT FPFLAG_ACTIVE|FPFLAG_USED|FPFLAG_VISIBLE
261 #define FPFLAG_DEFAULT_INPUT_STREAM FPFLAG_DEFAULT_INPUT|FPFLAG_STREAM_RUN_REQUIRED|FPFLAG_CHECKSTREAM
262 #define FPFLAG_DEFAULT_OUTPUT_STREAM FPFLAG_DEFAULT_INPUT|FPFLAG_CHECKSTREAM
263 
264 
265 // status parameters, no logging, read only
266 #define FPFLAG_DEFAULT_STATUS FPFLAG_ACTIVE|FPFLAG_USED|FPFLAG_VISIBLE
267 
268 
269 
270 
271 
272 #define FUNCTION_PARAMETER_NBPARAM_DEFAULT 100 // size of dynamically allocated array of parameters
273 
274 
275 
276 typedef struct
277 {
278  long streamID; // if type is stream and MASK_CHECKSTREAM. For CONF only
279  uint8_t stream_atype;
280 
281  // these have two entries. First is actual/measured, second is required (0 if dimension not active)
282  // tests are specified by flags FPFLAG_STREAM_ENFORCE_1D/2D/3D/XSIZE/YSIZE/ZSIZE
283  uint32_t stream_naxis[2];
284  uint32_t stream_xsize[2]; // xsize
285  uint32_t stream_ysize[2]; // ysize
286  uint32_t stream_zsize[2]; // zsize
287  uint8_t stream_sourceLocation; // where has the stream been loaded from ?
289 
290 
291 
292 typedef struct
293 {
294  long FPSNBparamMAX; // to be written by connect function
295  long FPSNBparamActive;
296  long FPSNBparamUsed;
298 
299 
300 
301 typedef struct
302 {
303  uint64_t fpflag;// 64 binary flags, see FUNCTION_PARAMETER_MASK_XXXX
304 
305  // Parameter name
306  char keywordfull[FUNCTION_PARAMETER_KEYWORD_STRMAXLEN*FUNCTION_PARAMETER_KEYWORD_MAXLEVEL];
307  char keyword[FUNCTION_PARAMETER_KEYWORD_MAXLEVEL][FUNCTION_PARAMETER_KEYWORD_STRMAXLEN];
308  int keywordlevel; // number of levels in keyword
309 
310  // if this parameter value imported from another parameter, source is:
311  char keywordfrom[FUNCTION_PARAMETER_KEYWORD_STRMAXLEN*FUNCTION_PARAMETER_KEYWORD_MAXLEVEL];
312 
313  char description[FUNCTION_PARAMETER_DESCR_STRMAXLEN];
314 
315  // one of FUNCTION_PARAMETER_TYPE_XXXX
316  uint32_t type;
317 
318  union
319  {
320  // value, min (inclusive), max (inclusive), current state (if different from request)
321  int64_t l[4];
322 
323  // value, min, max, current state (if different from request)
324  double f[4];
325  float s[4];
326 
327  // first value is set point, second is current state
328  pid_t pid[2];
329 
330  // first value is set point, second is current state
331  struct timespec ts[2];
332 
333  // first value is set point, second is current state
334  char string[2][FUNCTION_PARAMETER_STRMAXLEN];
335 
336  // if TYPE = PROCESS, string[0] is tmux session, string[1] is launch command
337  } val;
338 
339 
340  union
341  {
342  FUNCTION_PARAMETER_SUBINFO_STREAM stream; // if type stream
343  FUNCTION_PARAMETER_SUBINFO_FPS fps; // if FPTYPE_FPSNAME
344  } info;
345 
346 
347  long cnt0; // increments when changed
348 
350 
351 
352 
353 
354 #define STRINGMAXLEN_FPS_NAME 100
355 
356 #define FUNCTION_PARAMETER_STRUCT_MSG_SIZE 500
357 
358 
359 
360 #define FUNCTION_PARAMETER_STRUCT_STATUS_CONF 0x0001 // is configuration running ?
361 #define FUNCTION_PARAMETER_STRUCT_STATUS_RUN 0x0002 // is process running ?
362 
363 #define FUNCTION_PARAMETER_STRUCT_STATUS_CMDCONF 0x0010 // should configuration be running ?
364 #define FUNCTION_PARAMETER_STRUCT_STATUS_CMDRUN 0x0020 // should process be running ?
365 
366 #define FUNCTION_PARAMETER_STRUCT_STATUS_RUNLOOP 0x0100 // is process loop running ?
367 #define FUNCTION_PARAMETER_STRUCT_STATUS_CHECKOK 0x0200 // Are parameter values OK to run loop process ? (1=OK, 0=not OK)
368 
369 // are tmux sessions online ?
370 #define FUNCTION_PARAMETER_STRUCT_STATUS_TMUXCONF 0x1000
371 #define FUNCTION_PARAMETER_STRUCT_STATUS_TMUXRUN 0x2000
372 #define FUNCTION_PARAMETER_STRUCT_STATUS_TMUXCTRL 0x4000
373 
374 
375 
376 
377 
378 #define FUNCTION_PARAMETER_STRUCT_SIGNAL_CONFRUN 0x0001 // configuration process
379 //#define FUNCTION_PARAMETER_STRUCT_SIGNAL_CONFSTOP 0x0002 // stop configuration process
380 #define FUNCTION_PARAMETER_STRUCT_SIGNAL_UPDATE 0x0004 // re-run check of parameter
381 
382 #define FUNCTION_PARAMETER_STRUCT_SIGNAL_CHECKED 0x0008 // CheckParametersAll been completed.
383 // Toggles to 1 upon update request
384 // Toggles to 0 when update completed (in function CheckParametersAll)
385 
386 
387 
388 
389 
390 // ERROR AND WARNING MESSAGES
391 
392 #define FPS_NB_MSG 100 // max number of messages
393 #define FUNCTION_PARAMETER_STRUCT_MSG_LEN 500
394 
395 
396 #define FPS_MSG_FLAG_NOTINITIALIZED 0x0001
397 #define FPS_MSG_FLAG_BELOWMIN 0x0002
398 #define FPS_MSG_FLAG_ABOVEMAX 0x0004
399 
400 // by default, a message is a warning
401 #define FPS_MSG_FLAG_ERROR 0x0008 // if ERROR, then cannot start function
402 #define FPS_MSG_FLAG_INFO 0x0010
403 
404 
405 
406 #define FPS_CWD_STRLENMAX 200
407 #define FPS_DIR_STRLENMAX 200
408 #define FPS_SRCDIR_STRLENMAX 200
409 #define FPS_PNAME_STRMAXLEN 100
410 #define FPS_CALLPROGNAME_STRMAXLEN 80
411 #define FPS_CALLFUNCNAME_STRMAXLEN 100
412 #define FPS_DESCR_STRMAXLEN 200
413 #define STRINGMAXLEN_FPS_DIRNAME 200
414 
415 // metadata
416 typedef struct
417 {
418  // process name
419  // Name can include numbers in the format -XX-YY to allow for multiple structures be created by the same process function and to pass arguments (XX, YY) to process function
420  char name[STRINGMAXLEN_FPS_NAME]; // example: pname-01-32
421 
422  char description[FPS_DESCR_STRMAXLEN];
423 
424 
425  // where should processes run from ?
426  char workdir[FPS_CWD_STRLENMAX];
427 
428  // [output] where should configurations and results be written to ?
429  char datadir[FPS_DIR_STRLENMAX];
430  // [input] directory for configuration
431  char confdir[FPS_DIR_STRLENMAX];
432 
433  // source code file name
434  char sourcefname[FPS_SRCDIR_STRLENMAX];
435  // souce code line
436  int sourceline;
437 
438 
439 
440  // the name and indices are automatically parsed in the following format
441  char pname[FPS_PNAME_STRMAXLEN]; // example: pname
442  char callprogname[FPS_CALLPROGNAME_STRMAXLEN];
443  char callfuncname[FPS_CALLFUNCNAME_STRMAXLEN];
444  char nameindexW[16][10]; // subnames
445  int NBnameindex; // example: 2
446 
447  // configuration will run in tmux session pname-XX:conf
448  // process will run in tmux session pname-XX:run
449 
450  // PID of process owning parameter structure configuration
451  pid_t confpid;
452  struct timespec confpidstarttime;
453 
454  // PID of process running on this fps
455  pid_t runpid;
456  struct timespec runpidstarttime;
457 
458 
459 
460 
461 
462 
463  // Used to send signals to configuration process
464  uint64_t signal;
465 
466  // configuration wait timer value [us]
467  uint64_t confwaitus;
468 
469  uint32_t status; // conf and process status
470 
471 
472 
473  // size of parameter array (= max number of parameter supported)
474  long NBparamMAX;
475 
476 
477  char
478  message[FPS_NB_MSG][FUNCTION_PARAMETER_STRUCT_MSG_LEN];
479 
480  // to which entry does the message refer to ?
481  int msgpindex[FPS_NB_MSG];
482 
483  // What is the nature of the message/error ?
484  uint32_t msgcode[FPS_NB_MSG];
485 
486  long msgcnt;
487 
488  uint32_t conferrcnt;
489 
491 
492 
493 
494 
495 // localstatus flags
496 //
497 // run configuration loop
498 #define FPS_LOCALSTATUS_CONFLOOP 0x0001
499 
500 
501 
502 typedef struct
503 {
504  // these two structures are shared
506  FUNCTION_PARAMETER *parray; // array of function parameters
507 
508  // these variables are local to each process
509  uint16_t localstatus; // 1 if conf loop should be active
510  int SMfd;
511  uint32_t CMDmode;
512 
513  long NBparam; // number of parameters in array
514  long NBparamActive; // number of active parameters
515 
517 
518 
519 
520 
521 
522 
523 
524 //
525 // Tasks can be sequenced
526 // Typically these are read from command fifo
527 // The structure is meant to provide basic scheduling functionality
528 //
529 
530 // max number of entries in queues (total among all queues)
531 #define NB_FPSCTRL_TASK_MAX 500
532 #define NB_FPSCTRL_TASK_PURGESIZE 50
533 
534 // flags
535 #define FPSTASK_STATUS_ACTIVE 0x0000000000000001 // is the task entry in the array used ?
536 #define FPSTASK_STATUS_SHOW 0x0000000000000002
537 #define FPSTASK_STATUS_RUNNING 0x0000000000000004
538 #define FPSTASK_STATUS_COMPLETED 0x0000000000000008
539 
540 // status (cumulative)
541 #define FPSTASK_STATUS_WAITING 0x0000000000000010
542 #define FPSTASK_STATUS_RECEIVED 0x0000000000000020
543 #define FPSTASK_STATUS_CMDNOTFOUND 0x0000000000000040
544 #define FPSTASK_STATUS_CMDFAIL 0x0000000000000080
545 #define FPSTASK_STATUS_CMDOK 0x0000000000000100
546 
547 // use WAITONRUN to ensure the queue is blocked until the current run process is done
548 #define FPSTASK_FLAG_WAITONRUN 0x0000000000000001
549 #define FPSTASK_FLAG_WAITONCONF 0x0000000000000002
550 
551 // If ON, the task is a wait point, and will only proceed if the FPS pointed to by fpsindex is NOT running
552 #define FPSTASK_FLAG_WAIT_FOR_FPS_NORUN 0x0000000000000004
553 
554 #define NB_FPSCTRL_TASKQUEUE_MAX 100 // max number of queues
555 
556 typedef struct
557 {
558  int priority;
559  // high number = high priority
560  // 0 = queue not active
561 
563 
564 
565 
566 typedef struct
567 {
568 
569  char cmdstring[STRINGMAXLEN_FPS_CMDLINE];
570 
571 
572  uint64_t inputindex; // order in which tasks are submitted
573 
574  // Tasks in separate queues can run in parallel (not waiting for last task to run new one)
575  // Tasks within a queue run sequentially
576  uint32_t queue;
577  // Default queue is 0
578 
579  uint64_t status;
580  uint64_t flag;
581 
582  int fpsindex; // used to track status
583 
584  struct timespec creationtime;
585  struct timespec activationtime;
586  struct timespec completiontime;
587 
589 
590 
591 
592 
593 
594 
595 // status of control / monitoring process
596 //
597 typedef struct
598 {
599  int exitloop; // exit control loop if 1
600  int fpsCTRL_DisplayMode; // Display mode
601  uint32_t mode; // GUI mode
602  int NBfps; // Number of FPS entries
603  int NBkwn; // Number of keyword nodes
604  long NBindex;
605  char fpsnamemask[100];
606  int nodeSelected;
607  int run_display;
608  int fpsindexSelected;
609  int GUIlineSelected[100];
610  int currentlevel;
611  int directorynodeSelected;
612  int pindexSelected;
613  char fpsCTRLfifoname[200];
614  int fpsCTRLfifofd;
615  int direction;
617 
618 
619 
620 
621 
622 
623 
624 
625 
626 
627 
628 
629 
630 #define NB_KEYWNODE_MAX 10000
631 #define MAX_NB_CHILD 500
632 
633 typedef struct
634 {
635  char keywordfull[FUNCTION_PARAMETER_KEYWORD_STRMAXLEN *
636  FUNCTION_PARAMETER_KEYWORD_MAXLEVEL];
637  char keyword[FUNCTION_PARAMETER_KEYWORD_MAXLEVEL][FUNCTION_PARAMETER_KEYWORD_STRMAXLEN];
638  int keywordlevel;
639 
640  int parent_index;
641 
642  int NBchild;
643  int child[MAX_NB_CHILD];
644 
645  int leaf; // 1 if this is a leaf (no child)
646  int fpsindex;
647  int pindex;
648 
649 
651 
652 
653 
654 
655 
656 
657 
658 #include "fps_add_entry.h"
659 #include "fps_checkparameter.h"
660 #include "fps_connect.h"
661 #include "fps_connectExternalFPS.h"
662 #include "fps_CTRLscreen.h"
663 #include "fps_disconnect.h"
664 #include "fps_execFPScmd.h"
665 #include "fps_FPCONFexit.h"
666 #include "fps_FPCONFloopstep.h"
667 #include "fps_FPCONFsetup.h"
668 #include "fps_getFPSargs.h"
669 #include "fps_load.h"
670 #include "fps_outlog.h"
671 #include "fps_paramvalue.h"
672 #include "fps_processinfo_entries.h"
673 #include "fps_RUNexit.h"
674 #include "fps_save2disk.h"
675 #include "fps_shmdirname.h"
676 
677 
678 
679 
680 
681 
682 // ===========================
683 // CONVENIENT MACROS FOR FPS
684 // ===========================
685 
686 
703 #define FPS_SETUP_INIT(VARfpsname,VARCMDmode) FUNCTION_PARAMETER_STRUCT fps; do { \
704  fps.SMfd = -1; \
705  fps = function_parameter_FPCONFsetup((VARfpsname), (VARCMDmode)); \
706  strncpy(fps.md->sourcefname, __FILE__, FPS_SRCDIR_STRLENMAX);\
707  fps.md->sourceline = __LINE__; \
708  { \
709  char msgstring[STRINGMAXLEN_FPS_LOGMSG]; \
710  SNPRINTF_CHECK(msgstring, STRINGMAXLEN_FPS_LOGMSG, "LOGSTART %s %d %s %d", (VARfpsname), (VARCMDmode), fps.md->sourcefname, fps.md->sourceline); \
711  functionparameter_outlog("FPSINIT", msgstring); \
712  functionparameter_outlog_namelink(); \
713  } \
714 } while(0)
715 
716 
717 
722 #define FPS_CONNECT( VARfpsname, VARCMDmode ) FUNCTION_PARAMETER_STRUCT fps; do { \
723  fps.SMfd = -1; \
724  if(function_parameter_struct_connect( (VARfpsname) , &fps, (VARCMDmode) ) == -1) { \
725  printf("ERROR: fps \"%s\" does not exist -> running without FPS interface\n", VARfpsname); \
726  return RETURN_FAILURE; \
727  }\
728 } while(0)
729 
730 
731 
734 #define FPS_CONFLOOP_START if( ! fps.localstatus & FPS_LOCALSTATUS_CONFLOOP ) { \
735  return RETURN_SUCCESS; \
736 } \
737 while(fps.localstatus & FPS_LOCALSTATUS_CONFLOOP) { \
738 { \
739  struct timespec treq, trem; \
740  treq.tv_sec = 0; \
741  treq.tv_nsec = 50000; \
742  nanosleep(&treq, &trem); \
743  if(data.signal_INT == 1){fps.localstatus &= ~FPS_LOCALSTATUS_CONFLOOP;} \
744 } \
745 if(function_parameter_FPCONFloopstep(&fps) == 1) {
746 
749 #define FPS_CONFLOOP_END functionparameter_CheckParametersAll(&fps);} \
750 } \
751 function_parameter_FPCONFexit(&fps);
752 
753 
754 
755 
756 
764 #define FPS_ADDPARAM_FLT32_IN(key, pname, pdescr, dflt) \
765 long fp_##key = 0; \
766 do{ \
767  fp_##key = function_parameter_add_entry(&fps, (pname), (pdescr), FPTYPE_FLOAT32, FPFLAG_DEFAULT_INPUT, (dflt));\
768  (void) fp_##key;\
769 } while(0)
770 
771 
774 #define FPS_ADDPARAM_FLT64_IN(key, pname, pdescr, dflt) \
775 long fp_##key = 0; \
776 do{ \
777  fp_##key = function_parameter_add_entry(&fps, (pname), (pdescr), FPTYPE_FLOAT64, FPFLAG_DEFAULT_INPUT, (dflt));\
778  (void) fp_##key;\
779 } while(0)
780 
781 
782 
785 #define FPS_ADDPARAM_INT64_IN(key, pname, pdescr, dflt) \
786 long fp_##key = 0; \
787 do{ \
788  fp_##key = function_parameter_add_entry(&fps, (pname), (pdescr), FPTYPE_INT64, FPFLAG_DEFAULT_INPUT, (dflt));\
789  (void) fp_##key;\
790 } while(0)
791 
792 
795 #define FPS_ADDPARAM_FILENAME_IN(key, pname, pdescr, dflt) \
796 long fp_##key = 0; \
797 do{ \
798  fp_##key = function_parameter_add_entry(&fps, (pname), (pdescr), FPTYPE_FILENAME, FPFLAG_DEFAULT_INPUT_STREAM, (dflt));\
799  (void) fp_##key;\
800 } while(0)
801 
802 
805 #define FPS_ADDPARAM_STREAM_IN(key, pname, pdescr, dflt) \
806 long fp_##key = 0; \
807 do{ \
808  fp_##key = function_parameter_add_entry(&fps, (pname), (pdescr), FPTYPE_STREAMNAME, FPFLAG_DEFAULT_INPUT_STREAM, (dflt));\
809  (void) fp_##key;\
810 } while(0)
811 
812 
815 #define FPS_ADDPARAM_ONOFF(key, pname, pdescr, dflt) \
816 long fp_##key = 0; \
817 do{ \
818  fp_##key = function_parameter_add_entry(&fps, (pname), (pdescr), FPTYPE_ONOFF, FPFLAG_DEFAULT_INPUT, (dflt));\
819  (void) fp_##key;\
820 } while(0)
821 
822 
823 
824 
827 #define FPS_ADDPARAM_FLT32_OUT(key, pname, pdescr) \
828 long fp_##key = 0; \
829 do{ \
830  fp_##key = function_parameter_add_entry(&fps, (pname), (pdescr), FPTYPE_FLOAT32, FPFLAG_DEFAULT_OUTPUT, NULL);\
831  (void) fp_##key;\
832 } while(0)
833 
834 
837 #define FPS_ADDPARAM_FLT64_OUT(key, pname, pdescr) \
838 long fp_##key = 0; \
839 do{ \
840  fp_##key = function_parameter_add_entry(&fps, (pname), (pdescr), FPTYPE_FLOAT64, FPFLAG_DEFAULT_OUTPUT, NULL);\
841  (void) fp_##key;\
842 } while(0)
843 
844 
847 #define FPS_ADDPARAM_INT64_OUT(key, pname, pdescr) \
848 long fp_##key = 0; \
849 do{ \
850  fp_##key = function_parameter_add_entry(&fps, (pname), (pdescr), FPTYPE_INT64, FPFLAG_DEFAULT_OUTPUT, NULL);\
851  (void) fp_##key;\
852 } while(0)
853 
854 
857 #define FPS_ADDPARAM_STREAM_OUT(key, pname, pdescr) \
858 long fp_##key = 0; \
859 do{ \
860  fp_##key = function_parameter_add_entry(&fps, (pname), (pdescr), FPTYPE_STREAMNAME, FPFLAG_DEFAULT_OUTPUT_STREAM, NULL);\
861  (void) fp_##key;\
862 } while(0)
863 
864 
865 
866 
867 
868 
869  // end group fpsmacro
871 
872 
873 
874 
875 
876 
877 
878 #endif // FUNCTION_PARAMETERS_H
FPSCTRL_TASK_QUEUE
Definition: function_parameters.h:556
FUNCTION_PARAMETER_STRUCT
Definition: function_parameters.h:502
fps_shmdirname.h
create FPS shared memory directory name
fps_getFPSargs.h
read FPS args from CLI
fps_connect.h
connect to FPS
fps_save2disk.h
Save FPS content to disk.
fps_paramvalue.h
set and get parameter values
FUNCTION_PARAMETER_SUBINFO_STREAM
Definition: function_parameters.h:276
KEYWORD_TREE_NODE
Definition: function_parameters.h:633
FUNCTION_PARAMETER_STRUCT_MD
Definition: function_parameters.h:416
fps_RUNexit.h
Exit FPS run process.
fps_load.h
Load FPS.
FPSCTRL_PROCESS_VARS
Definition: function_parameters.h:597
FUNCTION_PARAMETER
Definition: function_parameters.h:301
fps_outlog.h
output log functions for FPS
fps_FPCONFloopstep.h
FPS conf process loop step.
FUNCTION_PARAMETER_SUBINFO_FPS
Definition: function_parameters.h:292
fps_execFPScmd.h
Execute FPS command.
FPSCTRL_TASK_ENTRY
Definition: function_parameters.h:566
fps_CTRLscreen.h
FPS control TUI.
fps_disconnect.h
Disconnect from FPS.
fps_add_entry.h
add parameter entry to FPS
fps_FPCONFsetup.h
FPS config setup.
fps_connectExternalFPS.h
connect to external FPS
fps_FPCONFexit.h
Exit FPS conf process.