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 | // At first we set no error itfRemoteMetric ); IF HasItfRemoteMetric THEN // we can safely 'plug it' in the method AddAllMetrics := _Encoder.AddMetric( Timestamp := Timestamp, SparkplugObject := itfRemoteMetric, AllMetricsWhichWillEverReport := AllMetricsList ); // Succes msgFmtStr := 'SparkplugBSimple AddMetricList Element added: %s', strArg := TO_STRING( WCONCAT( itfRemoteMetric.Name, WCONCAT( " : ", TO_WSTRING( itfRemoteMetric.DataType ) ) ) ) ); ELSE // SimpleValue Interface is NOT implemented 'SparkplugBSimple AddMetricList Error: element does not implement IRemoteMetric Interface: %s', strArg := TO_STRING( itfRemoteMetric.Name ) ); AddAllMetrics := ERROR.NotImplemented; END_IF HasItfRemoteMetric := FALSE; WriteDeviceLog( msgCtrlMask := UDINT_TO_DWORD( CmpLog.LogClass.LOG_ERROR ), Add a List of metric value's by spoonfeeding each metric in the list and add it seperatly Start Encoder and Send Blob immediatly after usage. An error is thrown if at least one metric adding has failed. |