Re: [foxboro] HLBL Array Question
- From: "Jeremy Milum" <jmilum@xxxxxxxxx>
- To: foxboro@xxxxxxxxxxxxx
- Date: Thu, 15 May 2008 14:11:02 -0500
You don't have to sum the whole array each time, just keep that total
sum and add in the new value and subtract out the old one. you also
don;t need to shuffle the array if you keep an index pointing to the
current location. Here is an example of how I wrote a similar running
average seq code. (I cut some stuff out so this may not compile, but
you get the idea)
---
CONSTANTS
sample_interval = 60;
slots = 1440;
VARIABLES
sample_avg_arr : R[slots];
USER_LABELS
run : BI0001;
init : BI0002;
sample : RI0001;
slot : IO0001;
sample_avg : RO0001;
STATEMENTS
<<initialize>>
slot := 1;
sample_avg := sample;
sample_avg_arr := SET_ARRAY(sample);
<<loop>>
FOR slot := 1 TO slots DO
sample_avg := sample_avg + ((sample -
sample_avg_arr[slot])/slots);
sample_avg_arr[slot] := sample;
WAIT UNTIL (NOT run) OR init AFTER sample_interval GOTO
continue;
<<continue>>
IF (NOT run) OR init THEN
GOTO initialize;
ENDIF;
ENDFOR;
GOTO loop;
--
_______________________________________________________________________
This mailing list is neither sponsored nor endorsed by Invensys Process
Systems (formerly The Foxboro Company). Use the info you obtain here at
your own risks. Read http://www.thecassandraproject.org/disclaimer.html
foxboro mailing list: http://www.freelists.org/list/foxboro
to subscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
to unsubscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
- Follow-Ups:
- Re: [foxboro] HLBL Array Question
- From: Jeremy Milum
- References:
- [foxboro] HLBL Array Question
- From: Bruley, Peter T
- Re: [foxboro] HLBL Array Question
- From: Bruley, Peter T
Other related posts:
- » Re: [foxboro] HLBL Array Question
- » Re: [foxboro] HLBL Array Question
- » Re: [foxboro] HLBL Array Question
- » Re: [foxboro] HLBL Array Question
- » Re: [foxboro] HLBL Array Question
- » Re: [foxboro] HLBL Array Question
- » Re: [foxboro] HLBL Array Question
- » Re: [foxboro] HLBL Array Question
- » Re: [foxboro] HLBL Array Question
- » Re: [foxboro] HLBL Array Question
- Re: [foxboro] HLBL Array Question
- From: Jeremy Milum
- [foxboro] HLBL Array Question
- From: Bruley, Peter T
- Re: [foxboro] HLBL Array Question
- From: Bruley, Peter T