public void TestLabelPrinted()
        {
            ZigbeeDeviceBase validationDevice = null;
            int validationTesterId            = 0;
            int validationNetworkColorId      = 0;
            int validationProductionSiteId    = 0;

            testFinalizeService.OnLabelPrinted += delegate(ZigbeeDeviceBase device, int testerId, int networkColorId, int productionSiteId)
            {
                validationDevice           = device;
                validationTesterId         = testerId;
                validationNetworkColorId   = networkColorId;
                validationProductionSiteId = productionSiteId;
            };

            var testDevice           = new DemoZigbeeDeviceBase();
            var testTesterId         = 9;
            var testNetworkColorId   = 99;
            var testProductionSiteId = 999;

            testFinalizeService.LabelPrinted(testDevice, testTesterId, testNetworkColorId, testProductionSiteId);

            Assert.AreEqual(validationDevice, testDevice);
            Assert.AreEqual(validationTesterId, testTesterId);
            Assert.AreEqual(validationNetworkColorId, testNetworkColorId);
            Assert.AreEqual(validationProductionSiteId, testProductionSiteId);
        }
Example #2
0
        public void TestClearTestEvents()
        {
            ZigbeeDeviceBase testDevice = null;

            testHostService.OnDeviceLeft += delegate(ZigbeeDeviceBase device)
            {
                testDevice = device;
            };

            testHostService.OnDeviceJoined += delegate(ZigbeeDeviceBase device)
            {
                testDevice = device;
            };

            testHostService.ClearTestEvents();

            var createdDevice = new DemoZigbeeDeviceBase();

            testHostService.DeviceLeft(createdDevice);

            Assert.AreEqual(testDevice, null);

            testHostService.DeviceJoined(createdDevice);

            Assert.AreEqual(testDevice, null);
        }
        public void AddMessage(EzspIncomingMessageHandlerResponse message, ZigbeeDeviceBase device)
        {
            lock (Messages)
            {
                Messages.Enqueue(Tuple.Create(message, device));
            }

            MessageAddedEvent?.Invoke();
        }
Example #4
0
        public void TestDeviceLeft()
        {
            ZigbeeDeviceBase testDevice = null;

            testHostService.OnDeviceLeft += delegate(ZigbeeDeviceBase device)
            {
                testDevice = device;
            };

            var createdDevice = new DemoZigbeeDeviceBase();

            testHostService.DeviceLeft(createdDevice);

            Assert.AreEqual(createdDevice, testDevice);
        }
        public void TestClearEvents()
        {
            ZigbeeDeviceBase validationDevice = default(ZigbeeDeviceBase);
            int?validationTesterId            = default(int?);
            int validationNetworkColorId      = default(int);
            int validationProductionSiteId    = default(int);
            int?validationSupervisorId        = default(int?);

            testFinalizeService.OnLabelPrinted += delegate(ZigbeeDeviceBase device, int testerId, int networkColorId, int productionSiteId)
            {
                validationDevice           = device;
                validationTesterId         = testerId;
                validationNetworkColorId   = networkColorId;
                validationProductionSiteId = productionSiteId;
            };

            testFinalizeService.OnSerialNumberGenerated += delegate(ZigbeeDeviceBase device, int?testerId, int?supervisorId)
            {
                validationDevice       = device;
                validationTesterId     = testerId;
                validationSupervisorId = supervisorId;
            };

            testFinalizeService.OnSerialNumberUpdated += delegate(ZigbeeDeviceBase device, int?testerId)
            {
                validationDevice   = device;
                validationTesterId = testerId;
            };

            var testDevice           = new DemoZigbeeDeviceBase();
            var testTesterId         = 9;
            var testNetworkColorId   = 99;
            var testProductionSiteId = 999;
            var testSupervisorId     = 99;

            testFinalizeService.ClearEvents();

            testFinalizeService.LabelPrinted(testDevice, testTesterId, testNetworkColorId, testProductionSiteId);
            testFinalizeService.SerialNumberGenerated(testDevice, testTesterId, testSupervisorId);
            testFinalizeService.SerialNumberUpdated(testDevice, testTesterId);

            Assert.AreEqual(validationDevice, default(ZigbeeDeviceBase));
            Assert.AreEqual(validationTesterId, default(int?));
            Assert.AreEqual(validationNetworkColorId, default(int));
            Assert.AreEqual(validationProductionSiteId, default(int));
            Assert.AreEqual(validationSupervisorId, default(int?));
        }
        public void TestSerialNumberUpdated()
        {
            ZigbeeDeviceBase validationDevice = null;
            int?validationTesterId            = null;

            testFinalizeService.OnSerialNumberUpdated += delegate(ZigbeeDeviceBase device, int?testerId)
            {
                validationDevice   = device;
                validationTesterId = testerId;
            };

            var testDevice   = new DemoZigbeeDeviceBase();
            var testTesterId = 9;

            testFinalizeService.SerialNumberUpdated(testDevice, testTesterId);

            Assert.AreEqual(validationDevice, testDevice);
            Assert.AreEqual(validationTesterId, testTesterId);
        }
Example #7
0
 private void RequestDeviceInformation(ZigbeeDeviceBase device)
 {
     if (device.Eui == null)
     {
         ZdoMessageComposer.SendIEEEAddressRequest(device.Address, ezspService);
     }
     else if (device.ModelString == default(string))
     {
         // Send ModelString request
         HaMessageComposer.SendModelStringRequest(device.Address, ezspService);
     }
     else if (device.LongFirmwareVersion == default(uint))
     {
         // Send Firmware Version Request
         HaMessageComposer.SendFirmwareVersionRequest(device.Address, ezspService);
     }
     else
     {
         device.Validated = true;
     }
 }
Example #8
0
        public void ValidateDevice(ZigbeeDeviceBase device, EzspIncomingMessageHandlerResponse message)
        {
            if (message != null)
            {
                EmberEui64 eui;
                string     modelString;
                uint       firmwareVersion;

                if ((ZdoMessageParser.TryParseDeviceAnnounce(message, out eui) || ZdoMessageParser.TryParseIEEEAddressResponse(message, out eui)))
                {
                    if (VerifyEui(eui))
                    {
                        device.Eui = eui;
                        OnAddDevice?.Invoke(device);
                    }
                    else
                    {
                        OnRemoveDevice?.Invoke(device);
                    }
                }
                else if (HaMessageParser.TryParseModelString(message, out modelString))
                {
                    if (VerifyModelString(modelString))
                    {
                        device.ModelString = modelString;
                    }
                    else
                    {
                        OnRemoveDevice?.Invoke(device);
                    }
                }
                else if (HaMessageParser.TryParseFirmwareVersion(message, out firmwareVersion))
                {
                    device.LongFirmwareVersion = (firmwareVersion == default(uint)) ? uint.MaxValue : firmwareVersion;
                }
            }

            RequestDeviceInformation(device);
        }
Example #9
0
 public void DeviceLeft(ZigbeeDeviceBase device)
 {
     OnDeviceLeft?.Invoke(device);
 }
Example #10
0
 public void DeviceJoined(ZigbeeDeviceBase device)
 {
     OnDeviceJoined?.Invoke(device);
 }
Example #11
0
 public void SerialNumberUpdated(ZigbeeDeviceBase device, int?testerId)
 {
     OnSerialNumberUpdated?.Invoke(device, testerId);
 }
Example #12
0
 public void SerialNumberGenerated(ZigbeeDeviceBase device, int?testerId, int?supervisorId)
 {
     OnSerialNumberGenerated?.Invoke(device, testerId, supervisorId);
 }
Example #13
0
 public void LabelPrinted(ZigbeeDeviceBase device, int testerId, int networkColorId, int productionSiteId)
 {
     OnLabelPrinted?.Invoke(device, testerId, networkColorId, productionSiteId);
 }
Example #14
0
 protected abstract void ProcessMessage(EzspIncomingMessageHandlerResponse message, ZigbeeDeviceBase device);
Example #15
0
 protected abstract void TestService_OnDeviceJoined(ZigbeeDeviceBase device);
Example #16
0
 protected abstract void TestService_OnDeviceLeft(ZigbeeDeviceBase device);