/// <summary> /// Initialization of the pipeline used for realtime movement recognition based on the settings /// </summary> public void Init() { //Initializing the parameters that will not change between executions for all stages _acquisitionController = new AcquisitionController(); _windowMaker = new WindowMaker(); _featureExtractor = new FeatureExtractor(); _patternRecognition = new PatternRecognition(); _movementGenerator = new MovementGenerator(); _thresholdEngine = new ThresholdEngine(); _acquisitionController.isOnline = true; _acquisitionController.isMonitored = true; _windowMaker.isOnline = true; _featureExtractor.isOnline = true; _featureExtractor.isMonitored = false; _movementGenerator.nMovements = nMovements; _movementGenerator.numSingleMovements = numSingleMovements; _movementGenerator.allowedComplexMovements = allowedComplexMovements; _movementGenerator.objectServer = _objectServer; _movementGenerator.movementMetadata = movementMetadata; _thresholdEngine.enabled = true; _thresholdEngine.isOnline = true; }
public override void Run() { ThreadStart runMethod; Thread myThread; runMethod = new ThreadStart(GetRecordingStatusChange); myThread = new Thread(runMethod); _recordingConfig = new RecordingConfig(); _recordingConfig.schedule.Add(new ScheduleItem(7,new ushort[] { 1, 3 })); _recordingConfig.schedule.Add(new ScheduleItem (0, new ushort[] { 0 })); _recordingConfig.schedule.Add(new ScheduleItem (9,new ushort[] { 1, 4 })); _recordingConfig.schedule.Add(new ScheduleItem (0,new ushort[] { 0 })); _recordingConfig.schedule.Add(new ScheduleItem (8,new ushort[] { 2, 3 })); _recordingConfig.schedule.Add(new ScheduleItem (0, new ushort[] { 0 })); _recordingConfig.schedule.Add(new ScheduleItem (10, new ushort[] { 2, 4 })); _recordingController = new AcquisitionController(_pipeline); _recordingController.dataProvider = _myDataProvider; _myDataProvider.recordingConfig = _recordingConfig; _recordingController.recordingConfig = _recordingConfig; _recordingController.StatusChanged += new EventHandler(RecordingStatusChange); _pipeline.StopPendingChanged += new EventHandler(StopPendingChange); _myDataProvider.StatusChanged += new EventHandler(DataProviderStatusChange); _pipeline.AddStage(_recordingController); _pipeline.AddStage(_outputDisplayer); _pipeline.Init(); //Ather the pipeline (and consequently the stages) are initialised, we can already create the //thread that will read the status change queue of the RecordingController object HERE myThread.Start(); _pipeline.Start(); while (_recordingController.currentScheduleItem != -1) { //Wait for the RecordingController to finish the job } //The thread running GetRecordingStatusChange() is ready to finish or has already finished. We do things right //by waiting for it here. myThread.Join(); if (_pipeline.stopPending) { Console.Out.WriteLine("Stopping pipeline on Run method..."); _pipeline.Stop(); Console.Out.WriteLine("Pipeline stopped!"); } Console.WriteLine("\n\nRecordingController execution finished. Press <ENTER> to view the captured data."); Console.ReadLine(); //printing results for (Int32 i = 0; i < _outputDisplayer.output.Count; i++) { Console.Out.WriteLine(_outputDisplayer.output.ElementAt(i)); } _recordingController.StatusChanged -= new EventHandler(RecordingStatusChange); _pipeline.StopPendingChanged -= new EventHandler(StopPendingChange); _myDataProvider.StatusChanged -= new EventHandler(DataProviderStatusChange); }
//Initialisation operations such as reading configuration and setting up of resources public void Init() { _recordingController = new AcquisitionController(_acqPipeline); _recordingController.numSingleMovements = numSingleMovements; _recordingController.allowedComplexMovements = allowedComplexMovements; _recordingStage = new Recorder(recordedData); _recordingStage.PropertyChanged += _recordingStage_PropertyChanged; _thresholdEngine = new ThresholdEngine(); _thresholdEngine.recordingConfig = recordingConfig; _thresholdEngine.windowLength = 200; //We build and initialise the pipeline _acqPipeline.AddStage(_recordingController); _acqPipeline.AddStage(_thresholdEngine); _acqPipeline.AddStage(_recordingStage); }