How can I get signal name from I/O at UR Caps

Dear UR+ Development Support

At [General] → [Screwdriving] view, the dropdown can displayI/O signal names.
For example [Input] → [OK] → dropdown [select , qw , qwe …]
Please see the image file[IO Setup.png] as follow.

But when we want to develop new view at [UR Caps], use dropdown can not get signal names what be set at I/O setup.

We know two ways to get signal names.

  1. Toolbar → ToolbarAPIProvider → getIOModel
  2. ProgramNode → ContributionProvider → get().getProgramAPI().getIOModel()

This time we want to get from Install View, use [InstallationAPIProvider] → ApplicationAPI → getIOModel(). There are error information when run.

Also we can get TCP location by using ApplicationAPI → getTCPModel. It is OK. So we think maybe ApplicationAPI is right.

Please tell us how can get IOModel at Install View.

Thanks

TFSOFT

The getIOModel() returns a Collection<IO> object.
Each IO object has both a Default Name (use getDefaultName()) and a name (use getName()).
The default name is always something like “digital_out[2]” where the regular name may be “StartConveyor” or whatever the user defined this name to be. If no name is set, the default name is returned by getName().

Also, you should generally use the Contribution to pull the list of IO’s, and then set this in the View.
This is better practice, than having the View itself pull the list of IO’s through the Contribution.
This is why it is only the Contribution via the ApplicationAPI, that has access to the IOModel.

jbm

Thanks for your reply!
There are some errors when we tried it.
Please confirm the program as follow.

Thank you.

TFSOFT

source code:
Contribution
public ScrewDrivingInstallationNodeContribution(InstallationAPIProvider apiProvider, DataModel model, ScrewDrivingInstallationNodeView view) {
this.keyboardFactory = apiProvider.getUserInterfaceAPI().getUserInteraction().getKeyboardInputFactory();
this.model = model;
this.view = view;

          ControllableResourceModel resourceModel = apiProvider . getInstallationAPI () . getControllableResourceModel ();
          CapabilityManager capabilityManager= apiProvider.getSystemAPI().getCapabilityManager();
          toolIOController = new ToolIOController ( resourceModel,capabilityManager);
          resourceModel . requestControl ( toolIOController );
         
          ApplicationAPI applicationAPI=apiProvider.getInstallationAPI();
          System.out.println("get ApplicationAPI:"+applicationAPI);
          System.out.println("get IOModel:"+applicationAPI.getIOModel());
          System.out.println("get IO List=="+applicationAPI.getIOModel().getIOs());
   }

error log:
WARNING: using the default ‘SACParserCSS21’ instead
get ApplicationAPI:com.ur.urcap.ui.main.impl.URCapAPIImpl@170576aa
get IOModel:com.ur.urcap.installation.io.IOModelImpl@3507d30f

09:39:04.661 WARN - Could not find component: class com.ur.view.modbus.ModbusComponent {thread: Thread-2 , loggerClass: gui.installation.services.RobotInstallationLookupServiceImpl}

09:39:04.666 ERROR - Exception occurred when setting Swing URCap model {thread: Thread-2 , loggerClass: com.ur.urcap.contribution.installation.InstallationContributionSwing}

java.lang.NullPointerException
at com.ur.view.modbus.ModbusInstallationImpl.getModbusInterface(ModbusInstallationImpl.java:17) ~[?:?]
at com.ur.view.modbus.ModbusIOComponent.getAllOfType(ModbusIOComponent.java:72) ~[?:?]
at com.ur.view.modbus.ModbusIOComponent.getInputs(ModbusIOComponent.java:40) ~[?:?]
at com.ur.view.io.IOServiceImpl.getInputs(IOServiceImpl.java:349) ~[?:?]
at com.ur.urcap.installation.io.IOModelImpl.getAllModbusIOs(IOModelImpl.java:107) ~[?:?]
at com.ur.urcap.installation.io.IOModelImpl.getIOs_aroundBody0(IOModelImpl.java:49) ~[?:?]
at com.ur.urcap.installation.io.IOModelImpl$AjcClosure1.run(IOModelImpl.java:1) ~[?:?]
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149) ~[?:?]
at com.ur.polyscope.valueobjects.aspects.UncaughtExceptionAspect.aroundMethod(UncaughtExceptionAspect.java:27) ~[polyscope-value-objects-api-1.8.3.jar:?]
at com.ur.urcap.installation.io.IOModelImpl.getIOs(IOModelImpl.java:43) ~[urcap-10.4.182.jar:?]
at com.ur.urcap.installation.io.IOModelImpl.getIOs(IOModelImpl.java:1) ~[urcap-10.4.182.jar:?]
at com.ur.urcap.tfsoft.hios.screwdriving.impl.ScrewDrivingInstallationNodeContribution.(ScrewDrivingInstallationNodeContribution.java:38) ~[?:?]
at com.ur.urcap.tfsoft.hios.screwdriving.impl.ScrewDrivingInstallationNodeService.createInstallationNode(ScrewDrivingInstallationNodeService.java:38) ~[?:?]
at com.ur.urcap.tfsoft.hios.screwdriving.impl.ScrewDrivingInstallationNodeService.createInstallationNode(ScrewDrivingInstallationNodeService.java:1) ~[?:?]
at com.ur.urcap.contribution.installation.InstallationContributionSwing.createInstallationNode(InstallationContributionSwing.java:109) ~[urcap-10.4.182.jar:?]
at com.ur.urcap.contribution.installation.InstallationContributionSwing.setModel(InstallationContributionSwing.java:79) [urcap-10.4.182.jar:?]
at com.ur.urcap.contribution.installation.AbstractURCapInstallation.updateInstallationContribution(AbstractURCapInstallation.java:115) [urcap-10.4.182.jar:?]
at com.ur.urcap.contribution.installation.AbstractURCapInstallation.setInstallationModel(AbstractURCapInstallation.java:139) [urcap-10.4.182.jar:?]
at com.ur.urcap.contribution.installation.URCapInstallationNodeSwing.setInstallationModel(URCapInstallationNodeSwing.java:1) [urcap-10.4.182.jar:?]
at com.ur.urcap.contribution.installation.URCapInstallationModule.setInstallationModel(URCapInstallationModule.java:246) [urcap-10.4.182.jar:?]
at com.ur.urcap.contribution.installation.URCapInstallationModule.updateModelAndInfo(URCapInstallationModule.java:236) [urcap-10.4.182.jar:?]
at com.ur.urcap.contribution.installation.URCapInstallationModule.updateInstalledURCaps(URCapInstallationModule.java:214) [urcap-10.4.182

Try querying the list of IOs outside of the InstallationNode constructor.
The IOModel is dynamic, and possibly not initialized at the time the InstallationNode is created.

1 Like

jbm

Thank you very much!
Accord your reply, We have solved this problem.

Thanks again!

TFSOFT

Hi!

I am getting this same nullpointer exception, but only if I use Polyscope version 5.4.0 or below.

In my code I do the following to obtain the IOModel for the DigitalIO.class:

IOModel ioModel = installationContribution.getInstallationAPI().getIOModel(); Collection<DigitalIO> ios = ioModel.getIOs(DigitalIO.class);

This code is called from the buildUI()-method in the class that implements the SwingInstallationNodeView.

What I find strange is that I get a nullpointer exception that seems to originate from the ModbusIO:

ERROR [Thread-0] 13:12:19 18/02/20: Exception occurred when setting Swing URCap model
java.lang.NullPointerException
at com.ur.view.modbus.ModbusInstallationImpl.getModbusInterface(ModbusInstallationImpl.java:17)
at com.ur.view.modbus.ModbusIOComponent.getAllOfType(ModbusIOComponent.java:72)
at com.ur.view.modbus.ModbusIOComponent.getInputs(ModbusIOComponent.java:40)
at com.ur.view.io.IOServiceImpl.getInputs(IOServiceImpl.java:333)
at com.ur.urcap.installation.io.IOModelImpl.getAllModbusIOs(IOModelImpl.java:109)
at com.ur.urcap.installation.io.IOModelImpl.getIOs_aroundBody0(IOModelImpl.java:51)
at com.ur.urcap.installation.io.IOModelImpl.getIOs_aroundBody1$advice(IOModelImpl.java:24)
at com.ur.urcap.installation.io.IOModelImpl.getIOs(IOModelImpl.java:1)
at com.ur.urcap.installation.io.IOModelImpl.getIOs_aroundBody2(IOModelImpl.java:185)
at com.ur.urcap.installation.io.IOModelImpl.getIOs_aroundBody3$advice(IOModelImpl.java:24)
at com.ur.urcap.installation.io.IOModelImpl.getIOs(IOModelImpl.java:1)

Why does it getModbusInterface when I have specifically told it to only fetch the DigitalIO.class’ IOs?

When I get the collection of IOs, I write code on “openview” function of conribution.
The error has never caused by doing this.