Skip to content
  • There are no suggestions because the search field is empty.

How can I add an OPC Item to my Configuration through DataHub scripting?

Is there a way to add an OPC Item to my DataHub OPC Configuration using a script?

Below is a sample of the code.  Attached is the full script.     

Running the Script

Go to the Scripting section in the DataHub.  Then click Add and the script.  Then you can highlight the script and click Load Now to load the script once.  Or you can check the box next to it and click apply to make it run on every start up and then restart the DataHub to load the script.

     //CREATE AN INSTANCE OF THE OPC CONNECTION CLASS
     myConnection = new OPCConnection();

     //SET THE OPC CONNECTION NAME
     myConnection.setServer("ATOPS");

     //ADD THE OPC ITEM
     myConnection.addItem("Channel_1.Device_1.Tag_2", "Channel_1.Device_1.Tag_2", 2);

     //APPLY THE TO CONFIGURATION AND THEN RELOAD THE CONNECTION
     myConnection.applyConfig();
     myConnection.reload(0);