Re: Optimizing sorts.
I can see the advantage of this but, wouldn't it complicate the file management aspect? I'm thinking I'd need ways to insert to the list; keep track of the quantity on the list; (randomly) delete items when their time is up. Probably other stuff I haven't thought of.
A chute CAN be activated each encoder count. Is this the same thing?Peter Nachtwey said:If a chute is activated each encoder count then maybe it can't.
How will I know when a chute is to be activated if I don't index through the file?Peter Nachtwey said:However, one should only need to index through the array each time a chute is activate. If this is only once in about 10 counts then then indexing can be reduce by 90%.
In my perception of this, each encoder pulse is an event. There are usually one but sometimes two pulses accumulated per scan (via STI program). I looked at using zero, or, preferably the sign bit as the trip signal but I can't discover why the original programmer used 0 <= count <= 8 as the criteria. Figuring there must be a reason I left it alone. One point I neglected to mention is that the original code went through the file (list) every scan, when I put in the condition 'is counts greater than zero?' scan time dropped significantly.Peter Nachtwey said:For starters, keep only one minimum count for all carriers that represent the number of counts till the next event. When this minimum count reaches 0 then subtract the original value of the minimum count from each carrier. Now all carriers that have their count reduced to 0 should have their chute activate.
What must be estimated is before implementing this procedure is how often will the minimum count be decrement to 0. If it happen almost every encoder count then your method works well and can't be improved. It the typical value of the minimum count is 10 then you can reduce the indexing through the arrays by a factor of ten.
The original program used a variation of this. Carriers needing tripped on any given scan were moved to a hand built stack and tripped all on one scan. It may be a good theory but the implementation left something to be desired!Peter Nachtwey said:Now all carriers that have their count reduced to 0 should have their chute activate.
To me, 'large periods of time between items being inserted on the list' equates with 'not much being put on the sorter'. It's very variable - on one revolution there may be only twenty or thirty items. On another there may be upwards of three hundred fifty. Quite a bit considering there are four hundred thirty-six carriers.Peter Nachtwey said:
I use doubly linked lists which is very efficient when there many items on the list like in your application. Each item is insterted into the list in the order in which it will be executed. This way only the first item at the beginning of list needs to be checked. This works well when there are large periods of time between items being inserted on the list.
I can see the advantage of this but, wouldn't it complicate the file management aspect? I'm thinking I'd need ways to insert to the list; keep track of the quantity on the list; (randomly) delete items when their time is up. Probably other stuff I haven't thought of.