diff --git a/config/APSCTTR.yaml b/config/APSCTTR.yaml index 0ce975bc55a3117df21f74afc4ec1c8ed9283e1a..b55a56ce7f4cba7db374b94568bf2c4bcee57c68 100644 --- a/config/APSCTTR.yaml +++ b/config/APSCTTR.yaml @@ -76,6 +76,8 @@ device_registers: - name: Version description: Set in production address: 0 + - name: Serial + address: 0x20 - name: VSENSE description: Monitor ADC @@ -116,6 +118,11 @@ variables: rw: ro #server RW variable, not linked to IO dtype: uint8 + - name: APSCTTR_monitor_rate + description: Monitor rate in seconds + rw: variable + dtype: uint8 + - name: APSCTTR_translator_busy description: False when idle rw: ro #server variable, not linked to IO @@ -134,7 +141,15 @@ variables: description: Version number driver: I2C_CLK devreg: ROM.Version - width: 80 #10 characters + width: 0x80 #16 characters + rw: ro + dtype: string + + - name: APSCT_PCB_number + description: PCB number (astron.nl/webforms/IenS-Boarden/view.php?id=xxx) + driver: I2C_CLK + devreg: ROM.Serial + width: 0x80 #16 characters rw: ro dtype: string @@ -280,6 +295,7 @@ methods: instructions: - APSCT_PCB_ID : Update - APSCT_PCB_version : Update + - APSCT_PCB_number : Update - APSCT_PWR_on: Update - APSCT_PWR_PLL_200MHz_on: Update - APSCT_PLL_200MHz_locked: Update diff --git a/config/APSPUTR.yaml b/config/APSPUTR.yaml index 24c33e05070d130d3863824f5f698629d95503ef..6224a1d7e96085681d73788e55e6efae39b0a14c 100644 --- a/config/APSPUTR.yaml +++ b/config/APSPUTR.yaml @@ -22,7 +22,9 @@ device_registers: - name: Version description: Set in production address: 0 - + - name: Serial + address: 0x20 + - name: MAX description: MAX6620 fan speed controller @@ -45,6 +47,11 @@ variables: rw: ro #server RW variable, not linked to IO dtype: uint8 + - name: APSPUTR_monitor_rate + description: Monitor rate in seconds + rw: variable + dtype: uint8 + - name: APSPUTR_translator_busy description: False when idle rw: ro #server variable, not linked to IO @@ -62,7 +69,15 @@ variables: description: Version number driver: I2C_PU devreg: ROM.Version - width: 80 #10 characters + width: 0x80 #10 characters + rw: ro + dtype: string + + - name: APSPU_PCB_number + description: PCB number (astron.nl/webforms/IenS-Boarden/view.php?id=xxx) + driver: I2C_PU + devreg: ROM.Serial + width: 0x80 #16 characters rw: ro dtype: string @@ -114,6 +129,7 @@ methods: instructions: - APSPU_PCB_ID : Update - APSPU_PCB_version : Update + - APSPU_PCB_number : Update - name: APSPU_FAN_monitor_on driver: I2C_PU diff --git a/config/RECVTR.yaml b/config/RECVTR.yaml index 19abb896d650f73a4acda75bc034b9a1a0306b66..267d7c08c6d59a62e02abfc1b18dd8e0f81a3218 100644 --- a/config/RECVTR.yaml +++ b/config/RECVTR.yaml @@ -89,6 +89,8 @@ device_registers: - name: Version description: Set in production address: 0 + - name: Serial + address: 0x20 - name: AN description: Monitor ADC on RCU @@ -206,6 +208,12 @@ device_registers: address: [0x1210,0x1110] variables: + - name: RECVTR_monitor_rate + description: Monitor rate in seconds + driver: I2C_RCU + rw: variable + dtype: uint8 + - name: ANT_mask description: Only masked RF chains are updated driver: I2C_RCU @@ -486,7 +494,17 @@ variables: description: RCU version number driver: I2C_RCU devreg: ROM.Version - width: 80 #10 characters + width: 0x80 #16 characters + rw: ro + dtype: string + dim: 32 + mask: RCU_mask + + - name: RCU_PCB_number + description: PCB number (astron.nl/webforms/IenS-Boarden/view.php?id=xxx) + driver: I2C_RCU + devreg: ROM.Serial + width: 0x80 #16 characters rw: ro dtype: string dim: 32 @@ -646,6 +664,7 @@ methods: - RCU_PWR_ANT_on: Update - RCU_PCB_ID: Update - RCU_PCB_version: Update + - RCU_PCB_number: Update - RCU_LED_red_on: Update - RCU_LED_green_on: Update - RCU_attenuator_dB: Update diff --git a/config/UNB2TR.yaml b/config/UNB2TR.yaml index 2e5416bd3ebfd84a580465b6957a948dcad05050..f1a00b33612c918fa67ef138397e64b16bac3690 100644 --- a/config/UNB2TR.yaml +++ b/config/UNB2TR.yaml @@ -121,11 +121,15 @@ variables: dtype: uint8 dim: 2 + - name: UNB2TR_monitor_rate + description: Monitor rate in seconds + rw: variable + dtype: uint8 + - name: UNB2TR_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 @@ -137,7 +141,7 @@ variables: driver: GPIO mask: UNB2_mask width: 1 - rw: rw + rw: ro dtype: boolean convert_unit: bool_invert dim: 2 @@ -156,7 +160,16 @@ variables: - name: UNB2_PCB_version driver: switch_UNB2 devreg: 0x50.0 - width: 80 #10 characters + width: 0x80 #16 char + rw: ro + dtype: string + dim: 2 + + - name: UNB2_PCB_number + description: PCB number (astron.nl/webforms/IenS-Boarden/view.php?id=xxx) + driver: switch_UNB2 + devreg: 0x50.0x20 + width: 0x80 #16 characters rw: ro dtype: string dim: 2 @@ -316,6 +329,7 @@ variables: rw: ro dtype: double scale: 3.90625e-3 #1/256 + convert_unit: temp_check dim: 48 monitor: true @@ -337,14 +351,15 @@ methods: - UNB2TR_I2C_error: 0 - UNB2_PCB_ID: Update - UNB2_PCB_version: Update + - UNB2_PCB_number: Update - UNB2_Front_Panel_LED_colour: Update - UNB2_PWR_on: Update - name: UNB2_on mask: UNB2_mask instructions: - - FP_IO.CONF: 0xff #TODO: setup correctly - - UNB2_PWR_on: 1 +# - FP_IO.CONF: 0xff #TODO: setup correctly + - UNB2_PWR_on: 0 #already inverted - UNB2_Front_Panel_LED_colour: 1 - UNB2_PCB_ID: Update - UNB2_PCB_version: Update @@ -352,5 +367,5 @@ methods: - name: UNB2_off mask: UNB2_mask instructions: - - UNB2_PWR_on: 0 + - UNB2_PWR_on: 1 #inverted # - UNB2_Front_Panel_LED_colour: 2 diff --git a/i2cserv/i2c.py b/i2cserv/i2c.py index 27e86db37782e13cdf95000b4890a338918a27ec..7376df4c09e49bd111e24876af4e70b99ea96df4 100644 --- a/i2cserv/i2c.py +++ b/i2cserv/i2c.py @@ -48,6 +48,6 @@ class i2c(hwdev): # else: if bus: bus.close() logging.debug("I2C failed!") -# data[0]=0xff + if len(data)>0: data[0]=0 return False; diff --git a/opcuaserv/convert_unit.py b/opcuaserv/convert_unit.py index 41bbc10cc276da47c6271870805ccbad91e34596..919a74bf651af3c151b259f8b73fc7bd3d6024e5 100644 --- a/opcuaserv/convert_unit.py +++ b/opcuaserv/convert_unit.py @@ -7,3 +7,7 @@ def period2RPM(T): def bool_invert(T): return not(T); + +def temp_check(T): + if (T<-100) or (T>200): return float('nan') + return T; \ No newline at end of file diff --git a/opcuaserv/opcuaserv.py b/opcuaserv/opcuaserv.py index c27ce04ae36aea81c04ed082c38953012e42c7ae..65eedc4fc9f14aca260c7d485f10fc3d340a0509 100644 --- a/opcuaserv/opcuaserv.py +++ b/opcuaserv/opcuaserv.py @@ -24,9 +24,9 @@ class SubHandler(object): vname,myvar,v,reader=Vars_W[node.nodeid.Identifier] # val=(val if isinstance(val, list) else [val] ) logging.info(str(("Datachange callback",vname,val))) + reader.setvar(v,val) # myvar2.Value.Value=val # myvar2.SourceTimestamp = datetime.utcnow() - reader.setvar(v,val) # Inst=Instr(DevType.Var,VarD,len(val),val) # Q1.put(Inst) @@ -68,7 +68,7 @@ def AddVarW(vname,varvalue2,v,Q1,debug): obj=(DEBUGobj if debug else PCCobj) myvar2 = obj.add_variable(idx, vname, varvalue2) myvar2.set_writable() - if v: + if not v is None: Vars_W[myvar2.nodeid.Identifier]=[vname,myvar2.get_data_value(),v,Q1] handle = sub.subscribe_data_change(myvar2) return myvar2 diff --git a/opcuaserv/yamlreader.py b/opcuaserv/yamlreader.py index c53c54612189e78ca0505516df16535ec02b81dc..4653f335ed6554eb788e2e33e24469c24c72f8f9 100644 --- a/opcuaserv/yamlreader.py +++ b/opcuaserv/yamlreader.py @@ -27,6 +27,7 @@ class yamlreader(yamlconfig): self.timecount=1000; #0 start a 0, 1000 first point immediate self.monitorvarcnt=0; self.statusid=self.getvarid(yamlfile+"_translator_busy"); + self.monitorvarid=self.getvarid(yamlfile+"_monitor_rate"); self.statusOPC=None def SetBusy(self): @@ -34,7 +35,6 @@ class yamlreader(yamlconfig): self.OPCset(self.statusid,[1],[]) def AddVars(self,AddVarR,AddVarW): - self.monitorvar=AddVarW(self.yamlfile+"_monitor_rate_RW",30,None,None,None) for v in self.conf['variables']: # print(v) dim1=v.get('dim',1); @@ -51,7 +51,7 @@ class yamlreader(yamlconfig): elif datatype=='string': varvalue2=dim1*[""] if len(varvalue2)==1: varvalue2=varvalue2[0]; # print(len(varvalue2),varvalue2) - if v.get('rw') in ['ro','rw']: + if v.get('rw') in ['ro','rw','variable']: var1=AddVarR(name+"_R",varvalue2,v['id'],v.get('debug')) v['OPCR']=var1 logging.debug("Var added:"+name+"_R") @@ -72,6 +72,18 @@ class yamlreader(yamlconfig): mask=mask.get('OPCW',None) if (mask==None): continue; v['maskOPC']=mask + if not self.monitorvarid is None: + self.monitorvar=self.conf['variables'][self.monitorvarid].get('OPCW') + self.monitorvar.set_value(30); + self.setvar(self.monitorvarid,30); + else: + logging.warning("No monitor_rate variable found") + self.monitorvar=None; + if not self.statusid is None: + self.statusOPC=self.conf['variables'][self.statusid].get('OPCR') + else: + logging.warning("No translator_busy variable found"); + self.statusOPC=None; def AddMethod(self,Addmethod): for v in self.conf['methods']: @@ -104,7 +116,15 @@ class yamlreader(yamlconfig): def setvar(self,id1,data=[]): v=self.conf['variables'][id1]; - if v['rw']=='variable': return; + if v['rw']=='variable': + var1=v.get('OPCR') +# if not(var1): var1=v.get('OPCW') + if not(var1): + logging.warn("OPCR variable not found!!"); + return; + logging.info("Update variable") + var1.set_value(data); + return; endian=v.get('endian','>'); mask=v.get('maskOPC',None); mask=mask.get_value() if (mask!=None) else []; @@ -236,10 +256,11 @@ class yamlreader(yamlconfig): var1.set_value(data3); def Monitor(self): + if self.monitorvar is None: return; T1=self.monitorvar.get_value()*10; if T1<=0: return; self.timecount+=1; - if self.statusOPC is None: self.statusOPC=self.conf['variables'][self.statusid].get('OPCR') +# if self.statusOPC is None: self.statusOPC=self.conf['variables'][self.statusid].get('OPCR') while self.timecount>=T1: if not(self.statusOPC is None) and self.statusOPC.get_value(): return; if self.server.QoutLength()>0: return; diff --git a/scripts/Att.py b/scripts/Att.py index ed75b9dbd01e62d2a333d6b6ae7200a1b406c569..3ca41f91d9f0e2daa5d269adac9fcb50aac4696b 100644 --- a/scripts/Att.py +++ b/scripts/Att.py @@ -1,6 +1,7 @@ from test_common import * +connect() -name="RCU_attenuator" +name="RCU_attenuator_dB" RCU=[1]; Att=[10,10,10] #RCU=[1,2,3]; diff --git a/scripts/FAN_on.py b/scripts/FAN_on.py new file mode 100644 index 0000000000000000000000000000000000000000..90b89ec524ca0768e3987f935d83bfa2c3148ff1 --- /dev/null +++ b/scripts/FAN_on.py @@ -0,0 +1,6 @@ +from test_common import * +connect("opc.tcp://localhost:4842/") + +callmethod("APSPU_FAN_monitor_on") + +disconnect();