Skip to content

Commit

Permalink
Update line endings for certain files
Browse files Browse the repository at this point in the history
  • Loading branch information
retiutut committed Aug 16, 2023
1 parent 78eff9d commit d9b1221
Show file tree
Hide file tree
Showing 5 changed files with 1,451 additions and 1,451 deletions.
260 changes: 130 additions & 130 deletions OpenBCI_GUI/Board.pde
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();
};
Loading

0 comments on commit d9b1221

Please sign in to comment.