-
Notifications
You must be signed in to change notification settings - Fork 113
Open
Description
Dear devs,
I am fetching structs from my PLC that contain variables that are REFERENCE TO LREAL (for example):
I have an array of these structs i want to read using the pyads.connection.read_structure_by_name method. my python structure def and code are attahed below :
import pyads
from config.targets.target_configs import VBox
structure_def = (
("nSignalIndex", pyads.PLCTYPE_UINT, 1),
("fValue", pyads.PLCTYPE_LREAL, 1),
("sModuleName", pyads.PLCTYPE_STRING, 1),
("sSignalName", pyads.PLCTYPE_STRING, 1, 255),
("sDataUnit", pyads.PLCTYPE_STRING, 1),
("sSignalInfo", pyads.PLCTYPE_STRING, 1, 255),
("sSignalPath", pyads.PLCTYPE_STRING, 1, 255),
)
# fetches a single struct in the array of structs
# returns NaN for the reference variable
get_struct = VBox.connection.read_structure_by_name(
data_name="GVL_MachineGlobals.gSignalRegistry_SingletonCore.aSignalInfo[2]",
structure_def=structure_def,
)
# fetches multiple structs in the array of structs
# returns NaN for the reference variable
array_structs = VBox.connection.read_structure_by_name(
data_name="GVL_MachineGlobals.gSignalRegistry_SingletonCore.aSignalInfo",
structure_def=structure_def,
array_size=3,
)
# fetches the NaN value directly
fValue = VBox.connection.read_by_name(
data_name="GVL_MachineGlobals.gSignalRegistry_SingletonCore.aSignalInfo[2].fValue",
plc_datatype=pyads.PLCTYPE_LREAL,
)
for key, item in get_struct.items():
print(f"{key}: {item}")
print("done")
If i now read this structure, all variables are correctly read, except the variables of type REFERENCE, they return NaN
If i manually read this REFERENCE variable directly using the pyads.connection.read_by_name method, it does correctly read the value, but if i read it within a structure_def, it gives me NaN
I hope the problem statement is clear like this.
Many thanks for looking into my issue <3
Metadata
Metadata
Assignees
Labels
No labels

