下面是我做的移动平均线。我对压力读数没有任何问题。对于流量读数,我对高读数有疑问。例如,我预计 34 升/分钟,但我的程序只读取 32 到 33 升/分钟。
谢谢你。
// get values to test
wrapper.GetDeviceSensorValue(pressure, ref this.vitalPressure);
wrapper.GetDeviceSensorValue(flow, ref this.vitalFlow);
{
int i;
float value1 = 0;
float value2 = 0;
int numReadings =3000000;
float vital1;
float vital2;
for (i = 0; i < numReadings; i++)
{
wrapper.GetDeviceSensorValue(pressure, ref this.vitalPressure);
value1 = value1 + this.vitalPressure;
}
vital1 = value1 / numReadings;
this.textBox1.Text = vital1.ToString("0.##");
System.Threading.Thread.Sleep(1);
for (i = 0; i < numReadings; i++)
{
wrapper.GetDeviceSensorValue(flow, ref this.vitalFlow);
value2 = value2 + this.vitalFlow;
}
vital2 = value2 / numReadings;
this.textBox2.Text = vital2.ToString("0.##");
System.Threading.Thread.Sleep(1);
}