Skip to content

Commit f007e5a

Browse files
committed
Fix line endings in datawriterodf, fileboard, signalcheckthresholds, w_playback, and w_pulsesensor
1 parent 7dcd64d commit f007e5a

5 files changed

Lines changed: 984 additions & 986 deletions

File tree

OpenBCI_GUI/DataWriterODF.pde

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
1-
public class DataWriterODF {
2-
private PrintWriter output;
3-
private String fname;
4-
private int rowsWritten;
5-
private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
6-
protected String fileNamePrependString = "OpenBCI-RAW-";
7-
protected String headerFirstLineString = "%OpenBCI Raw EXG Data";
8-
9-
//variation on constructor to have custom name
10-
DataWriterODF(String _sessionName, String _fileName) {
11-
settings.setSessionPath(directoryManager.getRecordingsPath() + "OpenBCISession_" + _sessionName + File.separator);
12-
fname = settings.getSessionPath();
13-
fname += fileNamePrependString;
14-
fname += _fileName;
15-
fname += ".txt";
16-
output = createWriter(fname); //open the file
17-
writeHeader(); //add the header
18-
rowsWritten = 0; //init the counter
19-
}
20-
21-
public void writeHeader() {
22-
output.println(headerFirstLineString);
23-
output.println("%Number of channels = " + getNumberOfChannels());
24-
output.println("%Sample Rate = " + getSamplingRate() + " Hz");
25-
output.println("%Board = " + getUnderlyingBoardClass());
26-
27-
String[] colNames = getChannelNames();
28-
29-
for (int i=0; i<colNames.length; i++) {
30-
output.print(colNames[i]);
31-
output.print(", ");
32-
}
33-
output.print("Timestamp (Formatted)");
34-
output.println();
35-
output.flush();
36-
}
37-
38-
public void append(double[][] data) {
39-
//get current date time with Date()
40-
for (int iSample=0; iSample<data[0].length; iSample++) {
41-
for (int iChan=0; iChan<data.length; iChan++) {
42-
output.print(data[iChan][iSample]);
43-
output.print(", ");
44-
}
45-
46-
int timestampChan = getTimestampChannel();
47-
// *1000 to convert from seconds to milliserconds
48-
long timestampMS = (long)(data[timestampChan][iSample] * 1000.0);
49-
50-
output.print(dateFormat.format(new Date(timestampMS)));
51-
output.println();
52-
53-
rowsWritten++;
54-
}
55-
}
56-
57-
public void closeFile() {
58-
output.close();
59-
}
60-
61-
public int getRowsWritten() {
62-
return rowsWritten;
63-
}
64-
65-
protected int getNumberOfChannels() {
66-
return nchan;
67-
}
68-
69-
protected int getSamplingRate() {
70-
return ((Board)currentBoard).getSampleRate();
71-
}
72-
73-
protected String getUnderlyingBoardClass() {
74-
return ((Board)currentBoard).getClass().getName();
75-
}
76-
77-
protected String[] getChannelNames() {
78-
return ((Board)currentBoard).getChannelNames();
79-
}
80-
81-
protected int getTimestampChannel() {
82-
return ((Board)currentBoard).getTimestampChannel();
83-
}
84-
85-
};
1+
public class DataWriterODF {
2+
private PrintWriter output;
3+
private String fname;
4+
private int rowsWritten;
5+
private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
6+
protected String fileNamePrependString = "OpenBCI-RAW-";
7+
protected String headerFirstLineString = "%OpenBCI Raw EXG Data";
8+
9+
//variation on constructor to have custom name
10+
DataWriterODF(String _sessionName, String _fileName) {
11+
settings.setSessionPath(directoryManager.getRecordingsPath() + "OpenBCISession_" + _sessionName + File.separator);
12+
fname = settings.getSessionPath();
13+
fname += fileNamePrependString;
14+
fname += _fileName;
15+
fname += ".txt";
16+
output = createWriter(fname); //open the file
17+
writeHeader(); //add the header
18+
rowsWritten = 0; //init the counter
19+
}
20+
21+
public void writeHeader() {
22+
output.println(headerFirstLineString);
23+
output.println("%Number of channels = " + getNumberOfChannels());
24+
output.println("%Sample Rate = " + getSamplingRate() + " Hz");
25+
output.println("%Board = " + getUnderlyingBoardClass());
26+
27+
String[] colNames = getChannelNames();
28+
29+
for (int i=0; i<colNames.length; i++) {
30+
output.print(colNames[i]);
31+
output.print(", ");
32+
}
33+
output.print("Timestamp (Formatted)");
34+
output.println();
35+
output.flush();
36+
}
37+
38+
public void append(double[][] data) {
39+
//get current date time with Date()
40+
for (int iSample=0; iSample<data[0].length; iSample++) {
41+
for (int iChan=0; iChan<data.length; iChan++) {
42+
output.print(data[iChan][iSample]);
43+
output.print(", ");
44+
}
45+
46+
int timestampChan = getTimestampChannel();
47+
// *1000 to convert from seconds to milliserconds
48+
long timestampMS = (long)(data[timestampChan][iSample] * 1000.0);
49+
50+
output.print(dateFormat.format(new Date(timestampMS)));
51+
output.println();
52+
53+
rowsWritten++;
54+
}
55+
}
56+
57+
public void closeFile() {
58+
output.close();
59+
}
60+
61+
public int getRowsWritten() {
62+
return rowsWritten;
63+
}
64+
65+
protected int getNumberOfChannels() {
66+
return nchan;
67+
}
68+
69+
protected int getSamplingRate() {
70+
return ((Board)currentBoard).getSampleRate();
71+
}
72+
73+
protected String getUnderlyingBoardClass() {
74+
return ((Board)currentBoard).getClass().getName();
75+
}
76+
77+
protected String[] getChannelNames() {
78+
return ((Board)currentBoard).getChannelNames();
79+
}
80+
81+
protected int getTimestampChannel() {
82+
return ((Board)currentBoard).getTimestampChannel();
83+
}
84+
85+
};

OpenBCI_GUI/FileBoard.pde

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
interface FileBoard {
2-
3-
public int getTotalSamples();
4-
5-
public float getTotalTimeSeconds();
6-
7-
public int getCurrentSample();
8-
9-
public float getCurrentTimeSeconds();
10-
11-
public void goToIndex(int index);
12-
13-
public boolean endOfFileReached();
14-
};
1+
interface FileBoard {
2+
3+
public int getTotalSamples();
4+
5+
public float getTotalTimeSeconds();
6+
7+
public int getCurrentSample();
8+
9+
public float getCurrentTimeSeconds();
10+
11+
public void goToIndex(int index);
12+
13+
public boolean endOfFileReached();
14+
};

0 commit comments

Comments
 (0)