forked from NMGRL/pychron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomms_protocol
44 lines (29 loc) · 1.83 KB
/
comms_protocol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
client ==>
socket.send('Read Foo')
server
RemoteCommandServer is a top level object that doesnt do much.
TCPServer is a subclass of SocketServer.ThreadingTCPServer
TCPServer doesnt do much either. MessagingHandler is where the real work
happens.
The TCPServer listens for incoming commands and creates a new MessageHandler object for each
request ie command and calls its handle function
The handler object gets the data from the socket, processes it, and returns the result
To process requests the command is repeated using the CommandRepeater to the CommandProcessor
living in Pychron
The CommandRepeater prepends a process_type string to the beginning of the request so the
RemoteHardwareManager knows how to handle the request. The process_type and data are
separated by a pipe character ex. 'System|Open V'
CommandProcessor is a simple socket server, (NOTE: isnt a subclass of a SocketServer, uses a
listener thread to wait for requests from CommandRepeater)
When CommandProcessor receives a request its passed to
RemoteHardwareManager.process_server_request
------------------------------RemoteHardwareServer------------------------------------
--------------------------------------------------------------------------------------
TCPServer --> MessagingHandler.handle --> CommandRepeater.get_response -->
--------------------------------------------------------------------------------------
-------------------------------------Pychron------------------------------------------
--------------------------------------------------------------------------------------
CommandProcessor._handler --> RemoteHardwareManager.process_server_request -->
[Request_type]Handler.handle --> result
--------------------------------------------------------------------------------------
return result up the call stack