电磁铁#
初始化电磁铁类#
使用以下构造函数创建电磁铁对象:
The electromagnet
constructor creates an electromagnet object in the specified Port:
范围 |
描述 |
---|---|
|
电磁铁所连接的有效 智能端口。 |
// Construct an Electromagnet "magnet" with the
// electromagnet class.
electromagnet magnet = electromagnet(PORT1);
This magnet
object will be used in all subsequent examples throughout this API documentation when referring to Electromagnet class methods.
类方法#
setPower()#
The setPower(power)
method sets the power level of the electromagnet used to pickup and drop.
参数 |
描述 |
---|---|
力量 |
功率级别设置在 0 - 100 范围内。 |
**返回:**无。
// Set the default power to 80%.
magnet.setPower(80);
pickup()#
该方法通过以下方式调用:
The pickup()
method activates the electromagnet to pickup an object for the default duration and at the default power specified by the setPower()
method.
// Set the magnet to pickup.
magnet.pickup();
The pickup(time, units)
method activates the electromagnet to pickup an object for a specified duration and at the default power specified by the setPower()
method.
参数 |
描述 |
---|---|
时间 |
激活电磁铁的持续时间。 |
单位 |
A valid timeUnit. The default is |
// Set the magnet to pickup for 10 seconds.
magnet.pickup(10, seconds);
The pickup(time, units, power)
method activates the electromagnet to pick up an object for a specified duration at a specified power.
参数 |
描述 |
---|---|
时间 |
激活电磁铁的持续时间。 |
单位 |
A valid timeUnit. The default is |
力量 |
要设置的功率级别。 |
// Set the magnet to pickup for 10 seconds at 90% power.
magnet.pickup(10, seconds, 90);
**返回:**无。
drop()#
该方法通过以下方式调用:
The drop()
method activates the electromagnet to pickup an object for the default duration and at the default power specified by the setPower()
method.
**返回:**无。
// Set the magnet to drop.
magnet.drop();
The drop(time, units)
method deactivates the electromagnet to drop an object for a specified duration and at the default power specified by the setPower()
method.
参数 |
描述 |
---|---|
时间 |
停用电磁铁的持续时间。 |
单位 |
A valid timeUnit. The default is |
**返回:**无。
// Set the magnet to drop for 10 seconds.
magnet.drop(10, seconds);
The drop(time, units, power)
method deactivates the electromagnet to drop an object for a specified duration at a specified power.
参数 |
描述 |
---|---|
时间 |
停用电磁铁的持续时间。 |
单位 |
A valid timeUnit. The default is |
力量 |
要设置的功率级别。 |
**返回:**无。
// Set the magnet to drop for 10 seconds at 90 percent power.
magnet.drop(10, seconds, 90);
temperature()#
The temperature(units)
method returns the temperature of the electromagnet.
参数 |
描述 |
---|---|
单位 |
A valid temperatureUnit. The default is |
**返回:**表示电磁铁温度的双精度数。
timestamp()#
The timestamp()
method requests the timestamp of the last received status packet from the Electromagnet.
**返回:**最后一个状态包的时间戳,以毫秒为单位的无符号 32 位整数。
installed()#
The installed()
method returns if the electromagnet is connected.
Returns: true
if the electromagnet is installed. false
if it is not.