Пример #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            byte[] temp;
            //temp = B2BToolKitControl.CommandProvider.SendingCmdToB2BToolKit<B2BToolKitControl.Cmd_ToolKitDataTransmit>(B2BToolKitControl.Cmd_ToolKitDataTransmit.Cmd_UART_RS485_Transmit_Data, new byte[] { 0x00 });
            //temp = B2BToolKitControl.CommandProvider.SendingCmdToB2BToolKit(B2BToolKitControl.Cmd_ToolKitDataTransmit.Cmd_UART_RS485_Transmit_Data, new byte[] { 0x00 });
            //temp = B2BToolKitControl.CommandProvider.SendingCmdToLevBatteryViaB2BToolKit<LEVBatteryPackControl.Cmd_Battery_SetInfor>(LEVBatteryPackControl.Cmd_Battery_SetInfor.Cmd_SetOneWireTransmitOnce, new byte[] { 0x01 });
            //temp = B2BToolKitControl.CommandProvider.SendingCmdToLevBatteryViaB2BToolKit(LEVBatteryPackControl.Cmd_Battery_SetInfor.Cmd_SetOneWireTransmitOnce, new byte[] { 0x01 });
            //textBox6.Text = LEVUtilityLibrary.MassUtilities.ByteArrayToHexString(temp, true);

            string str = LEVUtilityLibrary.MassUtilities.StringTrim_Replace_EnterAndTab_CombineMultiSpaceToOne(textBox1.Text);

            temp = LEVUtilityLibrary.MassUtilities.HexStringToByteArray(str);
            LEVBatteryPackControl.LEVBPReceivedDataDetector rxDetector = new LEVBatteryPackControl.LEVBPReceivedDataDetector();
            List <LEVBatteryPackControl.LEVBPReceivedDataDetector.ReceivedPacket> listRxPocket = new List <LEVBatteryPackControl.LEVBPReceivedDataDetector.ReceivedPacket>();

            listRxPocket = rxDetector.DataDetector(temp);
            textBox6.AppendText("listRxPocket count = " + listRxPocket.Count + Environment.NewLine);
            textBox6.AppendText("=============================================" + Environment.NewLine);
            foreach (LEVBatteryPackControl.LEVBPReceivedDataDetector.ReceivedPacket pocket in listRxPocket)
            {
                textBox6.AppendText("group = " + pocket.Type + Environment.NewLine);
                textBox6.AppendText("cmd = " + String.Format("{0:X}", pocket.Cmd) + Environment.NewLine);
                string strData = LEVUtilityLibrary.MassUtilities.ByteArrayToHexString(pocket.Data, true);
                textBox6.AppendText("data = " + strData + Environment.NewLine);
                textBox6.AppendText("=============================================" + Environment.NewLine);
            }

            LEV_ST_G2_OneWireDataResolution ost = new LEV_ST_G2_OneWireDataResolution();
            dynamic dy = ost.GetItemInfor <LEV_ST_G2_OneWireDataResolution.ItemNameOfEepromData>(LEV_ST_G2_OneWireDataResolution.ItemNameOfEepromData.SystemSetting_Info_Byte1_Var_uchar_offset_96);

            //string[] stArr = Enum.GetNames(typeof(OneWireDataResolution.NameOfEepromData));
            //byte[] newArray = new byte[] { 0x3e, 0xbe, 0xa6, 0x72 };
            //byte[] newArray = new byte[] { 0x72, 0xa6, 0xbe, 0x3e };
            //float f = BitConverter.ToSingle(newArray, 0);
            byte[] newArray = new byte[] { 0xa0, 0x08 };
            int    t        = BitConverter.ToInt16(newArray, 0);
            byte   a        = 0xfe;
            sbyte  b        = unchecked ((sbyte)a);

            textBox6.AppendText("=============================================" + b + Environment.NewLine);


            //ost.setOneWireData(OneWireDataResolution.OneWireDataGroup.SystemData, temp);
            //OneWireDataResolution.st_ItemInform[] stItems = ost.getAllOneWireData(typeof(OneWireDataResolution.ItemNameOfSystemStatus));
            //foreach (OneWireDataResolution.st_ItemInform item in stItems)
            //{
            //    textBox6.AppendText("===" + item.Name + "=" + item.Values + Environment.NewLine);
            //}
            //textBox6.AppendText("=============================================" + b + Environment.NewLine);
            //textBox6.AppendText("=============================================" + b + Environment.NewLine);
            //string[] stArr = Enum.GetNames(typeof(OneWireDataResolution.ItemNameOfSystemStatus));
            //int ItemIdx = 0;
            //foreach (string s in stArr)
            //{
            //    OneWireDataResolution.st_ItemInform item = ost.getOneWireData((OneWireDataResolution.ItemNameOfSystemStatus)ItemIdx);
            //    textBox6.AppendText("===" + item.Name + "=" + item.Values + Environment.NewLine);
            //    ItemIdx++;
            //}

            //ost.setOneWireData(OneWireDataResolution.OneWireDataGroup.EepromData, temp);
            //OneWireDataResolution.st_ItemInform[] stItems = ost.getAllOneWireData(typeof(OneWireDataResolution.ItemNameOfEepromData));
            //foreach (OneWireDataResolution.st_ItemInform item in stItems)
            //{
            //    textBox6.AppendText("===" + item.Name + "=" + item.Values + Environment.NewLine);
            //}
            //textBox6.AppendText("=============================================" + b + Environment.NewLine);
            //textBox6.AppendText("=============================================" + b + Environment.NewLine);
            //string[] stArr = Enum.GetNames(typeof(OneWireDataResolution.ItemNameOfEepromData));
            //int ItemIdx = 0;
            //foreach (string s in stArr)
            //{
            //    OneWireDataResolution.st_ItemInform item = ost.getOneWireData((OneWireDataResolution.ItemNameOfEepromData)ItemIdx);
            //    textBox6.AppendText("===" + item.Name + "=" + item.Values + "##" + Environment.NewLine);
            //    ItemIdx++;
            //}
        }