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

    Access/read Plugin-Data via C# DSF-API

    Scheduled Pinned Locked Moved
    DSF Development
    2
    7
    262
    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.
    • reroundefined
      rero
      last edited by

      Good evening,

      after solving my previous issue with populating the ObjectModel with Plugin-related data, I am now facing a related situation.

      I am developing a C#-based HMI-Application to control the CNC-machine and would like to show/present different IOs of my Plugin (which interfaces the IO-Board).

      If I got the documentation right, I should use ObjectModel.Plugins["MyPlugin"].Data to read the Plugin-Data.
      In my case this Dictionary is empty, although I have 8 IOs/Variables registered with the Plugin itself (and visible in the DWC-Objectmodel Plugin).

      Am I missing something here (doc says something about 'registration of Variables before using SetPluginData', but I want to read existing vars)?

      Any hint/help is appreciated 🙂

      Regards,
      Reiner

      chrishammundefined 1 Reply Last reply Reply Quote 0
      • chrishammundefined
        chrishamm administrators @rero
        last edited by

        @rero Your custom data needs to be registered using the data property and since you seem to be able to see it using the DWC OM browser, that should be alright. How are you trying to read your custom data keys?

        Duet software engineer

        reroundefined 1 Reply Last reply Reply Quote 0
        • reroundefined
          rero @chrishamm
          last edited by

          @chrishamm

          I am using a SubcribeConnection to access/update the ObjectModel:

          // connect and retrieve first complete ObjectModel
          await _subscriptionConnection.Connect(SubscriptionMode.Patch);
          _objectModel = await _subscriptionConnection.GetObjectModel();
          
          // periodically get ObjectModel-changes
          while (true)
          {
            using JsonDocument wModelPatch = await _subscriptionConnection.GetObjectModelPatch();
            _objectModel?.UpdateFromJson(wModelPatch.RootElement);
          }
          

          The code to access the Plugin-data, looks like this:

          if (_modelObserver.ObjectModel is not null)
          {
            _plugin = _modelObserver.ObjectModel.Plugins["IOExample"];
            if (_plugin is not null) 
            {
              //iterate over data-keys
              foreach (String key in _plugin.Data.Keys)
              {
                PluginInfo += $"Data/Json-Property '{key}': '{_plugin.Data[key]}'";
              }
            }
          }
          

          This works as expected, but the Plugin.Data member is empty in this case (while I can see the Data-variables in the DWC-ObjectModel-Plugin).

          chrishammundefined 1 Reply Last reply Reply Quote 0
          • chrishammundefined
            chrishamm administrators @rero
            last edited by

            @rero What DSF version are you using?

            Duet software engineer

            reroundefined 1 Reply Last reply Reply Quote 0
            • reroundefined
              rero @chrishamm
              last edited by

              @chrishamm I am using DSF version 3.5.4

              chrishammundefined 1 Reply Last reply Reply Quote 0
              • chrishammundefined
                chrishamm administrators @rero
                last edited by chrishamm

                @rero I could reproduce this problem and I'm looking into it. Version 3.6.0-beta.4 does not appear to be affected.

                PS: I've got a bug fix ready for the next 3.5 version.

                Duet software engineer

                reroundefined 1 Reply Last reply Reply Quote 0
                • reroundefined
                  rero @chrishamm
                  last edited by

                  @chrishamm thanks for checking the issue.

                  One thing I observed today: a similar/identical(?) problem exists also with ObjectModel.Global: this ModelDictionary also doesn't contain any entry ... while the variables are available via DWC/ObjectModel-Plugin.

                  I tried 3.6-beta4 last week, but was not able to compile it - there were some issues with your new SourceGenerator, I will try again when I have more time / finished the basic stuff with DSF/RRF 3.5.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Unless otherwise noted, all forum content is licensed under CC-BY-SA