libIEC61850  0.8.0
Open-source IEC 61850 MMS/GOOSE server and client library
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
model.h
Go to the documentation of this file.
1 /*
2  * model.h
3  *
4  * Copyright 2013 Michael Zillgith
5  *
6  * This file is part of libIEC61850.
7  *
8  * libIEC61850 is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * libIEC61850 is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * See COPYING file for the complete license text.
22  */
23 
24 #ifndef MODEL_H_
25 #define MODEL_H_
26 
27 #include "iec61850_common.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
46 typedef struct sModelNode ModelNode;
47 
51 typedef struct sDataAttribute DataAttribute;
52 
56 typedef struct sDataObject DataObject;
57 
61 typedef struct sLogicalNode LogicalNode;
62 
66 typedef struct sLogicalDevice LogicalDevice;
67 
71 typedef struct sIedModel IedModel;
72 
73 typedef struct sDataSet DataSet;
74 typedef struct sReportControlBlock ReportControlBlock;
75 typedef struct sGSEControlBlock GSEControlBlock;
76 
77 
78 typedef enum {
79  BOOLEAN = 0,/* int */
80  INT8 = 1, /* int8_t */
81  INT16 = 2, /* int16_t */
82  INT32 = 3, /* int32_t */
83  INT64 = 4, /* int64_t */
84  INT128 = 5, /* no native mapping! */
85  INT8U = 6, /* uint8_t */
86  INT16U = 7, /* uint16_t */
87  INT24U = 8, /* uint32_t */
88  INT32U = 9, /* uint32_t */
89  FLOAT32 = 10, /* float */
90  FLOAT64 = 11, /* double */
91  ENUMERATED = 12,
101  TIMESTAMP = 22,
102  QUALITY = 23,
103  CHECK = 24,
104  CODEDENUM = 25,
110 
111 typedef enum {
116 } ModelNodeType;
117 
118 struct sIedModel {
119  char* name;
120  LogicalDevice* firstChild;
121  DataSet* dataSets;
122  ReportControlBlock* rcbs;
123  GSEControlBlock* gseCBs;
124  void (*initializer) (void);
125 };
126 
129  char* name;
130  ModelNode* parent;
131  ModelNode* sibling;
132  ModelNode* firstChild;
133 };
134 
135 struct sModelNode {
137  char* name;
138  ModelNode* parent;
139  ModelNode* sibling;
140  ModelNode* firstChild;
141 };
142 
143 struct sLogicalNode {
145  char* name;
146  ModelNode* parent;
147  ModelNode* sibling;
148  ModelNode* firstChild;
149 };
150 
151 struct sDataObject {
153  char* name;
154  ModelNode* parent;
155  ModelNode* sibling;
156  ModelNode* firstChild;
157 
158  int elementCount; /* > 0 if this is an array */
159 };
160 
163  char* name;
164  ModelNode* parent;
165  ModelNode* sibling;
166  ModelNode* firstChild;
167 
168  int elementCount; /* > 0 if this is an array */
169 
172 
173  uint8_t triggerOptions; /* TRG_OPT_DATA_CHANGED | TRG_OPT_QUALITY_CHANGED | TRG_OPT_DATA_UPDATE */
174 
176 
177  uint32_t sAddr;
178 };
179 
180 typedef struct sDataSetEntry {
183  int index;
186  struct sDataSetEntry* sibling;
187 } DataSetEntry;
188 
189 struct sDataSet {
191  char* name; /* eg. MMXU1$dataset1 */
194  DataSet* sibling;
195 };
196 
198  LogicalNode* parent;
199  char* name;
200  char* rptId;
201  bool buffered;
202  char* dataSetName; /* pre loaded with relative name in logical node */
203 
204  uint32_t confRef; /* ConfRef - configuration revision */
205  uint8_t trgOps; /* TrgOps - trigger conditions */
206  uint8_t options; /* OptFlds */
207  uint32_t bufferTime; /* BufTm - time to buffer events until a report is generated */
208  uint32_t intPeriod; /* IntgPd - integrity period */
209 
210  ReportControlBlock* sibling; /* next control block in list or NULL if this is the last entry */
211 };
212 
213 typedef struct {
214  uint8_t vlanPriority;
215  uint16_t vlanId;
216  uint16_t appId;
217  uint8_t dstAddress[6];
218 } PhyComAddress;
219 
221  LogicalNode* parent;
222  char* name;
223  char* appId;
224  char* dataSetName; /* pre loaded with relative name in logical node */
225  uint32_t confRef; /* ConfRef - configuration revision */
226  bool fixedOffs; /* fixed offsets */
227  PhyComAddress* address; /* GSE communication parameters */
228 
229  GSEControlBlock* sibling; /* next control block in list or NULL if this is the last entry */
230 };
231 
240 int
241 ModelNode_getChildCount(ModelNode* modelNode);
242 
251 ModelNode*
252 ModelNode_getChild(ModelNode* modelNode, const char* name);
253 
263 char*
264 ModelNode_getObjectReference(ModelNode* node, char* objectReference);
265 
278 ModelNode*
279 IedModel_getModelNodeByObjectReference(IedModel* model, const char* objectReference);
280 
293 ModelNode*
294 IedModel_getModelNodeByShortObjectReference(IedModel* model, const char* objectReference);
295 
307 ModelNode*
308 IedModel_getModelNodeByShortAddress(IedModel* model, uint32_t shortAddress);
309 
310 LogicalNode*
311 LogicalDevice_getLogicalNode(LogicalDevice* device, const char* nodeName);
312 
323 void
324 IedModel_setAttributeValuesToNull(IedModel* iedModel);
325 
326 LogicalDevice*
327 IedModel_getDevice(IedModel* model, const char* deviceName);
328 
329 /*
330  * \param dataSetReference MMS mapping object reference! e.g. ied1Inverter/LLN0$dataset1
331  */
332 DataSet*
333 IedModel_lookupDataSet(IedModel* model, const char* dataSetReference);
334 
335 int
336 IedModel_getLogicalDeviceCount(IedModel* iedModel);
337 
338 int
339 LogicalDevice_getLogicalNodeCount(LogicalDevice* logicalDevice);
340 
341 bool
342 LogicalNode_hasFCData(LogicalNode* node, FunctionalConstraint fc);
343 
344 bool
345 LogicalNode_hasBufferedReports(LogicalNode* node);
346 
347 bool
348 LogicalNode_hasUnbufferedReports(LogicalNode* node);
349 
350 bool
351 DataObject_hasFCData(DataObject* dataObject, FunctionalConstraint fc);
352 
353 DataAttribute*
354 IedModel_lookupDataAttributeByMmsValue(IedModel* model, MmsValue* value);
355 
356 #ifdef __cplusplus
357 }
358 #endif
359 
360 
361 #endif /* MODEL_H_ */