Skip to content

Commit 575add4

Browse files
committed
fetch trace fixed
1 parent 84e45e0 commit 575add4

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

app/src/main/java/io/pslab/activity/OscilloscopeActivity.java

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,21 +1125,44 @@ protected Void doInBackground(String... params) {
11251125
yFloatData[i] = (float) yData[i];
11261126
}
11271127
} else {
1128-
scienceLab.captureTraces(1, samples, timeGap, analogInput1, isTriggerSelected, null);
1129-
data = scienceLab.fetchTrace(1);
1130-
double[] yData1 = data.get("y");
1131-
scienceLab.captureTraces(1, samples, timeGap, analogInput2, isTriggerSelected, null);
1132-
data = scienceLab.fetchTrace(1);
1133-
double[] yData2 = data.get("y");
1134-
int n = Math.min(yData1.length, yData2.length);
1135-
xFloatData = new float[n];
1136-
yFloatData = new float[n];
1137-
for (int i = 0; i < n; i++) {
1138-
xFloatData[i] = (float) yData1[i];
1139-
yFloatData[i] = (float) yData2[i];
1128+
int noChannels = 1;
1129+
if ((analogInput1.equals(CHANNEL.CH1.toString()) && analogInput2.equals(CHANNEL.CH2.toString())) || (analogInput1.equals(CHANNEL.CH2.toString()) && analogInput2.equals(CHANNEL.CH1.toString()))) {
1130+
noChannels = 2;
1131+
scienceLab.captureTraces(noChannels, 175, timeGap, "CH1", isTriggerSelected, null);
1132+
data = scienceLab.fetchTrace(1);
1133+
double[] yData1 = data.get("y");
1134+
data = scienceLab.fetchTrace(2);
1135+
double[] yData2 = data.get("y");
1136+
int n = Math.min(yData1.length, yData2.length);
1137+
xFloatData = new float[n];
1138+
yFloatData = new float[n];
1139+
for (int i = 0; i < n; i++) {
1140+
xFloatData[i] = (float) yData1[i];
1141+
yFloatData[i] = (float) yData2[i];
1142+
}
1143+
1144+
} else {
1145+
noChannels = 4;
1146+
scienceLab.captureTraces(noChannels, 175, timeGap, "CH1", isTriggerSelected, null);
1147+
data = scienceLab.fetchTrace(channelIndexMap.get(analogInput1) + 1);
1148+
double[] yData1 = data.get("y");
1149+
data = scienceLab.fetchTrace(channelIndexMap.get(analogInput2) + 1);
1150+
double[] yData2 = data.get("y");
1151+
int n = Math.min(yData1.length, yData2.length);
1152+
xFloatData = new float[n];
1153+
yFloatData = new float[n];
1154+
for (int i = 0; i < n; i++) {
1155+
xFloatData[i] = (float) yData1[i];
1156+
yFloatData[i] = (float) yData2[i];
1157+
}
11401158
}
1141-
}
11421159

1160+
}
1161+
try {
1162+
Thread.sleep(200);
1163+
} catch (InterruptedException e) {
1164+
e.printStackTrace();
1165+
}
11431166
return null;
11441167
}
11451168

0 commit comments

Comments
 (0)