def __init__(self, transport_loop): """Initialize member variables.""" self.messaging_stack = MessagingStack(transport_loop) self.z_printer = Printer('Z-Axis', prefix=batch.RESPONSE_PREFIX) self.y_printer = Printer('Y-Axis', prefix=batch.RESPONSE_PREFIX) self.command_printer = MessagePrinter(prefix=' Sending: ') self.z = Protocol('ZAxis', 'z', response_receivers=[self.z_printer], command_receivers=[self.command_printer]) self.y = Protocol('YAxis', 'y', response_receivers=[self.y_printer], command_receivers=[self.command_printer]) self.response_printer = MessagePrinter(prefix=batch.RESPONSE_PREFIX) self.messaging_stack.register_response_receivers(self.response_printer) self.messaging_stack.register_response_receivers(self.z) self.messaging_stack.register_response_receivers(self.y) self.messaging_stack.register_command_senders(self.z) self.messaging_stack.register_command_senders(self.y) self.batch_execution_manager = BatchExecutionManager( self.messaging_stack.arbiter, self.messaging_stack.command_sender, self.test_routine, header=batch.OUTPUT_HEADER, ready_waiter=self.messaging_stack.connection_synchronizer. wait_connected) self.messaging_stack.register_execution_manager( self.batch_execution_manager)
def __init__(self, transport_loop): """Initialize member variables.""" self.arbiter = arbiter(start=self._start, stopping=self._stop) self.command_printer = MessagePrinter(prefix=' Sending: ') self.echo_response_printer = MessagePrinter( prefix=('\t' * batch.OUTPUT_WIDTH + '[Echo]\t') ) self.reset_response_printer = MessagePrinter( prefix=('\t' * batch.OUTPUT_WIDTH + '[Reset]\t') ) self.version_response_printer = MessagePrinter( prefix=('\t' * batch.OUTPUT_WIDTH + '[Version]\t') ) self.builtin_led_response_printer = MessagePrinter( prefix=('\t' * batch.OUTPUT_WIDTH + '[BuiltinLED]\t') ) self.response_dispatcher = Dispatcher( receivers={ 'e': [self.echo_response_printer], 'r': [self.reset_response_printer] }, prefix_receivers={ 'v': [self.version_response_printer], 'l': [self.builtin_led_response_printer], } ) self.translator = BasicTranslator( message_receivers=[self.response_dispatcher] ) self.response_receiver = ResponseReceiver( response_receivers=[self.translator] ) self.transport_manager = TransportManager( self.arbiter, transport_loop, response_receiver=self.response_receiver ) self.translator.serialized_message_receivers.append( self.transport_manager.command_sender ) self.batch_execution_manager = BatchExecutionManager( self.arbiter, self.transport_manager.command_sender, self.test_routine, header=batch.OUTPUT_HEADER, ready_waiter=self.transport_manager.connection_synchronizer.wait_connected )
def main(): """Run some tests of BasicTranslator.""" serialized_printer = SerializedMessagePrinter(prefix='Serialized: ') deserialized_printer = MessagePrinter(prefix='Deserialized: ') translator = BasicTranslator( serialized_message_receivers=[serialized_printer], message_receivers=[deserialized_printer], ) basic_assertions(translator) print_serialized(translator) print_deserialized(translator)
def main(): """Run some tests of BasicTranslator.""" version_printer = VersionPrinter(prefix=' ') command_printer = MessagePrinter(prefix=' ') version_protocol = VersionProtocol(version_receivers=[version_printer], command_receivers=[command_printer]) version_tests() print('Version response handling') print_responses(version_protocol) print('\n\nVersion command issuing') print_commands(version_protocol)
def __init__(self, transport_loop): """Initialize member variables.""" self.arbiter = arbiter(start=self._start, stopping=self._stop) self.echo_response_printer = MessagePrinter( prefix=('\t' * cli.CONSOLE_WIDTH + '[Echo]\t')) self.reset_response_printer = MessagePrinter( prefix=('\t' * cli.CONSOLE_WIDTH + '[Reset]\t')) self.version_response_printer = MessagePrinter( prefix=('\t' * cli.CONSOLE_WIDTH + '[Version]\t')) self.builtin_led_response_printer = MessagePrinter( prefix=('\t' * cli.CONSOLE_WIDTH + '[BuiltinLED]\t')) self.response_dispatcher = Dispatcher( receivers={ 'e': [self.echo_response_printer], 'r': [self.reset_response_printer] }, prefix_receivers={ 'v': [self.version_response_printer], 'l': [self.builtin_led_response_printer], }) self.translator = BasicTranslator( message_receivers=[self.response_dispatcher]) self.response_receiver = ResponseReceiver( response_receivers=[self.translator]) self.transport_manager = TransportManager( self.arbiter, transport_loop, response_receiver=self.response_receiver) self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=1) self.console_manager = ConsoleManager( self.arbiter, self.transport_manager.command_sender, self.translator, console_header=cli.CONSOLE_HEADER, executor=self.executor, ready_waiter=self.transport_manager.connection_synchronizer. wait_connected)
def __init__(self, transport_loop): """Initialize member variables.""" self.arbiter = arbiter(start=self._start, stopping=self._stop) self.response_printer = MessagePrinter(prefix=('\t' * cli.CONSOLE_WIDTH)) self.translator = BasicTranslator( message_receivers=[self.response_printer]) self.response_receiver = ResponseReceiver( response_receivers=[self.translator]) self.transport_manager = TransportManager( self.arbiter, transport_loop, response_receiver=self.response_receiver) self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=1) self.console_manager = ConsoleManager( self.arbiter, self.transport_manager.command_sender, self.translator, console_header=cli.CONSOLE_HEADER, executor=self.executor, ready_waiter=self.transport_manager.connection_synchronizer. wait_connected)