You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

767 lines
31 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "StdAfx.h"
#include "WarningMgr.h"
#include "LogMgr.h"
#include "FileMgr.h"
#include "WorkTime.h"
#include "CStringFuc.h"
#include "MsgBox.h"
#include "ModuleDeviceMgr.h"
#include "ExceptionMsg.h"
#include "EncryptionMgr.h"
#include "ProgramLaserTuiHuo.h"
#include "CriticalSection.h"
#define RECORD_FILE_PATH _T("\\WarningRecord")
#define TAB_STR " "
#define SECS_FIRST_ALARM_ID 15001 //secs 通信的第一个alarm id
CWarningMgr *gWarningMgr = new CWarningMgr;
CWarningMgr::CWarningMgr(void)
{
m_bClearAllWarningState = false;//是否正在清空报警
}
CWarningMgr::~CWarningMgr(void)
{
}
#if 1
void CWarningMgr::OnAppInitialize()
{
//创建报警记录的文件夹
CreatRecordPath();
//初始化报警状态容器
InitWarningStateVec();
}
//同步读取的记录状态信息
void CWarningMgr::SyncWarningRecordVec(vector<CWarningState> &RecordInfoVec)
{
int size = RecordInfoVec.size();
for(int k =0;k<size;k++)
{
int size1 = m_WarningStateVec.size();
for(int i =0;i<size1;i++)
{
if(m_WarningStateVec[i].m_WarningCode == RecordInfoVec[k].m_WarningCode)
{
RecordInfoVec[k].m_Description = m_WarningStateVec[i].m_Description;
}
}
}
}
//创建报警记录的文件夹
void CWarningMgr::CreatRecordPath()
{
CString RecordPath;//记录的路径
CFileMgr FileMgr;
FileMgr.GetFullFilePath(RecordPath,RECORD_FILE_PATH);
if(!FileMgr.IsFileExist(RecordPath))//不存在,创建目录
{
FileMgr.CreatDir(RecordPath);
}
}
//获取名字为FileName 的记录路径
CString CWarningMgr::GetRecordFilePath(CString FileName)
{
CString FullFilePath;
CString FilePath = RECORD_FILE_PATH;
FilePath += "\\" + FileName + ".rcd";
CFileMgr FileMgr;
FileMgr.GetFullFilePath(FullFilePath,FilePath);
return FullFilePath;
}
//获取当前记录文件的名字
CString CWarningMgr::GetCurRecordFileName()
{
CString FileName;
CWorkTime WorkTime;
FileName = WorkTime.GetCurDate("_");
return FileName;
}
//初始化所有报警状态
void CWarningMgr::InitWarningStateVec()
{
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_00;
WarningState.m_Description = "";//
WarningState.m_bNeedInitDevice = false;//需要重新初始化
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
int SecsAlarmId = SECS_FIRST_ALARM_ID;//第一个id (定义在Alarm.csv)
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_05;
WarningState.m_Description = "Motion Ctrl I/O Error";//运动控制器IO 错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_08;
WarningState.m_Description = "Motor Z Drive Error";//Z 轴电机报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_09;
WarningState.m_Description = "Machine Gate Check Err";//机械光闸检查失败
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_10;
WarningState.m_Description = "Laser Beam Check Err";//加工前功率/ 光束检测失败
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_11;
WarningState.m_Description = "Wafer adsorption Err";//晶圆吸附检测异常
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_12;
WarningState.m_Description = "Door State Check Err";//门状态检测异常
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_14;
WarningState.m_Description = "Equip Authorization Error";//授权异常
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_17;
WarningState.m_Description = "Laser Spot Meter Error";//光速分析仪错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_18;
WarningState.m_Description = "Laser Device Comm Error";//激光器通信错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
#ifdef __LASER_DEVICE_PHOTONICS__
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
#else
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
#endif
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_19;
WarningState.m_Description = "Laser Device State Error";//激光器状态错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_21;
WarningState.m_Description = "Operate Ldd Error";//操作激光LDD 错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_22;
WarningState.m_Description = "Load Wafer Error";//上料错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_23;
WarningState.m_Description = "UnLoad Wafer Error";//下料错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_24;
WarningState.m_Description = "Red Laser Device Comm Error";//红光激光器通信错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_25;
WarningState.m_Description = "Red Laser device state Error";//红光激光器状态错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_27;
WarningState.m_Description = "Water leaking Alarm";//漏水报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_28;
WarningState.m_Description = "O2 Senser Alarm";//氧气含量过低报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_29;
WarningState.m_Description = "Wind pressure Alarm";//风压检测报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_30;
WarningState.m_Description = "Device Temperature Alarm";//机台温度报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_31;
WarningState.m_Description = "APT pressure Alarm";//APT负压报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_32;
WarningState.m_Description = "Smoke Senser Alarm";//烟雾传感器报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_33;
WarningState.m_Description = "Wave Form Channel Error";//波形发生器错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_34;
WarningState.m_Description = "Laser Cooling Alarm";//绿光水冷机报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_35;
WarningState.m_Description = "Water leaking Alarm";//漏水报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_36;
WarningState.m_Description = "Water leaking Alarm";//漏水报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_37;
WarningState.m_Description = "Water leaking Alarm";//漏水报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_38;
WarningState.m_Description = "Water leaking Alarm";//漏水报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_39;
WarningState.m_Description = "Water leaking Alarm";//漏水报警(PLC 点位反馈)
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_40;
WarningState.m_Description = "Set Laser Par Error";//激光器参数错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_41;
WarningState.m_Description = "Laser1 Pow Check Error";//激光1 功率点检错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_42;
WarningState.m_Description = "Laser2 Pow Check Error";//激光2 功率点检错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_43;
WarningState.m_Description = "Red Laser Pow Check Error";//红光功率点检错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_44;
WarningState.m_Description = "Wafer Aligner Error";//准直器错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_45;
WarningState.m_Description = "Oxygen Check Error";//氧气浓度检测错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_46;
WarningState.m_Description = "Tempratue Measure Error";//温度检测错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = false;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
{
CWarningState WarningState;
WarningState.m_WarningCode = _Warning_Code_47;
WarningState.m_Description ="Anneal Pow Check Error";//退火过程功率监控错误
WarningState.m_bNeedInitDevice = false;
WarningState.m_bSendToServer = false;//报警时是否发送给服务器
WarningState.m_bStopAnnealFlow = true;//是否立即终止退火过程
WarningState.m_SecsAlarmId = SecsAlarmId++;//发送给Secs 服务器的alarm id(定义在Alarm.csv)
WarningState.m_pModule = NULL;
m_WarningStateVec.push_back(WarningState);
}
}
#endif
#if 1
//设置报警状态(bThowException 抛出异常)
void CWarningMgr::SendWarningMsg(EWarningCode WarningCode,CString AddInfo,bool bThowException)
{
//笔记本上运行时不要报警
//if(gEncryptionMgr->IsbRunAtNoteBook())
//return;
gCriticalSection_WarningMsg.Lock();
if(AddInfo == "")
AddInfo = "nothing";
int size = m_WarningStateVec.size();
for(int k =0;k<size;k++)
{
CWarningState &WarningState = m_WarningStateVec[k];
//找到对应的警告
if(WarningState.m_WarningCode == WarningCode)
{
//只有无报警时才设置
if(WarningState.m_bWarning == WARNING_OFF)
{
WarningState.m_bWarning = WARNING_ON;
WarningState.m_AddInfo = AddInfo;
SendWarningMsgExt(WarningState);
}
break;
}
}
gCriticalSection_WarningMsg.Unlock();
if(bThowException)
{
CExceptionMsg ExceptionMsg;
ExceptionMsg.SetMsg(AddInfo);
throw ExceptionMsg;
}
}
void CWarningMgr::SendWarningMsgExt(CWarningState &WarningState)
{
}
//清除所有报警状态
void CWarningMgr::ClearAllWarningState()
{
}
//是否有报警
bool CWarningMgr::HasWarningMsg(bool bException)
{
int size = m_WarningStateVec.size();
for(int k =0;k<size;k++)
{
CWarningState &WarningState = m_WarningStateVec[k];
if(WarningState.m_bWarning)
{
if(bException)
{
CString s("报警状态未清除!");
CExceptionMsg Msg;
Msg.SetMsg(s);
throw Msg;
}
return true;
}
}
return false;
}
//获取指定报警的状态
bool CWarningMgr::GetWarningState(EWarningCode WarningCode)
{
int size = m_WarningStateVec.size();
for(int k =0;k<size;k++)
{
CWarningState &WarningState = m_WarningStateVec[k];
if(WarningState.m_WarningCode == WarningCode)
{
return WarningState.m_bWarning;
}
}
return false;
}
//是否有立即中断退火的报警
bool CWarningMgr::HasStopAnnealWarningMsg()
{
int size = m_WarningStateVec.size();
for(int k =0;k<size;k++)
{
CWarningState &WarningState = m_WarningStateVec[k];
if(WarningState.m_bWarning && WarningState.m_bStopAnnealFlow)
{
return true;
}
}
return false;
}
#endif
#if 1
//增加一条报警记录(写入文件)
void CWarningMgr::AddWarningRecord(CWarningState &WarningState)
{
vector<CWarningState> RecordInfoVec;
//先读取当天的记录
CString RecordFileName = GetCurRecordFileName();
CString RecordFilePath = GetRecordFilePath(RecordFileName);
ReadRecordInfoFile(RecordInfoVec,RecordFilePath);
//当前报警信息加到最后
RecordInfoVec.push_back(WarningState);
//写入到文件
WriteRecordInfoToFile(RecordInfoVec,RecordFilePath);
gLogMgr->WriteDebugLog("func---->AddWarningRecord");
}
//读取记录文件
void CWarningMgr::ReadRecordInfoFile(vector<CWarningState> &RecordInfoVec,CString Path)
{
CFile file;
if(file.Open(Path,CFile::modeRead))
{
CArchive ar(&file,CArchive::load);
int WarningRecordCnt = 0;
ar>>WarningRecordCnt;//记录的数量
for(int k=0;k<WarningRecordCnt;k++)
{
CWarningState WarningRecordInfo;
int tmp;
ar>>tmp;//报警错误的类型
WarningRecordInfo.m_WarningCode = (EWarningCode)tmp;
ar>>WarningRecordInfo.m_DateTime;//日期时间
ar>>WarningRecordInfo.m_AddInfo;//附加信息
RecordInfoVec.push_back(WarningRecordInfo);
}
}
}
void CWarningMgr::WriteRecordInfoToFile(vector<CWarningState> &RecordInfoVec,CString Path)
{
if(RecordInfoVec.empty())
return;
int size = RecordInfoVec.size();
CFile file(Path,CFile::modeReadWrite|CFile::modeCreate);
CArchive ar(&file,CArchive::store);
ar<<size;//记录的个数
for(int k=0;k<size;k++)
{
ar<<(int)RecordInfoVec[k].m_WarningCode;//报警错误的类型
ar<<RecordInfoVec[k].m_DateTime;//日期时间
ar<<RecordInfoVec[k].m_AddInfo;//附加信息
}
}
#endif
#if 1
//获取一个月的记录到RecordInfoVec
void CWarningMgr::GetOneMonthRecord(CString Date,vector<CWarningState> &RecordInfoVec)
{
//搜集当月的所有记录文件
vector<CString> RecordFileNameVec;
GetOneMonthRecordFileName(Date,RecordFileNameVec);
int size = RecordFileNameVec.size();
for(int k=0;k<size;k++)
{
ReadRecordInfoFile(RecordInfoVec,GetRecordFilePath(RecordFileNameVec[k]));
}
}
//2016_11_17---->2016_11
CString CWarningMgr::GetMonthStr(CString Date)
{
return Date.Left(7);
}
//获取一个月的所有record 文件名
void CWarningMgr::GetOneMonthRecordFileName(CString Date,vector<CString> &RecordFileNameVec)
{
//搜集所有记录文件名--------------------------------
vector <CString> NameVec;
CFileMgr FileMgr;
CString RecordPath;
FileMgr.GetFullFilePath(RecordPath,RECORD_FILE_PATH);
FileMgr.GetChildFileOrDirName(false,RecordPath,NameVec,"rcd");
//只保留当月的名字-----------------------------------
CString MonthStr = GetMonthStr(Date);
int size = NameVec.size();
for(int k=0;k<size;k++)
{
CString FileName = FileMgr.GetFileNameFromPath(NameVec[k],true);//提取文件名
if(FileName.Find(MonthStr) != -1)
{
RecordFileNameVec.push_back(FileName);
}
}
}
#endif
#if 1
//初始化报警状态list
void CWarningMgr::InitWarningStateToList(CListCtrl &List)
{
//设置风格
List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
//设置列
int idx = 0;
List.InsertColumn(idx,"代码",LVCFMT_LEFT,50,-1);
idx++;
List.InsertColumn(idx,"时间",LVCFMT_LEFT,150,-1);
idx++;
List.InsertColumn(idx,"描述",LVCFMT_LEFT,250,-1);
idx++;
List.InsertColumn(idx,"提示",LVCFMT_LEFT,350,-1);
idx++;
}
//记录插入到列表bShowByMonth 为按月显示
void CWarningMgr::InsertRecordList(CListCtrl &List,CString Date,bool bShowByMonth)
{
m_RecordInfoVec.clear();
if(bShowByMonth)//读取一个月的记录
{
GetOneMonthRecord(Date,m_RecordInfoVec);
}
else//读取一天的记录
{
CString Path = GetRecordFilePath(Date);
ReadRecordInfoFile(m_RecordInfoVec,Path);
}
//同步读取的记录状态信息
SyncWarningRecordVec(m_RecordInfoVec);
InsertRecordListExt(List,m_RecordInfoVec,false);
}
//bOnlyWarning 只显示报警中的状态
void CWarningMgr::InsertRecordListExt(CListCtrl &List,vector<CWarningState> &WarningStateVec,bool bOnlyWarning)
{
List.DeleteAllItems();
int size = WarningStateVec.size();
int LineIdx = 0;
for(int k =0;k<size;k++)
{
int idx = 0;
CWarningState &WarningState = WarningStateVec[k];
if(bOnlyWarning && !WarningState.m_bWarning)
continue;
List.InsertItem(LineIdx," ");//插入一行
List.SetItemText(LineIdx,idx++,GetWarningCode(WarningState));//代码
List.SetItemText(LineIdx,idx++,WarningState.m_DateTime);//时间
List.SetItemText(LineIdx,idx++,WarningState.m_Description);//描述
List.SetItemText(LineIdx,idx++,WarningState.m_AddInfo);//附加信息
LineIdx++;
}
}
//插入报警状态列表
void CWarningMgr::UpdateWarningStateToList(CListCtrl &List)
{
InsertRecordListExt(List,m_WarningStateVec,true);
}
//获取报警代码
CString CWarningMgr::GetWarningCode(CWarningState &WarningState)
{
CString CodeStr;
//使用Secs 的id 号
CodeStr = Int2CString(WarningState.m_SecsAlarmId);
return CodeStr;
}
#endif