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 Thu Sep 19, 2019 8:46 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Feb 19, 2013 1:22 pm 
Offline
User avatar

Joined: Thu Nov 16, 2006 4:20 pm
Posts: 9
Hallo Forum,

gibt es eine Funktion/Bibliothek um den Steuerungsnamen aus CODESYSCONTROL.CFG auszulesen?
Oder muss ich das von Hand und mit SysFile selbst bewerkstelligen?


Does a function/library exist to read out the nodename-value from CODESYSCONTROL.CFG?
Or do I have to read manually with library 'SysFile'?

_________________
Mensch nimm dir Zeit und nicht das Leben


Top
   
PostPosted: Fri Feb 22, 2013 12:41 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Tue Jun 06, 2006 9:03 am
Posts: 409
Good question. Please share your solution if you have found out how to do this.
You could use the CmpApp library to get information about the application, but as far as I have seen this doesn't give information about the device name.


Top
   
PostPosted: Fri Feb 22, 2013 2:34 pm 
Offline
User avatar

Joined: Thu Nov 16, 2006 4:20 pm
Posts: 9
my solution, quick and possibly "dirty" -> is there a better solution ?

e.g.

Code:
PROGRAM ReadOutSysInfos
VAR
   init: BOOL;

   strTemp: STRING(255);
   strBoardName: STRING(30);
   strBoardName2: STRING(30);
   wstrBoardName2: WSTRING(30);
   fileHandle:    SysTypes.RTS_IEC_HANDLE;                  // File handle number
   fileName:      STRING[63] := '/flashdisk/CodesysV3/CoDeSysControl.cfg';      // Path and file name
   rte:          RTS_IEC_RESULT;                  // Error code according runtime error list
   ptrToString: POINTER TO BYTE;
   ptrToString1: POINTER TO BYTE;
   ptrToString1a: POINTER TO STRING(255);
   strCmp1: STRING(12):= '[SysTarget]';
   readSize: UDINT := constantReadSize;
   bytesRead: UDINT := 0;
   udi :UDINT;
   readLog:      ARRAY [0..constantReadSize] OF BYTE;// Array to read old logs
   str_offset: INT;
   str_offset2: INT;

   iLen: INT;
   strComponent : STRING:='SysTarget';
   strKeyValue: STRING:='NodeName';
END_VAR
VAR CONSTANT
   constantReadSize:   UDINT:=4000;   
END_VAR


IF init = FALSE THEN
   IF strBoardName = '' THEN
      fileHandle := SysFileOpen(fileName, AM_READ,  ADR(rte));   // Open original file
      IF (fileHandle = 16#FFFFFFFF) OR (fileHandle = 0) THEN
         strBoardName := 'invalid handle';
      ELSE
         strBoardName := 'not found';
         ptrToString := ADR(readLog);
         ptrToString1 := ADR(strCmp1);
         bytesRead := SysFileRead(fileHandle, ptrToString, readSize, ADR(rte));   // Read the original file
         FOR udi:=1 TO (bytesRead - 250) DO
            ptrToString1a := ptrToString;
            str_offset := Standard.FIND(ptrToString1a^, strCmp1);
            IF str_offset > 0 THEN
               ptrToString1a := ptrToString1a + str_offset;
               str_offset := Standard.FIND(ptrToString1a^, 'NodeName=') + 8;
               IF str_offset > 8 THEN
                  ptrToString1a := ptrToString1a + str_offset + 1;
                  ptrToString1 := ptrToString1a + Standard.FIND(ptrToString1a^, '$R') - 2;
                  ptrToString1^ := 0;
                  strBoardName := ptrToString1a^;
                  EXIT;
               END_IF
            END_IF
            ptrToString := ptrToString + 1;
         END_FOR
         rte := SysFileClose(fileHandle);            // Close original file
      END_IF
   END_IF

   init:= TRUE;
END_IF

_________________
Mensch nimm dir Zeit und nicht das Leben


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 11 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