|
@@ -186,6 +186,50 @@ void split(char **arr, char *str, const char *del)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void AddFaultCodeToBuf(unsigned char *Code)
|
|
|
+{
|
|
|
+ if(ShmSysConfigAndInfo->SysWarningInfo.WarningCount < 10)
|
|
|
+ {
|
|
|
+ memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[ShmSysConfigAndInfo->SysWarningInfo.WarningCount][0], Code, 7);
|
|
|
+ ShmSysConfigAndInfo->SysWarningInfo.WarningCount++;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void RemoveFaultCodeToBuf(unsigned char *Code)
|
|
|
+{
|
|
|
+ unsigned char find = 0x01;
|
|
|
+ char _code[7];
|
|
|
+ sprintf(_code,"%s", Code);
|
|
|
+
|
|
|
+ while(find)
|
|
|
+ {
|
|
|
+ find = 0x00;
|
|
|
+ for(unsigned char i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++)
|
|
|
+ {
|
|
|
+ if (find == 0x00)
|
|
|
+ {
|
|
|
+ if(memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], _code, 7) == 0)
|
|
|
+ {
|
|
|
+ find = 0x01;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(i == ShmSysConfigAndInfo->SysWarningInfo.WarningCount - 1)
|
|
|
+ {
|
|
|
+ memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "", 7);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], &ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + 1][0], 7);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (find)
|
|
|
+ ShmSysConfigAndInfo->SysWarningInfo.WarningCount--;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
//==========================================
|
|
|
// Init all share memory
|
|
@@ -259,7 +303,7 @@ int InitShareMemory()
|
|
|
int main(void)
|
|
|
{
|
|
|
int ByteCount,BitCount;
|
|
|
- unsigned char tmp, EventCodeTmp[7];
|
|
|
+ unsigned char tmp, EventCodeTmp[7], EventCodeDisp[7];
|
|
|
|
|
|
if(InitShareMemory() == FAIL)
|
|
|
{
|
|
@@ -288,13 +332,20 @@ int main(void)
|
|
|
{
|
|
|
memset(EventCodeTmp,0,sizeof(EventCodeTmp));
|
|
|
memcpy(EventCodeTmp,FaultStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
|
|
|
+ memcpy(EventCodeDisp, EventCodeTmp, ARRAY_SIZE(EventCodeTmp));
|
|
|
+
|
|
|
if(((tmp>>BitCount)&0x01)==0)//Recovered
|
|
|
{
|
|
|
EventCodeTmp[0]='1';
|
|
|
ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount]&=~(1<<BitCount);
|
|
|
+ RemoveFaultCodeToBuf(EventCodeDisp);
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount]|=(1<<BitCount);
|
|
|
+ AddFaultCodeToBuf(EventCodeDisp);
|
|
|
+ }
|
|
|
+
|
|
|
EVENT_INFO("%s\n", EventCodeTmp);
|
|
|
}
|
|
|
}
|
|
@@ -313,13 +364,19 @@ int main(void)
|
|
|
{
|
|
|
memset(EventCodeTmp,0,sizeof(EventCodeTmp));
|
|
|
memcpy(EventCodeTmp,AlarmStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
|
|
|
+ memcpy(EventCodeDisp, EventCodeTmp, ARRAY_SIZE(EventCodeTmp));
|
|
|
+
|
|
|
if(((tmp>>BitCount)&0x01)==0)//Recovered
|
|
|
{
|
|
|
EventCodeTmp[0]='1';
|
|
|
ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount]&=(0<<BitCount);
|
|
|
+ RemoveFaultCodeToBuf(EventCodeDisp);
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount]|=(1<<BitCount);
|
|
|
+ AddFaultCodeToBuf(EventCodeDisp);
|
|
|
+ }
|
|
|
EVENT_INFO("%s\n", EventCodeTmp);
|
|
|
}
|
|
|
}
|
|
@@ -338,13 +395,19 @@ int main(void)
|
|
|
{
|
|
|
memset(EventCodeTmp,0,sizeof(EventCodeTmp));
|
|
|
memcpy(EventCodeTmp,InfoStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
|
|
|
+ memcpy(EventCodeDisp, EventCodeTmp, ARRAY_SIZE(EventCodeTmp));
|
|
|
+
|
|
|
if(((tmp>>BitCount)&0x01)==0)//Recovered
|
|
|
{
|
|
|
EventCodeTmp[0]='1';
|
|
|
ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount]&=(0<<BitCount);
|
|
|
+ RemoveFaultCodeToBuf(EventCodeDisp);
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount]|=(1<<BitCount);
|
|
|
+ AddFaultCodeToBuf(EventCodeDisp);
|
|
|
+ }
|
|
|
EVENT_INFO("%s\n", EventCodeTmp);
|
|
|
}
|
|
|
}
|