ICommunicationExtension

class

ICommunicationExtension.

ICommunicationExtension

Bases: object

Provides methods for communication-related settings and functions of a device.

get_communication_address

Retrieves the communication address of the controller.

Returns

The communication Address. This can be an IP Address, a nodename or fully qualified connection URI. Examples: - 192.168.2.25 - MyController - etcp3://192.168.2.25 - etcp3://10.128.154.12:1105,192.168.2.25 - enodename3://10.128.154.12:1105,MyController - etcp3://[10.128.154.12:1217],192.168.2.25 - enodename3://[10.128.154.12:1217],MyController

Return type

string

This example shows an example of getting the address.

from __future__ import print_function

def main():
    if not projects.primary:
        system.ui.error("No active project.")
        return

    project = projects.primary
    # locating the controller named 'LMC'
    controller = project.find('LMC', True)[0]    
    address = controller.get_communication_address()
    print(address)
    system.ui.info("Test complete")

main()

reboot_plc

Reboots the controller.

This example shows an example of rebooting the controller.

from __future__ import print_function

def perform_application_login(project):
    app = project.active_application
    onlineapp = online.create_online_application(app)
    onlineapp.login(OnlineChangeOption.Try, True)

def main():
    if not projects.primary:
        system.ui.error("No active project.")
        return

    perform_application_login(project)
    #find the controller named 'LMC' which is to be rebooted
    controller = project.find('LMC', True)[0]
    #reboot the controller
    controller.reboot_plc()
    system.ui.info("Test complete")

main()

reset_diagnosis_messages

Resets the diagnostic messages of the controller.

This example shows an example of resetting the diagnostic messages of a controller

from __future__ import print_function

def perform_application_login(project):
    app = project.active_application
    onlineapp = online.create_online_application(app)
    onlineapp.login(OnlineChangeOption.Try, True)

def main():
    if not projects.primary:
        system.ui.error("No active project.")
        return

    project = projects.primary
    perform_application_login(project)
    #find the controller which messages are to be acknowledged
    controller = project.find('LMC', True)[0]
    #acknowledge the diagnostic messages
    controller.reset_diagnosis_messages()
    system.ui.info("Test complete")

main()

stop_all_applications

Stops the applications of the controller.

This example shows an example of resetting the diagnostic messages of a controller

from __future__ import print_function

def perform_application_login(project):
    app = project.active_application
    onlineapp = online.create_online_application(app)
    onlineapp.login(OnlineChangeOption.Try, True)

def main():
    if not projects.primary:
        system.ui.error("No active project.")
        return

    project = projects.primary
    perform_application_login(project)
    #find the controller which the applications are to be stopped
    controller = project.find('LMC', True)[0]
    #stop all applications
    controller.stop_all_applications()
    system.ui.info("Test complete")

main()

execute_iec_echo_service_test

Execute the echo service that sends tests values for common data bytes that are to be returned with same values. This can be used for a smoke test. If any returned value differs from the expected value an exception is reported with the expected and actual value.

Note

The service is probably not registered on calling the test. This can be done inside the application using: SE_IRS.Instances.g_ifIecServices.GetServiceByName('EchoTest').RegisterService();

Reports

System.ArgumentException -- Invalid Result: Expected={expectedValue}, Actual={actualValue} or Invalid UDInt: Expected={expectedValue}, Actual={actualValue} or Invalid DInt: Expected={expectedValue}, Actual={actualValue} or Invalid String: Expected={expectedValue}, Actual={actualValue} or Invalid Bytes: Position={i}, Expected={expectedValue[i]}, Actual={actualValue[i]}

set_communication_address

address

Sets the communication address of the controller. This can be an IP Address, a nodename or fully qualified connection URI.

Parameters

address (string) -- The communication address in one of the following notations: - 192.168.2.25 - MyController - etcp3://192.168.2.25 - etcp3://10.128.154.12:1105,192.168.2.25 - enodename3://10.128.154.12:1105,MyController - etcp3://[10.128.154.12:1217],192.168.2.25 - enodename3://[10.128.154.12:1217],MyController

This example shows an example of setting an IP address.

from __future__ import print_function

def main():
    if not projects.primary:
        system.ui.error("No active project.")
        return

    project = projects.primary
    #find the controller by the object name where address is to be set and read.
    controller = project.find('LMC', True)[0]
    #reboot the controller
    controller.set_communication_address('192.168.2.25')
    #read address back and show it.
    print('get_communication_address:=' + controller.get_communication_address())
    system.ui.info("Test complete")

main()