Re: [foxboro] HLBL Array Question
- From: "Johnson, Alex P \(IPS\)" <alex.johnson@xxxxxxxxxxxxxxxx>
- To: <foxboro@xxxxxxxxxxxxx>
- Date: Thu, 15 May 2008 15:08:59 -0400
Peter,
Don't move the data. Change a variable that tells you where to insert
the next value instead.
Consider this array:
[1]
[2]
[3]
NF=3D1
With a next free spot (NF) index set to 1 initially.
First sample goes into NF, increment NF. So, we have:
[1] is 'a'
[2]
[3]
NF=3D2
Get next sample
[1] is 'a'
[2] is 'b'
[3]
NF=3D3
Get next sample
[1] is 'a'
[2] is 'b'
[3] is 'c'
NF=3D1
Now that we've reached the end of the array, NF wraps around to 1.
Get next sample
[1] is 'd'
[2] is 'b'
[3] is 'c'
NF=3D2
And so on.
Make sense? You increment NF until it hits the limit and wrap it to the
beginning.
In some situations, you also want a Next To Use pointer, but that's a
different lesson.
Regards,
=
Alex Johnson
Invensys Process Systems
10900 Equity Drive
Houston, TX 77041
713 329 8472 (voice)
713 329 1600 (switchboard)
713 329 1944 (fax)
alex.johnson@xxxxxxxxxxxxxxxx
http://ips.invensys.com =
-----Original Message-----
From: foxboro-bounce@xxxxxxxxxxxxx [mailto:foxboro-bounce@xxxxxxxxxxxxx]
On Behalf Of Bruley, Peter T
Sent: Thursday, May 15, 2008 1:46 PM
To: 'Foxboro DCS Mail List' ('Foxboro DCS Mail List')
Subject: [foxboro] HLBL Array Question
Gentlemen (and Ladies)
I have a large array size is 1440 (holds 24 hours worth of 1 min
sa=3D
mples)
Every minute I want to update the 1 of the sample value and
throw o=3D
ut the oldest value.
Problem 1)
Currently I am shuffling each value 1 at a time using this loop:
----------------------------
x :=3D3D 1;
SN01 :=3D3D "Preparing Array for new value ....";
WHILE (x < 1440) DO
ARHR[x] :=3D3D ARHR[x+1]; {* throw out arry position 1 and shuffle
*}
x :=3D3D x + 1;
ENDWHILE;
ARHR[1440] :=3D3D RI01; {* Load newest value into array position
14=3D
40 *}
------------------------------
This works however just to shuffle the values takes almost 30
secon=3D
ds.
Is there a quicker way to do this ?
Is there a way to copy array position [2] through [1440] to
another a=3D
rray using a single command ?
Problem 2)
During the next step of my sequence I have to find the average
for =3D
the last 24 hours so I need to find the sum of the array then divide by
144=3D
0. I use the following loop to find the sum:
----------------------------
y :=3D3D 1;
SUM :=3D3D 0;
WHILE ( y < 1441 ) DO
SUM :=3D3D SUM + ARHR[ y ];
y :=3D3D y + 1;
ENDWHILE;
RO01 :=3D3D 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=3Djoin
to unsubscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=3Dleave
=
* Confidentiality Notice:
This e-mail and any associated files are intended solely for the individual=
or entity to whom they are addressed. Please do not copy it or use it for =
any purposes, or disclose its contents to any other person. Further, this e=
-mail and any associated files may be confidential and further may be legal=
ly privileged. This email is from the Invensys Process Systems business uni=
t of Invensys plc which is a company registered in England and Wales with i=
ts registered office at Portland House, Bressenden Place, London, SW1E 5BF =
(Registered number 166023). For a list of European legal entities within t=
he Invensys Process Systems business group, please click here http://www.in=
vensys.com/legal/default.asp?top_nav_id=3D77&nav_id=3D80&prev_id=3D77.
If you have received this e-mail in error, you are on notice of its status.=
Please notify us immediately by reply e-mail and then delete this message =
from your system. Thank you for your co-operation. You may contact our Help=
desk on +44 (0)20 7821 3859 / 2105 or email inet.hqhelpdesk@xxxxxxxxxxxxx T=
his e-mail and any attachments thereto may be subject to the terms of any a=
greements between Invensys (and/or its subsidiaries and affiliates) and the=
recipient (and/or its subsidiaries and affiliates).
_______________________________________________________________________
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