zlp_connections module

Helper module for python thrift interface to ZLP Service. This module contains utility classes and methods which ease the usage of the thrift interface to communicate with the ZLP Service.

class z_laser_zlp1.zlp_connections.EventChannelInterfaceHandler[source]

Bases: object

This class implement the functions of ClientEventChannel thrift interface.

property_changed_callback

callback to handle settings changes on laser projector system

Type:object
geo_tree_changed_callback

callback to handle changes on geotree operator

Type:object
service_state_changed_callback

callback to handle changes on services state

Type:object
function_module_changed_callback

callback to handle changes on function module state

Type:object
rc_command_received_callback

callback to handle remote control commands reception

Type:object
on_reflection_state_changed_callback

callback to handle changes on reflection state

Type:object
__init__()[source]

Initialize the EventChannelInterfaceHandler object.

PropertyChanged(name, value)[source]

Set callback function to handle settings changes on laser projector system.

Parameters:
  • name (str) – full path of property that was changed
  • value (int) – value of property
GeoTreeChanged(changed_flags, element_names)[source]

Set callback function to handle changes on geotree operator.

Parameters:
  • changed_flags (int) – integer value with flags of type GeoTreeChangedFlags
  • element_names (enum) – identification of changed element (within the GeoTreeElemId enumeration )
ServiceStateChanged(oldState, newState)[source]

Set callback function to handle changes on services state.

Parameters:
  • oldState (enum) – old state (within the ServiceStates enumeration) before change
  • newState (enum) – new state (within the ServiceStates enumeration) after change
FunctionModuleStateChanged(functionModID, oldState, newState)[source]

Set callback function to handle changes on function module state.

Parameters:
  • functionModID (str) – identificator name of function module
  • oldState (enum) – old state (within the FunctionModuleStates enumeration) before change
  • newState (enum) – new state (within the FunctionModuleStates enumeration) after change
RemoteControlFrameReceived(rc_id, command, toggle, projector, timestamp)[source]

Set callback function to handle remote control commands reception.

Parameters:
  • rc_id (str) – address of RC-device
  • command (enum) – enum with command codes for remotecontrol functions
  • toggle (bool) – toggle function active
  • projector (str) – serial number of the projector
  • timestamp (int) – timestamp
onReflectionStateChanged(elementName, state)[source]

Set callback function to handle changes on reflection state.

Parameters:
  • elementName (str) – name of the element that changed state
  • state (bool) – true if a reflection was detected; False otherwise
class z_laser_zlp1.zlp_connections.ThriftClient(event_handler=<z_laser_zlp1.zlp_connections.EventChannelInterfaceHandler object>)[source]

Bases: thriftpy.thrift.TClient

This class implement the functions to carry out the connection with the ZLP Service.

Parameters:event_handler (object) – object with functions of ClientEventChannel thrift interface
thrift_interface

load the interface description file (interface.thrift) for the communication between

Type:obj
ZLP-Service and a remote client
__init__(event_handler=<z_laser_zlp1.zlp_connections.EventChannelInterfaceHandler object>)[source]

Initialize the ThriftClient object.

init_client(ip, port)[source]

Establish a connection to thrift server of ZLP Service. Init client opening sockets and init events handler.

Parameters:
  • ip (str) – ipv6 network address of ZLP-Service
  • port (str) – port number on which ZLP-Service listens for requests
init_event_channel()[source]

Create a thrift server and register it at ZLP Service to receive events.

set_property_changed_callback(callback)[source]

Set callback function related with laser projector settings changes.

Parameters:callback (object) – callback function to set
Raises:ValueError
set_geotree_changed_callback(callback)[source]

Set callback function related with geotree operator changes.

Parameters:callback (object) – callback function to set
Raises:ValueError
set_function_module_state_changed_callback(callback)[source]

Set callback function related with function module state changes.

Parameters:callback (object) – callback function to set
Raises:ValueError
set_rc_command_received_callback(callback)[source]

Set callback function related with remote control commands reception.

Parameters:callback (object) – callback function to set
Raises:ValueError
set_reflection_state_changed_callback(callback)[source]

Set callback function related with reflection state changes.

Parameters:callback (object) – callback function to set
Raises:ValueError
class z_laser_zlp1.zlp_connections.ProjectorClient[source]

Bases: object

This class implements the functions for connecting to the projector and basic projection features.

projector_id

serial number of the projector

Type:str
module_id

function module identification name

Type:str
__init__()[source]

Initialize the ProjectorClient object.

get_thrift_client()[source]

Return the object generated to communicate with the projector.

Returns:thrift client object generated to communicate with the projector
Return type:object
connect(server_IP, connection_port)[source]

Create and connect the client to thrift server (located at projector) of ZLP-Service and establish an event channel if needed.

Parameters:
  • server_IP (str) – ipv6 network address of ZLP-Service
  • connection_port (str) – port number on which ZLP-Service listens for requests
Returns:

the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string

Return type:

tuple[bool, str]

disconnect()[source]

Disconnect from ZLP Service thrift server and close own event server.

Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
connection_status()[source]

Get status of projection connection.

Returns:status of the event channel object. Projector connected if true, disconnected otherwise
Return type:bool
transfer_license(lic_path)[source]

Transfer data of the local license file to remote file at ZLP-Service.

Parameters:lic_path (str) – license file path
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
check_license()[source]

Check if license is valid.

Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
scan_projectors(scan_addresses='')[source]

Scan the network for projectors. Get a list of active projectors.

Parameters:scan_addresses (str) – addresses or address to scan
Returns:the first value in the returned tuple is a list of serial numbers of the projectors found, the second a bool success value and the third value in the tuple is an information message string
Return type:tuple[list, bool, str]
property_changed_callback(prop, value)[source]

Callback function related with laser projector settings changes.

Parameters:
  • prop (str) – full path of property that was changed
  • value (int) – value of property
activate_projector(projector_IP)[source]

Set properties to activate a projector.

Parameters:projector_IP (str) – address of the projector to scan
Returns:the first value in the returned tuple is the serial number string of the activated projector, the second a bool success value and the third value in the tuple is an information message string
Return type:tuple[str, bool, str]
deactivate_projector()[source]

Set properties to deactivate a projector.

Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
function_module_create()[source]

Create function module to operate with GeoTreeElements (coordinate systems and projection elements).

Returns:the first value in the returned tuple is the function module identification name string, the second is a bool success value and the third value in the tuple is an information message string
Return type:tuple[str, bool, str]
start_project(cs_name)[source]

Start projection on the surface of all projection elements that belong to the active coordinate system.

Parameters:cs_name (str) – name of the active coordinate system
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
stop_project()[source]

Stop projection of all elements.

Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
update_project(cs_name)[source]

Update changes on figures projected (restart projection).

Parameters:cs_name (str) – name of the coordinate system to update
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]
is_empty(cs_name)[source]

Check if coordinate system has associated projection elements.

Parameters:cs_name (str) – name of the coordinate system to check
Returns:true if there is any projection element defined at the coordinate system, false otherwise
Return type:bool
on_reflection_change(name, reflection)[source]

Default callback for reflection state change, events handler. It is used for running code when pointer is reflected.

Parameters:
  • name (str) – name of the pointer that changed state
  • reflection (bool) – true if a reflection was detected; False otherwise
scan_pointer(reflection_callback=None)[source]

Set callback for reflection state change.

Parameters:reflection_callback (object) – callback function
Returns:the first value in the returned tuple is a bool success value and the second value in the tuple is an information message string
Return type:tuple[bool, str]