private IPrinterResponse Send(IPrinterRequest irequest) { if (irequest is FPURequest) { return(base.Send((FPURequest)irequest)); } SlipResponse response = new SlipResponse(); return(response); }
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); }