Skip to content

Commit 2a9ba27

Browse files
committed
Refactor SessionSettings global variable to be named sessionSettings to distinguish with upcoming widgetSettings
1 parent 19a14e9 commit 2a9ba27

13 files changed

Lines changed: 80 additions & 80 deletions

OpenBCI_GUI/Containers.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ void drawContainers() {
8080
if (widthOfLastScreen_C != width || heightOfLastScreen_C != height) {
8181
setupContainers();
8282
//setupVizs(); //container extension example (more below)
83-
settings.widthOfLastScreen = width;
84-
settings.heightOfLastScreen = height;
83+
sessionSettings.widthOfLastScreen = width;
84+
sessionSettings.heightOfLastScreen = height;
8585
}
8686
}
8787

OpenBCI_GUI/ControlPanel.pde

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class ControlPanel {
266266
sb.append("OpenBCISession_");
267267
sb.append(dataLogger.getSessionName());
268268
sb.append(File.separator);
269-
settings.setSessionPath(sb.toString());
269+
sessionSettings.setSessionPath(sb.toString());
270270
}
271271

272272
public void setBrainFlowStreamerOutput() {
@@ -364,7 +364,7 @@ class DataSourceBox {
364364
Map bob = sourceList.getItem(int(sourceList.getValue()));
365365
String str = (String)bob.get("headline"); // Get the text displayed in the MenuList
366366
int newDataSource = (int)bob.get("value");
367-
settings.controlEventDataSource = str; //Used for output message on system start
367+
sessionSettings.controlEventDataSource = str; //Used for output message on system start
368368
eegDataSource = newDataSource;
369369

370370
//Reset protocol
@@ -910,7 +910,7 @@ class SessionDataBox {
910910
createODFButton("odfButton", "OpenBCI", dataLogger.getDataLoggerOutputFormat(), x + padding, y + padding*2 + 18 + 58, (w-padding*3)/2, 24);
911911
createBDFButton("bdfButton", "BDF+", dataLogger.getDataLoggerOutputFormat(), x + padding*2 + (w-padding*3)/2, y + padding*2 + 18 + 58, (w-padding*3)/2, 24);
912912

913-
createMaxDurationDropdown("maxFileDuration", Arrays.asList(settings.fileDurations));
913+
createMaxDurationDropdown("maxFileDuration", Arrays.asList(sessionSettings.fileDurations));
914914

915915

916916

@@ -1015,7 +1015,7 @@ class SessionDataBox {
10151015
private void createMaxDurationDropdown(String name, List<String> _items){
10161016
maxDurationDropdown = sessionData_cp5.addScrollableList(name)
10171017
.setOpen(false)
1018-
.setColor(settings.dropdownColors)
1018+
.setColor(sessionSettings.dropdownColors)
10191019
.setOutlineColor(150)
10201020
//.setColorBackground(OPENBCI_BLUE) // text field bg color
10211021
.setColorValueLabel(OPENBCI_DARKBLUE) // text color
@@ -1033,7 +1033,7 @@ class SessionDataBox {
10331033
maxDurationDropdown
10341034
.getCaptionLabel() //the caption label is the text object in the primary bar
10351035
.toUpperCase(false) //DO NOT AUTOSET TO UPPERCASE!!!
1036-
.setText(settings.fileDurations[settings.defaultOBCIMaxFileSize])
1036+
.setText(sessionSettings.fileDurations[sessionSettings.defaultOBCIMaxFileSize])
10371037
.setFont(p4)
10381038
.setSize(14)
10391039
.getStyle() //need to grab style before affecting the paddingTop
@@ -1042,7 +1042,7 @@ class SessionDataBox {
10421042
maxDurationDropdown
10431043
.getValueLabel() //the value label is connected to the text objects in the dropdown item bars
10441044
.toUpperCase(false) //DO NOT AUTOSET TO UPPERCASE!!!
1045-
.setText(settings.fileDurations[settings.defaultOBCIMaxFileSize])
1045+
.setText(sessionSettings.fileDurations[sessionSettings.defaultOBCIMaxFileSize])
10461046
.setFont(h5)
10471047
.setSize(12) //set the font size of the item bars to 14pt
10481048
.getStyle() //need to grab style before affecting the paddingTop
@@ -1052,7 +1052,7 @@ class SessionDataBox {
10521052
public void controlEvent(CallbackEvent theEvent) {
10531053
if (theEvent.getAction() == ControlP5.ACTION_BROADCAST) {
10541054
int n = (int)(theEvent.getController()).getValue();
1055-
settings.setLogFileDurationChoice(n);
1055+
sessionSettings.setLogFileDurationChoice(n);
10561056
println("ControlPanel: Chosen Recording Duration: " + n);
10571057
} else if (theEvent.getAction() == ControlP5.ACTION_ENTER) {
10581058
lockOutsideElements(true);
@@ -1775,7 +1775,7 @@ class BrainFlowStreamerBox {
17751775
private void createDropdown(String name){
17761776
bfFileSaveOption = bfStreamerCp5.addScrollableList(name)
17771777
.setOpen(false)
1778-
.setColor(settings.dropdownColors)
1778+
.setColor(sessionSettings.dropdownColors)
17791779
.setOutlineColor(150)
17801780
.setSize(167, (dataWriterBfEnum.values().length + 1) * 24)
17811781
.setBarHeight(24) //height of top/primary bar
@@ -2164,7 +2164,7 @@ class SDBox {
21642164

21652165
sdList = cp5_sdBox.addScrollableList(name)
21662166
.setOpen(false)
2167-
.setColor(settings.dropdownColors)
2167+
.setColor(sessionSettings.dropdownColors)
21682168
.setOutlineColor(150)
21692169
.setSize(w - padding*2, 2*24)//temporary size
21702170
.setBarHeight(24) //height of top/primary bar

OpenBCI_GUI/DataLogger.pde

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DataLogger {
3333

3434
private void saveNewData() {
3535
//If data is available, save to playback file...
36-
if(!settings.isLogFileOpen()) {
36+
if(!sessionSettings.isLogFileOpen()) {
3737
return;
3838
}
3939

@@ -54,21 +54,21 @@ class DataLogger {
5454
}
5555

5656
public void limitRecordingFileDuration() {
57-
if (settings.isLogFileOpen() && outputDataSource == OUTPUT_SOURCE_ODF && settings.maxLogTimeReached()) {
57+
if (sessionSettings.isLogFileOpen() && outputDataSource == OUTPUT_SOURCE_ODF && sessionSettings.maxLogTimeReached()) {
5858
println("DataLogging: Max recording duration reached for OpenBCI data format. Creating a new recording file in the session folder.");
5959
closeLogFile();
6060
openNewLogFile(directoryManager.getFileNameDateTime());
61-
settings.setLogFileStartTime(System.nanoTime());
61+
sessionSettings.setLogFileStartTime(System.nanoTime());
6262
}
6363
}
6464

6565
public void onStartStreaming() {
6666
if (outputDataSource > OUTPUT_SOURCE_NONE && eegDataSource != DATASOURCE_PLAYBACKFILE) {
6767
//open data file if it has not already been opened
68-
if (!settings.isLogFileOpen()) {
68+
if (!sessionSettings.isLogFileOpen()) {
6969
openNewLogFile(directoryManager.getFileNameDateTime());
7070
}
71-
settings.setLogFileStartTime(System.nanoTime());
71+
sessionSettings.setLogFileStartTime(System.nanoTime());
7272
}
7373

7474
//Print BrainFlow Streamer Info here after ODF and BDF println
@@ -111,7 +111,7 @@ class DataLogger {
111111
// Do nothing...
112112
break;
113113
}
114-
settings.setLogFileIsOpen(true);
114+
sessionSettings.setLogFileIsOpen(true);
115115
}
116116

117117
/**
@@ -159,7 +159,7 @@ class DataLogger {
159159
// Do nothing...
160160
break;
161161
}
162-
settings.setLogFileIsOpen(false);
162+
sessionSettings.setLogFileIsOpen(false);
163163
}
164164

165165
private void closeLogFileBDF() {
@@ -197,10 +197,10 @@ class DataLogger {
197197
}
198198

199199
public void setBfWriterDefaultFolder() {
200-
if (settings.getSessionPath() != "") {
201-
settings.setSessionPath(directoryManager.getRecordingsPath() + "OpenBCISession_" + sessionName);
200+
if (sessionSettings.getSessionPath() != "") {
201+
sessionSettings.setSessionPath(directoryManager.getRecordingsPath() + "OpenBCISession_" + sessionName);
202202
}
203-
fileWriterBF.setBrainFlowStreamerFolderName(sessionName, settings.getSessionPath());
203+
fileWriterBF.setBrainFlowStreamerFolderName(sessionName, sessionSettings.getSessionPath());
204204
}
205205

206206
public String getBfWriterFilePath() {

OpenBCI_GUI/DataWriterBF.pde

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class DataWriterBF {
4848
}
4949

5050
public void setBrainFlowStreamerFolderName(String _folderName, String _folderPath) {
51-
//settings.setSessionPath(directoryManager.getRecordingsPath() + "OpenBCISession_" + _sessionName + File.separator);
51+
//sessionSettings.setSessionPath(directoryManager.getRecordingsPath() + "OpenBCISession_" + _sessionName + File.separator);
5252
folderName = _folderName;
5353
folderPath = _folderPath;
5454

OpenBCI_GUI/DataWriterODF.pde

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public class DataWriterODF {
77
protected String headerFirstLineString = "%OpenBCI Raw EXG Data";
88

99
DataWriterODF(String _sessionName, String _fileName) {
10-
settings.setSessionPath(directoryManager.getRecordingsPath() + "OpenBCISession_" + _sessionName + File.separator);
11-
fname = settings.getSessionPath();
10+
sessionSettings.setSessionPath(directoryManager.getRecordingsPath() + "OpenBCISession_" + _sessionName + File.separator);
11+
fname = sessionSettings.getSessionPath();
1212
fname += fileNamePrependString;
1313
fname += _fileName;
1414
fname += ".txt";
@@ -21,8 +21,8 @@ public class DataWriterODF {
2121
DataWriterODF(String _sessionName, String _fileName, String _fileNamePrependString, String _headerFirstLineString) {
2222
fileNamePrependString = _fileNamePrependString;
2323
headerFirstLineString = _headerFirstLineString;
24-
settings.setSessionPath(directoryManager.getRecordingsPath() + "OpenBCISession_" + _sessionName + File.separator);
25-
fname = settings.getSessionPath();
24+
sessionSettings.setSessionPath(directoryManager.getRecordingsPath() + "OpenBCISession_" + _sessionName + File.separator);
25+
fname = sessionSettings.getSessionPath();
2626
fname += fileNamePrependString;
2727
fname += _fileName;
2828
fname += ".txt";

OpenBCI_GUI/Interactivity.pde

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ void parseKey(char val) {
101101
///////////////////// Save User settings lowercase n
102102
case 'n':
103103
println("Interactivity: Save key pressed!");
104-
settings.save(settings.getPath("User", eegDataSource, globalChannelCount));
105-
outputSuccess("Settings Saved! Using Expert Mode, you can load these settings using 'N' key. Click \"Default\" to revert to factory settings.");
104+
sessionSettings.save(sessionSettings.getPath("User", eegDataSource, globalChannelCount));
105+
outputSuccess("Settings Saved! Using Expert Mode, you can load these settings using 'N' key. Click \"Default\" to revert to factory sessionSettings.");
106106
return;
107107

108108
///////////////////// Load User settings uppercase N
109109
case 'N':
110110
println("Interactivity: Load key pressed!");
111-
settings.loadKeyPressed();
111+
sessionSettings.loadKeyPressed();
112112
return;
113113

114114
case '?':

OpenBCI_GUI/OpenBCI_GUI.pde

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public final static String stopButton_pressToStop_txt = "Stop Data Stream";
293293
public final static String stopButton_pressToStart_txt = "Start Data Stream";
294294

295295
DirectoryManager directoryManager;
296-
SessionSettings settings;
296+
SessionSettings sessionSettings;
297297
GuiSettings guiSettings;
298298
DataProcessing dataProcessing;
299299
FilterSettings filterSettings;
@@ -428,7 +428,7 @@ void setup() {
428428

429429
// Copy sample data to the Users' Documents folder + create Recordings folder
430430
directoryManager.init();
431-
settings = new SessionSettings();
431+
sessionSettings = new SessionSettings();
432432
guiSettings = new GuiSettings(directoryManager.getSettingsPath());
433433
userPlaybackHistoryFile = directoryManager.getSettingsPath()+"UserPlaybackHistory.json";
434434

@@ -445,8 +445,8 @@ void delayedSetup() {
445445
smooth(); //turn this off if it's too slow
446446

447447
surface.setResizable(true); //updated from frame.setResizable in Processing 2
448-
settings.widthOfLastScreen = width; //for screen resizing (Thank's Tao)
449-
settings.heightOfLastScreen = height;
448+
sessionSettings.widthOfLastScreen = width; //for screen resizing (Thank's Tao)
449+
sessionSettings.heightOfLastScreen = height;
450450

451451
setupContainers();
452452

@@ -533,8 +533,8 @@ synchronized void draw() {
533533
dataProcessing.networkingDataAccumulator.compareAndSetNetworkingFrameLocks();
534534
}
535535
} else if (systemMode == SYSTEMMODE_INTROANIMATION) {
536-
if (settings.introAnimationInit == 0) {
537-
settings.introAnimationInit = millis();
536+
if (sessionSettings.introAnimationInit == 0) {
537+
sessionSettings.introAnimationInit = millis();
538538
} else {
539539
introAnimation();
540540
}
@@ -750,12 +750,12 @@ void initSystem() {
750750
//don't save default session settings for StreamingBoard
751751
if (eegDataSource != DATASOURCE_STREAMING) {
752752
//Init software settings: create default settings file that is datasource unique
753-
settings.init();
753+
sessionSettings.init();
754754
verbosePrint("OpenBCI_GUI: initSystem: Session settings initialized");
755755
}
756756

757757
if (guiSettings.getAutoLoadSessionSettings()) {
758-
settings.autoLoadSessionSettings();
758+
sessionSettings.autoLoadSessionSettings();
759759
verbosePrint("OpenBCI_GUI: initSystem: User default session settings automatically loaded");
760760
}
761761

@@ -970,10 +970,10 @@ void systemUpdate() { // for updating data values and variables
970970
//updates while in system control panel before START SYSTEM
971971
controlPanel.update();
972972

973-
if (settings.widthOfLastScreen != width || settings.heightOfLastScreen != height) {
973+
if (sessionSettings.widthOfLastScreen != width || sessionSettings.heightOfLastScreen != height) {
974974
topNav.screenHasBeenResized(width, height);
975-
settings.widthOfLastScreen = width;
976-
settings.heightOfLastScreen = height;
975+
sessionSettings.widthOfLastScreen = width;
976+
sessionSettings.heightOfLastScreen = height;
977977
//println("W = " + width + " || H = " + height);
978978
}
979979
}
@@ -982,19 +982,19 @@ void systemUpdate() { // for updating data values and variables
982982

983983
//alternative component listener function (line 177 mouseReleased- 187 frame.addComponentListener) for processing 3,
984984
//Component listener doesn't seem to work, so staying with this method for now
985-
if (settings.widthOfLastScreen != width || settings.heightOfLastScreen != height) {
986-
settings.screenHasBeenResized = true;
987-
settings.timeOfLastScreenResize = millis();
988-
settings.widthOfLastScreen = width;
989-
settings.heightOfLastScreen = height;
985+
if (sessionSettings.widthOfLastScreen != width || sessionSettings.heightOfLastScreen != height) {
986+
sessionSettings.screenHasBeenResized = true;
987+
sessionSettings.timeOfLastScreenResize = millis();
988+
sessionSettings.widthOfLastScreen = width;
989+
sessionSettings.heightOfLastScreen = height;
990990
}
991991

992992
//re-initialize GUI if screen has been resized and it's been more than 1/2 seccond (to prevent reinitialization of GUI from happening too often)
993-
if (settings.screenHasBeenResized && settings.timeOfLastScreenResize + 500 > millis()) {
993+
if (sessionSettings.screenHasBeenResized && sessionSettings.timeOfLastScreenResize + 500 > millis()) {
994994
ourApplet = this; //reset PApplet...
995995
topNav.screenHasBeenResized(width, height);
996996
wm.screenResized();
997-
settings.screenHasBeenResized = false;
997+
sessionSettings.screenHasBeenResized = false;
998998
}
999999

10001000
if (wm.isWMInitialized) {
@@ -1064,7 +1064,7 @@ void systemInitSession() {
10641064
//Global function to update the number of channels
10651065
void updateGlobalChannelCount(int _channelCount) {
10661066
globalChannelCount = _channelCount;
1067-
settings.sessionSettingsChannelCount = _channelCount; //used in SoftwareSettings.pde only
1067+
sessionSettings.sessionSettingsChannelCount = _channelCount; //used in SoftwareSettings.pde only
10681068
fftBuff = new ddf.minim.analysis.FFT[globalChannelCount]; //reinitialize the FFT buffer
10691069
println("OpenBCI_GUI: Channel count set to " + str(globalChannelCount));
10701070
}
@@ -1076,8 +1076,8 @@ void introAnimation() {
10761076
int t1 = 0;
10771077
float transparency = 0;
10781078

1079-
if (millis() >= settings.introAnimationInit) {
1080-
transparency = map(millis() - settings.introAnimationInit, t1, settings.introAnimationDuration, 0, 255);
1079+
if (millis() >= sessionSettings.introAnimationInit) {
1080+
transparency = map(millis() - sessionSettings.introAnimationInit, t1, sessionSettings.introAnimationDuration, 0, 255);
10811081
verbosePrint(String.valueOf(transparency));
10821082
tint(255, transparency);
10831083
//draw OpenBCI Logo Front & Center
@@ -1091,7 +1091,7 @@ void introAnimation() {
10911091
}
10921092

10931093
//Exit intro animation when the duration has expired AND the Control Panel is ready
1094-
if ((millis() >= settings.introAnimationInit + settings.introAnimationDuration)
1094+
if ((millis() >= sessionSettings.introAnimationInit + sessionSettings.introAnimationDuration)
10951095
&& controlPanel != null) {
10961096
systemMode = SYSTEMMODE_PREINIT;
10971097
controlPanel.open();

0 commit comments

Comments
 (0)