Emulation
The emulator is a tool that allows you to simulate the behavior of a vending machine. It is a useful tool for testing and debugging the software that interacts with the vending machine.
In every method used is recommended send the instance of the class that is using the emulator.
Enable the Emulator
By default, the emulator is disabled. To enable it, you need to set the enable
property to true
in the configuration
import {Emulator} from '@danidoble/webserial';
Emulator.enable = true;
You need at least one class instance
import {Jofemar} from '@danidoble/webserial';
const machine = new Jofemar();
API
Set connection instance
As I said before, you need to set the instance of the class that is using the emulator.
But of course sending every time sounds like a lot of work, so you can set the connection instance. And then you can use the emulator methods without sending the instance.
Only if the instance is the same for all methods that you are going to use.
emulator.setConnection(machine);
Status
Simulate the status of the vending machine.
Emulator.status(machine)
Dispensed
Simulate the dispensing of a product.
Emulator.dispensed(machine)
Not Dispensed
Simulate the product not being dispensed.
Emulator.notDispensed(machine)
Gate inactive
Simulate the gate being inactive.
Only works with Locker
Emulator.gateInactive(machine)
Gate configured
Simulate the gate being configured.
Only works with Locker
Emulator.gateConfigured(machine)
Keyboard pressed
Simulate a key being pressed on the vending machine.
Only works with Jofemar
Emulator.keyboardPressed(machine)
Door opened
Simulate the door being opened.
Only works with Jofemar
and Boardroid
emulator.doorOpened(machine);
Door closed
Simulate the door being closed.
Only works with Jofemar
and Boardroid
emulator.doorClosed(machine);
Channel disconnected
Simulate a channel disconnected.
Only works with Jofemar
emulator.channelDisconnected(machine);
Channel connected
Simulate a channel connected.
Only works with Jofemar
emulator.channelConnected(machine);
Channel empty
Simulate a channel being empty.
Only works with Jofemar
emulator.channelEmpty(machine);
Working temperature
Simulate the working temperature of the vending machine.
Only works with Jofemar
emulator.workingTemperature(machine);
Current temperature
Simulate the current temperature of the vending machine.
Only works with Jofemar
and Boardroid
emulator.currentTemperature(machine);
Ready
Simulate the Machine is ready
Only works with Jofemar
emulator.ready(machine);
Busy
Simulate the Machine is busy
Only works with Jofemar
emulator.busy(machine);
Invalid tray
Simulate an invalid tray.
Only works with Jofemar
emulator.invalidTray(machine);
Invalid channel
Simulate an invalid channel.
Only works with Jofemar
emulator.invalidChannel(machine);
Empty channel
Simulate an empty channel.
Only works with Jofemar
emulator.emptyChannel(machine);
Elevator jam
Simulate an elevator jam.
Only works with Jofemar
emulator.elevatorJam(machine);
Elevator malfunction
Simulate an elevator malfunction.
Only works with Jofemar
emulator.elevatorMalfunction(machine);
Photo transistor failure
Simulate a photo transistor failure.
Only works with Jofemar
emulator.phototransistorFailure(machine);
All channels empty
Simulate all channels being empty.
Only works with Jofemar
emulator.allChannelsEmpty(machine);
Product detector failure
Simulate a product detector failure.
Only works with Jofemar
emulator.productDetectorFailure(machine);
Display disconnected
Simulate the display is disconnected.
Only works with Jofemar
emulator.displayDisconnected(machine);
Product under elevator
Simulate a product being under the elevator.
Only works with Jofemar
emulator.productUnderElevator(machine);
Elevator setting alarm
Simulate the elevator setting an alarm.
Only works with Jofemar
emulator.elevatorSettingAlarm(machine);
Button panel failure
Simulate a button panel failure.
Only works with Jofemar
emulator.buttonPanelFailure(machine);
Error Writing EEPROM
Simulate an error writing to the EEPROM.
Only works with Jofemar
emulator.errorWritingEeprom(machine);
Error in control temperature
Simulate an error in the control temperature.
Only works with Jofemar
emulator.errorControlTemperature(machine);
Thermometer disconnected
Simulate the thermometer being disconnected.
Only works with Jofemar
emulator.thermometerDisconnected(machine);
Thermometer misconfigured
Simulate the thermometer being misconfigured.
Only works with Jofemar
emulator.thermometerMisconfigured(machine);
Thermometer failure
Simulate the thermometer failing.
Only works with Jofemar
emulator.thermometerFailure(machine);
Error extractor consumption
Simulate an error in the extractor consumption.
Only works with Jofemar
emulator.errorExtractorConsumption(machine);
Channel search error
Simulate a channel search error.
Only works with Jofemar
emulator.channelSearchError(machine);
Product exit mouth search error
Simulate a product exit mouth search error.
Only works with Jofemar
emulator.productExitMouthSearchError(machine);
Interior elevator blocked
Simulate the interior elevator being blocked.
Only works with Jofemar
emulator.elevatorInteriorLocked(machine);
Product detector verifier error
Simulate a product detector verifier error.
Only works with Jofemar
emulator.productDetectorVerifierError(machine);