SUMOTime
MSTriggeredReader::wrappedExecute(SUMOTime current) {
    if (!isInitialised()) {
        init();
    }
    SUMOTime next = current;
    // loop until the next action lies in the future
    while (current == next) {
        // run the next action
        //  if it could be accomplished...
        if (processNextEntryReaderTriggered()) {
            // read the next one
            if (readNextTriggered()) {
                // set the time for comparison if a next one exists
                next = myOffset;
            } else {
                // leave if no further exists
                return 0;
            }
        } else {
            // action could not be accomplished; try next time step
            return DELTA_T;
        }
    }
    // come back if the next action shall be executed
    if (myOffset - current <= 0) {
        // current is delayed;
        return DELTA_T;
    }
    return myOffset - current;
}
예제 #2
0
void FORTE_INSYS_OUTPUT::executeEvent(int pa_nEIID){
  switch(pa_nEIID){
    case scm_nEventINITID:

    	output = std::make_unique<OutputSetterControl>(factory->getOutputSetter());

    	if(output) {
    		setInitialised();

			SUCCESS() = output->isControlStatusOK();
			RESPONSE().fromString(output->getControlStatusMessage().c_str());
    	} else {
    		resetInitialised();

			SUCCESS() = false;
			RESPONSE().fromString("ERROR: initialisation failed");
		}

		sendOutputEvent(scm_nEventINITOID);
      break;
    case scm_nEventREQID:

    	if(!QI()) {
    		SUCCESS() = false;
    		RESPONSE().fromString("QI is false");

    		sendOutputEvent(scm_nEventCNFID);

    		return;
    	}

    	if(!isInitialised()) {
    		SUCCESS() = false;
    		RESPONSE().fromString("ERROR: Not initialised");
    		return;
    	}

    	std::string outputName;

    	outputName = OUTPUT().getValue();
    	output->setOutputName(outputName);

    	output->setOutputState(CHANGE().getValue());

    	SUCCESS() = output->isControlStatusOK();
    	RESPONSE().fromString(output->getControlStatusMessage().c_str());

		sendOutputEvent(scm_nEventCNFID);
  }
}
예제 #3
0
bool HypothesisClient::launch() {
	if (!isInitialised() && mHost) {
		//launch process TODO better handling of paths
		std::ostringstream s;
		s << mHost->getExecString()+" --headless --id " << getId() << " --connect " << HypothesisManager::getHost() << " --port " << HypothesisManager::getPort() << " > clientLog" <<  getId() << ".txt 2>&1 &";
		//s << "cd ~/development/workspace/hammerQt/; ./hammerQt --id " << getId() << " --connect " << HypothesisManager::getHost() << " --port " << HypothesisManager::getPort() << " > clientLog" <<  getId() << ".txt 2>&1 &";

		std::string command;
		if (mHost->getHost() == "localhost" || mHost->getHost() == "127.0.0.1") {
			command = s.str();
		} else {
			command = "ssh "+mHost->getHost()+" \"" + s.str() + "\"";
		}
		int status = system(command.c_str());
		if (status == 0) {
			LOG_INFO("Launched: "+command);
			return true;
		}
	}
	return false;
}
예제 #4
0
void FORTE_MRX_INFO_LED::executeEvent(int pa_nEIID){
  switch(pa_nEIID){
	case scm_nEventINITID:

		cliCommander = std::make_unique<CliCommanderControl>(factory->getCliCommander());

		if(cliCommander) {
			setInitialised();

			SUCCESS() = cliCommander->isControlStatusOK();
			RESPONSE().fromString(cliCommander->getControlStatusMessage().c_str());
		} else {
			resetInitialised();

			SUCCESS() = false;
			RESPONSE().fromString("ERROR: initialisation failed");
		}

		sendOutputEvent(scm_nEventINITOID);
	  break;
	case scm_nEventREQID:
		if(!QI()) {
			SUCCESS() = false;
			RESPONSE().fromString("QI is false");

			sendOutputEvent(scm_nEventCNFID);

			return;
		}

		if(!isInitialised()) {
    		SUCCESS() = false;
    		RESPONSE().fromString("ERROR: Not initialised");

    		sendOutputEvent(scm_nEventCNFID);

    		return;
		}

		const std::string mode(MODE().getValue());

		if(mode != "on" && mode != "off" && mode != "flash") {
			SUCCESS() = false;
			RESPONSE().fromString("ERROR: Invalid mode");

			sendOutputEvent(scm_nEventCNFID);

			return;
		}

		std::string cliCommand = "help.debug.info_led.info_led=";

		cliCommand.append(MODE().getValue());
		cliCommander->sendCliCommand(cliCommand);

		if(!cliCommander->isControlStatusOK()) {
			SUCCESS() = cliCommander->isControlStatusOK();
			RESPONSE().fromString(cliCommander->getControlStatusMessage().c_str());

			sendOutputEvent(scm_nEventCNFID);
			return;
		}

		cliCommand = "help.debug.info_led.submit";
		cliCommander->sendCliCommand(cliCommand);

		SUCCESS() = cliCommander->isControlStatusOK();
		RESPONSE().fromString(cliCommander->getControlStatusMessage().c_str());

		sendOutputEvent(scm_nEventCNFID);
	  break;
  }
}
예제 #5
0
파일: Core.cpp 프로젝트: p-hoffmann/madpac
int tarch::multicore::tbb::Core::getNumberOfThreads() const {
  assertion( isInitialised() );
  return _numberOfThreads;
}
예제 #6
0
bool HypothesisClient::isIdle() {
	//return (isInitialised() && mCurrentHypothesis == NULL) || (isInitialised() && !mCurrentHypothesis->isAwaitingPredictions(mId));
	return (isInitialised() && mIdle);
}