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:48:18 2011 +0000
Revision:
1:9399d44c2b1a
Parent:
0:230c10b228ea

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sblair 1:9399d44c2b1a 1 /**
sblair 1:9399d44c2b1a 2 * Rapid-prototyping protection schemes with IEC 61850
sblair 1:9399d44c2b1a 3 *
sblair 1:9399d44c2b1a 4 * Copyright (c) 2011 Steven Blair
sblair 1:9399d44c2b1a 5 *
sblair 1:9399d44c2b1a 6 * This program is free software; you can redistribute it and/or
sblair 1:9399d44c2b1a 7 * modify it under the terms of the GNU General Public License
sblair 1:9399d44c2b1a 8 * as published by the Free Software Foundation; either version 2
sblair 1:9399d44c2b1a 9 * of the License, or (at your option) any later version.
sblair 1:9399d44c2b1a 10
sblair 1:9399d44c2b1a 11 * This program is distributed in the hope that it will be useful,
sblair 1:9399d44c2b1a 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
sblair 1:9399d44c2b1a 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
sblair 1:9399d44c2b1a 14 * GNU General Public License for more details.
sblair 1:9399d44c2b1a 15
sblair 1:9399d44c2b1a 16 * You should have received a copy of the GNU General Public License
sblair 1:9399d44c2b1a 17 * along with this program; if not, write to the Free Software
sblair 1:9399d44c2b1a 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
sblair 1:9399d44c2b1a 19 */
sblair 1:9399d44c2b1a 20
sblair 0:230c10b228ea 21 #include "ctypes.h"
sblair 0:230c10b228ea 22 #include "datatypes.h"
sblair 0:230c10b228ea 23 #include "ied.h"
sblair 0:230c10b228ea 24 #include "svDecodeBasic.h"
sblair 0:230c10b228ea 25 #include <string.h>
sblair 0:230c10b228ea 26
sblair 0:230c10b228ea 27 // SV encoding of basic types
sblair 0:230c10b228ea 28 int DECODE_CTYPE_FLOAT32(unsigned char *buf, CTYPE_FLOAT32 *value) {
sblair 1:9399d44c2b1a 29 netmemcpy(value, buf, SV_GET_LENGTH_FLOAT32);
sblair 0:230c10b228ea 30
sblair 1:9399d44c2b1a 31 return SV_GET_LENGTH_FLOAT32;
sblair 0:230c10b228ea 32 }
sblair 0:230c10b228ea 33 int DECODE_CTYPE_FLOAT64(unsigned char *buf, CTYPE_FLOAT64 *value) {
sblair 1:9399d44c2b1a 34 netmemcpy(value, buf, SV_GET_LENGTH_FLOAT64);
sblair 0:230c10b228ea 35
sblair 1:9399d44c2b1a 36 return SV_GET_LENGTH_FLOAT64;
sblair 0:230c10b228ea 37 }
sblair 0:230c10b228ea 38 int DECODE_CTYPE_QUALITY(unsigned char *buf, CTYPE_QUALITY *value) {
sblair 1:9399d44c2b1a 39 netmemcpy(value, buf, SV_GET_LENGTH_QUALITY);
sblair 0:230c10b228ea 40
sblair 1:9399d44c2b1a 41 return SV_GET_LENGTH_QUALITY;
sblair 0:230c10b228ea 42 }
sblair 0:230c10b228ea 43 int DECODE_CTYPE_TIMESTAMP(unsigned char *buf, CTYPE_TIMESTAMP *value) {
sblair 1:9399d44c2b1a 44 netmemcpy(value, buf, SV_GET_LENGTH_TIMESTAMP);
sblair 0:230c10b228ea 45
sblair 1:9399d44c2b1a 46 return SV_GET_LENGTH_TIMESTAMP;
sblair 0:230c10b228ea 47 }
sblair 1:9399d44c2b1a 48 int DECODE_CTYPE_ENUM(unsigned char *buf, CTYPE_ENUM *value) { // assuming enum is an int - allows any enum type to be used
sblair 1:9399d44c2b1a 49 netmemcpy(value, buf, SV_GET_LENGTH_ENUM);
sblair 0:230c10b228ea 50
sblair 1:9399d44c2b1a 51 return SV_GET_LENGTH_ENUM;
sblair 0:230c10b228ea 52 }
sblair 0:230c10b228ea 53 int DECODE_CTYPE_INT16(unsigned char *buf, CTYPE_INT16 *value) {
sblair 1:9399d44c2b1a 54 netmemcpy(value, buf, SV_GET_LENGTH_INT16);
sblair 0:230c10b228ea 55
sblair 1:9399d44c2b1a 56 return SV_GET_LENGTH_INT16;
sblair 0:230c10b228ea 57 }
sblair 0:230c10b228ea 58 int DECODE_CTYPE_INT32(unsigned char *buf, CTYPE_INT32 *value) {
sblair 1:9399d44c2b1a 59 netmemcpy(value, buf, SV_GET_LENGTH_INT32);
sblair 0:230c10b228ea 60
sblair 1:9399d44c2b1a 61 return SV_GET_LENGTH_INT32;
sblair 0:230c10b228ea 62 }
sblair 0:230c10b228ea 63 int DECODE_CTYPE_INT16U(unsigned char *buf, CTYPE_INT16U *value) {
sblair 1:9399d44c2b1a 64 netmemcpy(value, buf, SV_GET_LENGTH_INT16U);
sblair 0:230c10b228ea 65
sblair 1:9399d44c2b1a 66 return SV_GET_LENGTH_INT16U;
sblair 0:230c10b228ea 67 }
sblair 0:230c10b228ea 68 int DECODE_CTYPE_INT32U(unsigned char *buf, CTYPE_INT32U *value) {
sblair 1:9399d44c2b1a 69 netmemcpy(value, buf, SV_GET_LENGTH_INT32U);
sblair 0:230c10b228ea 70
sblair 1:9399d44c2b1a 71 return SV_GET_LENGTH_INT32U;
sblair 0:230c10b228ea 72 }
sblair 0:230c10b228ea 73 int DECODE_CTYPE_VISSTRING255(unsigned char *buf, CTYPE_VISSTRING255 *value) {
sblair 1:9399d44c2b1a 74 netmemcpy(value, buf, SV_GET_LENGTH_VISSTRING255);
sblair 0:230c10b228ea 75
sblair 1:9399d44c2b1a 76 return SV_GET_LENGTH_VISSTRING255;
sblair 0:230c10b228ea 77 }
sblair 0:230c10b228ea 78 int DECODE_CTYPE_BOOLEAN(unsigned char *buf, CTYPE_BOOLEAN *value) {
sblair 1:9399d44c2b1a 79 netmemcpy(value, buf, SV_GET_LENGTH_BOOLEAN);
sblair 0:230c10b228ea 80
sblair 1:9399d44c2b1a 81 return SV_GET_LENGTH_BOOLEAN;
sblair 0:230c10b228ea 82 }
sblair 0:230c10b228ea 83 int DECODE_CTYPE_DBPOS(unsigned char *buf, CTYPE_DBPOS *value) {
sblair 1:9399d44c2b1a 84 netmemcpy(value, buf, SV_GET_LENGTH_DBPOS);
sblair 0:230c10b228ea 85
sblair 1:9399d44c2b1a 86 return SV_GET_LENGTH_DBPOS;
sblair 0:230c10b228ea 87 }