コード例 #1
0
    /*
     * 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));
        }
    }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
    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();
    }
コード例 #4
0
    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();
        }
    }