FIWARE Device Simulator library
The FIWARE Device Simulator library can be found in the ./bin directory. It is composed of:
- The main
./lib/fiwareDeviceSimulator.jsfile. It exposes the following functions:start(): it takes a simulation configuration JSON object and returns an instance ofEventEmitterwhich informs of the following events to the client:token-request: Whenever a new authorization token is requested. No event object is passed as additional information for this event occurrence.token-response: Whenever a new authorization token is received. The passed event includes the following properties:-
expires_at: The expiration date
-
token-request-scheduled: Whenever a new authorization token request is scheduled. The passed event includes the following properties:scheduled_at: The scheduled date
update-scheduled: Whenever a new entity update is scheduled. The passed event includes the following properties:schedule: The scheduleentity: Information about the entity to be updatedattributes: The attributes to be updated
update-request: Whenever a new entity update is requested. The passed event includes the following properties:request: Details about the update request
update-response: Whenever a new entity update response is received. The passed event includes the following properties:request: Details about the update requestresponse: The body of the received update response
info: Informational event typically to inform about the simulation evolution. The passed event includes the following properties:message: The informational message.
progress-info: Progress information about the running simulation. The passed event includes the following properties:updatesProcessed: The total number of updates processedupdatesRequested: The number of update requests sentdelayedUpdateRequests: The number of delayed update requestserrorUpdateRequests: The number of erroneous update requestselapsedTime: The real elapsed timesimulatedElapsedTime: The simulated time in case of fast-forward simulationsupdateJobs: The array of scheduled update requestsclock: The lolex NPM packageclock(returned bylolex.createClock()) in case of fast-forward simulations
error: Whenever an error happens. The passed event includes the following properties:error: The errorrequest: The optional associated request (optional)
stop: Whenever the simulation is stopped. No event object is passed as additional information for this event occurrence.end: Whenever the simulation ends. No event object is passed as additional information for this event occurrence.stop(): it stops the currently running simulation, if any, and emits thestopevent.
- The
./lib/validators/fiwareDeviceSimulatorValidator.jsfile. It exposes the following functions:validateConfiguration: Validates a simulation configuration object asynchronously taking the simulation configuration object as input as well as a callback which will be called once the validation has been completed passing an error object with further information about the problem in case the simulation configuration object was not valid.
- The
./lib/errorsdirectory including:- The
fdsErrors.jsfile. It includes the errors which may be sent when running a device simulation.
- The
- The
./lib/interpolatorsdirectory including:- The
attributeFunctionInterpolator.jsfile. It implements theattribute-function-interpolatorattribute value resolver. - The
dateIncrementInterpolator.jsfile. It implements thedate-increment-interpolatorattribute value resolver. - The
linearInterpolator.jsfile. It implements thetime-linear-interpolatorattribute value resolver. - The
multilinePositionInterpolator.jsfile. It implements themultiline-position-interpolatorattribute value resolver. - The
randomLinearInterpolator.jsfile. It implements thetime-random-linear-interpolatorattribute value resolver. - The
stepAfterInterpolator.jsfile. It implements thetime-step-after-interpolatorattribute value resolver. - The
stepBeforeInterpolator.jsfile. It implements thetime-step-before-interpolatorattribute value resolver. - The
textRotationInterpolator.jsfile. It implements thetext-rotation-interpolatorattribute value resolver.
- The