versadac  1
versadac - Scalable Recorder Firmware
dua.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:: dua.h $*/
16 /* $Revision:: 5 $*/
17 /* $Date:: 11/08/10 9:33 $*/
18 /* */
19 /*---------------------------------------------------------------------------*/
20 /* */
21 /* D e s c r i p t i o n : DUA Management */
22 /* */
23 /* 10/04/2012 (KW) - Created to provide support for the SDR Device */
24 /* */
25 /*---------------------------------------------------------------------------*/
26 #ifndef _DUA_H
27 #define _DUA_H
28 
29 #include "duauser.h"
30 
31 // This is the highest level DUA context and connection information structure
32 typedef struct _dua_information
33 {
34  LPST_AREP lpstArep;
35  APP_DWORD dwDUAState;
36  APP_BYTE byNumArep;
37  APP_BYTE byContexte;
38 
40 
41 /***************************************************************************************/
42 /* The next 3 structures are used by the DUA application code to interace with the SDR */
43 /* it can be changed to support any product, in this case it has been modified */
44 /* to support the SDR product, it MUST match the structures in ProfinetIO_interface.h */
45 /***************************************************************************************/
46 typedef struct _alm_trigger
47 {
48  APP_BYTE byActive;
49  APP_BYTE byTriggered;
50  APP_BYTE byAck;
51 
52 } ALARM_CONF;
53 
54 typedef struct _subslot_conf
55 {
56  APP_DWORD dwApi; // API index
57  APP_DWORD dwModuleId; // Module id
58  APP_DWORD dwSubModuleId; // Submodule id
59  APP_WORD wSize; // Data size in bytes
60  APP_WORD wSlot; // Slot number
61  APP_WORD wSubSlot; // Sub slot number
62  APP_BYTE byIO; // INPUT_DATA or OUTPUT_DATA or both in controller view !!!!!!!!!
63  APP_BYTE byModuleType; // The enumeration type of the expected module
64  APP_FLOAT dwValue; // Current process value for this module/channel
65  APP_BYTE byStatus; // Current process value status for this module/channel
66  ALARM_CONF stAlarm[PND_MAX_NO_OF_ALARMS]; // Indicates that there is a new alarm on this sub slot
67 
69 
70 typedef struct _device_configuration
71 {
72  APP_DWORD dwVersion;
73  APP_DWORD dwIpAddress; // IP adress of the device
74  APP_DWORD dwSubNetMask; // Subnet mask
75  APP_DWORD dwGateway; // Gateway
76  APP_DWORD dwNbMaxSlot; // Number of sub slots in ArrayOfstSSlot
77 
78  ST_PND_SUB_SLOT_CONF *ArrayOfstSSlot; // Array of sub slots for the current configuration
79 
80  APP_LPCHAR lpsInterfaceName; // Interface Name: stack will use this parameter in the HW_OpenRead/HW_OpenWrite function
81  APP_WORD wDeviceID; // Device ID
82  APP_WORD wVendorID; // Vendor ID
83  APP_WORD wInstance; // Instance use for this device ID (for now should be 1)
84  APP_WORD wPort; // Interface Number: this number is use as parameter for this HW_SetSeletedDevice function
85 
86  APP_CHAR lpbyDeviceType[NAMELEN]; // Type of the device
87  APP_CHAR sName[NAMELEN]; // Name of the device: the name size must be lower than NAMELEN (240)
88 
89  APP_CHAR sDHCPparameter[NAMELEN]; // Name of DHCP use : the name size must be lower than NAMELEN (240)
90  APP_WORD wDHCPType; // Can be set to either PND_DHCP_ARBITRARY, PND_DHCP_MAC or PND_DHCP_NAME_OF_STATION
91  APP_WORD wIpMode; // Can be set to either PND_IP_STATIC or PND_IP_DHCP
92  APP_WORD byActualSubSlot; // The index into ArrayOfstSSlot array that we should start uplling/plugging sub slots
93  APP_BYTE byPullPlug; // Indicates if pull, plug or both
94  APP_BYTE byDeviceStatus; // Current stack device status
95 
96  ST_PND_SUB_SLOT_CONF PullSlot[PND_MAX_NO_OF_SUBLOSTS]; // Information required for a dynamic pull/plug of an entire sub slot set
97 
98 } ST_PND_CONF, APP_FAR *LPST_PND_CONF;
99 /******************************************************************************************/
100 
101 // Functions
102 APP_DWORD DuaInitProfinetStackDevice (LPST_DREP * z_lppPhysicalDevice, LPST_IREP * z_lppLogivalDevice, LPST_PND_CONF z_lpstConf, APP_LPBYTE z_lpbyContexteD, APP_LPBYTE z_lpbyContexteI);
103 APP_DWORD DuaPlugConfiguration (LPST_IREP z_lpLogivalDevice, LPST_PND_CONF z_lpstConf, APP_LPBYTE z_lpbyContext);
104 APP_DWORD DuaPullConfiguration (LPST_IREP z_lpLogivalDevice, LPST_PND_CONF z_lpstConf, APP_LPBYTE z_lpbyContext);
105 
106 APP_WORD DuaConnectionClosed (APP_VOID);
107 APP_WORD DuaConnectionOpened (APP_WORD z_wARType, APP_LPBYTE z_lpbyCMI_Mac, APP_LPBYTE z_lpbyCMI_Name, APP_WORD z_wCMI_Name_Len, APP_DWORD z_dwIPAddr);
108 APP_DWORD DuaGetInputDataFromNetwork (LPST_PND_DUA_INFO z_lpStDuaInfo, LPST_PND_CONF z_lpstConf);
109 APP_DWORD DuaSetOutputDataToNetwork (LPST_PND_DUA_INFO z_lpStDuaInfo, LPST_PND_CONF z_lpstConf);
110 APP_DWORD DuaSetAlarmsToNetwork (LPST_PND_DUA_INFO z_lpStDuaInfo, LPST_PND_CONF z_lpstConf);
111 APP_WORD DuaUserPlugPull (LPST_IREP z_lpLogicalDevice, LPST_PND_CONF z_lpstConf);
112 APP_WORD DuaSendProcessAlm (APP_LPVOID z_lpContext, LPST_IREP z_lpLogicalDevice, APP_WORD z_wSlot, APP_WORD z_wSubSlot);
113 APP_VOID DuaBlinkLed (APP_VOID);
114 APP_WORD DuaChangeIp (APP_DWORD z_dwIp, APP_DWORD z_dwSubMask, APP_DWORD z_dwGateway, APP_BYTE z_byRemanent);
115 APP_WORD DuaChangeName (APP_LPCHAR z_lpDeviceName, APP_BYTE z_byRemanent);
116 APP_WORD DuaConfigMismatch (APP_WORD z_wSlot, APP_WORD z_wSubSlot, APP_DWORD z_dwRealModuleID, APP_DWORD z_dwExpectedModuleID, APP_DWORD z_dwRealSubModuleID, APP_DWORD z_dwExpectedSubmoduleID);
117 APP_WORD DuaNewInputData (APP_WORD z_wSlot, APP_WORD z_wSubSlot, APP_LPBYTE lpData, APP_WORD wDataLen, APP_BYTE byIOPS);
118 APP_WORD DuaGetEvent (APP_VOID);
119 APP_WORD DuaUserWriteProcessing (APP_DWORD z_dwARContextInd, APP_DWORD z_dwApi, APP_WORD z_wIndex, APP_WORD z_wSlot, APP_WORD z_wSubSlot, APP_DWORD z_dwSizeOfData, APP_LPBYTE z_lpbyData, LPST_PNIO_RW_STATUS z_lpStatus, APP_LPBYTE z_lpbyAddData1, APP_LPBYTE z_lpbyAddData2);
120 APP_WORD DuaUserReadProcessing (APP_DWORD z_dwARContextInd, APP_DWORD z_dwApi, APP_WORD z_wIndex, APP_WORD z_wSlot, APP_WORD z_wSubSlot, APP_LPDWORD z_lpdwSizeOfData, APP_LPBYTE z_lpbyData, LPST_PNIO_RW_STATUS z_lpStatus, APP_LPBYTE z_lpbyAddData1, APP_LPBYTE z_lpbyAddData2);
121 APP_WORD DuaUserAlarmAck (APP_WORD z_wSlot, APP_WORD z_wSubSlot, APP_WORD z_wStatus);
122 APP_WORD DuaUserAlarmRecieved (APP_WORD z_wSlot, APP_WORD z_wSubSlot, APP_WORD z_wAlarmType);
123 APP_DWORD DuaReleaseBuffer (LPST_PND_CONF z_lpstPndConfiguration);
124 APP_WORD DuaValidateIndexes (APP_WORD z_wSlot, APP_WORD z_wSubSlot);
125 
126 // Put the data for the given slot into this buffer, buffer is initialised with the size of PND_SIZEOF_INPUT_DATA
127 //#define PND_DUA_GET_INPUT_DATA(wSlot ,byData) OS_MEMSET(byData, gwCurrentData, PND_SIZEOF_OUTPUT_DATA)
128 
129 // This function is called by the default DUA. Data sent to this function is the output of the data
130 //#define PND_DUA_SET_OUTPUT_DATA(wSlot ,byData) /*printf("Slot %d -- Data %02x \n", wSlot, byData[0] ) Nothing, because printing this informations is to long */
131 
132 // The context used to recover information when we update data
133 typedef struct _context_input_output
134 {
135  APP_DWORD API;
136  APP_WORD Slot;
137  APP_WORD SubSlot;
138  APP_BYTE byRequestFinish;
139  APP_BYTE byAPDUStatus;
140 
142 
143 #include "os_pck.h"
144 
145 #define IM_Tag_Function_LEN 32
146 #define IM_Tag_Location_LEN 22
147 #define IM_Descriptor_LEN 54
148 #define IM_Signature_LEN 54
149 
150 // Declaration of IM1 structure as defined in Profinet IO specification V2.1
151 // Visible string elements shall be filled with blanks if shorter than defined length
152 struct _ST_IM1
153 {
154  APP_WORD wBlocType;
155  APP_WORD wBlocLen;
156  APP_BYTE byVersionHigh;
157  APP_BYTE byVersionLow;
158  APP_BYTE IM_Tag_Function[IM_Tag_Function_LEN];
159  APP_BYTE IM_Tag_Location[IM_Tag_Location_LEN];
160 
161 } STRUCT_ALIGNEMENT;
162 
163 typedef struct _ST_IM1 PACK_ALIGNEMENT(ST_IM1), APP_FAR * LPST_IM1;
164 
165 #define IM_Date_LEN 16
166 // Declaration of IM2 structure as defined in Profinet IO specification V2.1
167 // Visible string elements shall be filled with blanks if shorter than defined length
168 struct _ST_IM2
169 {
170  APP_WORD wBlocType;
171  APP_WORD wBlocLen;
172  APP_BYTE byVersionHigh;
173  APP_BYTE byVersionLow;
174  APP_BYTE IM_Date[IM_Date_LEN];
175 
176 } STRUCT_ALIGNEMENT;
177 
178 typedef struct _ST_IM2 PACK_ALIGNEMENT(ST_IM2), APP_FAR * LPST_IM2;
179 
180 // Declaration of IM3 structure as defined in Profinet IO specification V2.1
181 // Visible string elements shall be filled with blanks if shorter than defined length
182 struct _ST_IM3
183 {
184  APP_WORD wBlocType;
185  APP_WORD wBlocLen;
186  APP_BYTE byVersionHigh;
187  APP_BYTE byVersionLow;
188  APP_BYTE IM_Descriptor[IM_Descriptor_LEN];
189 
190 } STRUCT_ALIGNEMENT;
191 
192 typedef struct _ST_IM3 PACK_ALIGNEMENT(ST_IM3), APP_FAR * LPST_IM3;
193 
194 // Declaration of IM4 structure as defined in Profinet IO specification V2.1
195 // Visible string elements shall be filled with blanks if shorter than defined length
196 struct _ST_IM4
197 {
198  APP_WORD wBlocType;
199  APP_WORD wBlocLen;
200  APP_BYTE byVersionHigh;
201  APP_BYTE byVersionLow;
202  APP_BYTE IM_Signature[IM_Signature_LEN];
203 
204 } STRUCT_ALIGNEMENT;
205 
206 typedef struct _ST_IM4 PACK_ALIGNEMENT(ST_IM4), APP_FAR * LPST_IM4;
207 
208 #include "os_unpck.h"
209 #endif
Definition: dua.h:133
Definition: pncbdev.h:35
Definition: dua.h:32
Definition: dua.h:182
Definition: dua.h:46
Definition: dua.h:152
Definition: dua.h:196
Definition: dua.h:70
Definition: dua.h:54
Definition: dua.h:168