From 9596c46a2e69cb7949e5dde2bcafd44521741d10 Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Thu, 14 Feb 2019 21:33:49 +0100 Subject: [PATCH] Update project dependencys fixing tiny stuff so that is compatible to the last version add .gitignore --- .gitignore | 3 + ConnectorDataMosquitto.sln | 68 ++++++----- .../ConnectorDataMosquitto.csproj | 106 +++++++++--------- ConnectorDataMosquitto/Mosquitto.cs | 24 ++-- 4 files changed, 108 insertions(+), 93 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..93879ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.vs +/ConnectorDataMosquitto/obj +/ConnectorDataMosquitto/bin diff --git a/ConnectorDataMosquitto.sln b/ConnectorDataMosquitto.sln index f5328c4..21a8094 100644 --- a/ConnectorDataMosquitto.sln +++ b/ConnectorDataMosquitto.sln @@ -1,31 +1,37 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.136 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorDataMosquitto", "ConnectorDataMosquitto\ConnectorDataMosquitto.csproj", "{39235FAD-BA9D-4B51-82FC-6969967BEAE9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils-IoT\Utils-IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.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 - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {07F7B20A-51A7-4AB2-B202-8DDDF1397EFA} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorDataMosquitto", "ConnectorDataMosquitto\ConnectorDataMosquitto.csproj", "{39235FAD-BA9D-4B51-82FC-6969967BEAE9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils-IoT\Utils-IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "litjson_4.7.1", "..\..\Librarys\litjson\litjson\litjson_4.7.1.csproj", "{91A14CD2-2940-4500-8193-56D37EDDDBAA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39235FAD-BA9D-4B51-82FC-6969967BEAE9}.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 + {91A14CD2-2940-4500-8193-56D37EDDDBAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {91A14CD2-2940-4500-8193-56D37EDDDBAA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {91A14CD2-2940-4500-8193-56D37EDDDBAA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {91A14CD2-2940-4500-8193-56D37EDDDBAA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {07F7B20A-51A7-4AB2-B202-8DDDF1397EFA} + EndGlobalSection +EndGlobal diff --git a/ConnectorDataMosquitto/ConnectorDataMosquitto.csproj b/ConnectorDataMosquitto/ConnectorDataMosquitto.csproj index 90b5ce8..0fba269 100644 --- a/ConnectorDataMosquitto/ConnectorDataMosquitto.csproj +++ b/ConnectorDataMosquitto/ConnectorDataMosquitto.csproj @@ -1,54 +1,54 @@ - - - - - Debug - AnyCPU - {39235FAD-BA9D-4B51-82FC-6969967BEAE9} - Library - Properties - BlubbFish.Utils.IoT.Connector.Data - ConnectorDataMosquitto - v4.7.1 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - {b870e4d5-6806-4a0b-b233-8907eedc5afc} - Utils-IoT - - - + + + + + Debug + AnyCPU + {39235FAD-BA9D-4B51-82FC-6969967BEAE9} + Library + Properties + BlubbFish.Utils.IoT.Connector.Data + ConnectorDataMosquitto + v4.7.1 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + {b870e4d5-6806-4a0b-b233-8907eedc5afc} + Utils-IoT + + + \ No newline at end of file diff --git a/ConnectorDataMosquitto/Mosquitto.cs b/ConnectorDataMosquitto/Mosquitto.cs index 9b460f3..37cd17c 100644 --- a/ConnectorDataMosquitto/Mosquitto.cs +++ b/ConnectorDataMosquitto/Mosquitto.cs @@ -2,17 +2,14 @@ using System.Collections.Generic; using System.Diagnostics; using System.Text.RegularExpressions; - +using BlubbFish.Utils.IoT.Events; + namespace BlubbFish.Utils.IoT.Connector.Data { public class Mosquitto : ADataBackend, IDisposable { private Process p; private String message; - public override event MqttMessage MessageIncomming; - public override event MqttMessage MessageSending; - - public Mosquitto(Dictionary mqtt_settings) { - this.settings = mqtt_settings; + public Mosquitto(Dictionary settings) : base(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(); @@ -69,7 +66,7 @@ namespace BlubbFish.Utils.IoT.Connector.Data { send.StartInfo.RedirectStandardError = true; send.Start(); send.WaitForExit(); - MessageSending?.Invoke(this, new MqttEventArgs(data, topic)); + this.NotifyClientSending(new DataEvent(data, topic, DateTime.Now)); } private void P_ErrorDataReceived(Object sender, DataReceivedEventArgs e) { @@ -85,7 +82,7 @@ namespace BlubbFish.Utils.IoT.Connector.Data { 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.NotifyClientIncomming(new DataEvent(message, topic, DateTime.Now)); } this.message = e.Data + "\n"; } else { @@ -94,9 +91,18 @@ namespace BlubbFish.Utils.IoT.Connector.Data { } } + public override Boolean IsConnected { + get { + if (!this.p.HasExited) { + return true; + } else { + return false; + } + } + } + #region IDisposable Support private Boolean disposedValue = false; // Dient zur Erkennung redundanter Aufrufe. - private readonly Dictionary settings; protected virtual void Dispose(Boolean disposing) { if (!this.disposedValue) {