SysGlobalF.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. //---------------------------------------------------------------------------
  2. #ifndef SysGlobalFH
  3. #define SysGlobalFH
  4. //---------------------------------------------------------------------------
  5. #include <vcl.h>
  6. #include <assert.h>
  7. #include <stdio.h>
  8. #include <windef.h>
  9. //---------------------------------------------------------------------------
  10. /*
  11. ******************************************************************************
  12. * Define
  13. ******************************************************************************
  14. */
  15. #define SAFE_DELETE(p) {if (p != NULL) { delete p; p = NULL; }}
  16. /*
  17. ******************************************************************************
  18. * Define constant
  19. ******************************************************************************
  20. */
  21. #define MAINHANDLE Application->MainForm->Handle
  22. // SendMessageTimeout
  23. #define SEND_LOGMSG(a,b,c,d,e,f,g) ::SendMessageTimeout(a, b, (WPARAM)c, (LPARAM)d, e, f, &g)
  24. //#define SEND_LOGMSG(a,b,c,d,e,f,g) ::PostMessage(a, b, (WPARAM)c, (LPARAM)d)
  25. #define SEND_MSG(x,y,z,p) ::SendMessage(x, y, (WPARAM)z, (LPARAM)p)
  26. #define POST_MSG(x,y,z,p) ::PostMessage(x, y, (WPARAM)z, (LPARAM)p)
  27. #define USER_MSG(x,y,z) ::PostMessage(x, WM_USER, (WPARAM)y, (LPARAM)p)
  28. #define WM_WINDOW_RESTORE (WM_USER+0xA0) /* 중복실행시 기존 윈도우 활성화 */
  29. #define WM_THREAD (WM_USER+0xF1) /* 스레드 연계 메시지 */
  30. #define WM_TCP_CLIENT (WM_USER+0xF2) /* TCP Client */
  31. #define WM_TCP_SERVER (WM_USER+0xF3) /* TCP Client */
  32. #define WM_VMS_THREAD (WM_USER+0xF4)
  33. #define WM_VMS_SERVER_STTS (WM_USER+0xB2) // VMS 접속/해제(통신스레드->메인)
  34. #define WM_VMS_CLIENT_STTS (WM_USER+0xB3) // VMS 접속/해제(통신스레드->메인)
  35. #define WM_VMS_STATE_STTS (WM_USER+0xB4) // VMS 상태정보 업데이트
  36. // 스레드 종료 대기 시간
  37. #define WAIT_THREAD_TERMINATE_TIME 5000 // Wait Thread Terminate Time(5 seconds)
  38. /*
  39. ******************************************************************************
  40. * 스레드로 전달하는 메시지
  41. ******************************************************************************
  42. */
  43. #define WM_EQUIP_STATE_ALL (WM_USER+0xB2) /* 시설물상태 개별 입력 */
  44. #define WM_EQUIP_STATE (WM_USER+0xC2) /* 시설물상태 전체 입력 */
  45. #define WM_DATABASE_CLOSE (WM_USER+0xA0) /* DATABASE CLOSE */
  46. #define WM_DATABASE_REFLASH (WM_USER+0xA1) /* DATABASE REFLASH */
  47. #define WM_DATABASE_OPEN (WM_USER+0xA2) /* DATABASE OPEN */
  48. #define WM_LOG_DISPLAY (WM_USER+0xA3) /* LOG DISPLAY */
  49. #define WM_MASTER_FORM (WM_USER+0xD1) /* 폼정보 변경 */
  50. #define WM_MASTER_IMAGE_SYMBOL (WM_USER+0xD2) /* 폼이미지정보 변경 */
  51. #define WM_MASTER_IMAGE_TRAFFIC (WM_USER+0xD3) /* 폼이미지소통정보 변경 */
  52. #define WM_MASTER_VMS_IFSC (WM_USER+0xD4) /* VMS IFSC 정보 변경 */
  53. #define WM_DATA_SAVE (WM_USER+0xA8) /* 데이터 저장 */
  54. #define WM_GET_ONOFF (WM_USER+0xA9) /* VMS ON/OFF */
  55. #define WM_PROVIDE_PROC (WM_USER+0xAA) /* VMS 교통정보 */
  56. #define WM_PROVIDE_SAVE (WM_USER+0xAB) /* VMS 제공정보 저장 */
  57. #define WM_DOWNLOAD_PROC (WM_USER+0xAC) /* VMS 다운로드 */
  58. #define WM_MAKE_DOWNLOAD_FORM (WM_USER+0xAD) /* VMS 다운로드폼 생성 */
  59. #define WM_SAVE_DOWNLOAD_FORM (WM_USER+0xAE) /* VMS 다운로드폼 저장 */
  60. /*
  61. ******************************************************************************
  62. * User Define
  63. ******************************************************************************
  64. */
  65. typedef enum eLOG_TYPE
  66. {
  67. LLOG = 3,
  68. LJOB = 5,
  69. LWARNING = 6,
  70. LERROR = 7,
  71. LALARM = 8,
  72. } LOG_TYPE;
  73. //---------------------------------------------------------------------------
  74. typedef struct tagThreadInfo
  75. {
  76. TThread *pThread;
  77. DWORD dwThreadId;
  78. unsigned int nHandle;
  79. bool bRunning;
  80. public:
  81. void Clear()
  82. {
  83. pThread = NULL;
  84. dwThreadId = 0;
  85. nHandle = 0;
  86. bRunning = false;
  87. }
  88. } THREAD_INFO;
  89. //---------------------------------------------------------------------------
  90. typedef struct tagDatabaseInfo
  91. {
  92. String sProvider;
  93. String sServerName;
  94. String sCatalog;
  95. String sUserName;
  96. String sPassword;
  97. String sConnectStr;
  98. public:
  99. void Clear()
  100. {
  101. sProvider = "";
  102. sServerName = "";
  103. sCatalog = "";
  104. sUserName = "";
  105. sPassword = "";
  106. sConnectStr = "";
  107. }
  108. void MakeConnString()
  109. {
  110. sConnectStr = "";
  111. sConnectStr += "Provider=" + sProvider;
  112. sConnectStr += ";Password=" + sPassword;
  113. sConnectStr += ";Persist Security Info=True";
  114. sConnectStr += ";User ID=" + sUserName;
  115. if (sCatalog != "")
  116. {
  117. sConnectStr += ";Initial Catalog=" + sCatalog;
  118. }
  119. sConnectStr += ";Data Source=" + sServerName;
  120. }
  121. } DATABASE_INFO;
  122. //---------------------------------------------------------------------------
  123. /*
  124. ******************************************************************************
  125. * Global variable definitions
  126. ******************************************************************************
  127. */
  128. extern String g_sAppDir ; // Application Directory
  129. extern String g_sAppName; // Program name
  130. extern String g_sCfgDir ; // Program Config Directory
  131. extern String g_sLogDir ; // Program Log Directory
  132. extern String g_sTempDir; // Program Temp Directory
  133. extern String g_sImgDir; // Program Image Directory
  134. extern String g_sFormDir; // Program Form Directory
  135. extern String g_sFtpDir ; // Application Directory
  136. /*
  137. ******************************************************************************
  138. * Global function definitios
  139. ******************************************************************************
  140. */
  141. bool SYS_ApplicationSingleInstance(AnsiString AProgName, AnsiString APidFile);
  142. void SYS_WritePidFile(long AHandle);
  143. bool SYS_WriteConfigInfo(String sTitle, String sItem, String sValue, String sCfgFile="");
  144. bool ReadConfigInfo(String sTitle, String sItem, String &sValue, String sCfgFile="");
  145. String SYS_GetSysError();
  146. #endif