Ejemplo n.º 1
0
 protected void OnCommandRecived(CommCommand inCommand)
 {
     if (CommandRecived != null)
     {
         CommandRecived(inCommand);
     }
 }
Ejemplo n.º 2
0
 void mComm_CommandRecived(CommCommand inCommand)
 {
     switch (inCommand.CommandType)
     {
         case (int)CommandsType.SET_VALUE:
             mComm.SendCommand(CommandsType.SET_VALUE, inCommand.Value1, inCommand.Value2);
             break;
         default:
             break;
     }
 }
Ejemplo n.º 3
0
        void comm_CommandRecived(CommCommand inCommand)
        {
            if (InvokeRequired)
            {
                this.Invoke(new EventHandler(delegate { comm_CommandRecived(inCommand); }));
            }
            else
            {

                if (inCommand.CommandType == (int)CommandsType.KEY_PRESSED)
                {
                    SetKeyPanelActive(inCommand.Value1 - (int)Enums.Commands.KEY1);
                    Application.DoEvents();
                    m_ActivePanel.HandleCommand((Enums.Commands)inCommand.Value1);
                }
                else if (inCommand.CommandType == (int)CommandsType.SET_VALUE)
                {
                    mModel.SetVar(inCommand.Value1, (char)inCommand.Value2);
                }
                else if (inCommand.CommandType == (int)CommandsType.GET_VALUE)
                {
                }
                else if (inCommand.CommandType == (int)CommandsType.PROGRAM_SELECT)
                {
                    this.ShowActivePanelFromCommand((Enums.FormsNames)inCommand.Value1);
                }
                else if (inCommand.CommandType == (int)CommandsType.ENABLE_COM_2)
                {
                    m_ActivePanel.HandleCommand(inCommand.Value1 != 0 ? Enums.Commands.COM_2_ENABLE : Enums.Commands.COM_2_DISABLE);
                }
                else if (inCommand.CommandType == (int)CommandsType.SWITCH_HANDLE_COM_2)
                {
                    m_ActivePanel.HandleCommand(Enums.Commands.COM_2_HANDLE_SWITCHED);
                }
                else // generic handeling
                {
                    m_ActivePanel.HandleCommand((Enums.Commands)inCommand.Value1);
                }
            }
        }
Ejemplo n.º 4
0
        CommCommand ParseCommand(string command)
        {
            CommCommand cmd = new CommCommand();

            if (command[0] == RS232Class.START_TOKEN)
            {
                if (command[1] == RS232Class.SEPERATOR_TOKEN)
                {
                    // read command
                    // wait for the next char
                    cmd.CommandType = (command[2] - 48) * 10 + command[3] - 48;

                    if (command[4] == RS232Class.SEPERATOR_TOKEN)
                    {
                        // read value1
                        cmd.Value1 = (command[5] - 48) * 10 + command[6] - 48;

                        if (command[7] == RS232Class.SEPERATOR_TOKEN)
                        {
                            // read value2
                            cmd.Value2 = (command[8] - 48) * 10 + command[9] - 48;
                            OnCommandRecived(cmd);
                        }
                    }
                }
            }
            return cmd;
        }
Ejemplo n.º 5
0
        CommCommand ParseCommand(string command)
        {
            CommCommand cmd = new CommCommand();

            try
            {

                if (command[0] == RS232Class.START_TOKEN)
                {
                    if (command[1] == RS232Class.SEPERATOR_TOKEN)
                    {
                        // read command
                        // wait for the next char
                        cmd.CommandType = (command[2] - 48) * 10 + command[3] - 48;

                        if (command[4] == RS232Class.SEPERATOR_TOKEN)
                        {
                            // read value1
                            cmd.Value1 = (command[5] - 48) * 10 + command[6] - 48;

                            if (command[7] == RS232Class.SEPERATOR_TOKEN)
                            {
                                // read value2
                                cmd.Value2 = (command[8] - 48) * 10 + command[9] - 48;
                                OnCommandRecived(cmd);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // problem with command
                Logger.Instance.WriteLine("error in Parse Command");
            }
            return cmd;
        }
Ejemplo n.º 6
0
 void comm_CommandRecived(CommCommand inCommand)
 {
     if (inCommand.CommandType == (int)CommandsType.KEY_PRESSED)
     {
         m_ActiveForm.HandleCommand((Enums.Commands)inCommand.Value1);
     }
     else if (inCommand.CommandType == (int)CommandsType.SET_VALUE)
     {
         mModel.SetVar(inCommand.Value1, (char)inCommand.Value2);
     }
     else if (inCommand.CommandType == (int)CommandsType.GET_VALUE)
     {
     }
     else if (inCommand.CommandType == (int)CommandsType.PROGRAM_SELECT)
     {
         this.ShowActiveForm((Enums.FormsNames)inCommand.Value1);
     }
 }