dripline.implementations.entity_endpoints module¶
A Entity is an enhanced implementation of a Dripline Endpoint with simple logging capabilities. The Entitys defined here are more broad-ranging than a single service, obviating the need to define new Entitys for each new service or provider.
When implementing a Entity, please remember: - All communication must be configured to return a response. If no useful get is possible, consider a *OPC? - set_and_check is a generally desirable functionality
Generic Entity catalog (in order of ease-of-use): - SimpleSCPIEntity: quick and simple minimal Entity - SimpleSCPIGetEntity/SimpleSCPISetEntity: limited instance of above with disabled Get/Set - FormatEntity: utility Entity with expanded functionality
-
class
dripline.implementations.entity_endpoints.
FormatEntity
(get_str=None, get_reply_float=False, set_str=None, set_value_lowercase=True, set_value_map=None, extract_raw_regex=None, **kwargs)[source]¶ Bases:
dripline.core.entity.Entity
Utility Entity allowing arbitrary set and query syntax and formatting for more complicated usage cases No assumption about SCPI communication syntax.
- Parameters
get_str (str) – sent verbatim in the event of on_get; if None, getting of endpoint is disabled
get_reply_float (bool) – apply special formatting to get return
set_str (str) – sent as set_str.format(value) in the event of on_set; if None, setting of endpoint is disabled
set_value_lowercase (bool) – default option to map all string set value to .lower() WARNING: never set to False if using a set_value_map dict
set_value_map (str||dict) – inverse of calibration to map raw set value to value sent; either a dictionary or an asteval-interpretable string
extract_raw_regex (str) – regular expression search pattern applied to get return. Must be constructed with an extraction group keyed with the name “value_raw” (ie r’(?P<value_raw>)’ )
-
on_get
(*args, **kwargs)¶ placeholder method for getting the value of an endpoint. Implementations may override to enable OP_GET operations. The implementation must return a value which is able to be passed to the ParamValue constructor.
-
class
dripline.implementations.entity_endpoints.
SimpleSCPIEntity
(base_str=None, **kwargs)[source]¶ Bases:
dripline.core.entity.Entity
Convenience Entity for interacting with SCPI endpoints that support basic assignment and query syntax. (That is, assignments of the form “base_string <new_value>” and queries of the form “base_string?”) Commands requiring a more complex structure, such as specifying channels or other arguments, should use FormatEntity or a custom Entity.
- Parameters
base_str (str) – string used to generate SCPI commands; get will be of the form “base_str?”; set will be of the form “base_str <value>;base_str?”
-
on_get
(*args, **kwargs)¶ placeholder method for getting the value of an endpoint. Implementations may override to enable OP_GET operations. The implementation must return a value which is able to be passed to the ParamValue constructor.
-
class
dripline.implementations.entity_endpoints.
SimpleSCPIGetEntity
(**kwargs)[source]¶ Bases:
dripline.implementations.entity_endpoints.SimpleSCPIEntity
Identical to SimpleSCPIEntity, but with an explicit exception if on_set is attempted
Args: base_str (str): string used to generate SCPI commands; get will be of the form “base_str?”; set will be of the form “base_str <value>;base_str?”
-
class
dripline.implementations.entity_endpoints.
SimpleSCPISetEntity
(**kwargs)[source]¶ Bases:
dripline.implementations.entity_endpoints.SimpleSCPIEntity
Modelled on SimpleSCPIEntity, but with an explicit exception if on_get is attempted. Uses *OPC? to ensure a response is generated when making an assignment.
Args: base_str (str): string used to generate SCPI commands; get will be of the form “base_str?”; set will be of the form “base_str <value>;base_str?”