protected virtual void Initialize(GenericDevice device) { this.ParentDevice = device; this.InReport = new IncomingReport(this); this.OutReport = new OutgoingReport(this); this.opCodeRequestTimer = new OpCodeRequestTimer(this, ceateDelegates()); }
protected virtual bool isOpCodeHeader(IncomingReport report) { if (AckOpCode == null) { return(false); } return(report.ShiftIfIsBlock(AckOpCode)); }
public virtual void Dispose() { opCodeRequestTimer.Stop(); operationMRE.Set(); OnAcked = null; OnParsed = null; OnError = null; OnFinished = null; ParentDevice = null; InReport = null; OutReport = null; }
private bool checkForAckHeader(IncomingReport report) { if (report.ShiftIfIsBlock(OpCodeSpecificAckHeader)) { if (OnAcked != null) { OnAcked(new OpCodeInvokerArgs { OpCode = this, Result = Result.OK }); } return(true); } return(false); }
private void processReport(IncomingReport report) { Result result = Result.OK; InReport.Assimilate(report); DoBeforeParseReport(); try { ParseReport(); } catch (Exception ex) { result = Result.ERROR; result.Exception = ex; } packetParsed(result); }
public void BeginParseReport(byte[] data) { IncomingReport report = IncomingReport.Create(this, data); if (!checkForAckHeader(report)) { if (isOpCodeHeader(report)) { ThreadPool.QueueUserWorkItem(delegate { if (ParentDevice == null) { return; } Log.WriteLine("Running thread: " + this.GetType().Name + ", data opcode: " + report[1].ToString("X")); processReport(report); }); } } }