Skip to content

Commit b037f03

Browse files
committed
ULOG handling improved
1 parent a9a4930 commit b037f03

File tree

4 files changed

+42
-11
lines changed

4 files changed

+42
-11
lines changed

MAVGCL/src/main/java/com/comino/flight/file/FileHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ public void fileImport(File file) {
235235

236236

237237
if(file.getName().endsWith("ulg")) {
238-
modelService.setCollectorInterval(AnalysisModelService.HISPEED_INTERVAL_US);
239238
ULogReader reader = new ULogReader(file.getAbsolutePath());
240239
MAVGCLPX4Parameters.getInstance().setParametersFromLog(reader.getParameters());
241240
converter = new UlogtoModelConverter(reader,modelService.getModelList());

MAVGCL/src/main/java/com/comino/flight/log/ulog/UlogtoModelConverter.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,21 @@ public UlogtoModelConverter(ULogReader reader, List<AnalysisDataModel> list) {
6868

6969
public void doConversion() throws FormatErrorException {
7070

71-
long tms_slot = 0; long tms = 0; boolean errorFlag = false;
71+
long tms_slot = 0; long tms = 0; long tms_old=0; boolean errorFlag = false;
7272

7373

7474
Map<String,Object> data = new HashMap<String,Object>();
7575

7676
list.clear();
7777

7878
int interval_us = AnalysisModelService.getInstance().setCollectorInterval(AnalysisModelService.HISPEED_INTERVAL_US);
79+
int interval_us2 = interval_us/2;
7980

8081
try {
8182

82-
System.out.println(reader.getStartMicroseconds()+"/"+interval_us);
83-
8483
while(tms < reader.getSizeMicroseconds()) {
8584
tms = reader.readUpdate(data) - reader.getStartMicroseconds();
86-
if(tms > tms_slot) {
85+
if(tms > (tms_slot-interval_us2)) {
8786
state.getProgressProperty().set(tms*1.0f/reader.getSizeMicroseconds());
8887
AnalysisDataModel model = new AnalysisDataModel();
8988
model.tms = tms;

MAVGCL/src/main/java/com/comino/flight/model/KeyFigureMetaData.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ public Double getValueFromULogModel(Map<String,Object> data) {
204204
if(source!=null && source.field!=null) { // source field specified
205205
Object o = data.get(source.field);
206206
if(o!=null) {
207+
if(o instanceof Long)
208+
value = (double)(Long)o;
207209
if(o instanceof Integer)
208210
value = (double)(Integer)o;
209211
else if(o instanceof Double)

MAVGCL/src/main/java/com/comino/flight/model/converter/ULOGDifferenceConverter.java

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@ public class ULOGDifferenceConverter extends SourceConverter {
3939

4040
private String ulogKeyFigure1 = null;
4141
private String ulogKeyFigure2 = null;
42-
42+
43+
private double v1=0;
44+
private double v2=0;
45+
4346

4447
@Override
4548
public void setParameter(String kfname, String[] params) {
4649
this.ulogKeyFigure1 = params[0];
4750
this.ulogKeyFigure2 = params[1];
48-
51+
4952
}
5053

5154
public ULOGDifferenceConverter() {
@@ -54,12 +57,40 @@ public ULOGDifferenceConverter() {
5457

5558
@Override
5659
public double convert(Map<String,Object> ulogdata) {
60+
61+
Object o1; Object o2;
62+
5763
try {
58-
if(ulogdata.get(ulogKeyFigure1)!=null && ulogdata.get(ulogKeyFigure2)!=null)
59-
return (Long)ulogdata.get(ulogKeyFigure1)/1000f - (Long)ulogdata.get(ulogKeyFigure2)/1000f;
60-
return 0;
64+
65+
o1 = ulogdata.get(ulogKeyFigure1);
66+
o2 = ulogdata.get(ulogKeyFigure2);
67+
68+
if(o1!=null) {
69+
if(o1 instanceof Long)
70+
v1 = (double)(Long)o1 / 1000.0d;
71+
if(o1 instanceof Integer)
72+
v1 = (double)(Integer)o1;
73+
else if(o1 instanceof Double)
74+
v1 = ((Double)o1).doubleValue();
75+
else if(o1 instanceof Float)
76+
v1 = ((Float)o1).doubleValue();
77+
}
78+
79+
80+
if(o2!=null) {
81+
if(o2 instanceof Long)
82+
v2 = (double)(Long)o2 / 1000.0d;
83+
if(o2 instanceof Integer)
84+
v2 = (double)(Integer)o2;
85+
else if(o2 instanceof Double)
86+
v2 = ((Double)o2).doubleValue();
87+
else if(o2 instanceof Float)
88+
v2 = ((Float)o2).doubleValue();
89+
}
90+
91+
return v1 - v2;
92+
6193
} catch( Exception e) {
62-
e.printStackTrace();
6394
return 0;
6495
}
6596
}

0 commit comments

Comments
 (0)