Example #1
0
 private void ProcessCommand(string command)
 {
     if (command.Length < 2)
     {
         return;
     }
     if (command.Substring(0, 2) == "ST")
     {
         replyBoxText.Clear();
         ErgometerData ergometerData = ergometer.GetData();
         replyBoxText.Text = ergometerData.ToString();
     }
     else if (command.Substring(0, 2) == "PW")
     {
         ergometer.SetPower(Convert.ToInt32(command.Substring(2)));
     }
     else if (command.Substring(0, 2) == "PD")
     {
         ergometer.SetDistance(Convert.ToInt32(command.Substring(2)));
     }
     else if (command.Substring(0, 2) == "PT")
     {
         ergometer.SetTime(Convert.ToInt32(command.Substring(2)));
     }
     else if (command.Substring(0, 2) == "CM")
     {
         ergometer.ErgometerCommandMode();
     }
     else if (command.Substring(0, 2) == "RS")
     {
         ergometer.Reset();
     }
 }
Example #2
0
 private void Data_Collector_Click(object sender, EventArgs e)
 {
     if (ergometer.IsConnected())
     {
         replyBoxText.Clear();
         ErgometerData ergometerData = ergometer.GetData();
         if (ergometerData != null)
         {
             replyBoxText.Text = ergometerData.ToString();
         }
     }
 }
Example #3
0
 public void GetData()
 {
     while (sessionID == null)
     {
         Thread.Sleep(100);
     }
     while (isConnected)
     {
         measurement++;
         if (simulation == null && ergometerCOM != null)
         {
             System.Diagnostics.Debug.WriteLine(isConnected);
             Healthcare_test.ErgometerData ergometerData = ergometerCOM.GetData();
             //vrc.UpdateBikePanelInVR(ergometerData);
             dynamic ergometerdata = new
             {
                 id      = "data",
                 session = sessionID,
                 data    = new
                 {
                     power    = ergometerData.Actual_Power,
                     speed    = ergometerData.Speed,
                     time     = ergometerData.Time,
                     RPM      = ergometerData.RPM,
                     distance = ergometerData.Distance,
                     pulse    = ergometerData.Pulse
                 }
             };
             if (measurement >= 10)
             {
                 Send(JsonConvert.SerializeObject(ergometerdata));
                 measurement = 0;
             }
         }
         else if (simulation != null)
         {
             System.Diagnostics.Debug.WriteLine(isConnected);
             Healthcare_test.ErgometerData ergometerData2 = simulation.GetData();
             //vrc.UpdateBikePanelInVR(ergometerData2);
             dynamic ergometerdata2 = new
             {
                 id      = "data",
                 session = sessionID,
                 data    = new
                 {
                     power    = ergometerData2.Actual_Power,
                     speed    = ergometerData2.Speed,
                     time     = ergometerData2.Time,
                     RPM      = ergometerData2.RPM,
                     distance = ergometerData2.Distance,
                     pulse    = ergometerData2.Pulse
                 }
             };
             if (measurement >= 10)
             {
                 Send(JsonConvert.SerializeObject(ergometerdata2));
                 measurement = 0;
             }
         }
         Thread.Sleep(100);
     }
 }