versadac  1
versadac - Scalable Recorder Firmware
arep.h
1 /*---------------------------------------------------------------------------*/
2 /* Copyright (C) 2006 Woodhead Software & Electonics. All rights reserved. */
3 /*---------------------------------------------------------------------------*/
4 /* This program is protected by international copyright. */
5 /* */
6 /* The use of this software including but not limited to its Source Code */
7 /* is subject to restrictions as agreed in the license agreement between */
8 /* you and Woodhead. */
9 /* Copying or distribution is not allowed unless expressly permitted */
10 /* according to your license agreement with Woodhead. */
11 /*---------------------------------------------------------------------------*/
12 /* */
13 /* Project : STACK PROFINET Controller */
14 /* Component : AREP managment */
15 /* $Workfile:: arep.h $*/
16 /* $Revision:: 13 $*/
17 /* $Date:: 28/02/12 15:44 $*/
18 /* */
19 /*---------------------------------------------------------------------------*/
20 /* */
21 /* D e s c r i p t i o n : */
22 /* Access API to AREP array. Internal used */
23 /* */
24 /*---------------------------------------------------------------------------*/
25 
26 #ifndef _AREP_H
27 #define _AREP_H
28 
29 /* Address resolution method*/
30 #define RESOLUTION_NONE 0
31 #define RESOLUTION_DCP 1
32 #define RESOLUTION_DNS 2
33 
34 #include "os_pck.h"
35 
36 /* CMDEV */
37 typedef struct _CMDEV
38 {
39  LPST_CBF lpstCMI_Timeout; /* callback function: use before sending, when waiting a write */
40  APP_WORD wState; /* actual state of this machine (CMDEV) */
41  APP_BOOL bIsFirstForConnect; /* first one ? */
42  APP_BOOL bIsMulticastComm; /* is multicast communication, not supported for now */
43  APP_BOOL bApplRdyDone; /* Did we receive app ready ? */
44 }PACK_ALIGNEMENT(ST_CMDEV), APP_FAR * LPST_CMDEV;
45 
46 #define GET_AREP_CMDEV_STATE(a) (a)->stCmdev.wState
47 #define SET_AREP_CMDEV_STATE(a,b) (a)->stCmdev.wState = b
48 
49 #define SET_AREP_CMDEV_APP_RDY_RCV(a) (a)->stCmdev.bApplRdyDone = APP_TRUE
50 #define SET_AREP_CMDEV_APP_RDY_NOT_RCV(a) (a)->stCmdev.bApplRdyDone = APP_FALSE
51 #define GET_AREP_CMDEV_APP_RDY_RVC(a) (a)->stCmdev.bApplRdyDone
52 
53 #define SET_AREP_CMDEV_FIRST(a) (a)->stCmdev.bIsFirstForConnect = APP_TRUE
54 #define SET_AREP_CMDEV_NOT_FIRST(a) (a)->stCmdev.bIsFirstForConnect = APP_FALSE
55 #define GET_AREP_CMDEV_IS_FIRST(a) (a)->stCmdev.bIsFirstForConnect
56 
57 #define SET_AREP_CMDEV_MULTICAST(a) (a)->stCmdev.bIsMulticastComm = APP_TRUE
58 #define SET_AREP_CMDEV_NOT_MULTICAST(a) (a)->stCmdev.bIsMulticastComm = APP_FALSE
59 #define GET_AREP_CMDEV_IS_MULTICAST(a) (a)->stCmdev.bIsMulticastComm
60 
61 #define SET_AREP_CMDEV_CMI_TIMEOUT_CB(a,b) (a)->stCmdev.lpstCMI_Timeout = b
62 #define GET_AREP_CMDEV_CMI_TIMEOUT_CB(a) (a)->stCmdev.lpstCMI_Timeout
63 
64 /* DIAG */
65 typedef struct _ST_BLOCVERSION{
66  APP_BYTE High;
67  APP_BYTE Low;
68 }PACK_ALIGNEMENT(ST_BLOCVERSION);
69 
70 typedef struct _ST_APPLICATION_RELATION {
71  ST_BLOCVERSION ARBlocVers; /*0 - 2*/
72  ST_BLOCVERSION IOCRBlocVers; /*2 - 2*/
73  ST_BLOCVERSION ALRMBlocVers; /*4 - 2*/
74  ST_BLOCVERSION SUBMODBlocVers;/*6 - 2*/
75  ST_BLOCVERSION PRMSRVBlocVers;/*8 - 2*/
76 }PACK_ALIGNEMENT(ST_APPLICATION_RELATION), APP_FAR * LPST_APPLICATION_RELATION;
77 #define ST_APPLICATION_RELATION_SIZEOF 10
78 
79 /* this is a "unique stack id" given for a device */
80 typedef struct _ST_UNIQUE_SUBMODULE_ID {
81  APP_DWORD dwAPI;
82  APP_WORD wSlot;
83  APP_WORD wSubSlot;
84 }PACK_ALIGNEMENT(ST_UNIQUE_SUBMODULE_ID), APP_FAR * LPST_UNIQUE_SUBMODULE_ID;
85 
86 /*the information use for a communication relation: CREP, IOCR */
88  ST_POOL stPoolOfExpectedConfiguration; /* Pool of USI: store unique stack id of this expect configuration */
89  ST_IOCR_BLOCK_REQ stIOCR;
90  APP_HANDLE lpstCrep; /*use app_handle but this is a lpstCrep */
91 }PACK_ALIGNEMENT(ST_CR), APP_FAR * LPST_CR;
92 
93 /*the expected configuration: the one from this controller */
95 
96  /*
97  02/05/2008, NG:
98  Slot of Input and Output management. In the special case of building EC for Slot I&O
99  stack will put IOCR crep IN into CommunicationRelation and IOCR crep OUT in CommunicationRelationIOCS
100 
101  */
102 
103 
104  LPST_CR CommunicationRelation; /*pointer on the CR using this EC */
105  LPST_CR CommunicationRelationIOCS; /*pointer on the CR using this EC for his IOCS */
106 
107  /*
108  we just care about submodule stat. This is not possible to add a module without submodule.
109  we considere error is always coming from submodule
110  */
111 
112  APP_WORD moduleState; /* MODULE_STATE_NO
113  MODULE_STATE_WRONG
114  MODULE_STATE_PROPER
115  MODULE_STATE_SUSTITUTE
116  */
117  APP_WORD subModuleState; /* SUBMODULE_STATE_FORMAT_IDENTINFO_OK
118  SUBMODULE_STATE_FORMAT_IDENTINFO_SUBSTITUTE
119  SUBMODULE_STATE_FORMAT_IDENTINFO_WRONG
120  SUBMODULE_STATE_FORMAT_IDENTINFO_NOSUBMODULE
121  */
122  APP_DWORD subModuleArInfo; /* SUBMODULE_STATE_FORMAT_ARINFO_OWN
123  SUBMODULE_STATE_FORMAT_ARINFO_ARP
124  SUBMODULE_STATE_FORMAT_ARINFO_SO
125  SUBMODULE_STATE_FORMAT_ARINFO_IOC
126  SUBMODULE_STATE_FORMAT_ARINFO_IOS
127  */
128  /* Ng need to build the connect rsp: the true module/submodule ident number. Only use in case of module diff block*/
129  APP_DWORD ModuleDiffModuleIdentNumber; /* see norme: 5.2.12.42 */
130  APP_DWORD ModuleDiffSubModuleIdentNumber; /* see norme: 5.2.12.43 */
131 
132  APP_DWORD ModuleIdentNumber; /* see norme: 5.2.12.42 */
133  APP_DWORD SubModuleIdentNumber; /* see norme: 5.2.12.43 */
134  APP_WORD ModuleProperties; /* see norme: 5.2.12.80 */
135  APP_WORD SubModuleProperties; /* see norme: 5.2.12.79 */
136 
137  APP_WORD IODataObjectFrameOffsetInput; /* offset of the data (for input ) */
138  APP_WORD IODataObjectFrameOffsetOutput; /* offset of the data (for output) */
139  APP_WORD IOCSObjectFrameOffsetInput; /* offset of the iocs (for input ) */
140  APP_WORD IOCSObjectFrameOffsetOutput; /* offset of the iocs (for output) */
141 
142  /* struct align word, word, byte , byte */
143  ST_DATADESCRIPTION_BLOCK_REQ stDataDesInput; /* data description for an input block */
144  ST_DATADESCRIPTION_BLOCK_REQ stDataDesOutput; /* data description for an output block */
145 
146 
147 }PACK_ALIGNEMENT(ST_EXPECTED_CONFIGURATION), APP_FAR * LPST_EXPECTED_CONFIGURATION;
148 
149 /*the expected configuration: the one from this controller */
150 typedef struct _ST_REAL_CONFIGURATION {
151  APP_DWORD ModuleIdentNumber;
152  APP_DWORD SubModuleIdentNumber;
153  APP_WORD InputLen;
154  APP_WORD OutputLen;
155 }PACK_ALIGNEMENT(ST_REAL_CONFIGURATION), APP_FAR * LPST_REAL_CONFIGURATION;
156 
157 typedef struct _ST_TEMPORARY_EC {
158  LPST_EXPECTED_CONFIGURATION lpstEC;
159  ST_UNIQUE_SUBMODULE_ID stTemporaryUniqueId;
160 }PACK_ALIGNEMENT(ST_TEMPORARY_EC), APP_FAR * LPST_TEMPORARY_EC;
161 
163  ST_UNIQUE_SUBMODULE_ID stUniqueId;
164  LPST_REAL_CONFIGURATION lpstRC;
165  /* LPST_EXPECTED_CONFIGURATION lpstEC; store in the list*/
166  LPST_EXPECTED_CONFIGURATION lpArrayOfstEc[(MAX_INSTANCE_PER_DEVICE * MAX_CONNEXION_PER_INSTANCE)]; /* 27/08/2008 - NG: Remove runtime allocation -- (stListOfExpectedConf) */
167  APP_WORD wStatePull;
168  APP_WORD wStatePlug;
169  APP_WORD wPlugTypeAlr; /* type of the actual alamr manage */
170  APP_BYTE bStatusInHasBeenGood;
171  APP_BYTE bStatusOutHasBeenGood;
172  APP_BYTE byCurrentStatusIn; /* Current IOPS status of this subslot (nb Input is send to controller) */
173  APP_BYTE byCurrentStatusOut; /* Current IOCS status of this subslot (nb Output is send by controller) */
174  APP_BYTE byNbAlmRetry;
175 }PACK_ALIGNEMENT(ST_CONFIGURATION_STORAGE), APP_FAR * LPST_CONFIGURATION_STORAGE;
176 
177 
178 /* for asynchonous request managment */
179 typedef struct _ST_ACYN_READ_WRITE {
180  APP_LPVOID lpstArepTarget;
181  APP_DWORD Api;
182  APP_DWORD Record_Data_Length;
183  APP_LPBYTE lpbyRecordData;
184  APP_WORD SeqNumber;
185  APP_WORD Slot_Number;
186  APP_WORD Subslot_Number;
187  APP_WORD Index;
188  APP_BYTE BlockVersionHigh;
189  APP_BYTE BlockVersionLow;
190 }PACK_ALIGNEMENT(ST_ACYN_READ_WRITE), APP_FAR * LPST_ACYN_READ_WRITE;
191 
192 /* Alm queue */
193 typedef struct sharedMemory
194 {
195  APP_DWORD dwOffsetData;
196  APP_DWORD dwOffsetStatus;
197  APP_DWORD dwOffsetOverRun;
198  APP_DWORD dwOffsetProtect;
199 }PACK_ALIGNEMENT(ST_SHARED_MEMORY), APP_FAR * LPST_SHARED_MEMORY;
200 
201 
202 /* Alm queue */
203 typedef struct queue_alm
204 {
205  APP_BYTE byQueueLow;
206  APP_DWORD dwQueueL[ALARM_MAX_QUEUE_LEVEL];
207  APP_BYTE byQueueHigh;
208  APP_DWORD dwQueueH[ALARM_MAX_QUEUE_LEVEL];
209 }PACK_ALIGNEMENT(ST_QUEUE_ALM), APP_FAR * LPST_QUEUE_ALM;
210 
211 
212 
213 typedef struct _ST_AREP {
214  APP_DWORD dwArep;
215 
216  /* From user*/
217  APP_DWORD dwARContextInd; /*
218  Application relation Contexte indicator
219  Handle give by user once an AR is opened (into the PND_CB_ArOpenedInd callback)
220  This handle is restore each time a callback concerned by this AR is call. This handle is uuse in place of giving an AREp to the user
221  */
222 
223  /* From connect */
224  ST_AR_BLOCK_REQ stARBlock;
225 
226  ST_ALARM_CR_BLOCK_REQ stAlarmBloc;
227  ST_PRMSERVER_CR_BLOCK_REQ stPrmServerBloc;
228  ST_MCR_CR_BLOCK_REQ stMcrBlockReq;
229 
230  /* alarm */
231  APP_WORD wSeqAlarmNumber;
232  APP_WORD wOldSeqAlarmNumber;
233  ST_QUEUE_ALM qstAlm;
234 
235  /*RPC */
236  APP_DWORD dwRpcReqSize;
237 
238  LPST_RPC_CALL lpstCurrRPCCall;
239  LPST_RPC_CALL listOflpstRPCCall[MAX_RPCCLIENT];
240 
241  LPST_RPC_REQ lpstRPCReq;
242  APP_WORD wRpcServerPort;
243  APP_DWORD dwControllerIp;
244 
245  /* state machine */
246  ST_CMDEV stCmdev;
247 
248  /* Asynchronous Read / Write Operations */
249  ST_ACYN_READ_WRITE stAcynReadWrite;
250 
251 
252 #ifdef SHARED_MEMORY_MODE
253 
254  /* In and out, device view. */
255 
256  ST_SHARED_MEMORY lpSharedMemoryIn [MAX_CR_IN_PER_AR]; /* --> consume by device */
257  ST_SHARED_MEMORY lpSharedMemoryOut[MAX_CR_OUT_PER_AR]; /* --> produce by device */
258 #endif
259 
260  ST_APPLICATION_RELATION stBlocVersion;
261 
262  ST_POOL stPoolOfTmpExpectedConfiguration;
263  ST_POOL stPoolOfCr;
264 
265  APP_LPVOID lpvIrep;
266 
267  APP_BYTE bIsIOSAR;
268 
269 }PACK_ALIGNEMENT(ST_AREP), APP_FAR * LPST_AREP;
270 
271 #include "os_unpck.h"
272 
273 /* Alarm Queue */
274 #define RESET_AREP_QUEUE_ALM_LOW(lpstArep) (lpstArep)->qstAlm.byQueueLow = 0;OS_MEMSET((lpstArep)->qstAlm.dwQueueL, APP_NULL, sizeof(APP_DWORD)*ALARM_MAX_QUEUE_LEVEL)
275 #define RESET_AREP_QUEUE_ALM_HIGH(lpstArep) (lpstArep)->qstAlm.byQueueHigh = 0;OS_MEMSET((lpstArep)->qstAlm.dwQueueH, APP_NULL, sizeof(APP_DWORD)*ALARM_MAX_QUEUE_LEVEL)
276 
277 #define GET_AREP_QUEUE_ALM_LOW(lpstArep) (lpstArep)->qstAlm.byQueueLow
278 #define GET_AREP_QUEUE_ALM_HIGH(lpstArep) (lpstArep)->qstAlm.byQueueHigh
279 
280 #define GET_AREP_PENDING_ALM_LOW(lpstArep) (lpstArep)->qstAlm.dwQueueL
281 #define GET_AREP_PENDING_ALM_HIGH(lpstArep) (lpstArep)->qstAlm.dwQueueH
282 
283 #define INC_AREP_QUEUE_ALM_LOW(lpstArep) ((lpstArep)->qstAlm.byQueueLow)++
284 #define INC_AREP_QUEUE_ALM_HIGH(lpstArep) ((lpstArep)->qstAlm.byQueueHigh)++
285 #define DEC_AREP_QUEUE_ALM_LOW(lpstArep) ((lpstArep)->qstAlm.byQueueLow)--
286 #define DEC_AREP_QUEUE_ALM_HIGH(lpstArep) ((lpstArep)->qstAlm.byQueueHigh)--
287 
288 #define SET_AREP_CONTEXT_IND(lpstArep, dwContextInd) (lpstArep)->dwARContextInd = (dwContextInd)
289 #define GET_AREP_CONTEXT_IND(lpstArep) (lpstArep)->dwARContextInd
290 
291  /*rpc */
292 #define SET_AREP_REQ_RPC_STATUS(arep,v) SET_REQ_RPC_STATUS((arep)->lpstRPCReq,v)
293 #define SET_AREP_RPC_MAX_LEN(lpArep, len) (lpArep)->dwRpcReqSize = (len)
294 #define GET_AREP_RPC_MAX_LEN(lpArep) (lpArep)->dwRpcReqSize
295 
296 #define SET_AREP_IP_CONTROLLER(lpArep, dwIPAddressCaller) (lpArep)->dwControllerIp = (dwIPAddressCaller)
297 #define GET_AREP_IP_CONTROLLER(lpArep) (lpArep)->dwControllerIp
298 
299 #define GET_RPC_SERVER_PORT(arep) gwServerPort
300 
301 #define GET_AREP_RPC_CALL_X(arep, index) ((arep)->listOflpstRPCCall[index])
302 #define GET_AREP_CALL_DATA_X(arep, index) CALL_DATA( ((arep)->listOflpstRPCCall[index]) )
303 
304 
305 #define GET_AREP_RPC_CALL(arep) ((arep)->lpstCurrRPCCall)
306 #define SET_AREP_RPC_CALL(arep, lpstCurrRPCCall) ((arep)->lpstCurrRPCCall) = (lpstCurrRPCCall)
307 #define GET_AREP_RPC_REQ(arep) (arep)->lpstRPCReq
308 #define SET_AREP_RPC_REQ(arep,v) (arep)->lpstRPCReq = (v)
309 
310 #define GET_AREP_REQ_DATA(arep) REQ_DATA((arep)->lpstRPCReq)
311 #define GET_AREP_CALL_DATA(arep) CALL_DATA( ((arep)->lpstCurrRPCCall) )
312 
313 
314 #define SET_AREP_REQ_RPC_STATUS(arep,v) SET_REQ_RPC_STATUS((arep)->lpstRPCReq,v)
315 #define GET_AREP_REQ_RPC_STATUS(arep) GET_REQ_RPC_STATUS((arep)->lpstRPCReq)
316 
317 
318 /* Asynchronous storage access */
319 #define GET_AREP_ACY_RW_AREP_TARGET(lparep) lparep->stAcynReadWrite.lpstArepTarget
320 #define SET_AREP_ACY_RW_AREP_TARGET(lparep,a) lparep->stAcynReadWrite.lpstArepTarget = a
321 
322 #define GET_AREP_ACY_RW_API(lparep) lparep->stAcynReadWrite.Api
323 #define SET_AREP_ACY_RW_API(lparep,a) lparep->stAcynReadWrite.Api = a
324 
325 #define GET_AREP_ACY_RW_LEN(lparep) lparep->stAcynReadWrite.Record_Data_Length
326 #define SET_AREP_ACY_RW_LEN(lparep,a) lparep->stAcynReadWrite.Record_Data_Length = a
327 
328 #define GET_AREP_ACY_RW_DATAPTR(lparep) lparep->stAcynReadWrite.lpbyRecordData
329 #define SET_AREP_ACY_RW_DATAPTR(lparep,a) lparep->stAcynReadWrite.lpbyRecordData = a
330 
331 #define GET_AREP_ACY_RW_SLOT(lparep) lparep->stAcynReadWrite.Slot_Number
332 #define SET_AREP_ACY_RW_SLOT(lparep,a) lparep->stAcynReadWrite.Slot_Number = a
333 
334 #define GET_AREP_ACY_RW_SUBSLOT(lparep) lparep->stAcynReadWrite.Subslot_Number
335 #define SET_AREP_ACY_RW_SUBSLOT(lparep,a) lparep->stAcynReadWrite.Subslot_Number = a
336 
337 #define GET_AREP_ACY_RW_INDEX(lparep) lparep->stAcynReadWrite.Index
338 #define SET_AREP_ACY_RW_INDEX(lparep,a) lparep->stAcynReadWrite.Index = a
339 
340 #define GET_AREP_ACY_RW_SEQNUMBER(lparep) lparep->stAcynReadWrite.SeqNumber
341 #define SET_AREP_ACY_RW_SEQNUMBER(lparep,a) lparep->stAcynReadWrite.SeqNumber = a
342 
343 #define GET_AREP_ACY_RW_BLOCK_VERSION_HIGH(lparep) lparep->stAcynReadWrite.BlockVersionHigh
344 #define SET_AREP_ACY_RW_BLOCK_VERSION_HIGH(lparep,a) lparep->stAcynReadWrite.BlockVersionHigh = a
345 
346 #define GET_AREP_ACY_RW_BLOCK_VERSION_LOW(lparep) lparep->stAcynReadWrite.BlockVersionLow
347 #define SET_AREP_ACY_RW_BLOCK_VERSION_LOW(lparep,a) lparep->stAcynReadWrite.BlockVersionLow = a
348 
349 /*********************************************************************/
350 /* Get an arep from a rpc request : done */
351 /*********************************************************************/
352 APP_VOID find_arep_from_rpc_req (LPST_AREP APP_FAR *lpstArep, APP_LPBYTE lpData, LPST_RPC_REQ lpstRPCReq);
353 APP_VOID find_arep_from_uuid (LPST_AREP APP_FAR *lpstArep, APP_LPBYTE lpDataUUID,LPST_RPC_REQ lpstRPCReq);
354 
355 APP_VOID find_free_arep_from_rpc_req(LPST_AREP APP_FAR *lpstArep, LPST_RPC_REQ lpstRPCReq);
356 APP_VOID getArepImplicit (LPST_AREP APP_FAR *lpstArep, LPST_RPC_REQ lpstRPCReq);
357 
358 APP_BOOL checkArepRpcCall (LPST_AREP lpstArep, LPST_RPC_CALL lpstRPCCall);
359 APP_VOID set_arep_call_ObjectUUID(LPST_AREP lpstArep, ST_CLR_RPC_UUID CMInitiatorObjectUUID);
360 
361 
362 #define AREP_IS_USED(lpstArep) (0 != lpstArep->stARBlock.StationNameLength)
363 
364 #define FIND_FREE_AREP_FROM_RPC_REQ(lpstDrep,lpstRPCReq) find_free_arep_from_rpc_req(&(lpstDrep), lpstRPCReq)
365 #define FIND_AREP_FROM_RPC_REQ(lpstArep, lpData, lpstRPCReq) find_arep_from_rpc_req( &(lpstArep), lpData, lpstRPCReq)
366 
367 /* Implicit read managment */
368 #define GET_AREP_IMPLICIT(lpArep, lpstRPCReq) getArepImplicit(lpArep, lpstRPCReq)
369 
370 #define AREP_IS_IMPLICIT(lpArep) lpArep == &((AREP_GET_DREP(lpArep))->stIrep[0].stArepImplicit[0])
371 #define AREP_IMPLICIT_IS_USED(lpArep) (0 != lpArep->stARBlock.StationNameLength)
372 #define SET_AREP_IMPLICIT_USED(lpArep) lpArep->stARBlock.StationNameLength = 1
373 #define SET_AREP_IMPLICIT_UNUSED(lpArep) lpArep->stARBlock.StationNameLength = 0
374 
375 APP_VOID Init_Arep (APP_LPVOID lpstIrep, LPST_AREP lpstarep);
376 APP_VOID Exit_Arep (LPST_AREP lpstArep);
377 APP_VOID Init_Arep_Implicit(APP_LPVOID lpstIrep, LPST_AREP lpstArep);
378 APP_VOID Exit_Arep_Implicit(LPST_AREP lpstArep);
379 APP_BOOL arepIsImplicit(LPST_AREP lpArep);
380 /*********************************************************************/
381 
382 APP_BOOL SET_AREP_RPC(LPST_AREP lpArep, APP_WORD wInstance, APP_WORD wDeviceId, APP_WORD wVendorId , LPST_CLR_RPC_UUID lpuuidPROFINETIOConstantValue,APP_WORD wRPCPort);
383 
384 
385 APP_WORD getExpectedSubSlot(APP_DWORD dwAPI, APP_WORD wSlot, APP_WORD wSubSlot, LPST_AREP lpstArep, APP_LPBYTE *lppbySubSlot);
386 APP_WORD getExpectedSlot(APP_DWORD dwAPI, APP_WORD wSlot, LPST_AREP lpstArep, APP_LPBYTE *lppbySlot);
387 
388 
389 #ifdef PLATFORM_LITTLE_ENDIAN
390 #define GET_AREP_LITTLEENDIAN(arep) (APP_TRUE)
391 #endif
392 
393 #ifndef PLATFORM_LITTLE_ENDIAN
394 #define GET_AREP_LITTLEENDIAN(arep) (APP_FALSE)
395 #endif
396 
397 
398 #define AREP_GET_AR_REQ(lpArep) &((lpArep)->stARBlock)
399 #define AREP_GET_IOCR_INPUT_REQ(lpArep) &(lpArep)->ListOfIOCRInputBlockReq
400 #define AREP_GET_IOCR_OUTPUT_REQ(lpArep) &(lpArep)->ListOfIOCROutpuBlockReq
401 #define AREP_GET_ALARM_REQ(lpArep) &(lpArep)->stAlarmBloc
402 #define AREP_GET_PRM_SERVER_REQ(lpArep) &(lpArep)->stPrmServerBloc
403 #define AREP_GET_MCR_SERVER_REQ(lpArep) &(lpArep)->stMcrBlockReq
404 
405 
406 /* AR field */
407 #define AREP_GET_AR_ARTYPE(lpArep) ((lpArep)->stARBlock).ARType
408 #define AREP_GET_ARUUID(lpArep) (lpArep)->stARBlock.ARUUID
409 #define AREP_GET_AR_SESSION_KEY(lpArep) (lpArep)->stARBlock.SessionKey
410 #define AREP_GET_CMIOUUID(lpArep) (lpArep)->stARBlock.CMInitiatorObjectUUID
411 #define AREP_GET_AR_INITIATOR_MAC(lpArep) (lpArep)->stARBlock.CMInitiatorMacAdd
412 #define AREP_GET_AR_INITIATOR_TIMEOUT_FACTOR(lpArep) (lpArep)->stARBlock.CMInitiatorActivityTimeoutFactor
413 #define AREP_GET_AR_INITIATOR_NAME(lpArep) (lpArep)->stARBlock.CMInitiatorStationName
414 #define AREP_GET_AR_INITIATOR_NAME_LEN(lpArep) (lpArep)->stARBlock.StationNameLength
415 #define AREP_GET_CONTROLLER_IP(lpArep) (lpArep)->dwControllerIp
416 
417 #define AREP_GET_AR_PROPERTIES(lpArep) (ALIGNED_DWORD_VALUE((lpArep)->stARBlock.ARProperties))
418 
419 
420 
421 /* alarm */
422 #define AREP_GET_DEVICE_SRC_ALARM_REFERENCE(lpArep) lpArep->stAlarmBloc.LocalAlarmReference
423 #define AREP_GET_DEVICE_ALARM_REFERENCE(lpArep) 0x0000
424 #define AREP_GET_DEVICE_MAX_ALARM_LEN(lpArep) MAX_ALARM_LENGTH_MIN_VALUE
425 #define AREP_GET_ALARM_RTA_TIMEOUT(lpArep) lpArep->stAlarmBloc.RTATimeoutFactor
426 #define AREP_GET_ALARM_RTA_RETRY(lpArep) lpArep->stAlarmBloc.RTARetries
427 #define AREP_GET_ALARM_PROPERTIES(lpArep) ALIGNED_DWORD_VALUE(lpArep->stAlarmBloc.AlarmCRProperties)
428 #define SUPPORT_ONLY_LOW_ALARMS 0X1
429 
430 #define AREP_GET_PULL_ALARM_ALLOWED(lpArep) ( ( (ALIGNED_DWORD_VALUE((lpArep)->stARBlock.ARProperties))>>7 ) & 1 )
431 
432 #define AREP_INIT(lpArep) (lpArep)->stPoolOfTmpExpectedConfiguration.lpFirstElement = APP_NULL; \
433  (lpArep)->stPoolOfTmpExpectedConfiguration.wSize = 0; \
434  (lpArep)->stPoolOfTmpExpectedConfiguration.wSizeElt = sizeof(ST_TEMPORARY_EC); \
435  (lpArep)->stPoolOfTmpExpectedConfiguration.wMaxElt = ( (HASH_KEY_MAX_API) * (HASH_KEY_MAX_SSLOT) * (HASH_KEY_MAX_SLOT) ); \
436  (lpArep)->stPoolOfCr.lpFirstElement = APP_NULL; \
437  (lpArep)->stPoolOfCr.wSize = 0; \
438  (lpArep)->stPoolOfCr.wSizeElt = sizeof(ST_CR); \
439  (lpArep)->stPoolOfCr.wMaxElt = MAX_CR_PER_AR; \
440  (lpArep)->wSeqAlarmNumber = 0; \
441  (lpArep)->wOldSeqAlarmNumber = 0;
442 
443 
444 /* Expected configuration management Macro*/
445 #define INSERT_EC_INTO_CONFIG_STORAGE(lpstConfigStorage, lpstEc, dwStatus){\
446  APP_DWORD dwI = 0;\
447  dwStatus = OS_NOT_OK;\
448  for(dwI = 0; dwI < ((MAX_INSTANCE_PER_DEVICE * MAX_CONNEXION_PER_INSTANCE)); dwI++){\
449  if(APP_NULL == (lpstConfigStorage)->lpArrayOfstEc[dwI]){\
450  (lpstConfigStorage)->lpArrayOfstEc[dwI] = (lpstEc);\
451  dwStatus = OS_OK;\
452  break;\
453  }\
454  }\
455 }
456 
457 #define GET_NB_EC_INTO_CONFIG_STORAGE(lpstConfigStorage, dwNbEc){\
458  APP_DWORD dwI = 0;\
459  dwNbEc = 0;\
460  for(dwI = 0; dwI < ((MAX_INSTANCE_PER_DEVICE * MAX_CONNEXION_PER_INSTANCE)); dwI++){\
461  if(APP_NULL != (lpstConfigStorage)->lpArrayOfstEc[dwI]){\
462  (dwNbEc)++;\
463  }else{\
464  break;/*No more EC*/\
465  }\
466  }\
467 }
468 
469 #define GET_INDEX_CR_FROM_CONFIG_STORAGE(lpstConfigStorage, lpstCr, dwIndex){\
470  APP_DWORD dwI = 0;\
471  dwIndex = ((APP_DWORD)-1);\
472  for(dwI = 0; dwI < ((MAX_INSTANCE_PER_DEVICE * MAX_CONNEXION_PER_INSTANCE)); dwI++){\
473  if(APP_NULL != (lpstConfigStorage)->lpArrayOfstEc[dwI]){\
474  HASH_TRACE("lpstCr (to find) 0x%lx \n", lpstCr);\
475  HASH_TRACE("lpstCr2 (comm) 0x%lx \n", ((lpstConfigStorage)->lpArrayOfstEc[dwI]->CommunicationRelation));\
476  HASH_TRACE("lpstCr3 (IOCR) 0x%lx \n", ((lpstConfigStorage)->lpArrayOfstEc[dwI]->CommunicationRelationIOCS));\
477  if( ((lpstConfigStorage)->lpArrayOfstEc[dwI]->CommunicationRelation) == lpstCr){\
478  dwIndex = dwI;\
479  HASH_TRACE("dwIndex %ld \n", dwIndex);\
480  break;\
481  }\
482  if( ((lpstConfigStorage)->lpArrayOfstEc[dwI]->CommunicationRelationIOCS) == lpstCr){/*Case of IO modules */\
483  dwIndex = dwI;\
484  HASH_TRACE("dwIndex %ld \n", dwIndex);\
485  break;\
486  }\
487  }else{\
488  HASH_TRACE("End of list\n");\
489  break;/*End of list */\
490  }\
491  }\
492 }
493 
494 #define REMOVE_AND_SHIFT_EC(lpstConfigStorage, dwIndex){\
495  APP_DWORD dwI = 0;\
496  for(dwI = dwIndex; dwI < (((MAX_INSTANCE_PER_DEVICE * MAX_CONNEXION_PER_INSTANCE)-1)); dwI++){\
497  (lpstConfigStorage)->lpArrayOfstEc[dwI] = (lpstConfigStorage)->lpArrayOfstEc[dwI+1];\
498  }\
499  (lpstConfigStorage)->lpArrayOfstEc[dwI] = APP_NULL;\
500 }
501 
502 /*End of Expected configuration management Macro*/
503 
504 APP_WORD CleanArep(LPST_AREP lpstArep, LPST_POOL lpstPoolEc, LPST_POOL lpstPoolTmpEc);
505 APP_WORD CleanIOSARArep(LPST_AREP lpstArep);
506 
507 /*bloc version */
508 #define GET_AR_VERS(parep) &(parep)->stBlocVersion
509 #define GET_AR_VERS_HIGH(parep) (parep)->stBlocVersion.ARBlocVers.High
510 #define GET_AR_VERS_LOW(parep) (parep)->stBlocVersion.ARBlocVers.Low
511 #define SET_AR_VERS_HIGH(parep, version) (parep)->stBlocVersion.ARBlocVers.High = version
512 #define SET_AR_VERS_LOW(parep, version ) (parep)->stBlocVersion.ARBlocVers.Low = version
513 
514 #define GET_IOCR_VERS_HIGH(parep) (parep)->stBlocVersion.IOCRBlocVers.High
515 #define GET_IOCR_VERS_LOW(parep) (parep)->stBlocVersion.IOCRBlocVers.Low
516 #define SET_IOCR_VERS_HIGH(parep, version) (parep)->stBlocVersion.IOCRBlocVers.High = version
517 #define SET_IOCR_VERS_LOW(parep, version ) (parep)->stBlocVersion.IOCRBlocVers.Low = version
518 
519 #define GET_ALARM_VERS_HIGH(parep) (parep)->stBlocVersion.ALRMBlocVers.High
520 #define GET_ALARM_VERS_LOW(parep) (parep)->stBlocVersion.ALRMBlocVers.Low
521 #define SET_ALARM_VERS_HIGH(parep, version) (parep)->stBlocVersion.ALRMBlocVers.High = version
522 #define SET_ALARM_VERS_LOW(parep, version ) (parep)->stBlocVersion.ALRMBlocVers.Low = version
523 
524 #define AREP_ARRPC_AVAILABLE(lpArep) APP_FALSE
525 #define AREP_GET_ARRPC_RESPONDER_SERVER_PORT(lpArep) 0x0000
526 
527 #define GET_ARRPC_VERS_HIGH(parep) 1
528 #define GET_ARRPC_VERS_LOW(parep) 0
529 #define SET_ARRPC_VERS_HIGH(parep, version)
530 #define SET_ARRPC_VERS_LOW(parep, version )
531 
532 /* Page 411 - table 216
533 The field AlarmSequenceNumber shall contain the value of the sub-field AlarmSpecifier.
534 SequenceNumber of the corresponding AlarmNotification-PDU.
535 */
536 #define AREP_SAVE_ALARM_SPECIFIER(lpArep) (lpArep)->wOldSeqAlarmNumber = (lpArep)->wSeqAlarmNumber
537 #define AREP_GET_OLD_ALARM_SPECIFIER(lpArep) (lpArep)->wOldSeqAlarmNumber
538 #define AREP_GET_ALARM_SPECIFIER(lpArep) (lpArep)->wSeqAlarmNumber
539 #define AREP_INCREMENT_ALARM_SPECIFIER(lpArep) if((lpArep)->wSeqAlarmNumber >= MAX_ALARM_SPECIFIER) {(lpArep)->wSeqAlarmNumber =0;} else {(lpArep)->wSeqAlarmNumber++;}
540 
541 /* test function */
542 
543 /* test if this arep have a correct AR Type. Actually the two type possible (IOCRARSINGLE and IOCRARSAR ) are test */
544 /* in frame checker, then this test is empty */
545 #define CHECK_AR_TYPE(a) APP_TRUE
546 
547 
548 /*CREP */
549 /* add a ppm crep to this arep in crep */
550 #define AREP_ADD_CREP_PPM(lpstArep, lpCrep) arep_add_crep(lpstArep,lpCrep, IOCR_INPUT_CR)
551 /* add a ppm crep to this arep in crep */
552 #define AREP_ADD_CREP_CPM(lpstArep, lpCrep) arep_add_crep(lpstArep,lpCrep, IOCR_OUTPUT_CR)
553 
554 
555 /* we have all crep init if stCREPIn containe a number of crep equal to the stIOCRBlockInput */
556 #define AREP_LAST_CREP_IN(lpstArep) (arep_last_crep(lpstArep, IOCR_INPUT_CR ))
557 #define AREP_LAST_CREP_OUT(lpstArep)(arep_last_crep(lpstArep, IOCR_OUTPUT_CR))
558 
559 
560 APP_WORD arep_add_crep(LPST_AREP lpstArep, APP_HANDLE CREP, APP_DWORD dwIOCRType);
561 APP_WORD arep_last_crep(LPST_AREP lpstArep, APP_DWORD dwIOCRType);
562 LPST_CR arep_get_CR(LPST_AREP lpstArep, APP_DWORD dwIOCRType);
563 APP_WORD arep_check_IOCRReference_is_unique(LPST_AREP lpstArep, APP_WORD IOCRReference, APP_LPVOID lpvstIOCR);
564 
565 APP_BOOL get_temporary_expected_conf(APP_DWORD dwApi,
566  APP_WORD wSlot,
567  APP_WORD wSubSlot,
568  LPST_EXPECTED_CONFIGURATION * lpstEC,
569  LPST_AREP lpstArep,
570  LPST_POOL lpstPoolEC,
571  LPST_POOL lpstPoolTmpEC);
572 
573 
574 APP_BOOL temporary_expected_conf_exist(APP_DWORD dwApi,
575  APP_WORD wSlot,
576  APP_WORD wSubSlot,
577  LPST_AREP lpstArep);
578 
579 #define COMPARE_UNIQUE_STACK_ID(API, SLOT, SUB_SLOT, lpstUniqueStackID) ( (API == lpstUniqueStackID->dwAPI) && (SLOT == lpstUniqueStackID->wSlot) && (SUB_SLOT == lpstUniqueStackID->wSubSlot) )
580 #define GET_AREP_POOL_OF_CR(lpstAREP) (&((lpstAREP)->stPoolOfCr))
581 #define GET_AREP_POOL_OF_TMP_EC(lpstAREP) (&((lpstAREP)->stPoolOfTmpExpectedConfiguration))
582 
583 
584 /* return the expected configuration block store in arep temporary */
585 /* if the block didn't exist, get a new one */
586 #define GET_TEMPORARY_EXPECTED_CONF(API, SLOT, SUB_SLOT, EC, AREP, POOL_EC, POOL_TMP_EC) get_temporary_expected_conf(API, SLOT, SUB_SLOT, EC, AREP, POOL_EC, POOL_TMP_EC)
587 
588 
589 #endif
Definition: arep.h:70
Definition: arep.h:37
Definition: arep.h:179
Definition: arep.h:80
Definition: arep.h:87
Definition: arep.h:162
Definition: schedule.h:40
Definition: arep.h:213
Definition: arep.h:150
Definition: arep.h:94
Definition: arep.h:157
Definition: arep.h:193
Definition: arep.h:65
Definition: arep.h:203