Device

physical. Device

A physical device that can turn lights on or off.

Constructor

(abstract) new Device(serialNum, isConnectedopt)

Source:
Parameters:
Name Type Attributes Default Description
serialNum string | number

The unique serial number of the device.

isConnected boolean <optional>
true

If the device is connected.

Extends

  • EventEmitter

Members

isConnected :boolean

Description:
  • If the device is connected.

Source:

If the device is connected.

Type:
  • boolean

serialNum :string|number

Description:
  • The unique serial number of the device.

Source:

The unique serial number of the device.

Type:
  • string | number

trafficLight :physical.PhysicalTrafficLight

Description:
  • The physical traffic light associated with this device.

Source:

The physical traffic light associated with this device.

Type:

Methods

connect()

Description:
  • Marks this device as connected.

Source:
Fires:

disconnect()

Description:
  • Marks this device as disconnected.

Source:
Fires:

(abstract) turn(lightID, onOff)

Description:
  • Turns a light on or off.

Source:
Parameters:
Name Type Description
lightID number

Zero-based index of the light to turn: 0 is red, 1 is yellow and 2 is green.

onOff number

On (1) or off (0).

Events

connected

Description:
  • Connected event.

Source:

disconnected

Description:
  • Disconnected event.

Source: