2

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
  • Are you saying you can read/write the `i_stStorage` variable in your function block but you can't read/write it to your Persistant variable that you assign to that input of the function block (i.e. `i_stStorage:=ADR(PersistVar)`) ? – mrsargent Feb 15 '17 at 16:41
  • ..because your code works for me when I run it. If I implement your `FB_Storage` and I assign the `i_stStorage` input to a persistent global variable I defined, I can read/write to that variable just fine. – mrsargent Feb 15 '17 at 20:07
  • I have tried by a different way. I have change : `astStore :ARRAY[0..9 ,0..9] OF ST_Location` to `astStore :ARRAY[0..9] OF ARRAY[,0..9] OF ST_Location` and it's works. I have certainly done some syntax mistake in my code.... Anyway, thanks for your help. – José Todeschini Feb 17 '17 at 07:06

0 Answers0