/// <summary> /// Initializes the SpiroController, cancels existing spirometer connection (if any) and connects to a device of the specified device type. /// </summary> private void Init() { //Debug.Log("Init device manager"); InitMinMax(); if (spiroController != null) //Disconnect with current device before establishing new connection { //Debug.Log("return want spiro is niet null"); spiroController.DisconnectDevice(); Invoke("Init", 0.5f); //Call init again after 0.5 seconds (delay to make sure device has time to disconnect) return; } //Debug.Log("Ik ga langs de if statements"); if (deviceType == DeviceType.AIRNEXT) { //Debug.Log("Ik ben een airnext"); spiroController = new BLESpiroController(); } if (deviceType == DeviceType.CONTROLLER) { //Debug.Log("Ik ben een controller"); spiroController = new SimulatedSpiroController(); } if (deviceType == DeviceType.KUEFFNER) { //Debug.Log("Ik ben een spiro"); spiroController = new USBSpiroController(); } ConnectSpirometer(); }
public void DisconnectSpirometer() { if (spiroController != null) { spiroController.DisconnectDevice(); spiroController = null; } }
void SpiroControllerNull() { spiroController = null; }