[NF] v1.1.2 Now complete Emulation of F4G Node
[NF] Possibility to attach internal cron events
This commit is contained in:
parent
74027d705d
commit
5fa97ea82b
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using BlubbFish.IoT.Zway;
|
using BlubbFish.IoT.Zway;
|
||||||
using BlubbFish.Utils;
|
using BlubbFish.Utils;
|
||||||
|
|
||||||
@ -16,5 +17,12 @@ namespace ZwayBot {
|
|||||||
public abstract event ModulEvent Update;
|
public abstract event ModulEvent Update;
|
||||||
|
|
||||||
public abstract void Dispose();
|
public abstract void Dispose();
|
||||||
|
public virtual void Interconnect(Dictionary<String, AModul> moduls) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void SetInterconnection(String param, Action hook) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ namespace ZwayBot.Moduls {
|
|||||||
internal class CronJob : AModul, IDisposable {
|
internal class CronJob : AModul, IDisposable {
|
||||||
private DateTime crontime;
|
private DateTime crontime;
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
|
private List<Tuple<String, Action>> internalCron = new List<Tuple<String, Action>>();
|
||||||
|
|
||||||
public override event ModulEvent Update;
|
public override event ModulEvent Update;
|
||||||
|
|
||||||
@ -35,10 +36,15 @@ namespace ZwayBot.Moduls {
|
|||||||
if(this.crontime.Minute != DateTime.Now.Minute) {
|
if(this.crontime.Minute != DateTime.Now.Minute) {
|
||||||
this.crontime = DateTime.Now;
|
this.crontime = DateTime.Now;
|
||||||
foreach (String item in this.ini.GetSections()) {
|
foreach (String item in this.ini.GetSections()) {
|
||||||
if(ParseCronString(this.ini.GetValue(item, "cron"))) {
|
if(this.ParseCronString(this.ini.GetValue(item, "cron"))) {
|
||||||
this.SetValues(this.ini.GetValue(item, "set"));
|
this.SetValues(this.ini.GetValue(item, "set"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach (Tuple<String, Action> item in this.internalCron) {
|
||||||
|
if(this.ParseCronString(item.Item1)) {
|
||||||
|
item.Item2?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
@ -156,6 +162,10 @@ namespace ZwayBot.Moduls {
|
|||||||
return ret.ContainsKey(Int32.Parse(date));
|
return ret.ContainsKey(Int32.Parse(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SetInterconnection(String cron, Action hook) {
|
||||||
|
this.internalCron.Add(new Tuple<String, Action>(cron, hook));
|
||||||
|
}
|
||||||
|
|
||||||
#region IDisposable Support
|
#region IDisposable Support
|
||||||
private Boolean disposedValue = false;
|
private Boolean disposedValue = false;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
using BlubbFish.IoT.Zway;
|
using BlubbFish.IoT.Zway;
|
||||||
using BlubbFish.IoT.Zway.Devices;
|
using BlubbFish.IoT.Zway.Devices;
|
||||||
using BlubbFish.IoT.Zway.Devices.CommandClasses;
|
using BlubbFish.IoT.Zway.Devices.CommandClasses;
|
||||||
@ -13,6 +14,7 @@ namespace ZwayBot.Moduls {
|
|||||||
class Flex4Grid : AModul, IDisposable {
|
class Flex4Grid : AModul, IDisposable {
|
||||||
private ADataBackend mqtt;
|
private ADataBackend mqtt;
|
||||||
private String household = "";
|
private String household = "";
|
||||||
|
private Object requestalivelock = new Object();
|
||||||
|
|
||||||
public override event ModulEvent Update;
|
public override event ModulEvent Update;
|
||||||
|
|
||||||
@ -114,6 +116,25 @@ namespace ZwayBot.Moduls {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RequestAlive() {
|
||||||
|
lock (this.requestalivelock) {
|
||||||
|
HttpWebRequest request = WebRequest.CreateHttp(this.ini.GetValue("f4g", "ping"));
|
||||||
|
try {
|
||||||
|
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {}
|
||||||
|
} catch(Exception) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Interconnect(Dictionary<String, AModul> moduls) {
|
||||||
|
if (this.ini.GetValue("f4g", "ping") != null) {
|
||||||
|
foreach (KeyValuePair<String, AModul> item in moduls) {
|
||||||
|
if (item.Value is CronJob) {
|
||||||
|
item.Value.SetInterconnection("10,40 * * * *", this.RequestAlive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region IDisposable Support
|
#region IDisposable Support
|
||||||
private Boolean disposedValue = false;
|
private Boolean disposedValue = false;
|
||||||
|
|
||||||
@ -134,6 +155,8 @@ namespace ZwayBot.Moduls {
|
|||||||
Dispose(true);
|
Dispose(true);
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,18 @@ namespace ZwayBot {
|
|||||||
this.zw = new ZwayController(InIReader.GetInstance("settings.ini").GetSection("zway"), names, false);
|
this.zw = new ZwayController(InIReader.GetInstance("settings.ini").GetSection("zway"), names, false);
|
||||||
this.zw.Update += this.ZwayDataUpate;
|
this.zw.Update += this.ZwayDataUpate;
|
||||||
this.ModulLoader();
|
this.ModulLoader();
|
||||||
|
this.ModulInterconnect();
|
||||||
this.ModulEvents();
|
this.ModulEvents();
|
||||||
this.WaitForShutdown();
|
this.WaitForShutdown();
|
||||||
this.ModulDispose();
|
this.ModulDispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ModulInterconnect() {
|
||||||
|
foreach (KeyValuePair<String, AModul> item in this.moduls) {
|
||||||
|
item.Value.Interconnect(this.moduls);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void WaitForShutdown() {
|
private void WaitForShutdown() {
|
||||||
while (true) {
|
while (true) {
|
||||||
System.Threading.Thread.Sleep(100);
|
System.Threading.Thread.Sleep(100);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Reflection;
|
using System.Resources;
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@ -6,12 +7,12 @@ using System.Runtime.InteropServices;
|
|||||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||||
// die einer Assembly zugeordnet sind.
|
// die einer Assembly zugeordnet sind.
|
||||||
[assembly: AssemblyTitle("Zway-Bot")]
|
[assembly: AssemblyTitle("Zway-Bot")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("Is a Bot for Zwave Devices")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("BlubbFish")]
|
||||||
[assembly: AssemblyProduct("Zway-Bot")]
|
[assembly: AssemblyProduct("Zway-Bot")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("BlubbFish")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
||||||
@ -32,7 +33,8 @@ 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,
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.1.2.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.1.2.0")]
|
||||||
|
[assembly: NeutralResourcesLanguage("de-DE")]
|
||||||
|
|
||||||
// “Internet Of Things” icon by By Michael Wohlwend, US, from thenounproject.com.
|
// “Internet Of Things” icon by By Michael Wohlwend, US, from thenounproject.com.
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user