The live preview of the horse training works when the EHM Device send data regarding horse to the API and the
Live Training Centers page starts receiving the live data. But during the development or maintenance it is not ideal
to have a real horse around to do testing. So we have created the Simulator that can simulate the device as if a horse
is in a race course and this will send the data to the Equetronic API. The simulated training can be previewed in real time
from the Live Training Centers Page.
If you are working on a local machine, then first open up your Equetronic API project and run the following command
npmrunstart
This will start your node server, where your API is hosted. (usually: http://127.0.0.1:5000/)
Then open the Training Simulator Page.
You will find that at the top there is a field that defines the API endpoint
By default it will take the value set in WEBSOCKET_API_ENPOINT in your .env
Select the mode of simulation. There are two options
Auto Generate: This will generate random ehm data values for a given horse. This is good for quick testing of
API and any other cosmetic features.
Import File: You can import a json file that contains accurate ehm data of any previous training records. This
is useful if we want to re-simulate any training record and debug any issue.
If you have selected the Auto Generate mode then, search and select the horse you want to simulate.
If you have selected the Import File mode then, an upload button would appear, and upload your sample file.
on the right hand side you will find a sample file
Note: As soon as the horse is selected by dropdown or from the uploaded file, the simulator will send /initialize
request to the API with the horse RFID, thus creating a session.
Click on the Start button. This will start sending data to the API. Then you will be able to see the data being
sent.
You can go to the Live Training Page and select the race course and the horse to see the live preview.
Important Note: Due to restrictions by the browser memory management, if the simulator page is not visible on screen
then the page will temporarily pause. To avoid this after starting the simulation, it is recommended to take the simulator page
in a separate window resize it and keep it open the screen.
// usage examples with output mentioned in comments
// Example 1
let randomNumber =this.getRandomArbitrary(1, 10);
console.log(randomNumber); // output: 7.42
This method sends sensor data to the API by making an AJAX call to the websocket API endpoint with the item at index i of sensor_data_to_send array as the parameters.
// usage examples with output mentioned in comments
// Example 1
this.sendSensorDataToApiAfter({"status": "success", "message": "Data sent successfully"});
// Example 2
let self =this;
this.$vaah.ajax(url, params, function(data){
self.sendSensorDataToApiAfter(data);
});