ProviewR Programmer's Reference Manual  V7.0.0
rt_qcom.h
Go to the documentation of this file.
1 /*
2  * ProviewR Open Source Process Control.
3  * Copyright (C) 2005-2026 SSAB EMEA AB.
4  *
5  * This file is part of ProviewR.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation, either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with ProviewR. If not, see <http://www.gnu.org/licenses/>
19  *
20  * Linking ProviewR statically or dynamically with other modules is
21  * making a combined work based on ProviewR. Thus, the terms and
22  * conditions of the GNU General Public License cover the whole
23  * combination.
24  *
25  * In addition, as a special exception, the copyright holders of
26  * ProviewR give you permission to, from the build function in the
27  * ProviewR Configurator, combine ProviewR with modules generated by the
28  * ProviewR PLC Editor to a PLC program, regardless of the license
29  * terms of these modules. You may copy and distribute the resulting
30  * combined work under the terms of your choice, provided that every
31  * copy of the combined work is accompanied by a complete copy of
32  * the source code of ProviewR (the version used to produce the
33  * combined work), being distributed under the terms of the GNU
34  * General Public License plus this exception.
35  */
36 
37 #ifndef rt_qcom_h
38 #define rt_qcom_h
39 
40 /* rt_qcom.h -- Queue communication */
41 
49 #include <pthread.h>
50 #include <rpc/rpc.h>
51 
52 #include "pwr_class.h"
53 #include "co_platform.h"
54 
55 #include "rt_gdb_msg.h"
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 #define qcom_cNQix 0
62 #define qcom_cNNid 0
63 #define qcom_cNAix 0
64 #define qcom_cTmoNone 0
65 #define qcom_cTmoEternal -1
66 #define qcom_cIloopBack (1 << 31 | 0)
67 #define qcom_cInetEvent (1 << 31 | 100)
68 #define qcom_cIapplEvent (1 << 31 | 101)
69 #define qcom_cImhAllHandlers (1 << 31 | 102)
70 #define qcom_cImhAllOutunits (1 << 31 | 103)
71 #define qcom_cIhdServer (1 << 31 | 104)
72 #define qcom_cIhdClient (1 << 31 | 105)
73 #define qcom_cInacp (1 << 31 | 106)
74 #define qcom_cIini (1 << 31 | 107)
75 #define qcom_cImonAction (1 << 31 | 108)
76 
81 typedef int qcom_tBus;
82 typedef int qcom_tQix;
83 typedef int qcom_tAix;
84 typedef int qcom_tRid;
85 
86 typedef enum {
87  qcom_eBtype__ = 0,
88  qcom_eBtype_system,
89  qcom_eBtype_qcom,
90  qcom_eBtype_event,
91  qcom_eBtype_ = 200
92 } qcom_eBtype;
93 
94 typedef enum {
95  qcom_eStype__ = 0,
96  qcom_eStype_linkConnect,
97  qcom_eStype_linkDisconnect,
98  qcom_eStype_linkActive,
99  qcom_eStype_linkStalled,
100  qcom_eStype_applConnect,
101  qcom_eStype_applDisconnect,
102  qcom_eStype_ = 32
103 } qcom_eStype;
104 
105 typedef enum {
106  qcom_eQtype__ = 0,
107  qcom_eQtype_private,
108  qcom_eQtype_forward,
109  qcom_eQtype_broadcast,
110  qcom_eQtype_event,
111  qcom_eQtype_
112 } qcom_eQtype;
113 
114 typedef enum {
115  qcom_eNodeConnectionFull = 0,
116  qcom_eNodeConnectionQcom = 1
117 } qcom_eNodeConnection;
118 
125 typedef struct {
126  qcom_tQix qix;
128 } qcom_sQid;
129 
130 static const qcom_sQid qcom_cNQid = { 0, 0 };
131 static const qcom_sQid qcom_cQnetEvent = { qcom_cInetEvent, 0 };
132 static const qcom_sQid qcom_cQapplEvent = { qcom_cIapplEvent, 0 };
133 static const qcom_sQid qcom_cQmhAllHandlers = { qcom_cImhAllHandlers, 0 };
134 static const qcom_sQid qcom_cQmhAllOutunits = { qcom_cImhAllOutunits, 0 };
135 static const qcom_sQid qcom_cQhdServer = { qcom_cIhdServer, 0 };
136 static const qcom_sQid qcom_cQhdClient = { qcom_cIhdClient, 0 };
137 static const qcom_sQid qcom_cQnacp = { qcom_cInacp, 0 };
138 static const qcom_sQid qcom_cQini = { qcom_cIini, 0 };
139 
141 typedef struct {
142  qcom_tAix aix;
144 } qcom_sAid;
145 
146 static const qcom_sAid qcom_cNAid = { 0, 0 };
147 
149 typedef struct {
150  qcom_sAid aid;
151  pid_t pid;
152 } qcom_sAppl;
153 
155 typedef struct {
156  qcom_sAid aid;
157  pid_t pid;
158  int mask;
159 } qcom_sEvent;
160 
162 typedef struct {
163  qcom_eQtype type;
164  unsigned int quota;
165 } qcom_sQattr;
166 
168 typedef struct {
169  qcom_eBtype b;
170  qcom_eStype s;
171 } qcom_sType;
172 
174 typedef struct {
175  qcom_sQid reply;
176  qcom_sType type;
177  unsigned int msg_id;
178  unsigned int prio;
179  unsigned int allocate;
180  unsigned int size;
181  void* data;
182 } qcom_sPut;
183 
185 typedef struct {
186  qcom_sAid sender;
187  pid_t pid;
188  qcom_sQid receiver;
189  qcom_sQid reply;
190  qcom_sType type;
191  qcom_tRid rid;
192  unsigned int maxSize;
193  unsigned int size;
194  void* data;
195 } qcom_sGet;
196 
198 typedef union {
199  pwr_tBitMask m;
201  pwr_32Bits(pwr_Bits(initiated, 1), pwr_Bits(connected, 1),
202  pwr_Bits(active, 1), pwr_Bits(fill_0, 5), , , , ,
203 
204  pwr_Bits(fill_1, 8), , , , , , , , pwr_Bits(fill_2, 8), , , , , , , ,
205  pwr_Bits(fill_3, 8), , , , , , , ) b;
206 
207 #define qcom_mNode__ 0
208 #define qcom_mNode_initiated pwr_Bit(0)
209 #define qcom_mNode_connected pwr_Bit(1)
210 #define qcom_mNode_active pwr_Bit(2)
211 
212 #define qcom_mNode_up (qcom_mNode_connected | qcom_mNode_active)
213 #define qcom_mNode_down (~qcom_mNode_up)
214 #define qcom_mNode_ (~qcom_mNode__)
215 
216 } qcom_mNode;
217 
219 typedef struct {
222  char name[80];
223  co_eOS os;
224  co_eHW hw;
225  co_eBO bo;
226  co_eFT ft;
227  qcom_eNodeConnection connection;
228 } qcom_sNode;
229 
236 /* Function prototypes. */
237 
238 int qcom_AidCompare(const qcom_sAid* a1, const qcom_sAid* a2);
239 
240 pwr_tBoolean qcom_AidIsEqual(const qcom_sAid* a1, const qcom_sAid* a2);
241 
242 pwr_tBoolean qcom_AidIsNotEqual(const qcom_sAid* a1, const qcom_sAid* a2);
243 
245 
247 
248 void* qcom_Alloc(pwr_tStatus* sts, unsigned int size);
249 
251 
252 pwr_tBoolean qcom_StealQ(pwr_tStatus *status, const qcom_sQid *qid);
253 
255  pwr_tStatus* sts, const qcom_sQid* myQ, const qcom_sQid* toQ);
256 
258  pwr_tStatus* sts, qcom_sQid* myQ, qcom_sQattr* attr, const char* qname);
259 
261 
262 pwr_tBoolean qcom_SignalAnd(
263  pwr_tStatus* status, const qcom_sQid* eid, int mask);
264 
265 pwr_tBoolean qcom_SignalOr(pwr_tStatus* status, const qcom_sQid* eid, int mask);
266 
267 pwr_tBoolean qcom_WaitAnd(pwr_tStatus* status, const qcom_sQid* qid,
268  const qcom_sQid* eid, int mask, int tmo);
269 
270 pwr_tBoolean qcom_WaitOr(pwr_tStatus* status, const qcom_sQid* qid,
271  const qcom_sQid* eid, int mask, int tmo, int* event);
272 
273 pwr_tBitMask qcom_EventMask(pwr_tStatus* status, const qcom_sQid* eid);
274 
276 
277 pwr_tBoolean qcom_Free(pwr_tStatus* sts, void* buffer);
278 
279 pwr_tBoolean qcom_Init(pwr_tStatus* sts, qcom_sAid* aid, const char* aname);
280 
281 void* qcom_Get(
282  pwr_tStatus* sts, const qcom_sQid* myQ, qcom_sGet* get, int tmo_ms);
283 
284 qcom_tBus qcom_MyBus(pwr_tStatus* sts);
285 
287 
288 char* qcom_NodeName(pwr_tNodeId nid);
289 
291 
293 
295  pwr_tStatus* sts, const qcom_sQid* receiver, qcom_sPut* put);
296 
297 int qcom_QidCompare(const qcom_sQid* q1, const qcom_sQid* q2);
298 
299 pwr_tBoolean qcom_QidIsEqual(const qcom_sQid* q1, const qcom_sQid* q2);
300 
301 pwr_tBoolean qcom_QidIsNotEqual(const qcom_sQid* q1, const qcom_sQid* q2);
302 
304 
306 
307 char* qcom_QidToString(char* s, qcom_sQid* qid, int prefix);
308 
310 
311 void* qcom_Request(pwr_tStatus* sts, const qcom_sQid* receiver, qcom_sPut* put,
312  const qcom_sQid* myQ, qcom_sGet* get, int tmo_ms, pwr_tBitMask flags);
313 
315  pwr_tStatus* sts, const qcom_sQid* myQ, const qcom_sQid* fromQ);
316 
317 void qcom_SetRedundancyState(pwr_eRedundancyState state);
318 
319 void qcom_LinkConnect(pwr_tNodeId nid);
320 
322 
323 bool_t xdr_qcom_sAid(XDR* xdrs, qcom_sAid* objp);
324 
325 bool_t xdr_qcom_sQid(XDR* xdrs, qcom_sQid* objp);
326 
327 #ifdef __cplusplus
328 }
329 #endif
330 
331 #endif
332 
int qcom_QidCompare(const qcom_sQid *q1, const qcom_sQid *q2)
Compare two queue identities;.
Definition: rt_qcom.c:858
pwr_tBoolean qcom_Reply(pwr_tStatus *sts, qcom_sGet *get, qcom_sPut *put)
Reply to a qcom_Request. The qcom_Reply() call looks almost like a qcom_Put(), but the queue id is re...
Definition: rt_qcom.c:1131
pwr_tBoolean qcom_WaitAnd(pwr_tStatus *status, const qcom_sQid *qid, const qcom_sQid *eid, int mask, int tmo)
Wait for an event or a message.
Definition: rt_qcom.c:1276
pwr_tBoolean qcom_AttachQ(pwr_tStatus *sts, const qcom_sQid *qid)
Attach to an allready created queue.
Definition: rt_qcom.c:111
pwr_tBoolean qcom_AidIsNotEqual(const qcom_sAid *a1, const qcom_sAid *a2)
Test if two application identities are different.
Definition: rt_qcom.c:968
pwr_tBoolean qcom_NextNode(pwr_tStatus *sts, qcom_sNode *node, pwr_tNodeId nid)
Get the next qcom node. If nid is pwr_cNNodeId the first node is returned.
Definition: rt_qcom.c:565
void qcom_LinkConnect(pwr_tNodeId nid)
Definition: rt_qcom.c:1382
pwr_tBoolean qcom_AidIsEqual(const qcom_sAid *a1, const qcom_sAid *a2)
Test if two application identities are equal.
Definition: rt_qcom.c:955
pwr_tBoolean qcom_QidIsEqual(const qcom_sQid *q1, const qcom_sQid *q2)
Test if two queue identities are equal.
Definition: rt_qcom.c:880
pwr_tBoolean qcom_MyNode(pwr_tStatus *sts, qcom_sNode *node)
Get the local qcom node.
Definition: rt_qcom.c:496
qcom_tBus qcom_MyBus(pwr_tStatus *sts)
Get the current qcom bus number.
Definition: rt_qcom.c:478
pwr_tBoolean qcom_Unbind(pwr_tStatus *sts, const qcom_sQid *myQ, const qcom_sQid *fromQ)
Disconnect a target queue from a bound source queue.
Definition: rt_qcom.c:811
pwr_tBoolean qcom_Exit(pwr_tStatus *sts)
Disconnect from QCom. Disconnects an application from the Qcom message bus, all resources such as,...
Definition: rt_qcom.c:331
pwr_tBoolean qcom_QidIsNotNull(const qcom_sQid *q)
Test if queue identity is not null.
Definition: rt_qcom.c:918
pwr_tBoolean qcom_Put(pwr_tStatus *sts, const qcom_sQid *receiver, qcom_sPut *put)
Put a new message.
Definition: rt_qcom.c:747
pwr_tBoolean qcom_Bind(pwr_tStatus *sts, const qcom_sQid *myQ, const qcom_sQid *toQ)
Bind one queue to another.
Definition: rt_qcom.c:171
pwr_tBoolean qcom_CreateQ(pwr_tStatus *sts, qcom_sQid *myQ, qcom_sQattr *attr, const char *qname)
Create a queue and make an implicit connect to it.
Definition: rt_qcom.c:213
pwr_tBoolean qcom_WaitOr(pwr_tStatus *status, const qcom_sQid *qid, const qcom_sQid *eid, int mask, int tmo, int *event)
Wait for an event or a message.
Definition: rt_qcom.c:1228
pwr_tBoolean qcom_Node(pwr_tStatus *sts, qcom_sNode *node, pwr_tNodeId nid)
Get qcom node from node identity.
Definition: rt_qcom.c:533
pwr_tBoolean qcom_QidIsNull(const qcom_sQid *q)
Test if queue identity is null.
Definition: rt_qcom.c:905
pwr_tBoolean qcom_Free(pwr_tStatus *sts, void *buffer)
Free a previously allocated buffer.
Definition: rt_qcom.c:355
void * qcom_Request(pwr_tStatus *sts, const qcom_sQid *receiver, qcom_sPut *put, const qcom_sQid *myQ, qcom_sGet *get, int tmo_ms, pwr_tBitMask flags)
Put a request and return the reply.
Definition: rt_qcom.c:1022
int qcom_AidCompare(const qcom_sAid *a1, const qcom_sAid *a2)
Compare two application identities;.
Definition: rt_qcom.c:932
void * qcom_Get(pwr_tStatus *sts, const qcom_sQid *myQ, qcom_sGet *get, int tmo_ms)
Get a new message.
Definition: rt_qcom.c:398
void qcom_LinkDisconnect(pwr_tNodeId nid)
Definition: rt_qcom.c:1402
pwr_tBoolean qcom_QidIsNotEqual(const qcom_sQid *q1, const qcom_sQid *q2)
Test if two queue identities are different.
Definition: rt_qcom.c:892
pwr_tBoolean qcom_Init(pwr_tStatus *sts, qcom_sAid *aid, const char *aname)
Connect to QCom.
Definition: rt_qcom.c:643
pwr_tBoolean qcom_AidIsNotNull(const qcom_sAid *a)
Test if application identity is not null.
Definition: rt_qcom.c:993
pwr_tBoolean qcom_DeleteQ(pwr_tStatus *sts, const qcom_sQid *myQ)
Delete a queue. Delete a queue and release all resources held by the queue.
Definition: rt_qcom.c:289
void * qcom_Alloc(pwr_tStatus *sts, unsigned int size)
Allocate a buffer in the qcom pool.
Definition: rt_qcom.c:85
char * qcom_QidToString(char *s, qcom_sQid *qid, int prefix)
Converts a queue identifier, 'qid' to a string.
Definition: rt_qcom.c:1199
pwr_tBoolean qcom_AidIsNull(const qcom_sAid *a)
Test if application identity is null.
Definition: rt_qcom.c:981
char * qcom_NodeName(pwr_tNodeId nid)
Get the name of a qcom node.
Definition: rt_qcom.c:515
pwr_tNid pwr_tNodeId
Node identity type.
Definition: pwr.h:298
unsigned int pwr_tBitMask
Bitmask type.
Definition: pwr.h:123
unsigned int pwr_tBoolean
Boolean type.
Definition: pwr.h:127
int pwr_tStatus
Status type.
Definition: pwr.h:284
Application identity.
Definition: rt_qcom.h:141
pwr_tNodeId nid
Definition: rt_qcom.h:143
qcom_tAix aix
Definition: rt_qcom.h:142
Qcom application.
Definition: rt_qcom.h:149
Qcom event.
Definition: rt_qcom.h:155
Get data structure.
Definition: rt_qcom.h:185
Data for a Qcom node.
Definition: rt_qcom.h:219
qcom_eNodeConnection connection
type of connection
Definition: rt_qcom.h:227
qcom_mNode flags
node flags
Definition: rt_qcom.h:221
pwr_tNodeId nid
node index
Definition: rt_qcom.h:220
co_eBO bo
big/little endian
Definition: rt_qcom.h:225
co_eFT ft
float type
Definition: rt_qcom.h:226
co_eHW hw
hardware
Definition: rt_qcom.h:224
co_eOS os
operating system
Definition: rt_qcom.h:223
Put data structure.
Definition: rt_qcom.h:174
Queue attributes.
Definition: rt_qcom.h:162
Queue identity.
Definition: rt_qcom.h:125
qcom_tQix qix
Definition: rt_qcom.h:126
pwr_tNodeId nid
Definition: rt_qcom.h:127
Qcom type.
Definition: rt_qcom.h:168
Node status.
Definition: rt_qcom.h:198