CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Tue Oct 15, 2019 12:42 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Nov 28, 2014 3:48 pm 
Offline

Joined: Thu Sep 01, 2011 5:09 pm
Posts: 95
Hello,

I'm trying to implement retrieving Retain variables from File, using lib cmpApp. I found a sample in Codesys Store:
http://store.codesys.com/application-manager.html

So I copied PRG into my project added lib and retain variable, And I get an error that RTS_IEC_RESULT is unknown type, but is declared like:

Code:
PROGRAM AppRetain

VAR
   fbDelete            : FILE.Delete; (* Function block to delete the file *)
    (* The retain file <application-name>.ret is placed in the directory of the bootproject *)
   sFileName          : STRING := 'App1.ret';
   pApp         : POINTER TO APPLICATION;
   Result                : RTS_IEC_RESULT; (* Result code *)
   xInit         : BOOL;
END_VAR


Code:

Code:
(* The retain variables are stores in a file and get retrieved afterwards. *)
IF NOT xInit THEN
   
   (* First delete the retain file.
      This is necessary, because the function AppStoreRetainsInFile appends the data at the end of the file. *)
   fbDelete(xExecute:=TRUE, sFileName:=sFileName);
   IF fbDelete.xDone OR (fbDelete.xError AND fbDelete.eError = FILE.ERROR.NOT_EXIST) THEN
      (* Attention: It takes at least one cycle until xDone is TRUE *)
      fbDelete(xExecute:=FALSE);
      xInit := TRUE;
      (* Now, it's the time to save the retains. *)
      pApp := AppGetCurrent(pResult:=ADR(Result));
      IF pApp <> 0 THEN
         (* Store the variables in a file*)
         Result := AppStoreRetainsInFile(pApp,sFileName);
      END_IF
   END_IF
END_IF

(* Restore the Retain Variables from the file.
   For storing and restoring, the same pointer to application (pApp) must be used.*)
Result := AppRestoreRetainsFromFile(pApp, sFileName);


I have no Idea how to declare it other way??? Any Ideas?

regards,
Alex


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Fri Nov 28, 2014 4:30 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Tue Jun 06, 2006 9:03 am
Posts: 409
With newer library versions it is required (and also better for older versions) to use the namespace to define which RTS_IEC_RESULT you want to use.

In this case you need to define the variable as:
Result : CmpApp.RTS_IEC_RESULT;


Top
   
PostPosted: Fri Nov 28, 2014 4:35 pm 
Offline

Joined: Thu Sep 01, 2011 5:09 pm
Posts: 95
Thank you TimvH didn't know that, Build OK, now testing.

regards,
Alex


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited