using System; using System.Collections.Generic; using System.Text; namespace IControls_FireManager { public class MskDeviceIDString { String mskId = ""; String dev_type = "M"; //M-Áß°è±â,I-IOº¸µå String inout_type = "I"; //ÀÔ·Âȸ·Î-I,Ãâ·Âȸ·Î-O int board_id = -1; //Åë½Åº¸µå int comm_id = 1; //1-front,2-back,3-io,4-keypad int loop_no = -1; //Loop No int repeater_id = -1; //Áß°è±â ID int device_id = -1; //ȸ·ÎID //MI-##-#-###-# :M(±¸ºÐ M-Áß°è±â,I-ÀԷ±׷ì)I,O(ȸ·Î±¸ºÐ)-##(º¸µåID)-#(ȸ·ÎID) public MskDeviceIDString(String dev_s, string Receiver_ID) { try { if (dev_s.Length == 13) { this.mskId = dev_s; this.dev_type = dev_s.Substring(0, 1).ToUpper(); this.inout_type = dev_s.Substring(1, 1).ToUpper(); this.board_id = Util.StrToInt(dev_s.Substring(3, 2), 0); this.loop_no = Util.StrToInt(dev_s.Substring(6, 1), -1); this.repeater_id = Util.StrToInt(dev_s.Substring(8, 3), 0); this.device_id = Util.StrToInt(dev_s.Substring(12, 1), 0); if (dev_type.Equals("I")) comm_id = 3; if (!inout_type.Equals(code_InOutType.Input) && !inout_type.Equals(code_InOutType.Output)) { throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. [ÀÔÃâ·Â±¸ºÐ]"); } // cyim 2016.12.05 : ¼ö½Å±â ¸ðµ¨º° ³»ºÎ ·ÎÁ÷ º¯°æ if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300") { if (board_id < 0 || board_id > 68) // cyim 2016.09.12 : Åë½Åº¸µå´Â 8°³(ID : 1~8), Áß°è¹ÝÀº 60°³ (ID : 9 ~ 68), ÃÑ 256 °èÅëÀÌ´Ù { throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. [Åë½Åº¸µåID]"); } if (loop_no < 0 || loop_no > 3) // cyim 2016.09.12 : ·çÇÁ¹øÈ£´Â 0~3 { throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. [Loop No]"); } } else { if (board_id == 0 || board_id > 32) { throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. [Åë½Åº¸µåID]"); } if (loop_no != 0 && loop_no != 1) { throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. [Loop No]"); } } if (repeater_id == 0 || repeater_id > 127) { throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. [Áß°è±âID]"); } if (device_id == 0) { throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. [ȸ·ÎID]"); } } else if (dev_s.Length == 9) { this.mskId = dev_s; this.dev_type = dev_s.Substring(0, 1).ToUpper(); this.inout_type = dev_s.Substring(2, 1).ToUpper(); this.board_id = Util.StrToInt(dev_s.Substring(4, 2), 0); this.loop_no = 0; this.repeater_id = 0; this.device_id = Util.StrToInt(dev_s.Substring(7, 2), 0); if (dev_type.Equals("I")) comm_id = 3; if (!inout_type.Equals(code_InOutType.Input) && !inout_type.Equals(code_InOutType.Output)) { throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. [ÀÔÃâ·Â±¸ºÐ]"); } if (board_id == 0) { throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. [I/Oº¸µåID]"); } if (device_id == 0) { throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. [ȸ·ÎID]"); } } else { throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù."); } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } // cyim 2016.12.05 : ¼ö½Å±â ¸ðµ¨º° ³»ºÎ ·ÎÁ÷ º¯°æ public MskDeviceIDString(int comm_id, int board_id, int loop_no, int repeater_id, int device_id, string inout_type, string Receiver_ID) { try { this.comm_id = comm_id; this.inout_type = inout_type; this.board_id = board_id; this.loop_no = loop_no; this.repeater_id = repeater_id; this.device_id = device_id; if (comm_id == 3) this.dev_type = "I"; else if (comm_id == 1) this.dev_type = "M"; else if (comm_id == 2) this.dev_type = "M"; else if (comm_id == 4) this.dev_type = "ŰÆÐµå"; //if (!inout_type.Equals(code_InOutType.Input) && !inout_type.Equals(code_InOutType.Output)) //{ // return; // //throw new Exception("ȸ·Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. [ÀÔÃâ·Â±¸ºÐ]"); //} if (this.comm_id == 1 || this.comm_id == 2) { // cyim 2016.12.05 : ¼ö½Å±â ¸ðµ¨º° ³»ºÎ ·ÎÁ÷ º¯°æ if ((((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300") && (board_id < 0 || board_id > 68)) // cyim 2016.09.12 : Åë½Åº¸µå´Â 8°³(ID : 1~8), Áß°è¹ÝÀº 60°³ (ID : 9 ~ 68), ÃÑ 256 °èÅëÀÌ´Ù { this.mskId = string.Format("Comm[{0}]", this.comm_id); } else if ((((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL != "IFC3300") && (board_id == 0 || board_id > 32)) { this.mskId = string.Format("Comm[{0}]", this.comm_id); } else { // cyim 2016.12.05 : ¼ö½Å±â ¸ðµ¨º° ³»ºÎ ·ÎÁ÷ º¯°æ if ((((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300") && (loop_no < 0 || loop_no > 3)) // cyim 2016.09.12 : ·çÇÁ¹øÈ£´Â 0~3 this.mskId = string.Format("Åë½Åº¸µå[{0}]", this.board_id); else if ((((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL != "IFC3300") && (loop_no != 0 && loop_no != 1)) this.mskId = string.Format("Åë½Åº¸µå[{0}]", this.board_id); else { if (repeater_id == 0 || repeater_id > 127) this.mskId = string.Format("Åë½Åº¸µå[{0}]-Loop[{1}]", this.board_id, this.loop_no); else { if (device_id == 0) this.mskId = string.Format("Åë½Åº¸µå[{0}]-Loop[{1}]-Áß°è±â[{2}]", this.board_id, this.loop_no, this.repeater_id); else { if (!inout_type.Equals(code_InOutType.Input) && !inout_type.Equals(code_InOutType.Output)) this.mskId = string.Format("Åë½Åº¸µå[{0}]-Loop[{1}]-Áß°è±â[{2}]-ȸ·Î[{3}]", this.board_id, this.loop_no, this.repeater_id, this.device_id); else { this.mskId = string.Format("{0}{1}-{2:00}-{3:0}-{4:000}-{5}", this.dev_type, this.inout_type, this.board_id , this.loop_no, this.repeater_id, this.device_id); } } } } } //if (device_id == 0) //{ // if (repeater_id == 0 || repeater_id > 127) // { // if (loop_no != 0 && loop_no != 1) // { // if (board_id == 0 || board_id > 32) // { // this.mskId = string.Format("Comm[{0}]", this.comm_id); // } // else // { // this.mskId = string.Format("Åë½Åº¸µå[{0}]", this.board_id); // } // } // else // { // this.mskId = string.Format("Åë½Åº¸µå[{0}]-Loop[{1}]", this.board_id, this.loop_no); // } // } // else // { // this.mskId = string.Format("Åë½Åº¸µå[{0}]-Loop[{1}]-Áß°è±â[{2}]", this.board_id, this.loop_no, this.repeater_id); // } //} //else //{ // this.mskId = string.Format("{0}{1}-{2:00}-{3:0}-{4:000}-{5}", this.dev_type, this.inout_type, this.board_id // , this.loop_no, this.repeater_id, this.device_id); //} } else if (this.comm_id == 3) { if (device_id == 0) { if (board_id == 0) { this.mskId = string.Format("IOº¸µå Comm[{0}]", this.comm_id); } else { this.mskId = string.Format("IOº¸µå[{0}]", this.board_id); } } else { //I-A-12-## this.mskId = String.Format("{0}-{1}-{2:00}-{3:00}", this.dev_type, this.inout_type, this.board_id, this.device_id); } } else if (this.comm_id == 4) { if (device_id == 0) { this.mskId = string.Format("ŰÆÐµå Comm[{0}]", this.comm_id); } else { //I-A-12-## this.mskId = String.Format("ŰÆÐµå ¹øÈ£[{0}]", this.device_id); } } } catch (Exception ex) { Util.UErrorMessage(ex, 0, 0); } } public int Board_id { get { return this.board_id; } } public int Comm_id { get { return this.comm_id; } } public int Loop_no { get { return this.loop_no; } } public int Repeater_id { get { return this.repeater_id; } } public int Device_id { get { return this.device_id; } } public String Inout_type { get { return this.inout_type; } } public String MskId { get { return this.mskId; } } } }