private void MotionCapture_TrackableListAvaliableEvent(List <Trackable> trackableList, long timeStamp) { tempTrackableList = new List <Trackable>(trackableList); tempTrackableListTimeStamp = timeStamp; foreach (Trackable trackable in tempTrackableList) { trackable.TimeStamp = timeStamp; if (trackable.Name == null) // Prevents binarywriter in Transmit trying to write a null name { trackable.Name = "Unknown"; } Transmit(trackable); } Trackable endOfFrameTrackable = new Trackable(); endOfFrameTrackable.TimeStamp = trackableList.Count; endOfFrameTrackable.ID = -2147483648; endOfFrameTrackable.Name = "End"; Transmit(endOfFrameTrackable); //Filter Markers - if they are from the same camera update FilteredMarkers if (tempTrackableListTimeStamp == tempMarkerListTimeStamp && processFilteredMarkers) { FilteredMarkerProcessor.UpdatedFilteredMarkers(tempMarkerList, tempTrackableList); } //Update Joints JointProcessor.UpdateJoints(tempTrackableList); }
/// <summary> /// Converts byte to command and then executes command /// </summary> /// <param name="receivedCommand"></param> public void handleCommand(byte[] receivedCommand) { lock (this) // Lock the code { int command = (int)receivedCommand[2]; switch (command) { // 0 is Start Cameras case 0: MotionCaptureStart(); break; // 1 is Stop Cameras case 1: MotionCaptureStop(); break; // 2 is Send Camera Coordinates case 2: if (MotionCaptureController.APIRunning) { MotionCaptureController.UpdateCameraList(); OptitrackCameraList.TransmitListOfCameras(); } break; // 3 is Start Treadmill At Fixed Speed case 3: { TreadmillController.SetSpeed((float)BitConverter.ToDouble(receivedCommand, 4)); break; } // 4 is Stop Treadmill case 4: { TreadmillController.SetSpeed(0.0f); break; } case 6: { if (VirtualMotionCaputrePlayback) { VirtualMotionCaptureController.UpdateCoordinates(); } else { MotionCaptureController.UpdateCoordinates(true, true); } break; } // 7 is Calibrate ground plane. case 7: { //TODO: Reinstate or remove this? //MotionCapture.Calibrate(); break; } //8 is toggle displaying feet case 8: { if (ToggleFeetCommandReceivedEvent != null) { ToggleFeetCommandReceivedEvent(BitConverter.ToBoolean(receivedCommand, 4)); } break; } case 9: // Shuts down the drivers so the application can close { FinalShutdown(); break; } case 10: // Clears the CoR data - This should be called at the start of each session { JointProcessor.ResetCoRCalculations(); break; } case 11: // Requests an update for the current speed { TreadmillController.TransmitSpeed(); break; } default: { System.Diagnostics.Debug.WriteLine("Invalid command received: " + command.ToString()); break; } } } }