20140507-181003

This commit is contained in:
BlubbFish 2014-05-07 16:10:08 +00:00
parent 68844e27f0
commit f853278bd7
24 changed files with 330 additions and 148 deletions

Binary file not shown.

View File

@ -7,18 +7,21 @@
</configSections>
<startup>
<supportedRuntime version="v2.0.50727"/></startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
<userSettings>
<Laminator_GUI.Properties.Settings>
<setting name="Com_Port" serializeAs="String">
<value>COM7</value>
</setting>
<setting name="Default_Temp" serializeAs="String">
<value>32</value>
</setting>
<setting name="Default_Motor" serializeAs="String">
<value>10</value>
</setting>
<setting name="Com_Port" serializeAs="String">
<value>COM7</value>
</setting>
<setting name="Setting" serializeAs="String">
<value />
</setting>
</Laminator_GUI.Properties.Settings>
</userSettings>
</configuration>

View File

@ -28,10 +28,10 @@
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series11 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series12 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.label1 = new System.Windows.Forms.Label();
this.Temp = new System.Windows.Forms.Label();
this.chart = new System.Windows.Forms.DataVisualization.Charting.Chart();
@ -43,11 +43,7 @@
this.motorbox = new System.Windows.Forms.NumericUpDown();
this.heizungSoll = new System.Windows.Forms.Label();
this.motorSoll = new System.Windows.Forms.Label();
this.setTemp1 = new System.Windows.Forms.Button();
this.setTemp2 = new System.Windows.Forms.Button();
this.setTemp3 = new System.Windows.Forms.Button();
this.setTemp4 = new System.Windows.Forms.Button();
this.setTemp5 = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tempbox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.motorbox)).BeginInit();
@ -75,26 +71,26 @@
//
// chart
//
chartArea4.Name = "ChartArea1";
this.chart.ChartAreas.Add(chartArea4);
chartArea1.Name = "ChartArea1";
this.chart.ChartAreas.Add(chartArea1);
this.chart.Location = new System.Drawing.Point(13, 134);
this.chart.Name = "chart";
series10.ChartArea = "ChartArea1";
series10.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
series10.Color = System.Drawing.Color.Red;
series10.IsVisibleInLegend = false;
series10.Name = "Temp";
series11.ChartArea = "ChartArea1";
series11.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
series11.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
series11.Name = "Motor";
series12.ChartArea = "ChartArea1";
series12.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
series12.Color = System.Drawing.Color.Blue;
series12.Name = "Heizung";
this.chart.Series.Add(series10);
this.chart.Series.Add(series11);
this.chart.Series.Add(series12);
series1.ChartArea = "ChartArea1";
series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
series1.Color = System.Drawing.Color.Red;
series1.IsVisibleInLegend = false;
series1.Name = "Temp";
series2.ChartArea = "ChartArea1";
series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
series2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
series2.Name = "Motor";
series3.ChartArea = "ChartArea1";
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
series3.Color = System.Drawing.Color.Blue;
series3.Name = "Heizung";
this.chart.Series.Add(series1);
this.chart.Series.Add(series2);
this.chart.Series.Add(series3);
this.chart.Size = new System.Drawing.Size(359, 122);
this.chart.TabIndex = 2;
this.chart.Text = "chart1";
@ -202,66 +198,19 @@
this.motorSoll.TabIndex = 12;
this.motorSoll.Text = "-1";
//
// setTemp1
// panel1
//
this.setTemp1.Location = new System.Drawing.Point(383, 12);
this.setTemp1.Name = "setTemp1";
this.setTemp1.Size = new System.Drawing.Size(89, 41);
this.setTemp1.TabIndex = 13;
this.setTemp1.Text = "Aufheizen 185°C";
this.setTemp1.UseVisualStyleBackColor = true;
this.setTemp1.Click += new System.EventHandler(this.setTemp1_Click);
//
// setTemp2
//
this.setTemp2.Location = new System.Drawing.Point(383, 59);
this.setTemp2.Name = "setTemp2";
this.setTemp2.Size = new System.Drawing.Size(89, 41);
this.setTemp2.TabIndex = 14;
this.setTemp2.Text = "Steppen 185°C";
this.setTemp2.UseVisualStyleBackColor = true;
this.setTemp2.Click += new System.EventHandler(this.setTemp2_Click);
//
// setTemp3
//
this.setTemp3.Location = new System.Drawing.Point(383, 106);
this.setTemp3.Name = "setTemp3";
this.setTemp3.Size = new System.Drawing.Size(89, 41);
this.setTemp3.TabIndex = 15;
this.setTemp3.Text = "Brennen 190°C";
this.setTemp3.UseVisualStyleBackColor = true;
this.setTemp3.Click += new System.EventHandler(this.setTemp3_Click);
//
// setTemp4
//
this.setTemp4.Location = new System.Drawing.Point(383, 153);
this.setTemp4.Name = "setTemp4";
this.setTemp4.Size = new System.Drawing.Size(89, 41);
this.setTemp4.TabIndex = 16;
this.setTemp4.Text = "Abkühlen Motor on";
this.setTemp4.UseVisualStyleBackColor = true;
this.setTemp4.Click += new System.EventHandler(this.setTemp4_Click);
//
// setTemp5
//
this.setTemp5.Location = new System.Drawing.Point(383, 200);
this.setTemp5.Name = "setTemp5";
this.setTemp5.Size = new System.Drawing.Size(89, 41);
this.setTemp5.TabIndex = 17;
this.setTemp5.Text = "Abkühlen Motor off";
this.setTemp5.UseVisualStyleBackColor = true;
this.setTemp5.Click += new System.EventHandler(this.setTemp5_Click);
this.panel1.Location = new System.Drawing.Point(378, 12);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(94, 244);
this.panel1.TabIndex = 13;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(484, 261);
this.Controls.Add(this.setTemp5);
this.Controls.Add(this.setTemp4);
this.Controls.Add(this.setTemp3);
this.Controls.Add(this.setTemp2);
this.Controls.Add(this.setTemp1);
this.ClientSize = new System.Drawing.Size(484, 262);
this.Controls.Add(this.panel1);
this.Controls.Add(this.motorSoll);
this.Controls.Add(this.heizungSoll);
this.Controls.Add(this.motorbox);
@ -300,11 +249,7 @@
private System.Windows.Forms.NumericUpDown motorbox;
private System.Windows.Forms.Label heizungSoll;
private System.Windows.Forms.Label motorSoll;
private System.Windows.Forms.Button setTemp1;
private System.Windows.Forms.Button setTemp2;
private System.Windows.Forms.Button setTemp3;
private System.Windows.Forms.Button setTemp4;
private System.Windows.Forms.Button setTemp5;
private System.Windows.Forms.Panel panel1;
}
}

View File

@ -10,6 +10,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Laminator_GUI.Properties;
using BlubbFish;
namespace Laminator_GUI
{
@ -30,10 +31,12 @@ namespace Laminator_GUI
private Thread t;
private Settings settings;
public delegate void InvokeDelegate();
private InIReader ini = new InIReader("temperatur.ini");
public Form1()
{
InitializeComponent();
InitializeComponent();
this.createButtons();
this.settings = new Settings();
this.chart.ChartAreas[0].AxisX.Maximum = 500;
this.serialPort = new SerialPort(this.settings.Com_Port, 9600, Parity.None, 8, StopBits.One);
@ -49,6 +52,27 @@ namespace Laminator_GUI
while (!t.IsAlive) ;
}
private void createButtons()
{
List<String> sections = this.ini.getSections();
int height = this.panel1.Size.Height;
int numbers = sections.Count;
int el = (height / numbers)-4;
int i = 0;
foreach (String profil in sections)
{
System.Windows.Forms.Button setTemp = new System.Windows.Forms.Button();
setTemp.Location = new System.Drawing.Point(2, (el*i)+2);
setTemp.Name = profil;
setTemp.Size = new System.Drawing.Size(89, el);
setTemp.Text = this.ini.getValue(profil, "name");
setTemp.UseVisualStyleBackColor = true;
setTemp.Click += new System.EventHandler(this.setTemp_Click);
this.panel1.Controls.Add(setTemp);
i++;
}
}
private void polling()
{
while (true)
@ -160,42 +184,11 @@ namespace Laminator_GUI
serialPort.Close();
}
private void setTemp1_Click(object sender, EventArgs e)
private void setTemp_Click(object sender, EventArgs e)
{
this.serialPort.Write("t185\n");
this.serialPort.Write("m10\n");
this.motorText = "-1";
this.solltempText = "-1";
}
private void setTemp2_Click(object sender, EventArgs e)
{
this.serialPort.Write("t185\n");
this.serialPort.Write("m02\n");
this.motorText = "-1";
this.solltempText = "-1";
}
private void setTemp3_Click(object sender, EventArgs e)
{
this.serialPort.Write("t190\n");
this.serialPort.Write("m10\n");
this.motorText = "-1";
this.solltempText = "-1";
}
private void setTemp4_Click(object sender, EventArgs e)
{
this.serialPort.Write("t010\n");
this.serialPort.Write("m10\n");
this.motorText = "-1";
this.solltempText = "-1";
}
private void setTemp5_Click(object sender, EventArgs e)
{
this.serialPort.Write("t010\n");
this.serialPort.Write("m00\n");
Button b = (Button)sender;
this.serialPort.Write("t" + this.ini.getValue(b.Name, "temp").PadLeft(3, '0') + "\n");
this.serialPort.Write("m" + this.ini.getValue(b.Name, "motor").PadLeft(2,'0') + "\n");
this.motorText = "-1";
this.solltempText = "-1";
}

View File

@ -0,0 +1,142 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
using System.Text.RegularExpressions;
namespace BlubbFish
{
public class InIReader
{
private Dictionary<string,Dictionary<string,string>> cont;
private FileSystemWatcher k = new FileSystemWatcher(Directory.GetCurrentDirectory(), "*.ini");
private string filename;
public InIReader(string filename)
{
this.filename = filename;
k.Changed += new FileSystemEventHandler(this.readAgain);
loadFile();
}
private void readAgain(object sender, EventArgs e)
{
loadFile();
}
private void loadFile()
{
this.cont = new Dictionary<string, Dictionary<string, string>>();
StreamReader file = new StreamReader(this.filename);
List<String> buf = new List<string>();
string fline = "";
while (fline != null)
{
fline = file.ReadLine();
if (fline != null)
buf.Add(fline);
}
file.Close();
Dictionary<string, string> sub = new Dictionary<string, string>();
string cap = "";
foreach (string line in buf)
{
Match match = Regex.Match(line, @"^\[[a-zA-Z0-9\-_ ]+\]\w*$", RegexOptions.IgnoreCase);
if (match.Success)
{
if (sub.Count != 0 && cap != "")
{
cont.Add(cap, sub);
}
cap = line;
sub = new Dictionary<string, string>();
}
else
{
if (line != "" && cap != "")
{
string key = line.Substring(0,line.IndexOf('='));
string value = line.Substring(line.IndexOf('=')+1);
sub.Add(key, value);
}
}
}
if (sub.Count != 0 && cap != "")
{
cont.Add(cap, sub);
}
}
public List<String> getSections()
{
return cont.Keys.ToList<String>();
}
public String getValue(String section, String key)
{
if (!section.StartsWith("["))
{
section = "[" + section + "]";
}
if (cont.Keys.Contains(section))
{
if (cont[section].Keys.Contains(key))
{
return cont[section][key];
}
}
return null;
}
public void SetValue(string section, string key, string value)
{
if (!section.StartsWith("["))
{
section = "[" + section + "]";
}
if (cont.Keys.Contains(section))
{
if (cont[section].Keys.Contains(key))
{
cont[section][key] = value;
}
else
{
cont[section].Add(key, value);
}
}
else
{
Dictionary<string,string> sub = new Dictionary<string,string>();
sub.Add(key, value);
cont.Add(section, sub);
}
k.Changed -= null;
saveSettings();
loadFile();
k.Changed += new FileSystemEventHandler(this.readAgain);
}
private void saveSettings()
{
StreamWriter file = new StreamWriter(this.filename);
file.BaseStream.SetLength(0);
file.BaseStream.Flush();
file.BaseStream.Seek(0, SeekOrigin.Begin);
foreach (KeyValuePair<string, Dictionary<string, string>> cap in this.cont)
{
file.WriteLine(cap.Key);
foreach (KeyValuePair<string, string> sub in cap.Value)
{
file.WriteLine(sub.Key + "=" + sub.Value);
}
file.WriteLine();
}
file.Flush();
file.Close();
}
}
}

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Laminator_GUI</RootNamespace>
<AssemblyName>Laminator-GUI</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
@ -74,8 +74,10 @@
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="InIReader.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
@ -89,6 +91,9 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="temperatur.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@ -23,18 +23,6 @@ namespace Laminator_GUI.Properties {
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("COM8")]
public string Com_Port {
get {
return ((string)(this["Com_Port"]));
}
set {
this["Com_Port"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("32")]
@ -58,5 +46,29 @@ namespace Laminator_GUI.Properties {
this["Default_Motor"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("COM7")]
public string Com_Port {
get {
return ((string)(this["Com_Port"]));
}
set {
this["Com_Port"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string Setting {
get {
return ((string)(this["Setting"]));
}
set {
this["Setting"] = value;
}
}
}
}

View File

@ -0,0 +1,28 @@
namespace Laminator_GUI.Properties {
// Diese Klasse ermöglicht die Behandlung bestimmter Ereignisse der Einstellungsklasse:
// Das SettingChanging-Ereignis wird ausgelöst, bevor der Wert einer Einstellung geändert wird.
// Das PropertyChanged-Ereignis wird ausgelöst, nachdem der Wert einer Einstellung geändert wurde.
// Das SettingsLoaded-Ereignis wird ausgelöst, nachdem die Einstellungswerte geladen wurden.
// Das SettingsSaving-Ereignis wird ausgelöst, bevor die Einstellungswerte gespeichert werden.
internal sealed partial class Settings {
public Settings() {
// // Heben Sie die Auskommentierung der unten angezeigten Zeilen auf, um Ereignishandler zum Speichern und Ändern von Einstellungen hinzuzufügen:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Fügen Sie hier Code zum Behandeln des SettingChangingEvent-Ereignisses hinzu.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Fügen Sie hier Code zum Behandeln des SettingsSaving-Ereignisses hinzu.
}
}
}

View File

View File

@ -7,18 +7,21 @@
</configSections>
<startup>
<supportedRuntime version="v2.0.50727"/></startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
<userSettings>
<Laminator_GUI.Properties.Settings>
<setting name="Com_Port" serializeAs="String">
<value>COM7</value>
</setting>
<setting name="Default_Temp" serializeAs="String">
<value>32</value>
</setting>
<setting name="Default_Motor" serializeAs="String">
<value>10</value>
</setting>
<setting name="Com_Port" serializeAs="String">
<value>COM7</value>
</setting>
<setting name="Setting" serializeAs="String">
<value />
</setting>
</Laminator_GUI.Properties.Settings>
</userSettings>
</configuration>

View File

@ -7,18 +7,21 @@
</configSections>
<startup>
<supportedRuntime version="v2.0.50727"/></startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
<userSettings>
<Laminator_GUI.Properties.Settings>
<setting name="Com_Port" serializeAs="String">
<value>COM7</value>
</setting>
<setting name="Default_Temp" serializeAs="String">
<value>32</value>
</setting>
<setting name="Default_Motor" serializeAs="String">
<value>10</value>
</setting>
<setting name="Com_Port" serializeAs="String">
<value>COM7</value>
</setting>
<setting name="Setting" serializeAs="String">
<value />
</setting>
</Laminator_GUI.Properties.Settings>
</userSettings>
</configuration>

View File

@ -0,0 +1,24 @@
[Profile 1]
temp=200
motor=10
name=Aufheitzen 200°C
[Profile 2]
temp=200
motor=2
name=Steppen 200°C
[Profile 3]
temp=210
motor=10
name=Brennen 210°C
[Profile 4]
temp=10
motor=10
name=Abkühlen Motor ein
[Profile 5]
temp=10
motor=0
name=Abkühlen Motor aus

View File

@ -1,5 +1,4 @@
D:\Doc's\Basteleien\Laminator\Laminator-GUI\Laminator-GUI\bin\x86\Release\Laminator-GUI.exe.config
D:\Doc's\Basteleien\Laminator\Laminator-GUI\Laminator-GUI\obj\x86\Release\Laminator-GUI.csprojResolveAssemblyReference.cache
D:\Doc's\Basteleien\Laminator\Laminator-GUI\Laminator-GUI\obj\x86\Release\Laminator_GUI.Form1.resources
D:\Doc's\Basteleien\Laminator\Laminator-GUI\Laminator-GUI\obj\x86\Release\Laminator_GUI.Properties.Resources.resources
D:\Doc's\Basteleien\Laminator\Laminator-GUI\Laminator-GUI\obj\x86\Release\Laminator-GUI.csproj.GenerateResource.Cache
@ -7,3 +6,4 @@ D:\Doc's\Basteleien\Laminator\Laminator-GUI\Laminator-GUI\bin\x86\Release\Lamina
D:\Doc's\Basteleien\Laminator\Laminator-GUI\Laminator-GUI\bin\x86\Release\Laminator-GUI.pdb
D:\Doc's\Basteleien\Laminator\Laminator-GUI\Laminator-GUI\obj\x86\Release\Laminator-GUI.exe
D:\Doc's\Basteleien\Laminator\Laminator-GUI\Laminator-GUI\obj\x86\Release\Laminator-GUI.pdb
D:\Doc's\Basteleien\Laminator\Laminator-GUI\Laminator-GUI\bin\x86\Release\temperatur.ini

View File

@ -0,0 +1,24 @@
[Profile 1]
temp=200
motor=10
name=Aufheitzen 200°C
[Profile 2]
temp=200
motor=2
name=Steppen 200°C
[Profile 3]
temp=210
motor=10
name=Brennen 210°C
[Profile 4]
temp=10
motor=10
name=Abkühlen Motor ein
[Profile 5]
temp=10
motor=0
name=Abkühlen Motor aus