Propar API¶
Instrument¶
-
class
propar.
instrument
(comport, address=128, baudrate=38400, channel=1, serial_class=<class 'serial.serialposix.Serial'>)¶ Implements a propar instrument for easy access to instrument parameters.
The instrument class wraps around a master instance, which is created for the given comport. Multiple instruments with the same comport use the same master.
Parameters: - comport (str) – COM port on which the instrument is connected (e.g. ‘COM1’ or ‘/dev/ttyUSB0’).
- address (int, optional) – Address of the instrument, default = 128 for local instrument.
- baudrate (int, optional) – Baudrate to use for communication.
- channel (int, optional) – Channel to use for communication.
- serial_class (obj, optional) – Custom serial class to be used for serial communication with the instrument.
-
address
¶ Address of the instrument
Type: int
-
comport
¶ COM port on which the instrument is connected
Type: str
-
master
¶ Instance of the master class used for communication.
Type: obj
-
db
¶ Instance of the propar database, for conversion from DDE number to process, parameter number.
Type: obj
-
readParameter
(dde_nr, channel=None)¶ Read a single parameter indicated by DDE nr.
Parameters: - dde_nr (int) – FlowDDE parameter number.
- channel (int, optional) – Channel to use for communication.
Returns: Parameter data if successful, None otherwise.
-
writeParameter
(dde_nr, data, channel=None)¶ Write a single parameter indicated by DDE nr.
Parameters: - dde_nr (int) – FlowDDE parameter number.
- data – Parameter data to write.
- channel (int, optional) – Channel to use for communication.
Returns: True if successful, False otherwise.
-
read_parameters
(parameters, callback=None, channel=None)¶ Read multiple parameters.
Parameters: - parameters – List of parameter objects.
- callback (function, optional) – Function to be called when parameters are received (function will return directly!).
- channel (int, optional) – Channel to use for communication.
Returns: List with parameters with data if successful, list with one status item otherwise.
-
write_parameters
(parameters, command=1, callback=None, channel=None)¶ Write multiple parameters.
Parameters: - parameters – List of parameter objects, with data.
- command (int, optional) – Propar command to use for writing.
- callback (function, optional) – Function to be called when parameters are received (function will return directly!).
- channel (int, optional) – Channel to use for communication.
Returns: Propar status code (0 if successful).
-
read
(proc_nr, parm_nr, parm_type)¶ Read a single parameter.
Parameters: - proc_nr (int) – process number.
- parm_nr (int) – parameter number.
- parm_type (int) – parameter type.
Returns: Parameter value if successful, None otherwise.
-
write
(proc_nr, parm_nr, parm_type, data)¶ Write a single parameter.
Parameters: - proc_nr (int) – process number.
- parm_nr (int) – parameter number.
- parm_type (int) – parameter type.
- data – parameter data.
Returns: True if successful, False otherwise.
-
wink
(time=9)¶ Wink the LEDs on the instrument.
Parameters: time (int, optional) – Wink duration 1-9 seconds. Returns: True if successful, False otherwise.
-
setpoint
¶ Reads the setpoint of the instrument (0-32000 = 0-100%).
Returns: Instrument setpoint if successful, None otherwise.
-
measure
¶ Reads the measure of the instrument (0-32000 = 0-100%).
Returns: Instrument measure if successful, None otherwise.
-
id
¶ Reads the ID parameter of the instrument.
Returns: Instrument ID if successful, None otherwise.
Master¶
-
class
propar.
master
(comport, baudrate, serial_class=<class 'serial.serialposix.Serial'>)¶ Implements a propar master for communication with Bronkhorst instruments.
After initializing this can be used to read/write parameters of an instrument. When local host functionality is used (MBC with flowbus), it is also possible to communicate with other nodes on the network.Parameters: - comport (str) – COM port on which the instrument is connected (e.g. ‘COM1’ or ‘/dev/ttyUSB0’).
- baudrate (int, optional) – Baudrate to use for communication.
- serial_class (obj, optional) – Custom serial class to be used for serial communication with the instrument.
-
address
¶ Address of the instrument
Type: int
-
comport
¶ COM port on which the instrument is connected
Type: str
-
master
¶ Instance of the master class used for communication.
Type: obj
-
db
¶ Instance of the propar database, for conversion from DDE number to process, parameter number.
Type: obj
-
set_baudrate
(baudrate)¶ Set the baudrate used for communication.
Parameters: baudrate (int) – New baudrate.
-
dump
(level=1)¶ Set dump level for debug purposes.
Dump level 0 = Disable. Dump level 1 = Print non-propar communication to console. Dump level 2 = Print all communication to console.
Parameters: level (int) – New dump level.
-
stop
()¶ Disconnect the comport.
-
start
()¶ Reconnect the comport.
-
get_nodes
(find_first=True)¶ Get a list of nodes on the network.
Will scan from 1 to local address to find the first node!
Parameters: find_first (bool, optional) – Scan from 1 to local address to find node. Returns: List with information about the instruments on the network.
-
read
(address, proc_nr, parm_nr, parm_type)¶ Read a single parameter.
Parameters: - address (int) – instrument node address.
- proc_nr (int) – process number.
- parm_nr (int) – parameter number.
- parm_type (int) – parameter type.
Returns: Parameter value if successful, None otherwise.
-
write
(address, proc_nr, parm_nr, parm_type, data)¶ Write a single parameter.
Parameters: - address (int) – instrument node address.
- proc_nr (int) – process number.
- parm_nr (int) – parameter number.
- parm_type (int) – parameter type.
- data – parameter data.
Returns: True if successful, False otherwise.
-
read_parameters
(parameters, callback=None)¶ Read multiple parameters.
From a list of parameter objects.
Parameters: - parameters (list) – List of parameter objects to read.
- callback (func, optional) – Function to call when parameters are received (parameters passed in callback).
Returns: List with parameters with data if successful, list with one status item otherwise. When callback is used this will return None.
-
write_parameters
(parameters, command=1, callback=None)¶ Write multiple parameters.
Parameters: - parameters – List of parameter objects, with data.
- command (int, optional) – Propar command to use for writing.
- callback (func, optional) – Function to call when parameters are received (parameters passed in callback).
Returns: Propar status code (0 if successful, or callback is used).
Database¶
-
class
propar.
database
(database_path=None)¶ The database class is used to convert FlowDDE numbers to propar parameter objects.
Several other supporting functions are also provided for manual use.
-
get_all_parameters
()¶ Get a list containing all known parameter objects.
-
get_parameters
(dde_parameter_nrs)¶ Get propar parameter objects from a list of DDE nrs.
Parameters: (list (dde_parameter_nrs) – int): List of DDE nrs. Returns: A list of corresponding propar parameter objects.
-
get_parameter
(dde_parameter_nr)¶ Get a propar parameter object for the given DDE nrs.
Parameters: dde_parameter_nr (int) – DDE nrs. Returns: A propar parameter object.
-
get_parameters_like
(like_this)¶ Get a list of propar parameter objects that match the like_this argument.
Parameters: like_this (str) – String to find in parameter name. Returns: A list of matching propar parameter objects.
-
get_parameter_values
(dde_parameter_nr)¶ Get a list of possible values for for the given DDE nr..
Parameters: dde_parameter_nr (int) – DDE nr. Returns: A list with possible values.
-
get_propar_parameter
(proc_nr, parm_nr)¶ Get a list of possible propar parameter objects for the given process, parameter number combination.
Parameters: - proc_nr (int) – Process number.
- parm_nr (int) – Parameter number.
Returns: A list with propar parameter objects.
-
get_propar_parameters
(process)¶ Get a list of possible propar parameter objects for the given process.
Parameters: proc_nr (int) – Process number. Returns: A list with processes, with a list of propar parameter objects per process.
-