Ejemplo n.º 1
0
        private void ProcessEvent(byte[] content)
        {
            var      eventType = (AciEventType)content[0];
            AciEvent aciEvent  = null;

            switch (eventType)
            {
            case AciEventType.BondStatus:
                aciEvent = new BondStatusEvent(content);
                HandleBondStatusEvent((BondStatusEvent)aciEvent);
                break;

            case AciEventType.CommandResponse:
                aciEvent = new CommandResponseEvent(content);
                HandleCommandResponseEvent((CommandResponseEvent)aciEvent);
                break;

            case AciEventType.Connected:
                aciEvent = new AciEvent(content);
                State    = Nrf8001State.Connected;
                break;

            case AciEventType.DataCredit:
                aciEvent = new DataCreditEvent(content);
                HandleDataCreditEvent((DataCreditEvent)aciEvent);
                break;

            case AciEventType.DataReceived:
                aciEvent = new DataReceivedEvent(content);
                HandleDataReceivedEvent((DataReceivedEvent)aciEvent);
                break;

            case AciEventType.DeviceStarted:
                aciEvent = new DeviceStartedEvent(content);
                HandleDeviceStartedEvent((DeviceStartedEvent)aciEvent);
                break;

            case AciEventType.Disconnected:
                aciEvent = new AciEvent(content);
                State    = Nrf8001State.Standby;
                break;

            case AciEventType.PipeStatus:
                aciEvent          = new AciEvent(content);
                OpenPipesBitmap   = aciEvent.Content.ToUnsignedLong(1);
                ClosedPipesBitmap = aciEvent.Content.ToUnsignedLong(9);
                break;

            default:
                aciEvent = new AciEvent(content);
                break;
            }

            Debug.Print("Event: " + eventType.GetName());

            if (AciEventReceived != null)
            {
                AciEventReceived(aciEvent);
            }
        }
Ejemplo n.º 2
0
 private void HandleDeviceStartedEvent(DeviceStartedEvent aciEvent)
 {
     State = aciEvent.State;
     DataCreditsAvailable = aciEvent.DataCreditsAvailable;
 }