Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    dsf-python 3.4.5 released

    Scheduled Pinned Locked Moved
    DSF Development
    2
    4
    451
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Falcounetundefined
      Falcounet
      last edited by Falcounet

      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

      • https://github.com/Duet3D/dsf-python/releases/3.4.5

      Installation

      • https://pypi.org/project/dsf-python/3.4.5/
      oozeBotundefined 1 Reply Last reply Reply Quote 5
      • Falcounetundefined Falcounet referenced this topic
      • Falcounetundefined
        Falcounet
        last edited by

        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

        • https://github.com/Duet3D/dsf-python/releases/tag/3.4.5-1

        Installation

        • https://pypi.org/project/dsf-python/3.4.5.post1/

        To install the latest version : sudo pip3 install dsf-python
        To upgrade to the latest version : sudo pip3 install --upgrade dsf-python

        1 Reply Last reply Reply Quote 0
        • Falcounetundefined Falcounet referenced this topic
        • oozeBotundefined
          oozeBot @Falcounet
          last edited by oozeBot

          @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}"
          
          Falcounetundefined 1 Reply Last reply Reply Quote 0
          • Falcounetundefined
            Falcounet @oozeBot
            last edited by

            @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 of dsf.commands.code.Code.
            The Code class has a parameters 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 not
            • string_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_value

            As 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()
            
            1 Reply Last reply Reply Quote 1
            • First post
              Last post
            Unless otherwise noted, all forum content is licensed under CC-BY-SA