Scripting Aspect - Write to an OPC property
I'm finding myself in a problem. I'm trying to write a value to an OPC property in my application with a Scripting Aspect.
I have declared the variable in control builder to the global variables. The Property can now be seen in engineering workplace.
After that I have added a Scripting Aspect to my control application.
I have also added a Scripting Property Bag Aspect, but for some reason it just shows error codes.
I have tried both integer and string datatypes. The function i've been using is WriteData. Manual 3BDS011223R4001 has said of this function the following:
This function writes persistent data. If a data entry with the given name already exists, the associated value is overridden. Otherwise a new data entry isd created for the given name
Is this function even able to write to an OPC property? If not, then what is the method to writing to an OPC-property?
System I am working in is 800xA 5.1, Rev B, FP3. I do NOT have Scripting Manager Extension.
If you have solutions to the problem, in VBScript or JScript, I would be very grateful to you?
Voted best answer
Set Server = CreateObject("OPC.Automation")
Server.Connect ("<----- OPCServer identity, ProgID --------->")
Set Groups = Server.OPCGroups
Set Group = Groups.Add("<----- Group -------->")
Set Items = Group.OPCItems
Set Item = Items.AddItem("Application.My_application.MyOPCProperty", 1)
Value = 7