-
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.
Fixes #44 - Retrieve unit from .ch file
- Loading branch information
1 parent
6863724
commit 869c992
Showing
6 changed files
with
75 additions
and
23 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
24 changes: 17 additions & 7 deletions
24
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,43 @@ | ||
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 java.util.List; | ||
|
||
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"); | ||
} | ||
|
||
List<Double> values = new ArrayList<>((int) numberOfPoints); | ||
UnitConverter unitConverter = getUnit().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)); | ||
} | ||
|
||
setValues(values); | ||
} | ||
} |
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