I Have Discovered Issue(not really but its not good too) In Old Code That,
IF Any one of the Variable is Changed
THEN writetable :=True
it means Every single time it will go and write value in table, I want to improve that in some better way.
If Any one Could suggest Anything it will be great.
Thank You
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
one possibility would be to use a FOR loop and Arrays. Something like this:
VAR  mParameter:ARRAY[0..ArrayLength]OFINT:=[1,2,3,4,5];  pParameter:ARRAY[0..ArrayLength]OFINT:=[1,2,3,7,5];  counter:INT;  writetable:BOOL;END_VARVARCONSTANT  ArrayLength  :INT:=4;END_VAR
FORcounter :=0TOArrayLengthDO
  IFmParameter[counter] <>pParameter[counter] THEN
    writetable :=TRUE;
    EXIT;
  END_IFEND_FOR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2018-09-20
Originally created by: Viacheslav Mezentsev
Struct + pointer + mem utils + crc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'd go with a crc approach as this is way more flexible with regards of your array/tablesize.
If the current crc (of your table) differs from the newly calculated crc then you trigger the writing of the table.
The example @Viacheslav Mezentsev demonstrates this mechanic.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello ,
I Have Discovered Issue(not really but its not good too) In Old Code That,
IF Any one of the Variable is Changed
THEN writetable :=True
it means Every single time it will go and write value in table, I want to improve that in some better way.
If Any one Could suggest Anything it will be great.
Thank You
Please explain your purpose/problem a bit more, some more information on what you are trying to achieve would be welcome
hello Aliazzz,
I explain The problem here :
if at least one parameter changes, send parameters table to Database
IF( (
mParameter1 <> pParameter1 OR
mParameter2 <> pParameter2 OR
mParameter3 <> pParameter3 OR
mParameter4 <> pParameter4 OR
mParameter5 <> pParameter5 ))
THEN
writetable := TRUE;
END_IF
Thank You,
Hi,
one possibility would be to use a FOR loop and Arrays. Something like this:
Originally created by: Viacheslav Mezentsev
Struct + pointer + mem utils + crc.
I'd go with a crc approach as this is way more flexible with regards of your array/tablesize.
If the current crc (of your table) differs from the newly calculated crc then you trigger the writing of the table.
The example @Viacheslav Mezentsev demonstrates this mechanic.