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();
        }
Ejemplo n.º 3
0
        private void cmdNext_Click(object sender, EventArgs e)
        {
            if (null != m_Command)
            {
                System.UInt16[] hwResult = null;
                if (HEXBuilder.HEXStringToU16Array(txtWriteWord.Text, ref hwResult))
                {
                    //! legal input
                    ((ESCommandWriteWord)m_Command).DataValue = hwResult[0];
                }
                else
                {
                    MessageBox.Show
                    (
                        "Please Enter Word in legal HEX string format.",
                        "Wizard Warnning",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning
                    );
                    return;
                }
            }


            frmCommandWizardStepH CommandWizard = new frmCommandWizardStepH(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 txtWriteWord_TextChanged(object sender, EventArgs e)
 {
     System.UInt16[] hwResult = null;
     if (false == HEXBuilder.HEXStringToU16Array(txtWriteWord.Text, ref hwResult))
     {
         //! illegal input
         txtWriteWord.Text = "";
     }
 }
 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.º 7
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.º 10
0
        //! \brief constructor
        public frmCommandWizardStepGWB(ESCommand Command)
        {
            InitializeComponent();

            m_Command = Command;

            if (null == m_Command)
            {
                cmdNext.Enabled         = false;
                txtCommandBrief.Enabled = false;
            }
            else
            {
                txtCommandBrief.Text = HEXBuilder.ByteArrayToHEXString(m_Command.Data);
            }
        }
Ejemplo n.º 11
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();
        }
Ejemplo n.º 12
0
        private void cmdPrevious_Click(object sender, EventArgs e)
        {
            if (null != m_Command)
            {
                System.UInt16[] hwResult = null;
                if (HEXBuilder.HEXStringToU16Array(txtWriteWord.Text, ref hwResult))
                {
                    //! legal input
                    ((ESCommandWriteWord)m_Command).DataValue = hwResult[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.º 14
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();
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public override Boolean ImportSetting(System.Xml.XmlDocument xmlDoc, System.Xml.XmlNode xmlRoot)
        {
            if ((null == xmlDoc) || (null == xmlRoot))
            {
                return(false);
            }

            try
            {
                //! get root node
                XmlNode BMCBatteryNode = null;

                if (xmlRoot.Name != "AdapterSetting")
                {
                    BMCBatteryNode = xmlRoot.SelectSingleNode("AdapterSetting");
                }
                else
                {
                    BMCBatteryNode = xmlRoot;
                }

                if (null == BMCBatteryNode)
                {
                    if (0 == xmlRoot.ChildNodes.Count)
                    {
                        return(false);
                    }

                    foreach (XmlNode xmlChildren in xmlRoot.ChildNodes)
                    {
                        if (ImportSetting(xmlDoc, xmlChildren))
                        {
                            return(true);
                        }
                    }

                    return(false);
                }

                //! get parameter group set with index number

                XmlNode xmlAdapter = BMCBatteryNode.SelectSingleNode("TelegraphHIDAdapter");
                if (null == xmlAdapter)
                {
                    return(false);
                }

                //! read setting
                do
                {
                    XmlNode xmlAdapterSetting = xmlAdapter.SelectSingleNode("Setting");
                    if (null == xmlAdapterSetting)
                    {
                        break;
                    }
                    String tSetting = xmlAdapterSetting.InnerText;
                    if (null == tSetting)
                    {
                        break;
                    }
                    else if ("" == tSetting.Trim())
                    {
                        break;
                    }

                    m_strUSBDevicePathName = tSetting;
                }while (false);

                //! read USB setting
                do
                {
                    XmlNode xmlUSBSetting = xmlAdapter.SelectSingleNode("USB");
                    if (null == xmlUSBSetting)
                    {
                        break;
                    }

                    do
                    {
                        //! VID
                        if (null == xmlUSBSetting.Attributes["VID"])
                        {
                            break;
                        }
                        String   strVID   = xmlUSBSetting.Attributes["VID"].Value;
                        UInt16[] hwResult = null;
                        if (!HEXBuilder.HEXStringToU16Array(strVID, ref hwResult))
                        {
                            break;
                        }
                        m_VID = hwResult[0];
                    }while (false);

                    do
                    {
                        //! VID
                        if (null == xmlUSBSetting.Attributes["PID"])
                        {
                            break;
                        }
                        String   strPID   = xmlUSBSetting.Attributes["PID"].Value;
                        UInt16[] hwResult = null;
                        if (!HEXBuilder.HEXStringToU16Array(strPID, ref hwResult))
                        {
                            break;
                        }
                        m_PID = hwResult[0];
                    }while (false);
                }while (false);
            }
            catch (Exception e)
            {
                e.ToString();
                return(false);
            }

            return(true);
        }
        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();
        }
        private void FormInitialize(ESCommand Command)
        {
            //! initialize command type
            ChangeCommandType(Command.Type);

            //! commmand type
            switch (Command.Type)
            {
            case BM_CMD_TYPE.BM_CMD_TYPE_NO_PARAMETER:
                combCommandType.SelectedIndex = 0;
                break;

            case BM_CMD_TYPE.BM_CMD_TYPE_WORD_WRITE:
                combCommandType.SelectedIndex = 1;
                //! command parameter
                txtWriteWord.Text = ((ESCommandWriteWord)Command).DataValue.ToString("X4");
                break;

            case BM_CMD_TYPE.BM_CMD_TYPE_WORD_READ:
                combCommandType.SelectedIndex = 2;
                break;

            case BM_CMD_TYPE.BM_CMD_TYPE_BLOCK_WRITE:
                combCommandType.SelectedIndex = 3;
                //! command parameter
                if (checkWriteBlockShowHEX.Checked)
                {
                    txtWriteBlock.Text = HEXBuilder.ByteArrayToHEXString(Command.Data);
                }
                else
                {
                    System.Byte[] chTempBuffer = Command.Data;

                    if (null != chTempBuffer)
                    {
                        //! normal string
                        StringBuilder sbTempString = new StringBuilder();

                        for (System.Int32 n = 0; n < chTempBuffer.Length; n++)
                        {
                            if ((chTempBuffer[n] >= 0x20) && (chTempBuffer[n] <= 0x7F))
                            {
                                sbTempString.Append((char)chTempBuffer[n]);
                            }
                            else
                            {
                                sbTempString.Append(".");
                            }

                            txtWriteBlock.Text = sbTempString.ToString();
                        }
                    }
                }
                break;

            case BM_CMD_TYPE.BM_CMD_TYPE_BLOCK_READ:
                combCommandType.SelectedIndex = 4;
                break;
            }

            //! command ID
            txtCommandID.Text = Command.ID;

            //! command
            txtCommand.Text = Command.Command.ToString("X2");

            //! brief
            textBrief.Text = Command.Description;

            //! timeout
            switch (Command.ResponseMode)
            {
            case BM_CMD_RT.BM_CMD_RT_NO_RESPONSE:
                combResponseType.SelectedIndex = 0;
                break;

            case BM_CMD_RT.BM_CMD_RT_NO_TIME_OUT:
                combResponseType.SelectedIndex = 1;
                break;

            default:
                combResponseType.Text = Command.TimeOut.ToString("D");
                break;
            }

            //! address
            switch (m_Command.Address)
            {
            case BM_CMD_ADDR.BM_CMD_ADDR_ADAPTER:
                combAddress.SelectedIndex = 0;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SMBUS:
                combAddress.SelectedIndex = 1;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SMBUS_PEC:
                combAddress.SelectedIndex = 2;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_UART:
                combAddress.SelectedIndex = 3;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_UART_PEC:
                combAddress.SelectedIndex = 4;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART:
                combAddress.SelectedIndex = 5;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART_PEC:
                combAddress.SelectedIndex = 6;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SPI:
                combAddress.SelectedIndex = 7;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SPI_PEC:
                combAddress.SelectedIndex = 8;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_I2C:
                combAddress.SelectedIndex = 9;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_I2C_PEC:
                combAddress.SelectedIndex = 10;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_LOADER:
                combAddress.SelectedIndex = 11;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_CHARGER:
                combAddress.SelectedIndex = 12;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_LCD:
                combAddress.SelectedIndex = 13;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_PRN:
                combAddress.SelectedIndex = 14;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SMBUS_EX:
                combAddress.SelectedIndex = 15;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SMBUS_PEC_EX:
                combAddress.SelectedIndex = 16;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_UART_EX:
                combAddress.SelectedIndex = 17;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_UART_PEC_EX:
                combAddress.SelectedIndex = 18;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART_EX:
                combAddress.SelectedIndex = 19;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SINGLE_WIRE_UART_PEC_EX:
                combAddress.SelectedIndex = 20;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SPI_EX:
                combAddress.SelectedIndex = 21;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_SPI_PEC_EX:
                combAddress.SelectedIndex = 22;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_I2C_EX:
                combAddress.SelectedIndex = 23;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_I2C_PEC_EX:
                combAddress.SelectedIndex = 24;
                break;

            case BM_CMD_ADDR.BM_CMD_ADDR_ALL:
                combAddress.SelectedIndex = 25;
                break;

            default:
                combAddress.Text = m_Command.AddressValue.ToString("X2");
                break;
            }

            //! optional address
            txtSubAddress.Text = m_Command.SubAddress.ToString("X2");
        }
        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();
        }