Create RsActionInstructionDescription
This example creates an RsActionInstructionDescription and adds some RsInstructionParameters to it. An action instruction defines an action for the robot to perform at a specified location in a path. The instruction parameter is the parameters to the instruction.
Example
Project.UndoContext.BeginUndoStep("CreateRsActionInstructionDescription");
try
{
// Get the active station.
Station station = Station.ActiveStation;
// Create an RsActionInstructionDescription.
RsActionInstructionDescription myAccSetDesc =
new RsActionInstructionDescription("AccSet");
myAccSetDesc.InformationText = "AccSet - Reduces the acceleration.";
// Create the InstructionParameterGroups and InstructionParameters
// and add them to the RsActionInstructionDescription.
RsInstructionParameterGroup rsIpg = new RsInstructionParameterGroup();
RsInstructionParameter rsIp = new RsInstructionParameter("Acc", "num");
rsIp.AccessMode = ParameterAccessMode.In;
rsIp.SyncReferencedData = false;
rsIp.Optional = false;
rsIpg.InstructionParameters.Add(rsIp);
myAccSetDesc.InstructionParameterGroups.Add(rsIpg);
// Create the second RsInstructionParameterGroup with a "Ramp" parameter.
rsIpg = new RsInstructionParameterGroup();
rsIp = new RsInstructionParameter("Ramp", "num");
rsIp.AccessMode = ParameterAccessMode.In;
rsIp.SyncReferencedData = false;
rsIp.Optional = false;
rsIpg.InstructionParameters.Add(rsIp);
myAccSetDesc.InstructionParameterGroups.Add(rsIpg);
// Create a default instruction template.
RsInstructionTemplate myDefaultTemplate = new RsInstructionTemplate();
myDefaultTemplate.Name = "Default";
// Create and add an enabled "Acc" instruction argument to the template.
RsInstructionArgument rsIa = new RsInstructionArgument("Acc", "");
rsIa.Enabled = true;
myDefaultTemplate.InstructionArguments.Add(rsIa);
// Create and add an enabled "Ramp" instruction argument to the template.
rsIa = new RsInstructionArgument("Ramp", "");
rsIa.Enabled = true;
myDefaultTemplate.InstructionArguments.Add(rsIa);
// Add the default template to the RsActionInstructionDescription.
myAccSetDesc.InstructionTemplates.Add(myDefaultTemplate);
// Set the active template to the default template.
myAccSetDesc.ActiveTemplate = myDefaultTemplate;
// Finally, add the RsActionInstructionDescription to the active task of the station.
station.ActiveTask.InstructionDescriptions.Add(myAccSetDesc);
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}