hvl_ccb.dev.fug.comm
SerialCommunication for FuG
- class FuGSerialCommunication(configuration)[source]
Bases:
SerialCommunication,SyncCommunicationProtocolSpecific communication protocol implementation for FuG power supplies. Already predefines device-specific protocol parameters in config.
- static config_cls()[source]
Return the default configdataclass class.
- Returns:
a reference to the default configdataclass class
- query(command: str, n_attempts_max: int | None = None, attempt_interval_sec: int | float | None = None) str | None[source]
Send a command to the interface and handle the status message. Raises an error, if the answer starts with “E”.
- Parameters:
command – Command to send
- Raises:
FuGError – if the connection is broken or the error from the power source itself
- Returns:
Answer from the interface or empty string
- class FuGSerialCommunicationConfig(terminator: bytes = b'\n', encoding: str = 'utf-8', encoding_error_handling: str = 'strict', wait_sec_read_text_nonempty: int | float = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: str | None = None, baudrate: int = 9600, parity: str | ~hvl_ccb.comm.serial.SerialCommunicationParity = <SerialCommunicationParity.NONE: 'N'>, stopbits: int | ~hvl_ccb.comm.serial.SerialCommunicationStopbits = <SerialCommunicationStopbits.ONE: 1>, bytesize: int | ~hvl_ccb.comm.serial.SerialCommunicationBytesize = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: int | float = 3)[source]
Bases:
SerialCommunicationConfigConfiguration dataclass for
FuGSerialCommunication.- baudrate: int = 9600
Baudrate for FuG power supplies is 9600 baud
- bytesize: int | SerialCommunicationBytesize = 8
One byte is eight bits long
- default_n_attempts_read_text_nonempty: int = 10
default number of attempts to read a non-empty text
- force_value(fieldname, value)
Forces a value to a dataclass field despite the class being frozen.
NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.
- Parameters:
fieldname – name of the field
value – value to assign
- classmethod keys() Sequence[str]
Returns a list of all configdataclass fields key-names.
- Returns:
a list of strings containing all keys.
- classmethod optional_defaults() dict[str, object]
Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.
- Returns:
a list of strings containing all optional keys.
- parity: str | SerialCommunicationParity = 'N'
FuG does not use parity
- classmethod required_keys() Sequence[str]
Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.
- Returns:
a list of strings containing all required keys.
- stopbits: int | SerialCommunicationStopbits = 1
FuG uses one stop bit
- terminator: bytes = b'\n'
The terminator is LF
- timeout: int | float = 3
use 3 seconds timeout as default
- wait_sec_read_text_nonempty: int | float = 0.5
default time to wait between attempts of reading a non-empty text