UnderAutomation
有问题吗?

[email protected]

联系我们
UnderAutomation
⌘Q
本页面仅提供英文版本。

Inputs and outputs

List the physical I/O of a Staubli controller, read several I/O in one request and write outputs, without a VAL 3 program.

  • List the I/O
  • Read I/O
  • Write I/O
  • Try it in the demo application
  • Reference

This page shows how to list, read and write the physical inputs and outputs of a Staubli CS8 or CS9 controller with the SDK: digital, analog and the other I/O of the boards of the controller. No VAL 3 program is needed.

List the I/O

GetAllPhysicalIos() returns every physical I/O of the controller, with its name, its type and its description.

var controller = new StaubliController();
controller.Connect("192.168.0.254");
// Every physical I/O of the controller
PhysicalIo[] ios = controller.Soap.GetAllPhysicalIos();
foreach (PhysicalIo io in ios)
{
// TypeStr: din, dout, ain, serial...
Console.WriteLine($"{io.Name} [{io.TypeStr}] {io.Description} lockable={io.Lockable}");
}
controller.Disconnect();
}
Click to see the full code

The name identifies the I/O in the read and write methods. It contains the board and the I/O, separated by a backslash, for example BasicIO-1\%I0. The boards depend on the configuration of each controller: read the names with GetAllPhysicalIos(), do not guess them. In C#, write the name as a verbatim string (@"BasicIO-1\%I0"), in Python as a raw string (r"BasicIO-1\%I0").

TypeStr gives the type, for example din or dout for a digital input or output, ain for an analog input, serial for a serial line.

Read I/O

ReadIos(names) reads several I/O in one request. It returns one PhysicalIoState per name, in the same order.

var controller = new StaubliController();
controller.Connect("192.168.0.254");
// Names as returned by GetAllPhysicalIos
string[] names = { @"BasicIO-1\%I0", @"BasicIO-1\%Q0" };
// One state per name, in the same order
PhysicalIoState[] states = controller.Soap.ReadIos(names);
for (int i = 0; i < names.Length; i++)
{
PhysicalIoState state = states[i];
// State tells if the name exists on this controller
if (state.State != PhysicalIoEnumState.Defined)
{
Console.WriteLine($"{names[i]}: {state.State}");
continue;
}
Console.WriteLine($"{names[i]} = {state.Value} locked={state.Locked} simulated={state.Simulated}");
}
controller.Disconnect();
}
Click to see the full code
  • State is Defined when the name exists, Undefined or InvalidName otherwise. Test it before you use the value.
  • Value is a number: 0 or 1 for a digital I/O.
  • Locked and Simulated tell if the I/O is locked or simulated on the controller.

Write I/O

WriteIos(names, values) writes several outputs in one request. The two arrays have the same length.

var controller = new StaubliController();
controller.Connect("192.168.0.254");
string[] names = { @"BasicIO-1\%Q0", @"BasicIO-1\%Q1" };
// One value per name. Digital outputs: 1 is on, 0 is off
double[] values = { 1, 0 };
PhysicalIoWriteResponse[] responses = controller.Soap.WriteIos(names, values);
for (int i = 0; i < names.Length; i++)
{
if (!responses[i].Found)
Console.WriteLine($"{names[i]}: unknown name");
else if (!responses[i].Success)
Console.WriteLine($"{names[i]}: write refused");
}
controller.Disconnect();
}
Click to see the full code

The answer has one PhysicalIoWriteResponse per name:

  • Found is false when the name does not exist.
  • Success is false when the controller refused the write, for example for an input.

Try it in the demo application

Everything on this page can be tried without writing code, in the Physical IOs page of the demo application.

Physical IOs page of the Staubli SDK demo application

The demo application is open source. The C# source of this page is PhysicalIosControl.cs.

Reference

Methods of SoapClientBase :
C#
// Get all the physical I/O values of the controller
PhysicalIo[] GetAllPhysicalIos();
// Read the state of specified physical I/Os
PhysicalIoState[] ReadIos(string[] ios);
// Write values to specified physical I/Os
PhysicalIoWriteResponse[] WriteIos(string[] ios, double[] values);
Class
PhysicalIo
C#Python

Represents a physical I/O on the robot.

MemberTypeDescription
PhysicalIo()
Constructor
Description
Property
string
Description of the physical I/O.
Lockable
Property
bool
Indicates whether the physical I/O is lockable.
Name
Property
string
Name of the physical I/O.
TypeStr
Property
string
Type of the physical I/O (e.g., din, dout, ain, serial, ...).
Equals(object)
Method
bool
GetHashCode()
Method
int
ToString()
Method
string
Class
PhysicalIoState
C#Python

Current state and value of a physical I/O.

MemberTypeDescription
PhysicalIoState()
Constructor
Initializes a new instance of the PhysicalIoState class.
Attribute
Property
PhysicalIoAttribute
I/O type-specific attributes (analog or digital).
Locked
Property
bool
Indicates whether the I/O is locked.
Simulated
Property
bool
Indicates whether the I/O is in simulation mode.
State
Property
PhysicalIoEnumState
Definition state of the I/O.
Value
Property
double
Current numeric value of the I/O.
Equals(object)
Method
bool
GetHashCode()
Method
int
ToString()
Method
string
Enum
PhysicalIoEnumState
C#Python

Definition state of a physical I/O.

NameValueDescription
Defined
0
The I/O is defined and available.
InvalidName
2
The I/O name is invalid.
Undefined
1
The I/O is not defined.
Class
PhysicalIoWriteResponse
C#Python

Result of a physical I/O write operation.

MemberTypeDescription
PhysicalIoWriteResponse()
Constructor
Initializes a new instance of the PhysicalIoWriteResponse class.
Found
Property
bool
Indicates whether the specified I/O was found.
Success
Property
bool
Indicates whether the write operation succeeded.
Equals(object)
Method
bool
GetHashCode()
Method
int
ToString()
Method
string
Class
PhysicalIoAttribute
C#Python

Physical I/O attribute containing either analog or digital specific attributes.

MemberTypeDescription
PhysicalIoAttribute()
Constructor
Initializes a new instance of the PhysicalIoAttribute class.
AioAttribute
Property
PhysicalAioAttribute
Analog I/O specific attributes (null if digital).
DioAttribute
Property
PhysicalDioAttribute
Digital I/O specific attributes (null if analog).
Equals(object)
Method
bool
GetHashCode()
Method
int
ToString()
Method
string

轻松将 Universal Robots、Fanuc、Yaskawa、ABB 或 Staubli 机器人集成到您的 .NET、Python、LabVIEW 或 Matlab 应用程序中

UnderAutomation
联系我们Legal

© All rights reserved.