Example #1
0
        private void OneWireSystemValuesSelect_comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string str = OneWireSystemValuesSelect_comboBox.Items[OneWireSystemValuesSelect_comboBox.SelectedIndex].ToString();

            //OneWireDataResolution.DetailOfItem item = g_Owdr.GetItemInfor(typeof(OneWireDataResolution.ItemNameOfSystemStatus), str);
            LEV_ST_G2_OneWireDataResolution.DetailOfItem item = g_Owdr.GetItemInfor <LEV_ST_G2_OneWireDataResolution.ItemNameOfSystemStatus>(str);
            OneWireSystemValues_textBox.Text = (item.Name.PadRight(48) + "= " + item.Values.ToString().PadRight(10) + "(type = " + item.Type + ")" + Environment.NewLine);
        }
Example #2
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++;
            //}
        }