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 | (* The Method returns 'No Error' if all metrics have been processed with succes Check the SparkPlugLog for details on which Metric has thrown the error. *) METHOD AddAllMetrics : ERROR VAR_INPUT Timestamp : T_DateTime; END_VAR VAR_IN_OUT // List of metrics we curently wish to send SendList : List; // OF ISimpleStorage // Global All Metrics List AllMetricsList : List; // OF ISimpleStorage VAR ItfCurElement : IElement; itfSimpleValue : IRemoteMetric; itfSimpleSparkplug : ISimpleSparkplug; HasitfSimpleSparkplug : BOOL; HasItfSimpleValue : BOOL; // At first we set no error HasitfSimpleSparkplug := __QUERYINTERFACE( itfCurElement, HasItfSimpleValue := __QUERYINTERFACE( itfCurElement, AddAllMetrics := _Encoder.AddMetric( Timestamp := Timestamp, AllMetricsWhichWillEverReport := AllMetricsList ); // Succes msgFmtStr := 'SparkplugBSimple AddMetricList Element added: %s', strArg := WCONCAT( " : ", WriteDeviceLog( msgCtrlMask := UDINT_TO_DWORD( CmpLog.LogClass.LOG_ERROR ), msgFmtStr := strArg := TO_STRING( itfSimpleSparkplug.Name ) ); AddAllMetrics := ERROR.NotImplemented; END_IF ELSE // No SimpleSparkplug Interface is NOT implemented 'SparkplugBSimple AddMetricList Error: element does not implement SimpleSparkplug Interface: %s', ItfCurElement := ItfCurElement.NextElem; // If NextElem = 0 we reached the end of the list END_WHILE ELSE // List empty msgFmtStr := 'SparkplugBSimple AddMetricList Error, List empty.', strArg := '' ); AddAllMetrics := ERROR.NotImplemented; END_IF |