Declaring IO Signals
IO signals are an important element that SmartComponents use to communicate with the rest of the Station. In this topic, the developer will learn how to declare them by modifying the SmartComponent's XML file.
The IOSignal class
contains the necessary elements for declaring inputs and outputs of several types. These types are enumerated in the IOSignal
The steps that we will perform in this topic are the following:
Create a signal of each type.
Set the value property to define the initial value of a signal.
Define the value range of an analog signal.
Hide a signal from the user interface.
Make a signal read-only.
Set the Auto-reset signal.
Note
The code in this topic can be tested using the default RobotStudio Smart Component template.
Signals and their arguments
The following snippet from the SmartComponent's XML file shows how to declare a signal of each of the types listed above:
<Signals> <IOSignal name="DigitalIn" signalType="DigitalInput" /> <IOSignal name="DigitalOut" signalType="DigitalOutput" /> <IOSignal name="AnalogIn" signalType="AnalogInput" /> <IOSignal name="AnalogOut" signalType="AnalogOutput" /> <IOSignal name="DigitalInBus" signalType="DigitalGroupInput" /> <IOSignal name="DigitalOutBus" signalType="DigitalGroupOutput" /> </Signals>
Use the Value property to set an initial value for the signal. Use 0 for digital signals and 0.0 for analog ones.
<IOSignal name="InitOutput" signalType="DigitalOutput" value="1" />
Define the value range for non-digital signals with the Min
Value and MaxValue arguments.<IOSignal name="Analog0to10" signalType="AnalogInput" minValue="0" maxValue="10" />
Signals can be hidden from the user interface with the UIVisible property.
<IOSignal name="HiddenSignal" signalType="DigitalInput" uiVisible="false" />
The Read
Only property renders the user unable to set the value of a signal from the user interface.<IOSignal name="ReadOnlyIn" signalType="DigitalInput" readOnly="true" />
The Auto
Reset property automatically returns the signal to its default state once it is activated.<IOSignal name="SinglePulse" signalType="DigitalOutput" autoReset="true" />
Example
The following XML file showcases a SmartComponent that has the declared signals.
<?xml version="1.0" encoding="utf-8" ?>
<lc:LibraryCompiler xmlns:lc="urn:abb-robotics-robotstudio-librarycompiler"
xmlns="urn:abb-robotics-robotstudio-graphiccomponent"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:abb-robotics-robotstudio-librarycompiler file:///C:\Program%20Files%20(x86)\ABB\SDK\RobotStudio%202024%20SDK\LibraryCompilerSchema.xsd
urn:abb-robotics-robotstudio-graphiccomponent file:///C:\Program%20Files%20(x86)\ABB\SDK\RobotStudio%202024%20SDK\GraphicComponentSchema.xsd">
<lc:Library fileName="SmartComponent.rslib">
<lc:DocumentProperties>
<lc:Author>USER_NAME</lc:Author>
<lc:Image source="SmartComponent.png"/>
</lc:DocumentProperties>
<SmartComponent name="SmartComponent" icon="SmartComponent.png"
codeBehind="SmartComponent.CodeBehind,SmartComponent.dll"
canBeSimulated="false">
<Properties>
<DynamicProperty name="SampleProperty" valueType="System.Double" value="10">
<Attribute key="MinValue" value="0"/>
<Attribute key="Quantity" value="Length"/>
</DynamicProperty>
</Properties>
<Bindings>
</Bindings>
<Signals>
<IOSignal name="DigitalIn" signalType="DigitalInput" />
<IOSignal name="DigitalOut" signalType="DigitalOutput"/>
<IOSignal name="AnalogIn" signalType="AnalogInput" />
<IOSignal name="AnalogOut" signalType="AnalogOutput" />
<IOSignal name="DigitalInBus" signalType="DigitalGroupInput" />
<IOSignal name="DigitalOutBus" signalType="DigitalGroupOutput" />
<IOSignal name="InitOutput" signalType="DigitalOutput" value="1" />
<IOSignal name="Analog0to10" signalType="AnalogInput" minValue="0" maxValue="10" />
<IOSignal name="HiddenSignal" signalType="DigitalInput" uiVisible="false" />
<IOSignal name="ReadOnlyIn" signalType="DigitalInput" readOnly="true" />
<IOSignal name="SinglePulse" signalType="DigitalOutput" autoReset="true" />
</Signals>
<GraphicComponents>
</GraphicComponents>
<Assets>
<Asset source="SmartComponent.dll"/>
</Assets>
</SmartComponent>
</lc:Library>
</lc:LibraryCompiler>