public void Count() { while (ShouldCount) { long beginTime = DateTime.Now.Ticks; try { CurrentTime.Timer(); TimeLabel.Invoke(new Action(() => TimeLabel.Text = CurrentTime.ToString())); Distance += (Speed / 3600); DistanceLabel.Invoke(new Action(() => DistanceLabel.Text = $"{Distance:f2}")); RPM = Speed * 2.8; RpmLabel.Invoke(new Action(() => RpmLabel.Text = RPM.ToString())); Pulse = 90 + (int)((Power / 6) * (Speed / 10)); PulseLabel.Invoke(new Action(() => PulseLabel.Text = Pulse.ToString())); SpeedTrackbar.Invoke(new Action(() => SpeedTrackbar.Value = (int)Speed)); SpeedLabel.Invoke(new Action(() => SpeedLabel.Text = Speed.ToString())); PowerTrackbar.Invoke(new Action(() => PowerTrackbar.Value = (int)Power)); PowerLabel.Invoke(new Action(() => PowerLabel.Text = Power.ToString())); } catch (Exception e) { } Wait1s(beginTime); } }
public void Count() { while (ShouldCount) { try { CurrentTime.Timer(); TimeLabel.Invoke(new Action(() => TimeLabel.Text = CurrentTime.ToString())); Distance += (Speed / 3600); DistanceLabel.Invoke(new Action(() => DistanceLabel.Text = $"{Distance:f2}")); RPM = Speed * 2.8; RpmLabel.Invoke(new Action(() => RpmLabel.Text = RPM.ToString())); Pulse = 90 + (int)((Power / 6) * (Speed / 20)); PulseLabel.Invoke(new Action(() => PulseLabel.Text = Pulse.ToString())); SpeedTrackbar.Invoke(new Action(() => SpeedTrackbar.Value = (int)Speed)); SpeedLabel.Invoke(new Action(() => SpeedLabel.Text = Speed.ToString())); PowerTrackbar.Invoke(new Action(() => PowerTrackbar.Value = (int)Power)); PowerLabel.Invoke(new Action(() => PowerLabel.Text = Power.ToString())); } catch (Exception e) { } Thread.Sleep(1000); } }
async Task MainAsync(ILogger logger, CancellationToken cancellationToken) { _hubConnection = new HubConnectionBuilder() .WithUrl(_HubUri + _HubPath) .Build(); try { await _hubConnection.StartAsync(cancellationToken); } catch { WriteLine("Can not start connection to hub."); return; } // start logger.LogInformation("Start Thread"); // Initialize a new Random Number Generator: var rnd = new Random(); var value = 0.0; var pulse = new Pulse(); while (true) { if (cancellationToken.IsCancellationRequested) { logger.LogInformation("IsCancellationRequested"); await _hubConnection.DisposeAsync(); return; } await Task.Delay(250); // Generate the value to Broadcast to Clients: value = Math.Min(Math.Max(value + (0.1 - rnd.NextDouble() / 5.0), -1), 1); // Set the Measurement with a Timestamp assigned: pulse.Timestamp = DateTime.UtcNow; pulse.Value = value; // report logger.LogInformation(pulse.ToString()); // Finally send the value: await _hubConnection.SendAsync("Broadcast", "Sensor", pulse, cancellationToken); } }
public override string ToString() { StringBuilder sb = new StringBuilder("HBMessageData("); sb.Append("Path: "); sb.Append(Path); sb.Append(",Pulse: "); sb.Append(Pulse == null ? "<null>" : Pulse.ToString()); sb.Append(",Boolval: "); sb.Append(Boolval); sb.Append(",Records: "); sb.Append(Records == null ? "<null>" : Records.ToString()); sb.Append(",Nodes: "); sb.Append(Nodes == null ? "<null>" : Nodes.ToString()); sb.Append(",Message_blob: "); sb.Append(Message_blob); sb.Append(")"); return(sb.ToString()); }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "" || textBox2.Text != "" || textBox3.Text != "" || textBox4.Text != "" || textBox5.Text != "" || textBox6.Text != "" || textBox7.Text != "" || textBox8.Text != "" || textBox9.Text != "") { try { TimeSpan t = new TimeSpan(); Random rd = new Random(); DateTime dt1 = Convert.ToDateTime(dtStart.Value.ToString("yyyy/MM/dd HH:mm")); DateTime dt2 = Convert.ToDateTime(dtEnd.Value.ToString("yyyy/MM/dd HH:mm")); int JGs = Convert.ToInt32(jiange); t = dt2 - dt1; string NIBPS; //收缩压 string NIBPD; //舒张压 string RRC; //呼吸 //int HR;//心率 string Pulse; //脉搏 string SpO2; //血氧 string ETCO2; //呼吸二氧化碳 string TEMP; //温度 string BIS; //bis string cvp; int X = (t.Days * 24 * 60 + t.Hours * 60 + t.Minutes) / JGs; for (int i = 0; i <= X; i++) { NIBPS = textBox1.Text; NIBPD = textBox2.Text; RRC = textBox3.Text; //HR = new Random().Next(31, 35); Pulse = textBox4.Text; SpO2 = textBox5.Text; ETCO2 = textBox6.Text; TEMP = textBox7.Text; BIS = textBox8.Text; cvp = textBox9.Text; if (bll.GetPointSingle(Mzjldid, dt1).Rows.Count == 0) { int result = bll.AddPoint(Mzjldid, dt1, NIBPS.ToString(), NIBPD.ToString(), RRC.ToString(), Pulse.ToString(), SpO2.ToString(), ETCO2.ToString(), BIS.ToString(), TEMP.ToString(), cvp); } //else // MessageBox.Show("该时间点数据已存在,不能重复添加"); dt1 = dt1.AddMinutes(JGs); } MessageBox.Show("设置完成"); this.Close(); } catch (Exception ex) { MessageBox.Show("设置失败!请重试!"); } } else { MessageBox.Show("如果没有数据请填写0"); } }