C++ TargetRTS
Loading...
Searching...
No Matches
endeBoth.h
1/*
2 * Licensed Materials - Property of HCL and/or IBM
3 * Copyright HCL Technologies Ltd. 2016, 2023. All Rights Reserved.
4 * Copyright IBM Corporation 1999, 2016. All Rights Reserved.
5 *
6 * U.S. Government Users Restricted Rights - Use, duplication or
7 * disclosure restricted by GSA ADP Schedule.
8 */
9
10#ifndef __endeBoth_h__
11#define __endeBoth_h__ included
12
13#ifndef __RTConfig_h__
14#include <RTConfig.h>
15#endif
16
17#ifdef __cplusplus
18extern "C"
19{
20#endif
21
22/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
23||
24|| Public:
25||
26+|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
27
28enum encodingResult /* when encoding a message to send */
29{
30 ENC_SUCCESS, /* encoding OK */
31 ENC_BAD_PARM, /* bad parameter was detected */
32 ENC_BAD_FUNC_TYPE, /* func value unknown */
33 ENC_OVERFLOW, /* buf was too small */
34
35 ENC_LAST /* last-in-list flag, no real meaning */
36};
37
38enum decodingResult /* when decoding a received message */
39{
40 DEC_SUCCESS, /* decoding OK */
41 DEC_BAD_PARM, /* bad parameter was detected */
42 DEC_UNDERRUN, /* buf contains incomplete message */
43 DEC_NO_FUNC_ID, /* FUNC_ identifier not found */
44 DEC_NO_FUNC_VAL, /* FUNC_ value could not be found */
45 DEC_BAD_FUNC_TYPE, /* FUNC_ value found but unknown */
46 DEC_NO_METHOD, /* No decoding method for this func found*/
47 DEC_NO_INT_ID, /* INT identifier not found */
48 DEC_NO_INT_VAL, /* INT value could not be read */
49 DEC_NO_STR_ID, /* STR identifier not found */
50 DEC_NO_STR_LEN, /* STR length field not found */
51 DEC_NO_STR_SPC, /* STR no space between length and value */
52
53 DEC_LAST /* last-in-list flag, no real meaning */
54};
55
56enum resultCode /* result of a target operation */
57{
58 RES_OK, /* Alles ist Gut! */
59 RES_BAD_FUNC, /* The func was not recognized */
60 RES_BAD_MESSAGE, /* The message could not be encoded */
61 RES_BAD_DAEMON, /* The daemon given could not be found */
62 RES_BAD_ACTOR, /* The actor given could not be found */
63 RES_BAD_PORT, /* The port given could not be found */
64 RES_BAD_STATE, /* The state given could not be found */
65 RES_BAD_CHAIN, /* The chain given could not be found */
66 RES_BAD_VAR, /* The variable given could not be found */
67
68 RES_OTHER_ERROR, /* An unspecified error occurred */
69
70 RES_LAST /* last-in-list flag, no real meaning */
71};
72
73enum rtsStatusCode
74{
75 RTS_STATUS_INITIAL, /* Initially, before started first time */
76 RTS_STATUS_RUNNING, /* Target started by someone */
77 RTS_STATUS_STOPPED, /* Target stopped manually by an observer*/
78 RTS_STATUS_HALTED, /* Target halted by a daemon with halt */
79
80 RTS_STATUS_LAST /* last-in-list flag, no real meaning */
81};
82
83enum funcType /* Direction: Toolset <-> Application */
84{
85 FUNC_NONE, /* last-in-list flag, no real meaning */
86
87 RES_CODE, /* <-- Result of the target operation */
88
89 EVT_TARGINFO, /* <-- Target Information */
90 EVT_PRESENCE, /* <-- Presence Event or Info */
91 EVT_REFERENCE, /* <-- Reference Event or Info */
92 EVT_CHAIN, /* <-- Chain Event or Info */
93 EVT_STATE, /* <-- State Event or Info */
94 EVT_VARIABLE, /* <-- Variable Event or Info */
95 EVT_MSG_OUT, /* <-- Message Out Event or Info */
96 EVT_MSG_IN, /* <-- Message In Event or Info */
97 EVT_MSG_OUTIN, /* <-- Message Between Event or Info */
98 EVT_RTS_STATUS, /* <-- RTS Status (Reset/Running/Stopped)*/
99 EVT_HISTORY, /* <-- State History Info */
100 EVT_MSG_QUEUE, /* <-- Message from Event Queue */
101 EVT_CHILDREN, /* <-- Actor parts and ports info */
102
103 CMD_REQ_INFO, /* --> Request Target Information */
104 CMD_CLOSE_SESSION, /* --> Close T.O. session */
105 CMD_CREATE_DAEMON, /* --> Create a daemon */
106 CMD_UPDATE_DAEMON, /* --> Send new settings to a daemon */
107 CMD_COMMAND_DAEMON, /* --> Send command to a daemon */
108 CMD_REFRESH_DAEMON, /* --> Ask daemon to refresh */
109 CMD_DESTROY_DAEMON, /* --> Destroy the daemon and all inside */
110
111 CMD_ADD_ACTOR, /* --> Add an actor to a daemon */
112 CMD_DEL_ACTOR, /* --> Del an actor from a daemon */
113 CMD_ADD_PORT, /* --> Add a port to a daemon */
114 CMD_DEL_PORT, /* --> Del a port from a daemon */
115 CMD_ADD_STATE, /* --> Add a state to a daemon */
116 CMD_DEL_STATE, /* --> Del a state from a daemon */
117 CMD_ADD_CHAIN, /* --> Add a chain to a daemon */
118 CMD_DEL_CHAIN, /* --> Del a chain from a daemon */
119 CMD_ADD_VAR, /* --> Add a variable to a daemon */
120 CMD_DEL_VAR, /* --> Del a variable from a daemon */
121 CMD_START_VAR_MON, /* --> Add a variable monitor */
122 CMD_STOP_VAR_MON, /* --> Del a variable monitor */
123 CMD_SET_VAR, /* --> Set a variable to a new value */
124 CMD_GET_VAR, /* --> Get a variable's value */
125
126 CMD_INJECT_MSG, /* --> Inject a message into all ports */
127
128 CMD_GET_MESSAGES, /* --> Get message queue */
129
130 CMD_SEND_TO_APP, /* Handle command send from UI to TargetRTS */
131
132 CMD_GET_CHILDREN, /* Get Children of Capsule */
133
134 FUNC_LAST /* last-in-list flag, no real meaning */
135};
136
137typedef struct
138{
139 long sec; /* seconds */
140 long nsec; /* nano-seconds */
142
143typedef struct
144{
145 int number;
146 char * invokeID;
148
149/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
150||
151|| Daemon Set-up and maintenance ( TOOLSET -> TARGET ):
152||
153+|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
154
155typedef struct
156{
157 const char * signal; /* the signal */
158 int prio; /* the priority */
159 char * data; /* the data */
160} TO_message;
161
162typedef struct
163{
164 char * settings; /* settings, like "type=FSM" or command */
166
167typedef struct
168{
169 char * actor; /* actor "/A1:1/A2:0" or ref "/A1:1/A2" */
170 int allRecurs; /* addActor ref: send presence setting */
171 /* delActor: delete recursive setting */
173
174typedef struct
175{
176 char * actor; /* actor, like "/sender:1/buf:0" */
177 char * port; /* port, like "commandPort:0" */
179
180typedef struct
181{
182 char * actor; /* actor, like "/sender:1/buf:0" */
183 char * state; /* state, like "running/wait4ack" */
185
186typedef struct
187{
188 char * actor; /* actor, like "/sender:1/buf:0" */
189 char * state; /* path to the LEAVING state */
190 char * chain; /* the chain (transition name) */
191 int position; /* pos withing chain: 1, 2, 3, or 0 */
193
194typedef struct
195{
196 char * actor; /* actor, like "/sender:1/buf:0" */
197 char * variable; /* the variable name */
199
200typedef struct
201{
202 char * variable; /* the variable name */
203 char * value; /* the variable data */
205
206typedef struct
207{
208 char * signal; /* the signal */
209 char * data; /* the data to inject */
210 int inwards; /* 1 if inwards, 0 if outwards */
211 int prio; /* the priority */
213
214typedef struct
215{
216 char * path; /* actor path, or null for all actors */
218
219typedef struct
220{
221 char * msgSendToApp; /* e.g. rtLogAll and rtDelAll data */
223
224typedef struct
225{
226 char * actor; /* path to actor */
227 char * actorID; /* actor's unique string */
228 char * classID; /* actor's class name, or "" of nonexist */
230
231/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
232||
233|| Daemon Events ( TOOLSET <- TARGET ):
234||
235+|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
236
237typedef struct
238{
239 int code; /* result code, see resultCode enum */
241
242typedef struct
243{
244 const char * info; /* target info, like "libset=sparc-gnu-2.8.1" */
246
247typedef struct
248{
249 TO_timeStamp time; /* timestamp (0,0) if response */
250 char * actor; /* path to actor */
251 char * actorID; /* actor's unique string */
252 const char * classID; /* actor's class name, or "" of nonexist */
254
255typedef struct
256{
257 TO_timeStamp time; /* timestamp (0,0) if response */
258 char * actorRef; /* path to actor reference */
259 int incarns; /* number of incarnations present */
261
262typedef struct
263{
264 TO_timeStamp time; /* timestamp (0,0) if response */
265 char * actor; /* path to actor */
266 char * state; /* path to the LEAVING state */
267 char * chain; /* the chain (transition name) */
269
270typedef struct
271{
272 TO_timeStamp time; /* timestamp (0,0) if response */
273 char * actor; /* path to actor */
274 char * state; /* path to the CURRENT state */
276
277typedef struct
278{
279 TO_timeStamp time; /* timestamp (0,0) if response */
280 char * actor; /* path to actor */
281 char * variable;
282 char * value;
284
285
286typedef struct
287{
288 TO_timeStamp time; /* timestamp (0,0) if response */
289 char * actor; /* path to actor */
290 char * actorID; /* actor's unique string */
291 const char * classID; /* actor's class name, or "" of nonexist */
292 char * data; /* the actor data in json string */
294
295typedef struct
296{
297 TO_timeStamp sendTime; /* timestamp sent */
298 char * sendActor; /* sending actor path */
299 char * sendPort; /* sending port */
300 int sendMethod; /* 0:send; 1:invoke; 2:reply to invoke */
301
302 TO_message message;
304
305typedef struct
306{
307 TO_timeStamp recTime; /* timestamp received */
308 char * recActor; /* receiving actor path */
309 char * recPort; /* receiving port */
310
311 TO_message message;
313
314typedef struct
315{
316 TO_timeStamp sendTime; /* timestamp sent */
317 char * sendActor; /* sending actor path */
318 char * sendPort; /* sending port */
319 int sendMethod; /* 0:send; 1:invoke; 2:reply to invoke */
320
321 TO_timeStamp recTime; /* timestamp received */
322 char * recActor; /* receiving actor path */
323 char * recPort; /* receiving port */
324
325 TO_message message;
327
328typedef struct
329{
330 TO_timeStamp time; /* timestamp (0,0) if response */
331 int status; /* status code, see rtsStatusCode enum */
332 int byYou; /* 1 if event was caused by this observer */
334
335typedef struct
336{
337 char * actor; /* path to actor */
338 char * state; /* the requested state */
339 char * history; /* history of the requested state */
340 char * current; /* the current state */
342
343typedef struct
344{
345 char * actor;
346 char * port;
347 TO_message message;
349
350typedef struct
351{
352 int size; /* size of data[] in bytes */
353 int used; /* encoded: how much used, decoded: where error */
354 int status; /* the encoding/decoding status code */
355 char * start; /* beginning of the buffer; length is stored here */
356 char * data; /* the data buffer */
358
359typedef struct
360{
361 int func; /* enum describing what struct */
362 void * ptr; /* pointer to the structure */
363 TO_daemonInfo daemon; /* daemon information */
365
366/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
367||
368|| Shared functions:
369||
370+|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
371
372/*----------------------------------------------------------------------------
373| Decode the buffer back to a decent structure.
374+-----------------------------------------------------------------------------
375| If decoding was successful:
376| returns DEC_SUCCESS and sets buf->status to same as return value
377| sets buf->used to number of bytes decoded
378| sets info->func to the enum code describing *ptr
379| sets info->ptr to point to a suitable struct. This struct is malloc'ed
380| by TO_decodeBuffer. YOU are responsible for freeing it, and a good
381| help is to use TO_freeStructInfo().
382|
383| If decoding was unsuccessful:
384| returns != DEC_SUCCESS (see enum decodingResult above for details),
385| and sets buf->status to same as return value
386| sets buf->used to _roughly_ where in buf->data something went wrong
387| sets info->func to FUNC_NONE
388| sets info->ptr to nullptr
389| No dynamic structures are allocated in this case.
390+-----------------------------------------------------------------------------
391| Example:
392|
393| TO_bufferInfo buf;
394| TO_structInfo info;
395|
396| TO_evtPresence myPresence;
397|
398| // YOU put decodeable data into buf.data and buf.size
399| // You don't need to set buf.used, buf.status or any info.* fields
400|
401| TO_decodeBuffer( &buf, &info );
402| switch( buf.status )
403| {
404| case DEC_SUCCESS:
405| switch( info.func )
406| {
407| case EVT_PRESENCE: myPresence = *(TO_evtPresence *)info.ptr;
408| // Use the presence information in some way...
409| break;
410| case ...
411| default: // I can't handle this kind of function.
412| }
413| TO_freeStructInfo( &info );
414| break;
415| case DEC_BAD_PARM:
416| // One or both parameters to TO_decodeBuffer were null pointers.
417| break;
418| case DEC_NO_STR_LEN:
419| // No string length field at or around buf.data[ buf.used ].
420| break;
421| case ... // Other error codes here.
422| }
423+---------------------------------------------------------------------------*/
424int TO_decodeBuffer( TO_bufferInfo * buf, TO_structInfo * info );
425
426/*----------------------------------------------------------------------------
427| Free whatever is in the info structure.
428+-----------------------------------------------------------------------------
429| This routine assumes that the field info->func actually matches the
430| data type info->ptr points to. Manual fiddling here can be disastrous.
431+---------------------------------------------------------------------------*/
432void TO_freeStructInfo( TO_structInfo * info );
433
434#ifdef __cplusplus
435}
436#endif
437
438#endif // __endeBoth_h__
Definition: endeBoth.h:168
Definition: endeBoth.h:351
Definition: endeBoth.h:187
Definition: endeBoth.h:144
Definition: endeBoth.h:163
Definition: endeBoth.h:263
Definition: endeBoth.h:287
Definition: endeBoth.h:336
Definition: endeBoth.h:306
Definition: endeBoth.h:296
Definition: endeBoth.h:315
Definition: endeBoth.h:344
Definition: endeBoth.h:248
Definition: endeBoth.h:256
Definition: endeBoth.h:329
Definition: endeBoth.h:271
Definition: endeBoth.h:243
Definition: endeBoth.h:278
Definition: endeBoth.h:225
Definition: endeBoth.h:215
Definition: endeBoth.h:207
Definition: endeBoth.h:156
Definition: endeBoth.h:175
Definition: endeBoth.h:238
Definition: endeBoth.h:220
Definition: endeBoth.h:181
Definition: endeBoth.h:360
Definition: endeBoth.h:138
Definition: endeBoth.h:201
Definition: endeBoth.h:195