Reading a timer seemingly not detecting tag structure #122
Replies: 3 comments 2 replies
-
So this is definitely a bug that I must've introduced recently, you should be able to read/write entire structures including the builtin types. You can see in the |
Beta Was this translation helpful? Give feedback.
-
I just pushed an initial fix to the |
Beta Was this translation helpful? Give feedback.
-
I haven't tried this library yet, but after reading the homepage it seems that the read and write methods are not recommended for working with built-in types such as timers and counters. I'd like to confirm that this is still the case and if not, what will be then the recommended way to work with these types of tags? Thank you. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm very new to python so forgive me if I'm on the wrong track. I'm just getting started reading tags from a CompactLogix L32E firmware version 20.19.
Here's the python 3.9 code I'm running within a venv in PyCharm 2020.3
from pycomm3 import LogixDriver
plc = LogixDriver('192.168.53.75')
plc.open()
print(plc.info)
print(plc.get_tag_info('AIR_MIXED_TMR'))
MyREAL = plc.read('HRS_HYDRAULICS')
print(MyREAL)
MyTimer = plc.read('AIR_MIXED_TMR')
print(MyTimer)
The read of a REAL tag works fine and I see the and see its value,
However, when I try to read a standard TIMER, it does not appear to return the internal structure, the value is simply None
According to the PyCharm object browser, both MyREAL and MyTimer appear to be of a type Tag:4. Internally MyREAL has a value type of float but MyTimer has a value type of NoneType.
However, calling plc.get_tag_info('AIR_MIXED_TMR') indicates that the plc object is aware that AIR_MIXED_TMR has a timer structure
{'tag_name': 'AIR_MIXED_TMR', 'dim': 0, 'alias': False, 'instance_id': 64539, 'symbol_address': 396996, 'symbol_object_address': 1101252, 'software_control': 67221775, 'external_access': 'Read/Write', 'dimensions': [0, 0, 0], 'template_instance_id': 3971, 'data_type': {'name': 'TIMER', 'internal_tags': {'CTL': {'offset': 0, 'tag_type': 'atomic', 'data_type': 'DWORD', 'data_type_name': 'DWORD', 'array': 0, 'type_class': DWORD}, 'PRE': {'offset': 4, 'tag_type': 'atomic', 'data_type': 'DINT', 'data_type_name': 'DINT', 'array': 0, 'type_class': DINT}, 'ACC': {'offset': 8, 'tag_type': 'atomic', 'data_type': 'DINT', 'data_type_name': 'DINT', 'array': 0, 'type_class': DINT}, 'EN': {'offset': 3, 'tag_type': 'atomic', 'data_type': 'BOOL', 'data_type_name': 'BOOL', 'bit': 7, 'type_class': BOOL}, 'TT': {'offset': 3, 'tag_type': 'atomic', 'data_type': 'BOOL', 'data_type_name': 'BOOL', 'bit': 6, 'type_class': BOOL}, 'DN': {'offset': 3, 'tag_type': 'atomic', 'data_type': 'BOOL', 'data_type_name': 'BOOL', 'bit': 5, 'type_class': BOOL}}, 'attributes': ['CTL', 'PRE', 'ACC', 'EN', 'TT', 'DN'], 'template': {'object_definition_size': 24, 'structure_size': 12, 'member_count': 6, 'structure_handle': 3971}, '_struct_members': ([DWORD(name='CTL'), DINT(name='PRE'), DINT(name='ACC'), BOOL(name='EN'), BOOL(name='TT'), BOOL(name='DN')], {}), 'type_class': StructTag(DWORD(name='CTL'), DINT(name='PRE'), DINT(name='ACC'), BOOL(name='EN'), BOOL(name='TT'), BOOL(name='DN'), bool_members={}, host_members={}, struct_size=12)}, 'data_type_name': 'TIMER', 'tag_type': 'struct', 'type_class': StructTag(DWORD(name='CTL'), DINT(name='PRE'), DINT(name='ACC'), BOOL(name='EN'), BOOL(name='TT'), BOOL(name='DN'), bool_members={}, host_members={}, struct_size=12)}
I can successfully read the internal structure of the timer piece by piece. e.g
plc.read('AIR_MIXED_TMR.PRE')
plc.read('AIR_MIXED_TMR.ACC')
Is this behaviour normal or am I missing something? I had been under the impression that reading a TIMER tag by its basic tagname would return an object that replicated the structure of the timer, allowing members of that structure to be accessed without individually re-reading the tag piece by piece.
I'm grateful for your time,
Cheers,
Simon
Beta Was this translation helpful? Give feedback.
All reactions