FrmVmsOprMainF.cpp 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009
  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 link "dxSkinPumpkin"
  94. #pragma link "dxSkinsDefaultPainters"
  95. #pragma link "dxSkinSpringTime"
  96. #pragma link "dxSkinSummer2008"
  97. #pragma link "dxSkinValentine"
  98. #pragma link "dxSkinXmas2008Blue"
  99. #pragma resource "*.dfm"
  100. TFrmVmsOprMain *FrmVmsOprMain = NULL;
  101. #define MAX_EXEPROGRAM 5
  102. ST_RUNPROGRAM g_RunProgram[MAX_EXEPROGRAM+1] = {
  103. {"TFrmVmsLogStts", "VmsLogStts.exe", "VMS상태이력조회"},
  104. {"TFrmVmsLogDspl", "VmsLogDspl.exe", "VMS제공이력조회"},
  105. {"TFrmVmsLogCtrl", "VmsLogCtrl.exe", "VMS제어이력조회"},
  106. {"TFrmVmsLogDnld", "VmsLogDnld.exe", "VMS다운로드이력조회"},
  107. {"TFrmVmsCamViewer", "VmsCamViewer.exe", "VMS영상모니터링"},
  108. {"", "", ""},
  109. };
  110. //---------------------------------------------------------------------------
  111. __fastcall TFrmVmsOprMain::TFrmVmsOprMain(TComponent* Owner)
  112. : TdxCustomRibbonForm(Owner)//TdxCustomRibbonForm(Owner)//TForm(Owner)
  113. {
  114. FLogoutTick = 0;
  115. DoubleBuffered = true;
  116. g_AppCfg.lMainWinHandle = (long)Handle;
  117. StartJobThread();
  118. while(!PostJobMessage(WM_THREAD, WP_PING)) ;
  119. Application->OnException = OnAppException;
  120. ::CoInitialize(NULL);
  121. //Caption = g_AppCfg.sTitle;
  122. LangTrans->Translate(this, ITSDb_GetConnection());
  123. ITSSkin_Initialize(Application, g_AppCfg.sLang, true, true);
  124. ITSSkin_Menu(this);
  125. String sCaption = "";
  126. ReadConfigInfo(g_AppCfg.sConfigFile, "APPLICATION", "CAPTION", sCaption);
  127. ITSSkin_Caption(sCaption == "1" ? true : false);
  128. BarVmsSys1->Visible = false;
  129. BarVmsSchMngr4->Visible = false;
  130. //NVMSM900M->Visible = ivNever;
  131. NVMSM800M->Visible = ivNever; // 기본스케쥴
  132. BarVmsSchMngr3->Visible = false; // 기본스케쥴
  133. //NVMSM430M->Visible = ivNever; // 동영상관리
  134. RVMSH300M->Visible = ivNever; // 제어이력 조회
  135. RVMSH400M->Visible = ivNever; // 다운로드이력 조회
  136. TabVmsConfig->Visible = false;
  137. NVMSM300M->Visible = ivNever; //VMS정보제공축관리
  138. NVMSM310M->Visible = ivNever; //VMS정보제공축설정
  139. //NVMS0600M->Visible = ivNever; //모듈상태 모니터링
  140. NVMS0TEST->Visible = ivNever;
  141. //NVMSM430M->Visible = ivNever;
  142. NVMS0010M->Visible = ivNever; //정보제공구간 현재소통정보
  143. //NVMSM420M->Visible = ivNever; //소통정보 이미지 관리
  144. Ribbon->ShowTabGroups = true; // 메뉴탭 show/hide
  145. Ribbon->QuickAccessToolbar->Visible = false;
  146. //Ribbon->ApplicationButton->Visible = false;
  147. Ribbon->SupportNonClientDrawing = true;
  148. Ribbon->EnableTabAero = true;
  149. TabVmsSystem->Active = true;
  150. SetColorScheme(g_AppCfg.sSkinName);
  151. //SetColorScheme("Blue");
  152. CMM_SetFormPosition(g_AppCfg.bSaveForm);
  153. CMM_LoadForm(g_sFormsDir, this);
  154. FVmsServerState = vms_comm_normal;
  155. APP_InitDisplayColor();
  156. TmrOnShow->Enabled = false;
  157. TmrAppState->Enabled = false;
  158. }
  159. //---------------------------------------------------------------------------
  160. LONG __stdcall HelperExceptionFilter(struct _EXCEPTION_POINTERS * pContext)
  161. {
  162. LONG lRet = EXCEPTION_EXECUTE_HANDLER;
  163. DWORD dwRet = ERROR_SUCCESS;
  164. __try
  165. {
  166. Application->NormalizeTopMosts();
  167. if (g_AppCfg.sLang == "kr")
  168. {
  169. Application->MessageBox(L"시스템에서 알수없는 오류가 발생했습니다.\r\n프로그램을 다시 기동해 주세요.",
  170. L"시스템 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  171. }
  172. else
  173. {
  174. Application->MessageBox(L"The system encountered an unknown error.\r\nPlease re-start the program.",
  175. L"System error", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  176. }
  177. Application->RestoreTopMosts();
  178. //TerminateProcess(GetCurrentProcess(), 0);
  179. }
  180. __finally
  181. {
  182. if(ERROR_SUCCESS != dwRet)
  183. {
  184. lRet = EXCEPTION_CONTINUE_SEARCH;
  185. }
  186. exit(0);
  187. }
  188. return lRet;
  189. }
  190. //---------------------------------------------------------------------------
  191. void __fastcall TFrmVmsOprMain::FormCreate(TObject *Sender)
  192. {
  193. /* 레지스터리 등록 IE 최신버전 */
  194. String sExeName = ExtractFileName(Application->ExeName);
  195. ITSMap_Init(sExeName);
  196. //SetUnhandledExceptionFilter(HelperExceptionFilter);
  197. Application->ShowMainForm = false;
  198. try {
  199. Application->Icon->LoadFromResourceName(((unsigned int)HInstance), "MAINICON");
  200. } catch(...) { ShowMessage("LoadFromResourceName failed"); }
  201. //DeleteLogFiles((PTCHAR)g_sLogDir.c_str(), 30, (PTCHAR)"*.*");
  202. //WindowState = wsMaximized;
  203. // 종료조건이 있는경우..
  204. //Application->Terminate();
  205. //return;
  206. Application->ShowMainForm = true;
  207. Application->OnHint = OnAppHint;
  208. ImgAlarm->Visible = false;
  209. ImgAlarmNormal->Visible = true;
  210. }
  211. //---------------------------------------------------------------------------
  212. void __fastcall TFrmVmsOprMain::FormShow(TObject *Sender)
  213. {
  214. Application->ProcessMessages();
  215. g_AppCfg.lMainWinHandle = (long)Handle;
  216. /*
  217. * 프로그램 초기화 작업
  218. */
  219. InitStatusBar();
  220. if (g_pLOGIN)
  221. {
  222. GetUserMenuRight(g_pLOGIN->sUserId, g_pLOGIN->sUserRightId);
  223. }
  224. String sBool = "1";
  225. ReadConfigInfo(g_AppCfg.sConfigFile, "APPLICATION", "DISPOFFLINEMSG", sBool);
  226. g_AppCfg.isDispOfflineMsg = sBool == "1" ? true : false;
  227. TmrOnShow->Enabled = true;
  228. }
  229. //---------------------------------------------------------------------------
  230. void __fastcall TFrmVmsOprMain::TmrOnShowTimer(TObject *Sender)
  231. {
  232. TmrOnShow->Enabled = false;
  233. Application->ProcessMessages();
  234. //폴링작업 객체 초기화
  235. FPollTraffic.Cycle = (60*1000*2)+11; // 정보제공구간소통정보
  236. FPollVmsMsg.Cycle = (60*1000*2)+15; // VMS Message
  237. FPollVmsState.Cycle = (60*1000*1)+ 1; // 시설물상태정보
  238. FPollPrcsState.Cycle = (60*1000*2)+ 3; // 프로세스상태정보
  239. FPollIncident.Cycle = (60*1000*2)+ 5; // 돌발정보
  240. FPollTraffic.IsPolling = true;
  241. FPollVmsMsg.IsPolling = true;
  242. FPollVmsState.IsPolling = true;
  243. FPollPrcsState.IsPolling = true;
  244. FPollIncident.IsPolling = true;
  245. TFrmInitialize *FrmInitialize = new TFrmInitialize(this);
  246. FrmInitialize->FThreadId = g_AppCfg.thr.dwThreadId;
  247. FrmInitialize->ShowModal();
  248. UpdateVmsCommStatus(true);
  249. int nPort = 4602;
  250. TItsProcess *pPrcs = ItsProcessManager->FLists.Find(g_AppCfg.sProcessId);
  251. if (!pPrcs)
  252. {
  253. if (g_AppCfg.sLang == "kr")
  254. {
  255. Application->MessageBox(L"통신프로세스를 초기화 하지 못하였습니다.\r\n환경설정에서 시스템ID를 확인하세요.\r\n프로그램을 종료합니다.",
  256. L"프로그램 통신오류_1", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  257. }
  258. else
  259. {
  260. Application->MessageBox(L"Failed to initialize communication process.\r\nPlease check your system ID in preferences.\r\nExit the program.",
  261. L"Program communication error_1", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  262. }
  263. g_AppCfg.bAppClose = true;
  264. Close();
  265. return;
  266. }
  267. nPort = pPrcs->PRGM_PORT.ToIntDef(4602);
  268. nPort += 1; //VMS운영단말은 DB에 저장되어 있지 않기 때문에 포트번호를 1 증가시켜 통신한다.
  269. int nResult = CComm_Initialize((long)Handle, g_AppCfg.sProcessId, "UOT", nPort, g_AppCfg.sLogDay);
  270. if (VERR_NONE != nResult)
  271. {
  272. if (g_AppCfg.sLang == "kr")
  273. {
  274. Application->MessageBox(L"통신프로세스를 초기화 하지 못하였습니다.\r\n환경설정에서 시스템ID를 확인하세요.\r\n프로그램을 종료합니다.",
  275. L"프로그램 통신오류_1", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  276. }
  277. else
  278. {
  279. Application->MessageBox(L"Failed to initialize communication process.\r\nPlease check your system ID in preferences.\r\nExit the program.",
  280. L"Program communication error_1", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  281. }
  282. g_AppCfg.bAppClose = true;
  283. Close();
  284. return;
  285. }
  286. FOR_STL(TItsProcess*, pObj, ItsProcessManager->FLists)
  287. {
  288. if (pObj->DEL_YN == "Y") continue;
  289. AnsiString sProcessId = AnsiString(pObj->SYST_ID);
  290. AnsiString sSystemTp = AnsiString(pObj->SYST_TYPE);
  291. AnsiString sIpAddress = AnsiString(pObj->SYST_IP_1);
  292. AnsiString sUdpPort = AnsiString(pObj->PRGM_PORT);
  293. if (CComm_AddProcess(sProcessId, sSystemTp, sIpAddress, sUdpPort) >= 0)
  294. {
  295. if ("UOT" == sSystemTp)
  296. {
  297. nPort = sUdpPort.ToIntDef(0);
  298. CComm_AddProcess(sProcessId, sSystemTp, sIpAddress, AnsiString(nPort+1));
  299. }
  300. }
  301. }
  302. if (VERR_NONE != CComm_Open())
  303. {
  304. if (g_AppCfg.sLang == "kr")
  305. {
  306. Application->MessageBox(L"통신프로세스를 초기화 하지 못하였습니다.\r\n환경설정에서 시스템ID를 확인하세요.\r\n프로그램을 종료합니다.",
  307. L"프로그램 통신오류_3", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  308. }
  309. else
  310. {
  311. Application->MessageBox(L"Failed to initialize communication process.\r\nPlease check your system ID in preferences.\r\nExit the program.",
  312. L"Program communication error_3", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  313. }
  314. g_AppCfg.bAppClose = true;
  315. Close();
  316. return;
  317. }
  318. UpdateInterCommStatus(true);
  319. Application->ProcessMessages();
  320. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex = ITSDb_IsOpen() ? 8 : 7;
  321. //TODO NITS0000MClick((TObject *)NITS0000M); //메인화면을 프로그램 기동과 동시에 호출하는 경우
  322. #if 0
  323. if (g_AppCfg.AutoLogout.LogoutExit)
  324. {
  325. Application->MessageBox(L"이전 프로그램은 자동로그아웃으로 종료되었습니다.\r\n프로그램을 실행합니다.",
  326. L"프로그램 실행정보", MB_OK|MB_ICONQUESTION|MB_APPLMODAL);
  327. }
  328. #endif
  329. g_AppCfg.AutoLogout.LogoutExit = false;
  330. TmrAppState->Enabled = true;
  331. TmrPolling->Enabled = true;
  332. TmrCommTimeout->Enabled = true;
  333. INT_VMS_STATE_REQ Req;
  334. memset((char*)&Req, 0x00, sizeof(Req));
  335. Req.Count = 0;
  336. Req.Type = vms_req_state_all;
  337. CComm_VmsStateReq(&Req);
  338. }
  339. //---------------------------------------------------------------------------
  340. bool __fastcall TFrmVmsOprMain::StartJobThread()
  341. {
  342. TThreadPolling *pPollingThread = new TThreadPolling(false);
  343. if (pPollingThread)
  344. {
  345. pPollingThread->OnTerminate = OnPollingThreadDone;
  346. g_AppCfg.thr.pThread = (TThread *)pPollingThread;
  347. g_AppCfg.thr.dwThreadId = pPollingThread->ThreadID;
  348. g_AppCfg.thr.nHandle = pPollingThread->Handle;
  349. //pPollingThread->Resume();
  350. return true;
  351. }
  352. return false;
  353. }
  354. //---------------------------------------------------------------------------
  355. void __fastcall TFrmVmsOprMain::TerminateJobThread()
  356. {
  357. if (g_AppCfg.thr.bRunning)
  358. {
  359. PostJobMessage(WM_THREAD, WM_QUIT);
  360. }
  361. Sleep(500);
  362. try
  363. {
  364. if (g_AppCfg.thr.bRunning)
  365. {
  366. TThreadPolling *pThread = (TThreadPolling *)g_AppCfg.thr.pThread;
  367. pThread->Terminate();
  368. //pThread->WaitFor();
  369. }
  370. g_AppCfg.thr.pThread = NULL;
  371. g_AppCfg.thr.dwThreadId = 0;
  372. g_AppCfg.thr.nHandle = 0;
  373. g_AppCfg.thr.bRunning = false;
  374. }
  375. catch(...)
  376. {
  377. }
  378. }
  379. //---------------------------------------------------------------------------
  380. void __fastcall TFrmVmsOprMain::FormCloseQuery(TObject *Sender, bool &CanClose)
  381. {
  382. // 폼이 닫히기 전에 수행해야 할 모뮬 기술
  383. // 프로그램 종료를 사용자가 확인할 수 있도록...
  384. if (!g_AppCfg.bAppClose)
  385. {
  386. #if 0
  387. String strMsg;
  388. strMsg = "";
  389. strMsg = "[ " + g_AppCfg.sTitle + " ]\r\n\n";
  390. strMsg+= FrmLang->cxLabel1->Caption;
  391. if(Application->MessageBox(strMsg.c_str(),
  392. FrmLang->cxLabel2->Caption.c_str(),
  393. MB_YESNO|MB_ICONQUESTION) == IDYES)
  394. {
  395. /*
  396. * 화면관련 작업을 못하도록 여기에 코드를 적자...
  397. */
  398. ITSDb_ApplicationTerm();
  399. g_AppCfg.bAppClose = true;
  400. }
  401. #else
  402. CloseAllWindow();
  403. ITSDb_ApplicationTerm();
  404. g_AppCfg.bAppClose = true;
  405. #endif
  406. CanClose = false;
  407. }
  408. }
  409. //---------------------------------------------------------------------------
  410. void __fastcall TFrmVmsOprMain::FormClose(TObject *Sender, TCloseAction &Action)
  411. {
  412. CommClose();
  413. Action = caFree;
  414. }
  415. //---------------------------------------------------------------------------
  416. void __fastcall TFrmVmsOprMain::CommClose()
  417. {
  418. try
  419. {
  420. CComm_Close();
  421. //CloseAllWindow();
  422. ITSSkin_Term();
  423. CMM_SaveForm(g_sFormsDir, this);
  424. WriteConfigInfo(g_AppCfg.sConfigFile, "APPLICATION", "LOGDAY", Now().FormatString("dd"));
  425. ::CoUninitialize();
  426. }
  427. catch(...)
  428. {
  429. }
  430. }
  431. //---------------------------------------------------------------------------
  432. void __fastcall TFrmVmsOprMain::CloseAllWindow()
  433. {
  434. int ii;
  435. if (g_AppCfg.bTermChildProg)
  436. {
  437. // 실행시킨 프로그램을 종료시킨다.
  438. for (ii = 0; ii < MAX_EXEPROGRAM; ii++)
  439. {
  440. if (g_RunProgram[ii].AClassName == "")
  441. continue;
  442. TermItsProgram(g_RunProgram[ii].AClassName, "");
  443. }
  444. }
  445. //실행중인 화면을 종료 시킨다.
  446. try {
  447. for (ii = 0; ii < Screen->FormCount; ii++)
  448. {
  449. if (Screen->Forms[ii] != this)
  450. {
  451. if (::IsWindow(Screen->Forms[ii]->Handle))
  452. {
  453. String sFormName = Screen->Forms[ii]->Name;
  454. if (sFormName == "ITSSkin") continue;
  455. if (sFormName == "FrmSkin") continue;
  456. if (sFormName == "FrmLang") continue;
  457. if (sFormName.SubString(1, 11) == "PlugInChart") continue;
  458. if (Screen->Forms[ii]->Owner == this ||
  459. Screen->Forms[ii]->Owner == Application)
  460. {
  461. //Screen->Forms[ii]->Close();
  462. PostMessage(Screen->Forms[ii]->Handle, WM_CLOSE, 0, 0);
  463. WaitForSingleObject(Screen->Forms[ii]->Handle, 1000);
  464. }
  465. }
  466. }
  467. }
  468. } catch(...) {}
  469. }
  470. //---------------------------------------------------------------------------
  471. void __fastcall TFrmVmsOprMain::CloseChildWindow()
  472. {
  473. int ii;
  474. //실행중인 화면을 종료 시킨다.
  475. try {
  476. for (ii = 0; ii < Screen->FormCount; ii++)
  477. {
  478. if (Screen->Forms[ii] != this)
  479. {
  480. if (::IsWindow(Screen->Forms[ii]->Handle))
  481. {
  482. String sFormName = Screen->Forms[ii]->Name;
  483. if (sFormName == "ITSSkin") continue;
  484. if (sFormName == "FrmSkin") continue;
  485. if (sFormName == "FrmLang") continue;
  486. if (sFormName.SubString(1, 11) == "PlugInChart") continue;
  487. if ((Screen->Forms[ii]->Owner == this || Screen->Forms[ii]->Owner == Application) &&
  488. (Screen->Forms[ii]->FormStyle == fsMDIChild)
  489. )
  490. {
  491. Screen->Forms[ii]->Close();
  492. WaitForSingleObject(Screen->Forms[ii]->Handle, 500);
  493. }
  494. }
  495. }
  496. }
  497. } catch(...) {}
  498. }
  499. //---------------------------------------------------------------------------
  500. void __fastcall TFrmVmsOprMain::TmrAppStateTimer(TObject *Sender)
  501. {
  502. /*
  503. * 타이머가 1초간격으로 응용프로그램의 상태를 체크하고
  504. * 응용프로그램의 상태를 주기적으로 체크하여 필요한 조치를 수행한다.
  505. */
  506. if (g_AppCfg.bAppClose)
  507. {
  508. TmrAppState->Enabled = false;
  509. TmrPolling->Enabled = false;
  510. UserLogout(); // 로그아웃
  511. TerminateJobThread();
  512. ITSDb_Close();
  513. Close(); // 응용프로그램 종료
  514. }
  515. else
  516. {
  517. TmrAppState->Enabled = false;
  518. UpdateStatusBar();
  519. if (g_AppCfg.AutoLogout.Enabled)
  520. {
  521. FLogoutTick++;
  522. if (FLogoutTick > (g_AppCfg.AutoLogout.IntervalMin*60))
  523. {
  524. //자동로그아웃처리
  525. g_AppCfg.bAppClose = true;
  526. g_AppCfg.AutoLogout.LogoutExit = true;
  527. }
  528. }
  529. TmrAppState->Enabled = true;
  530. }
  531. }
  532. //---------------------------------------------------------------------------
  533. void __fastcall TFrmVmsOprMain::UpdateInterCommStatus(bool AOk)
  534. {
  535. int nImgIdx = 8;
  536. if (AOk == false) nImgIdx = 7;
  537. if (((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbComm]->PanelStyle)->ImageIndex != nImgIdx)
  538. {
  539. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbComm]->PanelStyle)->ImageIndex = nImgIdx;
  540. }
  541. }
  542. //---------------------------------------------------------------------------
  543. void __fastcall TFrmVmsOprMain::UpdateVmsCommStatus(bool ADb)
  544. {
  545. if (ADb)
  546. {
  547. FOR_STL(TItsProcess*, pPrcs, ItsProcessManager->FLists)
  548. {
  549. if (pPrcs->SYST_TYPE == "VMS")
  550. {
  551. if (pPrcs->FCommStatus == "1")
  552. {
  553. FVmsServerState = vms_comm_normal;
  554. }
  555. else
  556. {
  557. FVmsServerState = vms_comm_error;
  558. }
  559. break;
  560. }
  561. }
  562. }
  563. int nImgIdx = 8;
  564. if (FVmsServerState == vms_comm_error) nImgIdx = 7;
  565. if (((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbVmsComm]->PanelStyle)->ImageIndex != nImgIdx)
  566. {
  567. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbVmsComm]->PanelStyle)->ImageIndex = nImgIdx;
  568. }
  569. }
  570. //---------------------------------------------------------------------------
  571. void __fastcall TFrmVmsOprMain::UpdateStatusBar()
  572. {
  573. try
  574. {
  575. dxStatusBar->Panels->Items[isbTime]->Text = Now().FormatString(STR_DATETIME);
  576. #if 0
  577. if (ITSDb_IsOpen())
  578. {
  579. if (((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex != 8)
  580. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex = 8;
  581. }
  582. else
  583. {
  584. if (((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex != 7)
  585. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex = 7;
  586. }
  587. #endif
  588. }
  589. catch(...)
  590. {
  591. }
  592. }
  593. //---------------------------------------------------------------------------
  594. void __fastcall TFrmVmsOprMain::DebugMsg(String AMsg)
  595. {
  596. dxStatusBar->Panels->Items[isbMsg]->Text = " " + AMsg;
  597. dxStatusBar->Panels->Items[isbMsg]->StatusBarControl->Refresh();
  598. TmrDebugHide->Enabled = false;
  599. TmrDebugHide->Enabled = true;
  600. LOGINFO(AnsiString(AMsg).c_str());
  601. }
  602. //---------------------------------------------------------------------------
  603. void __fastcall TFrmVmsOprMain::TmrDebugHideTimer(TObject *Sender)
  604. {
  605. dxStatusBar->Panels->Items[isbMsg]->Text = "";
  606. dxStatusBar->Panels->Items[isbMsg]->StatusBarControl->Refresh();
  607. TmrDebugHide->Enabled = false;
  608. }
  609. //---------------------------------------------------------------------------
  610. void __fastcall TFrmVmsOprMain::InitStatusBar()
  611. {
  612. try
  613. {
  614. dxStatusBar->Panels->Items[isbGisPos]->Text = "";
  615. dxStatusBar->Panels->Items[isbTime]->Text = Now().FormatString(STR_DATETIME);
  616. if (g_pLOGIN)
  617. {
  618. dxStatusBar->Panels->Items[isbUser]->Text = g_pLOGIN->sUserId;
  619. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbUser]->PanelStyle)->ImageIndex = 9;
  620. }
  621. dxStatusBar->Panels->Items[isbHint]->Text = "";
  622. dxStatusBar->Panels->Items[isbMsg]->Text = "";
  623. UpdateStatusBar();
  624. }
  625. catch(...)
  626. {
  627. }
  628. }
  629. //---------------------------------------------------------------------------
  630. void __fastcall TFrmVmsOprMain::InitUserMenu()
  631. {
  632. NVMS0100M->Enabled = false; //현시 모니터링
  633. NVMS0200M->Enabled = false; //시나리오 모니터링
  634. NVMS0300M->Enabled = false; //상태 모니터링
  635. NVMS0400M->Enabled = false; //영상 모니터링[R]
  636. NVMS0500M->Enabled = false; //VMS 제어
  637. NVMSM100M->Enabled = false; //기본정보 관리
  638. NVMSM200M->Enabled = false; //정보제공구간 관리
  639. NVMSM210M->Enabled = false; //정보제공구간 설정
  640. NVMSM400M->Enabled = false; //심볼이미지 관리
  641. NVMSM410M->Enabled = false; //소통정보 배경이미지 관리
  642. NVMSM500M->Enabled = false; //VMS 폼관리
  643. NVMSM600M->Enabled = false; //자동 스케줄 관리
  644. NVMSM700M->Enabled = false; //고정 스케줄 관리
  645. NVMSM800M->Enabled = false; //기본 스케줄 관리
  646. RVMSH100M->Enabled = false; //상태 이력조회[R]
  647. RVMSH200M->Enabled = false; //제공 이력조회[R]
  648. RVMSH300M->Enabled = false; //제어 이력조회[R]
  649. }
  650. //---------------------------------------------------------------------------
  651. void __fastcall TFrmVmsOprMain::SetUserMenu(String AMenuId)
  652. {
  653. String sMenuId = "";
  654. if (AMenuId == "MS000000") sMenuId = ""; //VMS관리프로그램 ==> 이거는 기존거 그냥 이용... 메뉴처리 없음
  655. else if (AMenuId == "MS010000") sMenuId = "NVMS0100M"; //, '현시 모니터링'
  656. else if (AMenuId == "MS010100") sMenuId = "NVMS0200M"; //, '시나리오 모니터링'
  657. else if (AMenuId == "MS010101") sMenuId = "NVMS0300M"; //, '상태 모니터링'
  658. else if (AMenuId == "MS010102") sMenuId = "NVMS0400M"; //, '영상 모니터링[R]'
  659. else if (AMenuId == "MS010103") sMenuId = "NVMS0500M"; //, 'VMS 제어'
  660. else if (AMenuId == "MS010104") sMenuId = "NVMSM100M"; //, '기본정보 관리'
  661. else if (AMenuId == "MS010200") sMenuId = "NVMSM200M"; //, '정보제공구간 관리'
  662. else if (AMenuId == "MS010201") sMenuId = "NVMSM210M"; //, '정보제공구간 설정'
  663. else if (AMenuId == "MS010202") sMenuId = "NVMSM400M"; //, '심볼이미지 관리'
  664. else if (AMenuId == "MS010300") sMenuId = "NVMSM410M"; //, '소통정보 배경이미지 관리'
  665. else if (AMenuId == "MS010301") sMenuId = "NVMSM500M"; //, 'VMS 폼관리'
  666. else if (AMenuId == "MS010302") sMenuId = "NVMSM600M"; //, '자동 스케줄 관리'
  667. else if (AMenuId == "MS010303") sMenuId = "NVMSM700M"; //, '고정 스케줄 관리'
  668. else if (AMenuId == "MS020000") sMenuId = "NVMSM800M"; //, '기본 스케줄 관리'
  669. else if (AMenuId == "MS020100") sMenuId = "RVMSH100M"; //, '상태 이력조회[R]'
  670. else if (AMenuId == "MS020101") sMenuId = "RVMSH200M"; //, '제공 이력조회[R]'
  671. else if (AMenuId == "MS020102") sMenuId = "RVMSH300M"; //, '제어 이력조회[R]'
  672. if (sMenuId == "") return;
  673. TdxBarLargeButton *pMenu = (TdxBarLargeButton *)FindComponent(sMenuId);
  674. if (pMenu)
  675. {
  676. pMenu->Enabled = true;
  677. if (sMenuId == "NVMS0500M") g_bControlAuth = false; //VMS제어 화면에 대한 권한이 있으면 다른 제어권한 설정
  678. }
  679. }
  680. //---------------------------------------------------------------------------
  681. bool __fastcall TFrmVmsOprMain::GetUserMenuRight(String AUserId, String AUserRight)
  682. {
  683. //모든 메뉴 비활성화, 디비에 등록된 메뉴 활성화
  684. #if 0
  685. InitUserMenu();
  686. #endif
  687. String sQry;
  688. TADOQuery *pADO = NULL;
  689. try
  690. {
  691. sQry = "SELECT OPERSYST_MENU_ID \r\n"
  692. " FROM TB_GROP_MENU_ATHR \r\n"
  693. " WHERE ATHR_YN = 'N' \r\n"
  694. " AND GROP_ID = (SELECT GROP_ID \r\n"
  695. " FROM TB_USER_INFR \r\n"
  696. " WHERE USER_ID = :p01) \r\n";
  697. try
  698. {
  699. pADO = new TADOQuery(NULL);
  700. pADO->Close();
  701. pADO->Connection = ITSDb_GetConnection();
  702. ITSDb_SQLText(pADO, sQry);
  703. ITSDb_SQLBind(pADO, "p01", AUserRight);
  704. ITSDb_SQLOpen(pADO);
  705. for( ; !pADO->Eof; pADO->Next())
  706. {
  707. String sMenuId = pADO->FieldByName("OPERSYST_MENU_ID")->AsString;
  708. #if 0
  709. SetUserMenu(sMenuId);
  710. #endif
  711. try
  712. {
  713. int nCompnentCnt = this->ComponentCount;
  714. for (int ii = 0; ii < nCompnentCnt; ii++)
  715. {
  716. String sClassName = this->Components[ii]->ClassName();
  717. if(sClassName == "TdxBarLargeButton")
  718. {
  719. TdxBarLargeButton *pMenu = (TdxBarLargeButton *)this->Components[ii];
  720. if (pMenu->Name == sMenuId)
  721. {
  722. pMenu->Enabled = false;
  723. break;
  724. }
  725. }
  726. }
  727. }
  728. catch(...)
  729. {
  730. }
  731. }
  732. }
  733. catch(EDatabaseError &E)
  734. {
  735. DBERRORMSG("TFrmMain::GetUserMenuRight", String(E.ClassName()), E.Message, sQry);
  736. throw Exception(String(E.ClassName()) + E.Message);
  737. }
  738. catch(Exception &e)
  739. {
  740. DBERRORMSG("TFrmMain::GetUserMenuRight", String(e.ClassName()), e.Message, sQry);
  741. throw Exception(String(e.ClassName()) + e.Message);
  742. }
  743. }
  744. __finally
  745. {
  746. if (pADO)
  747. {
  748. pADO->Close();
  749. delete pADO;
  750. }
  751. }
  752. return true;
  753. }
  754. //---------------------------------------------------------------------------
  755. HWND __fastcall TFrmVmsOprMain::FindChildWindow(String sFormName)
  756. {
  757. int nFormCnt = Screen->FormCount;
  758. for (int ii = 0; ii < nFormCnt; ii++)
  759. {
  760. TForm *pForm = Screen->Forms[ii];
  761. String sTmpFormName = pForm->Name.SubString(1, sFormName.Length());
  762. if (sTmpFormName == sFormName)
  763. {
  764. return pForm->Handle;
  765. }
  766. }
  767. return NULL;
  768. }
  769. //---------------------------------------------------------------------------
  770. void __fastcall TFrmVmsOprMain::OnSkinClick(TObject *Sender)
  771. {
  772. TdxBarButton *pMenu = (TdxBarButton*)Sender;
  773. try {
  774. dxSkinController1->SkinName = pMenu->Caption;
  775. dxSkinController1->Refresh();
  776. //ITSSkin_SetName(dxSkinController1->SkinName);
  777. } catch(...) {}
  778. }
  779. //---------------------------------------------------------------------------
  780. void __fastcall TFrmVmsOprMain::TmrPollingTimer(TObject *Sender)
  781. {
  782. TmrPolling->Enabled = false;
  783. DWORD dwTick = GetTickCount();
  784. UpdateThreadStatus(true); //작업스레드 실행 확인
  785. // 프로세스상태정보
  786. if (FPollPrcsState.IsPolling && FPollPrcsState.IsPollingTime(dwTick))
  787. {
  788. FPollPrcsState.Polling = dwTick;
  789. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_PROCESS_STTS);
  790. DebugMsg(">>> Process Status Request");//">>> 프로세스 상태 조회 요청");
  791. }
  792. // VMS상태정보
  793. if (FPollVmsState.IsPolling && FPollVmsState.IsPollingTime(dwTick))
  794. {
  795. FPollVmsState.Polling = dwTick;
  796. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_FACILITY_STTS);
  797. DebugMsg(">>> VMS Status Request");//">>> VMS 상태 조회 요청");
  798. }
  799. // VMS Message
  800. if (FPollVmsMsg.IsPolling && FPollVmsMsg.IsPollingTime(dwTick))
  801. {
  802. FPollVmsMsg.Polling = dwTick;
  803. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_VMS_DSPLMSG);
  804. DebugMsg(">>> VMS Display Message Request");//">>> VMS 표출메시지 조회 요청");
  805. }
  806. // 소통정보
  807. if (FPollTraffic.IsPolling && FPollTraffic.IsPollingTime(dwTick))
  808. {
  809. SetProcessWorkingSetSize(GetCurrentProcess(), -1, -1);
  810. FPollTraffic.Polling = dwTick;
  811. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_TRAFFIC);
  812. DebugMsg(">>> Traffic Request");//">>> 소통정보 조회 요청");
  813. }
  814. // 돌발정보
  815. if (FPollIncident.IsPolling && FPollIncident.IsPollingTime(dwTick))
  816. {
  817. FPollIncident.Polling = dwTick;
  818. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_INCIDENT);
  819. DebugMsg(">>> Incident Request");//">>> 돌발정보 조회 요청");
  820. }
  821. if (!g_AppCfg.bAppClose) TmrPolling->Enabled = true;
  822. }
  823. //---------------------------------------------------------------------------
  824. bool __fastcall TFrmVmsOprMain::PostJobMessage(UINT nMsg, int WParam/*=0*/, int LParam/*=0*/)
  825. {
  826. int nRes;
  827. //if (g_AppCfg.bDebug) ITSUtil_Trace("PostJobMessage: Msg: %02X, WParam: %02X, LParam: %02X", nMsg, WParam, LParam);
  828. if (g_AppCfg.thr.dwThreadId)
  829. {
  830. for (int ii = 0; ii < 3; ii++)
  831. {
  832. if (PostThreadMessageW(g_AppCfg.thr.dwThreadId, nMsg, WParam, LParam))
  833. {
  834. nRes = 0;
  835. return true;
  836. }
  837. else
  838. {
  839. nRes = GetLastError();
  840. if (ERROR_INVALID_THREAD_ID == nRes)
  841. {
  842. Sleep(500);
  843. continue;
  844. }
  845. }
  846. }
  847. }
  848. return false;
  849. }
  850. //---------------------------------------------------------------------------
  851. void __fastcall TFrmVmsOprMain::dxSkinChooserGalleryItem1SkinChanged(TObject *Sender, const UnicodeString ASkinName)
  852. {
  853. g_AppCfg.sSkinName = ASkinName;
  854. WriteConfigInfo(g_AppCfg.sConfigFile, "APPLICATION", "SKINNAME", g_AppCfg.sSkinName);
  855. SetColorScheme(ASkinName);
  856. }
  857. //---------------------------------------------------------------------------
  858. void __fastcall TFrmVmsOprMain::SetColorScheme(String ASkinName)
  859. {
  860. Ribbon->ColorSchemeName = ASkinName;
  861. dxSkinController1->SkinName = ASkinName;
  862. dxSkinController1->Refresh();
  863. dxTabbedMDIManager1->LookAndFeel->SkinName = ASkinName;
  864. dxStatusBar->Invalidate();
  865. //Panel1->Color = Ribbon->ColorScheme->GetPartColor(rfspRibbonForm);
  866. //Ribbon.ColorSchemeName := AName;
  867. //SkinChooserSelectSkinName(AName);
  868. //Panel1.Color := Ribbon.ColorScheme.GetPartColor(rfspRibbonForm);
  869. //dxStatusBar.Invalidate;
  870. }
  871. //---------------------------------------------------------------------------
  872. void __fastcall TFrmVmsOprMain::ExecuteItsProgram(String AClassName, String AExeName, String AOption)
  873. {
  874. HWND hExeForm = FindWindow(AClassName.c_str(), NULL);
  875. if (hExeForm)
  876. {
  877. SetWindowPos(hExeForm, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
  878. }
  879. else
  880. {
  881. String sExeName = "";
  882. String sExeParam= "";
  883. //if (!ReadConfigInfo(g_AppCfg.sConfigFile, "PROGRAM", AOption, sExeName))
  884. {
  885. sExeName = AExeName;
  886. sExeParam= g_pLOGIN->sUserId;
  887. }
  888. ShellExecute(Handle, NULL, sExeName.c_str(), sExeParam.c_str(), NULL, SW_SHOWNORMAL);
  889. }
  890. }
  891. //---------------------------------------------------------------------------
  892. void __fastcall TFrmVmsOprMain::TermItsProgram(String AClassName, String AExeName)
  893. {
  894. HWND hExeForm = FindWindow(AClassName.c_str(), NULL);
  895. if (hExeForm)
  896. {
  897. POST_MSG(hExeForm, WM_CLOSE, 0, 0);
  898. }
  899. }
  900. //---------------------------------------------------------------------------
  901. void __fastcall TFrmVmsOprMain::OnRunProgramClick(TObject *Sender)
  902. {
  903. TdxBarLargeButton *pButton = (TdxBarLargeButton*)Sender;
  904. int nIdx = pButton->Tag;
  905. if (nIdx < 0 || nIdx >= MAX_EXEPROGRAM) return;
  906. if (g_RunProgram[nIdx].AClassName == "") return;
  907. ExecuteItsProgram(g_RunProgram[nIdx].AClassName, g_RunProgram[nIdx].AExeName, g_RunProgram[nIdx].AOption);
  908. }
  909. //---------------------------------------------------------------------------
  910. void __fastcall TFrmVmsOprMain::OnAppHint(TObject *Sender)
  911. {
  912. dxStatusBar->Panels->Items[isbHint]->Text = " " + Application->Hint;
  913. dxStatusBar->Panels->Items[isbHint]->StatusBarControl->Refresh();
  914. }
  915. //---------------------------------------------------------------------------
  916. void __fastcall TFrmVmsOprMain::OnAppException(TObject *Sender, Exception *exception)
  917. {
  918. if (g_AppCfg.bDebug) ITSUtil_Trace("OnAppException");
  919. String sClassName = (NULL != Sender) ? Sender->ClassName() : String("Unknown_Class");
  920. String sErrMsg = (NULL != exception) ? exception->Message : String("Unknown_Error");
  921. String sError = sClassName + " : " + sErrMsg;
  922. //Application->ShowException(&exception);
  923. Application->NormalizeTopMosts();
  924. Application->MessageBox(sError.c_str(), L"System Error", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  925. Application->RestoreTopMosts();
  926. }
  927. //---------------------------------------------------------------------------
  928. void __fastcall TFrmVmsOprMain::UpdateThreadStatus(bool ARequest, bool APing/*=true*/)
  929. {
  930. return;
  931. try
  932. {
  933. if (APing) if (ARequest) PostJobMessage(WM_THREAD, WP_PING);
  934. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbStatus]->PanelStyle)->ImageIndex = ARequest ? 7 : 8;
  935. dxStatusBar->Panels->Items[isbDb]->StatusBarControl->Refresh();
  936. }
  937. catch(...)
  938. {
  939. }
  940. }
  941. //---------------------------------------------------------------------------
  942. void __fastcall TFrmVmsOprMain::UpdateDbStatus(bool ASelect)
  943. {
  944. try
  945. {
  946. ((TdxStatusBarTextPanelStyle*)dxStatusBar->Panels->Items[isbDb]->PanelStyle)->ImageIndex = ASelect ? 7 : 8;
  947. dxStatusBar->Panels->Items[isbDb]->StatusBarControl->Refresh();
  948. }
  949. catch(...)
  950. {
  951. }
  952. }
  953. //---------------------------------------------------------------------------
  954. void __fastcall TFrmVmsOprMain::ApplicationEvents1Message(tagMSG &Msg, bool &Handled)
  955. {
  956. switch(Msg.message)
  957. {
  958. case WM_THREAD:
  959. switch(Msg.wParam)
  960. {
  961. case WP_PING:
  962. UpdateThreadStatus(false); //스레드 핑 확인
  963. break;
  964. case WP_PARAM_TRAFFIC:
  965. break;
  966. case WP_DB_SELECT_START:
  967. UpdateDbStatus(true);
  968. break;
  969. case WP_DB_SELECT_OK:
  970. case WP_DB_SELECT_ERROR:
  971. case WP_DB_SELECT_CANCEL:
  972. UpdateDbStatus(false);
  973. if (Msg.wParam == WP_DB_SELECT_OK)
  974. {
  975. OnRefreshMessage(Msg.wParam, Msg.lParam);
  976. }
  977. break;
  978. }
  979. break;
  980. case WM_DATABASE_REFRESH:
  981. OnDatabaseMessage(Msg.wParam, Msg.lParam);
  982. break;
  983. case WM_PLUGINFORM:
  984. OnRefreshMessage(Msg.wParam, Msg.lParam);
  985. break;
  986. case WM_MOUSEMOVE:
  987. FLogoutTick = 0;
  988. break;
  989. case WM_KEYDOWN:
  990. FLogoutTick = 0;
  991. if (Msg.wParam == VK_F5)
  992. {
  993. NTST0100MClick((TObject*)NTST0100M);
  994. // Handled = true;
  995. }
  996. break;
  997. case WM_KEYUP:
  998. FLogoutTick = 0;
  999. break;
  1000. }
  1001. }
  1002. //---------------------------------------------------------------------------
  1003. void __fastcall TFrmVmsOprMain::OnRefreshMessage(WPARAM AWParam, LPARAM ALParam)
  1004. {
  1005. HWND hWnd;
  1006. // 폴링 스레드에서 데이터작업 완료 메시지 처리
  1007. if (AWParam == WP_DB_SELECT_OK)
  1008. {
  1009. DWORD dwTick = GetTickCount();
  1010. switch(ALParam)
  1011. {
  1012. case LP_MSG_PROCESS_STTS: DebugMsg("<<< Process Status Request Completed."/*"<<< 프로세스 상태 조회 완료"*/); FPollPrcsState.Polling = dwTick; break;
  1013. case LP_MSG_FACILITY_STTS: DebugMsg("<<< VMS Status Request Completed."/*"<<< VMS 상태 조회 완료"*/); FPollVmsState.Polling = dwTick; break;
  1014. case LP_MSG_VMS_DSPLMSG: DebugMsg("<<< VMS Display Message Request Completed."/*"<<< VMS 표출메시지 조회 완료"*/); FPollVmsMsg.Polling = dwTick; break;
  1015. case LP_MSG_TRAFFIC: DebugMsg("<<< Traffic Request Completed."/*"<<< 소통정보 조회 완료"*/); FPollTraffic.Polling = dwTick; break;
  1016. case LP_MSG_INCIDENT: DebugMsg("<<< Incident Request Completed."/*"<<< 돌발정보 조회 완료"*/); FPollIncident.Polling = dwTick; break;
  1017. }
  1018. if (ALParam == LP_MSG_PROCESS_STTS)
  1019. {
  1020. UpdateVmsCommStatus(true);
  1021. }
  1022. else
  1023. if (ALParam == LP_MSG_VMS_DSPLMSG)
  1024. {
  1025. RefreshVmsMessage(WM_VMS_FORM_REFRESH);
  1026. }
  1027. else
  1028. if (ALParam == LP_MSG_INCIDENT)
  1029. {
  1030. RefreshVmsMessage(WM_VMS_INCIDENT_REFRESH);
  1031. }
  1032. else
  1033. {
  1034. RefreshVmsMessage(WM_VMS_STATE_REFRESH);
  1035. if (NTST0100M->Enabled == false)
  1036. {
  1037. NTST0100M->Enabled = true;
  1038. }
  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::NTST0100MClick(TObject *Sender)
  1725. {
  1726. if (NTST0100M->Enabled == false)
  1727. {
  1728. return;
  1729. }
  1730. NTST0100M->Enabled = false;
  1731. DWORD dwTick = GetTickCount();
  1732. UpdateThreadStatus(true); //작업스레드 실행 확인
  1733. // 프로세스상태정보
  1734. if (FPollPrcsState.IsPolling)
  1735. {
  1736. FPollPrcsState.Polling = dwTick;
  1737. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_PROCESS_STTS);
  1738. DebugMsg(">>> Process Status Request");//">>> 프로세스 상태 조회 요청");
  1739. }
  1740. // VMS상태정보
  1741. if (FPollVmsState.IsPolling)
  1742. {
  1743. FPollVmsState.Polling = dwTick;
  1744. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_FACILITY_STTS);
  1745. DebugMsg(">>> VMS Status Request");//">>> VMS 상태 조회 요청");
  1746. }
  1747. // VMS Message
  1748. if (FPollVmsMsg.IsPolling)
  1749. {
  1750. FPollVmsMsg.Polling = dwTick;
  1751. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_VMS_DSPLMSG);
  1752. DebugMsg(">>> VMS Display Message Request");//">>> VMS 표출메시지 조회 요청");
  1753. }
  1754. // 소통정보
  1755. if (FPollTraffic.IsPolling)
  1756. {
  1757. SetProcessWorkingSetSize(GetCurrentProcess(), -1, -1);
  1758. FPollTraffic.Polling = dwTick;
  1759. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_TRAFFIC);
  1760. DebugMsg(">>> Traffic Request");//">>> 소통정보 조회 요청");
  1761. }
  1762. // 돌발정보
  1763. if (FPollIncident.IsPolling)
  1764. {
  1765. FPollIncident.Polling = dwTick;
  1766. PostJobMessage(WM_THREAD, WP_PARAM_TRAFFIC, LP_MSG_INCIDENT);
  1767. DebugMsg(">>> Incident Request");//">>> 돌발정보 조회 요청");
  1768. }
  1769. }
  1770. //---------------------------------------------------------------------------