Class RsDataDeclarationCollection
A collection of RsDataDeclaration objects.
Inheritance
RsDataDeclarationCollection
Assembly: ABB.Robotics.RobotStudio.Stations.dll
Syntax
public class RsDataDeclarationCollection : ICollection, IEnumerable<RsDataDeclaration>, IEnumerable
Examples
RsDataDeclarationCollection Collection.
Project.UndoContext.BeginUndoStep("RsDataDeclarationCollection");
try
{
Station station = Station.ActiveStation;
// Get the RsDataDeclarationCollection for the ActiveTask.
RsDataDeclarationCollection ddCol = station.ActiveTask.DataDeclarations;
RsRobTarget rbt = new RsRobTarget();
rbt.Name = station.ActiveTask.GetValidRapidName("MyRobTarget", "_", 1);
String robTargetName = rbt.Name;
ddCol.Add(rbt);
// Output some info of the DataDeclaration in the logger.
Logger.AddMessage(new LogMessage("The RsDataDeclarationCollection on the active task contains:"));
foreach (RsDataDeclaration dd in ddCol)
{
Logger.AddMessage(new LogMessage("DataDeclaration: " + dd.Name + " with type: " + dd.TypeDisplayName));
}
// Check that RsDataDeclarationCollection contains the RobTarget that was added.
if (station.ActiveTask.FindDataDeclarationFromModuleScope(robTargetName, rbt.ModuleName) != null)
{
Logger.AddMessage(new LogMessage("The RsDataDeclarationCollection contains " + robTargetName));
}
RsDataDeclaration rbt2;
try
{
rbt2 = station.ActiveTask.FindDataDeclarationFromModuleScope("MyRobTarget_2", rbt.ModuleName);
if (rbt2 != null)
{
Logger.AddMessage(new LogMessage("Found MyRobTarget_2"));
}
else
{
Logger.AddMessage(new LogMessage("Did not find MyRobTarget_2"));
}
}
catch (ArgumentException e)
{
Logger.AddMessage(new LogMessage("The error: '" + e.Message + "' occured when trying to get 'MyRobTarget_2'"));
}
// Remove MyRobTarget_1 from the collection.
ddCol.Remove(rbt);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Properties
Count
Declaration
public virtual int Count { get; }
Property Value
IsSynchronized
Declaration
public virtual bool IsSynchronized { get; }
Property Value
Item[Int32]
Declaration
public RsDataDeclaration this[int index] { get; }
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Property Value
Item[String]
Gets the declaration with the specified name.
Declaration
olete("Do not call this method, name is not unique. Use RsTask.FindDataDeclarationFromModuleScope")]
public RsDataDeclaration this[string name] { get; }
Parameters
Type |
Name |
Description |
String |
name |
The name of the declaration to get.
|
Property Value
Exceptions
Parent
Declaration
public ProjectObject Parent { get; }
Property Value
SyncRoot
Declaration
public virtual object SyncRoot { get; }
Property Value
Methods
Add(RsDataDeclaration)
Declaration
public void Add(RsDataDeclaration dataDeclaration)
Parameters
Examples
Add RsDataDeclaration.
Project.UndoContext.BeginUndoStep("RsDataDeclarationCollection");
try
{
Station station = Station.ActiveStation;
// Get the RsDataDeclarationCollection for the ActiveTask.
RsDataDeclarationCollection ddCol = station.ActiveTask.DataDeclarations;
RsRobTarget rbt = new RsRobTarget();
rbt.Name = station.ActiveTask.GetValidRapidName("MyRobTarget", "_", 1);
String robTargetName = rbt.Name;
ddCol.Add(rbt);
// Output some info of the DataDeclaration in the logger.
Logger.AddMessage(new LogMessage("The RsDataDeclarationCollection on the active task contains:"));
foreach (RsDataDeclaration dd in ddCol)
{
Logger.AddMessage(new LogMessage("DataDeclaration: " + dd.Name + " with type: " + dd.TypeDisplayName));
}
// Check that RsDataDeclarationCollection contains the RobTarget that was added.
if (station.ActiveTask.FindDataDeclarationFromModuleScope(robTargetName, rbt.ModuleName) != null)
{
Logger.AddMessage(new LogMessage("The RsDataDeclarationCollection contains " + robTargetName));
}
RsDataDeclaration rbt2;
try
{
rbt2 = station.ActiveTask.FindDataDeclarationFromModuleScope("MyRobTarget_2", rbt.ModuleName);
if (rbt2 != null)
{
Logger.AddMessage(new LogMessage("Found MyRobTarget_2"));
}
else
{
Logger.AddMessage(new LogMessage("Did not find MyRobTarget_2"));
}
}
catch (ArgumentException e)
{
Logger.AddMessage(new LogMessage("The error: '" + e.Message + "' occured when trying to get 'MyRobTarget_2'"));
}
// Remove MyRobTarget_1 from the collection.
ddCol.Remove(rbt);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Contains(RsDataDeclaration)
Declaration
public bool Contains(RsDataDeclaration obj)
Parameters
Returns
Contains(String)
Declaration
olete("Do not call this method, name is not unique. Use RsTask.FindDataDeclarationFromModuleScope")]
public bool Contains(string name)
Parameters
Returns
Type |
Description |
Boolean |
True if the collection contains a DataDeclaration with the specified name.
|
Examples
Contains.
Project.UndoContext.BeginUndoStep("RsDataDeclarationCollection");
try
{
Station station = Station.ActiveStation;
// Get the RsDataDeclarationCollection for the ActiveTask.
RsDataDeclarationCollection ddCol = station.ActiveTask.DataDeclarations;
RsRobTarget rbt = new RsRobTarget();
rbt.Name = station.ActiveTask.GetValidRapidName("MyRobTarget", "_", 1);
String robTargetName = rbt.Name;
ddCol.Add(rbt);
// Output some info of the DataDeclaration in the logger.
Logger.AddMessage(new LogMessage("The RsDataDeclarationCollection on the active task contains:"));
foreach (RsDataDeclaration dd in ddCol)
{
Logger.AddMessage(new LogMessage("DataDeclaration: " + dd.Name + " with type: " + dd.TypeDisplayName));
}
// Check that RsDataDeclarationCollection contains the RobTarget that was added.
if (station.ActiveTask.FindDataDeclarationFromModuleScope(robTargetName, rbt.ModuleName) != null)
{
Logger.AddMessage(new LogMessage("The RsDataDeclarationCollection contains " + robTargetName));
}
RsDataDeclaration rbt2;
try
{
rbt2 = station.ActiveTask.FindDataDeclarationFromModuleScope("MyRobTarget_2", rbt.ModuleName);
if (rbt2 != null)
{
Logger.AddMessage(new LogMessage("Found MyRobTarget_2"));
}
else
{
Logger.AddMessage(new LogMessage("Did not find MyRobTarget_2"));
}
}
catch (ArgumentException e)
{
Logger.AddMessage(new LogMessage("The error: '" + e.Message + "' occured when trying to get 'MyRobTarget_2'"));
}
// Remove MyRobTarget_1 from the collection.
ddCol.Remove(rbt);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
CopyTo(RsDataDeclaration[], Int32)
Declaration
public void CopyTo(RsDataDeclaration[] array, int index)
Parameters
CopyTo(Array, Int32)
Declaration
public virtual void CopyTo(Array array, int index)
Parameters
GetEnumerator()
Declaration
public virtual IEnumerator GetEnumerator()
Returns
Remove(RsDataDeclaration)
Declaration
public void Remove(RsDataDeclaration dataDeclaration)
Parameters
Examples
Remove RsDataDeclaration.
Project.UndoContext.BeginUndoStep("RsDataDeclarationCollection");
try
{
Station station = Station.ActiveStation;
// Get the RsDataDeclarationCollection for the ActiveTask.
RsDataDeclarationCollection ddCol = station.ActiveTask.DataDeclarations;
RsRobTarget rbt = new RsRobTarget();
rbt.Name = station.ActiveTask.GetValidRapidName("MyRobTarget", "_", 1);
String robTargetName = rbt.Name;
ddCol.Add(rbt);
// Output some info of the DataDeclaration in the logger.
Logger.AddMessage(new LogMessage("The RsDataDeclarationCollection on the active task contains:"));
foreach (RsDataDeclaration dd in ddCol)
{
Logger.AddMessage(new LogMessage("DataDeclaration: " + dd.Name + " with type: " + dd.TypeDisplayName));
}
// Check that RsDataDeclarationCollection contains the RobTarget that was added.
if (station.ActiveTask.FindDataDeclarationFromModuleScope(robTargetName, rbt.ModuleName) != null)
{
Logger.AddMessage(new LogMessage("The RsDataDeclarationCollection contains " + robTargetName));
}
RsDataDeclaration rbt2;
try
{
rbt2 = station.ActiveTask.FindDataDeclarationFromModuleScope("MyRobTarget_2", rbt.ModuleName);
if (rbt2 != null)
{
Logger.AddMessage(new LogMessage("Found MyRobTarget_2"));
}
else
{
Logger.AddMessage(new LogMessage("Did not find MyRobTarget_2"));
}
}
catch (ArgumentException e)
{
Logger.AddMessage(new LogMessage("The error: '" + e.Message + "' occured when trying to get 'MyRobTarget_2'"));
}
// Remove MyRobTarget_1 from the collection.
ddCol.Remove(rbt);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
ToArray()
Declaration
public RsDataDeclaration[] ToArray()
Returns
TryGetDataDeclaration(String, out RsDataDeclaration)
Gets the data declaration with the specified name.
Declaration
olete("Do not call this method. Use RsTask.FindDataDeclarationFromModuleScope")]
public bool TryGetDataDeclaration(string name, out RsDataDeclaration dataDeclaration)
Parameters
Type |
Name |
Description |
String |
name |
The name of the declaration to get.
|
RsDataDeclaration |
dataDeclaration |
When this method returns, contains the declaration associated with the specified name,
if the name is found; otherwise, null.
|
Returns
Type |
Description |
Boolean |
true if the RsDataDeclarationCollection contains an element with the specified name; otherwise, false.
|
Exceptions