ephys_link.server
WebSocket server and communication handler
Manages the WebSocket server and handles connections and events from the client. For every event, the server does the following:
Extract the arguments passed in the event
Log that the event was received
Call the appropriate function in
ephys_link.sensapex_handler
with argumentsRelay the response from
ephys_link.sensapex_handler
to the callback function
Functions
Bypass calibration of manipulator |
|
Calibrate manipulator |
|
Catch all event |
|
Close the serial connection |
|
Close the server |
|
Acknowledge connection to the server |
|
Acknowledge disconnection from the server |
|
Drive to depth |
|
Stops everything |
|
Get the list of discoverable manipulators |
|
Position of manipulator request |
|
Move manipulator to position |
|
Launch the server |
|
Continuously poll serial port for data |
|
Register a manipulator with the server |
|
Set manipulator can_write state |
|
Set the inside brain state |
|
Starts everything |
|
Stop all manipulators |
|
Unregister a manipulator from the server |
- platform: PlatformHandler
- poll_serial_thread: Thread
- poll_serial(kill_event: Event, serial_port: str) None [source]
Continuously poll serial port for data
- Parameters:
kill_event (Event) – Event to stop polling
serial_port (str) – The serial port to poll
- Returns:
None
- async connect(sid, _, __) bool [source]
Acknowledge connection to the server
- Parameters:
sid (str) – Socket session ID
_ (dict) – WSGI formatted dictionary with request info (unused)
__ (dict) – Authentication details (unused)
- Returns:
False on error to refuse connection. None otherwise.
- Return type:
bool
- async disconnect(sid) None [source]
Acknowledge disconnection from the server
- Parameters:
sid (str) – Socket session ID
- Returns:
None
- async get_manipulators(_) GetManipulatorsOutputData [source]
Get the list of discoverable manipulators
- Parameters:
_ (str) – Socket session ID (unused)
- Returns:
Callback parameters (manipulators, error message)
- Return type:
- async register_manipulator(_, manipulator_id: str) str [source]
Register a manipulator with the server
- Parameters:
_ (str) – Socket session ID (unused)
manipulator_id (str) – ID of the manipulator to register
- Returns:
Callback parameter (Error message (on error))
- Return type:
str
- async unregister_manipulator(_, manipulator_id: str) str [source]
Unregister a manipulator from the server
- Parameters:
_ (str) – Socket session ID (unused)
manipulator_id (str) – ID of the manipulator to unregister
- Returns:
Callback parameter (Error message (on error))
- Return type:
str
- async get_pos(_, manipulator_id: str) PositionalOutputData [source]
Position of manipulator request
- Parameters:
_ (str) – Socket session ID (unused)
manipulator_id (str) – ID of manipulator to pull position from
- Returns:
Callback parameters (manipulator ID, position in (x, y, z, w) (or an empty array on error), error message)
- Return type:
- async goto_pos(_, data: GotoPositionInputDataFormat) PositionalOutputData [source]
Move manipulator to position
- Parameters:
_ (str) – Socket session ID (unused)
data (
ephys_link.common.GotoPositionInputDataFormat
) – Data containing manipulator ID, position, and speed
- Returns:
Callback parameters (manipulator ID, position in (x, y, z, w) (or an empty tuple on error), error message)
- Return type:
- async drive_to_depth(_, data: DriveToDepthInputDataFormat) DriveToDepthOutputData [source]
Drive to depth
- Parameters:
_ (str) – Socket session ID (unused)
data (
ephys_link.common.DriveToDepthInputDataFormat
) – Data containing manipulator ID, depth, and speed
- Returns:
Callback parameters (manipulator ID, depth (or -1 on error), error message )
- Return type:
- async set_inside_brain(_, data: InsideBrainInputDataFormat) StateOutputData [source]
Set the inside brain state
- Parameters:
_ (str) – Socket session ID (unused)
data (
ephys_link.common.InsideBrainInputDataFormat
) – Data containing manipulator ID and inside brain state
- Returns:
Callback parameters (manipulator ID, inside, error message)
- Return type:
- async calibrate(_, manipulator_id: str) str [source]
Calibrate manipulator
- Parameters:
_ (str) – Socket session ID (unused)
manipulator_id (str) – ID of manipulator to calibrate
- Returns:
Callback parameters (manipulator ID, error message)
- Return type:
str
- async bypass_calibration(_, manipulator_id: str) str [source]
Bypass calibration of manipulator
- Parameters:
_ (str) – Socket session ID (unused)
manipulator_id (str) – ID of manipulator to bypass calibration
- Returns:
Callback parameters (manipulator ID, error message)
- Return type:
str
- async set_can_write(_, data: CanWriteInputDataFormat) StateOutputData [source]
Set manipulator can_write state
- Parameters:
_ (str) – Socket session ID (unused)
data (
ephys_link.common.CanWriteInputDataFormat
) – Data containing manipulator ID and can_write brain state
- Returns:
Callback parameters (manipulator ID, can_write, error message)
- Return type:
- stop(_) bool [source]
Stop all manipulators
- Parameters:
_ (str) – Socket session ID (unused)
- Returns:
True if successful, False otherwise
- Return type:
bool
- async catch_all(_, __, data: Any) None [source]
Catch all event
- Parameters:
_ (str) – Socket session ID (unused)
__ (str) – Client ID (unused)
data (Any) – Data received from client
- Returns:
None
- launch_server(platform_type: str, server_port: int, new_scale_port: str) None [source]
Launch the server
- Parameters:
platform_type (str) – Parsed argument for platform type
server_port (int) – HTTP port to serve the server
new_scale_port (str) – HTTP port which the New Scale HTTP server is served on
- Returns:
None