Beispiel #1
0
        private void btStrCvt_Click(object sender, EventArgs e)
        {
            byte[] hexDat = DatConvert.strToHexByte(tbAttrGet.Text);
            switch (cmbGetType.SelectedIndex)
            {
            case 0://Hex
                tbAttrGetCvt.Text = DatConvert.ByteArrayToHexString(hexDat);
                break;

            case 1://Number
            {
                if (cmbGetEndian.SelectedIndex == 1)
                {
                    Array.Reverse(hexDat);
                }
                switch (cmbGetFormat.SelectedIndex)
                {
                case 0:    //INT8
                case 1:    //UINT8
                    tbAttrGetCvt.Text = BitConverter.ToChar(hexDat, 0).ToString();
                    break;

                case 2:                                                             //INT16;
                    tbAttrGetCvt.Text = BitConverter.ToInt16(hexDat, 0).ToString(); //Int16.Parse(tbAttrGet.Text).ToString();
                    break;

                case 3:                                                              //UINT16
                    tbAttrGetCvt.Text = BitConverter.ToUInt16(hexDat, 0).ToString(); // UInt16.Parse(tbAttrGet.Text).ToString();
                    //tbAttrGet.Text = ByteArrayToDecString(e.value);
                    break;

                case 4:    //INT32;
                    tbAttrGetCvt.Text = BitConverter.ToInt32(hexDat, 0).ToString();
                    break;

                case 5:    //UINT32;
                    tbAttrGetCvt.Text = BitConverter.ToUInt32(hexDat, 0).ToString();
                    break;

                case 6:    //float
                    tbAttrGetCvt.Text = BitConverter.ToSingle(hexDat, 0).ToString();
                    break;

                default:
                    break;
                }
            }
            break;

            case 2://String
                tbAttrGetCvt.Text = DatConvert.HexArrayToString(hexDat);
                break;
            }
        }
Beispiel #2
0
        public void DelAttribute(byte[] uuid)
        {
            string uuidstr = DatConvert.HexArrayToString(uuid);

            foreach (CAttribute item in AttrList.ToArray())
            {
                if (uuidstr == item.AttUUID)
                {
                    AttrList.Remove(item);
                }
            }
        }
Beispiel #3
0
        public CAttribute GetAttribute(byte[] uuid)
        {
            CAttribute mAttribute = null;
            string     uuidstr    = DatConvert.HexArrayToString(uuid);

            foreach (CAttribute item in AttrList.ToArray())
            {
                if (uuidstr == item.AttUUID)
                {
                    mAttribute = item;
                    break;
                }
            }
            return(mAttribute);
        }