[BF] Typo
[NF] Nun mit Beispieldateien [NF] Benutzen einer Fabrik
This commit is contained in:
parent
75e9dd084f
commit
59d1f15bc2
@ -59,8 +59,11 @@
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Sensor\ASensor.cs" />
|
||||
<Compile Include="Sensor\Luminanz.cs" />
|
||||
<Compile Include="Sensor\Power.cs" />
|
||||
<Compile Include="Sensor\Pir.cs" />
|
||||
<Compile Include="Sensor\Switch.cs" />
|
||||
<Compile Include="Sensor\Temperatur.cs" />
|
||||
<Compile Include="Tracings\ATracings.cs" />
|
||||
<Compile Include="Tracings\Graph.cs" />
|
||||
<Compile Include="Tracings\Meter.cs" />
|
||||
@ -89,15 +92,9 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<None Include="sensor.ini">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="settings.ini">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="tracings.ini">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="sensor.ini.example" />
|
||||
<None Include="settings.ini.example" />
|
||||
<None Include="tracings.ini.example" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
|
@ -7,7 +7,6 @@ using Dashboard.Tracings;
|
||||
using BlubbFish.Utils;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Dashboard.tracings;
|
||||
|
||||
namespace Dashboard {
|
||||
public partial class Dashboard : Form {
|
||||
@ -32,35 +31,20 @@ namespace Dashboard {
|
||||
|
||||
private void Dashboard_SizeChanged(Object sender, EventArgs e) {
|
||||
this.flowLayoutPanel2.Size = new System.Drawing.Size(this.Size.Width - 40, this.Size.Width - 76);
|
||||
//this.Size.Height
|
||||
}
|
||||
|
||||
private void GenerateSensors() {
|
||||
InIReader ini = InIReader.GetInstance("sensor.ini");
|
||||
List<String> sensorini = ini.GetSections();
|
||||
foreach(String sensor in sensorini) {
|
||||
ASensor s;
|
||||
switch(ini.GetValue(sensor, "type").ToLower()) {
|
||||
case "power": s = new Power(ini.GetSection(sensor)); break;
|
||||
case "switch": s = new Switch(ini.GetSection(sensor)); break;
|
||||
default: throw new ArgumentException("sensor.ini: " + sensor + " section has a missconfiguration in type");
|
||||
}
|
||||
this.sensors.Add(sensor.ToLower().Substring(1, sensor.Length - 2), s);
|
||||
this.sensors.Add(sensor.ToLower().Substring(1, sensor.Length - 2), ASensor.GetInstance(ini.GetValue(sensor, "type").ToLower(), ini.GetSection(sensor)));
|
||||
}
|
||||
}
|
||||
private void GenerateForms() {
|
||||
InIReader ini = InIReader.GetInstance("tracings.ini");
|
||||
List<String> tracingini = ini.GetSections();
|
||||
foreach(String tracing in tracingini) {
|
||||
ATracings t;
|
||||
switch(ini.GetValue(tracing, "type").ToLower()) {
|
||||
case "graph": t = new Graph(this.sensors[ini.GetValue(tracing, "sensor").ToLower()],ini.GetSection(tracing)); break;
|
||||
case "meter": t = new Meter(this.sensors[ini.GetValue(tracing, "sensor").ToLower()], ini.GetSection(tracing)); break;
|
||||
case "powermeter": t = new PowerMeter(this.sensors[ini.GetValue(tracing, "sensor").ToLower()], ini.GetSection(tracing)); break;
|
||||
case "switcher": t = new Switcher(this.sensors[ini.GetValue(tracing, "sensor").ToLower()], ini.GetSection(tracing)); break;
|
||||
default: throw new ArgumentException("tracings.ini: " + tracing + " section has a missconfiguration in type");
|
||||
}
|
||||
this.flowLayoutPanel2.Controls.Add(t.GetPanel());
|
||||
this.flowLayoutPanel2.Controls.Add(ATracings.GetInstance(ini.GetValue(tracing, "type").ToLower(), this.sensors[ini.GetValue(tracing, "sensor").ToLower()], ini.GetSection(tracing)).GetPanel());
|
||||
}
|
||||
}
|
||||
private void SensorPolling() {
|
||||
|
@ -37,6 +37,18 @@ namespace Dashboard.Sensor {
|
||||
}
|
||||
protected abstract void UpdateValue(MqttMsgPublishEventArgs e);
|
||||
public Int32 GetInt { get; protected set; }
|
||||
|
||||
internal static ASensor GetInstance(String v, Dictionary<String, String> dictionary) {
|
||||
string object_sensor = "Dashboard.Sensor." + char.ToUpper(v[0]) + v.Substring(1);
|
||||
Type t = null;
|
||||
try {
|
||||
t = Type.GetType(object_sensor, true);
|
||||
} catch(TypeLoadException) {
|
||||
throw new ArgumentException("sensor.ini: " + v + " is not a Sensor");
|
||||
}
|
||||
return (ASensor)t.GetConstructor(new Type[] { typeof(Dictionary<String, String>) }).Invoke(new object[] { dictionary });
|
||||
}
|
||||
|
||||
public Single GetFloat { get; protected set; }
|
||||
public Boolean GetBool { get; protected set; }
|
||||
public Types Datatypes { get; protected set; }
|
||||
|
20
Mqtt-Dashboard/Sensor/Luminanz.cs
Normal file
20
Mqtt-Dashboard/Sensor/Luminanz.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using uPLibrary.Networking.M2Mqtt.Messages;
|
||||
|
||||
namespace Dashboard.Sensor {
|
||||
class Luminanz : ASensor {
|
||||
public Luminanz(Dictionary<String, String> settings) : base(settings) {
|
||||
this.GetBool = true;
|
||||
this.GetFloat = 0.0f;
|
||||
this.GetInt = 0;
|
||||
this.Datatypes = Types.Int;
|
||||
}
|
||||
|
||||
protected override void UpdateValue(MqttMsgPublishEventArgs e) {
|
||||
this.GetInt = Int32.Parse(Encoding.UTF8.GetString(e.Message), new CultureInfo("en-US"));
|
||||
}
|
||||
}
|
||||
}
|
16
Mqtt-Dashboard/Sensor/Pir.cs
Normal file
16
Mqtt-Dashboard/Sensor/Pir.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using uPLibrary.Networking.M2Mqtt.Messages;
|
||||
|
||||
namespace Dashboard.Sensor {
|
||||
class Pir : ASensor {
|
||||
public Pir(Dictionary<String, String> settings) : base(settings) {
|
||||
this.Datatypes = Types.Bool;
|
||||
}
|
||||
|
||||
protected override void UpdateValue(MqttMsgPublishEventArgs e) {
|
||||
this.GetBool = (Encoding.UTF8.GetString(e.Message).ToLower() == "on") ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
20
Mqtt-Dashboard/Sensor/Temperatur.cs
Normal file
20
Mqtt-Dashboard/Sensor/Temperatur.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using uPLibrary.Networking.M2Mqtt.Messages;
|
||||
|
||||
namespace Dashboard.Sensor {
|
||||
class Temperatur : ASensor {
|
||||
public Temperatur(Dictionary<String, String> settings) : base(settings) {
|
||||
this.GetBool = true;
|
||||
this.GetFloat = 0.0f;
|
||||
this.GetInt = 0;
|
||||
this.Datatypes = Types.Float;
|
||||
}
|
||||
|
||||
protected override void UpdateValue(MqttMsgPublishEventArgs e) {
|
||||
this.GetFloat = Single.Parse(Encoding.UTF8.GetString(e.Message), new CultureInfo("en-US"));
|
||||
}
|
||||
}
|
||||
}
|
@ -15,5 +15,15 @@ namespace Dashboard.Tracings {
|
||||
}
|
||||
protected abstract void SensorUpdate(Object sender, EventArgs e);
|
||||
public abstract Panel GetPanel();
|
||||
internal static ATracings GetInstance(String v, ASensor aSensor, Dictionary<String, String> dictionary) {
|
||||
string object_sensor = "Dashboard.Tracings." + char.ToUpper(v[0]) + v.Substring(1);
|
||||
Type t = null;
|
||||
try {
|
||||
t = Type.GetType(object_sensor, true);
|
||||
} catch(TypeLoadException) {
|
||||
throw new ArgumentException("tracings.ini: " + v + " is not a Tracing");
|
||||
}
|
||||
return (ATracings)t.GetConstructor(new Type[] { typeof(ASensor), typeof(Dictionary<String, String>) }).Invoke(new object[] { aSensor, dictionary });
|
||||
}
|
||||
}
|
||||
}
|
@ -8,8 +8,8 @@ using System.Windows.Forms;
|
||||
using Dashboard.Sensor;
|
||||
|
||||
namespace Dashboard.Tracings {
|
||||
class PowerMeter : Meter {
|
||||
public PowerMeter(ASensor sensor, Dictionary<String, String> settings) : base(sensor, settings) {
|
||||
class Powermeter : Meter {
|
||||
public Powermeter(ASensor sensor, Dictionary<String, String> settings) : base(sensor, settings) {
|
||||
}
|
||||
protected override void SensorUpdate(Object sender, EventArgs e) {
|
||||
String value = "";
|
||||
|
@ -4,9 +4,8 @@ using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
using Dashboard.Connector;
|
||||
using Dashboard.Sensor;
|
||||
using Dashboard.Tracings;
|
||||
|
||||
namespace Dashboard.tracings {
|
||||
namespace Dashboard.Tracings {
|
||||
class Switcher : ATracings {
|
||||
private Label label;
|
||||
private Button button1;
|
||||
|
Loading…
Reference in New Issue
Block a user