Backend API¶
This page gathers all the API calls that can be used by the front end.
Front end -> Backend
Global configuration¶
Collection of all functions/API calls available to the front end that handles the global variables.
saveConfigParams(configParams)¶
saveConfigParams(configParams)
Saves the config parameters to the persistent file
loadConfigParams()¶
loadConfigParams()
Loads the config parameters from the persistent file
Data base¶
Collection of all functions/API calls available to the front end that handles the communication with the data base, such as fetching and storing data.
getMaterialList()¶
getMaterialList()
TODO
getMaterialAt(index)¶
getMaterialAt(index)
Returns the material at an index
from the database.
getExperimentAt(index)¶
getExperimentAt(index)
Returns the experiment at an index
from the database.
getDataPointArrayAt(index)¶
getDataPointArrayAt(index)
Returns an array of DataPoint
at an index
from the database.
postMaterialJS(material)¶
postMaterialJS(material)
Posts a new material to the Data base
patchMaterialByIdJS(patchMaterial)¶
patchMaterialByIdJS(patchMaterial)
Patches an existing material in the Data base
deleteMaterialByIdJS(id)¶
deleteMaterialByIdJS(id)
Deletes an existing material in the Data base.
postExperimentJS(experiment)¶
postExperimentJS(experiment)
Posts a new experiment to the Data base
patchExperimentByIdJS(patchExperiment)¶
patchExperimentByIdJS(patchExperiment)
Patches an existing experiment in the Data base
deleteExperimentByIdJS(id)¶
deleteExperimentByIdJS(id)
Deletes an existing experiment in the Data base.
Core¶
checkCanStartExperimentJS()¶
checkCanStartExperimentJS()
This function calls the check_can_start_experiment(experiment_id)
on the backend.
The front end will call this function when the user click to start experiment.
The backend MUST respond with a 1 if everything is ok or 0 if something is not correct.
In case something is wrong the backend also displays an error to the user telling what went wrong
startExperimentRoutineJS(experimentId)¶
startExperimentRoutineJS(experimentId)
This function calls the start_experiment_routine(experiment_id)
on the backend.
The front end will call this function after everything is correct and ready to change pages.
Receives an id
to an experiment as parameter.
The backend MUST send a command to change to the experiment page.
Returns 1 if succeeded.
endExperimentRoutineJS()¶
endExperimentRoutineJS()
This function calls the end_experiment_routine()
on the backend.
Usually it should be used to handle when the user press a "end experiment" button or something similar.
setCustomMovementDistanceJS()¶
setCustomMovementDistanceJS()
Warning
DEPRECATED
This function calls the set_custom_movement_distance(new_movement_distance)
on the backend.
Sets the movement distance that the z-axis moves when the user is controlling the machine manually.
This distance is set in MILLIMETERS
Returns 1 if succeeded.
returnZAxisJS()¶
returnZAxisJS()
This function calls the return_z_axis()
on the backend.
Returns the z-axis to the origin.
Returns 1 if succeeded (if the function was acknowledged).
stopZAxisJS()¶
stopZAxisJS()
This function calls the stop_z_axis()
on the backend.
Stops the z-axis.
Returns 1 if succeeded (if the function was acknowledged).
moveZAxisMillimetersJS(distance)¶
moveZAxisMillimetersJS(distance)
This function calls the move_z_axis_millimeters(distance)
on the backend.
Moves the z-axis [distance]mm.
This distance is set in MILLIMETERS
Returns 1 if succeeded (if the function was acknowledged).
moveZAxisRevolutionsJS(revolutions)¶
moveZAxisRevolutionsJS(revolutions)
This function calls the move_z_axis_revolutions(revolutions)
on the backend.
Moves the z-axis [revolutions].
This distance is set in revolutions
Returns 1 if succeeded (if the function was acknowledged).
getAvailablePortsListJS()¶
getAvailablePortsListJS()
This function calls the get_available_ports_list()
on the backend.
Returns a JSON object containing the available COM ports:
connectToPortJS()¶
connectToPortJS()
This function calls the connect_to_port()
on the backend.
Connects to a port. The port argument is a string like COM4
Returns 1 connection was successful
disconnectGranuladoJS()¶
!!! quote "### disconnectGranuladoJS()
()"
This function calls the disconnect_granulado()
on the backend.
Returns 1 connection was successful
``` javaScript title="React usage example"
import { disconnectGranuladoJS } from "./api/backend-api";
onClick(()=>{
disconnectGranuladoJS("COM3");
};)
```
tareLoadJS()¶
tareLoadJS()
This function calls the tare_load()
on the backend.
Tares the load cell
Returns 1 if succeeded (if the function was acknowledged).
calibrateKnownWeightJS()¶
calibrateKnownWeightJS()
This function calls the calibrate_known_weight()
on the backend.
Calibrates the load cell to the known weight
Returns 1 if succeeded (if the function was acknowledged).
calibrateZAxisJS()¶
calibrateZAxisJS()
This function calls the calibrate_z_axis()
on the backend.
Calibrates z axis of the machine
Returns 1 if succeeded (if the function was acknowledged).