V1.0.2.0
* Added RS232/RS485 Packet Analyzer (Tools -> Packet Analyzer) * Updated BMS History register request/response length by model * Fixed decimal truncation issue in Brazil locale for DB/CSV Log and Excel Export
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using DevExpress.XtraGauges.Core.Model;
|
||||
using DevExpress.XtraGauges.Core.Model;
|
||||
using LFP_Manager.DataStructure;
|
||||
using LFP_Manager.Function;
|
||||
using LFP_Manager.Utils;
|
||||
@@ -39,6 +39,7 @@ namespace LFP_Manager.Threads
|
||||
public event UartDataUpdateRS485 OnUpdate = null;
|
||||
public event UartDataRecvRS485 OnDataRecv = null;
|
||||
public event UartDataPrintRS485 OnPrint = null;
|
||||
public event UartDataPacketRS485 OnPacketLog = null;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -467,6 +468,7 @@ namespace LFP_Manager.Threads
|
||||
{
|
||||
sPort.Write(txData, 0, txData.Length);
|
||||
SafeRaiseOnPrint(csLog.trx_data_print(txData, txData.Length, 0));
|
||||
OnPacketLog?.Invoke(DateTime.Now, true, txData, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -514,6 +516,12 @@ namespace LFP_Manager.Threads
|
||||
break;
|
||||
case 1: // Packet OK, no error
|
||||
SafeRaiseOnPrint(csLog.trx_data_print(ReadBuf, rPosition, 1));
|
||||
if (OnPacketLog != null)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, null);
|
||||
}
|
||||
|
||||
TimeOutCount[ModuleID - 1] = 0;
|
||||
|
||||
@@ -530,6 +538,12 @@ namespace LFP_Manager.Threads
|
||||
goto StartSend;
|
||||
case 2: // Fw Update Packet OK
|
||||
SafeRaiseOnPrint(csLog.trx_data_print(ReadBuf, rPosition, 1));
|
||||
if (OnPacketLog != null)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, "FW Update Response");
|
||||
}
|
||||
|
||||
TimeOutCount[ModuleID - 1] = 0;
|
||||
rFlag = false;
|
||||
@@ -541,6 +555,12 @@ namespace LFP_Manager.Threads
|
||||
}
|
||||
goto StartSend;
|
||||
case -1: // Packet error
|
||||
if (OnPacketLog != null && rPosition > 0)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, "Packet Error / CRC Mismatch");
|
||||
}
|
||||
RecvPacketInit();
|
||||
Thread.Sleep(100);
|
||||
goto StartSend;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using LFP_Manager.DataStructure;
|
||||
using LFP_Manager.DataStructure;
|
||||
using LFP_Manager.Function;
|
||||
using SnmpSharpNet;
|
||||
using System;
|
||||
@@ -489,38 +489,48 @@ namespace LFP_Manager.Threads
|
||||
j = 0;
|
||||
for (i = 0; i < tSize; i++)
|
||||
{
|
||||
short tempVal = aSystemData.ValueData.CellTemperature[i];
|
||||
if (tempVal == 0) continue; // 미연결 및 초기 0도 제외
|
||||
|
||||
if (j == 0)
|
||||
{
|
||||
max.value = aSystemData.ValueData.CellTemperature[i];
|
||||
max.value = tempVal;
|
||||
max.num = i;
|
||||
min.value = aSystemData.ValueData.CellTemperature[i];
|
||||
min.value = tempVal;
|
||||
min.num = i;
|
||||
}
|
||||
|
||||
if (max.value < aSystemData.ValueData.CellTemperature[i])
|
||||
if (max.value < tempVal)
|
||||
{
|
||||
max.value = aSystemData.ValueData.CellTemperature[i];
|
||||
max.value = tempVal;
|
||||
max.num = i;
|
||||
}
|
||||
if (min.value > aSystemData.ValueData.CellTemperature[i])
|
||||
if (min.value > tempVal)
|
||||
{
|
||||
min.value = aSystemData.ValueData.CellTemperature[i];
|
||||
min.value = tempVal;
|
||||
min.num = i;
|
||||
}
|
||||
|
||||
sum += aSystemData.ValueData.CellTemperature[i];
|
||||
sum += tempVal;
|
||||
j++;
|
||||
}
|
||||
|
||||
if (j == 0)
|
||||
{ aSystemData.AvgData.avgTemp = 0; }
|
||||
{
|
||||
aSystemData.AvgData.avgTemp = 0;
|
||||
aSystemData.AvgData.maxTemp = 0;
|
||||
aSystemData.AvgData.maxTempNum = 0;
|
||||
aSystemData.AvgData.minTemp = 0;
|
||||
aSystemData.AvgData.minTempNum = 0;
|
||||
}
|
||||
else
|
||||
{ aSystemData.AvgData.avgTemp = (short)(sum / j); }
|
||||
|
||||
aSystemData.AvgData.maxTemp = max.value;
|
||||
aSystemData.AvgData.maxTempNum = max.num;
|
||||
aSystemData.AvgData.minTemp = min.value;
|
||||
aSystemData.AvgData.minTempNum = min.num;
|
||||
{
|
||||
aSystemData.AvgData.avgTemp = (short)(sum / j);
|
||||
aSystemData.AvgData.maxTemp = max.value;
|
||||
aSystemData.AvgData.maxTempNum = max.num;
|
||||
aSystemData.AvgData.minTemp = min.value;
|
||||
aSystemData.AvgData.minTempNum = min.num;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using LFP_Manager.DataStructure;
|
||||
using LFP_Manager.DataStructure;
|
||||
using LFP_Manager.Function;
|
||||
using LFP_Manager.Utils;
|
||||
using SnmpSharpNet;
|
||||
@@ -516,34 +516,55 @@ namespace LFP_Manager.Threads
|
||||
return;
|
||||
|
||||
var temperatures = systemData.ValueData.CellTemperature;
|
||||
var validCount = Math.Min((int)tempSize, temperatures.Length);
|
||||
var limitCount = Math.Min((int)tempSize, temperatures.Length);
|
||||
|
||||
var sum = 0;
|
||||
int validCount = 0;
|
||||
short maxVal = 0, minVal = 0;
|
||||
int maxIdx = 0, minIdx = 0;
|
||||
|
||||
for (int i = 0; i < limitCount; i++)
|
||||
{
|
||||
var temp = temperatures[i];
|
||||
if (temp == 0) continue; // 미연결 및 초기 0도 제외
|
||||
|
||||
if (validCount == 0)
|
||||
{
|
||||
maxVal = minVal = temp;
|
||||
maxIdx = minIdx = i;
|
||||
}
|
||||
|
||||
sum += temp;
|
||||
validCount++;
|
||||
|
||||
if (temp > maxVal)
|
||||
{
|
||||
maxVal = temp;
|
||||
maxIdx = i;
|
||||
}
|
||||
if (temp < minVal)
|
||||
{
|
||||
minVal = temp;
|
||||
minIdx = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (validCount == 0)
|
||||
{
|
||||
systemData.AvgData.avgTemp = 0;
|
||||
return;
|
||||
systemData.AvgData.maxTemp = 0;
|
||||
systemData.AvgData.maxTempNum = 0;
|
||||
systemData.AvgData.minTemp = 0;
|
||||
systemData.AvgData.minTempNum = 0;
|
||||
}
|
||||
|
||||
var sum = 0;
|
||||
var max = new { value = temperatures[0], index = 0 };
|
||||
var min = new { value = temperatures[0], index = 0 };
|
||||
|
||||
for (int i = 0; i < validCount; i++)
|
||||
else
|
||||
{
|
||||
var temp = temperatures[i];
|
||||
sum += temp;
|
||||
|
||||
if (temp > max.value)
|
||||
max = new { value = temp, index = i };
|
||||
if (temp < min.value)
|
||||
min = new { value = temp, index = i };
|
||||
systemData.AvgData.avgTemp = (short)(sum / validCount);
|
||||
systemData.AvgData.maxTemp = maxVal;
|
||||
systemData.AvgData.maxTempNum = maxIdx;
|
||||
systemData.AvgData.minTemp = minVal;
|
||||
systemData.AvgData.minTempNum = minIdx;
|
||||
}
|
||||
|
||||
systemData.AvgData.avgTemp = (short)(sum / validCount);
|
||||
systemData.AvgData.maxTemp = max.value;
|
||||
systemData.AvgData.maxTempNum = max.index;
|
||||
systemData.AvgData.minTemp = min.value;
|
||||
systemData.AvgData.minTempNum = min.index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
using System.Threading;
|
||||
using System.IO.Ports;
|
||||
@@ -44,6 +44,7 @@ namespace LFP_Manager.Threads
|
||||
public event UartDataUpdate OnUpdate = null;
|
||||
public event UartDataRecv OnDataRecv = null;
|
||||
public event UartDataPrint OnPrint = null;
|
||||
public event UartDataPacket OnPacketLog = null;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -632,6 +633,7 @@ namespace LFP_Manager.Threads
|
||||
FlushBuff();
|
||||
sPort.Write(txData, 0, txData.Length);
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(txData, txData.Length, 0));
|
||||
OnPacketLog?.Invoke(DateTime.Now, true, txData, null);
|
||||
}
|
||||
|
||||
if (rFlag == true)
|
||||
@@ -669,6 +671,12 @@ namespace LFP_Manager.Threads
|
||||
break;
|
||||
case 1: // Packet OK, no error
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(ReadBuf, rPosition, 1));
|
||||
if (OnPacketLog != null)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, null);
|
||||
}
|
||||
|
||||
TimeOutCount = 0;
|
||||
|
||||
@@ -691,8 +699,8 @@ namespace LFP_Manager.Threads
|
||||
WriteRegAddr = 0;
|
||||
if (OnDataRecv != null)
|
||||
{
|
||||
byte[] adata = new byte[rPosition + 1];
|
||||
for (int j = 0; j < adata.Length; j++) { adata[j] = ReadBuf[j]; }
|
||||
byte[] adata = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, adata, 0, rPosition);
|
||||
OnDataRecv(adata);
|
||||
}
|
||||
}
|
||||
@@ -701,20 +709,29 @@ namespace LFP_Manager.Threads
|
||||
goto StartSend;
|
||||
case 2: // Fw Update Packet OK
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(ReadBuf, rPosition, 1));
|
||||
if (OnPacketLog != null)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, "FW Update Response");
|
||||
}
|
||||
|
||||
TimeOutCount = 0;
|
||||
rFlag = false;
|
||||
if (OnDataRecv != null)
|
||||
{
|
||||
byte[] adata = new byte[rPosition + 1];
|
||||
for (int j = 0; j < adata.Length; j++)
|
||||
{
|
||||
adata[j] = ReadBuf[j];
|
||||
}
|
||||
byte[] adata = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, adata, 0, rPosition);
|
||||
OnDataRecv(adata);
|
||||
}
|
||||
goto StartSend;
|
||||
case -1: // Packet error
|
||||
if (OnPacketLog != null && rPosition > 0)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, "Packet Error / CRC Mismatch");
|
||||
}
|
||||
RecvPacketInit();
|
||||
Thread.Sleep(100);
|
||||
goto StartSend;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
using System.Threading;
|
||||
using System.IO.Ports;
|
||||
@@ -15,6 +15,7 @@ namespace LFP_Manager.Threads
|
||||
public delegate void UartDataUpdateRS485(object sender, ref DeviceSystemData[] aSystemData);
|
||||
public delegate void UartDataRecvRS485(byte[] data);
|
||||
public delegate void UartDataPrintRS485(object sender, string msg);
|
||||
public delegate void UartDataPacketRS485(DateTime timestamp, bool isTx, byte[] data, string description);
|
||||
#endregion
|
||||
|
||||
class CsUartThreadDelta
|
||||
@@ -50,6 +51,7 @@ namespace LFP_Manager.Threads
|
||||
public event UartDataUpdateRS485 OnUpdate = null;
|
||||
public event UartDataRecvRS485 OnDataRecv = null;
|
||||
public event UartDataPrintRS485 OnPrint = null;
|
||||
public event UartDataPacketRS485 OnPacketLog = null;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -451,6 +453,7 @@ namespace LFP_Manager.Threads
|
||||
{
|
||||
sPort.Write(txData, 0, txData.Length);
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(txData, txData.Length, 0));
|
||||
OnPacketLog?.Invoke(DateTime.Now, true, txData, null);
|
||||
}
|
||||
|
||||
if (rFlag == true)
|
||||
@@ -491,6 +494,12 @@ namespace LFP_Manager.Threads
|
||||
break;
|
||||
case 1: // Packet OK, no error
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(ReadBuf, rPosition, 1));
|
||||
if (OnPacketLog != null)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, null);
|
||||
}
|
||||
|
||||
TimeOutCount[ModuleID - 1] = 0;
|
||||
|
||||
@@ -507,20 +516,29 @@ namespace LFP_Manager.Threads
|
||||
goto StartSend;
|
||||
case 2: // Fw Update Packet OK
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(ReadBuf, rPosition, 1));
|
||||
if (OnPacketLog != null)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, "FW Update Response");
|
||||
}
|
||||
|
||||
TimeOutCount[ModuleID - 1] = 0;
|
||||
rFlag = false;
|
||||
if (OnDataRecv != null)
|
||||
{
|
||||
byte[] adata = new byte[rPosition + 1];
|
||||
for (int j = 0; j < adata.Length; j++)
|
||||
{
|
||||
adata[j] = ReadBuf[j];
|
||||
}
|
||||
byte[] adata = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, adata, 0, rPosition);
|
||||
OnDataRecv(adata);
|
||||
}
|
||||
goto StartSend;
|
||||
case -1: // Packet error
|
||||
if (OnPacketLog != null && rPosition > 0)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, "Packet Error / CRC Mismatch");
|
||||
}
|
||||
RecvPacketInit();
|
||||
Thread.Sleep(100);
|
||||
goto StartSend;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
using System.Threading;
|
||||
using System.IO.Ports;
|
||||
@@ -15,6 +15,7 @@ namespace LFP_Manager.Threads
|
||||
public delegate void UartDataUpdate(object sender, ref DeviceSystemData aSystemData);
|
||||
public delegate void UartDataRecv(byte[] data);
|
||||
public delegate void UartDataPrint(object sender, string msg);
|
||||
public delegate void UartDataPacket(DateTime timestamp, bool isTx, byte[] data, string description);
|
||||
#endregion
|
||||
|
||||
class csUartThread
|
||||
@@ -50,6 +51,7 @@ namespace LFP_Manager.Threads
|
||||
public event UartDataUpdate OnUpdate = null;
|
||||
public event UartDataRecv OnDataRecv = null;
|
||||
public event UartDataPrint OnPrint = null;
|
||||
public event UartDataPacket OnPacketLog = null;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -643,6 +645,7 @@ namespace LFP_Manager.Threads
|
||||
FlushBuff();
|
||||
sPort.Write(txData, 0, txData.Length);
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(txData, txData.Length, 0));
|
||||
OnPacketLog?.Invoke(DateTime.Now, true, txData, null);
|
||||
}
|
||||
|
||||
if (rFlag == true)
|
||||
@@ -680,6 +683,12 @@ namespace LFP_Manager.Threads
|
||||
break;
|
||||
case 1: // Packet OK, no error
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(ReadBuf, rPosition, 1));
|
||||
if (OnPacketLog != null)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, null);
|
||||
}
|
||||
|
||||
TimeOutCount = 0;
|
||||
|
||||
@@ -702,8 +711,8 @@ namespace LFP_Manager.Threads
|
||||
WriteRegAddr = 0;
|
||||
if (OnDataRecv != null)
|
||||
{
|
||||
byte[] adata = new byte[rPosition + 1];
|
||||
for (int j = 0; j < adata.Length; j++) { adata[j] = ReadBuf[j]; }
|
||||
byte[] adata = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, adata, 0, rPosition);
|
||||
OnDataRecv(adata);
|
||||
}
|
||||
}
|
||||
@@ -712,20 +721,29 @@ namespace LFP_Manager.Threads
|
||||
goto StartSend;
|
||||
case 2: // Fw Update Packet OK
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(ReadBuf, rPosition, 1));
|
||||
if (OnPacketLog != null)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, "FW Update Response");
|
||||
}
|
||||
|
||||
TimeOutCount = 0;
|
||||
rFlag = false;
|
||||
if (OnDataRecv != null)
|
||||
{
|
||||
byte[] adata = new byte[rPosition + 1];
|
||||
for (int j = 0; j < adata.Length; j++)
|
||||
{
|
||||
adata[j] = ReadBuf[j];
|
||||
}
|
||||
byte[] adata = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, adata, 0, rPosition);
|
||||
OnDataRecv(adata);
|
||||
}
|
||||
goto StartSend;
|
||||
case -1: // Packet error
|
||||
if (OnPacketLog != null && rPosition > 0)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, "Packet Error / CRC Mismatch");
|
||||
}
|
||||
RecvPacketInit();
|
||||
Thread.Sleep(100);
|
||||
goto StartSend;
|
||||
|
||||
Reference in New Issue
Block a user