forked from FOME-Tech/fome-fw
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
101 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
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
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
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
76 changes: 76 additions & 0 deletions
76
...ools/configuration_definition/src/main/java/com/rusefi/newparse/outputs/SdLogVisitor.java
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.rusefi.newparse.outputs; | ||
|
||
import com.rusefi.newparse.layout.*; | ||
|
||
import java.io.PrintStream; | ||
|
||
public class SdLogVisitor extends ILayoutVisitor { | ||
private final String mSourceName; | ||
|
||
public SdLogVisitor(String sourceName) { | ||
mSourceName = sourceName; | ||
} | ||
|
||
@Override | ||
public void visit(StructLayout struct, PrintStream ps, StructNamePrefixer prefixer, int offsetAdd, int[] arrayDims) { | ||
if (arrayDims.length == 0) { | ||
visit(struct, ps, prefixer, offsetAdd, struct.name); | ||
} else if (arrayDims.length == 1) { | ||
int elementOffset = offsetAdd; | ||
|
||
for (int i = 0; i < arrayDims[0]; i++) { | ||
visit(struct, ps, prefixer, elementOffset, struct.name + "[" + i + "]"); | ||
elementOffset += struct.size; | ||
} | ||
} else { | ||
throw new IllegalStateException("Output channels don't support multi dimension arrays"); | ||
} | ||
} | ||
|
||
private void visitScalar(ScalarLayout scalar, PrintStream ps, StructNamePrefixer prefixer, String arraySub, String commentSuffix) { | ||
final String prefixedName = prefixer.get(scalar.name); | ||
|
||
ps.print("\t{"); | ||
ps.print(mSourceName); | ||
ps.print(prefixedName); | ||
ps.print(arraySub); | ||
ps.print(", \""); | ||
|
||
String comment = scalar.options.comment; | ||
|
||
// default to name in case of no comment | ||
if (comment == null || comment.isEmpty()) { | ||
comment = prefixedName; | ||
} | ||
|
||
ps.print(comment.split("\\n")[0]); | ||
ps.print(commentSuffix); | ||
ps.print("\", "); | ||
ps.print(scalar.options.units); | ||
ps.print(", "); | ||
ps.print(scalar.options.digits); | ||
ps.println("},"); | ||
} | ||
|
||
@Override | ||
public void visit(ScalarLayout scalar, PrintStream ps, StructNamePrefixer prefixer, int offsetAdd, int[] arrayDims) { | ||
if (scalar.name.startsWith("unused")) { | ||
return; | ||
} | ||
|
||
if (arrayDims.length == 0) { | ||
visitScalar(scalar, ps, prefixer, "", ""); | ||
} else if (arrayDims.length == 1) { | ||
for (int i = 0; i < arrayDims[0]; i++) { | ||
visitScalar(scalar, ps, prefixer, "[" + i + "]", " " + (i + 1)); | ||
} | ||
} else { | ||
throw new IllegalStateException("SD log doesn't support multi dimension arrays"); | ||
} | ||
} | ||
|
||
@Override | ||
public void visit(BitGroupLayout bitGroup, PrintStream ps, StructNamePrefixer prefixer, int offsetAdd, int[] arrayDims) { | ||
|
||
} | ||
} |
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