Skip to content

Commit a021b0e

Browse files
committed
Clean up Examples
1 parent f79462d commit a021b0e

4 files changed

Lines changed: 20 additions & 16 deletions

File tree

examples/GE EGD exchanges example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
from kepconfig import connection, error
13-
from kepconfig.connectivity import channel, device, tag, egd
13+
from kepconfig.connectivity import channel, egd
1414

1515
# Channel and Device name to be used
1616
ch_name = 'EGD'

examples/complex-example/Modbus2MQTT_MultiServer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import csv
2626
import json
2727
import kepconfig
28-
from kepconfig.connectivity import channel, device, tag
28+
from kepconfig.connectivity import channel, device
2929
import kepconfig.iot_gateway as IoT
3030

3131
def ErrorHandler(err):

examples/iot gateway example.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010

1111
from kepconfig import connection, error
1212
from kepconfig.connectivity import channel
13-
import kepconfig.iot_gateway as IoT
14-
from kepconfig.iot_gateway import agent, iot_items
13+
import kepconfig.iot_gateway as iot
1514

1615
# Agent name and Type to be used - constants from kepconfig.iotgateway
1716
# can be used to identify the type of agent
1817
agent_name = 'MQTT Agent 1'
19-
agent_type = IoT.MQTT_CLIENT_AGENT
18+
agent_type = iot.MQTT_CLIENT_AGENT
2019

2120
#Tag Address to add to the IoT agent
2221
iot_item_name = "Channel1.Device1.Tag1"
@@ -100,7 +99,7 @@ def ErrorHandler(err):
10099
"iot_gateway.MQTT_CLIENT_PASSWORD": ""
101100
}
102101
try:
103-
print("{} - {}".format("Add the MQTT Agent", agent.add_iot_agent(server, agent_data, agent_type)))
102+
print("{} - {}".format("Add the MQTT Agent", iot.agent.add_iot_agent(server, agent_data, agent_type)))
104103
except Exception as err:
105104
ErrorHandler(err)
106105

@@ -109,20 +108,20 @@ def ErrorHandler(err):
109108
}
110109
agent_data['common.ALLTYPES_DESCRIPTION'] = 'This is the test agent created'
111110
try:
112-
print("{} - {}".format("Modify property in the MQTT Agent", agent.modify_iot_agent(server,agent_data, agent_name, agent_type)))
111+
print("{} - {}".format("Modify property in the MQTT Agent", iot.agent.modify_iot_agent(server,agent_data, agent_name, agent_type)))
113112
except Exception as err:
114113
ErrorHandler(err)
115114

116115
# Get Agent the properties for the agent that was created. It will return the
117116
# JSON of the properties
118117
try:
119-
print("{} - {}".format("Read properties of the MQTT Agent", agent.get_iot_agent(server, agent_name, agent_type)))
118+
print("{} - {}".format("Read properties of the MQTT Agent", iot.agent.get_iot_agent(server, agent_name, agent_type)))
120119
except Exception as err:
121120
ErrorHandler(err)
122121

123122
# Get a list of all MQTT Agents that are configured
124123
try:
125-
print("{} - {}".format("Getting list of MQTT Agents", agent.get_all_iot_agents(server, agent_type)))
124+
print("{} - {}".format("Getting list of MQTT Agents", iot.agent.get_all_iot_agents(server, agent_type)))
126125
except Exception as err:
127126
ErrorHandler(err)
128127

@@ -139,7 +138,7 @@ def ErrorHandler(err):
139138
"iot_gateway.IOT_ITEM_DATA_TYPE": 5
140139
}
141140
try:
142-
print("{} - {}".format("Add new tag to the MQTT Agent", iot_items.add_iot_item(server, iot_item_data, agent_name, agent_type)))
141+
print("{} - {}".format("Add new tag to the MQTT Agent", iot.iot_items.add_iot_item(server, iot_item_data, agent_name, agent_type)))
143142
except Exception as err:
144143
ErrorHandler(err)
145144

@@ -150,7 +149,7 @@ def ErrorHandler(err):
150149
"iot_gateway.IOT_ITEM_SCAN_RATE_MS": 500
151150
}
152151
try:
153-
print("{} - {}".format("Modify the tag or IoT Item added", iot_items.modify_iot_item(server, modify_iot_item, agent_name, agent_type)))
152+
print("{} - {}".format("Modify the tag or IoT Item added", iot.iot_items.modify_iot_item(server, modify_iot_item, agent_name, agent_type)))
154153
except Exception as err:
155154
ErrorHandler(err)
156155

@@ -162,30 +161,30 @@ def ErrorHandler(err):
162161
"iot_gateway.IOT_ITEM_SCAN_RATE_MS": 2000
163162
}
164163
try:
165-
print("{} - {}".format("Modify the tag or IoT Item added again", iot_items.modify_iot_item(server, modify_iot_item, agent_name, agent_type, iot_item_name, force = True)))
164+
print("{} - {}".format("Modify the tag or IoT Item added again", iot.iot_items.modify_iot_item(server, modify_iot_item, agent_name, agent_type, iot_item_name, force = True)))
166165
except Exception as err:
167166
ErrorHandler(err)
168167

169168
# Read the tag or IoT Item configured in the MQTT Agent
170169
try:
171-
print("{} - {}".format("Read the properties of the IoT Item", iot_items.get_iot_item(server, iot_item_name, agent_name, agent_type)))
170+
print("{} - {}".format("Read the properties of the IoT Item", iot.iot_items.get_iot_item(server, iot_item_name, agent_name, agent_type)))
172171
except Exception as err:
173172
ErrorHandler(err)
174173

175174
# Get a list of all tags or IoT Items configured in the MQTT Agent
176175
try:
177-
print("{} - {}".format("Get a list of all the IoT Items configured in the MQTT Agent", iot_items.get_all_iot_items(server, agent_name, agent_type)))
176+
print("{} - {}".format("Get a list of all the IoT Items configured in the MQTT Agent", iot.iot_items.get_all_iot_items(server, agent_name, agent_type)))
178177
except Exception as err:
179178
ErrorHandler(err)
180179

181180
# Delete a tag or IoT Item configured in the MQTT Agent
182181
try:
183-
print("{} - {}".format("Delete the IoT Item", iot_items.del_iot_item(server, iot_item_name, agent_name, agent_type)))
182+
print("{} - {}".format("Delete the IoT Item", iot.iot_items.del_iot_item(server, iot_item_name, agent_name, agent_type)))
184183
except Exception as err:
185184
ErrorHandler(err)
186185

187186
# Delete the MQTT Agent
188187
try:
189-
print("{} - {}".format("Delete the MQTT Agent", agent.del_iot_agent(server, agent_name, agent_type)))
188+
print("{} - {}".format("Delete the MQTT Agent", iot.agent.del_iot_agent(server, agent_name, agent_type)))
190189
except Exception as err:
191190
ErrorHandler(err)

examples/services and logs example.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ def ErrorHandler(err):
9999
except Exception as err:
100100
ErrorHandler(err)
101101

102+
try:
103+
print("{} - {}".format("Here are only the Information entries of the Event Log", json.dumps(server.get_event_log(None, datetime.datetime.fromisoformat('2019-11-03T23:35:23.000'), datetime.datetime.utcnow(), options= {'event': 'Information'}), indent=4)))
104+
except Exception as err:
105+
ErrorHandler(err)
106+
102107
#Get Configuration API Transaction Log
103108
try:
104109
print("{} - {}".format("Here is the last API Transaction Log Entry", json.dumps(server.get_transaction_log(1), indent=4)))

0 commit comments

Comments
 (0)