Exemplo n.º 1
0
        private void cmdPrevious_Click(object sender, EventArgs e)
        {
            if (null != m_Command)
            {
                if (rbNoResponse.Checked)
                {
                    m_Command.ResponseMode = BM_CMD_RT.BM_CMD_RT_NO_RESPONSE;
                }
                else if (rbNoTimeout.Checked)
                {
                    m_Command.ResponseMode = BM_CMD_RT.BM_CMD_RT_NO_TIME_OUT;
                }
                else
                {
                    System.UInt16 hwResult = 0;
                    if (DECBuilder.DECStringToWord(txtTimeout.Text, ref hwResult))
                    {
                        m_Command.TimeOut = hwResult;
                    }
                }
            }


            frmCommandWizardStepE CommandWizard = new frmCommandWizardStepE(m_Command);

            this.Hide();
            CommandWizard.Show();
            this.Dispose();
        }
Exemplo n.º 2
0
        private void txtTimeout_TextChanged(object sender, EventArgs e)
        {
            System.UInt16 hwResult = 0;
            if (false == DECBuilder.DECStringToWord(txtTimeout.Text, ref hwResult))
            {
                //! illegal input
                txtTimeout.Text = "";
                cmdNext.Enabled = false;
            }
            else
            {
                cmdNext.Enabled = true;
            }

            if ((txtTimeout.Text.StartsWith("-")) || (txtTimeout.Text.StartsWith("+")))
            {
                if ((txtTimeout.Text.StartsWith("-")))
                {
                    txtTimeout.Text = "";
                    cmdNext.Enabled = false;
                }
                else
                {
                    txtTimeout.MaxLength = 6;
                }
            }
            else
            {
                txtTimeout.MaxLength = 5;
            }
        }
        private void combResponseType_TextChanged(object sender, EventArgs e)
        {
            System.UInt16 hwResult = 0;
            if (false == DECBuilder.DECStringToWord(combResponseType.Text, ref hwResult))
            {
                //! illegal input
                combResponseType.Text = "";
            }

            if ((combResponseType.Text.StartsWith("-")) || (combResponseType.Text.StartsWith("+")))
            {
                if ((combResponseType.Text.StartsWith("-")))
                {
                    combResponseType.Text = "";
                }
                else
                {
                    combResponseType.MaxLength = 6;
                }
            }
            else
            {
                combResponseType.MaxLength = 5;
            }
        }
Exemplo n.º 4
0
        private void cmdNext_Click(object sender, EventArgs e)
        {
            if (null != m_Command)
            {
                if (rbNoResponse.Checked)
                {
                    m_Command.ResponseMode = BM_CMD_RT.BM_CMD_RT_NO_RESPONSE;
                }
                else if (rbNoTimeout.Checked)
                {
                    m_Command.ResponseMode = BM_CMD_RT.BM_CMD_RT_NO_TIME_OUT;
                }
                else
                {
                    System.UInt16 hwResult = 0;
                    if (DECBuilder.DECStringToWord(txtTimeout.Text, ref hwResult))
                    {
                        m_Command.TimeOut = hwResult;
                    }
                    else
                    {
                        MessageBox.Show
                        (
                            "Please Enter a legal timeout period or select a response mode.",
                            "Wizard Warnning",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Warning
                        );
                        return;
                    }
                }

                this.Hide();
                switch (m_Command.Type)
                {
                case BM_CMD_TYPE.BM_CMD_TYPE_NO_PARAMETER:
                case BM_CMD_TYPE.BM_CMD_TYPE_BLOCK_READ:
                case BM_CMD_TYPE.BM_CMD_TYPE_WORD_READ:
                {
                    frmCommandWizardStepH CommandWizard = new frmCommandWizardStepH(m_Command);
                    CommandWizard.Show();
                }
                break;

                case BM_CMD_TYPE.BM_CMD_TYPE_BLOCK_WRITE:
                {
                    frmCommandWizardStepGWB CommandWizard = new frmCommandWizardStepGWB(m_Command);
                    CommandWizard.Show();
                }
                break;

                case BM_CMD_TYPE.BM_CMD_TYPE_WORD_WRITE:
                {
                    frmCommandWizardStepGWW CommandWizard = new frmCommandWizardStepGWW(m_Command);
                    CommandWizard.Show();
                }
                break;
                }
                this.Dispose();
            }
        }
        private void cmdApply_Click(object sender, EventArgs e)
        {
            System.Byte[] cCommand = null;
            //! get command
            txtCommand.Text = txtCommand.Text.Trim().ToUpper();
            if (false == HEXBuilder.HEXStringToByteArray(txtCommand.Text, ref cCommand))
            {
                //! illegal command
                MessageBox.Show
                (
                    "Please enter a legal command byte!",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
                return;
            }

            //! get target address
            System.Byte[] cAddress    = new Byte[1];
            System.Byte[] cSubAddress = new Byte[1];
            if (-1 == combAddress.SelectedIndex)
            {
                //! text
                combAddress.Text = combAddress.Text.Trim().ToUpper();
                if (false == HEXBuilder.HEXStringToByteArray(combAddress.Text, ref cAddress))
                {
                    //! illegal command
                    MessageBox.Show
                    (
                        "Please enter a legal target address!",
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                    );
                    return;
                }
            }
            else
            {
                switch (combAddress.SelectedIndex)
                {
                case 0:                         //!< Adapter
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_ADAPTER;
                    break;

                case 1:                         //!< SMBus
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SMBUS;
                    break;

                case 2:
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SMBUS_PEC;
                    break;

                case 3:                         //!< UART
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_UART;
                    break;

                case 4:
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_UART_PEC;
                    break;

                case 5:                         //!< Single wire UART
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART;
                    break;

                case 6:
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART_PEC;
                    break;

                case 7:                         //!< SPI
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SPI;
                    break;

                case 8:
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SPI_PEC;
                    break;

                case 9:                         //!< I2C
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_I2C;
                    break;

                case 10:
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_I2C_PEC;
                    break;

                case 11:                        //!< Loader
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_LOADER;
                    break;

                case 12:                        //!< Charger
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_CHARGER;
                    break;

                case 13:                        //!< printer
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_PRN;
                    break;

                case 14:                        //!< LCD
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_LCD;
                    break;

                case 15:                         //!< SMBus Extend
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SMBUS_EX;
                    break;

                case 16:
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SMBUS_PEC_EX;
                    break;

                case 17:                         //!< UART Extend
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_UART_EX;
                    break;

                case 18:
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_UART_PEC_EX;
                    break;

                case 19:                         //!< Single wire UART Extend
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART_EX;
                    break;

                case 20:
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART_PEC_EX;
                    break;

                case 21:                         //!< SPI Extend
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SPI_EX;
                    break;

                case 22:
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SPI_PEC_EX;
                    break;

                case 23:                         //!< I2C Extend
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_I2C_EX;
                    break;

                case 24:
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_I2C_PEC_EX;
                    break;

                case 25:                        //!< All
                    cAddress[0] = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_ALL;
                    break;
                }
            }

            //! get sub address
            do
            {
                if (false == HEXBuilder.HEXStringToByteArray(txtSubAddress.Text, ref cSubAddress))
                {
                    //! illegal command
                    MessageBox.Show
                    (
                        "Please enter a legal optinal sub address!",
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                    );
                    return;
                }
            }while (false);

            //! get response type
            System.UInt16 hwTimeOut = 0;
            if (-1 == combResponseType.SelectedIndex)
            {
                if (false == DECBuilder.DECStringToWord(combResponseType.Text, ref hwTimeOut))
                {
                    combResponseType.Text = "300";
                    hwTimeOut             = 300;
                }
            }
            else
            {
                switch (combResponseType.SelectedIndex)
                {
                case 0:
                    hwTimeOut = (UInt16)BM_CMD_RT.BM_CMD_RT_NO_RESPONSE;
                    break;

                case 1:
                    hwTimeOut = (UInt16)BM_CMD_RT.BM_CMD_RT_NO_TIME_OUT;
                    break;
                }
            }

            //! handle command type

            switch (combCommandType.SelectedIndex)
            {
            case 1:                     //!< write word
                System.UInt16[] hwWriteWord = null;
                if (false == HEXBuilder.HEXStringToU16Array(txtWriteWord.Text, ref hwWriteWord))
                {
                    //! illegal command
                    MessageBox.Show
                    (
                        "Please enter a legal word value!",
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                    );
                    return;
                }

                ((ESCommandWriteWord)m_Command).DataValue = hwWriteWord[0];
                break;

            case 2:                     //!< read word
                break;

            case 3:                     //!< write block
                System.Byte[] BlockWriteBuffer = null;

                if (checkWriteBlockShowHEX.Checked)
                {
                    //! hex string
                    if (false == HEXBuilder.HEXStringToByteArray(txtWriteBlock.Text, ref BlockWriteBuffer, false))
                    {
                        //! illegal command
                        MessageBox.Show
                        (
                            "Please enter a legal HEX String",
                            "Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Warning
                        );
                        return;
                    }

                    txtWriteBlock.Text = HEXBuilder.ByteArrayToHEXString(BlockWriteBuffer);
                }
                else
                {
                    Char[] CharBuffer = txtWriteBlock.Text.ToCharArray();
                    BlockWriteBuffer = new System.Byte[CharBuffer.Length];
                    //! Just string

                    for (System.Int32 n = 0; n < BlockWriteBuffer.Length; n++)
                    {
                        BlockWriteBuffer[n] = (System.Byte)CharBuffer[n];
                    }
                }
                m_Command.Data = BlockWriteBuffer;
                break;

            case 4:                     //!< read block
                break;

            case 0:                     //!< just command
                break;

            default:
                break;
            }

            m_Command.Command      = cCommand[0];
            m_Command.AddressValue = cAddress[0];
            m_Command.SubAddress   = cSubAddress[0];
            m_Command.TimeOut      = hwTimeOut;
            m_Command.Description  = textBrief.Text;

            if (null != CommandEditEvent)
            {
                //! raising event
                CommandEditEvent(BM_CMD_EDIT_RESULT.BM_CMD_EDIT_FINISH, m_Command);
            }

            this.Dispose();
        }