气动#
初始化气动类#
使用以下构造函数创建气动系统:
pneumatic
构造函数在指定的端口中创建一个气动对象。
范围 |
描述 |
---|---|
|
与气动电磁阀连接的有效 智能端口。 |
|
表示是否启用或禁用气泵的布尔值。 |
// Construct a Pneumatic System "Pneumatic" with the
// pneumatic class.
pneumatic Pnuematic = pneumatic(PORT1);
当引用气动类方法时,此“气动”对象将在整个 API 文档的所有后续示例中使用。
类方法#
延长()#
extend(value)
方法延伸圆柱体。
参数 |
描述 |
---|---|
价值 |
有效的 cylinderType。 |
**返回:**无。
// Extend the first cylinder.
Pneumatic.extend(cylinder1);
// Wait 2 seconds.
wait(2, seconds);
// Retract the first cylinder.
Pneumatic.retract(cylinder1);
收回()#
retract(value)
方法缩回圆柱体。
参数 |
描述 |
---|---|
价值 |
有效的 cylinderType。 |
**返回:**无。
// Extend the first cylinder.
Pneumatic.extend(cylinder1);
// Wait 2 seconds.
wait(2, seconds);
// Retract the first cylinder.
Pneumatic.retract(cylinder1);
pumpOn()#
pumpOn()
方法打开气动气泵。
**返回:**无。
// Turn air pump on.
Pneumatic.pumpOn();
pumpOff()#
pumpOff()
方法关闭气动气泵。
**返回:**无。
// Turn air pump off.
Pneumatic.pumpOff();
泵()#
pump(state)
方法打开或关闭气动气泵。
参数 |
描述 |
---|---|
状态 |
压缩机状态。“true”表示打开。“false”表示关闭。 |
**返回:**无。
// Turn air pump on.
Pneumatic.pump(true);
wait(3, seconds);
// Turn air pump off.
Pneumatic.pump(false);
时间戳()#
timestamp()
方法请求气动系统最后接收到的状态包的时间戳。
**返回:**最后一个状态包的时间戳,以毫秒为单位的无符号 32 位整数。
安装()#
installed()
方法检查设备连接。
**返回:**如果设备已连接,则返回 true
。如果未连接,则返回 false
。