private static void ReadBatteryBankVoltage(RS232 paramcom, ValenceBattery paramBattery) { try { paramcom.Write(paramBattery.VoltRead()); if (paramcom.Read(25) == -1) { throw new Exception("Read Voltage Error!"); } if (!paramBattery.VoltReturn(paramcom.InputStream)) { throw new Exception("Read Voltage Error!"); } strCellVolt[0] = Convert.ToString(paramBattery.VOLT1); strCellVolt[1] = Convert.ToString(paramBattery.VOLT2); strCellVolt[2] = Convert.ToString(paramBattery.VOLT3); strCellVolt[3] = Convert.ToString(paramBattery.VOLT4); strModuleV = Convert.ToString(paramBattery.VOLTS); strCellVoltDiff = (checked (paramBattery.CellVoltage_Max - paramBattery.CellVoltage_Min) * 0.001m); strCellVoltMin = paramBattery.CellVoltage_Min * 0.001m; strCellVoltMax = paramBattery.CellVoltage_Max * 0.001m; Console.WriteLine($"C1 voltage: {strCellVolt[0]}"); Console.WriteLine($"C2 voltage: {strCellVolt[1]}"); Console.WriteLine($"C3 voltage: {strCellVolt[2]}"); Console.WriteLine($"C4 voltage: {strCellVolt[3]}"); Console.WriteLine($"Voltage: {strModuleV}"); Console.WriteLine($"Cell Voltage Difference: {Convert.ToString(strCellVoltDiff)}"); Console.WriteLine($"Cell Voltage Min: {Convert.ToString(strCellVoltMin)}"); Console.WriteLine($"Cell Voltage Max: {Convert.ToString(strCellVoltMax)}"); #region TODO in other software // monitoring TODO: implement things like this in the visual console that reads from the dataset directly** //if (strCellVoltDiff > strStandardVD) //{ // //TxtStatusVD.BackColor = Color.Pink; // //strVoltDiffStatus = "FAIL"; //} //else //{ // //TxtStatusVD.BackColor = Color.GreenYellow; // //strVoltDiffStatus = "PASS"; //} //if (strCellVoltMin < strStandardCellMin) //{ // //txtCellMin.BackColor = Color.Pink; // //strVoltMinStatus = "FAIL"; //} //else //{ // //txtCellMin.BackColor = Color.GreenYellow; // //strVoltMinStatus = "PASS"; //} //if (strCellVoltMax > strStandardCellMax) //{ // //txtCellMax.BackColor = Color.Pink; //} //else //{ // //txtCellMax.BackColor = Color.GreenYellow; //} #endregion } catch (Exception ex) { strErrorMessage = "Communication Error"; WriteError(ex.Message.ToString()); } }