The goal of this software is to automatically generate C/C++ code which reads and writes GOOSE and Sampled Value packets. Any valid IEC 61850 Substation Configuration Description (SCD) file, describing GOOSE and/or SV communications, can be used as the input. The output code is lightweight and platform-independent, so it can run on a variety of devices, including low-cost microcontrollers. It\'s ideal for rapid-prototyping new protection and control systems that require communications. This mbed project is a simple example of this functionality. Other code: https://github.com/stevenblair/rapid61850 Project homepage: http://personal.strath.ac.uk/steven.m.blair/

Committer:
sblair
Date:
Fri Oct 07 13:41:08 2011 +0000
Revision:
0:230c10b228ea
Child:
1:9399d44c2b1a

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sblair 0:230c10b228ea 1 #include "ctypes.h"
sblair 0:230c10b228ea 2 #include "datatypes.h"
sblair 0:230c10b228ea 3 #include "ied.h"
sblair 0:230c10b228ea 4 #include "svDecodeBasic.h"
sblair 0:230c10b228ea 5 #include <string.h>
sblair 0:230c10b228ea 6
sblair 0:230c10b228ea 7 // SV encoding of basic types
sblair 0:230c10b228ea 8 int DECODE_CTYPE_FLOAT32(unsigned char *buf, CTYPE_FLOAT32 *value) {
sblair 0:230c10b228ea 9 netmemcpy(value, buf, SV_GET_LENGTH_FLOAT32);
sblair 0:230c10b228ea 10
sblair 0:230c10b228ea 11 return SV_GET_LENGTH_FLOAT32;
sblair 0:230c10b228ea 12 }
sblair 0:230c10b228ea 13 int DECODE_CTYPE_FLOAT64(unsigned char *buf, CTYPE_FLOAT64 *value) {
sblair 0:230c10b228ea 14 netmemcpy(value, buf, SV_GET_LENGTH_FLOAT64);
sblair 0:230c10b228ea 15
sblair 0:230c10b228ea 16 return SV_GET_LENGTH_FLOAT64;
sblair 0:230c10b228ea 17 }
sblair 0:230c10b228ea 18 int DECODE_CTYPE_QUALITY(unsigned char *buf, CTYPE_QUALITY *value) {
sblair 0:230c10b228ea 19 netmemcpy(value, buf, SV_GET_LENGTH_QUALITY);
sblair 0:230c10b228ea 20
sblair 0:230c10b228ea 21 return SV_GET_LENGTH_QUALITY;
sblair 0:230c10b228ea 22 }
sblair 0:230c10b228ea 23 int DECODE_CTYPE_TIMESTAMP(unsigned char *buf, CTYPE_TIMESTAMP *value) {
sblair 0:230c10b228ea 24 netmemcpy(value, buf, SV_GET_LENGTH_TIMESTAMP);
sblair 0:230c10b228ea 25
sblair 0:230c10b228ea 26 return SV_GET_LENGTH_TIMESTAMP;
sblair 0:230c10b228ea 27 }
sblair 0:230c10b228ea 28 int DECODE_CTYPE_ENUM(unsigned char *buf, CTYPE_ENUM *value) { // assuming enum is an int - allows any enum type to be used
sblair 0:230c10b228ea 29 netmemcpy(value, buf, SV_GET_LENGTH_ENUM);
sblair 0:230c10b228ea 30
sblair 0:230c10b228ea 31 return SV_GET_LENGTH_ENUM;
sblair 0:230c10b228ea 32 }
sblair 0:230c10b228ea 33 int DECODE_CTYPE_INT16(unsigned char *buf, CTYPE_INT16 *value) {
sblair 0:230c10b228ea 34 netmemcpy(value, buf, SV_GET_LENGTH_INT16);
sblair 0:230c10b228ea 35
sblair 0:230c10b228ea 36 return SV_GET_LENGTH_INT16;
sblair 0:230c10b228ea 37 }
sblair 0:230c10b228ea 38 int DECODE_CTYPE_INT32(unsigned char *buf, CTYPE_INT32 *value) {
sblair 0:230c10b228ea 39 netmemcpy(value, buf, SV_GET_LENGTH_INT32);
sblair 0:230c10b228ea 40
sblair 0:230c10b228ea 41 return SV_GET_LENGTH_INT32;
sblair 0:230c10b228ea 42 }
sblair 0:230c10b228ea 43 int DECODE_CTYPE_INT16U(unsigned char *buf, CTYPE_INT16U *value) {
sblair 0:230c10b228ea 44 netmemcpy(value, buf, SV_GET_LENGTH_INT16U);
sblair 0:230c10b228ea 45
sblair 0:230c10b228ea 46 return SV_GET_LENGTH_INT16U;
sblair 0:230c10b228ea 47 }
sblair 0:230c10b228ea 48 int DECODE_CTYPE_INT32U(unsigned char *buf, CTYPE_INT32U *value) {
sblair 0:230c10b228ea 49 netmemcpy(value, buf, SV_GET_LENGTH_INT32U);
sblair 0:230c10b228ea 50
sblair 0:230c10b228ea 51 return SV_GET_LENGTH_INT32U;
sblair 0:230c10b228ea 52 }
sblair 0:230c10b228ea 53 int DECODE_CTYPE_VISSTRING255(unsigned char *buf, CTYPE_VISSTRING255 *value) {
sblair 0:230c10b228ea 54 netmemcpy(value, buf, SV_GET_LENGTH_VISSTRING255);
sblair 0:230c10b228ea 55
sblair 0:230c10b228ea 56 return SV_GET_LENGTH_VISSTRING255;
sblair 0:230c10b228ea 57 }
sblair 0:230c10b228ea 58 int DECODE_CTYPE_BOOLEAN(unsigned char *buf, CTYPE_BOOLEAN *value) {
sblair 0:230c10b228ea 59 netmemcpy(value, buf, SV_GET_LENGTH_BOOLEAN);
sblair 0:230c10b228ea 60
sblair 0:230c10b228ea 61 return SV_GET_LENGTH_BOOLEAN;
sblair 0:230c10b228ea 62 }
sblair 0:230c10b228ea 63 int DECODE_CTYPE_DBPOS(unsigned char *buf, CTYPE_DBPOS *value) {
sblair 0:230c10b228ea 64 netmemcpy(value, buf, SV_GET_LENGTH_DBPOS);
sblair 0:230c10b228ea 65
sblair 0:230c10b228ea 66 return SV_GET_LENGTH_DBPOS;
sblair 0:230c10b228ea 67 }