Ejemplo n.º 1
0
        protected override void OnPrintBarcode(string barcode, AlignOptions align, bool readable)
        {
            _docBuffer[_bufSize++] = 0x1B;
            _docBuffer[_bufSize++] = 0x28;
            _docBuffer[_bufSize++] = 0x42;

            _docBuffer[_bufSize++] = (byte)(barcode.Length + 6); // nL
            _docBuffer[_bufSize++] = 0x00;                       // nH

            _docBuffer[_bufSize++] = 0x00;                       // k

            _docBuffer[_bufSize++] = 0x02;                       // m

            _docBuffer[_bufSize++] = 0xFE;                       // s

            _docBuffer[_bufSize++] = 0x84;                       // v1
            _docBuffer[_bufSize++] = 0x00;                       // v2
            _docBuffer[_bufSize++] = 0x05;                       // c

            Encoding.ASCII.GetBytes(barcode).CopyTo(_docBuffer, _bufSize);
            _bufSize += barcode.Length;

            _docBuffer[_bufSize++] = 0x0D;
            _docBuffer[_bufSize++] = 0x0A;
            _docBuffer[_bufSize++] = 0x0D;
            _docBuffer[_bufSize++] = 0x0A;
        }
Ejemplo n.º 2
0
 protected override void OnPrintImage(Bitmap image, AlignOptions align)
 {
     _printBuffer.Add(new LineInfo()
     {
         Image = image, Align = align
     });
 }
Ejemplo n.º 3
0
 protected override void OnPrintBarcode(string barcode, AlignOptions align, bool readable)
 {
     _printBuffer.Add(new LineInfo()
     {
         Text  = readable ? barcode : string.Empty,
         Align = align,
         Image = BarcodeBuilder.GetBarcodeImage(barcode, BC_HEIGHT)
     });
 }
Ejemplo n.º 4
0
        protected override void OnPrintBarcode(string barcode, AlignOptions align,
                                               bool readable)
        {
            ExecuteDriverCommand(delegate()
            {
                _errorCode = (short)GeneralError.Success;

                byte[] nPrintBuffer = new byte[256];
                int BufSize         = 0;

                // позиционирование по центру
                nPrintBuffer[BufSize++] = 0x1B;
                nPrintBuffer[BufSize++] = Convert.ToByte('a');
                nPrintBuffer[BufSize++] = 1;

                // высота штрих-кода
                nPrintBuffer[BufSize++] = 0x1D;
                nPrintBuffer[BufSize++] = Convert.ToByte('h');
                nPrintBuffer[BufSize++] = 70;

                // ширина кода
                nPrintBuffer[BufSize++] = 0x1D;
                nPrintBuffer[BufSize++] = Convert.ToByte('w');
                nPrintBuffer[BufSize++] = 2;

                // цифры
                nPrintBuffer[BufSize++] = 0x1D;
                nPrintBuffer[BufSize++] = Convert.ToByte('H');
                if (readable)
                {
                    nPrintBuffer[BufSize++] = 2;
                }
                else
                {
                    nPrintBuffer[BufSize++] = 0;
                }

                // штрих-код
                nPrintBuffer[BufSize++] = 0x1D;
                nPrintBuffer[BufSize++] = Convert.ToByte('k');
                nPrintBuffer[BufSize++] = 0x43;
                nPrintBuffer[BufSize++] = 0x0C;

                POSCommand cmd = new POSCommand(237);
                cmd.AddChar(OPERATOR_PASSWD, 4);                                            // пароль
                cmd.AddNumeric(0, 1);                                                       // устройство
                cmd.AddBChar(Encoding.ASCII.GetString(nPrintBuffer, 0, BufSize) + barcode); // данные

                _errorCode = cmd.Execute(Port);

                if (_errorCode != (short)GeneralError.Success)
                {
                    CancelDocument();
                }
            });
        }
Ejemplo n.º 5
0
        protected override void OnPrintImage(System.Drawing.Bitmap image, AlignOptions align)
        {
            ExecuteDriverCommand(delegate()
            {
                byte[] imageBytes = GetImageBytes(image);
                if (imageBytes == null)
                {
                    return;
                }

                if (!CheckSlipSize(image.Height / 8))
                {
                    return;
                }

                ClearBuffer();
                int paddingLength = 0;
                if (align != AlignOptions.Left)
                {
                    paddingLength = CurrTapeWidth - imageBytes.Length / (PrintOnSlip ? 10 : 12);
                }
                if (align != AlignOptions.Right)
                {
                    paddingLength = paddingLength / 2;
                }
                byte[] paddingBytes = Encoding.ASCII.GetBytes(new string(' ', paddingLength));

                // печать картинки
                int rowsCount = image.Height / 8;
                if (image.Height % 8 > 0)
                {
                    rowsCount++;
                }

                for (int rowNo = 0; rowNo < rowsCount; rowNo++)
                {
                    // позиционирование пробелами
                    WriteBuffer(paddingBytes);
                    // команда печати графики
                    WriteBuffer(0x1B, 0x4C);
                    // длина строки
                    WriteBuffer(BitConverter.GetBytes((short)image.Width));
                    WriteBuffer(0x00);
                    // байты строки изображения
                    WriteBuffer(imageBytes, rowNo * image.Width, image.Width);
                    // переход на новую строку
                    WriteBuffer(0x1B, 0x4A, PrintOnSlip ? (byte)8 : (byte)12);
                }

                FlushBuffer();
            });
        }
Ejemplo n.º 6
0
        protected override void OnPrintBarcode(string barcode, AlignOptions align,
                                               bool readable)
        {
            _deviceProtocol.WriteDebugLine(string.Format("OnPrintBarcode({0}, {1}, {2})", barcode, align, readable));
            ExecuteDriverCommand(!IsPrim02, delegate()
            {
                if (IsPrim02)
                {
                    _deviceProtocol.CreateCommand("1A");
                    _deviceProtocol.AddString("02");
                    _deviceProtocol.AddString(readable ? "02" : "00");
                    _deviceProtocol.AddString("00");
                    _deviceProtocol.AddString("46");
                    _deviceProtocol.AddString("02");
                    _deviceProtocol.AddString(barcode);
                    _deviceProtocol.Execute();
                }
                else
                {
                    // расположение
                    switch (align)
                    {
                    case AlignOptions.Left:
                        _deviceProtocol.Write(new byte[] { 0x1B, Convert.ToByte('a'), 0 });
                        break;

                    case AlignOptions.Center:
                        _deviceProtocol.Write(new byte[] { 0x1B, Convert.ToByte('a'), 1 });
                        break;

                    case AlignOptions.Right:
                        _deviceProtocol.Write(new byte[] { 0x1B, Convert.ToByte('a'), 2 });
                        break;
                    }
                    // высота штрих-кода
                    _deviceProtocol.Write(new byte[] { 0x1D, Convert.ToByte('h'), 70 });
                    // ширина кода
                    _deviceProtocol.Write(new byte[] { 0x1D, Convert.ToByte('w'), 2 });
                    // цифры
                    _deviceProtocol.Write(new byte[] { 0x1D, Convert.ToByte('H'), readable ? (byte)2 : (byte)0 });
                    // тип штрих-кода
                    _deviceProtocol.Write(new byte[] { 0x1D, Convert.ToByte('k'), 0x43, 0x0C });
                    // данные
                    _deviceProtocol.Write(Encoding.ASCII.GetBytes(barcode));
                    // NULL
                    _deviceProtocol.Write(new byte[] { 0x00 });
                    // сброс расположения
                    _deviceProtocol.Write(new byte[] { 0x1B, Convert.ToByte('a'), 0 });
                }
            });
        }
Ejemplo n.º 7
0
 protected override void OnPrintImage(System.Drawing.Bitmap image, AlignOptions align)
 {
     ExecuteDriverCommand(true, protocol => { });
 }
Ejemplo n.º 8
0
 protected override void OnPrintBarcode(string barcode, AlignOptions align, bool readable)
 {
     ExecuteDriverCommand("24", true, readable ? "2" : "0", "2", "70", "2", barcode);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// align can be 'left', 'center', or 'right'
 /// </summary>
 /// <param name="align"></param>
 public void setAlign(AlignOptions align) { }
Ejemplo n.º 10
0
        protected override void OnPrintImage(System.Drawing.Bitmap image, AlignOptions align)
        {
            ExecuteDriverCommand(delegate()
            {
                byte[] nCmd = new byte[MAX_CMD_LEN * 100];
                int nLen    = 0;

                // для позиционирования картинки используем сдвиг отступа печати
                nCmd[nLen++] = 0x1D;
                nCmd[nLen++] = Convert.ToByte('L');

                if (align == AlignOptions.Left || TAPE_WIDTH_PX < image.Width)
                {
                    nCmd[nLen++] = 0;
                    nCmd[nLen++] = 0;
                }
                else
                {
                    switch (align)
                    {
                    case AlignOptions.Center:
                        nCmd[nLen++] = (byte)((TAPE_WIDTH_PX - image.Width) / 2);
                        nCmd[nLen++] = 0;
                        break;

                    case AlignOptions.Right:
                        nCmd[nLen++] = (byte)((TAPE_WIDTH_PX - image.Width) % 256);
                        nCmd[nLen++] = (byte)((TAPE_WIDTH_PX - image.Width) / 256);
                        break;
                    }
                }

                byte[] imageBytes = null;
                int stride        = 0;

                if (image.PixelFormat == PixelFormat.Format1bppIndexed)
                {
                    imageBytes = GetImageBytes(image, out stride);
                }
                else
                {
                    imageBytes = GetColorImageBytes(image, out stride);
                }

                // печать картинки
                nCmd[nLen++] = 0x1D;
                nCmd[nLen++] = Convert.ToByte('v');
                nCmd[nLen++] = Convert.ToByte('0');

                nCmd[nLen++] = 0;
                nCmd[nLen++] = (byte)stride;
                nCmd[nLen++] = 0;
                nCmd[nLen++] = (byte)(image.Height % 256);
                nCmd[nLen++] = (byte)(image.Height / 256);

                Array.Copy(imageBytes, 0, nCmd, nLen, imageBytes.Length);
                nLen += imageBytes.Length;
                WriteBuffer(nCmd, nLen);

                System.Threading.Thread.Sleep(500);

                // возвращаем отступ в исходное положение
                nLen         = 0;
                nCmd[nLen++] = 0x1D;
                nCmd[nLen++] = Convert.ToByte('L');
                nCmd[nLen++] = 0;
                nCmd[nLen++] = 0;

                // промотка строки
                nCmd[nLen++] = 0x0A;
                WriteBuffer(nCmd, nLen);
            });
        }
Ejemplo n.º 11
0
        protected override void OnPrintBarcode(string barcode, AlignOptions align,
                                               bool readable)
        {
            ExecuteDriverCommand(delegate()
            {
                WriteDebugLine("OnPrintBarcode");
                WriteDebugLine(barcode);
                byte[] nCmd = new byte[MAX_CMD_LEN];
                int nLen    = 0;

                // расположение
                nCmd[nLen++] = 0x1B;
                nCmd[nLen++] = Convert.ToByte('a');

                switch (align)
                {
                case AlignOptions.Left:
                    nCmd[nLen++] = 0;
                    break;

                case AlignOptions.Center:
                    nCmd[nLen++] = 1;
                    break;

                case AlignOptions.Right:
                    nCmd[nLen++] = 2;
                    break;
                }

                // высота штрих-кода
                nCmd[nLen++] = 0x1D;
                nCmd[nLen++] = Convert.ToByte('h');
                nCmd[nLen++] = 70;

                // ширина кода
                nCmd[nLen++] = 0x1D;
                nCmd[nLen++] = Convert.ToByte('w');
                nCmd[nLen++] = 2;

                // цифры
                nCmd[nLen++] = 0x1D;
                nCmd[nLen++] = Convert.ToByte('H');
                if (readable)
                {
                    nCmd[nLen++] = 2;
                }
                else
                {
                    nCmd[nLen++] = 0;
                }

                // штрих-код
                nCmd[nLen++] = 0x1D;
                nCmd[nLen++] = Convert.ToByte('k');
                nCmd[nLen++] = 0x43;
                nCmd[nLen++] = 0x0C;

                // данные
                Array.Copy(Encoding.ASCII.GetBytes(barcode), 0, nCmd, nLen, barcode.Length);
                nLen += barcode.Length;

                // NUL
                nCmd[nLen++] = 0x00;

                // сброс расположения
                nCmd[nLen++] = 0x1B;
                nCmd[nLen++] = Convert.ToByte('a');
                nCmd[nLen++] = 0;

                WriteBuffer(nCmd, nLen);
            });
        }
Ejemplo n.º 12
0
 protected override void OnPrintImage(System.Drawing.Bitmap image, AlignOptions align)
 {
     ErrorCode = new ServerErrorCode(this, GeneralError.Success);
 }
Ejemplo n.º 13
0
        protected override void OnPrintBarcode(string barcode, AlignOptions align, bool readable)
        {
            ExecuteDriverCommand(delegate()
            {
                int width           = 2;
                byte[] barcodeBytes = GetBarcodeBytes(barcode, width);
                if (barcodeBytes == null)
                {
                    return;
                }

                if (!CheckSlipSize(width * 2))
                {
                    return;
                }

                int paddingLength = 0;
                if (align != AlignOptions.Left)
                {
                    paddingLength = CurrTapeWidth - barcodeBytes.Length / (PrintOnSlip ? 10 : 12);
                }
                if (align != AlignOptions.Right)
                {
                    paddingLength = paddingLength / 2;
                }
                byte[] paddingBytes = Encoding.ASCII.GetBytes(new string(' ', paddingLength));

                ClearBuffer();
                for (int i = 0; i < width * 2; i++)
                {
                    // позиционирование пробелами
                    WriteBuffer(paddingBytes);
                    // команда печати графики
                    WriteBuffer(0x1B, 0x4C);
                    // длина строки
                    WriteBuffer(BitConverter.GetBytes((short)barcodeBytes.Length));
                    WriteBuffer(0x00);
                    // байты штрихкода
                    WriteBuffer(barcodeBytes);
                    // переход на новую строку
                    WriteBuffer(0x1B, 0x4A, PrintOnSlip ? (byte)8 : (byte)11);
                }

                if (readable)
                {
                    // позиционирование пробелами
                    WriteBuffer(paddingBytes);
                    WriteBuffer(0x20, 0x20);
                    if (PrintOnSlip)
                    {
                        WriteBuffer(0x20, 0x20);
                    }
                    // печать цифр штрихкода
                    WriteBuffer(barcode);
                    // CRLF
                    WriteBuffer(0x0D, 0x0A);
                }

                FlushBuffer();
            });
        }
Ejemplo n.º 14
0
 protected override void OnPrintImage(System.Drawing.Bitmap image, AlignOptions align)
 {
     ExecuteDriverCommand(delegate() { });
 }
Ejemplo n.º 15
0
    /** Generates a steering that dinamically aligns the orientation to the target orientation  */
    public static Steering Align(Kinematic source, Steering sourceSteering, float targetOrientation, AlignOptions opts)
    {
        Steering steering = new Steering();

        // Define objectives
        float rotation     = Kinematic.OrientDiff(source.orientation, targetOrientation);
        float rotationSize = System.Math.Abs(rotation);
        float targetRotation;

        // Define target rotation
        if (rotationSize < opts.targetRadius)
        {
            return(steering);
        }
        if (rotationSize > opts.slowRadius)
        {
            targetRotation = opts.maxRotation;
        }
        else
        {
            targetRotation = rotationSize * opts.maxRotation / opts.slowRadius;
        }

        // Define steering based on target rotation
        steering.angular  = Math.Min((targetRotation * Mathf.Sign(rotation) - sourceSteering.rotation) / opts.timeToTarget, opts.maxAngular);
        steering.rotation = sourceSteering.rotation + steering.angular * Time.deltaTime;

        return(steering);
    }
Ejemplo n.º 16
0
 protected override void OnPrintImage(System.Drawing.Bitmap image, AlignOptions align)
 {
     _deviceProtocol.WriteDebugLine("OnPrintImage");
     ExecuteDriverCommand(delegate() { });
 }
Ejemplo n.º 17
0
 /** Generates a steering that dinamically aligns the orientation to face the target */
 public static Steering Face(Kinematic source, Steering sourceSteering, ILocation target, AlignOptions opts)
 {
     return(Dynamic.Align(source, sourceSteering, Kinematic.Vec2Orient(target.position - source.position), opts));
 }
Ejemplo n.º 18
0
 protected override void OnPrintBarcode(string barcode, AlignOptions align,
                                        bool readable)
 {
     OnPrintString(barcode.PadLeft((barcode.Length + PrinterInfo.TapeWidth.MainPrinter) / 2), FontStyle.Regular);
     ErrorCode = new ServerErrorCode(this, GeneralError.Success);
 }