📄 kj4service.cpp
字号:
// KJ4Service.cpp: implementation of the KJ4Service class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "KJ4Service.h"
#include "../KylinSystem/KTimerManager.h"
#include "../KylinSystem/KThreadPool.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
const KGuid KJ4Service::_TypeID(_T("27A1109E-5C6A-4836-B24A-10974731775A"));
const CString KJ4Service::_TypeName(_T("SuperKJ.KJ4Service"));
KJ4Service::KJ4Service()
: mInterfaceFail(true)
{
}
KJ4Service::~KJ4Service()
{
}
const KGuid KJ4Service::TypeID()
{
return _TypeID;
}
const CString KJ4Service::TypeName()
{
return _TypeName;
}
const KGuid KJ4Service::GetTypeID()
{
return _TypeID;
}
const CString KJ4Service::GetTypeName()
{
return _TypeName;
}
bool KJ4Service::Initialize(KXMLNode& node)
{
mMineID = node.GetAttribGuid(_T("mineid"));
mMineName = node.GetAttrib(_T("minename"));
mAddr = node.GetAttrib(_T("addr"), _T("0.0.0.0"));
mPort = node.GetAttribInt(_T("port"), 2048);
mPath = node.GetAttrib(_T("path"));
mInterval = node.GetAttribInt(_T("interval"), 600) * 1000;
mSensorType.Load();
mRealDataStatus.Load();
mRealDataJob.SetHostService(this);
mRealDataJob.Init();
mSensorJob.SetHostService(this);
mSensorJob.Init();
return true;
}
bool KJ4Service::Start()
{
KTimerManager::Instance()->SetTimer(this, 0, mInterval);
mRealDataJob.Start();
return true;
}
bool KJ4Service::Stop()
{
mRealDataJob.Stop();
KTimerManager::Instance()->KillTimer(this, 0);
return true;
}
void KJ4Service::OnTimer(UINT timer, LPVOID param)
{
KThreadPool::Instance()->QueueWorkItem(&mSensorJob);
}
void KJ4Service::GetSensorType(SensorItem& item, const CString &token)
{
item.Type = 0;
//根据token(测点定义文件中的名称,实际上指明了测点的类型)确定测点类型
//如果上述操作失败,则根据测点的单位确定测点类型
mSensorType.GetSensorType(item, token);
}
void KJ4Service::GetRealDataStatus(RealDataItem &item, const CString &token)
{
item.Status = 0;
mRealDataStatus.GetStatus(item, token);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -