public void SendCommand7Test()
        {
            NuvoTelegramMock     nuvoTelegram = new NuvoTelegramMock();
            NuvoEssentiaProtocol target       = new NuvoEssentiaProtocol(1, nuvoTelegram);

            target.onCommandReceived += new ConcreteProtocolEventHandler(serialPort_CommandReceived);

            NuvoEssentiaCommand command = new NuvoEssentiaCommand(ENuvoEssentiaCommands.SetZoneStatus, ENuvoEssentiaZones.Zone4, ENuvoEssentiaSources.Source4, -50);

            target.SendCommand(command);
            // Three commands => TurnZoneON, SetVolume and SetSource.
            nuvoTelegram.passDataToTestClass("Z04PWRON,SRC1,GRP0,VOL-60");
            Assert.IsTrue(_eventRaisedCount == 1);
            Assert.AreEqual(ENuvoEssentiaCommands.TurnZoneON, _nuvoProtocolEventArgs.Command.Command);
            Assert.AreEqual("Z04ON", _nuvoProtocolEventArgs.Command.OutgoingCommand);

            nuvoTelegram.passDataToTestClass("Z04PWRON,SRC1,GRP0,VOL-50");
            Assert.IsTrue(_eventRaisedCount == 2);
            Assert.AreEqual(ENuvoEssentiaCommands.SetVolume, _nuvoProtocolEventArgs.Command.Command);
            Assert.AreEqual("Z04VOL50", _nuvoProtocolEventArgs.Command.OutgoingCommand);

            nuvoTelegram.passDataToTestClass("Z04PWRON,SRC4,GRP0,VOL-50");
            Assert.IsTrue(_eventRaisedCount == 3);
            Assert.AreEqual(ENuvoEssentiaCommands.SetSource, _nuvoProtocolEventArgs.Command.Command);
            Assert.AreEqual("Z04SRC4", _nuvoProtocolEventArgs.Command.OutgoingCommand);
        }
Пример #2
0
        public void SendCommandTest3()
        {
            INuvoEssentiaCommand command1 = new NuvoEssentiaCommand(ENuvoEssentiaCommands.SetZoneStatus, ENuvoEssentiaZones.Zone5, ENuvoEssentiaSources.Source4, -30);
            INuvoEssentiaCommand command2 = new NuvoEssentiaCommand(ENuvoEssentiaCommands.SetZoneStatus, ENuvoEssentiaZones.Zone7, ENuvoEssentiaSources.Source2, -40);

            _protDriver.onCommandReceived    += new ProtocolCommandReceivedEventHandler(_protDriver_onCommandReceived);
            _protDriver.onDeviceStatusUpdate += new ProtocolDeviceUpdatedEventHandler(_protDriver_onDeviceStatusUpdate);
            _protDriver.onZoneStatusUpdate   += new ProtocolZoneUpdatedEventHandler(_protDriver_onZoneStatusUpdate);
            _protDriver.SendCommand(_zoneAddress, command1);
            _protDriver.SendCommand(_zoneAddress, command2);
            Thread.Sleep(2000); // give control to worker thread

            // return the answer of the first command
            _nuvoTelegramMock.passDataToTestClass("Z05PWRON,SRC3,GRP0,VOL-50");
            _nuvoTelegramMock.passDataToTestClass("Z05PWRON,SRC3,GRP0,VOL-30");
            _nuvoTelegramMock.passDataToTestClass("Z05PWRON,SRC4,GRP0,VOL-30");

            Assert.AreEqual(0, _protDeviceUpdatedEventArgs.Count);      // get ZERO device state update events
            Assert.AreEqual(3, _protCommandReceivedEventArgs.Count);    // get THREE command events
            Assert.AreEqual(1, _protZoneUpdatedEventArgs.Count);        // get ONE zone state update event

            // .. and now return the answer of the second command
            _nuvoTelegramMock.passDataToTestClass("Z07PWRON,SRC3,GRP0,VOL-50");
            _nuvoTelegramMock.passDataToTestClass("Z07PWRON,SRC3,GRP0,VOL-40");
            _nuvoTelegramMock.passDataToTestClass("Z07PWRON,SRC2,GRP0,VOL-40");

            Assert.AreEqual(0, _protDeviceUpdatedEventArgs.Count);      // get ZERO device state update events
            Assert.AreEqual(6, _protCommandReceivedEventArgs.Count);    // get SIX command events
            Assert.AreEqual(2, _protZoneUpdatedEventArgs.Count);        // get TWO zone state update event
        }
Пример #3
0
        public void SendCommandTest1()
        {
            INuvoEssentiaCommand command = new NuvoEssentiaCommand(ENuvoEssentiaCommands.SetZoneStatus, ENuvoEssentiaZones.Zone4, ENuvoEssentiaSources.Source5, -22);
            Address zoneAddress          = new Address(_deviceId, 4); // Zone 4

            _protDriver.SendCommand(zoneAddress, command);
            Thread.Sleep(2000); // give control to worker thread

            Assert.IsTrue(_nuvoTelegramMock.TelegramList.Count >= 3);
            Assert.AreEqual(true, _nuvoTelegramMock.TelegramList.Contains("Z04ON"));
            Assert.AreEqual(true, _nuvoTelegramMock.TelegramList.Contains("Z04VOL22"));
            Assert.AreEqual(true, _nuvoTelegramMock.TelegramList.Contains("Z04SRC5"));
        }
Пример #4
0
        public void SendCommandTest4()
        {
            INuvoEssentiaCommand command = new NuvoEssentiaCommand(ENuvoEssentiaCommands.SetZoneStatus, ENuvoEssentiaZones.Zone5, ENuvoEssentiaSources.Source4, -30);

            _protDriver.onCommandReceived    += new ProtocolCommandReceivedEventHandler(_protDriver_onCommandReceived);
            _protDriver.onDeviceStatusUpdate += new ProtocolDeviceUpdatedEventHandler(_protDriver_onDeviceStatusUpdate);
            _protDriver.onZoneStatusUpdate   += new ProtocolZoneUpdatedEventHandler(_protDriver_onZoneStatusUpdate);

            _nuvoTelegramMock.passDataToTestClass("ALLOFF");         // receive spontaneous command

            Assert.AreEqual(0, _protDeviceUpdatedEventArgs.Count);   // get ZERO device state update events
            Assert.AreEqual(1, _protCommandReceivedEventArgs.Count); // get ONE command events
            Assert.AreEqual(12, _protZoneUpdatedEventArgs.Count);    // get TWELVE zone state update event
        }
Пример #5
0
        /// <summary>
        /// Sets the zoen state for this control base on the command passed into.
        /// Depending on the command the zone state is set.
        /// E.g. if the command is 'Turn Zone Off' (see <see cref="ENuvoEssentiaCommands"/>) the
        /// power state of the zone is set to off.
        /// </summary>
        /// <param name="command">Command, which changes the zone state.</param>
        public void updateZoneState(NuvoEssentiaSingleCommand command)
        {
            _log.Trace(m => m("Update Zone state in control {0}. Command='{1}'", this.Name, command));
            if (command.ZoneId != ENuvoEssentiaZones.NoZone)
            {
                // Select zone received by command string
                cmbZoneSelect.SelectedIndex = (int)command.ZoneId - 1;

                switch (command.Command)
                {
                case ENuvoEssentiaCommands.SetVolume:
                    // DOESN'T trigger the method trackVolume_Scroll()
                    trackVolume.Value = Math.Abs(NuvoEssentiaCommand.calcVolume2NuvoControl(command.VolumeLevel));
                    VolumeLevel_Changed();
                    break;

                case ENuvoEssentiaCommands.SetSource:
                    // triggers the method cmbSourceSelect_SelectedIndexChanged()
                    cmbSourceSelect.SelectedIndex = (int)command.SourceId - 1;
                    break;

                case ENuvoEssentiaCommands.TurnZoneON:
                    // triggers the method cmbPowerStatusSelect_SelectedIndexChanged()
                    cmbPowerStatusSelect.SelectedItem = EZonePowerStatus.ZoneStatusON.ToString();
                    break;

                case ENuvoEssentiaCommands.TurnZoneOFF:
                    // triggers the method cmbPowerStatusSelect_SelectedIndexChanged()
                    cmbPowerStatusSelect.SelectedItem = EZonePowerStatus.ZoneStatusOFF.ToString();
                    break;

                case ENuvoEssentiaCommands.TurnALLZoneOFF:
                    //TODO: Switch off all zones and send response
                    break;

                case ENuvoEssentiaCommands.ReadVersion:
                    // do nothing
                    break;

                case ENuvoEssentiaCommands.ReadStatusCONNECT:
                case ENuvoEssentiaCommands.ReadStatusZONE:
                    break;
                }
            }
        }
Пример #6
0
        public void SendCommandTest2()
        {
            INuvoEssentiaCommand command = new NuvoEssentiaCommand(ENuvoEssentiaCommands.SetZoneStatus, ENuvoEssentiaZones.Zone5, ENuvoEssentiaSources.Source4, -30);

            _protDriver.onCommandReceived    += new ProtocolCommandReceivedEventHandler(_protDriver_onCommandReceived);
            _protDriver.onDeviceStatusUpdate += new ProtocolDeviceUpdatedEventHandler(_protDriver_onDeviceStatusUpdate);
            _protDriver.onZoneStatusUpdate   += new ProtocolZoneUpdatedEventHandler(_protDriver_onZoneStatusUpdate);
            _protDriver.SendCommand(_zoneAddress, command);
            Thread.Sleep(2000);                                                 // give control to worker thread

            _nuvoTelegramMock.passDataToTestClass("Z05PWRON,SRC3,GRP0,VOL-50"); // as answer to "Z05ON" (TurnZoneOn)
            _nuvoTelegramMock.passDataToTestClass("Z05PWRON,SRC3,GRP0,VOL-30"); // as answer to "Z05VOL30" (SetVolume)
            _nuvoTelegramMock.passDataToTestClass("Z05PWRON,SRC4,GRP0,VOL-50"); // as answer to "Z05SRC4" (SetSource)

            Assert.AreEqual(0, _protDeviceUpdatedEventArgs.Count);              // get ZERO device state update events
            Assert.AreEqual(3, _protCommandReceivedEventArgs.Count);            // get THREE command events
            Assert.AreEqual(1, _protZoneUpdatedEventArgs.Count);                // get ONE zone state update event
        }
Пример #7
0
 public void calcVolume2NuvoEssentiaTest()
 {
     Assert.AreEqual(-79, NuvoEssentiaCommand.calcVolume2NuvoEssentia(0));
     Assert.AreEqual(0, NuvoEssentiaCommand.calcVolume2NuvoEssentia(100));
     Assert.AreEqual(-39, NuvoEssentiaCommand.calcVolume2NuvoEssentia(50));
 }
Пример #8
0
 public void calcVolume2NuvoControlTest()
 {
     Assert.AreEqual(0, NuvoEssentiaCommand.calcVolume2NuvoControl(-79));
     Assert.AreEqual(100, NuvoEssentiaCommand.calcVolume2NuvoControl(0));
     Assert.AreEqual(50, NuvoEssentiaCommand.calcVolume2NuvoControl(-39));
 }