For signals creation check ITxPlcSignalCreation interface. It is implemented by TxPlcProgram class and provides methods for signals creation. For robot signals use CreateFromRobotSignal and CreateToRobotSignal. The Signal Function is set when you associate a signal with the robot using the properties of TxRobot - EmergencyStopSignal, ProgramElementNumberSignal, StartProgramSignal, ProgramPauseSignal, ProgramEndedSignal,RobotReadySignal and more.
Hi Diana or anyone,
im doing like you said.
private void CreateDefaultSignalsForRobot()
TxRobot robot = m_robot01picker.Object as TxRobot;
TxPlcProgram plcProgram = TxApplication.ActiveDocument.PlcProgramRoot.CurrentPlcProgram;
TxPlcFromRobotSignalCreationData createDataFromRobotSignal = new TxPlcFromRobotSignalCreationData(robot.Name + "_startProgram")
TargetRobot = robot,
PrivateName = "startProgram"
So my problem is that code creates signal with correct name, but the robot is not in Resource.
Is this not possible or am I doing something wrong?
In picture first signal is created with API and second in simulate with Robot Signal.
After you create the signal, you need to set it to the corresponding default signal property of the robot.
For your example, first note that "startProgram" is a ToRobotSignal, not a FromRobotSignal. After correcting this, then you should be able to make the change below to the last line of your code:
robot.StartProgramSignal = plcProgram.CreateToRobotSignal(createDataToRobotSignal);
I assume the above will work, but in my code the signal is set to a variable of type TxPlcToRobotSignal, then later set to the default signal property, so if the above doesn't work, try the code below:
TxPlcToRobotSignal newToRobotSignal = plcProgram.CreateToRobotSignal(createDataToRobotSignal); robot.StartProgramSignal = newToRobotSignal;