You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Overview

Resumo do conteúdo da página

On this page:


Classes in-depth

Content

Class workflow

Content

Defining a Class

Content

Calling Classes

How to call a class on HTML5 (@Script.Class.<ClassName>)?

Default

Content

HTML5 pages

Content



ServerMain Class methods

This section has information on some methods accessible by the ServerMain Class pre-built in any new project and how to use them in your projects. This section covers the following ServerMain class methods:

These methods can be adapted to fit various application requirements and ensure smooth transitions between different project states or dynamic configurations. To utilize methods from the ServerMain Class, follow these steps:

  1. Navigate to Scripts → Classes → ServerMain.

  2. Within the ServerMain class, you can create methods to execute code during the server processes.

  3. To implement these methods, go to Scripts → CodeEditor.

  4. In the CodeEditor, write the necessary code for the methods you've created in the ServerMain Class.

For instance, you can utilize ServerMain Class methods to reestablish communications after any project or server state change. This applies to scenarios like starting the project or switching between active and standby states in a two-project redundancy setup.



OnActivate

The OnActivate method is invoked when a project transitions from an inactive to an active state, such as during initial startup or when a standby project becomes active in a redundancy scenario. 

OnActivate Method
public void OnActivate(){
     //Write your code here 
}

This method executes the instructions within its code block whenever the project or server changes from inactive to active.


OnDeactivate

The OnDeactivate method is invoked when a project transitions from an active to an inactive state, either when it is stopped or during a redundancy scenario. 

OnDeactivate Method
public void OnDeactivate(){
     //Write your code here 
}

Upon each change from active to inactive, this method executes the instructions specified within its code block.


GetInitialDataSetParameters

The GetInitialDataSetParameters method retrieves initial parameters for a DataSet, which is useful for configuring dynamic data sources with diverse initial settings. This method is called for every dataset configured in Datasets→DBs, enabling customization of each field (columns) within the Datasets→DBs, such as reading from an XML file. If the method returns "true", the configuration in the Manager is replaced with the new values obtained from the output arguments.

GetInitialDataSetParameters Method
public bool GetInitialDataSetParameters(string datasetName, out string provider, out string database, out string connectionString, out string logonName, out string logonPassword, out string serverIP)
{
       //Write your code here
  return true;
}

Remote Tags Methods

Content



Remote Tags methods

This section contains information about how to use remote tags methods.

The Remote Tags API allows the application to consume directly Assets and Tags defined in remote system such as OSIsoft PI System or OSIsoft PI AF (Asset Framework).

You can use that functionality in two ways:

  1. The Drawing Tool object "Remote Assets" will display automatically the remote asset tree, and the configuration on DEVICES, as describe below, is executed. 

  2. There are methods on the Script which allows the dynamic binding to consume the remote data model.

In order to use the Remote Tag API, you need to make sure some requirements are met.

Feature Requirements

Project Settings

To enable the RemoteAssets and RemoteTags features in your Project, you must be configured for the Enterprise Family. To do so, go to Info → Settings, and select the correct family.

Otherwise, you may see an error message on your TraceWindow Logs, as shown in the image.

Device Configuration

In the Devices → Channels tab, create a new Channel for the desired communication protocol. Configure the ProtocolOptions field with the necessary information if the driver requires it.

In the Devices → Nodes tab, create a node, assign it to our newly created channel, and fill in the Station parameters as required by the driver.

There is no need to create communication Points when using the Remote Tags and Assets feature.

Server Startup Task

On Scripts → Tasks, select the default ServerStartup task, and go to its Code Editor environment. Add the following call method:

The following code block defines a function that sets up the device node for RemoteTags and RemoteAssets services. It should only be invoked during the ServerStartup task and expects two parameters: the device node name for RemoteTags and the device node name for RemoteAssets.

@Server.SetRemoteDeviceNode(string deviceNodeNameTags, string deviceNodeNameAssets)

Example:


Example
string nodeRemoteTags =  @Device.Node.<NodeForRemoteTags>.GetName();

string nodeRemoteAssets = @Device.Node.<NodeForRemoteAssets>.GetName();

@Server.SetRemoteDeviceNode(nodeRemoteTags, nodeRemoteAssets);


This call method will enable some predefined methods available for Remote Tags and Assets in the chosen Node. These methods are described in the next sections.



ServerMain Class methods EXEMPLO

This section has information on some methods accessible by the ServerMain Class pre-built in any new project and how to use them in your projects. This section covers the following ServerMain class methods:

These methods can be adapted to fit various application requirements and ensure smooth transitions between different project states or dynamic configurations. To utilize methods from the ServerMain Class, follow these steps:

  1. Navigate to Scripts → Classes → ServerMain.

  2. Within the ServerMain class, you can create methods to execute code during the server processes.

  3. To implement these methods, go to Scripts → CodeEditor.

  4. In the CodeEditor, write the necessary code for the methods you've created in the ServerMain Class.

For instance, you can utilize ServerMain Class methods to reestablish communications after any project or server state change. This applies to scenarios like starting the project or switching between active and standby states in a two-project redundancy setup.





In this section...

The root page @parent could not be found in space v10.

  • No labels