From 604840c417efdce5d23d2bb1afedf403717d3b03 Mon Sep 17 00:00:00 2001 From: kruger <kruger@astron.nl> Date: Thu, 29 Apr 2021 15:26:53 +0200 Subject: [PATCH] translator_ready added --- config/CLK.yaml | 6 ++++++ config/RCU.yaml | 14 ++++++++++---- config/UNB2.yaml | 7 +++++++ i2cserv/i2cthread.py | 3 ++- opcuaserv/yamlreader.py | 9 ++++++++- scripts/ADCreset.py | 12 +++++++++++- scripts/CLK.py | 10 ++++++++-- 7 files changed, 52 insertions(+), 9 deletions(-) diff --git a/config/CLK.yaml b/config/CLK.yaml index 6399a66..5bd9021 100644 --- a/config/CLK.yaml +++ b/config/CLK.yaml @@ -48,6 +48,12 @@ variables: rw: ro #server RW variable, not linked to IO dtype: uint8 + - name: CLK_translator_busy + description: False when idle + rw: ro #server variable, not linked to IO + dtype: boolean + dim: 1 + - name: CLK_Enable_PWR description: Power enabled rw: ro diff --git a/config/RCU.yaml b/config/RCU.yaml index 5cae6d6..f1c28dd 100644 --- a/config/RCU.yaml +++ b/config/RCU.yaml @@ -210,11 +210,17 @@ variables: mask: RCU_mask dim: 32 - - name: RCU_state - description: State of RCUs 0=unknown, 1=ready, 2=busy, 3= wait PPS, 4=error - driver: I2C_RCU +# - name: RCU_state +# description: State of RCUs 0=unknown, 1=ready, 2=busy, 3= wait PPS, 4=error +# driver: I2C_RCU +# rw: ro #server variable, not linked to IO +# dtype: uint8 +# dim: 1 + + - name: RCU_translator_busy + description: False when idle rw: ro #server variable, not linked to IO - dtype: uint8 + dtype: boolean dim: 1 - name: RCU_attenuator diff --git a/config/UNB2.yaml b/config/UNB2.yaml index 3ff6241..5ac6515 100644 --- a/config/UNB2.yaml +++ b/config/UNB2.yaml @@ -87,6 +87,7 @@ device_registers: variables: + #When I2C bus timeout, bus_STATUS set to False. Can we set to True again to retry. - name: UNB2_I2C_bus_STATUS driver: switch_UNB2 @@ -119,6 +120,12 @@ variables: dtype: uint8 dim: 2 + - name: UNB2_translator_busy + description: False when idle + rw: ro #server variable, not linked to IO + dtype: boolean + dim: 1 + ##Central MP for whole Uniboard2 - name: UNB2_mask rw: variable #translator variable diff --git a/i2cserv/i2cthread.py b/i2cserv/i2cthread.py index 7fe2035..d4066a0 100644 --- a/i2cserv/i2cthread.py +++ b/i2cserv/i2cthread.py @@ -108,6 +108,7 @@ def I2Cserver(Qin,Qout,name): conf.linkdevices() conf.loaddrivers() conf.linkdrivers() + statusid=conf.getvarid(name+"_translator_busy"); while True: item = Qin.get() if item is None: break; @@ -124,7 +125,7 @@ def I2Cserver(Qin,Qout,name): elif (item.type==InstType.method): runmethod(conf,Qout,item.id,item.mask) else: print("OPCUA call not implemented!"); # print("TODO: Set ready") -# if Qin.qsize()==0: self.statevar.set_value("ready"); + if (Qin.qsize()==0) and not(statusid is None): Qout.put(OPCUAset(statusid,InstType.varSet,[0],[])) logging.info("End i2c process "+name) # if name=='RCU': diff --git a/opcuaserv/yamlreader.py b/opcuaserv/yamlreader.py index 940e491..e0c3873 100644 --- a/opcuaserv/yamlreader.py +++ b/opcuaserv/yamlreader.py @@ -24,7 +24,12 @@ class yamlreader(yamlconfig): self.server=i2cserver; self.timecount=0; self.monitorvarcnt=0; - + self.statusid=self.getvarid(yamlfile+"_translator_busy"); + + def SetBusy(self): + if self.statusid is None: return + self.OPCset(self.statusid,[1],[]) + def AddVars(self,AddVarR,AddVarW): self.monitorvar=AddVarW(self.yamlfile+"_monitor_rate_RW",60,None,None,None) for v in self.conf['variables']: @@ -84,6 +89,7 @@ class yamlreader(yamlconfig): logging.debug("Method called!"+v['name']) mask=v.get('maskOPC',None); mask=mask.get_value() if (mask!=None) else []; + self.SetBusy() self.server.callmethod(id1,mask) def CallInit(self): @@ -131,6 +137,7 @@ class yamlreader(yamlconfig): return; data2=[d for d in data2] logging.debug(str(("setvar ",v['name'],data2,mask))); + self.SetBusy() self.server.setvar(id1,data2,mask) def getvar(self): diff --git a/scripts/ADCreset.py b/scripts/ADCreset.py index e42c94a..7cb6d6e 100644 --- a/scripts/ADCreset.py +++ b/scripts/ADCreset.py @@ -3,10 +3,20 @@ from test_common import * RCUs=[0,1,2,3]; setRCUmask(RCUs) -#callmethod("RCU_off") +def wait(var1="RCU_translator_busy_R"): + for x in range(20): + busy=get_value(var1) +# print(busy) + if not(busy): break + time.sleep(0.1) + print("Time=",x*0.1,"s") + +callmethod("RCU_off") +wait() #exit() #time.sleep(2) callmethod("RCU_on") +wait() #callmethod("RCU_on") #time.sleep(1) #callmethod("ADC_on") diff --git a/scripts/CLK.py b/scripts/CLK.py index 4dbf2b4..19c524b 100644 --- a/scripts/CLK.py +++ b/scripts/CLK.py @@ -4,8 +4,14 @@ from test_common import * #time.sleep(1) callmethod("CLK_on") -time.sleep(1) -callmethod("CLK_PLL_setup") +for x in range(10): + busy=get_value("CLK_translator_busy_R") + print(busy) + if not(busy): break + time.sleep(0.1) + +#time.sleep(1) +#callmethod("CLK_PLL_setup") #exit() #time.sleep(1) #callmethod("RCU_on") -- GitLab