| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- #pragma once
- #include <string>
- #include <map>
- #include "platform.h"
- #include "BaseDispatch.h"
- #if defined(_MSC_VER) || defined(WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
- #define STD_CALL __stdcall
- #else
- #define STD_CALL __attribute__((__stdcall__))
- #endif
- //模块创建和释放的函数指针
- typedef CBaseDispatch* (STD_CALL* _CreateSubModule)();
- typedef void(STD_CALL* _FreeSubModule)(void*);
- using namespace std;
- //模块管理信息
- struct sPlugin
- {
- int nModuleID;
- void* nFileDll; //库的句柄
- _CreateSubModule nCreatePlug; //创建模块的函数指针
- _FreeSubModule nFreePlug; //释放模块的函数指针
- bool bInitOk; //是否初始化成功
- string Str_ModuleName; //模块名称
- void Check_Is_OK()
- {
- if (NULL == nCreatePlug || NULL == nFreePlug)
- {
- bInitOk = false;
- }
- else
- {
- bInitOk = true;
- }
- }
- sPlugin()
- {
- nModuleID = -1; //模块编号
- nFileDll = NULL; //库的句柄
- nCreatePlug = NULL; //创建模块的函数指针
- nFreePlug = NULL; //释放模块的函数指针
- bInitOk = false; //是否初始化成功
- Str_ModuleName = ""; //模块名称
- }
- };
- typedef map<int, sPlugin> Map_Plugin;
- typedef map<std::string, CBaseDispatch*> DISTASKMAP;
- class LogCtrl :public CFrameTool_I
- {
- public:
- virtual BOOL Add_Log(int nLevel, LPCSTR pszFmt, ...);
- private:
- };
- class TaskMNG
- {
- /*
- ===============================================单例=====================================================
- */
- public:
- //初始化获取
- static TaskMNG* instance();
- //释放结束
- static void destroyInstance();
- enum TaskStatus
- {
- Status_Error=-1,
- Status_Null = 0,
- Status_Init = 1,
- Status_Run = 2,
- Status_Pass = 3,
- Status_Stop = 4,
- };
- private:
- TaskMNG();
- ~TaskMNG();
- TaskMNG(const TaskMNG& pData);
- //const TaskMNG& operator=(const TaskMNG& pData)=0;
- static TaskMNG* g_GlobalSingle;
- static std::mutex m_Mutex;
- public:
- void InitDB(string strIP,int nType,string strDBname,string strUser,string strPwd);
- bool CreateDispatchTask(int courseid, int systype, int trainid
- , int runlineid, int parm1, int parm2, InitCourInfo* curseinfo);
- bool DeleteDispatchTask(int courseid, int systype, int trainid);
- bool StopDispatchTask(int courseid, int systype, int trainid);
- bool PauseDispatchTask(int courseid, int systype, int trainid);
- bool ResumeDispatchTask(int courseid, int systype, int trainid);
- bool RunDispatchTask(int courseid, int systype, int trainid);
- bool NetComand_Receive(OCCCOMMAND& command);
- void NetComand_Send(LPBASENETPACKET pnetmsg, int dessystype, OCCCOMMAND::CmdType cmdtype, int trianid, int nDesID = -1);
- //获取列表
- CBaseDispatch* CreateNewTaskType(int systype);
- //日志模块
- void AddLogItem(string str1, string str2, int nLevel);
- string GetCurTime_ms();
- CBaseDispatch* pGetEleVOC();
- TaskMNG::TaskStatus getTaskStatus();
- std::string getTaskText();
- protected:
- DISTASKMAP m_DispatchTasksMap;
- public:
- CommandQueue m_pSendList;
- CommandQueue m_pRecvList;
- CommandQueue m_pSendGroupList;
- CommandQueue m_pGetGroupList;
- CommandQueue m_pGetRealList;
- CommandQueue m_pSendRealList;
- YD_DBOperator* m_pdb;
- int m_NetServerID;
- public:
- Map_Plugin m_PluginMap;
- string m_strSeverIP;
- string m_strDBName;
- string m_strUserID;
- string m_strPassWord;
- int m_nDBType;
- LogCtrl pLogCtrl;
- TaskStatus nTaskStatus;
- string m_strLog;
- };
|