def run(): '''Run CommandInterface''' z = ManagingObject() lancero.server.startServer(z, '127.0.0.1', getRegistry('afserver-lancero-port')) print 'LANCERO started' donothing()
def run(): tcs = ThreadingTCPServer(('', getRegistry('afserver-p24-port')), P24Handler) tcs.serve_forever() print 'P24 started' donothing()
from Protocol import * from socket import SOL_TCP, TCP_NODELAY, SOL_SOCKET, SO_KEEPALIVE import Queue from time import sleep from weakref import proxy from Order import * from Connections import CONNECTIONS from threading import Thread from lancero.operators import Get import lancero.client import lancero.base from afruntime.config import getRegistry lancero.client.registerServer( lancero.client.ServerDefinitionEntry('127.0.0.1', getRegistry('afsensors-lancero-port'), 'afsensors', '')) afsObj = lancero.base.RemoteProxy(lancero.base.RemoteSource('afsensors', 0)) class ReaderThread(Thread): def __init__(self, rqh): '''I assume RQH is a WeakProxy''' self.rqh = rqh self.device = rqh.device self.device.setStat('thread.reader', 1) self.id = rqh.id Thread.__init__(self) def run(self): try:
# coding=UTF-8 from afruntime import DEVDB_ROOT from afruntime.config import getRegistry from afruntime.device import Device from datetime import datetime, timedelta from threading import Lock from time import time, sleep import lancero.client import lancero.base from afruntime.log import log as debugLog from lancero.operators import Get lancero.client.registerServer( lancero.client.ServerDefinitionEntry('127.0.0.1', getRegistry('afserver-lancero-port'), 'afserver', '')) sObj = lancero.base.RemoteProxy(lancero.base.RemoteSource('afserver', 0)) SENSORICS = {} class Sensor(object): '''Sensor, as seen by sensor processor''' def __init__(self, id, regtype, dev, register, runlevel_settings): self.id = id self.lastupdated = time() self.dev = dev self.regtype = regtype self.register = register self.runlevel_settings = runlevel_settings self.rt1expire = None
# coding=UTF-8 from afruntime import DEVDB_ROOT from afruntime.config import getRegistry from afruntime.device import Device from datetime import datetime, timedelta from threading import Lock from time import time, sleep import lancero.client import lancero.base from afruntime.log import log as debugLog from lancero.operators import Get lancero.client.registerServer(lancero.client.ServerDefinitionEntry('127.0.0.1', getRegistry('afserver-lancero-port'), 'afserver', '')) sObj = lancero.base.RemoteProxy(lancero.base.RemoteSource('afserver', 0)) SENSORICS = {} class Sensor(object): '''Sensor, as seen by sensor processor''' def __init__(self, id, regtype, dev, register, runlevel_settings): self.id = id self.lastupdated = time() self.dev = dev self.regtype = regtype self.register = register self.runlevel_settings = runlevel_settings self.rt1expire = None self.interval = self.runlevel_settings[0] def weight(self): # za ile sekund następny odpyt f = self.interval - (time()-self.lastupdated)
from patelnia.p24 import Exceptions from afruntime import DEVDB_ROOT import os import re import codecs from datetime import datetime import afruntime.config import lancero.client from lancero.operators import Get from afruntime.config import getRegistry from afruntime.numeric import * sensorRegexp = re.compile('s([0-9]+)([rfi])([0-9]+)') reg_typeStI = {'r':0, 'f':1, 'i':2, 'o':3} reg_typeItS = {0:'r', 1:'f', 2:'i', 3:'o'} lancero.client.registerServer(lancero.client.ServerDefinitionEntry('127.0.0.1', getRegistry('afserver-lancero-port'), 'afserver', '')) lancero.client.registerServer(lancero.client.ServerDefinitionEntry('127.0.0.1', getRegistry('afsensors-lancero-port'), 'afsensors', '')) sObj = lancero.base.RemoteProxy(lancero.base.RemoteSource('afserver', 0)) afsObj = lancero.base.RemoteProxy(lancero.base.RemoteSource('afsensors', 0)) from afruntime.device import Device as AFDevice class Sensor(object): __slots__ = ('device','modbus_nr','reg_type','register','intervals') def __init__(self, device, modbus_nr, reg_type, register, intervals=[]): self.device = device self.modbus_nr = modbus_nr self.reg_type = reg_type self.register = register self.intervals = intervals def getReadTime(self): x = reg_typeItS[self.reg_type]
def run(): """Run CommandInterface""" z = ManagingObject() lancero.server.startServer(z, "127.0.0.1", getRegistry("afsensors-lancero-port")) print "LANCERO started" donothing()