-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update line endings for certain files
- Loading branch information
Showing
5 changed files
with
1,451 additions
and
1,451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,130 +1,130 @@ | ||
import org.apache.commons.lang3.tuple.Pair; | ||
|
||
abstract class Board implements DataSource { | ||
|
||
private FixedStack<double[]> accumulatedData = new FixedStack<double[]>(); | ||
private double[][] dataThisFrame; | ||
protected PacketLossTracker packetLossTracker; | ||
|
||
// accessible by all boards, can be returned as valid empty data | ||
protected double[][] emptyData; | ||
|
||
@Override | ||
public boolean initialize() { | ||
boolean res = initializeInternal(); | ||
|
||
double[] fillData = new double[getTotalChannelCount()]; | ||
accumulatedData.setSize(getCurrentBoardBufferSize()); | ||
accumulatedData.fill(fillData); | ||
|
||
emptyData = new double[getTotalChannelCount()][0]; | ||
|
||
packetLossTracker = setupPacketLossTracker(); | ||
|
||
return res; | ||
} | ||
|
||
@Override | ||
public void uninitialize() { | ||
uninitializeInternal(); | ||
} | ||
|
||
@Override | ||
public void startStreaming() { | ||
packetLossTracker.onStreamStart(); | ||
} | ||
|
||
@Override | ||
public void stopStreaming() { | ||
|
||
// empty | ||
} | ||
|
||
@Override | ||
public void update() { | ||
updateInternal(); | ||
|
||
dataThisFrame = getNewDataInternal(); | ||
|
||
for (int i = 0; i < dataThisFrame[0].length; i++) { | ||
double[] newEntry = new double[getTotalChannelCount()]; | ||
for (int j = 0; j < getTotalChannelCount(); j++) { | ||
newEntry[j] = dataThisFrame[j][i]; | ||
} | ||
|
||
accumulatedData.push(newEntry); | ||
} | ||
|
||
if( packetLossTracker != null) { | ||
//TODO: make all API including getNewDataInternal() return List<double[]> | ||
// and we can just pass dataThisFrame here. | ||
packetLossTracker.addSamples(getData(dataThisFrame[0].length)); | ||
} | ||
} | ||
|
||
@Override | ||
public int getNumEXGChannels() { | ||
return getEXGChannels().length; | ||
} | ||
|
||
// returns all the data this board has received in this frame | ||
@Override | ||
public double[][] getFrameData() { | ||
return dataThisFrame; | ||
} | ||
|
||
@Override | ||
public List<double[]> getData(int maxSamples) { | ||
int endIndex = accumulatedData.size(); | ||
int startIndex = max(0, endIndex - maxSamples); | ||
|
||
return accumulatedData.subList(startIndex, endIndex); | ||
} | ||
|
||
public String[] getChannelNames() { | ||
String[] names = new String[getTotalChannelCount()]; | ||
Arrays.fill(names, "Other"); | ||
|
||
names[getTimestampChannel()] = "Timestamp"; | ||
names[getSampleIndexChannel()] = "Sample Index"; | ||
|
||
int[] exgChannels = getEXGChannels(); | ||
for (int i=0; i<exgChannels.length; i++) { | ||
names[exgChannels[i]] = "EXG Channel " + i; | ||
} | ||
|
||
addChannelNamesInternal(names); | ||
return names; | ||
} | ||
|
||
public PacketLossTracker getPacketLossTracker() { | ||
return packetLossTracker; | ||
} | ||
|
||
public abstract boolean isConnected(); | ||
|
||
public abstract boolean isStreaming(); | ||
|
||
public abstract Pair <Boolean, String> sendCommand(String command); | ||
|
||
public abstract void insertMarker(int value); | ||
|
||
public abstract void insertMarker(double value); | ||
|
||
// *************************************** | ||
// protected methods implemented by board | ||
|
||
// implemented by each board class and used internally here to accumulate the FixedStack | ||
// and provide with public interfaces getFrameData() and getData(int) | ||
protected abstract double[][] getNewDataInternal(); | ||
|
||
protected abstract boolean initializeInternal(); | ||
|
||
protected abstract void uninitializeInternal(); | ||
|
||
protected abstract void updateInternal(); | ||
|
||
protected abstract void addChannelNamesInternal(String[] channelNames); | ||
|
||
protected abstract PacketLossTracker setupPacketLossTracker(); | ||
}; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
|
||
abstract class Board implements DataSource { | ||
|
||
private FixedStack<double[]> accumulatedData = new FixedStack<double[]>(); | ||
private double[][] dataThisFrame; | ||
protected PacketLossTracker packetLossTracker; | ||
|
||
// accessible by all boards, can be returned as valid empty data | ||
protected double[][] emptyData; | ||
|
||
@Override | ||
public boolean initialize() { | ||
boolean res = initializeInternal(); | ||
|
||
double[] fillData = new double[getTotalChannelCount()]; | ||
accumulatedData.setSize(getCurrentBoardBufferSize()); | ||
accumulatedData.fill(fillData); | ||
|
||
emptyData = new double[getTotalChannelCount()][0]; | ||
|
||
packetLossTracker = setupPacketLossTracker(); | ||
|
||
return res; | ||
} | ||
|
||
@Override | ||
public void uninitialize() { | ||
uninitializeInternal(); | ||
} | ||
|
||
@Override | ||
public void startStreaming() { | ||
packetLossTracker.onStreamStart(); | ||
} | ||
|
||
@Override | ||
public void stopStreaming() { | ||
|
||
// empty | ||
} | ||
|
||
@Override | ||
public void update() { | ||
updateInternal(); | ||
|
||
dataThisFrame = getNewDataInternal(); | ||
|
||
for (int i = 0; i < dataThisFrame[0].length; i++) { | ||
double[] newEntry = new double[getTotalChannelCount()]; | ||
for (int j = 0; j < getTotalChannelCount(); j++) { | ||
newEntry[j] = dataThisFrame[j][i]; | ||
} | ||
|
||
accumulatedData.push(newEntry); | ||
} | ||
|
||
if( packetLossTracker != null) { | ||
//TODO: make all API including getNewDataInternal() return List<double[]> | ||
// and we can just pass dataThisFrame here. | ||
packetLossTracker.addSamples(getData(dataThisFrame[0].length)); | ||
} | ||
} | ||
|
||
@Override | ||
public int getNumEXGChannels() { | ||
return getEXGChannels().length; | ||
} | ||
|
||
// returns all the data this board has received in this frame | ||
@Override | ||
public double[][] getFrameData() { | ||
return dataThisFrame; | ||
} | ||
|
||
@Override | ||
public List<double[]> getData(int maxSamples) { | ||
int endIndex = accumulatedData.size(); | ||
int startIndex = max(0, endIndex - maxSamples); | ||
|
||
return accumulatedData.subList(startIndex, endIndex); | ||
} | ||
|
||
public String[] getChannelNames() { | ||
String[] names = new String[getTotalChannelCount()]; | ||
Arrays.fill(names, "Other"); | ||
|
||
names[getTimestampChannel()] = "Timestamp"; | ||
names[getSampleIndexChannel()] = "Sample Index"; | ||
|
||
int[] exgChannels = getEXGChannels(); | ||
for (int i=0; i<exgChannels.length; i++) { | ||
names[exgChannels[i]] = "EXG Channel " + i; | ||
} | ||
|
||
addChannelNamesInternal(names); | ||
return names; | ||
} | ||
|
||
public PacketLossTracker getPacketLossTracker() { | ||
return packetLossTracker; | ||
} | ||
|
||
public abstract boolean isConnected(); | ||
|
||
public abstract boolean isStreaming(); | ||
|
||
public abstract Pair <Boolean, String> sendCommand(String command); | ||
|
||
public abstract void insertMarker(int value); | ||
|
||
public abstract void insertMarker(double value); | ||
|
||
// *************************************** | ||
// protected methods implemented by board | ||
|
||
// implemented by each board class and used internally here to accumulate the FixedStack | ||
// and provide with public interfaces getFrameData() and getData(int) | ||
protected abstract double[][] getNewDataInternal(); | ||
|
||
protected abstract boolean initializeInternal(); | ||
|
||
protected abstract void uninitializeInternal(); | ||
|
||
protected abstract void updateInternal(); | ||
|
||
protected abstract void addChannelNamesInternal(String[] channelNames); | ||
|
||
protected abstract PacketLossTracker setupPacketLossTracker(); | ||
}; |
Oops, something went wrong.