Example #1
0
 /// <summary>
 /// Connection status handler
 /// </summary>
 private void OnHatConnectionStatusUpdate(object sender, BrainHatStatusEventArgs e)
 {
     if (e.Status.HostName == ConnectedServer.HostName)
     {
         LatestOffsetTime = e.Status.OffsetTime;
         LatestRawLatency = e.Status.RawLatency;
     }
 }
Example #2
0
        private void OnHatStatusUpdate(object sender, BrainHatStatusEventArgs e)
        {
            //  TODO
            //if (IsConnected && e.Status.HostName == ConnectedServer.HostName)
            //{
            //    string statusString = $"host: {e.Status.HostName}\n";
            //    statusString += $"eth0:  {e.Eth0Description}\n";
            //    statusString += $"wlan0: {e.Wlan0Description}\n";
            //    statusString += $"ping speed: {e.Status.PingSpeed.TotalMilliseconds.ToString("N3")} ms.";
            //    ConnectionStatusLastUpdateTime = DateTimeOffset.UtcNow;

            //    labelConnectionStatus.Invoke(new Action(() => { labelConnectionStatus.Text = statusString; }));
            //}
        }
Example #3
0
 private async void OnHatStatusUpdate(object sender, BrainHatStatusEventArgs e)
 {
     if (ConnectToServer && !IsConnected)
     {
         if (!IsConnected && e.Status.HostName == HostName)
         {
             if (StartMonitorForServer(e.Status))
             {
                 buttonStart.Invoke(new Action(() => buttonStart.Enabled = true));
                 labelConnectionStatus.Invoke(new Action(() => labelConnectionStatus.Text = $"Connected to {HostName}."));
                 await StartLightSequence();
             }
         }
     }
 }
Example #4
0
        /// <summary>
        /// Board status update handler
        /// </summary>
        private void OnStatusUpdate(object sender, BrainHatStatusEventArgs e)
        {
            try
            {
                if (BroadcastStatus != null && BrainflowBoard != null)
                {
                    if (BrainflowBoard != null)
                    {
                        e.Status.SampleRate  = BrainflowBoard.SampleRate;
                        e.Status.BoardId     = BrainflowBoard.BoardId;
                        e.Status.IsStreaming = BrainflowBoard.IsStreaming;
                        e.Status.CytonSRB1   = BrainflowBoard.CytonSRB1;
                        e.Status.DaisySRB1   = BrainflowBoard.DaisySRB1;
                    }
                    if (FileWriter.IsLogging)
                    {
                        e.Status.RecordingDataBrainHat     = FileWriter.IsLogging;
                        e.Status.RecordingFileNameBrainHat = Path.GetFileName(FileWriter.FileName);
                        e.Status.RecordingDurationBrainHat = FileWriter.FileDuration;
                    }
                    else
                    {
                        e.Status.RecordingDataBrainHat     = false;
                        e.Status.RecordingFileNameBrainHat = "";
                        e.Status.RecordingDurationBrainHat = 0.0;
                    }

                    UpdateStatusUi(e.Status);

                    BroadcastStatus.QueueStringToBroadcast(JsonConvert.SerializeObject(e.Status));
                }
            }
            catch (Exception ex)
            {
                Logger.AddLog(new LogEventArgs(this, "OnStatusUpdate", ex, LogLevel.ERROR));
            }
        }