An mbed implementation of IEC 61850-9-2LE Sample Values. Creating using the rapid61850 library, available at: https://github.com/stevenblair/rapid61850.
An mbed implementation of IEC 61850-9-2LE Sample Values. Creating using the rapid61850 library, available at: https://github.com/stevenblair/rapid61850.
rapid61850/svEncode.c@0:f09b7bb8bcce, 2012-10-02 (annotated)
- Committer:
- sblair
- Date:
- Tue Oct 02 21:31:05 2012 +0000
- Revision:
- 0:f09b7bb8bcce
converted library to folder
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sblair | 0:f09b7bb8bcce | 1 | /** |
sblair | 0:f09b7bb8bcce | 2 | * Rapid-prototyping protection schemes with IEC 61850 |
sblair | 0:f09b7bb8bcce | 3 | * |
sblair | 0:f09b7bb8bcce | 4 | * Copyright (c) 2012 Steven Blair |
sblair | 0:f09b7bb8bcce | 5 | * |
sblair | 0:f09b7bb8bcce | 6 | * This program is free software; you can redistribute it and/or |
sblair | 0:f09b7bb8bcce | 7 | * modify it under the terms of the GNU General Public License |
sblair | 0:f09b7bb8bcce | 8 | * as published by the Free Software Foundation; either version 2 |
sblair | 0:f09b7bb8bcce | 9 | * of the License, or (at your option) any later version. |
sblair | 0:f09b7bb8bcce | 10 | |
sblair | 0:f09b7bb8bcce | 11 | * This program is distributed in the hope that it will be useful, |
sblair | 0:f09b7bb8bcce | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
sblair | 0:f09b7bb8bcce | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
sblair | 0:f09b7bb8bcce | 14 | * GNU General Public License for more details. |
sblair | 0:f09b7bb8bcce | 15 | |
sblair | 0:f09b7bb8bcce | 16 | * You should have received a copy of the GNU General Public License |
sblair | 0:f09b7bb8bcce | 17 | * along with this program; if not, write to the Free Software |
sblair | 0:f09b7bb8bcce | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
sblair | 0:f09b7bb8bcce | 19 | */ |
sblair | 0:f09b7bb8bcce | 20 | |
sblair | 0:f09b7bb8bcce | 21 | #include "svEncodeBasic.h" |
sblair | 0:f09b7bb8bcce | 22 | #include "ied.h" |
sblair | 0:f09b7bb8bcce | 23 | #include "svEncode.h" |
sblair | 0:f09b7bb8bcce | 24 | |
sblair | 0:f09b7bb8bcce | 25 | |
sblair | 0:f09b7bb8bcce | 26 | |
sblair | 0:f09b7bb8bcce | 27 | |
sblair | 0:f09b7bb8bcce | 28 | int encode_IEC_61850_9_2LEAV(unsigned char *buf, struct IEC_61850_9_2LEAV *IEC_61850_9_2LEAV) { |
sblair | 0:f09b7bb8bcce | 29 | int offset = 0; |
sblair | 0:f09b7bb8bcce | 30 | |
sblair | 0:f09b7bb8bcce | 31 | offset += ENCODE_CTYPE_INT32(&buf[offset], &IEC_61850_9_2LEAV->i); |
sblair | 0:f09b7bb8bcce | 32 | |
sblair | 0:f09b7bb8bcce | 33 | return offset; |
sblair | 0:f09b7bb8bcce | 34 | } |
sblair | 0:f09b7bb8bcce | 35 | int encode_IEC_61850_9_2LEsVCAmp(unsigned char *buf, struct IEC_61850_9_2LEsVCAmp *IEC_61850_9_2LEsVCAmp) { |
sblair | 0:f09b7bb8bcce | 36 | int offset = 0; |
sblair | 0:f09b7bb8bcce | 37 | |
sblair | 0:f09b7bb8bcce | 38 | offset += ENCODE_CTYPE_FLOAT32(&buf[offset], &IEC_61850_9_2LEsVCAmp->scaleFactor); |
sblair | 0:f09b7bb8bcce | 39 | offset += ENCODE_CTYPE_FLOAT32(&buf[offset], &IEC_61850_9_2LEsVCAmp->offset); |
sblair | 0:f09b7bb8bcce | 40 | |
sblair | 0:f09b7bb8bcce | 41 | return offset; |
sblair | 0:f09b7bb8bcce | 42 | } |
sblair | 0:f09b7bb8bcce | 43 | int encode_IEC_61850_9_2LEsVCVol(unsigned char *buf, struct IEC_61850_9_2LEsVCVol *IEC_61850_9_2LEsVCVol) { |
sblair | 0:f09b7bb8bcce | 44 | int offset = 0; |
sblair | 0:f09b7bb8bcce | 45 | |
sblair | 0:f09b7bb8bcce | 46 | offset += ENCODE_CTYPE_FLOAT32(&buf[offset], &IEC_61850_9_2LEsVCVol->scaleFactor); |
sblair | 0:f09b7bb8bcce | 47 | offset += ENCODE_CTYPE_FLOAT32(&buf[offset], &IEC_61850_9_2LEsVCVol->offset); |
sblair | 0:f09b7bb8bcce | 48 | |
sblair | 0:f09b7bb8bcce | 49 | return offset; |
sblair | 0:f09b7bb8bcce | 50 | } |
sblair | 0:f09b7bb8bcce | 51 | int encode_IEC_61850_9_2LESAVAmp(unsigned char *buf, struct IEC_61850_9_2LESAVAmp *IEC_61850_9_2LESAVAmp) { |
sblair | 0:f09b7bb8bcce | 52 | int offset = 0; |
sblair | 0:f09b7bb8bcce | 53 | |
sblair | 0:f09b7bb8bcce | 54 | offset += encode_IEC_61850_9_2LEAV(&buf[offset], &IEC_61850_9_2LESAVAmp->instMag); |
sblair | 0:f09b7bb8bcce | 55 | offset += ENCODE_CTYPE_QUALITY(&buf[offset], &IEC_61850_9_2LESAVAmp->q); |
sblair | 0:f09b7bb8bcce | 56 | offset += encode_IEC_61850_9_2LEsVCAmp(&buf[offset], &IEC_61850_9_2LESAVAmp->sVC); |
sblair | 0:f09b7bb8bcce | 57 | |
sblair | 0:f09b7bb8bcce | 58 | return offset; |
sblair | 0:f09b7bb8bcce | 59 | } |
sblair | 0:f09b7bb8bcce | 60 | int encode_IEC_61850_9_2LESAVVol(unsigned char *buf, struct IEC_61850_9_2LESAVVol *IEC_61850_9_2LESAVVol) { |
sblair | 0:f09b7bb8bcce | 61 | int offset = 0; |
sblair | 0:f09b7bb8bcce | 62 | |
sblair | 0:f09b7bb8bcce | 63 | offset += encode_IEC_61850_9_2LEAV(&buf[offset], &IEC_61850_9_2LESAVVol->instMag); |
sblair | 0:f09b7bb8bcce | 64 | offset += ENCODE_CTYPE_QUALITY(&buf[offset], &IEC_61850_9_2LESAVVol->q); |
sblair | 0:f09b7bb8bcce | 65 | offset += encode_IEC_61850_9_2LEsVCVol(&buf[offset], &IEC_61850_9_2LESAVVol->sVC); |
sblair | 0:f09b7bb8bcce | 66 | |
sblair | 0:f09b7bb8bcce | 67 | return offset; |
sblair | 0:f09b7bb8bcce | 68 | } |
sblair | 0:f09b7bb8bcce | 69 | int encode_IEC_61850_9_2LEINC(unsigned char *buf, struct IEC_61850_9_2LEINC *IEC_61850_9_2LEINC) { |
sblair | 0:f09b7bb8bcce | 70 | int offset = 0; |
sblair | 0:f09b7bb8bcce | 71 | |
sblair | 0:f09b7bb8bcce | 72 | offset += ENCODE_CTYPE_INT32(&buf[offset], &IEC_61850_9_2LEINC->ctlVal); |
sblair | 0:f09b7bb8bcce | 73 | offset += ENCODE_CTYPE_INT32(&buf[offset], &IEC_61850_9_2LEINC->stVal); |
sblair | 0:f09b7bb8bcce | 74 | offset += ENCODE_CTYPE_QUALITY(&buf[offset], &IEC_61850_9_2LEINC->q); |
sblair | 0:f09b7bb8bcce | 75 | offset += ENCODE_CTYPE_TIMESTAMP(&buf[offset], &IEC_61850_9_2LEINC->t); |
sblair | 0:f09b7bb8bcce | 76 | |
sblair | 0:f09b7bb8bcce | 77 | return offset; |
sblair | 0:f09b7bb8bcce | 78 | } |
sblair | 0:f09b7bb8bcce | 79 | int encode_LE_IED_MUnn_PhsMeas1(unsigned char *buf) { |
sblair | 0:f09b7bb8bcce | 80 | int offset = 0; |
sblair | 0:f09b7bb8bcce | 81 | |
sblair | 0:f09b7bb8bcce | 82 | offset += encode_IEC_61850_9_2LEAV(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETCTR_1.Amp.instMag); |
sblair | 0:f09b7bb8bcce | 83 | offset += ENCODE_CTYPE_QUALITY(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETCTR_1.Amp.q); |
sblair | 0:f09b7bb8bcce | 84 | offset += encode_IEC_61850_9_2LEAV(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETCTR_2.Amp.instMag); |
sblair | 0:f09b7bb8bcce | 85 | offset += ENCODE_CTYPE_QUALITY(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETCTR_2.Amp.q); |
sblair | 0:f09b7bb8bcce | 86 | offset += encode_IEC_61850_9_2LEAV(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETCTR_3.Amp.instMag); |
sblair | 0:f09b7bb8bcce | 87 | offset += ENCODE_CTYPE_QUALITY(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETCTR_3.Amp.q); |
sblair | 0:f09b7bb8bcce | 88 | offset += encode_IEC_61850_9_2LEAV(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETCTR_4.Amp.instMag); |
sblair | 0:f09b7bb8bcce | 89 | offset += ENCODE_CTYPE_QUALITY(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETCTR_4.Amp.q); |
sblair | 0:f09b7bb8bcce | 90 | offset += encode_IEC_61850_9_2LEAV(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETVTR_1.Vol.instMag); |
sblair | 0:f09b7bb8bcce | 91 | offset += ENCODE_CTYPE_QUALITY(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETVTR_1.Vol.q); |
sblair | 0:f09b7bb8bcce | 92 | offset += encode_IEC_61850_9_2LEAV(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETVTR_2.Vol.instMag); |
sblair | 0:f09b7bb8bcce | 93 | offset += ENCODE_CTYPE_QUALITY(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETVTR_2.Vol.q); |
sblair | 0:f09b7bb8bcce | 94 | offset += encode_IEC_61850_9_2LEAV(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETVTR_3.Vol.instMag); |
sblair | 0:f09b7bb8bcce | 95 | offset += ENCODE_CTYPE_QUALITY(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETVTR_3.Vol.q); |
sblair | 0:f09b7bb8bcce | 96 | offset += encode_IEC_61850_9_2LEAV(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETVTR_4.Vol.instMag); |
sblair | 0:f09b7bb8bcce | 97 | offset += ENCODE_CTYPE_QUALITY(&buf[offset], &LE_IED.S1.MUnn.IEC_61850_9_2LETVTR_4.Vol.q); |
sblair | 0:f09b7bb8bcce | 98 | |
sblair | 0:f09b7bb8bcce | 99 | return offset; |
sblair | 0:f09b7bb8bcce | 100 | } |
sblair | 0:f09b7bb8bcce | 101 | int encode_control_LE_IED_MUnn_MSVCB01(unsigned char *buf) { |
sblair | 0:f09b7bb8bcce | 102 | return encode_LE_IED_MUnn_PhsMeas1(buf); |
sblair | 0:f09b7bb8bcce | 103 | } |
sblair | 0:f09b7bb8bcce | 104 | |
sblair | 0:f09b7bb8bcce | 105 |