diff --git a/BosmonMqtt/BosMonPluginClass.cs b/BosmonMqtt/BosMonPluginClass.cs
index 089f293..d9e28f5 100644
--- a/BosmonMqtt/BosMonPluginClass.cs
+++ b/BosmonMqtt/BosMonPluginClass.cs
@@ -21,7 +21,7 @@ namespace BlubbFish.BosmonMqtt {
Int32 IBosMonPlugin.PluginVersion {
get {
- return 4;
+ return 5;
}
}
diff --git a/BosmonMqtt/BosmonMqtt.csproj b/BosmonMqtt/BosmonMqtt.csproj
index 8e1de56..8626dcc 100644
--- a/BosmonMqtt/BosmonMqtt.csproj
+++ b/BosmonMqtt/BosmonMqtt.csproj
@@ -27,7 +27,7 @@
pdbonly
true
bin\Release\
- TRACE;MF_FRAMEWORK_VERSION_V4_2
+ TRACE;COMPACT_FRAMEWORK
prompt
4
x86
@@ -205,12 +205,18 @@
lib\M2Mqtt\Utility\QueueExtension.cs
+
+
+ True
+ True
+ Resources.resx
+
Form
@@ -225,6 +231,10 @@
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
ActionDialog.cs
@@ -232,7 +242,9 @@
Config.cs
-
+
+
+
copy "$(TargetPath)" "D:\Programme\BosMon_dev\plugins\$(TargetFileName)"
diff --git a/BosmonMqtt/Controller/MqttActionProvider.cs b/BosmonMqtt/Controller/MqttActionProvider.cs
index 8dee904..aaac3b4 100644
--- a/BosmonMqtt/Controller/MqttActionProvider.cs
+++ b/BosmonMqtt/Controller/MqttActionProvider.cs
@@ -1,8 +1,6 @@
using System;
using System.Drawing;
using System.Windows.Forms;
-using BlubbFish.BosmonMqtt.Models;
-using BlubbFish.BosmonMqtt.Views;
using BosMon.Prefs;
using TelegramsEvents;
using TelegramsEvents.Actions;
@@ -10,11 +8,9 @@ using TelegramsEvents.Prefs;
namespace BlubbFish.BosmonMqtt.Controller {
internal class MqttActionProvider : IActionProvider {
- private TelegramsEventsPlugin plugin;
- //private TelegramsEventConfig eventconfig;
-
- public MqttActionProvider(MqttEventProcessor mqtteventprocessor) {
+ public MqttActionProvider(MqttEventProcessor mqttEventProcessor) {
+ this.MqttEventProcessor = mqttEventProcessor;
}
public String Name {
@@ -31,7 +27,7 @@ namespace BlubbFish.BosmonMqtt.Controller {
public Image Image {
get {
- return new Bitmap(16, 16, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
+ return Properties.Resources.ActionProviderIcon;
}
}
@@ -41,75 +37,22 @@ namespace BlubbFish.BosmonMqtt.Controller {
}
}
+ public MqttEventProcessor MqttEventProcessor { get; }
+
public IActionSettings CreateAction(IAlarmSettings alarmSettings) {
- return new MqttActionSettings(this, new BosMonConfiguration().Storage);
+ return new MqttActionSettings(this);
}
public IActionSettings CreateAction(IAlarmSettings alarmSettings, IBosMonConfigurationStorage storage) {
- System.Windows.Forms.MessageBox.Show("test");
- throw new System.NotImplementedException();
+ return new MqttActionSettings(this, storage);
}
- public void Dispose() {
- //throw new System.NotImplementedException();
- }
+ public void Dispose() { }
public DialogResult EditAction(IActionSettings item) {
return item.EditAction();
}
- public void Init(IBosMonConfigurationStorage storage, TelegramsEventsPlugin plugin) {
- this.plugin = plugin;
- //this.eventconfig = new TelegramsEventConfig(storage);
- //plugin
- }
- }
-
-
-
-
- class MqttActionSettings : IActionSettings {
- private readonly MqttActionProvider mqttActionProvider;
- private TelegramsEventConfig eventconfig;
-
- public MqttActionSettings(MqttActionProvider mqttActionProvider, IBosMonConfigurationStorage storage) {
- this.mqttActionProvider = mqttActionProvider;
- this.Enabled = true;
- this.Storage = storage;
- }
-
- public Boolean Enabled { get; set; }
-
- public String Name { get { return this.eventconfig.Title; } }
-
- public String Description { get { return this.eventconfig.Desc; } }
-
- public IActionProvider ActionProvider { get { return this.mqttActionProvider; } }
-
- public Int32 Id { get { return 456548; } }
-
- public IBosMonConfigurationStorage Storage {
- get {
- return this.eventconfig.PluginStorage;
- }
- set {
- this.eventconfig = new TelegramsEventConfig(value);
- }
- }
-
-
- public Object Clone() {
- throw new System.NotImplementedException();
- }
-
- public DialogResult EditAction() {
- ActionDialog a = new ActionDialog(this.eventconfig);
- a.LoadSettings();
- return a.ShowDialog();
- }
-
- public void ExecuteAction(System.Int32 id, System.String description, AlarmEventArgs args) {
- throw new System.NotImplementedException();
- }
+ public void Init(IBosMonConfigurationStorage storage, TelegramsEventsPlugin plugin) { }
}
}
\ No newline at end of file
diff --git a/BosmonMqtt/Controller/MqttActionSettings.cs b/BosmonMqtt/Controller/MqttActionSettings.cs
new file mode 100644
index 0000000..6445025
--- /dev/null
+++ b/BosmonMqtt/Controller/MqttActionSettings.cs
@@ -0,0 +1,77 @@
+using System;
+using System.Windows.Forms;
+using BlubbFish.BosmonMqtt.Models;
+using BlubbFish.BosmonMqtt.Views;
+using BosMon.Prefs;
+using TelegramsEvents;
+using TelegramsEvents.Actions;
+using TelegramsEvents.Prefs;
+
+namespace BlubbFish.BosmonMqtt.Controller {
+ class MqttActionSettings : IActionSettings {
+ private readonly MqttActionProvider mqttActionProvider;
+
+ public MqttActionSettings(MqttActionProvider mqttActionProvider) {
+ this.mqttActionProvider = mqttActionProvider;
+ this.Eventconfig = new TelegramsEventConfig(this.ActionProvider.ActionId) {
+ Enabled = true
+ };
+ }
+
+ public MqttActionSettings(MqttActionProvider mqttActionProvider, IBosMonConfigurationStorage storage) {
+ this.mqttActionProvider = mqttActionProvider;
+ this.Eventconfig = new TelegramsEventConfig(storage);
+ }
+
+ public Boolean Enabled {
+ get {
+ return this.Eventconfig.Enabled;
+ }
+ set {
+ this.Eventconfig.Enabled = value;
+ }
+ }
+
+ public String Name { get { return this.Eventconfig.Title; } }
+
+ public String Description { get { return this.Eventconfig.Desc; } }
+
+ public IActionProvider ActionProvider { get { return this.mqttActionProvider; } }
+
+ public Int32 Id { get { return this.ActionProvider.ActionId; } }
+
+ public TelegramsEventConfig Eventconfig { get; set; }
+
+ public IBosMonConfigurationStorage Storage {
+ get {
+ return this.Eventconfig.PluginStorage;
+ }
+ set {
+ this.Eventconfig.PluginStorage = value;
+ }
+ }
+
+
+ public Object Clone() {
+ return new MqttActionSettings(this.mqttActionProvider) {
+ Eventconfig = new TelegramsEventConfig(this.ActionProvider.ActionId) {
+ Desc = this.Eventconfig.Desc,
+ Enabled = this.Eventconfig.Enabled,
+ Message = this.Eventconfig.Message,
+ Title = this.Eventconfig.Title,
+ Topic = this.Eventconfig.Topic
+ }
+ };
+ }
+
+ public DialogResult EditAction() {
+ ActionDialog a = new ActionDialog(this.Eventconfig);
+ a.LoadSettings();
+ return a.ShowDialog();
+ }
+
+ public void ExecuteAction(Int32 id, String description, AlarmEventArgs args) {
+ this.mqttActionProvider.MqttEventProcessor.Send(this.Eventconfig.Topic, this.Eventconfig.Message);
+ }
+ }
+}
diff --git a/BosmonMqtt/Controller/MqttEventProcessor.cs b/BosmonMqtt/Controller/MqttEventProcessor.cs
index 0a360ee..e9aaa2a 100644
--- a/BosmonMqtt/Controller/MqttEventProcessor.cs
+++ b/BosmonMqtt/Controller/MqttEventProcessor.cs
@@ -153,13 +153,19 @@ namespace BlubbFish.BosmonMqtt.Controller {
text = JsonMapper.ToJson(z);
topic = this.pluginconfig.Topic + "zveidmf/" + z.Address;
}
- this.client.Publish(topic, Encoding.UTF8.GetBytes(text));
+ this.Send(topic, text);
}
}
- } catch (Exception) { }
+ } catch { }
}
}
+ internal void Send(String topic, String text) {
+ try {
+ this.client.Publish(topic, Encoding.UTF8.GetBytes(text));
+ } catch { }
+ }
+
private Boolean FilterMatch(Telegram t) {
if (t.Type == PocsagTelegram.TYPE_POCSAG) {
return this.FilterMatchType(this.pfilter, t);
diff --git a/BosmonMqtt/Models/TelegramsEventConfig.cs b/BosmonMqtt/Models/TelegramsEventConfig.cs
index f593e26..599f021 100644
--- a/BosmonMqtt/Models/TelegramsEventConfig.cs
+++ b/BosmonMqtt/Models/TelegramsEventConfig.cs
@@ -4,74 +4,113 @@ using System.Text;
namespace BlubbFish.BosmonMqtt.Models {
internal class TelegramsEventConfig : BosMonConfiguration, IBosMonConfigurationTemplate {
- private String _title;
- private String _message;
- private String _topic;
- private String _desc;
+ private Boolean hasStorage = false;
+ private String title;
+ private String message;
+ private String topic;
+ private Boolean enabled;
+ private String desc;
+ private Int32 actionId;
public delegate void Change(Object sender, EventArgs e);
public event Change ConfigChanged;
public TelegramsEventConfig(IBosMonConfigurationStorage storage) : base(storage) {
- this.PluginStorage = storage;
+ this.hasStorage = true;
+ this.ReadConfiguration();
+ }
+
+ public TelegramsEventConfig(Int32 actionId) {
+ this.actionId = actionId;
}
#region öffentliche Eigenschaften
- public IBosMonConfigurationStorage PluginStorage { get; private set; }
+ public IBosMonConfigurationStorage PluginStorage {
+ get {
+ if (this.hasStorage) {
+ return this.Storage;
+ } else {
+ return null;
+ }
+ }
+ set {
+ this.Storage = value;
+ if(!this.hasStorage && this.Storage != null) {
+ this.hasStorage = true;
+ this.WriteConfiguration();
+ }
+ }
+ }
public String Title {
get {
- return this._title;
+ return this.title;
}
set {
- this._title = value;
+ this.title = value;
WriteConfiguration();
}
}
public String Message {
get {
- return this._message;
+ return this.message;
}
set {
- this._message = value;
+ this.message = value;
WriteConfiguration();
}
}
public String Topic {
get {
- return this._topic;
+ return this.topic;
}
set {
- this._topic = value;
+ this.topic = value;
WriteConfiguration();
}
}
public String Desc {
get {
- return this._desc;
+ return this.desc;
}
set {
- this._desc = value;
+ this.desc = value;
+ WriteConfiguration();
+ }
+ }
+ public Boolean Enabled {
+ get {
+ return this.enabled;
+ }
+ set {
+ this.enabled = value;
WriteConfiguration();
}
}
-
#endregion
#region IBosMonConfigurationTemplate Config-Variablen
public override void ReadConfiguration() {
- base.ReadConfiguration();
- this._title = this.Storage.ReadString("title", "");
- this._desc = this.Storage.ReadString("desc", "");
- this._message = this.Storage.ReadString("message", "");
- this._topic = this.Storage.ReadString("topic", "");
+ if (this.hasStorage) {
+ base.ReadConfiguration();
+ this.title = this.Storage.ReadString("title", "");
+ this.desc = this.Storage.ReadString("desc", "");
+ this.message = this.Storage.ReadString("message", "");
+ this.topic = this.Storage.ReadString("topic", "");
+ this.enabled = this.Storage.ReadBoolean("enabled", true);
+ this.actionId = this.Storage.ReadInteger("actionId");
+ }
}
public override void WriteConfiguration() {
- this.Storage.Write("title", this._title);
- this.Storage.Write("desc", this._desc);
- this.Storage.Write("message", this._message);
- this.Storage.Write("topic", this._topic);
- base.WriteConfiguration();
+ if (this.hasStorage) {
+ this.Storage.Write("title", this.title);
+ this.Storage.Write("desc", this.desc);
+ this.Storage.Write("message", this.message);
+ this.Storage.Write("topic", this.topic);
+ this.Storage.Write("actionId", this.actionId);
+ this.Storage.Write("enabled", this.enabled);
+ base.WriteConfiguration();
+ }
}
#endregion
@@ -89,7 +128,21 @@ namespace BlubbFish.BosmonMqtt.Models {
}
}
-
+ public override TKeyVal[] IntVariables {
+ get {
+ return Merge(new TKeyVal[] {
+ new TKeyVal("actionId", 12345)
+ }, base.IntVariables);
+ }
+ }
+
+ public override TKeyVal[] BoolVariables {
+ get {
+ return Merge(new TKeyVal[] {
+ new TKeyVal("enabled", true)
+ }, base.BoolVariables);
+ }
+ }
public void Saved() {
this.ConfigChanged?.Invoke(this, new EventArgs());
diff --git a/BosmonMqtt/Properties/AssemblyInfo.cs b/BosmonMqtt/Properties/AssemblyInfo.cs
index 8033e64..54803ad 100644
--- a/BosmonMqtt/Properties/AssemblyInfo.cs
+++ b/BosmonMqtt/Properties/AssemblyInfo.cs
@@ -11,7 +11,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BosmonMqtt")]
-[assembly: AssemblyCopyright("Copyright © 2018")]
+[assembly: AssemblyCopyright("Copyright © 2018 - 08.10.2018")]
[assembly: AssemblyTrademark("BlubbFish")]
[assembly: AssemblyCulture("")]
@@ -33,7 +33,7 @@ using System.Runtime.InteropServices;
// 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.3.0.0")]
-[assembly: AssemblyFileVersion("1.3.0.0")]
+[assembly: AssemblyVersion("1.4.0")]
+[assembly: AssemblyFileVersion("1.4.0")]
[assembly: NeutralResourcesLanguage("de")]
diff --git a/BosmonMqtt/Properties/Resources.Designer.cs b/BosmonMqtt/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..a78bc33
--- /dev/null
+++ b/BosmonMqtt/Properties/Resources.Designer.cs
@@ -0,0 +1,73 @@
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.42000
+//
+// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
+// der Code erneut generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace BlubbFish.BosmonMqtt.Properties {
+ using System;
+
+
+ ///
+ /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
+ ///
+ // Diese Klasse wurde von der StronglyTypedResourceBuilder 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
+ // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.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() {
+ }
+
+ ///
+ /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
+ ///
+ [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("BlubbFish.BosmonMqtt.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
+ /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap ActionProviderIcon {
+ get {
+ object obj = ResourceManager.GetObject("ActionProviderIcon", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/BosmonMqtt/Properties/Resources.resx b/BosmonMqtt/Properties/Resources.resx
new file mode 100644
index 0000000..94b1e9b
--- /dev/null
+++ b/BosmonMqtt/Properties/Resources.resx
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ ..\Resources\mqtt.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/BosmonMqtt/Resources/mqtt.png b/BosmonMqtt/Resources/mqtt.png
new file mode 100644
index 0000000..1530b96
Binary files /dev/null and b/BosmonMqtt/Resources/mqtt.png differ
diff --git a/BosmonMqtt/Views/ActionDialog.cs b/BosmonMqtt/Views/ActionDialog.cs
index ec82483..eaac16b 100644
--- a/BosmonMqtt/Views/ActionDialog.cs
+++ b/BosmonMqtt/Views/ActionDialog.cs
@@ -1,7 +1,6 @@
using System;
using System.Windows.Forms;
using BlubbFish.BosmonMqtt.Models;
-using BosMon.Utils;
namespace BlubbFish.BosmonMqtt.Views {
internal partial class ActionDialog : Form {
diff --git a/BosmonMqtt/bin/Release/BosmonMqtt.dll b/BosmonMqtt/bin/Release/BosmonMqtt.dll
index c13c750..d298aff 100644
Binary files a/BosmonMqtt/bin/Release/BosmonMqtt.dll and b/BosmonMqtt/bin/Release/BosmonMqtt.dll differ