[NF] Filter nun auch für FMS und ZVEI
This commit is contained in:
parent
01140f1700
commit
fcdf4fd964
@ -17,7 +17,9 @@ namespace BlubbFish.BosmonMqtt {
|
|||||||
private IBosMonHost pluginhost;
|
private IBosMonHost pluginhost;
|
||||||
private MqttClient client;
|
private MqttClient client;
|
||||||
private FilterList filter;
|
private FilterList filter;
|
||||||
private List<PocsagFilterItem> pfilter = new List<PocsagFilterItem>();
|
private List<FilterItem> pfilter = new List<FilterItem>();
|
||||||
|
private List<FilterItem> ffilter = new List<FilterItem>();
|
||||||
|
private List<FilterItem> zfilter = new List<FilterItem>();
|
||||||
Thread connectionWatcher;
|
Thread connectionWatcher;
|
||||||
|
|
||||||
public MqttEventProcessor(PluginConfiguration pluginconfiguration, IBosMonHost pluginHost) {
|
public MqttEventProcessor(PluginConfiguration pluginconfiguration, IBosMonHost pluginHost) {
|
||||||
@ -102,6 +104,12 @@ namespace BlubbFish.BosmonMqtt {
|
|||||||
if (item.GetType() == typeof(PocsagFilterItem)) {
|
if (item.GetType() == typeof(PocsagFilterItem)) {
|
||||||
this.pfilter.Add(item as PocsagFilterItem);
|
this.pfilter.Add(item as PocsagFilterItem);
|
||||||
}
|
}
|
||||||
|
if (item.GetType() == typeof(FmsFilterItem)) {
|
||||||
|
this.ffilter.Add(item as FmsFilterItem);
|
||||||
|
}
|
||||||
|
if (item.GetType() == typeof(ZveiFilterItem)) {
|
||||||
|
this.zfilter.Add(item as ZveiFilterItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.Log("Connect", "Erfolgreich verbunden.");
|
this.Log("Connect", "Erfolgreich verbunden.");
|
||||||
}
|
}
|
||||||
@ -109,6 +117,8 @@ namespace BlubbFish.BosmonMqtt {
|
|||||||
|
|
||||||
private void Disconnect() {
|
private void Disconnect() {
|
||||||
this.pfilter.Clear();
|
this.pfilter.Clear();
|
||||||
|
this.ffilter.Clear();
|
||||||
|
this.zfilter.Clear();
|
||||||
if (this.client != null && this.client.IsConnected) {
|
if (this.client != null && this.client.IsConnected) {
|
||||||
this.client.Unsubscribe(new String[] { this.pluginconfig.Topic });
|
this.client.Unsubscribe(new String[] { this.pluginconfig.Topic });
|
||||||
this.client.Disconnect();
|
this.client.Disconnect();
|
||||||
@ -122,20 +132,52 @@ namespace BlubbFish.BosmonMqtt {
|
|||||||
try {
|
try {
|
||||||
Telegram t = e.Telegram as Telegram;
|
Telegram t = e.Telegram as Telegram;
|
||||||
if (this.client != null && this.client.IsConnected && this.filter != null) {
|
if (this.client != null && this.client.IsConnected && this.filter != null) {
|
||||||
|
if (this.FilterMatch(t)) {
|
||||||
if (t.Type == PocsagTelegram.TYPE_POCSAG) {
|
if (t.Type == PocsagTelegram.TYPE_POCSAG) {
|
||||||
PocsagTelegram p = t as PocsagTelegram;
|
PocsagTelegram p = t as PocsagTelegram;
|
||||||
foreach (PocsagFilterItem item in this.pfilter) {
|
this.client.Publish(this.pluginconfig.Topic + "pocsag/" + p.Address + p.Func, Encoding.UTF8.GetBytes(p.Msg));
|
||||||
if ((item.IsMatching(p) && item.Negated)) {
|
} else if(t.Type == FmsTelegram.TYPE_FMS) {
|
||||||
return;
|
FmsTelegram f = t as FmsTelegram;
|
||||||
|
this.client.Publish(this.pluginconfig.Topic + "fms/" + f.Address, Encoding.UTF8.GetBytes(f.Bos + "\t" + f.Fzg + "\t" + f.Info + "\t" + f.Lkz + "\t" + f.Msg + "\t" + f.Okz + "\t" + f.Status));
|
||||||
|
} else if(t.Type == ZveiTelegram.TYPE_ZVEI) {
|
||||||
|
ZveiTelegram z = t as ZveiTelegram;
|
||||||
|
this.client.Publish(this.pluginconfig.Topic + "zvei/" + z.Address, Encoding.UTF8.GetBytes(""));
|
||||||
|
} else if (t.Type == ZveiDtmfTelegram.TYPE_ZVEIDTMF) {
|
||||||
|
ZveiDtmfTelegram z = t as ZveiDtmfTelegram;
|
||||||
|
this.client.Publish(this.pluginconfig.Topic + "zveidmf/" + z.Address, Encoding.UTF8.GetBytes(z.DtmfTone));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.client.Publish(this.pluginconfig.Topic + p.Address + p.Func, Encoding.UTF8.GetBytes(p.Msg));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception) { }
|
} catch (Exception) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Boolean FilterMatch(Telegram t) {
|
||||||
|
if (t.Type == PocsagTelegram.TYPE_POCSAG) {
|
||||||
|
return this.FilterMatchType(this.pfilter, t);
|
||||||
|
} else if(t.Type == FmsTelegram.TYPE_FMS) {
|
||||||
|
return this.FilterMatchType(this.ffilter, t);
|
||||||
|
} else {
|
||||||
|
return this.FilterMatchType(this.zfilter, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Boolean FilterMatchType(List<FilterItem> filter, Telegram t) {
|
||||||
|
Boolean negatedInList = false;
|
||||||
|
foreach (FilterItem item in filter) {
|
||||||
|
if (item.IsMatching(t) && item.Negated) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(item.IsMatching(t) && !item.Negated) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(item.Negated) {
|
||||||
|
negatedInList = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return negatedInList;
|
||||||
|
}
|
||||||
|
|
||||||
private void Log(String method, String text) {
|
private void Log(String method, String text) {
|
||||||
BosMonLog.Logger.WriteLine(LogSeverity.Info, "BosmonMqtt.MqttEventProcessor", method, text);
|
BosMonLog.Logger.WriteLine(LogSeverity.Info, "BosmonMqtt.MqttEventProcessor", method, text);
|
||||||
this.pluginhost.AddMessage(DateTime.Now.Ticks, MessageType.Message, "BosmonMqtt " + text);
|
this.pluginhost.AddMessage(DateTime.Now.Ticks, MessageType.Message, "BosmonMqtt " + text);
|
||||||
|
@ -21,7 +21,7 @@ namespace BlubbFish.BosmonMqtt {
|
|||||||
|
|
||||||
Int32 IBosMonPlugin.PluginVersion {
|
Int32 IBosMonPlugin.PluginVersion {
|
||||||
get {
|
get {
|
||||||
return 1;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ using System.Runtime.InteropServices;
|
|||||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||||
// indem Sie "*" wie unten gezeigt eingeben:
|
// indem Sie "*" wie unten gezeigt eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.2.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.2.0.0")]
|
||||||
[assembly: NeutralResourcesLanguage("de")]
|
[assembly: NeutralResourcesLanguage("de")]
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user