From 6ead050b6ce128ead3254be5d6eed05aed60233a Mon Sep 17 00:00:00 2001
From: Paulus Kruger <Kruger@NBKRUGER-W10.nfra.nl>
Date: Mon, 11 Apr 2022 17:10:30 +0200
Subject: [PATCH] make it a library

---
 log.txt                                       |   8 ------
 CRC_HBAT1.npy => pypcc/CRC_HBAT1.npy          | Bin
 SCTable.py => pypcc/SCTable.py                |   0
 VarTable.py => pypcc/VarTable.py              |   0
 {i2cserv => pypcc}/__init__.py                |   0
 {config => pypcc/config}/APSCTTR.yaml         |   0
 {config => pypcc/config}/APSPUTR.yaml         |   0
 {config => pypcc/config}/CLK.yaml             |   0
 {config => pypcc/config}/HBAT2.yaml           |   0
 {config => pypcc/config}/PPS.yaml             |   0
 {config => pypcc/config}/RCU.yaml             |   0
 {config => pypcc/config}/RCUL.yaml            |   0
 {config => pypcc/config}/RCU_uC_test.yaml     |   0
 {config => pypcc/config}/RECVTR.yaml          |   0
 {config => pypcc/config}/RECVTR_HB.yaml       |   0
 {config => pypcc/config}/RECVTR_LB.yaml       |   0
 {config => pypcc/config}/UNB2.yaml            |   0
 {config => pypcc/config}/UNB2TR.yaml          |   0
 {config => pypcc/config}/apsctl.schema.json   |   0
 {opcuaserv => pypcc/i2cserv}/__init__.py      |   0
 {i2cserv => pypcc/i2cserv}/gpio.py            |   2 +-
 .../i2cserv}/gpio_hba_trigger.py              |   0
 {i2cserv => pypcc/i2cserv}/gpio_pps.py        |   2 +-
 {i2cserv => pypcc/i2cserv}/hba1.py            |   2 +-
 {i2cserv => pypcc/i2cserv}/hbat2_array.py     |   0
 {i2cserv => pypcc/i2cserv}/hbat2raw.py        |   0
 {i2cserv => pypcc/i2cserv}/hbat_pico_io.py    |   0
 {i2cserv => pypcc/i2cserv}/hwdev.py           |   0
 {i2cserv => pypcc/i2cserv}/i2c.py             |   0
 {i2cserv => pypcc/i2cserv}/i2c_array.py       |   0
 {i2cserv => pypcc/i2cserv}/i2c_array2.py      |   0
 {i2cserv => pypcc/i2cserv}/i2c_dev.py         |   0
 {i2cserv => pypcc/i2cserv}/i2c_smbus.py       |   0
 {i2cserv => pypcc/i2cserv}/i2c_switch.py      |   0
 {i2cserv => pypcc/i2cserv}/i2c_switch2.py     |   0
 {i2cserv => pypcc/i2cserv}/i2cbitbang1.py     |   0
 {i2cserv => pypcc/i2cserv}/i2cbitbangp.py     |   0
 {i2cserv => pypcc/i2cserv}/i2cp.py            |   0
 {i2cserv => pypcc/i2cserv}/i2cthread.py       |   4 +--
 {i2cserv => pypcc/i2cserv}/spibitbang1.py     |   0
 {i2cserv => pypcc/i2cserv}/spibitbang2.py     |   0
 pypcc/opcuaserv/__init__.py                   |   0
 .../opcuaserv}/convert_unit.py                |   0
 {opcuaserv => pypcc/opcuaserv}/i2client.py    |   2 +-
 {opcuaserv => pypcc/opcuaserv}/opcuaserv.py   |   0
 {opcuaserv => pypcc/opcuaserv}/smbus_float.py |   0
 {opcuaserv => pypcc/opcuaserv}/yamlreader.py  |   4 +--
 pypcc2.py => pypcc/pypcc.py                   |  27 +++++++++---------
 queuetypes.py => pypcc/queuetypes.py          |   0
 yamlconfig.py => pypcc/yamlconfig.py          |   7 +++--
 start.sh => scripts/start.sh                  |   0
 setup.cfg                                     |  25 ++++++++++++++++
 setup.py                                      |  12 ++++++++
 logconfig.py => tests/logconfig.py            |   0
 testCLK.py => tests/testCLK.py                |   0
 testDTH.py => tests/testDTH.py                |   0
 testHBA.py => tests/testHBA.py                |   0
 testHBA2_pico.py => tests/testHBA2_pico.py    |   0
 testRCU.py => tests/testRCU.py                |   0
 testRCU1.py => tests/testRCU1.py              |   0
 testRCUH.py => tests/testRCUH.py              |   0
 testRCUH_pwr.py => tests/testRCUH_pwr.py      |   0
 testRCUL.py => tests/testRCUL.py              |   0
 testRCUL_on.py => tests/testRCUL_on.py        |   0
 testUNB2.py => tests/testUNB2.py              |   0
 test_common.py => tests/test_common.py        |   0
 66 files changed, 64 insertions(+), 31 deletions(-)
 delete mode 100644 log.txt
 rename CRC_HBAT1.npy => pypcc/CRC_HBAT1.npy (100%)
 rename SCTable.py => pypcc/SCTable.py (100%)
 rename VarTable.py => pypcc/VarTable.py (100%)
 rename {i2cserv => pypcc}/__init__.py (100%)
 rename {config => pypcc/config}/APSCTTR.yaml (100%)
 rename {config => pypcc/config}/APSPUTR.yaml (100%)
 rename {config => pypcc/config}/CLK.yaml (100%)
 rename {config => pypcc/config}/HBAT2.yaml (100%)
 rename {config => pypcc/config}/PPS.yaml (100%)
 rename {config => pypcc/config}/RCU.yaml (100%)
 rename {config => pypcc/config}/RCUL.yaml (100%)
 rename {config => pypcc/config}/RCU_uC_test.yaml (100%)
 rename {config => pypcc/config}/RECVTR.yaml (100%)
 rename {config => pypcc/config}/RECVTR_HB.yaml (100%)
 rename {config => pypcc/config}/RECVTR_LB.yaml (100%)
 rename {config => pypcc/config}/UNB2.yaml (100%)
 rename {config => pypcc/config}/UNB2TR.yaml (100%)
 rename {config => pypcc/config}/apsctl.schema.json (100%)
 rename {opcuaserv => pypcc/i2cserv}/__init__.py (100%)
 rename {i2cserv => pypcc/i2cserv}/gpio.py (97%)
 rename {i2cserv => pypcc/i2cserv}/gpio_hba_trigger.py (100%)
 rename {i2cserv => pypcc/i2cserv}/gpio_pps.py (98%)
 rename {i2cserv => pypcc/i2cserv}/hba1.py (98%)
 rename {i2cserv => pypcc/i2cserv}/hbat2_array.py (100%)
 rename {i2cserv => pypcc/i2cserv}/hbat2raw.py (100%)
 rename {i2cserv => pypcc/i2cserv}/hbat_pico_io.py (100%)
 rename {i2cserv => pypcc/i2cserv}/hwdev.py (100%)
 rename {i2cserv => pypcc/i2cserv}/i2c.py (100%)
 rename {i2cserv => pypcc/i2cserv}/i2c_array.py (100%)
 rename {i2cserv => pypcc/i2cserv}/i2c_array2.py (100%)
 rename {i2cserv => pypcc/i2cserv}/i2c_dev.py (100%)
 rename {i2cserv => pypcc/i2cserv}/i2c_smbus.py (100%)
 rename {i2cserv => pypcc/i2cserv}/i2c_switch.py (100%)
 rename {i2cserv => pypcc/i2cserv}/i2c_switch2.py (100%)
 rename {i2cserv => pypcc/i2cserv}/i2cbitbang1.py (100%)
 rename {i2cserv => pypcc/i2cserv}/i2cbitbangp.py (100%)
 rename {i2cserv => pypcc/i2cserv}/i2cp.py (100%)
 rename {i2cserv => pypcc/i2cserv}/i2cthread.py (98%)
 rename {i2cserv => pypcc/i2cserv}/spibitbang1.py (100%)
 rename {i2cserv => pypcc/i2cserv}/spibitbang2.py (100%)
 create mode 100644 pypcc/opcuaserv/__init__.py
 rename {opcuaserv => pypcc/opcuaserv}/convert_unit.py (100%)
 rename {opcuaserv => pypcc/opcuaserv}/i2client.py (97%)
 rename {opcuaserv => pypcc/opcuaserv}/opcuaserv.py (100%)
 rename {opcuaserv => pypcc/opcuaserv}/smbus_float.py (100%)
 rename {opcuaserv => pypcc/opcuaserv}/yamlreader.py (99%)
 rename pypcc2.py => pypcc/pypcc.py (84%)
 rename queuetypes.py => pypcc/queuetypes.py (100%)
 rename yamlconfig.py => pypcc/yamlconfig.py (97%)
 rename start.sh => scripts/start.sh (100%)
 create mode 100644 setup.cfg
 create mode 100644 setup.py
 rename logconfig.py => tests/logconfig.py (100%)
 rename testCLK.py => tests/testCLK.py (100%)
 rename testDTH.py => tests/testDTH.py (100%)
 rename testHBA.py => tests/testHBA.py (100%)
 rename testHBA2_pico.py => tests/testHBA2_pico.py (100%)
 rename testRCU.py => tests/testRCU.py (100%)
 rename testRCU1.py => tests/testRCU1.py (100%)
 rename testRCUH.py => tests/testRCUH.py (100%)
 rename testRCUH_pwr.py => tests/testRCUH_pwr.py (100%)
 rename testRCUL.py => tests/testRCUL.py (100%)
 rename testRCUL_on.py => tests/testRCUL_on.py (100%)
 rename testUNB2.py => tests/testUNB2.py (100%)
 rename test_common.py => tests/test_common.py (100%)

diff --git a/log.txt b/log.txt
deleted file mode 100644
index 71156f5..0000000
--- 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 eaa4731..74950d2 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 b06843b..d7a6e6c 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 25b13af..9ab8b63 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 7d9675d..ee4d9d7 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 0000000..e69de29
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 b00d227..80024fe 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 5c16162..29d4f7b 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 624abf9..10df5ac 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 f0c304e..4005ad7 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 0000000..4f9c9a0
--- /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 0000000..730cc02
--- /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
-- 
GitLab