diff --git a/config/CLK.yaml b/config/CLK.yaml index 6399a6666d3e4bcb9d2f30a8813dc3f50ee047bd..5bd902124c20314573e3759649cc728fb6ff2b78 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 5cae6d6c03be422d91b1164308c62f97a41162d4..f1c28ddb334ea76076ff2cc4a94904b2d4b26531 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 3ff6241f2023cad04aa67196c60a0bf9d8f6f2c3..5ac65152df724826fc6d31bd083adf5d8d630d2f 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 7fe2035012a99d33a4fc9ce7e68cde24fd813945..d4066a059f7ce397e2b2df10d6c91a4257749fcf 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 940e49132db9d5fa435e9359a9293ca443ef91f6..e0c3873729830e1d99f4322c022398b43a012c06 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 e42c94acc4acadf705c19747f1f63955e81d6814..7cb6d6e2201c508110731f166f2d2fe911affb63 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 4dbf2b4179174154d421998068cee27faa7108cb..19c524bed4db0b8a5765a96752682c058c9fbe5c 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")