示例#1
0
        private static async Task RecordDeviceValue(InfluxDBMeasurementsCollector collector, IHSApplication HS, DeviceClass device)
        {
            if (device != null)
            {
                int  deviceRefId = device.get_Ref(HS);
                bool notValid    = HS.get_DeviceInvalidValue(deviceRefId);
                if (!notValid)
                {
                    double deviceValue  = device.get_devValue(HS);
                    string deviceString = HS.DeviceString(deviceRefId);
                    if (string.IsNullOrWhiteSpace(deviceString))
                    {
                        deviceString = HS.DeviceVSP_GetStatus(deviceRefId, deviceValue, ePairStatusControl.Status);
                    }
                    Trace.WriteLine(Invariant($"Recording Device Ref Id: {deviceRefId} with [{deviceValue}] & [{deviceString}]"));

                    DateTime lastChange = device.get_Last_Change(HS);

                    RecordData recordData = new RecordData(deviceRefId,
                                                           deviceValue,
                                                           deviceString,
                                                           device.get_Name(HS),
                                                           device.get_Location(HS),
                                                           device.get_Location2(HS),
                                                           lastChange);

                    await collector.Record(recordData).ConfigureAwait(false);
                }
                else
                {
                    Trace.TraceWarning(Invariant($"Not recording Device Ref Id: {deviceRefId} as it has invalid value."));
                }
            }
        }