| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- // mod_heartbeat.cpp : Defines the exported functions for the DLL application.
- //
- #include "stdafx.h"
- #include "mod_heartbeat.h"
- void HeartBeatServerSession::Handle_Instruction(SpReqAnsContext<HeartBeatService_Instruction_Req, HeartBeatService_Instruction_Ans>::Pointer ctx)
- {
- LOG_FUNCTION();
- m_pEntity->Instruction(ctx);
- }
- void HeartBeatServerSession::Handle_CardActive(SpReqAnsContext<HeartBeatService_CardActive_Req, HeartBeatService_CardActive_Ans>::Pointer ctx)
- {
- LOG_FUNCTION();
- m_pEntity->CardActive(ctx);
- }
- void HeartBeatServerSession::Handle_CrossTermCall(SpReqAnsContext<HeartBeatService_CrossTermCall_Req, HeartBeatService_CrossTermCall_Ans>::Pointer ctx)
- {
- LOG_FUNCTION();
- m_pEntity->CrossTermCall(ctx);
- }
- void HeartBeatServerSession::Handle_CallFromILToRVC(SpOnewayCallContext<HeartBeatService_CallFromILToRVC_Info>::Pointer ctx)
- {
- LOG_FUNCTION();
- m_pEntity->CallFromILToRVC(ctx);
- }
- void HeartBeatServerSession::Handle_CallResultToIL(SpOnewayCallContext<HeartBeatService_CallResultToIL_Info>::Pointer ctx)
- {
- LOG_FUNCTION();
- m_pEntity->CallResultToIL(ctx);
- }
- ErrorCodeEnum CHeartBeatEntity::GetEntityErrorList(int &warmLevel,CSimpleStringA &strList)
- {
- if (m_pSelfCheckerClient == NULL)
- {
- m_pSelfCheckerClient = new SelfCheckerService_ClientBase(this);
- if (m_pSelfCheckerClient == NULL)
- {
- Dbg("create(new) client failed.");
- m_pSelfCheckerClient->SafeDelete();
- m_pSelfCheckerClient = NULL;
- return Error_Resource;
- }
- Dbg("creat selfchecher client suc.");
- }
- ErrorCodeEnum eErr = Error_Unexpect;
- CSmartPointer<IAsynWaitSp> spWait;
- if (!m_bConnetedSS)
- {
- ErrorCodeEnum eErrConn = Error_Unexpect;
- eErrConn = m_pSelfCheckerClient->Connect(spWait);
- if (eErrConn == Error_Succeed && spWait != NULL)
- eErr = spWait->WaitAnswer(2000);
- if (eErrConn != Error_Succeed || eErr != Error_Succeed)
- {
- Dbg("connect to selfchecker failed.");
- m_pSelfCheckerClient->SafeDelete();
- m_pSelfCheckerClient = NULL;
- return Error_Unexpect;
- }
- Dbg("connect to selfchecker suc.");
- m_bConnetedSS = true;
- }
- //SpReqAnsContext<SelfCheckerService_GetEntityErrorList_Req, SelfCheckerService_GetEntityErrorList_Ans>::Pointer ctx;
- SelfCheckerService_GetEntityErrorList_Req req;
- SelfCheckerService_GetEntityErrorList_Ans ans;
- eErr = m_pSelfCheckerClient->GetEntityErrorList(req,ans,5000);
- if (eErr != Error_Succeed)
- {
- Dbg("GetEntityErrorList failed.%d",eErr);
- m_bConnetedSS = false;
- m_pSelfCheckerClient->SafeDelete();
- m_pSelfCheckerClient = NULL;
- return eErr;
- }
- m_fsm.SetErrorList(ans.warmLevel,ans.list);
- return Error_Succeed;
- }
- void CHeartBeatEntity::OnSysVarEvent(const char *pszKey,
- const char *pszValue, const char *pszOldValue, const char *pszEntityName)
- {
- if ((_strnicmp(pszKey, "TradeManageState", strlen("TradeManageState")) == 0))
- {
- if (_strnicmp(pszValue, "L", strlen("L")) == 0)
- {
- Dbg("To set trade manager state to 8.");
- m_fsm.SetTradeManagerState(8);
- }
- else
- {
- Dbg("To set trade manager state to 1.");
- m_fsm.SetTradeManagerState(1);
- }
- }
- if ((_strnicmp(pszKey, "TerminalManagerState", strlen("TerminalManagerState")) == 0))
- {
- if (_strnicmp(pszValue, "L", strlen("L")) == 0)
- {
- Dbg("To set terminal manager state to 7.");
- m_fsm.SetTradeManagerState(7);
- }
- else if (_strnicmp(pszValue, "N", strlen("N")) == 0)
- {
- Dbg("To set terminal manager state to 1.");
- m_fsm.SetTradeManagerState(1);
- }
- else if (_strnicmp(pszValue, "K", strlen("K")) == 0)
- {
- Dbg("To set terminal manager state to 6.");
- m_fsm.SetTradeManagerState(6);
- }
- }
- if ((_strnicmp(pszKey, "TerminalStage", strlen("TerminalStage")) == 0))
- {
- if (_strnicmp(pszValue, "A", strlen("A")) == 0)
- {
- Dbg("To set terminal stage to %s.",pszValue);
- m_fsm.SetTerminalStageState(pszValue);
- }
- }
- }
- void CHeartBeatEntity::OnBroadcastEvent(CUUID SubID, const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, CAutoBuffer Buffer)
- {
- if (_strnicmp(pszEntityName, "HealthManager", strlen("HealthManager")) == 0)
- {
- if (dwMessageSignature == eMsgSig_TerminalManager)
- {
- HealthManager::TerminalManager tm;
- SpBuffer2Object(Buffer, tm);
- if (tm.op == 99)
- {
- Dbg("Receive healthmanager event 99,to set terminal manager state to 1.");
- m_fsm.SetTradeManagerState(1);
- }
- }
- }
- }
- void CHeartBeatEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID, const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
- const DWORD dwSysError, const DWORD dwUserCode, const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
- const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName, const char *pszMessage)
- {
- switch (dwUserCode)
- {
- default:
- break;
- }
- }
- SP_BEGIN_ENTITY_MAP()
- SP_ENTITY(CHeartBeatEntity)
- SP_END_ENTITY_MAP()
|