/////////////////////////////////////////////////////////////////////// private void SendCommand_Async(X10Command command) { _logger.Debug("queueing {0}", command); ThreadPool.QueueUserWorkItem(delegate { SendCommand_Sync(command); }); }
/////////////////////////////////////////////////////////////////////// public void Send(X10Command command) { if (Settings.Default.SendAsync) { SendCommand_Async(command); } else { SendCommand_Sync(command); } }
/////////////////////////////////////////////////////////////////////// private void SendDeviceCommand(X10Command.Command action) { var cmd = new X10Command { House = House, Device = Unit, Action = action }; Controller.Send(cmd); }
/////////////////////////////////////////////////////////////////////// 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); }
/////////////////////////////////////////////////////////////////////// protected abstract void SendCommand(X10Command command);
/////////////////////////////////////////////////////////////////////// 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; }