Skip to content

Emulator

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.

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();

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.

emulator.setConnection(machine);

Simulate the status of the vending machine.

Emulator.status(machine)

Simulate the dispensing of a product.

Emulator.dispensed(machine)

Simulate the product not being dispensed.

Emulator.notDispensed(machine)

Simulate the gate being inactive.

Emulator.gateInactive(machine)

Simulate the gate being configured.

Emulator.gateConfigured(machine)

Simulate a key being pressed on the vending machine.

Emulator.keyboardPressed(machine)

Simulate the door being opened.

emulator.doorOpened(machine);

Simulate the door being closed.

emulator.doorClosed(machine);

Simulate a channel disconnected.

emulator.channelDisconnected(machine);

Simulate a channel connected.

emulator.channelConnected(machine);

Simulate a channel being empty.

emulator.channelEmpty(machine);

Simulate the working temperature of the vending machine.

emulator.workingTemperature(machine);

Simulate the current temperature of the vending machine.

emulator.currentTemperature(machine);

Simulate the Machine is ready

emulator.ready(machine);

Simulate the Machine is busy

emulator.busy(machine);

Simulate an invalid tray.

emulator.invalidTray(machine);

Simulate an invalid channel.

emulator.invalidChannel(machine);

Simulate an empty channel.

emulator.emptyChannel(machine);

Simulate an elevator jam.

emulator.elevatorJam(machine);

Simulate an elevator malfunction.

emulator.elevatorMalfunction(machine);

Simulate a photo transistor failure.

emulator.phototransistorFailure(machine);

Simulate all channels being empty.

emulator.allChannelsEmpty(machine);

Simulate a product detector failure.

emulator.productDetectorFailure(machine);

Simulate the display is disconnected.

emulator.displayDisconnected(machine);

Simulate a product being under the elevator.

emulator.productUnderElevator(machine);

Simulate the elevator setting an alarm.

emulator.elevatorSettingAlarm(machine);

Simulate a button panel failure.

emulator.buttonPanelFailure(machine);

Simulate an error writing to the EEPROM.

emulator.errorWritingEeprom(machine);

Simulate an error in the control temperature.

emulator.errorControlTemperature(machine);

Simulate the thermometer being disconnected.

emulator.thermometerDisconnected(machine);

Simulate the thermometer being misconfigured.

emulator.thermometerMisconfigured(machine);

Simulate the thermometer failing.

emulator.thermometerFailure(machine);

Simulate an error in the extractor consumption.

emulator.errorExtractorConsumption(machine);

Simulate a channel search error.

emulator.channelSearchError(machine);

Simulate a product exit mouth search error.

emulator.productExitMouthSearchError(machine);

Simulate the interior elevator being blocked.

emulator.elevatorInteriorLocked(machine);

Simulate a product detector verifier error.

emulator.productDetectorVerifierError(machine);

Simulate waiting for a product recall.

emulator.waitingForProductRecall(machine);

Simulate a product expiring due to temperature.

emulator.productExpiredByTemperature(machine);

Simulate a faulty automatic door.

emulator.faultyAutomaticDoor(machine);

Simulate the reject lever was pressed.

emulator.rejectLever(machine);

Simulate the coin purse being reset.

emulator.resetCoinPurse(machine);

Simulate a coin being inserted into the box.

emulator.coinInsertedBox(machine);

Simulate a coin being inserted into the tube.

emulator.coinInsertedTube(machine);

Simulate a banknote being inserted into the stacker.

emulator.banknoteInsertedStacker(machine);

Simulate a banknote being inserted into the escrow.

emulator.banknoteInsertedEscrow(machine);

Simulate a banknote being ejected.

emulator.banknoteEjected(machine);

Simulate a banknote being inserted into the recycler.

emulator.banknoteInsertedRecycler(machine);

Simulate a banknote being taken.

emulator.banknoteTaken(machine);

Simulate the coin purse being enabled.

emulator.coinPurseEnabled(machine);

Simulate the coin purse being disabled.

emulator.coinPurseDisabled(machine);

Simulate the banknote purse being disabled.

emulator.billPurseDisabled(machine);

Simulate the banknote purse being enabled.

emulator.billPurseEnabled(machine);

Simulate reading the tubes.

emulator.readTubes(machine);

Simulate reading the banknote purse.

emulator.readBillPurse(machine);

Simulate a banknote being accepted.

emulator.banknoteAccepted(machine);

Simulate a banknote being rejected.

emulator.banknoteRejected(machine);

Simulate banknotes being dispensed.

emulator.banknotesDispensed(machine);

Simulate coins being dispensed.

emulator.coinsDispensed(machine);

Simulate the relay being turned on.

emulator.relayOn(machine);

Simulate the relay being turned off.

emulator.relayOff(machine);

Simulate the Nayax being enabled.

emulator.nayaxEnabled(machine);

Simulate the Nayax being disabled.

emulator.nayaxDisabled(machine);

Simulate the Nayax pre-credit being authorized.

emulator.nayaxPreCreditAuthorized(machine);

Simulate the Nayax cancel request.

emulator.nayaxCancelRequest(machine);

Simulate the Nayax sell being approved.

emulator.nayaxSellApproved(machine);

Simulate the Nayax sell being denied.

emulator.nayaxSellDenied(machine);

Simulate the Nayax session ending.

emulator.nayaxEndSession(machine);

Simulate the Nayax being cancelled.

emulator.nayaxCancelled(machine);

Simulate the Nayax dispensing.

emulator.nayaxDispensed(machine);

Simulate the Nayax not dispensing.

emulator.nayaxNotDispensed(machine);

Simulate a full tray.

emulator.fullTray(machine);