public void FromByteTest()
        {
            // arrange
            var testee = new CardRelayState(8, 1);

            // act
            testee.FromByte(Convert.ToByte(164));

            // assert
            Assert.AreEqual(false, testee.CardState[0]);
            Assert.AreEqual(false, testee.CardState[1]);
            Assert.AreEqual(true, testee.CardState[2]);
            Assert.AreEqual(false, testee.CardState[3]);
            Assert.AreEqual(false, testee.CardState[4]);
            Assert.AreEqual(true, testee.CardState[5]);
            Assert.AreEqual(false, testee.CardState[6]);
            Assert.AreEqual(true, testee.CardState[7]);
        }
        public void DelSingleCommandTest()
        {
            // arrange
            var fullState = new CardRelayState(Conrad8RelayCard.ConstNumberOfCardPorts, ConstTesteeCardAddress);
            fullState.FromByte(255);
            this.testee.SetPortCommand(fullState);
            Thread.Sleep(500);

            // act
            for (var i = 0; i < 8; i++)
            {
                var state = new CardRelayState(Conrad8RelayCard.ConstNumberOfCardPorts, ConstTesteeCardAddress);
                state.CardState[i] = true;
                this.testee.DelSingleCommand(state);

                Thread.Sleep(500);
            }

            // assert
            // ...Verify events on card!
        }
예제 #3
0
        /// <summary>
        /// Executes a ToggleCommand on the card
        /// </summary>
        private static void Toggle()
        {
            consoleLog.Debug("Command: Toggle");
            var address = Convert.ToInt16(RuntimeOptions.CommandMask.Split(';')[0]);
            var portPattern = Convert.ToByte(RuntimeOptions.CommandMask.Split(';')[1], 2);
            consoleLog.Debug("Toggle address param is: " + address + ", data byte: " + portPattern.ToString());

            var state = new CardRelayState(Conrad8RelayCard.ConstNumberOfCardPorts, address);
            state.FromByte(portPattern);
            var res = conradCard.ToggleCommand(state);
            consoleLog.Info("Result frame: " + res.CardResponseFrame);
            consoleLog.Info("Result state: " + res.RelayState);
        }
예제 #4
0
 /// <summary>
 /// Single switch command issued by setPort command
 /// </summary>
 /// <param name="addr">The card addr.</param>
 /// <param name="value">The data byte.</param>
 /// <param name="holdTime">The hold time in ms.</param>
 private static void HardwareTestSwitchSingleValue(int addr, byte value, int holdTime)
 {
     var newState = new CardRelayState(Conrad8RelayCard.ConstNumberOfCardPorts, addr);
     consoleLog.Debug("Hardwaretest, newState: " + value);
     newState.FromByte(value);
     var res = conradCard.SetPortCommand(newState);
     consoleLog.Info("Result frame: " + res);
     Thread.Sleep(holdTime - 20);
 }
        public void ToggleCommandManyTest()
        {
            // arrange
            var zeroState = new CardRelayState(8, 1);
            zeroState.FromByte(0);
            this.testee.SetPortCommand(zeroState);
            Thread.Sleep(500);

            // act
            for (var i = 0; i < 4; i++)
            {
                this.testee.ToggleCommand(new CardRelayState(Conrad8RelayCard.ConstNumberOfCardPorts, ConstTesteeCardAddress, 1, 0, 1, 0, 1, 0, 1, 0));
                Thread.Sleep(500);
                this.testee.ToggleCommand(new CardRelayState(Conrad8RelayCard.ConstNumberOfCardPorts, ConstTesteeCardAddress, 1, 0, 1, 0, 1, 0, 1, 0));
                Thread.Sleep(500);

                this.testee.ToggleCommand(new CardRelayState(Conrad8RelayCard.ConstNumberOfCardPorts, ConstTesteeCardAddress, 0, 1, 0, 1, 0, 1, 0, 1));
                Thread.Sleep(500);
                this.testee.ToggleCommand(new CardRelayState(Conrad8RelayCard.ConstNumberOfCardPorts, ConstTesteeCardAddress, 0, 1, 0, 1, 0, 1, 0, 1));
                Thread.Sleep(500);
            }

            // assert
            // ...Verify events on card!
        }
        public void SetPortCommandIterationTest()
        {
            // arrange
            const int Sleep = 60;

            // act
            for (var i = 256; i > 192; i--)
            {
                var state = new CardRelayState(Conrad8RelayCard.ConstNumberOfCardPorts, ConstTesteeCardAddress);
                state.FromByte((byte)i);

                this.testee.SetPortCommand(state);
                Thread.Sleep(Sleep);
            }
        }