Configuration domain
Overview
The Configuration domain namespace enables access to the configuration database of the controller. Using this domain you can read or write the value of a configuration parameter to the configuration database of the controller. When logged on to a controller, you can have either read-only access or write access. Read only is the default access right. To get write access, the client needs to request mastership of the controller resource it wants to manipulate. To write to the configuration domain, client needs to request mastership of controller resource Configuration.
The ABB.Robotics.Controllers.ConfigurationDomain namespace contains classes for working with configuration of the robot controller.
Accessing the configuration database
The configuration database must be accessed for reading and writing the configuration types and attributes of
the robot controller. Accessing the database is done through the
Configuration
Controller controller = new Controller ();
ConfigurationDatabase _database = controller.Configuration;
Read and Write configuration parameters
Configuration parameters can be read from the configuration database of the controller. The first code example shows how to read the unitmap value for signal TestDI. The variables in the path are the same as the ones in the configuration files (in this case eio.cfg). The second code example shows how to read the value of cal_offset for rob1_1 (moc.cfg).
using ABB.Robotics;
using ABB.Robotics.Controllers;
using ABB.Robotics.Controllers.ConfigurationDomain;
...
Controller controller = new Controller();
ConfigurationDatabase cfg = controller.Configuration;
string[] path = { "EIO", "EIO_SIGNAL", "TestDI", "UnitMap" };
string data = cfg.Read(path);
string[] path = { "MOC", "MOTOR_CALIB", "rob1_1", "cal_offset" };
string data = cfg.Read(path);
Configuration parameters can be written from the configuration database of the controller. The following code example shows how to set the unitmap of signal TestDI to 17.
using ABB.Robotics;
using ABB.Robotics.Controllers;
using ABB.Robotics.Controllers.ConfigurationDomain;
...
try
{
Controller controller = new Controller();
Mastership master;
ConfigurationDatabase cfg = controller.Configuration;
using (master = Mastership.Request(controller.Configuration))
{
string[] path = { "EIO", "EIO_SIGNAL", "TestDI", "UnitMap" };
cfg.Write("17", path);
}
}
catch (System.InvalidOperationException ex)
{
MessageBox.Show("Mastership is held by another client.");
}
catch (System.Exception ex)
{
// TODO: Add error handling
}
finally
{
//must release mastership in case an error occurred when Write was executed
if (master != null)
{
master.Dispose();
master = null;
}
}
Getting the controller domains
To get the list of all domains available in the configuration database, use the
Domain
DomainCollection domains = _database.Domains;
Reading the configuration types and attributes
ConfigurationDomain.Attribute object contains description of
the attribute for configuration domain. This cannot be used to read or write the value of attribute. To read and write
attribute value use the
Get
ConfigurationDomain.Instance object defines an instance of a specific Type. This object is a disconnected set of data from the configuration database.
The following code example shows how to create an instance and then subsequently use
Set
using ABB.Robotics;
using ABB.Robotics.Controllers;
using ABB.Robotics.Controllers.ConfigurationDomain;
...
DomainCollection domains = _database.Domains;
Domain domain = _ctrl.Configuration.Domains[_ctrl.Configuration.Domains.IndexOf("SYS")];
_ctrl.Logon(UserInfo.DefaultUser);
using (Mastership.Request(_ctrl.Configuration))
{
ABB.Robotics.Controllers.ConfigurationDomain.Type taskType =
domain.Types[domain.Types.IndexOf("CAB_TASKS")];
objInstance = taskType["T_ROB1"];
if (objInstance == null)
{
objInstance = taskType.Create("Test_Instance");
}
objInstance.SetAttribute("Entry", "STATIC");
object objEntry = objInstance.GetAttribute("Entry");
}
Saving configuration parameter
Use the Domain.Save(String) method to save database configuration domain to a specified file. The following code example shows how to save all the database configuration domains to a file for a controller.
using ABB.Robotics;
using ABB.Robotics.Controllers;
using ABB.Robotics.Controllers.ConfigurationDomain;
...
DomainCollection domains = _database.Domains;
foreach (Domain domain in domains)
{
string file = Directory.GetCurrentDirectory() + @"\" + domain.Name + ".cfg";
if (File.Exists(file))
{
File.Delete(file);
}
_ctrl.Logon(UserInfo.DefaultUser);
using (Mastership.Request(_ctrl.Configuration))
{
domain.Save(file);
}
}