Compare commits
2 Commits
0af235eb3d
...
9fbe461e0e
| Author | SHA1 | Date | |
|---|---|---|---|
| 9fbe461e0e | |||
| e2b5223a39 |
@@ -360,6 +360,7 @@ namespace LFP_Manager.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region TIMER EVENT
|
#region TIMER EVENT
|
||||||
private void tmrDisplay_Tick(object sender, EventArgs e)
|
private void tmrDisplay_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace LFP_Manager.DataStructure
|
|||||||
public int UartModelIndex;
|
public int UartModelIndex;
|
||||||
public int UartProtocol;
|
public int UartProtocol;
|
||||||
|
|
||||||
public int CommFailTime;
|
public int CommFailMaxCount;
|
||||||
|
|
||||||
public int DbLogPeriod;
|
public int DbLogPeriod;
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ namespace LFP_Manager.DataStructure
|
|||||||
UartProtocol = 0;
|
UartProtocol = 0;
|
||||||
|
|
||||||
RecvWaitTime = 1500; // 1500ms
|
RecvWaitTime = 1500; // 1500ms
|
||||||
CommFailTime = 5000; // 5000ms
|
CommFailMaxCount = 5; // 5 times
|
||||||
|
|
||||||
DbLogPeriod = 5;
|
DbLogPeriod = 5;
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ namespace LFP_Manager.Function
|
|||||||
rConfig.RecvWaitTime = (int)csIniControlFunction.GetPrivateProfileInt("UART", "RECV_WAIT_TIME", 1500, InIPath);
|
rConfig.RecvWaitTime = (int)csIniControlFunction.GetPrivateProfileInt("UART", "RECV_WAIT_TIME", 1500, InIPath);
|
||||||
|
|
||||||
// COMM FAIL TIME OUT
|
// COMM FAIL TIME OUT
|
||||||
rConfig.CommFailTime = (int)csIniControlFunction.GetPrivateProfileInt("UART", "COMM_FAIL_TIME", 5000, InIPath);
|
rConfig.CommFailMaxCount = (int)csIniControlFunction.GetPrivateProfileInt("UART", "COMM_FAIL_COUNT", 5, InIPath);
|
||||||
|
|
||||||
// Etc. Config
|
// Etc. Config
|
||||||
rConfig.DbLogPeriod = (int)csIniControlFunction.GetPrivateProfileInt("DATABASE", "LOG_PERIOD", 1, InIPath);
|
rConfig.DbLogPeriod = (int)csIniControlFunction.GetPrivateProfileInt("DATABASE", "LOG_PERIOD", 1, InIPath);
|
||||||
@@ -147,7 +147,7 @@ namespace LFP_Manager.Function
|
|||||||
rConfig.UartProtocol= 0;
|
rConfig.UartProtocol= 0;
|
||||||
rConfig.RecvWaitTime = 1500;
|
rConfig.RecvWaitTime = 1500;
|
||||||
|
|
||||||
rConfig.CommFailTime = 5000;
|
rConfig.CommFailMaxCount = 5;
|
||||||
|
|
||||||
rConfig.DbLogPeriod = 5;
|
rConfig.DbLogPeriod = 5;
|
||||||
|
|
||||||
@@ -187,8 +187,8 @@ namespace LFP_Manager.Function
|
|||||||
// RECV_WAIT_TIME
|
// RECV_WAIT_TIME
|
||||||
WritePrivateProfileString("UART", "RECV_WAIT_TIME", aConfig.RecvWaitTime.ToString(), InIPath);
|
WritePrivateProfileString("UART", "RECV_WAIT_TIME", aConfig.RecvWaitTime.ToString(), InIPath);
|
||||||
|
|
||||||
// COMM_FAIL_TIME
|
// COMM_FAIL_COUNT
|
||||||
WritePrivateProfileString("UART", "COMM_FAIL_TIME", aConfig.CommFailTime.ToString(), InIPath);
|
WritePrivateProfileString("UART", "COMM_FAIL_COUNT", aConfig.CommFailMaxCount.ToString(), InIPath);
|
||||||
|
|
||||||
// Etc Config
|
// Etc Config
|
||||||
WritePrivateProfileString("DATABASE", "LOG_PERIOD", aConfig.DbLogPeriod.ToString(), InIPath);
|
WritePrivateProfileString("DATABASE", "LOG_PERIOD", aConfig.DbLogPeriod.ToString(), InIPath);
|
||||||
|
|||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.7")]
|
[assembly: AssemblyVersion("1.0.0.8")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.7")]
|
[assembly: AssemblyFileVersion("1.0.0.8")]
|
||||||
|
|||||||
@@ -356,35 +356,6 @@ namespace LFP_Manager.Threads
|
|||||||
|
|
||||||
#region TX BUFFERING
|
#region TX BUFFERING
|
||||||
|
|
||||||
private byte[] MakeWriteRegData(ushort DevID, ushort WriteAddr, ushort WriteLen, ref ushort[] WriteData)
|
|
||||||
{
|
|
||||||
byte[] wData = null;
|
|
||||||
|
|
||||||
if (WriteLen > 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return wData;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string MakeCheckSum(byte[] sData, int len)
|
|
||||||
{
|
|
||||||
string result = "";
|
|
||||||
int checksum = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < len; i++)
|
|
||||||
{
|
|
||||||
checksum += sData[i + 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
checksum = ~checksum + 1;
|
|
||||||
|
|
||||||
result = String.Format("{0:X2}{1:X2}", (byte)(checksum >> 8), (byte)checksum);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] MakeTxDataDelta(bool wData)
|
private byte[] MakeTxDataDelta(bool wData)
|
||||||
{
|
{
|
||||||
byte[] sData = null;
|
byte[] sData = null;
|
||||||
@@ -492,8 +463,9 @@ namespace LFP_Manager.Threads
|
|||||||
private void uartCommThreadSB(CancellationToken token)
|
private void uartCommThreadSB(CancellationToken token)
|
||||||
{
|
{
|
||||||
int RecvTimeout = Config.RecvWaitTime;
|
int RecvTimeout = Config.RecvWaitTime;
|
||||||
int COMM_TIMEOUT_MS = Config.CommFailTime; // 5초 동안 수신 없으면 Fail
|
int COMM_TIMEOUT_MAX_COUNT = (Config.CommFailMaxCount > 100) ? 5 : Config.CommFailMaxCount; // 5초 동안 수신 없으면 Fail
|
||||||
DateTime[] LastReceiveTime = new DateTime[csConstData.SystemInfo.MAX_MODULE_SIZE];
|
DateTime[] LastReceiveTime = new DateTime[csConstData.SystemInfo.MAX_MODULE_SIZE];
|
||||||
|
int[] RecvTimeoutCount = new int[csConstData.SystemInfo.MAX_MODULE_SIZE];
|
||||||
|
|
||||||
// ★ 마지막 수신 시간 초기화 (현재 시각 기준)
|
// ★ 마지막 수신 시간 초기화 (현재 시각 기준)
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
@@ -561,8 +533,9 @@ namespace LFP_Manager.Threads
|
|||||||
{
|
{
|
||||||
// 마지막 정상 업데이트 시간 기록
|
// 마지막 정상 업데이트 시간 기록
|
||||||
LastReceiveTime[mID] = DateTime.UtcNow;
|
LastReceiveTime[mID] = DateTime.UtcNow;
|
||||||
|
RecvTimeoutCount[mID] = 0;
|
||||||
|
|
||||||
ModuleData[mID].CommFail = false;
|
ModuleData[mID].mNo = mID + 1;
|
||||||
ModuleData[mID].ShelfCommFail = false;
|
ModuleData[mID].ShelfCommFail = false;
|
||||||
var rc = CsSerialCommFunctionDelta.SerialRxProcess(
|
var rc = CsSerialCommFunctionDelta.SerialRxProcess(
|
||||||
ReadBuf, RequestRegAddr, (ushort)rPosition, ref ModuleData[mID]);
|
ReadBuf, RequestRegAddr, (ushort)rPosition, ref ModuleData[mID]);
|
||||||
@@ -605,25 +578,26 @@ namespace LFP_Manager.Threads
|
|||||||
{
|
{
|
||||||
int idx = csUtils.MathEx.Clamp(ModuleID - 1, 0, csConstData.SystemInfo.MAX_MODULE_SIZE - 1);
|
int idx = csUtils.MathEx.Clamp(ModuleID - 1, 0, csConstData.SystemInfo.MAX_MODULE_SIZE - 1);
|
||||||
|
|
||||||
|
RecvTimeoutCount[idx]++;
|
||||||
// 아직 한 번도 정상 수신한 적 없는 경우 MinValue일 수 있으므로,
|
// 아직 한 번도 정상 수신한 적 없는 경우 MinValue일 수 있으므로,
|
||||||
// 첫 타임아웃에서는 기준 시간을 현재로 초기화해 준다.
|
// 첫 타임아웃에서는 기준 시간을 현재로 초기화해 준다.
|
||||||
if (LastReceiveTime[idx] == DateTime.MinValue)
|
if (LastReceiveTime[idx] == DateTime.MinValue)
|
||||||
LastReceiveTime[idx] = DateTime.UtcNow;
|
LastReceiveTime[idx] = DateTime.UtcNow;
|
||||||
|
|
||||||
// 시간 차이 계산
|
// 시간 차이 계산
|
||||||
var elapsed = (DateTime.Now - LastReceiveTime[idx]).TotalMilliseconds;
|
var elapsed = (DateTime.UtcNow - LastReceiveTime[idx]).TotalMilliseconds;
|
||||||
|
|
||||||
if (elapsed >= COMM_TIMEOUT_MS)
|
if (RecvTimeoutCount[idx] >= COMM_TIMEOUT_MAX_COUNT)
|
||||||
|
//if (elapsed >= COMM_TIMEOUT_MS)
|
||||||
{
|
{
|
||||||
|
RecvTimeoutCount[idx] = 5;
|
||||||
// Fail 처리
|
// Fail 처리
|
||||||
if (!ModuleData[idx].ShelfCommFail)
|
if (!ModuleData[idx].ShelfCommFail)
|
||||||
{
|
{
|
||||||
ModuleData[idx].Reset();
|
ModuleData[idx].Reset();
|
||||||
|
ModuleData[idx].mNo = ModuleID;
|
||||||
ModuleData[idx].ShelfCommFail = true;
|
ModuleData[idx].ShelfCommFail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModuleData[idx].CommFail = true;
|
|
||||||
ModuleData[idx].ShelfCommFail = true;
|
|
||||||
}
|
}
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,11 +492,11 @@ namespace LFP_Manager.Threads
|
|||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.Now;
|
||||||
|
|
||||||
// 시스템 통신 상태 변화 기록
|
// 시스템 통신 상태 변화 기록
|
||||||
if (oModule.CommFail != nModule.CommFail)
|
if (oModule.ShelfCommFail != nModule.ShelfCommFail)
|
||||||
{
|
{
|
||||||
eventFlag |= BmsAlarmDataInsert(modelName, (int)DbConstData.Alarm.COMM_FAIL,
|
eventFlag |= BmsAlarmDataInsert(modelName, (int)DbConstData.Alarm.COMM_FAIL,
|
||||||
nModule.CommFail ? (int)DbConstData.Flag.WARNING : (int)DbConstData.Flag.RELEASE, nModule, now);
|
nModule.ShelfCommFail ? (int)DbConstData.Flag.WARNING : (int)DbConstData.Flag.RELEASE, nModule, now);
|
||||||
oModule.CommFail = nModule.CommFail;
|
oModule.ShelfCommFail = nModule.ShelfCommFail;
|
||||||
}
|
}
|
||||||
// 0..15 비트에 대한 경고/보호 엣지 검사
|
// 0..15 비트에 대한 경고/보호 엣지 검사
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user