Commit 6478c757 authored by Arnaud WATLET's avatar Arnaud WATLET
Browse files

Updates io on pwr_dps5005

Showing with 8 additions and 6 deletions
+8 -6
...@@ -6,7 +6,8 @@ import minimalmodbus # noqa ...@@ -6,7 +6,8 @@ import minimalmodbus # noqa
import os import os
CTL_CONFIG = HARDWARE_CONFIG['ctl'] CTL_CONFIG = HARDWARE_CONFIG['ctl']
ctl_name = CTL_CONFIG.pop('board_name', 'raspberry_pi_modbus') ctl_name = HARDWARE_CONFIG['ctl'].pop('board_name', 'raspberry_pi')
ctl_connection = HARDWARE_CONFIG['ctl'].pop('connection', 'modbus')
ctl_module = importlib.import_module(f'ohmpi.hardware_components.{ctl_name}') ctl_module = importlib.import_module(f'ohmpi.hardware_components.{ctl_name}')
CTL_CONFIG['baudrate'] = CTL_CONFIG.pop('baudrate', 9600) CTL_CONFIG['baudrate'] = CTL_CONFIG.pop('baudrate', 9600)
CTL_CONFIG['bitesize'] = CTL_CONFIG.pop('bitesize', 8) CTL_CONFIG['bitesize'] = CTL_CONFIG.pop('bitesize', 8)
...@@ -26,6 +27,7 @@ class Pwr(PwrAbstract): ...@@ -26,6 +27,7 @@ class Pwr(PwrAbstract):
# if a controller is passed in kwargs, it will be instantiated # if a controller is passed in kwargs, it will be instantiated
if self.ctl is None: if self.ctl is None:
self.ctl = ctl_module.Ctl(**CTL_CONFIG) self.ctl = ctl_module.Ctl(**CTL_CONFIG)
self.io = self.ctl.connections[kwargs.pop('connection', ctl_connection)]
self.voltage_adjustable = True self.voltage_adjustable = True
self._voltage = voltage self._voltage = voltage
self._current_adjustable = False self._current_adjustable = False
...@@ -41,11 +43,11 @@ class Pwr(PwrAbstract): ...@@ -41,11 +43,11 @@ class Pwr(PwrAbstract):
self.exec_logger.debug(f'Current cannot be set on {self.board_name}') self.exec_logger.debug(f'Current cannot be set on {self.board_name}')
def turn_off(self): def turn_off(self):
self.ctl.bus.write_register(0x09, 1) self.io.write_register(0x09, 1)
self.exec_logger.debug(f'{self.board_name} is off') self.exec_logger.debug(f'{self.board_name} is off')
def turn_on(self): def turn_on(self):
self.ctl.bus.write_register(0x09, 1) self.io.write_register(0x09, 1)
self.exec_logger.debug(f'{self.board_name} is on') self.exec_logger.debug(f'{self.board_name} is on')
@property @property
...@@ -54,11 +56,11 @@ class Pwr(PwrAbstract): ...@@ -54,11 +56,11 @@ class Pwr(PwrAbstract):
@voltage.setter @voltage.setter
def voltage(self, value): def voltage(self, value):
self.ctl.bus.write_register(0x0000, value, 2) self.io.write_register(0x0000, value, 2)
def battery_voltage(self): def battery_voltage(self):
self.ctl.bus.read_register(0x05, 2) self.io.read_register(0x05, 2)
@property @property
def current_max(self,value): def current_max(self,value):
self.ctl.bus.write_register(0x0001, value * 10, 0) self.io.write_register(0x0001, value * 10, 0)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment