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; } } } }