using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; namespace Cosmos.KPS { [Serializable] public class PrinterCommand { #region 위치 public enum Position { Top, Buttom, TopAndButtom, None } public enum Alignment { Center, Left, Right } #endregion #region Character size/Filter /// /// Character size horizontal [넓이 배율 1~8] /// public enum CharactersizeH { H_1, H_2, H_3, H_4, H_5, H_6, H_7, H_8 } /// /// Character size vertical [높이 배율 1~8] /// public enum CharactersizeV { V_1, V_2, V_3, V_4, V_5, V_6, V_7, V_8 } /// /// Bold 체 여부 /// public enum TextBold { Nomal, Bold } /// /// 밑줄(UnderLine) /// public enum TextUnderLine { Nomal, UnderLine } /// /// 반전 Text 효과 /// public enum TextReverseMode { Nomal, ReverseMode } #endregion #region Barcode Type /// /// Print Barcode /// 1Dh, 6BH, m, d1, ...dk, 00H [0 ≤ m ≤ 6, 32 ≤ k ≤ 126, 1 ≤ k ≤ 255] /// 1Dh, 6BH, m, n, d1, ...dn [65 ≤ m ≤ 73, 1 ≤ n ≤ 255, 0 ≤ d ≤ 127] /// public enum BarcodeType : int { UPC_A = 0, //m = 0, 65, UPC_E = 1, //m = 1, 66 EAN13_KAN13 = 2, //m = 2, 67 EAN8_KAN8 = 3, //m = 3, 68 COE39 = 4, //m = 4, 69 ITF = 5, //m = 5, 70 CODEBAR = 6, //m = 6, 71 CODE93 = 72, //m = 72 CODE128 = 73 //m = 73 } #endregion #region Error Code public const int PRT_SUCCESS = 0; #endregion #region "StatusUpdateEvent" Event: "Data" Parameter Constants public const int PTR_SUE_COVER_OPEN = 11; public const int PTR_SUE_COVER_OK = 12; public const int PTR_SUE_JRN_EMPTY = 21; public const int PTR_SUE_JRN_NEAREMPTY = 22; public const int PTR_SUE_JRN_PAPEROK = 23; public const int PTR_SUE_REC_EMPTY = 24; public const int PTR_SUE_REC_NEAREMPTY = 25; public const int PTR_SUE_REC_PAPEROK = 26; public const int PTR_SUE_SLP_EMPTY = 27; public const int PTR_SUE_SLP_NEAREMPTY = 28; public const int PTR_SUE_SLP_PAPEROK = 29; public const int PTR_SUE_JRN_CARTRIDGE_EMPTY = 41; public const int PTR_SUE_JRN_CARTRIDGE_NEAREMPTY = 42; public const int PTR_SUE_JRN_HEAD_CLEANING = 43; public const int PTR_SUE_JRN_CARTRIDGE_OK = 44; public const int PTR_SUE_REC_CARTRIDGE_EMPTY = 45; public const int PTR_SUE_REC_CARTRIDGE_NEAREMPTY = 46; public const int PTR_SUE_REC_HEAD_CLEANING = 47; public const int PTR_SUE_REC_CARTRIDGE_OK = 48; public const int PTR_Sue_Slp_CARTRIDGE_EMPTY = 49; public const int PTR_Sue_Slp_CARTRIDGE_NEAREMPTY = 50; public const int PTR_SUE_SLP_HEAD_CLEANING = 51; public const int PTR_SUE_SLP_CARTRIDGE_OK = 52; public const int PTR_SUE_IDLE = 1001; #endregion #region Default public byte ESC = 0x1B; public byte SP = 0x14; public byte ESC_CR = 0x0D; public byte ESC_LF = 0x0A; public byte ESC_FF = 0xFF; public byte[] ESC_INITPRINTER = { 0x1B, 0x40 }; //Printer 초기화 //1BH, 74H, n n=1(Katakana) //1BH, 52H, n n=0(USA), n=8(Japan), n=13(korea) 'Select an international characer set //1CH, 43H, n n=0,48 JIS code system , n=1,49 Shift JIS code system. public byte[] ESC_LANGE = { 0x1B, 0x74, 0x01, 0x1B, 0x52, 0x08, 0x1C, 0x43, 0x01, 0x1C, 0x26 }; /// /// Buffer clear /// [10H, 14H, 08H, d1......d7] /// [d1=1, d2=3, d3=20, d4=1, d5=6, d6=2, d7=8] /// public byte[] ESC_BUFFERCLEAR = { 0x10, 0x14, 0x08, 0x01, 0x03, 0x14, 0x01, 0x06, 0x02, 0x08 }; #endregion #region Request Status (상태 전송) public byte[] ESC_REQ_SUATUS_PAPER_SENSOR = { 0x1D, 0x72, 0x01 }; //용지 센서 상태를 송신합니다 public byte[] ESC_REQ_SUATUS_PAPER_SENSOR1 = { 0x1D, 0x72, 0x31 }; //용지 센서 상태를 송신합니다 public byte[] ESC_REQ_SUATUS_DRAW_CON = { 0x1D, 0x72, 0x02 }; //캐쉬 드로어 커넥터 상태를 송신 합니다. public byte[] ESC_REQ_SUATUS_DRAW_CON1 = { 0x1D, 0x72, 0x32 }; //캐쉬 드로어 커넥터 상태를 송신 합니다. //public byte[] ESC_REQ_SUATUS_PAPER_SENSOR2 = { 0x1B, 0x63, 0x33 }; //용지 센서 상태를 송신합니다 #endregion #region BarCode Commad //Select printing position for HRI character /// /// HRI Print 안함 /// public byte[] ESC_HRI_NOTPRINT = { 0x1D, 0x48, 0x00 }; /// /// Barcode 상단에 HRI Print /// public byte[] ESC_HRI_TOPPRINT = { 0x1D, 0x48, 0x01 }; /// /// Barcode 아래에 HRI Print /// public byte[] ESC_HRI_BELOWPRINT = { 0x1D, 0x48, 0x02 }; /// /// Barcode 위,아래에 HRI Print /// public byte[] ESC_HRI_TOPANDBELOWPRINT = { 0x1D, 0x48, 0x03 }; #endregion #region Alignment public byte[] ESC_CENTER = { 0x1B, 0x61, 0x01 }; // CENTER 정렬 public byte[] ESC_RIGHT = { 0x1B, 0x61, 0x02 }; // 오른쪽 정렬 public byte[] ESC_LEFT = { 0x1B, 0x61, 0x00 }; // 왼쪽 정렬 #endregion #region Text public byte[] ESC_NORMAL = { 0x1B, 0x21, 0x00, 0x1C, 0x21, 0x00 }; //보통문자 #region Select print mode // [Format] 1BH, 21H, n // [Valid limits] 0<=n<=255 // [Initial value] n=0 //┌──┬────────────┬────────────────────┐ //│ │ │ Value │ //│Bit │ Function ├─────────┬──────────┤ //│ │ │ 0 │ 1 │ //├──┼────────────┼─────────┼──────────┤ //│ 0 │Character font │Font A is selected│Font B/C is selected│ //├──┼────────────┼─────────┼──────────┤ //│ 1 │To be defined │ -- │ -- │ //├──┼────────────┼─────────┼──────────┤ //│ 2 │To be defined │ -- │ -- │ //├──┼────────────┼─────────┼──────────┤ //│ 3 │Emphasized printing │ Candel │ Specify │ //├──┼────────────┼─────────┼──────────┤ //│ 4 │Double character height │ Candel │ Specify │ //├──┼────────────┼─────────┼──────────┤ //│ 5 │Double character width │ Candel │ Specify │ //├──┼────────────┼─────────┼──────────┤ //│ 6 │To be defined │ -- │ -- │ //├──┼────────────┼─────────┼──────────┤ //│ 7 │Underline │ Candel │ Specify │ //└──┴────────────┴─────────┴──────────┘ public byte[] ESC_FontA = { 0x1B, 0x21, 0x00 }; // Font A 인쇄 public byte[] ESC_FontBC = { 0x1B, 0x21, 0x01 }; // Font B/C 인쇄 public byte[] ESC_DOUBLE = { 0x1B, 0x21, 0x30, 0x1C, 0x57, 0x01 }; // 가로세로 2배 확대 public byte[] ESC_DBLHEIGH = { 0x1B, 0x21, 0x10, 0x1C, 0x21, 0x08 }; // 세로 2배 확대 public byte[] ESC_DBLWIDTH = { 0x1B, 0x21, 0x20, 0x1C, 0x21, 0x04 }; // 가로 2배 확대 ESC + "|2hC" public byte[] ESC_UNDERLINE = { 0x1B, 0x21, 0x80 }; // UnderLine ESC + "|uC" public byte[] ESC_UNDERLINEON1DOT = { 0x1B, 0x2D, 0x01 }; // UnderLine Mode On 1Dot public byte[] ESC_UNDERLINEON2DOT = { 0x1B, 0x2D, 0x02 }; // UnderLine Mode On 2Dot public byte[] ESC_UNDERLINEOFF = { 0x1B, 0x2D, 0x00 }; // UnderLine Mode Off #endregion #region Set Character size public byte[] ESC_VHMAG = { 0x1D, 0x21 }; // 배율확대확대 인쇄(FontSize) public byte[] ESC_H1MAG = { 0x1D, 0x21, 0x00 }; // 가로 1배확대 인쇄(FontSize) public byte[] ESC_V1MAG = { 0x1D, 0x21, 0x00 }; // 세로 1배확대 인쇄(FontSize) public byte[] ESC_H2Y2MAG = { 0x1D, 0x21, 0x11 }; // 가로/세로 2배 확대 public byte[] ESC_H2MAG = { 0x1D, 0x21, 0x10 }; // 가로 2배확대 인쇄(FontSize) public byte[] ESC_V2MAG = { 0x1D, 0x21, 0x01 }; // 세로 2배확대 인쇄(FontSize) public byte[] ESC_H3MAG = { 0x1D, 0x21, 0x20 }; // 가로 3배확대 인쇄(FontSize) public byte[] ESC_V3MAG = { 0x1D, 0x21, 0x02 }; // 세로 3배확대 인쇄(FontSize) public byte[] ESC_H4MAG = { 0x1D, 0x21, 0x30 }; // 가로 4배확대 인쇄(FontSize) public byte[] ESC_V4MAG = { 0x1D, 0x21, 0x03 }; // 세로 4배확대 인쇄(FontSize) public byte[] ESC_H5MAG = { 0x1D, 0x21, 0x40 }; // 가로 5배확대 인쇄(FontSize) public byte[] ESC_V5MAG = { 0x1D, 0x21, 0x04 }; // 세로 5배확대 인쇄(FontSize) public byte[] ESC_H6MAG = { 0x1D, 0x21, 0x50 }; // 가로 6배확대 인쇄(FontSize) public byte[] ESC_V6MAG = { 0x1D, 0x21, 0x05 }; // 세로 6배확대 인쇄(FontSize) public byte[] ESC_H7MAG = { 0x1D, 0x21, 0x60 }; // 가로 7배확대 인쇄(FontSize) public byte[] ESC_V7MAG = { 0x1D, 0x21, 0x06 }; // 세로 7배확대 인쇄(FontSize) public byte[] ESC_H8MAG = { 0x1D, 0x21, 0x70 }; // 가로 8배확대 인쇄(FontSize) public byte[] ESC_V8MAG = { 0x1D, 0x21, 0x07 }; // 세로 8배확대 인쇄(FontSize) #endregion #region Set Bold On/Off public byte[] ESC_BOLD_ON = { 0x1B, 0x45, 0x01 }; // 진하게 인쇄선언 public byte[] ESC_BOLD_OFF = { 0x1B, 0x45, 0x00 }; // 진하게 인쇄선언해제 public byte[] ESC_BOLD = { 0x1B, 0x21, 0x08 }; //'진하게 ESC + "|bC" #endregion #region Set Reverse Mode On/Off /// /// On Reverse Mode /// public byte[] ESC_REVERSE_MODE_ON = { 0x1D, 0x42, 0x01 };//ESC + "|rvC" /// /// Off Revers Mode /// public byte[] ESC_REVERSE_MODE_OFF = { 0x1D, 0x42, 0x00 };//ESC + "|!rvC" #endregion /* 'ESC_CUT = Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + ESC + "|P" ESC_CUT = ESC + "|50P" 'ESC_FEEDCUT = Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + ESC + "|fP" ESC_FEEDCUT = ESC + "|100fP" ESC_BITMAP1 = ESC + "|1B" ESC_BITMAP2 = ESC + "|2B" ESC_TOPLOGO = ESC + "|tL" ESC_BTMLOGO = ESC + "|bL" ESC_LINEFEED = ESC + "|lF" ESC_FEED = ESC + "|uF" ESC_NOT_BOLD = ESC + "|!bC" ESC_COLOR = ESC + "|rC" ESC_1MAG = ESC + "|1C" ESC_2MAG = ESC + "|4C" ESC_HMAG = ESC + "|2C" ESC_VMAG = ESC + "|3C" ESC_CENTER = ESC + "|cA" ESC_RIGHT = ESC + "|rA" */ #endregion #region Cut paper [Browsable(false), Category("Exception"), Description("Cutting Command"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [AmbientValue("")] public byte[] ESC_CUT = { 0x1D, 0x56, 0x31 }; //Convert.ToByte(49) }; public byte[] ESC_FULLCUT = { 0x1B, 0x69 }; public byte[] ESC_PARTCUT = { 0x1B, 0x6D }; #endregion #region Paper sensor to outpu paper out signals //용지부족/용지없음 Sensor public byte[] ESC_PAPERSENSOR_OFF = { 0x1B, 0x63, 0x33, 0x00 }; public byte[] ESC_PAPERSENSOR_ON = { 0x1B, 0x63, 0x33, 0x0F }; #endregion #region Paper sensor to stop printing /// /// Paper near end detector Valid /// public byte[] ESC_PAPER_NEAREND_0N = { 0x1B, 0x63, 0x34, 0x01 }; /// /// Paper near end detector InValid /// public byte[] ESC_PAPER_NEAREND_0FF = { 0x1B, 0x63, 0x34, 0x01 }; #endregion #region Real-time status transmission public byte[] ESC_TRANS_STATUS = { 0x10, 0x04, 0x01 }; /// /// Cover 상태 체크 명령어 /// public byte[] ESC_TRANS_OFFLINE = { 0x10, 0x04, 0x02 }; public byte[] ESC_TRANS_ERR_STUS = { 0x10, 0x04, 0x03 }; /// /// Paper 상태 체크 명령어 /// public byte[] ESC_TRANS_CONTI_STATUS = { 0x10, 0x04, 0x04 }; #endregion #region Enable/disable automatic status back public byte[] ESC_STATUSBACK = { 0x1d, 0x61, 0xCF }; #endregion #region Select peripheral device public byte[] ESC_DEVICE_PRT = { 0x1B, 0x3D, 0x01 }; #endregion #region Open CashDrawer public byte[] cmd_OpenCashDraerBox = { 0x1B, 0x70, 0x30 }; #endregion #region Print Type public enum PRT_CMD { NONE, //미지원 형식 PRT_IMG, //Image PRT_BAR, //바코드 PRT_CUT, //CUT PRT_NOR, //일반 문자 PRT_BLD, //진하게 PRT_VER, //세로확대 PRT_HOR, //가로확대 PRT_BIG, //가로/세로확대 PRT_CNT, //가로확대+가운데 정렬 PRT_JNL, //저널데이터 PRT_DRW, //돈통열림 ERROR //Error } public string PRT_IMG = "[IMG]"; //Image public string PRT_BAR = "[BAR]"; //바코드 public string PRT_CUT = "[CUT]"; //CUT public string PRT_NOR = "[NOR]"; //일반 문자 public string PRT_BLD = "[BLD]"; //진하게 public string PRT_VER = "[VER]"; //세로확대 public string PRT_HOR = "[HOR]"; //가로확대 public string PRT_BIG = "[BIG]"; //가로/세로확대 public string PRT_CNT = "[CNT]"; //가로확대+가운데 정렬 public string PRT_JNL = "[JNL]"; //저널데이터 public string PRT_DRW = "[DRW]"; //돈통열림 #endregion #region 상태체크 /// /// 상태체크(Paper, Drawer 상태 ) /// Drawer 상태는 상태체크가 가능한 돈통에 한함. /// public enum CHK_PRT_STATUS { CHK_PAPER, CHK_DRAWER } #endregion } /// /// Printer Status Information /// [Serializable] public class PrinterInformation { #region Printer Event private bool[,] Infomation = new bool[8 * 4, 2]; private enum eStatusInfo : int { //Event First Byte /// /// State of the drawer kick connector pin 3 [false:Low, true: High] /// DrwKickLH = 7 - 2, /// /// Online.offline [false: Online, true: Offline] /// OnOffLine = 7 - 3, /// /// Cover state [false:Closed, true : Open] /// Coverstate = 7 - 5, /// /// Paper feed by paper feed switch [false:Stopped, true : Operation] /// feedswitch = 7 - 6, //Event Second Byte(error information) /// /// Macro executing [false:Not execute, true : execute] /// MacroExecuting = 8 + 7 - 0, /// /// Panel switch[false:Off, true:On] /// Panelswitch = 8 + 7 - 1, /// /// Mechanical error(cover Open, Cutter Jam) [false:No, true: Yes] /// MechanicalErr = 8 * 7 - 2, /// /// Cutter jam [false:No, true: Yes] /// CutterJam = 8 * 7 - 3, /// /// Unrecoverable error[false:No, true:Yes] /// UnrecoverableErr = 8 + 7 - 5, /// /// Auto-recoverrable error detected [false:No, true:Yes] /// AutoRecoverableErr = 8 + 7 - 6, //Third byte(paper detector information) /// /// Roll Paper Near end detecter[false:Paper present, true Nopaper] /// PaperNearEnd_1 = 16 + 7 - 0, /// /// Roll Paper Near end detecter[false:Paper present, true Nopaper] /// PaperNearEnd_2 = 16 + 7 - 0, /// /// Roll Paper end detecter[false:Paper present, true Nopaper] /// PaperEnd_1 = 16 + 7 - 2, /// /// Roll Paper end detecter[false:Paper present, true Nopaper] /// PaperEnd_2 = 16 + 7 - 3, //Fourth byte (paper detector information) /// /// F/W down load Fail[false: Not Fail, true: Fail] /// FWdownLoadFail = 24 + 7 - 5 } public enum eSetStatusType : int { /// /// PRINTER STATUS[First Byte] /// PRT_PRINTERINFOMATION, /// /// ERROR INFOMATION[Second Byte] /// PRT_ERRINFOMATION, /// /// Paper Status[Third Byte] /// PRT_PAPERINFOMATION, /// /// Firm Ware[Fourth Byte] /// PRT_FIRMWAREDOWN } #endregion #region All Set public void SetAllData(char[] szData) { char[] szEvt = szData; //string bitStringFirst = str2bitstr(szData[0].ToString(), 1); //string bitStringSecond = str2bitstr(szData[1].ToString(), 1); //string bitStringThird = str2bitstr(szData[2].ToString(), 1); //string bitStringFourth = str2bitstr(szData[3].ToString(), 1); //string sBitInfo = bitStringFirst + bitStringSecond + bitStringThird + bitStringFourth; string sBitInfo = ""; sBitInfo = str2bitstr(szData[0].ToString(), 1); sBitInfo += str2bitstr(szData[1].ToString(), 1); sBitInfo += str2bitstr(szData[2].ToString(), 1); sBitInfo += str2bitstr(szData[3].ToString(), 1); string sValue = ""; for (int nRow = 0; nRow < Infomation.GetLength(0); nRow++) { sValue = sBitInfo.Substring(nRow, 1); Infomation[nRow, 1] = Infomation[nRow, 0] == (sValue == "1" ? true : false) ? false : true; Infomation[nRow, 0] = sValue == "1" ? true : false; } //bool DrawerKick = Infomation[eStatusInfo.DrwKickLH]; } public char[] GetAllData() { string sRet = ""; string szTemp = ""; for (int nRow = 0; nRow < Infomation.Length; nRow++) { szTemp += Infomation[nRow, 1] == true ? "1" : "0"; } return sRet.ToCharArray(); } #endregion #region Printer Status First/Second/Third/Fourth Byte Set public void SetPrintStatus(eSetStatusType eType, char szData) { string sBitInfo = str2bitstr(szData.ToString(), 1); int nStart = 0; switch (eType) { case eSetStatusType.PRT_PRINTERINFOMATION: nStart = 0; break; case eSetStatusType.PRT_ERRINFOMATION: nStart = 8; break; case eSetStatusType.PRT_PAPERINFOMATION: nStart = 16; break; case eSetStatusType.PRT_FIRMWAREDOWN: nStart = 24; break; default: return; } string sValue = ""; for (int nRow = 0; nRow < 8; nRow++) { sValue = sBitInfo.Substring(nRow, 1); Infomation[nStart + nRow, 1] = Infomation[nStart + nRow, 0] == (sValue == "1" ? true : false) ? false : true; Infomation[nStart + nRow, 0] = sValue == "1" ? true : false; } } #endregion #region First Byte(Printer Infomation) /// /// [Printer Status Infomation] /// State of the drawer kick connector pin3 /// FALSE: Low, TRUE : High /// public bool IsDrawerKickLoHi { get { return Infomation[(int)eStatusInfo.DrwKickLH, 0]; } set { Infomation[(int)eStatusInfo.DrwKickLH, 0] = value; } } public bool IsDrawerKickLoHiChange { get { bool bRet = Infomation[(int)eStatusInfo.DrwKickLH, 1]; Infomation[(int)eStatusInfo.DrwKickLH, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.DrwKickLH, 1] = value; } } /// /// [Printer Status Infomation] /// OnLine / OffLine /// FALSE : OnLine, TRUE ; OffLine /// public bool IsOffLine { get { return Infomation[(int)eStatusInfo.OnOffLine, 0]; } set { Infomation[(int)eStatusInfo.OnOffLine, 0] = value; } } public bool IsOffLineChange { get { bool bRet = Infomation[(int)eStatusInfo.OnOffLine, 1]; Infomation[(int)eStatusInfo.OnOffLine, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.OnOffLine, 1] = value; } } /// /// [Printer Status Infomation] /// Cover Open /// FALSE : Closed, TRUE : Open /// public bool IsCoverOpen { get { return Infomation[(int)eStatusInfo.Coverstate, 0]; } set { Infomation[(int)eStatusInfo.Coverstate, 0] = value; } } public bool IsCoverOpenChange { get { bool bRet = Infomation[(int)eStatusInfo.Coverstate, 1]; Infomation[(int)eStatusInfo.Coverstate, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.Coverstate, 1] = value; } } /// /// [Printer Status Infomation] /// Feed Switch /// FALSE : stop, TRUE : operating /// public bool Isfeedswitch { get { return Infomation[(int)eStatusInfo.feedswitch, 0]; } set { Infomation[(int)eStatusInfo.feedswitch, 0] = value; } } public bool IsfeedswitchChange { get { bool bRet = Infomation[(int)eStatusInfo.feedswitch, 1]; Infomation[(int)eStatusInfo.feedswitch, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.feedswitch, 1] = value; } } #endregion #region Second Byte(error information) /// /// [Error Information] /// IsMacroExecuting /// FALSE : Not Excuting, TRUE : Excuting /// public bool IsMacroExecuting { get { return Infomation[(int)eStatusInfo.MacroExecuting, 0]; } set { Infomation[(int)eStatusInfo.MacroExecuting, 0] = value; } } public bool IsMacroExecutingChange { get { bool bRet = Infomation[(int)eStatusInfo.MacroExecuting, 1]; Infomation[(int)eStatusInfo.MacroExecuting, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.MacroExecuting, 1] = value; } } /// /// [Error Information] /// Panel switch /// FALSE : OFF, TRUE : ON /// public bool IsPanelswitch { get { return Infomation[(int)eStatusInfo.Panelswitch, 0]; } set { Infomation[(int)eStatusInfo.Panelswitch, 0] = value; } } public bool IsPanelswitchChange { get { bool bRet = Infomation[(int)eStatusInfo.Panelswitch, 1]; Infomation[(int)eStatusInfo.Panelswitch, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.Panelswitch, 1] = value; } } /// /// [Error Information] /// Mechanical Error /// (Cover oen, Cutter jam) /// FALSE : No, TRUE : Yes /// public bool IsMechanicalError { get { return Infomation[(int)eStatusInfo.MechanicalErr, 0]; } set { Infomation[(int)eStatusInfo.MechanicalErr, 0] = value; } } public bool IsMechanicalErrorChange { get { bool bRet = Infomation[(int)eStatusInfo.MechanicalErr, 1]; Infomation[(int)eStatusInfo.MechanicalErr, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.MechanicalErr, 1] = value; } } /// /// [Error Information] /// Cutter jam /// FALSE : No, TRUE : Yes /// public bool IsCutterJam { get { return Infomation[(int)eStatusInfo.CutterJam, 0]; } set { Infomation[(int)eStatusInfo.CutterJam, 0] = value; } } public bool IsCutterJamChange { get { bool bRet = Infomation[(int)eStatusInfo.CutterJam, 1]; Infomation[(int)eStatusInfo.CutterJam, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.CutterJam, 1] = value; } } /// /// [Error Information] /// Unrecoverable Error /// FALSE : No, TRUE : Yes /// public bool IsUnrecoverableErr { get { return Infomation[(int)eStatusInfo.UnrecoverableErr, 0]; } set { Infomation[(int)eStatusInfo.UnrecoverableErr, 0] = value; } } public bool IsUnrecoverableErrChange { get { bool bRet = Infomation[(int)eStatusInfo.UnrecoverableErr, 1]; Infomation[(int)eStatusInfo.UnrecoverableErr, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.UnrecoverableErr, 1] = value; } } /// /// [Error Information] /// Auto-Recoverable Error detected /// FALSE : No, TRUE : Yes /// public bool IsAutoRecoverableErr { get { return Infomation[(int)eStatusInfo.AutoRecoverableErr, 0]; } set { Infomation[(int)eStatusInfo.AutoRecoverableErr, 0] = value; } } public bool IsAutoRecoverableErrChange { get { bool bRet = Infomation[(int)eStatusInfo.AutoRecoverableErr, 1]; Infomation[(int)eStatusInfo.AutoRecoverableErr, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.AutoRecoverableErr, 1] = value; } } #endregion #region Third byte(paper detector information) /// /// [paper detector information] /// Roll paper near end detector /// FALSE : Paper present , TRUE : No paper /// private bool IsPaperNearEnd_1 { get { return Infomation[(int)eStatusInfo.PaperNearEnd_1, 0]; } set { Infomation[(int)eStatusInfo.PaperNearEnd_1, 0] = value; } } private bool IsPaperNearEnd_1Change { get { bool bRet = Infomation[(int)eStatusInfo.PaperNearEnd_1, 1]; Infomation[(int)eStatusInfo.PaperNearEnd_1, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.PaperNearEnd_1, 1] = value; } } /// /// [paper detector information] /// Roll paper near end detector /// FALSE : Paper present , TRUE : No paper /// private bool IsPaperNearEnd_2 { get { return Infomation[(int)eStatusInfo.PaperNearEnd_2, 0]; } set { Infomation[(int)eStatusInfo.PaperNearEnd_2, 0] = value; } } private bool IsPaperNearEnd_2Change { get { bool bRet = Infomation[(int)eStatusInfo.PaperNearEnd_2, 1]; Infomation[(int)eStatusInfo.PaperNearEnd_2, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.PaperNearEnd_2, 1] = value; } } /// /// [paper detector information] /// Roll paper near end detector /// FALSE : Paper present , TRUE : No paper /// public bool IsPaperNearEnd { get { if (IsPaperNearEnd_1 && IsPaperNearEnd_2)return true; else return false; } set { IsPaperNearEnd_1 = value; IsPaperNearEnd_2 = value; } } public bool IsPaperNearEndChange { get { if (IsPaperNearEnd_1Change && IsPaperNearEnd_2Change)return true; else return false; } set { IsPaperNearEnd_1Change = value; IsPaperNearEnd_2Change = value; } } /// /// [paper detector information] /// Roll paper end detector /// FALSE : Paper present , TRUE : No paper /// private bool IsPaperEnd_1 { get { return Infomation[(int)eStatusInfo.PaperEnd_1, 0]; } set { Infomation[(int)eStatusInfo.PaperEnd_1, 0] = value; } } private bool IsPaperEnd_1Change { get { bool bRet = Infomation[(int)eStatusInfo.PaperEnd_1, 1]; Infomation[(int)eStatusInfo.PaperEnd_1, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.PaperEnd_1, 1] = value; } } /// /// [paper detector information] /// Roll paper end detector /// FALSE : Paper present, TRUE : No paper /// private bool IsPaperEnd_2 { get { return Infomation[(int)eStatusInfo.PaperEnd_2, 0]; } set { Infomation[(int)eStatusInfo.PaperEnd_2, 0] = value; } } private bool IsPaperEnd_2Change { get { bool bRet = Infomation[(int)eStatusInfo.PaperEnd_2, 1]; Infomation[(int)eStatusInfo.PaperEnd_2, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.PaperEnd_2, 1] = value; } } /// /// [paper detector information] /// Roll paper end detector /// FALSE : Paper present, TRUE : No paper /// public bool IsPaperEnd { get { if (IsPaperEnd_1 && IsPaperEnd_2) return true; else return false; } set { IsPaperEnd_1 = value; IsPaperEnd_2 = value; } } public bool IsPaperEndChange { get { if (IsPaperEnd_1Change && IsPaperEnd_2Change) return true; else return false; } set { IsPaperEnd_1Change = value; IsPaperEnd_2Change = value; } } #endregion #region Fourth byte (paper detector information) /// /// [paper detector information] /// paper detector information /// FW down load Fail /// FALSE : Not Fail, TRUE : Fail /// public bool IsFWdownLoadFail { get { return Infomation[(int)eStatusInfo.FWdownLoadFail, 0]; } set { Infomation[(int)eStatusInfo.FWdownLoadFail, 0] = value; } } public bool IsFWdownLoadFailChange { get { bool bRet = Infomation[(int)eStatusInfo.FWdownLoadFail, 1]; Infomation[(int)eStatusInfo.FWdownLoadFail, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.FWdownLoadFail, 1] = value; } } #endregion #region 형변환 private long chararry2Hexstr(char[] src, int st, out string dest) { long nRet = 0; char[] temp = null; dest = ""; if (src.Length < 1) return 0; temp = new char[src.Length - st]; for (int i = 0; i < src.Length - st; i++) { temp[i] = src[i + st]; string tt = src[i + st].ToString(); dest += String.Format("{0:X}", tt); } //temp.CopyTo(src, st); //bit //string sbit = int.Parse("0100", System.Globalization.NumberStyles.AllowHexSpecifier) & (2 ^ 0); return nRet; } // String To Hex private int string2Hex(string src) { return int.Parse(src, System.Globalization.NumberStyles.HexNumber); } public string string2Hexstr(string src) { string sRet = ""; char[] values = src.ToCharArray(); foreach (char letter in values) { uint value = Convert.ToUInt32(letter); string hexstr = string.Format("{0:X2}", value); sRet += hexstr; } return sRet; } // Hex To String private string Hex2string(int number) { return Convert.ToString(number, 16).ToUpper().PadLeft(2, '0'); } // Byte[] To UInt32 private UInt32 Byte2UInt32SmallEndian(byte[] src, int i) { return Convert.ToUInt32(src[i] + (src[i + 1] << 8) + (src[i + 2] << 16) + (src[i + 3] << 24)); } // Byte[] To UInt32 private UInt32 Byte2UInt32BigEndian(byte[] src, int i) { return Convert.ToUInt32(src[i + 3] + (src[i + 2] << 8) + (src[i + 1] << 16) + (src[i] << 24)); } //UInt32 To Byte[] Small-Endian private void Uint322Byte(byte[] dstByte, UInt32 srcuint, int start) { dstByte[3 + start] = (byte)((srcuint & 0xff000000) >> 24); dstByte[2 + start] = (byte)((srcuint & 0x00ff0000) >> 16); dstByte[1 + start] = (byte)((srcuint & 0x0000ff00) >> 8); dstByte[0 + start] = (byte)((srcuint & 0x000000ff)); } //UInt32 To Byte[] Big-Endian private void UInt32ToByteBif(byte[] dstByte, UInt32 srcuint, int start) { dstByte[0 + start] = (byte)((srcuint & 0xff000000) >> 24); dstByte[1 + start] = (byte)((srcuint & 0x00ff0000) >> 16); dstByte[2 + start] = (byte)((srcuint & 0x0000ff00) >> 8); dstByte[3 + start] = (byte)((srcuint & 0x000000ff)); } //byte[] To string public String Byte2string(byte[] src) { //string sRet = Encoding.Default.GetString(src); return Encoding.Default.GetString(src);// UnicodeEncoding.ASCII.GetString(src); } public String Byte2string(byte[] src, int index, int size) { string sRet = ""; char sz; for (int i = index; i < src.Length; i++) { sz = Convert.ToChar(src[i]); sRet += sz.ToString(); } return sRet;// UnicodeEncoding.ASCII.GetString(src, index, size); } //string To Byte[] public Byte[] string2byte(String src) { return Encoding.Default.GetBytes(src); //UnicodeEncoding.ASCII.GetBytes(src); } //string To Byte[] public int string2byte(String src, int sindex, int slength, byte[] dst, int bindex) { return UnicodeEncoding.ASCII.GetBytes(src, sindex, slength, dst, bindex); } /// /// 문자열을 byte[]으로 변환 /// /// /// private byte[] ConvertToByteArrayFromString(string str) { byte[] temp = Encoding.Default.GetBytes(str); if (temp.Length % 16 != 0) { byte[] temp2 = new byte[((temp.Length / 16) + 1) * 16]; Buffer.BlockCopy(temp, 0, temp2, 0, temp.Length); return temp2; } else { return temp; } } public byte[] hex2Byte(string hex) { byte[] bytes = new byte[hex.Length / 2]; for (int i = 0; i < bytes.Length; i++) { try { bytes[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16); } catch { throw new ArgumentException("hex is not a valid hex number!", "hex"); } } return bytes; } public string str2bitstr(string sValue, int nByteLen) { //char bit; string sRet = ""; string hexstr = string2Hexstr(sValue); long value = string2Hex(hexstr); sRet += Convert.ToString(value, 2).PadLeft(8, '0'); int d = Math.Abs((sRet.Length % 8) - 8); if (d != 8 && d != 0) sRet = sRet.PadLeft(d + sRet.Length, '0'); return sRet; } #endregion } }