[r815]: / branches / FeatureBranches / refactorpayload / SparkplugB / Function Blocks / FB_Device / FB_Device_1 / GetMetricbyName / svnobj  Maximize  Restore  History

Download this file

33 lines (32 with data), 3.4 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
METHOD GetMetricbyName
VAR_IN_OUT CONSTANT
    MetricName : WSTRING;
END_VAR
VAR_OUTPUT
    Metric       : IRemoteMetric;
    GetTimestamp : T_DateTime; //NOT IMPLEMENTED
    xError       : BOOL;
    eError       : ERROR;
VAR
    HasNext     : BOOL;
    FoundMetric : BOOL;
    itfElement  : IElement;
//Device Metric
eError := ERROR.DeviceIDNotFound;
_metrics.ItterateRestart( HasNext => HasNext );
WHILE HasNext AND NOT FoundMetric DO
    _metrics.ItterateNext( itfElement => itfElement,
                           HasNext => HasNext );
    IF __QUERYINTERFACE( itfElement,
                         _Metric ) THEN
        IF _Metric.Name = MetricName THEN
            FoundMetric := TRUE;
            eError      := ERROR.NO_ERROR;
            Metric      := _Metric;
        END_IF
    END_IF
END_WHILE
xError := (eError <> ERROR.NO_ERROR);
IF Metric = 0 THEN
	Metric := GVL_sparkplug.InvalidRemoteMetric;
END_IF