mirror of
https://github.com/lowobservable/oec.git
synced 2026-01-11 23:53:04 +00:00
Get features when terminal is attached
This commit is contained in:
parent
49a1a0283a
commit
78e05cc6ce
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user