-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* conclicts fixed * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * created devices/caen module * fix import * core classes: CAEN, ISEG * some methods of class Channel setters are not labeled as such yet * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add function to list serial ports * add test for module * add test for channel * working alarm parsing * fix parse response when not returning parameter * fix bad bit array parsing * correctly parse alarm/stat * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * do not run tests if no serial device exists * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * decorator to skip test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * attempt to fix skip * use correct annotations * use correct annotations * rest of channel commands and a few module commands * iseg tests * fix conflicts * implement more iseg * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * rest of module methods * add mypy to pre-commit * removed replicated code, added setter's decorators and missing type hints Some methods in iseg.devices.channel were duplicated * use ruff instead of mypy * all iseg methods * test_utils updated * comments indicating the devices where some methods only work + some fixes * annotations imported from future * annotations imported from future, again * improved imports * add "--show-fixes" to ruff * reduce code duplication * add .ruff_cache/ to .gitignore * add .ruff_cache/ to .gitignore * some fixes and almost all tests * rest of iseg tests * fixed errors due to automatic merge * Fix imports * fix test_caen_commands * fixed test_caen_commands --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Luis Antonio Obis Aparicio <[email protected]> Co-authored-by: Luis Antonio Obis Aparicio <[email protected]>
- Loading branch information
1 parent
eab3d16
commit f6e7e0f
Showing
24 changed files
with
2,655 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,3 +132,6 @@ dmypy.json | |
.vscode/ | ||
|
||
node_modules/ | ||
|
||
# ruff | ||
.ruff_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
from .devices import Caen, Iseg | ||
from .version import __version__ | ||
from hvps.devices.caen.caen import Caen | ||
from hvps.devices.iseg.iseg import Iseg | ||
from .version import __version__ | ||
|
||
__all__ = ["Caen", "Iseg", "__version__"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
from __future__ import annotations | ||
|
||
_mon_module_commands = { | ||
":READ:MODULE:CHANNELNUMBER": "The number of channels in the module.", | ||
":READ:FIRMWARE:RELEASE": "Read out Firmware Release (XX.X)", | ||
":READ:MODULE:STATUS": "Read out module status register", | ||
":CONF:AVER": "Query the digital filter averaging steps.", | ||
":CONF:KILL": "Get the current value for the kill enable function.", | ||
":CONF:ADJUST": "Get the fine adjustment state.", | ||
":CONF:CAN:ADDR": "Query the module's CAN bus address.", | ||
":CONF:CAN:BITRATE": "Query the module's CAN bus bit rate.", | ||
":CONF:SERIAL:BAUD": "Query the device's serial baud rate.", | ||
":CONF:SERIAL:ECHO": "Check if serial echo is enabled or disabled.", | ||
":READ:VOLT:LIM": "Query the module's voltage limit in percent.", | ||
":READ:CURR:LIM": "Query the module's current limit in percent.", | ||
":READ:RAMP:VOLT": "Query the module's voltage ramp speed in percent/second.", | ||
":READ:RAMP:CURR": "Query the module's current ramp speed in percent/second.", | ||
":READ:MODULE:CONTROL": "Query the Module Control register", | ||
":READ:MODULE:EVENT:STATUS": "Query the Module Event Status register", | ||
":READ:MODULE:EVENT:MASK": "Query the Module Event Mask register", | ||
":READ:MODULE:EVENT:CHANSTAT": "Query the Module Event Channel Status register", | ||
":READ:MODULE:EVENT:CHANMASK": "Query the Module Event Channel Mask register", | ||
":READ:MODULE:SUPPLY? (@0-6)": "Query the module supply voltages", | ||
":READ:MODULE:SUPPLY:P24V": "Query the module supply voltage +24 Volt", | ||
":READ:MODULE:SUPPLY:N24V": "Query the module supply voltage -24 Volt", | ||
":READ:MODULE:SUPPLY:P5V": "Query the module supply voltage +5 Volt", | ||
":READ:MODULE:SUPPLY:P3V": "Query the module internal supply voltage +3.3 Volt", | ||
":READ:MODULE:SUPPLY:P12V": "Query the module internal supply voltage +12 Volt", | ||
":READ:MODULE:SUPPLY:N12V": "Query the module internal supply voltage -12 Volt", | ||
":READ:MODULE:TEMPERATURE": "Query the module temperature in degree Celsius", | ||
":READ:MODULE:SETVALUE": "Query the setvalue changes counter", | ||
":READ:FIRMWARE:NAME": "Query the module's firmware name", | ||
":CONF:EVENT:MASK": "Query the Module Event Mask register", | ||
":CONF:EVENT:CHANMASK": "Query the Module Event Channel Mask register", | ||
} | ||
|
||
_set_module_commands = { | ||
":CONF:AVER": "Query the digital filter averaging steps.", | ||
":CONF:KILL": "Get the current value for the kill enable function.", | ||
":CONF:ADJUST": "Get the fine adjustment state.", | ||
":CONF:CAN:ADDR": "Query the module's CAN bus address.", | ||
":CONF:CAN:BITRATE": "Query the module's CAN bus bit rate.", | ||
":CONF:SERIAL:BAUD": "Query the device's serial baud rate.", | ||
":CONF:SERIAL:ECHO": "Check if serial echo is enabled or disabled.", | ||
":CONF:EVENT:MASK": "Set the Module Event Mask register", | ||
":CONF:EVENT:CHANMASK": "Set the Module Event Channel Mask register", | ||
":SYSTEM:USER:CONFIG": "Set the device to configuration mode to change the CAN bitrate or address", | ||
":CONF:EVENT CLEAR": "Reset the Module Event Status register", | ||
":CONF:EVENT": "Clear single bits or bit combinations in the Module Event Status register", | ||
} | ||
|
||
|
||
def _get_mon_module_command(command: str) -> bytes: | ||
""" | ||
Generates a query command string for monitoring a specific module. | ||
Args: | ||
command (str): The base command without the query symbol. | ||
Returns: | ||
bytes: The query command string as bytes. | ||
Raises: | ||
ValueError: If the provided command is not a valid command. | ||
Example: | ||
command = ":MEAS:CURR" | ||
query_command = _get_mon_module_command(command) | ||
print(query_command) | ||
b':MEAS:CURR?\r\n' | ||
""" | ||
command = command.upper() | ||
if command not in _mon_module_commands: | ||
valid_commands = ", ".join(_mon_module_commands.keys()) | ||
raise ValueError( | ||
f"Invalid command '{command}'. Valid commands are: {valid_commands}." | ||
) | ||
|
||
return f"{command.strip()}?\r\n".encode("ascii") | ||
|
||
|
||
def _get_set_module_command(command: str, value: str | int | float | None) -> bytes: | ||
""" | ||
Generates an order command as a bytes object to set a value for a specific module. | ||
Args: | ||
command (str): The base command without the value and channel suffix. | ||
value (str | int | float | None): The value to be set. Can be a string, integer, float, or None. | ||
Returns: | ||
bytes: The order command as a bytes object. | ||
Raises: | ||
ValueError: If the provided command is not a valid command. | ||
Example: | ||
command = ":VOLT" | ||
value = 200 | ||
order_command = _get_set_module_command(command, value) | ||
print(order_command) | ||
b':VOLT 200;*OPC?\r\n' | ||
""" | ||
command = command.upper() | ||
if command not in _set_module_commands: | ||
valid_commands = ", ".join(_set_module_commands.keys()) | ||
raise ValueError( | ||
f"Invalid command '{command}'. Valid commands are: {valid_commands}." | ||
) | ||
if isinstance(value, float): | ||
value = f"{value:E}" | ||
|
||
return f"{command.strip()} {value};*OPC?\r\n".encode("ascii") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
from .caen import Caen | ||
from .iseg import Iseg | ||
Oops, something went wrong.