コード例 #1
0
        private static void ReadBatteryTemperature(RS232 paramcom, ValenceBattery paramBattery)
        {
            try
            {
                paramcom.Write(paramBattery.TempRead());
                if (paramcom.Read(21) == -1)
                {
                    throw new Exception("Read Temperature Error!");
                }
                if (!paramBattery.TempReturn(paramcom.InputStream))
                {
                    throw new Exception("Read Temperature Error!");
                }

                strCellTemp[0] = Convert.ToString(paramBattery.TEMP1);
                strCellTemp[1] = Convert.ToString(paramBattery.TEMP2);
                strCellTemp[2] = Convert.ToString(paramBattery.TEMP3);
                strCellTemp[3] = Convert.ToString(paramBattery.TEMP4);
                //strCellTemp[4] = Convert.ToString(paramBattery.TEMP5);
                //strCellTemp[5] = Convert.ToString(paramBattery.TEMP6);
                strPCBATemp = Convert.ToString(paramBattery.TEMPPCB);

                Console.WriteLine($"C1 Temp: {Convert.ToString(paramBattery.TEMP1)}");
                Console.WriteLine($"C2 Temp: {Convert.ToString(paramBattery.TEMP2)}");
                Console.WriteLine($"C3 Temp: {Convert.ToString(paramBattery.TEMP3)}");
                Console.WriteLine($"C4 Temp: {Convert.ToString(paramBattery.TEMP4)}");
                Console.WriteLine($"PCBA Temp: {Convert.ToString(paramBattery.TEMPPCB)}");
            }
            catch (Exception ex)
            {
                strErrorMessage = "Communication Error";
                WriteError(ex.Message.ToString());
            }
        }