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();
218 HasDescription::writeElement(o, tag);
226 flowplanlist::const_iterator i = flowplans.
begin();
228 for (; i!=flowplans.
end() && i->getType()!=1 && !i->getDate(); ++i) ;
229 if (i!=flowplans.
end() && i->getType()==1)
248 i = flowplans.
begin();
253 for (; i!=flowplans.
end(); ++i)
307 else throw LogicException(
"Incorrect object type during read operation");
313 else throw LogicException(
"Incorrect object type during read operation");
331 throw LogicException(
"Incorrect object type during read operation");
333 "' has invalid type for use as buffer min calendar");
346 throw LogicException(
"Incorrect object type during read operation");
348 "' has invalid type for use as buffer max calendar");
355 else throw LogicException(
"Incorrect object type during read operation");
362 HasDescription::endElement(pIn, pAttr, pElement);
385 for (flowplanlist::iterator oo=flowplans.
begin(); oo!=flowplans.
end(); oo++)
386 if (oo->getType() == 3)
389 static_cast<flowplanlist::EventMinQuantity *
>(&*oo)->setMin(min_val);
393 flowplanlist::EventMinQuantity *newEvent =
394 new flowplanlist::EventMinQuantity(Date::infinitePast, min_val);
395 flowplans.
insert(newEvent);
402 if (min_cal == cal)
return;
408 for (flowplanlist::iterator oo=flowplans.
begin(); oo!=flowplans.
end(); )
409 if (oo->getType() == 3)
411 flowplans.
erase(&(*oo));
428 if (curMin != x.getValue())
431 flowplanlist::EventMinQuantity *newBucket =
432 new flowplanlist::EventMinQuantity(x.getDate(), curMin);
433 flowplans.
insert(newBucket);
455 for (flowplanlist::iterator oo=flowplans.
begin(); oo!=flowplans.
end(); oo++)
456 if (oo->getType() == 4)
459 static_cast<flowplanlist::EventMaxQuantity *
>(&*oo)->setMax(max_val);
463 flowplanlist::EventMaxQuantity *newEvent =
464 new flowplanlist::EventMaxQuantity(Date::infinitePast, max_val);
465 flowplans.
insert(newEvent);
472 if (max_cal == cal)
return;
478 for (flowplanlist::iterator oo=flowplans.
begin(); oo!=flowplans.
end(); )
479 if (oo->getType() == 4)
481 flowplans.
erase(&(*oo));
498 if (curMax != x.getValue())
501 flowplanlist::EventMaxQuantity *newBucket =
502 new flowplanlist::EventMaxQuantity(x.getDate(), curMax);
503 flowplans.
insert(newBucket);
532 if (invoper)
delete invoper;
541 Buffer::flowplanlist::const_iterator f = getFlowPlans().begin(curflowplan);
548 double endQty = f->getCumulativeConsumed();
549 double startQty = endQty + f->getQuantity();
550 if (f->getCumulativeProduced() <= startQty)
553 while (f!=getFlowPlans().end()
554 && f->getCumulativeProduced() <= startQty) ++f;
555 while (f!=getFlowPlans().end()
556 && ( (f->getQuantity()<=0 && f->getCumulativeProduced() < endQty)
557 || (f->getQuantity()>0
558 && f->getCumulativeProduced()-f->getQuantity() < endQty))
563 double newqty = f->getQuantity();
564 if (f->getCumulativeProduced()-f->getQuantity() < startQty)
565 newqty -= startQty - (f->getCumulativeProduced()-f->getQuantity());
566 if (f->getCumulativeProduced() > endQty)
567 newqty -= f->getCumulativeProduced() - endQty;
572 curfactor*newqty/f->getQuantity(),
581 while ( f!=getFlowPlans().end()
582 && ((f->getQuantity()<=0 && f->getCumulativeProduced() > endQty)
583 || (f->getQuantity()>0
584 && f->getCumulativeProduced()-f->getQuantity() > endQty))) --f;
585 while (f!=getFlowPlans().end() && f->getCumulativeProduced() > startQty)
589 double newqty = f->getQuantity();
590 if (f->getCumulativeProduced()-f->getQuantity() < startQty)
591 newqty -= startQty - (f->getCumulativeProduced()-f->getQuantity());
592 if (f->getCumulativeProduced() > endQty)
593 newqty -= f->getCumulativeProduced() - endQty;
598 curfactor*newqty/f->getQuantity(),
608 curqty*(peggedQty - endQty + startQty)/curflowplan->
getQuantity(),
621 double endQty = f->getCumulativeProduced();
622 double startQty = endQty - f->getQuantity();
623 if (f->getCumulativeConsumed() <= startQty)
626 while (f!=getFlowPlans().end()
627 && f->getCumulativeConsumed() <= startQty) ++f;
628 while (f!=getFlowPlans().end()
629 && ( (f->getQuantity()<=0
630 && f->getCumulativeConsumed()+f->getQuantity() < endQty)
631 || (f->getQuantity()>0 && f->getCumulativeConsumed() < endQty))
636 double newqty = - f->getQuantity();
637 if (f->getCumulativeConsumed()+f->getQuantity() < startQty)
638 newqty -= startQty - (f->getCumulativeConsumed()+f->getQuantity());
639 if (f->getCumulativeConsumed() > endQty)
640 newqty -= f->getCumulativeConsumed() - endQty;
645 -curfactor*newqty/f->getQuantity(),
654 while ( f!=getFlowPlans().end()
655 && ((f->getQuantity()<=0 && f->getCumulativeConsumed()+f->getQuantity() < endQty)
656 || (f->getQuantity()>0 && f->getCumulativeConsumed() < endQty))) --f;
657 while (f!=getFlowPlans().end() && f->getCumulativeConsumed() > startQty)
661 double newqty = - f->getQuantity();
662 if (f->getCumulativeConsumed()+f->getQuantity() < startQty)
663 newqty -= startQty - (f->getCumulativeConsumed()+f->getQuantity());
664 if (f->getCumulativeConsumed() > endQty)
665 newqty -= f->getCumulativeConsumed() - endQty;
670 -curfactor*newqty/f->getQuantity(),
676 if (peggedQty < endQty - startQty)
680 curqty*(endQty - startQty - peggedQty)/curflowplan->
getQuantity(),
782 new FlowEnd(o, const_cast<BufferProcure*>(
this), 1);
853 Buffer* y =
static_cast<Buffer*
>(
static_cast<PyObject*
>(field));
873 Item* y =
static_cast<Item*
>(
static_cast<PyObject*
>(field));