0a9d448a464080189e3b5e346b0d44f24851891d.svn-base 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using Microsoft.Win32;
  9. using System.Net;
  10. using System.Diagnostics;
  11. using System.IO;
  12. using System.Collections;
  13. using System.Threading;
  14. using System.Media;
  15. // cyim 2015.7.29 수신반 모드
  16. // 수신반의 경우의 환경설정은 아래와 같다
  17. // 수신기와 마찬가지로 레지스트리를 읽어서 현재 DB 정보를 읽도록 한다. ini 파일에 의해 수신반이 될지, 수신기가 될지 결정된다.
  18. // 동작 기본 : 기존과 동일하게 레지스트리값을 읽어 DB 를 읽고, 이 DB 는 수신기의 아이디 리스트 및 기본 디바이스 설정 정보를 가져오기 위한 용도로만 사용한다
  19. // 주의해야 될 점은 소스측면에서는 수신반의 레지스트리에서 지정된 경로로 데이타베이스에 접속할때는 수신기 아이디가 0 으로 조회를 하게 된다,
  20. // 실제 데이타베이스에 조회하는 경우가 있을때는 각 수신기의 실제 DB 에 접속하여 접속하여 사용한다. 데몬을 통하는 것은 카운터, 이벤트 정보뿐이다.
  21. // 다만, DB 백업 및 기타 동작은 무시해도 된다. 수신반은 모니터링이 주 목적이다.
  22. // 수신기별 프로젝트 및 DB 파일 위치 : 각각 아이디별로 틀리다. DB 경로와 프로젝트 파일이 동일한 파일을 각각 폴더에 셋팅해두도록 한다 (Config.ini 을 참고해야됨)
  23. // 프로그램 모드 : Config.ini 파일에 mode 가 1로 되어 있으면 수신반, ini 파일이 없다면 기본으로 수신기 프로그램으로 동작된다
  24. // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  25. // 수신반을 위한 Static 클래스 정리
  26. // -> Static 을 허용하는 것은 오직 _Data.cs 와 _Ini.cs _Timer.cs_Data.cs 와 _Ini.cs _Timer.cs
  27. // 기존코드를 많이 수정하였다. 이는 결국 MdiParent 클래스를 독립적으로 관리하게 수정하는 것을 최종 목표로한다
  28. // cyim 2015.9.15 수신반 1차 버전 완료 : 2.0.1.0
  29. // 수신기 상태 및 제어 기능
  30. // 카운터 통합 모니터링 기능
  31. // 개별 수신기 복구
  32. // 통합 현재 이벤트 표시 기능
  33. // 통합 과거 내역 조회 기능
  34. // cyim 2015.9.30 수신반은 ini 파일을 이용해서 데이타베이스 접속 : 2.0.1.1
  35. namespace FPER
  36. {
  37. public partial class FireDesk : Form
  38. {
  39. // 임시 아이디 리스트를 만들어서 폼을 load 완료하면 리스트에서 삭제하도록 하여 전체 폼을 다 미리 로드한다
  40. public ArrayList LoadMdiparentFormList = new ArrayList();
  41. // 폼을 로드한것이 진행중이라면 수신반 메인폼에서 계속 폼을 생성하지 못하게 한다
  42. public bool FormLoadComplete = false;
  43. // 수신기폼을 로드시에 기다리는 팝업창을 생성
  44. public frmWaitingMsg waitingForm_FireDesk = null; // cyim 2015.8.3 검토해본 결과 기존의 팝업창을 그대로 사용하도록 한다
  45. // cyim 2015.8.4 수신반을 위한 static 클래스 정리 : 타이머
  46. public _Timer_WindowBase Timer_WindowBase_FireDesk = new _Timer_WindowBase();
  47. // cyim 2015.8.4 수신반을 위한 static 클래스 정리 : 이벤트
  48. public _Event Event = new _Event();
  49. // cyim 2015.9.1 1개의 수신기가 접속이 안되더라도 나머지는 접속시도할수 있도록 수정
  50. public ArrayList CommErrorReceiver = new ArrayList();
  51. // cyim 2015.9.15 수신반 하단 이벤트 표시
  52. // 카운터 표시 (통합 카운터이다. 즉 모든 수신기의 카운터의 합이다)
  53. //
  54. // 아래의 변수 정보는 수신기로 부터 직접 전달받은 카운터를 합 한것이고, 일정 시간마다 갱신된다
  55. public int fireCount = 0, facilityCount = 0, errorCount = 0, blockingCount = 0, cutCnt = 0;
  56. public int fireCount_Accumulation = 0;
  57. // 아래의 리스트 정보는 각각 수신기의 이벤트가 발생할때마다 갱신된다
  58. public ArrayList PreFireList = new ArrayList();
  59. public ArrayList FireList = new ArrayList();
  60. public ArrayList FireList_Accumulation = new ArrayList();
  61. public ArrayList EquipList = new ArrayList();
  62. // 상태 라벨 카운트 (미사용)
  63. public int LEDCount = 0;
  64. public ArrayList LEDList = new ArrayList();
  65. // cyim 2015.9.23 시간정보 표시 오류 (갱신을 안함)
  66. public string MyTime = null;
  67. // cyim 2016.06.15 : 화재 음원 출력
  68. //public SoundPlayer SoundPlayer_AlarmPopupSound = new SoundPlayer(Properties.Resources.emergency);
  69. public SoundPlayer SoundPlayer_AlarmPopupSound = null;
  70. public int SoundPlayer_AlarmPopupSound_Count = 0;
  71. // 생성자
  72. public FireDesk()
  73. {
  74. InitializeComponent();
  75. // cyim 2016.11.11 : 비상 음원 출력 음원 파일 없을때 대응 코드 추가
  76. if (File.Exists(Environment.CurrentDirectory + "\\emergency.wav") == true)
  77. SoundPlayer_AlarmPopupSound = new SoundPlayer(Environment.CurrentDirectory + "\\emergency.wav");// cyim 2016.06.24 : 음원 출력시 교체 가능
  78. // 이벤트
  79. this.FormClosing += new FormClosingEventHandler(FireDesk_FormClosing);
  80. this.Load += new EventHandler(FireDesk_Load);
  81. Event.FireDesk_Update_SendMessage_Event += new _Event.FireDesk_Update_SendMessage_Handler(_Event_FireDesk_Update_SendMessage_Event); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  82. // UI
  83. for (int id = 1; id <= 16; id++)
  84. {
  85. // 수신기 버튼
  86. Button button_Receiver = (Button)Util.FineControl(panel_Middle, "button_Receiver" + id.ToString());
  87. button_Receiver.Tag = id.ToString();
  88. button_Receiver.Click += new EventHandler(button_Receiver_Click);
  89. // 수신기 복구 버튼
  90. Button button_Recover = (Button)Util.FineControl(panel_Middle, "button_Recover" + id.ToString());
  91. button_Recover.Tag = id.ToString();
  92. button_Recover.Click += new EventHandler(button_Recover_Click);
  93. }
  94. // cyim 2015.8.4 수신반을 위한 static 클래스 정리 ; 타이머
  95. Timer_WindowBase_FireDesk.Create("timer_1000", 1000, timer_1000_Tick, true);
  96. Timer_WindowBase_FireDesk.Create("timer_500", 500, timer_500_Tick, true);
  97. }
  98. // 소멸자
  99. private void FireDesk_FormClosing(object sender, FormClosingEventArgs e)
  100. {
  101. // 타이머
  102. Timer_WindowBase_FireDesk.Delete("timerDateTime"); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  103. //
  104. // cyim 2016.11.11 : 수신반 프로세스 종료 코드 추가
  105. //
  106. // 스레드 종료
  107. Application.ExitThread();
  108. for (int i = 0; i < 1000000; i++) { ;}
  109. // 프로세스 종료
  110. Application.Exit();
  111. // 프로세스가 남아있다면 최종 종료
  112. System.Diagnostics.Process[] mProcess = System.Diagnostics.Process.GetProcessesByName(Application.ProductName);
  113. foreach (System.Diagnostics.Process p in mProcess)
  114. p.Kill();
  115. // 최종 정리 (보완코드 : 크로스 스레드 문제 발생 여지가 있으므로 사용주의)
  116. Environment.Exit(0);
  117. }
  118. //
  119. // 초기화
  120. //
  121. private void FireDesk_Load(object sender, EventArgs e)
  122. {
  123. // cyim 2015.7.31 수신반 팝업창은 별도로 존재
  124. ShowWaitingMsgForm("수신반을 시작합니다", 10);
  125. // cyim
  126. // 해당 DB 를 읽고 어떤 IP 에 어떤 수신기 ID 가 맵핑되어있는지 알아야한다
  127. // 수신기에 원격으로 데몬이 붙어서 동작할수 있다.
  128. // 맨처음 가동단계는 현재 DB 를 읽어서 수신반 구동을 시작한다
  129. // 현재 데이타베이스를 읽고 현재 설정된 수신기가 어떤 아이디들로 구성되어 있는지 알아야 한다
  130. // 데이타베이스를 토대로 각각 수신기 정보를 알아야 되며, 레지스트리 값을 읽어서 쓰는 루틴은 그대로 이용하되,
  131. // 레지스트리 값중에 프로젝트 경로는 각 수신기별로 정보를 가지고 있도록 해야한다
  132. // 수신반의 경우 중계기, 보드 정보, 수신기 설정값을 알필요가 없다. (물론 각 수신기에 접속하면 알수가 있지만 평상시에는 알 필요가 없다)
  133. // 수신기 아이디 해쉬 테이블 초기화 - Config.ini 기반
  134. Initialize_Hash_Receiver(_Data.Hash_Receiver);
  135. // 수신기 아이디 키 배열 생성
  136. _Data.Hash_Receiver_keys = new string[_Data.Hash_Receiver.Keys.Count];
  137. _Data.Hash_Receiver.Keys.CopyTo(_Data.Hash_Receiver_keys, 0);
  138. // 수신기 아이디 해쉬 테이블 셋팅 - DB 기반
  139. foreach (string id in _Data.Hash_Receiver_keys)
  140. {
  141. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[id];
  142. // 특별처리 : 데이타베이스를 접근해야되는데 어차피 TB_CONFIG 테이블은 유일하게 수신반DB 에 사용되므로
  143. // 수신반 DB를 이용하도록 한다. 수신반 DB 를 접근하려면 아이디가 0으로 되어있으면 수신반 DB 이다.
  144. // 경로는 레지스트리 값 경로를 이용하면 된다
  145. DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(0);
  146. DataTable dt = dacReceiverConfig.Config_Select(0);
  147. // 마스터 모드
  148. foreach (DataRow dr in dt.Rows)
  149. {
  150. if (id == dr["RECEIVER_ID"].ToString())
  151. {
  152. FireDesk_Receiver.MASTER_FLAG = dr["MASTER_FLAG"].ToString();//dt.Rows[0]["MASTER_FLAG"].ToString();
  153. break;
  154. }
  155. }
  156. }
  157. // cyim 2015.9.11 : 과거내역 통합조회창에서 사용할 DB 에서 미리 읽은값을 사용하도록 수정함
  158. // 공통정보를 데이타베이스에서 불러온다
  159. ShowWaitingMsgForm("수신기 디바이스 DB를 읽고 있습니다..", 20);
  160. this.GetDeviceDB();
  161. ShowWaitingMsgForm("수신기 중계기 DB를 읽고 있습니다..", 30);
  162. this.GetRepeaterDB();
  163. //AnalogDetect.Get_TB_DAYTIME(0); // 수신반은 필요없다
  164. this.GetAnalogDetecterLevelDB();
  165. ShowWaitingMsgForm("수신기 통신 보드 설정을 읽고 있습니다..", 40);
  166. this.GetBoardDB();
  167. ShowWaitingMsgForm("수신기 기본 설정값을 읽고 있습니다..", 50);
  168. //
  169. // UI
  170. //
  171. // 불필요한 수신기는 정리한다
  172. for (int id = 1; id <= 16; id++)
  173. {
  174. // 사용하지 않는 수신기
  175. if (_Data.Hash_Receiver.ContainsKey(id.ToString()) == false)
  176. {
  177. Panel p = (Panel)Util.FineControl(panel_Middle, "panel_Receiver" + id.ToString());
  178. p.Enabled = false;
  179. p.ForeColor = Color.Gray;
  180. }
  181. else
  182. {
  183. //
  184. // 사용중인 수신기
  185. //
  186. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[id.ToString()];
  187. // cyim 2015.9.1 1개의 수신기가 접속이 안되더라도 나머지는 접속시도할수 있도록 수정
  188. if (_Ethernet.Ping_SyncCheck(FireDesk_Receiver.DATABASE_NAME_IP) == true)
  189. {
  190. // 클래스를 생성한다, 단 Load, 즉 Show 는 하지 않는다
  191. FireDesk_Receiver.mdi = new MDIParent(id, Event); // cyim 2015.8.4 수신반을 위한 static 클래스 정리
  192. // 어레이리스트의 경우 int 값을 키로 하면 오류가 발생할 여지가 있다.
  193. LoadMdiparentFormList.Add(id.ToString());
  194. }
  195. else
  196. {
  197. Panel p = (Panel)Util.FineControl(panel_Middle, "panel_Receiver" + id.ToString());
  198. p.Enabled = false;
  199. p.BackColor = Color.Red;
  200. CommErrorReceiver.Add(id.ToString());
  201. }
  202. }
  203. }
  204. // cyim 2015.9.1 1개의 수신기가 접속이 안되더라도 나머지는 접속시도할수 있도록 수정 : 활성화된 수신기를 개수를 표시한다
  205. if(CommErrorReceiver.Count != 0)
  206. label_ReceiverCount.Text = string.Format("전체 수신기 대수 : {0} 개 , 통신 불량 수신기 아이디 : {1}", _Data.Hash_Receiver.Keys.Count, _Convert.ArrayList_to_String(CommErrorReceiver,","));
  207. else
  208. label_ReceiverCount.Text = string.Format("전체 수신기 대수 : {0} 개", _Data.Hash_Receiver.Keys.Count);
  209. // 클래스를 미리 업로드 시킨다. 단, 팝업창을 포함해서 모두 숨긴채로 로드한다
  210. while (true)
  211. {
  212. foreach (string id in _Data.Hash_Receiver_keys)
  213. {
  214. // 해쉬테이블에서 폼로드 진행을 변수에 저장
  215. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[id];
  216. // cyim 2015.9.1 1개의 수신기가 접속이 안되더라도 나머지는 접속시도할수 있도록 수정
  217. if (_Ethernet.Ping_SyncCheck(FireDesk_Receiver.DATABASE_NAME_IP) == true)
  218. {
  219. if (FireDesk_Receiver.LoadStart == false && FormLoadComplete == false)
  220. {
  221. FormLoadComplete = true; // 하단의 mdi.show 함수에서 딜레이가 심하다. 코드 위치를 변경하면 안된다
  222. FireDesk_Receiver.LoadStart = true;
  223. FireDesk_Receiver.mdi.Show(); // 실제로 수신기 메인폼을 올리는 주체는 여기다
  224. }
  225. }
  226. }
  227. if (LoadMdiparentFormList.Count == 0)
  228. break;
  229. }
  230. // cyim 2015.7.31 수신반 팝업창은 별도로 존재 : 문구 출력 이후에 종료
  231. ShowWaitingMsgForm("수신반을 시작합니다", 100);
  232. Thread.Sleep(2000);
  233. waitingForm_FireDesk.Close();
  234. waitingForm_FireDesk = null;
  235. }
  236. //
  237. // 수신반 클래스 초기화
  238. //
  239. private void Initialize_Hash_Receiver(Hashtable hashtable)
  240. {
  241. hashtable.Clear();
  242. for (int i = 1; i <= 16; i++)
  243. {
  244. // USE 값이 1인 경우에만 읽도록 한다
  245. string use = _Ini.Read_Ini("RECEIVER"+i.ToString(), "USE", 1024, Environment.CurrentDirectory + "\\Config.ini");
  246. if (use == "1")
  247. {
  248. // 수신반 클래스
  249. _FireDesk_Receiver firedesk_receiver = new _FireDesk_Receiver();
  250. // 아이디
  251. firedesk_receiver.RECEIVER_ID = i.ToString();
  252. string Temp_DATABASE_NAME = _Ini.Read_Ini("RECEIVER" + i.ToString(), "DATABASE_NAME", 1024, Environment.CurrentDirectory + "\\Config.ini");
  253. // IP + PATH
  254. firedesk_receiver.DATABASE_NAME = Temp_DATABASE_NAME;
  255. // IP
  256. firedesk_receiver.DATABASE_NAME_IP = Temp_DATABASE_NAME.Substring(0, Temp_DATABASE_NAME.IndexOf(":"));
  257. // PATH
  258. firedesk_receiver.DATABASE_NAME_PATH = Temp_DATABASE_NAME.Substring(Temp_DATABASE_NAME.IndexOf(":") + 1);
  259. string Temp_PROJECT_DIR = _Ini.Read_Ini("RECEIVER" + i.ToString(), "PROJECT_DIR", 1024, Environment.CurrentDirectory + "\\Config.ini");
  260. // 프로젝트 경로
  261. firedesk_receiver.PROJECT_DIRECTORY = Temp_PROJECT_DIR;
  262. // 해쉬에 추가
  263. if (hashtable.ContainsKey(firedesk_receiver.RECEIVER_ID) == false)
  264. hashtable.Add(firedesk_receiver.RECEIVER_ID, firedesk_receiver);
  265. }
  266. }
  267. }
  268. //
  269. // 팝업창
  270. //
  271. // cyim 2015.7.31 수신반 팝업창은 별도로 존재
  272. //
  273. delegate void WaitingMsg_Callback(string msg, int processValue);
  274. public void ShowWaitingMsgForm(string msg, int processValue)
  275. {
  276. if (this.InvokeRequired)
  277. {
  278. WaitingMsg_Callback d = new WaitingMsg_Callback(ShowWaitingMsgForm);
  279. this.Invoke(d, new object[] { msg, processValue });
  280. }
  281. else
  282. {
  283. if (this.waitingForm_FireDesk == null)
  284. {
  285. // cyim 2015.8.3 검토해본 결과 기존의 팝업창을 그대로 사용하도록 한다
  286. // 다만 수신기별로 각각 팝업창이 계속 표시가 되면 될것같음. 즉 같은 팝업창의 진행도가 0~100 ->0~100 을 자동반복함
  287. this.waitingForm_FireDesk = new frmWaitingMsg();
  288. this.waitingForm_FireDesk.Text = Application.ProductName;
  289. this.waitingForm_FireDesk.TopMost = true;
  290. Point loc = new Point(
  291. (1280 - this.waitingForm_FireDesk.Size.Width) / 2 + this.Location.X,
  292. (1024 - this.waitingForm_FireDesk.Size.Height) / 2 + this.Location.Y
  293. );
  294. this.waitingForm_FireDesk.Location = loc;
  295. this.waitingForm_FireDesk.Show();
  296. }
  297. this.waitingForm_FireDesk.setMessage(msg, processValue);
  298. this.Update();
  299. }
  300. }
  301. //
  302. // 타이머
  303. //
  304. // 1000 ms 타이머
  305. int timer_1000_Tick_Cnt = 0;
  306. private void timer_1000_Tick(object sende, EventArgs e)
  307. {
  308. // cyim 2015.9.23 시간정보 표시 오류 (갱신을 안함)
  309. MyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  310. // 초기화 팝업창때는 실행안됨
  311. if (waitingForm_FireDesk != null && waitingForm_FireDesk.Visible == true) return;
  312. // 현재 상태 갱신 : 시간표시
  313. this.label_Time.Text = string.Format("{0:yyyy}년 {0:MM}월 {0:dd}일 {0:HH}:{0:mm}:{0:ss}", DateTime.Now);
  314. // cyim 2015.9.15 주기적으로 수신기 통신상태를 점검 : 10 초에 한번 수신기 통신상태를 점검해본다
  315. if (timer_1000_Tick_Cnt > 10)
  316. timer_1000_Tick_Cnt = 0;
  317. else
  318. timer_1000_Tick_Cnt++;
  319. if (timer_1000_Tick_Cnt == 0)
  320. {
  321. foreach (string id in _Data.Hash_Receiver_keys)
  322. {
  323. // 해쉬테이블에서 폼로드 진행을 변수에 저장
  324. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[id];
  325. if (_Ethernet.Ping_SyncCheck(FireDesk_Receiver.DATABASE_NAME_IP) == false) // cyim 2015.9.1 1개의 수신기가 접속이 안되더라도 나머지는 접속시도할수 있도록 수정
  326. {
  327. FireDesk_Receiver.LoadStart = false;
  328. FireDesk_Receiver.mdi.Close(); // 통신이 안되면 종료시켜버린다.
  329. }
  330. else // 통신이 잘되는 경우 기존에 사용되지 않은 경우
  331. {
  332. if (FireDesk_Receiver.LoadStart == false && FormLoadComplete == false)
  333. {
  334. FormLoadComplete = true; // 하단의 mdi.show 함수에서 딜레이가 심하다. 코드 위치를 변경하면 안된다
  335. FireDesk_Receiver.LoadStart = true;
  336. FireDesk_Receiver.mdi.Show(); // 실제로 수신기 메인폼을 올리는 주체는 여기다
  337. }
  338. }
  339. }
  340. }
  341. }
  342. // 알람 상태 표시
  343. bool timer_500_toggle = false;
  344. // 500 ms 타이머
  345. private void timer_500_Tick(object sende, EventArgs e)
  346. {
  347. // 초기화 팝업창때는 실행안됨
  348. if (waitingForm_FireDesk != null && waitingForm_FireDesk.Visible == true) return;
  349. // 토글용
  350. timer_500_toggle = !timer_500_toggle;
  351. //
  352. // 전체현황 카운터 표시
  353. //
  354. fireCount = 0;
  355. facilityCount = 0;
  356. errorCount = 0;
  357. blockingCount = 0;
  358. cutCnt = 0;
  359. fireCount_Accumulation = 0;
  360. PreFireList = new ArrayList();
  361. foreach (string id in _Data.Hash_Receiver_keys)
  362. {
  363. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[id];
  364. // cyim 2015.9.1 1개의 수신기가 접속이 안되더라도 나머지는 접속시도할수 있도록 수정
  365. if (FireDesk_Receiver.mdi != null)
  366. {
  367. // 화재
  368. fireCount = fireCount + FireDesk_Receiver.mdi.fireCount;
  369. // 설비
  370. facilityCount = facilityCount + FireDesk_Receiver.mdi.facilityCount;
  371. // 통신
  372. errorCount = errorCount + FireDesk_Receiver.mdi.errorCount;
  373. // 단선
  374. blockingCount = blockingCount + FireDesk_Receiver.mdi.blockingCount;
  375. // 차단
  376. cutCnt = cutCnt + FireDesk_Receiver.mdi.CutCnt;
  377. // 축적화재
  378. fireCount_Accumulation = fireCount_Accumulation + FireDesk_Receiver.mdi.fireCount_Accumulation;
  379. // 아날로그감지기의 PreFire
  380. foreach (string data in FireDesk_Receiver.mdi.PreFireList)
  381. PreFireList.Add(data);
  382. }
  383. }
  384. // 전체 현황의 경우 카운터가 0이상이면 깜빡거리게 만든다
  385. Toggle_ControlForeColor(this.label_CurrentStatus_Fire, fireCount, string.Format("화재({0})", fireCount));
  386. Toggle_ControlForeColor(this.label_CurrentStatus_Facility, facilityCount, string.Format("설비({0})", facilityCount));
  387. Toggle_ControlForeColor(this.label_CurrentStatus_Error, errorCount, string.Format("통신({0})", errorCount));
  388. Toggle_ControlForeColor(this.label_CurrentStatus_Blocking, blockingCount, string.Format("단선({0})", blockingCount));
  389. Toggle_ControlForeColor(this.label_CurrentStatus_Cut, cutCnt, string.Format("차단({0})", cutCnt));
  390. //
  391. // 점검 표시
  392. //
  393. foreach (string id in _Data.Hash_Receiver_keys)
  394. {
  395. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[id];
  396. Button btn = (Button)Util.FineControl(panel_Middle, "button_Check" + id.ToString());
  397. // cyim 2015.9.1 1개의 수신기가 접속이 안되더라도 나머지는 접속시도할수 있도록 수정
  398. if (FireDesk_Receiver.mdi != null)
  399. {
  400. // 점검
  401. if (FireDesk_Receiver.mdi.CheckBtn_Current_Status == true
  402. || FireDesk_Receiver.mdi.lblEmergencyBoardStatus_Visible == true // 비상방송연결이상
  403. || FireDesk_Receiver.mdi.socketUI.myCntLabel.Visible == true) // 통신데몬연결이상
  404. {
  405. Toggle_ControlBackColor(btn, 1, null);
  406. }
  407. else
  408. Toggle_ControlBackColor(btn, 0, null);
  409. }
  410. }
  411. // cyim 2015.9.15 수신반 하단 이벤트 표시 : 화재 및 설비 표시
  412. FireFacilityEventCheck();
  413. // cyim 2016.06.15 : 화재 음원 출력
  414. if (SoundPlayer_AlarmPopupSound_Count > 6)
  415. {
  416. SoundPlayer_AlarmPopupSound_Count = 0; // 3초마다
  417. AlarmPopup_PlaySound_Check();
  418. }
  419. else
  420. {
  421. SoundPlayer_AlarmPopupSound_Count++;
  422. }
  423. }
  424. // cyim 2016.06.15 : 화재 음원 출력
  425. public void AlarmPopup_PlaySound_Check()
  426. {
  427. if (SoundPlayer_AlarmPopupSound != null) // cyim 2016.11.11 : 비상 음원 출력 음원 파일 없을때 대응 코드 추가
  428. {
  429. if (this.label_FireAlert.Visible == true || this.label_FacilityAlert.Visible == true) // cyim 2016.06.16 : 설비동작 발생시 음원 출력 포함
  430. SoundPlayer_AlarmPopupSound.Play();
  431. else
  432. SoundPlayer_AlarmPopupSound.Stop();
  433. }
  434. }
  435. // 글자색을 토글
  436. private void Toggle_ControlForeColor(Label label, int count, string text)
  437. {
  438. if (count > 0)
  439. {
  440. if (timer_500_toggle == true) label.ForeColor = Color.White;
  441. else label.ForeColor = Color.Red;
  442. }
  443. else
  444. {
  445. if (label.ForeColor != Color.White)
  446. label.ForeColor = Color.White;
  447. }
  448. if (text != null)
  449. label.Text = text;
  450. }
  451. // 배경색을 토글
  452. private void Toggle_ControlBackColor(Control ctrl, int count, string text)
  453. {
  454. if (count > 0)
  455. {
  456. if (timer_500_toggle == true) ctrl.BackColor = Color.Transparent;
  457. else ctrl.BackColor = Color.Red;
  458. }
  459. else
  460. {
  461. if (ctrl.BackColor != Color.Transparent)
  462. ctrl.BackColor = Color.Transparent;
  463. }
  464. if (text != null)
  465. ctrl.Text = text;
  466. }
  467. //
  468. // cyim 2015.9.15 수신반 하단 이벤트 표시 : 화재 및 설비 표시루틴을 그대로 이용하도록 한다 MdiParent.cs 와 동일함
  469. //
  470. public void FireFacilityEventCheck()
  471. {
  472. {
  473. //
  474. // 화재
  475. //
  476. if (this.fireCount > 0)
  477. {
  478. this.label_FireAlert.Visible = true;
  479. //this.labelFireAlert.Image = null;//sdkim, 20120129, [MTS-47]
  480. this.label_FireAlert_inform_1th.Visible = true;
  481. this.txtFirstFireWarnningMessage.Visible = true;
  482. if (this.fireCount > 1)
  483. {
  484. this.label_FireAlert_inform_2th.Visible = true;
  485. this.cboSecondFireWarnningMessage.Visible = true;
  486. }
  487. else
  488. {
  489. this.label_FireAlert_inform_2th.Visible = false;
  490. this.cboSecondFireWarnningMessage.Visible = false;
  491. }
  492. if (timer_500_toggle == false)
  493. {
  494. this.label_FireAlert.BackColor = Color.Red;
  495. this.label_FireAlert.ForeColor = Color.Black;
  496. }
  497. else
  498. {
  499. this.label_FireAlert.BackColor = Color.Transparent;
  500. this.label_FireAlert.ForeColor = Color.Red;
  501. }
  502. }
  503. // cyim 2014.7.10 : 축적화재 표시 : KFI 요청사항
  504. else if (this.fireCount_Accumulation > 0)
  505. {
  506. // 상위 화재와 동일한 코드이다. 굳이 상위와 합치지 않은 이유는 우선순위는 무조건 일반 화재가 높기 때문이다. (위험도 고려)
  507. this.label_FireAlert.Visible = true;
  508. //this.labelFireAlert.Image = null;//sdkim, 20120129, [MTS-47]
  509. this.label_FireAlert_inform_1th.Visible = true;
  510. this.txtFirstFireWarnningMessage.Visible = true;
  511. if (this.fireCount_Accumulation > 1)
  512. {
  513. this.label_FireAlert_inform_2th.Visible = true;
  514. this.cboSecondFireWarnningMessage.Visible = true;
  515. }
  516. else
  517. {
  518. this.label_FireAlert_inform_2th.Visible = false;
  519. this.cboSecondFireWarnningMessage.Visible = false;
  520. }
  521. if (timer_500_toggle == false)
  522. {
  523. this.label_FireAlert.BackColor = Color.Red;
  524. this.label_FireAlert.ForeColor = Color.Black;
  525. }
  526. else
  527. {
  528. this.label_FireAlert.BackColor = Color.Transparent;
  529. this.label_FireAlert.ForeColor = Color.Red;
  530. }
  531. }
  532. else
  533. {
  534. this.label_FireAlert.Visible = false;
  535. this.txtFirstFireWarnningMessage.Visible = false;
  536. this.label_FireAlert_inform_1th.Visible = false;
  537. this.cboSecondFireWarnningMessage.Visible = false;
  538. this.cboSecondFireWarnningMessage.Items.Clear();
  539. this.label_FireAlert_inform_2th.Visible = false;
  540. }
  541. //
  542. // cyim 2015.7.9 PreFire 표시 문제 : 아날로그 감지기는 PreFire 단계가 있다
  543. //
  544. if (this.PreFireList.Count > 0)
  545. {
  546. this.labelPreFireAlert.Visible = true;
  547. this.cboPreFireWarnningMessage.Visible = true;
  548. if (timer_500_toggle == false)
  549. {
  550. this.labelPreFireAlert.BackColor = Color.Red;
  551. this.labelPreFireAlert.ForeColor = Color.Black;
  552. }
  553. else
  554. {
  555. this.labelPreFireAlert.BackColor = Color.Transparent;
  556. this.labelPreFireAlert.ForeColor = Color.Red;
  557. }
  558. }
  559. else
  560. {
  561. this.labelPreFireAlert.Visible = false;
  562. this.cboPreFireWarnningMessage.Visible = false;
  563. this.cboPreFireWarnningMessage.Items.Clear();
  564. }
  565. //
  566. // 설비
  567. //
  568. if (this.facilityCount > 0)
  569. {
  570. this.label_FacilityAlert.Visible = true;
  571. //this.labelFacilityAlert.Image = null;//sdkim, 20120129, [MTS-47]
  572. this.cboWriteWarningMessage.Visible = true;
  573. this.label_FacilityAlert_inform_1th.Visible = true;
  574. if (timer_500_toggle == false)
  575. {
  576. this.label_FacilityAlert.BackColor = Color.Blue;
  577. this.label_FacilityAlert.ForeColor = Color.White;
  578. }
  579. else
  580. {
  581. this.label_FacilityAlert.BackColor = Color.Transparent;
  582. this.label_FacilityAlert.ForeColor = Color.LightSkyBlue;
  583. }
  584. }
  585. else
  586. {
  587. this.label_FacilityAlert.Visible = false;
  588. this.cboWriteWarningMessage.Visible = false;
  589. this.cboWriteWarningMessage.Items.Clear();
  590. this.label_FacilityAlert_inform_1th.Visible = false;
  591. }
  592. LEDCount = LEDList.Count;
  593. if (this.LEDCount > 0)
  594. {
  595. this.lblLEDText.Text = LEDList[LEDCount - 1].ToString();
  596. this.lblLEDText.Visible = true;
  597. //this.labelFacilityAlert.Image = null;//sdkim, 20120129, [MTS-47]
  598. if (timer_500_toggle == false)
  599. {
  600. this.lblLEDText.BackColor = Color.LightPink;
  601. this.lblLEDText.ForeColor = Color.White;
  602. }
  603. else
  604. {
  605. this.lblLEDText.BackColor = Color.Transparent;
  606. this.lblLEDText.ForeColor = Color.LightPink;
  607. }
  608. }
  609. else
  610. {
  611. this.lblLEDText.Visible = false;
  612. }
  613. }
  614. }
  615. //
  616. // cyim 2015.9.15 수신반 하단 이벤트 표시
  617. // 현재 접속되어있는 데몬을 기준으로 화재 정보를 처리한다
  618. // 화재,축적,아날로그 Prefire,설비 의 경우 이벤트가 발생하면 아래의 함수에서 글자를 셋팅한다
  619. //
  620. public void FireEventProcess()
  621. {
  622. // 일반화재
  623. int iFireEventCount = FireList.Count;
  624. // 축적화재
  625. int iFireEventCount_Accumulation = FireList_Accumulation.Count;
  626. try
  627. {
  628. if (this.cboSecondFireWarnningMessage.InvokeRequired)
  629. {
  630. dCommandFuctionCallEvent d = new dCommandFuctionCallEvent(FireEventProcess);
  631. this.cboSecondFireWarnningMessage.Invoke(d, new object[] { });
  632. }
  633. else
  634. {
  635. this.Focus(); // cyim 2014.5.15 : OutofRangeException
  636. this.cboSecondFireWarnningMessage.Items.Clear();
  637. this.cboSecondFireWarnningMessage.Text = "";
  638. if (iFireEventCount > 0)
  639. {
  640. // 2보 정리
  641. for (int iLoop = 1; iLoop < iFireEventCount; iLoop++)
  642. this.cboSecondFireWarnningMessage.Items.Add(FireList[iLoop].ToString());
  643. if (this.cboSecondFireWarnningMessage.Items.Count > 0)
  644. this.cboSecondFireWarnningMessage.Text = this.cboSecondFireWarnningMessage.Items[0].ToString();
  645. // 1보 정리
  646. this.txtFirstFireWarnningMessage.Text = FireList[0].ToString();
  647. // 화재 타입
  648. this.label_FireAlert.Text = "화재발생";
  649. }
  650. // cyim 2014.7.10 : 축적화재 표시 : KFI 요청사항
  651. else if (iFireEventCount_Accumulation > 0)
  652. {
  653. // 2보 정리
  654. for (int iLoop = 1; iLoop < iFireEventCount_Accumulation; iLoop++)
  655. this.cboSecondFireWarnningMessage.Items.Add(FireList_Accumulation[iLoop].ToString());
  656. if (this.cboSecondFireWarnningMessage.Items.Count > 0)
  657. this.cboSecondFireWarnningMessage.Text = this.cboSecondFireWarnningMessage.Items[0].ToString();
  658. // 1보 정리
  659. this.txtFirstFireWarnningMessage.Text = FireList_Accumulation[0].ToString();
  660. // 화재 타입
  661. this.label_FireAlert.Text = "화재축적상태 발생";
  662. }
  663. }
  664. }
  665. catch (Exception ex)
  666. {
  667. Util.UErrorMessage(ex, 0, 0);
  668. }
  669. }
  670. public delegate void dCommandFuctionCallEvent_PreFireEventProcess();
  671. public void PreFireEventProcess()
  672. {
  673. // PreFire
  674. int iPreFireListCount = PreFireList.Count;
  675. if (this.cboPreFireWarnningMessage.InvokeRequired)
  676. {
  677. dCommandFuctionCallEvent_PreFireEventProcess d = new dCommandFuctionCallEvent_PreFireEventProcess(PreFireEventProcess);
  678. this.cboPreFireWarnningMessage.Invoke(d, new object[] { });
  679. }
  680. else
  681. {
  682. this.Focus(); // OutofRangeException 문제 수정
  683. this.cboPreFireWarnningMessage.Items.Clear();
  684. this.cboPreFireWarnningMessage.Text = "";
  685. if (PreFireList.Count > 0)
  686. {
  687. for (int i = 0; i < iPreFireListCount; i++)
  688. this.cboPreFireWarnningMessage.Items.Add(PreFireList[i].ToString());
  689. this.cboPreFireWarnningMessage.Text = PreFireList[0].ToString();
  690. }
  691. }
  692. }
  693. public delegate void dCommandFuctionCallEvent();
  694. public void EquipEventProcess()
  695. {
  696. int iEquipEventCount = EquipList.Count;
  697. try
  698. {
  699. if (this.cboWriteWarningMessage.InvokeRequired)
  700. {
  701. dCommandFuctionCallEvent d = new dCommandFuctionCallEvent(EquipEventProcess);
  702. this.cboWriteWarningMessage.Invoke(d, new object[] { });
  703. }
  704. else
  705. {
  706. this.Focus(); // cyim 2014.5.15 : OutofRangeException
  707. this.cboWriteWarningMessage.Items.Clear();
  708. this.cboWriteWarningMessage.Text = "";
  709. if (iEquipEventCount > 0)
  710. {
  711. for (int iLoop = 0; iLoop < iEquipEventCount; iLoop++)
  712. {
  713. this.cboWriteWarningMessage.Items.Add(EquipList[iLoop].ToString());
  714. }
  715. if (this.cboWriteWarningMessage.Items.Count > 0)
  716. {
  717. this.cboWriteWarningMessage.Text = this.cboWriteWarningMessage.Items[0].ToString();
  718. }
  719. }
  720. }
  721. }
  722. catch (Exception ex)
  723. {
  724. Util.UErrorMessage(ex, 0, 0);
  725. }
  726. }
  727. //
  728. // 이벤트
  729. //
  730. // 외부에서 화면을 변경하는 경우
  731. private void _Event_FireDesk_Update_SendMessage_Event(int id, string cmd, string type, int data)
  732. {
  733. // 카운터 업데이트
  734. if (cmd == "Count")
  735. {
  736. // 화재
  737. if (type == "FireDetect")
  738. {
  739. Button btn = (Button)Util.FineControl(panel_Middle, "button_FireDetect" + id.ToString());
  740. btn.Text = string.Format("화재 : {0:0000}", data);
  741. if (data > 9999) btn.Text = String.Format("화재 : {0:00000}", data);
  742. else btn.Text = String.Format("화재 : {0:0000}", data);
  743. }
  744. // 설비
  745. else if (type == "DeviceInput")
  746. {
  747. Button btn = (Button)Util.FineControl(panel_Middle, "button_DeviceInput" + id.ToString());
  748. btn.Text = string.Format("설비 : {0:0000}", data);
  749. if (data > 9999) btn.Text = String.Format("설비 : {0:00000}", data);
  750. else btn.Text = String.Format("설비 : {0:0000}", data);
  751. }
  752. // 통신
  753. else if (type == "RepeaterError")
  754. {
  755. Button btn = (Button)Util.FineControl(panel_Middle, "button_RepeaterError" + id.ToString());
  756. btn.Text = string.Format("통신 : {0:0000}", data);
  757. if (data > 9999) btn.Text = String.Format("통신 : {0:00000}", data);
  758. else btn.Text = String.Format("통신 : {0:0000}", data);
  759. }
  760. // 단선
  761. else if (type == "DeviceCut")
  762. {
  763. Button btn = (Button)Util.FineControl(panel_Middle, "button_DeviceCut" + id.ToString());
  764. btn.Text = string.Format("단선 : {0:0000}", data);
  765. if (data > 9999) btn.Text = String.Format("단선 : {0:00000}", data);
  766. else btn.Text = String.Format("단선 : {0:0000}", data);
  767. }
  768. // 차단
  769. else if (type == "DeviceNotuse")
  770. {
  771. Button btn = (Button)Util.FineControl(panel_Middle, "button_DeviceNotuse" + id.ToString());
  772. btn.Text = string.Format("차단 : {0:0000}", data);
  773. if (data > 9999) btn.Text = String.Format("차단 : {0:00000}", data);
  774. else btn.Text = String.Format("차단 : {0:0000}", data);
  775. }
  776. }
  777. // 폼을 로드
  778. else if (cmd == "FormLoad")
  779. {
  780. // 완료
  781. if (type == "MDIParentComplete")
  782. {
  783. FormLoadComplete = false;
  784. LoadMdiparentFormList.Remove(id.ToString());
  785. }
  786. }
  787. // 팝업창을 로드
  788. else if (cmd == "Popup")
  789. {
  790. ShowWaitingMsgForm(string.Format("수신기 [{0}]:",id) + type, data);
  791. }
  792. // cyim 2015.9.15 : 일반화재,축적화재,PreFire,설비,복구 의 경우 이벤트로 처리 (참고로 카운터 표시는 주기적으로 함)
  793. else if (cmd == "EventProcess")
  794. {
  795. if (type == "Fire") // 일반화재, 축적화재
  796. {
  797. FireList.Clear();
  798. FireList_Accumulation.Clear();
  799. foreach (string ID in _Data.Hash_Receiver_keys)
  800. {
  801. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[ID];
  802. foreach (string item in FireDesk_Receiver.mdi.FireList)
  803. FireList.Add(item);
  804. foreach (string item in FireDesk_Receiver.mdi.FireList_Accumulation)
  805. FireList_Accumulation.Add(item);
  806. }
  807. FireEventProcess();
  808. }
  809. else if (type == "PreFire") // PreFire
  810. {
  811. PreFireList.Clear();
  812. foreach (string ID in _Data.Hash_Receiver_keys)
  813. {
  814. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[ID];
  815. foreach (string item in FireDesk_Receiver.mdi.PreFireList)
  816. PreFireList.Add(item);
  817. }
  818. PreFireEventProcess();
  819. }
  820. else if (type == "Equip") // 설비
  821. {
  822. EquipList.Clear();
  823. foreach (string ID in _Data.Hash_Receiver_keys)
  824. {
  825. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[ID];
  826. foreach (string item in FireDesk_Receiver.mdi.EquipList)
  827. EquipList.Add(item);
  828. }
  829. EquipEventProcess();
  830. }
  831. else if (type == "Reset") // 복구
  832. {
  833. FireList.Clear();
  834. FireList_Accumulation.Clear();
  835. PreFireList.Clear();
  836. EquipList.Clear();
  837. // 복구할 때는 현재 복구하는 수신기만 제외하고 다시 불러 읽어들인다
  838. foreach (string ID in _Data.Hash_Receiver_keys)
  839. {
  840. if (id.ToString() != ID)
  841. {
  842. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[ID];
  843. foreach (string item in FireDesk_Receiver.mdi.FireList)
  844. FireList.Add(item);
  845. foreach (string item in FireDesk_Receiver.mdi.FireList_Accumulation)
  846. FireList_Accumulation.Add(item);
  847. foreach (string item in FireDesk_Receiver.mdi.PreFireList)
  848. PreFireList.Add(item);
  849. foreach (string item in FireDesk_Receiver.mdi.EquipList)
  850. EquipList.Add(item);
  851. }
  852. }
  853. FireEventProcess();
  854. PreFireEventProcess();
  855. EquipEventProcess();
  856. }
  857. }
  858. }
  859. // 수신기 버튼
  860. private void button_Receiver_Click(object sender, EventArgs e)
  861. {
  862. Button btn = (Button)sender;
  863. string id = btn.Tag.ToString();
  864. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[id];
  865. FireDesk_Receiver.mdi.Visible = true;
  866. }
  867. // 수신기 복구 버튼
  868. private void button_Recover_Click(object sender, EventArgs e)
  869. {
  870. if (MessageBox.Show("수신기에 복구 명령을 수행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  871. {
  872. Button btn = (Button)sender;
  873. string id = btn.Tag.ToString();
  874. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[id];
  875. FireDesk_Receiver.mdi.Visible = true;
  876. // cyim 2015.8.18 수신기복구 기능 추가
  877. // 해당 수신기의 화면으로 자동으로 들어가서 수신기 복구 팝업창을 확인하고 나올수 있도록 수정한다
  878. FireDesk_Receiver.mdi.FireReset_Process();
  879. FireDesk_Receiver.mdi.socketUI.ReceiverDemonReset();
  880. }
  881. }
  882. // 수신기 점검 버튼
  883. // 주음향정지
  884. private void button_MainSoundStop_Click(object sender, EventArgs e)
  885. {
  886. if (MessageBox.Show("모든 수신기에 주음향정지 명령을 수행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
  887. {
  888. foreach (string id in _Data.Hash_Receiver_keys)
  889. {
  890. _FireDesk_Receiver FireDesk_Receiver = (_FireDesk_Receiver)_Data.Hash_Receiver[id];
  891. FireDesk_Receiver.mdi.ShowControlWrite(true); // cyim 2015.8.18 주경종정지 기능 추가
  892. }
  893. }
  894. }
  895. // 연동상태조회
  896. private void button_SearchControl_Click(object sender, EventArgs e)
  897. {
  898. if (_Data.FireDesk_Operation_Enable == false) // cyim 2015.8.3 수신반 연동기능 추가
  899. {
  900. FireDesk_Operation Operation = new FireDesk_Operation();
  901. Operation.Show();
  902. }
  903. }
  904. // 과거내역통합조회
  905. private void button_SearchHistory_Click(object sender, EventArgs e)
  906. {
  907. if (_Data.FireDesk_FormLogView_Enable == false)
  908. {
  909. FireDesk_FormLogView FormLogView = new FireDesk_FormLogView(this);
  910. FormLogView.Show();
  911. }
  912. }
  913. //
  914. // cyim 2015.9.11 : 과거내역 통합조회창에서 사용할 DB 에서 미리 읽은값을 사용하도록 수정함
  915. // DB 에서 보드, 중계기, 디바이스 정보를 가져온다
  916. //
  917. // 보드
  918. //DataTable dtBoardList = null;
  919. public void GetBoardDB()
  920. {
  921. DacBoardConfig dacBoardConfig = new DacBoardConfig(0); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  922. _Data.dtBoardList = dacBoardConfig.SelectBoard(0);
  923. }
  924. // 중계기
  925. //DataTable dtRepeaterList2 = null;
  926. public void GetRepeaterDB()
  927. {
  928. DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(0); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  929. _Data.dtRepeaterList2 = dacRepeaterConfig.SelectRepeater2(0);
  930. }
  931. // 아날로그감지기 레벨
  932. //DataTable dtAnalogDetecterLevel = null;
  933. public void GetAnalogDetecterLevelDB()
  934. {
  935. DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(0); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  936. _Data.dtAnalogDetecterLevel = dacRepeaterConfig.SelectRepeater_AnalogDetecterLevel(0);
  937. }
  938. // 디바이스
  939. //DataTable dtDeviceDBList2 = null;
  940. public void GetDeviceDB()
  941. {
  942. DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(0); // cyim 2015.7.30 데이타베이스 접속 루틴 변경
  943. _Data.dtDeviceDBList2 = dacDeviceConfig.SelectDevice2(0);
  944. }
  945. // cyim 2015.7.1 속도개선작업
  946. // 데이타베이스 파일을 미리 읽도록 하되, DataTable 에 한해서 Foreach -> Select 으로 대체
  947. // DataTable 에서 정보를 가져온다
  948. // 중계기 이름을 얻어온다.
  949. public string GetDeviceName(int BOARD_ID, int LOOP_NO, int REPEATER_ID)
  950. {
  951. string ret = "";
  952. if (_Data.dtRepeaterList2 != null)
  953. {
  954. // cyim 2015.7.1 속도개선작업
  955. DataRow[] result = _Data.dtRepeaterList2.Select(
  956. string.Format("BOARD_ID={0} AND LOOP_NO={1} AND REPEATER_ID={2}", BOARD_ID, LOOP_NO, REPEATER_ID));
  957. if (result != null && result.Length > 0)
  958. ret = result[0]["REPEATER_NAME"].ToString();
  959. }
  960. return ret;
  961. }
  962. // 보드명을 가져온다
  963. public string GetDeviceName(int BOARD_ID, int CommID)
  964. {
  965. string ret = "";
  966. if (_Data.dtBoardList != null)
  967. {
  968. // cyim 2015.7.1 속도개선작업
  969. DataRow[] result = _Data.dtBoardList.Select(
  970. string.Format("BOARD_ID={0} AND COMM_ID={1}", BOARD_ID, CommID));
  971. if (result != null && result.Length > 0)
  972. ret = result[0]["BOARD_NAME"].ToString();
  973. }
  974. return ret;
  975. }
  976. // 회로명을 가져온다
  977. public string GetDeviceName(int BOARD_ID, int LOOP_NO, int REPEATER_ID, int DEVICE_ID, String INOUT_TYPE)
  978. {
  979. string ret = "";
  980. if (_Data.dtDeviceDBList2 != null)
  981. {
  982. // cyim 2015.7.1 속도개선작업
  983. DataRow[] result = _Data.dtDeviceDBList2.Select(
  984. string.Format("BOARD_ID={0} AND COMM_ID={1} AND LOOP_NO={2} AND REPEATER_ID={3} AND DEVICE_ID={4} AND INOUT_TYPE='{5}'", // cyim 2015.7.8 쿼리수정 , Inout 타입의 경우 ' ' 작은따옴표를 사용해야함, 이벤트로그가 안보이게됨
  985. BOARD_ID, 1, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE));
  986. if (result != null && result.Length > 0)
  987. ret = result[0]["DEVICE_NAME"].ToString();
  988. }
  989. return ret;
  990. }
  991. // 조건에 맞는 중계기의 위치명 / 위치 코드 / 중계기 명칭을 리턴한다.
  992. public string GetDevicePositionName(int BOARD_ID, int LOOP_NO, int REPEATER_ID)
  993. {
  994. string ret = "";
  995. if (_Data.dtRepeaterList2 != null)
  996. {
  997. // cyim 2015.7.1 속도개선작업
  998. DataRow[] result = _Data.dtRepeaterList2.Select(
  999. string.Format("BOARD_ID={0} AND LOOP_NO={2} AND REPEATER_ID={3}",
  1000. BOARD_ID, 1, LOOP_NO, REPEATER_ID));
  1001. if (result != null && result.Length > 0)
  1002. {
  1003. // 만약 위치 명이 있으면, 위치명으로 리턴한다.
  1004. if (result[0]["POSITION_NAME"].ToString() != "")
  1005. ret = result[0]["POSITION_NAME"].ToString();
  1006. // 위치명이 없고.. 위치 코드가 있으면, 위치 코드를 리턴하도록 한다.
  1007. else if (result[0]["POSITION_CODE"].ToString() != "")
  1008. ret = result[0]["POSITION_CODE"].ToString();
  1009. // 기본값 RepeaterName을 리턴할 준비를 한다.
  1010. else
  1011. ret = result[0]["REPEATER_NAME"].ToString();
  1012. }
  1013. }
  1014. return ret;
  1015. }
  1016. // 디바이스 위치를 리턴한다. 만약 맞는 위치명이 없으면.. 위치 코드라도 리턴한다.
  1017. public string GetDevicePositionName(int BOARD_ID, int LOOP_NO, int REPEATER_ID, int DEVICE_ID, String INOUT_TYPE)
  1018. {
  1019. string ret = "";
  1020. if (_Data.dtDeviceDBList2 != null)
  1021. {
  1022. // cyim 2015.7.1 속도개선작업
  1023. string SQL = string.Format("BOARD_ID={0} AND COMM_ID={1} AND LOOP_NO={2} AND REPEATER_ID={3} AND DEVICE_ID={4} AND INOUT_TYPE='{5}'", // cyim 2015.7.8 쿼리수정 , Inout 타입의 경우 ' ' 작은따옴표를 사용해야함, 이벤트로그가 안보이게됨
  1024. BOARD_ID, 1, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE);
  1025. DataRow[] result = _Data.dtDeviceDBList2.Select(SQL);
  1026. if (result != null && result.Length > 0)
  1027. {
  1028. // 만약 위치 명이 있으면, 위치명으로 리턴한다.
  1029. if (result[0]["POSITION_NAME"].ToString() != "")
  1030. ret = result[0]["POSITION_NAME"].ToString();
  1031. // 위치명이 없고.. 위치 코드가 있으면, 위치 코드를 리턴하도록 한다.
  1032. else if (result[0]["POSITION_CODE"].ToString() != "")
  1033. ret = result[0]["POSITION_CODE"].ToString();
  1034. // 기본값 Device Name을 리턴할 준비를 한다.
  1035. else
  1036. ret = result[0]["DEVICE_NAME"].ToString();
  1037. }
  1038. }
  1039. return ret;
  1040. }
  1041. // cyim 2015.7.1 속도개선작업
  1042. // 해쉬테이블을 사용해서 아날로그 감지기를 미리 저장해두어야 한다
  1043. // 아날로그감지기 아이디를 모두 가져온다 (아이디로 구성된 키를 가지고, 데이터는 레벨값 FAULT_VALUE;PREFIRE_VALUE;FIRED_VALUE;FIREN_VALUE)
  1044. public Hashtable GetAnalogDetecterRepeaterID(int RECEIVER_ID, int BOARD_ID, int LOOP_NO)
  1045. {
  1046. Hashtable ret = new Hashtable();
  1047. try
  1048. {
  1049. if (_Data.dtAnalogDetecterLevel != null)
  1050. {
  1051. DataRow[] result = _Data.dtAnalogDetecterLevel.Select(
  1052. string.Format("RECEIVER_ID={0} AND BOARD_ID={1} AND LOOP_NO={2}", RECEIVER_ID, BOARD_ID, LOOP_NO));
  1053. if (result.Length > 0)
  1054. {
  1055. foreach (DataRow Data in result)
  1056. {
  1057. string key = Data["REPEATER_ID"].ToString();
  1058. AnalogLevel data = new AnalogLevel(
  1059. Int32.Parse(Data["FAULT_VALUE"].ToString()),
  1060. Int32.Parse(Data["PREFIRE_VALUE"].ToString()),
  1061. Int32.Parse(Data["FIRED_VALUE"].ToString()),
  1062. Int32.Parse(Data["FIREN_VALUE"].ToString()));
  1063. ret.Add(key, data);
  1064. }
  1065. }
  1066. }
  1067. }
  1068. catch (Exception ex)
  1069. {
  1070. Util.UErrorMessage(ex, 0, 0);
  1071. }
  1072. return ret;
  1073. }
  1074. // cyim 2016.01.07 아날로그 감지기 이력 조회시 표시 수정 : 중계기 타입을 조회할수 있도록 한다
  1075. public string GetRepeaterType(int BOARD_ID, int LOOP_NO, int REPEATER_ID)
  1076. {
  1077. string ret = "";
  1078. if (_Data.dtRepeaterList2 != null)
  1079. {
  1080. // cyim 2015.7.1 속도개선작업
  1081. DataRow[] result = _Data.dtRepeaterList2.Select(
  1082. string.Format("BOARD_ID={0} AND LOOP_NO={2} AND REPEATER_ID={3}",
  1083. BOARD_ID, 1, LOOP_NO, REPEATER_ID));
  1084. if (result != null && result.Length > 0)
  1085. {
  1086. ret = result[0]["REPEATER_TYPE"].ToString();
  1087. }
  1088. }
  1089. return ret;
  1090. }
  1091. }
  1092. //
  1093. // 수신반 전용 클래스
  1094. // 이 클래스는 범용으로 수신반에서 다른 수신기간의 데이터를 쉽게 공유할수 있게 만든 클래스이다.
  1095. // 실제로 사용하는 데이터만 추가하도록 한다
  1096. // 자세한 정보는 결국 직접 접속해서 볼수 있는 화면으로 구성한다
  1097. public class _FireDesk_Receiver
  1098. {
  1099. // 수신기 기본정보
  1100. public string RECEIVER_ID = "1";
  1101. public string MASTER_FLAG = "N";
  1102. public string PROJECT_DIRECTORY;
  1103. public string DATABASE_NAME; // IP + PATH
  1104. public string DATABASE_NAME_IP; // PATH
  1105. public string DATABASE_NAME_PATH; // PATH
  1106. // 카운터 정보
  1107. public int FireDetect = 0; // 화재
  1108. public int DeviceInput = 0; // 설비
  1109. public int RepeaterError = 0; // 통신
  1110. public int DeviceCut = 0; // 단선
  1111. public int DeviceNotuse = 0; // 차단
  1112. // 클래스 정보
  1113. public bool LoadStart = false;
  1114. public MDIParent mdi = null;
  1115. }
  1116. }