def load(self): main_words.register_statement(PWMHandler) main_words.register_statement(PWMUpdate) main_words.register_statement(PWMSet) main_words.register_statement(VarPWMHandler) register_condition(PWMs.exists) register_condition(OnPWMCheck)
def load(self): main_words.register_statement(AMQPconn) main_words.register_statement(AMQPstart) main_words.register_statement(AMQPstop) main_words.register_statement(AMQPlog) main_words.register_statement(AMQPtell) main_words.register_statement(AMQPlisten) register_condition(AMQPclients.exists)
def load(self): main_words.register_statement(TimeslotHandler) main_words.register_statement(TimeslotUpdate) main_words.register_statement(TimeslotStart) main_words.register_statement(TimeslotStop) main_words.register_statement(VarTimeslotHandler) register_condition(RunningTimeslotCheck) register_condition(DuringTimeslotCheck)
def load(self): main_words.register_statement(MonitorMaker) main_words.register_statement(MonitorHandler) main_words.register_statement(MonitorUpdate) main_words.register_statement(MonitorSet) main_words.register_statement(MonitorStart) main_words.register_statement(MonitorStop) main_words.register_statement(VarMonitorHandler) register_condition(RunningMonitorCheck) register_condition(WaitingMonitorCheck)
def load(self): main_words.register_statement(StateHandler) main_words.register_statement(SetStateHandler) main_words.register_statement(VarStateHandler) main_words.register_statement(ForgetStateHandler) register_condition(StateCheck) register_condition(StateLockedCheck) register_condition(LastStateCheck) register_condition(States.exists) register_condition(SavedStateCheck)
def load(self): mlen=0 for v in globals().values(): m = getattr(v,"mode",None) if m is None: continue modes[m] = v if mlen < len(m): mlen = len(m) for v in modes.values(): AvgHandler.long_doc += v.mode+" "*(mlen-len(v.mode)+1)+v.doc+"\n" main_words.register_statement(AvgHandler) main_words.register_statement(AvgSet) main_words.register_statement(AvgReset) main_words.register_statement(VarAvgHandler) register_condition(Avgs.exists)
def load(self): main_words.register_statement(RRDconnect) main_words.register_statement(RRDsetfile) main_words.register_statement(RRDset) register_condition(RRDconnected) register_condition(RRDchannels.exists) register_condition(RRDservers.exists) register_condition(RRDfiles.exists)
def load(self): mlen = 0 for v in globals().values(): m = getattr(v, "mode", None) if m is None: continue modes[m] = v if mlen < len(m): mlen = len(m) for v in modes.values(): AvgHandler.long_doc += v.mode + " " * (mlen - len(v.mode) + 1) + v.doc + "\n" main_words.register_statement(AvgHandler) main_words.register_statement(AvgSet) main_words.register_statement(AvgReset) main_words.register_statement(VarAvgHandler) register_condition(Avgs.exists)
def load(self): main_words.register_statement(NETlisten) main_words.register_statement(NETconnect) main_words.register_statement(NETsend) register_condition(Nets.exists) register_condition(NetListens.exists) register_condition(NETconnected)
def load(self): main_words.register_statement(WAGOconnect) main_words.register_statement(WAGOmonitor) main_words.register_statement(WAGOraw) register_condition(WAGOconnected) register_condition(WAGOservers.exists) register_condition(WAGOchannels.exists) register_input(WAGOinput) register_output(WAGOoutput)
def load(self): global _new_bus_ev _new_bus_ev = NewBusEvent() main_words.register_statement(OWFSconnect) main_words.register_statement(OWFSdisconnect) main_words.register_statement(OWFSdir) main_words.register_statement(OWFSscan) main_words.register_statement(OWFSset) main_words.register_statement(OWFSmonitor) main_words.register_statement(OWFSpoll) main_words.register_statement(AutoPoll) register_input(OWFSinput) register_output(OWFSoutput) register_condition(OWFSconnected) register_condition(OWFSconnectedbus) register_condition(OWFSpolls.exists)
def load(self): register_condition(ExistsPathCheck) register_condition(ExistsFileCheck) register_condition(ExistsDirCheck)
from moat.check import register_condition from moat.delay import DelayFor,DelayWhile,DelayUntil,DelayNext, DelayCancelled import gevent from gevent.event import AsyncResult import os import sys import socket import errno class Inputs(Collection): name = "input" Inputs = Inputs() Inputs.does("del") register_condition(Inputs.exists) class Outputs(Collection): name = "output" Outputs = Outputs() Outputs.does("del") register_condition(Outputs.exists) @six.python_2_unicode_compatible class BadValue(RuntimeError): """The input doesn't match the expected values""" def __init__(self, inp,val): self.inp = inp self.val = val def __str__(self): return "BadValue: read %s: bad value for %s" % (self.val,self.inp)
def load(self): main_words.register_statement(WaitHandler) main_words.register_statement(VarWaitHandler) register_condition(Waiters.exists)
flags |= OWdevformat.fdi << OWdevformat._offset log("onewire", DEBUG, "SEND", 0, len(data), typ, flags, rlen, 0, repr(data)) self.write(struct.pack("!6i", \ 0, len(data), typ, flags, rlen, 0) +data) class OWchans(Collection): name = "onewire connection" OWchans = OWchans() OWchans.does("del") OWchans2 = {} register_condition(OWchans.exists) class OWFSchannel(OWFSassembler, NetActiveConnector): """A receiver for the protocol used by OWFS.""" storage = OWchans.storage storage2 = OWchans2 typ = "onewire" def down_event(self, external=False): simple_event("onewire", "disconnect", *self.name, deprecated=True) simple_event("onewire", "link", "state", *self.name, state="down") def up_event(self, external=False): simple_event("onewire", "connect", *self.name, deprecated=True) simple_event("onewire", "link", "state", *self.name, state="up")
def load(self): main_words.register_statement(OnEventHandler) main_words.register_statement(OnSkip) main_words.register_statement(OnSkip2) register_condition(OnHandlers.exists)
def load(self): main_words.register_statement(List) main_words.register_statement(Del) register_condition(VarCheck)
def load(self): main_words.register_statement(RPClisten) register_condition(RPCconns.exists) register_condition(RPCservers.exists)
def load(self): PREFIX[PREFIX_ENERGY] = en_handler() main_words.register_statement(FS20en) main_words.register_statement(FS20enVal) register_condition(ENs.exists)
def load(self): PREFIX[PREFIX_TX] = tx_handler() main_words.register_statement(FS20tx) main_words.register_statement(FS20txVal) register_condition(TXs.exists)
def load(self): main_words.register_statement(AVRconnect) main_words.register_statement(AVRsend) register_condition(AVRs.exists) register_condition(AVRconnected)
def load(self): register_condition(TrueCheck) register_condition(FalseCheck) register_condition(NoneCheck) register_condition(EqualCheck) register_condition(LessCheck) register_condition(GreaterCheck)
def par(_): return os.path.join(os.pardir,_) #if os.path.exists("modules"): # ModuleDirs.append("modules") #elif os.path.exists(par("modules")) and os.path.exists(par("Makefile")): # ModuleDirs.append(par("modules")) class ModuleExistsError(RuntimeError): """A module with that name already exists.""" pass class Modules(Collection): name = "module" prio = 99 Modules = Modules() Modules.does("del") register_condition(Modules.exists) class Module(Collected): """\ This is a loadable module. See moat.config.py, the "Loader" and "Unloader" classes, for examples. """ name = "Module" storage = Modules.storage info = "some idiot programmer forgot to override me" path = None def __init__(self, *name): """\ Initialize a module. The arguments are passed in from the
def load(self): main_words.register_statement(LogHandler) main_words.register_statement(LogLevelHandler) register_condition(Loggers.exists)
def load(self): PREFIX[PREFIX_EM] = em_handler() PREFIX[PREFIX_EM2] = em2_handler() main_words.register_statement(FS20em) main_words.register_statement(FS20emVal) register_condition(EMs.exists)
def load(self): main_words.register_statement(FS20switches) main_words.register_statement(FS20send) register_condition(SwitchGroups.exists) register_condition(Switches.exists)
import gevent from gevent.event import AsyncResult import os import sys import socket import errno class Inputs(Collection): name = "input" Inputs = Inputs() Inputs.does("del") register_condition(Inputs.exists) class Outputs(Collection): name = "output" Outputs = Outputs() Outputs.does("del") register_condition(Outputs.exists) @six.python_2_unicode_compatible class BadValue(RuntimeError): """The input doesn't match the expected values""" def __init__(self, inp, val):
def load(self): main_words.register_statement(RRDHandler) main_words.register_statement(RRDset) main_words.register_statement(VarRRDHandler) register_condition(RRDs.exists)
from moat.collect import Collection,Collected from moat.check import register_condition from gevent.event import Event as gEvent from gevent.queue import Channel,Queue import gevent from time import time import os,sys import datetime as dt class Monitors(Collection): name = "monitor" Monitors = Monitors() Monitors.does("del") register_condition(Monitors.exists) class MonitorAgain(RuntimeError): """The monitor is not ready yet; retry please""" pass @six.python_2_unicode_compatible class MonitorError(RuntimeError): def __init__(self,w): self.monitor = w def __str__(self): return self.text % (" ".join(six.text_type(x) for x in self.monitor.name),) class DupMonitorError(MonitorError): text = u"A monitor ‹%s› already exists"
# needed for sometimes-broken 1wire daemons flags |= OWFlag.busret # flags |= 1<<8 ## ? flags |= OWtempformat.celsius << OWtempformat._offset flags |= OWdevformat.fdi << OWdevformat._offset log("onewire",DEBUG,"SEND", 0, len(data), typ, flags, rlen, 0, repr(data)) self.write(struct.pack("!6i", \ 0, len(data), typ, flags, rlen, 0) +data) class OWchans(Collection): name = "onewire connection" OWchans = OWchans() OWchans.does("del") OWchans2 = {} register_condition(OWchans.exists) class OWFSchannel(OWFSassembler, NetActiveConnector): """A receiver for the protocol used by OWFS.""" storage = OWchans.storage storage2 = OWchans2 typ = "onewire" def down_event(self, external=False): simple_event("onewire","disconnect",*self.name, deprecated=True) simple_event("onewire","link","state",*self.name, state="down") def up_event(self, external=False): simple_event("onewire","connect",*self.name, deprecated=True) simple_event("onewire","link","state",*self.name, state="up")
# ModuleDirs.append(par("modules")) class ModuleExistsError(RuntimeError): """A module with that name already exists.""" pass class Modules(Collection): name = "module" prio = 99 Modules = Modules() Modules.does("del") register_condition(Modules.exists) class Module(Collected): """\ This is a loadable module. See moat.config.py, the "Loader" and "Unloader" classes, for examples. """ name = "Module" storage = Modules.storage info = "some idiot programmer forgot to override me" path = None def __init__(self, *name): """\
from moat.base import Name from moat.twist import callLater, fix_exception from moat.context import Context from moat.check import register_condition from moat.logging import log,TRACE,DEBUG,ERROR from moat.collect import Collection,Collected from time import time import os import datetime as dt class Timeslots(Collection): name = "timeslot" Timeslots = Timeslots() Timeslots.does("del") register_condition(Timeslots.exists) class Timeslotted(object): pass # def slot_up(self): # pass # def slot_down(self): # pass @six.python_2_unicode_compatible class TimeslotError(RuntimeError): def __init__(self,w): self.timeslot = w def __str__(self): return self.text % (" ".join(six.text_type(x) for x in self.timeslot.name),)
def load(self): main_words.register_statement(QBconnect) register_condition(QBconns.exists)