Exemple #1
0
        //  ESC *   1B 2A 00/01/20/21 0001-0960 00-FF...
        internal static string DecodeEscSelectBitImageMode(EscPosCmd record, int index)
        {
            int height = record.cmddata[index] switch
            {
                0 => 8,
                1 => 8,
                32 => 24,
                33 => 24,
                _ => - 1,
            };
            string modestr = record.cmddata[index] switch
            {
                0 => "8 dot Single(low) density ",
                1 => "8 dot Double(high) density",
                32 => "24 dot Single(low) density",
                33 => "24 dot Double(high) density",
                _ => "Undefined",
            };
            int    width    = BitConverter.ToUInt16(record.cmddata, index + 1);
            string widthstr = width.ToString("D", invariantculture);

            if ((height > 0) && ((width > 0) && (width <= 0x960)))
            {
                record.somebinary = GetBitmap(width, height, ImageDataType.Column, record.cmddata, (index + 3), "1");
            }
            return($"Mode:{modestr}, Width:{widthstr} dot");
        }
Exemple #2
0
        //  US  ( E 1F 28 45 000A-FFFA 03 [09-0F 30-32]...
        internal static string DecodeVfdUsSetMemorySwitchValues(EscPosCmd record, int index)
        {
            int length = BitConverter.ToUInt16(record.cmddata, 3);

            if ((length < 10) && (length > 65530))
            {
                return("Out of range");
            }
            else if (((length - 1) % 9) != 0)
            {
                return("Miss align length");
            }
            int           count   = (length - 1) / 9;
            List <string> memorys = new List <string>();

            for (int i = 0, currindex = 6; i < count; i++, currindex += 2)
            {
                string msw = record.cmddata[currindex] switch
                {
                    9 => "Backlight OFF setting",
                    10 => "Character code table",
                    11 => "International character set",
                    12 => "Brightness adjustment",
                    13 => "Specification of the peripheral device",
                    14 => "Display of the cursor",
                    15 => "Number of display",
                    _ => "Undefined",
                };
                string setting = ascii.GetString(record.cmddata, (currindex + 1), 8).Replace('2', '_');
                memorys.Add($"MemorySwitch:{msw} Setting:{setting}");
            }
            return(string.Join <string>(", ", memorys));
        }
Exemple #3
0
        //  US  ( A 1F 28 41 0003-FFFF 30 [30/31 00-FF]...
        internal static string DecodeVfdUsSelectDisplays(EscPosCmd record, int index)
        {
            int length = BitConverter.ToUInt16(record.cmddata, 3);

            if (length < 3)
            {
                return("Out of range");
            }
            else if ((length & 1) == 0)
            {
                return("Even length");
            }
            int           count    = (length - 1) / 2;
            List <string> displays = new List <string>();

            for (int i = 0, currindex = 6; i < count; i++, currindex += 2)
            {
                string enable = record.cmddata[currindex] switch
                {
                    48 => "Disabled",
                    49 => "Enabled",
                    _ => "Undefined",
                };
                displays.Add($"Setting:{enable} Display No.:{record.cmddata[currindex + 1]}");
            }
            return(string.Join <string>(", ", displays));
        }
Exemple #4
0
        //  ESC ( A 1B 28 41 05 00 61 64 00-3F 00-FF 00-FF
        internal static string DecodeEscBeeperBuzzerM1b(EscPosCmd record, int index)
        {
            byte cycles      = record.cmddata[index];
            byte onduration  = record.cmddata[index + 1];
            byte offduration = record.cmddata[index + 2];

            return($"Cycles:{cycles}, On-Duration:{onduration} x 100ms, Off-Duration:{offduration} x 100ms");
        }
Exemple #5
0
        //  FS  !   1C 21 bx0xx0000
        internal static string DecodeFsSelectPrintModeKanji(EscPosCmd record, int index)
        {
            byte   mode         = record.cmddata[index];
            string underline    = (mode & 0x80) == 0x80 ? "ON" : "OFF";
            string doublewidth  = (mode & 0x20) == 0x20 ? "ON" : "OFF";
            string doubleheight = (mode & 0x10) == 0x10 ? "ON" : "OFF";

            return($"Underline:{underline}, DoubleWidth:{doublewidth}, DoubleHeight:{doubleheight}");
        }
Exemple #6
0
 //  US  ( G 1F 28 47 02 00 61 00/01/30/31
 internal static string DecodeVfdUsSelectKanjiCharacterCodeSystem(EscPosCmd record, int index)
 {
     return(record.cmddata[index] switch
     {
         0 => "JIS",
         48 => "JIS",
         1 => "ShiftJIS",
         49 => "ShiftJIS",
         _ => "Undefined",
     });
Exemple #7
0
        //  ESC !   1B 21 bx0xxx00x
        internal static string DecodeEscSelectPrintMode(EscPosCmd record, int index)
        {
            byte   mode         = record.cmddata[index];
            string underline    = (mode & 0x80) == 0x80 ? "ON" : "OFF";
            string doublewidth  = (mode & 0x20) == 0x20 ? "ON" : "OFF";
            string doubleheight = (mode & 0x10) == 0x10 ? "ON" : "OFF";
            string emphasize    = (mode & 0x08) == 0x08 ? "ON" : "OFF";
            string font         = (mode & 0x01) == 0x01 ? "B" : "A";

            return($"Underline:{underline}, DoubleWidth:{doublewidth}, DoubleHeight:{doubleheight}, Emphasize:{emphasize}, Font:{font}");
        }
Exemple #8
0
 //  ESC -   1B 2D 00-02/30-32
 internal static string DecodeEscUnderlineMode(EscPosCmd record, int index)
 {
     return(record.cmddata[index] switch
     {
         0 => "OFF",
         48 => "OFF",
         1 => "ON 1 dot",
         49 => "ON 1 dot",
         2 => "ON 2 dot",
         50 => "ON 2 dot",
         _ => "Undefined",
     });
Exemple #9
0
 //  ESC M   1B 4D 00-04/30-34/61/62
 internal static string DecodeFsSelectKanjiCharacterFont(EscPosCmd record, int index)
 {
     return(record.cmddata[index] switch
     {
         0 => "A",
         48 => "A",
         1 => "B",
         49 => "B",
         2 => "C",
         50 => "C",
         _ => "Undefined",
     });
Exemple #10
0
        //  US  $   1F 24 01-14 01/02
        internal static string DecodeVfdUsMoveCursorSpecifiedPosition(EscPosCmd record, int index)
        {
            byte   x      = record.cmddata[index];
            string column = ((x >= 1) && (x <= 20)) ? x.ToString("D", invariantculture) : "Out of range";
            string row    = record.cmddata[index + 1] switch
            {
                1 => "1",
                2 => "2",
                _ => "Out of range",
            };

            return($"Column:{column}, Row:{row}");
        }
Exemple #11
0
        //  US  ( E 1F 28 45 02 00 04 09-0F/6D-70/72/73
        internal static string DecodeVfdUsSendingDisplayingMemorySwitchValues(EscPosCmd record, int index)
        {
            byte m = record.cmddata[index];

            if (((m >= 9) && (m <= 15)) || ((m >= 109) && (m <= 112)) || (m == 114) || (m == 115))
            {
                return(m.ToString("D", invariantculture));
            }
            else
            {
                return("Out of range");
            }
        }
Exemple #12
0
        //  US  #   1F 23 00/01/30/31 00-14
        internal static string DecodeVfdUsTurnAnnounciatorOnOff(EscPosCmd record, int index)
        {
            string mode = record.cmddata[index] switch
            {
                0 => "OFF",
                48 => "OFF",
                1 => "ON",
                49 => "ON",
                _ => "Undefined",
            };
            byte   number       = record.cmddata[index + 1];
            string announciator = number <= 20 ? number.ToString("D", invariantculture) : "Out of range";

            return($"Mode:{mode}, Number:{announciator}");
        }
Exemple #13
0
        //  ESC ( A 1B 28 41 03 00 61 01-07 00-FF
        internal static string DecodeEscBeeperBuzzerM1a(EscPosCmd record, int index)
        {
            byte   pattern = record.cmddata[index];
            byte   cycles  = record.cmddata[index + 1];
            string result  = $"Cycles:{cycles}, Pattern:{pattern} is ";

            result += pattern switch
            {
                1 => "A",
                2 => "B",
                3 => "C",
                4 => "D",
                5 => "E",
                6 => "Error",
                7 => "Paper-End",
                _ => "Undefined",
            };
            return(result);
        }
Exemple #14
0
        //  ESC ( A 1B 28 41 07 00 62 30-33 01 64 00/FF 01-32/FF 01-32
        internal static string DecodeEscBeeperBuzzerOffline(EscPosCmd record, int index)
        {
            string factor = record.cmddata[index] switch
            {
                48 => "Cover open",
                49 => "Paper end",
                50 => "Recoverable error",
                51 => "Unrecoverable error",
                _ => "Undefined",
            };
            string beeptype = record.cmddata[index + 3] switch
            {
                0 => "OFF",
                255 => "Infinite",
                _ => "Undefined",
            };
            byte onduration  = record.cmddata[index + 4];
            byte offduration = record.cmddata[index + 5];

            return($"Factor:{factor}, Type:{beeptype}, On-Duration:{onduration} x 100ms, Off-Duration:{offduration} x 100ms");
        }
Exemple #15
0
        //  ESC ( Y 1B 28 59 02 00 00/01/30/31 00/01/30/31
        internal static string DecodeEscSpecifyBatchPrint(EscPosCmd record, int index)
        {
            string fanc = record.cmddata[index] switch
            {
                0 => "Print bufferd batch data",
                48 => "Print bufferd batch data",
                1 => "Start batch buffering",
                49 => "Start batch buffering",
                _ => "Undefined",
            };
            string direction = record.cmddata[index + 1] switch
            {
                0 => "Normal direction",
                48 => "Normal direction",
                1 => "Reverse direction",
                49 => "Reverse direction",
                _ => "Undefined",
            };

            return($"{fanc}, {direction}");
        }
Exemple #16
0
        //  ESC ( A 1B 28 41 07 00 63 30 01 64 00/FF 01-32/FF 01-32
        internal static string DecodeEscBeeperBuzzerNearEnd(EscPosCmd record, int index)
        {
            string beeptype = record.cmddata[index] switch
            {
                0 => "OFF",
                255 => "Infinite",
                _ => "Undefined",
            };
            byte   onduration = record.cmddata[index + 1];
            string t1;

            if (onduration == 255)
            {
                t1 = "On-Duration:Infinite";
            }
            else if ((onduration >= 1) && (onduration <= 50))
            {
                t1 = $"On-Duration:{onduration} x 100ms";
            }
            else
            {
                t1 = $"On-Duration:{onduration} Out of range";
            }
            byte   offduration = record.cmddata[index + 2];
            string t2;

            if ((offduration >= 1) && (offduration <= 50))
            {
                t2 = $"Off-Duration:{offduration} x 100ms";
            }
            else
            {
                t2 = $"Off-Duration:{offduration} Out of range";
            }
            return($"Type:{beeptype}, {t1}, {t2}");
        }
Exemple #17
0
        internal static string DecodeEscDefineUserDefinedCharacters(EscPosCmd record, int index, int maxwidth, int height)
        {
            byte          ybytes                = record.cmddata[index];
            byte          startcode             = record.cmddata[index + 1];
            byte          endcode               = record.cmddata[index + 2];
            int           count                 = startcode - endcode + 1;
            int           i                     = index + 3;
            List <string> chars                 = new List <string>();
            List <System.Drawing.Bitmap> glyphs = new List <System.Drawing.Bitmap>();

            for (int n = 0; n < count; n++)
            {
                byte xbytes = record.cmddata[i];
                int  size   = ybytes * xbytes;
                if (size > 0)
                {
                    glyphs.Add(GetBitmap(xbytes, height, ImageDataType.Column, record.cmddata, (i + 1), "1"));
                }
                else
                {
                    System.Drawing.Bitmap bitmap  = new System.Drawing.Bitmap(maxwidth, height, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
                    ColorPalette          palette = bitmap.Palette;
                    palette.Entries[0] = Color.White;
                    palette.Entries[1] = Color.Black;
                    bitmap.Palette     = palette;
                    glyphs.Add(bitmap);
                }

                i += size + 1;
                chars.Add($"X:{xbytes} bytes, Size:{size}");
            }
            record.somebinary = glyphs.ToArray();
            string charslist = string.Join(", ", chars);

            return($"VerticalBytes:{ybytes}, StartCode:{startcode}, EndCode:{endcode}, Characters:{charslist}");
        }
Exemple #18
0
        //  ESC ( A 1B 28 41 04 00 30 30-3A 01-3F 0A-FF
        internal static string DecodeEscBeeperBuzzer(EscPosCmd record, int index)
        {
            byte   pattern  = record.cmddata[index];
            byte   cycles   = record.cmddata[index + 1];
            byte   duration = record.cmddata[index + 2];
            string result   = $"Cycles:{cycles}, Duration:{duration} x 100ms, Pattern:{pattern} is ";

            result += pattern switch
            {
                48 => "doesn't beep",
                49 => "1320 Hz: 1000 ms beeping",
                50 => "2490 Hz: 1000 ms beeping",
                51 => "1320 Hz: 200 ms beeping",
                52 => "2490 Hz: 200 ms beeping",
                53 => "1320 Hz: 200 ms beeping → 200 ms off → 200 ms beeping",
                54 => "2490 Hz: 200 ms beeping → 200 ms off → 200 ms beeping",
                55 => "1320 Hz: 500 ms beeping",
                56 => "2490 Hz: 500 ms beeping",
                57 => "1320 Hz: 200 ms beeping → 200 ms off → 200 ms beeping → 200 ms off → 200 ms beeping",
                58 => "2490 Hz: 200 ms beeping → 200 ms off → 200 ms beeping → 200 ms off → 200 ms beeping",
                _ => "Undefined",
            };
            return(result);
        }
Exemple #19
0
 internal static string DecodeEscDefineUserDefinedCharacters0816(EscPosCmd record, int index)
 {
     return(DecodeEscDefineUserDefinedCharacters(record, index, 8, 16));
 }
Exemple #20
0
 internal static string DecodeEscDefineUserDefinedCharacters0917(EscPosCmd record, int index)
 {
     return(DecodeEscDefineUserDefinedCharacters(record, index, 9, 17));
 }
Exemple #21
0
 internal static string DecodeEscDefineUserDefinedCharacters1024(EscPosCmd record, int index)
 {
     return(DecodeEscDefineUserDefinedCharacters(record, index, 10, 24));
 }