Exemplo n.º 1
0
        ///////////////////////////////////////////////////////////////////////
        private void SendCommand_Async(X10Command command)
        {
            _logger.Debug("queueing {0}", command);

            ThreadPool.QueueUserWorkItem(delegate {
                SendCommand_Sync(command);
            });
        }
Exemplo n.º 2
0
 ///////////////////////////////////////////////////////////////////////
 public void Send(X10Command command)
 {
     if (Settings.Default.SendAsync) {
         SendCommand_Async(command);
     } else {
         SendCommand_Sync(command);
     }
 }
Exemplo n.º 3
0
        ///////////////////////////////////////////////////////////////////////
        private void SendDeviceCommand(X10Command.Command action)
        {
            var cmd = new X10Command {
                House = House,
                Device = Unit,
                Action = action
            };

            Controller.Send(cmd);
        }
Exemplo n.º 4
0
        ///////////////////////////////////////////////////////////////////////
        private void SendCommand_Sync(X10Command command)
        {
            _logger.Info("send: {0}", command);

            _swatch.Clock(delegate {
                SendCommand(command);
            });

            _logger.Debug("{0} sent in {1} ms", command, _swatch.ElapsedMilliseconds);
        }
Exemplo n.º 5
0
 ///////////////////////////////////////////////////////////////////////
 protected abstract void SendCommand(X10Command command);
Exemplo n.º 6
0
        ///////////////////////////////////////////////////////////////////////
        public static X10Command Parse(String x10)
        {
            var cmd = new X10Command();
            var match = kCommandRE.Match(x10);

            if (match.Success) {
                cmd.House = match.Groups["house"].Value[0];

                if (match.Groups["device"].Success) {
                    cmd.Device = byte.Parse(match.Groups["device"].Value);
                }

                String action = null;
                if (match.Groups["devcmd"].Success) {
                    action = match.Groups["devcmd"].Value;
                } else if (match.Groups["allcmd"].Success) {
                    action = match.Groups["allcmd"].Value;
                }

                cmd.Action = (Command) Enum.Parse(typeof(Command), action);
            }

            return cmd;
        }