Skip to content

Commit

Permalink
Altered the SW CDR file reader to address bugs with partition vs. SCL…
Browse files Browse the repository at this point in the history
…K priority.
  • Loading branch information
dsteph11JHUAPL committed Oct 31, 2024
1 parent 179cba5 commit ba093b0
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions src/main/java/reader/SWCDRLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@

public class SWCDRLibrary {

private NavigableMap<Integer, NavigableMap<Integer, String>> swMapS;
private NavigableMap<Integer, NavigableMap<Integer, String>> swMapL;
// private NavigableMap<Integer, NavigableMap<Integer, String>> swMapS;
// private NavigableMap<Integer, NavigableMap<Integer, String>> swMapL;
private NavigableMap<Integer, String> swMapS;
private NavigableMap<Integer, String> swMapL;

private final String swPath = "/resources/sw";

Expand All @@ -51,21 +53,21 @@ private SWCDRLibrary() {
}

public LinkedHashMap<Integer, Double> getBandMap(String detector, int partition, double sclk) {
NavigableMap<Integer, NavigableMap<Integer, String>> swMap = null;
NavigableMap<Integer, String> swMap = null;

if (detector.trim().equalsIgnoreCase("s"))
swMap = swMapS;
else if (detector.trim().equalsIgnoreCase("l"))
swMap = swMapL;

Map.Entry<Integer, NavigableMap<Integer, String>> swEntry = swMap.floorEntry(partition);
NavigableMap<Integer, String> partitionMap = swEntry.getValue();
if (partitionMap == null)
return null;
// Map.Entry<Integer, NavigableMap<Integer, String>> swEntry = swMap.floorEntry(partition);
// NavigableMap<Integer, String> partitionMap = swEntry.getValue();
// if (partitionMap == null)
// return null;

Map.Entry<Integer, String> partitionEntry = partitionMap.floorEntry((int) sclk);
Map.Entry<Integer, String> swEntry = swMap.floorEntry((int) sclk);

String cdrFile = partitionEntry.getValue();
String cdrFile = swEntry.getValue();
if (cdrFile == null)
return null;

Expand Down Expand Up @@ -112,25 +114,30 @@ private void readResources() throws URISyntaxException, IOException {
if (path.toString().endsWith("tab")) {
String basename = FilenameUtils.getBaseName(path.toString());
String[] parts = basename.split("_");
int partition = Integer.parseInt(parts[1]);
// int partition = Integer.parseInt(parts[1]); # not needed since sclk does not reset on partition change
int sclk = Integer.parseInt(parts[2]);
String detector = parts[4];

NavigableMap<Integer, NavigableMap<Integer, String>> swMap;
NavigableMap<Integer, String> swMap;
if (detector.equalsIgnoreCase("s")) {
swMap = swMapS;
} else if (detector.equalsIgnoreCase("l")) {
swMap = swMapL;
} else
continue;

NavigableMap<Integer, String> partitionMap = swMap.get(partition);
if (partitionMap == null) {
partitionMap = new TreeMap<>();
swMap.put(partition, partitionMap);
// NavigableMap<Integer, String> partitionMap = swMap.get(partition);
// if (partitionMap == null) {
// partitionMap = new TreeMap<>();
// swMap.put(partition, partitionMap);
// }

String swEntry = swMap.get(sclk);
if (swEntry == null){
swMap.put(sclk, path.toString());
}

partitionMap.put(sclk, path.toString());
// partitionMap.put(sclk, path.toString());
}
}
}
Expand Down

0 comments on commit ba093b0

Please sign in to comment.