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.
65 lines
1.4 KiB
C++
65 lines
1.4 KiB
C++
#include "StdAfx.h"
|
|
#include "EncryptionMgr.h"
|
|
#include "PlcIOMgr.h"
|
|
#include "LogMgr.h"
|
|
#include "MsgBox.h"
|
|
|
|
#define ENCRYPT_PORT "5" //加密使用的PLC 端口
|
|
|
|
CEncryptionMgr *gEncryptionMgr = new CEncryptionMgr;
|
|
CEncryptionMgr::CEncryptionMgr(void)
|
|
{
|
|
m_bEncrypt = false;//是否需要加密
|
|
m_bLocked = false;//是否被锁定(锁定之后不能正常运行)
|
|
}
|
|
CEncryptionMgr::~CEncryptionMgr(void)
|
|
{
|
|
}
|
|
void CEncryptionMgr::Ini()
|
|
{
|
|
if(!m_bEncrypt)
|
|
return ;
|
|
//打开软件时检查锁定状态
|
|
//CheckLockState();
|
|
}
|
|
|
|
//检查锁定状态
|
|
void CEncryptionMgr::CheckLockState()
|
|
{
|
|
if(m_bEncrypt)
|
|
{
|
|
if(!gPlcIOMgr->CheckPortState(ENCRYPT_PORT,5))
|
|
{
|
|
m_bLocked = true;//是否被锁定(锁定之后不能正常运行)
|
|
gLogMgr->WriteDebugLog("Err---->EncryptionMgr Check Lock State");
|
|
gLogMgr->WriteDebugLog("Device Locked");
|
|
}
|
|
else
|
|
{
|
|
m_bLocked = false;
|
|
gLogMgr->WriteDebugLog("Fun---->EncryptionMgr Check Lock State");
|
|
gLogMgr->WriteDebugLog("Device UnLocked");
|
|
}
|
|
}
|
|
}
|
|
//检查是否处于锁定状态
|
|
bool CEncryptionMgr::IsbLocked()
|
|
{
|
|
if(!m_bEncrypt)
|
|
return false;
|
|
|
|
if(m_bLocked)
|
|
{
|
|
CMsgBox MsgBox;
|
|
MsgBox.Show("设备授权证书错误:代码0x000045");
|
|
}
|
|
return m_bLocked;
|
|
}
|
|
//解锁
|
|
void CEncryptionMgr::UnLock()
|
|
{
|
|
|
|
gLogMgr->WriteDebugLog("Fun---->EncryptionMgr Unlock Succeed");
|
|
}
|
|
|