Example #1
0
        public bool SendCommand(CommandsType CommandType, int inValue1, int inValue2)
        {
            bool retVal = false;

            string cmdText = BuildCommand(CommandType, inValue1, inValue2);

            try
            {
                RS232.SendCommand(cmdText);
                retVal = true;
            }
            catch (Exception ex)
            {
                retVal = false;
            }

            return retVal;
        }
        public IControlebel GetCommand(CommandsType commandType, out ICommand onCommand, out ICommand offCommand)
        {
            IControlebel controlebel;

            switch (commandType)
            {
            case CommandsType.Light:
                controlebel = new Light(win);
                onCommand   = new LightOnCommand(controlebel);
                offCommand  = new LightOffCommand(controlebel);
                break;

            case CommandsType.Garage:
                controlebel = new Garage(win);
                onCommand   = new GarageDoorOpenCommand(controlebel);
                offCommand  = new GarageDoorCloseCommand(controlebel);
                break;

            case CommandsType.Stereo:
                controlebel = new Stereo(win);
                onCommand   = new StereoOnWithCDCommand(controlebel);
                offCommand  = new StereoOffCommand(controlebel);
                break;

            case CommandsType.MacroCommand:
                controlebel = default(IControlebel);
                onCommand   = new MacroCommand();
                offCommand  = new MacroCommand();
                break;

            default:
                controlebel = default(IControlebel);
                onCommand   = default(ICommand);
                offCommand  = default(ICommand);
                break;
            }

            return(controlebel);
        }
Example #3
0
        private string BuildCommand(CommandsType inCommandType, int inValue1, int inValue2)
        {
            // @Prefix@   @Seperator@   @CommandType@   @Seperator@   @CommandValue@   @Seperator@   @Suffix@
            StringBuilder sb = new StringBuilder();

            sb.Append(RS232Class.START_TOKEN);
            sb.Append(RS232Class.SEPERATOR_TOKEN);

            sb.AppendFormat("{0:00}", (int)inCommandType);
            sb.Append(RS232Class.SEPERATOR_TOKEN);

            sb.AppendFormat("{0:00}", inValue1);
            sb.Append(RS232Class.SEPERATOR_TOKEN);

            sb.AppendFormat("{0:00}", inValue2);
            sb.Append(RS232Class.SEPERATOR_TOKEN);

            sb.Append(RS232Class.END_TOKEN);

            return sb.ToString();
        }
Example #4
0
 public IMessageHandlerPipeline <T> Register <TCommand>() where TCommand : IParameterizedCommand <T>
 {
     CommandsType.Add(typeof(TCommand));
     return(this);
 }