Client will perform GET FLASKAPP/api/openbci/start to start the bci stream process, and the response will only come once the stream process is connected to the bci machine. The response will contain the process_id
Once the client is ready to begin collecting data for a character, it will send a request at POST FLASKAPP/api/openbci/:process_id/collect/start with a request form containing the following information:
character
phase
frequency
Once the client wants to stop recording the information, it will send a request to POST FLASKAPP/api/openbci/:process_id/collect/stop, and the backend will upload the information to the db for the character that just stopped recording. The response will only return once the backend has finished uploading the data to the db
The client can now repeat steps 2 and 3 for all the required characters.
Once the client has finished obtaining results for all characters, it may call the endpoint POST FLASKAPP/api/openbci/:process_id/stop to close the subprocess. If the process is still recording information or if it is still in the midst of uploading data, it should return the appropriate error in a message.
Testing:
The above workflow has been tested on a local database running in docker, and all the endpoints were tested in a simple smoke test with dummy data from openBCI.
No substantial delay was noticed when uploading around 5 seconds of data, but additional testing may be required depending on the use case.
I suggest additional testing with production database, and with the actual equipment.
Shared dictionary:
This is the template for the new shared dictionary between the flask app and subprocesses:
bci_processes_states = {process_id: {
character : str,
phase: float,
frequency: float,
q: Queue,
config_id: int,
bci_config: str,
state: str (Could be either start, ready, collect, stop)
}
}
The state allows the subprocess to act as a simple state machine, where its action performed will depend on the state given by the parent process
Issues linked: closes #86, closes #87, closes #88, closes #89 Workflow:
GET FLASKAPP/api/openbci/start
to start the bci stream process, and the response will only come once the stream process is connected to the bci machine. The response will contain theprocess_id
POST FLASKAPP/api/openbci/:process_id/collect/start
with a request form containing the following information:POST FLASKAPP/api/openbci/:process_id/collect/stop
, and the backend will upload the information to the db for the character that just stopped recording. The response will only return once the backend has finished uploading the data to the dbPOST FLASKAPP/api/openbci/:process_id/stop
to close the subprocess. If the process is still recording information or if it is still in the midst of uploading data, it should return the appropriate error in a message.Testing: The above workflow has been tested on a local database running in docker, and all the endpoints were tested in a simple smoke test with dummy data from openBCI.
No substantial delay was noticed when uploading around 5 seconds of data, but additional testing may be required depending on the use case.
I suggest additional testing with production database, and with the actual equipment.
Shared dictionary: This is the template for the new shared dictionary between the flask app and subprocesses:
The state allows the subprocess to act as a simple state machine, where its action performed will depend on the state given by the parent process