Compare commits

...
3 Commits
Author SHA1 Message Date
BlubbFish c96b2393d3 [BF] v.1.2.1.1 Next try to emulate F4G Events 2017-12-09 12:33:15 +00:00
BlubbFish 5fa97ea82b [NF] v1.1.2 Now complete Emulation of F4G Node
[NF] Possibility to attach internal cron events
2017-12-08 19:30:29 +00:00
BlubbFish 74027d705d [NF] Filter topics if usefull 2017-12-05 23:22:33 +00:00
11 changed files with 80 additions and 7 deletions
+8
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using BlubbFish.IoT.Zway;
using BlubbFish.Utils;
@@ -16,5 +17,12 @@ namespace ZwayBot {
public abstract event ModulEvent Update;
public abstract void Dispose();
public virtual void Interconnect(Dictionary<String, AModul> moduls) {
}
public virtual void SetInterconnection(String param, Action hook) {
}
}
}
+11 -1
View File
@@ -11,6 +11,7 @@ namespace ZwayBot.Moduls {
internal class CronJob : AModul, IDisposable {
private DateTime crontime;
private Thread thread;
private List<Tuple<String, Action>> internalCron = new List<Tuple<String, Action>>();
public override event ModulEvent Update;
@@ -35,10 +36,15 @@ namespace ZwayBot.Moduls {
if(this.crontime.Minute != DateTime.Now.Minute) {
this.crontime = DateTime.Now;
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"));
}
}
foreach (Tuple<String, Action> item in this.internalCron) {
if(this.ParseCronString(item.Item1)) {
item.Item2?.Invoke();
}
}
}
Thread.Sleep(100);
}
@@ -156,6 +162,10 @@ namespace ZwayBot.Moduls {
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
private Boolean disposedValue = false;
+45
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using BlubbFish.IoT.Zway;
using BlubbFish.IoT.Zway.Devices;
using BlubbFish.IoT.Zway.Devices.CommandClasses;
@@ -13,6 +14,7 @@ namespace ZwayBot.Moduls {
class Flex4Grid : AModul, IDisposable {
private ADataBackend mqtt;
private String household = "";
private Object requestalivelock = new Object();
public override event ModulEvent Update;
@@ -114,6 +116,47 @@ namespace ZwayBot.Moduls {
}
}
private void RequestAlive() {
String raspi = this.ini.GetValue("f4g", "raspi");
lock (this.requestalivelock) {
String req = "https://wiki.flex4grid.eu/rupdate/rupdate_general.yml.gpg.asc?gw=" + raspi;
HttpWebRequest request = WebRequest.CreateHttp(req);
try {
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
this.Update?.Invoke(this, new Flex4gridEvent(req, response.StatusCode.ToString()));
}
} catch (Exception) { }
}
lock (this.requestalivelock) {
String req = "https://wiki.flex4grid.eu/rupdate/rupdate_general.yml?gw=" + raspi;
HttpWebRequest request = WebRequest.CreateHttp(req);
try {
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
this.Update?.Invoke(this, new Flex4gridEvent(req, response.StatusCode.ToString()));
}
} catch (Exception) { }
}
lock (this.requestalivelock) {
String req = "http://swb.pcs.flex4grid.eu/gateway/" + raspi;
HttpWebRequest request = WebRequest.CreateHttp(req);
try {
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
this.Update?.Invoke(this, new Flex4gridEvent(req, response.StatusCode.ToString()));
}
} catch (Exception) { }
}
}
public override void Interconnect(Dictionary<String, AModul> moduls) {
if (this.ini.GetValue("f4g", "raspi") != null) {
foreach (KeyValuePair<String, AModul> item in moduls) {
if (item.Value is CronJob) {
item.Value.SetInterconnection("10,40 * * * *", this.RequestAlive);
}
}
}
}
#region IDisposable Support
private Boolean disposedValue = false;
@@ -134,6 +177,8 @@ namespace ZwayBot.Moduls {
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
}
+7
View File
@@ -27,11 +27,18 @@ namespace ZwayBot {
this.zw = new ZwayController(InIReader.GetInstance("settings.ini").GetSection("zway"), names, false);
this.zw.Update += this.ZwayDataUpate;
this.ModulLoader();
this.ModulInterconnect();
this.ModulEvents();
this.WaitForShutdown();
this.ModulDispose();
}
private void ModulInterconnect() {
foreach (KeyValuePair<String, AModul> item in this.moduls) {
item.Value.Interconnect(this.moduls);
}
}
private void WaitForShutdown() {
while (true) {
System.Threading.Thread.Sleep(100);
+8 -6
View File
@@ -1,4 +1,5 @@
using System.Reflection;
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -6,12 +7,12 @@ using System.Runtime.InteropServices;
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("Zway-Bot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Is a Bot for Zwave Devices")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("BlubbFish")]
[assembly: AssemblyProduct("Zway-Bot")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyTrademark("BlubbFish")]
[assembly: AssemblyCulture("")]
// 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,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.2.1")]
[assembly: AssemblyFileVersion("1.1.2.1")]
[assembly: NeutralResourcesLanguage("de-DE")]
// “Internet Of Things” icon by By Michael Wohlwend, US, from thenounproject.com.
+1
View File
@@ -58,6 +58,7 @@
<Compile Include="Moduls\CronJob.cs" />
<Compile Include="Helper.cs" />
<Compile Include="Moduls\Flex4Grid.cs" />
<Compile Include="Moduls\Mqtt.cs" />
<Compile Include="Moduls\Overtaker.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.