Network
- class ingenialink.ethernet.network.EthernetNetwork[source]
Network for all Ethernet communications.
- connect_to_slave(target: str, dictionary: str, port: int = 1061, connection_timeout: float = 1, servo_status_listener: bool = False, net_status_listener: bool = False, is_eoe: bool = False) EthernetServo [source]
Connects to a slave through the given network settings.
- Parameters:
target – IP of the target slave.
dictionary – Path to the target dictionary file.
port – Port to connect to the slave.
connection_timeout – Time in seconds of the connection timeout.
servo_status_listener – Toggle the listener of the servo for its status, errors, faults, etc.
net_status_listener – Toggle the listener of the network status, connection and disconnection.
is_eoe – True if communication is EoE.
False
by default.
- Returns:
Instance of the servo connected.
- Return type:
EthernetServo
- disconnect_from_slave(servo: EthernetServo) None [source]
Disconnects the slave from the network.
- Parameters:
servo – Instance of the servo connected.
- get_servo_state(servo_id: int | str) NET_STATE [source]
Get the state of a servo that’s a part of network. The state indicates if the servo is connected or disconnected.
- Parameters:
servo_id – The servo’s IP address.
- Returns:
The servo’s state.
- static load_firmware(fw_file: str, target: str = '192.168.2.22', ftp_user: str = '', ftp_pwd: str = '') None [source]
Loads a given firmware file to the target slave.
Warning
It is needed to disconnect the drive(
disconnect_from_slave()
) after loading the firmware since the Servo object’s data will become obsolete.- Parameters:
fw_file – Path to the firmware file to be loaded.
target – IP of the target slave.
ftp_user – FTP user to connect with.
ftp_pwd – FTP password for the given user.
- Raises:
ILError – If the loading firmware process fails.
- static load_firmware_moco(node: int, subnode: int, ip: str, port: int, moco_file: str) None [source]
Update MOCO firmware through UDP protocol.
- Parameters:
node – Network node.
subnode – Drive subnode.
ip – Drive address IP.
port – Drive port.
moco_file – Path to the firmware file.
- Returns:
Result code.
- Raises:
ILFirmwareLoadError – The firmware load process fails with an error message.
- subscribe_to_status(ip: str, callback: Callable[[NET_DEV_EVT], Any]) None [source]
Subscribe to network state changes.
- Parameters:
ip – IP of the drive to subscribe.
callback – Callback function.
- unsubscribe_from_status(ip: str, callback: Callable[[NET_DEV_EVT], Any]) None [source]
Unsubscribe from network state changes.
- Parameters:
ip – IP of the drive to unsubscribe.
callback – Callback function.
- servos: List[Any]
List of the connected servos in the network.
- class ingenialink.ethernet.network.NetStatusListener(network: EthernetNetwork, refresh_time: float = 0.25)[source]
Network status listener thread to check if the drive is alive.
- Parameters:
network – Network instance of the Ethernet communication.
- is_alive()
Return whether the thread is alive.
This method returns True just before the run() method starts until just after the run() method terminates. See also the module function enumerate().
- join(timeout=None)
Wait until the thread terminates.
This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.
When the timeout argument is not present or None, the operation will block until the thread terminates.
A thread can be join()ed many times.
join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.
- run() None [source]
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
- start()
Start the thread’s activity.
It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.
This method will raise a RuntimeError if called more than once on the same thread object.
- property daemon
A boolean value indicating whether this thread is a daemon thread.
This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False.
The entire Python program exits when only daemon threads are left.
- property ident
Thread identifier of this thread or None if it has not been started.
This is a nonzero integer. See the get_ident() function. Thread identifiers may be recycled when a thread exits and another thread is created. The identifier is available even after the thread has exited.
- property name
A string used for identification purposes only.
It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor.
- property native_id
Native integral thread ID of this thread, or None if it has not been started.
This is a non-negative integer. See the get_native_id() function. This represents the Thread ID as reported by the kernel.