FIWARE Device Simulator library
The FIWARE Device Simulator library can be found in the ./bin
directory. It is composed of:
- The main
./lib/fiwareDeviceSimulator.js
file. It exposes the following functions:start()
: it takes a simulation configuration JSON object and returns an instance ofEventEmitter
which 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 thestop
event.
- The
./lib/validators/fiwareDeviceSimulatorValidator.js
file. 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/errors
directory including:- The
fdsErrors.js
file. It includes the errors which may be sent when running a device simulation.
- The
- The
./lib/interpolators
directory including:- The
attributeFunctionInterpolator.js
file. It implements theattribute-function-interpolator
attribute value resolver. - The
dateIncrementInterpolator.js
file. It implements thedate-increment-interpolator
attribute value resolver. - The
linearInterpolator.js
file. It implements thetime-linear-interpolator
attribute value resolver. - The
multilinePositionInterpolator.js
file. It implements themultiline-position-interpolator
attribute value resolver. - The
randomLinearInterpolator.js
file. It implements thetime-random-linear-interpolator
attribute value resolver. - The
stepAfterInterpolator.js
file. It implements thetime-step-after-interpolator
attribute value resolver. - The
stepBeforeInterpolator.js
file. It implements thetime-step-before-interpolator
attribute value resolver. - The
textRotationInterpolator.js
file. It implements thetext-rotation-interpolator
attribute value resolver.
- The