コード例 #1
0
        private IPrinterResponse Send(IPrinterRequest irequest)
        {
            if (irequest is FPURequest)
            {
                return(base.Send((FPURequest)irequest));
            }

            SlipResponse response = new SlipResponse();

            return(response);
        }
コード例 #2
0
ファイル: SlipPrinter.cs プロジェクト: serhatmorkoc/cepos
        private IPrinterResponse Send(IPrinterRequest irequest)
        {
            //if (irequest is FPURequest) return base.Send((FPURequest)irequest);


            SlipResponse response = new SlipResponse();

            if (sp == null)
            {
                response.Detail = "serial port has not been initialized yet";
                return(response);
            }

            SlipRequest request = (SlipRequest)irequest;

            byte[] b = StringToByteArray(request.ToString());
            sp.Write(b, 0, b.Length);

            if (request.StatusCheck)
            {
                System.Threading.Thread.Sleep(100);
            }
            else
            {
                TimeSpan ts = DateTime.Now.Subtract(lastWRTime);
                if (ts.TotalMilliseconds < SLIP_DELAY)
                {
                    System.Threading.Thread.Sleep(SLIP_DELAY - (int)ts.TotalMilliseconds);
                }
            }

            lastWRTime = DateTime.Now;
            if (sp.BytesToRead > 0)
            {
                response = new SlipResponse(sp.ReadByte().ToString());
            }

            return(response);
        }