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 Sep 17, 2019 11:39 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
 Post subject: Generic Change Log
PostPosted: Fri Mar 01, 2019 6:52 am 
Offline

Joined: Wed Jan 16, 2019 7:18 pm
Posts: 11
I need to develop a generic change log.

I want to be able to compare two instances of a structure (dutName and dutNameLast), and determine which elements have changed.

I can use the MEM.Compare function to determine that there is a difference between the two instances of structures.

But once I detect that there is a difference, I need to populate a Change Log, which will be an array of a structure that looks like this:

ChangeTS | SeqNum | VarName | OldValue | NewValue
DATE_AND_TIME | 123 | dutName.configINT_A | 'xxx' | 'xxy'
DATE_AND_TIME | 122 | dutName.configREAL_B | 'x.xxxx' | 'y.yyyy'
DATE_AND_TIME | 121 | dutName.configBOOL_C | '1' | '0'
DATE_AND_TIME | 120 | dutName.configDINT_D | 'xxxxxx' | 'yyyxyy'

Only the elements that have changed get logged.

I want this to be generic, because I need to be able to compare two instances of a variety of structures.

I am having trouble figuring out how to do the following:

1. Is there a programmatic way to determine what the element names are for a structure? I'd like to be able to reference the structure somehow, and get a list of element names returned.

2. Is there an easy way to traverse the elements of a structure, so that I can do a comparison of the individual elements in some kind of loop:

Loop through the elements of the structure
compare value of dutName.(nth_elementname) to value of dutNameLast.(nth_elementname)
change *.(nth_elementname) to *.(nth+1elementname)
End loop

Any assistance or advice would be greatly appreciated.

_________________
Tim Manning


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

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 5 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