/* * INPUT: None * OUTPUT: None * * SUMMARY: Checks for correct operational state, then attempts * to detach from COM port * * ATTACH SUCCEED: update operational state, stop scanning for devices * ATTACH FAIL: state unchanged, prints error message to debug log * * RETURNS: NONE */ public void detachPort() { StringBuilder returnBuffer = new StringBuilder(EnfluxVRSuit.MESSAGESIZE); if (operatingState == ConnectionState.ATTACHED || operatingState == ConnectionState.DISCONNECTED || operatingState == ConnectionState.CONNECTED) { if (EnfluxVRSuit.detachPort(returnBuffer) < 1) { operatingState = ConnectionState.DETACHED; Debug.Log(returnBuffer); scanUpdater.StopScanning(); } else { Debug.Log(returnBuffer); } } else { Debug.Log("Unable to detach from port, program is in wrong state " + Enum.GetName(typeof(ConnectionState), operatingState)); } }
public void detachPort() { if (operatingState == ConnectionState.ATTACHED || operatingState == ConnectionState.DISCONNECTED) { if (EnfluxVRSuit.detachPort() < 1) { operatingState = ConnectionState.DETACHED; scanUpdater.StopScanning(); } else { Debug.Log("Error occured while detaching"); } } else { Debug.Log("Unable to detach from port, program is in wrong state " + Enum.GetName(typeof(ConnectionState), operatingState)); } }
void OnApplicationQuit() { //Just in case some steps were skipped Debug.Log("Making sure things are closed down"); // Make sure sensors are disconnected, port is detached, // and client connection closed if (operatingState != ConnectionState.NONE || operatingState != ConnectionState.DETACHED || operatingState != ConnectionState.DISCONNECTED) { if (operatingState == ConnectionState.STREAMING) { disableAnimate(); } disconnectEnflux(); } if (operatingState != ConnectionState.NONE && operatingState != ConnectionState.DETACHED) { StringBuilder returnBuffer = new StringBuilder(EnfluxVRSuit.MESSAGESIZE); EnfluxVRSuit.detachPort(returnBuffer); } if (client != null) { client.Close(); } if (serverState != ServerState.CLOSED) { #if !NO_APPLICATION serverProcess.Kill(); #endif } EnfluxVRSuit.unregisterResponseCallbacks(); }
void OnApplicationQuit() { //Just in case some steps were skipped Debug.Log("Making sure things are closed down"); /** * Skips state check to be certain that port and background thread is * shutdown * */ if (operatingState != ConnectionState.NONE && operatingState != ConnectionState.DETACHED) { EnfluxVRSuit.detachPort(); } if (serverState != ServerState.CLOSED) { //todo: message from server confirming client disconnect //client.Close(); //todo: make this actually kill the process //currently just returns and error serverProcess.Kill(); } }