Пример #1
0
        public static void Setup(string ip, int port)
        {
            Connection_TCP conn = null;

            try
            {
                byte[] bytes = new byte[sensorTypeCommand.Length + setStartOfPrintPosition.Length];
                Buffer.BlockCopy(sensorTypeCommand, 0, bytes, 0, sensorTypeCommand.Length);
                Buffer.BlockCopy(setStartOfPrintPosition, 0, bytes, sensorTypeCommand.Length,
                                 setStartOfPrintPosition.Length);

                conn = Connection_TCP.CreateClient(ip, port);
                var ok = conn.Open();
                conn.Write(bytes);
                conn.WaitForEmptyBuffer(5000);
                conn.Close();
                Thread.Sleep(3000);
            }
            catch
            {
                // ignore
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
Пример #2
0
        public static void Calibrate(string ip, int port)
        {
            Connection_TCP conn = Connection_TCP.CreateClient(ip, port);
            var            ok   = conn.Open();

            conn.Write(quickMediaCalibration);
        }
Пример #3
0
        public static bool Print(byte[] bytes, string ip, int port)
        {
            bool           result = false;
            Connection_TCP conn   = null;

            try
            {
                DocumentDPL   docDPL   = new DocumentDPL();
                ParametersDPL paramDPL = new ParametersDPL();
                docDPL.ColumnOffset = 65;
                docDPL.RowOffset    = 0;
                MemoryStream ms = new MemoryStream();
                ms.Write(bytes, 0, bytes.Length);
                Bitmap anImage = new Bitmap(ms);
                anImage.RotateFlip(RotateFlipType.Rotate90FlipX);
                docDPL.WriteImage(anImage, DocumentDPL.ImageType.Other, 0, 0, paramDPL);
                byte[] printData = docDPL.GetDocumentImageData();

                conn = Connection_TCP.CreateClient(ip, port);

                conn.Open();

                uint bytesWritten   = 0;
                uint bytesToWrite   = 1024;
                uint totalBytes     = (uint)printData.Length;
                uint remainingBytes = totalBytes;
                while (bytesWritten < totalBytes)
                {
                    if (remainingBytes < bytesToWrite)
                    {
                        bytesToWrite = remainingBytes;
                    }
                    conn.Write(printData, (int)bytesWritten, (int)bytesToWrite);
                    bytesWritten  += bytesToWrite;
                    remainingBytes = remainingBytes - bytesToWrite;
                }
                conn.WaitForEmptyBuffer(5000);
                conn.Close();
                Thread.Sleep(1000);
                result = true;
            }
            catch
            {
                // ignore
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }

            return(result);
        }
Пример #4
0
        public static Dictionary <string, object> RunQuery(string clause, string ip, int printPort)
        {
            Connection_TCP conn = null;
            Dictionary <string, object> result = new Dictionary <string, object>();

            try
            {
                conn = Connection_TCP.CreateClient(ip, printPort);
                bool gh = conn.Open();
                PrinterInformation_DPL p = new PrinterInformation_DPL();
                p.QueryPrinter(conn, 3000);
                result.Add("General", p);

                MediaLabel_DPL mediaLabel = new MediaLabel_DPL();
                mediaLabel.QueryPrinter(conn, 3000);
                result.Add("MediaLabel", mediaLabel);

                SystemSettings_DPL sysSettings = new SystemSettings_DPL();
                sysSettings.QueryPrinter(conn, 3000);
                result.Add("System", sysSettings);

                PrintSettings_DPL printSettings = new PrintSettings_DPL();
                printSettings.QueryPrinter(conn, 3000);
                result.Add("Print Controls", printSettings);

                SensorCalibration_DPL sensorCalibration = new SensorCalibration_DPL();
                sensorCalibration.QueryPrinter(conn, 3000);
                result.Add("Calibration", sensorCalibration);

                Miscellaneous_DPL misc = new Miscellaneous_DPL();
                misc.QueryPrinter(conn, 3000);
                result.Add("Misc", misc);
                conn.Close();
            }
            catch
            {
                //bool r = false;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }

            return(result);
        }