Re: [foxboro] HLBL Array Question
- From: Mike.Spigel@xxxxxxxxxxxx
- To: foxboro@xxxxxxxxxxxxx
- Date: Thu, 15 May 2008 15:16:45 -0400
Peter:
Use a Circular Queue / Circular Array / Circular Buffer.
A good place to start:
http://en.wikipedia.org/wiki/Circular_buffer
-Mike
foxboro-bounce@xxxxxxxxxxxxx wrote on 05/15/2008 02:45:41 PM:
> Gentlemen (and Ladies)
>
> I have a large array size is 1440 (holds 24 hours worth of 1 min
sa=
> mples)
>
> Every minute I want to update the 1 of the sample value and
throw o=
> ut the oldest value.
>
> Problem 1)
>
> Currently I am shuffling each value 1 at a time using this loop:
> ----------------------------
> x :=3D 1;
> SN01 :=3D "Preparing Array for new value ....";
> WHILE (x < 1440) DO
> ARHR[x] :=3D ARHR[x+1]; {* throw out arry position 1 and shuffle
*}
> x :=3D x + 1;
> ENDWHILE;
> ARHR[1440] :=3D RI01; {* Load newest value into array position
14=
> 40 *}
> ------------------------------
>
>
> This works however just to shuffle the values takes almost 30
secon=
> ds.
>
> Is there a quicker way to do this ?
> Is there a way to copy array position [2] through [1440] to
another a=
> rray using a single command ?
>
> Problem 2)
>
> During the next step of my sequence I have to find the average
for =
> the last 24 hours so I need to find the sum of the array then divide by
144=
> 0. I use the following loop to find the sum:
>
> ----------------------------
> y :=3D 1;
> SUM :=3D 0;
> WHILE ( y < 1441 ) DO
> SUM :=3D SUM + ARHR[ y ];
> y :=3D y + 1;
> ENDWHILE;
> RO01 :=3D SUM/1440; {* 24 Hour rolling average *}
> ----------------------------
>
> Again it takes about 30 seconds just to find the sum of the
array.
>
> Is there a quicker way to find the sum of an array?
>
>
> Thank You,
>
> Peter Bruley
>
>
>
>
>
> _______________________________________________________________________
> 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
>
_______________________________________________________________________
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
- References:
- [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
- [foxboro] HLBL Array Question
- From: Bruley, Peter T