예제 #1
0
        public void TransformTestWithoutUnit()
        {
            string jsonContent        = @"{
                  'gwy': 'b19IoTWorx',
                  'name': 'Device_190130_AV_67',
                  'value': '400.000000',
                  'timestamp': '2019-06-10T23:48:43.667Z',
                  'status': true
                }";
            var    telemetryDataPoint = JsonConvert.DeserializeObject <BACNetTelemetryMsg>(jsonContent, _jsonSerializerSettings);
            var    eventData          = new EventData(new byte[0]);
            BACNetIoTHubMessage bacNetIoTHubMessage = new BACNetIoTHubMessage(telemetryDataPoint, eventData.SystemProperties, eventData.Properties);

            DeviceDocument inputDeviceDocument = new DeviceDocument()
            {
                id = telemetryDataPoint.name
            };
            DeviceDocument output = IoTWorxBuildingDataProcessingFunction.ApplyTelemetryToDeviceDoc(bacNetIoTHubMessage, inputDeviceDocument);

            output.EventEnqueuedUtcTime.ShouldBe(DateTime.UtcNow, TimeSpan.FromMilliseconds(1000));
            output.PresentValue.ShouldBe("400.000000");
            output.ValueUnits.ShouldBeEmpty();
            output.DeviceTimestamp.ShouldBe(DateTime.Parse("2019-06-10T23:48:43.667Z"));
            output.DeviceStatus.ToLower().ShouldBe(bool.TrueString.ToLower());
        }
예제 #2
0
        public void TransformTestWithUnit()
        {
            string jsonContent =
                @"{
                    'gwy': 'b19IoTWorx',
                    'name': 'Device_190131_AV_90',
                    'value': '73.000000 DEGREES-FAHRENHEIT',
                    'timestamp': '2019-06-10T23:48:43.667Z',
                    'status': true
                }";
            var telemetryDataPoint = JsonConvert.DeserializeObject <BACNetTelemetryMsg>(jsonContent, _jsonSerializerSettings);
            var eventData          = new EventData(new byte[0]);
            BACNetIoTHubMessage bacNetIoTHubMessage = new BACNetIoTHubMessage(telemetryDataPoint, eventData.SystemProperties, eventData.Properties);

            DeviceDocument inputDeviceDocument = new DeviceDocument()
            {
                id         = telemetryDataPoint.name,
                DeviceName = "190131",
                ObjectType = "AnalogValue",
                Instance   = 90
            };
            DeviceDocument output = IoTWorxBuildingDataProcessingFunction.ApplyTelemetryToDeviceDoc(bacNetIoTHubMessage, inputDeviceDocument);

            //output.Gateway.ShouldBe("b19IoTWorx");
            output.id.ShouldBe((string)telemetryDataPoint.name);
            output.EventEnqueuedUtcTime.ShouldBe(DateTime.UtcNow, TimeSpan.FromMilliseconds(1000));
            output.DeviceName.ShouldBe("190131");
            output.ObjectType.ShouldBe("AnalogValue");
            output.Instance.ShouldBe(90);
            output.PresentValue.ShouldBe("73.000000");
            output.ValueUnits.ShouldBe("DEGREES-FAHRENHEIT");
            output.DeviceTimestamp.ShouldBe(DateTime.Parse("2019-06-10T23:48:43.667Z"));
            output.DeviceStatus.ToLower().ShouldBe(bool.TrueString.ToLower());
            Console.Write(JsonConvert.SerializeObject(output));
        }