Ejemplo n.º 1
0
        public void BlinkDetectorRisingAndFalling()
        {
            LeftCount  = 0;
            RightCount = 0;

            BlinkDetector detector = new BlinkDetector();

            detector.DetectedBlink += Detector_DetectedBlink;

            BFSampleImplementation data = new BFSampleImplementation(0)
            {
                TimeStamp = 1.00100,
            };

            //  this looks like rising edge
            detector.DetectBlinks(data, 31.0, 10.0, 31.0, 10.0);

            //  no blinks on rising edge alone
            Assert.AreEqual(0, LeftCount);
            Assert.AreEqual(0, RightCount);

            data = new BFSampleImplementation(0)
            {
                TimeStamp = 1.25,
            };

            // this looks like falling edge
            detector.DetectBlinks(data, 11.0, 10.0, 11.0, 10.0);

            //  should be one blink
            Assert.AreEqual(1, LeftCount);
            Assert.AreEqual(1, RightCount);
        }
Ejemplo n.º 2
0
        public async Task BlinkWink10_DetectFirstFiveBlinks()
        {
            CountLeft  = 0;
            CountRight = 0;

            //  create a processor
            BrainflowDataProcessor processor = new BrainflowDataProcessor("", 0, 250);
            BlinkDetector          detector  = new BlinkDetector();

            detector.GetData          = processor.GetRawChunk;
            detector.GetStdDevMedians = processor.GetStdDevianMedians;
            processor.NewSample      += detector.OnNewSample;
            detector.Log           += Detector_Log;
            detector.DetectedBlink += Processor_DetectedBlink;


            //  read this test file
            using (var reader = new StreamReader("./TestFiles/blinkWink10_082530.csv"))
                using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
                {
                    csv.Configuration.HasHeaderRecord = false;
                    var data = csv.GetRecords <BFSampleImplementation>().ToList();

                    await processor.StartDataProcessorAsync();

                    //  get data up to the first end of the first blink sequence, 15 seconds into the data file
                    TestTimeStart = data.First().TimeStamp;
                    foreach (var nextReading in data)
                    {
                        if (nextReading.TimeStamp - TestTimeStart < 5)
                        {
                            continue;
                        }

                        processor.AddDataToProcessor(nextReading);

                        await Task.Delay(1);

                        if (nextReading.TimeStamp - TestTimeStart > 15)
                        {
                            break;
                        }
                    }
                }

            await processor.StopDataProcessorAsync();


            //  should have been five full blinks
            Assert.AreEqual(5, CountLeft);
            Assert.AreEqual(5, CountRight);
        }
Ejemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();

            FormClosing += OnFormClosing;
            PlatformHelper.PlatformHelper.GetLibraryEnvironment();

            HostName = GpioPinManager.LoadFromConfigFile();
            GpioPinManager.SetupGpio();

            textBoxHostName.Text = HostName;
            ConnectToServer      = false;
            ActiveClient         = null;

            EnableMotor  = true;
            EnableLights = true;

            checkBoxHapticMotor.Checked = true;
            checkBoxLightsAuto.Checked  = true;



            ServersMonitor      = new HatServersMonitor();
            ServersMonitor.Log += OnLog;
            ServersMonitor.HatConnectionStatusUpdate += OnHatStatusUpdate;
            ServersMonitor.HatConnectionChanged      += OnHatConnectionChanged;

            BlinkDetector = new BlinkDetector();
            BlinkDetector.DetectedBlink += OnDetectedBlink;

            SeekingAlpha = new AlphaWaveDetector();
            SeekingAlpha.DetectedBrainWave += OnDetectedBrainWave;


            _ = Task.Run(async() =>
            {
                //await GpioPinManager.TestConfig();

                await ServersMonitor.StartMonitorAsync();
                await SeekingAlpha.StartDetectorAsync();

                await StartLightFlash();
            });
        }
Ejemplo n.º 4
0
        private static void Game_OnStart(EventArgs args)
        {
            Menu = MainMenu.AddMenu("Brain.exe", "braindotexe");
            Menu.AddSeparator();
            Menu.AddLabel("By KK2 & MrArticuno");

            DrawMenu = Menu.AddSubMenu("Draw", "brainDraw");
            DrawMenu.Add("drawDisable", new CheckBox("Turn off all drawings", false));
            DrawMenu.Add("streamMode", new CheckBox("Stream Mode", false));

            JungleTimers.Init();
            Cooldown.Init();
            CloneRevelaer.Init();
            Pink.Init();
            TowerUtil.Init();
            SmiteME.Init();
            BlinkDetector.Init();
            WardTracker.Init();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Form1(HatClient server)
        {
            InitializeComponent();

            //  reference to the server we are connecting to
            ConnectedServer = server;

            //  create the data processor
            DataProcessor           = new BrainflowDataProcessor(server.HostName, server.BoardId, server.SampleRate);
            DataProcessor.Log      += OnLog;
            server.RawDataReceived += DataProcessor.AddDataToProcessor;

            //  create the blink detector
            BlinkDetector                  = new BlinkDetector();
            BlinkDetector.Log             += OnLog;
            DataProcessor.NewSample       += BlinkDetector.OnNewSample;
            BlinkDetector.GetData          = DataProcessor.GetRawChunk;
            BlinkDetector.GetStdDevMedians = DataProcessor.GetStdDevianMedians;

            //  create the alpha wave detector
            AlphaDetector = new AlphaWaveDetector();
            AlphaDetector.GetBandPower       = DataProcessor.GetBandPower;
            AlphaDetector.Log               += OnLog;
            AlphaDetector.DetectedBrainWave += OnAlphaDetectorDetectedBrainWave;

            //  create a file writer to record raw data
            FileWriter = new BrainHatFileWriter();

            //  init the blink counter
            BlinkLeftCount  = 0;
            BlinkRightCount = 0;

            checkBoxMuteBeeper.Checked = false;
            checkBoxMuteBeeper.Visible = false;

            //  init UI begin state
            SetupFormUi();

            //  start processes
            Start();
        }