|
@@ -60,7 +60,7 @@ def get():
|
|
|
for group in point_base_dic:
|
|
|
for item in point_base_dic[group]:
|
|
|
point_arr.append(item['key'])
|
|
|
-
|
|
|
+
|
|
|
# 根据服务地址获取Opc数据
|
|
|
data = asyncio.run(get_opc_data(sys_url, point_arr, 2))
|
|
|
# 显示请求地址IP
|
|
@@ -100,7 +100,10 @@ async def get_opc_data(sys_url, point_arr, ns=2):
|
|
|
while i < len(point_arr):
|
|
|
node = f"ns={ns};s={point_arr[i]}"
|
|
|
tag = client.get_node(node)
|
|
|
- sub = await client.create_subscription(500, handler)
|
|
|
+ try:
|
|
|
+ sub = await client.create_subscription(500, handler)
|
|
|
+ except Exception as e:
|
|
|
+ raise Exception("连接opc服务错误!")
|
|
|
value = None
|
|
|
try:
|
|
|
value = await tag.read_value()
|
|
@@ -120,6 +123,7 @@ async def get_opc_data(sys_url, point_arr, ns=2):
|
|
|
return result_arr
|
|
|
finally:
|
|
|
# 网络连通性测试
|
|
|
+ print("报错咯")
|
|
|
sys_ip = sys_url[10: sys_url.index(":", 10)]
|
|
|
os.system(f'ping {sys_ip} -n 1')
|
|
|
|