[NF] Aufgeräumt
This commit is contained in:
parent
8d80a132dc
commit
b1efd55025
41
.gitignore
vendored
41
.gitignore
vendored
@ -90,3 +90,44 @@
|
|||||||
/Mqtt-Dashboard/Mqtt-Dashboard/Connector/.svn
|
/Mqtt-Dashboard/Mqtt-Dashboard/Connector/.svn
|
||||||
/Mqtt-Dashboard/Mqtt-Dashboard/Sensor/.svn
|
/Mqtt-Dashboard/Mqtt-Dashboard/Sensor/.svn
|
||||||
/IoT-Bot/IoT-Bot/bin/Debug
|
/IoT-Bot/IoT-Bot/bin/Debug
|
||||||
|
/.gitattributes
|
||||||
|
/Utils/Utils/bin/Release/Utils.dll.CodeAnalysisLog.xml
|
||||||
|
/Utils/Utils/bin/Release/Utils.dll.lastcodeanalysissucceeded
|
||||||
|
/Utils/packages
|
||||||
|
/Utils/IoT/.vs/Utils-IoT/v15
|
||||||
|
/Utils/IoT/bin/Debug
|
||||||
|
/Utils/IoT/bin/Release/M2Mqtt.Net.pdb
|
||||||
|
/Utils/IoT/bin/Release/LitJson.dll
|
||||||
|
/Utils/IoT/bin/Release/M2Mqtt.Net.dll
|
||||||
|
/Utils/IoT/bin/Release/Microsoft.Win32.Primitives.dll
|
||||||
|
/Utils/IoT/bin/Release/Newtonsoft.Json.dll
|
||||||
|
/Utils/IoT/bin/Release/Newtonsoft.Json.xml
|
||||||
|
/Utils/IoT/bin/Release/System.AppContext.dll
|
||||||
|
/Utils/IoT/bin/Release/System.Console.dll
|
||||||
|
/Utils/IoT/bin/Release/System.Diagnostics.DiagnosticSource.dll
|
||||||
|
/Utils/IoT/bin/Release/System.Diagnostics.DiagnosticSource.xml
|
||||||
|
/Utils/IoT/bin/Release/System.Globalization.Calendars.dll
|
||||||
|
/Utils/IoT/bin/Release/System.IO.Compression.dll
|
||||||
|
/Utils/IoT/bin/Release/System.IO.Compression.ZipFile.dll
|
||||||
|
/Utils/IoT/bin/Release/System.IO.FileSystem.dll
|
||||||
|
/Utils/IoT/bin/Release/System.IO.FileSystem.Primitives.dll
|
||||||
|
/Utils/IoT/bin/Release/System.Net.Http.dll
|
||||||
|
/Utils/IoT/bin/Release/System.Net.Sockets.dll
|
||||||
|
/Utils/IoT/bin/Release/System.Runtime.InteropServices.RuntimeInformation.dll
|
||||||
|
/Utils/IoT/bin/Release/System.Security.Cryptography.Algorithms.dll
|
||||||
|
/Utils/IoT/bin/Release/System.Security.Cryptography.Encoding.dll
|
||||||
|
/Utils/IoT/bin/Release/System.Security.Cryptography.Primitives.dll
|
||||||
|
/Utils/IoT/bin/Release/System.Security.Cryptography.X509Certificates.dll
|
||||||
|
/Utils/IoT/bin/Release/System.Xml.ReaderWriter.dll
|
||||||
|
/Utils/IoT/bin/Release/Telegram.Bot.dll
|
||||||
|
/Utils/IoT/bin/Release/Utils-IoT.dll.CodeAnalysisLog.xml
|
||||||
|
/Utils/IoT/bin/Release/Utils-IoT.dll.lastcodeanalysissucceeded
|
||||||
|
/Utils/IoT/bin/Release/Utils-IoT.dll.config
|
||||||
|
/Utils/IoT/bin/Release/Utils-IoT.pdb
|
||||||
|
/Utils/IoT/bin/Release/Utils.dll
|
||||||
|
/Utils/IoT/bin/Release/Utils.pdb
|
||||||
|
/Utils/IoT/obj
|
||||||
|
/Utils/.vs
|
||||||
|
/Mqtt-Dashboard/Mqtt-Dashboard/bin/Release/Newtonsoft.Json.xml
|
||||||
|
/Mqtt-Dashboard/Mqtt-Dashboard/bin/Release/Utils-IoT.dll.config
|
||||||
|
/Mqtt-Dashboard/Mqtt-Dashboard/bin/Release/Utils-IoT.pdb
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 14.0.25420.1
|
VisualStudioVersion = 15.0.26730.16
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoT-Bot", "IoT-Bot\IoT-Bot.csproj", "{89077643-B472-419F-8EAB-56B9E2D13ABC}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoT-Bot", "IoT-Bot\IoT-Bot.csproj", "{89077643-B472-419F-8EAB-56B9E2D13ABC}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils\IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\Utils\Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -15,8 +19,19 @@ Global
|
|||||||
{89077643-B472-419F-8EAB-56B9E2D13ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{89077643-B472-419F-8EAB-56B9E2D13ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{89077643-B472-419F-8EAB-56B9E2D13ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{89077643-B472-419F-8EAB-56B9E2D13ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{89077643-B472-419F-8EAB-56B9E2D13ABC}.Release|Any CPU.Build.0 = Release|Any CPU
|
{89077643-B472-419F-8EAB-56B9E2D13ABC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {868AF401-44D7-4E3C-826A-8FA1E24C850D}
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
|
||||||
</startup>
|
</startup>
|
||||||
</configuration>
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
using IoTBot.Sensor;
|
using BlubbFish.Utils.IoT.Sensor;
|
||||||
|
|
||||||
namespace IoTBot.Condition {
|
namespace IoTBot.Condition {
|
||||||
abstract class ACondition {
|
abstract class ACondition {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
using IoTBot.Sensor;
|
using BlubbFish.Utils.IoT.Sensor;
|
||||||
|
|
||||||
namespace IoTBot.Condition {
|
namespace IoTBot.Condition {
|
||||||
class Edge : ACondition {
|
class Edge : ACondition {
|
||||||
@ -15,7 +15,7 @@ namespace IoTBot.Condition {
|
|||||||
if(this.sensor.Datatypes == ASensor.Types.Bool) {
|
if(this.sensor.Datatypes == ASensor.Types.Bool) {
|
||||||
if(this.sensor.GetBool == Boolean.Parse(this.settings["sensor_value"]) && this.histBool != this.sensor.GetBool) {
|
if(this.sensor.GetBool == Boolean.Parse(this.settings["sensor_value"]) && this.histBool != this.sensor.GetBool) {
|
||||||
this.histBool = this.sensor.GetBool;
|
this.histBool = this.sensor.GetBool;
|
||||||
IoTBot.Connector.Telegram.Instance.Send("Jemand ist DA!");
|
Telegram.Instance.Send("Jemand ist DA!");
|
||||||
} else {
|
} else {
|
||||||
this.histBool = this.sensor.GetBool;
|
this.histBool = this.sensor.GetBool;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using BlubbFish.Utils;
|
using BlubbFish.Utils;
|
||||||
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
using IoTBot.Condition;
|
using IoTBot.Condition;
|
||||||
using IoTBot.Connector;
|
|
||||||
|
|
||||||
namespace IoTBot {
|
namespace IoTBot {
|
||||||
class ConditionWorker {
|
class ConditionWorker {
|
||||||
private InIReader ini;
|
private InIReader ini;
|
||||||
private static ConditionWorker instance;
|
private static ConditionWorker instance;
|
||||||
private List<ACondition> conditions;
|
private List<ACondition> conditions;
|
||||||
private Connector.Telegram telegram;
|
private Telegram telegram;
|
||||||
|
|
||||||
public static ConditionWorker GetInstance(ADataBackend backend) {
|
public static ConditionWorker GetInstance(ADataBackend backend) {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
@ -18,7 +18,7 @@ namespace IoTBot {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Run(Connector.Telegram telegram) {
|
internal void Run(Telegram telegram) {
|
||||||
this.telegram = telegram;
|
this.telegram = telegram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,121 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
|
||||||
class Mosquitto : ADataBackend, IDisposable {
|
|
||||||
private Process p;
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
public override event MqttMessage MessageIncomming;
|
|
||||||
public override event MqttMessage MessageSending;
|
|
||||||
|
|
||||||
public Mosquitto(Dictionary<String, String> mqtt_settings) {
|
|
||||||
this.settings = mqtt_settings;
|
|
||||||
//mosquitto_sub --cafile ca.pem --cert cert.pem --key cert.key -h swb.broker.flex4grid.eu -p 8883 -t "#" -v -d
|
|
||||||
this.message = "";
|
|
||||||
this.p = new Process();
|
|
||||||
this.p.StartInfo.FileName = "mosquitto_sub";
|
|
||||||
String args = "-h " + this.settings["server"]+" ";
|
|
||||||
if(this.settings.ContainsKey("port")) {
|
|
||||||
args += "-p "+ this.settings["port"]+" ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("cafile")) {
|
|
||||||
args += "--cafile " + this.settings["cafile"] + " ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("cert")) {
|
|
||||||
args += "--cert " + this.settings["cert"] + " ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("key")) {
|
|
||||||
args += "--key " + this.settings["key"] + " ";
|
|
||||||
}
|
|
||||||
this.p.StartInfo.Arguments = args+"-t \"#\" -v -d";
|
|
||||||
this.p.StartInfo.CreateNoWindow = true;
|
|
||||||
this.p.StartInfo.UseShellExecute = false;
|
|
||||||
this.p.StartInfo.RedirectStandardOutput = true;
|
|
||||||
this.p.StartInfo.RedirectStandardError = true;
|
|
||||||
this.p.OutputDataReceived += this.P_OutputDataReceived;
|
|
||||||
this.p.ErrorDataReceived += this.P_ErrorDataReceived;
|
|
||||||
this.p.Start();
|
|
||||||
this.p.BeginOutputReadLine();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Send(String topic, String data) {
|
|
||||||
Process send = new Process();
|
|
||||||
send.StartInfo.FileName = "mosquitto_pub";
|
|
||||||
String args = "-h " + this.settings["server"] + " ";
|
|
||||||
if (this.settings.ContainsKey("port")) {
|
|
||||||
args += "-p " + this.settings["port"] + " ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("cafile")) {
|
|
||||||
args += "--cafile " + this.settings["cafile"] + " ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("cert")) {
|
|
||||||
args += "--cert " + this.settings["cert"] + " ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("key")) {
|
|
||||||
args += "--key " + this.settings["key"] + " ";
|
|
||||||
}
|
|
||||||
send.StartInfo.Arguments = args + "-m \""+data.Replace("\"","\\\"")+"\" -t \""+topic+"\" -d";
|
|
||||||
send.StartInfo.CreateNoWindow = true;
|
|
||||||
send.StartInfo.UseShellExecute = false;
|
|
||||||
send.StartInfo.RedirectStandardOutput = true;
|
|
||||||
send.StartInfo.RedirectStandardError = true;
|
|
||||||
send.Start();
|
|
||||||
send.WaitForExit();
|
|
||||||
MessageSending?.Invoke(this, new MqttEventArgs(data, topic));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void P_ErrorDataReceived(Object sender, DataReceivedEventArgs e) {
|
|
||||||
if (e.Data != null) {
|
|
||||||
throw new NotImplementedException(e.Data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void P_OutputDataReceived(Object sender, DataReceivedEventArgs e) {
|
|
||||||
if (e.Data != null) {
|
|
||||||
if (e.Data.StartsWith("Client mosqsub")) {
|
|
||||||
if (this.message != "" && this.message.IndexOf(" received PUBLISH ") > 0) {
|
|
||||||
MatchCollection matches = (new Regex("^Client mosqsub[\\|/].*received PUBLISH \\(.*,.*,.*,.*, '(.*)'.*\\)\\)\n[^ ]* (.*)$", RegexOptions.IgnoreCase | RegexOptions.Singleline)).Matches(this.message);
|
|
||||||
String topic = matches[0].Groups[1].Value;
|
|
||||||
String message = matches[0].Groups[2].Value.Trim();
|
|
||||||
this.MessageIncomming?.Invoke(this, new MqttEventArgs(message, topic));
|
|
||||||
}
|
|
||||||
this.message = e.Data + "\n";
|
|
||||||
} else {
|
|
||||||
this.message += e.Data + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IDisposable Support
|
|
||||||
private Boolean disposedValue = false; // Dient zur Erkennung redundanter Aufrufe.
|
|
||||||
private readonly Dictionary<String, String> settings;
|
|
||||||
|
|
||||||
protected virtual void Dispose(Boolean disposing) {
|
|
||||||
if (!this.disposedValue) {
|
|
||||||
if (disposing) {
|
|
||||||
this.p.CancelOutputRead();
|
|
||||||
if (!this.p.HasExited) {
|
|
||||||
this.p.Kill();
|
|
||||||
}
|
|
||||||
this.p.Close();
|
|
||||||
}
|
|
||||||
this.p = null;
|
|
||||||
this.disposedValue = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~Mosquitto() {
|
|
||||||
Dispose(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using uPLibrary.Networking.M2Mqtt;
|
|
||||||
using uPLibrary.Networking.M2Mqtt.Messages;
|
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
|
||||||
class Mqtt : ADataBackend, IDisposable {
|
|
||||||
private MqttClient client;
|
|
||||||
|
|
||||||
public override event MqttMessage MessageIncomming;
|
|
||||||
public override event MqttMessage MessageSending;
|
|
||||||
|
|
||||||
public Mqtt(Dictionary<String, String> settings) {
|
|
||||||
if(settings.ContainsKey("port")) {
|
|
||||||
this.client = new MqttClient(settings["server"], Int32.Parse(settings["port"]), false, null, null, MqttSslProtocols.None);
|
|
||||||
} else {
|
|
||||||
this.client = new MqttClient(settings["server"]);
|
|
||||||
}
|
|
||||||
Connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Connect() {
|
|
||||||
this.client.MqttMsgPublishReceived += this.Client_MqttMsgPublishReceived;
|
|
||||||
this.client.Connect(Guid.NewGuid().ToString());
|
|
||||||
this.client.Subscribe(new String[] { "#" }, new Byte[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE });
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Client_MqttMsgPublishReceived(Object sender, MqttMsgPublishEventArgs e) {
|
|
||||||
this.MessageIncomming?.Invoke(this, new MqttEventArgs(Encoding.UTF8.GetString(e.Message), e.Topic));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Send(String topic, String data) {
|
|
||||||
this.client.Publish(topic, Encoding.UTF8.GetBytes(data));
|
|
||||||
this.MessageSending?.Invoke(this, new MqttEventArgs(data, topic));
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IDisposable Support
|
|
||||||
private Boolean disposedValue = false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected virtual void Dispose(Boolean disposing) {
|
|
||||||
if(!this.disposedValue) {
|
|
||||||
if(disposing) {
|
|
||||||
this.client.MqttMsgPublishReceived -= this.Client_MqttMsgPublishReceived;
|
|
||||||
this.client.Unsubscribe(new String[] { "#" });
|
|
||||||
this.client.Disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.client = null;
|
|
||||||
|
|
||||||
this.disposedValue = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
~Mqtt() {
|
|
||||||
Dispose(false);
|
|
||||||
}
|
|
||||||
public override void Dispose() {
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
using BlubbFish.Utils;
|
|
||||||
using System;
|
|
||||||
using Telegram.Bot;
|
|
||||||
using Telegram.Bot.Args;
|
|
||||||
using Telegram.Bot.Exceptions;
|
|
||||||
using Telegram.Bot.Types;
|
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
|
||||||
class Telegram {
|
|
||||||
private static Telegram instance;
|
|
||||||
private TelegramBotClient bot;
|
|
||||||
private ChatId chat;
|
|
||||||
|
|
||||||
public delegate void TelegramMessage(Object sender, Message e);
|
|
||||||
|
|
||||||
public event TelegramMessage MessageIncomming;
|
|
||||||
public event TelegramMessage MessageSending;
|
|
||||||
|
|
||||||
private Telegram() {
|
|
||||||
this.bot = new TelegramBotClient(InIReader.GetInstance("settings.ini").GetValue("general", "telegram-key"));
|
|
||||||
this.bot.OnMessage += this.Bot_OnMessage;
|
|
||||||
this.Connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Bot_OnMessage(Object sender, MessageEventArgs e) {
|
|
||||||
this.MessageIncomming?.Invoke(this, e.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Telegram Instance {
|
|
||||||
get {
|
|
||||||
if(instance == null) {
|
|
||||||
instance = new Telegram();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Connect() {
|
|
||||||
this.bot.StartReceiving();
|
|
||||||
this.chat = new ChatId(InIReader.GetInstance("settings.ini").GetValue("general", "chatid"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void Send(String text) {
|
|
||||||
try {
|
|
||||||
Message x = await this.bot.SendTextMessageAsync(this.chat, text);
|
|
||||||
this.MessageSending?.Invoke(this, x);
|
|
||||||
} catch(ApiRequestException e) {
|
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
|
||||||
Console.WriteLine(e.Message+" "+e.ErrorCode+" "+e.Parameters);
|
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,9 +9,10 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>MqttToTelegram</RootNamespace>
|
<RootNamespace>MqttToTelegram</RootNamespace>
|
||||||
<AssemblyName>MqttToTelegram</AssemblyName>
|
<AssemblyName>MqttToTelegram</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@ -32,50 +33,12 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="M2Mqtt.Net, Version=4.3.0.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\M2Mqtt.4.3.0.0\lib\net45\M2Mqtt.Net.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.ComponentModel.Composition" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.IO.Compression" />
|
|
||||||
<Reference Include="System.Numerics" />
|
|
||||||
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
<Reference Include="Telegram.Bot, Version=13.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\Telegram.Bot.13.1.0\lib\netstandard1.1\Telegram.Bot.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="ConditionWorker.cs" />
|
<Compile Include="ConditionWorker.cs" />
|
||||||
<Compile Include="Condition\ACondition.cs" />
|
<Compile Include="Condition\ACondition.cs" />
|
||||||
<Compile Include="Condition\Edge.cs" />
|
<Compile Include="Condition\Edge.cs" />
|
||||||
<Compile Include="Connector\ADataBackend.cs" />
|
|
||||||
<Compile Include="Connector\Mqtt.cs" />
|
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Sensor\ASensor.cs" />
|
|
||||||
<Compile Include="Sensor\Luminanz.cs" />
|
|
||||||
<Compile Include="Sensor\Pir.cs" />
|
|
||||||
<Compile Include="Sensor\Power.cs" />
|
|
||||||
<Compile Include="Sensor\Switch.cs" />
|
|
||||||
<Compile Include="Sensor\Temperatur.cs" />
|
|
||||||
<Compile Include="Connector\Telegram.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
@ -84,12 +47,15 @@
|
|||||||
<None Include="settings.ini.example" />
|
<None Include="settings.ini.example" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Utils\IoT\Utils-IoT.csproj">
|
||||||
|
<Project>{b870e4d5-6806-4a0b-b233-8907eedc5afc}</Project>
|
||||||
|
<Name>Utils-IoT</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
|
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
|
||||||
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
|
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
|
||||||
<Name>Utils</Name>
|
<Name>Utils</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
using System;
|
using System;
|
||||||
using BlubbFish.Utils;
|
using BlubbFish.Utils;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
|
|
||||||
namespace IoTBot {
|
namespace IoTBot {
|
||||||
class Program {
|
class Program {
|
||||||
static void Main(String[] args) {
|
static void Main(String[] args) {
|
||||||
ADataBackend mqtt = ADataBackend.GetInstance(InIReader.GetInstance("settings.ini").GetSection("mqtt"));
|
ADataBackend mqtt = ADataBackend.GetInstance(InIReader.GetInstance("settings.ini").GetSection("mqtt"));
|
||||||
ConditionWorker.GetInstance(mqtt).Run(Connector.Telegram.Instance);
|
ConditionWorker.GetInstance(mqtt).Run(Telegram.Instance);
|
||||||
mqtt.MessageIncomming += Mqtt_MessageIncomming;
|
mqtt.MessageIncomming += Mqtt_MessageIncomming;
|
||||||
mqtt.MessageSending += Mqtt_MessageSending;
|
mqtt.MessageSending += Mqtt_MessageSending;
|
||||||
Connector.Telegram.Instance.MessageIncomming += Telegram_MessageIncomming;
|
Telegram.Instance.MessageIncomming += Telegram_MessageIncomming;
|
||||||
Connector.Telegram.Instance.MessageSending += Telegram_MessageSending;
|
Telegram.Instance.MessageSending += Telegram_MessageSending;
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
System.Threading.Thread.Sleep(100);
|
System.Threading.Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Mqtt_MessageSending(ADataBackend sender, MqttEventArgs e) {
|
private static void Mqtt_MessageSending(Object sender, MqttEventArgs e) {
|
||||||
Console.WriteLine("-> [" + DateTime.Now.ToUniversalTime() + "] MQTT: " + e.Message + " on " + e.Topic);
|
Console.WriteLine("-> [" + DateTime.Now.ToUniversalTime() + "] MQTT: " + e.Message + " on " + e.Topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Telegram_MessageSending(Object sender, global::Telegram.Bot.Types.Message e) {
|
private static void Telegram_MessageSending(Object sender, TelegramEventArgs e) {
|
||||||
Console.WriteLine("-> [" + e.Date.ToUniversalTime() + "] Telegram: " + e.Text + " on " + e.Chat.Id);
|
Console.WriteLine("-> [" + e.Date.ToUniversalTime() + "] Telegram: " + e.Message + " on " + e.UserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Telegram_MessageIncomming(Object sender, global::Telegram.Bot.Types.Message e) {
|
private static void Telegram_MessageIncomming(Object sender, TelegramEventArgs e) {
|
||||||
Console.WriteLine("<- [" + e.Date.ToUniversalTime() + "] Telegram: " + e.Text + " on " + e.Chat.Id);
|
Console.WriteLine("<- [" + e.Date.ToUniversalTime() + "] Telegram: " + e.Message + " on " + e.UserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Mqtt_MessageIncomming(ADataBackend sender, MqttEventArgs e) {
|
private static void Mqtt_MessageIncomming(Object sender, MqttEventArgs e) {
|
||||||
Console.WriteLine("<- [" + DateTime.Now.ToUniversalTime() + "] MQTT: " + e.Message + " on " + e.Topic);
|
Console.WriteLine("<- [" + DateTime.Now.ToUniversalTime() + "] MQTT: " + e.Message + " on " + e.Topic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using IoTBot.Connector;
|
|
||||||
using LitJson;
|
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
|
||||||
class Flex4gridpower : ASensor {
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
public Flex4gridpower(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
|
||||||
this.Datatypes = Types.Float;
|
|
||||||
this.id = settings["id"];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Boolean UpdateValue(MqttEventArgs e) {
|
|
||||||
CultureInfo info = new CultureInfo("de-DE");
|
|
||||||
info.NumberFormat.NumberDecimalSeparator = ".";
|
|
||||||
CultureInfo.DefaultThreadCurrentCulture = info;
|
|
||||||
CultureInfo.DefaultThreadCurrentUICulture = info;
|
|
||||||
System.Threading.Thread.CurrentThread.CurrentCulture = info;
|
|
||||||
System.Threading.Thread.CurrentThread.CurrentUICulture = info;
|
|
||||||
try {
|
|
||||||
JsonData data = JsonMapper.ToObject(e.Message);
|
|
||||||
if(data["id"].ToString() == this.id) {
|
|
||||||
this.GetFloat = Single.Parse(data["power"].ToString());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Exception) {
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using IoTBot.Connector;
|
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
|
||||||
class Pir : ASensor {
|
|
||||||
public Pir(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
|
||||||
this.Datatypes = Types.Bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Boolean UpdateValue(MqttEventArgs e) {
|
|
||||||
this.GetBool = (e.Message.ToLower() == "on") ? true : false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using IoTBot.Connector;
|
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
|
||||||
class Power : ASensor {
|
|
||||||
public Power(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
|
||||||
this.GetBool = true;
|
|
||||||
this.GetFloat = 0.0f;
|
|
||||||
this.GetInt = 0;
|
|
||||||
this.Datatypes = Types.Float;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Boolean UpdateValue(MqttEventArgs e) {
|
|
||||||
this.GetFloat = Single.Parse(e.Message, new CultureInfo("en-US"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using IoTBot.Connector;
|
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
|
||||||
class Switch : ASensor {
|
|
||||||
public Switch(Dictionary<System.String, System.String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
|
||||||
this.Datatypes = Types.Bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Boolean UpdateValue(MqttEventArgs e) {
|
|
||||||
this.GetBool = (e.Message.ToLower() == "on") ? true : false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +1,51 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="M2Mqtt" version="4.3.0.0" targetFramework="net452" />
|
<package id="M2Mqtt" version="4.3.0.0" targetFramework="net452" />
|
||||||
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net452" />
|
<package id="Microsoft.NETCore.Platforms" version="2.0.0" targetFramework="net462" />
|
||||||
|
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net462" />
|
||||||
<package id="NETStandard.Library" version="1.6.1" targetFramework="net452" />
|
<package id="NETStandard.Library" version="1.6.1" targetFramework="net452" />
|
||||||
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
|
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
|
||||||
|
<package id="System.AppContext" version="4.3.0" targetFramework="net462" />
|
||||||
<package id="System.Collections" version="4.3.0" targetFramework="net452" />
|
<package id="System.Collections" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net452" />
|
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net452" />
|
||||||
|
<package id="System.Console" version="4.3.0" targetFramework="net462" />
|
||||||
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net452" />
|
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net452" />
|
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net452" />
|
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net452" requireReinstallation="true" />
|
||||||
<package id="System.Globalization" version="4.3.0" targetFramework="net452" />
|
<package id="System.Globalization" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.IO" version="4.3.0" targetFramework="net452" />
|
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net462" />
|
||||||
<package id="System.IO.Compression" version="4.3.0" targetFramework="net452" />
|
<package id="System.IO" version="4.3.0" targetFramework="net452" requireReinstallation="true" />
|
||||||
|
<package id="System.IO.Compression" version="4.3.0" targetFramework="net452" requireReinstallation="true" />
|
||||||
|
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net462" />
|
||||||
|
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net462" />
|
||||||
|
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net462" />
|
||||||
<package id="System.Linq" version="4.3.0" targetFramework="net452" />
|
<package id="System.Linq" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net452" />
|
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Net.Http" version="4.3.0" targetFramework="net452" />
|
<package id="System.Net.Http" version="4.3.3" targetFramework="net462" />
|
||||||
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net452" />
|
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net452" />
|
||||||
|
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net462" />
|
||||||
<package id="System.ObjectModel" version="4.3.0" targetFramework="net452" />
|
<package id="System.ObjectModel" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Reflection" version="4.3.0" targetFramework="net452" />
|
<package id="System.Reflection" version="4.3.0" targetFramework="net452" requireReinstallation="true" />
|
||||||
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net452" />
|
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net452" />
|
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net452" />
|
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Runtime" version="4.3.0" targetFramework="net452" />
|
<package id="System.Runtime" version="4.3.0" targetFramework="net452" requireReinstallation="true" />
|
||||||
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net452" />
|
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net452" requireReinstallation="true" />
|
||||||
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net452" />
|
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net462" />
|
||||||
|
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net452" requireReinstallation="true" />
|
||||||
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net452" />
|
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net452" />
|
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net452" />
|
||||||
|
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net462" />
|
||||||
|
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net462" />
|
||||||
|
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net462" />
|
||||||
|
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net462" />
|
||||||
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net452" />
|
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net452" />
|
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net452" />
|
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Threading" version="4.3.0" targetFramework="net452" />
|
<package id="System.Threading" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net452" />
|
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net452" />
|
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net452" />
|
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net452" requireReinstallation="true" />
|
||||||
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net452" />
|
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net452" />
|
||||||
<package id="Telegram.Bot" version="13.1.0" targetFramework="net452" />
|
<package id="Telegram.Bot" version="13.2.1" targetFramework="net462" />
|
||||||
</packages>
|
</packages>
|
@ -1,12 +1,14 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 15.0.26403.7
|
VisualStudioVersion = 15.0.26730.16
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dashboard", "Mqtt-Dashboard\Dashboard.csproj", "{16AC0F61-0B60-4A1D-A827-B3BFDBA9AAC7}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dashboard", "Mqtt-Dashboard\Dashboard.csproj", "{16AC0F61-0B60-4A1D-A827-B3BFDBA9AAC7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\Utils\Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\Utils\Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils\IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -21,8 +23,15 @@ Global
|
|||||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {1B2A7AC0-6D12-415F-89CF-9C5AFADDD227}
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||||
</startup>
|
</startup>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
|
||||||
public abstract class ADataBackend {
|
|
||||||
|
|
||||||
public abstract event MqttMessage MessageIncomming;
|
|
||||||
public abstract event MqttMessage MessageSending;
|
|
||||||
public delegate void MqttMessage(ADataBackend sender, MqttEventArgs e);
|
|
||||||
|
|
||||||
public static ADataBackend GetInstance(Dictionary<String, String> dictionary) {
|
|
||||||
String object_sensor = "IoTBot.Connector." + Char.ToUpper(dictionary["type"][0]) + dictionary["type"].Substring(1).ToLower();
|
|
||||||
Type t = null;
|
|
||||||
try {
|
|
||||||
t = Type.GetType(object_sensor, true);
|
|
||||||
} catch (TypeLoadException) {
|
|
||||||
throw new ArgumentException("settings.ini: " + dictionary["type"] + " is not a Connector");
|
|
||||||
}
|
|
||||||
return (ADataBackend)t.GetConstructor(new Type[] { typeof(Dictionary<String, String>) }).Invoke(new Object[] { dictionary });
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void Send(String topic, String data);
|
|
||||||
|
|
||||||
public abstract void Dispose();
|
|
||||||
}
|
|
||||||
public class MqttEventArgs : EventArgs {
|
|
||||||
public MqttEventArgs() : base() { }
|
|
||||||
public MqttEventArgs(String message, String topic) {
|
|
||||||
this.Topic = topic;
|
|
||||||
this.Message = message;
|
|
||||||
this.Date = DateTime.Now;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String Topic { get; private set; }
|
|
||||||
public String Message { get; private set; }
|
|
||||||
public DateTime Date { get; private set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,121 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
|
||||||
class Mosquitto : ADataBackend, IDisposable {
|
|
||||||
private Process p;
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
public override event MqttMessage MessageIncomming;
|
|
||||||
public override event MqttMessage MessageSending;
|
|
||||||
|
|
||||||
public Mosquitto(Dictionary<String, String> mqtt_settings) {
|
|
||||||
this.settings = mqtt_settings;
|
|
||||||
//mosquitto_sub --cafile ca.pem --cert cert.pem --key cert.key -h swb.broker.flex4grid.eu -p 8883 -t "#" -v -d
|
|
||||||
this.message = "";
|
|
||||||
this.p = new Process();
|
|
||||||
this.p.StartInfo.FileName = "mosquitto_sub";
|
|
||||||
String args = "-h " + this.settings["server"]+" ";
|
|
||||||
if(this.settings.ContainsKey("port")) {
|
|
||||||
args += "-p "+ this.settings["port"]+" ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("cafile")) {
|
|
||||||
args += "--cafile " + this.settings["cafile"] + " ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("cert")) {
|
|
||||||
args += "--cert " + this.settings["cert"] + " ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("key")) {
|
|
||||||
args += "--key " + this.settings["key"] + " ";
|
|
||||||
}
|
|
||||||
this.p.StartInfo.Arguments = args+"-t \"#\" -v -d";
|
|
||||||
this.p.StartInfo.CreateNoWindow = true;
|
|
||||||
this.p.StartInfo.UseShellExecute = false;
|
|
||||||
this.p.StartInfo.RedirectStandardOutput = true;
|
|
||||||
this.p.StartInfo.RedirectStandardError = true;
|
|
||||||
this.p.OutputDataReceived += this.P_OutputDataReceived;
|
|
||||||
this.p.ErrorDataReceived += this.P_ErrorDataReceived;
|
|
||||||
this.p.Start();
|
|
||||||
this.p.BeginOutputReadLine();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Send(String topic, String data) {
|
|
||||||
Process send = new Process();
|
|
||||||
send.StartInfo.FileName = "mosquitto_pub";
|
|
||||||
String args = "-h " + this.settings["server"] + " ";
|
|
||||||
if (this.settings.ContainsKey("port")) {
|
|
||||||
args += "-p " + this.settings["port"] + " ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("cafile")) {
|
|
||||||
args += "--cafile " + this.settings["cafile"] + " ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("cert")) {
|
|
||||||
args += "--cert " + this.settings["cert"] + " ";
|
|
||||||
}
|
|
||||||
if (this.settings.ContainsKey("key")) {
|
|
||||||
args += "--key " + this.settings["key"] + " ";
|
|
||||||
}
|
|
||||||
send.StartInfo.Arguments = args + "-m \""+data.Replace("\"","\\\"")+"\" -t \""+topic+"\" -d";
|
|
||||||
send.StartInfo.CreateNoWindow = true;
|
|
||||||
send.StartInfo.UseShellExecute = false;
|
|
||||||
send.StartInfo.RedirectStandardOutput = true;
|
|
||||||
send.StartInfo.RedirectStandardError = true;
|
|
||||||
send.Start();
|
|
||||||
send.WaitForExit();
|
|
||||||
MessageSending?.Invoke(this, new MqttEventArgs(data, topic));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void P_ErrorDataReceived(Object sender, DataReceivedEventArgs e) {
|
|
||||||
if (e.Data != null) {
|
|
||||||
throw new NotImplementedException(e.Data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void P_OutputDataReceived(Object sender, DataReceivedEventArgs e) {
|
|
||||||
if (e.Data != null) {
|
|
||||||
if (e.Data.StartsWith("Client mosqsub")) {
|
|
||||||
if (this.message != "" && this.message.IndexOf(" received PUBLISH ") > 0) {
|
|
||||||
MatchCollection matches = (new Regex("^Client mosqsub[\\|/].*received PUBLISH \\(.*,.*,.*,.*, '(.*)'.*\\)\\)\n[^ ]* (.*)$", RegexOptions.IgnoreCase | RegexOptions.Singleline)).Matches(this.message);
|
|
||||||
String topic = matches[0].Groups[1].Value;
|
|
||||||
String message = matches[0].Groups[2].Value.Trim();
|
|
||||||
this.MessageIncomming?.Invoke(this, new MqttEventArgs(message, topic));
|
|
||||||
}
|
|
||||||
this.message = e.Data + "\n";
|
|
||||||
} else {
|
|
||||||
this.message += e.Data + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IDisposable Support
|
|
||||||
private Boolean disposedValue = false; // Dient zur Erkennung redundanter Aufrufe.
|
|
||||||
private readonly Dictionary<String, String> settings;
|
|
||||||
|
|
||||||
protected virtual void Dispose(Boolean disposing) {
|
|
||||||
if (!this.disposedValue) {
|
|
||||||
if (disposing) {
|
|
||||||
this.p.CancelOutputRead();
|
|
||||||
if (!this.p.HasExited) {
|
|
||||||
this.p.Kill();
|
|
||||||
}
|
|
||||||
this.p.Close();
|
|
||||||
}
|
|
||||||
this.p = null;
|
|
||||||
this.disposedValue = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~Mosquitto() {
|
|
||||||
Dispose(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using uPLibrary.Networking.M2Mqtt;
|
|
||||||
using uPLibrary.Networking.M2Mqtt.Messages;
|
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
|
||||||
class Mqtt : ADataBackend, IDisposable {
|
|
||||||
private MqttClient client;
|
|
||||||
|
|
||||||
public override event MqttMessage MessageIncomming;
|
|
||||||
public override event MqttMessage MessageSending;
|
|
||||||
|
|
||||||
public Mqtt(Dictionary<String, String> settings) {
|
|
||||||
if(settings.ContainsKey("port")) {
|
|
||||||
this.client = new MqttClient(settings["server"], Int32.Parse(settings["port"]), false, null, null, MqttSslProtocols.None);
|
|
||||||
} else {
|
|
||||||
this.client = new MqttClient(settings["server"]);
|
|
||||||
}
|
|
||||||
Connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Connect() {
|
|
||||||
this.client.MqttMsgPublishReceived += this.Client_MqttMsgPublishReceived;
|
|
||||||
this.client.Connect(Guid.NewGuid().ToString());
|
|
||||||
this.client.Subscribe(new String[] { "#" }, new Byte[] { MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE });
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Client_MqttMsgPublishReceived(Object sender, MqttMsgPublishEventArgs e) {
|
|
||||||
this.MessageIncomming?.Invoke(this, new MqttEventArgs(Encoding.UTF8.GetString(e.Message), e.Topic));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Send(String topic, String data) {
|
|
||||||
this.client.Publish(topic, Encoding.UTF8.GetBytes(data));
|
|
||||||
this.MessageSending?.Invoke(this, new MqttEventArgs(data, topic));
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IDisposable Support
|
|
||||||
private Boolean disposedValue = false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected virtual void Dispose(Boolean disposing) {
|
|
||||||
if(!this.disposedValue) {
|
|
||||||
if(disposing) {
|
|
||||||
this.client.MqttMsgPublishReceived -= this.Client_MqttMsgPublishReceived;
|
|
||||||
this.client.Unsubscribe(new String[] { "#" });
|
|
||||||
this.client.Disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.client = null;
|
|
||||||
|
|
||||||
this.disposedValue = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
~Mqtt() {
|
|
||||||
Dispose(false);
|
|
||||||
}
|
|
||||||
public override void Dispose() {
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
using BlubbFish.Utils;
|
|
||||||
using System;
|
|
||||||
using Telegram.Bot;
|
|
||||||
using Telegram.Bot.Args;
|
|
||||||
using Telegram.Bot.Exceptions;
|
|
||||||
using Telegram.Bot.Types;
|
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
|
||||||
class Telegram {
|
|
||||||
private static Telegram instance;
|
|
||||||
private TelegramBotClient bot;
|
|
||||||
private ChatId chat;
|
|
||||||
|
|
||||||
public delegate void TelegramMessage(Object sender, Message e);
|
|
||||||
|
|
||||||
public event TelegramMessage MessageIncomming;
|
|
||||||
public event TelegramMessage MessageSending;
|
|
||||||
|
|
||||||
private Telegram() {
|
|
||||||
this.bot = new TelegramBotClient(InIReader.GetInstance("settings.ini").GetValue("general", "telegram-key"));
|
|
||||||
this.bot.OnMessage += this.Bot_OnMessage;
|
|
||||||
this.Connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Bot_OnMessage(Object sender, MessageEventArgs e) {
|
|
||||||
this.MessageIncomming?.Invoke(this, e.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Telegram Instance {
|
|
||||||
get {
|
|
||||||
if(instance == null) {
|
|
||||||
instance = new Telegram();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Connect() {
|
|
||||||
this.bot.StartReceiving();
|
|
||||||
this.chat = new ChatId(InIReader.GetInstance("settings.ini").GetValue("general", "chatid"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void Send(String text) {
|
|
||||||
try {
|
|
||||||
Message x = await this.bot.SendTextMessageAsync(this.chat, text);
|
|
||||||
this.MessageSending?.Invoke(this, x);
|
|
||||||
} catch(ApiRequestException e) {
|
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
|
||||||
Console.WriteLine(e.Message+" "+e.ErrorCode+" "+e.Parameters);
|
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,7 +8,7 @@
|
|||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>Dashboard</RootNamespace>
|
<RootNamespace>Dashboard</RootNamespace>
|
||||||
<AssemblyName>Dashboard</AssemblyName>
|
<AssemblyName>Dashboard</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<PublishUrl>publish\</PublishUrl>
|
<PublishUrl>publish\</PublishUrl>
|
||||||
@ -26,6 +26,7 @@
|
|||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@ -50,12 +51,6 @@
|
|||||||
<StartupObject />
|
<StartupObject />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="LitJson, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\LitJson.0.9.0\lib\LitJson.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="M2Mqtt.Net, Version=4.3.0.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\M2Mqtt.4.3.0.0\lib\net45\M2Mqtt.Net.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="OxyPlot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=638079a8f0bd61e9, processorArchitecture=MSIL">
|
<Reference Include="OxyPlot, Version=1.0.0.0, Culture=neutral, PublicKeyToken=638079a8f0bd61e9, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\OxyPlot.Core.1.0.0\lib\net45\OxyPlot.dll</HintPath>
|
<HintPath>..\packages\OxyPlot.Core.1.0.0\lib\net45\OxyPlot.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -67,7 +62,6 @@
|
|||||||
<Reference Include="System.Windows.Forms.DataVisualization" />
|
<Reference Include="System.Windows.Forms.DataVisualization" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Deployment" />
|
<Reference Include="System.Deployment" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
@ -76,9 +70,6 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Connector\ADataBackend.cs" />
|
|
||||||
<Compile Include="Connector\Mosquitto.cs" />
|
|
||||||
<Compile Include="Connector\Mqtt.cs" />
|
|
||||||
<Compile Include="Form1.cs">
|
<Compile Include="Form1.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -87,11 +78,6 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Sensor\ASensor.cs" />
|
|
||||||
<Compile Include="Sensor\Flex4GridPower.cs" />
|
|
||||||
<Compile Include="Sensor\Power.cs" />
|
|
||||||
<Compile Include="Sensor\Flex4GridSwitch.cs" />
|
|
||||||
<Compile Include="Sensor\Switch.cs" />
|
|
||||||
<Compile Include="Tracings\ATracings.cs" />
|
<Compile Include="Tracings\ATracings.cs" />
|
||||||
<Compile Include="Tracings\Graph.cs" />
|
<Compile Include="Tracings\Graph.cs" />
|
||||||
<Compile Include="Tracings\Meter.cs" />
|
<Compile Include="Tracings\Meter.cs" />
|
||||||
@ -128,6 +114,10 @@
|
|||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Utils\IoT\Utils-IoT.csproj">
|
||||||
|
<Project>{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}</Project>
|
||||||
|
<Name>Utils-IoT</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
|
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
|
||||||
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
|
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
|
||||||
<Name>Utils</Name>
|
<Name>Utils</Name>
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using BlubbFish.Utils;
|
using BlubbFish.Utils;
|
||||||
using IoTBot.Connector;
|
|
||||||
using IoTBot.Sensor;
|
|
||||||
using Dashboard.Tracings;
|
using Dashboard.Tracings;
|
||||||
|
using BlubbFish.Utils.IoT.Sensor;
|
||||||
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
|
|
||||||
namespace Dashboard {
|
namespace Dashboard {
|
||||||
public partial class Dashboard : Form {
|
public partial class Dashboard : Form {
|
||||||
|
@ -19,7 +19,7 @@ namespace Dashboard.Properties {
|
|||||||
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||||
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||||
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class Resources {
|
internal class Resources {
|
||||||
|
@ -12,7 +12,7 @@ namespace Dashboard.Properties {
|
|||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
@ -1,121 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading;
|
|
||||||
using IoTBot.Connector;
|
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
|
||||||
public abstract class ASensor : IDisposable {
|
|
||||||
protected String topic;
|
|
||||||
protected Int32 pollcount;
|
|
||||||
private Dictionary<String, String> settings;
|
|
||||||
protected ADataBackend backend;
|
|
||||||
private Thread updateThread;
|
|
||||||
private Boolean pollEnabled = false;
|
|
||||||
|
|
||||||
public ASensor(Dictionary<String, String> settings, String name, ADataBackend backend) {
|
|
||||||
this.GetBool = true;
|
|
||||||
this.GetFloat = 0.0f;
|
|
||||||
this.GetInt = 0;
|
|
||||||
this.topic = (settings.Keys.Contains("topic")) ? settings["topic"] : "";
|
|
||||||
this.settings = settings;
|
|
||||||
this.Title = (settings.Keys.Contains("title")) ? settings["title"] : "";
|
|
||||||
this.Name = name;
|
|
||||||
this.backend = backend;
|
|
||||||
this.backend.MessageIncomming += this.IncommingMqttMessage;
|
|
||||||
if (settings.Keys.Contains("polling")) {
|
|
||||||
this.pollEnabled = true;
|
|
||||||
this.Polling = Int32.Parse(settings["polling"]);
|
|
||||||
this.pollcount = this.Polling;
|
|
||||||
this.updateThread = new Thread(this.SensorPolling);
|
|
||||||
this.updateThread.Start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SensorPolling() {
|
|
||||||
while(this.pollEnabled) {
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
this.Poll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void IncommingMqttMessage(Object sender, MqttEventArgs e) {
|
|
||||||
if(Regex.Match(e.Topic, this.topic).Success) {
|
|
||||||
if (this.UpdateValue(e)) {
|
|
||||||
this.Timestamp = DateTime.Now;
|
|
||||||
this.Update?.Invoke(this, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static ASensor GetInstance(ADataBackend backend, Dictionary<String, String> dictionary, String name) {
|
|
||||||
String object_sensor = "IoTBot.Sensor." + Char.ToUpper(dictionary["type"][0]) + dictionary["type"].Substring(1).ToLower();
|
|
||||||
Type t = null;
|
|
||||||
try {
|
|
||||||
t = Type.GetType(object_sensor, true);
|
|
||||||
} catch(TypeLoadException) {
|
|
||||||
throw new ArgumentException("sensor.ini: " + dictionary["type"] + " is not a Sensor");
|
|
||||||
}
|
|
||||||
return (ASensor)t.GetConstructor(new Type[] { typeof(Dictionary<String, String>), typeof(String), typeof(ADataBackend) }).Invoke(new Object[] { dictionary, name, backend });
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Poll() {
|
|
||||||
if(this.pollcount++ >= this.Polling) {
|
|
||||||
this.pollcount = 1;
|
|
||||||
this.backend.Send(this.topic + "/status","");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal virtual void SetBool(Boolean v) {
|
|
||||||
this.backend.Send(this.topic + "/set", v ? "on" : "off");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract Boolean UpdateValue(MqttEventArgs e);
|
|
||||||
|
|
||||||
public Single GetFloat { get; protected set; }
|
|
||||||
public Boolean GetBool { get; protected set; }
|
|
||||||
public Int32 GetInt { get; protected set; }
|
|
||||||
public Types Datatypes { get; protected set; }
|
|
||||||
public DateTime Timestamp { get; protected set; }
|
|
||||||
public Int32 Polling { get; private set; }
|
|
||||||
public String Title { get; protected set; }
|
|
||||||
public String Name { get; internal set; }
|
|
||||||
|
|
||||||
public enum Types {
|
|
||||||
Bool,
|
|
||||||
Int,
|
|
||||||
Float
|
|
||||||
}
|
|
||||||
public delegate void UpdatedValue(ASensor sender, EventArgs e);
|
|
||||||
public event UpdatedValue Update;
|
|
||||||
|
|
||||||
#region IDisposable Support
|
|
||||||
private Boolean disposedValue = false;
|
|
||||||
|
|
||||||
|
|
||||||
protected virtual void Dispose(Boolean disposing) {
|
|
||||||
if(!this.disposedValue) {
|
|
||||||
if(disposing) {
|
|
||||||
this.pollEnabled = false;
|
|
||||||
if (this.updateThread != null && this.updateThread.ThreadState == ThreadState.Running) {
|
|
||||||
this.updateThread.Abort();
|
|
||||||
while (this.updateThread.ThreadState != ThreadState.Aborted) { }
|
|
||||||
}
|
|
||||||
this.backend.MessageIncomming -= this.IncommingMqttMessage;
|
|
||||||
}
|
|
||||||
this.settings = null;
|
|
||||||
this.updateThread = null;
|
|
||||||
this.disposedValue = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
~ASensor() {
|
|
||||||
Dispose(false);
|
|
||||||
}
|
|
||||||
public void Dispose() {
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using IoTBot.Connector;
|
|
||||||
using LitJson;
|
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
|
||||||
class Flex4gridswitch : ASensor {
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
public Flex4gridswitch(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
|
||||||
this.Datatypes = Types.Bool;
|
|
||||||
this.id = settings["id"];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Boolean UpdateValue(MqttEventArgs e) {
|
|
||||||
CultureInfo info = new CultureInfo("de-DE");
|
|
||||||
info.NumberFormat.NumberDecimalSeparator = ".";
|
|
||||||
CultureInfo.DefaultThreadCurrentCulture = info;
|
|
||||||
CultureInfo.DefaultThreadCurrentUICulture = info;
|
|
||||||
System.Threading.Thread.CurrentThread.CurrentCulture = info;
|
|
||||||
System.Threading.Thread.CurrentThread.CurrentUICulture = info;
|
|
||||||
try {
|
|
||||||
JsonData data = JsonMapper.ToObject(e.Message);
|
|
||||||
if (data.Keys.Contains("id") && data["id"].ToString() == this.id) {
|
|
||||||
this.GetBool = data["status"].ToString() == "active" ? true : false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(data.Keys.Contains(this.id)) {
|
|
||||||
this.GetBool = data[this.id].ToString() == "active" ? true : false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Exception) {
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Poll() {
|
|
||||||
if (this.pollcount++ >= this.Polling) {
|
|
||||||
this.pollcount = 1;
|
|
||||||
String hid = Regex.Match(this.topic, "/flex4grid/v1/households/([^/]*)/device/state").Groups[1].Value;
|
|
||||||
this.backend.Send("/flex4grid/v1/households/" + hid + "/devices/state/request", "{\"timestamp\": \"" + DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffff'Z'") + "\"}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void SetBool(Boolean v) {
|
|
||||||
String hid = Regex.Match(this.topic, "/flex4grid/v1/households/([^/]*)/device/state").Groups[1].Value;
|
|
||||||
this.backend.Send("/flex4grid/v1/households/" + hid + "/device/actuate", "{\"command\":\""+(v ? "ON" : "OFF") + "\",\"deviceId\":\""+ this.id + "\",\"timestamp\":\"" + DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffff'Z'") + "\"}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using IoTBot.Connector;
|
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
|
||||||
class Luminanz : ASensor {
|
|
||||||
public Luminanz(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
|
||||||
this.GetBool = true;
|
|
||||||
this.GetFloat = 0.0f;
|
|
||||||
this.GetInt = 0;
|
|
||||||
this.Datatypes = Types.Int;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Boolean UpdateValue(MqttEventArgs e) {
|
|
||||||
this.GetInt = Int32.Parse(e.Message, new CultureInfo("en-US"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using IoTBot.Connector;
|
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
|
||||||
class Temperatur : ASensor {
|
|
||||||
public Temperatur(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
|
||||||
this.GetBool = true;
|
|
||||||
this.GetFloat = 0.0f;
|
|
||||||
this.GetInt = 0;
|
|
||||||
this.Datatypes = Types.Float;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Boolean UpdateValue(MqttEventArgs e) {
|
|
||||||
this.GetFloat = Single.Parse(e.Message, new CultureInfo("en-US"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using IoTBot.Sensor;
|
using BlubbFish.Utils.IoT.Sensor;
|
||||||
|
|
||||||
namespace Dashboard.Tracings {
|
namespace Dashboard.Tracings {
|
||||||
public abstract class ATracings {
|
public abstract class ATracings {
|
||||||
@ -22,8 +22,8 @@ namespace Dashboard.Tracings {
|
|||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void SensorsUpdate(ASensor sender, EventArgs e);
|
protected abstract void SensorsUpdate(Object sender, EventArgs e);
|
||||||
protected abstract void SensorUpdate(ASensor sender, EventArgs e);
|
protected abstract void SensorUpdate(Object sender, EventArgs e);
|
||||||
public abstract Panel GetPanel();
|
public abstract Panel GetPanel();
|
||||||
internal static ATracings GetInstance(String v, Dictionary<String, ASensor> sensorList, Dictionary<String, String> dictionary) {
|
internal static ATracings GetInstance(String v, Dictionary<String, ASensor> sensorList, Dictionary<String, String> dictionary) {
|
||||||
String object_sensor = "Dashboard.Tracings." + Char.ToUpper(v[0]) + v.Substring(1);
|
String object_sensor = "Dashboard.Tracings." + Char.ToUpper(v[0]) + v.Substring(1);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using IoTBot.Sensor;
|
using BlubbFish.Utils.IoT.Sensor;
|
||||||
using OxyPlot;
|
using OxyPlot;
|
||||||
using OxyPlot.Axes;
|
using OxyPlot.Axes;
|
||||||
using OxyPlot.Series;
|
using OxyPlot.Series;
|
||||||
@ -68,14 +68,14 @@ namespace Dashboard.Tracings {
|
|||||||
panel.Size = new System.Drawing.Size(fieldWidth, 200);
|
panel.Size = new System.Drawing.Size(fieldWidth, 200);
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
protected override void SensorUpdate(ASensor sender, EventArgs e) {
|
protected override void SensorUpdate(Object sender, EventArgs e) {
|
||||||
Single v = 0;
|
Single v = 0;
|
||||||
switch (sender.Datatypes) {
|
switch (((ASensor)sender).Datatypes) {
|
||||||
case ASensor.Types.Bool: v = sender.GetBool ? 1 : 0; break;
|
case ASensor.Types.Bool: v = ((ASensor)sender).GetBool ? 1 : 0; break;
|
||||||
case ASensor.Types.Int: v = sender.GetInt; break;
|
case ASensor.Types.Int: v = ((ASensor)sender).GetInt; break;
|
||||||
case ASensor.Types.Float: v = sender.GetFloat; break;
|
case ASensor.Types.Float: v = ((ASensor)sender).GetFloat; break;
|
||||||
}
|
}
|
||||||
this.hist.Enqueue(new Tuple<DateTime, Single>(sender.Timestamp, v));
|
this.hist.Enqueue(new Tuple<DateTime, Single>(((ASensor)sender).Timestamp, v));
|
||||||
if (this.MaximumDrawn < v) {
|
if (this.MaximumDrawn < v) {
|
||||||
this.MaximumDrawn = v;
|
this.MaximumDrawn = v;
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ namespace Dashboard.Tracings {
|
|||||||
this.plot.BeginInvoke((MethodInvoker)delegate {
|
this.plot.BeginInvoke((MethodInvoker)delegate {
|
||||||
this.Model.Axes[1].Maximum = this.MaximumDrawn * 1.1;
|
this.Model.Axes[1].Maximum = this.MaximumDrawn * 1.1;
|
||||||
this.Model.Axes[1].AbsoluteMaximum = this.MaximumDrawn * 1.1;
|
this.Model.Axes[1].AbsoluteMaximum = this.MaximumDrawn * 1.1;
|
||||||
this.Model.Axes[0].AbsoluteMaximum = DateTimeAxis.ToDouble(sender.Timestamp);
|
this.Model.Axes[0].AbsoluteMaximum = DateTimeAxis.ToDouble(((ASensor)sender).Timestamp);
|
||||||
((LineSeries)this.Model.Series[0]).Points.Clear();
|
((LineSeries)this.Model.Series[0]).Points.Clear();
|
||||||
try {
|
try {
|
||||||
foreach(Tuple<DateTime, Single> temp in this.hist) {
|
foreach(Tuple<DateTime, Single> temp in this.hist) {
|
||||||
@ -98,26 +98,26 @@ namespace Dashboard.Tracings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SensorsUpdate(ASensor sender, EventArgs e) {
|
protected override void SensorsUpdate(Object sender, EventArgs e) {
|
||||||
Single v = 0;
|
Single v = 0;
|
||||||
if (!this.hists.ContainsKey(sender.Name)) {
|
if (!this.hists.ContainsKey(((ASensor)sender).Name)) {
|
||||||
this.hists.Add(sender.Name, new Queue<Tuple<DateTime, Single>>());
|
this.hists.Add(((ASensor)sender).Name, new Queue<Tuple<DateTime, Single>>());
|
||||||
this.hists_last.Add(sender.Name, 0);
|
this.hists_last.Add(((ASensor)sender).Name, 0);
|
||||||
}
|
}
|
||||||
switch (sender.Datatypes) {
|
switch (((ASensor)sender).Datatypes) {
|
||||||
case ASensor.Types.Bool:
|
case ASensor.Types.Bool:
|
||||||
v = sender.GetBool ? 1 : 0;
|
v = ((ASensor)sender).GetBool ? 1 : 0;
|
||||||
break;
|
break;
|
||||||
case ASensor.Types.Int:
|
case ASensor.Types.Int:
|
||||||
v = sender.GetInt;
|
v = ((ASensor)sender).GetInt;
|
||||||
break;
|
break;
|
||||||
case ASensor.Types.Float:
|
case ASensor.Types.Float:
|
||||||
v = sender.GetFloat;
|
v = ((ASensor)sender).GetFloat;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.hists_last[sender.Name] = v;
|
this.hists_last[((ASensor)sender).Name] = v;
|
||||||
foreach (KeyValuePair<String, Queue<Tuple<DateTime, Single>>> item in this.hists) {
|
foreach (KeyValuePair<String, Queue<Tuple<DateTime, Single>>> item in this.hists) {
|
||||||
item.Value.Enqueue(new Tuple<DateTime, Single>(sender.Timestamp, this.hists_last[item.Key]));
|
item.Value.Enqueue(new Tuple<DateTime, Single>(((ASensor)sender).Timestamp, this.hists_last[item.Key]));
|
||||||
if (this.MaximumDrawn < this.hists_last[item.Key]) {
|
if (this.MaximumDrawn < this.hists_last[item.Key]) {
|
||||||
this.MaximumDrawn = this.hists_last[item.Key];
|
this.MaximumDrawn = this.hists_last[item.Key];
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ namespace Dashboard.Tracings {
|
|||||||
try {
|
try {
|
||||||
this.Model.Axes[1].Maximum = this.MaximumDrawn * 1.1;
|
this.Model.Axes[1].Maximum = this.MaximumDrawn * 1.1;
|
||||||
this.Model.Axes[1].AbsoluteMaximum = this.MaximumDrawn * 1.1;
|
this.Model.Axes[1].AbsoluteMaximum = this.MaximumDrawn * 1.1;
|
||||||
this.Model.Axes[0].AbsoluteMaximum = DateTimeAxis.ToDouble(sender.Timestamp);
|
this.Model.Axes[0].AbsoluteMaximum = DateTimeAxis.ToDouble(((ASensor)sender).Timestamp);
|
||||||
((LineSeries)item).Points.Clear();
|
((LineSeries)item).Points.Clear();
|
||||||
foreach (Tuple<DateTime, Single> temp in this.hists[item.TrackerKey]) {
|
foreach (Tuple<DateTime, Single> temp in this.hists[item.TrackerKey]) {
|
||||||
((LineSeries)item).Points.Add(new DataPoint(DateTimeAxis.ToDouble(temp.Item1), temp.Item2));
|
((LineSeries)item).Points.Add(new DataPoint(DateTimeAxis.ToDouble(temp.Item1), temp.Item2));
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using IoTBot.Sensor;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using BlubbFish.Utils.IoT.Sensor;
|
||||||
|
|
||||||
namespace Dashboard.Tracings {
|
namespace Dashboard.Tracings {
|
||||||
class Meter : ATracings {
|
class Meter : ATracings {
|
||||||
@ -45,16 +45,16 @@ namespace Dashboard.Tracings {
|
|||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SensorsUpdate(ASensor sender, EventArgs e) {
|
protected override void SensorsUpdate(Object sender, EventArgs e) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SensorUpdate(ASensor sender, EventArgs e) {
|
protected override void SensorUpdate(Object sender, EventArgs e) {
|
||||||
String value = "";
|
String value = "";
|
||||||
switch(sender.Datatypes) {
|
switch(((ASensor)sender).Datatypes) {
|
||||||
case ASensor.Types.Bool: this.DisplayAverage.Enqueue((sender.GetBool) ? 1 : 0); value = sender.GetBool.ToString(new CultureInfo("de-DE")); break;
|
case ASensor.Types.Bool: this.DisplayAverage.Enqueue((((ASensor)sender).GetBool) ? 1 : 0); value = ((ASensor)sender).GetBool.ToString(new CultureInfo("de-DE")); break;
|
||||||
case ASensor.Types.Int: this.DisplayAverage.Enqueue(sender.GetInt); value = sender.GetInt.ToString(); break;
|
case ASensor.Types.Int: this.DisplayAverage.Enqueue(((ASensor)sender).GetInt); value = ((ASensor)sender).GetInt.ToString(); break;
|
||||||
case ASensor.Types.Float: this.DisplayAverage.Enqueue(sender.GetFloat); value = sender.GetFloat.ToString(new CultureInfo("de-DE")); break;
|
case ASensor.Types.Float: this.DisplayAverage.Enqueue(((ASensor)sender).GetFloat); value = ((ASensor)sender).GetFloat.ToString(new CultureInfo("de-DE")); break;
|
||||||
}
|
}
|
||||||
if(this.DisplayAverage.Count > this.DisplayItems) {
|
if(this.DisplayAverage.Count > this.DisplayItems) {
|
||||||
this.DisplayAverage.Dequeue();
|
this.DisplayAverage.Dequeue();
|
||||||
|
@ -3,26 +3,26 @@ using System.Collections.Generic;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using IoTBot.Sensor;
|
using BlubbFish.Utils.IoT.Sensor;
|
||||||
|
|
||||||
namespace Dashboard.Tracings {
|
namespace Dashboard.Tracings {
|
||||||
class Powermeter : Meter {
|
class Powermeter : Meter {
|
||||||
public Powermeter(ASensor sensor, Dictionary<String, String> settings) : base(sensor, settings) {
|
public Powermeter(ASensor sensor, Dictionary<String, String> settings) : base(sensor, settings) {
|
||||||
}
|
}
|
||||||
protected override void SensorUpdate(ASensor sender, EventArgs e) {
|
protected override void SensorUpdate(Object sender, EventArgs e) {
|
||||||
String value = "";
|
String value = "";
|
||||||
switch (sender.Datatypes) {
|
switch (((ASensor)sender).Datatypes) {
|
||||||
case ASensor.Types.Bool:
|
case ASensor.Types.Bool:
|
||||||
this.DisplayAverage.Enqueue((sender.GetBool) ? 1 : 0);
|
this.DisplayAverage.Enqueue((((ASensor)sender).GetBool) ? 1 : 0);
|
||||||
value = sender.GetBool.ToString(new CultureInfo("de-DE"));
|
value = ((ASensor)sender).GetBool.ToString(new CultureInfo("de-DE"));
|
||||||
break;
|
break;
|
||||||
case ASensor.Types.Int:
|
case ASensor.Types.Int:
|
||||||
this.DisplayAverage.Enqueue(sender.GetInt);
|
this.DisplayAverage.Enqueue(((ASensor)sender).GetInt);
|
||||||
value = sender.GetInt.ToString();
|
value = ((ASensor)sender).GetInt.ToString();
|
||||||
break;
|
break;
|
||||||
case ASensor.Types.Float:
|
case ASensor.Types.Float:
|
||||||
this.DisplayAverage.Enqueue(sender.GetFloat);
|
this.DisplayAverage.Enqueue(((ASensor)sender).GetFloat);
|
||||||
value = sender.GetFloat.ToString(new CultureInfo("de-DE"));
|
value = ((ASensor)sender).GetFloat.ToString(new CultureInfo("de-DE"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.DisplayAverage.Count > this.DisplayItems) {
|
if (this.DisplayAverage.Count > this.DisplayItems) {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Sensor;
|
||||||
using IoTBot.Sensor;
|
|
||||||
|
|
||||||
namespace Dashboard.Tracings {
|
namespace Dashboard.Tracings {
|
||||||
class Switcher : ATracings {
|
class Switcher : ATracings {
|
||||||
@ -65,19 +63,19 @@ namespace Dashboard.Tracings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SensorUpdate(ASensor sender, EventArgs e) {
|
protected override void SensorUpdate(Object sender, EventArgs e) {
|
||||||
this.label.BeginInvoke((MethodInvoker)delegate {
|
this.label.BeginInvoke((MethodInvoker)delegate {
|
||||||
this.label.Text = sender.GetBool?"Eingeschaltet":"Ausgeschaltet";
|
this.label.Text = ((ASensor)sender).GetBool?"Eingeschaltet":"Ausgeschaltet";
|
||||||
});
|
});
|
||||||
this.button1.BeginInvoke((MethodInvoker)delegate {
|
this.button1.BeginInvoke((MethodInvoker)delegate {
|
||||||
this.button1.Enabled = !sender.GetBool;
|
this.button1.Enabled = !((ASensor)sender).GetBool;
|
||||||
});
|
});
|
||||||
this.button2.BeginInvoke((MethodInvoker)delegate {
|
this.button2.BeginInvoke((MethodInvoker)delegate {
|
||||||
this.button2.Enabled = sender.GetBool;
|
this.button2.Enabled = ((ASensor)sender).GetBool;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SensorsUpdate(ASensor sender, EventArgs e) {
|
protected override void SensorsUpdate(Object sender, EventArgs e) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
BIN
Mqtt-Dashboard/Mqtt-Dashboard/bin/Release/Newtonsoft.Json.dll
Normal file
BIN
Mqtt-Dashboard/Mqtt-Dashboard/bin/Release/Newtonsoft.Json.dll
Normal file
Binary file not shown.
BIN
Mqtt-Dashboard/Mqtt-Dashboard/bin/Release/Telegram.Bot.dll
Normal file
BIN
Mqtt-Dashboard/Mqtt-Dashboard/bin/Release/Telegram.Bot.dll
Normal file
Binary file not shown.
BIN
Mqtt-Dashboard/Mqtt-Dashboard/bin/Release/Utils-IoT.dll
Normal file
BIN
Mqtt-Dashboard/Mqtt-Dashboard/bin/Release/Utils-IoT.dll
Normal file
Binary file not shown.
Binary file not shown.
@ -1,12 +1,14 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 14.0.25420.1
|
VisualStudioVersion = 15.0.26730.16
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mqtt-SWB-Dashboard", "Mqtt-SWB-Dashboard\Mqtt-SWB-Dashboard.csproj", "{324B2308-7C6E-4F16-8764-7C2F8C342B6A}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mqtt-SWB-Dashboard", "Mqtt-SWB-Dashboard\Mqtt-SWB-Dashboard.csproj", "{324B2308-7C6E-4F16-8764-7C2F8C342B6A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\Utils\Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\Utils\Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils\IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -21,6 +23,10 @@ Global
|
|||||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||||
</startup>
|
</startup>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
|
||||||
public abstract class ADataBackend {
|
|
||||||
|
|
||||||
public abstract event MqttMessage MessageIncomming;
|
|
||||||
public abstract event MqttMessage MessageSending;
|
|
||||||
public delegate void MqttMessage(ADataBackend sender, MqttEventArgs e);
|
|
||||||
|
|
||||||
public static ADataBackend GetInstance(Dictionary<String, String> dictionary) {
|
|
||||||
String object_sensor = "IoTBot.Connector." + Char.ToUpper(dictionary["type"][0]) + dictionary["type"].Substring(1).ToLower();
|
|
||||||
Type t = null;
|
|
||||||
try {
|
|
||||||
t = Type.GetType(object_sensor, true);
|
|
||||||
} catch (TypeLoadException) {
|
|
||||||
throw new ArgumentException("settings.ini: " + dictionary["type"] + " is not a Connector");
|
|
||||||
}
|
|
||||||
return (ADataBackend)t.GetConstructor(new Type[] { typeof(Dictionary<String, String>) }).Invoke(new Object[] { dictionary });
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void Send(String topic, String data);
|
|
||||||
|
|
||||||
public abstract void Dispose();
|
|
||||||
}
|
|
||||||
public class MqttEventArgs : EventArgs {
|
|
||||||
public MqttEventArgs() : base() { }
|
|
||||||
public MqttEventArgs(String message, String topic) {
|
|
||||||
this.Topic = topic;
|
|
||||||
this.Message = message;
|
|
||||||
this.Date = DateTime.Now;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String Topic { get; private set; }
|
|
||||||
public String Message { get; private set; }
|
|
||||||
public DateTime Date { get; private set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,8 @@
|
|||||||
using BlubbFish.Utils;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils;
|
||||||
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
|
|
||||||
namespace Mqtt_SWB_Dashboard {
|
namespace Mqtt_SWB_Dashboard {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -8,11 +8,12 @@
|
|||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>Mqtt_SWB_Dashboard</RootNamespace>
|
<RootNamespace>Mqtt_SWB_Dashboard</RootNamespace>
|
||||||
<AssemblyName>Mqtt-SWB-Dashboard</AssemblyName>
|
<AssemblyName>Mqtt-SWB-Dashboard</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@ -63,8 +64,6 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Compile Include="Connector\ADataBackend.cs" />
|
|
||||||
<Compile Include="Connector\Mosquitto.cs" />
|
|
||||||
<Compile Include="Helper\Device.cs" />
|
<Compile Include="Helper\Device.cs" />
|
||||||
<Compile Include="Helper\Household.cs" />
|
<Compile Include="Helper\Household.cs" />
|
||||||
<Compile Include="Helper\Raspi.cs" />
|
<Compile Include="Helper\Raspi.cs" />
|
||||||
@ -115,6 +114,10 @@
|
|||||||
<Folder Include="Properties\DataSources\" />
|
<Folder Include="Properties\DataSources\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Utils\IoT\Utils-IoT.csproj">
|
||||||
|
<Project>{b870e4d5-6806-4a0b-b233-8907eedc5afc}</Project>
|
||||||
|
<Name>Utils-IoT</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
|
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
|
||||||
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
|
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
|
||||||
<Name>Utils</Name>
|
<Name>Utils</Name>
|
||||||
|
@ -1,62 +1,63 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// Dieser Code wurde von einem Tool generiert.
|
// Dieser Code wurde von einem Tool generiert.
|
||||||
// Laufzeitversion: 4.0.30319.42000
|
// Laufzeitversion:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
|
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||||
// der Code neu generiert wird.
|
// der Code erneut generiert wird.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Mqtt_SWB_Dashboard.Properties {
|
namespace Mqtt_SWB_Dashboard.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
|
||||||
/// </summary>
|
|
||||||
// Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
|
|
||||||
// über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
|
||||||
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
|
||||||
// mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
internal class Resources {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal Resources() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||||
get {
|
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||||
if ((resourceMan == null)) {
|
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mqtt_SWB_Dashboard.Properties.Resources", typeof(Resources).Assembly);
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||||
resourceMan = temp;
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mqtt_SWB_Dashboard.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||||
|
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
|
||||||
/// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// Dieser Code wurde von einem Tool generiert.
|
||||||
// Runtime Version:4.0.30319.42000
|
// Laufzeitversion:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||||
// the code is regenerated.
|
// der Code erneut generiert wird.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Mqtt_SWB_Dashboard.Properties {
|
namespace Mqtt_SWB_Dashboard.Properties {
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
public static Settings Default {
|
public static Settings Default {
|
||||||
get {
|
get {
|
||||||
return defaultInstance;
|
return defaultInstance;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
using Mqtt_SWB_Dashboard.Helper;
|
using Mqtt_SWB_Dashboard.Helper;
|
||||||
|
|
||||||
|
31
Utils/IoT.sln
Normal file
31
Utils/IoT.sln
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 15
|
||||||
|
VisualStudioVersion = 15.0.26730.16
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "Utils\Utils.csproj", "{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FAC8CE64-BF13-4ECE-8097-AEB5DD060098}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {844D8F60-6DE1-4C48-976D-F71450E9707B}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
@ -1,15 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
namespace BlubbFish.Utils.IoT.Connector {
|
||||||
public abstract class ADataBackend {
|
public abstract class ADataBackend {
|
||||||
|
|
||||||
public abstract event MqttMessage MessageIncomming;
|
public abstract event MqttMessage MessageIncomming;
|
||||||
public abstract event MqttMessage MessageSending;
|
public abstract event MqttMessage MessageSending;
|
||||||
public delegate void MqttMessage(ADataBackend sender, MqttEventArgs e);
|
public delegate void MqttMessage(Object sender, MqttEventArgs e);
|
||||||
|
|
||||||
public static ADataBackend GetInstance(Dictionary<String, String> dictionary) {
|
public static ADataBackend GetInstance(Dictionary<String, String> dictionary) {
|
||||||
String object_sensor = "IoTBot.Connector." + Char.ToUpper(dictionary["type"][0]) + dictionary["type"].Substring(1).ToLower();
|
String object_sensor = "BlubbFish.Utils.IoT.Connector." + Char.ToUpper(dictionary["type"][0]) + dictionary["type"].Substring(1).ToLower();
|
||||||
Type t = null;
|
Type t = null;
|
||||||
try {
|
try {
|
||||||
t = Type.GetType(object_sensor, true);
|
t = Type.GetType(object_sensor, true);
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
namespace BlubbFish.Utils.IoT.Connector {
|
||||||
class Mosquitto : ADataBackend, IDisposable {
|
class Mosquitto : ADataBackend, IDisposable {
|
||||||
private Process p;
|
private Process p;
|
||||||
private String message;
|
private String message;
|
@ -4,7 +4,7 @@ using System.Text;
|
|||||||
using uPLibrary.Networking.M2Mqtt;
|
using uPLibrary.Networking.M2Mqtt;
|
||||||
using uPLibrary.Networking.M2Mqtt.Messages;
|
using uPLibrary.Networking.M2Mqtt.Messages;
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
namespace BlubbFish.Utils.IoT.Connector {
|
||||||
class Mqtt : ADataBackend, IDisposable {
|
class Mqtt : ADataBackend, IDisposable {
|
||||||
private MqttClient client;
|
private MqttClient client;
|
||||||
|
|
@ -1,17 +1,16 @@
|
|||||||
using BlubbFish.Utils;
|
using System;
|
||||||
using System;
|
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Args;
|
using Telegram.Bot.Args;
|
||||||
using Telegram.Bot.Exceptions;
|
using Telegram.Bot.Exceptions;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
|
|
||||||
namespace IoTBot.Connector {
|
namespace BlubbFish.Utils.IoT.Connector {
|
||||||
class Telegram {
|
public class Telegram {
|
||||||
private static Telegram instance;
|
private static Telegram instance;
|
||||||
private TelegramBotClient bot;
|
private TelegramBotClient bot;
|
||||||
private ChatId chat;
|
private ChatId chat;
|
||||||
|
|
||||||
public delegate void TelegramMessage(Object sender, Message e);
|
public delegate void TelegramMessage(Object sender, TelegramEventArgs e);
|
||||||
|
|
||||||
public event TelegramMessage MessageIncomming;
|
public event TelegramMessage MessageIncomming;
|
||||||
public event TelegramMessage MessageSending;
|
public event TelegramMessage MessageSending;
|
||||||
@ -23,7 +22,7 @@ namespace IoTBot.Connector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Bot_OnMessage(Object sender, MessageEventArgs e) {
|
private void Bot_OnMessage(Object sender, MessageEventArgs e) {
|
||||||
this.MessageIncomming?.Invoke(this, e.Message);
|
this.MessageIncomming?.Invoke(this, new TelegramEventArgs(e.Message.Text, e.Message.Chat.Id, e.Message.Date));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Telegram Instance {
|
public static Telegram Instance {
|
||||||
@ -43,7 +42,7 @@ namespace IoTBot.Connector {
|
|||||||
public async void Send(String text) {
|
public async void Send(String text) {
|
||||||
try {
|
try {
|
||||||
Message x = await this.bot.SendTextMessageAsync(this.chat, text);
|
Message x = await this.bot.SendTextMessageAsync(this.chat, text);
|
||||||
this.MessageSending?.Invoke(this, x);
|
this.MessageSending?.Invoke(this, new TelegramEventArgs(x.Text, x.Chat.Id, x.Date));
|
||||||
} catch(ApiRequestException e) {
|
} catch(ApiRequestException e) {
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
Console.WriteLine(e.Message+" "+e.ErrorCode+" "+e.Parameters);
|
Console.WriteLine(e.Message+" "+e.ErrorCode+" "+e.Parameters);
|
||||||
@ -51,4 +50,16 @@ namespace IoTBot.Connector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public class TelegramEventArgs : EventArgs {
|
||||||
|
public TelegramEventArgs() : base() { }
|
||||||
|
public TelegramEventArgs(String message, Int64 UserId, DateTime date) {
|
||||||
|
this.UserId = UserId;
|
||||||
|
this.Message = message;
|
||||||
|
this.Date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Int64 UserId { get; private set; }
|
||||||
|
public String Message { get; private set; }
|
||||||
|
public DateTime Date { get; private set; }
|
||||||
|
}
|
||||||
}
|
}
|
36
Utils/IoT/Properties/AssemblyInfo.cs
Normal file
36
Utils/IoT/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||||
|
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||||
|
// die einer Assembly zugeordnet sind.
|
||||||
|
[assembly: AssemblyTitle("IoT")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("IoT")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
||||||
|
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
|
||||||
|
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||||
|
[assembly: Guid("b870e4d5-6806-4a0b-b233-8907eedc5afc")]
|
||||||
|
|
||||||
|
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||||
|
//
|
||||||
|
// Hauptversion
|
||||||
|
// Nebenversion
|
||||||
|
// Buildnummer
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||||
|
// indem Sie "*" wie unten gezeigt eingeben:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@ -3,9 +3,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
namespace BlubbFish.Utils.IoT.Sensor {
|
||||||
public abstract class ASensor : IDisposable {
|
public abstract class ASensor : IDisposable {
|
||||||
protected String topic;
|
protected String topic;
|
||||||
protected Int32 pollcount;
|
protected Int32 pollcount;
|
||||||
@ -49,8 +49,8 @@ namespace IoTBot.Sensor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ASensor GetInstance(ADataBackend backend, Dictionary<String, String> dictionary, String name) {
|
public static ASensor GetInstance(ADataBackend backend, Dictionary<String, String> dictionary, String name) {
|
||||||
String object_sensor = "IoTBot.Sensor." + Char.ToUpper(dictionary["type"][0]) + dictionary["type"].Substring(1).ToLower();
|
String object_sensor = "BlubbFish.Utils.IoT.Sensor." + Char.ToUpper(dictionary["type"][0]) + dictionary["type"].Substring(1).ToLower();
|
||||||
Type t = null;
|
Type t = null;
|
||||||
try {
|
try {
|
||||||
t = Type.GetType(object_sensor, true);
|
t = Type.GetType(object_sensor, true);
|
||||||
@ -67,7 +67,7 @@ namespace IoTBot.Sensor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal virtual void SetBool(Boolean v) {
|
public virtual void SetBool(Boolean v) {
|
||||||
this.backend.Send(this.topic + "/set", v ? "on" : "off");
|
this.backend.Send(this.topic + "/set", v ? "on" : "off");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ namespace IoTBot.Sensor {
|
|||||||
Int,
|
Int,
|
||||||
Float
|
Float
|
||||||
}
|
}
|
||||||
public delegate void UpdatedValue(ASensor sender, EventArgs e);
|
public delegate void UpdatedValue(Object sender, EventArgs e);
|
||||||
public event UpdatedValue Update;
|
public event UpdatedValue Update;
|
||||||
|
|
||||||
#region IDisposable Support
|
#region IDisposable Support
|
@ -2,10 +2,10 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
namespace BlubbFish.Utils.IoT.Sensor {
|
||||||
class Flex4gridswitch : ASensor {
|
class Flex4gridswitch : ASensor {
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ namespace IoTBot.Sensor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void SetBool(Boolean v) {
|
public override void SetBool(Boolean v) {
|
||||||
String hid = Regex.Match(this.topic, "/flex4grid/v1/households/([^/]*)/device/state").Groups[1].Value;
|
String hid = Regex.Match(this.topic, "/flex4grid/v1/households/([^/]*)/device/state").Groups[1].Value;
|
||||||
this.backend.Send("/flex4grid/v1/households/" + hid + "/device/actuate", "{\"command\":\""+(v ? "ON" : "OFF") + "\",\"deviceId\":\""+ this.id + "\",\"timestamp\":\"" + DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffff'Z'") + "\"}");
|
this.backend.Send("/flex4grid/v1/households/" + hid + "/device/actuate", "{\"command\":\""+(v ? "ON" : "OFF") + "\",\"deviceId\":\""+ this.id + "\",\"timestamp\":\"" + DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffff'Z'") + "\"}");
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
namespace BlubbFish.Utils.IoT.Sensor {
|
||||||
class Flex4gridpower : ASensor {
|
class Flex4gridpower : ASensor {
|
||||||
private String id;
|
private String id;
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
namespace BlubbFish.Utils.IoT.Sensor {
|
||||||
class Luminanz : ASensor {
|
class Luminanz : ASensor {
|
||||||
public Luminanz(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
public Luminanz(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
||||||
this.GetBool = true;
|
this.GetBool = true;
|
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
namespace BlubbFish.Utils.IoT.Sensor {
|
||||||
class Pir : ASensor {
|
class Pir : ASensor {
|
||||||
public Pir(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
public Pir(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
||||||
this.Datatypes = Types.Bool;
|
this.Datatypes = Types.Bool;
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
namespace BlubbFish.Utils.IoT.Sensor {
|
||||||
class Power : ASensor {
|
class Power : ASensor {
|
||||||
public Power(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
public Power(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
||||||
this.GetBool = true;
|
this.GetBool = true;
|
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
namespace BlubbFish.Utils.IoT.Sensor {
|
||||||
class Switch : ASensor {
|
class Switch : ASensor {
|
||||||
public Switch(Dictionary<System.String, System.String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
public Switch(Dictionary<System.String, System.String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
||||||
this.Datatypes = Types.Bool;
|
this.Datatypes = Types.Bool;
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using IoTBot.Connector;
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
|
|
||||||
namespace IoTBot.Sensor {
|
namespace BlubbFish.Utils.IoT.Sensor {
|
||||||
class Temperatur : ASensor {
|
class Temperatur : ASensor {
|
||||||
public Temperatur(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
public Temperatur(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
|
||||||
this.GetBool = true;
|
this.GetBool = true;
|
136
Utils/IoT/Utils-IoT.csproj
Normal file
136
Utils/IoT/Utils-IoT.csproj
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>BlubbFish.Utils.IoT</RootNamespace>
|
||||||
|
<AssemblyName>Utils-IoT</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="LitJson, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\LitJson.0.9.0\lib\LitJson.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="M2Mqtt.Net, Version=4.3.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\M2Mqtt.4.3.0.0\lib\net45\M2Mqtt.Net.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ComponentModel.Composition" />
|
||||||
|
<Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Globalization.Calendars, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.Compression.FileSystem" />
|
||||||
|
<Reference Include="System.IO.Compression.ZipFile, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Sockets, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Numerics" />
|
||||||
|
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Telegram.Bot, Version=13.2.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\IoT-Bot\packages\Telegram.Bot.13.2.1\lib\netstandard1.1\Telegram.Bot.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Connector\ADataBackend.cs" />
|
||||||
|
<Compile Include="Connector\Mosquitto.cs" />
|
||||||
|
<Compile Include="Connector\Mqtt.cs" />
|
||||||
|
<Compile Include="Connector\Telegram.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Sensor\ASensor.cs" />
|
||||||
|
<Compile Include="Sensor\Flex4GridPower.cs" />
|
||||||
|
<Compile Include="Sensor\Flex4GridSwitch.cs" />
|
||||||
|
<Compile Include="Sensor\Luminanz.cs" />
|
||||||
|
<Compile Include="Sensor\Pir.cs" />
|
||||||
|
<Compile Include="Sensor\Power.cs" />
|
||||||
|
<Compile Include="Sensor\Switch.cs" />
|
||||||
|
<Compile Include="Sensor\Temperatur.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Utils\Utils.csproj">
|
||||||
|
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
|
||||||
|
<Name>Utils</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
15
Utils/IoT/app.config
Normal file
15
Utils/IoT/app.config
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /></startup></configuration>
|
BIN
Utils/IoT/bin/Release/Utils-IoT.dll
Normal file
BIN
Utils/IoT/bin/Release/Utils-IoT.dll
Normal file
Binary file not shown.
53
Utils/IoT/packages.config
Normal file
53
Utils/IoT/packages.config
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="LitJson" version="0.9.0" targetFramework="net462" />
|
||||||
|
<package id="M2Mqtt" version="4.3.0.0" targetFramework="net461" />
|
||||||
|
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net461" />
|
||||||
|
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="NETStandard.Library" version="1.6.1" targetFramework="net461" />
|
||||||
|
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" />
|
||||||
|
<package id="System.AppContext" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Collections" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Console" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Globalization" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.IO" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.IO.Compression" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Linq" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Net.Http" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.ObjectModel" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Reflection" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Runtime" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Threading" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net461" />
|
||||||
|
<package id="Telegram.Bot" version="13.2.1" targetFramework="net461" />
|
||||||
|
</packages>
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user