RPC Call From Gateway To Designer

Hi,

I've been reading a lot lately on how the intricacies of the SDK are working.

In brief, I'm trying to build a module, that expose a REST API, that I can then connect to a custom VSCode extension to make changes to the custom scripts (or maybe all resources...) in Ignition. I have also the goal, later on, to version resources in GIT. I have the first part almost working.

However, now I'm trying to execute a call to the private handleSave method of the designer, so I can refresh the designer without closing/opening it, as described here. I understand this is not officially supported by the SDK.

Where I need your help, is I'm trying to find a way to invoke this method in the Designer Scope, from the Gateway Scope where the REST API lives. Is there any way to maybe list the currently open designers, from the Gateway Scope, to then get their context to call the handleSave method ? Or maybe, is there a way to make RPC call from Gateway to Designer, instead of the Designer to Gateway way described here ? I've poked around the SDK for the past day or two without success...

Thanks in advance for your help ! I hope my question is clear.

You have to send (unsolicited) messages. A client session is provided when RPC from the designer is first requested. You can use a weak reference cache for those to target specific designers. I'm not sure about broadcasting.

Hi,

Thanks for the reply ! I just needed this small push to help me get in the right direction. I was a bit confused at first with DesignerGatewayConnection object.

I've followed instruction on this thread to get it working.

Related to this, I have another question... Is there a way to programmatically restart the designer when pushing new module update (through Maven Post goal) instead of doing it manually, in order to get the new updated code from the module in the designer ?

Thanks again for your help !!

1 Like

Huh. When I install a new module, my designer(s) force me to restart.

No.

You would register a PushNotificationListener; you can add PushNotifications to the sessions you have/hold onto/interrogate from the platform.

However, this all sounds like a bit of an XY problem. If you're already communicating with the gateway via REST, why not just make programmatic updates to the project directly from the gateway? You can push change operations with correctly formatted resources. If you really wanted to, you could then broadcast a push notification that the designer handles; there's a public void updateProject method on the (internal) IgnitionDesigner class you can pretty easily get access to.

Gateways that are on a 'dev' build skip this check.

Ewww. Didn't know that. Good that it hasn't caught me.

Multiple things here ! Let me just ask a couple questions to make sure I understand everything.

Context: I'm trying to edit resources from VSCode (/usr/local/bin/ignition/data/projects/samplequickstart/ignition/script-python/...)
and then have the designer reload the changes I made in VSCode. I got that information from here

However, when I try to invoke handleSave (from a pushNotification that then calls it in the designerScope), the designer won't reload the changes, even though the invoke seems to have worked.

Is there another function I should call instead (i.e. updateProject) ? If so, could you provide me a snippet of how to invoke it ? Or maybe I didn't understand that I could trigger something like that from the gateway (i.e. push). In that case, I think I would need to push the file from VsCode, right ?

Other question: to trigger the designer restart, I didn't think I was on a dev build. I'm using the following Dockerfile:

FROM inductiveautomation/ignition:8.1.28
USER root
RUN apt-get update
RUN apt-get install -y wget build-essential python2
USER ignition
CMD ["/bin/bash"]

***Not yet completed, the plan is to add ignition api mocks and other tools

Is there maybe a flag or something I should turn on/off to activate the check ?

Thanks !

In the meanwhile, I tried a combination of calling handleSave and/or updateProject, and none are reloading resources changed outside of the designer (i.e. python code files).

Do I need to trigger something else ? I saw in a couple threads talks about the scanning of resources...

If you're on a new enough SDK version, there will be a requestScan method available on the project manager interface on the gateway. However, that would only be relevant if you were directly modifying files on disk; if you're already working with Ignition APIs everything should be picked up immediately.