I'm working on codesys (ST) to create a storekeeper programm.
I have a persistant variable which is a strucure name ST_STORAGE, here it definition :
TYPE ST_STORAGE :
STRUCT
xInitialized :BOOL; // Indicate if the storage have been already initialized
astStore :ARRAY[0..9 ,0..9] OF ST_Location; // Indicate location (composed of columns and rows) available in all storage
uiNbColumns :UINT; // Indicate number of columns that are really availablein this storage
uiNbRows :UINT; // Indicate number of rows that are really available in this storage
END_STRUCT
END_TYPE
The structure ST_LOCATION is composed of :
TYPE ST_LOCATION :
STRUCT
xEmpty :BOOL; // Indicate if location is used or empty
uiColumn :UINT; // Indicate location's column where tool is stored
uiRow :UINT; // Indicate location's row where tool is stored
stToolRef :STRING; // Indicate RFID reference of tool stored
END_STRUCT
END_TYPE
My function block FB_Storage take in input :
VAR_INPUT
i_xInitialize :BOOL; // Indicate initializing instruction (init MAX column and row of the store)
i_xScan :BOOL; // Indicate scanning instruction (scanning locations to find our tool's reference)
i_xStore :BOOL; // Indicate storing instruction (storing a tool reference in a specified location)
i_xPickUp :BOOL; // Indicate picking up instruction (pick up a tool in specified location and clean location after picking up)
i_sToolRef :STRING; // Indicate Tool ref to store in a speciefied location
i_stStorage :POINTER TO ST_STORAGE; // Indicate the storage to scan,store,pick up in
END_VAR
So i can write / read in my storage by the pointer i_stStorage. But i can't read or write in my speciefied location by :
i_stStorage^.astStore[x,y].xEmpty