bool SpecificCore::commandMinimum(std::shared_ptr<SPICE::BIG::ICommandCallback> commandCallback) { // --- example: typical working cycle --- // start process here startProcess(); bool active = true; while(active) { // wait on end of process and check for interupts from the ServiceConsumer if(!processIsActive()) { active = false; } else if(commandCallback->hasToReset()) { return false; } else if(commandCallback->hasToAbort()) { return abortProcess(); } else if(commandCallback->hasToPause()) { pauseProcess(); commandCallback->enterPause(); continueProcess(); } else { std::this_thread::sleep_for(std::chrono::milliseconds(20)); } } // --- example: how to get a value from the parameters or configurations --- bool boolParameter = _resourceProvider->getParameterSet()->getFirstDataEntryByName("BoolParameter")->getValueAsString() == "true"; int intParameter = std::stoi(_resourceProvider->getParameterSet()->getFirstDataEntryByName("IntParameter")->getValueAsString()); unsigned int uintParameter = (unsigned int)std::stoul(_resourceProvider->getParameterSet()->getFirstDataEntryByName("UnsignedIntParameter")->getValueAsString()); // --- example: how to throw errors // -> fatal error { std::shared_ptr<SPICE::BIG::CommandError> error(new SPICE::BIG::CommandError("the error message", "EnterInError", "Enters the inError state. A SiLA-Reset is needed.", SPICE::BIG::ContinuationTask::TaskTypes::fatalError)); commandCallback->throwError(error); return false; } // -> error with selection, the given continuation task at the CommandError-constructor is the default continuation task { std::shared_ptr<SPICE::BIG::CommandError> error(new SPICE::BIG::CommandError("the error message", "EnterInError", "Enters the inError state. A SiLA-Reset is needed.", SPICE::BIG::ContinuationTask::TaskTypes::fatalError)); error->addContinuationTask("AbortAll", "Aborts this command and empty the command buffer", SPICE::BIG::ContinuationTask::TaskTypes::abortAllCommands); error->addContinuationTask("AbortThis", "Aborts / Ends this command", SPICE::BIG::ContinuationTask::TaskTypes::abortCurrentCommand); error->addContinuationTask("Retry", "Tries to continue the command", SPICE::BIG::ContinuationTask::TaskTypes::continueCommand); commandCallback->throwError(error); if(error->getSelectedTaskType() == SPICE::BIG::ContinuationTask::TaskTypes::continueCommand) { // do something to acknowledge the command and continue } else { // do something else, like things to abort return false; } } return true; }
void Process::pause(bool pause) { pauseProcess(pause); }