Skip to main content

API

Here you will find the methods that you can use to interact with the Relay device.

Setters

listenOnPort

Each device can have different configurations, for Relays port doesn't matter

Warning

Better don't use this

machine.listenOnPort = 1;

serialFilters

usbVendorId usbProductId are the filters that you can use to connect to the device

machine.serialFilters = [{
usbVendorId: 0x04d8,
usbProductId: 0x0053
}];

serialConfigPort

Warning

This is better don't use once constructor was called

machine.serialConfigPort = {
baudRate: 9600,
dataBits: 8,
stopBits: 1,
parity: "none",
bufferSize: 32768,
flowControl: "none",
}

Getters

listenOnPort

Address of the machine

console.log(machine.listenOnPort);

serialFilters

get the filters that apply when require a serial device

console.log(machine.serialFilters);

serialConfigPort

get the configuration of the serial port

console.log(machine.serialConfigPort);

isConnected

Check if the machine is connected

console.log(machine.isConnected);

isDisconnected

Check if the machine is disconnected

console.log(machine.isDisconnected);

deviceNumber

Get the number of device, isn't the same of the address.

Warning

Number of device is util if you have more than one machine in the same pc

console.log(machine.deviceNumber);

uuid

Get the uuid of the connection

When you create a new instance of the class, the uuid is generated

console.log(machine.uuid);

typeDevice

Get the type of the device each class has a different type, in this case is relay

console.log(machine.typeDevice);

queue

Get the queue of commands that are waiting to be executed

console.log(machine.queue);

isDispensing

Check if the machine is dispensing

console.log(machine.isDispensing);

Methods

softReload

Soft reload the machine

await machine.softReload();

sendConnect

Send connect to the machine

await machine.sendConnect();

sendCustomCode

Send custom code to the machine

await machine.sendCustomCode({code: ['00', '00', '00', '00', '00', '00', '00', '00', '00', '00']});

turnOn

Turn on the relay

await machine.turnOn();

turnOff

Turn off the relay

await machine.turnOff();

toggle

Toggle the relay

await machine.toggle({inverse: false, ms: 300});