Skip to content

Commit

Permalink
Change from wait mode to disable
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoAldea committed Feb 6, 2024
1 parent 90c331e commit 6e20326
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions code/drv_ea/src/wattrex_driver_ea/drv_ea.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def __init__(self, config: DrvScpiSerialConfC) -> None:
self.__tx_chan.send_data(add_msg)
self.__rx_chan.delete_until_last()
self.__wait_4_response: bool = False
self.__last_mode: DrvBasePwrModeE = DrvBasePwrModeE.WAIT
self.last_data: DrvEaDataC = DrvEaDataC(mode = DrvBasePwrModeE.WAIT,
self.__last_mode: DrvBasePwrModeE = DrvBasePwrModeE.DISABLE
self.last_data: DrvEaDataC = DrvEaDataC(mode = DrvBasePwrModeE.DISABLE,
status = DrvBaseStatusE.OK,
current = 0, voltage = 0, power = 0)

Expand Down Expand Up @@ -157,8 +157,10 @@ def read_buffer(self) -> None: #pylint: disable=too-many-branches, too-many-stat
elif all (x in data for x in ("error", "Error", "ERROR")):
self.last_data.status = DrvBaseStatusE.COMM_ERROR #pylint: disable=attribute-defined-outside-init
elif 'OFF' in data:
self.last_data.mode = DrvBasePwrModeE.WAIT #pylint: disable=attribute-defined-outside-init
elif 'ON' in data and self.last_data.mode == DrvBasePwrModeE.WAIT:
self.last_data.mode = self.__last_mode #pylint: disable=attribute-defined-outside-init
elif ('ON' in data and
(self.last_data.mode == DrvBasePwrModeE.WAIT or
self.last_data.mode == DrvBasePwrModeE.DISABLE)):
self.last_data.mode = self.__last_mode #pylint: disable=attribute-defined-outside-init
elif data.startswith('EA'):
data = data.split(',')
Expand Down Expand Up @@ -186,7 +188,7 @@ def read_buffer(self) -> None: #pylint: disable=too-many-branches, too-many-stat
if power > 0:
self.last_data.mode = self.__last_mode #pylint: disable=attribute-defined-outside-init
else:
self.last_data.mode = DrvBasePwrModeE.WAIT #pylint: disable=attribute-defined-outside-init
self.last_data.mode = DrvBasePwrModeE.DISABLE #pylint: disable=attribute-defined-outside-init
self.__wait_4_response = False
log.debug(f"Response: {data}")
elif msg is None:
Expand Down Expand Up @@ -269,7 +271,7 @@ def get_data(self) -> DrvEaDataC:
return self.last_data


def set_cc_mode(self, curr_ref: int, voltage_limit: int= None) -> None:
def set_cc_mode(self, curr_ref: int, voltage_limit: int|None= None) -> None:
'''
Use source in constant current mode.
Sink mode will be set with negative current values.
Expand Down Expand Up @@ -314,7 +316,7 @@ def set_cc_mode(self, curr_ref: int, voltage_limit: int= None) -> None:
self.read_buffer()


def set_cv_mode(self, volt_ref: int, current_limit: int= None) -> None:
def set_cv_mode(self, volt_ref: int, current_limit: int|None= None) -> None:
'''
Use source in constant voltage mode .
Security current limit can be also set for both sink and source modes.
Expand Down Expand Up @@ -364,6 +366,7 @@ def disable(self) -> None:
Raises:
- None
'''
self.__last_mode = DrvBasePwrModeE.DISABLE
msg = DrvScpiCmdDataC(data_type = DrvScpiCmdTypeE.WRITE,
port = self.__port,
payload = _ScpiCmds.OUTPUT_OFF.value)
Expand Down
2 changes: 1 addition & 1 deletion code/drv_ea/tests/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def main():
'''
Example usage of drv_ea with a source_ea device.
'''
ea_scpi_conf = DrvScpiSerialConfC(port = '/dev/ttyACM0', separator='\n', baudrate=38400,
ea_scpi_conf = DrvScpiSerialConfC(port = '/dev/wattrex/source/EA_2963640425', separator='\n', baudrate=38400,
timeout=1, write_timeout=1)

source = DrvEaDeviceC(config = ea_scpi_conf)
Expand Down

0 comments on commit 6e20326

Please sign in to comment.