FrmVmsOprMainF.cpp 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSLangTransF.h"
  6. #include "ITSMapF.h"
  7. #pragma hdrstop
  8. #include "FrmVmsOprMainF.h"
  9. #include "TThreadPollingF.h"
  10. #include "FrmInitializeF.h" // 프로그램 초기화화면
  11. //#include "CDSVmsTrafficF.h"
  12. //---------------------------------------------------------------------------
  13. #include "VMS0500MF.h"
  14. #include "VMS0100MF.h"
  15. #include "VMS0200MF.h"
  16. #include "VMS0300MF.h"
  17. #include "VMS0600MF.h"
  18. #include "VMS0000MF.h"
  19. #include "VMS0010MF.h"
  20. #include "VMSM100MF.h"
  21. #include "VMSM200MF.h"
  22. #include "VMSM210MF.h"
  23. #ifdef USE_EVPS
  24. #include "VMSMA00MF.h"
  25. #include "VMSMA10MF.h"
  26. #endif
  27. #include "VMSM400MF.h"
  28. #include "VMSM410MF.h"
  29. #include "VMSM420MF.h"
  30. #include "VMSM430MF.h"
  31. #include "VMSM500MF.h"
  32. #include "VMSM600MF.h"
  33. #include "VMSM700MF.h"
  34. #include "VMSM800MF.h"
  35. #include "VMSM900MF.h"
  36. //---------------------------------------------------------------------------
  37. //---------------------------------------------------------------------------
  38. #pragma package(smart_init)
  39. #pragma link "cxClasses"
  40. #pragma link "cxContainer"
  41. #pragma link "cxControls"
  42. #pragma link "cxEdit"
  43. #pragma link "cxGraphics"
  44. #pragma link "cxHint"
  45. #pragma link "cxLabel"
  46. #pragma link "cxLookAndFeelPainters"
  47. #pragma link "cxLookAndFeels"
  48. #pragma link "cxMaskEdit"
  49. #pragma link "cxPC"
  50. #pragma link "cxPCdxBarPopupMenu"
  51. #pragma link "cxSpinEdit"
  52. #pragma link "cxTextEdit"
  53. #pragma link "dxBar"
  54. #pragma link "dxCustomHint"
  55. #pragma link "dxRibbon"
  56. #pragma link "dxRibbonGallery"
  57. #pragma link "dxRibbonSkins"
  58. #pragma link "dxRibbonStatusBar"
  59. #pragma link "dxScreenTip"
  60. #pragma link "dxSkinBlack"
  61. #pragma link "dxSkinBlue"
  62. #pragma link "dxSkinCaramel"
  63. #pragma link "dxSkinChooserGallery"
  64. #pragma link "dxSkinCoffee"
  65. #pragma link "dxSkinDarkRoom"
  66. #pragma link "dxSkinDarkSide"
  67. #pragma link "dxSkinFoggy"
  68. #pragma link "dxSkinGlassOceans"
  69. #pragma link "dxSkiniMaginary"
  70. #pragma link "dxSkinLilian"
  71. #pragma link "dxSkinLiquidSky"
  72. #pragma link "dxSkinLondonLiquidSky"
  73. #pragma link "dxSkinMcSkin"
  74. #pragma link "dxSkinMoneyTwins"
  75. #pragma link "dxSkinOffice2007Black"
  76. #pragma link "dxSkinOffice2007Blue"
  77. #pragma link "dxSkinOffice2007Green"
  78. #pragma link "dxSkinOffice2007Pink"
  79. #pragma link "dxSkinOffice2007Silver"
  80. #pragma link "dxSkinOffice2010Black"
  81. #pragma link "dxSkinOffice2010Blue"
  82. #pragma link "dxSkinOffice2010Silver"
  83. #pragma link "dxSkinsCore"
  84. #pragma link "dxSkinscxPCPainter"
  85. #pragma link "dxSkinsdxBarPainter"
  86. #pragma link "dxSkinsdxRibbonPainter"
  87. #pragma link "dxSkinSeven"
  88. #pragma link "dxSkinsForm"
  89. #pragma link "dxSkinSharp"
  90. #pragma link "dxSkinSilver"
  91. #pragma link "dxSkinStardust"
  92. #pragma link "dxStatusBar"
  93. #pragma link "dxTabbedMDI"
  94. #pragma link "IdAntiFreeze"
  95. #pragma link "IdAntiFreezeBase"
  96. #pragma link "IdBaseComponent"
  97. #pragma link "dxSkinPumpkin"
  98. #pragma link "dxSkinsDefaultPainters"
  99. #pragma link "dxSkinSpringTime"
  100. #pragma link "dxSkinSummer2008"
  101. #pragma link "dxSkinValentine"
  102. #pragma link "dxSkinXmas2008Blue"
  103. #pragma resource "*.dfm"
  104. TFrmVmsOprMain *FrmVmsOprMain = NULL;
  105. #define MAX_EXEPROGRAM 5
  106. ST_RUNPROGRAM g_RunProgram[MAX_EXEPROGRAM+1] = {
  107. {"TFrmVmsLogStts", "VmsLogStts.exe", "VMS상태이력조회"},
  108. {"TFrmVmsLogDspl", "VmsLogDspl.exe", "VMS제공이력조회"},
  109. {"TFrmVmsLogCtrl", "VmsLogCtrl.exe", "VMS제어이력조회"},
  110. {"TFrmVmsLogDnld", "VmsLogDnld.exe", "VMS다운로드이력조회"},
  111. {"TFrmVmsCamViewer", "VmsCamViewer.exe", "VMS영상모니터링"},
  112. {"", "", ""},
  113. };
  114. //---------------------------------------------------------------------------
  115. __fastcall TFrmVmsOprMain::TFrmVmsOprMain(TComponent* Owner)
  116. : TdxCustomRibbonForm(Owner)//TdxCustomRibbonForm(Owner)//TForm(Owner)
  117. {
  118. FLogoutTick = 0;
  119. DoubleBuffered = true;
  120. g_AppCfg.lMainWinHandle = (long)Handle;
  121. StartJobThread();
  122. while(!PostJobMessage(WM_THREAD, WP_PING)) ;
  123. Application->OnException = OnAppException;
  124. ::CoInitialize(NULL);
  125. //Caption = g_AppCfg.sTitle;
  126. LangTrans->Translate(this, ITSDb_GetConnection());
  127. ITSSkin_Initialize(Application, g_AppCfg.sLang, true, true);
  128. ITSSkin_Menu(this);
  129. String sCaption = "";
  130. ReadConfigInfo(g_AppCfg.sConfigFile, "APPLICATION", "CAPTION", sCaption);
  131. ITSSkin_Caption(sCaption == "1" ? true : false);
  132. BarVmsSys1->Visible = false;
  133. BarVmsSchMngr4->Visible = false;
  134. //NVMSM900M->Visible = ivNever;
  135. NVMSM800M->Visible = ivNever; // 기본스케쥴
  136. BarVmsSchMngr3->Visible = false; // 기본스케쥴
  137. NVMSM430M->Visible = ivNever; // 동영상관리
  138. RVMSH400M->Visible = ivNever;
  139. TabVmsConfig->Visible = false;
  140. NVMSM300M->Visible = ivNever; //VMS정보제공축관리
  141. NVMSM310M->Visible = ivNever; //VMS정보제공축설정
  142. //NVMS0600M->Visible = ivNever; //모듈상태 모니터링
  143. NVMS0TEST->Visible = ivNever;
  144. //NVMSM430M->Visible = ivNever;
  145. NVMS0010M->Visible = ivNever; //정보제공구간 현재소통정보
  146. //NVMSM420M->Visible = ivNever; //소통정보 이미지 관리
  147. #ifndef USE_EVPS
  148. BarEvspMngr->Visible = false;
  149. NVMSMA00M->Visible = ivNever; //긴급차량우선신호 구간 관리
  150. NVMSMA10M->Visible = ivNever; //긴급차량우선신호 구간 설정
  151. #endif
  152. Ribbon->ShowTabGroups = true; // 메뉴탭 show/hide
  153. Ribbon->QuickAccessToolbar->Visible = false;
  154. //Ribbon->ApplicationButton->Visible = false;
  155. Ribbon->SupportNonClientDrawing = true;
  156. Ribbon->EnableTabAero = true;
  157. TabVmsSystem->Active = true;
  158. SetColorScheme(g_AppCfg.sSkinName);
  159. //SetColorScheme("Blue");
  160. CMM_SetFormPosition(g_AppCfg.bSaveForm);
  161. CMM_LoadForm(g_sFormsDir, this);
  162. FVmsServerState = vms_comm_normal;
  163. APP_InitDisplayColor();
  164. TmrOnShow->Enabled = false;
  165. TmrAppState->Enabled = false;
  166. }
  167. //---------------------------------------------------------------------------
  168. LONG __stdcall HelperExceptionFilter(struct _EXCEPTION_POINTERS * pContext)
  169. {
  170. LONG lRet = EXCEPTION_EXECUTE_HANDLER;
  171. DWORD dwRet = ERROR_SUCCESS;
  172. __try
  173. {
  174. Application->NormalizeTopMosts();
  175. if (g_AppCfg.sLang == "kr")
  176. {
  177. Application->MessageBox(L"시스템에서 알수없는 오류가 발생했습니다.\r\n프로그램을 다시 기동해 주세요.",
  178. L"시스템 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  179. }
  180. else
  181. {
  182. Application->MessageBox(L"The system encountered an unknown error.\r\nPlease re-start the program.",
  183. L"System error", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  184. }
  185. Application->RestoreTopMosts();
  186. //TerminateProcess(GetCurrentProcess(), 0);
  187. }
  188. __finally
  189. {
  190. if(ERROR_SUCCESS != dwRet)
  191. {
  192. lRet = EXCEPTION_CONTINUE_SEARCH;
  193. }
  194. exit(0);
  195. }
  196. return lRet;
  197. }
  198. //---------------------------------------------------------------------------
  199. void __fastcall TFrmVmsOprMain::FormCreate(TObject *Sender)
  200. {
  201. /* 레지스터리 등록 IE 최신버전 */
  202. String sExeName = ExtractFileName(Application->ExeName);
  203. ITSMap_Init(sExeName);
  204. //SetUnhandledExceptionFilter(HelperExceptionFilter);
  205. Application->ShowMainForm = false;
  206. try {
  207. Application->Icon->LoadFromResourceName(((unsigned int)HInstance), "MAINICON");
  208. } catch(...) { ShowMessage("LoadFromResourceName failed"); }
  209. //DeleteLogFiles((PTCHAR)g_sLogDir.c_str(), 30, (PTCHAR)"*.*");
  210. //WindowState = wsMaximized;
  211. // 종료조건이 있는경우..
  212. //Application->Terminate();
  213. //return;
  214. Application->ShowMainForm = true;
  215. Application->OnHint = OnAppHint;
  216. ImgAlarm->Visible = false;
  217. ImgAlarmNormal->Visible = true;
  218. }
  219. //---------------------------------------------------------------------------
  220. void __fastcall TFrmVmsOprMain::FormShow(TObject *Sender)
  221. {
  222. Application->ProcessMessages();
  223. g_AppCfg.lMainWinHandle = (long)Handle;
  224. /*
  225. * 프로그램 초기화 작업
  226. */
  227. InitStatusBar();
  228. if (g_pLOGIN)
  229. {
  230. GetUserMenuRight(g_pLOGIN->sUserId, g_pLOGIN->sUserRightId);
  231. }
  232. TmrOnShow->Enabled = true;
  233. }
  234. //---------------------------------------------------------------------------
  235. void __fastcall TFrmVmsOprMain::TmrOnShowTimer(TObject *Sender)
  236. {
  237. TmrOnShow->Enabled = false;
  238. Application->ProcessMessages();
  239. //폴링작업 객체 초기화
  240. FPollTraffic.Cycle = (60*1000*2)+11; // 정보제공구간소통정보
  241. FPollVmsMsg.Cycle = (60*1000*2)+15; // VMS Message
  242. FPollVmsState.Cycle = (60*1000*1)+ 1; // 시설물상태정보
  243. FPollPrcsState.Cycle = (60*1000*2)+ 3; // 프로세스상태정보
  244. FPollIncident.Cycle = (60*1000*2)+ 5; // 돌발정보
  245. FPollTraffic.IsPolling = true;
  246. FPollVmsMsg.IsPolling = true;
  247. FPollVmsState.IsPolling = true;
  248. FPollPrcsState.IsPolling = true;
  249. FPollIncident.IsPolling = true;
  250. TFrmInitialize *FrmInitialize = new TFrmInitialize(this);
  251. FrmInitialize->FThreadId = g_AppCfg.thr.dwThreadId;
  252. FrmInitialize->ShowModal();
  253. UpdateVmsCommStatus(true);
  254. int nPort = 4602;
  255. TItsProcess *pPrcs = ItsProcessManager->FLists.Find(g_AppCfg.sProcessId);
  256. if (!pPrcs)
  257. {
  258. if (g_AppCfg.sLang == "kr")
  259. {
  260. Application->MessageBox(L"통신프로세스를 초기화 하지 못하였습니다.\r\n환경설정에서 시스템ID를 확인하세요.\r\n프로그램을 종료합니다.",
  261. L"프로그램 통신오류_1", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  262. }
  263. else
  264. {
  265. Application->MessageBox(L"Failed to initialize communication process.\r\nPlease check your system ID in preferences.\r\nExit the program.",
  266. L"Program communication error_1", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  267. }
  268. g_AppCfg.bAppClose = true;
  269. Close();
  270. return;
  271. }
  272. nPort = pPrcs->PRGM_PORT.ToIntDef(4602);
  273. nPort += 1; //VMS운영단말은 DB에 저장되어 있지 않기 때문에 포트번호를 1 증가시켜 통신한다.
  274. int nResult = CComm_Initialize((long)Handle, g_AppCfg.sProcessId, "UOT", nPort, g_AppCfg.sLogDay);
  275. if (VERR_NONE != nResult)
  276. {
  277. if (g_AppCfg.sLang == "kr")
  278. {
  279. Application->MessageBox(L"통신프로세스를 초기화 하지 못하였습니다.\r\n환경설정에서 시스템ID를 확인하세요.\r\n프로그램을 종료합니다.",
  280. L"프로그램 통신오류_1", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  281. }
  282. else
  283. {
  284. Application->MessageBox(L"Failed to initialize communication process.\r\nPlease check your system ID in preferences.\r\nExit the program.",
  285. L"Program communication error_1", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  286. }
  287. g_AppCfg.bAppClose = true;
  288. Close();
  289. return;
  290. }
  291. FOR_STL(TItsProcess*, pObj, ItsProcessManager->FLists)
  292. {
  293. if (pObj->DEL_YN == "Y") continue;
  294. AnsiString sProcessId = AnsiString(pObj->SYST_ID);
  295. AnsiString sSystemTp = AnsiString(pObj->SYST_TYPE);
  296. AnsiString sIpAddress = AnsiString(pObj->SYST_IP_1);
  297. AnsiString sUdpPort = AnsiString(pObj->PRGM_PORT);
  298. if (CComm_AddProcess(sProcessId, sSystemTp, sIpAddress, sUdpPort) >= 0)
  299. {
  300. if ("UOT" == sSystemTp)
  301. {
  302. nPort = sUdpPort.ToIntDef(0);
  303. CComm_AddProcess(sProcessId, sSystemTp, sIpAddress, AnsiString(nPort+1));
  304. }
  305. }
  306. }
  307. if (VERR_NONE != CComm_Open())
  308. {
  309. if (g_AppCfg.sLang == "kr")
  310. {
  311. Application->MessageBox(L"통신프로세스를 초기화 하지 못하였습니다.\r\n환경설정에서 시스템ID를 확인하세요.\r\n프로그램을 종료합니다.",
  312. L"프로그램 통신오류_3", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  313. }
  314. else
  315. {
  316. Application->MessageBox(L"Failed to initialize communication process.\r\nPlease check your system ID in preferences.\r\nExit the program.",
  317. L"Program communication error_3", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  318. }
  319. g_AppCfg.bAppClose = true;
  320. Close();
  321. return;
  322. }
  323. UpdateInterCommStatus(true);
  324. Application->ProcessMessages();
  325. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex = ITSDb_IsOpen() ? 8 : 7;
  326. //TODO NITS0000MClick((TObject *)NITS0000M); //메인화면을 프로그램 기동과 동시에 호출하는 경우
  327. #if 0
  328. if (g_AppCfg.AutoLogout.LogoutExit)
  329. {
  330. Application->MessageBox(L"이전 프로그램은 자동로그아웃으로 종료되었습니다.\r\n프로그램을 실행합니다.",
  331. L"프로그램 실행정보", MB_OK|MB_ICONQUESTION|MB_APPLMODAL);
  332. }
  333. #endif
  334. g_AppCfg.AutoLogout.LogoutExit = false;
  335. TmrAppState->Enabled = true;
  336. TmrPolling->Enabled = true;
  337. TmrCommTimeout->Enabled = true;
  338. INT_VMS_STATE_REQ Req;
  339. memset((char*)&Req, 0x00, sizeof(Req));
  340. Req.Count = 0;
  341. Req.Type = vms_req_state_all;
  342. CComm_VmsStateReq(&Req);
  343. }
  344. //---------------------------------------------------------------------------
  345. bool __fastcall TFrmVmsOprMain::StartJobThread()
  346. {
  347. TThreadPolling *pPollingThread = new TThreadPolling(false);
  348. if (pPollingThread)
  349. {
  350. pPollingThread->OnTerminate = OnPollingThreadDone;
  351. g_AppCfg.thr.pThread = (TThread *)pPollingThread;
  352. g_AppCfg.thr.dwThreadId = pPollingThread->ThreadID;
  353. g_AppCfg.thr.nHandle = pPollingThread->Handle;
  354. //pPollingThread->Resume();
  355. return true;
  356. }
  357. return false;
  358. }
  359. //---------------------------------------------------------------------------
  360. void __fastcall TFrmVmsOprMain::TerminateJobThread()
  361. {
  362. if (g_AppCfg.thr.bRunning)
  363. {
  364. PostJobMessage(WM_THREAD, WM_QUIT);
  365. }
  366. Sleep(500);
  367. try
  368. {
  369. if (g_AppCfg.thr.bRunning)
  370. {
  371. TThreadPolling *pThread = (TThreadPolling *)g_AppCfg.thr.pThread;
  372. pThread->Terminate();
  373. //pThread->WaitFor();
  374. }
  375. g_AppCfg.thr.pThread = NULL;
  376. g_AppCfg.thr.dwThreadId = 0;
  377. g_AppCfg.thr.nHandle = 0;
  378. g_AppCfg.thr.bRunning = false;
  379. }
  380. catch(...)
  381. {
  382. }
  383. }
  384. //---------------------------------------------------------------------------
  385. void __fastcall TFrmVmsOprMain::FormCloseQuery(TObject *Sender, bool &CanClose)
  386. {
  387. // 폼이 닫히기 전에 수행해야 할 모뮬 기술
  388. // 프로그램 종료를 사용자가 확인할 수 있도록...
  389. if (!g_AppCfg.bAppClose)
  390. {
  391. #if 0
  392. String strMsg;
  393. strMsg = "";
  394. strMsg = "[ " + g_AppCfg.sTitle + " ]\r\n\n";
  395. strMsg+= FrmLang->cxLabel1->Caption;
  396. if(Application->MessageBox(strMsg.c_str(),
  397. FrmLang->cxLabel2->Caption.c_str(),
  398. MB_YESNO|MB_ICONQUESTION) == IDYES)
  399. {
  400. /*
  401. * 화면관련 작업을 못하도록 여기에 코드를 적자...
  402. */
  403. ITSDb_ApplicationTerm();
  404. g_AppCfg.bAppClose = true;
  405. }
  406. #else
  407. CloseAllWindow();
  408. ITSDb_ApplicationTerm();
  409. g_AppCfg.bAppClose = true;
  410. #endif
  411. CanClose = false;
  412. }
  413. }
  414. //---------------------------------------------------------------------------
  415. void __fastcall TFrmVmsOprMain::FormClose(TObject *Sender, TCloseAction &Action)
  416. {
  417. CommClose();
  418. Action = caFree;
  419. }
  420. //---------------------------------------------------------------------------
  421. void __fastcall TFrmVmsOprMain::CommClose()
  422. {
  423. try
  424. {
  425. CComm_Close();
  426. //CloseAllWindow();
  427. ITSSkin_Term();
  428. CMM_SaveForm(g_sFormsDir, this);
  429. WriteConfigInfo(g_AppCfg.sConfigFile, "APPLICATION", "LOGDAY", Now().FormatString("dd"));
  430. ::CoUninitialize();
  431. }
  432. catch(...)
  433. {
  434. }
  435. }
  436. //---------------------------------------------------------------------------
  437. void __fastcall TFrmVmsOprMain::CloseAllWindow()
  438. {
  439. int ii;
  440. if (g_AppCfg.bTermChildProg)
  441. {
  442. // 실행시킨 프로그램을 종료시킨다.
  443. for (ii = 0; ii < MAX_EXEPROGRAM; ii++)
  444. {
  445. if (g_RunProgram[ii].AClassName == "")
  446. continue;
  447. TermItsProgram(g_RunProgram[ii].AClassName, "");
  448. }
  449. }
  450. //실행중인 화면을 종료 시킨다.
  451. try {
  452. for (ii = 0; ii < Screen->FormCount; ii++)
  453. {
  454. if (Screen->Forms[ii] != this)
  455. {
  456. if (::IsWindow(Screen->Forms[ii]->Handle))
  457. {
  458. String sFormName = Screen->Forms[ii]->Name;
  459. if (sFormName == "ITSSkin") continue;
  460. if (sFormName == "FrmSkin") continue;
  461. if (sFormName == "FrmLang") continue;
  462. if (sFormName.SubString(1, 11) == "PlugInChart") continue;
  463. if (Screen->Forms[ii]->Owner == this ||
  464. Screen->Forms[ii]->Owner == Application)
  465. {
  466. //Screen->Forms[ii]->Close();
  467. PostMessage(Screen->Forms[ii]->Handle, WM_CLOSE, 0, 0);
  468. WaitForSingleObject(Screen->Forms[ii]->Handle, 1000);
  469. }
  470. }
  471. }
  472. }
  473. } catch(...) {}
  474. }
  475. //---------------------------------------------------------------------------
  476. void __fastcall TFrmVmsOprMain::CloseChildWindow()
  477. {
  478. int ii;
  479. //실행중인 화면을 종료 시킨다.
  480. try {
  481. for (ii = 0; ii < Screen->FormCount; ii++)
  482. {
  483. if (Screen->Forms[ii] != this)
  484. {
  485. if (::IsWindow(Screen->Forms[ii]->Handle))
  486. {
  487. String sFormName = Screen->Forms[ii]->Name;
  488. if (sFormName == "ITSSkin") continue;
  489. if (sFormName == "FrmSkin") continue;
  490. if (sFormName == "FrmLang") continue;
  491. if (sFormName.SubString(1, 11) == "PlugInChart") continue;
  492. if ((Screen->Forms[ii]->Owner == this || Screen->Forms[ii]->Owner == Application) &&
  493. (Screen->Forms[ii]->FormStyle == fsMDIChild)
  494. )
  495. {
  496. Screen->Forms[ii]->Close();
  497. WaitForSingleObject(Screen->Forms[ii]->Handle, 500);
  498. }
  499. }
  500. }
  501. }
  502. } catch(...) {}
  503. }
  504. //---------------------------------------------------------------------------
  505. void __fastcall TFrmVmsOprMain::TmrAppStateTimer(TObject *Sender)
  506. {
  507. /*
  508. * 타이머가 1초간격으로 응용프로그램의 상태를 체크하고
  509. * 응용프로그램의 상태를 주기적으로 체크하여 필요한 조치를 수행한다.
  510. */
  511. if (g_AppCfg.bAppClose)
  512. {
  513. TmrAppState->Enabled = false;
  514. TmrPolling->Enabled = false;
  515. UserLogout(); // 로그아웃
  516. TerminateJobThread();
  517. ITSDb_Close();
  518. Close(); // 응용프로그램 종료
  519. }
  520. else
  521. {
  522. TmrAppState->Enabled = false;
  523. UpdateStatusBar();
  524. if (g_AppCfg.AutoLogout.Enabled)
  525. {
  526. FLogoutTick++;
  527. if (FLogoutTick > (g_AppCfg.AutoLogout.IntervalMin*60))
  528. {
  529. //자동로그아웃처리
  530. g_AppCfg.bAppClose = true;
  531. g_AppCfg.AutoLogout.LogoutExit = true;
  532. }
  533. }
  534. TmrAppState->Enabled = true;
  535. }
  536. }
  537. //---------------------------------------------------------------------------
  538. void __fastcall TFrmVmsOprMain::UpdateInterCommStatus(bool AOk)
  539. {
  540. int nImgIdx = 8;
  541. if (AOk == false) nImgIdx = 7;
  542. if (((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbComm]->PanelStyle)->ImageIndex != nImgIdx)
  543. {
  544. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbComm]->PanelStyle)->ImageIndex = nImgIdx;
  545. }
  546. }
  547. //---------------------------------------------------------------------------
  548. void __fastcall TFrmVmsOprMain::UpdateVmsCommStatus(bool ADb)
  549. {
  550. if (ADb)
  551. {
  552. FOR_STL(TItsProcess*, pPrcs, ItsProcessManager->FLists)
  553. {
  554. if (pPrcs->SYST_TYPE == "VMS")
  555. {
  556. if (pPrcs->FCommStatus == "1")
  557. {
  558. FVmsServerState = vms_comm_normal;
  559. }
  560. else
  561. {
  562. FVmsServerState = vms_comm_error;
  563. }
  564. break;
  565. }
  566. }
  567. }
  568. int nImgIdx = 8;
  569. if (FVmsServerState == vms_comm_error) nImgIdx = 7;
  570. if (((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbVmsComm]->PanelStyle)->ImageIndex != nImgIdx)
  571. {
  572. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbVmsComm]->PanelStyle)->ImageIndex = nImgIdx;
  573. }
  574. }
  575. //---------------------------------------------------------------------------
  576. void __fastcall TFrmVmsOprMain::UpdateStatusBar()
  577. {
  578. try
  579. {
  580. dxStatusBar->Panels->Items[isbTime]->Text = Now().FormatString(STR_DATETIME);
  581. #if 0
  582. if (ITSDb_IsOpen())
  583. {
  584. if (((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex != 8)
  585. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex = 8;
  586. }
  587. else
  588. {
  589. if (((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex != 7)
  590. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex = 7;
  591. }
  592. #endif
  593. }
  594. catch(...)
  595. {
  596. }
  597. }
  598. //---------------------------------------------------------------------------
  599. void __fastcall TFrmVmsOprMain::DebugMsg(String AMsg)
  600. {
  601. dxStatusBar->Panels->Items[isbMsg]->Text = " " + AMsg;
  602. dxStatusBar->Panels->Items[isbMsg]->StatusBarControl->Refresh();
  603. TmrDebugHide->Enabled = false;
  604. TmrDebugHide->Enabled = true;
  605. LOGINFO(AnsiString(AMsg).c_str());
  606. }
  607. //---------------------------------------------------------------------------
  608. void __fastcall TFrmVmsOprMain::TmrDebugHideTimer(TObject *Sender)
  609. {
  610. dxStatusBar->Panels->Items[isbMsg]->Text = "";
  611. dxStatusBar->Panels->Items[isbMsg]->StatusBarControl->Refresh();
  612. TmrDebugHide->Enabled = false;
  613. }
  614. //---------------------------------------------------------------------------
  615. void __fastcall TFrmVmsOprMain::InitStatusBar()
  616. {
  617. try
  618. {
  619. dxStatusBar->Panels->Items[isbGisPos]->Text = "";
  620. dxStatusBar->Panels->Items[isbTime]->Text = Now().FormatString(STR_DATETIME);
  621. if (g_pLOGIN)
  622. {
  623. dxStatusBar->Panels->Items[isbUser]->Text = g_pLOGIN->sUserId;
  624. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbUser]->PanelStyle)->ImageIndex = 9;
  625. }
  626. dxStatusBar->Panels->Items[isbHint]->Text = "";
  627. dxStatusBar->Panels->Items[isbMsg]->Text = "";
  628. UpdateStatusBar();
  629. }
  630. catch(...)
  631. {
  632. }
  633. }
  634. //---------------------------------------------------------------------------
  635. void __fastcall TFrmVmsOprMain::InitUserMenu()
  636. {
  637. NVMS0100M->Enabled = false; //현시 모니터링
  638. NVMS0200M->Enabled = false; //시나리오 모니터링
  639. NVMS0300M->Enabled = false; //상태 모니터링
  640. NVMS0400M->Enabled = false; //영상 모니터링[R]
  641. NVMS0500M->Enabled = false; //VMS 제어
  642. NVMSM100M->Enabled = false; //기본정보 관리
  643. NVMSM200M->Enabled = false; //정보제공구간 관리
  644. NVMSM210M->Enabled = false; //정보제공구간 설정
  645. NVMSM400M->Enabled = false; //심볼이미지 관리
  646. NVMSM410M->Enabled = false; //소통정보 배경이미지 관리
  647. NVMSM500M->Enabled = false; //VMS 폼관리
  648. NVMSM600M->Enabled = false; //자동 스케줄 관리
  649. NVMSM700M->Enabled = false; //고정 스케줄 관리
  650. NVMSM800M->Enabled = false; //기본 스케줄 관리
  651. RVMSH100M->Enabled = false; //상태 이력조회[R]
  652. RVMSH200M->Enabled = false; //제공 이력조회[R]
  653. RVMSH300M->Enabled = false; //제어 이력조회[R]
  654. }
  655. //---------------------------------------------------------------------------
  656. void __fastcall TFrmVmsOprMain::SetUserMenu(String AMenuId)
  657. {
  658. String sMenuId = "";
  659. if (AMenuId == "MS000000") sMenuId = ""; //VMS관리프로그램 ==> 이거는 기존거 그냥 이용... 메뉴처리 없음
  660. else if (AMenuId == "MS010000") sMenuId = "NVMS0100M"; //, '현시 모니터링'
  661. else if (AMenuId == "MS010100") sMenuId = "NVMS0200M"; //, '시나리오 모니터링'
  662. else if (AMenuId == "MS010101") sMenuId = "NVMS0300M"; //, '상태 모니터링'
  663. else if (AMenuId == "MS010102") sMenuId = "NVMS0400M"; //, '영상 모니터링[R]'
  664. else if (AMenuId == "MS010103") sMenuId = "NVMS0500M"; //, 'VMS 제어'
  665. else if (AMenuId == "MS010104") sMenuId = "NVMSM100M"; //, '기본정보 관리'
  666. else if (AMenuId == "MS010200") sMenuId = "NVMSM200M"; //, '정보제공구간 관리'
  667. else if (AMenuId == "MS010201") sMenuId = "NVMSM210M"; //, '정보제공구간 설정'
  668. else if (AMenuId == "MS010202") sMenuId = "NVMSM400M"; //, '심볼이미지 관리'
  669. else if (AMenuId == "MS010300") sMenuId = "NVMSM410M"; //, '소통정보 배경이미지 관리'
  670. else if (AMenuId == "MS010301") sMenuId = "NVMSM500M"; //, 'VMS 폼관리'
  671. else if (AMenuId == "MS010302") sMenuId = "NVMSM600M"; //, '자동 스케줄 관리'
  672. else if (AMenuId == "MS010303") sMenuId = "NVMSM700M"; //, '고정 스케줄 관리'
  673. else if (AMenuId == "MS020000") sMenuId = "NVMSM800M"; //, '기본 스케줄 관리'
  674. else if (AMenuId == "MS020100") sMenuId = "RVMSH100M"; //, '상태 이력조회[R]'
  675. else if (AMenuId == "MS020101") sMenuId = "RVMSH200M"; //, '제공 이력조회[R]'
  676. else if (AMenuId == "MS020102") sMenuId = "RVMSH300M"; //, '제어 이력조회[R]'
  677. if (sMenuId == "") return;
  678. TdxBarLargeButton *pMenu = (TdxBarLargeButton *)FindComponent(sMenuId);
  679. if (pMenu)
  680. {
  681. pMenu->Enabled = true;
  682. if (sMenuId == "NVMS0500M") g_bControlAuth = false; //VMS제어 화면에 대한 권한이 있으면 다른 제어권한 설정
  683. }
  684. }
  685. //---------------------------------------------------------------------------
  686. bool __fastcall TFrmVmsOprMain::GetUserMenuRight(String AUserId, String AUserRight)
  687. {
  688. //모든 메뉴 비활성화, 디비에 등록된 메뉴 활성화
  689. #if 0
  690. InitUserMenu();
  691. #endif
  692. String sQry;
  693. TADOQuery *pADO = NULL;
  694. try
  695. {
  696. sQry = "SELECT OPERSYST_MENU_ID \r\n"
  697. " FROM TB_GROP_MENU_ATHR \r\n"
  698. " WHERE ATHR_YN = 'N' \r\n"
  699. " AND GROP_ID = (SELECT GROP_ID \r\n"
  700. " FROM TB_USER_INFR \r\n"
  701. " WHERE USER_ID = :p01) \r\n";
  702. try
  703. {
  704. pADO = new TADOQuery(NULL);
  705. pADO->Close();
  706. pADO->Connection = ITSDb_GetConnection();
  707. ITSDb_SQLText(pADO, sQry);
  708. ITSDb_SQLBind(pADO, "p01", AUserRight);
  709. ITSDb_SQLOpen(pADO);
  710. for( ; !pADO->Eof; pADO->Next())
  711. {
  712. String sMenuId = pADO->FieldByName("OPERSYST_MENU_ID")->AsString;
  713. #if 0
  714. SetUserMenu(sMenuId);
  715. #endif
  716. try
  717. {
  718. int nCompnentCnt = this->ComponentCount;
  719. for (int ii = 0; ii < nCompnentCnt; ii++)
  720. {
  721. String sClassName = this->Components[ii]->ClassName();
  722. if(sClassName == "TdxBarLargeButton")
  723. {
  724. TdxBarLargeButton *pMenu = (TdxBarLargeButton *)this->Components[ii];
  725. if (pMenu->Name == sMenuId)
  726. {
  727. pMenu->Enabled = false;
  728. break;
  729. }
  730. }
  731. }
  732. }
  733. catch(...)
  734. {
  735. }
  736. }
  737. }
  738. catch(EDatabaseError &E)
  739. {
  740. DBERRORMSG("TFrmMain::GetUserMenuRight", String(E.ClassName()), E.Message, sQry);
  741. throw Exception(String(E.ClassName()) + E.Message);
  742. }
  743. catch(Exception &e)
  744. {
  745. DBERRORMSG("TFrmMain::GetUserMenuRight", String(e.ClassName()), e.Message, sQry);
  746. throw Exception(String(e.ClassName()) + e.Message);
  747. }
  748. }
  749. __finally
  750. {
  751. if (pADO)
  752. {
  753. pADO->Close();
  754. delete pADO;
  755. }
  756. }
  757. return true;
  758. }
  759. //---------------------------------------------------------------------------
  760. HWND __fastcall TFrmVmsOprMain::FindChildWindow(String sFormName)
  761. {
  762. int nFormCnt = Screen->FormCount;
  763. for (int ii = 0; ii < nFormCnt; ii++)
  764. {
  765. TForm *pForm = Screen->Forms[ii];
  766. String sTmpFormName = pForm->Name.SubString(1, sFormName.Length());
  767. if (sTmpFormName == sFormName)
  768. {
  769. return pForm->Handle;
  770. }
  771. }
  772. return NULL;
  773. }
  774. //---------------------------------------------------------------------------
  775. void __fastcall TFrmVmsOprMain::OnSkinClick(TObject *Sender)
  776. {
  777. TdxBarButton *pMenu = (TdxBarButton*)Sender;
  778. try {
  779. dxSkinController1->SkinName = pMenu->Caption;
  780. dxSkinController1->Refresh();
  781. //ITSSkin_SetName(dxSkinController1->SkinName);
  782. } catch(...) {}
  783. }
  784. //---------------------------------------------------------------------------
  785. void __fastcall TFrmVmsOprMain::TmrPollingTimer(TObject *Sender)
  786. {
  787. TmrPolling->Enabled = false;
  788. DWORD dwTick = GetTickCount();
  789. UpdateThreadStatus(true); //작업스레드 실행 확인
  790. // 프로세스상태정보
  791. if (FPollPrcsState.IsPolling && FPollPrcsState.IsPollingTime(dwTick))
  792. {
  793. FPollPrcsState.Polling = dwTick;
  794. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_PROCESS_STTS);
  795. DebugMsg(">>> Process Status Request");//">>> 프로세스 상태 조회 요청");
  796. }
  797. // VMS상태정보
  798. if (FPollVmsState.IsPolling && FPollVmsState.IsPollingTime(dwTick))
  799. {
  800. FPollVmsState.Polling = dwTick;
  801. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_FACILITY_STTS);
  802. DebugMsg(">>> VMS Status Request");//">>> VMS 상태 조회 요청");
  803. }
  804. // VMS Message
  805. if (FPollVmsMsg.IsPolling && FPollVmsMsg.IsPollingTime(dwTick))
  806. {
  807. FPollVmsMsg.Polling = dwTick;
  808. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_VMS_DSPLMSG);
  809. DebugMsg(">>> VMS Display Message Request");//">>> VMS 표출메시지 조회 요청");
  810. }
  811. // 소통정보
  812. if (FPollTraffic.IsPolling && FPollTraffic.IsPollingTime(dwTick))
  813. {
  814. SetProcessWorkingSetSize(GetCurrentProcess(), -1, -1);
  815. FPollTraffic.Polling = dwTick;
  816. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_TRAFFIC);
  817. DebugMsg(">>> Traffic Request");//">>> 소통정보 조회 요청");
  818. }
  819. // 돌발정보
  820. if (FPollIncident.IsPolling && FPollIncident.IsPollingTime(dwTick))
  821. {
  822. FPollIncident.Polling = dwTick;
  823. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_INCIDENT);
  824. DebugMsg(">>> Incident Request");//">>> 돌발정보 조회 요청");
  825. }
  826. if (!g_AppCfg.bAppClose) TmrPolling->Enabled = true;
  827. }
  828. //---------------------------------------------------------------------------
  829. bool __fastcall TFrmVmsOprMain::PostJobMessage(UINT nMsg, int WParam/*=0*/, int LParam/*=0*/)
  830. {
  831. int nRes;
  832. //if (g_AppCfg.bDebug) ITSUtil_Trace("PostJobMessage: Msg: %02X, WParam: %02X, LParam: %02X", nMsg, WParam, LParam);
  833. if (g_AppCfg.thr.dwThreadId)
  834. {
  835. for (int ii = 0; ii < 3; ii++)
  836. {
  837. if (PostThreadMessageW(g_AppCfg.thr.dwThreadId, nMsg, WParam, LParam))
  838. {
  839. nRes = 0;
  840. return true;
  841. }
  842. else
  843. {
  844. nRes = GetLastError();
  845. if (ERROR_INVALID_THREAD_ID == nRes)
  846. {
  847. Sleep(500);
  848. continue;
  849. }
  850. }
  851. }
  852. }
  853. return false;
  854. }
  855. //---------------------------------------------------------------------------
  856. void __fastcall TFrmVmsOprMain::dxSkinChooserGalleryItem1SkinChanged(TObject *Sender, const UnicodeString ASkinName)
  857. {
  858. g_AppCfg.sSkinName = ASkinName;
  859. WriteConfigInfo(g_AppCfg.sConfigFile, "APPLICATION", "SKINNAME", g_AppCfg.sSkinName);
  860. SetColorScheme(ASkinName);
  861. }
  862. //---------------------------------------------------------------------------
  863. void __fastcall TFrmVmsOprMain::SetColorScheme(String ASkinName)
  864. {
  865. Ribbon->ColorSchemeName = ASkinName;
  866. dxSkinController1->SkinName = ASkinName;
  867. dxSkinController1->Refresh();
  868. dxTabbedMDIManager1->LookAndFeel->SkinName = ASkinName;
  869. dxStatusBar->Invalidate();
  870. //Panel1->Color = Ribbon->ColorScheme->GetPartColor(rfspRibbonForm);
  871. //Ribbon.ColorSchemeName := AName;
  872. //SkinChooserSelectSkinName(AName);
  873. //Panel1.Color := Ribbon.ColorScheme.GetPartColor(rfspRibbonForm);
  874. //dxStatusBar.Invalidate;
  875. }
  876. //---------------------------------------------------------------------------
  877. void __fastcall TFrmVmsOprMain::ExecuteItsProgram(String AClassName, String AExeName, String AOption)
  878. {
  879. HWND hExeForm = FindWindow(AClassName.c_str(), NULL);
  880. if (hExeForm)
  881. {
  882. SetWindowPos(hExeForm, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
  883. }
  884. else
  885. {
  886. String sExeName = "";
  887. String sExeParam= "";
  888. //if (!ReadConfigInfo(g_AppCfg.sConfigFile, "PROGRAM", AOption, sExeName))
  889. {
  890. sExeName = AExeName;
  891. sExeParam= g_pLOGIN->sUserId;
  892. }
  893. ShellExecute(Handle, NULL, sExeName.c_str(), sExeParam.c_str(), NULL, SW_SHOWNORMAL);
  894. }
  895. }
  896. //---------------------------------------------------------------------------
  897. void __fastcall TFrmVmsOprMain::TermItsProgram(String AClassName, String AExeName)
  898. {
  899. HWND hExeForm = FindWindow(AClassName.c_str(), NULL);
  900. if (hExeForm)
  901. {
  902. POST_MSG(hExeForm, WM_CLOSE, 0, 0);
  903. }
  904. }
  905. //---------------------------------------------------------------------------
  906. void __fastcall TFrmVmsOprMain::OnRunProgramClick(TObject *Sender)
  907. {
  908. TdxBarLargeButton *pButton = (TdxBarLargeButton*)Sender;
  909. int nIdx = pButton->Tag;
  910. if (nIdx < 0 || nIdx >= MAX_EXEPROGRAM) return;
  911. if (g_RunProgram[nIdx].AClassName == "") return;
  912. ExecuteItsProgram(g_RunProgram[nIdx].AClassName, g_RunProgram[nIdx].AExeName, g_RunProgram[nIdx].AOption);
  913. }
  914. //---------------------------------------------------------------------------
  915. void __fastcall TFrmVmsOprMain::OnAppHint(TObject *Sender)
  916. {
  917. dxStatusBar->Panels->Items[isbHint]->Text = " " + Application->Hint;
  918. dxStatusBar->Panels->Items[isbHint]->StatusBarControl->Refresh();
  919. }
  920. //---------------------------------------------------------------------------
  921. void __fastcall TFrmVmsOprMain::OnAppException(TObject *Sender, Exception *exception)
  922. {
  923. if (g_AppCfg.bDebug) ITSUtil_Trace("OnAppException");
  924. String sClassName = (NULL != Sender) ? Sender->ClassName() : String("Unknown_Class");
  925. String sErrMsg = (NULL != exception) ? exception->Message : String("Unknown_Error");
  926. String sError = sClassName + " : " + sErrMsg;
  927. //Application->ShowException(&exception);
  928. Application->NormalizeTopMosts();
  929. Application->MessageBox(sError.c_str(), L"System Error", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  930. Application->RestoreTopMosts();
  931. }
  932. //---------------------------------------------------------------------------
  933. void __fastcall TFrmVmsOprMain::UpdateThreadStatus(bool ARequest, bool APing/*=true*/)
  934. {
  935. return;
  936. try
  937. {
  938. if (APing) if (ARequest) PostJobMessage(WM_THREAD, WP_PING);
  939. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbStatus]->PanelStyle)->ImageIndex = ARequest ? 7 : 8;
  940. dxStatusBar->Panels->Items[isbDb]->StatusBarControl->Refresh();
  941. }
  942. catch(...)
  943. {
  944. }
  945. }
  946. //---------------------------------------------------------------------------
  947. void __fastcall TFrmVmsOprMain::UpdateDbStatus(bool ASelect)
  948. {
  949. try
  950. {
  951. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex = ASelect ? 7 : 8;
  952. dxStatusBar->Panels->Items[isbDb]->StatusBarControl->Refresh();
  953. }
  954. catch(...)
  955. {
  956. }
  957. }
  958. //---------------------------------------------------------------------------
  959. void __fastcall TFrmVmsOprMain::ApplicationEvents1Message(tagMSG &Msg, bool &Handled)
  960. {
  961. switch(Msg.message)
  962. {
  963. case WM_THREAD:
  964. switch(Msg.wParam)
  965. {
  966. case WP_PING:
  967. UpdateThreadStatus(false); //스레드 핑 확인
  968. break;
  969. case WP_PARAM_TRAFFIC:
  970. break;
  971. case WP_DB_SELECT_START:
  972. UpdateDbStatus(true);
  973. break;
  974. case WP_DB_SELECT_OK:
  975. case WP_DB_SELECT_ERROR:
  976. case WP_DB_SELECT_CANCEL:
  977. UpdateDbStatus(false);
  978. if (Msg.wParam == WP_DB_SELECT_OK)
  979. {
  980. OnRefreshMessage(Msg.wParam, Msg.lParam);
  981. }
  982. break;
  983. }
  984. break;
  985. case WM_DATABASE_REFRESH:
  986. OnDatabaseMessage(Msg.wParam, Msg.lParam);
  987. break;
  988. case WM_PLUGINFORM:
  989. OnRefreshMessage(Msg.wParam, Msg.lParam);
  990. break;
  991. case WM_MOUSEMOVE:
  992. FLogoutTick = 0;
  993. break;
  994. case WM_KEYDOWN:
  995. FLogoutTick = 0;
  996. if (Msg.wParam == VK_F5)
  997. {
  998. // Handled = true;
  999. }
  1000. break;
  1001. case WM_KEYUP:
  1002. FLogoutTick = 0;
  1003. break;
  1004. }
  1005. }
  1006. //---------------------------------------------------------------------------
  1007. void __fastcall TFrmVmsOprMain::OnRefreshMessage(WPARAM AWParam, LPARAM ALParam)
  1008. {
  1009. HWND hWnd;
  1010. // 폴링 스레드에서 데이터작업 완료 메시지 처리
  1011. if (AWParam == WP_DB_SELECT_OK)
  1012. {
  1013. DWORD dwTick = GetTickCount();
  1014. switch(ALParam)
  1015. {
  1016. case LP_MSG_PROCESS_STTS: DebugMsg("<<< Process Status Request Completed."/*"<<< 프로세스 상태 조회 완료"*/); FPollPrcsState.Polling = dwTick; break;
  1017. case LP_MSG_FACILITY_STTS: DebugMsg("<<< VMS Status Request Completed."/*"<<< VMS 상태 조회 완료"*/); FPollVmsState.Polling = dwTick; break;
  1018. case LP_MSG_VMS_DSPLMSG: DebugMsg("<<< VMS Display Message Request Completed."/*"<<< VMS 표출메시지 조회 완료"*/); FPollVmsMsg.Polling = dwTick; break;
  1019. case LP_MSG_TRAFFIC: DebugMsg("<<< Traffic Request Completed."/*"<<< 소통정보 조회 완료"*/); FPollTraffic.Polling = dwTick; break;
  1020. case LP_MSG_INCIDENT: DebugMsg("<<< Incident Request Completed."/*"<<< 돌발정보 조회 완료"*/); FPollIncident.Polling = dwTick; break;
  1021. }
  1022. if (ALParam == LP_MSG_PROCESS_STTS)
  1023. {
  1024. UpdateVmsCommStatus(true);
  1025. }
  1026. else
  1027. if (ALParam == LP_MSG_VMS_DSPLMSG)
  1028. {
  1029. RefreshVmsMessage(WM_VMS_FORM_REFRESH);
  1030. }
  1031. else
  1032. if (ALParam == LP_MSG_INCIDENT)
  1033. {
  1034. RefreshVmsMessage(WM_VMS_INCIDENT_REFRESH);
  1035. }
  1036. else
  1037. {
  1038. RefreshVmsMessage(WM_VMS_STATE_REFRESH);
  1039. }
  1040. #if 0
  1041. if (NVMS0000M->Enabled)
  1042. {
  1043. hWnd = FindChildWindow("VMS0000M");
  1044. if (hWnd) POST_MSG(hWnd, WM_MAINFORM, AWParam, ALParam);
  1045. }
  1046. #endif
  1047. if (ALParam == LP_MSG_TRAFFIC)
  1048. {
  1049. hWnd = FindChildWindow("VMS0010M");
  1050. if (hWnd) POST_MSG(hWnd, WM_MAINFORM, AWParam, ALParam);
  1051. }
  1052. #if 0
  1053. if (ALParam == LP_MSG_11)
  1054. {
  1055. //시설물 상태정보 업데이트
  1056. ShowFacilityStatus();
  1057. }
  1058. #endif
  1059. }
  1060. else
  1061. {
  1062. LOGERROR("DB Thread failed: %02X[%02X]", ALParam, AWParam);
  1063. }
  1064. }
  1065. //---------------------------------------------------------------------------
  1066. void __fastcall TFrmVmsOprMain::OnDatabaseMessage(WPARAM AWParam, LPARAM ALParam)
  1067. {
  1068. #if 0
  1069. HWND hWnd;
  1070. switch(AWParam)
  1071. {
  1072. case WP_MSG_01: //소통등급변경
  1073. case WP_MSG_02: //돌발정보변경(오보/등록/해제)
  1074. if (NITS0000M->Enabled)
  1075. {
  1076. hWnd = FindChildWindow("ITS0000M");
  1077. if (hWnd) POST_MSG(hWnd, WM_MAINFORM, AWParam, ALParam);
  1078. }
  1079. break;
  1080. case WP_MSG_03: //시설물 정보 변경
  1081. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_14);
  1082. //hWnd = FindChildWindow("ITS0000M");
  1083. //if (hWnd) POST_MSG(hWnd, WM_MAINFORM, AWParam, ALParam);
  1084. break;
  1085. case WP_MSG_04: // IDB0070M-휴일정보
  1086. case WP_MSG_05: // FrmLinkGradeSet-구간등급변경
  1087. case WP_MSG_06: // IDB0060M - 소통등급
  1088. case WP_MSG_07: // IDB0050M -교통파라미터
  1089. //NodeLinkChangeReq(AnsiString("UTP01")); //통합교통정보가공시스템으로 정보변경 내용을 전송
  1090. break;
  1091. case WP_MSG_09: // IDB0100M
  1092. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_09); //작업스레드에서 읽어 처리하도록 한다.
  1093. break;
  1094. case WP_MSG_14: // DSRM010M -DSRC-RSE 관리
  1095. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_14); //작업스레드에서 읽어 처리하도록 한다.
  1096. break;
  1097. default:
  1098. LOGERROR("Unknown Database Msg: %02X[%02X]", ALParam, AWParam);
  1099. break;
  1100. }
  1101. #endif
  1102. }
  1103. //---------------------------------------------------------------------------
  1104. void __fastcall TFrmVmsOprMain::OnUdpDataRecvMessage(TMessage &Msg)
  1105. {
  1106. int nResult;
  1107. IPC_MSG_DATA *RcvData = (IPC_MSG_DATA*)Msg.LParam;
  1108. INT_SENDER *Sender = &RcvData->Sender;
  1109. INT_PACKET *Pkt = &RcvData->Pkt;
  1110. INT_HEAD *head = &Pkt->head;
  1111. INT_DATA *data = &Pkt->data;
  1112. char *pData = &Pkt->data.Data[0];
  1113. BYTE OpCode = head->OpCode;
  1114. //LOGINFO("*** OPR Client Req: %s.%d", CComm_ulong2ip(Sender->IP), Sender->Port);
  1115. String sMsg = "";
  1116. String sVmsNmbr = "";
  1117. TmrCommTimeout->Enabled = false;
  1118. //FVmsServerState = vms_comm_normal;
  1119. UpdateVmsCommStatus(false);
  1120. UpdateInterCommStatus(true);
  1121. switch(OpCode)
  1122. {
  1123. case INT_OP_TRAFFIC_CHANGE: /* 0x01, 교통정보가공완료 */
  1124. {
  1125. DebugMsg("*** Traffic Changed");
  1126. FPollTraffic.Reset(); // 링크소통정보(전체)
  1127. }
  1128. break;
  1129. case INT_OP_PG_STATE_RES:
  1130. {
  1131. DebugMsg("*** VMS Process Stauts Recvieved");//"*** VMS 프로세스 상태정보 수신");
  1132. INT_PG_STATE_RES *ARes = (INT_PG_STATE_RES*)pData;
  1133. for (int ii = 0; ii < ARes->Count && ii < INT_MAX_PG_STATE; ii++)
  1134. {
  1135. if (ARes->Unit[ii].Type == INT_ID_VMS_SERVER)
  1136. {
  1137. FVmsServerState = ARes->Unit[ii].Action;
  1138. UpdateVmsCommStatus(false);
  1139. FPollPrcsState.Polling = GetTickCount(); //프로세스상태정보 조회 타이머 리셋
  1140. break;
  1141. }
  1142. }
  1143. }
  1144. break;
  1145. case INT_OP_VMS_PARAM_RES:
  1146. {
  1147. INT_VMS_PARAM_RES *ARes = (INT_VMS_PARAM_RES*)pData;
  1148. sMsg = "";
  1149. sMsg.printf(L"*** VMS Controller Parameter Received: %d EA", ARes->Count);
  1150. DebugMsg(sMsg);
  1151. for (int ii = 0; ii < ARes->Count && ii < INT_VMS_MAX_PARAM; ii++)
  1152. {
  1153. INT_VMS_PARAM *pVms = &ARes->Unit[ii];
  1154. TVmsCtlr *pObj = VmsCtlrManager->FLists.Find(String(pVms->VMS_CTLR_NMBR));
  1155. if (pObj)
  1156. {
  1157. pObj->PANL_PWER_MODE = pVms->led; // N NUMBER(3) Y 2 전광판 전원 모드(0x00:꺼짐,0x01:켜짐,0x02:자동,0x09:알수없음)
  1158. pObj->FAN_MODE = pVms->fan; // N NUMBER(3) Y 2 FAN 동작모드(0x00:꺼짐,0x01:켜짐,0x02:자동,0x09:알수없음)
  1159. pObj->FAN_RUN_TMPR = pVms->fanTmpr; // N NUMBER(3) Y 30 팬 동작 온도
  1160. pObj->HETR_MODE = pVms->hetr; // N NUMBER(3) Y 2 히터 동작모드(0x00:꺼짐,0x01:켜짐,0x02:자동,0x09:알수없음)
  1161. pObj->HETR_RUN_TMPR = pVms->hetrTmpr; // N NUMBER(3) Y 0 히터 동작 온도
  1162. pObj->BRGH_MODE = pVms->brgh; // N NUMBER(3) Y 2 휘도 모드(0x00:주간,0x01:야간,0x00:자동,0x09:알수없음)
  1163. pObj->BRGH_CURR_STEP = pVms->brghVal; // N NUMBER(3) Y 40 휘도 현재 단계(0~100)
  1164. pObj->BRGH_WEEK_STEP = pVms->brghDay; // N NUMBER(3) Y 64 휘도 주간 단계(0~100)
  1165. pObj->BRGH_NGHT_STEP = pVms->brghNight; // N NUMBER(3) Y 48 휘도 야간 단계(0~100)
  1166. pObj->ParamResTime.printf(L"%s", pVms->time);
  1167. }
  1168. else
  1169. {
  1170. sMsg.printf(L"INT_OP_VMS_PARAM_RES VMS not found: %s", String(pVms->VMS_CTLR_NMBR).c_str());
  1171. DebugMsg(sMsg);
  1172. }
  1173. }
  1174. }
  1175. break;
  1176. case INT_OP_VMS_STATE_RES:
  1177. {
  1178. char szVmsNmbr[INT_VMS_MAX_ID+1];
  1179. INT_VMS_STATE_RES *ARes = (INT_VMS_STATE_RES*)pData;
  1180. sMsg = "";
  1181. //sMsg.printf(L"*** VMS 제어기 상태정보 수신: %d EA", ARes->Count);
  1182. sMsg.printf(L"*** VMS Controller Status Received: %d EA", ARes->Count);
  1183. DebugMsg(sMsg);
  1184. for (int ii = 0; ii < ARes->Count && ii < INT_VMS_MAX_STATE; ii++)
  1185. {
  1186. sMsg = "";
  1187. INT_VMS_STATE *pVms = &ARes->Unit[ii];
  1188. sVmsNmbr = String(pVms->VMS_CTLR_NMBR);
  1189. TVmsCtlr *pObj = VmsCtlrManager->FLists.Find(sVmsNmbr);
  1190. if (pObj)
  1191. {
  1192. memcpy(&pObj->STATE, pVms, sizeof(INT_VMS_STATE));
  1193. if (pObj->STATE.OprMode == 'A') pObj->OPER_MODE = "A";
  1194. else if (pObj->STATE.OprMode == 'B') pObj->OPER_MODE = "B";
  1195. else pObj->OPER_MODE = "F";
  1196. //pObj->VMS_PHSE_CHNG_CYCL = pObj->STATE.ScheduledMessageOperatingTime;
  1197. #if 0
  1198. pObj->VMS_CMNC_ERR_BASS_VAL = pObj->STATE.ModuleOperatingTemperature;
  1199. pObj->FAN_MTNS_TMPR = pObj->STATE.FanOperatingTemperature;
  1200. pObj->HETR_MTNS_TMPR = pObj->STATE.HeaterOperatingTemperature;
  1201. pObj->VMS_MODL_ERR_RATE = pObj->STATE.ModuleBasicFailureRate;
  1202. #endif
  1203. pObj->CheckRunState();
  1204. if (pObj->STATE.Comm != vms_comm_normal)
  1205. {
  1206. pObj->VmsMsg->OFFER_YN = false;
  1207. }
  1208. }
  1209. else
  1210. {
  1211. sMsg.printf(L"INT_OP_VMS_STATE_RES VMS not found: %s", sVmsNmbr.c_str());
  1212. DebugMsg(sMsg);
  1213. }
  1214. }
  1215. RefreshVmsMessage(WM_VMS_STATE_REFRESH);
  1216. FPollVmsState.Polling = GetTickCount();
  1217. }
  1218. break;
  1219. case INT_OP_VMS_FORM_SAVE:
  1220. {
  1221. FPollVmsMsg.Reset(); //VMS메시지 조회 타이머 리셋
  1222. char szDateTime[INT_VMS_MAX_DATETIME+1];
  1223. INT_VMS_FORM_SAVE_REQ *AReq = (INT_VMS_FORM_SAVE_REQ*)pData;
  1224. sprintf(szDateTime, "%.*s", INT_VMS_MAX_DATETIME, (char*)AReq->Date);
  1225. String sDateTime = String(szDateTime);
  1226. sMsg = "";
  1227. //sMsg.printf(L"*** VMS 폼생성 완료 메시지 수신: %s", sDateTime.c_str());
  1228. sMsg.printf(L"*** VMS Form Create Message Received: %s", sDateTime.c_str());
  1229. DebugMsg(sMsg);
  1230. }
  1231. break;
  1232. case INT_OP_VMS_FORM_DOWNLOAD:
  1233. {
  1234. char szDateTime[INT_VMS_MAX_DATETIME+1];
  1235. char szVmsNmbr[INT_VMS_MAX_ID+1];
  1236. INT_VMS_FORM_DOWNLOAD_REQ *AReq = (INT_VMS_FORM_DOWNLOAD_REQ*)pData;
  1237. //sMsg.printf(L"*** VMS 폼 다운로드 메시지 수신: %d EA", AReq->Count);
  1238. sMsg.printf(L"*** VMS Form Download Recieved: %d EA", AReq->Count);
  1239. DebugMsg(sMsg);
  1240. for (int ii = 0; ii < AReq->Count && ii < INT_VMS_MAX_FORM_DOWNLOAD; ii++)
  1241. {
  1242. sMsg = "";
  1243. INT_VMS_FORM_DOWNLOAD *pVms = &AReq->Unit[ii];
  1244. sprintf(szVmsNmbr, "%.*s", INT_VMS_MAX_ID, (char*)pVms->VmsId);
  1245. sprintf(szDateTime, "%.*s", INT_VMS_MAX_DATETIME, (char*)pVms->Date);
  1246. sVmsNmbr = String(szVmsNmbr);
  1247. String sDateTime = String(szDateTime);
  1248. TVmsCtlr *pObj = VmsCtlrManager->FLists.Find(sVmsNmbr);
  1249. if (pObj)
  1250. {
  1251. bool bDnLd = (pVms->Result == vms_download_succ) ? true : false;
  1252. String sResult = bDnLd ? "Succ" : "Fail";
  1253. pObj->VmsMsg->OFFER_DT = sDateTime;
  1254. pObj->VmsMsg->OFFER_YN = bDnLd;
  1255. for (int kk = 0; kk < pObj->VmsMsg->Total && kk < INT_VMS_MAX_FORM; kk++)
  1256. {
  1257. pObj->VmsMsg->PHASE[kk].DNLD_YN = bDnLd ? "Y" : "N";
  1258. }
  1259. //sMsg.printf(L"*** ===> VMS Msg download: %s, %s", pObj->VMS_CTLR_ID.c_str(), sResult.c_str());
  1260. //DebugMsg(sMsg);
  1261. }
  1262. else
  1263. {
  1264. sMsg.printf(L"*** INT_OP_VMS_FORM_DOWNLOAD VMS not found: %s", sVmsNmbr.c_str());
  1265. DebugMsg(sMsg);
  1266. }
  1267. }
  1268. RefreshVmsMessage(WM_VMS_STATE_REFRESH);
  1269. RefreshVmsMessage(WM_VMS_FORM_REFRESH);
  1270. }
  1271. break;
  1272. }
  1273. TmrCommTimeout->Enabled = true;
  1274. }
  1275. //---------------------------------------------------------------------------
  1276. void __fastcall TFrmVmsOprMain::RefreshVmsMessage(int AMsg, WPARAM AWParam/*=0*/, LPARAM ALParam/*=0*/)
  1277. {
  1278. HWND hWnd;
  1279. if (NVMS0000M->Enabled)
  1280. {
  1281. hWnd = FindChildWindow("VMS0000M");
  1282. if (hWnd) POST_MSG(hWnd, AMsg, AWParam, ALParam);
  1283. }
  1284. if (NVMS0100M->Enabled)
  1285. {
  1286. hWnd = FindChildWindow("VMS0100M");
  1287. if (hWnd) POST_MSG(hWnd, AMsg, AWParam, ALParam);
  1288. }
  1289. if (NVMS0200M->Enabled)
  1290. {
  1291. hWnd = FindChildWindow("VMS0200M");
  1292. if (hWnd) POST_MSG(hWnd, AMsg, AWParam, ALParam);
  1293. }
  1294. if (NVMS0300M->Enabled)
  1295. {
  1296. hWnd = FindChildWindow("VMS0300M");
  1297. if (hWnd) POST_MSG(hWnd, AMsg, AWParam, ALParam);
  1298. }
  1299. #if 0
  1300. if (NVMS0400M->Enabled)
  1301. {
  1302. hWnd = FindChildWindow("VMS0400M");
  1303. if (hWnd) POST_MSG(hWnd, AMsg, AWParam, ALParam);
  1304. }
  1305. #endif
  1306. if (NVMS0500M->Enabled)
  1307. {
  1308. hWnd = FindChildWindow("VMS0500M");
  1309. if (hWnd) POST_MSG(hWnd, AMsg, AWParam, ALParam);
  1310. }
  1311. if (NVMS0600M->Enabled)
  1312. {
  1313. hWnd = FindChildWindow("VMS0600M");
  1314. if (hWnd) POST_MSG(hWnd, AMsg, AWParam, ALParam);
  1315. }
  1316. }
  1317. //---------------------------------------------------------------------------
  1318. void __fastcall TFrmVmsOprMain::OnPollingThreadDone(TObject *Sender)
  1319. {
  1320. LOGINFO("*** Polling thead terminated ***");
  1321. g_AppCfg.thr.bRunning = false;
  1322. }
  1323. //---------------------------------------------------------------------------
  1324. void __fastcall TFrmVmsOprMain::ShowFacilityStatus()
  1325. {
  1326. // HWND hWnd = FindChildWindow("ITS0000M");
  1327. // if (hWnd) POST_MSG(hWnd, WM_MAINFORM, AWParam, ALParam);
  1328. return;
  1329. #if 0
  1330. bool bShow = false;
  1331. try
  1332. {
  1333. ItsFacilityManager->FLists.Lock();
  1334. try
  1335. {
  1336. FOR_STL(TItsFacility*, pFacility, ItsFacilityManager->FLists)
  1337. {
  1338. if (pFacility->DEL_YN == "Y") continue;
  1339. if (pFacility->FCLT_TYPE == "DSRC")
  1340. {
  1341. if (pFacility->FCollCntBase > pFacility->FCollCntCurr)
  1342. {
  1343. bShow = true;
  1344. break;
  1345. }
  1346. }
  1347. if (pFacility->FComm != "1")
  1348. {
  1349. bShow = true;
  1350. break;
  1351. }
  1352. else
  1353. {
  1354. try
  1355. {
  1356. String sValue = pFacility->FCBoxTmpr;
  1357. int nValue = 0;
  1358. if (TryStrToInt(sValue, nValue))
  1359. {
  1360. if (nValue > g_AppCfg.Temp.AlarmValue)
  1361. {
  1362. bShow = true;
  1363. break;
  1364. }
  1365. }
  1366. } catch(...) {}
  1367. }
  1368. }
  1369. }
  1370. __finally
  1371. {
  1372. ItsFacilityManager->FLists.UnLock();
  1373. }
  1374. }
  1375. catch(...)
  1376. {
  1377. }
  1378. if (!bShow)
  1379. {
  1380. LblAlarm->Style->Font->Color = clBlack;
  1381. LblAlarm->Caption = "알람정보";
  1382. ImgAlarm->Visible = false;
  1383. ImgAlarmNormal->Visible = true;
  1384. try {
  1385. if (ImgAlarm->Picture->Graphic->ClassName() == "TGIFImage")
  1386. ((TGIFImage *)ImgAlarm->Picture->Graphic)->Animate = false;
  1387. } catch(...) {}
  1388. return;
  1389. }
  1390. ImgAlarmNormal->Visible = false;
  1391. ImgAlarm->Visible = true;
  1392. try {
  1393. if (ImgAlarm->Picture->Graphic->ClassName() == "TGIFImage")
  1394. ((TGIFImage *)ImgAlarm->Picture->Graphic)->Animate = true;
  1395. } catch(...) {}
  1396. LblAlarm->Caption = "알람발생";
  1397. LblAlarm->Style->Font->Color = clRed;
  1398. if (!g_AppCfg.Alarm.Enabled) return;
  1399. if (!g_AppCfg.Alarm.Window) return;
  1400. #endif
  1401. }
  1402. //---------------------------------------------------------------------------
  1403. void __fastcall TFrmVmsOprMain::NVMSM100MClick(TObject *Sender)
  1404. {
  1405. FORMSHOW(VMSM100M);
  1406. }
  1407. //---------------------------------------------------------------------------
  1408. void __fastcall TFrmVmsOprMain::NVMSM200MClick(TObject *Sender)
  1409. {
  1410. FORMSHOW(VMSM200M);
  1411. }
  1412. //---------------------------------------------------------------------------
  1413. void __fastcall TFrmVmsOprMain::NVMSM210MClick(TObject *Sender)
  1414. {
  1415. FORMSHOW(VMSM210M);
  1416. }
  1417. //---------------------------------------------------------------------------
  1418. void __fastcall TFrmVmsOprMain::NVMSM300MClick(TObject *Sender)
  1419. {
  1420. //FORMSHOW(VMSM300M);
  1421. }
  1422. //---------------------------------------------------------------------------
  1423. void __fastcall TFrmVmsOprMain::NVMSM310MClick(TObject *Sender)
  1424. {
  1425. //FORMSHOW(VMSM310M);
  1426. }
  1427. //---------------------------------------------------------------------------
  1428. void __fastcall TFrmVmsOprMain::NVMSM400MClick(TObject *Sender)
  1429. {
  1430. FORMSHOW(VMSM400M);
  1431. }
  1432. //---------------------------------------------------------------------------
  1433. void __fastcall TFrmVmsOprMain::NVMSM410MClick(TObject *Sender)
  1434. {
  1435. FORMSHOW(VMSM410M);
  1436. }
  1437. //---------------------------------------------------------------------------
  1438. void __fastcall TFrmVmsOprMain::NVMSM420MClick(TObject *Sender)
  1439. {
  1440. FORMSHOW(VMSM420M);
  1441. }
  1442. //---------------------------------------------------------------------------
  1443. void __fastcall TFrmVmsOprMain::NVMSM430MClick(TObject *Sender)
  1444. {
  1445. FORMSHOW(VMSM430M);
  1446. }
  1447. //---------------------------------------------------------------------------
  1448. void __fastcall TFrmVmsOprMain::NVMSM500MClick(TObject *Sender)
  1449. {
  1450. FORMSHOW(VMSM500M);
  1451. }
  1452. //---------------------------------------------------------------------------
  1453. void __fastcall TFrmVmsOprMain::NVMSM600MClick(TObject *Sender)
  1454. {
  1455. FORMSHOW(VMSM600M);
  1456. }
  1457. //---------------------------------------------------------------------------
  1458. void __fastcall TFrmVmsOprMain::NVMSM700MClick(TObject *Sender)
  1459. {
  1460. FORMSHOW(VMSM700M);
  1461. }
  1462. //---------------------------------------------------------------------------
  1463. void __fastcall TFrmVmsOprMain::NVMSM800MClick(TObject *Sender)
  1464. {
  1465. FORMSHOW(VMSM800M);
  1466. }
  1467. //---------------------------------------------------------------------------
  1468. void __fastcall TFrmVmsOprMain::NVMSM900MClick(TObject *Sender)
  1469. {
  1470. FORMSHOW(VMSM900M);
  1471. }
  1472. //---------------------------------------------------------------------------
  1473. void __fastcall TFrmVmsOprMain::NVMS0000MClick(TObject *Sender)
  1474. {
  1475. FORMSHOW(VMS0000M);
  1476. }
  1477. //---------------------------------------------------------------------------
  1478. void __fastcall TFrmVmsOprMain::NVMS0100MClick(TObject *Sender)
  1479. {
  1480. if (g_AppCfg.bOnlyOneScreen) CloseChildWindow();
  1481. FORMSHOW(VMS0100M);
  1482. }
  1483. //---------------------------------------------------------------------------
  1484. void __fastcall TFrmVmsOprMain::NVMS0010MClick(TObject *Sender)
  1485. {
  1486. FORMSHOW(VMS0010M);
  1487. }
  1488. //---------------------------------------------------------------------------
  1489. void __fastcall TFrmVmsOprMain::NVMS0200MClick(TObject *Sender)
  1490. {
  1491. if (g_AppCfg.bOnlyOneScreen) CloseChildWindow();
  1492. FORMSHOW(VMS0200M);
  1493. }
  1494. //---------------------------------------------------------------------------
  1495. void __fastcall TFrmVmsOprMain::NVMS0300MClick(TObject *Sender)
  1496. {
  1497. if (g_AppCfg.bOnlyOneScreen) CloseChildWindow();
  1498. FORMSHOW(VMS0300M);
  1499. }
  1500. //---------------------------------------------------------------------------
  1501. void __fastcall TFrmVmsOprMain::NVMS0400MClick(TObject *Sender)
  1502. {
  1503. //FORMSHOW(VMS0400M);
  1504. }
  1505. //---------------------------------------------------------------------------
  1506. void __fastcall TFrmVmsOprMain::NVMS0500MClick(TObject *Sender)
  1507. {
  1508. if (g_AppCfg.bOnlyOneScreen) CloseChildWindow();
  1509. FORMSHOW(VMS0500M);
  1510. }
  1511. //---------------------------------------------------------------------------
  1512. void __fastcall TFrmVmsOprMain::NVMS0600MClick(TObject *Sender)
  1513. {
  1514. if (g_AppCfg.bOnlyOneScreen) CloseChildWindow();
  1515. FORMSHOW(VMS0600M);
  1516. }
  1517. //---------------------------------------------------------------------------
  1518. void __fastcall TFrmVmsOprMain::TmrCommTimeoutTimer(TObject *Sender)
  1519. {
  1520. //통신타임아웃
  1521. TmrCommTimeout->Enabled = false;
  1522. UpdateInterCommStatus(false);
  1523. FVmsServerState = vms_comm_error;
  1524. UpdateVmsCommStatus(false);
  1525. LOGINFO("xxx VMS Communication Time out xxx");
  1526. }
  1527. //---------------------------------------------------------------------------
  1528. void __fastcall TFrmVmsOprMain::ApplicationEvents1Restore(TObject *Sender)
  1529. {
  1530. //화면 재생
  1531. }
  1532. //---------------------------------------------------------------------------
  1533. void __fastcall TFrmVmsOprMain::ApplicationEvents1Minimize(TObject *Sender)
  1534. {
  1535. //화면 정지
  1536. }
  1537. //---------------------------------------------------------------------------
  1538. void __fastcall TFrmVmsOprMain::OnMenuMouseMove(TObject *Sender, TShiftState Shift, int X,
  1539. int Y)
  1540. {
  1541. ::SetCursor(Screen->Cursors[crHandPoint]);
  1542. }
  1543. //---------------------------------------------------------------------------
  1544. void __fastcall TFrmVmsOprMain::ApplicationEvents1SettingChange(TObject *Sender, int Flag,
  1545. const UnicodeString Section, int &Result)
  1546. {
  1547. DateSeparator = '-';
  1548. TimeSeparator = ':';
  1549. ShortDateFormat = "yyyy-MM-dd";
  1550. ShortTimeFormat = "HH:NN:SS";
  1551. LongTimeFormat = "HH:NN:SS";
  1552. cxFormatController()->BeginUpdate();
  1553. cxFormatController()->UseDelphiDateTimeFormats = true;
  1554. cxFormatController()->EndUpdate();
  1555. cxFormatController()->GetFormats();
  1556. cxFormatController()->NotifyListeners();
  1557. }
  1558. //---------------------------------------------------------------------------
  1559. void __fastcall TFrmVmsOprMain::NVMS0TESTClick(TObject *Sender)
  1560. {
  1561. //
  1562. }
  1563. //---------------------------------------------------------------------------
  1564. void __fastcall TFrmVmsOprMain::NTST0000MClick(TObject *Sender)
  1565. {
  1566. #if 0
  1567. VmsCtlrManager->LoadVmsMsg();
  1568. String sExeName = "Project1.exe";
  1569. String sParam = "\"" + g_pLOGIN->sUserId + "\" \"" + g_pLOGIN->sUserId + "\"";
  1570. //ShellExecute(NULL,"open", "C:\\myprocess.exe", "\"my argument 1 containing spaces\" \"my argument 2\"","C:\\",SW_SHOWNORMAL);
  1571. ShellExecute(Handle, NULL, sExeName.c_str(), sParam.c_str(), NULL, SW_SHOWNORMAL);
  1572. #endif
  1573. #include <stdio.h>
  1574. AnsiString sQry1 = "INSERT INTO TB_OPERSYST_MENU VALUES('%s', 'VMS.%02d.%s', 'N', 1, '');\n";
  1575. AnsiString sQry2 = "INSERT INTO TB_OPERSYST_MENU VALUES('%s', '%s', 'N', 2, '%s');\n";
  1576. AnsiString sMenuFile = g_sAppDir + "Menu_VMS.TXT";
  1577. FILE *pFileMenu = NULL;
  1578. pFileMenu = fopen(sMenuFile.c_str(), "w+");
  1579. if (pFileMenu == NULL)
  1580. {
  1581. ShowMessage("메뉴파일을 생성하지 못하였습니다.");
  1582. return;
  1583. }
  1584. int nMenuCnt = 1;
  1585. int nMenuTabs = Ribbon->Tabs->Count;
  1586. for (int ii = 0; ii < nMenuTabs; ii++)
  1587. {
  1588. TdxRibbonTab *pTab = Ribbon->Tabs->Items[ii];
  1589. if (pTab->Visible == false) continue;
  1590. AnsiString sMainName = pTab->Name;
  1591. AnsiString sMainCap = pTab->Caption;
  1592. fprintf(pFileMenu, sQry1.c_str(), sMainName.c_str(), nMenuCnt++, sMainCap.c_str());
  1593. int nSubMenus = pTab->Groups->Count;
  1594. for (int jj = 0; jj < nSubMenus; jj++)
  1595. {
  1596. TdxRibbonTabGroup *pGroup = pTab->Groups->Items[jj];
  1597. TdxBar *pBar = pGroup->ToolBar;
  1598. if (pBar == NULL)
  1599. {
  1600. continue;
  1601. }
  1602. if (pBar->Visible == false) continue;
  1603. int nMenus = pBar->ItemLinks->Count;
  1604. for (int kk = 0; kk < nMenus; kk++)
  1605. {
  1606. TdxBarItemLink *pItemLink = pBar->ItemLinks->Items[kk];
  1607. TdxBarLargeButton *pMenuBtn = (TdxBarLargeButton*)pItemLink->Item;
  1608. if (pMenuBtn->Visible != ivAlways) continue;
  1609. AnsiString sMenuName = pMenuBtn->Name;
  1610. AnsiString sMenuCap = pMenuBtn->Caption;
  1611. fprintf(pFileMenu, sQry2.c_str(), sMenuName.c_str(), sMenuCap.c_str(), sMainName.c_str());
  1612. }
  1613. }
  1614. }
  1615. fclose(pFileMenu);
  1616. pFileMenu = NULL;
  1617. #if 0
  1618. for (int ii = 0; ii < nCompnentCnt; ii++)
  1619. {
  1620. String sClassName = this->Components[ii]->ClassName();
  1621. if(sClassName == "TdxBarLargeButton")
  1622. {
  1623. TdxBarLargeButton *pMenu = (TdxBarLargeButton *)this->Components[ii];
  1624. if (pMenu->Name == sMenuId)
  1625. {
  1626. pMenu->Enabled = false;
  1627. break;
  1628. }
  1629. }
  1630. }
  1631. #endif
  1632. }
  1633. //---------------------------------------------------------------------------
  1634. void __fastcall TFrmVmsOprMain::FormDblClick(TObject *Sender)
  1635. {
  1636. NTST0000MClick((TObject*)NTST0000M);
  1637. }
  1638. //---------------------------------------------------------------------------
  1639. void __fastcall TFrmVmsOprMain::ApplicationEvents1ShortCut(TWMKey &Msg, bool &Handled)
  1640. {
  1641. #if 0
  1642. bool bCTRL = ::GetAsyncKeyState(VK_CONTROL);
  1643. bool bSHIFT = ::GetAsyncKeyState(VK_SHIFT);
  1644. switch(Msg.CharCode)
  1645. {
  1646. case VK_ESCAPE:
  1647. // 선택 취소
  1648. SelectAll(false);
  1649. Handled = true;
  1650. break;
  1651. case 0xBB:
  1652. if (bCTRL && bSHIFT)
  1653. {
  1654. }
  1655. break;
  1656. }
  1657. //이렇게 하시면 될 것 같습니다. + 은, = 에 Shift 가 눌린것으로 검사를 하시면 되고, Ctrl 까지 연산을 하시면, Ctrl + "+" 를 검사하실수 있습니다.
  1658. if (0 > GetKeyState(17) && 0 > GetKeyState(97))
  1659. Shape1->Brush->Color = clRed;
  1660. else Shape1->Brush->Color = clWhite;
  1661. Handled = true;
  1662. if (Msg.CharCode==37) Image2->Left -= 8;
  1663. if (Msg.CharCode==38) Image2->Top -= 8;
  1664. if (Msg.CharCode==39) Image2->Left += 8;
  1665. if (Msg.CharCode==40) Image2->Top += 8;
  1666. Handled = true;
  1667. if(Msg.CharCode == 'W'){
  1668. xkam=xkam+2*sin(kat*3.14/180);
  1669. zkam=zkam+2*cos(kat*3.14/180);
  1670. xcelu=xkam+200*sin(kat*3.14/180);
  1671. zcelu=zkam+200*cos(kat*3.14/180);
  1672. }
  1673. if(Msg.CharCode == 'Z'){
  1674. xkam=xkam-2*sin(kat*3.14/180);
  1675. zkam=zkam-2*cos(kat*3.14/180);
  1676. xcelu=xkam+200*sin(kat*3.14/180);
  1677. zcelu=zkam+200*cos(kat*3.14/180);
  1678. }
  1679. if(Msg.CharCode == 'A'){
  1680. kat=kat+4;
  1681. xcelu=xkam+200*sin(kat*3.14/180);
  1682. zcelu=zkam+200*cos(kat*3.14/180);
  1683. }
  1684. if(Msg.CharCode == 'D'){
  1685. kat=kat-4;
  1686. xcelu=xkam+200*sin(kat*3.14/180);
  1687. zcelu=zkam+200*cos(kat*3.14/180);
  1688. }
  1689. if(Msg.CharCode == 'Q'){
  1690. ykam=ykam+1;
  1691. ycelu=ycelu+1;
  1692. }
  1693. if(Msg.CharCode == 'E'){
  1694. ykam=ykam-1;
  1695. ycelu=ycelu-1;
  1696. }
  1697. if(Msg.CharCode == 'R'){
  1698. ycelu=ycelu+1;
  1699. }
  1700. if(Msg.CharCode == 'T'){
  1701. ycelu=ycelu-1;
  1702. }
  1703. #endif
  1704. if (Msg.CharCode == VK_F2)
  1705. {
  1706. NVMS0010MClick((TObject*)NVMS0010M);
  1707. }
  1708. else
  1709. if (Msg.CharCode == VK_F5)
  1710. {
  1711. DWORD dwTick = GetTickCount();
  1712. FPollVmsMsg.Polling = dwTick;
  1713. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_VMS_DSPLMSG);
  1714. DebugMsg(">>> VMS Display Message Request");//">>> VMS 표출메시지 조회 요청");
  1715. FPollPrcsState.Polling = dwTick;
  1716. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_PROCESS_STTS);
  1717. DebugMsg(">>> Process Status Request");//">>> 프로세스 상태 조회 요청");
  1718. FPollVmsState.Polling = dwTick;
  1719. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_FACILITY_STTS);
  1720. DebugMsg(">>> VMS Status Request");//">>> VMS 상태 조회 요청");
  1721. }
  1722. }
  1723. //---------------------------------------------------------------------------
  1724. void __fastcall TFrmVmsOprMain::NVMSMA00MClick(TObject *Sender)
  1725. {
  1726. #ifdef USE_EVPS
  1727. FORMSHOW(VMSMA00M);
  1728. #endif
  1729. }
  1730. //---------------------------------------------------------------------------
  1731. void __fastcall TFrmVmsOprMain::NVMSMA10MClick(TObject *Sender)
  1732. {
  1733. #ifdef USE_EVPS
  1734. FORMSHOW(VMSMA10M);
  1735. #endif
  1736. }
  1737. //---------------------------------------------------------------------------