* @brief Returns true if the given agent has reached the end of its run **************************************************************************/
| 222 | * @brief Returns true if the given agent has reached the end of its run |
| 223 | **************************************************************************/ |
| 224 | bool RunScheduler::IsAgentFinished(AgentSML* pAgentSML, bool forever, smlRunStepSize runStepSize, uint64_t count) |
| 225 | { |
| 226 | uint64_t current = pAgentSML->GetRunCounter(runStepSize) ; |
| 227 | uint64_t initial = pAgentSML->GetInitialRunCount() ; |
| 228 | |
| 229 | uint64_t difference = current - initial ; |
| 230 | |
| 231 | //fprintf(stdout, "Agent %s current is %d initial is %d diff is %d\n", pAgent->GetName(), current, initial, difference) ; fflush(stdout) ; |
| 232 | |
| 233 | bool finished = (difference >= count) && !forever; |
| 234 | |
| 235 | |
| 236 | // if a sml_STOP_AFTER_DECISION_CYCLE is requested, then |
| 237 | // agents that are running by Decisions should get marked as finished. |
| 238 | // They will generate interrupt in MoveTo_StopBeforePhase |
| 239 | |
| 240 | if (((sml_DECISION == runStepSize) || forever) && (pAgentSML->GetInterruptFlags() & sml_STOP_AFTER_DECISION_CYCLE)) |
| 241 | { |
| 242 | finished = true; |
| 243 | } |
| 244 | |
| 245 | // The code that runs an agent to its appropriate StopBeforePhase only runs |
| 246 | // after all agents Finish the run. See MoveTo_StopBeforePhase. KJC 12/05 |
| 247 | |
| 248 | return finished ; |
| 249 | } |
| 250 | |
| 251 | /******************************************************************** |
| 252 | * @brief Some agents will complete a RunType sooner than others. |
nothing calls this directly
no test coverage detected