Configuration of objects

Changing a configuration of objects in GI.config is done with a combination of the methods

  • GetConfigs
  • SetConfigs

Be sure, that all information provided in your own user interface (UI) is always a 1:1 reflection of the current settings in GI.config to visualize changes, or even warnings or errors. Changing a parameter, will not automatically change the information in your UI. You need to take care of that by yourself using the corresponding return states and returned changes lists!

Refer to: GI.config -> Design Rule Check and API - base results

An important thing to keep in mind:

If any configuration change is done via GI.config API, be aware that also other depending settings/objects within the project can be influenced! Make sure, that all information in your own Software (user interface) will be kept up to date to GI.config during configuration (also including errors and warnings)!

Use: SetConfigs to set a single property, followed by GetConfigs to read back the whole information of the complete object (optionally decode the list of changes provided in the respons message of “SetConfigs” to detect all changes - see API - base results).

A simple example:

  • Changing the “type” of a variable: if you set a variable type from “Setpoint” to “Analog Input” → the new variable type will have a lot more properties, which will be set to “default” values when created. Be sure to “re-load” all variable information in your UI, to make all new options available for the user.

1. Get Configuration

When a project is loaded in GI.config (see Read Project), it provides all system components as single objects of different types:

  • Project
  • Features
  • Stream Processors
  • Controller
  • Adapter
  • InternalModule
  • Module
  • Variable

Each object “living” in GI.config, has its own ID. The ID is used to clearly identify them and to have quick access to get/set their properties/configuration.

1.1 Get Object IDs

The first step to get an objects' configuration is to get the IDs of the object type.

Step Parameters/Results Action
Connect to GI.config → ConfigAPI    
Execute method “GetIDsFromObjectType Parameters:
* Type: Set the Type of object of which you want to receive the IDs
Results:
* Info_Element_List of all IDs of the desired object type
As value of the parameter “Type”, use the predefined ObjectTypes strings from the API-Options (for example in C++ included in “giconfig_ConfigAPI_Options.h”):

giconfig_ConfigAPI::COptions::CCommon::CObjectType::Adapter()
giconfig_ConfigAPI::COptions::CCommon::CObjectType::Controller()
giconfig_ConfigAPI::COptions::CCommon::CObjectType::Feature()
giconfig_ConfigAPI::COptions::CCommon::CObjectType::StreamProcessor()
giconfig_ConfigAPI::COptions::CCommon::CObjectType::Module()
giconfig_ConfigAPI::COptions::CCommon::CObjectType::Project()
giconfig_ConfigAPI::COptions::CCommon::CObjectType::InternalModule()
giconfig_ConfigAPI::COptions::CCommon::CObjectType::Variable()
 

You can also identify “owned” (child-) objects of certain parent-objects → see dependencies of the objects here: Object Types

 

1.2 Get Configs

If once all IDs of the objects are known, you now can read the object properties/configuration.

NOTE:

  • Each Object-Type mentioned above has different properties!
  • A property can be
    • a struct, defined in GI.config API - Structs as Type_Config_<ObjectType>_…
    • a single element in a struct, for example Type_Config_Variable_General → Description.
  • ONLY same properties of multiple objects of the same type can be requested by one execute.
    • Example: not all variable objects have the same properties! (for e.g. “Analog Input” <> “Digital Input”)
Step Parameters/Results Action
Connect to GI.config → ConfigAPI    
Execute method “GetConfigs Parameters:
* IDs: IDs of the requested objects
* PropertyName: requested property
* WithOptions: true/false
* WithImages: true/false
Results:
* Configs: array of CType_Base_ConfigWithOwner
* ReturnStates
* ReturnLists
The parameter “IDs” is of type “Edit_Edit_ElementListSelectionList”, which allows multiple selections → on multi-select, only select objects of the same type!

As parameter “PropertyName” set the desired property of the object, structured conform the “ItemNames” of the element you would like to read, separated by “/” (see Examples).
Also individual possibilities of object properties are provided as ElementSelectionLists if “WithOptions” is set to TRUE (for example all available measurement types of an AnalogInput). Also wiring images are available with “WithImages”. These options can be displayed to a user interface to change a configuration.

The Configs array of type “CType_Base_ConfigWithOwner” returns the result, depending on the requested objects (size of array) and property → compare with “StructTypeID()”.
 

1.3 Object Properties

You can get a list of all properties of an object using the method “GetPropertyNames” of the ConfigAPI in GI.config.

Additional, GI.monitor offers this list (pre-filled in the background) as a drop-down menu, so you can easily inspect all properties of the selected object with GI.monitor.

Example in GI.monitor → see all properties of the selected object of type variable (“TyVar”). As you can see, the variable “Timestamp” is obviously an “arithmetic” variable, so it gives you the properties of arithmetic-variables:

1

1.3.1 Read all properties

You can read the information of ALL properties with one single request, using “-” in GI.monitor (see screenshot above), or an “empty” string in your own implementation.

C++/C#

If you set an empty string as property name (compare with GI.monitor → using “-”), the result will be a “Type_Config_<ObjectType>” (this is the base struct for the config-information of a certain object). GI.config will, depending on the object-ID, know the object-type.

To validate the estimated response, use “StructTypeID()” to compare with the result (see example code).

This example requested all property information form multiple Variable-Objects (→ number of Objects = Results.GetSize_Configs()) and “WithOptions” is set to TRUE. One element in the array of “Configs” is of type giconfig_ConfigAPI::CType_Config_Variable:

int cnt = Results.GetSize_Configs(); //all variable configs as an array of giconfig_ConfigAPI::CType_Base_ConfigWithOwner
for(int confIndex = 0; confIndex < cnt; confIndex++)
{
giconfig_ConfigAPI::CType_Base_ConfigWithOwner result;
Results.Get_Configs(confIndex, result); //the results are GInsXmlRpcValues
 
//identify XmlRpcValue Result of "GetConfigs" of a Variable-Object with PropertyName = ""
// -> compare structID of the result
if (result.Get_Config().getStructTypeID().compare(giconfig_ConfigAPI::CType_Config_Variable::StructTypeID()) == 0)
{
giconfig_ConfigAPI::CType_Config_Variable value;
result.Get_Config(value);
 
//depending on the variable type, the result delivers valid/invalid structs for its elements
//check valid elements with:
 
if (value.Get_AnalogInput() != GInsXmlRpc::XmlRpcValue()) //check if valid
{
std::cout << " -----> Analog Input found! " << std::endl;
std::cout << " Type: " << value.Get_AnalogInput().Get_Type().Get_Value().Get_Description() << std::endl;
 
//if "WithOptions" is enabled, you can also read all possible type-options of this channel
GInsXmlRpcStdAPI::CGIns_Edit_ElementSelectionList types;
value.Get_AnalogInput().Get_Type(types);
for (int typeIndex = 0; typeIndex < types.GetSize_List(); typeIndex++)
{
GInsXmlRpcStdAPI::CGIns_Base_ElementValue element;
value.Get_AnalogInput().Get_Type().Get_List(typeIndex, element);
std::cout << " - " << element.Get_Description() << std::endl;
}
}
else if (value.Get_AnalogOutput() != GInsXmlRpc::XmlRpcValue()) //check if valid
{
std::cout << " -----> Analog Output found! " << std::endl;
}
else if (value.Get_DigitalInput() != GInsXmlRpc::XmlRpcValue()) //check if valid
{
std::cout << " -----> Digital Input found! " << std::endl;
}
}
}

To read all variable informations (also from “General” - see Type_config_variable), navigate through all sub-structs. Remember the path of the object-property elements for a quick access later.

1.3.2 Read single properties

To access a single property of an object directly, you need to set the “path” of the object-property as “PropertyName”. Example: reading the “Description” of a Variable-Object: as you can see in the API-description, this is an element in “Type_Config_Variable_General”. Based on the object type (respectively the object ID), GI.config already knows, that you are requesting a Variable-Information. The desired property (“Description”) is an element of the “General” information of this object type. So, the resulting “path” of this object property is General/Description.

To avoid using constant strings for the property names in your code, you can use the functions “ItemName_xxx()” of the strutcs, for example

	std::string PropertyName = giconfig_ConfigAPI::CType_Config_Variable::ItemName_General();
PropertyName += "/";
PropertyName += giconfig_ConfigAPI::CType_Config_Variable_General::ItemName_Description();

Again, similar as in the above example, iterate through the received array of “Configs” to get the requested information (“General/Description” of all Variables):

int cnt = Results.GetSize_Configs(); //all variable configs as an array of giconfig_ConfigAPI::CType_Base_ConfigWithOwner
for(int confIndex = 0; confIndex < cnt; confIndex++)
{
giconfig_ConfigAPI::CType_Base_ConfigWithOwner result;
Results.Get_Configs(confIndex, result); //the results are GInsXmlRpcValues
 
//identify XmlRpcValue Struct-Type -> CGins_Edit_StringValue (see API-description for types)
if (result.Get_Config().getStructTypeID().compare(GInsXmlRpcStdAPI::CGIns_Edit_StringValue::StructTypeID()) == 0)
{
GInsXmlRpcStdAPI::CGIns_Edit_StringValue value;
result.Get_Config(value);
 
std::cout << "VarName: " << value.Get_Value() << std::endl;
}
}

1.3.3 Property Options

When reading properties, you also have the possibility to read all available options for the selected property using the parameter “WithOptions = true” (and even “WithImages = true” - for connection diagrams for example - if available for the property):

2

You can use this list of options in your own UI as possible selections (same as in GI.bench). The strings in the brackets are the “Values” of these “Element-Values”. These are unique identifiers of an option. You need these “Values” to set a new option. The name before the brackets is the “description” of that Element, which can be used to visualize to the user.

2. Set Configuration

Similar as for “Get Configuration” it is necessary to know an Object ID to clearly identify it in GI.config, for setting its property/configuration. Usually, after loading all configuration information with “GetConfigs” (see 1.) the Object IDs for all items are already known in the overlying software (for example in a GUI, as GI.bench-UI), which offers a user to do changes in the configuration. So it might not be necessary to execute “GetIDsFromObjectType” again.

Step Parameters/Results Action
Connect to GI.config → ConfigAPI    
Execute method “SetConfigs Parameters:
* IDs: IDs of the objects to set
* PropertyName: property of the selected object to set
* Config: XmlRpcValue
* DisableDRC: false
Results:
* ReturnStates
* ReturnLists
- The parameter “IDs” is of type “Edit_Edit_ElementListSelectionList”, which allows multiple selections → on multi-select, only select objects of the same type to set the same property!
- As parameter “PropertyName” set the desired property of the object, structured conform the “ItemNames” of the element you would like to read, separated by “/” (see Examples).
- The type of parameter “Config” needs to be conform the property you set.
- “DisableDRC” is set to “false” by default.

Results: API - base results, it contains Lists of “States” and “Changes”. Please evaluate them immediately after the call (especially “Changes” will only be available once). To get errors, warnings, info later, you can still run the DRC seperately.