/
XNetPortControllerScaffold.java
133 lines (108 loc) · 2.91 KB
/
XNetPortControllerScaffold.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package jmri.jmrix.lenz;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Implementation of XNetPortController that eases
* checking whether data was forwarded or not.
*
* @author Bob Jacobsen Copyright (C) 2006, 2015
*/
public class XNetPortControllerScaffold extends XNetSimulatorPortController {
private final static Logger log = LoggerFactory.getLogger(XNetPortControllerScaffold.class);
/*@Override
public java.util.Vector<String> getPortNames() {
return null;
}*/
@Override
public String openPort(String portName, String appName) {
return null;
}
@Override
public void configure() {
}
@Override
public String getCurrentPortName() {
return("testport");
}
@Override
public String[] validBaudRates() {
return null;
}
@Override
public int[] validBaudNumbers() {
return null;
}
PipedInputStream otempIPipe;
PipedOutputStream otempOPipe;
PipedInputStream itempIPipe;
PipedOutputStream itempOPipe;
public XNetPortControllerScaffold() throws Exception {
otempIPipe = new PipedInputStream(200);
tostream = new DataInputStream(otempIPipe);
otempOPipe = new PipedOutputStream(otempIPipe);
ostream = new DataOutputStream(otempOPipe);
itempIPipe = new PipedInputStream(200);
istream = new DataInputStream(itempIPipe);
itempOPipe = new PipedOutputStream(itempIPipe);
tistream = new DataOutputStream(itempOPipe);
}
public void flush() {
try {
ostream.flush();
otempOPipe.flush();
tistream.flush();
itempOPipe.flush();
jmri.util.JUnitUtil.releaseThread(this);
} catch (Exception e) {
log.error("Exception during flush", e);
}
}
/**
* Returns the InputStream from the port.
*/
@Override
public DataInputStream getInputStream() {
return istream;
}
/**
* Returns the outputStream to the port.
*/
@Override
public DataOutputStream getOutputStream() {
return ostream;
}
/**
* Check that this object is ready to operate.
*/
@Override
public boolean status() {
return true;
}
@Override
public boolean okToSend() {
return true;
}
@Override
public void setOutputBufferEmpty(boolean s) {
}
/**
* Traffic controller writes to this.
*/
DataOutputStream ostream;
/**
* Can read test data from this.
*/
public DataInputStream tostream;
/**
* Tests write to this.
*/
public DataOutputStream tistream;
/**
* The traffic controller can read test data from this.
*/
DataInputStream istream;
}