aboutsummaryrefslogtreecommitdiffstats
path: root/dpd/src/Adapt.py
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-08-24 19:28:17 +0200
committerandreas128 <Andreas>2017-08-24 19:28:17 +0200
commitc4f2d4a830890590af16e58e97707b2aa21bc29b (patch)
treeb0bbbfd46c0cbfc3fa2e872e9d69a20dec6db7e8 /dpd/src/Adapt.py
parent3ca742663b6bf20a89c28a70668f50ceee6a23d0 (diff)
downloaddabmod-c4f2d4a830890590af16e58e97707b2aa21bc29b.tar.gz
dabmod-c4f2d4a830890590af16e58e97707b2aa21bc29b.tar.bz2
dabmod-c4f2d4a830890590af16e58e97707b2aa21bc29b.zip
Add control for dpd phase coefficient
Diffstat (limited to 'dpd/src/Adapt.py')
-rw-r--r--dpd/src/Adapt.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/dpd/src/Adapt.py b/dpd/src/Adapt.py
index 4117856..cc4c8c7 100644
--- a/dpd/src/Adapt.py
+++ b/dpd/src/Adapt.py
@@ -23,10 +23,11 @@ class Adapt:
ZMQ remote control.
"""
- def __init__(self, port, coef_path):
+ def __init__(self, port, coef_am_path, coef_pm_path):
logging.info("Instantiate Adapt object")
self.port = port
- self.coef_path = coef_path
+ self.coef_am_path = coef_am_path
+ self.coef_pm_path = coef_pm_path
self.host = "localhost"
self._context = zmq.Context()
@@ -110,10 +111,10 @@ class Adapt:
# TODO handle failure
return self.send_receive("get uhd rxgain")
- def _read_coef_file(self):
+ def _read_coef_file(self, path):
"""Load the coefficients from the file in the format given in the README"""
coefs_out = []
- f = open(self.coef_path, 'r')
+ f = open(path, 'r')
lines = f.readlines()
n_coefs = int(lines[0])
coefs = [float(l) for l in lines[1:]]
@@ -124,24 +125,31 @@ class Adapt:
else:
raise ValueError(
"Incorrect coef file format: too many coefficients in {}, should be {}, coefs are {}"
- .format(self.coef_path, n_coefs, coefs))
+ .format(path, n_coefs, coefs))
i += 1
f.close()
return coefs_out
- def get_coefs(self):
- return self._read_coef_file()
+ def get_coefs_am(self):
+ return self._read_coef_file(self.coef_am_path)
- def _write_coef_file(self, coefs):
- f = open(self.coef_path, 'w')
+ def get_coefs_pm(self):
+ return self._read_coef_file(self.coef_pm_path)
+
+ def _write_coef_file(self, coefs, path):
+ f = open(path, 'w')
f.write("{}\n".format(len(coefs)))
for coef in coefs:
f.write("{}\n".format(coef))
f.close()
- def set_coefs(self, coefs):
- self._write_coef_file(coefs)
- self.send_receive("set memlesspoly coeffile {}".format(self.coef_path))
+ def set_coefs_am(self, coefs):
+ self._write_coef_file(coefs, self.coef_am_path)
+ self.send_receive("set memlesspoly coeffile_am {}".format(self.coef_am_path))
+
+ def set_coefs_pm(self, coefs):
+ self._write_coef_file(coefs, self.coef_pm_path)
+ self.send_receive("set memlesspoly coeffile_pm {}".format(self.coef_pm_path))
# The MIT License (MIT)
#