Beispiel #1
0
        public override void Blinds(uint channel, BlindsCommand command)
        {
            if (!_blindRelays.ContainsKey(channel))
            {
                return;
            }
            var relays = _blindRelays[channel];

            switch (command)
            {
            case BlindsCommand.Up:
                relays.Up();
                break;

            case BlindsCommand.Down:
                relays.Down();
                break;

            case BlindsCommand.Stop:
                relays.StopUsingPulseBoth();
                break;

            default:
                throw new ArgumentOutOfRangeException("command");
            }
        }
Beispiel #2
0
        public async Task SendCommand(BlindsChannel channel, BlindsCommand blindsCommand)
        {
            const string preamble = "11011101001101101";

            (string cmd, string crc)cmdBits = blindsCommand switch
            {
                BlindsCommand.Up => (cmd : "001110001000", crc : "1000"),
                BlindsCommand.Down => (cmd : "100010001000", crc : "0011"),
                BlindsCommand.Stop => (cmd : "101010000000", crc : "1001"),
                BlindsCommand.Open => (cmd : "001110000000", crc : "0100"),
                BlindsCommand.Close => (cmd : "100010000000", crc : "1011"),
                _ => throw new ArgumentOutOfRangeException(nameof(blindsCommand), blindsCommand, null)
            };

            (string channel, string crc)chBits = channel switch
            {
                BlindsChannel.Channel1 => (channel : "1000", crc : "0011"),
                BlindsChannel.Channel2 => (channel : "0100", crc : "1101"),
                BlindsChannel.Channel3 => (channel : "1100", crc : ""),
                BlindsChannel.Channel4 => (channel : "0010", crc : ""),
                BlindsChannel.Channel5 => (channel : "1010", crc : ""),
                BlindsChannel.Channel6 => (channel : "0110", crc : "")
            };

            var bits = preamble + chBits.channel + cmdBits.cmd + chBits.crc + cmdBits.crc + "1";
            var data = bits.SelectMany(bit =>
                                       bit == '1' ?
                                       new [] { new RadioSymbol(725, true), new RadioSymbol(350, false) } :
                                       new [] { new RadioSymbol(350, true), new RadioSymbol(725, false) }
                                       ).ToList();

            var buffer  = _startPattern.Concat(data);
            var buffer2 = _repeatPattern.Concat(data).ToArray();

            for (int i = 0; i < 10; ++i)
            {
                buffer = buffer.Concat(buffer2);
            }

            await _transmitter433.Transmit(buffer.ToArray());
        }
    }
Beispiel #3
0
 public override void Blinds(uint channel, BlindsCommand command)
 {
     throw new NotImplementedException();
 }
Beispiel #4
0
 public abstract void Blinds(uint channel, BlindsCommand command);