Class Relay8Module

Class Examples

Relay8Module class example
from emod_controller_python_binding import relay8_module
import time

################################# TEST BINDINGS #######################################

# Create Relay8Module object
f = relay8_module.Relay8Module()

# Init module
if f.init() == 0:
    print("Init done properly")

    # Config pulse width
    if f.config_pulse_width(relay8_module.RELAY8MODULE_RELAY1, 0) == 0:
        print("Pulse width properly configured")
    else:
        print("Pulse width NOT properly configured")

    while 1:
        # Activate all relays
        if f.activate_all_relays() == 0:
            print("Activation succeeded")
        else:
            print("Activation NOT succeeded")

        # Get relay status
        status = f.get_relay_status(relay8_module.RELAY8MODULE_RELAY1)
        print("Status Relay1:" + str(status))
        status = f.get_relay_status(relay8_module.RELAY8MODULE_RELAY2)
        print("Status Relay2:" + str(status))
        status = f.get_all_relay_status()
        print("Status Relays:" + str(status))

        time.sleep(2)

        # Deactivate all relays
        if f.deactivate_all_relays() == 0:
            print("Activation succeeded")
        else:
            print("Activation NOT succeeded")

        # Get relay status
        status = f.get_relay_status(relay8_module.RELAY8MODULE_RELAY1)
        print("Status Relay1:" + str(status))
        status = f.get_relay_status(relay8_module.RELAY8MODULE_RELAY2)
        print("Status Relay2:" + str(status))
        status = f.get_all_relay_status()
        print("Status Relays:" + str(status))

        time.sleep(2)

        # Activate 1 relay
        if f.activate_relay(relay8_module.RELAY8MODULE_RELAY1) == 0:
            print("Activation succeeded")
        else:
            print("Activation NOT succeeded")

        # Get relay status
        status = f.get_relay_status(relay8_module.RELAY8MODULE_RELAY1)
        print("Status Relay1:" + str(status))
        status = f.get_relay_status(relay8_module.RELAY8MODULE_RELAY2)
        print("Status Relay2:" + str(status))
        status = f.get_all_relay_status()
        print("Status Relays:" + str(status))

        time.sleep(2)

        # Deactivate 1 relay
        if f.deactivate_relay(relay8_module.RELAY8MODULE_RELAY1) == 0:
            print("Deactivation succeeded")
        else:
            print("Activation NOT succeeded")

        # Get relay status
        status = f.get_relay_status(relay8_module.RELAY8MODULE_RELAY1)
        print("Status Relay1:" + str(status))
        status = f.get_relay_status(relay8_module.RELAY8MODULE_RELAY2)
        print("Status Relay2:" + str(status))
        status = f.get_all_relay_status()
        print("Status Relays:" + str(status))

        time.sleep(2)
else:
    print("Some error occured during module initialization...")

Public Functions

class emod_controller_python_binding.relay8_module.Relay8Module[source]

Bases: object

activate_all_relays()[source]

Activates all module relays.

Returns

It returns if the initialization was successfull (0) or not (!=0).

activate_relay(relay_mask)[source]

Activates a relay or set of relays.

Parameters

relay_mask – relay or list of relays to activate.

Returns

It returns if the initialization was successfull (0) or not (!=0).

config_all_pulse_width(width_ms)[source]

Configure pulse width of all relays. When pulse width is 0 a relay stays in the current state, and there is no pulse.

Parameters

width_ms – pulse width in ms. Value range 0 to 2^32-1. A 0-value means disable pulse. Default value is 0.

Returns

It returns if the initialization was successfull (0) or not (!=0).

config_pulse_width(relay_mask, width_ms)[source]

Configure pulse width of a relay or list of relays. When pulse width is 0 a relay stays in the current state, and there is no pulse.

Parameters
  • relay_mask – relay or list of relays to configure.

  • width_ms – pulse width in ms. Value range 0 to 2^32-1. A 0-value means disable pulse. Default value is 0.

Returns

It returns if the initialization was successfull (0) or not (!=0).

deactivate_all_relays()[source]

Deactivates all module relays.

Returns

It returns if the initialization was successfull (0) or not (!=0).

deactivate_relay(relay_mask)[source]

Deactivates a relay or set of relays.

Parameters

relay_mask – relay or list of relays to deactivate.

Returns

It returns if the initialization was successfull (0) or not (!=0).

get_all_relay_status()[source]

Gets all relay status.

Returns

Every bit represents a relay order status. Status is 1 when is activate and 0 when deactivate.

get_relay_status(relay_mask)[source]

Gets a relay status.

Parameters

relay_mask – relay mask number to get the status.

Returns

Every bit represents a relay order status. Status is 1 when is activate and 0 when deactivate.

init()[source]

Initialize module. It is important to emphasize that init() method is mandatory to call it and must be called always after instantiating the module. It can be called several times, each of which the module is initialized again.

Returns

It returns if the initialization was successfull (0) or not (!=0).

init_v(variant)[source]

Initialize module. It is important to emphasize that this method is mandatory to call it. It can be called several times, each of which the module is initialized again.

Parameters

variant – identifies the module in case more than one module of the same type are present.

Returns

It returns if the initialization was successfull (0) or not (!=0).