FrmVmsOprMainF.cpp 63 KB

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