本文整理汇总了C++中Flow::setQuantity方法的典型用法代码示例。如果您正苦于以下问题:C++ Flow::setQuantity方法的具体用法?C++ Flow::setQuantity怎么用?C++ Flow::setQuantity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flow
的用法示例。
在下文中一共展示了Flow::setQuantity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setOnHand
DECLARE_EXPORT void Buffer::setOnHand(double f)
{
// The dummy operation to model the inventory may need to be created
Operation *o = Operation::find(INVENTORY_OPERATION);
Flow *fl;
if (!o)
{
// Create a fixed time operation with zero leadtime, hidden from the xml
// output, hidden for the solver, and without problem detection.
o = new OperationFixedTime();
o->setName(INVENTORY_OPERATION);
o->setHidden(true);
o->setDetectProblems(false);
fl = new FlowEnd(o, this, 1);
}
else
// Find the flow of this operation
fl = const_cast<Flow*>(&*(o->getFlows().begin()));
// Check valid pointers
if (!fl || !o)
throw LogicException("Failed creating inventory operation for '"
+ getName() + "'");
// Make sure the sign of the flow is correct: +1 or -1.
fl->setQuantity(f>=0.0 ? 1.0 : -1.0);
// Create a dummy operationplan on the inventory operation
OperationPlan::iterator i(o);
if (i == OperationPlan::end())
{
// No operationplan exists yet
OperationPlan *opplan = o->createOperationPlan(
fabs(f), Date::infinitePast, Date::infinitePast);
opplan->setLocked(true);
opplan->activate();
}
else
{
// Update the existing operationplan
i->setLocked(false);
i->setQuantity(fabs(f));
i->setLocked(true);
}
setChanged();
}