Ejemplo n.º 1
0
        private void txtCommandBrief_TextChanged(object sender, EventArgs e)
        {
            if (checkWriteBlockShowHEX.Checked)
            {
                System.Byte[] cResult = null;

                if (null != txtCommandBrief.Text)
                {
                    //! hex string model
                    if (!HEXBuilder.HEXStringToByteArray(txtCommandBrief.Text, ref cResult))
                    {
                        MessageBox.Show
                        (
                            "Please Enter a legal HEX string.",
                            "Wizard Warnning",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Warning
                        );
                        txtCommandBrief.Text = txtCommandBrief.Text.Substring(0, txtCommandBrief.Text.Length - 1);
                        //cmdNext.Enabled = false;
                    }
                    else
                    {
                        cmdNext.Enabled = true;
                    }
                }
            }
            else
            {
                cmdNext.Enabled = true;
            }
        }
        private void cmdNext_Click(object sender, EventArgs e)
        {
            if (null != m_Command)
            {
                System.Byte[] cResult = null;
                if (HEXBuilder.HEXStringToByteArray(txtCommand.Text, ref cResult))
                {
                    //! legal input
                    m_Command.Command = cResult[0];
                }
                else
                {
                    MessageBox.Show
                    (
                        "Please Enter a legal command byte in HEX string format.",
                        "Wizard Warnning",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning
                    );
                    return;
                }
            }

            frmCommandWizardStepD CommandWizard = new frmCommandWizardStepD(m_Command);

            this.Hide();
            CommandWizard.Show();
            this.Dispose();
        }
 private void txtSubAddress_TextChanged(object sender, EventArgs e)
 {
     System.Byte[] cResult = null;
     if (false == HEXBuilder.HEXStringToByteArray(txtSubAddress.Text, ref cResult))
     {
         //! illegal input
         txtSubAddress.Text = "00";
     }
 }
 private void combAddress_TextUpdate(object sender, EventArgs e)
 {
     System.Byte[] cResult = null;
     if (false == HEXBuilder.HEXStringToByteArray(combAddress.Text, ref cResult))
     {
         //! illegal input
         combAddress.Text = "";
     }
 }
Ejemplo n.º 5
0
        private void cmdNext_Click(object sender, EventArgs e)
        {
            if (null != m_Command)
            {
                if (checkWriteBlockShowHEX.Checked)
                {
                    //! hex string
                    System.Byte[] cResult = null;

                    //! hex string model
                    if (HEXBuilder.HEXStringToByteArray(txtCommandBrief.Text, ref cResult))
                    {
                        m_Command.Data = cResult;
                    }
                    else
                    {
                        MessageBox.Show
                        (
                            "Please Enter a legal HEX string.",
                            "Wizard Warnning",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Warning
                        );
                        return;
                    }
                }
                else
                {
                    //! normal string
                    System.Byte[] BlockWriteBuffer = null;
                    if (null != txtCommandBrief.Text)
                    {
                        Char[] CharBuffer = txtCommandBrief.Text.ToCharArray();
                        BlockWriteBuffer = new System.Byte[CharBuffer.Length];

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

                        m_Command.Data = BlockWriteBuffer;
                    }
                    else
                    {
                        m_Command.Data = new Byte[0];
                    }
                }
            }

            frmCommandWizardStepH CommandWizard = new frmCommandWizardStepH(m_Command);

            this.Hide();
            CommandWizard.Show();
            this.Dispose();
        }
 private void txtCommand_TextChanged(object sender, EventArgs e)
 {
     System.Byte[] cResult = null;
     if (false == HEXBuilder.HEXStringToByteArray(txtCommand.Text, ref cResult))
     {
         //! illegal input
         txtCommand.Text = "";
         cmdNext.Enabled = false;
     }
     else
     {
         cmdNext.Enabled = true;
     }
 }
 private void combCommandAddress_TextUpdate(object sender, EventArgs e)
 {
     System.Byte[] cResult = null;
     if (false == HEXBuilder.HEXStringToByteArray(combCommandAddress.Text, ref cResult))
     {
         //! illegal input
         combCommandAddress.Text = "";
         cmdNext.Enabled         = false;
     }
     else
     {
         cmdNext.Enabled = true;
     }
 }
Ejemplo n.º 8
0
        private void cmdPrevious_Click(object sender, EventArgs e)
        {
            if (null != m_Command)
            {
                if (checkWriteBlockShowHEX.Checked)
                {
                    //! hex string
                    System.Byte[] cResult = null;

                    //! hex string model
                    if (HEXBuilder.HEXStringToByteArray(txtCommandBrief.Text, ref cResult))
                    {
                        m_Command.Data = cResult;
                    }
                }
                else
                {
                    //! normal string
                    System.Byte[] BlockWriteBuffer = null;

                    if (null != txtCommandBrief.Text)
                    {
                        Char[] CharBuffer = txtCommandBrief.Text.ToCharArray();
                        BlockWriteBuffer = new System.Byte[CharBuffer.Length];

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

                        m_Command.Data = BlockWriteBuffer;
                    }
                    else
                    {
                        m_Command.Data = new Byte[0];
                    }
                }
            }

            frmCommandWizardStepF CommandWizard = new frmCommandWizardStepF(m_Command);

            this.Hide();
            CommandWizard.Show();
            this.Dispose();
        }
        private void cmdPrevious_Click(object sender, EventArgs e)
        {
            if (null != m_Command)
            {
                System.Byte[] cResult = null;
                if (HEXBuilder.HEXStringToByteArray(txtCommand.Text, ref cResult))
                {
                    //! legal input
                    m_Command.Command = cResult[0];
                }
            }

            frmCommandWizardStepB CommandWizard = new frmCommandWizardStepB(m_Command);

            this.Hide();
            CommandWizard.Show();
            this.Dispose();
        }
Ejemplo n.º 10
0
        private void checkWriteBlockShowHEX_CheckedChanged(object sender, EventArgs e)
        {
            if (checkWriteBlockShowHEX.Checked)
            {
                //! HEX string
                //! normal string
                System.Byte[] BlockWriteBuffer = null;

                Char[] CharBuffer = txtCommandBrief.Text.ToCharArray();
                BlockWriteBuffer = new System.Byte[CharBuffer.Length];

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

                txtCommandBrief.Text = HEXBuilder.ByteArrayToHEXString(BlockWriteBuffer);
            }
            else
            {
                //! normal string
                System.Byte[] cResult = null;

                //! hex string model
                if (HEXBuilder.HEXStringToByteArray(txtCommandBrief.Text, ref cResult))
                {
                    StringBuilder sbTempString = new StringBuilder();

                    for (System.Int32 n = 0; n < cResult.Length; n++)
                    {
                        sbTempString.Append((Char)cResult[n]);

                        txtCommandBrief.Text = sbTempString.ToString();
                    }
                }
            }
        }
        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();
        }
        private void cmdNext_Click(object sender, EventArgs e)
        {
            if (null != m_Command)
            {
                if (-1 == combCommandAddress.SelectedIndex)
                {
                    System.Byte[] cResult = null;
                    if (HEXBuilder.HEXStringToByteArray(combCommandAddress.Text, ref cResult))
                    {
                        m_Command.AddressValue = cResult[0];
                    }
                }
                else
                {
                    switch (combCommandAddress.SelectedIndex)
                    {
                    case 0:                         //!< Adapter
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_ADAPTER;
                        break;

                    case 1:                         //!< SMBus
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SMBUS;
                        break;

                    case 2:
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SMBUS_PEC;
                        break;

                    case 3:                         //!< UART
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_UART;
                        break;

                    case 4:
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_UART_PEC;
                        break;

                    case 5:                         //!< Single wire UART
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART;
                        break;

                    case 6:
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART_PEC;
                        break;

                    case 7:                         //!< SPI
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SPI;
                        break;

                    case 8:
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SPI_PEC;
                        break;

                    case 9:                         //!< I2C
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_I2C;
                        break;

                    case 10:
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_I2C_PEC;
                        break;

                    case 11:                        //!< Loader
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_LOADER;
                        break;

                    case 12:                        //!< Charger
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_CHARGER;
                        break;

                    case 13:                        //!< printer
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_PRN;
                        break;

                    case 14:                        //!< LCD
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_LCD;
                        break;

                    case 15:                         //!< SMBus Extend
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SMBUS_EX;
                        break;

                    case 16:
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SMBUS_PEC_EX;
                        break;

                    case 17:                         //!< UART Extend
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_UART_EX;
                        break;

                    case 18:
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_UART_PEC_EX;
                        break;

                    case 19:                         //!< Single wire UART Extend
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART_EX;
                        break;

                    case 20:
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART_PEC_EX;
                        break;

                    case 21:                         //!< SPI Extend
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SPI_EX;
                        break;

                    case 22:
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_SPI_PEC_EX;
                        break;

                    case 23:                         //!< I2C Extend
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_I2C_EX;
                        break;

                    case 24:
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_I2C_PEC_EX;
                        break;

                    case 25:                        //!< All
                        m_Command.AddressValue = (Byte)BM_CMD_ADDR.BM_CMD_ADDR_ALL;
                        break;
                    }
                }

                do
                {
                    Byte[] cResult = null;
                    if (HEXBuilder.HEXStringToByteArray(txtSubAddress.Text, ref cResult))
                    {
                        m_Command.SubAddress = cResult[0];
                    }
                    else
                    {
                        m_Command.SubAddress = 0;
                    }
                }while (false);
            }

            frmCommandWizardStepF CommandWizard = new frmCommandWizardStepF(m_Command);

            this.Hide();
            CommandWizard.Show();
            this.Dispose();
        }