Skip to content

Commit

Permalink
#3 add stopwatch for sampling data
Browse files Browse the repository at this point in the history
  • Loading branch information
jaehun-han committed May 9, 2019
1 parent da7056b commit 825f53c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions DustSensorViewer/Form1.cs
Expand Up @@ -159,8 +159,32 @@ private void button_con_Click(object sender, EventArgs e)
"{0}\tPM 10\t{1} µg/m3\tPM 2.5\t{2} µg/m3\tPM 1.0\t{3} µg/m3\tSensor: {4}"};


private static System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();

private void update(string sensor_name, double pm10, double pm25)
{
if (checkBox_sampling.Checked)
{
if (stopwatch.IsRunning)
{
if((stopwatch.ElapsedMilliseconds / 1000) < (numericUpDown2.Value * 60))
{
return;
}

stopwatch.Reset();
}
else
{
stopwatch.Start();
}
}
else
{
stopwatch.Reset();
stopwatch.Stop();
}

string s_log = String.Format(LOG_LINE[0], DateTime.Now.ToString(TIME_FORMAT[0]), pm10.ToString("0.0"), pm25.ToString("0.0"));
string s_text = String.Format(TEXT_LINE[0], DateTime.Now.ToString(TIME_FORMAT[1]), pm10.ToString("0.0"), pm25.ToString("0.0"), sensor_name);

Expand All @@ -171,6 +195,28 @@ private void update(string sensor_name, double pm10, double pm25)

private void update(string sensor_name, int pm10, int pm25, int pm1)
{
if (checkBox_sampling.Checked)
{
if (stopwatch.IsRunning)
{
if ((stopwatch.ElapsedMilliseconds / 1000) < (numericUpDown2.Value * 60))
{
return;
}

stopwatch.Reset();
}
else
{
stopwatch.Start();
}
}
else
{
stopwatch.Reset();
stopwatch.Stop();
}

string s_log = String.Format(LOG_LINE[1], DateTime.Now.ToString(TIME_FORMAT[0]), pm10, pm25, pm1);
string s_text = String.Format(TEXT_LINE[1], DateTime.Now.ToString(TIME_FORMAT[1]), pm10, pm25, pm1, sensor_name);

Expand Down
Binary file modified DustSensorViewer/bin/Debug/DustSensorViewer.exe
Binary file not shown.

0 comments on commit 825f53c

Please sign in to comment.