[r919]: / branches / develop / mqttsparkplug / mqttsparkplug / Sparkplug™ MQTT edge and host / Function Blocks / FB_Payload_1 / FB_PayloadPropertyValue / svnobj  Maximize  Restore  History

Download this file

86 lines (85 with data), 47.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
VAR_INPUT
    xDecode              : BOOL;
    protobufBlobMaxIndex : DINT;
END_VAR
VAR_OUTPUT
    eDecodeError                           : ERROR;
    eEncodeError                           : ERROR;
    (*Internal variables*)
    startingByteOfEncodedData  : DINT;
    lengthOfObject             : DINT;
    // 	    message PropertyValue {
    //         optional uint32     type                    = 1;
    _eType    : PropertyDataType;
    //         optional bool       is_null                 = 2; 
    _xIs_null    : BOOL;
    _eHasValue : PropertyProtobufsType;
    //             uint64          long_value              = 4;
    _dzzValue : DecodedVarInt;
    _rValue : REAL;
    _lrValue : LREAL;
    _sValue : WSTRING;
    _myPropertySet : FB_PayloadPropertySet;
    //             PropertySetList propertysets_value      = 10;      // List of Property Values
    _myPropertySetList           : List; // OF FB_PayloadPropertySet
    _myPropertySetListendindex   : DINT; //decode
    //             PropertyValueExtension extension_value  = 11;
    //         message PropertyValueExtension {
    //             extensions                             1 to max;
    // NO EXTENSIONS
    _COL_Element : IElement;
	// IElement
    _itfNext : IElement;
                            //This IF statement
IF xDecode AND xEncode THEN //ERROR
    xDecodeDone  := FALSE;
    xDecodeBusy  := FALSE;
    xDecodeError := TRUE;
    eDecodeError := ERROR.PayloadYouCantDoBothAtOnce;
    xEncodeDone  := FALSE;
    xEncodeBusy  := FALSE;
    xEncodeError := TRUE;
    eEncodeError := ERROR.PayloadYouCantDoBothAtOnce;
    dviTemp           := OwnerPayload.DecodeNextVarInt(); //updates i to end of the varint
    lengthOfObject    := dviTemp.int32;
    finalByteIndex    := ProtobufBlobIndex + lengthOfObject;
    ProtobufBlobIndex := ProtobufBlobIndex + 1;
    eDecodeState      := PayloadDecodeStates.object_getmember;
    //for i to i + length - 1
                        eDecodeError      := ERROR.PayloadFound00;
                        eDecodeState := PayloadDecodeStates.object_gettype;
                    ProtobufedId.PropertyValue_is_null:
                        eDecodeState := PayloadDecodeStates.object_getint_value;
                    ProtobufedId.PropertyValue_long_value:
                        eDecodeState := PayloadDecodeStates.object_getfloat_value;
                    ProtobufedId.PropertyValue_double_value:
                        eDecodeState := PayloadDecodeStates.object_getboolean_value;
                    ProtobufedId.PropertyValue_string_value:
                    ProtobufedId.PropertyValue_propertyset_value:
                    ProtobufedId.PropertyValue_propertysets_value:
                        eDecodeError      := ERROR.PayloadFoundExtensions;
                    eDecodeError      := ERROR.PayloadFoundExtensions;
                dviTemp      := OwnerPayload.DecodeNextVarInt(); //updates i to end of the varint
                _eType       := dviTemp.UInt32;
                _eHasValue   := PropertyProtobufsType.int_value;
                _eHasValue   := PropertyProtobufsType.long_value;
            PayloadDecodeStates.object_getfloat_value:
                _rValue      := OwnerPayload.DecodeNextFloat(); //updates i to end of the varint
            PayloadDecodeStates.object_getdouble_value:
                _lrValue     := OwnerPayload.DecodeNextDouble(); //updates i to end of the varint
            PayloadDecodeStates.object_getboolean_value:
                _eHasValue   := PropertyProtobufsType.string_value;
                _eHasValue := PropertyProtobufsType.propertyset_value;
                THIS^._myPropertySet( xDecode := TRUE,
                                      xEncode := FALSE,
                                      OwnerPayload := OwnerPayload,
                                      myProtobufBlob := myProtobufBlob,
                                      xDecodeDone =>,
                                      xDecodeBusy =>,
                                      eDecodeError => eDecodeError );
                IF NOT xDecodeError THEN
                dviTemp                    := OwnerPayload.DecodeNextVarInt(); //updates i to end of the varint
                IF ProtobufBlobIndex < _myPropertySetListendindex THEN
                    eDecodeState := PayloadDecodeStates.object_getPropertyList_member;
                    ProtobufedId.PropertySetList_propertyset:
                        eDecodeState := PayloadDecodeStates.object_getPropertyList_PropertiesSet;