mirror of
https://github.com/lowobservable/oec.git
synced 2026-02-07 16:52:31 +00:00
Add support for TN3270 alarm and VT100 bell
This commit is contained in:
@@ -5,7 +5,7 @@ oec.controller
|
||||
|
||||
import time
|
||||
import logging
|
||||
from coax import poll, poll_ack, KeystrokePollResponse, ReceiveTimeout, \
|
||||
from coax import poll, poll_ack, PollAction, KeystrokePollResponse, ReceiveTimeout, \
|
||||
ReceiveError, ProtocolError
|
||||
|
||||
from .terminal import Terminal, read_terminal_ids
|
||||
@@ -166,7 +166,9 @@ class Controller:
|
||||
|
||||
self.last_poll_time = time.perf_counter()
|
||||
|
||||
poll_response = poll(self.interface, timeout=1)
|
||||
poll_action = self.terminal.get_poll_action() if self.terminal else PollAction.NONE
|
||||
|
||||
poll_response = poll(self.interface, poll_action, timeout=1)
|
||||
|
||||
if poll_response:
|
||||
try:
|
||||
|
||||
@@ -5,7 +5,8 @@ oec.terminal
|
||||
|
||||
import time
|
||||
import logging
|
||||
from coax import read_terminal_id, read_extended_id, ReceiveError, ProtocolError
|
||||
from coax import read_terminal_id, read_extended_id, PollAction, ReceiveError, \
|
||||
ProtocolError
|
||||
|
||||
from .display import Dimensions, Display
|
||||
from .keyboard import Keyboard
|
||||
@@ -67,3 +68,16 @@ class Terminal:
|
||||
|
||||
self.display = Display(interface, dimensions)
|
||||
self.keyboard = Keyboard(keymap)
|
||||
|
||||
self.alarm = False
|
||||
|
||||
def sound_alarm(self):
|
||||
self.alarm = True
|
||||
|
||||
def get_poll_action(self):
|
||||
if self.alarm:
|
||||
self.alarm = False
|
||||
|
||||
return PollAction.ALARM
|
||||
|
||||
return PollAction.NONE
|
||||
|
||||
@@ -71,6 +71,8 @@ class TN3270Session(Session):
|
||||
|
||||
self.emulator = Emulator(self.telnet, rows, columns)
|
||||
|
||||
self.emulator.alarm = lambda: self.terminal.sound_alarm()
|
||||
|
||||
def terminate(self):
|
||||
if self.telnet:
|
||||
self._disconnect_host()
|
||||
|
||||
@@ -86,6 +86,14 @@ class VT100Session(Session):
|
||||
|
||||
self.vt100_screen.write_process_input = lambda data: self.host_process.write(data.encode())
|
||||
|
||||
# Unfortunately multiple VT100 bells will be replaced with a single 3270 terminal
|
||||
# alarm - also because the alarm is only sounded on terminal POLL the alarm sound
|
||||
# may appear out of sync with the terminal.
|
||||
#
|
||||
# A better approach may be to perform a flush when the bell is encountered but
|
||||
# that does not appear possible with the standard pyte ByteStream.
|
||||
self.vt100_screen.bell = lambda: self.terminal.sound_alarm()
|
||||
|
||||
self.vt100_stream = pyte.ByteStream(self.vt100_screen)
|
||||
|
||||
def start(self):
|
||||
|
||||
Reference in New Issue
Block a user