TData.cs 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Net;
  5. using System.Net.Sockets;
  6. using System.IO;
  7. using System.Threading;
  8. using System.Runtime.Serialization.Formatters.Binary;
  9. using System.Runtime.InteropServices;
  10. using System.Reflection;
  11. namespace FPER
  12. {
  13. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  14. public struct PRTIO_Type1
  15. {// say hell to io board , read io board status ,read io board data
  16. public byte head;
  17. public byte RPT_loop;
  18. public byte BD_ID;
  19. public byte length;
  20. public byte cmd;
  21. public byte IVK_ID;
  22. public byte RCVR_ID;
  23. public byte cs;
  24. }
  25. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  26. public struct PRTIO_Type2
  27. {// none
  28. public byte head;
  29. public byte RPT_loop;
  30. public byte BD_ID;
  31. public byte length;
  32. public byte cmd;
  33. public byte IVK_ID;
  34. public byte RCVR_ID;
  35. public byte Option1;
  36. public byte cs;
  37. }
  38. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  39. public struct PRTIO_Type3
  40. {// write io board status , write io board data
  41. public byte head;
  42. public byte RPT_loop;
  43. public byte BD_ID;
  44. public byte length;
  45. public byte cmd;
  46. public byte IVK_ID;
  47. public byte RCVR_ID;
  48. public byte Option1;
  49. public byte Option2;
  50. public byte cs;
  51. }
  52. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  53. public struct PRTDemon_Type1
  54. {// write io board status , write io board data
  55. public byte head;
  56. public byte RPT_loop;
  57. public byte BD_ID;
  58. public byte length;
  59. public byte cmd;
  60. public byte IVK_ID;
  61. public byte RCVR_ID;
  62. public byte cs;
  63. }
  64. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  65. public struct PRTReceiver_Type1
  66. {// say hell to board , read board status
  67. public byte head;
  68. public byte RPT_loop;
  69. public byte TBD_ID;
  70. public byte length;
  71. public byte cmd;
  72. public byte IVK_ID;
  73. public byte RCVR_ID;
  74. public byte cs;
  75. }
  76. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  77. public struct PRTReceiver_Type2
  78. {// resetrepeaterunit
  79. public byte head;
  80. public byte RPT_loop;
  81. public byte TBD_ID;
  82. public byte length;
  83. public byte cmd;
  84. public byte IVK_ID;
  85. public byte RCVR_ID;
  86. public byte Option1;
  87. public byte cs;
  88. }
  89. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  90. public struct PRTReceiver_Type3
  91. {//search repeater all, read repeaterpoint all, write repeater output unit ,read repeater info all, read repeater info unit, reset repeater all , write repeater input unit
  92. public byte head;
  93. public byte RPT_loop;
  94. public byte TBD_ID;
  95. public byte length;
  96. public byte cmd;
  97. public byte IVK_ID;
  98. public byte RCVR_ID;
  99. public byte Option1;
  100. public byte Option2;
  101. public byte cs;
  102. }
  103. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  104. public struct PRTReceiver_Type4
  105. {// none
  106. public byte head;
  107. public byte RPT_loop;
  108. public byte TBD_ID;
  109. public byte length;
  110. public byte cmd;
  111. public byte IVK_ID;
  112. public byte RCVR_ID;
  113. public byte Option1;
  114. public byte Option2;
  115. public byte Option3;
  116. public byte cs;
  117. }
  118. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  119. public struct PRTReceiver_Type5
  120. {//none
  121. public byte head;
  122. public byte RPT_loop;
  123. public byte TBD_ID;
  124. public byte length;
  125. public byte cmd;
  126. public byte IVK_ID;
  127. public byte RCVR_ID;
  128. public byte Option1;
  129. public byte Option2;
  130. public byte Option3;
  131. public byte Option4;
  132. public byte cs;
  133. }
  134. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  135. public struct PRTReceiver_Type6
  136. {//write board status
  137. public byte head;
  138. public byte RPT_loop;
  139. public byte TBD_ID;
  140. public byte length;
  141. public byte cmd;
  142. public byte IVK_ID;
  143. public byte RCVR_ID;
  144. public byte Option1;
  145. public byte Option2;
  146. public byte Option3;
  147. public byte Option4;
  148. public byte Option5;
  149. public byte cs;
  150. }
  151. //데몬명령-누적카운트및사용자설정 변경
  152. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  153. public struct PRTReceiver_Type_CommandStatus
  154. {//write board status
  155. public byte head; //0x02
  156. public byte RPT_loop; //ID 하위 바이트 (Loop 번호)
  157. public byte TBD_ID; //ID 상위 바이트 (통신보드 ID)
  158. public byte length; //0x0D, 전체 Packet 길이
  159. public byte cmd; //0x76, Status Command 명령
  160. public byte IVK_ID; //Invoke ID
  161. public byte RCVR_ID; //수신기 ID
  162. public byte RepeaterID; //중계기 ID (1~ 127)
  163. public byte Address; //ADDRESS (1 ~ 16) 회로ID
  164. public byte InOut; //IN/OUT (I/O) C-comm,L-loop,B-board,R-repeater
  165. public byte CommId; //1-front,3-io,4-keypad
  166. public byte CommandType1; //Command Type 1 C:카운트읽기
  167. public byte CommandType2; //Command Type 2 C:카운트읽기
  168. public byte SubType; //SubType : Device Type
  169. public byte ApplyRange; //ApplyRange : A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
  170. public byte Status; //Status
  171. public byte cs;
  172. }
  173. // 아날로그 감지기 레벨값 쓰기 명령
  174. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  175. public struct PRTReceiver_Type_AnalogDetecterLevel
  176. {
  177. public byte head; //0x02
  178. public byte RPT_loop; //ID 하위 바이트 (Loop 번호)
  179. public byte TBD_ID; //ID 상위 바이트 (통신보드 ID)
  180. public byte length; //0x0C, 전체 Packet 길이
  181. public byte cmd; //0x78, AnalogDetecterLevel Write 명령
  182. public byte IVK_ID; //Invoke ID
  183. public byte RCVR_ID; //수신기 ID
  184. public byte RepeaterID; //중계기 ID (1~ 127) , 0xFF (BroadCast)
  185. public byte Fault;
  186. public byte PreFire;
  187. public byte FireNight;
  188. public byte FireDay;
  189. public byte cs;
  190. }
  191. // cyim 2016.10.27 : 대용량 수신기 아날로그 감지기 트랜드 읽기
  192. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  193. public struct PRTReceiver_Type_AnalogDetecterTrend
  194. {
  195. public byte head; //0x02
  196. public byte RPT_loop; //ID 하위 바이트 (Loop 번호)
  197. public byte TBD_ID; //ID 상위 바이트 (통신보드 ID)
  198. public byte length; //0x08, 전체 Packet 길이
  199. public byte cmd; //0x24, AnalogDetecterTrend Read 명령
  200. public byte IVK_ID; //Invoke ID
  201. public byte RCVR_ID; //수신기 ID
  202. public byte RepeaterID; //감지기 ID
  203. public byte cs;
  204. }
  205. public class GeneralBaseInfo
  206. {
  207. private int unitID_d = 0;
  208. private int unitID_u = 0;
  209. private int receiverID = 0;
  210. private int invorkNo = 0;
  211. private int errNo = 0;
  212. private int errLocation = 0;
  213. private string errLocationMessage = "";
  214. private string errMessage = "[NACK]통신오류가 발생하였습니다. 관리자에게 문의하시기 바랍니다.";
  215. public GeneralBaseInfo(byte[] buffer)
  216. {
  217. try
  218. {
  219. this.unitID_d = (int)buffer[1];
  220. this.unitID_u = (int)buffer[2];
  221. //if(buffer[3] == 0x00) {
  222. // this.InvorkNo = buffer[7];
  223. // this.ReceiverID = buffer[8];
  224. //}
  225. //else {
  226. // this.InvorkNo = buffer[5];
  227. // this.ReceiverID = buffer[6];
  228. //}
  229. this.invorkNo = (int)buffer[5];
  230. this.receiverID = (int)buffer[6];
  231. this.errLocation = (int)buffer[7];
  232. this.errNo = (int)buffer[8];
  233. this.errNo = ((int)buffer[9]) * 256 + this.errNo;
  234. //에러코드명을 저장한다.
  235. DemonErrCode errCode = new DemonErrCode(this.errNo);
  236. this.errLocationMessage = errCode.GetErrorName();
  237. //switch (this.errLocation)
  238. //{
  239. // case 1: this.errLocationMessage = "Demon Error"; break;
  240. // case 2: this.errLocationMessage = "통신 보드 Error"; break;
  241. // case 3: this.errLocationMessage = "IO 보드 Error"; break;
  242. // default: this.errLocationMessage = "알수없음"; break;
  243. //}
  244. }
  245. catch (Exception ex)
  246. {
  247. Util.UErrorMessage(ex, 0, 0);
  248. }
  249. }
  250. public int UnitID_d { get { return (int)this.unitID_d; } }
  251. public int UnitID_u { get { return (int)this.unitID_u; } }
  252. public int ReceiverID { get { return (int)this.receiverID; } }
  253. public int InvorkNo { get { return (int)this.invorkNo; } }
  254. public int ErrReceiverID { get { return (int)this.receiverID; } }
  255. public int ErrInvorkNo { get { return (int)this.invorkNo; } }
  256. public int ErrNo { get { return 0; } }
  257. public string ErrMessage
  258. {
  259. get
  260. {
  261. // return string.Format("{0}\r\n[{1}] 발생위치:{2}, 수신기번호:{3}, Invork번호:{4}"
  262. //, this.errMessage, this.errNo, this.errLocationMessage, this.receiverID, this.invorkNo);
  263. return string.Format("{0}\r\n\r\n[에러코드:{1}] 에러내역:{2}", this.errMessage, this.errNo, this.errLocationMessage);
  264. }
  265. }
  266. }
  267. public class DemonErrCode
  268. {
  269. int errCode = 0;
  270. const int PROCESS_STOP = 1;
  271. const int PROCESS_RUN = 2;
  272. const int POLLING_STOP = 3;
  273. const int POLLING_START = 4;
  274. const int DATABASE_CONNECT = 11;
  275. const int DATABASE_INSERT = 12;
  276. const int DATABASE_DELETE = 13;
  277. const int DATABASE_CONNECT_ERROR = 14;
  278. const int DATABASE_INSERT_ERROR = 15;
  279. const int DATABASE_DELETE_ERROR = 16;
  280. const int COMMUNICATION_CONNECT = 20;
  281. const int COMMUNICATION_DISCONNECT = 21;
  282. const int COMMUNICATION_SEND = 22;
  283. const int COMMUNICATION_RECEIVE = 23;
  284. const int COMMUNICATION_CONNECT_ERROR = 24;
  285. const int COMMUNICATION_SEND_ERROR = 25;
  286. const int COMMUNICATION_SEND_TIMEOUT = 26;
  287. const int COMMUNICATION_RECEIVE_ERROR = 27;
  288. const int COMMUNICATION_RECEIVE_TIMEOUT = 28;
  289. const int COMMUNICATION_DATA_INVALID = 29;
  290. const int COMMUNICATION_CHECKBYTE_INVALID = 30;
  291. const int DATA_STX_INVALID = 31;
  292. const int DATA_BOARD_ID_INVALID = 32;
  293. const int DATA_LOOP_NO_INVALID = 33;
  294. const int DATA_COMMAND_INVALID = 34;
  295. const int DATA_LENGTH_INVALID = 35;
  296. const int DATA_RECEIVER_ID_INVALID = 36;
  297. const int DATA_COMM_ID_INVALID = 37;
  298. const int DATA_CHECKBYTE_INVALID = 38;
  299. const int DATA_REPLY_INVALID = 126;
  300. const int COMMUNICATION_FAIL = 127;
  301. const int COMMUNICATION_OK = 0;
  302. const int CHECKBYTE_ERROR = 0xFF;
  303. const int NOT_SUPPORT_COMMAND = 0xFE;
  304. const int NOT_SUPPORT_VALUE = 0xFD;
  305. public DemonErrCode(int errCode)
  306. {
  307. this.errCode = errCode;
  308. }
  309. public string GetErrorName()
  310. {
  311. string errName = "";
  312. try
  313. {
  314. // ERROR CODE CHECK (CHECK BYTE ERROR)
  315. if (this.errCode == CHECKBYTE_ERROR)
  316. {
  317. // ERROR NAME 설정
  318. //errName = "CHECK BYTE ERROR";
  319. errName = "CHECK BYTE ERROR:체크바이트값이 올바르지 않습니다.";
  320. }
  321. // ERROR CODE CHECK (NOT SUPPORT COMMAND)
  322. else if (this.errCode == NOT_SUPPORT_COMMAND)
  323. {
  324. // ERROR NAME 설정
  325. //errName = "NOT SUPPORT COMMAND";
  326. errName = "NOT SUPPORT COMMAND:지원하지 않는 명령형식입니다. 통신데이터를 확인하십시요.";
  327. }
  328. // ERROR CODE CHECK (NOT SUPPORT VALUE)
  329. else if (this.errCode == NOT_SUPPORT_VALUE)
  330. {
  331. // ERROR NAME 설정
  332. //errName = "NOT SUPPORT VALUE";
  333. errName = "NOT SUPPORT VALUE:지원하지 않는 값입니다. 통신데이터를 확인하십시요.";
  334. }
  335. // ERROR CODE CHECK (PROCESS STOP)
  336. else if (this.errCode == PROCESS_STOP)
  337. {
  338. // ERROR NAME 설정
  339. errName = "PROCESS STOP:데몬통신 중지중입니다.";
  340. }
  341. // ERROR CODE CHECK (PROCESS RUN)
  342. else if (this.errCode == PROCESS_RUN)
  343. {
  344. // ERROR NAME 설정
  345. errName = "PROCESS RUN:데몬통신이 실행중입니다.";
  346. }
  347. // ERROR CODE CHECK (POLLING STOP)
  348. else if (this.errCode == POLLING_STOP)
  349. {
  350. // ERROR NAME 설정
  351. errName = "POLLING STOP:데몬이 중지되었습니다.";
  352. }
  353. // ERROR CODE CHECK (POLLING START)
  354. else if (this.errCode == POLLING_START)
  355. {
  356. // ERROR NAME 설정
  357. errName = "POLLING START:데몬이 시작되었습니다.";
  358. }
  359. // ERROR CODE CHECK (DATABASE CONNECT)
  360. else if (this.errCode == DATABASE_CONNECT)
  361. {
  362. // ERROR NAME 설정
  363. errName = "DATABASE CONNECT:데이터베이스 연결이 시작되었습니다.";
  364. }
  365. // ERROR CODE CHECK (DATABASE INSERT)
  366. else if (this.errCode == DATABASE_INSERT)
  367. {
  368. // ERROR NAME 설정
  369. errName = "DATABASE INSERT:데이터베이스 자료입력 작업중입니다.";
  370. }
  371. // ERROR CODE CHECK (DATABASE DELETE)
  372. else if (this.errCode == DATABASE_DELETE)
  373. {
  374. // ERROR NAME 설정
  375. errName = "DATABASE DELETE:데이터베이스 자료삭제 작업중입니다.";
  376. }
  377. // ERROR CODE CHECK (DATABASE CONNECT ERROR)
  378. else if (this.errCode == DATABASE_CONNECT_ERROR)
  379. {
  380. // ERROR NAME 설정
  381. errName = "DATABASE CONNECT ERROR:데이터베이스 연결 오류입니다.";
  382. }
  383. // ERROR CODE CHECK (DATABASE INSERT ERROR)
  384. else if (this.errCode == DATABASE_INSERT_ERROR)
  385. {
  386. // ERROR NAME 설정
  387. errName = "DATABASE INSERT ERROR:데이터베이스 자료입력 오류입니다.";
  388. }
  389. // ERROR CODE CHECK (DATABASE DELETE ERROR)
  390. else if (this.errCode == DATABASE_DELETE_ERROR)
  391. {
  392. // ERROR NAME 설정
  393. errName = "DATABASE DELETE ERROR:데이터베이스 자료삭제 오류입니다.";
  394. }
  395. // ERROR CODE CHECK (COMMUNICATION CONNECT)
  396. else if (this.errCode == COMMUNICATION_CONNECT)
  397. {
  398. // ERROR NAME 설정
  399. errName = "COMMUNICATION CONNECT:통신연결 되었습니다.";
  400. }
  401. // ERROR CODE CHECK (COMMUNICATION DISCONNECT)
  402. else if (this.errCode == COMMUNICATION_DISCONNECT)
  403. {
  404. // ERROR NAME 설정
  405. errName = "COMMUNICATION DISCONNECT:통신연결상태가 아닙니다. 통신보드연결상태를 확인하십시요.";
  406. }
  407. // ERROR CODE CHECK (COMMUNICATION S})
  408. else if (this.errCode == COMMUNICATION_SEND)
  409. {
  410. // ERROR NAME 설정
  411. errName = "COMMUNICATION SEND:통신 데이터 전송중입니다.";
  412. }
  413. // ERROR CODE CHECK (COMMUNICATION RECEIVE)
  414. else if (this.errCode == COMMUNICATION_RECEIVE)
  415. {
  416. // ERROR NAME 설정
  417. errName = "COMMUNICATION RECEIVE:통신 데이터 송신중입니다.";
  418. }
  419. // ERROR CODE CHECK (COMMUNICATION CONNECT ERROR)
  420. else if (this.errCode == COMMUNICATION_CONNECT_ERROR)
  421. {
  422. // ERROR NAME 설정
  423. errName = "COMMUNICATION CONNECT ERROR:통신 연결 오류입니다.";
  424. }
  425. // ERROR CODE CHECK (COMMUNICATION S} ERROR)
  426. else if (this.errCode == COMMUNICATION_SEND_ERROR)
  427. {
  428. // ERROR NAME 설정
  429. errName = "COMMUNICATION SEND ERROR:통신 데이터 전송 오류입니다.";
  430. }
  431. // ERROR CODE CHECK (COMMUNICATION S} TIMEOUT)
  432. else if (this.errCode == COMMUNICATION_SEND_TIMEOUT)
  433. {
  434. // ERROR NAME 설정
  435. errName = "COMMUNICATION SEND TIMEOUT:통신 데이터 전송중 타임아웃되었습니다.";
  436. }
  437. // ERROR CODE CHECK (COMMUNICATION RECEIVE ERROR)
  438. else if (this.errCode == COMMUNICATION_RECEIVE_ERROR)
  439. {
  440. // ERROR NAME 설정
  441. errName = "COMMUNICATION RECEIVE ERROR:통신 데이터 송신 오류입니다.";
  442. }
  443. // ERROR CODE CHECK (COMMUNICATION RECEIVE TIMEOUT)
  444. else if (this.errCode == COMMUNICATION_RECEIVE_TIMEOUT)
  445. {
  446. // ERROR NAME 설정
  447. errName = "COMMUNICATION RECEIVE TIMEOUT:통신 데이터 송신중 타임아웃되었습니다.";
  448. }
  449. // ERROR CODE CHECK (COMMUNICATION DATA INVALID)
  450. else if (this.errCode == COMMUNICATION_DATA_INVALID)
  451. {
  452. // ERROR NAME 설정
  453. errName = "COMMUNICATION DATA INVALID:통신 데이터가 올바르지 않습니다.";
  454. }
  455. // ERROR CODE CHECK (COMMUNICATION CHECKBYTE INVALID)
  456. else if (this.errCode == COMMUNICATION_CHECKBYTE_INVALID)
  457. {
  458. // ERROR NAME 설정
  459. errName = "COMMUNICATION CHECKBYTE INVALID:통신 데이터 체크바이트가 올바르지 않습니다.";
  460. }
  461. // ERROR CODE CHECK (DATA STX INVALID)
  462. else if (this.errCode == DATA_STX_INVALID)
  463. {
  464. // ERROR NAME 설정
  465. errName = "DATA INVALID (STX): STX오류입니다.";
  466. }
  467. // ERROR CODE CHECK (DATA BOARD ID INVALID)
  468. else if (this.errCode == DATA_BOARD_ID_INVALID)
  469. {
  470. // ERROR NAME 설정
  471. errName = "DATA INVALID (BOARD ID):통신보드ID가 올바르지 않습니다.";
  472. }
  473. // ERROR CODE CHECK (DATA LOOP NO. INVALID)
  474. else if (this.errCode == DATA_LOOP_NO_INVALID)
  475. {
  476. // ERROR NAME 설정
  477. errName = "DATA INVALID (LOOP NO.):LOOP NO가 올바르지 않습니다.";
  478. }
  479. // ERROR CODE CHECK (DATA COMMAND INVALID)
  480. else if (this.errCode == DATA_COMMAND_INVALID)
  481. {
  482. // ERROR NAME 설정
  483. errName = "DATA INVALID (COMMAND):명령데이터가 올바르지 않습니다.";
  484. }
  485. // ERROR CODE CHECK (DATA LENGTH INVALID)
  486. else if (this.errCode == DATA_LENGTH_INVALID)
  487. {
  488. // ERROR NAME 설정
  489. errName = "DATA INVALID (LENGTH):통신데이터 길이가 올바르지 않습니다.";
  490. }
  491. // ERROR CODE CHECK (DATA RECEIVER ID INVALID)
  492. else if (this.errCode == DATA_RECEIVER_ID_INVALID)
  493. {
  494. // ERROR NAME 설정
  495. errName = "DATA INVALID (RECEIVER ID):수신기ID가 올바르지 않습니다.";
  496. }
  497. // ERROR CODE CHECK (DATA COMM. ID INVALID)
  498. else if (this.errCode == DATA_COMM_ID_INVALID)
  499. {
  500. // ERROR NAME 설정
  501. errName = "DATA INVALID (COMM. ID):COMM ID가 올바르지 않습니다.";
  502. }
  503. // ERROR CODE CHECK (DATA CHECK BYTE INVALID)
  504. else if (this.errCode == DATA_CHECKBYTE_INVALID)
  505. {
  506. // ERROR NAME 설정
  507. errName = "DATA INVALID (CHECK BYTE):체크바이트가 올바르지 않습니다.";
  508. }
  509. // ERROR CODE CHECK (DATA REPLY INVALID)
  510. else if (this.errCode == DATA_REPLY_INVALID)
  511. {
  512. // ERROR NAME 설정
  513. errName = "DATA INVALID (REPLY):응답데이터가 올바르지 않습니다.";
  514. }
  515. // ERROR CODE CHECK (COMMUNICATION FAIL)
  516. else if (this.errCode == COMMUNICATION_FAIL)
  517. {
  518. // ERROR NAME 설정
  519. errName = "COMMUNICATION FAIL:통신오류가 발생하였습니다.";
  520. }
  521. // ERROR CODE CHECK (COMMUNICATION OK)
  522. else if (this.errCode == COMMUNICATION_OK)
  523. {
  524. // ERROR NAME 설정
  525. errName = "COMMUNICATION OK:통신이 정상적으로 진행되었습니다.";
  526. }
  527. // ERROR CODE CHECK (ETC)
  528. else
  529. {
  530. // ERROR NAME 설정
  531. errName = "UNKNOWN ERROR:알수 없는 통신오류 입니다.";
  532. }
  533. }
  534. catch (Exception ex)
  535. {
  536. Util.UErrorMessage(ex, 0, 0);
  537. }
  538. return errName;
  539. }
  540. }
  541. public class RCVData_ACK
  542. {
  543. private GeneralBaseInfo baseInfo;
  544. public byte Position = 0x00;
  545. public byte NR = 0x00;
  546. public byte FL = 0x00;
  547. public RCVData_ACK(byte[] buffer)
  548. {
  549. this.baseInfo = new GeneralBaseInfo(buffer);
  550. this.Position = buffer[7];
  551. this.NR = buffer[8];
  552. this.FL = buffer[9];
  553. }
  554. /////// base info /////////////////
  555. public GeneralBaseInfo Baseinfo
  556. {
  557. get
  558. {
  559. return this.baseInfo;
  560. }
  561. }
  562. public int UnitID_d
  563. {
  564. get
  565. {
  566. return this.baseInfo.UnitID_d;
  567. }
  568. }
  569. public int UnitID_u
  570. {
  571. get
  572. {
  573. return this.baseInfo.UnitID_u;
  574. }
  575. }
  576. public int InvorkNo
  577. {
  578. get
  579. {
  580. return this.baseInfo.InvorkNo;
  581. }
  582. }
  583. public int ReceiverID
  584. {
  585. get
  586. {
  587. return this.baseInfo.ReceiverID;
  588. }
  589. }
  590. }
  591. public class RCVData_NACK
  592. {
  593. private GeneralBaseInfo baseInfo;
  594. public byte Position = 0x00;
  595. public byte ErrorNumber_d = 0x00;
  596. public byte ErrorNumber_u = 0x00;
  597. public byte[] Option;
  598. public int OptionCnt = 0;
  599. public RCVData_NACK(byte[] buffer)
  600. {
  601. try
  602. {
  603. this.baseInfo = new GeneralBaseInfo(buffer);
  604. this.Position = buffer[7];
  605. this.ErrorNumber_d = buffer[8];
  606. this.ErrorNumber_u = buffer[9];
  607. this.OptionCnt = buffer[3] - 9;
  608. if (this.OptionCnt > 0)
  609. {
  610. this.Option = new byte[this.OptionCnt];
  611. for (int i = 0; i < this.OptionCnt; i++)
  612. {
  613. Option[i] = buffer[i + 10];
  614. }
  615. }
  616. }
  617. catch (Exception ex)
  618. {
  619. Util.UErrorMessage(ex, 0, 0);
  620. }
  621. }
  622. /////// base info /////////////////
  623. public GeneralBaseInfo Baseinfo
  624. {
  625. get
  626. {
  627. return this.baseInfo;
  628. }
  629. }
  630. public int UnitID_d
  631. {
  632. get
  633. {
  634. return this.baseInfo.UnitID_d;
  635. }
  636. }
  637. public int UnitID_u
  638. {
  639. get
  640. {
  641. return this.baseInfo.UnitID_u;
  642. }
  643. }
  644. public int InvorkNo
  645. {
  646. get
  647. {
  648. return this.baseInfo.InvorkNo;
  649. }
  650. }
  651. public int ReceiverID
  652. {
  653. get
  654. {
  655. return this.baseInfo.ReceiverID;
  656. }
  657. }
  658. }
  659. public class TBoardBaseInfo
  660. {
  661. public byte TBD_ID = 0;
  662. public byte Repeater_loop = 0;
  663. public byte ReceiverID = 0;
  664. public byte InvorkNo = 0;
  665. public TBoardBaseInfo(byte[] buffer)
  666. {
  667. try
  668. {
  669. this.TBD_ID = buffer[2];
  670. this.Repeater_loop = buffer[1];
  671. if (buffer[3] == 0x00)
  672. {
  673. this.InvorkNo = buffer[7];
  674. this.ReceiverID = buffer[8];
  675. }
  676. else
  677. {
  678. this.InvorkNo = buffer[5];
  679. this.ReceiverID = buffer[6];
  680. }
  681. }
  682. catch (Exception ex)
  683. {
  684. Util.UErrorMessage(ex, 0, 0);
  685. }
  686. }
  687. }
  688. //통신보드 상태쓰기 데이터
  689. public class TBoardData
  690. {
  691. private int mode = 0;
  692. public byte TBD_MainVersion = 0;
  693. public byte TBD_SubVersion = 0;
  694. public byte RCV_BaudRate = 0;
  695. public byte TBD_Loop1_BaudRate = 0;
  696. public byte TBD_Loop2_BaudRate = 0;
  697. public byte TBD_Term = 0;
  698. public byte TBD_24Voltage_d = 0;
  699. public byte TBD_24Voltage_u = 0;
  700. public byte TBD_5Voltage_d = 0;
  701. public byte TBD_5Voltage_u = 0;
  702. public byte TBD_33Voltage_d = 0;
  703. public byte TBD_33Voltage_u = 0;
  704. public byte TBD_Cut = 0;
  705. public byte Reset = 0;
  706. public TBoardData()
  707. {
  708. this.mode = 1;
  709. }
  710. public TBoardData(byte[] buffer)
  711. {
  712. try
  713. {
  714. this.mode = 2;
  715. this.TBD_MainVersion = buffer[7];
  716. this.TBD_SubVersion = buffer[8];
  717. this.RCV_BaudRate = buffer[9];
  718. this.TBD_Loop1_BaudRate = buffer[10];
  719. this.TBD_Loop2_BaudRate = buffer[11];
  720. this.TBD_Term = buffer[12];
  721. this.TBD_24Voltage_d = buffer[13];
  722. this.TBD_24Voltage_u = buffer[14];
  723. this.TBD_5Voltage_d = buffer[15];
  724. this.TBD_5Voltage_u = buffer[16];
  725. this.TBD_33Voltage_d = buffer[17];
  726. this.TBD_33Voltage_u = buffer[18];
  727. this.TBD_Cut = buffer[19];
  728. }
  729. catch (Exception ex)
  730. {
  731. Util.UErrorMessage(ex, 0, 0);
  732. }
  733. }
  734. public int Mode
  735. {
  736. get
  737. {
  738. return this.mode;
  739. }
  740. }
  741. }
  742. public class RCVData_ReadTBoardStatus
  743. {
  744. private TBoardBaseInfo baseInfo;
  745. private TBoardData data;
  746. public RCVData_ReadTBoardStatus(byte[] buffer)
  747. {
  748. this.baseInfo = new TBoardBaseInfo(buffer);
  749. this.data = new TBoardData(buffer);
  750. }
  751. /////// base info /////////////////
  752. public byte TBD_ID
  753. {
  754. get
  755. {
  756. return this.baseInfo.TBD_ID;
  757. }
  758. }
  759. public byte Repeater_loop
  760. {
  761. get
  762. {
  763. return this.baseInfo.Repeater_loop;
  764. }
  765. }
  766. public byte InvorkNo
  767. {
  768. get
  769. {
  770. return this.baseInfo.InvorkNo;
  771. }
  772. }
  773. public byte ReceiverID
  774. {
  775. get
  776. {
  777. return this.baseInfo.ReceiverID;
  778. }
  779. }
  780. /////// data /////////////////
  781. public TBoardData Data
  782. {
  783. get
  784. {
  785. return this.data;
  786. }
  787. }
  788. public byte TBD_MainVersion
  789. {
  790. get
  791. {
  792. return this.data.TBD_MainVersion;
  793. }
  794. }
  795. public byte TBD_SubVersion
  796. {
  797. get
  798. {
  799. return this.data.TBD_SubVersion;
  800. }
  801. }
  802. public byte RCV_BaudRate
  803. {
  804. get
  805. {
  806. return this.data.RCV_BaudRate;
  807. }
  808. }
  809. public byte TBD_Loop1_BaudRate
  810. {
  811. get
  812. {
  813. return this.data.TBD_Loop1_BaudRate;
  814. }
  815. }
  816. public byte TBD_Loop2_BaudRate
  817. {
  818. get
  819. {
  820. return this.data.TBD_Loop2_BaudRate;
  821. }
  822. }
  823. public byte TBD_Term
  824. {
  825. get
  826. {
  827. return this.data.TBD_Term;
  828. }
  829. }
  830. //24v 하위바이트
  831. public byte TBD_24Voltage_d
  832. {
  833. get
  834. {
  835. return this.data.TBD_24Voltage_d;
  836. }
  837. }
  838. //24v 상위바이트
  839. public byte TBD_24Voltage_u
  840. {
  841. get
  842. {
  843. return this.data.TBD_24Voltage_u;
  844. }
  845. }
  846. public double TBD_24Voltage
  847. {
  848. get
  849. {
  850. //24V (상위*256 + 하위) / 100
  851. int vol = ((int)this.data.TBD_24Voltage_u * 256) + (int)this.data.TBD_24Voltage_d;
  852. return vol / 100;
  853. }
  854. }
  855. public byte TBD_5Voltage_d
  856. {
  857. get
  858. {
  859. return this.data.TBD_5Voltage_d;
  860. }
  861. }
  862. public byte TBD_5Voltage_u
  863. {
  864. get
  865. {
  866. return this.data.TBD_5Voltage_u;
  867. }
  868. }
  869. public byte TBD_33Voltage_d
  870. {
  871. get
  872. {
  873. return this.data.TBD_33Voltage_d;
  874. }
  875. }
  876. public byte TBD_33Voltage_u
  877. {
  878. get
  879. {
  880. return this.data.TBD_33Voltage_u;
  881. }
  882. }
  883. public byte TBD_Cut
  884. {
  885. get
  886. {
  887. return this.data.TBD_Cut;
  888. }
  889. }
  890. }
  891. public class RCVData_WriteTBoardStatus
  892. {
  893. private TBoardBaseInfo baseInfo;
  894. private TBoardData data;
  895. public RCVData_WriteTBoardStatus(byte[] buffer)
  896. {
  897. try
  898. {
  899. this.baseInfo = new TBoardBaseInfo(buffer);
  900. this.data = new TBoardData(buffer);
  901. }
  902. catch (Exception ex)
  903. {
  904. Util.UErrorMessage(ex, 0, 0);
  905. }
  906. }
  907. /////// base info /////////////////
  908. public byte TBD_ID
  909. {
  910. get
  911. {
  912. return this.baseInfo.TBD_ID;
  913. }
  914. }
  915. public byte Repeater_loop
  916. {
  917. get
  918. {
  919. return this.baseInfo.Repeater_loop;
  920. }
  921. }
  922. public byte InvorkNo
  923. {
  924. get
  925. {
  926. return this.baseInfo.InvorkNo;
  927. }
  928. }
  929. public byte ReceiverID
  930. {
  931. get
  932. {
  933. return this.baseInfo.ReceiverID;
  934. }
  935. }
  936. /////// data /////////////////
  937. public TBoardData Data
  938. {
  939. get
  940. {
  941. return this.data;
  942. }
  943. }
  944. public byte TBD_MainVersion
  945. {
  946. get
  947. {
  948. return this.data.TBD_MainVersion;
  949. }
  950. }
  951. public byte TBD_SubVersion
  952. {
  953. get
  954. {
  955. return this.data.TBD_SubVersion;
  956. }
  957. }
  958. public byte RCV_BaudRate
  959. {
  960. get
  961. {
  962. return this.data.RCV_BaudRate;
  963. }
  964. }
  965. public byte TBD_Loop1_BaudRate
  966. {
  967. get
  968. {
  969. return this.data.TBD_Loop1_BaudRate;
  970. }
  971. }
  972. public byte TBD_Loop2_BaudRate
  973. {
  974. get
  975. {
  976. return this.data.TBD_Loop2_BaudRate;
  977. }
  978. }
  979. public byte TBD_Term
  980. {
  981. get
  982. {
  983. return this.data.TBD_Term;
  984. }
  985. }
  986. public byte TBD_24Voltage_d
  987. {
  988. get
  989. {
  990. return this.data.TBD_24Voltage_d;
  991. }
  992. }
  993. public byte TBD_24Voltage_u
  994. {
  995. get
  996. {
  997. return this.data.TBD_24Voltage_u;
  998. }
  999. }
  1000. public byte TBD_5Voltage_d
  1001. {
  1002. get
  1003. {
  1004. return this.data.TBD_5Voltage_d;
  1005. }
  1006. }
  1007. public byte TBD_5Voltage_u
  1008. {
  1009. get
  1010. {
  1011. return this.data.TBD_5Voltage_u;
  1012. }
  1013. }
  1014. public byte TBD_33Voltage_d
  1015. {
  1016. get
  1017. {
  1018. return this.data.TBD_33Voltage_d;
  1019. }
  1020. }
  1021. public byte TBD_33Voltage_u
  1022. {
  1023. get
  1024. {
  1025. return this.data.TBD_33Voltage_u;
  1026. }
  1027. }
  1028. public byte TBD_Cut
  1029. {
  1030. get
  1031. {
  1032. return this.data.TBD_Cut;
  1033. }
  1034. }
  1035. }
  1036. public class RepeaterBaseInfo
  1037. {
  1038. public byte TBD_ID = 0;
  1039. public byte Repeater_loop = 0;
  1040. public byte ReceiverID = 0;
  1041. public byte InvorkNo = 0;
  1042. public RepeaterBaseInfo(byte[] buffer)
  1043. {
  1044. try
  1045. {
  1046. this.TBD_ID = buffer[2];
  1047. this.Repeater_loop = buffer[1];
  1048. if (buffer[3] == 0x00)
  1049. {
  1050. this.InvorkNo = buffer[7];
  1051. this.ReceiverID = buffer[8];
  1052. }
  1053. else
  1054. {
  1055. this.InvorkNo = buffer[5];
  1056. this.ReceiverID = buffer[6];
  1057. }
  1058. }
  1059. catch (Exception ex)
  1060. {
  1061. Util.UErrorMessage(ex, 0, 0);
  1062. }
  1063. }
  1064. }
  1065. // cyim 2015.7.2 주석 정리 : 프로토콜 설명부
  1066. public class RepeaterData
  1067. {
  1068. // repeater id//
  1069. public byte repeater_ID = 0;
  1070. // repeater state //
  1071. public bool Err = false; // 중계기 송수신 Error
  1072. public bool Non = false; // 존재하지 않는 중계기
  1073. public bool R0 = false; // Reserved - 0 정상, 1 전원이상
  1074. public bool R1 = false; // Reserved - 0 정상, 1 아날로그감지기 Fault
  1075. public bool R2 = false;
  1076. public bool R = false; // Recovery Input Port - 중계기 복구 명령 (07H) 의 결과를 나타내며, 명령 수행이 완료되지 않았으면 1, 완료되었으면 0
  1077. public bool W = false; // Write Complete - 중계기 포인트 쓰기 명령 (03H) 의 결과를 나타내며, 명령 수행이 완료되지 않았으면 1, 완료되었으면 0
  1078. public bool S = false; // Search Complete - 중계기 검색 명령 (06H) 의 결과를 나타내며, 명령 수행이 완료되지 않았으면 1, 완료되었으면 0
  1079. // repeater input //
  1080. public int Repeater_state_1 = 0;
  1081. public int Repeater_state_2 = 0;
  1082. public int Repeater_state_3 = 0;
  1083. public int Repeater_state_4 = 0;
  1084. // repeater output //
  1085. public bool Repeater_output_4_C = false;
  1086. public bool Repeater_output_3_C = false;
  1087. public bool Repeater_output_2_C = false;
  1088. public bool Repeater_output_1_C = false;
  1089. public bool Repeater_output_4_W = false;
  1090. public bool Repeater_output_3_W = false;
  1091. public bool Repeater_output_2_W = false;
  1092. public bool Repeater_output_1_W = false;
  1093. // repeater info //
  1094. public bool B = false;
  1095. public bool Rserved1 = false;
  1096. public bool Rserved2 = false;
  1097. public bool Rserved3 = false;
  1098. // cyim 2015.6.8 아날로그 감지기 연동 추가
  1099. // '1' = A : 2X2
  1100. // '2' = B : 4X4
  1101. // '4' = C : 아날로그연감지기
  1102. // '5' = D : 아날로그열감지기
  1103. public int RepeaterSetting = 0;
  1104. // repeater byte data //
  1105. public byte Repeater_Output = 0x00;
  1106. public byte Repeater_Input = 0x00;
  1107. public byte Repeater_Info = 0x00;
  1108. public byte Repeater_Status = 0x00;
  1109. // cyim 2015.7.1 입력회로 상태값 추가 : 아날로그 감지기 연동으로 인하여 입력값은 중계기든 아날로그 감지기는 반드시 1byte 저장하게 된다
  1110. public int AnalogDetecterValue_Input = 0; // 중계기 Block 포인트 읽기 0x14 를 위함
  1111. // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기
  1112. public byte AnalogDetecterFault = 0x00;
  1113. public byte AnalogDetecterPreFire = 0x00;
  1114. public byte AnalogDetecterFireNight = 0x00;
  1115. public byte AnalogDetecterFireDay = 0x00;
  1116. public bool AnalogDetecter = false;
  1117. private int mode = 0;
  1118. public int Mode
  1119. {
  1120. get
  1121. {
  1122. return this.mode;
  1123. }
  1124. }
  1125. //
  1126. ////////////////// response data input /////////////////
  1127. //
  1128. // only use real data input
  1129. public RepeaterData(byte RepeaterID)
  1130. {
  1131. try
  1132. {
  1133. this.repeater_ID = RepeaterID;
  1134. this.mode = 1;
  1135. }
  1136. catch (Exception ex)
  1137. {
  1138. Util.UErrorMessage(ex, 0, 0);
  1139. }
  1140. }
  1141. // 설정
  1142. public RepeaterData(byte RepeaterID, byte Info)
  1143. {
  1144. try
  1145. {
  1146. this.repeater_ID = RepeaterID;
  1147. this.mode = 2;
  1148. this.Set_Info_Data(Info);
  1149. }
  1150. catch (Exception ex)
  1151. {
  1152. Util.UErrorMessage(ex, 0, 0);
  1153. }
  1154. }
  1155. // 상태 + 입력 + 출력
  1156. public RepeaterData(byte RepeaterID, byte Status, byte Input, byte Output)
  1157. {
  1158. try
  1159. {
  1160. this.repeater_ID = RepeaterID;
  1161. this.mode = 3;
  1162. this.Set_Status_Data(Status);
  1163. this.Set_Input_Data(Input);
  1164. this.Set_Output_Data(Output);
  1165. // cyim 2015.7.1 입력회로 상태값 추가 : 아날로그 감지기 연동으로 인하여 입력값은 중계기든 아날로그 감지기는 반드시 1byte 저장하게 된다
  1166. // 아날로그 감지기 입력값을 위해 Raw 데이터를 저장해둔다, 단 상위 1 bit 를 제거해서 (화재) 온전한 감지값만을 보관하고 있으면 된다
  1167. // 차후에 중계기가 이 정보를 저장해도 소용없도록, 아날로그 감지기에서만 사용하게만 하면 무리가 없다고 판단됨
  1168. this.AnalogDetecterValue_Input = Input & 0x7F;
  1169. }
  1170. catch (Exception ex)
  1171. {
  1172. Util.UErrorMessage(ex, 0, 0);
  1173. }
  1174. }
  1175. // 상태 + 입력 + 출력
  1176. public RepeaterData(byte RepeaterID, byte Status, byte Input, byte Output, byte Info)
  1177. {
  1178. try
  1179. {
  1180. this.repeater_ID = RepeaterID;
  1181. this.mode = 4;
  1182. this.Set_Status_Data(Status);
  1183. this.Set_Output_Data(Output);
  1184. this.Set_Input_Data(Input);
  1185. this.Set_Status_Data(this.Err, this.Non, this.R0, this.R1, this.R2, this.R, this.W, this.S);
  1186. this.Set_Output_Data(this.Repeater_output_4_C, this.Repeater_output_3_C, this.Repeater_output_2_C, this.Repeater_output_1_C, this.Repeater_output_4_W, this.Repeater_output_3_W, this.Repeater_output_2_W, this.Repeater_output_1_W);
  1187. this.Set_Input_Data(this.Repeater_state_4, this.Repeater_state_3, this.Repeater_state_2, this.Repeater_state_1);
  1188. this.Set_Info_Data(this.B, this.Rserved1, this.Rserved2, this.Rserved3, this.RepeaterSetting);
  1189. // cyim 2013.7.19 속도개선작업
  1190. //TDebug.DoPrintDBGMSG("initial input, ID : " + RepeaterID.ToString() + " :"+ Status.ToString() + "," + Input.ToString() + "," + Output.ToString() + "," + Info.ToString());
  1191. //TDebug.DoPrintDBGMSG("Status = "+ Err.ToString() + "," + Non.ToString() + "," + R0.ToString() + "," + R1.ToString()
  1192. // + "," + R2.ToString() + "," + R.ToString() + "," + W.ToString() + "," + S.ToString());
  1193. //TDebug.DoPrintDBGMSG("input = "+ Repeater_state_1.ToString() + "," + Repeater_state_2.ToString() + ","
  1194. // + Repeater_state_3.ToString() + "," + Repeater_state_4.ToString());
  1195. //TDebug.DoPrintDBGMSG("Output = "+ Repeater_output_4_C.ToString() + "," + Repeater_output_3_C.ToString()
  1196. // + "," + Repeater_output_2_C.ToString() + "," + Repeater_output_1_C.ToString()
  1197. // + "," + Repeater_output_4_W.ToString() + "," + Repeater_output_3_W.ToString()
  1198. // + "," + Repeater_output_2_W.ToString() + "," + Repeater_output_1_W.ToString());
  1199. //TDebug.DoPrintDBGMSG("info = "+ B.ToString() + "," + Rserved1.ToString() + "," + Rserved3.ToString()
  1200. // + "," + Rserved3.ToString() + "," + RepeaterSetting.ToString() );
  1201. //TDebug.DoPrintDBGMSG("final data = "+ Repeater_Status.ToString() + "," + Repeater_Input.ToString()
  1202. // + "," + Repeater_Output.ToString() + "," + Repeater_Info.ToString() );
  1203. }
  1204. catch (Exception ex)
  1205. {
  1206. Util.UErrorMessage(ex, 0, 0);
  1207. }
  1208. }
  1209. //
  1210. ////////////////// cmd data input /////////////////
  1211. //
  1212. // 상태
  1213. public void Set_Status_Data(bool Err, bool Non, bool R0, bool R1, bool R2, bool R, bool W, bool S)
  1214. {
  1215. try
  1216. {
  1217. this.Repeater_Status = 0x00;
  1218. this.Repeater_Status = (byte)(Convert.ToByte(Err) << 7);
  1219. this.Repeater_Status += (byte)(Convert.ToByte(Non) << 6);
  1220. this.Repeater_Status += (byte)(Convert.ToByte(R0) << 5);
  1221. this.Repeater_Status += (byte)(Convert.ToByte(R1) << 4);
  1222. this.Repeater_Status += (byte)(Convert.ToByte(R2) << 3);
  1223. this.Repeater_Status += (byte)(Convert.ToByte(R) << 2);
  1224. this.Repeater_Status += (byte)(Convert.ToByte(W) << 1);
  1225. this.Repeater_Status += (byte)(Convert.ToByte(S) << 0);
  1226. }
  1227. catch (Exception ex)
  1228. {
  1229. Util.UErrorMessage(ex, 0, 0);
  1230. }
  1231. }
  1232. // 읽기
  1233. public void Set_Input_Data(int Repeater_state_4, int Repeater_state_3, int Repeater_state_2, int Repeater_state_1)
  1234. {
  1235. try
  1236. {
  1237. this.Repeater_Input = 0x00;
  1238. this.Repeater_Input = (byte)((Repeater_state_4 & 0x03) << 6);
  1239. this.Repeater_Input += (byte)((Repeater_state_3 & 0x03) << 4);
  1240. this.Repeater_Input += (byte)((Repeater_state_2 & 0x03) << 2);
  1241. this.Repeater_Input += (byte)((Repeater_state_1 & 0x03) << 0);
  1242. }
  1243. catch (Exception ex)
  1244. {
  1245. Util.UErrorMessage(ex, 0, 0);
  1246. }
  1247. }
  1248. // 출력
  1249. public void Set_Output_Data(bool Repeater_output_4_C, bool Repeater_output_3_C, bool Repeater_output_2_C, bool Repeater_output_1_C,
  1250. bool Repeater_output_4_W, bool Repeater_output_3_W, bool Repeater_output_2_W, bool Repeater_output_1_W)
  1251. {
  1252. try
  1253. {
  1254. this.Repeater_Output = 0x00;
  1255. this.Repeater_Output = (byte)(Convert.ToByte(Repeater_output_4_C) << 7);
  1256. this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_3_C) << 6);
  1257. this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_2_C) << 5);
  1258. this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_1_C) << 4);
  1259. this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_4_W) << 3);
  1260. this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_3_W) << 2);
  1261. this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_2_W) << 1);
  1262. this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_1_W) << 0);
  1263. }
  1264. catch (Exception ex)
  1265. {
  1266. Util.UErrorMessage(ex, 0, 0);
  1267. }
  1268. }
  1269. // 설정
  1270. public void Set_Info_Data(bool B, bool FireResetFlag, bool Reserved2, bool Reserved3, int RepeaterSetting)
  1271. {
  1272. try
  1273. {
  1274. this.Repeater_Info = 0x00;
  1275. this.Repeater_Info = (byte)(Convert.ToByte(B) << 7);
  1276. this.Repeater_Info += (byte)(Convert.ToByte(FireResetFlag) << 6);
  1277. this.Repeater_Info += (byte)(Convert.ToByte(Reserved2) << 5);
  1278. this.Repeater_Info += (byte)(Convert.ToByte(Reserved3) << 4);
  1279. byte tmp_data = 0x00;
  1280. // cyim 2015.6.8 아날로그 감지기 연동 추가
  1281. // '1' = A : 2X2
  1282. // '2' = B : 4X4
  1283. // '4' = C : 아날로그연감지기
  1284. // '5' = D : 아날로그열감지기
  1285. // 0 0 0 0 : 중계기 연결 안됨
  1286. // 0 0 0 1 : 2 * 2 중계기
  1287. // 0 0 1 0 : 4 * 4 중계기
  1288. // 0 1 0 0 : 아날로그 연감지기
  1289. // 0 1 0 1 : 아날로그 열감지기
  1290. switch (RepeaterSetting)
  1291. {
  1292. case 0:
  1293. {
  1294. tmp_data = 0x00;
  1295. break;
  1296. }
  1297. case 1:
  1298. {
  1299. tmp_data = 0x01;
  1300. break;
  1301. }
  1302. case 2:
  1303. {
  1304. tmp_data = 0x02;
  1305. break;
  1306. }
  1307. case 4:
  1308. {
  1309. tmp_data = 0x04;
  1310. break;
  1311. }
  1312. case 5:
  1313. {
  1314. tmp_data = 0x05;
  1315. break;
  1316. }
  1317. default:
  1318. {
  1319. tmp_data = 0x00;
  1320. break;
  1321. }
  1322. }
  1323. this.Repeater_Info += tmp_data;
  1324. ////Util.UDebugMessage(string.Format("Set_Info_Data Repeater={0} Repeater_Info={1} ", this.repeater_ID, this.Repeater_Info), 0, 0);
  1325. }
  1326. catch (Exception ex)
  1327. {
  1328. Util.UErrorMessage(ex, 0, 0);
  1329. }
  1330. }
  1331. //
  1332. ////////////////// byte data input /////////////////
  1333. //
  1334. // 상태
  1335. private void Set_Status_Data(byte in_data)
  1336. {
  1337. try
  1338. {
  1339. this.Err = (((in_data >> 7) & 0x01) == 0x01);
  1340. this.Non = (((in_data >> 6) & 0x01) == 0x01);
  1341. this.R0 = (((in_data >> 5) & 0x01) == 0x01);
  1342. this.R1 = (((in_data >> 4) & 0x01) == 0x01);
  1343. this.R2 = (((in_data >> 3) & 0x01) == 0x01);
  1344. this.R = (((in_data >> 2) & 0x01) == 0x01);
  1345. this.W = (((in_data >> 1) & 0x01) == 0x01);
  1346. this.S = (((in_data >> 0) & 0x01) == 0x01);
  1347. }
  1348. catch (Exception ex)
  1349. {
  1350. Util.UErrorMessage(ex, 0, 0);
  1351. }
  1352. }
  1353. // 입력
  1354. private void Set_Input_Data(byte in_data)
  1355. {
  1356. try
  1357. {
  1358. this.Repeater_state_4 = (in_data >> 6) & 0x03;
  1359. this.Repeater_state_3 = (in_data >> 4) & 0x03;
  1360. this.Repeater_state_2 = (in_data >> 2) & 0x03;
  1361. this.Repeater_state_1 = (in_data >> 0) & 0x03;
  1362. }
  1363. catch (Exception ex)
  1364. {
  1365. Util.UErrorMessage(ex, 0, 0);
  1366. }
  1367. }
  1368. // 출력
  1369. private void Set_Output_Data(byte in_data)
  1370. {
  1371. try
  1372. {
  1373. this.Repeater_output_4_C = (((in_data >> 7) & 0x01) == 0x01);
  1374. this.Repeater_output_3_C = (((in_data >> 6) & 0x01) == 0x01);
  1375. this.Repeater_output_2_C = (((in_data >> 5) & 0x01) == 0x01);
  1376. this.Repeater_output_1_C = (((in_data >> 4) & 0x01) == 0x01);
  1377. this.Repeater_output_4_W = (((in_data >> 3) & 0x01) == 0x01);
  1378. this.Repeater_output_3_W = (((in_data >> 2) & 0x01) == 0x01);
  1379. this.Repeater_output_2_W = (((in_data >> 1) & 0x01) == 0x01);
  1380. this.Repeater_output_1_W = (((in_data >> 0) & 0x01) == 0x01);
  1381. }
  1382. catch (Exception ex)
  1383. {
  1384. Util.UErrorMessage(ex, 0, 0);
  1385. }
  1386. }
  1387. // 설정
  1388. private void Set_Info_Data(byte InfoData)
  1389. {
  1390. try
  1391. {
  1392. this.B = (((InfoData >> 7) & 0x01) == 0x01);
  1393. this.Rserved1 = (((InfoData >> 6) & 0x01) == 0x01);
  1394. this.Rserved2 = (((InfoData >> 5) & 0x01) == 0x01);
  1395. this.Rserved3 = (((InfoData >> 4) & 0x01) == 0x01);
  1396. int tmp_data = (InfoData >> 0) & 0x0f;
  1397. // cyim 2015.6.8 아날로그 감지기 연동 추가
  1398. // '1' = A : 2X2
  1399. // '2' = B : 4X4
  1400. // '4' = C : 아날로그연감지기
  1401. // '5' = D : 아날로그열감지기
  1402. // 0 0 0 0 : 중계기 연결 안됨
  1403. // 0 0 0 1 : 2 * 2 중계기
  1404. // 0 0 1 0 : 4 * 4 중계기
  1405. // 0 1 0 0 : 아날로그 연감지기
  1406. // 0 1 0 1 : 아날로그 열감지기
  1407. switch (tmp_data)
  1408. {
  1409. case 0x00:
  1410. {
  1411. this.RepeaterSetting = 0; // 중계기 연결 안됨
  1412. break;
  1413. }
  1414. case 0x01:
  1415. {
  1416. this.RepeaterSetting = 1; // 2*2 중계기
  1417. break;
  1418. }
  1419. case 0x02:
  1420. {
  1421. this.RepeaterSetting = 2; // 4*4 중계기
  1422. break;
  1423. }
  1424. case 0x04:
  1425. {
  1426. this.RepeaterSetting = 4; // 아날로그 연감지기
  1427. break;
  1428. }
  1429. case 0x05:
  1430. {
  1431. this.RepeaterSetting = 5; // 아날로그 열감지기
  1432. break;
  1433. }
  1434. default:
  1435. {
  1436. this.RepeaterSetting = -1;
  1437. break;
  1438. }
  1439. }
  1440. }
  1441. catch (Exception ex)
  1442. {
  1443. Util.UErrorMessage(ex, 0, 0);
  1444. }
  1445. }
  1446. // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기
  1447. public void Set_Level_AnalogDetecter(byte Fault, byte PreFire, byte FireNight, byte FireDay)
  1448. {
  1449. this.AnalogDetecterFault = Fault;
  1450. this.AnalogDetecterPreFire = PreFire;
  1451. this.AnalogDetecterFireNight = FireNight;
  1452. this.AnalogDetecterFireDay = FireDay;
  1453. this.AnalogDetecter = true;
  1454. }
  1455. }
  1456. public class RCVData_ReadRepeaterPointAll
  1457. {
  1458. private RepeaterBaseInfo baseInfo;
  1459. private RepeaterData[] data = new RepeaterData[127];
  1460. public RCVData_ReadRepeaterPointAll(byte[] buffer)
  1461. {
  1462. try
  1463. {
  1464. this.baseInfo = new RepeaterBaseInfo(buffer);
  1465. for (int i = 0; i < 127; i++)
  1466. {
  1467. // cyim 2015.7.1 입력회로 상태값 추가 : 아날로그 감지기 연동으로 인하여 입력값은 중계기든 아날로그 감지기는 반드시 1byte 저장하게 된다
  1468. // 아날로그 감지기의 경우. 입력이 1byte 로 들어온다. 2^7 승 (하위 7bit 사용)
  1469. // 하지만 중계기 클래스를 생성할때 중계기 타입에 맞추어서 저장하기에는 너무 빠른 속도로 패킷이 들어온다
  1470. // 중계기 상태보기와 같이 특별한 경우에는 UI 에서 미리 중계기에 해당하는 레벨을 알아두고
  1471. // 각각의 입력값 1byte 는 raw 데이타로 항상 가지고 있도록 해야한다
  1472. this.data[i] = new RepeaterData((byte)(i + 1), buffer[3 * i + 9], buffer[3 * i + 10], buffer[3 * i + 11]);
  1473. }
  1474. }
  1475. catch (Exception ex)
  1476. {
  1477. Util.UErrorMessage(ex, 0, 0);
  1478. }
  1479. }
  1480. public byte TBD_ID
  1481. {
  1482. get
  1483. {
  1484. return baseInfo.TBD_ID;
  1485. }
  1486. }
  1487. public byte Repeater_loop
  1488. {
  1489. get
  1490. {
  1491. return baseInfo.Repeater_loop;
  1492. }
  1493. }
  1494. public byte InvorkNo
  1495. {
  1496. get
  1497. {
  1498. return baseInfo.InvorkNo;
  1499. }
  1500. }
  1501. public byte ReceiverID
  1502. {
  1503. get
  1504. {
  1505. return baseInfo.ReceiverID;
  1506. }
  1507. }
  1508. public RepeaterData[] Data
  1509. {
  1510. get
  1511. {
  1512. return data;
  1513. }
  1514. }
  1515. }
  1516. public class RCVData_WriteRepeaterOutputUNIT
  1517. {
  1518. private RepeaterBaseInfo baseInfo;
  1519. private RepeaterData data;
  1520. public RCVData_WriteRepeaterOutputUNIT(byte[] buffer)
  1521. {
  1522. try
  1523. {
  1524. this.baseInfo = new RepeaterBaseInfo(buffer);
  1525. this.data = new RepeaterData(buffer[7], buffer[8], buffer[9], buffer[10]);
  1526. }
  1527. catch (Exception ex)
  1528. {
  1529. Util.UErrorMessage(ex, 0, 0);
  1530. }
  1531. }
  1532. public byte TBD_ID
  1533. {
  1534. get
  1535. {
  1536. return this.baseInfo.TBD_ID;
  1537. }
  1538. }
  1539. public byte Repeater_loop
  1540. {
  1541. get
  1542. {
  1543. return this.baseInfo.Repeater_loop;
  1544. }
  1545. }
  1546. public byte InvorkNo
  1547. {
  1548. get
  1549. {
  1550. return this.baseInfo.InvorkNo;
  1551. }
  1552. }
  1553. public byte ReceiverID
  1554. {
  1555. get
  1556. {
  1557. return this.baseInfo.ReceiverID;
  1558. }
  1559. }
  1560. public RepeaterData Data
  1561. {
  1562. get
  1563. {
  1564. return this.data;
  1565. }
  1566. }
  1567. }
  1568. public class RCVData_ReadRepeaterInfoAll
  1569. {
  1570. private RepeaterBaseInfo baseInfo;
  1571. private RepeaterData[] data = new RepeaterData[127];
  1572. public RCVData_ReadRepeaterInfoAll(byte[] buffer)
  1573. {
  1574. try
  1575. {
  1576. this.baseInfo = new RepeaterBaseInfo(buffer);
  1577. for (int i = 0; i < 127; i++)
  1578. {
  1579. this.data[i] = new RepeaterData((byte)(i + 1), buffer[i + 7]);
  1580. }
  1581. }
  1582. catch (Exception ex)
  1583. {
  1584. Util.UErrorMessage(ex, 0, 0);
  1585. }
  1586. }
  1587. public byte TBD_ID
  1588. {
  1589. get
  1590. {
  1591. return this.baseInfo.TBD_ID;
  1592. }
  1593. }
  1594. public byte Repeater_loop
  1595. {
  1596. get
  1597. {
  1598. return this.baseInfo.Repeater_loop;
  1599. }
  1600. }
  1601. public byte InvorkNo
  1602. {
  1603. get
  1604. {
  1605. return this.baseInfo.InvorkNo;
  1606. }
  1607. }
  1608. public byte ReceiverID
  1609. {
  1610. get
  1611. {
  1612. return this.baseInfo.ReceiverID;
  1613. }
  1614. }
  1615. public RepeaterData[] Data
  1616. {
  1617. get
  1618. {
  1619. return data;
  1620. }
  1621. }
  1622. }
  1623. public class RCVData_WriteRepeaterInfoUNIT
  1624. {
  1625. private RepeaterBaseInfo baseInfo;
  1626. private RepeaterData data;
  1627. public RCVData_WriteRepeaterInfoUNIT(byte[] buffer)
  1628. {
  1629. try
  1630. {
  1631. this.baseInfo = new RepeaterBaseInfo(buffer);
  1632. this.data = new RepeaterData(buffer[7], buffer[8]);
  1633. }
  1634. catch (Exception ex)
  1635. {
  1636. Util.UErrorMessage(ex, 0, 0);
  1637. }
  1638. }
  1639. public byte TBD_ID
  1640. {
  1641. get
  1642. {
  1643. return this.baseInfo.TBD_ID;
  1644. }
  1645. }
  1646. public byte Repeater_loop
  1647. {
  1648. get
  1649. {
  1650. return this.baseInfo.Repeater_loop;
  1651. }
  1652. }
  1653. public byte InvorkNo
  1654. {
  1655. get
  1656. {
  1657. return this.baseInfo.InvorkNo;
  1658. }
  1659. }
  1660. public byte ReceiverID
  1661. {
  1662. get
  1663. {
  1664. return this.baseInfo.ReceiverID;
  1665. }
  1666. }
  1667. public RepeaterData Data
  1668. {
  1669. get
  1670. {
  1671. return this.data;
  1672. }
  1673. }
  1674. }
  1675. public class RCVData_WriteRepeaterInputUNIT
  1676. {
  1677. private RepeaterBaseInfo baseInfo;
  1678. private RepeaterData data;
  1679. public RCVData_WriteRepeaterInputUNIT(byte[] buffer)
  1680. {
  1681. try
  1682. {
  1683. this.baseInfo = new RepeaterBaseInfo(buffer);
  1684. this.data = new RepeaterData(buffer[7], buffer[8], buffer[9], buffer[10]);
  1685. }
  1686. catch (Exception ex)
  1687. {
  1688. Util.UErrorMessage(ex, 0, 0);
  1689. }
  1690. }
  1691. public byte TBD_ID
  1692. {
  1693. get
  1694. {
  1695. return this.baseInfo.TBD_ID;
  1696. }
  1697. }
  1698. public byte Repeater_loop
  1699. {
  1700. get
  1701. {
  1702. return this.baseInfo.Repeater_loop;
  1703. }
  1704. }
  1705. public byte InvorkNo
  1706. {
  1707. get
  1708. {
  1709. return this.baseInfo.InvorkNo;
  1710. }
  1711. }
  1712. public byte ReceiverID
  1713. {
  1714. get
  1715. {
  1716. return this.baseInfo.ReceiverID;
  1717. }
  1718. }
  1719. public RepeaterData Data
  1720. {
  1721. get
  1722. {
  1723. return this.data;
  1724. }
  1725. }
  1726. }
  1727. public class RCVData_SearchRepeaterUNIT
  1728. {
  1729. private RepeaterBaseInfo baseInfo;
  1730. private RepeaterData data;
  1731. public RCVData_SearchRepeaterUNIT(byte[] buffer)
  1732. {
  1733. try
  1734. {
  1735. this.baseInfo = new RepeaterBaseInfo(buffer);
  1736. this.data = new RepeaterData(buffer[7], buffer[8], buffer[9], buffer[10], buffer[11]);
  1737. }
  1738. catch (Exception ex)
  1739. {
  1740. Util.UErrorMessage(ex, 0, 0);
  1741. }
  1742. }
  1743. public byte TBD_ID
  1744. {
  1745. get
  1746. {
  1747. return this.baseInfo.TBD_ID;
  1748. }
  1749. }
  1750. public byte Repeater_loop
  1751. {
  1752. get
  1753. {
  1754. return this.baseInfo.Repeater_loop;
  1755. }
  1756. }
  1757. public byte InvorkNo
  1758. {
  1759. get
  1760. {
  1761. return this.baseInfo.InvorkNo;
  1762. }
  1763. }
  1764. public byte ReceiverID
  1765. {
  1766. get
  1767. {
  1768. return this.baseInfo.ReceiverID;
  1769. }
  1770. }
  1771. public RepeaterData Data
  1772. {
  1773. get
  1774. {
  1775. return this.data;
  1776. }
  1777. }
  1778. }
  1779. //2010.12.05, k.s.d, repeater information block write.
  1780. public class RepeaterDataAll
  1781. {
  1782. //private RepeaterBaseInfo baseInfo = null;
  1783. private RepeaterData[] data = new RepeaterData[127];
  1784. public byte InvorkNo = 0;
  1785. public byte ReceiverID = 0;
  1786. public byte Repeater_loop = 0;
  1787. public byte TBD_ID = 0;
  1788. public RepeaterDataAll()
  1789. {
  1790. try
  1791. {
  1792. for (int i = 0; i < 127; i++)
  1793. {
  1794. this.data[i] = new RepeaterData((byte)i, 0x00);
  1795. }
  1796. }
  1797. catch (Exception ex)
  1798. {
  1799. Util.UErrorMessage(ex, 0, 0);
  1800. }
  1801. }
  1802. //public byte TBD_ID
  1803. //{
  1804. // get
  1805. // {
  1806. // return this.baseInfo.TBD_ID;
  1807. // }
  1808. //}
  1809. //public byte Repeater_loop
  1810. //{
  1811. // get
  1812. // {
  1813. // return this.baseInfo.Repeater_loop;
  1814. // }
  1815. //}
  1816. //public byte InvorkNo
  1817. //{
  1818. // get
  1819. // {
  1820. // return this.baseInfo.InvorkNo;
  1821. // }
  1822. //}
  1823. //public byte ReceiverID
  1824. //{
  1825. // get
  1826. // {
  1827. // return this.baseInfo.ReceiverID;
  1828. // }
  1829. //}
  1830. public RepeaterData[] Data
  1831. {
  1832. get
  1833. {
  1834. return data;
  1835. }
  1836. }
  1837. }
  1838. public class IOBoardBaseInfo
  1839. {
  1840. public byte IOBD_ID = 0;
  1841. public byte Extend_ID = 0;
  1842. public byte ReceiverID = 0;
  1843. public byte InvorkNo = 0;
  1844. public IOBoardBaseInfo(byte[] buffer)
  1845. {
  1846. try
  1847. {
  1848. this.IOBD_ID = buffer[2];
  1849. this.Extend_ID = buffer[1];
  1850. if (buffer[3] == 0x00)
  1851. {
  1852. this.InvorkNo = buffer[7];
  1853. this.ReceiverID = buffer[8];
  1854. }
  1855. else
  1856. {
  1857. this.InvorkNo = buffer[5];
  1858. this.ReceiverID = buffer[6];
  1859. }
  1860. }
  1861. catch (Exception ex)
  1862. {
  1863. Util.UErrorMessage(ex, 0, 0);
  1864. }
  1865. }
  1866. }
  1867. public class IOBoardData
  1868. {
  1869. private int mode = 0;
  1870. public bool[] Input = new bool[16];
  1871. public bool[] Output = new bool[16];
  1872. public byte Version_d = 0;
  1873. public byte Version_u = 0;
  1874. public byte BaudRate = 0;
  1875. public byte Reset = 0;
  1876. /*
  1877. public byte IOBD_24Voltage_d = 0;
  1878. public byte IOBD_24Voltage_u = 0;
  1879. public byte IOBD_5Voltage_d = 0;
  1880. public byte IOBD_5Voltage_u = 0;
  1881. public byte IOBD_33Voltage_d = 0;
  1882. public byte IOBD_33Voltage_u = 0;
  1883. */
  1884. public float TBD_24Voltage;
  1885. public float TBD_5Voltage;
  1886. public float TBD_33Voltage;
  1887. public byte OutData_d = 0x00;
  1888. public byte OutData_u = 0x00;
  1889. public int Mode
  1890. {
  1891. get
  1892. {
  1893. return this.mode;
  1894. }
  1895. }
  1896. public IOBoardData()
  1897. {
  1898. try
  1899. {
  1900. this.mode = 1;
  1901. }
  1902. catch (Exception ex)
  1903. {
  1904. Util.UErrorMessage(ex, 0, 0);
  1905. }
  1906. }
  1907. public IOBoardData(byte BaudRate, byte Reset)
  1908. {
  1909. try
  1910. {
  1911. this.BaudRate = BaudRate;
  1912. this.Reset = Reset;
  1913. this.mode = 2;
  1914. }
  1915. catch (Exception ex)
  1916. {
  1917. Util.UErrorMessage(ex, 0, 0);
  1918. }
  1919. }
  1920. public IOBoardData(byte Version_d, byte Version_u, byte BaudRate)
  1921. {
  1922. try
  1923. {
  1924. this.Version_d = Version_d;
  1925. this.Version_u = Version_u;
  1926. this.BaudRate = BaudRate;
  1927. this.mode = 3;
  1928. }
  1929. catch (Exception ex)
  1930. {
  1931. Util.UErrorMessage(ex, 0, 0);
  1932. }
  1933. }
  1934. public IOBoardData(byte[] buffer)
  1935. {
  1936. try
  1937. {
  1938. for (int i = 0; i < 8; i++)
  1939. {
  1940. // this.Input[i] = (((buffer[7] >> (7-i)) & 0x01) == 0x01);
  1941. // this.Input[i+8] = (((buffer[8] >> (7-i)) & 0x01) == 0x01);
  1942. // this.Output[i] = (((buffer[9] >> (7-i)) & 0x01) == 0x01);
  1943. // this.Output[i+8] = (((buffer[10] >> (7-i)) & 0x01) == 0x01);
  1944. this.Input[i] = (((buffer[7] >> i) & 0x01) == 0x01);
  1945. this.Input[i + 8] = (((buffer[8] >> i) & 0x01) == 0x01);
  1946. this.Output[i] = (((buffer[9] >> i) & 0x01) == 0x01);
  1947. this.Output[i + 8] = (((buffer[10] >> i) & 0x01) == 0x01);
  1948. }
  1949. /*
  1950. this.IOBD_24Voltage_d = buffer[11];
  1951. this.IOBD_24Voltage_u = buffer[12];
  1952. this.IOBD_5Voltage_d = buffer[13];
  1953. this.IOBD_5Voltage_u = buffer[14];
  1954. this.IOBD_33Voltage_d = buffer[15];
  1955. this.IOBD_33Voltage_u = buffer[16];
  1956. */
  1957. this.TBD_24Voltage = (buffer[11] + 256 * buffer[12]) / 100;
  1958. this.TBD_5Voltage = (buffer[13] + 256 * buffer[14]) / 100;
  1959. this.TBD_33Voltage = (buffer[15] + 256 * buffer[16]) / 100;
  1960. this.mode = 4;
  1961. }
  1962. catch (Exception ex)
  1963. {
  1964. Util.UErrorMessage(ex, 0, 0);
  1965. }
  1966. }
  1967. public void Set_OutputData(int position, bool data)
  1968. {
  1969. try
  1970. {
  1971. this.Output[position] = data;
  1972. }
  1973. catch (Exception ex)
  1974. {
  1975. Util.UErrorMessage(ex, 0, 0);
  1976. }
  1977. }
  1978. public void Set_InputData(int position, bool data)
  1979. {
  1980. try
  1981. {
  1982. this.Input[position] = data;
  1983. }
  1984. catch (Exception ex)
  1985. {
  1986. Util.UErrorMessage(ex, 0, 0);
  1987. }
  1988. }
  1989. }
  1990. public class RCVData_ReadIOBoardStatus
  1991. {
  1992. private IOBoardBaseInfo baseInfo;
  1993. public byte Version_d = 0;
  1994. public byte Version_u = 0;
  1995. public byte BaudRate = 0;
  1996. public RCVData_ReadIOBoardStatus(byte[] buffer)
  1997. {
  1998. try
  1999. {
  2000. this.baseInfo = new IOBoardBaseInfo(buffer);
  2001. this.Version_d = buffer[7];
  2002. this.Version_u = buffer[8];
  2003. this.BaudRate = buffer[9];
  2004. }
  2005. catch (Exception ex)
  2006. {
  2007. Util.UErrorMessage(ex, 0, 0);
  2008. }
  2009. }
  2010. public byte IOBD_ID
  2011. {
  2012. get
  2013. {
  2014. return this.baseInfo.IOBD_ID;
  2015. }
  2016. }
  2017. public byte Extend_ID
  2018. {
  2019. get
  2020. {
  2021. return this.baseInfo.Extend_ID;
  2022. }
  2023. }
  2024. public byte InvorkNo
  2025. {
  2026. get
  2027. {
  2028. return this.baseInfo.InvorkNo;
  2029. }
  2030. }
  2031. public byte ReceiverID
  2032. {
  2033. get
  2034. {
  2035. return this.baseInfo.ReceiverID;
  2036. }
  2037. }
  2038. }
  2039. public class RCVData_WriteIOBoardStatus
  2040. {
  2041. private IOBoardBaseInfo baseInfo;
  2042. public byte BaudRate = 0;
  2043. public byte Reset = 0;
  2044. public RCVData_WriteIOBoardStatus(byte[] buffer)
  2045. {
  2046. try
  2047. {
  2048. this.baseInfo = new IOBoardBaseInfo(buffer);
  2049. this.BaudRate = buffer[7];
  2050. this.Reset = buffer[8];
  2051. }
  2052. catch (Exception ex)
  2053. {
  2054. Util.UErrorMessage(ex, 0, 0);
  2055. }
  2056. }
  2057. public byte IOBD_ID
  2058. {
  2059. get
  2060. {
  2061. return this.baseInfo.IOBD_ID;
  2062. }
  2063. }
  2064. public byte Extend_ID
  2065. {
  2066. get
  2067. {
  2068. return this.baseInfo.Extend_ID;
  2069. }
  2070. }
  2071. public byte InvorkNo
  2072. {
  2073. get
  2074. {
  2075. return this.baseInfo.InvorkNo;
  2076. }
  2077. }
  2078. public byte ReceiverID
  2079. {
  2080. get
  2081. {
  2082. return this.baseInfo.ReceiverID;
  2083. }
  2084. }
  2085. }
  2086. public class RCVData_ReadIOBoardData
  2087. {
  2088. private IOBoardBaseInfo baseInfo;
  2089. public bool[] input = new bool[16];
  2090. public bool[] output = new bool[16];
  2091. public float TBD_24Voltage;
  2092. public float TBD_5Voltage;
  2093. public float TBD_33Voltage;
  2094. public RCVData_ReadIOBoardData(byte[] buffer)
  2095. {
  2096. try
  2097. {
  2098. this.baseInfo = new IOBoardBaseInfo(buffer);
  2099. for (int i = 0; i < 8; i++)
  2100. {
  2101. // this.input[i] = (((buffer[7] >> (7-i)) & 0x01) == 0x01);
  2102. // this.input[i+8] = (((buffer[8] >> (7-i)) & 0x01) == 0x01);
  2103. // this.output[i] = (((buffer[9] >> (7-i)) & 0x01) == 0x01);
  2104. // this.output[i+8] = (((buffer[10] >> (7-i)) & 0x01) == 0x01);
  2105. this.input[i] = (((buffer[7] >> i) & 0x01) == 0x01);
  2106. this.input[i + 8] = (((buffer[8] >> i) & 0x01) == 0x01);
  2107. this.output[i] = (((buffer[9] >> i) & 0x01) == 0x01);
  2108. this.output[i + 8] = (((buffer[10] >> i) & 0x01) == 0x01);
  2109. }
  2110. this.TBD_24Voltage = (buffer[11] + 256 * buffer[12]) / 100;
  2111. this.TBD_5Voltage = (buffer[13] + 256 * buffer[14]) / 100;
  2112. this.TBD_33Voltage = (buffer[15] + 256 * buffer[16]) / 100;
  2113. }
  2114. catch (Exception ex)
  2115. {
  2116. Util.UErrorMessage(ex, 0, 0);
  2117. }
  2118. }
  2119. public byte IOBD_ID
  2120. {
  2121. get
  2122. {
  2123. return this.baseInfo.IOBD_ID;
  2124. }
  2125. }
  2126. public byte Extend_ID
  2127. {
  2128. get
  2129. {
  2130. return this.baseInfo.Extend_ID;
  2131. }
  2132. }
  2133. public byte InvorkNo
  2134. {
  2135. get
  2136. {
  2137. return this.baseInfo.InvorkNo;
  2138. }
  2139. }
  2140. public byte ReceiverID
  2141. {
  2142. get
  2143. {
  2144. return this.baseInfo.ReceiverID;
  2145. }
  2146. }
  2147. }
  2148. public class RCVData_WriteIOBoardData
  2149. {
  2150. private IOBoardBaseInfo baseInfo;
  2151. public bool[] input = new bool[16];
  2152. public bool[] output = new bool[16];
  2153. /*
  2154. * public byte IOBD_24Voltage_d;
  2155. public byte IOBD_24Voltage_u;
  2156. public byte IOBD_5Voltage_d;
  2157. public byte IOBD_5Voltage_u;
  2158. public byte IOBD_33Voltage_d;
  2159. public byte IOBD_33Voltage_u;
  2160. */
  2161. public float TBD_24Voltage;
  2162. public float TBD_5Voltage;
  2163. public float TBD_33Voltage;
  2164. public RCVData_WriteIOBoardData(byte[] buffer)
  2165. {
  2166. try
  2167. {
  2168. this.baseInfo = new IOBoardBaseInfo(buffer);
  2169. for (int i = 0; i < 8; i++)
  2170. {
  2171. // this.input[i] = (((buffer[7] >> (7-i)) & 0x01) == 0x01);
  2172. // this.input[i+8] = (((buffer[8] >> (7-i)) & 0x01) == 0x01);
  2173. // this.output[i] = (((buffer[9] >> (7-i)) & 0x01) == 0x01);
  2174. // this.output[i+8] = (((buffer[10] >> (7-i)) & 0x01) == 0x01);
  2175. this.input[i] = (((buffer[7] >> i) & 0x01) == 0x01);
  2176. this.input[i + 8] = (((buffer[8] >> i) & 0x01) == 0x01);
  2177. this.output[i] = (((buffer[9] >> i) & 0x01) == 0x01);
  2178. this.output[i + 8] = (((buffer[10] >> i) & 0x01) == 0x01);
  2179. }
  2180. // this.IOBD_24Voltage_d = buffer[11];
  2181. // this.IOBD_24Voltage_u = buffer[12];
  2182. // this.IOBD_5Voltage_d = buffer[13];
  2183. // this.IOBD_5Voltage_u = buffer[14];
  2184. // this.IOBD_33Voltage_d = buffer[15];
  2185. // this.IOBD_33Voltage_u = buffer[16];
  2186. this.TBD_24Voltage = (buffer[11] + 256 * buffer[12]) / 100;
  2187. this.TBD_5Voltage = (buffer[13] + 256 * buffer[14]) / 100;
  2188. this.TBD_33Voltage = (buffer[15] + 256 * buffer[16]) / 100;
  2189. }
  2190. catch (Exception ex)
  2191. {
  2192. Util.UErrorMessage(ex, 0, 0);
  2193. }
  2194. }
  2195. public byte IOBD_ID
  2196. {
  2197. get
  2198. {
  2199. return this.baseInfo.IOBD_ID;
  2200. }
  2201. }
  2202. public byte Extend_ID
  2203. {
  2204. get
  2205. {
  2206. return this.baseInfo.Extend_ID;
  2207. }
  2208. }
  2209. public byte InvorkNo
  2210. {
  2211. get
  2212. {
  2213. return this.baseInfo.InvorkNo;
  2214. }
  2215. }
  2216. public byte ReceiverID
  2217. {
  2218. get
  2219. {
  2220. return this.baseInfo.ReceiverID;
  2221. }
  2222. }
  2223. }
  2224. public class DemonBaseInfo
  2225. {
  2226. public byte ReceiverID = 0;
  2227. public byte InvorkNo = 0;
  2228. public DemonBaseInfo(byte[] buffer)
  2229. {
  2230. try
  2231. {
  2232. if (buffer[3] == 0x00)
  2233. {
  2234. this.InvorkNo = buffer[7];
  2235. this.ReceiverID = buffer[8];
  2236. }
  2237. else
  2238. {
  2239. this.InvorkNo = buffer[5];
  2240. this.ReceiverID = buffer[6];
  2241. }
  2242. }
  2243. catch (Exception ex)
  2244. {
  2245. Util.UErrorMessage(ex, 0, 0);
  2246. }
  2247. }
  2248. }
  2249. public class RCVData_ReadDemonStatus
  2250. {
  2251. private DemonBaseInfo baseInfo;
  2252. public byte Status = 0;
  2253. public RCVData_ReadDemonStatus(byte[] buffer)
  2254. {
  2255. try
  2256. {
  2257. this.baseInfo = new DemonBaseInfo(buffer);
  2258. this.Status = buffer[7];
  2259. }
  2260. catch (Exception ex)
  2261. {
  2262. Util.UErrorMessage(ex, 0, 0);
  2263. }
  2264. }
  2265. public byte InvorkNo
  2266. {
  2267. get
  2268. {
  2269. return this.baseInfo.InvorkNo;
  2270. }
  2271. }
  2272. public byte ReceiverID
  2273. {
  2274. get
  2275. {
  2276. return this.baseInfo.ReceiverID;
  2277. }
  2278. }
  2279. }
  2280. //누적정보 또는 차단명령결과 -- 추가1
  2281. public class RCVData_ReadCommandStatus
  2282. {
  2283. private int loop_no = 0;
  2284. private int board_id = 0;
  2285. private int invork_id = 0;
  2286. private int receiver_id = 0;
  2287. private int repeater_id = 0;
  2288. private int device_id = 0;
  2289. private String device_type = "";
  2290. private int comm_id = 0;
  2291. private string commandType;
  2292. private string subType; //회로타입(회로타입차단용)
  2293. private string applyRange; //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
  2294. private int status = 0; //
  2295. //누적카운트
  2296. private int reply_value1 = 0;
  2297. private int reply_value2 = 0;
  2298. private int reply_value3 = 0;
  2299. private int reply_value4 = 0;
  2300. private int reply_value5 = 0;
  2301. private int reply_value6 = 0;
  2302. private int reply_value7 = 0;
  2303. private int reply_value8 = 0;
  2304. //24Voltage
  2305. private float voltage24 = 0;
  2306. private float voltage5 = 0;
  2307. private float voltage3_3 = 0;
  2308. //통신보드 통신상태
  2309. private string[] boardConnStatus = new string[16];
  2310. // 트렌드값 (44개의 데이터)
  2311. private int[] analogDetecterTrend = new int[44];
  2312. public RCVData_ReadCommandStatus(byte[] buffer)
  2313. {
  2314. try
  2315. {
  2316. this.loop_no = (int)buffer[1];
  2317. this.board_id = (int)buffer[2];
  2318. this.invork_id = (int)buffer[5];
  2319. this.receiver_id = (int)buffer[6];
  2320. this.repeater_id = (int)buffer[7];
  2321. this.device_id = (int)buffer[8];
  2322. this.device_type = Util.ByteToStr(buffer, 9, 1);
  2323. this.comm_id = (int)buffer[10];
  2324. this.commandType = Util.ByteToStr(buffer, 11, 2);
  2325. this.subType = Util.ByteToStr(buffer, 13, 1);
  2326. this.applyRange = Util.ByteToStr(buffer, 14, 1);
  2327. this.status = (int)buffer[15];
  2328. // 전압
  2329. if (this.commandType.Equals("CV"))
  2330. {
  2331. //24V (상위*256 + 하위) / 100
  2332. this.voltage24 = Util.ToValtage((int)buffer[16], (int)buffer[17]);
  2333. this.voltage5 = Util.ToValtage((int)buffer[18], (int)buffer[19]);
  2334. this.voltage3_3 = Util.ToValtage((int)buffer[20], (int)buffer[21]);
  2335. }
  2336. //전체누적정보
  2337. else if (this.commandType.Equals("CC") || this.commandType.Equals("VI"))
  2338. {
  2339. this.reply_value1 = (int)buffer[17] * 256 + (int)buffer[16]; // 통신이상
  2340. this.reply_value2 = (int)buffer[19] * 256 + (int)buffer[18]; // 설비
  2341. this.reply_value3 = (int)buffer[21] * 256 + (int)buffer[20];
  2342. this.reply_value4 = (int)buffer[23] * 256 + (int)buffer[22]; // 화재
  2343. this.reply_value5 = (int)buffer[25] * 256 + (int)buffer[24]; // 단선
  2344. this.reply_value6 = (int)buffer[27] * 256 + (int)buffer[26];
  2345. this.reply_value7 = (int)buffer[29] * 256 + (int)buffer[28]; // 차단
  2346. this.reply_value8 = (int)buffer[31] * 256 + (int)buffer[30];
  2347. }
  2348. //환경정보변경
  2349. else if (this.commandType.Equals("CS"))
  2350. {
  2351. this.reply_value1 = (int)buffer[17] * 256 + (int)buffer[16];
  2352. //this.reply_value2 = (int)buffer[19] * 256 + (int)buffer[18];
  2353. //this.reply_value3 = (int)buffer[21] * 256 + (int)buffer[20];
  2354. //this.reply_value4 = (int)buffer[23] * 256 + (int)buffer[22];
  2355. //this.reply_value5 = (int)buffer[25] * 256 + (int)buffer[24];
  2356. }
  2357. //통신보드 통신상태 F-front,B-back,X-error,N-none
  2358. else if (this.commandType.Equals("BS"))
  2359. {
  2360. // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다
  2361. // cyim 2016.11.03 : 통신보드(중계반)는 최대 64
  2362. for (int i = 0; i < 65; i++)
  2363. {
  2364. boardConnStatus[i] = Util.ByteToStr(buffer, 16 + i, 1);
  2365. }
  2366. }
  2367. // cyim 2015.7.5 아날로그 감지기 트렌드 읽기 명령 프로토콜 추가
  2368. else if (this.commandType.Equals("TR"))
  2369. {
  2370. for (int i = 0; i < 44; i++)
  2371. {
  2372. // ex : 0x20 =>
  2373. analogDetecterTrend[i] = Convert.ToInt32(buffer[32 + i]);//(buffer, 16 + i, 1);
  2374. }
  2375. }
  2376. }
  2377. catch (Exception ex)
  2378. {
  2379. Util.UErrorMessage(ex, 0, 0);
  2380. }
  2381. }
  2382. public String CommandType { get { return this.commandType; } }
  2383. public String SubType { get { return this.subType; } }
  2384. public String ApplyRange { get { return this.applyRange; } }
  2385. public int Reply_value1 { get { return this.reply_value1; } }
  2386. public int Reply_value2 { get { return this.reply_value2; } }
  2387. public int Reply_value3 { get { return this.reply_value3; } }
  2388. public int Reply_value4 { get { return this.reply_value4; } }
  2389. public int Reply_value5 { get { return this.reply_value5; } }
  2390. public int Reply_value6 { get { return this.reply_value6; } }
  2391. public int Reply_value7 { get { return this.reply_value7; } }
  2392. public int Reply_value8 { get { return this.reply_value8; } }
  2393. public float Voltage24 { get { return this.voltage24; } }
  2394. public float Voltage5 { get { return this.voltage5; } }
  2395. public float Voltage3_3 { get { return this.voltage3_3; } }
  2396. public int Receiver_id { get { return this.receiver_id; } }
  2397. public int Repeater_id { get { return this.repeater_id; } }
  2398. public int Loop_no { get { return this.loop_no; } }
  2399. public int Board_id { get { return this.board_id; } }
  2400. public int Device_id { get { return this.device_id; } }
  2401. public String Device_type { get { return this.device_type; } }
  2402. public int Comm_id { get { return this.comm_id; } }
  2403. public String[] BoardConnStatus { get { return this.boardConnStatus; } }
  2404. // cyim 2015.7.5 아날로그 감지기 트렌드 읽기 명령 프로토콜 추가
  2405. public int[] AnalogDetecterTrend { get { return this.analogDetecterTrend; } }
  2406. }
  2407. //이벤트알람정보 -- 추가2
  2408. public class RCVData_ReadNotifyStatus
  2409. {
  2410. private int loop_no = 0;
  2411. private int board_id = 0;
  2412. private int invork_id = 0;
  2413. private int receiver_id = 0;
  2414. private int repeater_id = 0;
  2415. private int device_id = 0;
  2416. private String device_type = "";
  2417. private string eventLogID = "";
  2418. private int comm_id = 0;
  2419. //이벤트타입코드
  2420. private String eventType;
  2421. //누적카운트
  2422. private int count = 0;
  2423. //통신보드 통신상태
  2424. private string[] boardConnStatus = new string[33];
  2425. public RCVData_ReadNotifyStatus(byte[] buffer)
  2426. {
  2427. try
  2428. {
  2429. this.loop_no = (int)buffer[1];
  2430. this.board_id = (int)buffer[2];
  2431. this.invork_id = (int)buffer[5];
  2432. this.receiver_id = (int)buffer[6];
  2433. this.repeater_id = (int)buffer[7];
  2434. this.device_id = (int)buffer[8];
  2435. this.device_type = Util.ByteToStr(buffer, 9, 1);
  2436. this.comm_id = (int)buffer[10];
  2437. this.eventType = Util.ByteToStr(buffer, 11, 2);
  2438. this.count = (int)buffer[14] * 256 + (int)buffer[13];
  2439. for (int i = 0; i < 33; i++)
  2440. {
  2441. boardConnStatus[i] = Util.ByteToStr(buffer, 15 + i, 1);
  2442. }
  2443. this.eventLogID = Util.ByteToStr(buffer, 15, 33);
  2444. // cyim 2013.7.19 속도개선작업
  2445. //string str_GetPacket = "RCVData_ReadNotifyStatus Packet : ";
  2446. //string str_Msg = "RCVData_ReadNotifyStatus Data : ";
  2447. //for(int i=0; i<15; i++) {
  2448. // str_GetPacket += string.Format("0x{0:x2}", buffer[i]);
  2449. //}
  2450. //str_Msg += string.Format("loop_no = {0} ", loop_no);
  2451. //str_Msg += string.Format("board_id = {0} ", board_id);
  2452. //str_Msg += string.Format("invork_id = {0} ", invork_id);
  2453. //str_Msg += string.Format("receiver_id = {0} ", receiver_id);
  2454. //str_Msg += string.Format("repeater_id = {0} ", repeater_id);
  2455. //str_Msg += string.Format("device_id = {0} ", device_id);
  2456. //str_Msg += string.Format("device_type = {0} ", device_type);
  2457. //str_Msg += string.Format("comm_id = {0} ", comm_id);
  2458. //str_Msg += string.Format("eventType = {0} ", eventType);
  2459. //str_Msg += string.Format("count = {0} ", count);
  2460. //str_Msg += string.Format("eventLogID = {0} ", eventLogID);
  2461. //for (int i = 0; i < 33; i++) {
  2462. // str_Msg += string.Format("boardConnStatus[{0}] = {1} ", i, boardConnStatus[i]);
  2463. //}
  2464. //Util.UDebugMessage(str_GetPacket, 0, 0);
  2465. //Util.UDebugMessage(str_Msg, 0, 0);
  2466. }
  2467. catch (Exception ex)
  2468. {
  2469. Util.UErrorMessage(ex, 0, 0);
  2470. }
  2471. }
  2472. public int Receiver_id { get { return this.receiver_id; } }
  2473. public int Repeater_id { get { return this.repeater_id; } }
  2474. public int Loop_no { get { return this.loop_no; } }
  2475. public int Board_id { get { return this.board_id; } }
  2476. public int Device_id { get { return this.device_id; } }
  2477. public String Device_type { get { return this.device_type; } }
  2478. public int Comm_id { get { return this.comm_id; } }
  2479. public int Count { get { return this.count; } }
  2480. public String EventType { get { return this.eventType; } }
  2481. public String[] BoardConnStatus { get { return this.boardConnStatus; } }
  2482. public String EventLogID { set { this.eventLogID = value; } get { return this.eventLogID; } }
  2483. }
  2484. // cyim 2015.6.29 아날로그감지기 레벨값 쓰기 명령 프로토콜 추가
  2485. // cyim 2015.7.5 아날로그 감지기 트렌드 읽기 명령 프로토콜 추가
  2486. public class RCVData_WriteAnalogDetecterLevel
  2487. {
  2488. //public byte head; //0x02
  2489. //public byte RPT_loop; //ID 하위 바이트 (Loop 번호)
  2490. //public byte TBD_ID; //ID 상위 바이트 (통신보드 ID)
  2491. //public byte length; //0x0C, 전체 Packet 길이
  2492. //public byte cmd; //0xF8, AnalogDetecterLevel Write 명령 - 응답
  2493. //public byte IVK_ID; //Invoke ID
  2494. //public byte RCVR_ID; //수신기 ID
  2495. //public byte RepeaterID; //감지기 ID (1~ 127)
  2496. //public byte Fault;
  2497. //public byte PreFire;
  2498. //public byte FireNight;
  2499. //public byte FireDay;
  2500. //public byte cs;
  2501. private int loop_no = 0;
  2502. private int board_id = 0;
  2503. private int invork_id = 0;
  2504. private int receiver_id = 0;
  2505. private int repeater_id = 0;
  2506. private byte fault = 0x00;
  2507. private byte preFire = 0x00;
  2508. private byte fireNight = 0x00;
  2509. private byte fireDay = 0x00;
  2510. public RCVData_WriteAnalogDetecterLevel(byte[] buffer)
  2511. {
  2512. try
  2513. {
  2514. this.loop_no = (int)buffer[1];
  2515. this.board_id = (int)buffer[2];
  2516. this.invork_id = (int)buffer[5];
  2517. this.receiver_id = (int)buffer[6];
  2518. this.repeater_id = (int)buffer[7];
  2519. this.fault = buffer[8];
  2520. this.preFire = buffer[9];
  2521. this.fireNight = buffer[10];
  2522. this.fireDay = buffer[11];
  2523. }
  2524. catch (Exception ex)
  2525. {
  2526. Util.UErrorMessage(ex, 0, 0);
  2527. }
  2528. }
  2529. public int Loop_no { get { return this.loop_no; } }
  2530. public int Board_id { get { return this.board_id; } }
  2531. public int Receiver_id { get { return this.receiver_id; } }
  2532. public int Repeater_id { get { return this.repeater_id; } }
  2533. public int Fault { get { return this.fault; } }
  2534. public int PreFire { get { return this.preFire; } }
  2535. public int FireNight { get { return this.fireNight; } }
  2536. public int FireDay { get { return this.fireDay; } }
  2537. }
  2538. //대용량
  2539. public class RCVData_WriteAnalogDetecterLevel2
  2540. {
  2541. private int loop_no = 0;
  2542. private int board_id = 0;
  2543. private int invork_id = 0;
  2544. private int receiver_id = 0;
  2545. private int repeater_id = 0;
  2546. private byte fault = 0x00;
  2547. private byte preFire = 0x00;
  2548. private byte fireNight = 0x00;
  2549. private byte fireDay = 0x00;
  2550. public RCVData_WriteAnalogDetecterLevel2(byte[] buffer)
  2551. {
  2552. try
  2553. {
  2554. this.loop_no = (int)buffer[1];
  2555. this.board_id = (int)buffer[2];
  2556. this.invork_id = (int)buffer[7];
  2557. this.receiver_id = (int)buffer[8];
  2558. this.repeater_id = (int)buffer[9];
  2559. this.fault = buffer[10];
  2560. this.preFire = buffer[11];
  2561. this.fireNight = buffer[12];
  2562. this.fireDay = buffer[13];
  2563. }
  2564. catch (Exception ex)
  2565. {
  2566. Util.UErrorMessage(ex, 0, 0);
  2567. }
  2568. }
  2569. public int Loop_no { get { return this.loop_no; } }
  2570. public int Board_id { get { return this.board_id; } }
  2571. public int Receiver_id { get { return this.receiver_id; } }
  2572. public int Repeater_id { get { return this.repeater_id; } }
  2573. public int Fault { get { return this.fault; } }
  2574. public int PreFire { get { return this.preFire; } }
  2575. public int FireNight { get { return this.fireNight; } }
  2576. public int FireDay { get { return this.fireDay; } }
  2577. }
  2578. // cyim 2016.10.27 : 대용량 수신기 아날로그 감지기 트랜드 읽기
  2579. public class RCVData_ReadAnalogDetecterTrend
  2580. {
  2581. //public byte head; //0x02
  2582. //public byte RPT_loop; //ID 하위 바이트 (Loop 번호)
  2583. //public byte TBD_ID; //ID 상위 바이트 (통신보드 ID)
  2584. //public byte length; //0x34, 전체 Packet 길이
  2585. //public byte cmd; //0xA4, AnalogDetecterTrend Read 명령 - 응답
  2586. //public byte IVK_ID; //Invoke ID
  2587. //public byte RCVR_ID; //수신기 ID
  2588. //public byte RepeaterID; //감지기 ID (1~ 127)
  2589. //public byte cs;
  2590. private int loop_no = 0;
  2591. private int board_id = 0;
  2592. private int invork_id = 0;
  2593. private int receiver_id = 0;
  2594. private int repeater_id = 0;
  2595. // 트렌드값 (44개의 데이터)
  2596. private int[] analogDetecterTrend = new int[44];
  2597. public RCVData_ReadAnalogDetecterTrend(byte[] buffer)
  2598. {
  2599. try
  2600. {
  2601. this.loop_no = (int)buffer[1];
  2602. this.board_id = (int)buffer[2];
  2603. this.invork_id = (int)buffer[5];
  2604. this.receiver_id = (int)buffer[6];
  2605. this.repeater_id = (int)buffer[7];
  2606. for (int i = 0; i < 44; i++)
  2607. {
  2608. analogDetecterTrend[i] = Convert.ToInt32(buffer[8 + i]);
  2609. }
  2610. }
  2611. catch (Exception ex)
  2612. {
  2613. Util.UErrorMessage(ex, 0, 0);
  2614. }
  2615. }
  2616. public int Loop_no { get { return this.loop_no; } }
  2617. public int Board_id { get { return this.board_id; } }
  2618. public int Receiver_id { get { return this.receiver_id; } }
  2619. public int Repeater_id { get { return this.repeater_id; } }
  2620. public int[] AnalogDetecterTrend { get { return this.analogDetecterTrend; } }
  2621. }
  2622. }