opslaan en ophalen

het ophalen werkt en is met een file opener.
het opslaan is met een timer op het moment.
er zit een file bij die data van het opslaan bevat.
This commit is contained in:
sandriek
2015-09-17 15:14:14 +02:00
parent 17f72ca63a
commit 8e6e091390
32 changed files with 61405 additions and 13 deletions
@@ -45,6 +45,9 @@ namespace ErgometerApplication
this.distanceButton = new System.Windows.Forms.Button();
this.saveTimer = new System.Windows.Forms.Timer(this.components);
this.writeTimer = new System.Windows.Forms.Timer(this.components);
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// richTextBox1
@@ -170,11 +173,46 @@ namespace ErgometerApplication
this.distanceButton.UseVisualStyleBackColor = true;
this.distanceButton.Click += new System.EventHandler(this.distanceButton_Click);
//
// button3
//
this.button3.Enabled = false;
this.button3.Location = new System.Drawing.Point(224, 268);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(110, 27);
this.button3.TabIndex = 16;
this.button3.Text = "next";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button2
//
this.button2.Enabled = false;
this.button2.Location = new System.Drawing.Point(223, 233);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(113, 29);
this.button2.TabIndex = 15;
this.button2.Text = "back";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(221, 198);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(113, 29);
this.button1.TabIndex = 17;
this.button1.Text = "Read File";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Ergometer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(351, 328);
this.Controls.Add(this.button1);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.distanceButton);
this.Controls.Add(this.energyButton);
this.Controls.Add(this.timeButton);
@@ -211,5 +249,8 @@ namespace ErgometerApplication
private System.Windows.Forms.Button distanceButton;
private System.Windows.Forms.Timer saveTimer;
private System.Windows.Forms.Timer writeTimer;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
}
}
@@ -15,8 +15,10 @@ namespace ErgometerApplication
public partial class Ergometer : Form
{
private ComPort comPort;
private Meting schrijfweg;
private Meting Write;
private List<Meting> _data;
private int i = 0;
List<Meting> readedFile = new List<Meting>();
public Ergometer()
{
InitializeComponent();
@@ -52,6 +54,7 @@ namespace ErgometerApplication
Console.WriteLine(response);
Meting test = FormatHelper.Status(response);
Write = test;
string test2 = test.ToString();
richTextBox1.Text = test2;
}
@@ -169,14 +172,13 @@ namespace ErgometerApplication
private void saveTimer_Tick(object sender, EventArgs e)
{
saveData(schrijfweg);
saveData(Write);
}
private void writeFile()
{
string json = JsonConvert.SerializeObject(_data.ToArray());
string json = Newtonsoft.Json.JsonConvert.SerializeObject(_data.ToArray());
System.IO.File.WriteAllText(@Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//path.ergo", json);
}
private void saveData(Meting meting)
@@ -184,14 +186,14 @@ namespace ErgometerApplication
_data = new List<Meting>();
_data.Add(new Meting()
{
HeartBeat = schrijfweg.HeartBeat,
RPM = schrijfweg.RPM,
Speed = schrijfweg.Speed,
Distance = schrijfweg.Distance,
Power = schrijfweg.Power,
Energy = schrijfweg.Energy,
Seconds = schrijfweg.Seconds,
ActualPower = schrijfweg.ActualPower
HeartBeat = Write.HeartBeat,
RPM = Write.RPM,
Speed = Write.Speed,
Distance = Write.Distance,
Power = Write.Power,
Energy = Write.Energy,
Seconds = Write.Seconds,
ActualPower = Write.ActualPower
});
}
@@ -200,9 +202,58 @@ namespace ErgometerApplication
writeFile();
}
private void Ergometer_Load(object sender, EventArgs e)
private void readFile()
{
string path;
OpenFileDialog file = new OpenFileDialog();
if (file.ShowDialog() == DialogResult.OK)
{
path = file.FileName;
readedFile = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Meting>>(System.IO.File.ReadAllText(path));
richTextBox1.Text = readedFile.ElementAt(i).ToString();
}
else
{
readedFile = null;
}
}
private void button1_Click(object sender, EventArgs e)
{
readFile();
if (readedFile != null)
{
button3.Enabled = true;
button2.Enabled = true;
}
}
private void button2_Click(object sender, EventArgs e)
{
if (i > 0)
{ i--;
button3.Enabled = true;
}
if (i == 0)
{
button2.Enabled = false;
}
richTextBox1.Text = readedFile.ElementAt(i).ToString();
}
private void button3_Click(object sender, EventArgs e)
{
if (i < (readedFile.Count - 1))
{ i++;
button2.Enabled = true;
}
if (i == (readedFile.Count - 1))
{
button3.Enabled = false;
}
richTextBox1.Text = readedFile.ElementAt(i).ToString();
}
}
}
@@ -33,6 +33,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -69,6 +73,7 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
File diff suppressed because it is too large Load Diff
@@ -9,3 +9,11 @@ C:\Users\Remco\Documents\GitHub\ErgometerApplication\ErgometerApplication\Ergome
C:\Users\Remco\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.pdb
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.exe
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.pdb
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\bin\Debug\ErgometerApplication.exe
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\bin\Debug\ErgometerApplication.pdb
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\bin\Debug\Newtonsoft.Json.dll
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\bin\Debug\Newtonsoft.Json.xml
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.csprojResolveAssemblyReference.cache
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.Ergometer.resources
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.Properties.Resources.resources
C:\Users\sander\Documents\GitHub\ErgometerApplication\ErgometerApplication\ErgometerApplication\obj\Debug\ErgometerApplication.csproj.GenerateResource.Cache
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
</packages>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,112 @@
param($installPath, $toolsPath, $package, $project)
# open json.net splash page on package install
# don't open if json.net is installed as a dependency
try
{
$url = "http://www.newtonsoft.com/json/install?version=" + $package.Version
$dte2 = Get-Interface $dte ([EnvDTE80.DTE2])
if ($dte2.ActiveWindow.Caption -eq "Package Manager Console")
{
# user is installing from VS NuGet console
# get reference to the window, the console host and the input history
# show webpage if "install-package newtonsoft.json" was last input
$consoleWindow = $(Get-VSComponentModel).GetService([NuGetConsole.IPowerConsoleWindow])
$props = $consoleWindow.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
$prop = $props | ? { $_.Name -eq "ActiveHostInfo" } | select -first 1
if ($prop -eq $null) { return }
$hostInfo = $prop.GetValue($consoleWindow)
if ($hostInfo -eq $null) { return }
$history = $hostInfo.WpfConsole.InputHistory.History
$lastCommand = $history | select -last 1
if ($lastCommand)
{
$lastCommand = $lastCommand.Trim().ToLower()
if ($lastCommand.StartsWith("install-package") -and $lastCommand.Contains("newtonsoft.json"))
{
$dte2.ItemOperations.Navigate($url) | Out-Null
}
}
}
else
{
# user is installing from VS NuGet dialog
# get reference to the window, then smart output console provider
# show webpage if messages in buffered console contains "installing...newtonsoft.json" in last operation
$instanceField = [NuGet.Dialog.PackageManagerWindow].GetField("CurrentInstance", [System.Reflection.BindingFlags]::Static -bor `
[System.Reflection.BindingFlags]::NonPublic)
$consoleField = [NuGet.Dialog.PackageManagerWindow].GetField("_smartOutputConsoleProvider", [System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
if ($instanceField -eq $null -or $consoleField -eq $null) { return }
$instance = $instanceField.GetValue($null)
if ($instance -eq $null) { return }
$consoleProvider = $consoleField.GetValue($instance)
if ($consoleProvider -eq $null) { return }
$console = $consoleProvider.CreateOutputConsole($false)
$messagesField = $console.GetType().GetField("_messages", [System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic)
if ($messagesField -eq $null) { return }
$messages = $messagesField.GetValue($console)
if ($messages -eq $null) { return }
$operations = $messages -split "=============================="
$lastOperation = $operations | select -last 1
if ($lastOperation)
{
$lastOperation = $lastOperation.ToLower()
$lines = $lastOperation -split "`r`n"
$installMatch = $lines | ? { $_.StartsWith("------- installing...newtonsoft.json ") } | select -first 1
if ($installMatch)
{
$dte2.ItemOperations.Navigate($url) | Out-Null
}
}
}
}
catch
{
try
{
$pmPane = $dte2.ToolWindows.OutputWindow.OutputWindowPanes.Item("Package Manager")
$selection = $pmPane.TextDocument.Selection
$selection.StartOfDocument($false)
$selection.EndOfDocument($true)
if ($selection.Text.StartsWith("Attempting to gather dependencies information for package 'Newtonsoft.Json." + $package.Version + "'"))
{
$dte2.ItemOperations.Navigate($url) | Out-Null
}
}
catch
{
# stop potential errors from bubbling up
# worst case the splash page won't open
}
}
# still yolo
+2
View File
@@ -0,0 +1,2 @@
[{"HeartBeat":0,"RPM":0,"Speed":0.0,"Distance":0.0,"Power":0,"Energy":0,"Seconds":4,"ActualPower":0},
{"HeartBeat":10,"RPM":64,"Speed":99.0,"Distance":20.0,"Power":30,"Energy":89,"Seconds":4,"ActualPower":30}]