-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package sisc.devices; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
import sisc.api.io.InputDevice; | ||
import sisc.api.io.InputPair; | ||
|
||
public class TerminalInput implements InputDevice { | ||
private boolean closed; | ||
@Override | ||
public void start(InputPair pair) { | ||
pair.connectTo(2, 16, 3); | ||
InputStreamReader reader = new InputStreamReader(System.in); | ||
BufferedReader bReader = new BufferedReader(reader); | ||
|
||
while (!closed) { | ||
try { | ||
pair.offer((short)Short.parseShort(bReader.readLine())); | ||
} catch (IOException e) { | ||
throw new AssertionError(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onClose() { | ||
// haha yes. This doesn't work because reader.read waits indefinitely for input. | ||
// would need to do some kind-of active wait, or just set ourselves as daemon somehow | ||
// edit: done this is now a daemon thread | ||
closed = true; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return "Console"; | ||
} | ||
|
||
@Override | ||
public void configure(Thread t) { | ||
t.setDaemon(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package sisc.devices; | ||
|
||
import sisc.api.io.OutputDevice; | ||
import sisc.api.io.OutputPair; | ||
|
||
public class TerminalNumberOutput implements OutputDevice { | ||
|
||
@Override | ||
public void start(OutputPair pair) { | ||
// TODO Auto-generated method stub | ||
pair.connectTo(0, 50, 1); | ||
while (true) { | ||
System.out.println(pair.recieve()); | ||
} | ||
} | ||
|
||
@Override | ||
public void onClose() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public String name() { | ||
// TODO Auto-generated method stub | ||
return "Terminal"; | ||
} | ||
|
||
} |