Virtual Objects

To better integrate scripts with other Desigo CC functions (such as, macros, reactions, and so on), it is possible to create virtual objects which are global variables (or virtual data points) that scripts can read and write to store information that can be accessed by other scripts or other Desigo CC functions. In particular, scripts use virtual objects to store the values for the Desigo CC supported data types that are useful to the other Desigo CC functions, or where such functions can write to interact with scripts. See the following examples of use:

  • A script monitors a virtual object to execute certain instructions while a macro writes in this virtual object to trigger the execution of the script instructions.
  • A script monitors a virtual object to execute certain instructions while another script writes in this virtual object to trigger the execution of the script instructions.
  • A reaction uses a virtual data point as trigger while a script writes in this virtual object to match the conditions of the reaction.

The Desigo CC virtual objects are located in a dedicated folder under Logics in Application View of System Browser.

Object Configurator rights define the access permission to create and delete objects in a Desigo CC system. For more details about the application rights, see User and User Group Administration.

Virtual objects are made up of a property and a command:

  • Value: property in which the concerned information is stored. See the following table for details about data types that can be stored based on the object model.
  • Write: command available for the Value property that allows other scripts or other Desigo CC functions to write the concerned value.
  • WriteInternal: command available for the Value property that allows other scripts or other Desigo CC functions to write the concerned value. The execution of this command is not recorded in the History Database.

 

Virtual Object

Data Type

Simple Data Type

Virtual Analog

GmsReal

Yes

Virtual Binary

GmsBool

Yes

Virtual BitString

GmsBitString

Yes

Virtual Combination

-

No

Virtual DateTime

PvssTime

Yes

Virtual Duration

GmsDuration

Yes

Virtual Folder

-

No

Virtual Integer

GmsInt

Yes

Virtual Multistate

GmsEnum

Yes

Virtual String

PvssString

Yes

Virtual Unsigned

GmsUint

Yes

Note that:

  • For many of these objects, you can customize the display of Value, in the Details expander of the Object Configurator. For example, it is possible to specify the unit of a Virtual Analog by changing the value attributes at the point level.
  • The parameter for Virtual Binary can be one of the following: 0/1, "True"/"False" (strings) or true/false (keywords).
  • For the Virtual BitString, when storing the values, it is necessary to pass the decimal value that corresponds with the bitmask. Consequently, the result of the read operation is the decimal value, possibly to convert again into string or bit for later use.
  • The Virtual Combination is a combination of simple data types.
  • The Virtual Folder can be used to create hierarchies of virtual objects or other virtual object folders.
  • For the Virtual Multistate, when storing the values, it is necessary to pass the numeric value that corresponds with a specific textgroup item, previously configured.

When the execution of a script starts, the script will check whether all the necessary virtual objects (global variables exist); if not:

  • In Engineering mode, the technician is informed by an error of type Warning in the Script Editor (Error List expander). If any required virtual object is missing, then it can be created in the scripts library (see Create Missing Objects for Library Scripts).
  • In Operating mode, the operator is not informed, and the script is executed anyway but it may not work properly.

 

NOTICE

To prevent Desigo CC failure, be careful not to store too much data (at megabyte level) in an individual virtual object.

Virtual Objects in Distributed Systems

In distributed systems, a script of a certain system can store information in a virtual object that belongs to another system.

Example of Use

 

How to write, read, and print to Console the supported virtual data points

console("------ TEST BEGINS @ " + new Date().toString() + " ------")

 

executePropertyCommand("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_analog","Value","Write", -300.018)

var vdAnalogRead = read("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_analog","Value")

console("Global Variable Analog =" + vdAnalogRead.value.displayValue)

 

executePropertyCommand("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_binary","Value", "Write", "false")

var vdBinaryRead = read("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_binary","Value")

console("Global Variable Binary =" + vdBinaryRead.value.displayValue)

 

executePropertyCommand("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_bitstring","Value","Write", 15)

var vdBitstringRead = read("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_bitstring","Value")

console("Global Variable Bitstring =" + vdBitstringRead.value.displayValue)

 

executePropertyCommand("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_combination","FloatValue","Write", 455.75)

var vdCombinationRead = read("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_combination","FloatValue")

console("Global Variable Combination =" + vdCombinationRead.value.displayValue)

 

executePropertyCommand("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_datetime", "Value", "Write", Date.now())

var vdDateTimeRead = read("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_datetime","Value")

console("Global Variable Date & Time =" + vdDateTimeRead.value.displayValue)

 

executePropertyCommand("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_duration","Value", "Write", 567)

var vdDurationRead = read("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_duration","Value")

console("Global Variable Duration =" + dDurationRead.value.displayValue)

 

executePropertyCommand("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_integer","Value", "Write", 18)

var vdIntegerRead = read("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_integer", "Value")

console("Global Variable Integer =" + vdIntegerRead.value.displayValue)

 

executePropertyCommand("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_multistate","Value","Write", 1);

var vdMultistateRead = read("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_multistate", "Value")

console("Global Variable Multistate =" + vdMultistateRead.value.displayValue)

 

executePropertyCommand("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_string","Value","Write", "ciao")

var vdStringRead = read("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_string", "Value")

console("Global Variable String =" + vdStringRead.value.displayValue)

 

executePropertyCommand("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_unsigned", "Value", "Write", 2)

var vdUnsignedRead = read("System1.ApplicationView:ApplicationView.Logics.VirtualObjects.vd_unsigned", "Value")

console("Global Variable Unsigned =" + vdUnsignedRead.value.displayValue)

 

console("------ TEST ENDS @ " + new Date().toString() + " ------")