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 | /// /// Device Command (DCMD) /// /// to devices. Multiple metrics can be supplied in a single DCMD message. /// spBv1.0/Sparkplug B Devices/DCMD/Raspberry Pi/Pibrella /// The host EoN node ID of this device is: Raspberry Pi /// The Device ID is: Pibrella /// This is an DCMD message from the device /// The DCMD payload tells the EoN node to write true to the attached device s green and yellow LEDs. As a result, pTopic : POINTER TO WSTRING(GC_Sparkplug.supported_string_lengths); // resembles the topic under which the message is posted END_VAR VAR_IN_OUT newName : WSTRING(GC_Sparkplug.supported_string_lengths); newVarInt : DecodedVarInt; newLreal : LREAL; newHasNext : BOOL; newtimestamp : T_DateTime; //note: pMessage is already decoded onDCMDMessage := FALSE; //get first message pMessage.GetFirstMetric( name => newName, datatype => newdatatype, timestamp => newtimestamp, valueString => newString, valueLreal => newLreal, valueReal => newreal, valueVarInt => newVarInt, MetricValid => newMetricValid, HasNext => newHasNext); THIS^.GetMetricbyName( MetricName:= newName, Metric=> itfExistingMetric, GetTimestamp=> , xError=> MetricNotExisting, eError=> ); IF NOT newMetricValid THEN ; // There are no metrics, so we needn't do anything ELSIF MetricNotExisting THEN WriteDeviceLog( UDINT_TO_DWORD( CmpLog.LogClass.LOG_INFO ), 'Someone sent an DCMD with metric %s not in our DBIRTH. It was ignored', TO_STRING(newName) ); ELSE //update one Update( Metric := itfExistingMetric, Name := newName, DataType := newdatatype, Status := MetricStatus.ONLINE_OK, Timestamp := newtimestamp, String_ := newString, LReal_ := newLreal, Real_ := newreal, VarInt := newVarInt ); END_IF END_WHILE WriteDeviceLog( UDINT_TO_DWORD( CmpLog.LogClass.LOG_INFO ), 'EoN DCMD Received Topic: %s', WSTRING_TO_STRING( pTopic^ ) ); onDCMDMessage := TRUE; |