/
FoxTest.java
57 lines (47 loc) · 1.82 KB
/
FoxTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package ru.r2cloud.jradio.fox;
import static org.junit.Assert.assertTrue;
import java.util.HashSet;
import java.util.Set;
import org.junit.After;
import org.junit.Test;
import ru.r2cloud.jradio.AssertJson;
import ru.r2cloud.jradio.blocks.CorrelateSyncword;
import ru.r2cloud.jradio.blocks.SoftToHard;
import ru.r2cloud.jradio.demod.FskDemodulator;
import ru.r2cloud.jradio.source.WavFileSource;
public class FoxTest {
private Fox<Fox1ABeacon> input;
@Test
public void testSuccess() throws Exception {
WavFileSource source = new WavFileSource(FoxTest.class.getClassLoader().getResourceAsStream("slowFox1a.wav"));
FskDemodulator demod = new FskDemodulator(source, 200, 0.0f, 120, 200);
Set<String> codes = new HashSet<>();
codes.add("0011111010");
codes.add("1100000101");
SoftToHard s2h = new SoftToHard(demod);
CorrelateSyncword pdu = new CorrelateSyncword(s2h, 0, codes, Fox.SLOW_FRAME_SIZE * 10);
input = new Fox<>(pdu, Fox1ABeacon.class);
assertTrue(input.hasNext());
AssertJson.assertObjectsEqual("Fox1ABeacon.json", input.next());
}
@Test
public void testHighSpeed() throws Exception {
WavFileSource source = new WavFileSource(FoxTest.class.getClassLoader().getResourceAsStream("fox1dWithImage.wav"));
FskDemodulator demod = new FskDemodulator(source, 9600, 0.0f, 1, 2000);
Set<String> codes = new HashSet<>();
codes.add("0011111010");
codes.add("1100000101");
SoftToHard s2h = new SoftToHard(demod);
CorrelateSyncword pdu = new CorrelateSyncword(s2h, 0, codes, HighSpeedFox.HIGH_SPEED_FRAME_SIZE * 10);
HighSpeedFox<Fox1DBeacon> input = new HighSpeedFox<>(pdu, Fox1DBeacon.class);
assertTrue(input.hasNext());
AssertJson.assertObjectsEqual("Fox1DBeacon-highspeed.json", input.next());
input.close();
}
@After
public void stop() throws Exception {
if (input != null) {
input.close();
}
}
}