guiconsole_define.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #include <string>
  2. #include <iostream>
  3. #include <vector>
  4. #include <SpUtility.h>
  5. struct EntityEntry
  6. {
  7. CSimpleStringA Name;
  8. CSimpleStringA ModuleName;
  9. int Type;
  10. int State;
  11. int Id;
  12. int Pid;
  13. int DevelopID;
  14. int DebugLevel;
  15. CSmallDateTime lastStartTime;
  16. static const char* GetTypeName(int type)
  17. {
  18. static const char* _names[] = {
  19. "auto",
  20. "manual"
  21. };
  22. return _names[type % ARRAYSIZE(_names)];
  23. }
  24. static const char* GetStateName(int state)
  25. {
  26. static const char* _names[] = {
  27. "NoStart",
  28. "Starting",
  29. "Idle",
  30. "Busy",
  31. "Pause",
  32. "UnLoading",
  33. "Lost",
  34. "Close",
  35. "Killed",
  36. };
  37. return _names[state % ARRAYSIZE(_names)];
  38. }
  39. static const char* GetErrorName(ErrorCodeEnum Error)
  40. {
  41. return "Unknown Error";
  42. }
  43. };
  44. #define OP_STOP_ENTITY 0
  45. #define OP_START_ENTITY 1
  46. #define OP_PAUSE_ENTITY 2
  47. #define OP_TERMINATE_ENTITY 3
  48. #define OP_CONTINUE_ENTITY 4
  49. #define OP_FIRE_ENTITY_STATE 5
  50. struct callback_entry : public IReleasable
  51. {
  52. virtual ~callback_entry() {}
  53. CSimpleStringA EntityName;
  54. union {
  55. void* pRawData;
  56. int state;
  57. };
  58. int op;
  59. ErrorCodeEnum ErrorResult;
  60. };
  61. struct TerminalBaseInfo
  62. {
  63. CSimpleStringA strTerminalNo;
  64. CSimpleStringA strMachineType;
  65. CSimpleStringA strSoftwareVersion;
  66. TerminalBaseInfo()
  67. :strTerminalNo(true), strMachineType(true), strSoftwareVersion(true) {}
  68. TerminalBaseInfo(TerminalBaseInfo& rhs)
  69. :strTerminalNo(rhs.strTerminalNo), strMachineType(rhs.strMachineType), strSoftwareVersion(rhs.strSoftwareVersion) {}
  70. TerminalBaseInfo(const TerminalBaseInfo& rhs)
  71. :strTerminalNo(rhs.strTerminalNo), strMachineType(rhs.strMachineType), strSoftwareVersion(rhs.strSoftwareVersion)
  72. {
  73. }
  74. };
  75. // ½« process ¸ÄÃûΪ processStatus
  76. struct processStatus {
  77. std::string processName;
  78. int ID;
  79. double PercentProcessorTime;
  80. unsigned long UsedMemory;
  81. double PercentMemory;
  82. int HandleCount;
  83. char UserName[MAX_PATH];
  84. //ULONGLONG UpTime;
  85. //DWORD BasePriority;
  86. //DWORD ParentPID;
  87. //ULONGLONG DiskOperationsPrev;
  88. //ULONGLONG DiskOperations;
  89. //DWORD DiskUsage;
  90. //DWORD TreeDepth;
  91. // Constructor to initialize the fields
  92. processStatus() {
  93. ID = 0;
  94. PercentProcessorTime = 0.0;
  95. UsedMemory = 0;
  96. PercentMemory = 0.0;
  97. HandleCount = 0;
  98. ZeroMemory(UserName, sizeof(UserName));
  99. //Handle = nullptr;
  100. //UpTime = 0;
  101. //BasePriority = 0;
  102. //ParentPID = 0;
  103. //DiskOperationsPrev = 0;
  104. //DiskOperations = 0;
  105. //DiskUsage = 0;
  106. //TreeDepth = 0;
  107. }
  108. };
  109. struct system_monitor_status {
  110. std::vector<processStatus> processList;
  111. double total_cpu;
  112. long total_tasks;
  113. ULONGLONG total_uptime;
  114. ULONGLONG TotalMemory;
  115. ULONGLONG UsedMemory;
  116. double UsedMemoryPerc;
  117. ULONGLONG TotalPageMemory;
  118. ULONGLONG UsedPageMemory;
  119. double UsedPageMemoryPerc;
  120. // Constructor to initialize the fields
  121. system_monitor_status()
  122. : total_cpu(0.0),
  123. total_tasks(0),
  124. total_uptime(0),
  125. TotalMemory(0),
  126. UsedMemory(0),
  127. UsedMemoryPerc(0.0),
  128. TotalPageMemory(0),
  129. UsedPageMemory(0),
  130. UsedPageMemoryPerc(0.0)
  131. {
  132. processList.clear();
  133. }
  134. };
  135. #define TO_MB(X) ((X)/1048576)
  136. std::pair<long, std::string> PollProcessList(long UpdateTime, system_monitor_status& curStatus);
  137. std::string GenerateTimeStr();
  138. std::string LogTypeEnumToString(LogTypeEnum logType);
  139. LogTypeEnum StringToLogTypeEnum(const std::string& logTypeStr);
  140. void startProcess(std::string cmdline, bool isWait);