mirror of https://github.com/rusefi/rusefi-1.git
extracting opensr5
This commit is contained in:
parent
1e81281db0
commit
f67dbce2cc
|
@ -1,7 +1,6 @@
|
|||
package com.opensr5.io;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -11,6 +10,8 @@ import java.util.List;
|
|||
public class IniFileMetaInfo {
|
||||
public static final int DEFAULT_BLOCKING_FACTOR = 16000;
|
||||
private final int nPages;
|
||||
private final String signature;
|
||||
private final List<String> pageReadCommands;
|
||||
|
||||
private int totalSize;
|
||||
private final List<Integer> pageSizes = new ArrayList<>();
|
||||
|
@ -26,10 +27,9 @@ public class IniFileMetaInfo {
|
|||
|
||||
blockingFactor = file.getSimpleIntegerProperty("blockingFactor", DEFAULT_BLOCKING_FACTOR);
|
||||
|
||||
signature = file.getValues("signature").get(0);
|
||||
|
||||
RawIniFile.Line pageSize = file.getMandatoryLine("pageSize");
|
||||
|
||||
List<String> individualPageSizes = Arrays.asList(pageSize.getTokens()).subList(1, pageSize.getTokens().length);
|
||||
List<String> individualPageSizes = file.getValues("pageSize");
|
||||
|
||||
if (individualPageSizes.size() != nPages)
|
||||
throw new IllegalStateException("Unexpected individual sizes: " + individualPageSizes);
|
||||
|
@ -39,6 +39,8 @@ public class IniFileMetaInfo {
|
|||
pageSizes.add(size);
|
||||
totalSize += size;
|
||||
}
|
||||
|
||||
pageReadCommands = file.getValues("pageReadCommand");
|
||||
}
|
||||
|
||||
public int getnPages() {
|
||||
|
@ -52,4 +54,16 @@ public class IniFileMetaInfo {
|
|||
public int getTotalSize() {
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public String getPageReadCommand(int pageIndex) {
|
||||
return pageReadCommands.get(pageIndex);
|
||||
}
|
||||
|
||||
public int getPageSize(int pageIndex) {
|
||||
return pageSizes.get(pageIndex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,11 @@ public class RawIniFile {
|
|||
return getSimpleIntegerProperty(key);
|
||||
}
|
||||
|
||||
public List<String> getValues(String key) {
|
||||
RawIniFile.Line line = getMandatoryLine(key);
|
||||
return Arrays.asList(line.getTokens()).subList(1, line.getTokens().length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Immutable representation of since ini file line
|
||||
*/
|
||||
|
|
|
@ -61,6 +61,8 @@ public class IniFileReaderTest {
|
|||
@Test
|
||||
public void testTotalPagesSize() {
|
||||
String string = " nPages = 3\n" +
|
||||
" signature = \"unit test\"\n" +
|
||||
" pageReadCommand = \"X\", \"X\", \"X\"\n\n\n\n" +
|
||||
" pageSize = 288, 64, 288\n";
|
||||
|
||||
|
||||
|
@ -71,5 +73,9 @@ public class IniFileReaderTest {
|
|||
assertEquals(3, meta.getnPages());
|
||||
assertEquals(IniFileMetaInfo.DEFAULT_BLOCKING_FACTOR, meta.getBlockingFactor());
|
||||
assertEquals(640, meta.getTotalSize());
|
||||
assertEquals("unit test", meta.getSignature());
|
||||
|
||||
assertEquals(64, meta.getPageSize(1));
|
||||
assertEquals("X", meta.getPageReadCommand(1));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue