Ejemplo n.º 1
0
        public void AddTrainingData()
        {
            var predictor    = new AggregateKNNCorrelationPredictor(2, 3, 0.1, new EEGDataType[] { EEGDataType.ALPHA_ABSOLUTE });
            var trainingData = new EEGEvent[][] {
                new EEGEvent[] { new EEGEvent(DateTime.UtcNow, EEGDataType.ALPHA_ABSOLUTE, new double[] { 1, 1 }) },
            };

            predictor.AddTrainingData(1, trainingData[0]);
        }
Ejemplo n.º 2
0
        public void CTDRaceCondition()
        {
            var ctdPredictor = new RaceCondTestPredictor(2, 3, 0.1, new EEGDataType[] { EEGDataType.ALPHA_ABSOLUTE });
            var trainingData = new EEGEvent[][] {
                new EEGEvent[] { new EEGEvent(DateTime.UtcNow, EEGDataType.ALPHA_ABSOLUTE, new double[] { 1, 1 }) }
            };

            for (int i = 0; i < 5; i++)
            {
                ctdPredictor.AddTrainingData(1, trainingData[0]);
            }

            Exception lastException = null;

            ThreadStart t1Method = delegate {
                try {
                    var p = ctdPredictor.Predict(trainingData[0]);
                    Assert.AreEqual(Predictor.NO_PREDICTION, p, "Should return a null prediction on case of clear during prediction");
                } catch (Exception e) {
                    lastException = e;
                }
            };

            ThreadStart t2Method = delegate {
                try {
                    while (!ctdPredictor.isPredicting)
                    {
                    }
                    ctdPredictor.ClearTrainingData();
                    ctdPredictor.canceled = true;
                } catch (Exception e) {
                    lastException = e;
                }
            };

            var t1 = new Thread(t1Method);
            var t2 = new Thread(t2Method);

            t1.Start();
            t2.Start();

            t1.Join();
            t2.Join();

            if (lastException != null)
            {
                throw lastException;
            }
        }
Ejemplo n.º 3
0
 void HandleConnStatus(EEGEvent evt)
 {
     messageReceived = true;
     connectStatus   = evt.data;
 }