def read(self): MynaConfig.read(self) config = self.getDaemonConfig('daemon') try: if 'Daemon' in config: self.mbaddr = config['Daemon']['listenaddress'] self.mbport = int(config['Daemon']['listenport']) self.uid = int(config['Daemon']['uid']) self.gid = int(config['Daemon']['gid']) self.sgroups = config['Daemon']['supplementarygroups'] self.pidfile = config['Daemon']['pidfile'] if 'Modbus' in config: self.mbregs = int(config['Modbus']['registers']) self.mbstore = config['Modbus']['datastore'] endianity = {'BIG': Endian.Big, 'LITTLE': Endian.Little} if 'endianity' in config['Modbus'] and config['Modbus'][ 'endianity'].upper() in endianity: self.endian = endianity[config['Modbus'] ['endianity'].upper()] if 'PiFace' in config: self.pifaces = int(config['PiFace']['boards']) if 'Ownet' in config: self.owserver = config['Ownet']['server'] self.owport = int(config['Ownet']['port']) self.owpath = config['Ownet']['path'] self.owfail = int(config['Ownet']['failvalue']) self.owstore = config['Ownet']['datastore'] self.owtime = int(config['Ownet']['pollingtime']) self.owhold = int(config['Ownet']['holdingtime']) if 'EnOcean' in config: self.enport = config['EnOcean']['port'] self.enfail = int(config['EnOcean']['failvalue']) self.enstore = config['EnOcean']['datastore'] self.entime = int(config['EnOcean']['pollingtime']) self.enhold = int(config['EnOcean']['holdingtime']) if 'Identity' in config: self.mbident.VendorName = config['Identity']['vendorname'] self.mbident.ProductCode = config['Identity']['productcode'] self.mbident.VendorUrl = config['Identity']['vendorurl'] self.mbident.ProductName = config['Identity']['productname'] self.mbident.ModelName = config['Identity']['modelname'] self.mbident.MajorMinorRevision = config['Identity'][ 'majorminorrevision'] if 'RRD' in config: self.rrdenable = config['RRD']['enable'] self.rrdpath = config['RRD']['path'] except KeyError, e: print 'Missing configuration key: %s' % e os._exit(1)
def read(self): MynaConfig.read(self) config = self.getDaemonConfig('daemon') try: if 'Daemon' in config: self.mbaddr = config['Daemon']['listenaddress'] self.mbport = int(config['Daemon']['listenport']) self.uid = int(config['Daemon']['uid']) self.gid = int(config['Daemon']['gid']) self.sgroups = config['Daemon']['supplementarygroups'] self.pidfile = config['Daemon']['pidfile'] if 'Modbus' in config: self.mbregs = int(config['Modbus']['registers']) self.mbstore = config['Modbus']['datastore'] endianity = {'BIG': Endian.Big, 'LITTLE': Endian.Little} if 'endianity' in config['Modbus'] and config['Modbus']['endianity'].upper() in endianity: self.endian = endianity[config['Modbus']['endianity'].upper()] if 'PiFace' in config: self.pifaces = int(config['PiFace']['boards']) if 'Ownet' in config: self.owserver = config['Ownet']['server'] self.owport = int(config['Ownet']['port']) self.owpath = config['Ownet']['path'] self.owfail = int(config['Ownet']['failvalue']) self.owstore = config['Ownet']['datastore'] self.owtime = int(config['Ownet']['pollingtime']) self.owhold = int(config['Ownet']['holdingtime']) if 'EnOcean' in config: self.enport = config['EnOcean']['port'] self.enfail = int(config['EnOcean']['failvalue']) self.enstore = config['EnOcean']['datastore'] self.entime = int(config['EnOcean']['pollingtime']) self.enhold = int(config['EnOcean']['holdingtime']) if 'Identity' in config: self.mbident.VendorName = config['Identity']['vendorname'] self.mbident.ProductCode = config['Identity']['productcode'] self.mbident.VendorUrl = config['Identity']['vendorurl'] self.mbident.ProductName = config['Identity']['productname'] self.mbident.ModelName = config['Identity']['modelname'] self.mbident.MajorMinorRevision = config['Identity']['majorminorrevision'] if 'RRD' in config: self.rrdenable = config['RRD']['enable'] self.rrdpath = config['RRD']['path'] except KeyError, e: print 'Missing configuration key: %s' % e os._exit(1)
def __init__(self, cfgfile): self.pidfile = '/run/modbus/modbus.pid' # PID file self.uid = 0 # Unix UID (default: root) self.gid = 0 # Unix GID (default: root) self.sgroups = True # Unix supplementary groups self.mbaddr = '0.0.0.0' # Modbus listen address self.mbport = 502 # Modbus listen port self.mbregs = 255 # Modbus registers available self.mbstore = '/run/modbus/mbstore' # Modbus data store to allow daemon restart without loosing states self.endian = Endian.Big # Modbus words endianity self.pifaces = 1 # Number of PiFace boards (max 8 I/O ports per PiFace) self.owserver = 'localhost' # Ownet server self.owport = 4304 # Ownet port self.owpath = '/' # Ownet path self.owfail = 0 # Ownet sensor empty/fail value self.owstore = '/run/modbus/owstore' # Ownet data store to allow daemon restart without loosing states self.owtime = 60 # Ownet polling time and holding registers update (in seconds) self.owhold = 120 # Ownet holding of last values before failing (in seconds) self.enport = None # EnOcean adapter serial port self.enfail = 0 # EnOcean sensor empty/fail value self.enstore = '/run/modbus/enstore' # EnOcean data store to allow daemon restart without loosing states self.entime = 60 # EnOcean polling time and holding registers update (in seconds) self.enhold = 120 # EnOcean holding of last values before failing (in seconds) self.mbident = ModbusDeviceIdentification() self.mbident.VendorName = 'Pymodbus' self.mbident.ProductCode = 'PM' self.mbident.VendorUrl = 'http://github.com/bashwork/pymodbus/' self.mbident.ProductName = 'Pymodbus Server' self.mbident.ModelName = 'Pymodbus Server' self.mbident.MajorMinorRevision = '1.0' self.rrdenable = False # RRD history sensors data saving self.rrdpath = '/tmp' # RRD default path self.devices = {} MynaConfig.__init__(self, cfgfile) # read configuration file and validate parameters MynaConfig.read(self)