Ejemplo n.º 1
0
 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());
 }
Ejemplo n.º 2
0
        protected virtual bool isOpCodeHeader(IncomingReport report)
        {
            if (AckOpCode == null)
            {
                return(false);
            }

            return(report.ShiftIfIsBlock(AckOpCode));
        }
Ejemplo n.º 3
0
 public virtual void Dispose()
 {
     opCodeRequestTimer.Stop();
     operationMRE.Set();
     OnAcked      = null;
     OnParsed     = null;
     OnError      = null;
     OnFinished   = null;
     ParentDevice = null;
     InReport     = null;
     OutReport    = null;
 }
Ejemplo n.º 4
0
        private bool checkForAckHeader(IncomingReport report)
        {
            if (report.ShiftIfIsBlock(OpCodeSpecificAckHeader))
            {
                if (OnAcked != null)
                {
                    OnAcked(new OpCodeInvokerArgs {
                        OpCode = this, Result = Result.OK
                    });
                }
                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
                    });
                }
            }
        }