dsf-python 3.4.5 released
-
The Python bindings for DSF dsf-python v3.4.5 has been released.
This release brings the bindings up-to-date with the current 3.4.5 version of DSF.
A proper Python implementation of the ObjectModel has been added as well.As there are some changes made on the modules architecture to better match the DSF API one, existing scripts or plugins may need to change their module imports to use that version.
Release Notes
- Add ObjectModel implementation
- Change modules architecture to better match DSF API
- Bring API protocol up to date with DSF 3.4.5 such as :
- Remove stuff related to MachineModel and use ObjectModel instead
- Add evaluate_expression method to BaseCommandConnection
- Remove origin_port parameter for add_user_session command
- Add parameter to get_file_info command to get thumbnail content
- Add invalidate_channel() generic command
- Add StartPlugins and StopPlugins API calls
- Added new API command to reload plugin manifest
- Added new IPC command to invalidate codes and files
- Added new API command to enable or disable network protocols
- Added new API command to install system packages on demand
Downloads
Installation
-
-
I released dsf-python 3.4.5-post1 to fix patching/updating the ObjectModel.
I did some more testing to validate it to work but I'm still working on a way to test it more properly so please report back here or by opening an issue on github if you encounter any problem.
Release Notes
- Bug fix: Make ObjectModel patching to work (Implement ModelCollection and ModelDictionary + various minor fixes)
Downloads
Installation
To install the latest version :
sudo pip3 install dsf-python
To upgrade to the latest version :sudo pip3 install --upgrade dsf-python
-
-
@Falcounet said in dsf-python 3.4.5 released:
Add evaluate_expression method to BaseCommandConnection
Would you please provide an example for this? If I'm understanding this correctly from previous conversations, this will allow something like the following to work?
in DWC: M8000 H"{global.XXXXX}" in DSF_Python: if cde.majorNumber == 8000: tVar = ParseParam(cde.parameter("H")) <== evaluate_expression goes here? tVar now contains the contents of global.XXXXX, not the literal string "{global.XXXXX}"
-
@oozeBot I suggest first to update to dsf-python 3.4.6 as I fixed
CodeParameter.is_expression
in that version.In your exemple
cde
is an instance ofdsf.commands.code.Code
.
TheCode
class has aparameters
attributes (eg :cde.parameters
) which is a List containing the GCode parameters.The class
dsf.commands.code_parameter.CodeParameter
has the following attributes :letter
: which contains the letter of the Gcode (eg : H)is_expression
: which return either if the parameter value is an expression or notstring_value
: The value of the gcode as a string
If you want to parse an expression, you have to use the generic function
evaluate_expression
over the string_valueAs an example :
from dsf.connections import InterceptConnection, InterceptionMode from dsf.commands.code import CodeType def start_intercept(): filters = ["M1234"] intercept_connection = InterceptConnection(InterceptionMode.PRE, filters=filters, debug=True) intercept_connection.connect() try: while True: # Wait for a code to arrive cde = intercept_connection.receive_code() # Check for the type of the code if cde.type == CodeType.MCode and cde.majorNumber == 1234: # Go through all the Gcode parameters for parameter in cde.parameters: if parameter.is_expression: print(intercept_connection.evaluate_expression(parameter.string_value)) # Resolve it so that DCS knows we took care of it intercept_connection.resolve_code() else: # We did not handle it so we ignore it and it will be continued to be processed intercept_connection.ignore_code() except Exception as e: print("Closing connection: ", e) traceback.print_exc() intercept_connection.close() if __name__ == "__main__": start_intercept()