"common.ALLTYPES_DESCRIPTION":
    "This is the test channel created",
    "servermain.MULTIPLE_TYPES_DEVICE_DRIVER":
    "Allen-Bradley Controllogix Ethernet",
    "devices": [{
        "common.ALLTYPES_NAME": dev_name,
        "common.ALLTYPES_DESCRIPTION": "Hello, new description",
        "servermain.MULTIPLE_TYPES_DEVICE_DRIVER":
        "Allen-Bradley Controllogix Ethernet",
        "servermain.DEVICE_MODEL": 0,
        "servermain.DEVICE_ID_STRING": "<{}>,1,0".format(device_IP)
    }]
}
try:
    print("{} - {}".format("Adding Controllogix Channel and Device",
                           channel.add_channel(server, channel_data)))
except Exception as err:
    ErrorHandler(err)

# Execute the "TagGeneration" service available in the Kepware Configuration API
try:
    print("{} - {}".format(
        "Executing ATG for Controllogix Device",
        device.auto_tag_gen(server, '{}.{}'.format(ch_name, dev_name))))
except Exception as err:
    ErrorHandler(err)
# Get Event Log from Kepware instance.
# Time parameters need to be UTC values.
try:
    print("{} - {}".format(
        "Here is the last Event Log Entry",
Beispiel #2
0
    uniqueDevices = get_unique_devices(masterList)

    print ("Creating Modbus channel, device, and tag structure")
    for device in uniqueDevices:
        # create device configuration JSON
        dev_JSON = make_device(device, jChan, jDev, device_limit)
        all_devices_JSON.append(dev_JSON)

        # create MQTT Agent JSON
        agent_JSON = make_MQTT_agent(device, jAgent, MQTT_broker)
        all_agents_JSON.append(agent_JSON)

        # add tags to devices and iot item references to agent
        dev_tags_JSON, agent_tags_JSON = make_tags(masterList, device, jTag, device_limit, jAgentItem)
        all_devices_JSON[-1]['devices'][-1]['tags'] = dev_tags_JSON
        all_agents_JSON[-1]['iot_items'] = agent_tags_JSON
    print ("-- Devices, tags IoT Agents and IoT item references created")
    
    print ("-- Channel and devices and agent creation attempt")
    for Kepware_IP in Kepware_IP_Array:
        server = kepconfig.connection.server(Kepware_IP, Kepware_Port, user, passw)
        try:
            print("{} - {}".format("Adding all devices", channel.add_channel(server,all_devices_JSON)))
        except Exception as err:
            ErrorHandler(err)
        try:
            print("{} - {}".format("Adding all Agents", IoT.agent.add_iot_agent(server,all_agents_JSON,IoT.MQTT_CLIENT_AGENT)))
        except Exception as err:
            ErrorHandler(err)
    print ("-- Channel and devices and agent creation completed")
Beispiel #3
0
        print(err.reason)
    else:
        print('Different Exception Received: {}'.format(err))


# This creates a server reference that is used to target all modifications of
# the Kepware configuration
server = connection.server(host='127.0.0.1',
                           port=57412,
                           user='******',
                           pw='')

# Add a EGD Channel and Device
try:
    print("{} - {}".format("Adding EGD Channel and Device:",
                           channel.add_channel(server, egd_device)))
except Exception as err:
    HTTPErrorHandler(err)

#####################################################################
# Examples of managing Exchanges and Ranges in the Exchanges
#####################################################################

# Adding Exchanges to the device - Multiple exchanges can be added by creating a list of exchanges
consumer_exchange = {
    "common.ALLTYPES_NAME": "0",
    "common.ALLTYPES_DESCRIPTION": "",
    "ge_ethernet_global_data.CONSUMER_EXCHANGE_ID": 0,
    "ge_ethernet_global_data.CONSUMER_EXCHANGE_NUMBER": 1,
    "ge_ethernet_global_data.CONSUMER_EXCHANGE_PRODUCER_ID": "192.168.1.130",
    "ge_ethernet_global_data.CONSUMER_EXCHANGE_GROUP_ID": 1,
Beispiel #4
0
        # create MQTT Agent JSON
        agent_JSON = make_MQTT_agent(device, jAgent, MQTT_broker)
        all_agents_JSON.append(agent_JSON)

        # add tags to devices and iot item references to agent
        dev_tags_JSON, agent_tags_JSON = make_tags(masterList, device, jTag,
                                                   device_limit, jAgentItem)
        all_devices_JSON[-1]['devices'][-1]['tags'] = dev_tags_JSON
        all_agents_JSON[-1]['iot_items'] = agent_tags_JSON
    print("-- Devices, tags IoT Agents and IoT item references created")

    print("-- Channel and devices and agent creation attempt")
    for Kepware_IP in Kepware_IP_Array:
        server = kepconfig.connection.server(Kepware_IP, Kepware_Port, user,
                                             passw)
        try:
            print("{} - {}".format(
                "Adding all devices",
                channel.add_channel(server, all_devices_JSON)))
        except Exception as err:
            HTTPErrorHandler(err)
        try:
            print("{} - {}".format(
                "Adding all Agents",
                IoT.agent.add_iot_agent(server, all_agents_JSON,
                                        IoT.MQTT_CLIENT_AGENT)))
        except Exception as err:
            HTTPErrorHandler(err)
    print("-- Channel and devices and agent creation completed")
                },
                {
                    "common.ALLTYPES_NAME": "Tag2",
                    "common.ALLTYPES_DESCRIPTION": "Constant Read/Write tag used to verify client connection",
                    "servermain.TAG_ADDRESS": "K0001",
                    "servermain.TAG_DATA_TYPE": 5,
                    "servermain.TAG_READ_WRITE_ACCESS": 1,
                    "servermain.TAG_SCAN_RATE_MILLISECONDS": 100,
                    "servermain.TAG_SCALING_TYPE": 0
                }
            ]
        }
    ]
}
try:
    print("{} - {}".format("Adding Channel, Device and tags", channel.add_channel(server,channel_data)))
except Exception as err:
    HTTPErrorHandler(err)


# Add the Datalogger Log Group with the appropriate parameters
try:
    print("{} - {}".format("Add the Datalogger Log Group", DL.log_group.add_log_group(server, log_group1)))
except Exception as err:
    HTTPErrorHandler(err)

# Modify a property of the Log Group If the "common.ALLTYPES_Name" is defined
# the "modify_log_group" function does not need have the log group name as an input

# Change Update rate to 1000 ms
log_group_mod_properties = {