How to upload changes to objects using scripting from OMI runtime?

Hello All, I am trying to find a way to update my object attribute values such as alarm Hi limit, lo limit, initial values, etc. (integer, float, boolean) from runtime itself. Is there a way for me to make these changes like an upload change function that I can use from buttons to specifically upload selected values to the object? I am having to do this because there can be situations in our project where we won't be able to "Preserver Runtime Changes" when re-deploying engines because of some bugs we are encountering. I am hoping there is way to force update the object when someone updates the alarm limits from runtime for example.

Parents
  • (Edited with some clarifications)

    Hi,

    In InTouch you have the Retentive value configuration witch retains configuration data on a tag between shutdown and start up of the application.

    But with Application there is no such thing and for years there has been different approaches to resolve the issue you are describing.

    The Upload Runtime changes is one, but it will retain ALL settings and you have no control over witch of the settings are saved, performing this in IDE will save alarm settings, comments, data source configuration etc.

    This problem was resolved by introducing the Preserve Runtime changes setting on the deploy prompt, and you can configure an attribute to align to this setting. But as you say it is not always 100% reliable, certain configuration changes on a object will upon deploy disregard of the setting and I would advise to test the function if you come to rely on it for production data.

    AND if you find bugs or issues, report it to AVEVA tech support.

    So back to the Upload Runtime changes, witch is one option.

    There is no native way of triggering this action from OMI but the GRAccess Toolkit allows for programmatically perform Upload Runtime changes.

    In similar scenarios I have created a 'helper object' (using GRAccess in script) that you can trigger to perform this action, and similar from any other instance/object. using this method i have created self configurating applications and applications that can create, modify and deploy objects without the usage of IDE. Big disclaimer here, GRAccess will require a license for connecting to the galaxy as a development session, so make sure that the object is deployed on the node that you are normally use IDE on, or make sure you have enough development licenses available. GRAccess is not a free path to development actions Slight smile

    Another workaround is to store requested limits / configuration in a database, or even in xml files, reading settings upon deploy.

    If you have them in a database it allows for easy bulk modifications and customer documentation.

    The solution of using external storage of important configuration data is commonly used in many systems, and as mentioned, there are several methods in doing so. I would say using a custom database is very common.

    Triggering the read configuration upon deploy. Note, to NOT put the database access in the Onscan or startup script since it can effect your deploy stability, there are some good examples on how to implement scripting that triggers on deploy in the Scripting Guide from Aveva.

    And to support the update of values you store upon the change of data.

    Same thing here, it is not advisable to put the 'save' of data in the Offscan or Shutdown script for the same reasons as Onscan/Shutdown.  

    From GRAccess manual:

    Upload Method
    Uploads AutomationObject configuration changes made at run time.
    Class
    IInstance
    Syntax
    [C#]
    void Upload(
    EAutomaticallyUndocheckout automaticallyUndocheckout,
    ESkipOtherUsersCheckedOutObjects
    skipOtherUsersCheckedOutObjects,
    ESkipObjectsWithPendingUpdates skipObjectsWithPendingUpdates
    );

  • Here is a example on how to do this using GRAccess in a ArchestrA object script.

    Keep in mind that it is an example and I would put some effort in improving the error management etc.

    but it gives you an idea on how to begin.

    I believe it requires you to import the dll for usage in your galaxy (ArchestrA.GRAccess.dll) as a script function library

    Also using scripts like this requires you to understand the way of how synchronous vs asynchronous scripting works to avoid locking up you application engine. 

    if Me.GR.TagName <> "" then 
    	dim ok as boolean;
    	try
    		dim tagnames[1] as string;
    		dim gals as ArchestrA.GRAccess.IGalaxies;
    		dim galaxy as ArchestrA.GRAccess.IGalaxy;
    		dim cmd as ArchestrA.GRAccess.ICommandResult;
    		tagnames[1] = Me.GR.TagName;
    
    		dim grAccess as ArchestrA.GRAccess.GRAccessAppClass;
    		grAccess = new ArchestrA.GRAccess.GRAccessAppClass();
    		gals = grAccess.QueryGalaxies(MyPlatform.NodeName);
    		galaxy = gals["myGalaxyName"];
    		galaxy.Login("", "");
    		dim queryResult as ArchestrA.GRAccess.IgObjects;
    		queryResult = galaxy.QueryObjectsByName(ArchestrA.GRAccess.EgObjectIsTemplateOrInstance.gObjectIsInstance,tagnames[]);
    		cmd = galaxy.CommandResult;
    		if (cmd.Successful) then
    			LogMessage("Command successful");
    			dim myInstance as ArchestrA.GRAccess.IInstance;
    			myInstance = queryResult[1];
    			if (myInstance.CheckoutStatus == ArchestrA.GRAccess.ECheckoutStatus.notCheckedOut) then
    				myInstance.Upload(ArchestrA.GRAccess.EAutomaticallyUndocheckout.dontAutomaticallyUndocheckout,ArchestrA.GRAccess.ESkipOtherUsersCheckedOutObjects.doSkipOtherUsersCheckedOutObjects,ArchestrA.GRAccess.ESkipObjectsWithPendingUpdates.doSkipObjectsWithPendingUpdates);
    				ok = true;
    			else
    				LogMessage("Will not complete: object is checked out");
    			endif;
    		else
    			LogMessage("Failed to upload changes,  error: "+cmd.CustomMessage);
    		endif;
    	catch
    		LogError("Error in Upload changes: "+error);
    	endtry;
    
    	if ok then
    		Me.GR.TagName = "";
    	endif;
    endIf;
    
    
    
    Me.GR.UploadRT = false;

Reply
  • Here is a example on how to do this using GRAccess in a ArchestrA object script.

    Keep in mind that it is an example and I would put some effort in improving the error management etc.

    but it gives you an idea on how to begin.

    I believe it requires you to import the dll for usage in your galaxy (ArchestrA.GRAccess.dll) as a script function library

    Also using scripts like this requires you to understand the way of how synchronous vs asynchronous scripting works to avoid locking up you application engine. 

    if Me.GR.TagName <> "" then 
    	dim ok as boolean;
    	try
    		dim tagnames[1] as string;
    		dim gals as ArchestrA.GRAccess.IGalaxies;
    		dim galaxy as ArchestrA.GRAccess.IGalaxy;
    		dim cmd as ArchestrA.GRAccess.ICommandResult;
    		tagnames[1] = Me.GR.TagName;
    
    		dim grAccess as ArchestrA.GRAccess.GRAccessAppClass;
    		grAccess = new ArchestrA.GRAccess.GRAccessAppClass();
    		gals = grAccess.QueryGalaxies(MyPlatform.NodeName);
    		galaxy = gals["myGalaxyName"];
    		galaxy.Login("", "");
    		dim queryResult as ArchestrA.GRAccess.IgObjects;
    		queryResult = galaxy.QueryObjectsByName(ArchestrA.GRAccess.EgObjectIsTemplateOrInstance.gObjectIsInstance,tagnames[]);
    		cmd = galaxy.CommandResult;
    		if (cmd.Successful) then
    			LogMessage("Command successful");
    			dim myInstance as ArchestrA.GRAccess.IInstance;
    			myInstance = queryResult[1];
    			if (myInstance.CheckoutStatus == ArchestrA.GRAccess.ECheckoutStatus.notCheckedOut) then
    				myInstance.Upload(ArchestrA.GRAccess.EAutomaticallyUndocheckout.dontAutomaticallyUndocheckout,ArchestrA.GRAccess.ESkipOtherUsersCheckedOutObjects.doSkipOtherUsersCheckedOutObjects,ArchestrA.GRAccess.ESkipObjectsWithPendingUpdates.doSkipObjectsWithPendingUpdates);
    				ok = true;
    			else
    				LogMessage("Will not complete: object is checked out");
    			endif;
    		else
    			LogMessage("Failed to upload changes,  error: "+cmd.CustomMessage);
    		endif;
    	catch
    		LogError("Error in Upload changes: "+error);
    	endtry;
    
    	if ok then
    		Me.GR.TagName = "";
    	endif;
    endIf;
    
    
    
    Me.GR.UploadRT = false;

Children
No Data