From f0147b6dfe68d196481af50538e5c252a9530cb9 Mon Sep 17 00:00:00 2001 From: gfrn Date: Fri, 2 Sep 2022 15:26:23 -0300 Subject: [PATCH 1/7] Removes deprecation notices --- src/pydrs/base.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/pydrs/base.py b/src/pydrs/base.py index b38cd2e..2768c04 100644 --- a/src/pydrs/base.py +++ b/src/pydrs/base.py @@ -654,7 +654,6 @@ def read_csv_param_bank(self, param_csv_file: str): return csv_param_list - @print_deprecated def get_param_bank( self, list_param: list = None, @@ -1593,7 +1592,6 @@ def decode_interlocks(self, reg_interlocks, list_interlocks: list) -> list: return active_interlocks - @print_deprecated def read_vars_fbp(self) -> dict: vars_dict = {} if self.var_group_index is not None: @@ -1650,7 +1648,6 @@ def read_vars_fbp(self) -> dict: ) return vars_dict - @print_deprecated def read_vars_fbp_dclink(self) -> dict: vars_dict = { "modules_status": self.read_bsmp_variable(33, "uint32_t"), @@ -1668,7 +1665,6 @@ def read_vars_fbp_dclink(self) -> dict: return vars_dict - @print_deprecated def read_vars_fac_acdc(self, iib: bool = True) -> dict: vars_dict = { "cap_bank_voltage": f"{round(self.read_bsmp_variable(33, 'float'), 3)} V", @@ -1728,7 +1724,6 @@ def read_vars_fac_acdc(self, iib: bool = True) -> dict: return vars_dict - @print_deprecated def read_vars_fac_dcdc(self, iib=True) -> dict: # TODO: Is this rounding really necessary? wref_index = ( @@ -1781,7 +1776,6 @@ def read_vars_fac_dcdc(self, iib=True) -> dict: return vars_dict - @print_deprecated def read_vars_fac_dcdc_ema(self, iib=False) -> dict: vars_dict = { "load_current": f"{round(self.read_bsmp_variable(33, 'float'), 3)} A", @@ -1881,7 +1875,6 @@ def _read_fac_2s_acdc_module(self, iib: bool) -> dict: return vars_dict - @print_deprecated def read_vars_fac_2s_acdc(self, add_mod_a=2, iib=False) -> dict: vars_dict = {} old_add = self.slave_addr @@ -1897,7 +1890,6 @@ def read_vars_fac_2s_acdc(self, add_mod_a=2, iib=False) -> dict: finally: self.slave_addr = old_add - @print_deprecated def read_vars_fac_2s_dcdc(self, com_add=1, iib=False) -> dict: old_add = self.slave_addr iib_offset = 14 * (iib - 1) @@ -1952,7 +1944,6 @@ def read_vars_fac_2s_dcdc(self, com_add=1, iib=False) -> dict: finally: self.slave_addr = old_add - @print_deprecated def read_vars_fac_2p4s_acdc(self, add_mod_a=1, iib=0): self.read_vars_fac_2s_acdc(add_mod_a, iib) @@ -1986,7 +1977,6 @@ def _read_fac2p4s_dcdc_iib_module(self, module: int) -> dict: return vars_dict - @print_deprecated def read_vars_fac_2p4s_dcdc(self, com_add=1, iib=False) -> dict: old_add = self.slave_addr @@ -2033,7 +2023,6 @@ def read_vars_fac_2p4s_dcdc(self, com_add=1, iib=False) -> dict: finally: self.slave_addr = old_add - @print_deprecated def read_vars_fap(self, com_add=1, iib=True) -> dict: old_add = self.slave_addr @@ -2090,7 +2079,6 @@ def read_vars_fap(self, com_add=1, iib=True) -> dict: finally: self.slave_addr = old_add - @print_deprecated def read_vars_fap_4p(self, com_add=1, iib=0) -> dict: old_add = self.slave_addr iib_offset = 16 * (iib - 1) @@ -2175,7 +2163,6 @@ def read_vars_fap_4p(self, com_add=1, iib=0) -> dict: finally: self.slave_addr = old_add - @print_deprecated def read_vars_fap_2p2s(self, com_add=1, iib=0) -> dict: old_add = self.slave_addr iib_offset = 16 * (iib - 1) @@ -2434,7 +2421,6 @@ def save_ramp_waveform_col(self, ramp): for val in ramp: writer.writerow([val]) - @print_deprecated def read_vars_fac_n(self, n=1, dt=0.5): vars_dict = {} old_add = self.slave_addr @@ -2477,7 +2463,6 @@ def set_prbs_sampling_freq(self, freq, type_memory): self.set_param("Freq_TimeSlicer", 1, freq) self.save_param_bank(type_memory) - @print_deprecated def get_dsp_modules_bank( self, list_dsp_classes=None, From 4ef703090148b9254cd127322edbedfc2de4fc19 Mon Sep 17 00:00:00 2001 From: gfrn Date: Fri, 2 Sep 2022 16:49:29 -0300 Subject: [PATCH 2/7] Fixes IIB comparision error --- src/pydrs/base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pydrs/base.py b/src/pydrs/base.py index 2768c04..89fb3a6 100644 --- a/src/pydrs/base.py +++ b/src/pydrs/base.py @@ -50,7 +50,6 @@ SerialError, SerialErrPckgLen, SerialInvalidCmd, - print_deprecated, ) logger = get_logger(name=__file__) @@ -2134,7 +2133,7 @@ def read_vars_fap_4p(self, com_add=1, iib=0) -> dict: ), } - if iib >= 0: + if iib > 0: vars_dict[f"iib_{iib}"] = { **vars_dict[f"iib_{iib}"], **{ From dc4c19702cd25e53125a4eed010151b764fac993 Mon Sep 17 00:00:00 2001 From: gfrn Date: Fri, 2 Sep 2022 16:59:38 -0300 Subject: [PATCH 3/7] Returns DSP module bank --- src/pydrs/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pydrs/base.py b/src/pydrs/base.py index 89fb3a6..a4a5451 100644 --- a/src/pydrs/base.py +++ b/src/pydrs/base.py @@ -2515,6 +2515,13 @@ def get_dsp_modules_bank( "coeffs" ].append(dsp_coeffs) + if return_floathex: + dsp_modules_bank[dsp_classes_names[dsp_class]]["coeffs"] = ( + [dsp_coeffs, dsp_coeffs_hex] + ) + else: + dsp_modules_bank[dsp_classes_names[dsp_class]]["coeffs"] = dsp_coeffs + if print_modules: prettier_print(dsp_modules_bank) From 6ec716fe1258338f43845247b77e478cec851bfa Mon Sep 17 00:00:00 2001 From: gfrn Date: Fri, 9 Sep 2022 09:19:38 -0300 Subject: [PATCH 4/7] Fixes swapped interlock/alarm dict keys --- src/pydrs/base.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pydrs/base.py b/src/pydrs/base.py index 2768c04..b2182ba 100644 --- a/src/pydrs/base.py +++ b/src/pydrs/base.py @@ -1717,7 +1717,7 @@ def read_vars_fac_acdc(self, iib: bool = True) -> dict: fac.list_acdc_iib_cmd_interlocks, ) - vars_dict["cmd"]["interlocks"] = self.decode_interlocks( + vars_dict["cmd"]["alarms"] = self.decode_interlocks( self.read_bsmp_variable(58, "uint32_t"), fac.list_acdc_iib_cmd_alarms, ) @@ -1806,12 +1806,12 @@ def read_vars_fac_dcdc_ema(self, iib=False) -> dict: "board_rh": f"{round(self.read_bsmp_variable(48, 'float'), 3)} °C", } - vars_dict["iib"]["alarms"] = self.decode_interlocks( + vars_dict["iib"]["interlocks"] = self.decode_interlocks( self.read_bsmp_variable(49, "uint32_t"), fac.list_dcdc_ema_iib_interlocks, ) - vars_dict["iib"]["interlocks"] = self.decode_interlocks( + vars_dict["iib"]["alarms"] = self.decode_interlocks( self.read_bsmp_variable(50, "uint32_t"), fac.list_dcdc_ema_iib_alarms, ) @@ -2067,11 +2067,11 @@ def read_vars_fap(self, com_add=1, iib=True) -> dict: "board_rh": f"{round(self.read_bsmp_variable(55, 'float'), 3)} %", } - vars_dict["iib"]["alarms"] = self.decode_interlocks( + vars_dict["iib"]["interlocks"] = self.decode_interlocks( self.read_bsmp_variable(56, "uint32_t"), fap.list_iib_interlocks ) - vars_dict["iib"]["interlocks"] = self.decode_interlocks( + vars_dict["iib"]["alarms"] = self.decode_interlocks( self.read_bsmp_variable(57, "uint32_t"), fap.list_iib_alarms ) From f79b0ef04a08e9570f868d54c637443943118d6c Mon Sep 17 00:00:00 2001 From: Guilherme Francisco Date: Fri, 9 Sep 2022 11:24:04 -0300 Subject: [PATCH 5/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fac61b..17496e9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![Latest tag](https://img.shields.io/github/tag/lnls-sirius/pydrs.svg?style=flat) [![Latest release](https://img.shields.io/github/release/lnls-sirius/pydrs.svg?style=flat)](https://github.com/lnls-sirius/pydrs/releases) [![PyPI version fury.io](https://badge.fury.io/py/pydrs.svg)](https://pypi.python.org/pypi/pydrs/) -[![Read the Docs](https://readthedocs.org/projects/spack/badge/?version=latest)](https://lnls-sirius.github.io/pydrs/) +[![Read the Docs](https://readthedocs.org/projects/spack/badge/?version=latest)](https://cnpem-sei.github.io/pydrs/) ## What is PyDRS? From a13dd2e9b506e72930c059171ba8a8c996374491 Mon Sep 17 00:00:00 2001 From: Guilherme Francisco Date: Fri, 9 Sep 2022 16:21:36 -0300 Subject: [PATCH 6/7] Update base.py --- src/pydrs/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pydrs/base.py b/src/pydrs/base.py index 732b441..8b65e55 100644 --- a/src/pydrs/base.py +++ b/src/pydrs/base.py @@ -2221,7 +2221,7 @@ def read_vars_fap_2p2s(self, com_add=1, iib=0) -> dict: ), } - if iib >= 0: + if iib > 0: vars_dict[f"iib_{iib}"] = { **vars_dict[f"iib_{iib}"], **{ From ad237f0c946e02f3871406f3917b059914779b99 Mon Sep 17 00:00:00 2001 From: Guilherme Francisco Date: Mon, 12 Sep 2022 12:39:21 -0300 Subject: [PATCH 7/7] Update README.md --- README.md | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 6fac61b..d13ed36 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,6 @@ In order to cover all DRS driven current power supplies whilst meeting models sp 1. **Common variables**: Variables used by all power supplies models, for example, general status and operating mode parameters. These variables occupy the first 25 BSMP variable Id's. 2. **Specific variables**: Each power supply model (chosen through the *PS Model* parameter) defines ID variables greater than 24 according to its application. Thus, when communicating with a power supply, its model should prior be known in order to correctly use the specifications of those BSMP variables. This includes measures of feedback and monitoring and also interlocks records. - -Development packages are listed at [requirements-dev.txt](requirements_dev.txt) and runtime dependencies at [requirements.txt](requirements.txt). - ## Basic Small Messages Protocol Library The BSMP - Basic Small Messages Protocol - is a stateless, synchronous and lightweight protocol. It was designed to be used in serial communication networks of small embedded devices which contain a device with the role of a master. @@ -119,9 +116,7 @@ pip install -e . ### Tests ```command -pip install -r requirements.txt -pip install -r requirements_dev.txt -pip install -e . -v +pip install -e .[dev] -v coverage run -m unittest discover coverage xml coverage report @@ -157,33 +152,18 @@ Although old method names and operations are still supported and work as expecte ### Basic usage (pre 1.2.0) -When all installation is done, python or ipython instance can be called. - -![14](https://user-images.githubusercontent.com/19196344/138935751-d90dc9b9-1409-4dc4-98bd-66f480dcd489.png) - - -Import pydrs - -![image](https://user-images.githubusercontent.com/19196344/139112617-2629340e-fac9-4002-8456-1e3b079cd837.png) - - -Create *drs* object. - -![image](https://user-images.githubusercontent.com/19196344/139116187-fc58c909-9b4f-46fe-91ca-d80796f3256d.png) - - -Establish the connection. +**Disclaimer:** TCP (ethernet) communication is not available on versions prior to 1.2.0 -![image](https://user-images.githubusercontent.com/19196344/139116355-790b9f0e-8536-4203-9276-b3e592329661.png) +```python +>>> import pydrs # Import the module +>>> drs = pydrs.SerialDRS() -Set the device address to communicate. - -![image](https://user-images.githubusercontent.com/19196344/139116450-1b083db1-b257-40ca-868c-350b9af193e4.png) - - -Use BSMP commands to control the device. - -![image](https://user-images.githubusercontent.com/19196344/139116593-7fcbd965-85e4-460e-a912-91782a21d412.png) + pyDRS - compatible UDC firmware version: 0.44 2022-06-30 +>>> drs.connect("COM3", 115200) +>>> drs.set_slave_addr(5) # Set slave address (optional) +>>> drs.read_ps_status() # Run your command +{'state': 'Off', 'open_loop': 0, 'interface': 0, 'active': 1, 'model': 'FBP', 'unlocked': 0} +```