| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854 | 
using System;using System.Collections.Generic;using System.Text;using System.Net;using System.Net.Sockets;using System.IO;using System.Threading;using System.Runtime.Serialization.Formatters.Binary;using System.Runtime.InteropServices;using System.Reflection;namespace FPER{    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTIO_Type1    {// say hell to io board , read io board status ,read io board data        public byte head;        public byte RPT_loop;        public byte BD_ID;        public byte length;        public byte cmd;        public byte IVK_ID;        public byte RCVR_ID;        public byte cs;    }    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTIO_Type2    {// none        public byte head;        public byte RPT_loop;        public byte BD_ID;        public byte length;        public byte cmd;        public byte IVK_ID;        public byte RCVR_ID;        public byte Option1;        public byte cs;    }    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTIO_Type3    {// write io board status , write io board data        public byte head;        public byte RPT_loop;        public byte BD_ID;        public byte length;        public byte cmd;        public byte IVK_ID;        public byte RCVR_ID;        public byte Option1;        public byte Option2;        public byte cs;    }    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTDemon_Type1    {// write io board status , write io board data        public byte head;        public byte RPT_loop;        public byte BD_ID;        public byte length;        public byte cmd;        public byte IVK_ID;        public byte RCVR_ID;        public byte cs;    }    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTReceiver_Type1    {// say hell to board , read board status         public byte head;        public byte RPT_loop;        public byte TBD_ID;        public byte length;        public byte cmd;        public byte IVK_ID;        public byte RCVR_ID;        public byte cs;    }    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTReceiver_Type2    {// resetrepeaterunit        public byte head;        public byte RPT_loop;        public byte TBD_ID;        public byte length;        public byte cmd;        public byte IVK_ID;        public byte RCVR_ID;        public byte Option1;        public byte cs;    }    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTReceiver_Type3    {//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         public byte head;        public byte RPT_loop;        public byte TBD_ID;        public byte length;        public byte cmd;        public byte IVK_ID;        public byte RCVR_ID;        public byte Option1;        public byte Option2;        public byte cs;    }    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTReceiver_Type4    {// none        public byte head;        public byte RPT_loop;        public byte TBD_ID;        public byte length;        public byte cmd;        public byte IVK_ID;        public byte RCVR_ID;        public byte Option1;        public byte Option2;        public byte Option3;        public byte cs;    }    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTReceiver_Type5    {//none        public byte head;        public byte RPT_loop;        public byte TBD_ID;        public byte length;        public byte cmd;        public byte IVK_ID;        public byte RCVR_ID;        public byte Option1;        public byte Option2;        public byte Option3;        public byte Option4;        public byte cs;    }    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTReceiver_Type6    {//write board status        public byte head;        public byte RPT_loop;        public byte TBD_ID;        public byte length;        public byte cmd;        public byte IVK_ID;        public byte RCVR_ID;        public byte Option1;        public byte Option2;        public byte Option3;        public byte Option4;        public byte Option5;        public byte cs;    }    //데몬명령-누적카운트및사용자설정 변경    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTReceiver_Type_CommandStatus    {//write board status        public byte head;        //0x02        public byte RPT_loop;  //ID 하위 바이트 (Loop 번호)        public byte TBD_ID;     //ID 상위 바이트 (통신보드 ID)        public byte length;   //0x0D, 전체 Packet 길이        public byte cmd;  //0x76, Status Command 명령        public byte IVK_ID;  //Invoke ID        public byte RCVR_ID;  //수신기 ID        public byte RepeaterID;  //중계기 ID (1~ 127)        public byte Address;   //ADDRESS (1 ~ 16) 회로ID        public byte InOut;        //IN/OUT (I/O)  C-comm,L-loop,B-board,R-repeater        public byte CommId;        //1-front,3-io,4-keypad        public byte CommandType1;     //Command Type 1 C:카운트읽기        public byte CommandType2;     //Command Type 2 C:카운트읽기        public byte SubType;     //SubType : Device Type        public byte ApplyRange;     //ApplyRange : A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로        public byte Status;      //Status        public byte cs;    }    // 아날로그 감지기 레벨값 쓰기 명령    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTReceiver_Type_AnalogDetecterLevel    {        public byte head;       //0x02        public byte RPT_loop;   //ID 하위 바이트 (Loop 번호)        public byte TBD_ID;     //ID 상위 바이트 (통신보드 ID)        public byte length;     //0x0C, 전체 Packet 길이        public byte cmd;        //0x78, AnalogDetecterLevel Write 명령        public byte IVK_ID;     //Invoke ID        public byte RCVR_ID;    //수신기 ID        public byte RepeaterID; //중계기 ID (1~ 127) , 0xFF (BroadCast)        public byte Fault;        public byte PreFire;        public byte FireNight;        public byte FireDay;        public byte cs;    }    // cyim 2016.10.27 : 대용량 수신기 아날로그 감지기 트랜드 읽기    [StructLayout(LayoutKind.Sequential, Pack = 1)]    public struct PRTReceiver_Type_AnalogDetecterTrend    {        public byte head;       //0x02        public byte RPT_loop;   //ID 하위 바이트 (Loop 번호)        public byte TBD_ID;     //ID 상위 바이트 (통신보드 ID)        public byte length;     //0x08, 전체 Packet 길이        public byte cmd;        //0x24, AnalogDetecterTrend Read 명령        public byte IVK_ID;     //Invoke ID        public byte RCVR_ID;    //수신기 ID        public byte RepeaterID; //감지기 ID         public byte cs;    }    public class GeneralBaseInfo    {        private int unitID_d = 0;        private int unitID_u = 0;        private int receiverID = 0;        private int invorkNo = 0;        private int errNo = 0;        private int errLocation = 0;        private string errLocationMessage = "";        private string errMessage = "[NACK]통신오류가 발생하였습니다. 관리자에게 문의하시기 바랍니다.";        public GeneralBaseInfo(byte[] buffer)        {            try            {                this.unitID_d = (int)buffer[1];                this.unitID_u = (int)buffer[2];                //if(buffer[3]  == 0x00) {                //  this.InvorkNo     = buffer[7];                //  this.ReceiverID   = buffer[8];                //}                //else {                //  this.InvorkNo     = buffer[5];                //  this.ReceiverID   = buffer[6];                //}                this.invorkNo = (int)buffer[5];                this.receiverID = (int)buffer[6];                this.errLocation = (int)buffer[7];                this.errNo = (int)buffer[8];                this.errNo = ((int)buffer[9]) * 256 + this.errNo;                //에러코드명을 저장한다.                DemonErrCode errCode = new DemonErrCode(this.errNo);                this.errLocationMessage = errCode.GetErrorName();                //switch (this.errLocation)                //{                //    case 1: this.errLocationMessage = "Demon Error"; break;                //    case 2: this.errLocationMessage = "통신 보드 Error"; break;                //    case 3: this.errLocationMessage = "IO 보드 Error"; break;                //    default: this.errLocationMessage = "알수없음"; break;                //}            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public int UnitID_d { get { return (int)this.unitID_d; } }        public int UnitID_u { get { return (int)this.unitID_u; } }        public int ReceiverID { get { return (int)this.receiverID; } }        public int InvorkNo { get { return (int)this.invorkNo; } }        public int ErrReceiverID { get { return (int)this.receiverID; } }        public int ErrInvorkNo { get { return (int)this.invorkNo; } }        public int ErrNo { get { return 0; } }        public string ErrMessage        {            get            {                //  return  string.Format("{0}\r\n[{1}] 발생위치:{2}, 수신기번호:{3}, Invork번호:{4}"                //, this.errMessage, this.errNo, this.errLocationMessage, this.receiverID, this.invorkNo);                return string.Format("{0}\r\n\r\n[에러코드:{1}] 에러내역:{2}", this.errMessage, this.errNo, this.errLocationMessage);            }        }    }    public class DemonErrCode    {        int errCode = 0;        const int PROCESS_STOP = 1;        const int PROCESS_RUN = 2;        const int POLLING_STOP = 3;        const int POLLING_START = 4;        const int DATABASE_CONNECT = 11;        const int DATABASE_INSERT = 12;        const int DATABASE_DELETE = 13;        const int DATABASE_CONNECT_ERROR = 14;        const int DATABASE_INSERT_ERROR = 15;        const int DATABASE_DELETE_ERROR = 16;        const int COMMUNICATION_CONNECT = 20;        const int COMMUNICATION_DISCONNECT = 21;        const int COMMUNICATION_SEND = 22;        const int COMMUNICATION_RECEIVE = 23;        const int COMMUNICATION_CONNECT_ERROR = 24;        const int COMMUNICATION_SEND_ERROR = 25;        const int COMMUNICATION_SEND_TIMEOUT = 26;        const int COMMUNICATION_RECEIVE_ERROR = 27;        const int COMMUNICATION_RECEIVE_TIMEOUT = 28;        const int COMMUNICATION_DATA_INVALID = 29;        const int COMMUNICATION_CHECKBYTE_INVALID = 30;        const int DATA_STX_INVALID = 31;        const int DATA_BOARD_ID_INVALID = 32;        const int DATA_LOOP_NO_INVALID = 33;        const int DATA_COMMAND_INVALID = 34;        const int DATA_LENGTH_INVALID = 35;        const int DATA_RECEIVER_ID_INVALID = 36;        const int DATA_COMM_ID_INVALID = 37;        const int DATA_CHECKBYTE_INVALID = 38;        const int DATA_REPLY_INVALID = 126;        const int COMMUNICATION_FAIL = 127;        const int COMMUNICATION_OK = 0;        const int CHECKBYTE_ERROR = 0xFF;        const int NOT_SUPPORT_COMMAND = 0xFE;        const int NOT_SUPPORT_VALUE = 0xFD;        public DemonErrCode(int errCode)        {            this.errCode = errCode;        }        public string GetErrorName()        {            string errName = "";            try            {                // ERROR CODE CHECK (CHECK BYTE ERROR)                if (this.errCode == CHECKBYTE_ERROR)                {                    // ERROR NAME 설정                    //errName = "CHECK BYTE ERROR";                    errName = "CHECK BYTE ERROR:체크바이트값이 올바르지 않습니다.";                }                // ERROR CODE CHECK (NOT SUPPORT COMMAND)                else if (this.errCode == NOT_SUPPORT_COMMAND)                {                    // ERROR NAME 설정                    //errName = "NOT SUPPORT COMMAND";                    errName = "NOT SUPPORT COMMAND:지원하지 않는 명령형식입니다. 통신데이터를 확인하십시요.";                }                // ERROR CODE CHECK (NOT SUPPORT VALUE)                else if (this.errCode == NOT_SUPPORT_VALUE)                {                    // ERROR NAME 설정                    //errName = "NOT SUPPORT VALUE";                    errName = "NOT SUPPORT VALUE:지원하지 않는 값입니다. 통신데이터를 확인하십시요.";                }                // ERROR CODE CHECK (PROCESS STOP)                else if (this.errCode == PROCESS_STOP)                {                    // ERROR NAME 설정                    errName = "PROCESS STOP:데몬통신 중지중입니다.";                }                // ERROR CODE CHECK (PROCESS RUN)                else if (this.errCode == PROCESS_RUN)                {                    // ERROR NAME 설정                    errName = "PROCESS RUN:데몬통신이 실행중입니다.";                }                // ERROR CODE CHECK (POLLING STOP)                else if (this.errCode == POLLING_STOP)                {                    // ERROR NAME 설정                    errName = "POLLING STOP:데몬이 중지되었습니다.";                }                // ERROR CODE CHECK (POLLING START)                else if (this.errCode == POLLING_START)                {                    // ERROR NAME 설정                    errName = "POLLING START:데몬이 시작되었습니다.";                }                // ERROR CODE CHECK (DATABASE CONNECT)                else if (this.errCode == DATABASE_CONNECT)                {                    // ERROR NAME 설정                    errName = "DATABASE CONNECT:데이터베이스 연결이 시작되었습니다.";                }                // ERROR CODE CHECK (DATABASE INSERT)                else if (this.errCode == DATABASE_INSERT)                {                    // ERROR NAME 설정                    errName = "DATABASE INSERT:데이터베이스 자료입력 작업중입니다.";                }                // ERROR CODE CHECK (DATABASE DELETE)                else if (this.errCode == DATABASE_DELETE)                {                    // ERROR NAME 설정                    errName = "DATABASE DELETE:데이터베이스 자료삭제 작업중입니다.";                }                // ERROR CODE CHECK (DATABASE CONNECT ERROR)                else if (this.errCode == DATABASE_CONNECT_ERROR)                {                    // ERROR NAME 설정                    errName = "DATABASE CONNECT ERROR:데이터베이스 연결 오류입니다.";                }                // ERROR CODE CHECK (DATABASE INSERT ERROR)                else if (this.errCode == DATABASE_INSERT_ERROR)                {                    // ERROR NAME 설정                    errName = "DATABASE INSERT ERROR:데이터베이스 자료입력 오류입니다.";                }                // ERROR CODE CHECK (DATABASE DELETE ERROR)                else if (this.errCode == DATABASE_DELETE_ERROR)                {                    // ERROR NAME 설정                    errName = "DATABASE DELETE ERROR:데이터베이스 자료삭제 오류입니다.";                }                // ERROR CODE CHECK (COMMUNICATION CONNECT)                else if (this.errCode == COMMUNICATION_CONNECT)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION CONNECT:통신연결 되었습니다.";                }                // ERROR CODE CHECK (COMMUNICATION DISCONNECT)                else if (this.errCode == COMMUNICATION_DISCONNECT)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION DISCONNECT:통신연결상태가 아닙니다. 통신보드연결상태를 확인하십시요.";                }                // ERROR CODE CHECK (COMMUNICATION S})                else if (this.errCode == COMMUNICATION_SEND)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION SEND:통신 데이터 전송중입니다.";                }                // ERROR CODE CHECK (COMMUNICATION RECEIVE)                else if (this.errCode == COMMUNICATION_RECEIVE)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION RECEIVE:통신 데이터 송신중입니다.";                }                // ERROR CODE CHECK (COMMUNICATION CONNECT ERROR)                else if (this.errCode == COMMUNICATION_CONNECT_ERROR)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION CONNECT ERROR:통신 연결 오류입니다.";                }                // ERROR CODE CHECK (COMMUNICATION S} ERROR)                else if (this.errCode == COMMUNICATION_SEND_ERROR)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION SEND ERROR:통신 데이터 전송 오류입니다.";                }                // ERROR CODE CHECK (COMMUNICATION S} TIMEOUT)                else if (this.errCode == COMMUNICATION_SEND_TIMEOUT)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION SEND TIMEOUT:통신 데이터 전송중 타임아웃되었습니다.";                }                // ERROR CODE CHECK (COMMUNICATION RECEIVE ERROR)                else if (this.errCode == COMMUNICATION_RECEIVE_ERROR)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION RECEIVE ERROR:통신 데이터 송신 오류입니다.";                }                // ERROR CODE CHECK (COMMUNICATION RECEIVE TIMEOUT)                else if (this.errCode == COMMUNICATION_RECEIVE_TIMEOUT)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION RECEIVE TIMEOUT:통신 데이터 송신중 타임아웃되었습니다.";                }                // ERROR CODE CHECK (COMMUNICATION DATA INVALID)                else if (this.errCode == COMMUNICATION_DATA_INVALID)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION DATA INVALID:통신 데이터가 올바르지 않습니다.";                }                // ERROR CODE CHECK (COMMUNICATION CHECKBYTE INVALID)                else if (this.errCode == COMMUNICATION_CHECKBYTE_INVALID)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION CHECKBYTE INVALID:통신 데이터 체크바이트가 올바르지 않습니다.";                }                // ERROR CODE CHECK (DATA STX INVALID)                else if (this.errCode == DATA_STX_INVALID)                {                    // ERROR NAME 설정                    errName = "DATA INVALID (STX): STX오류입니다.";                }                // ERROR CODE CHECK (DATA BOARD ID INVALID)                else if (this.errCode == DATA_BOARD_ID_INVALID)                {                    // ERROR NAME 설정                    errName = "DATA INVALID (BOARD ID):통신보드ID가 올바르지 않습니다.";                }                // ERROR CODE CHECK (DATA LOOP NO. INVALID)                else if (this.errCode == DATA_LOOP_NO_INVALID)                {                    // ERROR NAME 설정                    errName = "DATA INVALID (LOOP NO.):LOOP NO가 올바르지 않습니다.";                }                // ERROR CODE CHECK (DATA COMMAND INVALID)                else if (this.errCode == DATA_COMMAND_INVALID)                {                    // ERROR NAME 설정                    errName = "DATA INVALID (COMMAND):명령데이터가 올바르지 않습니다.";                }                // ERROR CODE CHECK (DATA LENGTH INVALID)                else if (this.errCode == DATA_LENGTH_INVALID)                {                    // ERROR NAME 설정                    errName = "DATA INVALID (LENGTH):통신데이터 길이가 올바르지 않습니다.";                }                // ERROR CODE CHECK (DATA RECEIVER ID INVALID)                else if (this.errCode == DATA_RECEIVER_ID_INVALID)                {                    // ERROR NAME 설정                    errName = "DATA INVALID (RECEIVER ID):수신기ID가 올바르지 않습니다.";                }                // ERROR CODE CHECK (DATA COMM. ID INVALID)                else if (this.errCode == DATA_COMM_ID_INVALID)                {                    // ERROR NAME 설정                    errName = "DATA INVALID (COMM. ID):COMM ID가 올바르지 않습니다.";                }                // ERROR CODE CHECK (DATA CHECK BYTE INVALID)                else if (this.errCode == DATA_CHECKBYTE_INVALID)                {                    // ERROR NAME 설정                    errName = "DATA INVALID (CHECK BYTE):체크바이트가 올바르지 않습니다.";                }                // ERROR CODE CHECK (DATA REPLY INVALID)                else if (this.errCode == DATA_REPLY_INVALID)                {                    // ERROR NAME 설정                    errName = "DATA INVALID (REPLY):응답데이터가 올바르지 않습니다.";                }                // ERROR CODE CHECK (COMMUNICATION FAIL)                else if (this.errCode == COMMUNICATION_FAIL)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION FAIL:통신오류가 발생하였습니다.";                }                // ERROR CODE CHECK (COMMUNICATION OK)                else if (this.errCode == COMMUNICATION_OK)                {                    // ERROR NAME 설정                    errName = "COMMUNICATION OK:통신이 정상적으로 진행되었습니다.";                }                // ERROR CODE CHECK (ETC)                else                {                    // ERROR NAME 설정                    errName = "UNKNOWN ERROR:알수 없는 통신오류 입니다.";                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }            return errName;        }    }    public class RCVData_ACK    {        private GeneralBaseInfo baseInfo;        public byte Position = 0x00;        public byte NR = 0x00;        public byte FL = 0x00;        public RCVData_ACK(byte[] buffer)        {            this.baseInfo = new GeneralBaseInfo(buffer);            this.Position = buffer[7];            this.NR = buffer[8];            this.FL = buffer[9];        }        /////// base info /////////////////        public GeneralBaseInfo Baseinfo        {            get            {                return this.baseInfo;            }        }        public int UnitID_d        {            get            {                return this.baseInfo.UnitID_d;            }        }        public int UnitID_u        {            get            {                return this.baseInfo.UnitID_u;            }        }        public int InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public int ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }    }    public class RCVData_NACK    {        private GeneralBaseInfo baseInfo;        public byte Position = 0x00;        public byte ErrorNumber_d = 0x00;        public byte ErrorNumber_u = 0x00;        public byte[] Option;        public int OptionCnt = 0;        public RCVData_NACK(byte[] buffer)        {            try            {                this.baseInfo = new GeneralBaseInfo(buffer);                this.Position = buffer[7];                this.ErrorNumber_d = buffer[8];                this.ErrorNumber_u = buffer[9];                this.OptionCnt = buffer[3] - 9;                if (this.OptionCnt > 0)                {                    this.Option = new byte[this.OptionCnt];                    for (int i = 0; i < this.OptionCnt; i++)                    {                        Option[i] = buffer[i + 10];                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        /////// base info /////////////////        public GeneralBaseInfo Baseinfo        {            get            {                return this.baseInfo;            }        }        public int UnitID_d        {            get            {                return this.baseInfo.UnitID_d;            }        }        public int UnitID_u        {            get            {                return this.baseInfo.UnitID_u;            }        }        public int InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public int ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }    }    public class TBoardBaseInfo    {        public byte TBD_ID = 0;        public byte Repeater_loop = 0;        public byte ReceiverID = 0;        public byte InvorkNo = 0;        public TBoardBaseInfo(byte[] buffer)        {            try            {                this.TBD_ID = buffer[2];                this.Repeater_loop = buffer[1];                if (buffer[3] == 0x00)                {                    this.InvorkNo = buffer[7];                    this.ReceiverID = buffer[8];                }                else                {                    this.InvorkNo = buffer[5];                    this.ReceiverID = buffer[6];                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }    }    //통신보드 상태쓰기 데이터    public class TBoardData    {        private int mode = 0;        public byte TBD_MainVersion = 0;        public byte TBD_SubVersion = 0;        public byte RCV_BaudRate = 0;        public byte TBD_Loop1_BaudRate = 0;        public byte TBD_Loop2_BaudRate = 0;        public byte TBD_Term = 0;        public byte TBD_24Voltage_d = 0;        public byte TBD_24Voltage_u = 0;        public byte TBD_5Voltage_d = 0;        public byte TBD_5Voltage_u = 0;        public byte TBD_33Voltage_d = 0;        public byte TBD_33Voltage_u = 0;        public byte TBD_Cut = 0;        public byte Reset = 0;        public TBoardData()        {            this.mode = 1;        }        public TBoardData(byte[] buffer)        {            try            {                this.mode = 2;                this.TBD_MainVersion = buffer[7];                this.TBD_SubVersion = buffer[8];                this.RCV_BaudRate = buffer[9];                this.TBD_Loop1_BaudRate = buffer[10];                this.TBD_Loop2_BaudRate = buffer[11];                this.TBD_Term = buffer[12];                this.TBD_24Voltage_d = buffer[13];                this.TBD_24Voltage_u = buffer[14];                this.TBD_5Voltage_d = buffer[15];                this.TBD_5Voltage_u = buffer[16];                this.TBD_33Voltage_d = buffer[17];                this.TBD_33Voltage_u = buffer[18];                this.TBD_Cut = buffer[19];            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public int Mode        {            get            {                return this.mode;            }        }    }    public class RCVData_ReadTBoardStatus    {        private TBoardBaseInfo baseInfo;        private TBoardData data;        public RCVData_ReadTBoardStatus(byte[] buffer)        {            this.baseInfo = new TBoardBaseInfo(buffer);            this.data = new TBoardData(buffer);        }        /////// base info /////////////////        public byte TBD_ID        {            get            {                return this.baseInfo.TBD_ID;            }        }        public byte Repeater_loop        {            get            {                return this.baseInfo.Repeater_loop;            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }        /////// data  /////////////////        public TBoardData Data        {            get            {                return this.data;            }        }        public byte TBD_MainVersion        {            get            {                return this.data.TBD_MainVersion;            }        }        public byte TBD_SubVersion        {            get            {                return this.data.TBD_SubVersion;            }        }        public byte RCV_BaudRate        {            get            {                return this.data.RCV_BaudRate;            }        }        public byte TBD_Loop1_BaudRate        {            get            {                return this.data.TBD_Loop1_BaudRate;            }        }        public byte TBD_Loop2_BaudRate        {            get            {                return this.data.TBD_Loop2_BaudRate;            }        }        public byte TBD_Term        {            get            {                return this.data.TBD_Term;            }        }        //24v 하위바이트        public byte TBD_24Voltage_d        {            get            {                return this.data.TBD_24Voltage_d;            }        }        //24v 상위바이트        public byte TBD_24Voltage_u        {            get            {                return this.data.TBD_24Voltage_u;            }        }        public double TBD_24Voltage        {            get            {                //24V (상위*256 + 하위) / 100                int vol = ((int)this.data.TBD_24Voltage_u * 256) + (int)this.data.TBD_24Voltage_d;                return vol / 100;            }        }        public byte TBD_5Voltage_d        {            get            {                return this.data.TBD_5Voltage_d;            }        }        public byte TBD_5Voltage_u        {            get            {                return this.data.TBD_5Voltage_u;            }        }        public byte TBD_33Voltage_d        {            get            {                return this.data.TBD_33Voltage_d;            }        }        public byte TBD_33Voltage_u        {            get            {                return this.data.TBD_33Voltage_u;            }        }        public byte TBD_Cut        {            get            {                return this.data.TBD_Cut;            }        }    }    public class RCVData_WriteTBoardStatus    {        private TBoardBaseInfo baseInfo;        private TBoardData data;        public RCVData_WriteTBoardStatus(byte[] buffer)        {            try            {                this.baseInfo = new TBoardBaseInfo(buffer);                this.data = new TBoardData(buffer);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        /////// base info /////////////////        public byte TBD_ID        {            get            {                return this.baseInfo.TBD_ID;            }        }        public byte Repeater_loop        {            get            {                return this.baseInfo.Repeater_loop;            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }        /////// data  /////////////////        public TBoardData Data        {            get            {                return this.data;            }        }        public byte TBD_MainVersion        {            get            {                return this.data.TBD_MainVersion;            }        }        public byte TBD_SubVersion        {            get            {                return this.data.TBD_SubVersion;            }        }        public byte RCV_BaudRate        {            get            {                return this.data.RCV_BaudRate;            }        }        public byte TBD_Loop1_BaudRate        {            get            {                return this.data.TBD_Loop1_BaudRate;            }        }        public byte TBD_Loop2_BaudRate        {            get            {                return this.data.TBD_Loop2_BaudRate;            }        }        public byte TBD_Term        {            get            {                return this.data.TBD_Term;            }        }        public byte TBD_24Voltage_d        {            get            {                return this.data.TBD_24Voltage_d;            }        }        public byte TBD_24Voltage_u        {            get            {                return this.data.TBD_24Voltage_u;            }        }        public byte TBD_5Voltage_d        {            get            {                return this.data.TBD_5Voltage_d;            }        }        public byte TBD_5Voltage_u        {            get            {                return this.data.TBD_5Voltage_u;            }        }        public byte TBD_33Voltage_d        {            get            {                return this.data.TBD_33Voltage_d;            }        }        public byte TBD_33Voltage_u        {            get            {                return this.data.TBD_33Voltage_u;            }        }        public byte TBD_Cut        {            get            {                return this.data.TBD_Cut;            }        }    }    public class RepeaterBaseInfo    {        public byte TBD_ID = 0;        public byte Repeater_loop = 0;        public byte ReceiverID = 0;        public byte InvorkNo = 0;        public RepeaterBaseInfo(byte[] buffer)        {            try            {                this.TBD_ID = buffer[2];                this.Repeater_loop = buffer[1];                if (buffer[3] == 0x00)                {                    this.InvorkNo = buffer[7];                    this.ReceiverID = buffer[8];                }                else                {                    this.InvorkNo = buffer[5];                    this.ReceiverID = buffer[6];                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }    }    // cyim 2015.7.2 주석 정리 : 프로토콜 설명부    public class RepeaterData    {        // repeater id//        public byte repeater_ID = 0;        // repeater state //        public bool Err = false;    // 중계기 송수신 Error        public bool Non = false;    // 존재하지 않는 중계기        public bool R0 = false;     // Reserved - 0 정상, 1 전원이상        public bool R1 = false;     // Reserved - 0 정상, 1 아날로그감지기 Fault          public bool R2 = false;        public bool R = false;      // Recovery Input Port - 중계기 복구 명령 (07H) 의 결과를 나타내며, 명령 수행이 완료되지 않았으면 1, 완료되었으면 0        public bool W = false;      // Write Complete - 중계기 포인트 쓰기 명령 (03H) 의 결과를 나타내며, 명령 수행이 완료되지 않았으면 1, 완료되었으면 0        public bool S = false;      // Search Complete - 중계기 검색 명령 (06H) 의 결과를 나타내며, 명령 수행이 완료되지 않았으면 1, 완료되었으면 0        // repeater input //        public int Repeater_state_1 = 0;        public int Repeater_state_2 = 0;        public int Repeater_state_3 = 0;        public int Repeater_state_4 = 0;        // repeater output //        public bool Repeater_output_4_C = false;        public bool Repeater_output_3_C = false;        public bool Repeater_output_2_C = false;        public bool Repeater_output_1_C = false;        public bool Repeater_output_4_W = false;        public bool Repeater_output_3_W = false;        public bool Repeater_output_2_W = false;        public bool Repeater_output_1_W = false;        // repeater info //        public bool B = false;        public bool Rserved1 = false;        public bool Rserved2 = false;        public bool Rserved3 = false;        // cyim 2015.6.8 아날로그 감지기 연동 추가        // '1' = A : 2X2         // '2' = B : 4X4         // '4' = C : 아날로그연감지기         // '5' = D : 아날로그열감지기         public int RepeaterSetting = 0;        // repeater byte data //        public byte Repeater_Output = 0x00;        public byte Repeater_Input = 0x00;        public byte Repeater_Info = 0x00;        public byte Repeater_Status = 0x00;        // cyim 2015.7.1 입력회로 상태값 추가 :  아날로그 감지기 연동으로 인하여 입력값은 중계기든 아날로그 감지기는 반드시 1byte 저장하게 된다        public int AnalogDetecterValue_Input = 0; // 중계기 Block 포인트 읽기 0x14 를 위함        // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기         public byte AnalogDetecterFault = 0x00;        public byte AnalogDetecterPreFire = 0x00;        public byte AnalogDetecterFireNight = 0x00;        public byte AnalogDetecterFireDay = 0x00;        public bool AnalogDetecter = false;        private int mode = 0;        public int Mode        {            get            {                return this.mode;            }        }        //        ////////////////// response data input  /////////////////        //        // only use real data input        public RepeaterData(byte RepeaterID)        {            try            {                this.repeater_ID = RepeaterID;                this.mode = 1;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // 설정        public RepeaterData(byte RepeaterID, byte Info)        {            try            {                this.repeater_ID = RepeaterID;                this.mode = 2;                this.Set_Info_Data(Info);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // 상태 + 입력 + 출력         public RepeaterData(byte RepeaterID, byte Status, byte Input, byte Output)        {            try            {                this.repeater_ID = RepeaterID;                this.mode = 3;                this.Set_Status_Data(Status);                this.Set_Input_Data(Input);                this.Set_Output_Data(Output);                // cyim 2015.7.1 입력회로 상태값 추가 :  아날로그 감지기 연동으로 인하여 입력값은 중계기든 아날로그 감지기는 반드시 1byte 저장하게 된다                // 아날로그 감지기 입력값을 위해 Raw 데이터를 저장해둔다, 단 상위 1 bit 를 제거해서 (화재) 온전한 감지값만을 보관하고 있으면 된다                // 차후에 중계기가 이 정보를 저장해도 소용없도록, 아날로그 감지기에서만 사용하게만 하면 무리가 없다고 판단됨                this.AnalogDetecterValue_Input = Input & 0x7F;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // 상태 + 입력 + 출력         public RepeaterData(byte RepeaterID, byte Status, byte Input, byte Output, byte Info)        {            try            {                this.repeater_ID = RepeaterID;                this.mode = 4;                this.Set_Status_Data(Status);                this.Set_Output_Data(Output);                this.Set_Input_Data(Input);                this.Set_Status_Data(this.Err, this.Non, this.R0, this.R1, this.R2, this.R, this.W, this.S);                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);                this.Set_Input_Data(this.Repeater_state_4, this.Repeater_state_3, this.Repeater_state_2, this.Repeater_state_1);                this.Set_Info_Data(this.B, this.Rserved1, this.Rserved2, this.Rserved3, this.RepeaterSetting);                // cyim 2013.7.19 속도개선작업                //TDebug.DoPrintDBGMSG("initial input, ID : " + RepeaterID.ToString() + " :"+ Status.ToString() + "," + Input.ToString() + "," + Output.ToString() + "," + Info.ToString());                //TDebug.DoPrintDBGMSG("Status = "+ Err.ToString() + "," + Non.ToString() + "," + R0.ToString() + "," + R1.ToString()                //  + "," + R2.ToString() + "," + R.ToString() + "," + W.ToString() + "," + S.ToString());                //TDebug.DoPrintDBGMSG("input = "+ Repeater_state_1.ToString() + "," + Repeater_state_2.ToString() + ","                 //  + Repeater_state_3.ToString() + "," + Repeater_state_4.ToString());                //TDebug.DoPrintDBGMSG("Output = "+ Repeater_output_4_C.ToString() + "," + Repeater_output_3_C.ToString()                 //  + "," + Repeater_output_2_C.ToString() + "," + Repeater_output_1_C.ToString()                //  + "," + Repeater_output_4_W.ToString() + "," + Repeater_output_3_W.ToString()                 //  + "," + Repeater_output_2_W.ToString() + "," + Repeater_output_1_W.ToString());                //TDebug.DoPrintDBGMSG("info = "+ B.ToString() + "," + Rserved1.ToString() + "," + Rserved3.ToString()                 //  + "," + Rserved3.ToString() + "," + RepeaterSetting.ToString() );                //TDebug.DoPrintDBGMSG("final data = "+ Repeater_Status.ToString() + "," + Repeater_Input.ToString()                //  + "," + Repeater_Output.ToString() + "," + Repeater_Info.ToString() );            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //        ////////////////// cmd data input  /////////////////        //        // 상태        public void Set_Status_Data(bool Err, bool Non, bool R0, bool R1, bool R2, bool R, bool W, bool S)        {            try            {                this.Repeater_Status = 0x00;                this.Repeater_Status = (byte)(Convert.ToByte(Err) << 7);                this.Repeater_Status += (byte)(Convert.ToByte(Non) << 6);                this.Repeater_Status += (byte)(Convert.ToByte(R0) << 5);                this.Repeater_Status += (byte)(Convert.ToByte(R1) << 4);                this.Repeater_Status += (byte)(Convert.ToByte(R2) << 3);                this.Repeater_Status += (byte)(Convert.ToByte(R) << 2);                this.Repeater_Status += (byte)(Convert.ToByte(W) << 1);                this.Repeater_Status += (byte)(Convert.ToByte(S) << 0);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // 읽기        public void Set_Input_Data(int Repeater_state_4, int Repeater_state_3, int Repeater_state_2, int Repeater_state_1)        {            try            {                this.Repeater_Input = 0x00;                this.Repeater_Input = (byte)((Repeater_state_4 & 0x03) << 6);                this.Repeater_Input += (byte)((Repeater_state_3 & 0x03) << 4);                this.Repeater_Input += (byte)((Repeater_state_2 & 0x03) << 2);                this.Repeater_Input += (byte)((Repeater_state_1 & 0x03) << 0);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // 출력        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,                                        bool Repeater_output_4_W, bool Repeater_output_3_W, bool Repeater_output_2_W, bool Repeater_output_1_W)        {            try            {                this.Repeater_Output = 0x00;                this.Repeater_Output = (byte)(Convert.ToByte(Repeater_output_4_C) << 7);                this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_3_C) << 6);                this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_2_C) << 5);                this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_1_C) << 4);                this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_4_W) << 3);                this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_3_W) << 2);                this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_2_W) << 1);                this.Repeater_Output += (byte)(Convert.ToByte(Repeater_output_1_W) << 0);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // 설정        public void Set_Info_Data(bool B, bool FireResetFlag, bool Reserved2, bool Reserved3, int RepeaterSetting)        {            try            {                this.Repeater_Info = 0x00;                this.Repeater_Info = (byte)(Convert.ToByte(B) << 7);                this.Repeater_Info += (byte)(Convert.ToByte(FireResetFlag) << 6);                this.Repeater_Info += (byte)(Convert.ToByte(Reserved2) << 5);                this.Repeater_Info += (byte)(Convert.ToByte(Reserved3) << 4);                byte tmp_data = 0x00;                // cyim 2015.6.8 아날로그 감지기 연동 추가                // '1' = A : 2X2                 // '2' = B : 4X4                 // '4' = C : 아날로그연감지기                 // '5' = D : 아날로그열감지기                 // 0 0 0 0 : 중계기 연결 안됨                // 0 0 0 1 : 2 * 2 중계기                // 0 0 1 0 : 4 * 4 중계기                // 0 1 0 0 : 아날로그 연감지기                // 0 1 0 1 : 아날로그 열감지기                switch (RepeaterSetting)                {                    case 0:                        {                            tmp_data = 0x00;                            break;                        }                    case 1:                        {                            tmp_data = 0x01;                            break;                        }                    case 2:                        {                            tmp_data = 0x02;                            break;                        }                    case 4:                        {                            tmp_data = 0x04;                            break;                        }                    case 5:                        {                            tmp_data = 0x05;                            break;                        }                    default:                        {                            tmp_data = 0x00;                            break;                        }                }                this.Repeater_Info += tmp_data;                ////Util.UDebugMessage(string.Format("Set_Info_Data Repeater={0} Repeater_Info={1} ", this.repeater_ID, this.Repeater_Info), 0, 0);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //        ////////////////// byte data input  /////////////////        //        // 상태        private void Set_Status_Data(byte in_data)        {            try            {                this.Err = (((in_data >> 7) & 0x01) == 0x01);                this.Non = (((in_data >> 6) & 0x01) == 0x01);                this.R0 = (((in_data >> 5) & 0x01) == 0x01);                this.R1 = (((in_data >> 4) & 0x01) == 0x01);                this.R2 = (((in_data >> 3) & 0x01) == 0x01);                this.R = (((in_data >> 2) & 0x01) == 0x01);                this.W = (((in_data >> 1) & 0x01) == 0x01);                this.S = (((in_data >> 0) & 0x01) == 0x01);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // 입력        private void Set_Input_Data(byte in_data)        {            try            {                this.Repeater_state_4 = (in_data >> 6) & 0x03;                this.Repeater_state_3 = (in_data >> 4) & 0x03;                this.Repeater_state_2 = (in_data >> 2) & 0x03;                this.Repeater_state_1 = (in_data >> 0) & 0x03;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // 출력        private void Set_Output_Data(byte in_data)        {            try            {                this.Repeater_output_4_C = (((in_data >> 7) & 0x01) == 0x01);                this.Repeater_output_3_C = (((in_data >> 6) & 0x01) == 0x01);                this.Repeater_output_2_C = (((in_data >> 5) & 0x01) == 0x01);                this.Repeater_output_1_C = (((in_data >> 4) & 0x01) == 0x01);                this.Repeater_output_4_W = (((in_data >> 3) & 0x01) == 0x01);                this.Repeater_output_3_W = (((in_data >> 2) & 0x01) == 0x01);                this.Repeater_output_2_W = (((in_data >> 1) & 0x01) == 0x01);                this.Repeater_output_1_W = (((in_data >> 0) & 0x01) == 0x01);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // 설정        private void Set_Info_Data(byte InfoData)        {            try            {                this.B = (((InfoData >> 7) & 0x01) == 0x01);                this.Rserved1 = (((InfoData >> 6) & 0x01) == 0x01);                this.Rserved2 = (((InfoData >> 5) & 0x01) == 0x01);                this.Rserved3 = (((InfoData >> 4) & 0x01) == 0x01);                int tmp_data = (InfoData >> 0) & 0x0f;                // cyim 2015.6.8 아날로그 감지기 연동 추가                // '1' = A : 2X2                 // '2' = B : 4X4                 // '4' = C : 아날로그연감지기                 // '5' = D : 아날로그열감지기                 // 0 0 0 0 : 중계기 연결 안됨                // 0 0 0 1 : 2 * 2 중계기                // 0 0 1 0 : 4 * 4 중계기                // 0 1 0 0 : 아날로그 연감지기                // 0 1 0 1 : 아날로그 열감지기                switch (tmp_data)                {                    case 0x00:                        {                            this.RepeaterSetting = 0;   // 중계기 연결 안됨                            break;                        }                    case 0x01:                        {                            this.RepeaterSetting = 1;   // 2*2 중계기                            break;                        }                    case 0x02:                        {                            this.RepeaterSetting = 2;   // 4*4 중계기                            break;                        }                    case 0x04:                        {                            this.RepeaterSetting = 4;   // 아날로그 연감지기                            break;                        }                    case 0x05:                        {                            this.RepeaterSetting = 5;   // 아날로그 열감지기                            break;                        }                    default:                        {                            this.RepeaterSetting = -1;                            break;                        }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기         public void Set_Level_AnalogDetecter(byte Fault, byte PreFire, byte FireNight, byte FireDay)        {            this.AnalogDetecterFault = Fault;            this.AnalogDetecterPreFire = PreFire;            this.AnalogDetecterFireNight = FireNight;            this.AnalogDetecterFireDay = FireDay;            this.AnalogDetecter = true;        }    }    public class RCVData_ReadRepeaterPointAll    {        private RepeaterBaseInfo baseInfo;        private RepeaterData[] data = new RepeaterData[127];        public RCVData_ReadRepeaterPointAll(byte[] buffer)        {            try            {                this.baseInfo = new RepeaterBaseInfo(buffer);                for (int i = 0; i < 127; i++)                {                    // cyim 2015.7.1 입력회로 상태값 추가 :  아날로그 감지기 연동으로 인하여 입력값은 중계기든 아날로그 감지기는 반드시 1byte 저장하게 된다                    // 아날로그 감지기의 경우. 입력이 1byte 로 들어온다. 2^7 승 (하위 7bit 사용)                    // 하지만 중계기 클래스를 생성할때 중계기 타입에 맞추어서 저장하기에는 너무 빠른 속도로 패킷이 들어온다                    // 중계기 상태보기와 같이 특별한 경우에는 UI 에서 미리 중계기에 해당하는 레벨을 알아두고                    // 각각의 입력값 1byte 는 raw 데이타로 항상 가지고 있도록 해야한다                    this.data[i] = new RepeaterData((byte)(i + 1), buffer[3 * i + 9], buffer[3 * i + 10], buffer[3 * i + 11]);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public byte TBD_ID        {            get            {                return baseInfo.TBD_ID;            }        }        public byte Repeater_loop        {            get            {                return baseInfo.Repeater_loop;            }        }        public byte InvorkNo        {            get            {                return baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return baseInfo.ReceiverID;            }        }        public RepeaterData[] Data        {            get            {                return data;            }        }    }    public class RCVData_WriteRepeaterOutputUNIT    {        private RepeaterBaseInfo baseInfo;        private RepeaterData data;        public RCVData_WriteRepeaterOutputUNIT(byte[] buffer)        {            try            {                this.baseInfo = new RepeaterBaseInfo(buffer);                this.data = new RepeaterData(buffer[7], buffer[8], buffer[9], buffer[10]);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public byte TBD_ID        {            get            {                return this.baseInfo.TBD_ID;            }        }        public byte Repeater_loop        {            get            {                return this.baseInfo.Repeater_loop;            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }        public RepeaterData Data        {            get            {                return this.data;            }        }    }    public class RCVData_ReadRepeaterInfoAll    {        private RepeaterBaseInfo baseInfo;        private RepeaterData[] data = new RepeaterData[127];        public RCVData_ReadRepeaterInfoAll(byte[] buffer)        {            try            {                this.baseInfo = new RepeaterBaseInfo(buffer);                for (int i = 0; i < 127; i++)                {                    this.data[i] = new RepeaterData((byte)(i + 1), buffer[i + 7]);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public byte TBD_ID        {            get            {                return this.baseInfo.TBD_ID;            }        }        public byte Repeater_loop        {            get            {                return this.baseInfo.Repeater_loop;            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }        public RepeaterData[] Data        {            get            {                return data;            }        }    }    public class RCVData_WriteRepeaterInfoUNIT    {        private RepeaterBaseInfo baseInfo;        private RepeaterData data;        public RCVData_WriteRepeaterInfoUNIT(byte[] buffer)        {            try            {                this.baseInfo = new RepeaterBaseInfo(buffer);                this.data = new RepeaterData(buffer[7], buffer[8]);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public byte TBD_ID        {            get            {                return this.baseInfo.TBD_ID;            }        }        public byte Repeater_loop        {            get            {                return this.baseInfo.Repeater_loop;            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }        public RepeaterData Data        {            get            {                return this.data;            }        }    }    public class RCVData_WriteRepeaterInputUNIT    {        private RepeaterBaseInfo baseInfo;        private RepeaterData data;        public RCVData_WriteRepeaterInputUNIT(byte[] buffer)        {            try            {                this.baseInfo = new RepeaterBaseInfo(buffer);                this.data = new RepeaterData(buffer[7], buffer[8], buffer[9], buffer[10]);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public byte TBD_ID        {            get            {                return this.baseInfo.TBD_ID;            }        }        public byte Repeater_loop        {            get            {                return this.baseInfo.Repeater_loop;            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }        public RepeaterData Data        {            get            {                return this.data;            }        }    }    public class RCVData_SearchRepeaterUNIT    {        private RepeaterBaseInfo baseInfo;        private RepeaterData data;        public RCVData_SearchRepeaterUNIT(byte[] buffer)        {            try            {                this.baseInfo = new RepeaterBaseInfo(buffer);                this.data = new RepeaterData(buffer[7], buffer[8], buffer[9], buffer[10], buffer[11]);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public byte TBD_ID        {            get            {                return this.baseInfo.TBD_ID;            }        }        public byte Repeater_loop        {            get            {                return this.baseInfo.Repeater_loop;            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }        public RepeaterData Data        {            get            {                return this.data;            }        }    }    //2010.12.05, k.s.d, repeater information block write.    public class RepeaterDataAll    {        //private RepeaterBaseInfo baseInfo = null;        private RepeaterData[] data = new RepeaterData[127];        public byte InvorkNo = 0;        public byte ReceiverID = 0;        public byte Repeater_loop = 0;        public byte TBD_ID = 0;        public RepeaterDataAll()        {            try            {                for (int i = 0; i < 127; i++)                {                    this.data[i] = new RepeaterData((byte)i, 0x00);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //public byte TBD_ID        //{        //    get        //    {        //        return this.baseInfo.TBD_ID;        //    }        //}        //public byte Repeater_loop        //{        //    get        //    {        //        return this.baseInfo.Repeater_loop;        //    }        //}        //public byte InvorkNo        //{        //    get        //    {        //        return this.baseInfo.InvorkNo;        //    }        //}        //public byte ReceiverID        //{        //    get        //    {        //        return this.baseInfo.ReceiverID;        //    }        //}        public RepeaterData[] Data        {            get            {                return data;            }        }    }    public class IOBoardBaseInfo    {        public byte IOBD_ID = 0;        public byte Extend_ID = 0;        public byte ReceiverID = 0;        public byte InvorkNo = 0;        public IOBoardBaseInfo(byte[] buffer)        {            try            {                this.IOBD_ID = buffer[2];                this.Extend_ID = buffer[1];                if (buffer[3] == 0x00)                {                    this.InvorkNo = buffer[7];                    this.ReceiverID = buffer[8];                }                else                {                    this.InvorkNo = buffer[5];                    this.ReceiverID = buffer[6];                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }    }    public class IOBoardData    {        private int mode = 0;        public bool[] Input = new bool[16];        public bool[] Output = new bool[16];        public byte Version_d = 0;        public byte Version_u = 0;        public byte BaudRate = 0;        public byte Reset = 0;        /*            public byte IOBD_24Voltage_d = 0;            public byte IOBD_24Voltage_u = 0;            public byte IOBD_5Voltage_d  = 0;            public byte IOBD_5Voltage_u  = 0;            public byte IOBD_33Voltage_d = 0;            public byte IOBD_33Voltage_u = 0;        */        public float TBD_24Voltage;        public float TBD_5Voltage;        public float TBD_33Voltage;        public byte OutData_d = 0x00;        public byte OutData_u = 0x00;        public int Mode        {            get            {                return this.mode;            }        }        public IOBoardData()        {            try            {                this.mode = 1;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public IOBoardData(byte BaudRate, byte Reset)        {            try            {                this.BaudRate = BaudRate;                this.Reset = Reset;                this.mode = 2;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public IOBoardData(byte Version_d, byte Version_u, byte BaudRate)        {            try            {                this.Version_d = Version_d;                this.Version_u = Version_u;                this.BaudRate = BaudRate;                this.mode = 3;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public IOBoardData(byte[] buffer)        {            try            {                for (int i = 0; i < 8; i++)                {                    //          this.Input[i]     = (((buffer[7]  >> (7-i)) & 0x01) == 0x01);                    //          this.Input[i+8]   = (((buffer[8]  >> (7-i)) & 0x01) == 0x01);                    //          this.Output[i]    = (((buffer[9]  >> (7-i)) & 0x01) == 0x01);                    //          this.Output[i+8]  = (((buffer[10] >> (7-i)) & 0x01) == 0x01);                    this.Input[i] = (((buffer[7] >> i) & 0x01) == 0x01);                    this.Input[i + 8] = (((buffer[8] >> i) & 0x01) == 0x01);                    this.Output[i] = (((buffer[9] >> i) & 0x01) == 0x01);                    this.Output[i + 8] = (((buffer[10] >> i) & 0x01) == 0x01);                }                /*                        this.IOBD_24Voltage_d = buffer[11];                        this.IOBD_24Voltage_u = buffer[12];                        this.IOBD_5Voltage_d = buffer[13];                        this.IOBD_5Voltage_u = buffer[14];                        this.IOBD_33Voltage_d = buffer[15];                        this.IOBD_33Voltage_u = buffer[16];                */                this.TBD_24Voltage = (buffer[11] + 256 * buffer[12]) / 100;                this.TBD_5Voltage = (buffer[13] + 256 * buffer[14]) / 100;                this.TBD_33Voltage = (buffer[15] + 256 * buffer[16]) / 100;                this.mode = 4;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public void Set_OutputData(int position, bool data)        {            try            {                this.Output[position] = data;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public void Set_InputData(int position, bool data)        {            try            {                this.Input[position] = data;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }    }    public class RCVData_ReadIOBoardStatus    {        private IOBoardBaseInfo baseInfo;        public byte Version_d = 0;        public byte Version_u = 0;        public byte BaudRate = 0;        public RCVData_ReadIOBoardStatus(byte[] buffer)        {            try            {                this.baseInfo = new IOBoardBaseInfo(buffer);                this.Version_d = buffer[7];                this.Version_u = buffer[8];                this.BaudRate = buffer[9];            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public byte IOBD_ID        {            get            {                return this.baseInfo.IOBD_ID;            }        }        public byte Extend_ID        {            get            {                return this.baseInfo.Extend_ID;            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }    }    public class RCVData_WriteIOBoardStatus    {        private IOBoardBaseInfo baseInfo;        public byte BaudRate = 0;        public byte Reset = 0;        public RCVData_WriteIOBoardStatus(byte[] buffer)        {            try            {                this.baseInfo = new IOBoardBaseInfo(buffer);                this.BaudRate = buffer[7];                this.Reset = buffer[8];            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public byte IOBD_ID        {            get            {                return this.baseInfo.IOBD_ID;            }        }        public byte Extend_ID        {            get            {                return this.baseInfo.Extend_ID;            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }    }    public class RCVData_ReadIOBoardData    {        private IOBoardBaseInfo baseInfo;        public bool[] input = new bool[16];        public bool[] output = new bool[16];        public float TBD_24Voltage;        public float TBD_5Voltage;        public float TBD_33Voltage;        public RCVData_ReadIOBoardData(byte[] buffer)        {            try            {                this.baseInfo = new IOBoardBaseInfo(buffer);                for (int i = 0; i < 8; i++)                {                    //          this.input[i]     = (((buffer[7]  >> (7-i)) & 0x01) == 0x01);                    //          this.input[i+8]   = (((buffer[8]  >> (7-i)) & 0x01) == 0x01);                    //          this.output[i]    = (((buffer[9]  >> (7-i)) & 0x01) == 0x01);                    //          this.output[i+8]  = (((buffer[10] >> (7-i)) & 0x01) == 0x01);                    this.input[i] = (((buffer[7] >> i) & 0x01) == 0x01);                    this.input[i + 8] = (((buffer[8] >> i) & 0x01) == 0x01);                    this.output[i] = (((buffer[9] >> i) & 0x01) == 0x01);                    this.output[i + 8] = (((buffer[10] >> i) & 0x01) == 0x01);                }                this.TBD_24Voltage = (buffer[11] + 256 * buffer[12]) / 100;                this.TBD_5Voltage = (buffer[13] + 256 * buffer[14]) / 100;                this.TBD_33Voltage = (buffer[15] + 256 * buffer[16]) / 100;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public byte IOBD_ID        {            get            {                return this.baseInfo.IOBD_ID;            }        }        public byte Extend_ID        {            get            {                return this.baseInfo.Extend_ID;            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }    }    public class RCVData_WriteIOBoardData    {        private IOBoardBaseInfo baseInfo;        public bool[] input = new bool[16];        public bool[] output = new bool[16];        /*         * public byte IOBD_24Voltage_d;            public byte IOBD_24Voltage_u;            public byte IOBD_5Voltage_d;            public byte IOBD_5Voltage_u;            public byte IOBD_33Voltage_d;            public byte IOBD_33Voltage_u;        */        public float TBD_24Voltage;        public float TBD_5Voltage;        public float TBD_33Voltage;        public RCVData_WriteIOBoardData(byte[] buffer)        {            try            {                this.baseInfo = new IOBoardBaseInfo(buffer);                for (int i = 0; i < 8; i++)                {                    //          this.input[i]     = (((buffer[7]  >> (7-i)) & 0x01) == 0x01);                    //          this.input[i+8]   = (((buffer[8]  >> (7-i)) & 0x01) == 0x01);                    //          this.output[i]    = (((buffer[9]  >> (7-i)) & 0x01) == 0x01);                    //          this.output[i+8]  = (((buffer[10] >> (7-i)) & 0x01) == 0x01);                    this.input[i] = (((buffer[7] >> i) & 0x01) == 0x01);                    this.input[i + 8] = (((buffer[8] >> i) & 0x01) == 0x01);                    this.output[i] = (((buffer[9] >> i) & 0x01) == 0x01);                    this.output[i + 8] = (((buffer[10] >> i) & 0x01) == 0x01);                }                //        this.IOBD_24Voltage_d = buffer[11];                //        this.IOBD_24Voltage_u = buffer[12];                //        this.IOBD_5Voltage_d  = buffer[13];                //        this.IOBD_5Voltage_u  = buffer[14];                //        this.IOBD_33Voltage_d = buffer[15];                //        this.IOBD_33Voltage_u = buffer[16];                this.TBD_24Voltage = (buffer[11] + 256 * buffer[12]) / 100;                this.TBD_5Voltage = (buffer[13] + 256 * buffer[14]) / 100;                this.TBD_33Voltage = (buffer[15] + 256 * buffer[16]) / 100;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public byte IOBD_ID        {            get            {                return this.baseInfo.IOBD_ID;            }        }        public byte Extend_ID        {            get            {                return this.baseInfo.Extend_ID;            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }    }    public class DemonBaseInfo    {        public byte ReceiverID = 0;        public byte InvorkNo = 0;        public DemonBaseInfo(byte[] buffer)        {            try            {                if (buffer[3] == 0x00)                {                    this.InvorkNo = buffer[7];                    this.ReceiverID = buffer[8];                }                else                {                    this.InvorkNo = buffer[5];                    this.ReceiverID = buffer[6];                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }    }    public class RCVData_ReadDemonStatus    {        private DemonBaseInfo baseInfo;        public byte Status = 0;        public RCVData_ReadDemonStatus(byte[] buffer)        {            try            {                this.baseInfo = new DemonBaseInfo(buffer);                this.Status = buffer[7];            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public byte InvorkNo        {            get            {                return this.baseInfo.InvorkNo;            }        }        public byte ReceiverID        {            get            {                return this.baseInfo.ReceiverID;            }        }    }    //누적정보 또는 차단명령결과 -- 추가1    public class RCVData_ReadCommandStatus    {        private int loop_no = 0;        private int board_id = 0;        private int invork_id = 0;        private int receiver_id = 0;        private int repeater_id = 0;        private int device_id = 0;        private String device_type = "";        private int comm_id = 0;        private string commandType;        private string subType;        //회로타입(회로타입차단용)        private string applyRange;        //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로        private int status = 0;       //        //누적카운트        private int reply_value1 = 0;        private int reply_value2 = 0;        private int reply_value3 = 0;        private int reply_value4 = 0;        private int reply_value5 = 0;        private int reply_value6 = 0;        private int reply_value7 = 0;        private int reply_value8 = 0;        //24Voltage        private float voltage24 = 0;        private float voltage5 = 0;        private float voltage3_3 = 0;        //통신보드 통신상태        private string[] boardConnStatus = new string[16];        // 트렌드값 (44개의 데이터)        private int[] analogDetecterTrend = new int[44];        public RCVData_ReadCommandStatus(byte[] buffer)        {            try            {                this.loop_no = (int)buffer[1];                this.board_id = (int)buffer[2];                this.invork_id = (int)buffer[5];                this.receiver_id = (int)buffer[6];                this.repeater_id = (int)buffer[7];                this.device_id = (int)buffer[8];                this.device_type = Util.ByteToStr(buffer, 9, 1);                this.comm_id = (int)buffer[10];                this.commandType = Util.ByteToStr(buffer, 11, 2);                this.subType = Util.ByteToStr(buffer, 13, 1);                this.applyRange = Util.ByteToStr(buffer, 14, 1);                this.status = (int)buffer[15];                // 전압                if (this.commandType.Equals("CV"))                {                    //24V (상위*256 + 하위) / 100                    this.voltage24 = Util.ToValtage((int)buffer[16], (int)buffer[17]);                    this.voltage5 = Util.ToValtage((int)buffer[18], (int)buffer[19]);                    this.voltage3_3 = Util.ToValtage((int)buffer[20], (int)buffer[21]);                }                //전체누적정보                else if (this.commandType.Equals("CC") || this.commandType.Equals("VI"))                {                    this.reply_value1 = (int)buffer[17] * 256 + (int)buffer[16]; // 통신이상                    this.reply_value2 = (int)buffer[19] * 256 + (int)buffer[18]; // 설비                    this.reply_value3 = (int)buffer[21] * 256 + (int)buffer[20];                    this.reply_value4 = (int)buffer[23] * 256 + (int)buffer[22]; // 화재                    this.reply_value5 = (int)buffer[25] * 256 + (int)buffer[24]; // 단선                    this.reply_value6 = (int)buffer[27] * 256 + (int)buffer[26];                    this.reply_value7 = (int)buffer[29] * 256 + (int)buffer[28]; // 차단                    this.reply_value8 = (int)buffer[31] * 256 + (int)buffer[30];                }                //환경정보변경                else if (this.commandType.Equals("CS"))                {                    this.reply_value1 = (int)buffer[17] * 256 + (int)buffer[16];                    //this.reply_value2 = (int)buffer[19] * 256 + (int)buffer[18];                    //this.reply_value3 = (int)buffer[21] * 256 + (int)buffer[20];                    //this.reply_value4 = (int)buffer[23] * 256 + (int)buffer[22];                    //this.reply_value5 = (int)buffer[25] * 256 + (int)buffer[24];                }                //통신보드 통신상태 F-front,B-back,X-error,N-none                else if (this.commandType.Equals("BS"))                {                    // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다                                        // cyim 2016.11.03 : 통신보드(중계반)는 최대 64	                    for (int i = 0; i < 65; i++)                    {                        boardConnStatus[i] = Util.ByteToStr(buffer, 16 + i, 1);                    }                }                // cyim 2015.7.5 아날로그 감지기 트렌드 읽기 명령 프로토콜 추가                else if (this.commandType.Equals("TR"))                {                    for (int i = 0; i < 44; i++)                    {                        // ex : 0x20 =>                         analogDetecterTrend[i] = Convert.ToInt32(buffer[32 + i]);//(buffer, 16 + i, 1);                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public String CommandType { get { return this.commandType; } }        public String SubType { get { return this.subType; } }        public String ApplyRange { get { return this.applyRange; } }        public int Reply_value1 { get { return this.reply_value1; } }        public int Reply_value2 { get { return this.reply_value2; } }        public int Reply_value3 { get { return this.reply_value3; } }        public int Reply_value4 { get { return this.reply_value4; } }        public int Reply_value5 { get { return this.reply_value5; } }        public int Reply_value6 { get { return this.reply_value6; } }        public int Reply_value7 { get { return this.reply_value7; } }        public int Reply_value8 { get { return this.reply_value8; } }        public float Voltage24 { get { return this.voltage24; } }        public float Voltage5 { get { return this.voltage5; } }        public float Voltage3_3 { get { return this.voltage3_3; } }        public int Receiver_id { get { return this.receiver_id; } }        public int Repeater_id { get { return this.repeater_id; } }        public int Loop_no { get { return this.loop_no; } }        public int Board_id { get { return this.board_id; } }        public int Device_id { get { return this.device_id; } }        public String Device_type { get { return this.device_type; } }        public int Comm_id { get { return this.comm_id; } }        public String[] BoardConnStatus { get { return this.boardConnStatus; } }        // cyim 2015.7.5 아날로그 감지기 트렌드 읽기 명령 프로토콜 추가        public int[] AnalogDetecterTrend { get { return this.analogDetecterTrend; } }    }    //이벤트알람정보 -- 추가2    public class RCVData_ReadNotifyStatus    {        private int loop_no = 0;        private int board_id = 0;        private int invork_id = 0;        private int receiver_id = 0;        private int repeater_id = 0;        private int device_id = 0;        private String device_type = "";        private string eventLogID = "";        private int comm_id = 0;        //이벤트타입코드        private String eventType;        //누적카운트        private int count = 0;        //통신보드 통신상태        private string[] boardConnStatus = new string[33];        public RCVData_ReadNotifyStatus(byte[] buffer)        {            try            {                this.loop_no = (int)buffer[1];                this.board_id = (int)buffer[2];                this.invork_id = (int)buffer[5];                this.receiver_id = (int)buffer[6];                this.repeater_id = (int)buffer[7];                this.device_id = (int)buffer[8];                this.device_type = Util.ByteToStr(buffer, 9, 1);                this.comm_id = (int)buffer[10];                this.eventType = Util.ByteToStr(buffer, 11, 2);                this.count = (int)buffer[14] * 256 + (int)buffer[13];                for (int i = 0; i < 33; i++)                {                    boardConnStatus[i] = Util.ByteToStr(buffer, 15 + i, 1);                }                this.eventLogID = Util.ByteToStr(buffer, 15, 33);                // cyim 2013.7.19 속도개선작업                //string str_GetPacket = "RCVData_ReadNotifyStatus Packet : ";                //string str_Msg = "RCVData_ReadNotifyStatus Data : ";                //for(int i=0; i<15; i++) {                //  str_GetPacket += string.Format("0x{0:x2}", buffer[i]);                //}                //str_Msg += string.Format("loop_no = {0} ", loop_no);                //str_Msg += string.Format("board_id = {0} ", board_id);                //str_Msg += string.Format("invork_id = {0} ", invork_id);                //str_Msg += string.Format("receiver_id = {0} ", receiver_id);                //str_Msg += string.Format("repeater_id = {0} ", repeater_id);                //str_Msg += string.Format("device_id = {0} ", device_id);                //str_Msg += string.Format("device_type = {0} ", device_type);                //str_Msg += string.Format("comm_id = {0} ", comm_id);                //str_Msg += string.Format("eventType = {0} ", eventType);                //str_Msg += string.Format("count = {0} ", count);                //str_Msg += string.Format("eventLogID = {0} ", eventLogID);                //for (int i = 0; i < 33; i++) {                //  str_Msg += string.Format("boardConnStatus[{0}] = {1} ", i, boardConnStatus[i]);                //}                //Util.UDebugMessage(str_GetPacket, 0, 0);                //Util.UDebugMessage(str_Msg, 0, 0);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public int Receiver_id { get { return this.receiver_id; } }        public int Repeater_id { get { return this.repeater_id; } }        public int Loop_no { get { return this.loop_no; } }        public int Board_id { get { return this.board_id; } }        public int Device_id { get { return this.device_id; } }        public String Device_type { get { return this.device_type; } }        public int Comm_id { get { return this.comm_id; } }        public int Count { get { return this.count; } }        public String EventType { get { return this.eventType; } }        public String[] BoardConnStatus { get { return this.boardConnStatus; } }        public String EventLogID { set { this.eventLogID = value; } get { return this.eventLogID; } }    }    // cyim 2015.6.29 아날로그감지기 레벨값 쓰기 명령 프로토콜 추가    // cyim 2015.7.5 아날로그 감지기 트렌드 읽기 명령 프로토콜 추가    public class RCVData_WriteAnalogDetecterLevel    {        //public byte head;       //0x02        //public byte RPT_loop;   //ID 하위 바이트 (Loop 번호)        //public byte TBD_ID;     //ID 상위 바이트 (통신보드 ID)        //public byte length;     //0x0C, 전체 Packet 길이        //public byte cmd;        //0xF8, AnalogDetecterLevel Write 명령 - 응답        //public byte IVK_ID;     //Invoke ID        //public byte RCVR_ID;    //수신기 ID        //public byte RepeaterID; //감지기 ID (1~ 127)         //public byte Fault;        //public byte PreFire;        //public byte FireNight;        //public byte FireDay;        //public byte cs;        private int loop_no = 0;        private int board_id = 0;        private int invork_id = 0;        private int receiver_id = 0;        private int repeater_id = 0;        private byte fault = 0x00;        private byte preFire = 0x00;        private byte fireNight = 0x00;        private byte fireDay = 0x00;        public RCVData_WriteAnalogDetecterLevel(byte[] buffer)        {            try            {                this.loop_no = (int)buffer[1];                this.board_id = (int)buffer[2];                this.invork_id = (int)buffer[5];                this.receiver_id = (int)buffer[6];                this.repeater_id = (int)buffer[7];                this.fault = buffer[8];                this.preFire = buffer[9];                this.fireNight = buffer[10];                this.fireDay = buffer[11];            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public int Loop_no { get { return this.loop_no; } }        public int Board_id { get { return this.board_id; } }        public int Receiver_id { get { return this.receiver_id; } }        public int Repeater_id { get { return this.repeater_id; } }        public int Fault { get { return this.fault; } }        public int PreFire { get { return this.preFire; } }        public int FireNight { get { return this.fireNight; } }        public int FireDay { get { return this.fireDay; } }    }    //대용량    public class RCVData_WriteAnalogDetecterLevel2    {        private int loop_no = 0;        private int board_id = 0;        private int invork_id = 0;        private int receiver_id = 0;        private int repeater_id = 0;        private byte fault = 0x00;        private byte preFire = 0x00;        private byte fireNight = 0x00;        private byte fireDay = 0x00;        public RCVData_WriteAnalogDetecterLevel2(byte[] buffer)        {            try            {                this.loop_no = (int)buffer[1];                this.board_id = (int)buffer[2];                this.invork_id = (int)buffer[7];                this.receiver_id = (int)buffer[8];                this.repeater_id = (int)buffer[9];                this.fault = buffer[10];                this.preFire = buffer[11];                this.fireNight = buffer[12];                this.fireDay = buffer[13];            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public int Loop_no { get { return this.loop_no; } }        public int Board_id { get { return this.board_id; } }        public int Receiver_id { get { return this.receiver_id; } }        public int Repeater_id { get { return this.repeater_id; } }        public int Fault { get { return this.fault; } }        public int PreFire { get { return this.preFire; } }        public int FireNight { get { return this.fireNight; } }        public int FireDay { get { return this.fireDay; } }    }    // cyim 2016.10.27 : 대용량 수신기 아날로그 감지기 트랜드 읽기     public class RCVData_ReadAnalogDetecterTrend    {        //public byte head;       //0x02        //public byte RPT_loop;   //ID 하위 바이트 (Loop 번호)        //public byte TBD_ID;     //ID 상위 바이트 (통신보드 ID)        //public byte length;     //0x34, 전체 Packet 길이        //public byte cmd;        //0xA4, AnalogDetecterTrend Read 명령 - 응답        //public byte IVK_ID;     //Invoke ID        //public byte RCVR_ID;    //수신기 ID        //public byte RepeaterID; //감지기 ID (1~ 127)         //public byte cs;        private int loop_no = 0;        private int board_id = 0;        private int invork_id = 0;        private int receiver_id = 0;        private int repeater_id = 0;        // 트렌드값 (44개의 데이터)        private int[] analogDetecterTrend = new int[44];        public RCVData_ReadAnalogDetecterTrend(byte[] buffer)        {            try            {                this.loop_no = (int)buffer[1];                this.board_id = (int)buffer[2];                this.invork_id = (int)buffer[5];                this.receiver_id = (int)buffer[6];                this.repeater_id = (int)buffer[7];                for (int i = 0; i < 44; i++)                {                    analogDetecterTrend[i] = Convert.ToInt32(buffer[8 + i]);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        public int Loop_no { get { return this.loop_no; } }        public int Board_id { get { return this.board_id; } }        public int Receiver_id { get { return this.receiver_id; } }        public int Repeater_id { get { return this.repeater_id; } }        public int[] AnalogDetecterTrend { get { return this.analogDetecterTrend; } }    }}
 |