[r818]: / branches / FeatureBranches / Debuglogging / SparkplugB / Function Blocks / FB_Edge / FB_Edge / NCMD / onNCMDMessage / svnobj  Maximize  Restore  History

Download this file

75 lines (74 with data), 26.7 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
VAR_INPUT
    pTopic : POINTER TO WSTRING(GC_Sparkplug.supported_string_lengths); // resembles the topic under which the message is posted 
VAR_IN_OUT
    pMessage : FB_PayloadSimpleDecoder; //should already be decoded
    Rebirth : BOOL := FALSE;
    MetricValid       : BOOL;
    MetricValueString : WSTRING;
    MetricValueReal   : REAL;
    datatype          : MetricDataType;
//note: pMessage is already decoded
onNCMDMessage := FALSE;
//get first message
pMessage.GetFirstMetric( name => MetricName,
                         datatype => datatype,
                         timestamp =>, //don't care
                         valueString => MetricValueString,
                         valueLreal => MetricValueLreal,
                         valueReal => MetricValueReal,
                         valueVarInt => MetricValueVarInt,
                         MetricValid => MetricValid,
                         HasNext => HasNext );
                                      1 ) TO UPPER_BOUND( THIS^.arSparkplugInt8,
                    IF MetricName = arSparkplugInt8[i].Name THEN
                                      1 ) TO UPPER_BOUND( THIS^.arSparkplugInt16,
                        arSparkplugInt16[i].Value := MetricValueVarInt.Int16;
                                      1 ) TO UPPER_BOUND( THIS^.arSparkplugUInt8,
                        arSparkplugUInt8[i].Value := MetricValueVarInt.UInt8;
            MetricDataType.Int32:
                FOR i := LOWER_BOUND( THIS^.arSparkplugInt32,
                    IF MetricName = arSparkplugInt32[i].Name THEN
                                      1 ) TO UPPER_BOUND( THIS^.arSparkplugUInt16,
                        arSparkplugUInt16[i].Value := MetricValueVarInt.UInt16;
            MetricDataType.Int64:
                FOR i := LOWER_BOUND( THIS^.arSparkplugInt64,
                    IF MetricName = arSparkplugInt64[i].Name THEN
                                      1 ) TO UPPER_BOUND( THIS^.arSparkplugUInt32,
                        arSparkplugUInt32[i].Value := MetricValueVarInt.UInt32;
                FOR i := LOWER_BOUND( THIS^.arSparkplugUint64,
                    IF MetricName = arSparkplugUint64[i].Name THEN
                                      1 ) TO UPPER_BOUND( THIS^.arSparkplugFloat,
                        arSparkplugFloat[i].Value := MetricValueReal;
            MetricDataType.Double:
                FOR i := LOWER_BOUND( THIS^.arSparkplugDouble,
                    IF MetricName = arSparkplugDouble[i].Name THEN
                    //We have found that the server wants us to rebirth
                    Rebirth := TRUE;
                    WriteDeviceLog( gc_sparkplug.CMP_EDGE,
                                    CmpLog.LogClass.LOG_DEBUG,
                                    TO_STRING( MetricValueVarInt.Boolean ) );
                END_IF
                //normal place for normal booleans
                FOR i := LOWER_BOUND( THIS^.arSparkplugBoolean,
                    IF MetricName = arSparkplugBoolean[i].Name THEN
                                      1 ) TO UPPER_BOUND( THIS^.arSparkplugString,
                        arSparkplugString[i].Value := MetricValueString;
                FOR i := LOWER_BOUND( THIS^.arSparkplugText,
                    IF MetricName = arSparkplugText[i].Name THEN
                                      1 ) TO UPPER_BOUND( THIS^.arSparkplugUUID,
                        arSparkplugUUID[i].Value := MetricValueString;
            MetricDataType.DateTime:
                                      1 ) TO UPPER_BOUND( THIS^.arSparkplugDateTime,
                        arSparkplugDateTime[i].Value := MetricValueVarInt.uliDateTime;
            MetricDataType.Text:
            MetricDataType.UUID:
                ; //maybe a log message? in any case, do nothing.  
                            datatype => datatype,
                            valueString => MetricValueString,
                            valueReal => MetricValueReal,
                            MetricValid => MetricValid,
UNTIL HasNext = FALSE
//pMessage.GetNextMetric don't care today
//pMessage.GetTimestamp don't care today
                CmpLog.LogClass.LOG_DEBUG,
                WSTRING_TO_STRING( pTopic^ ) );