public void Process(IZvtApdu requestApdu, IZvtApdu responseApdu) { PrintDocument printDocument; if (_printDocuments.Count == 0) { printDocument = new PrintDocument(); _printDocuments.Add(printDocument); } else printDocument = (PrintDocument)_printDocuments[_printDocuments.Count - 1]; printDocument.AddRange(((PrintLineApduResponse)responseApdu).ConvertToPrintLine()); if (((PrintLineApduResponse)responseApdu).LastLine) { printDocument = new PrintDocument(); _printDocuments.Add(printDocument); } }
/// <summary> /// Checks if this handler is compatible with the specified apdu /// </summary> /// <param name="responseApdu"></param> /// <returns></returns> public bool IsCompatibleHandler(IZvtApdu responseApdu) { foreach (byte[] compatibleApdu in _compatibleApdus) { if (responseApdu.ControlField.Equals(compatibleApdu)) return true; } return false; }
/// <summary> /// Finds the handlers of the specified response apdu /// </summary> /// <param name="apdu"></param> /// <returns></returns> private void CallResponseApduHandlers(IZvtApdu requestApdu, IZvtApdu responseApdu) { foreach (IApduHandler handler in _apduHandlers) { if (handler.IsCompatibleHandler(responseApdu)) { handler.Process(requestApdu, responseApdu); } } }
/// <summary> /// Checks if this handler is compatible with the specified apdu /// </summary> /// <param name="responseApdu"></param> /// <returns></returns> public bool IsCompatibleHandler(IZvtApdu responseApdu) { foreach (byte[] compatibleApdu in _compatibleApdus) { if (responseApdu.ControlField.Equals(compatibleApdu)) { return(true); } } return(false); }
/// <summary> /// Checks if this handler is compatible with the specified apdu /// </summary> /// <param name="responseApdu"></param> /// <returns></returns> public bool IsCompatibleHandler(IZvtApdu responseApdu) { Console.WriteLine("Received: {0:x2}, {1:x2}", responseApdu.ControlField.Class, responseApdu.ControlField.Instruction); foreach (byte[] compatibleApdu in _compatibleApdus) { if (responseApdu.ControlField.Equals(compatibleApdu)) { return(true); } } return(false); }
public ApduCollection TransmitAPDU(IZvtApdu apdu) { foreach (IApduHandler apduHandler in _apduHandlers) { apduHandler.StartCommand(); } _transport.Transmit(_transport.CreateTpdu(apdu)); ApduCollection responses = new ApduCollection(); while (true) { byte[] apduData = _transport.ReceiveResponsePacket(); byte[] apduCopy = new byte[apduData.Length]; Array.Copy(apduData, apduCopy, apduData.Length); IZvtApdu responseApdu = ApduResponse.Create(apduData); if (responseApdu == null) { throw new ArgumentException("Could not retrieve response"); } if (this.ResponseReceived != null) { ResponseReceived(responseApdu); } responses.Add(responseApdu); CallResponseApduHandlers(apdu, responseApdu); if (IsCompletionPacket == null && InternalIsCompletionPacket(apdu, responseApdu)) { break; } else if (IsCompletionPacket != null && IsCompletionPacket(apdu, responseApdu)) { break; } } return(responses); }
public void Process(IZvtApdu requestApdu, IZvtApdu responseApdu) { PrintDocument printDocument; if (_printDocuments.Count == 0) { printDocument = new PrintDocument(); _printDocuments.Add(printDocument); } else { printDocument = (PrintDocument)_printDocuments[_printDocuments.Count - 1]; } printDocument.AddRange(((PrintLineApduResponse)responseApdu).ConvertToPrintLine()); if (((PrintLineApduResponse)responseApdu).LastLine) { printDocument = new PrintDocument(); _printDocuments.Add(printDocument); } }
private bool InternalIsCompletionPacket(IZvtApdu transmittedApdu, IZvtApdu responseApdu) { if (transmittedApdu.SendsCompletionPacket) { byte[] apduData = responseApdu.GetRawApduData(); if (apduData[0] == 0x80 && apduData[1] == 0x00) { _transport.MasterMode = false; } if (responseApdu is CompletionApduResponse || responseApdu is AbortApduResponse || (responseApdu is StatusApdu && ((StatusApdu)responseApdu).Status != StatusCodes.ErrorIDEnum.NoError)) { _transport.MasterMode = true; return(true); } return(false); } else { return(true); } }
protected virtual void ResponseReceived(IZvtApdu responseApdu) { }
private void _commandTransmitter_ResponseReceived(IZvtApdu responseApdu) { }
public RS232Tpdu(IZvtApdu apdu) : this(apdu.GetRawApduData()) { }
public void Process(IZvtApdu requestApdu, IZvtApdu responseApdu) { _transport.Transmit(_transport.CreateTpdu(new StatusApdu())); }
public IZvtTpdu CreateTpdu(IZvtApdu apdu) { return new RS232Tpdu(apdu); }
public NetworkTpdu(IZvtApdu apdu) : this(apdu.GetRawApduData()) { }
public IZvtTpdu CreateTpdu(IZvtApdu apdu) { return(new RS232Tpdu(apdu)); }
public IZvtTpdu CreateTpdu(IZvtApdu apdu) { return(new NetworkTpdu(apdu)); }
public void Process(IZvtApdu requestApdu, IZvtApdu responseApdu) { _intermediateStatusCallback(responseApdu as IntermediateStatusApduResponse); }