123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- #include <string>
- #include <iostream>
- #include <vector>
- #include <SpUtility.h>
- struct EntityEntry
- {
- CSimpleStringA Name;
- CSimpleStringA ModuleName;
- int Type;
- int State;
- int Id;
- int Pid;
- int DevelopID;
- int DebugLevel;
- CSmallDateTime lastStartTime;
- static const char* GetTypeName(int type)
- {
- static const char* _names[] = {
- "auto",
- "manual"
- };
- return _names[type % ARRAYSIZE(_names)];
- }
- static const char* GetStateName(int state)
- {
- static const char* _names[] = {
- "NoStart",
- "Starting",
- "Idle",
- "Busy",
- "Pause",
- "UnLoading",
- "Lost",
- "Close",
- "Killed",
- };
- return _names[state % ARRAYSIZE(_names)];
- }
- static const char* GetErrorName(ErrorCodeEnum Error)
- {
- return "Unknown Error";
- }
- };
- #define OP_STOP_ENTITY 0
- #define OP_START_ENTITY 1
- #define OP_PAUSE_ENTITY 2
- #define OP_TERMINATE_ENTITY 3
- #define OP_CONTINUE_ENTITY 4
- #define OP_FIRE_ENTITY_STATE 5
- struct callback_entry : public IReleasable
- {
- virtual ~callback_entry() {}
- CSimpleStringA EntityName;
- union {
- void* pRawData;
- int state;
- };
- int op;
- ErrorCodeEnum ErrorResult;
- };
- struct TerminalBaseInfo
- {
- CSimpleStringA strTerminalNo;
- CSimpleStringA strMachineType;
- CSimpleStringA strSoftwareVersion;
- TerminalBaseInfo()
- :strTerminalNo(true), strMachineType(true), strSoftwareVersion(true) {}
- TerminalBaseInfo(TerminalBaseInfo& rhs)
- :strTerminalNo(rhs.strTerminalNo), strMachineType(rhs.strMachineType), strSoftwareVersion(rhs.strSoftwareVersion) {}
- TerminalBaseInfo(const TerminalBaseInfo& rhs)
- :strTerminalNo(rhs.strTerminalNo), strMachineType(rhs.strMachineType), strSoftwareVersion(rhs.strSoftwareVersion)
- {
- }
- };
- // ½« process ¸ÄÃûΪ processStatus
- struct processStatus {
- std::string processName;
- int ID;
- double PercentProcessorTime;
- unsigned long UsedMemory;
- double PercentMemory;
- int HandleCount;
- char UserName[MAX_PATH];
- //ULONGLONG UpTime;
- //DWORD BasePriority;
- //DWORD ParentPID;
- //ULONGLONG DiskOperationsPrev;
- //ULONGLONG DiskOperations;
- //DWORD DiskUsage;
- //DWORD TreeDepth;
- // Constructor to initialize the fields
- processStatus() {
- ID = 0;
- PercentProcessorTime = 0.0;
- UsedMemory = 0;
- PercentMemory = 0.0;
-
- HandleCount = 0;
-
- ZeroMemory(UserName, sizeof(UserName));
- //Handle = nullptr;
- //UpTime = 0;
- //BasePriority = 0;
- //ParentPID = 0;
- //DiskOperationsPrev = 0;
- //DiskOperations = 0;
- //DiskUsage = 0;
- //TreeDepth = 0;
- }
- };
- struct system_monitor_status {
- std::vector<processStatus> processList;
- double total_cpu;
- long total_tasks;
- ULONGLONG total_uptime;
- ULONGLONG TotalMemory;
- ULONGLONG UsedMemory;
- double UsedMemoryPerc;
- ULONGLONG TotalPageMemory;
- ULONGLONG UsedPageMemory;
- double UsedPageMemoryPerc;
- // Constructor to initialize the fields
- system_monitor_status()
- : total_cpu(0.0),
- total_tasks(0),
- total_uptime(0),
- TotalMemory(0),
- UsedMemory(0),
- UsedMemoryPerc(0.0),
- TotalPageMemory(0),
- UsedPageMemory(0),
- UsedPageMemoryPerc(0.0)
- {
- processList.clear();
- }
- };
- #define TO_MB(X) ((X)/1048576)
- std::pair<long, std::string> PollProcessList(long UpdateTime, system_monitor_status& curStatus);
- std::string GenerateTimeStr();
- std::string LogTypeEnumToString(LogTypeEnum logType);
- LogTypeEnum StringToLogTypeEnum(const std::string& logTypeStr);
- void startProcess(std::string cmdline, bool isWait);
|