You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/iot gateway example.py
+13-14Lines changed: 13 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -10,13 +10,12 @@
10
10
11
11
fromkepconfigimportconnection, error
12
12
fromkepconfig.connectivityimportchannel
13
-
importkepconfig.iot_gatewayasIoT
14
-
fromkepconfig.iot_gatewayimportagent, iot_items
13
+
importkepconfig.iot_gatewayasiot
15
14
16
15
# Agent name and Type to be used - constants from kepconfig.iotgateway
17
16
# can be used to identify the type of agent
18
17
agent_name='MQTT Agent 1'
19
-
agent_type=IoT.MQTT_CLIENT_AGENT
18
+
agent_type=iot.MQTT_CLIENT_AGENT
20
19
21
20
#Tag Address to add to the IoT agent
22
21
iot_item_name="Channel1.Device1.Tag1"
@@ -100,7 +99,7 @@ def ErrorHandler(err):
100
99
"iot_gateway.MQTT_CLIENT_PASSWORD": ""
101
100
}
102
101
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)))
104
103
exceptExceptionaserr:
105
104
ErrorHandler(err)
106
105
@@ -109,20 +108,20 @@ def ErrorHandler(err):
109
108
}
110
109
agent_data['common.ALLTYPES_DESCRIPTION'] ='This is the test agent created'
111
110
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)))
113
112
exceptExceptionaserr:
114
113
ErrorHandler(err)
115
114
116
115
# Get Agent the properties for the agent that was created. It will return the
117
116
# JSON of the properties
118
117
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)))
120
119
exceptExceptionaserr:
121
120
ErrorHandler(err)
122
121
123
122
# Get a list of all MQTT Agents that are configured
124
123
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)))
126
125
exceptExceptionaserr:
127
126
ErrorHandler(err)
128
127
@@ -139,7 +138,7 @@ def ErrorHandler(err):
139
138
"iot_gateway.IOT_ITEM_DATA_TYPE": 5
140
139
}
141
140
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)))
143
142
exceptExceptionaserr:
144
143
ErrorHandler(err)
145
144
@@ -150,7 +149,7 @@ def ErrorHandler(err):
150
149
"iot_gateway.IOT_ITEM_SCAN_RATE_MS": 500
151
150
}
152
151
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)))
154
153
exceptExceptionaserr:
155
154
ErrorHandler(err)
156
155
@@ -162,30 +161,30 @@ def ErrorHandler(err):
162
161
"iot_gateway.IOT_ITEM_SCAN_RATE_MS": 2000
163
162
}
164
163
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)))
166
165
exceptExceptionaserr:
167
166
ErrorHandler(err)
168
167
169
168
# Read the tag or IoT Item configured in the MQTT Agent
170
169
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)))
172
171
exceptExceptionaserr:
173
172
ErrorHandler(err)
174
173
175
174
# Get a list of all tags or IoT Items configured in the MQTT Agent
176
175
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)))
178
177
exceptExceptionaserr:
179
178
ErrorHandler(err)
180
179
181
180
# Delete a tag or IoT Item configured in the MQTT Agent
182
181
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)))
184
183
exceptExceptionaserr:
185
184
ErrorHandler(err)
186
185
187
186
# Delete the MQTT Agent
188
187
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)))
Copy file name to clipboardExpand all lines: examples/services and logs example.py
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -99,6 +99,11 @@ def ErrorHandler(err):
99
99
exceptExceptionaserr:
100
100
ErrorHandler(err)
101
101
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
+
exceptExceptionaserr:
105
+
ErrorHandler(err)
106
+
102
107
#Get Configuration API Transaction Log
103
108
try:
104
109
print("{} - {}".format("Here is the last API Transaction Log Entry", json.dumps(server.get_transaction_log(1), indent=4)))
0 commit comments