void Place::print() { std::cout << "Place : " << this << std::endl; std::cout << "Outgoings Arcs : " << std::endl; arcList outGoingArcs = outGoingArcsOf(); for (unsigned int i = 0; i < outGoingArcs.size(); ++i) { std::cout << "To : " << outGoingArcs[i]->getTo() << std::endl; std::cout << "RelMin : " << outGoingArcs[i]->getRelativeMinValue().getValue() << std::endl; std::cout << "RelMax : " << outGoingArcs[i]->getRelativeMaxValue().getValue() << std::endl; std::cout << "AbsMin : " << outGoingArcs[i]->getAbsoluteMinValue().getValue() << std::endl; std::cout << "AbsMax : " << outGoingArcs[i]->getAbsoluteMaxValue().getValue() << std::endl; } std::cout << "Ingoings Arcs : " << std::endl; arcList inGoingArcs = inGoingArcsOf(); for (unsigned int i = 0; i < inGoingArcs.size(); ++i) { std::cout << "From : " << inGoingArcs[i]->getFrom() << std::endl; std::cout << "RelMin : " << inGoingArcs[i]->getRelativeMinValue().getValue() << std::endl; std::cout << "RelMax : " << inGoingArcs[i]->getRelativeMaxValue().getValue() << std::endl; std::cout << "AbsMin : " << inGoingArcs[i]->getAbsoluteMinValue().getValue() << std::endl; std::cout << "AbsMax : " << inGoingArcs[i]->getAbsoluteMaxValue().getValue() << std::endl; } }
void Place::produceTokens(unsigned int nbOfTokens, unsigned int colorLabel, int tokensTime) { unsigned int oldNumberOfTokens = getNbOfTokens(colorLabel); for (unsigned int i = 0; i < nbOfTokens; ++i) { Token token(tokensTime); m_tokenByColor[colorLabel - 1].push_back(token); } // if(tokensTime < 0){tokensTime = 0;} // CB incompatible with deactivation (tokenTime = -1) if ((oldNumberOfTokens < NB_OF_TOKEN_TO_ACTIVE_ARC) && (getNbOfTokens(colorLabel) >= NB_OF_TOKEN_TO_ACTIVE_ARC)) { // CB WTF : Si un token et deux arcs sortant, bug ? arcList outGoingArcs = outGoingArcsOf(colorLabel); for (unsigned int i = 0 ; i < outGoingArcs.size() ; ++i) { PetriNetArc* arc = outGoingArcs[i]; // if (!arc->getCondition()) { // CB check if the arc can be activated // continue; // } Transition* transitionTo = dynamic_cast<Transition*>(arc->getTo()); if (!transitionTo) { throw IncoherentStateException(); } transitionTo->setArcAsActive(arc, tokensTime, true); if (transitionTo->isStatic()) { if(arc->getRelativeMinValue().getValue() < (int) tokensTime) { getPetriNet()->pushTransitionToCrossWhenAcceleration(transitionTo); } } else { if(arc->getRelativeMaxValue().getValue() < (int) tokensTime) { getPetriNet()->pushTransitionToCrossWhenAcceleration(transitionTo); } } } } }
void Place::produceTokens(unsigned int nbOfTokens, unsigned int colorLabel, unsigned int tokensTime) { unsigned int oldNumberOfTokens = getNbOfTokens(colorLabel); for (unsigned int i = 0; i < nbOfTokens; ++i) { Token token; token.setRemainingTime(tokensTime); m_tokenByColor[colorLabel - 1].push_back(token); } if ((oldNumberOfTokens < NB_OF_TOKEN_TO_ACTIVE_ARC) && (getNbOfTokens(colorLabel) >= NB_OF_TOKEN_TO_ACTIVE_ARC)) { arcList outGoingArcs = outGoingArcsOf(colorLabel); for (unsigned int i = 0 ; i < outGoingArcs.size() ; ++i) { Arc* arc = outGoingArcs[i]; if (!(dynamic_cast<Transition*>(arc->getTo()))) { throw IncoherentStateException(); } Transition* transitionTo = ((Transition*) arc->getTo()); transitionTo->setArcAsActive(arc, tokensTime, true); if (transitionTo->isStatic()) { if(arc->getRelativeMinValue().getValue() < (int) tokensTime) { getPetriNet()->pushTransitionToCrossWhenAcceleration(transitionTo); } } else { if(arc->getRelativeMaxValue().getValue() < (int) tokensTime) { getPetriNet()->pushTransitionToCrossWhenAcceleration(transitionTo); } } } } }