private void HandlePortEvent(PortEvent evt) { Port port = _ports.GetPort(evt.PortId); if (port == null) { throw new WirekiteException(String.Format("Port event received for invalid port ID {0}", evt.PortId)); } PortType type = port.Type; switch (type) { case PortType.DigitalInputOnDemand: case PortType.DigitalInputPrecached: case PortType.DigitalInputTriggering: case PortType.DigitalOutput: HandleDigitalPinEvent(evt); break; case PortType.AnalogInputOnDemand: case PortType.AnalogInputSampling: HandleAnalogPinEvent(evt); break; case PortType.I2CPort: HandleI2CEvent(evt); break; case PortType.SPIPort: HandleSPIEvent(evt); break; default: throw new WirekiteException(String.Format("Port event received for invalid for type {0} of port ID {1}", type, evt.PortId)); } }