public static void TestSetup()
        {
            _deviceA = new Configuration.Device
            {
                Id = "DeviceA",
                DefaultIndexName = "DeviceAIndex",
                DefaultInterval = TimeSpan.FromSeconds(75),
                DefaultType = "DeviceAType",
                Variables = new[] {
                    new Configuration.Variable { Name = "temp", IndexName = "tempIndex", Interval = TimeSpan.FromSeconds(10), Type = "tempType", OmitDuplicateReadings = true },
                    new Configuration.Variable { Name = "humidity", IndexName = "humidityIndex", Interval = TimeSpan.FromSeconds(20), Type = "humidityType", OmitDuplicateReadings = true }
                }
            };

            _deviceB = new Configuration.Device
            {
                Id = "DeviceB",
                DefaultIndexName = "DeviceBIndex",
                DefaultInterval = TimeSpan.FromSeconds(75),
                DefaultType = "DeviceBType",
                Variables = new[] {
                    new Configuration.Variable { Name = "light", IndexName = "lightIndex", Interval = TimeSpan.FromSeconds(30), Type = "lightType", OmitDuplicateReadings = true }
                }
            };

            _tempIndex = new Configuration.Index { Name = "tempIndex", AppendDate = true, DateFormat = "yyy-MM-dd" };
            _lightIndex = new Configuration.Index { Name = "lightIndex", AppendDate = true };
            _humidityIndex = new Configuration.Index { Name = "humidityIndex", AppendDate = false };
        }
Пример #2
0
        public void ShouldUseDeviceFactoryToConstructDevicesWithCorrectSettings()
        {
            Configuration.Device deviceA = new Configuration.Device
            {
                LocalCommandPort = 5100,
                LocalPacketPort = 5110,
                OwlCommandKey = "6C9DB92A",
                OwlIpAddress = "192.168.1.113",
                OwlCommandPort = 5100,
                OwlCommandResponseTimeout = "00:00:10",
                AutoConfigurePacketPort = true
            };

            Configuration.Device deviceB = new Configuration.Device
            {
                LocalCommandPort = 6100,
                LocalPacketPort = 6110,
                OwlCommandKey = "6C9DB92A",
                OwlIpAddress = "192.168.1.113",
                OwlCommandPort = 6100,
                OwlCommandResponseTimeout = "00:00:10",
                AutoConfigurePacketPort = true
            };

            A.CallTo(() => _configurationSettings.Devices).Returns(new [] { deviceA, deviceB });

            _subject.Initialize();

            A.CallTo(() => _deviceFactory.CreateDeviceInContext(deviceA, _clientEndpoint)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _deviceFactory.CreateDeviceInContext(deviceB, _clientEndpoint)).MustHaveHappened(Repeated.Exactly.Once);
        }
Пример #3
0
        public void ShouldUseDeviceFactoryToConstructDevicesWithCorrectSettings()
        {
            Configuration.Device deviceA = new Configuration.Device
            {
                LocalCommandPort          = 5100,
                LocalPacketPort           = 5110,
                OwlCommandKey             = "6C9DB92A",
                OwlIpAddress              = "192.168.1.113",
                OwlCommandPort            = 5100,
                OwlCommandResponseTimeout = "00:00:10",
                AutoConfigurePacketPort   = true
            };

            Configuration.Device deviceB = new Configuration.Device
            {
                LocalCommandPort          = 6100,
                LocalPacketPort           = 6110,
                OwlCommandKey             = "6C9DB92A",
                OwlIpAddress              = "192.168.1.113",
                OwlCommandPort            = 6100,
                OwlCommandResponseTimeout = "00:00:10",
                AutoConfigurePacketPort   = true
            };

            A.CallTo(() => _configurationSettings.Devices).Returns(new [] { deviceA, deviceB });

            _subject.Initialize();

            A.CallTo(() => _deviceFactory.CreateDeviceInContext(deviceA, _clientEndpoint)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _deviceFactory.CreateDeviceInContext(deviceB, _clientEndpoint)).MustHaveHappened(Repeated.Exactly.Once);
        }
 private void button4_Click(object sender, EventArgs e)
 {
     Configuration.Device frm = new Configuration.Device();
     frm.Show();
 }
Пример #5
0
        /// <summary>
        /// 初始化设备
        /// </summary>
        /// <param name="instance">设备</param>
        /// <param name="device">设备配置</param>
        /// <returns>是否成功</returns>
        private bool InitializeDevice(IDevice instance, Configuration.Device device)
        {
            try {
                var category = Enum.Parse(typeof(DeviceType), device.category);
                switch (category)
                {
                case DeviceType.Camera:
                    // TODO: 启动服务线程并设置参数
                    if (!instance.Write(WriteMode.URI, device.uri))
                    {
                        Tracker.LogE($"Write parameters fail: {device.model}");
                        return(false);
                    }

                    if (!instance.Write(WriteMode.CameraParameters, device.cameraParameters))
                    {
                        Tracker.LogE($"Write parameters fail: {device.model}");
                        return(false);
                    }

                    break;

                case DeviceType.IrCamera:
                    // TODO: 启动服务线程并设置参数
                    if (!instance.Write(WriteMode.URI, device.uri))
                    {
                        Tracker.LogE($"Write parameters fail: {device.model}");
                        return(false);
                    }

                    if (!instance.Write(WriteMode.IrCameraParameters, device.irCameraParameters))
                    {
                        Tracker.LogE($"Write parameters fail: {device.model}");
                        return(false);
                    }

                    if (!instance.Write(WriteMode.CameraParameters, device.cameraParameters))
                    {
                        Tracker.LogE($"Write parameters fail: {device.model}");
                        return(false);
                    }

                    // 启动获取数据工作线程
                    var worker = new CaptureVideoWorker();
                    if (ARESULT.AFAILED(worker.Initialize(new Dictionary <string, object>()
                    {
                        { "device", instance }
                    })))
                    {
                        Tracker.LogE($"CaptureVideoWorker initialize fail: {device.model}");
                        return(false);
                    }

                    if (ARESULT.AFAILED(worker.Start()))
                    {
                        Tracker.LogE($"CaptureVideoWorker start fail: {device.model}");
                        return(false);
                    }

                    workers.Add(worker);

                    break;

                default:
                    return(false);
                }

                return(true);
            }
            catch (Exception e) {
                Tracker.LogE($"Initialize device fail: {device.model}", e);
                return(false);
            }
        }