diff --git a/log.txt b/log.txt deleted file mode 100644 index 71156f50a3ec5dff55b1112e09a980860fe23f56..0000000000000000000000000000000000000000 --- a/log.txt +++ /dev/null @@ -1,8 +0,0 @@ -ID= ['0x0', '0x81', '0x3a', '0x24'] -Frequency set= 150000000 -['0x8', '0xf0', '0xd1', '0x80'] -si status: 0x80 -si status: 0x80 -si status: 0x80 -Frequency read back= 150000000 -['0x8', '0xf0', '0xd1', '0x80', '0x8', '0xf0', '0xd1', '0x80', '0x8', '0xf0', '0xd1', '0x80', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0'] diff --git a/CRC_HBAT1.npy b/pypcc/CRC_HBAT1.npy similarity index 100% rename from CRC_HBAT1.npy rename to pypcc/CRC_HBAT1.npy diff --git a/SCTable.py b/pypcc/SCTable.py similarity index 100% rename from SCTable.py rename to pypcc/SCTable.py diff --git a/VarTable.py b/pypcc/VarTable.py similarity index 100% rename from VarTable.py rename to pypcc/VarTable.py diff --git a/i2cserv/__init__.py b/pypcc/__init__.py similarity index 100% rename from i2cserv/__init__.py rename to pypcc/__init__.py diff --git a/config/APSCTTR.yaml b/pypcc/config/APSCTTR.yaml similarity index 100% rename from config/APSCTTR.yaml rename to pypcc/config/APSCTTR.yaml diff --git a/config/APSPUTR.yaml b/pypcc/config/APSPUTR.yaml similarity index 100% rename from config/APSPUTR.yaml rename to pypcc/config/APSPUTR.yaml diff --git a/config/CLK.yaml b/pypcc/config/CLK.yaml similarity index 100% rename from config/CLK.yaml rename to pypcc/config/CLK.yaml diff --git a/config/HBAT2.yaml b/pypcc/config/HBAT2.yaml similarity index 100% rename from config/HBAT2.yaml rename to pypcc/config/HBAT2.yaml diff --git a/config/PPS.yaml b/pypcc/config/PPS.yaml similarity index 100% rename from config/PPS.yaml rename to pypcc/config/PPS.yaml diff --git a/config/RCU.yaml b/pypcc/config/RCU.yaml similarity index 100% rename from config/RCU.yaml rename to pypcc/config/RCU.yaml diff --git a/config/RCUL.yaml b/pypcc/config/RCUL.yaml similarity index 100% rename from config/RCUL.yaml rename to pypcc/config/RCUL.yaml diff --git a/config/RCU_uC_test.yaml b/pypcc/config/RCU_uC_test.yaml similarity index 100% rename from config/RCU_uC_test.yaml rename to pypcc/config/RCU_uC_test.yaml diff --git a/config/RECVTR.yaml b/pypcc/config/RECVTR.yaml similarity index 100% rename from config/RECVTR.yaml rename to pypcc/config/RECVTR.yaml diff --git a/config/RECVTR_HB.yaml b/pypcc/config/RECVTR_HB.yaml similarity index 100% rename from config/RECVTR_HB.yaml rename to pypcc/config/RECVTR_HB.yaml diff --git a/config/RECVTR_LB.yaml b/pypcc/config/RECVTR_LB.yaml similarity index 100% rename from config/RECVTR_LB.yaml rename to pypcc/config/RECVTR_LB.yaml diff --git a/config/UNB2.yaml b/pypcc/config/UNB2.yaml similarity index 100% rename from config/UNB2.yaml rename to pypcc/config/UNB2.yaml diff --git a/config/UNB2TR.yaml b/pypcc/config/UNB2TR.yaml similarity index 100% rename from config/UNB2TR.yaml rename to pypcc/config/UNB2TR.yaml diff --git a/config/apsctl.schema.json b/pypcc/config/apsctl.schema.json similarity index 100% rename from config/apsctl.schema.json rename to pypcc/config/apsctl.schema.json diff --git a/opcuaserv/__init__.py b/pypcc/i2cserv/__init__.py similarity index 100% rename from opcuaserv/__init__.py rename to pypcc/i2cserv/__init__.py diff --git a/i2cserv/gpio.py b/pypcc/i2cserv/gpio.py similarity index 97% rename from i2cserv/gpio.py rename to pypcc/i2cserv/gpio.py index eaa473191ee7204e842efc90e45ba505d715c097..74950d2bce32ec58a57b5c57ad1dfcb6583609b5 100644 --- a/i2cserv/gpio.py +++ b/pypcc/i2cserv/gpio.py @@ -2,7 +2,7 @@ from .hwdev import hwdev; import logging import RPi.GPIO as GPIO -from queuetypes import * +from pypcc.queuetypes import * class gpio(hwdev): diff --git a/i2cserv/gpio_hba_trigger.py b/pypcc/i2cserv/gpio_hba_trigger.py similarity index 100% rename from i2cserv/gpio_hba_trigger.py rename to pypcc/i2cserv/gpio_hba_trigger.py diff --git a/i2cserv/gpio_pps.py b/pypcc/i2cserv/gpio_pps.py similarity index 98% rename from i2cserv/gpio_pps.py rename to pypcc/i2cserv/gpio_pps.py index b06843b8103dca0117076b61b4b1f1a191e5bde6..d7a6e6c6b8203a6cf7d4ee2c6c5493d664667b04 100644 --- a/i2cserv/gpio_pps.py +++ b/pypcc/i2cserv/gpio_pps.py @@ -1,7 +1,7 @@ from .hwdev import hwdev; import logging import threading -from queuetypes import * +from pypcc.queuetypes import * import time; import struct diff --git a/i2cserv/hba1.py b/pypcc/i2cserv/hba1.py similarity index 98% rename from i2cserv/hba1.py rename to pypcc/i2cserv/hba1.py index 25b13aff3f5c04ef46a3a155b39aeec01528be5c..9ab8b63e9201ac9b1cac1b9f6e3acde48a97b2f6 100644 --- a/i2cserv/hba1.py +++ b/pypcc/i2cserv/hba1.py @@ -3,7 +3,7 @@ from .hwdev import hwdev import logging from .i2c_array import ApplyMask from time import sleep -from queuetypes import * +from pypcc.queuetypes import * import signal try: import RPi.GPIO as GPIO diff --git a/i2cserv/hbat2_array.py b/pypcc/i2cserv/hbat2_array.py similarity index 100% rename from i2cserv/hbat2_array.py rename to pypcc/i2cserv/hbat2_array.py diff --git a/i2cserv/hbat2raw.py b/pypcc/i2cserv/hbat2raw.py similarity index 100% rename from i2cserv/hbat2raw.py rename to pypcc/i2cserv/hbat2raw.py diff --git a/i2cserv/hbat_pico_io.py b/pypcc/i2cserv/hbat_pico_io.py similarity index 100% rename from i2cserv/hbat_pico_io.py rename to pypcc/i2cserv/hbat_pico_io.py diff --git a/i2cserv/hwdev.py b/pypcc/i2cserv/hwdev.py similarity index 100% rename from i2cserv/hwdev.py rename to pypcc/i2cserv/hwdev.py diff --git a/i2cserv/i2c.py b/pypcc/i2cserv/i2c.py similarity index 100% rename from i2cserv/i2c.py rename to pypcc/i2cserv/i2c.py diff --git a/i2cserv/i2c_array.py b/pypcc/i2cserv/i2c_array.py similarity index 100% rename from i2cserv/i2c_array.py rename to pypcc/i2cserv/i2c_array.py diff --git a/i2cserv/i2c_array2.py b/pypcc/i2cserv/i2c_array2.py similarity index 100% rename from i2cserv/i2c_array2.py rename to pypcc/i2cserv/i2c_array2.py diff --git a/i2cserv/i2c_dev.py b/pypcc/i2cserv/i2c_dev.py similarity index 100% rename from i2cserv/i2c_dev.py rename to pypcc/i2cserv/i2c_dev.py diff --git a/i2cserv/i2c_smbus.py b/pypcc/i2cserv/i2c_smbus.py similarity index 100% rename from i2cserv/i2c_smbus.py rename to pypcc/i2cserv/i2c_smbus.py diff --git a/i2cserv/i2c_switch.py b/pypcc/i2cserv/i2c_switch.py similarity index 100% rename from i2cserv/i2c_switch.py rename to pypcc/i2cserv/i2c_switch.py diff --git a/i2cserv/i2c_switch2.py b/pypcc/i2cserv/i2c_switch2.py similarity index 100% rename from i2cserv/i2c_switch2.py rename to pypcc/i2cserv/i2c_switch2.py diff --git a/i2cserv/i2cbitbang1.py b/pypcc/i2cserv/i2cbitbang1.py similarity index 100% rename from i2cserv/i2cbitbang1.py rename to pypcc/i2cserv/i2cbitbang1.py diff --git a/i2cserv/i2cbitbangp.py b/pypcc/i2cserv/i2cbitbangp.py similarity index 100% rename from i2cserv/i2cbitbangp.py rename to pypcc/i2cserv/i2cbitbangp.py diff --git a/i2cserv/i2cp.py b/pypcc/i2cserv/i2cp.py similarity index 100% rename from i2cserv/i2cp.py rename to pypcc/i2cserv/i2cp.py diff --git a/i2cserv/i2cthread.py b/pypcc/i2cserv/i2cthread.py similarity index 98% rename from i2cserv/i2cthread.py rename to pypcc/i2cserv/i2cthread.py index 7d9675ddaa439bf6e1e83f3b93dc90f3798a926f..ee4d9d72bc1cd61875dad9721cb3037b3584041e 100644 --- a/i2cserv/i2cthread.py +++ b/pypcc/i2cserv/i2cthread.py @@ -1,7 +1,7 @@ #Start the correct I2C server connect to the pipes on a new process import logging from multiprocessing import Process -from queuetypes import * +from pypcc.queuetypes import * from time import sleep #from i2cserv import I2Cswitch1 #from i2cserv import I2C_dummy as I2C @@ -9,7 +9,7 @@ from time import sleep #from i2cserv import RCU #from i2cserv import CLK -import yamlconfig as yc +import pypcc.yamlconfig as yc import yaml class AttrDict(object): diff --git a/i2cserv/spibitbang1.py b/pypcc/i2cserv/spibitbang1.py similarity index 100% rename from i2cserv/spibitbang1.py rename to pypcc/i2cserv/spibitbang1.py diff --git a/i2cserv/spibitbang2.py b/pypcc/i2cserv/spibitbang2.py similarity index 100% rename from i2cserv/spibitbang2.py rename to pypcc/i2cserv/spibitbang2.py diff --git a/pypcc/opcuaserv/__init__.py b/pypcc/opcuaserv/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/opcuaserv/convert_unit.py b/pypcc/opcuaserv/convert_unit.py similarity index 100% rename from opcuaserv/convert_unit.py rename to pypcc/opcuaserv/convert_unit.py diff --git a/opcuaserv/i2client.py b/pypcc/opcuaserv/i2client.py similarity index 97% rename from opcuaserv/i2client.py rename to pypcc/opcuaserv/i2client.py index b00d227a52297b16e43c29ff4962a926804b1427..80024fe10b647970824c4b21f557c38117f972fe 100644 --- a/opcuaserv/i2client.py +++ b/pypcc/opcuaserv/i2client.py @@ -1,7 +1,7 @@ #This is the OPC-UA side of the pipes to I2Cserver from multiprocessing import Queue -from queuetypes import * +from pypcc.queuetypes import * class i2client(): diff --git a/opcuaserv/opcuaserv.py b/pypcc/opcuaserv/opcuaserv.py similarity index 100% rename from opcuaserv/opcuaserv.py rename to pypcc/opcuaserv/opcuaserv.py diff --git a/opcuaserv/smbus_float.py b/pypcc/opcuaserv/smbus_float.py similarity index 100% rename from opcuaserv/smbus_float.py rename to pypcc/opcuaserv/smbus_float.py diff --git a/opcuaserv/yamlreader.py b/pypcc/opcuaserv/yamlreader.py similarity index 99% rename from opcuaserv/yamlreader.py rename to pypcc/opcuaserv/yamlreader.py index 5c1616274bca3eb3848be16b7b0950aaaf658a17..29d4f7bd189d0a90aedf7615ee59606a2f474a1c 100644 --- a/opcuaserv/yamlreader.py +++ b/pypcc/opcuaserv/yamlreader.py @@ -1,10 +1,10 @@ import yaml import struct import time -from yamlconfig import * +from pypcc.yamlconfig import * import logging from .smbus_float import * -from opcuaserv import convert_unit +from pypcc.opcuaserv import convert_unit def bytes2int(bts): x=0; for b in bts: diff --git a/pypcc2.py b/pypcc/pypcc.py similarity index 84% rename from pypcc2.py rename to pypcc/pypcc.py index 624abf9328af54324f51d5551c5132f60e94683e..10df5acc2a6df4f2cff97f688fd8780c7b0f78f0 100755 --- a/pypcc2.py +++ b/pypcc/pypcc.py @@ -1,10 +1,10 @@ import logging import argparse -from opcuaserv import opcuaserv -from opcuaserv import i2client -from opcuaserv import yamlreader +from pypcc.opcuaserv import opcuaserv +from pypcc.opcuaserv import i2client +from pypcc.opcuaserv import yamlreader #from opcuaserv import pypcc2 -from i2cserv import i2cthread +from pypcc.i2cserv import i2cthread import threading import time import sys @@ -19,15 +19,16 @@ parser.add_argument("--loghost", help="Logstash host to which to forward logs [% parser.add_argument("-c", "--config", help="YAML config files, comma seperated [%(default)s]",type=str, default='RCU') args = parser.parse_args() -from logconfig import configure_logger -log_extra = { - "simulator": args.simulator, - "test": args.test, - "port": args.port, - "config": args.config, - "lofar_id": f"pypcc - {args.config}", -} -configure_logger(logstash_host=args.loghost,level=args.loglevel, log_extra=log_extra) +#Todo test logstash +#from logconfig import configure_logger +#log_extra = { +# "simulator": args.simulator, +# "test": args.test, +# "port": args.port, +# "config": args.config, +# "lofar_id": f"pypcc - {args.config}", +#} +#configure_logger(logstash_host=args.loghost,level=args.loglevel, log_extra=log_extra) RunTimer=True; def signal_handler(sig, frame): diff --git a/queuetypes.py b/pypcc/queuetypes.py similarity index 100% rename from queuetypes.py rename to pypcc/queuetypes.py diff --git a/yamlconfig.py b/pypcc/yamlconfig.py similarity index 97% rename from yamlconfig.py rename to pypcc/yamlconfig.py index f0c304e78ff994b418b471d0c17b293437ccc8c5..4005ad77699ec3aa50f4c39f2c83eb72a43d6436 100644 --- a/yamlconfig.py +++ b/pypcc/yamlconfig.py @@ -2,6 +2,7 @@ import yaml import struct import time import logging +import importlib.resources as importlib_resources def Find(L,name,value,default=False): for x in L: @@ -24,7 +25,9 @@ def str2int(x): class yamlconfig(): def __init__(self,yamlfile='RCU'): - self.conf=yaml.load(open("config/"+yamlfile+'.yaml')) + pkg = importlib_resources.files("pypcc") + pkg_data_file = pkg / "config" / (yamlfile+'.yaml') + self.conf=yaml.load(pkg_data_file.open()) self.expand_variables() # print([[v['name'],v.get('devreg')] for v in var1]) # print(len(self.conf['variables']),N) @@ -158,7 +161,7 @@ class yamlconfig(): for c in self.conf['drivers']: # print("loading",c['name'],c['type']); # try: - i = importlib.import_module("i2cserv."+c['type']) + i = importlib.import_module("pypcc.i2cserv."+c['type']) # except: # logging.warn("No driver for "+c['type']) # c['obj']=None; diff --git a/start.sh b/scripts/start.sh similarity index 100% rename from start.sh rename to scripts/start.sh diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4f9c9a084505b8a6f6615e65789af05836c9df60 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,25 @@ +[metadata] +name = pypcc +version = 0.1.0 +summary = LOFAR 2.0 APSCT hardware translator +description_file = + README.md +description_content_type = text/x-rst; charset=UTF-8 +author = ASTRON +home_page = https://astron.nl + +[options] +package_dir= + =. +packages=find: +python_requires = >=3.7 + +[options.packages.find] +where=. + +[options.entry_points] +console_scripts = + hwtr = pypcc.pypcc:main + +[options.package_data] +pypcc = config/*.yaml \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..730cc02f6e36f1ac8c023f55e8086d08a1772c55 --- /dev/null +++ b/setup.py @@ -0,0 +1,12 @@ +import setuptools + +#with open('requirements.txt') as f: +# required = f.read().splitlines() +# Requires: setup.cfg +setuptools.setup(install_requires=["opcua", + "numpy", + "recordclass", + "pyyaml", + "python-logstash-async", + ]) + diff --git a/logconfig.py b/tests/logconfig.py similarity index 100% rename from logconfig.py rename to tests/logconfig.py diff --git a/testCLK.py b/tests/testCLK.py similarity index 100% rename from testCLK.py rename to tests/testCLK.py diff --git a/testDTH.py b/tests/testDTH.py similarity index 100% rename from testDTH.py rename to tests/testDTH.py diff --git a/testHBA.py b/tests/testHBA.py similarity index 100% rename from testHBA.py rename to tests/testHBA.py diff --git a/testHBA2_pico.py b/tests/testHBA2_pico.py similarity index 100% rename from testHBA2_pico.py rename to tests/testHBA2_pico.py diff --git a/testRCU.py b/tests/testRCU.py similarity index 100% rename from testRCU.py rename to tests/testRCU.py diff --git a/testRCU1.py b/tests/testRCU1.py similarity index 100% rename from testRCU1.py rename to tests/testRCU1.py diff --git a/testRCUH.py b/tests/testRCUH.py similarity index 100% rename from testRCUH.py rename to tests/testRCUH.py diff --git a/testRCUH_pwr.py b/tests/testRCUH_pwr.py similarity index 100% rename from testRCUH_pwr.py rename to tests/testRCUH_pwr.py diff --git a/testRCUL.py b/tests/testRCUL.py similarity index 100% rename from testRCUL.py rename to tests/testRCUL.py diff --git a/testRCUL_on.py b/tests/testRCUL_on.py similarity index 100% rename from testRCUL_on.py rename to tests/testRCUL_on.py diff --git a/testUNB2.py b/tests/testUNB2.py similarity index 100% rename from testUNB2.py rename to tests/testUNB2.py diff --git a/test_common.py b/tests/test_common.py similarity index 100% rename from test_common.py rename to tests/test_common.py