public void Dispose() { // Close the socket (if open) if (isenseSocket != null) { isenseSocket.Dispose(); isenseSocket = null; } // Close the serial port (if open) if (isenseHandle != IntPtr.Zero) { ISDllBridge.ISD_CloseTracker(isenseHandle); isenseHandle = IntPtr.Zero; } }
private bool InitSocket() { if (connInfo == null) { return(false); } if (isenseSocket == null) { isenseSocket = new InterSenseSocket(); } Debug.Assert(!isenseSocket.IsConnected()); return(isenseSocket.Connect(connInfo.host, connInfo.port)); }
public void Update(TimeSpan elapsedTime, bool deviceActive) { if (!IsAvailable) { return; } ISDllBridge.ISD_TRACKER_DATA_TYPE dataISense; bool bSuccess = false; // Try the socket if (isenseSocket != null) { if (!isenseSocket.IsConnected()) { return; } // Pass the station array so that we know that stations to // request data for in the network message bSuccess = isenseSocket.GetData(stationArray, out dataISense); if (bSuccess) { stationArray.SetData(dataISense); return; } else { // If that fails, try connecting directly using the serial port driver InitDriver(); isenseSocket = null; } } // Try getting the data via serial port if (!bSuccess && isenseHandle != IntPtr.Zero) { bSuccess = ISDllBridge.ISD_GetData(isenseHandle, out dataISense); if (bSuccess) { stationArray.SetData(dataISense); } } }