From 3ce28d35c0ed07934a873def8c0096be58104b3f Mon Sep 17 00:00:00 2001 From: kruger <kruger@astron.nl> Date: Fri, 2 Apr 2021 16:55:06 +0200 Subject: [PATCH] Start processes earlier --- pypcc2.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pypcc2.py b/pypcc2.py index c0935e2..054f2bb 100644 --- a/pypcc2.py +++ b/pypcc2.py @@ -24,7 +24,6 @@ if not isinstance(loglevel_nr, int): logging.basicConfig(level=loglevel_nr,format='%(asctime)s [%(levelname)-8s,%(filename)-20s:%(lineno)-3d] %(message)s') - RunTimer=True; def signal_handler(sig, frame): logging.warn('Stop signal received!') @@ -32,29 +31,29 @@ def signal_handler(sig, frame): RunTimer=False signal.signal(signal.SIGINT, signal_handler) - -#Initialise OPCUA server -logging.info("Initialised OPC-UA Server") -opcuaserv.InitServer(port=args.port) - - -logging.info("Start threads") +#Start i2c processes as soon as possible to have minimum duplication +logging.info("Start I2C processes") I2Cports=['RCU'] #I2Cports=[] threads=[] I2Cclients=[] for name in I2Cports: - logging.info("Start I2C server process...") RCU_I2C=i2client.i2client(name=name) thread1=i2cthread.start(*RCU_I2C.GetInfo()) threads.append(thread1) I2Cclients.append(RCU_I2C) +#Initialise OPCUA server +logging.info("Initialised OPC-UA Server") +opcuaserv.InitServer(port=args.port) + +logging.info("Load OPCUA variables & start i2c listing thread") +for i,name in enumerate(I2Cports): + RCU_I2C=I2Cclients[i] RCU_conf=yamlreader.yamlreader(RCU_I2C,yamlfile=name) RCU_conf.AddVars(opcuaserv.AddVarR,opcuaserv.AddVarW) RCU_conf.AddMethod(opcuaserv.Addmethod) - logging.info("Start listing thread...") thread2=threading.Thread(target=RCU_conf.getvar); #Thread on OPC-UA side of pipe thread2.start() threads.append(thread2) -- GitLab