Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/issue-003'
Browse files Browse the repository at this point in the history
  • Loading branch information
MalcolmHannah committed May 10, 2017
2 parents 825450b + 6ce4fdf commit 6102a60
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions SingleTact Demo/GUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,22 @@ public void AddData(double time, double[] measurements)
graph_.AxisChange();
}

/// <summary>
/// Finds a character to separate exported values.
/// </summary>
/// <returns>A semi-colon for locales where comma is the decimal
/// separator; otherwise a comma.</returns>
private string safeSeparator()
{
double testValue = 3.14;
string testText = testValue.ToString();

if (testText.IndexOf(',') < 0)
return ",";

return ";";
}

//Save data to CSV
private void buttonSave_Click(object sender, EventArgs e)
{
Expand All @@ -257,16 +273,19 @@ private void buttonSave_Click(object sender, EventArgs e)

if (saveDataDialog.ShowDialog() == DialogResult.OK)
{
// To fix Issue 3, separate exported values by semi-colon instead
// of comma if current locale's decimal separator is comma.
string separator = safeSeparator();
string saveFileName = saveDataDialog.FileName;
StreamWriter dataWriter = new StreamWriter(saveFileName, false, Encoding.Default);

//Write a header
dataWriter.WriteLine("Time (s)" + "," + "Value (0 = 0 PSI 511 = Full Scale Range)");
dataWriter.WriteLine("Time (s)" + separator + "Value (0 = 0 PSI 511 = Full Scale Range)");

//Just export first trace (we only support 1 sensor)
for (int i = 0; i < dataBuffer_.data[0].Count; i++)
{
dataWriter.WriteLine(dataBuffer_.data[0][i].X + "," + dataBuffer_.data[0][i].Y);
dataWriter.WriteLine(dataBuffer_.data[0][i].X + separator + dataBuffer_.data[0][i].Y);
}

dataWriter.Close();
Expand Down

0 comments on commit 6102a60

Please sign in to comment.