File nbproject/project.properties changed (mode: 100644) (index 511a934..da11af9) |
1 |
1 |
annotation.processing.enabled=true |
annotation.processing.enabled=true |
2 |
2 |
annotation.processing.enabled.in.editor=false |
annotation.processing.enabled.in.editor=false |
3 |
|
annotation.processing.processor.options= |
|
4 |
3 |
annotation.processing.processors.list= |
annotation.processing.processors.list= |
5 |
4 |
annotation.processing.run.all.processors=true |
annotation.processing.run.all.processors=true |
6 |
5 |
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output |
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output |
|
6 |
|
application.title=lleakres |
|
7 |
|
application.vendor=oam |
7 |
8 |
build.classes.dir=${build.dir}/classes |
build.classes.dir=${build.dir}/classes |
8 |
9 |
build.classes.excludes=**/*.java,**/*.form |
build.classes.excludes=**/*.java,**/*.form |
9 |
10 |
# This directory is removed when the project is cleaned: |
# This directory is removed when the project is cleaned: |
|
... |
... |
dist.jar=${dist.dir}/lleakres.jar |
32 |
33 |
dist.javadoc.dir=${dist.dir}/javadoc |
dist.javadoc.dir=${dist.dir}/javadoc |
33 |
34 |
dist.jlink.dir=${dist.dir}/jlink |
dist.jlink.dir=${dist.dir}/jlink |
34 |
35 |
dist.jlink.output=${dist.jlink.dir}/lleakres |
dist.jlink.output=${dist.jlink.dir}/lleakres |
|
36 |
|
endorsed.classpath= |
35 |
37 |
excludes= |
excludes= |
36 |
38 |
includes=** |
includes=** |
37 |
39 |
jar.compress=false |
jar.compress=false |
|
... |
... |
javac.source=11 |
48 |
50 |
javac.target=11 |
javac.target=11 |
49 |
51 |
javac.test.classpath=\ |
javac.test.classpath=\ |
50 |
52 |
${javac.classpath}:\ |
${javac.classpath}:\ |
51 |
|
${build.classes.dir} |
|
|
53 |
|
${build.classes.dir}:\ |
|
54 |
|
${libs.junit_4.classpath}:\ |
|
55 |
|
${libs.hamcrest.classpath} |
52 |
56 |
javac.test.modulepath=\ |
javac.test.modulepath=\ |
53 |
57 |
${javac.modulepath} |
${javac.modulepath} |
54 |
58 |
javac.test.processorpath=\ |
javac.test.processorpath=\ |
File src/lleak/channel/ChanCol.java changed (mode: 100644) (index c3378c2..5d209ad) |
6 |
6 |
package lleak.channel; |
package lleak.channel; |
7 |
7 |
|
|
8 |
8 |
/** |
/** |
9 |
|
* |
|
10 |
|
* @author oam |
|
|
9 |
|
* |
|
10 |
|
* @author tassy |
11 |
11 |
*/ |
*/ |
12 |
12 |
public class ChanCol { |
public class ChanCol { |
13 |
|
private int ic; // индекс столбца |
|
14 |
|
private String varname; // идентификатор |
|
15 |
|
private String fullname; // полное название |
|
16 |
|
|
|
17 |
|
public ChanCol() { |
|
18 |
|
} |
|
19 |
|
|
|
20 |
|
public ChanCol(int ic, String varname, String fullname) { |
|
21 |
|
this.ic = ic; |
|
22 |
|
this.varname = varname; |
|
23 |
|
this.fullname = fullname; |
|
24 |
|
} |
|
25 |
|
|
|
26 |
|
public int getIc() { |
|
27 |
|
return ic; |
|
28 |
|
} |
|
29 |
|
|
|
30 |
|
public void setIc(int ic) { |
|
31 |
|
this.ic = ic; |
|
32 |
|
} |
|
33 |
|
|
|
34 |
|
public String getVarname() { |
|
35 |
|
return varname; |
|
36 |
|
} |
|
37 |
|
|
|
38 |
|
public void setVarname(String varname) { |
|
39 |
|
this.varname = varname; |
|
40 |
|
} |
|
41 |
|
|
|
42 |
|
public String getFullname() { |
|
43 |
|
return fullname; |
|
44 |
|
} |
|
45 |
|
|
|
46 |
|
public void setFullname(String fullname) { |
|
47 |
|
this.fullname = fullname; |
|
48 |
|
} |
|
49 |
|
|
|
50 |
|
|
|
|
13 |
|
|
|
14 |
|
private int ic; // индекс столбца |
|
15 |
|
private String varname; // идентификатор |
|
16 |
|
private String fullname; // полное название |
|
17 |
|
|
|
18 |
|
public ChanCol() { |
|
19 |
|
} |
|
20 |
|
|
|
21 |
|
public ChanCol(int ic, String varname, String fullname) { |
|
22 |
|
this.ic = ic; |
|
23 |
|
this.varname = varname; |
|
24 |
|
this.fullname = fullname; |
|
25 |
|
} |
|
26 |
|
|
|
27 |
|
public int getIc() { |
|
28 |
|
return ic; |
|
29 |
|
} |
|
30 |
|
|
|
31 |
|
public void setIc(int ic) { |
|
32 |
|
this.ic = ic; |
|
33 |
|
} |
|
34 |
|
|
|
35 |
|
public String getVarname() { |
|
36 |
|
return varname; |
|
37 |
|
} |
|
38 |
|
|
|
39 |
|
public void setVarname(String varname) { |
|
40 |
|
this.varname = varname; |
|
41 |
|
} |
|
42 |
|
|
|
43 |
|
public String getFullname() { |
|
44 |
|
return fullname; |
|
45 |
|
} |
|
46 |
|
|
|
47 |
|
public void setFullname(String fullname) { |
|
48 |
|
this.fullname = fullname; |
|
49 |
|
} |
|
50 |
|
|
51 |
51 |
} |
} |
File src/lleak/channel/ChanFile.java added (mode: 100644) (index 0000000..c3b5e44) |
|
1 |
|
/* |
|
2 |
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
|
3 |
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
|
4 |
|
*/ |
|
5 |
|
package lleak.channel; |
|
6 |
|
|
|
7 |
|
import java.io.BufferedReader; |
|
8 |
|
import java.io.FileNotFoundException; |
|
9 |
|
import java.io.FileReader; |
|
10 |
|
import java.io.IOException; |
|
11 |
|
import java.util.ArrayList; |
|
12 |
|
import java.util.logging.Level; |
|
13 |
|
import java.util.logging.Logger; |
|
14 |
|
|
|
15 |
|
/** |
|
16 |
|
* Класс, представляющий данные из расчетного файла в виде массива (списка) состояний в каждый момент времени |
|
17 |
|
* @author tassy |
|
18 |
|
*/ |
|
19 |
|
public class ChanFile { |
|
20 |
|
private final String chname; |
|
21 |
|
private ArrayList<ChanCol> columns; // метаданные по столбцам |
|
22 |
|
private int nt; // количество шагов по времени |
|
23 |
|
private int nx; // количество точек по х |
|
24 |
|
private int nc; // количество столбцов |
|
25 |
|
private ArrayList<ChanProf> data; |
|
26 |
|
|
|
27 |
|
public ChanFile(int nt, int nx, String chname, ArrayList<ChanCol> columns) { |
|
28 |
|
this.chname = chname; |
|
29 |
|
this.columns = columns; |
|
30 |
|
this.nt = nt; |
|
31 |
|
this.nx = nx; |
|
32 |
|
this.nc = columns.size(); |
|
33 |
|
data = new ArrayList<>(nt); // инициализируем по количеству шагов по времени |
|
34 |
|
readChan(); |
|
35 |
|
} |
|
36 |
|
|
|
37 |
|
/** |
|
38 |
|
* Чтение файла, заполнение структур данных |
|
39 |
|
*/ |
|
40 |
|
public void readChan(){ |
|
41 |
|
BufferedReader br = null; |
|
42 |
|
try { |
|
43 |
|
br = new BufferedReader(new FileReader(chname)); |
|
44 |
|
String line; |
|
45 |
|
// цикл по количеству шагов по времени |
|
46 |
|
for(int i=0; i<nt; ++i){ |
|
47 |
|
// первая строка для каждого шага - для определения времени |
|
48 |
|
line = br.readLine(); |
|
49 |
|
String[] arr = line.trim().split("\\s+"); |
|
50 |
|
ChanProf cp = new ChanProf(nx, arr[0], columns); |
|
51 |
|
cp.readFromLine(0, line); |
|
52 |
|
for(int j=1; j<nx; ++j){ |
|
53 |
|
line = br.readLine(); |
|
54 |
|
cp.readFromLine(j, line); |
|
55 |
|
} |
|
56 |
|
data.add(cp); |
|
57 |
|
} |
|
58 |
|
} catch (FileNotFoundException ex) { |
|
59 |
|
Logger.getLogger(ChanFile.class.getName()).log(Level.SEVERE, null, ex); |
|
60 |
|
} catch (IOException ex) { |
|
61 |
|
Logger.getLogger(ChanFile.class.getName()).log(Level.SEVERE, null, ex); |
|
62 |
|
} finally { |
|
63 |
|
if(br != null)try { |
|
64 |
|
br.close(); |
|
65 |
|
} catch (IOException ex) { |
|
66 |
|
Logger.getLogger(ChanFile.class.getName()).log(Level.SEVERE, null, ex); |
|
67 |
|
} |
|
68 |
|
} |
|
69 |
|
} |
|
70 |
|
|
|
71 |
|
public String getChname() { |
|
72 |
|
return chname; |
|
73 |
|
} |
|
74 |
|
|
|
75 |
|
public ArrayList<ChanCol> getColumns() { |
|
76 |
|
return columns; |
|
77 |
|
} |
|
78 |
|
|
|
79 |
|
public int getNt() { |
|
80 |
|
return nt; |
|
81 |
|
} |
|
82 |
|
|
|
83 |
|
public int getNx() { |
|
84 |
|
return nx; |
|
85 |
|
} |
|
86 |
|
|
|
87 |
|
public int getNc() { |
|
88 |
|
return nc; |
|
89 |
|
} |
|
90 |
|
|
|
91 |
|
public ArrayList<ChanProf> getData() { |
|
92 |
|
return data; |
|
93 |
|
} |
|
94 |
|
|
|
95 |
|
} |
File src/lleak/channel/ChanProf.java changed (mode: 100644) (index 55dba96..c74003b) |
... |
... |
import java.util.Map; |
10 |
10 |
import java.util.TreeMap; |
import java.util.TreeMap; |
11 |
11 |
|
|
12 |
12 |
/** |
/** |
13 |
|
* Класс для представления |
|
14 |
|
* @author oam |
|
|
13 |
|
* Класс для представления состояния канала в заданный момент времени |
|
14 |
|
* |
|
15 |
|
* @author tassy |
15 |
16 |
*/ |
*/ |
16 |
17 |
public class ChanProf { |
public class ChanProf { |
17 |
|
private double time; |
|
18 |
|
private String stime; |
|
19 |
|
private ArrayList<double []> columns; // список массивов значений столбцов, кроме первого (время) и второго (индекс точки) |
|
20 |
|
private Map<String, double[]> namedcols; // для поиска по ключу - имени переменной |
|
21 |
|
|
|
22 |
|
/** |
|
23 |
|
* В списке столбцов первые два (время и индекс точки) игнорируются |
|
24 |
|
* @param stime время (строка) |
|
25 |
|
* @param list список столбцов |
|
26 |
|
*/ |
|
27 |
|
public ChanProf(String stime, ArrayList<ChanCol> list) { |
|
28 |
|
this.stime = stime; |
|
29 |
|
time = Double.parseDouble(stime); |
|
30 |
|
columns = new ArrayList<>(24); |
|
31 |
|
namedcols = new TreeMap<>(); |
|
32 |
|
} |
|
33 |
|
|
|
|
18 |
|
private ArrayList<ChanCol> varlist; |
|
19 |
|
private double time; |
|
20 |
|
private String stime; |
|
21 |
|
private ArrayList<double[]> columns; // список массивов значений столбцов, кроме первого (время) и второго (индекс точки) |
|
22 |
|
private Map<String, double[]> namedcols; // для поиска по ключу - имени переменной |
|
23 |
|
|
|
24 |
|
/** |
|
25 |
|
* Конструктор класса |
|
26 |
|
* |
|
27 |
|
* @param nx количество точек по х |
|
28 |
|
* @param stime время (строка) |
|
29 |
|
* @param varlist список столбцов |
|
30 |
|
*/ |
|
31 |
|
public ChanProf(int nx, String stime, ArrayList<ChanCol> varlist) { |
|
32 |
|
this.stime = stime; |
|
33 |
|
this.varlist = varlist; |
|
34 |
|
time = Double.parseDouble(stime); |
|
35 |
|
int nc = varlist.size()-2; // первые два столбца - t и j - игнорируются |
|
36 |
|
columns = new ArrayList<>(); |
|
37 |
|
namedcols = new TreeMap<>(); |
|
38 |
|
for(int i=0;i<varlist.size()-2;++i){ |
|
39 |
|
double [] da = new double[nx]; |
|
40 |
|
columns.add(da); |
|
41 |
|
// помещаем в словарь ссылку на массив с ключом имя переменной |
|
42 |
|
namedcols.put(varlist.get(i+2).getVarname(), da); |
|
43 |
|
} |
|
44 |
|
} |
|
45 |
|
|
|
46 |
|
/** |
|
47 |
|
* Чтение данных из строки с заданным индексом |
|
48 |
|
* @param index индекс |
|
49 |
|
* @param line строка из исходного файла |
|
50 |
|
*/ |
|
51 |
|
public void readFromLine(int index, String line){ |
|
52 |
|
String[] arr = line.trim().split("\\s+"); |
|
53 |
|
for(int i=2;i<varlist.size();++i){ |
|
54 |
|
columns.get(i-2)[index] = Double.parseDouble(arr[i]); |
|
55 |
|
} |
|
56 |
|
} |
|
57 |
|
|
|
58 |
|
public ArrayList<ChanCol> getVarlist() { |
|
59 |
|
return varlist; |
|
60 |
|
} |
|
61 |
|
|
|
62 |
|
public double getTime() { |
|
63 |
|
return time; |
|
64 |
|
} |
|
65 |
|
|
|
66 |
|
public String getStime() { |
|
67 |
|
return stime; |
|
68 |
|
} |
|
69 |
|
|
|
70 |
|
public ArrayList<double[]> getColumns() { |
|
71 |
|
return columns; |
|
72 |
|
} |
|
73 |
|
|
|
74 |
|
public Map<String, double[]> getNamedcols() { |
|
75 |
|
return namedcols; |
|
76 |
|
} |
|
77 |
|
|
34 |
78 |
} |
} |
File test/lleak/channel/ChanFileTest.java added (mode: 100644) (index 0000000..1ebb461) |
|
1 |
|
/* |
|
2 |
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
|
3 |
|
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template |
|
4 |
|
*/ |
|
5 |
|
package lleak.channel; |
|
6 |
|
|
|
7 |
|
import java.util.ArrayList; |
|
8 |
|
import org.junit.After; |
|
9 |
|
import org.junit.AfterClass; |
|
10 |
|
import org.junit.Before; |
|
11 |
|
import org.junit.BeforeClass; |
|
12 |
|
import org.junit.Test; |
|
13 |
|
import static org.junit.Assert.*; |
|
14 |
|
|
|
15 |
|
/** |
|
16 |
|
* |
|
17 |
|
* @author oam |
|
18 |
|
*/ |
|
19 |
|
public class ChanFileTest { |
|
20 |
|
|
|
21 |
|
public ChanFileTest() { |
|
22 |
|
} |
|
23 |
|
|
|
24 |
|
@BeforeClass |
|
25 |
|
public static void setUpClass() { |
|
26 |
|
} |
|
27 |
|
|
|
28 |
|
@AfterClass |
|
29 |
|
public static void tearDownClass() { |
|
30 |
|
} |
|
31 |
|
|
|
32 |
|
@Before |
|
33 |
|
public void setUp() { |
|
34 |
|
} |
|
35 |
|
|
|
36 |
|
@After |
|
37 |
|
public void tearDown() { |
|
38 |
|
} |
|
39 |
|
|
|
40 |
|
/** |
|
41 |
|
* Test of readChan method, of class ChanFile. |
|
42 |
|
*/ |
|
43 |
|
@Test |
|
44 |
|
public void testReadChan() { |
|
45 |
|
System.out.println("readChan"); |
|
46 |
|
ArrayList<ChanCol> columns = new ArrayList<>(); |
|
47 |
|
columns.add(new ChanCol(0, "t", "Время")); |
|
48 |
|
columns.add(new ChanCol(1, "j", "Индекс")); |
|
49 |
|
columns.add(new ChanCol(2, "x", "Координата")); |
|
50 |
|
columns.add(new ChanCol(3, "u", "Скорость")); |
|
51 |
|
ChanFile instance = new ChanFile(1001, 201, "/home/oam/ch1", columns); |
|
52 |
|
int index = 1000; |
|
53 |
|
double[] res = instance.getData().get(index).getColumns().get(1); |
|
54 |
|
System.out.println(res[0]); } |
|
55 |
|
|
|
56 |
|
} |