Methods
(static) MAINLOOP() → {void}
- Description:
This is the main function of the entire app. Every X milliseconds we start by gathering data (either from file or in real-time).
Once the data is gathered, prepared and displayed, we set the screen information (mv/div, etc..).
If the oscilloscope is currently triggered, we keep the loop going and call every UI drawings 'by hand' since the functions gathering the data won't be able to do it.
The main loop depends mainly on the following factors:
- > Is the oscilloscope running?
- > What is the active mode (file / real-time)?
- > Is the oscilloscope triggered?
At the end of every loop, we wait a few milliseconds before gathering data again to make sure there is no bottleneck happening. From our tests, going below 50ms for every loop will start raising errors.
- Source:
Returns:
- Type
- void
(static) environmentSetup() → {void}
- Description:
This function is the first one to be called once the page is fully loaded.
Its purpose is to make ready every single UI interaction available on the oscilloscope page. This includes every function button (SETUP, DISPLAY, etc..) and channel buttons, cursors, etc ..
Once every listener is set on the page we finish by gathering the current settings from the backend.
- Source:
Fires:
- event:changeChannelButtonStatus - When a channel button is clicked on.
- event:isRunning - When the RUN/STOP button is clicked on.
- event:downloadCanvasAsImage - When the PRINT button is clicked on.
- event:populateModalForSave - When the SAVE button is clicked on.
- event:populateModalForMeasure_MATHS - When the MEASURE button is clicked on.
- event:populateModalForTrigger - When the TRIGGER button is clicked on (if oscilloscope isn't triggered).
- event:autoset - When the AUTOSET button is clicked on.
- event:populateModalForCursors - When the CURSORS button is clicked on.
- event:populateModalForSize - When the SIZE button is clicked on.
- event:populateModalForDisplay - WHen the DISPLAY button is clicked on.
- event:populateModalForSetup - When the SETUP button is clicked on.
Listens to Events:
- event:horizontalCursor For a user dragging the horizontal offset cursor (triangle).
- event:VerticalKnob For a user interacting with the vertical scaling knob (bottom right).
- event:HorizontalKnob For a user interacting with the horizontal scaling knob (bottom right).
- event:CANVAS For a user dragging their mouse on the canvas.
- event:"Shift+X" Remove the zoom (if any) when user presses Shift + X.
Returns:
- Type
- void
(static) fetchDataFromFile() → {void}
- Description:
Fetches oscilloscope data from a file on the server and updates the channel data arrays with the received data.
This function sends a GET request to the server to retrieve data from the specified file at the current file position. We need to specify from which file we need the data and the current position within the file (default = 0). The received data is used to populate the
channelData
arrays, and various aspects of the oscilloscope's display are updated accordingly. It also handles cursor and trigger displays, as well as error handling for network issues.
- Source:
Throws:
-
Throws an error with a code 408 if anything went wrong with the backend.
- Type
- Error
Returns:
- Type
- void
(static) fetchRawData() → {void}
- Description:
Fetches oscilloscope data either in real-time from a STARE card or via a mockup server like "fakestare.py".
This function sends a GET request to the server which will make it grab the latest data packet it can find and forward it back to the front-end. The data is being sent raw, which is why we need to parse it in the second half of the function. Just like with 'fetchDataFromFile', we then draw the signal we gathered from each channel and also added UI elements like the trigger cursor, measure cursors, etc..
We also call a function 'removeSpikes' to get rid of potential triggerpoints in a set of data which would otherwise result in one big spike on the screen.
- Source:
Throws:
-
After a certain number of failed gathering attempts, the user will be warned something is wrong.
- Type
- Error
Returns:
- Type
- void
(static) getCurrentSettings() → {void}
- Description:
Fetches the current oscilloscope settings from the server and updates the configuration and channel data accordingly.
This function makes a POST request to the '/oscillo/settings/' endpoint to retrieve the current settings. It updates the global
config
object with the received settings and also updates thechannelData
object based on the number of channels specified in the settings.
- Source:
Throws:
-
Throws an error if there's any problem with the XMLHttpRequest.
- Type
- Error
Returns:
- Type
- void
(static) saveColorChoices() → {void}
- Description:
This function saves a user's color selection for each channel (both dark and light) and options regarding the grid.
We start by gathering every color the user has selected within the 'SETUP' menu. Once we got every jvalues for all the channels and the grid, we make a POST request to the server to save the selections for the user.
- Source:
Throws:
-
If the user is not registered, we let him know that the color choices won't be persistent unless they login / create an account.
- Type
- Error
Returns:
- Type
- void