versadac  1
versadac - Scalable Recorder Firmware
stackdev.h
1 /*---------------------------------------------------------------------------*/
2 /* Copyright (C) 2007 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 Device */
14 /* Component : */
15 /* $Workfile:: stackdev.h $*/
16 /* $Revision:: 5 $*/
17 /* $Date:: 13/07/11 13:57 $*/
18 /* */
19 /*---------------------------------------------------------------------------*/
20 /* */
21 /* D e s c r i p t i o n : */
22 /* */
23 /* */
24 /*---------------------------------------------------------------------------*/
25 
26 
27 #ifndef __STACKDEV_H__
28  #define __STACKDEV_H__
29 
30 #include "system.h"
31 #include "pniostat.h"
32 #include "platform.h"
33 #include "os_net.h"
34 #include "hwif.h"
35 #include "netif.h"
36 #include "pool.h"
37 #include "uuid.h"
38 
39 #include "stk_thd.h"
40 
41 #include "link.h"
42 #include "schedule.h"
43 #include "commonid.h"
44 
45 #include "message.h"
46 #include "param.h"
47 #include "tools.h"
48 #include "fspm.h"
49 
50 #include "pnio_pdu.h"
51 #include "rpctools.h"
52 #include "rpcrunti.h"
53 
54 #include "irep.h"
55 #include "drep.h"
56 
57 #include "monitor.h"
58 
59 #include "alm.h"
60 #include "ase_def.h"
61 
62 #define UNUSED_ARG(p) p=p
63 
64 
65 /************************ define ************************/
66 /*data APDU status flag values*/
67 #define APDU_DATA_FLAG_VALUE 0x04
68 #define APDU_AR_STATE_FLAG_VALUE 0x01
69 #define APDU_PROVIDER_DATA_FLAG_VALUE 0x10
70 #define APDU_PROBLEME_IND_FLAG_VALUE 0x20
71 
72 
73 /* APDU set/not set flag */
74 #define APDU_DATA_VALIDE 1
75 #define APDU_AR_STATE_PRIMARY 1
76 #define APDU_PROVIDER_RUN 1
77 #define APDU_NO_PROBLEME 1
78 
79 #define APDU_DATA_INVALID 0
80 #define APDU_AR_STATE_BACKUP 0
81 #define APDU_PROVIDER_STOP 0
82 #define APDU_HAVE_PROBLEME 0
83 
84 /********* IP type: provided by DHCP or static **/
85 #define PND_IP_STATIC 0x00
86 #define PND_IP_DHCP 0x80
87 #define PND_IP_DHCP_MAC 0x81
88 #define PND_IP_DHCP_NAME 0x82
89 #define PND_IP_DHCP_ID 0x83
90 
91 /********* Initiative delay accepted **/
92 #define PND_INITIAVE_DELAY_MODE_OFF 0x00 /* Device does not issue a DCP-Hello-ReqPDU after power on. */
93 #define PND_INITIAVE_DELAY_MODE_ON 0x01 /* Device does issue a DCP-Hello-ReqPDU after power on. */
94 
95 #define PND_HELLO_INTERVAL_0030MS 30
96 #define PND_HELLO_INTERVAL_0050MS 50
97 #define PND_HELLO_INTERVAL_0100MS 100
98 #define PND_HELLO_INTERVAL_0300MS 300
99 #define PND_HELLO_INTERVAL_0500MS 500
100 #define PND_HELLO_INTERVAL_1000MS 1000
101 
102 #define PND_HELLO_DELAY_OFF 0
103 #define PND_HELLO_DELAY_0050MS 50
104 #define PND_HELLO_DELAY_0100MS 100
105 #define PND_HELLO_DELAY_0300MS 300
106 #define PND_HELLO_DELAY_0500MS 500
107 #define PND_HELLO_DELAY_1000MS 1000
108 
109 
110 #define PND_HELLO_MAX_RETRY_ALLOWED 0x0F /*Due to specification no more than0x0F retry are allowed*/
111 
112 /********************* Function prototype *****************/
113 /* Stack Init/Exit */
114 APP_WORD APP_FAR PND_Init(APP_LPWORD lpwStatus);
115 APP_WORD APP_FAR PND_Exit(APP_LPWORD lpwStatus);
116 
117 /* Stack Start/Stop */
118 APP_WORD APP_FAR PND_Start(LPST_DREP lpPhyDev, APP_LPWORD lpwStatus);
119 APP_WORD APP_FAR PND_Stop (LPST_DREP lpPhyDev, APP_LPWORD lpwStatus);
120 
121 /* Add/del device */
122 APP_WORD APP_FAR PND_AddDevice(LPST_DREP APP_FAR *lpPhyDev, APP_DWORD dwDRContextInd, APP_LPCHAR lpszInterfaceName, APP_WORD wPort, APP_LPCHAR lpbyDeviceName, APP_LPCHAR lpbyDeviceType, APP_WORD wDeviceID, APP_WORD wVendorID, APP_BYTE byTypeIp, APP_DWORD dwIpAddress, APP_DWORD dwSubNetMask, APP_DWORD dwGateway, APP_LPCHAR lpbyDHCPParameter, APP_WORD wDHCPType, APP_WORD wReserved1, APP_WORD wReserved2, APP_LPWORD lpwStatus);
123 APP_WORD APP_FAR PND_DelDevice(LPST_DREP lpPhyDev, APP_LPWORD lpwStatus);
124 
125 /* Add Instance */
126 APP_WORD APP_FAR PND_AddInstance(LPST_DREP lpPhyDev, LPST_IREP APP_FAR *lpLogDev, APP_DWORD dwIRContextInd, APP_WORD wInstance, APP_LPWORD lpwStatus);
127 
128 /* Plug a SubModule in a given API, slot, subslot*/
129 APP_WORD APP_FAR PND_PlugSubModule(LPST_IREP lpLogDev, APP_DWORD dwApi, APP_WORD wSlot, APP_WORD wSubSlot, APP_DWORD dwModuleId, APP_DWORD dwSubModuleId, APP_WORD wSizeIn, APP_WORD wSizeOut, APP_LPWORD lpwStatus);
130 APP_WORD APP_FAR PND_PullSubModule(LPST_IREP lpLogDev, APP_DWORD dwApi, APP_WORD wSlot, APP_WORD wSubSlot, APP_LPWORD lpwStatus);
131 
132 /* set/get subModuleState */
133 APP_WORD APP_FAR PND_SetSubModuleState(LPST_IREP lpLogDev, APP_DWORD dwApi ,APP_DWORD dwSlot, APP_DWORD dwSubSlot, APP_DWORD dwState, APP_LPWORD lpwStatus);
134 APP_WORD APP_FAR PND_GetSubModuleState(LPST_IREP lpLogDev, APP_DWORD dwApi, APP_DWORD dwSlot, APP_DWORD dwSubSlot, APP_LPDWORD lpdwState, APP_LPWORD lpwStatus);
135 
136 /* Send an Application Ready*/
137 APP_WORD APP_FAR PND_ApplicationReady(LPST_AREP lpstArep, APP_LPWORD lpwStatus);
138 
139 /* Close an opened connection */
140 APP_WORD APP_FAR PND_ArAbort(LPST_AREP lpstArep, APP_LPWORD lpwStatus);
141 
142 /* Alarms */
143 APP_WORD APP_FAR PND_Alarm_Process (LPST_IREP lpLogDev, APP_DWORD dwApi, APP_WORD wSlot, APP_WORD wSubSlot, APP_LPBYTE lpbyAlarmData, APP_WORD wAlarmDataLen, APP_WORD wUserStructureCode, APP_LPVOID lpContext,APP_WORD wReserved1, APP_WORD wReserved2, APP_LPWORD lpwStatus);
144 APP_WORD APP_FAR PND_Alarm_Diagnosis (LPST_IREP lpLogDev, APP_DWORD dwApi, APP_WORD wSlot, APP_WORD wSubSlot, APP_LPBYTE lpbyAlarmData, APP_WORD wAlarmDataLen, APP_WORD wUserStructureCode, APP_LPVOID lpContext,APP_WORD wReserved1, APP_WORD wReserved2, APP_LPWORD lpwStatus);
145 APP_WORD APP_FAR PND_Alarm (LPST_IREP lpLogDev, APP_DWORD dwApi, APP_BYTE byPriority, APP_WORD wAlarmType, APP_WORD wSlot, APP_WORD wSubSlot, APP_WORD wAlarmSpecifier, APP_LPBYTE lpbyAlarmData, APP_WORD wAlarmDataLen, APP_WORD wUserStructureCode, APP_HANDLE hUserHandle, APP_WORD wReserved1, APP_LPWORD lpwStatus);
146 
147 /* IO function access */
148 APP_WORD APP_FAR PND_Set_Output (LPST_DREP lpstDrep, APP_LPVOID lpContext, APP_DWORD dwApi, APP_WORD wSlot, APP_WORD wSubSlot, APP_BYTE byIOPS, APP_LPVOID lpvData, APP_WORD wDataSize, APP_LPWORD lpwStatus);
149 APP_WORD APP_FAR PND_Set_Input_Iocs (LPST_DREP lpstDrep, APP_LPVOID lpContext, APP_DWORD dwApi, APP_WORD wSlot, APP_WORD wSubSlot, APP_BYTE byIOCS, APP_WORD wIOCSLength, APP_LPWORD lpwStatus);
150 APP_WORD APP_FAR PND_Get_Output_Iocs (LPST_DREP lpstDrep, APP_LPVOID lpContext, APP_DWORD dwApi, APP_WORD wSlot, APP_WORD wSubSlot, APP_LPWORD lpwStatus);
151 APP_WORD APP_FAR PND_Get_Input (LPST_DREP lpstDrep, APP_LPVOID lpContext, APP_DWORD dwApi, APP_WORD wSlot, APP_WORD wSubSlot, APP_LPWORD lpwStatus);
152 APP_WORD APP_FAR PND_Set_Output_Apdu_Status (LPST_AREP lpstArep, APP_LPVOID lpContext, APP_BYTE byData_Flag, APP_BYTE byAR_State_Flag, APP_BYTE byProvider_State_Flag, APP_BYTE byProblem_Indicator_Flag, APP_LPWORD lpwStatus);
153 APP_WORD APP_FAR PND_Get_Input_Apdu_Status (LPST_AREP lpstArep, APP_LPVOID lpContext, APP_LPWORD lpwStatus);
154 APP_WORD APP_FAR PND_DCP_Hello_req (LPST_DREP lpstDrep, APP_WORD wPort, APP_LPWORD lpwStatus);
155 APP_WORD APP_FAR PND_Configure_dcp_hello (LPST_DREP lpstDrep,APP_BOOL bIsEnabled, APP_BYTE byInitiaveValues, APP_WORD wHelloInterval, APP_WORD wHelloStartUpDelay, APP_WORD wRetriesCount, APP_LPWORD lpwStatus);
156 
157 typedef struct _ST_DEVICE_CONF{
158 
159  LPST_DREP lpstDrep;
160  APP_HANDLE hHInterfaceName;
161  APP_DWORD dwSelectedInterface;
162  LPST_DREP lpstDrepBase; /* Array of all DREP*/
163 }ST_DEVICE_CONF, APP_FAR * LPST_DEVICE_CONF;
164 
165 #define ST_DEVICE_CONF_LEN sizeof(ST_DEVICE_CONF)
166 
167 
168 typedef struct _ST_PLUG_PULL_PARAM{
169 
170  LPST_IREP lpLogDev; /* for plug pull */
171  APP_DWORD dwApi; /* for plug pull */
172  APP_DWORD dwModuleId; /* for plug */
173  APP_DWORD dwSubModuleId; /* for plug */
174  APP_WORD wModule; /* for plug pull */
175  APP_WORD wSubModule; /* for plug pull */
176  APP_WORD wSizeIn; /* for plug pull */
177  APP_WORD wSizeOut; /* for plug pull */
178 
179 
181 
182 #define ST_PLUG_PULL_PARAM_SIZEOF sizeof(ST_DEVICE_CONF)
183 
184 
185 typedef struct _ST_INPUT_PARAM{
186 
187  LPST_DREP lpstDrep;
188  APP_LPVOID lpContext;
189  APP_DWORD dwApi;
190  APP_WORD wSlot;
191  APP_WORD wSubSlot;
192 
193 }ST_INPUT_PARAM, APP_FAR * LPST_INPUT_PARAM;
194 
195 #define ST_INPUT_PARAM_SIZEOF sizeof(ST_INPUT_PARAM)
196 
197 
198 typedef struct _ST_SET_PARAM{
199 
200  LPST_DREP lpstDrep;
201  APP_LPVOID lpContext;
202  APP_DWORD dwDataSize;
203  APP_DWORD dwApi;
204  APP_WORD wSlot;
205  APP_WORD wSubSlot;
206  APP_BYTE byIOXS;
207  APP_BYTE byData[MAX_DATA_FRAME_IO];
208 
209 }ST_SET_PARAM, APP_FAR * LPST_SET_PARAM;
210 
211 #define ST_SET_PARAM_SIZEOF sizeof(ST_SET_PARAM)
212 
213 
214 typedef struct _ST_HELLO_PARAMETERS{
215 
216  APP_BOOL bIsEnabled;
217  APP_BYTE byInitiaveValues;
218  APP_WORD wHelloInterval;
219  APP_WORD wHelloStartUpDelay;
220  APP_WORD wRetriesCount;
221 
223 
224 #define ST_HELLO_PARAMETERS_SIZEOF sizeof(ST_HELLO_PARAMETERS)
225 
226 
227 /* Define ioxs */
228 #define PND_IOCS_OK 0x80
229 #define PND_IOCS_NOT_OK 0x00
230 
231 #define PND_IOPS_OK 0x80
232 #define PND_IOPS_NOT_OK 0x00
233 
234 #endif/*End of stackdev_H */
Definition: stackdev.h:214
Definition: stackdev.h:198
Definition: stackdev.h:157
Definition: stackdev.h:168
Definition: stackdev.h:185