• 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:  include file for Epl Configuration Manager Module
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: EplCfgMau.h,v $
53 
54                 $Author: D.Krueger $
55 
56                 $Revision: 1.4 $  $Date: 2008/10/17 15:32:32 $
57 
58                 $State: Exp $
59 
60                 Build Environment:
61                 VC7
62 
63   -------------------------------------------------------------------------
64 
65   Revision History:
66 
67   2006/07/14 k.t.:   start of the implementation
68                      -> based on CANopen CfgMa-Modul (CANopen version 5.34)
69 
70 ****************************************************************************/
71 
72 #include "../EplInc.h"
73 
74 #ifndef _EPLCFGMA_H_
75 #define _EPLCFGMA_H_
76 
77 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFGMA)) != 0)
78 
79 #include "EplObdu.h"
80 #include "EplSdoComu.h"
81 
82 //---------------------------------------------------------------------------
83 // typedef
84 //---------------------------------------------------------------------------
85 //define max number of timeouts for configuration of 1 device
86 #define EPL_CFGMA_MAX_TIMEOUT   3
87 
88 //callbackfunction, called if configuration is finished
89 typedef void (PUBLIC * tfpEplCfgMaCb) (unsigned int uiNodeId_p,
90 				       tEplKernel Errorstate_p);
91 
92 //State for configuartion manager Statemachine
93 typedef enum {
94 	// general states
95 	kEplCfgMaIdle = 0x0000,	// Configurationsprocess
96 	// is idle
97 	kEplCfgMaWaitForSdocEvent = 0x0001,	// wait until the last
98 	// SDOC is finisched
99 	kEplCfgMaSkipMappingSub0 = 0x0002,	// write Sub0 of mapping
100 	// parameter with 0
101 
102 	kEplCfgMaFinished = 0x0004	// configuartion is finished
103 } tEplCfgState;
104 
105 typedef enum {
106 	kEplCfgMaDcfTypSystecSeg = 0x00,
107 	kEplCfgMaDcfTypConDcf = 0x01,
108 	kEplCfgMaDcfTypDcf = 0x02,	// not supported
109 	kEplCfgMaDcfTypXdc = 0x03	// not supported
110 } tEplCfgMaDcfTyp;
111 
112 typedef enum {
113 	kEplCfgMaCommon = 0,	// all other index
114 	kEplCfgMaPdoComm = 1,	// communication index
115 	kEplCfgMaPdoMapp = 2,	// mapping index
116 	kEplCfgMaPdoCommAfterMapp = 3,	// write PDO Cob-Id after mapping subindex 0(set PDO valid)
117 
118 } tEplCfgMaIndexType;
119 
120 //bitcoded answer about the last sdo transfer saved in m_SdocState
121 // also used to singal start of the State Maschine
122 typedef enum {
123 	kEplCfgMaSdocBusy = 0x00,	// SDOC activ
124 	kEplCfgMaSdocReady = 0x01,	// SDOC finished
125 	kEplCfgMaSdocTimeout = 0x02,	// SDOC Timeout
126 	kEplCfgMaSdocAbortReceived = 0x04,	// SDOC Abort, see Abortcode
127 	kEplCfgMaSdocStart = 0x08	// start State Mschine
128 } tEplSdocState;
129 
130 //internal structure (instancetable for modul configuration manager)
131 typedef struct {
132 	tEplCfgState m_CfgState;	// state of the configuration state maschine
133 	tEplSdoComConHdl m_SdoComConHdl;	// handle for sdo connection
134 	DWORD m_dwLastAbortCode;
135 	unsigned int m_uiLastIndex;	// last index of configuration, to compair with actual index
136 	BYTE *m_pbConcise;	// Ptr to concise DCF
137 	BYTE *m_pbActualIndex;	// Ptr to actual index in the DCF segment
138 	tfpEplCfgMaCb m_pfnCfgMaCb;	// Ptr to CfgMa Callback, is call if configuration finished
139 	tEplKernel m_EplKernelError;	// errorcode
140 	DWORD m_dwNumValueCopy;	// numeric values are copied in this variable
141 	unsigned int m_uiPdoNodeId;	// buffer for PDO node id
142 	BYTE m_bNrOfMappedObject;	// number of mapped objects
143 	unsigned int m_uiNodeId;	// Epl node addresse
144 	tEplSdocState m_SdocState;	// bitcoded state of the SDO transfer
145 	unsigned int m_uiLastSubIndex;	// last subindex of configuration
146 	BOOL m_fOneTranferOk;	// atleased one transfer was successful
147 	BYTE m_bEventFlag;	// for Eventsignaling to the State Maschine
148 	DWORD m_dwCntObjectInDcf;	// number of Objects in DCF
149 	tEplCfgMaIndexType m_SkipCfg;	// TRUE if a adsitional Configurationprocess
150 	// have to insert e.g. PDO-mapping
151 	WORD m_wTimeOutCnt;	// Timeout Counter, break configuration is
152 	// m_wTimeOutCnt == CFGMA_MAX_TIMEOUT
153 
154 } tEplCfgMaNode;
155 
156 //---------------------------------------------------------------------------
157 // function prototypes
158 //---------------------------------------------------------------------------
159 
160 //---------------------------------------------------------------------------
161 // Function:    EplCfgMaInit()
162 //
163 // Description: Function creates first instance of Configuration Manager
164 //
165 // Parameters:
166 //
167 // Returns:     tEplKernel              = error code
168 //---------------------------------------------------------------------------
169 tEplKernel PUBLIC EplCfgMaInit();
170 
171 //---------------------------------------------------------------------------
172 // Function:    EplCfgMaAddInstance()
173 //
174 // Description: Function creates additional instance of Configuration Manager
175 //
176 // Parameters:
177 //
178 // Returns:     tEplKernel              = error code
179 //---------------------------------------------------------------------------
180 tEplKernel PUBLIC EplCfgMaAddInstance();
181 
182 //---------------------------------------------------------------------------
183 // Function:    EplCfgMaDelInstance()
184 //
185 // Description: Function delete instance of Configuration Manager
186 //
187 // Parameters:
188 //
189 // Returns:     tEplKernel              = error code
190 //---------------------------------------------------------------------------
191 tEplKernel PUBLIC EplCfgMaDelInstance();
192 
193 //---------------------------------------------------------------------------
194 // Function:    EplCfgMaStartConfig()
195 //
196 // Description: Function starts the configuration process
197 //              initialization the statemachine for CfgMa- process
198 //
199 // Parameters:  uiNodeId_p              = NodeId of the node to configure
200 //              pbConcise_p             = pointer to DCF
201 //              fpCfgMaCb_p             = pointer to callback function (should not be NULL)
202 //              SizeOfConcise_p         = size of DCF in BYTE -> for future use
203 //              DcfType_p               = type of the DCF
204 //
205 // Returns:     tCopKernel              = error code
206 //---------------------------------------------------------------------------
207 tEplKernel PUBLIC EplCfgMaStartConfig(unsigned int uiNodeId_p,
208 				      BYTE * pbConcise_p,
209 				      tfpEplCfgMaCb fpCfgMaCb_p,
210 				      tEplObdSize SizeOfConcise_p,
211 				      tEplCfgMaDcfTyp DcfType_p);
212 
213 //---------------------------------------------------------------------------
214 // Function:    CfgMaStartConfigurationNode()
215 //
216 // Description: Function started the configuration process
217 //              with the DCF from according OD-entry Subindex == bNodeId_p
218 //
219 // Parameters:  uiNodeId_p              = NodeId of the node to configure
220 //              fpCfgMaCb_p             = pointer to callback function (should not be NULL)
221 //              DcfType_p               = type of the DCF
222 //
223 // Returns:     tCopKernel              = error code
224 //---------------------------------------------------------------------------
225 tEplKernel PUBLIC EplCfgMaStartConfigNode(unsigned int uiNodeId_p,
226 					  tfpEplCfgMaCb fpCfgMaCb_p,
227 					  tEplCfgMaDcfTyp DcfType_p);
228 
229 //---------------------------------------------------------------------------
230 // Function:    EplCfgMaStartConfigNodeDcf()
231 //
232 // Description: Function starts the configuration process
233 //              and links the configuration data to the OD
234 //
235 // Parameters:  uiNodeId_p              = NodeId of the node to configure
236 //              pbConcise_p             = pointer to DCF
237 //              fpCfgMaCb_p             = pointer to callback function (should not be NULL)
238 //              SizeOfConcise_p         = size of DCF in BYTE -> for future use
239 //              DcfType_p               = type of the DCF
240 //
241 // Returns:     tCopKernel              = error code
242 //---------------------------------------------------------------------------
243 tEplKernel PUBLIC EplCfgMaStartConfigNodeDcf(unsigned int uiNodeId_p,
244 					     BYTE * pbConcise_p,
245 					     tfpEplCfgMaCb fpCfgMaCb_p,
246 					     tEplObdSize SizeOfConcise_p,
247 					     tEplCfgMaDcfTyp DcfType_p);
248 
249 //---------------------------------------------------------------------------
250 // Function:    EplCfgMaLinkDcf()
251 //
252 // Description: Function links the configuration data to the OD
253 //
254 // Parameters:  uiNodeId_p              = NodeId of the node to configure
255 //              pbConcise_p             = pointer to DCF
256 //              SizeOfConcise_p        = size of DCF in BYTE -> for future use
257 //              DcfType_p               = type of the DCF
258 //
259 // Returns:     tCopKernel              = error code
260 //---------------------------------------------------------------------------
261 tEplKernel PUBLIC EplCfgMaLinkDcf(unsigned int uiNodeId_p,
262 				  BYTE * pbConcise_p,
263 				  tEplObdSize SizeOfConcise_p,
264 				  tEplCfgMaDcfTyp DcfType_p);
265 
266 //---------------------------------------------------------------------------
267 // Function:    EplCfgMaCheckDcf()
268 //
269 // Description: Function check if there is allready a configuration file linked
270 //              to the OD (type is given by DcfType_p)
271 //
272 // Parameters:  uiNodeId_p              = NodeId
273 //              DcfType_p               = type of the DCF
274 //
275 // Returns:     tCopKernel              = error code
276 //---------------------------------------------------------------------------
277 tEplKernel PUBLIC EplCfgMaCheckDcf(unsigned int uiNodeId_p,
278 				   tEplCfgMaDcfTyp DcfType_p);
279 
280 #endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFGMA)) != 0)
281 
282 #endif // _EPLCFGMA_H_
283 
284 // EOF
285