Get features when terminal is attached

This commit is contained in:
Andrew Kay 2020-07-19 14:02:44 -05:00
parent 49a1a0283a
commit 78e05cc6ce
5 changed files with 18 additions and 5 deletions

View File

@ -5,7 +5,7 @@ oec.controller
import time
import logging
from coax import poll, poll_ack, load_control_register, PollAction, \
from coax import poll, poll_ack, load_control_register, get_features, PollAction, \
KeystrokePollResponse, TerminalType, ReceiveTimeout, \
ReceiveError, ProtocolError
@ -97,11 +97,17 @@ class Controller:
if terminal_id.type != TerminalType.CUT:
raise UnsupportedTerminalError('Only CUT type terminals are supported')
# Get the terminal features.
features = get_features(self.interface)
self.logger.info(f'Features = {features}')
# Get the keymap.
keymap = self.get_keymap(terminal_id, extended_id)
# Initialize the terminal.
self.terminal = Terminal(self.interface, terminal_id, extended_id, keymap)
self.terminal = Terminal(self.interface, terminal_id, extended_id,
features, keymap)
(rows, columns) = self.terminal.display.dimensions
keymap_name = self.terminal.keyboard.keymap.name

View File

@ -59,10 +59,11 @@ def read_terminal_ids(interface, extended_id_retry_attempts=3):
class Terminal:
"""Terminal information and devices."""
def __init__(self, interface, terminal_id, extended_id, keymap):
def __init__(self, interface, terminal_id, extended_id, features, keymap):
self.interface = interface
self.terminal_id = terminal_id
self.extended_id = extended_id
self.features = features
dimensions = get_dimensions(self.terminal_id, self.extended_id)

View File

@ -1,5 +1,5 @@
ptyprocess==0.6.0
pycoax==0.4.2
pycoax==0.5.0
pyserial==3.4
pyte==0.8.0
pytn3270==0.5.1

View File

@ -44,6 +44,12 @@ class RunLoopTestCase(unittest.TestCase):
self.load_control_register_mock = patcher.start()
patcher = patch('oec.controller.get_features')
self.get_features_mock = patcher.start()
self.get_features_mock.return_value = { }
patcher = patch('oec.controller.time.perf_counter')
self.perf_counter_mock = patcher.start()

View File

@ -8,4 +8,4 @@ class TerminalGetPollActionTestCase(unittest.TestCase):
def setUp(self):
self.interface = Mock()
self.terminal = Terminal(self.interface, TerminalId(0b11110100), 'c1348300', KEYMAP_3278_2)
self.terminal = Terminal(self.interface, TerminalId(0b11110100), 'c1348300', { }, KEYMAP_3278_2)