本文整理汇总了C++中Operation::createOperationPlan方法的典型用法代码示例。如果您正苦于以下问题:C++ Operation::createOperationPlan方法的具体用法?C++ Operation::createOperationPlan怎么用?C++ Operation::createOperationPlan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operation
的用法示例。
在下文中一共展示了Operation::createOperationPlan方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: location_tmp
//.........这里部分代码省略.........
PyErr_SetString(PythonDataException, "supplier argument must be of type supplier");
return NULL;
}
Item *item = static_cast<Item*>(item_tmp.getObject());
Location *location = static_cast<Location*>(location_tmp.getObject());
Supplier *supplier = pysupplier ? static_cast<Supplier*>(supplier_tmp.getObject()) : NULL;
// Find or create the destination buffer.
Buffer* destbuffer = NULL;
for (Buffer::iterator bufiter = Buffer::begin(); bufiter != Buffer::end(); ++bufiter)
{
if (bufiter->getLocation() == location && bufiter->getItem() == item)
{
if (destbuffer)
{
stringstream o;
o << "Multiple buffers found for item '" << item << "'' and location'" << location << "'";
throw DataException(o.str());
}
destbuffer = &*bufiter;
}
}
if (!destbuffer)
{
// Create the destination buffer
destbuffer = new BufferDefault();
stringstream o;
o << item << " @ " << location;
destbuffer->setName(o.str());
destbuffer->setItem(item);
destbuffer->setLocation(location);
}
// Look for a matching matching supplying operation on this buffer.
// Here we also trigger the creation of its producing operation, which
// contains the logic to build possible transfer operations.
Operation *oper = NULL;
Operation* prodOper = destbuffer->getProducingOperation();
if (prodOper && prodOper->getType() == *OperationItemSupplier::metadata)
{
if (supplier)
{
if (supplier->isMemberOf(static_cast<OperationItemSupplier*>(prodOper)->getItemSupplier()->getSupplier()))
oper = prodOper;
}
else
oper = prodOper;
}
else if (prodOper && prodOper->getType() == *OperationAlternate::metadata)
{
SubOperation::iterator soperiter = prodOper->getSubOperationIterator();
while (SubOperation *soper = soperiter.next())
{
if (soper->getType() == *OperationItemSupplier::metadata)
{
if (supplier)
{
if (supplier->isMemberOf(static_cast<OperationItemSupplier*>(prodOper)->getItemSupplier()->getSupplier()))
{
oper = soper->getOperation();
break;
}
}
else
{
oper = prodOper;
break;
}
}
}
}
// No matching operation is found.
if (!oper)
{
// We'll create one now, but that requires that we have a supplier defined.
if (!supplier)
throw DataException("Supplier is needed on this purchase order");
// Note: We know that we need to create a new one. An existing one would
// have created an operation on the buffer already.
ItemSupplier *itemsupplier = new ItemSupplier();
itemsupplier->setSupplier(supplier);
itemsupplier->setItem(item);
itemsupplier->setLocation(location);
oper = new OperationItemSupplier(itemsupplier, destbuffer);
new ProblemInvalidData(oper, "Purchase orders on unauthorized supplier", "operation",
Date::infinitePast, Date::infiniteFuture, 1);
}
// Finally, create the operationplan
OperationPlan *opplan = oper->createOperationPlan(qty, start, end);
if (status)
opplan->setStatus(status);
if (ref)
opplan->setReference(ref);
// Return result
Py_INCREF(opplan);
return opplan;
}
示例3: location_tmp
//.........这里部分代码省略.........
PyErr_SetString(PythonDataException, "location argument must be of type location");
return NULL;
}
PythonData item_tmp(pyitem);
if (!item_tmp.check(Item::metadata))
{
PyErr_SetString(PythonDataException, "item argument must be of type item");
return NULL;
}
PythonData supplier_tmp(pysupplier);
if (pysupplier && !supplier_tmp.check(Supplier::metadata))
{
PyErr_SetString(PythonDataException, "supplier argument must be of type supplier");
return NULL;
}
Item *item = static_cast<Item*>(item_tmp.getObject());
Location *location = static_cast<Location*>(location_tmp.getObject());
Supplier *supplier = pysupplier ? static_cast<Supplier*>(supplier_tmp.getObject()) : NULL;
// Find or create the destination buffer.
Buffer* destbuffer = NULL;
Item::bufferIterator buf_iter(item);
while (Buffer* tmpbuf = buf_iter.next())
{
if (tmpbuf->getLocation() == location)
{
if (destbuffer)
{
stringstream o;
o << "Multiple buffers found for item '" << item << "'' and location'" << location << "'";
throw DataException(o.str());
}
destbuffer = tmpbuf;
}
}
if (!destbuffer)
{
// Create the destination buffer
destbuffer = new BufferDefault();
stringstream o;
o << item << " @ " << location;
destbuffer->setName(o.str());
destbuffer->setItem(item);
destbuffer->setLocation(location);
}
// Build the producing operation for this buffer.
destbuffer->getProducingOperation();
// Look for a matching operation replenishing this buffer.
Operation *oper = NULL;
for (Buffer::flowlist::const_iterator flowiter = destbuffer->getFlows().begin();
flowiter != destbuffer->getFlows().end() && !oper; ++flowiter)
{
if (flowiter->getOperation()->getType() != *OperationItemSupplier::metadata)
continue;
OperationItemSupplier* opitemsupplier = static_cast<OperationItemSupplier*>(flowiter->getOperation());
if (supplier)
{
if (supplier->isMemberOf(opitemsupplier->getItemSupplier()->getSupplier()))
oper = opitemsupplier;
}
else
oper = opitemsupplier;
}
// No matching operation is found.
if (!oper)
{
// We'll create one now, but that requires that we have a supplier defined.
if (!supplier)
throw DataException("Supplier is needed on this purchase order");
// Note: We know that we need to create a new one. An existing one would
// have created an operation on the buffer already.
ItemSupplier *itemsupplier = new ItemSupplier();
itemsupplier->setSupplier(supplier);
itemsupplier->setItem(item);
itemsupplier->setLocation(location);
oper = new OperationItemSupplier(itemsupplier, destbuffer);
new ProblemInvalidData(oper, "Purchase orders on unauthorized supplier", "operation",
Date::infinitePast, Date::infiniteFuture, 1);
}
// Finally, create the operationplan
OperationPlan *opplan = oper->createOperationPlan(qty, start, end);
if (id)
opplan->setRawIdentifier(id); // We can use this fast method because we call activate later
if (status)
opplan->setStatus(status);
// Reset quantity after the status update to assure that
// also non-valid quantities are getting accepted.
opplan->setQuantity(qty);
if (ref)
opplan->setReference(ref);
opplan->activate();
// Return result
Py_INCREF(opplan);
return opplan;
}
示例4: dest_tmp
//.........这里部分代码省略.........
o << "Multiple buffers found for item '" << item << "'' and location'" << dest << "'";
throw DataException(o.str());
}
destbuffer = &*bufiter;
}
}
if (!destbuffer)
{
// Create the destination buffer
destbuffer = new BufferDefault();
stringstream o;
o << item << " @ " << dest;
destbuffer->setName(o.str());
destbuffer->setItem(item);
destbuffer->setLocation(dest);
}
// Build the producing operation for this buffer.
destbuffer->getProducingOperation();
// Look for a matching operation replenishing this buffer.
Operation *oper = NULL;
for (Buffer::flowlist::const_iterator flowiter = destbuffer->getFlows().begin();
flowiter != destbuffer->getFlows().end() && !oper; ++flowiter)
{
if (flowiter->getOperation()->getType() != *OperationItemDistribution::metadata
|| flowiter->getQuantity() <= 0)
continue;
OperationItemDistribution* opitemdist = static_cast<OperationItemDistribution*>(flowiter->getOperation());
if (origin)
{
// Origin must match as well
for (Operation::flowlist::const_iterator fl = opitemdist->getFlows().begin();
fl != opitemdist->getFlows().end(); ++ fl)
{
if (fl->getQuantity() < 0 && fl->getBuffer()->getLocation()->isMemberOf(origin))
oper = opitemdist;
}
}
else
oper = opitemdist;
}
// No matching operation is found.
if (!oper)
{
// We'll create one now, but that requires that we have an origin defined.
if (!origin)
throw DataException("Origin location is needed on this distribution order");
Buffer* originbuffer = NULL;
for (Buffer::iterator bufiter = Buffer::begin(); bufiter != Buffer::end(); ++bufiter)
{
if (bufiter->getLocation() == origin && bufiter->getItem() == item)
{
if (originbuffer)
{
stringstream o;
o << "Multiple buffers found for item '" << item << "'' and location'" << dest << "'";
throw DataException(o.str());
}
originbuffer = &*bufiter;
}
}
if (!originbuffer)
{
// Create the origin buffer
originbuffer = new BufferDefault();
stringstream o;
o << item << " @ " << origin;
originbuffer->setName(o.str());
originbuffer->setItem(item);
originbuffer->setLocation(origin);
}
// Note: We know that we need to create a new one. An existing one would
// have created an operation on the buffer already.
ItemDistribution *itemdist = new ItemDistribution();
itemdist->setOrigin(origin);
itemdist->setItem(item);
itemdist->setDestination(dest);
oper = new OperationItemDistribution(itemdist, originbuffer, destbuffer);
new ProblemInvalidData(oper, "Distribution orders on unauthorized lanes", "operation",
Date::infinitePast, Date::infiniteFuture, 1);
}
// Finally, create the operationplan
OperationPlan *opplan = oper->createOperationPlan(qty, start, end, NULL, NULL, 0, false);
if (id)
opplan->setIdentifier(id);
if (status)
opplan->setStatus(status);
if (ref)
opplan->setReference(ref);
if (!consume)
opplan->setConsumeMaterial(false);
opplan->activate();
// Return result
Py_INCREF(opplan);
return opplan;
}