diff --git a/howtogit.txt b/howtogit.txt new file mode 100644 index 0000000000000000000000000000000000000000..f931006a1e23579de14b99d67fc79fbc0f0b3307 --- /dev/null +++ b/howtogit.txt @@ -0,0 +1,8 @@ +1. Make dynamic tunnel from pi to local machine (kruger@dop416 in this example) +On LCU: (pi can not ssh to LCU, so we need reverse ssh) + ssh -R 20222:dop416:22 pi@10.99.0.101 +then on pi: (dynamic tunnel) + ssh kruger@localhost -p 20222 -D 1080 + +2. Configure git to use tunnel + git config http.proxy socks5h://localhost:1080 \ No newline at end of file diff --git a/pypcc/config/APSCTTR.yaml b/pypcc/config/APSCTTR.yaml index 512d1caad9b7a5271f29e9f298ff2df848c8bff1..cf94065101098c5f850622e8af750a0573d72145 100644 --- a/pypcc/config/APSCTTR.yaml +++ b/pypcc/config/APSCTTR.yaml @@ -9,17 +9,21 @@ drivers: type: i2c_dev #I2C devices parent: I2C status: APSCTTR_I2C_error - - name: SPIbb1 - type: spibitbang2 #SPI bitbang via GPIO expander: CLK, SDI,SDO,CS + - name: SPIbb1 + type: spibitbang3 #SPI bitbang via GPIO expander: CLK, SDI,SDO,CS parent: I2C_CLK devreg: [IO1.GPIO1,IO1.GPIO1,IO1.GPIO1,IO1.GPIO1] parameters: [4,7,5,6] - name: SPIbb2 - type: spibitbang2 #SPI bitbang via GPIO expander: CLK, SDI,SDO,CS + type: spibitbang3 #SPI bitbang via GPIO expander: CLK, SDI,SDO,CS parent: I2C_CLK devreg: [IO2.GPIO1,IO2.GPIO1,IO2.GPIO1,IO2.GPIO1] parameters: [4,7,5,6] + - name: LMP_GPIO + type: gpio_id + parameters: [21,20,16,12,7,8] + #This is the I2C devices in the RCU device_registers: - name: IO @@ -44,8 +48,12 @@ device_registers: description: Input/Ouput port 2 address: [1,3] #Read / Write address different store: True + - name: POL1 + address: 4 + - name: POL2 + address: 5 - - name: PLL2 + - name: PLL2 #200MHz on IO1 driver: SPIbb1 registers: - name: PLL_stat @@ -129,6 +137,14 @@ variables: dtype: boolean dim: 1 + - name: LMP_ID + driver: LMP_GPIO + devreg: ROM.ID #this is ignored + width: 6 + rw: ro + dtype: uint8 + + - name: APSCT_PCB_ID description: Unique PCB ID driver: I2C_CLK @@ -210,23 +226,52 @@ variables: bitoffset: 3 width: 1 - - name: APSCT_PLL_200MHz_locked_SPI - description: 0x81=locked + - name: APSCT_PLL_200MHz_lol + rw: ro + dtype: boolean + convert_unit: bool_invert + monitor: true driver: I2C_CLK - devreg: PLL2.PLL_stat - width: 8 + devreg: IO2.GPIO2 + bitoffset: 4 + width: 1 + + - name: APSCT_PLL_160MHz_lol rw: ro - dtype: uint8 - debug: True + dtype: boolean + convert_unit: bool_invert + monitor: true + driver: I2C_CLK + devreg: IO2.GPIO2 + bitoffset: 5 + width: 1 - - name: APSCT_PLL_160MHz_locked_SPI - description: 0x81=locked + - name: APSCT_PLL_clr_lol + rw: rw + dtype: boolean +# monitor: true driver: I2C_CLK - devreg: PLL1.PLL_stat - width: 8 - rw: ro - dtype: uint8 - debug: True + devreg: IO1.GPIO2 + bitoffset: 4 + width: 1 + +# - name: APSCT_PLL_200MHz_locked_SPI +# description: 0x81=locked +# driver: I2C_CLK +# devreg: PLL2.PLL_stat +# width: 8 +# rw: ro +# dtype: uint8 +# debug: True + + # - name: APSCT_PLL_160MHz_locked_SPI +# description: 0x81=locked +# driver: I2C_CLK +# devreg: PLL1.PLL_stat +# width: 8 +# rw: ro +# dtype: uint8 +# debug: True # - name: [APSCT_PLL_r3,APSCT_PLL_r5,APSCT_PLL_r6] # driver: I2C_CLK @@ -297,6 +342,7 @@ methods: - APSCT_PCB_version : Update - APSCT_PCB_number : Update - APSCT_PWR_on: Update + - LMP_ID: Update - APSCT_PWR_PLL_200MHz_on: Update - APSCT_PLL_200MHz_locked: Update - APSCT_PLL_200MHz_error: Update @@ -304,24 +350,41 @@ methods: - APSCT_PLL_160MHz_locked: Update - APSCT_PLL_160MHz_error: Update - APSCT_PPS_ignore : Update + - APSCT_PLL_clr_lol: Update + - APSCT_PLL_200MHz_lol: Update + - APSCT_PLL_160MHz_lol: Update +# - name: APSCT_clr_lol +# driver: I2C_CLK +# description: Clear lock-off-lock +# instructions: +# - APSCTTR_I2C_error : 0 + - name: APSCT_200MHz_on driver: I2C_CLK description: Configure clock. Monitored using APSCT_PWR_on, APSCT_PLL_error and APSCT_PLL_locked instructions: - APSCTTR_I2C_error : 0 + - IO1.POL1: 0 + - IO1.POL2: 0 + - IO2.POL1: 0 + - IO2.POL2: 0 - IO1.CONF1: 0x2C #0010 1100 PPS/PWR output, SCLK,CS,SDI - IO1.CONF2: 0x00 - IO2.CONF1: 0x2C #0010 1100 PPS/PWR output, SCLK,CS,SDI - - IO2.CONF2: 0x03 # + - IO2.CONF2: 0xFF # - IO1.GPIO1: 0x42 #0100 0010 high:200MHz PLL enable, CS high - - IO1.GPIO2: 0xF8 #PWR enable ##Check if not 4?? +# - IO1.GPIO2: 0xF8 #PWR enable ##Check if not 4?? + - IO1.GPIO2: 0x28 #PWR enable - IO2.GPIO1: 0x00 #All low - - IO2.GPIO2: 0x00 #All low (just inputs) +# - IO2.GPIO2: 0x00 #All low (just inputs) - WAIT: 200 - APSCT_PLL200_setup: 0 - WAIT: 200 #ms to wait before checking lock + - APSCT_PLL_clr_lol: 1 + - WAIT: 10 #ms + - APSCT_PLL_clr_lol: 0 - APSCTTR_Update: 0 #refresh all settings - name: APSCT_160MHz_on @@ -329,18 +392,25 @@ methods: description: Configure clock. Monitored using APSCT_PWR_on, APSCT_PLL_error and APSCT_PLL_locked instructions: - APSCTTR_I2C_error : 0 + - IO1.POL1: 0 + - IO1.POL2: 0 + - IO2.POL1: 0 + - IO2.POL2: 0 - IO1.CONF1: 0x2C #0010 1100 PPS/PWR output, SCLK,CS,SDI - IO1.CONF2: 0x00 - IO2.CONF1: 0x2C #0010 1100 PPS/PWR output, SCLK,CS,SDI - - IO2.CONF2: 0x03 # + - IO2.CONF2: 0xFF # - IO1.GPIO1: 0x00 - IO1.GPIO2: 0x08 #PWR enable ##Check if not 4?? - IO2.GPIO1: 0x42 #0100 0010 high:160MHz PLL enable, CS high - - IO2.GPIO2: 0x00 #All low (just inputs) +# - IO2.GPIO2: 0x00 #All low (just inputs) - WAIT: 200 - APSCT_PLL160_setup: 0 - WAIT: 200 #ms to wait before checking lock + - APSCT_PLL_clr_lol: 1 + - WAIT: 10 #ms + - APSCT_PLL_clr_lol: 0 - APSCTTR_Update: 0 #refresh all settings - name: APSCT_off @@ -358,45 +428,50 @@ methods: driver: I2C_CLK debug: true instructions: -# - PLL2.0x03: 0x08 #Set power, this is default - - PLL2.0x04: 0xCF # - - PLL2.0x05: 0x97 #was 97, set lock time = =x17? - - PLL2.0x06: 0x10 - - - PLL2.0x07: 0x04 #Stop R divider - - PLL2.0x08: 0x01 #Set R divider - - PLL2.0x07: 0x00 #Start R divider - - - PLL2.0x09: 0x10 #Stop N divider - - PLL2.0x0A: 0x14 #Set N divider=20, 200MHz/20=10MHz = input clock - - PLL2.0x09: 0x00 #Start N divider - - - PLL2.0x0D: 0x01 #Divider output 1=1 - - PLL2.0x0F: 0x01 #Divider output 2=1 - - PLL2.0x11: 0x01 #Divider output 3=1 - - PLL2.0x13: 0x01 #Divider output 4=1 + - PLL2.0x04: 0x01 #div a + - PLL2.0x05: 0x00 #div b, high + - PLL2.0x06: 0x14 #dib b, low + - PLL2.0x07: 0x00 # No LOR + - PLL2.0x08: 0x3B # Charge pump normal + Status bit + - PLL2.0x09: 0x30 # Charge pump current + - PLL2.0x0A: 0x00 # Fixed Divide 1 + - PLL2.0x0B: 0x00 + - PLL2.0x0C: 0x01 + - PLL2.0x45: 0x00 # CLK2 as feedback clock input + - PLL2.0x3d: 0x08 # OUT0 ON LVDS Standard + - PLL2.0x3e: 0x0a # OUT1 OFF + - PLL2.0x3f: 0x0a # OUT2 OFF + - PLL2.0x40: 0x03 # OUT3 OFF + - PLL2.0x41: 0x02 # OUT4 ON LVDS Standard + - PLL2.0x4b: 0x80 # OUT0 bypass divider + - PLL2.0x4d: 0x80 # OUT1 bypass divider + - PLL2.0x4f: 0x80 # OUT2 bypass divider + - PLL2.0x51: 0x80 # OUT3 bypass divider + - PLL2.0x53: 0x80 # OUT4 bypass divider + - PLL2.0x5a: 0x0f # Update registers - name: APSCT_PLL160_setup driver: I2C_CLK debug: true instructions: -# - PLL1.0x03: 0x08 #Set power, this is default - - PLL1.0x04: 0xCF # - - PLL1.0x05: 0x97 #was 97, set lock time = =x17? - - PLL1.0x06: 0x10 - - - PLL1.0x07: 0x04 #Stop R divider - - PLL1.0x08: 0x01 #Set R divider - - PLL1.0x07: 0x00 #Start R divider - - - PLL1.0x09: 0x10 #Stop N divider - - PLL1.0x0A: 0x10 #Set N divider=16, 160MHz/16=10MHz = input clock - - PLL1.0x09: 0x00 #Start N divider - - - PLL1.0x0D: 0x01 #Divider output 1=1 - - PLL1.0x0F: 0x01 #Divider output 2=1 - - PLL1.0x11: 0x01 #Divider output 3=1 - - PLL1.0x13: 0x01 #Divider output 4=1 - - - + - PLL1.0x04: 0x01 #div a + - PLL1.0x05: 0x00 #div b, high + - PLL1.0x06: 0x10 #dib b, low + - PLL1.0x07: 0x00 # No LOR + - PLL1.0x08: 0x3B # Charge pump normal + Status bit + - PLL1.0x09: 0x30 # Charge pump current + - PLL1.0x0A: 0x00 # Fixed Divide 1 + - PLL1.0x0B: 0x00 + - PLL1.0x0C: 0x01 + - PLL1.0x45: 0x00 # CLK2 as feedback clock input + - PLL1.0x3d: 0x08 # OUT0 ON LVDS Standard + - PLL1.0x3e: 0x0a # OUT1 OFF + - PLL1.0x3f: 0x0a # OUT2 OFF + - PLL1.0x40: 0x03 # OUT3 OFF + - PLL1.0x41: 0x02 # OUT4 ON LVDS Standard + - PLL1.0x4b: 0x80 # OUT0 bypass divider + - PLL1.0x4d: 0x80 # OUT1 bypass divider + - PLL1.0x4f: 0x80 # OUT2 bypass divider + - PLL1.0x51: 0x80 # OUT3 bypass divider + - PLL1.0x53: 0x80 # OUT4 bypass divider + - PLL1.0x5a: 0x0f # Update registers diff --git a/pypcc/config/UNB2TR.yaml b/pypcc/config/UNB2TR.yaml index a804f92b67ee2bd98dc848de9517ba41e2b300f5..08d98afe0d0e0d29713a9e99c9ea999aca0f98cd 100644 --- a/pypcc/config/UNB2TR.yaml +++ b/pypcc/config/UNB2TR.yaml @@ -52,6 +52,10 @@ drivers: type: gpio parameters: [11,13] + - name: I2C_reset_GPIO + type: gpio + parameters: [15,15] + #This is the I2C devices in the RCU device_registers: @@ -266,6 +270,15 @@ variables: dtype: boolean dim: 2 + - name: UNB2_I2C_reset + driver: I2C_reset_GPIO + mask: UNB2_mask + width: 1 + rw: rw + dtype: boolean + dim: 2 +# convert_unit: bool_invert + - name: UNB2_Front_Panel_LED_colour description: bit 0=Red, 1=Blue, 2=Green mask: UNB2_mask @@ -483,7 +496,8 @@ methods: debug: True instructions: - UNB2TR_I2C_error: 0 - - UNB2_I2C_enabled: 1 #Make sure I2C switches are enabled + - UNB2_I2C_enabled: 1 #Make sure UNB2 I2C switches are enabled + - UNB2_I2C_reset: 1 #Make sure APSCT I2C switches are enabled - UNB2_PCB_ID: Update - UNB2_PCB_version: Update - UNB2_PCB_number: Update diff --git a/pypcc/i2cserv/gpio.py b/pypcc/i2cserv/gpio.py index 74950d2bce32ec58a57b5c57ad1dfcb6583609b5..fbe08e588a435c625a9056919fe3e6b40982417f 100644 --- a/pypcc/i2cserv/gpio.py +++ b/pypcc/i2cserv/gpio.py @@ -11,24 +11,24 @@ class gpio(hwdev): self.pins=config['parameters'] self.Npins=len(self.pins); GPIO.setmode(GPIO.BCM) - self.state=[0 for pin in self.pins] - logging.info(str(("gpio, Pins=",self.state))); +# self.state=[0 for pin in self.pins] +# logging.info(str(("gpio, Pins=",self.state))); for i,pin in enumerate(self.pins): GPIO.setup(pin,GPIO.OUT) # for i,pin in enumerate(self.pins): # GPIO.setup(pin,GPIO.IN) -# self.state=[GPIO.input(pin) for pin in self.pins] -# logging.info(str(("gpio, Pins=",self.state))); + self.state=[GPIO.input(pin) for pin in self.pins] + logging.info(str((config['name']," gpio, Pins=",self.state))); def OPCUASetVariable(self,varid,var1,data,mask): logging.info("Set gpio"); if len(mask)!=self.Npins: - logging.warning("Wrong mask length"); + if len(mask)>0: logging.warning("GPIO Wrong mask length %i,%i"%(len(mask),self.Npins)); mask=[True]*self.Npins; if len(data)!=self.Npins: if len(data)==1: data=[data[0]]*self.Npins; else: - logging.warning("Wrong data length"); + logging.warning("GPIO Wrong data length"); return [] for i,pin in enumerate(self.pins): if mask[i]: diff --git a/pypcc/i2cserv/gpio_id.py b/pypcc/i2cserv/gpio_id.py new file mode 100644 index 0000000000000000000000000000000000000000..4fc24598545cbaf5241a1d768c648b23c9de2677 --- /dev/null +++ b/pypcc/i2cserv/gpio_id.py @@ -0,0 +1,34 @@ +#import numpy as np +from .hwdev import hwdev; +import logging +import RPi.GPIO as GPIO +from pypcc.queuetypes import * + + +class gpio_id(hwdev): + def __init__(self,config): + hwdev.__init__(self,config); + self.pins=config['parameters'] + self.Npins=len(self.pins); + GPIO.setmode(GPIO.BCM) + for i,pin in enumerate(self.pins): + GPIO.setup(pin,GPIO.IN) + logging.info(str((config['name']," gpio, value=",self.get_value()))); + + def get_value(self): + value=0; + for pin in self.pins: + value=2*value+1 if GPIO.input(pin) else 2*value + return value + + def OPCUASetVariable(self,varid,var1,data,mask): + return [] + + def OPCUAReadVariable(self,varid,var1,mask): + value=self.get_value() + logging.info(" gpio, value=%i"%value); + Data=OPCUAset(varid,InstType.varSet,[value],mask.copy()) + return [Data] + + + diff --git a/pypcc/i2cserv/spibitbang3.py b/pypcc/i2cserv/spibitbang3.py new file mode 100644 index 0000000000000000000000000000000000000000..f6bbbdad7767e019334a17617c7d923ed0610a02 --- /dev/null +++ b/pypcc/i2cserv/spibitbang3.py @@ -0,0 +1,97 @@ +from enum import Enum +import logging +import numpy as np +from .hwdev import hwdev + +class SPIBB_pins(Enum): + CLK = 0 + SDI = 1 + SDO = 2 + CS = 3 + + +class spibitbang3(hwdev): + def __init__(self,config): + hwdev.__init__(self,config) + + def i2csetget(self,addr,data,reg=None,read=0): + if read==0: return self.SetSPIbb(reg,data) + elif read==1: return self.GetSPIbb(reg,data) + else: logging.warn("Not implemented!") + return False; + + def SetSPIbb(self,address,value): + CSdev=self.conf['devreg'][SPIBB_pins.CS.value] + CSpin=self.conf['parameters'][SPIBB_pins.CS.value] + SDIdev=self.conf['devreg'][SPIBB_pins.SDI.value] + SDIpin=self.conf['parameters'][SPIBB_pins.SDI.value] + CLKdev=self.conf['devreg'][SPIBB_pins.CLK.value] + CLKpin=self.conf['parameters'][SPIBB_pins.CLK.value] + + logging.info(str(("SPIbb3 set",address,value))) + SetI2C=self.conf['parentcls'].SetVarValue + ADC_bytes = 0x00 + ADC_rw = 0x00 # 0 for write, 1 for read + data2 = ( ADC_rw << 23 ) + ( ADC_bytes << 21 ) + ( address << 8 ) + value[0] + bit_array = "{0:{fill}24b}".format(data2, fill='0') + + # print(bit_array) +# SetI2C(CSdev,1,CSpin,[1]) #disable + if not(SetI2C(CSdev,1,CSpin,[0])): return False #enable + for bit in bit_array: + SetI2C(SDIdev,1,SDIpin,[int(bit)]) + SetI2C(CLKdev,1,CLKpin,[1]) + SetI2C(CLKdev,1,CLKpin,[0]) + SetI2C(CSdev,1,CSpin,[1]) #disable +# SetI2C(SDOdev,1,SDOpin,[1]) #high when finished + return True; + + def GetSPIbb(self,reg_address,value): + CSdev=self.conf['devreg'][SPIBB_pins.CS.value] + CSpin=self.conf['parameters'][SPIBB_pins.CS.value] + SDOdev=self.conf['devreg'][SPIBB_pins.SDO.value] + SDOpin=self.conf['parameters'][SPIBB_pins.SDO.value] + SDIdev=self.conf['devreg'][SPIBB_pins.SDI.value] + SDIpin=self.conf['parameters'][SPIBB_pins.SDI.value] + CLKdev=self.conf['devreg'][SPIBB_pins.CLK.value] + CLKpin=self.conf['parameters'][SPIBB_pins.CLK.value] + + + logging.info(str(("SPIbb2 get",reg_address))) + SetI2C=self.conf['parentcls'].SetVarValue + GetI2C=self.conf['parentcls'].GetVarValue + + ADC_bytes = 0x00 + # ADC_rw = 0x01 # 0 for write, 1 for read + #data = (reg_address << 1) + 1 #was 7?? + ADC_rw = 0x01 # 0 for write, 1 for read + + data = ( ADC_rw << 15) + ( ADC_bytes << 13 ) + reg_address + + SetI2C(CSdev,1,CSpin,[1]) #disable + SetI2C(CSdev,1,CSpin,[0]) #enable + + bit_array = "{0:{fill}16b}".format(data, fill='0') + for bit in bit_array: + SetI2C(SDIdev,1,SDIpin,[int(bit)]) + SetI2C(CLKdev,1,CLKpin,[0]) + SetI2C(CLKdev,1,CLKpin,[1]) + + # print("read byte") + a=[0] + N=1 #len(value) + ret_value=[0] + for i in range(N): value[i]=0 + for cnt in range(8*(ADC_bytes+1)): + SetI2C(CLKdev,1,CLKpin,[0]) + SetI2C(CLKdev,1,CLKpin,[1]) #read after rising + GetI2C(SDOdev,1,SDOpin,ret_value) +# for i in range(N): value[i]=(value[i]<<1)+ ret_value[i] + for i in range(N): + if ret_value is None: value[i]=None + elif not value[i] is None: value[i]=(value[i]<<1)+ ret_value[i] + SetI2C(CLKdev,1,CLKpin,[0]) + SetI2C(CSdev,1,CSpin,[1]) #disable + return True; + + diff --git a/pypcc/pypcc.py b/pypcc/pypcc.py index 9d5cb779faa8255bfa55d6854f55ce70e3390879..af1cb0353aab3f2102e5c1ccdb99ed43c443d929 100755 --- a/pypcc/pypcc.py +++ b/pypcc/pypcc.py @@ -1,14 +1,10 @@ import logging import argparse -from pypcc.opcuaserv import opcuaserv -from pypcc.opcuaserv import i2client -from pypcc.opcuaserv import yamlreader -#from opcuaserv import pypcc2 -from pypcc.i2cserv import i2cthread import threading import time import sys import signal +from importlib_metadata import metadata parser = argparse.ArgumentParser() parser.add_argument("-s", "--simulator", help="Do not connect to I2c, but simulate behaviour.", action="store_true") @@ -30,6 +26,14 @@ args = parser.parse_args() #} #configure_logger(logstash_host=args.loghost,level=args.loglevel, log_extra=log_extra) logging.getLogger().setLevel(args.loglevel) +git_hash=metadata("pypcc")["Summary"] +logging.info("Git Hash="+git_hash) + +from pypcc.opcuaserv import opcuaserv +from pypcc.opcuaserv import i2client +from pypcc.opcuaserv import yamlreader +#from opcuaserv import pypcc2 +from pypcc.i2cserv import i2cthread RunTimer=True; def signal_handler(sig, frame): @@ -64,6 +68,7 @@ configs=[] if not(args.test): handler=opcuaserv.InitServer(port=args.port) logging.info("Load OPCUA variables & start i2c listing thread") + opcuaserv.AddVarR("pypcc_git_hash",git_hash,[],False) for i,name in enumerate(I2Cports): RCU_I2C=I2Cclients[i] RCU_conf=yamlreader.yamlreader(RCU_I2C,yamlfile=name) diff --git a/scripts/apsct_test.py b/scripts/apsct_test.py new file mode 100644 index 0000000000000000000000000000000000000000..9721a9d3687bfd7b7e84b1cf1c8d68cc041f67f9 --- /dev/null +++ b/scripts/apsct_test.py @@ -0,0 +1,35 @@ +from test_common import * +from time import sleep +connect("opc.tcp://localhost:4843/") + +if True: + print("Switch off") + callmethod("APSCT_off") + sleep(0.5) + wait_not_busy("APSCTTR_translator_busy_R",timeout_sec=3) + +if True: + print("Setup 160MHz") + callmethod("APSCT_160MHz_on") + sleep(0.5) + wait_not_busy("APSCTTR_translator_busy_R",timeout_sec=3) + +if False: + print("Setup 200MHz") + callmethod("APSCT_200MHz_on") + sleep(0.5) + wait_not_busy("APSCTTR_translator_busy_R",timeout_sec=3) + +if False: + print("Get monitor values") + set_value("APSCTTR_monitor_rate_RW",1) + sleep(3) + set_value("APSCTTR_monitor_rate_RW",30) + + +names=get_all_variables() +for name in names: + att=get_value(name) + print(name,[att]) + +disconnect(); diff --git a/scripts/git_hash.py b/scripts/git_hash.py new file mode 100644 index 0000000000000000000000000000000000000000..6a44e1cc3368d06228c41e041dd8ed02c40ab555 --- /dev/null +++ b/scripts/git_hash.py @@ -0,0 +1,4 @@ +from test_common import * +connect("opc.tcp://localhost:4840/") +print(get_value("pypcc_git_hash")) +disconnect(); diff --git a/scripts/test_common.py b/scripts/test_common.py index 634fc8067bf6e679095e3d21ada8abe8421d4f97..02a36ba0596ef0217997ec45b3081c41504aeab0 100644 --- a/scripts/test_common.py +++ b/scripts/test_common.py @@ -41,6 +41,16 @@ def set_value(name,value,tp=None): else: var1.set_value(value,tp) +def get_all_variables(): + vars0=[] + obj0=root.get_child(["0:Objects"]) + for nodeid in obj0.get_children(): + ch = client.get_node(nodeid) + name=ch.get_display_name().Text + if ch.get_node_class()==ua.NodeClass.Variable: + vars0.append(name) + return vars0 + def get_debug_value(name): var1 = root.get_child(["0:Objects", "2:DEBUG", "2:"+name]) diff --git a/setup.py b/setup.py index 25adcbf6c8ede44d4565fb729756ec288db654f7..16a86eba70e3e6396395cf7287db5637d6549b8c 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,26 @@ import setuptools +import subprocess +def _get_version_hash(): + """Talk to git and find out the tag/hash of our latest commit""" + try: + p = subprocess.Popen(["git", "rev-parse","HEAD"], +# p = subprocess.Popen(["git", "log","-1","--format='%H'"], + stdout=subprocess.PIPE) + except EnvironmentError: + print("Couldn't run git to get a version number for setup.py") + return + ver = p.communicate()[0] + ver=ver.strip() + ver=str(ver)[2:-1] + print("Git hash=",ver) + return ver + #with open('requirements.txt') as f: # required = f.read().splitlines() # Requires: setup.cfg -setuptools.setup(install_requires=["asyncua", +setuptools.setup(description=_get_version_hash(), + install_requires=["asyncua", "numpy", "recordclass", "pyyaml",