27 #define INVENTORY_OPERATION "Inventory of buffer '" + string(getName()) + "'"
30 #define PROCURE_OPERATION "Procure for buffer '" + string(getName()) + "'"
59 Object::createString<BufferDefault>,
true);
72 Object::createString<BufferInfinite>);
85 Object::createString<BufferProcure>);
125 fabs(f), Date::infinitePast, Date::infinitePast);
144 for (flowplanlist::const_iterator oo=flowplans.
begin();
145 oo!=flowplans.
end(); ++oo)
147 if (oo->getDate() > d)
151 tmp = oo->getOnhand();
170 double tmp(0.0), record(0.0);
172 for (flowplanlist::const_iterator oo=flowplans.
begin();
true; ++oo)
174 if (oo==flowplans.
end() || oo->getDate() > d)
186 if (min) {
if (tmp < record) record = tmp;}
187 else {
if (tmp > record) record = tmp;}
191 if (prev_Date > d2 || oo==flowplans.
end())
return record;
196 tmp = oo->getOnhand();
197 prev_Date = oo->getDate();
225 flowplanlist::const_iterator i = flowplans.
begin();
227 for (; i!=flowplans.
end() && i->getType()!=1 && !i->getDate(); ++i) ;
228 if (i!=flowplans.
end() && i->getType()==1)
247 i = flowplans.
begin();
252 for (; i!=flowplans.
end(); ++i)
295 else throw LogicException(
"Incorrect object type during read operation");
301 else throw LogicException(
"Incorrect object type during read operation");
319 throw LogicException(
"Incorrect object type during read operation");
321 "' has invalid type for use as buffer min calendar");
334 throw LogicException(
"Incorrect object type during read operation");
336 "' has invalid type for use as buffer max calendar");
343 else throw LogicException(
"Incorrect object type during read operation");
373 for (flowplanlist::iterator oo=flowplans.
begin(); oo!=flowplans.
end(); oo++)
374 if (oo->getType() == 3)
377 static_cast<flowplanlist::EventMinQuantity *
>(&*oo)->setMin(min_val);
381 flowplanlist::EventMinQuantity *newEvent =
382 new flowplanlist::EventMinQuantity(Date::infinitePast, min_val);
383 flowplans.
insert(newEvent);
390 if (min_cal == cal)
return;
396 for (flowplanlist::iterator oo=flowplans.
begin(); oo!=flowplans.
end(); )
397 if (oo->getType() == 3)
399 flowplans.
erase(&(*oo));
416 if (curMin != x.getValue())
419 flowplanlist::EventMinQuantity *newBucket =
420 new flowplanlist::EventMinQuantity(x.getDate(), curMin);
421 flowplans.
insert(newBucket);
443 for (flowplanlist::iterator oo=flowplans.
begin(); oo!=flowplans.
end(); oo++)
444 if (oo->getType() == 4)
447 static_cast<flowplanlist::EventMaxQuantity *
>(&*oo)->setMax(max_val);
451 flowplanlist::EventMaxQuantity *newEvent =
452 new flowplanlist::EventMaxQuantity(Date::infinitePast, max_val);
453 flowplans.
insert(newEvent);
460 if (max_cal == cal)
return;
466 for (flowplanlist::iterator oo=flowplans.
begin(); oo!=flowplans.
end(); )
467 if (oo->getType() == 4)
469 flowplans.
erase(&(*oo));
486 if (curMax != x.getValue())
489 flowplanlist::EventMaxQuantity *newBucket =
490 new flowplanlist::EventMaxQuantity(x.getDate(), curMax);
491 flowplans.
insert(newBucket);
520 if (invoper)
delete invoper;
529 Buffer::flowplanlist::const_iterator f = getFlowPlans().begin(curflowplan);
536 double endQty = f->getCumulativeConsumed();
537 double startQty = endQty + f->getQuantity();
538 if (f->getCumulativeProduced() <= startQty)
541 while (f!=getFlowPlans().end()
542 && f->getCumulativeProduced() <= startQty) ++f;
543 while (f!=getFlowPlans().end()
544 && ( (f->getQuantity()<=0 && f->getCumulativeProduced() < endQty)
545 || (f->getQuantity()>0
546 && f->getCumulativeProduced()-f->getQuantity() < endQty))
551 double newqty = f->getQuantity();
552 if (f->getCumulativeProduced()-f->getQuantity() < startQty)
553 newqty -= startQty - (f->getCumulativeProduced()-f->getQuantity());
554 if (f->getCumulativeProduced() > endQty)
555 newqty -= f->getCumulativeProduced() - endQty;
560 curfactor*newqty/f->getQuantity(),
569 while ( f!=getFlowPlans().end()
570 && ((f->getQuantity()<=0 && f->getCumulativeProduced() > endQty)
571 || (f->getQuantity()>0
572 && f->getCumulativeProduced()-f->getQuantity() > endQty))) --f;
573 while (f!=getFlowPlans().end() && f->getCumulativeProduced() > startQty)
577 double newqty = f->getQuantity();
578 if (f->getCumulativeProduced()-f->getQuantity() < startQty)
579 newqty -= startQty - (f->getCumulativeProduced()-f->getQuantity());
580 if (f->getCumulativeProduced() > endQty)
581 newqty -= f->getCumulativeProduced() - endQty;
586 curfactor*newqty/f->getQuantity(),
596 curqty*(peggedQty - endQty + startQty)/curflowplan->
getQuantity(),
609 double endQty = f->getCumulativeProduced();
610 double startQty = endQty - f->getQuantity();
611 if (f->getCumulativeConsumed() <= startQty)
614 while (f!=getFlowPlans().end()
615 && f->getCumulativeConsumed() <= startQty) ++f;
616 while (f!=getFlowPlans().end()
617 && ( (f->getQuantity()<=0
618 && f->getCumulativeConsumed()+f->getQuantity() < endQty)
619 || (f->getQuantity()>0 && f->getCumulativeConsumed() < endQty))
624 double newqty = - f->getQuantity();
625 if (f->getCumulativeConsumed()+f->getQuantity() < startQty)
626 newqty -= startQty - (f->getCumulativeConsumed()+f->getQuantity());
627 if (f->getCumulativeConsumed() > endQty)
628 newqty -= f->getCumulativeConsumed() - endQty;
633 -curfactor*newqty/f->getQuantity(),
642 while ( f!=getFlowPlans().end()
643 && ((f->getQuantity()<=0 && f->getCumulativeConsumed()+f->getQuantity() < endQty)
644 || (f->getQuantity()>0 && f->getCumulativeConsumed() < endQty))) --f;
645 while (f!=getFlowPlans().end() && f->getCumulativeConsumed() > startQty)
649 double newqty = - f->getQuantity();
650 if (f->getCumulativeConsumed()+f->getQuantity() < startQty)
651 newqty -= startQty - (f->getCumulativeConsumed()+f->getQuantity());
652 if (f->getCumulativeConsumed() > endQty)
653 newqty -= f->getCumulativeConsumed() - endQty;
658 -curfactor*newqty/f->getQuantity(),
664 if (peggedQty < endQty - startQty)
668 curqty*(endQty - startQty - peggedQty)/curflowplan->
getQuantity(),
767 new FlowEnd(o, const_cast<BufferProcure*>(
this), 1);
838 Buffer* y =
static_cast<Buffer*
>(
static_cast<PyObject*
>(field));
858 Item* y =
static_cast<Item*
>(
static_cast<PyObject*
>(field));