根据文件(OpenOPC Documentation)中的解释,opc.属性('test测试/测试。测试')应该返回一个元组列表(id、description、value),但这只是给我一个值。你知道吗
import OpenOPC
import time
import pywintypes
pywintypes.datetime = pywintypes.TimeType
opc = OpenOPC.client()
opc.connect('abc.xyz')
list_possible_turbines = opc.list(recursive=True)
print(list_possible_turbines)
while True:
try:
for i in range(1,6):
print(opc.properties('Testtest/test.test', id=i))
except:
print('error')
time.sleep(5)
有人能帮我吗?我期待这样的输出:
[(1, 'Item Canonical DataType', 'VT_I4'), (2, 'Item Value', 491), (3, 'Item Quality', 'Good'), (4, 'Item Timestamp', '06/25/07 02:24:44'), (5, 'Item Access Rights', 'Read')]
而不是:
['VT_I4', 491, 'Good','06/25/07 02:24:44','Read]
另外,如果我不提身份证:
while True:
try:
print(opc.properties(list_possible_turbines))
except OpenOPC.TimeoutError:
print('Timeout error')
time.sleep(1)
我得到了这样一个错误:
Traceback (most recent call last):
File "C:/Users/UI585722/PycharmProjects/OPCDataRead/OPCRead/connect_data.py", line 20, in <module>
print(opc.properties(list_possible_turbines))
File "C:\Users\UI585722\PycharmProjects\OPCDataRead\venv\lib\site-packages\OpenOPC.py", line 1006, in properties
return list(props)
File "C:\Users\UI585722\PycharmProjects\OPCDataRead\venv\lib\site-packages\OpenOPC.py", line 938, in iproperties
property_id = [p for p, d in tag_properties if p > 0]
File "C:\Users\UI585722\PycharmProjects\OPCDataRead\venv\lib\site-packages\OpenOPC.py", line 938, in <listcomp>
property_id = [p for p, d in tag_properties if p > 0]
TypeError: 'NoneType' object is not callable
提前谢谢
那是因为您正在设置
id=
。你知道吗从docs(我的重点):
以及:
OpenOPC库就是这样构建的,因此我创建了自己的版本来获得我想要的响应。现在,即使在每个场景中,它都会返回库中描述的元组(id、description、value)。你知道吗
请在这里找到我的版本:
EditedVersion
相关问题 更多 >
编程相关推荐