Class Controller
java.lang.Object
controller.Controller
- All Implemented Interfaces:
IModelToViewController, IViewToModelController
Controls the simulation logic for the simulation page.
This class creates the engine, starts the run, changes speed,
pauses and resumes the run, and sends engine updates to the UI.
-
Constructor Summary
ConstructorsConstructorDescriptionController(HistoryPageController historyPageController) Creates a controller for the history page.Controller(MainPageController mainPageController) Creates a controller for the main page.Controller(ResultsPageController resultsPageController) Creates a controller for the results page.Controller(SimulationPageController simulationPageController) Creates a controller for one simulation page. -
Method Summary
Modifier and TypeMethodDescriptionvoidApplies the balanced preset to the main page inputs.voidApplies the high-frequency preset to the main page inputs.voidApplies the slow stable preset to the main page inputs.voidApplies the volatile market preset to the main page inputs.voidMakes the simulation slower by increasing the delay.voidMakes the simulation faster by decreasing the delay.voidLoads saved runs from the database and shows them in the history page menu.voidApplies the default preset values on the main page inputs.voidOpens the history page from the main page after user clicks the History button.voidOpens the main page from the history page after user clicks return.voidOpens the main page from the results page after user clicks on the button to return to the main page.voidReads main page inputs, and, by user click on the button, opens the simulation page and starts the run there.voidshowEndTime(double time) Opens the results page after the engine finishes the simulation.voidshowOrderBook(OrderBook.OrderBookSnapshot snapshot) Requests a fresh order book table update for the simulation page.voidshowResultsPage(StatisticsCollector.Snapshot snapshot, Records.StatisticsAndMetricsRecord record) Opens the results page and sends final simulation data there.voidstartSimulation(eds.config.SimulationConfig config) Starts a new simulation run with the selected configuration.voidPauses the simulation or resumes it if it is already paused.voidupdateHistoryPage(int recordIndex) Fills the history page from one database record selected by the user.voidupdateOrderBook(OrderBook.OrderBookSnapshot snapshot) Sends a new order book snapshot to the simulation page table.voidupdateResultsPage(StatisticsCollector.Snapshot snapshot, Records.StatisticsAndMetricsRecord record) Fills the results page labels with already computed simulation output.voidUpdates the timer and queue labels on the simulation page.
-
Constructor Details
-
Controller
Creates a controller for one simulation page.- Parameters:
simulationPageController- the simulation page that receives UI updates
-
Controller
Creates a controller for the main page.- Parameters:
mainPageController- the main page that sends user input to this controller
-
Controller
Creates a controller for the results page.- Parameters:
resultsPageController- the results page that shows final simulation output
-
Controller
Creates a controller for the history page.- Parameters:
historyPageController- the history page that handles navigation
-
-
Method Details
-
initializeMainPage
public void initializeMainPage()Applies the default preset values on the main page inputs. The balanced preset chose as default, but can be changed.- Specified by:
initializeMainPagein interfaceIViewToModelController
-
initializeHistoryPage
public void initializeHistoryPage()Loads saved runs from the database and shows them in the history page menu.- Specified by:
initializeHistoryPagein interfaceIViewToModelController
-
applyBalancedPreset
public void applyBalancedPreset()Applies the balanced preset to the main page inputs.- Specified by:
applyBalancedPresetin interfaceIViewToModelController
-
applySlowPreset
public void applySlowPreset()Applies the slow stable preset to the main page inputs.- Specified by:
applySlowPresetin interfaceIViewToModelController
-
applyHighFrequencyPreset
public void applyHighFrequencyPreset()Applies the high-frequency preset to the main page inputs.- Specified by:
applyHighFrequencyPresetin interfaceIViewToModelController
-
applyVolatilePreset
public void applyVolatilePreset()Applies the volatile market preset to the main page inputs.- Specified by:
applyVolatilePresetin interfaceIViewToModelController
-
openSimulationPageFromMain
public void openSimulationPageFromMain()Reads main page inputs, and, by user click on the button, opens the simulation page and starts the run there.- Specified by:
openSimulationPageFromMainin interfaceIViewToModelController
-
openHistoryPageFromMain
public void openHistoryPageFromMain()Opens the history page from the main page after user clicks the History button.- Specified by:
openHistoryPageFromMainin interfaceIViewToModelController
-
updateResultsPage
public void updateResultsPage(StatisticsCollector.Snapshot snapshot, Records.StatisticsAndMetricsRecord record) Fills the results page labels with already computed simulation output.- Specified by:
updateResultsPagein interfaceIViewToModelController- Parameters:
snapshot- the final simulation snapshotrecord- the saved metrics record used for readable insight text
-
updateHistoryPage
public void updateHistoryPage(int recordIndex) Fills the history page from one database record selected by the user.- Specified by:
updateHistoryPagein interfaceIViewToModelController- Parameters:
recordIndex- index of the selected saved simulation run
-
openMainPageFromResults
public void openMainPageFromResults()Opens the main page from the results page after user clicks on the button to return to the main page.- Specified by:
openMainPageFromResultsin interfaceIViewToModelController
-
openMainPageFromHistory
public void openMainPageFromHistory()Opens the main page from the history page after user clicks return.- Specified by:
openMainPageFromHistoryin interfaceIViewToModelController
-
startSimulation
public void startSimulation(eds.config.SimulationConfig config) Starts a new simulation run with the selected configuration.- Specified by:
startSimulationin interfaceIViewToModelController- Parameters:
config- the full set of values for the simulation run
-
decreaseSpeed
public void decreaseSpeed()Makes the simulation slower by increasing the delay.- Specified by:
decreaseSpeedin interfaceIViewToModelController
-
increaseSpeed
public void increaseSpeed()Makes the simulation faster by decreasing the delay.- Specified by:
increaseSpeedin interfaceIViewToModelController
-
togglePause
public void togglePause()Pauses the simulation or resumes it if it is already paused.- Specified by:
togglePausein interfaceIViewToModelController
-
showEndTime
public void showEndTime(double time) Opens the results page after the engine finishes the simulation.- Specified by:
showEndTimein interfaceIModelToViewController- Parameters:
time- the final simulation time reported by the engine
-
updateTimeAndQueues
public void updateTimeAndQueues()Updates the timer and queue labels on the simulation page.- Specified by:
updateTimeAndQueuesin interfaceIModelToViewController
-
updateOrderBook
Sends a new order book snapshot to the simulation page table.- Specified by:
updateOrderBookin interfaceIModelToViewController- Parameters:
snapshot- the latest order book state from the engine
-
showResultsPage
public void showResultsPage(StatisticsCollector.Snapshot snapshot, Records.StatisticsAndMetricsRecord record) Opens the results page and sends final simulation data there.- Specified by:
showResultsPagein interfaceIViewToModelController- Parameters:
snapshot- the final simulation snapshotrecord- the final database record with metrics
-
showOrderBook
Requests a fresh order book table update for the simulation page.- Specified by:
showOrderBookin interfaceIViewToModelController- Parameters:
snapshot- the latest order book snapshot
-