Files
Zway-Bot/Zway-Bot/Moduls/StatusPolling.cs
T

46 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using BlubbFish.IoT.Zway;
using BlubbFish.IoT.Zway.Devices;
using BlubbFish.IoT.Zway.Interfaces;
using BlubbFish.Utils;
using BlubbFish.Utils.IoT.Bots.Events;
using BlubbFish.Utils.IoT.Bots.Moduls;
namespace BlubbFish.IoT.Bots.ZwayBot.Moduls {
class Statuspolling : Statuspolling<ZwayController> {
public override event ModulEvent Update;
public Statuspolling(ZwayController zway, InIReader settings) : base(zway, settings) { }
protected override void PollSpecific(Object obj) {
String devices = (String)obj;
foreach (String item in devices.Split(',')) {
ACommandClass c = this.library.GetCommandClass(item);
c.PollOnce = true;
this.Update?.Invoke(this, new StatusPollingEvent("Polling", item));
}
}
protected override void PollAll(Object obj) {
foreach (KeyValuePair<Int32, Device> device in this.library.Devices) {
foreach (KeyValuePair<Int32, Instance> instance in device.Value.Instances) {
foreach (KeyValuePair<ACommandClass.Classes, ACommandClass> commandclass in instance.Value.CommandClasses) {
commandclass.Value.PollOnce = true;
if(commandclass.Value.HasSub) {
foreach (KeyValuePair<Int32, ACommandClass> subclass in commandclass.Value.Sub) {
subclass.Value.PollOnce = true;
}
}
}
}
}
this.Update?.Invoke(this, new StatusPollingEvent("Polling", "all nodes"));
}
public override void EventLibSetter() { }
protected override void LibUpadteThread(Object state) { }
}
}