• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2 
3   (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4       www.systec-electronic.com
5 
6   Project:      openPOWERLINK
7 
8   Description:  global include file for EPL-NMT-Modules
9 
10   License:
11 
12     Redistribution and use in source and binary forms, with or without
13     modification, are permitted provided that the following conditions
14     are met:
15 
16     1. Redistributions of source code must retain the above copyright
17        notice, this list of conditions and the following disclaimer.
18 
19     2. Redistributions in binary form must reproduce the above copyright
20        notice, this list of conditions and the following disclaimer in the
21        documentation and/or other materials provided with the distribution.
22 
23     3. Neither the name of SYSTEC electronic GmbH nor the names of its
24        contributors may be used to endorse or promote products derived
25        from this software without prior written permission. For written
26        permission, please contact info@systec-electronic.com.
27 
28     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32     COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39     POSSIBILITY OF SUCH DAMAGE.
40 
41     Severability Clause:
42 
43         If a provision of this License is or becomes illegal, invalid or
44         unenforceable in any jurisdiction, that shall not affect:
45         1. the validity or enforceability in that jurisdiction of any other
46            provision of this License; or
47         2. the validity or enforceability in other jurisdictions of that or
48            any other provision of this License.
49 
50   -------------------------------------------------------------------------
51 
52                 $RCSfile: EplNmt.h,v $
53 
54                 $Author: D.Krueger $
55 
56                 $Revision: 1.6 $  $Date: 2008/11/17 16:40:39 $
57 
58                 $State: Exp $
59 
60                 Build Environment:
61                     GCC V3.4
62 
63   -------------------------------------------------------------------------
64 
65   Revision History:
66 
67   2006/06/09 k.t.:   start of the implementation
68 
69 ****************************************************************************/
70 
71 #ifndef _EPLNMT_H_
72 #define _EPLNMT_H_
73 
74 #include "EplInc.h"
75 
76 //---------------------------------------------------------------------------
77 // const defines
78 //---------------------------------------------------------------------------
79 
80 // define super-states and masks to identify a super-state
81 #define EPL_NMT_GS_POWERED          0x0008	// super state
82 #define EPL_NMT_GS_INITIALISATION   0x0009	// super state
83 #define EPL_NMT_GS_COMMUNICATING    0x000C	// super state
84 #define EPL_NMT_CS_EPLMODE          0x000D	// super state
85 #define EPL_NMT_MS_EPLMODE          0x000D	// super state
86 
87 #define EPL_NMT_SUPERSTATE_MASK     0x000F	// mask to select state
88 
89 #define EPL_NMT_TYPE_UNDEFINED      0x0000	// type of NMT state is still undefined
90 #define EPL_NMT_TYPE_CS             0x0100	// CS type of NMT state
91 #define EPL_NMT_TYPE_MS             0x0200	// MS type of NMT state
92 #define EPL_NMT_TYPE_MASK           0x0300	// mask to select type of NMT state (i.e. CS or MS)
93 
94 //---------------------------------------------------------------------------
95 // typedef
96 //---------------------------------------------------------------------------
97 
98 // the lower Byte of the NMT-State is encoded
99 // like the values in the EPL-Standard
100 // the higher byte is used to encode MN
101 // (Bit 1 of the higher byte = 1) or CN (Bit 0 of the
102 // higher byte  = 1)
103 // the super-states are not mentioned in this
104 // enum because they are no real states
105 // --> there are masks defined to indentify the
106 // super-states
107 
108 typedef enum {
109 	kEplNmtGsOff = 0x0000,
110 	kEplNmtGsInitialising = 0x0019,
111 	kEplNmtGsResetApplication = 0x0029,
112 	kEplNmtGsResetCommunication = 0x0039,
113 	kEplNmtGsResetConfiguration = 0x0079,
114 	kEplNmtCsNotActive = 0x011C,
115 	kEplNmtCsPreOperational1 = 0x011D,
116 	kEplNmtCsStopped = 0x014D,
117 	kEplNmtCsPreOperational2 = 0x015D,
118 	kEplNmtCsReadyToOperate = 0x016D,
119 	kEplNmtCsOperational = 0x01FD,
120 	kEplNmtCsBasicEthernet = 0x011E,
121 	kEplNmtMsNotActive = 0x021C,
122 	kEplNmtMsPreOperational1 = 0x021D,
123 	kEplNmtMsPreOperational2 = 0x025D,
124 	kEplNmtMsReadyToOperate = 0x026D,
125 	kEplNmtMsOperational = 0x02FD,
126 	kEplNmtMsBasicEthernet = 0x021E
127 } tEplNmtState;
128 
129 // NMT-events
130 typedef enum {
131 	// Events from DLL
132 	// Events defined by EPL V2 specification
133 	kEplNmtEventNoEvent = 0x00,
134 //    kEplNmtEventDllMePres           =   0x01,
135 	kEplNmtEventDllMePresTimeout = 0x02,
136 //    kEplNmtEventDllMeAsnd           =   0x03,
137 //    kEplNmtEventDllMeAsndTimeout    =   0x04,
138 	kEplNmtEventDllMeSoaSent = 0x04,
139 	kEplNmtEventDllMeSocTrig = 0x05,
140 	kEplNmtEventDllMeSoaTrig = 0x06,
141 	kEplNmtEventDllCeSoc = 0x07,
142 	kEplNmtEventDllCePreq = 0x08,
143 	kEplNmtEventDllCePres = 0x09,
144 	kEplNmtEventDllCeSoa = 0x0A,
145 	kEplNmtEventDllCeAsnd = 0x0B,
146 	kEplNmtEventDllCeFrameTimeout = 0x0C,
147 
148 	// Events triggered by NMT-Commands
149 	kEplNmtEventSwReset = 0x10,	// NMT_GT1, NMT_GT2, NMT_GT8
150 	kEplNmtEventResetNode = 0x11,
151 	kEplNmtEventResetCom = 0x12,
152 	kEplNmtEventResetConfig = 0x13,
153 	kEplNmtEventEnterPreOperational2 = 0x14,
154 	kEplNmtEventEnableReadyToOperate = 0x15,
155 	kEplNmtEventStartNode = 0x16,	// NMT_CT7
156 	kEplNmtEventStopNode = 0x17,
157 
158 	// Events triggered by higher layer
159 	kEplNmtEventEnterResetApp = 0x20,
160 	kEplNmtEventEnterResetCom = 0x21,
161 	kEplNmtEventInternComError = 0x22,	// NMT_GT6, internal communication error -> enter ResetCommunication
162 	kEplNmtEventEnterResetConfig = 0x23,
163 	kEplNmtEventEnterCsNotActive = 0x24,
164 	kEplNmtEventEnterMsNotActive = 0x25,
165 	kEplNmtEventTimerBasicEthernet = 0x26,	// NMT_CT3; timer triggered state change (NotActive -> BasicEth)
166 	kEplNmtEventTimerMsPreOp1 = 0x27,	// enter PreOp1 on MN (NotActive -> MsPreOp1)
167 	kEplNmtEventNmtCycleError = 0x28,	// NMT_CT11, NMT_MT6; error during cycle -> enter PreOp1
168 	kEplNmtEventTimerMsPreOp2 = 0x29,	// enter PreOp2 on MN (MsPreOp1 -> MsPreOp2 if kEplNmtEventAllMandatoryCNIdent)
169 	kEplNmtEventAllMandatoryCNIdent = 0x2A,	// enter PreOp2 on MN if kEplNmtEventTimerMsPreOp2
170 	kEplNmtEventEnterReadyToOperate = 0x2B,	// application ready for the state ReadyToOp
171 	kEplNmtEventEnterMsOperational = 0x2C,	// enter Operational on MN
172 	kEplNmtEventSwitchOff = 0x2D,	// enter state Off
173 	kEplNmtEventCriticalError = 0x2E,	// enter state Off because of critical error
174 
175 } tEplNmtEvent;
176 
177 // type for argument of event kEplEventTypeNmtStateChange
178 typedef struct {
179 	tEplNmtState m_NewNmtState;
180 	tEplNmtEvent m_NmtEvent;
181 
182 } tEplEventNmtStateChange;
183 
184 // structure for kEplEventTypeHeartbeat
185 typedef struct {
186 	unsigned int m_uiNodeId;	// NodeId
187 	tEplNmtState m_NmtState;	// NMT state (remember distinguish between MN / CN)
188 	WORD m_wErrorCode;	// EPL error code in case of NMT state NotActive
189 
190 } tEplHeartbeatEvent;
191 
192 typedef enum {
193 	kEplNmtNodeEventFound = 0x00,
194 	kEplNmtNodeEventUpdateSw = 0x01,	// application shall update software on CN
195 	kEplNmtNodeEventCheckConf = 0x02,	// application / Configuration Manager shall check and update configuration on CN
196 	kEplNmtNodeEventUpdateConf = 0x03,	// application / Configuration Manager shall update configuration on CN (check was done by NmtMn module)
197 	kEplNmtNodeEventVerifyConf = 0x04,	// application / Configuration Manager shall verify configuration of CN
198 	kEplNmtNodeEventReadyToStart = 0x05,	// issued if EPL_NMTST_NO_STARTNODE set
199 	// application must call EplNmtMnuSendNmtCommand(kEplNmtCmdStartNode) manually
200 	kEplNmtNodeEventNmtState = 0x06,
201 	kEplNmtNodeEventError = 0x07,	// NMT error of CN
202 
203 } tEplNmtNodeEvent;
204 
205 typedef enum {
206 	kEplNmtNodeCommandBoot = 0x01,	// if EPL_NODEASSIGN_START_CN not set it must be issued after kEplNmtNodeEventFound
207 	kEplNmtNodeCommandSwOk = 0x02,	// application updated software on CN successfully
208 	kEplNmtNodeCommandSwUpdated = 0x03,	// application updated software on CN successfully
209 	kEplNmtNodeCommandConfOk = 0x04,	// application / Configuration Manager has updated configuration on CN successfully
210 	kEplNmtNodeCommandConfReset = 0x05,	// application / Configuration Manager has updated configuration on CN successfully
211 	// and CN needs ResetConf so that the configuration gets actived
212 	kEplNmtNodeCommandConfErr = 0x06,	// application / Configuration Manager failed on updating configuration on CN
213 	kEplNmtNodeCommandStart = 0x07,	// if EPL_NMTST_NO_STARTNODE set it must be issued after kEplNmtNodeEventReadyToStart
214 
215 } tEplNmtNodeCommand;
216 
217 typedef enum {
218 	kEplNmtBootEventBootStep1Finish = 0x00,	// PreOp2 is possible
219 	kEplNmtBootEventBootStep2Finish = 0x01,	// ReadyToOp is possible
220 	kEplNmtBootEventCheckComFinish = 0x02,	// Operational is possible
221 	kEplNmtBootEventOperational = 0x03,	// all mandatory CNs are Operational
222 	kEplNmtBootEventError = 0x04,	// boot process halted because of an error
223 
224 } tEplNmtBootEvent;
225 
226 //---------------------------------------------------------------------------
227 // function prototypes
228 //---------------------------------------------------------------------------
229 
230 #endif // #ifndef _EPLNMT_H_
231