Skip to content

Commit

Permalink
Now support ea-eps bidirecctional source
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoAldea committed Feb 14, 2024
1 parent 3b72fa0 commit 158528c
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions code/drv_ea/src/wattrex_driver_ea/drv_ea.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ def read_buffer(self) -> None: #pylint: disable=too-many-branches, too-many-stat
elif ('ON' in data and self.last_data.mode in (DrvBasePwrModeE.WAIT,
DrvBasePwrModeE.DISABLE)):
self.last_data.mode = self.__last_mode #pylint: disable=attribute-defined-outside-init
elif data.startswith('EA'):
elif data.startswith('EA') or data.startswith('EPS'):
data = data.split(',')
self.properties.model = data[1] #pylint: disable=attribute-defined-outside-init
self.properties.serial_number = data[2] #pylint: disable=attribute-defined-outside-init
self.properties.model = data[1].replace(" ","") #pylint: disable=attribute-defined-outside-init
self.properties.serial_number = data[2].replace(" ", "") #pylint: disable=attribute-defined-outside-init
log.debug(f"Serial number: {data[2]}")
log.debug(f"Model: {data[1]}")
elif all(x in data for x in ("V,", "A,", "W")):
Expand Down Expand Up @@ -304,6 +304,7 @@ def set_cc_mode(self, curr_ref: int, voltage_limit: int|None= None) -> None:
Raises:
- None
'''
curr_ref = abs(curr_ref)
self.__change_last_mode(DrvBasePwrModeE.CC_MODE)
current = round(float(curr_ref) / _MILI_UNITS, 2)
if current > self.properties.max_current_limit:
Expand All @@ -320,6 +321,15 @@ def set_cc_mode(self, curr_ref: int, voltage_limit: int|None= None) -> None:
else:
current = 0
voltage = 0
log.critical(self.properties.model)
log.critical(self.properties.model.startswith("PSB"))
if self.properties.model.startswith("PSB"):
msg = DrvScpiCmdDataC(data_type = DrvScpiCmdTypeE.WRITE,
port = self.__port, payload = "SINK:"+_ScpiCmds.SEND_CURR.value + str(current))
log.critical(f"Sending: {msg.payload}")
self.__tx_chan.send_data(msg)
self.read_buffer()

msg = DrvScpiCmdDataC(data_type = DrvScpiCmdTypeE.WRITE,
port = self.__port, payload = _ScpiCmds.SEND_CURR.value + str(current))
self.__tx_chan.send_data(msg)
Expand Down Expand Up @@ -366,6 +376,12 @@ def set_cv_mode(self, volt_ref: int, current_limit: int|None= None) -> None:
else:
current = 0
voltage = 0
if self.properties.model.startswith("PSB"):
msg = DrvScpiCmdDataC(data_type = DrvScpiCmdTypeE.WRITE,
port = self.__port, payload = "SINK:"+_ScpiCmds.SEND_CURR.value + str(current))
self.__tx_chan.send_data(msg)
self.read_buffer()

msg = DrvScpiCmdDataC(data_type = DrvScpiCmdTypeE.WRITE,
port = self.__port, payload = _ScpiCmds.SEND_CURR.value + str(current))
self.__tx_chan.send_data(msg)
Expand Down

0 comments on commit 158528c

Please sign in to comment.