-
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.
Browse files
Browse the repository at this point in the history
Read unit from .ch file and convert from it to picoampere when reading values
- Loading branch information
1 parent
6863724
commit 5742b5c
Showing
6 changed files
with
84 additions
and
48 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
21 changes: 14 additions & 7 deletions
21
src/main/java/fr/ifpen/allotropeconverters/gc/chemstation/chfile/ChFile179.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 |
---|---|---|
@@ -1,33 +1,40 @@ | ||
package fr.ifpen.allotropeconverters.gc.chemstation.chfile; | ||
|
||
import java.io.*; | ||
import javax.measure.converter.UnitConverter; | ||
import java.io.IOException; | ||
import java.io.RandomAccessFile; | ||
import java.util.ArrayList; | ||
|
||
import static fr.ifpen.allotropeconverters.gc.chemstation.chfile.ReadHelpers.readLittleEndianDouble; | ||
|
||
class ChFile179 extends ChFile { | ||
|
||
private static final int DATA_START = 6144; // https://github.com/CINF/PyExpLabSys/blob/master/PyExpLabSys/file_parsers/chemstation.py | ||
private static final int START_TIME_POSITION = 282; | ||
private static final int END_TIME_POSITION = 286; | ||
private static final int UNITS_POSITION = 4172; | ||
private static final int Y_OFFSET_POSITION = 4724; | ||
private static final int Y_SCALING_POSITION = 4732; | ||
private static final int DETECTOR_POSITION = 4213; | ||
|
||
ChFile179(RandomAccessFile input) throws IOException { | ||
super(input, DATA_START, START_TIME_POSITION, END_TIME_POSITION, Y_OFFSET_POSITION, Y_SCALING_POSITION, DETECTOR_POSITION); | ||
super(input, DATA_START, START_TIME_POSITION, END_TIME_POSITION, UNITS_POSITION, Y_OFFSET_POSITION, Y_SCALING_POSITION, DETECTOR_POSITION); | ||
} | ||
|
||
|
||
@Override | ||
protected void parseData(RandomAccessFile input) throws IOException { | ||
|
||
long numberOfPoints = (input.length() - DATA_START) / 8; | ||
if (numberOfPoints > Integer.MAX_VALUE) { | ||
throw new IllegalArgumentException("Input too large to parse"); | ||
} | ||
|
||
values = new ArrayList<>((int) numberOfPoints); | ||
UnitConverter unitConverter = unit.getConverterTo(PICO_AMPERE_UNIT); | ||
|
||
input.seek(DATA_START); | ||
|
||
setValues(new ArrayList<>()); | ||
for(int i=0; i<numberOfPoints;i++){ | ||
getValues().add(readLittleEndianDouble(input) * yScaling); | ||
for (int i = 0; i < numberOfPoints; i++) { | ||
values.add(unitConverter.convert(readLittleEndianDouble(input) * yScaling)); | ||
} | ||
} | ||
} |
27 changes: 15 additions & 12 deletions
27
src/main/java/fr/ifpen/allotropeconverters/gc/chemstation/chfile/ChFile181.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
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