Skip to content

Commit 71c514b

Browse files
committed
Add classes and methods for all DataSourcePlayback boards
1 parent 67a5e0c commit 71c514b

5 files changed

Lines changed: 465 additions & 464 deletions

File tree

OpenBCI_GUI/BoardBrainFlowSynthetic.pde

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ import brainflow.*;
22

33
import org.apache.commons.lang3.tuple.Pair;
44

5-
class BoardBrainFlowSynthetic extends BoardBrainFlow
6-
implements AccelerometerCapableBoard, PPGCapableBoard, EDACapableBoard, BatteryInfoCapableBoard {
5+
class BoardBrainFlowSynthetic extends BoardBrainFlow implements AccelerometerCapableBoard {
76

87
private int[] accelChannelsCache = null;
9-
private int[] edaChannelsCache = null;
10-
private int[] ppgChannelsCache = null;
11-
private Integer batteryChannelCache = null;
128
private int numChannels = 0;
139
private volatile boolean[] activeChannels = null;
1410

@@ -97,80 +93,12 @@ implements AccelerometerCapableBoard, PPGCapableBoard, EDACapableBoard, BatteryI
9793
return accelChannelsCache;
9894
}
9995

100-
@Override
101-
public boolean isPPGActive() {
102-
return true;
103-
}
104-
105-
@Override
106-
public void setPPGActive(boolean active) {
107-
outputWarn("PPG is always active for BrainflowSyntheticBoard");
108-
}
109-
110-
@Override
111-
public int[] getPPGChannels() {
112-
if(ppgChannelsCache == null) {
113-
try {
114-
ppgChannelsCache = BoardShim.get_ppg_channels(getBoardIdInt());
115-
116-
} catch (BrainFlowError e) {
117-
e.printStackTrace();
118-
}
119-
}
120-
121-
return ppgChannelsCache;
122-
}
123-
124-
@Override
125-
public boolean isEDAActive() {
126-
return true;
127-
}
128-
129-
@Override
130-
public void setEDAActive(boolean active) {
131-
outputWarn("EDA is always active for BrainflowSyntheticBoard");
132-
}
133-
134-
@Override
135-
public int[] getEDAChannels() {
136-
if (edaChannelsCache == null) {
137-
try {
138-
edaChannelsCache = BoardShim.get_eda_channels(getBoardIdInt());
139-
140-
} catch (BrainFlowError e) {
141-
e.printStackTrace();
142-
}
143-
}
144-
145-
return edaChannelsCache;
146-
}
147-
148-
@Override
149-
public Integer getBatteryChannel() {
150-
if (batteryChannelCache == null) {
151-
try {
152-
batteryChannelCache = BoardShim.get_battery_channel(getBoardIdInt());
153-
} catch (BrainFlowError e) {
154-
e.printStackTrace();
155-
156-
}
157-
}
158-
159-
return batteryChannelCache;
160-
}
16196

16297
@Override
16398
protected void addChannelNamesInternal(String[] channelNames) {
164-
for (int i=0; i<getEDAChannels().length; i++) {
165-
channelNames[getEDAChannels()[i]] = "EDA Channel " + i;
166-
}
167-
for (int i=0; i<getPPGChannels().length; i++) {
168-
channelNames[getPPGChannels()[i]] = "PPG Channel " + i;
169-
}
17099
for (int i=0; i<getAccelerometerChannels().length; i++) {
171100
channelNames[getAccelerometerChannels()[i]] = "Accel Channel " + i;
172101
}
173-
channelNames[getBatteryChannel()] = "Battery Info Channel";
174102
}
175103

176104
@Override
@@ -186,38 +114,8 @@ implements AccelerometerCapableBoard, PPGCapableBoard, EDACapableBoard, BatteryI
186114
return getData(maxSamples);
187115
}
188116

189-
@Override
190-
public List<double[]> getDataWithPPG(int maxSamples) {
191-
return getData(maxSamples);
192-
}
193-
194-
@Override
195-
public List<double[]> getDataWithEDA(int maxSamples) {
196-
return getData(maxSamples);
197-
}
198-
199-
@Override
200-
public List<double[]> getDataWithBatteryInfo(int maxSamples) {
201-
return getData(maxSamples);
202-
}
203-
204117
@Override
205118
public int getAccelSampleRate() {
206119
return getSampleRate();
207120
}
208-
209-
@Override
210-
public int getPPGSampleRate() {
211-
return getSampleRate();
212-
}
213-
214-
@Override
215-
public int getEDASampleRate() {
216-
return getSampleRate();
217-
}
218-
219-
@Override
220-
public int getBatteryInfoSampleRate() {
221-
return getSampleRate();
222-
}
223121
};

OpenBCI_GUI/DataSourcePlayback.pde

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,16 @@ public DataSourcePlayback getDataSourcePlaybackClassFromFile(String path) {
303303

304304
switch (underlyingBoardClassName) {
305305
case ("BoardCytonSerial"):
306+
case ("BoardCytonSerialDaisy"):
307+
case ("BoardCytonWifi"):
308+
case ("BoardCytonWifiDaisy"):
306309
return new DataSourcePlaybackCyton(path);
310+
case ("BoardGanglionBLE"):
311+
case ("BoardGanglionNative"):
312+
case ("BoardGanglionWifi"):
313+
return new DataSourcePlaybackGanglion(path);
314+
case ("BoardBrainFlowSynthetic"):
315+
return new DataSourcePlaybackSynthetic(path);
307316
default:
308317
return null;
309318
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
class DataSourcePlaybackGanglion extends DataSourcePlayback implements AccelerometerCapableBoard, FileBoard {
2+
3+
DataSourcePlaybackGanglion(String filePath) {
4+
super(filePath);
5+
}
6+
7+
@Override
8+
public int getAccelSampleRate() {
9+
return getSampleRate();
10+
}
11+
12+
@Override
13+
public boolean isAccelerometerActive() {
14+
return underlyingBoard instanceof AccelerometerCapableBoard;
15+
}
16+
17+
@Override
18+
public void setAccelerometerActive(boolean active) {
19+
// nothing
20+
}
21+
22+
@Override
23+
public boolean canDeactivateAccelerometer() {
24+
return false;
25+
}
26+
27+
@Override
28+
public int[] getAccelerometerChannels() {
29+
if (underlyingBoard instanceof AccelerometerCapableBoard) {
30+
return ((AccelerometerCapableBoard)underlyingBoard).getAccelerometerChannels();
31+
}
32+
33+
return new int[0];
34+
}
35+
36+
@Override
37+
public List<double[]> getDataWithAccel(int maxSamples) {
38+
return getData(maxSamples);
39+
}
40+
41+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
class DataSourcePlaybackSynthetic extends DataSourcePlayback implements AccelerometerCapableBoard, FileBoard {
2+
3+
DataSourcePlaybackSynthetic(String filePath) {
4+
super(filePath);
5+
}
6+
7+
protected boolean instantiateUnderlyingBoard() {
8+
try {
9+
underlyingBoard = new BoardBrainFlowSynthetic(nchan);
10+
} catch (Exception e) {
11+
println(e.getMessage());
12+
e.printStackTrace();
13+
return false;
14+
}
15+
16+
return underlyingBoard != null;
17+
}
18+
19+
@Override
20+
public int getAccelSampleRate() {
21+
return getSampleRate();
22+
}
23+
24+
@Override
25+
public boolean isAccelerometerActive() {
26+
return underlyingBoard instanceof AccelerometerCapableBoard;
27+
}
28+
29+
@Override
30+
public void setAccelerometerActive(boolean active) {
31+
// nothing
32+
}
33+
34+
@Override
35+
public boolean canDeactivateAccelerometer() {
36+
return false;
37+
}
38+
39+
@Override
40+
public int[] getAccelerometerChannels() {
41+
if (underlyingBoard instanceof AccelerometerCapableBoard) {
42+
return ((AccelerometerCapableBoard)underlyingBoard).getAccelerometerChannels();
43+
}
44+
45+
return new int[0];
46+
}
47+
48+
@Override
49+
public List<double[]> getDataWithAccel(int maxSamples) {
50+
return getData(maxSamples);
51+
}
52+
53+
}

0 commit comments

Comments
 (0)