diff --git a/fastFeedbackApp/src/framework/Commands.cc b/fastFeedbackApp/src/framework/Commands.cc index 045132f..55504fe 100644 --- a/fastFeedbackApp/src/framework/Commands.cc +++ b/fastFeedbackApp/src/framework/Commands.cc @@ -168,6 +168,14 @@ void IocshRegister::registerHelp() { command.second += " Turns STATE=OFF to all loops. This releases all Fcom\n"; command.second += " and ChannelAccess connections.\n"; helpMap->insert(command); + + command.first = "ffPatternGenMode"; + command.second = "Usage: ffPatternMode \n"; + command.second += " Sets the pattern generator mode.\n"; + command.second += " Mode:\n"; + command.second += " 0 - Disabled\n"; + command.second += " 1 - Enabled\n"; + helpMap->insert(command); } /** ffReboot ******************************************************************/ @@ -537,6 +545,19 @@ static void LoopShowEvents(const iocshArgBuf *args) { EventLogger::getInstance().dump(); } +/** ffPatternGenMode *************************************************************/ +static const iocshArg ffPatternGenMode_Arg0 = {"Mode (0-Disabled, 1-Enabled)", iocshArgInt}; +static const iocshArg * const ffPatternGenMode_Args[1] = {&ffPatternGenMode_Arg0}; +static const iocshFuncDef ffPatternGenMode_FuncDef = {"ffPatternGenMode", 1, ffPatternGenMode_Args}; + +static void ExecThreadSetPatternGenMode(const iocshArgBuf *args) { + + std::cout << "Setting Pattern Gen Mode to Specified\n"; + bool patternGenMode = args[0].ival; + + ExecThread::getInstance().setPatternGenMode(patternGenMode); +} + /** Register all commands */ IocshRegister::IocshRegister() { @@ -584,6 +605,8 @@ IocshRegister::IocshRegister() { iocshRegister(&ffShowDevices_FuncDef, LoopShowDevices); iocshRegister(&ffsd_FuncDef, LoopShowDevices); + + iocshRegister(&ffPatternGenMode_FuncDef, ExecThreadSetPatternGenMode); iocshRegister(&ffHelp_FuncDef, Help); } diff --git a/fastFeedbackApp/src/framework/ExecConfiguration.cc b/fastFeedbackApp/src/framework/ExecConfiguration.cc index b02b8e1..079a940 100644 --- a/fastFeedbackApp/src/framework/ExecConfiguration.cc +++ b/fastFeedbackApp/src/framework/ExecConfiguration.cc @@ -36,8 +36,8 @@ _s29AsumPv("S29_ASUM") { } else { Log::getInstance() << "ERROR: Failed to register algorithms." << Log::flush; } - - _hasPatternGenerator = false; + // Use Pattern Generator for now. + //_hasPatternGenerator = false; std::cout << ">> ExecConfiguration instance created." << std::endl; }; @@ -83,7 +83,7 @@ int ExecConfiguration::initialize() { // differences. // Use the pattern generator for now - _hasPatternGenerator = true; + //_hasPatternGenerator = true; return 0; } diff --git a/fastFeedbackApp/src/framework/ExecConfiguration.h b/fastFeedbackApp/src/framework/ExecConfiguration.h index 9dd37c2..115e930 100644 --- a/fastFeedbackApp/src/framework/ExecConfiguration.h +++ b/fastFeedbackApp/src/framework/ExecConfiguration.h @@ -43,7 +43,7 @@ class ExecConfiguration { static ExecConfiguration &getInstance(); int getLoopIndex(std::string loopName); int getSlotNames(std::vector &slotNames); - + //void setPatternGenMode(bool patternGenMode); /** * Map containing the feedback loop configurations, keyed by the * loop (slot) name @@ -93,7 +93,7 @@ class ExecConfiguration { PvData _s29AsumPv; /** Set to true if PatternGenerator is configured. Used for testing only. */ - bool _hasPatternGenerator; + //bool _hasPatternGenerator; }; FF_NAMESPACE_END diff --git a/fastFeedbackApp/src/framework/ExecThread.cc b/fastFeedbackApp/src/framework/ExecThread.cc index e60602c..c6610ee 100644 --- a/fastFeedbackApp/src/framework/ExecThread.cc +++ b/fastFeedbackApp/src/framework/ExecThread.cc @@ -113,7 +113,7 @@ int ExecThread::preRun() { // If the ExecConfiguration::_hasPatternGenerator is true, then start // Generating patterns -> This must be called here, after the ca_context // is created! - if (ExecConfiguration::getInstance()._hasPatternGenerator) { + if (_hasPatternGenerator) { std::cout << "--- Starting PatternGenerator ... "; PatternGenerator::getInstance().start(); std::cout << "done." << std::endl; @@ -212,7 +212,7 @@ int ExecThread::stop() { // If the ExecConfiguration::_hasPatternGenerator is true, then start // Generating patterns - if (ExecConfiguration::getInstance()._hasPatternGenerator) { + if (_hasPatternGenerator) { PatternGenerator::getInstance().stop(); } @@ -438,3 +438,19 @@ void ExecThread::showLoopConfig(std::string loopName) { std::cerr << "showLoopConfig command ERROR: " << e.what() << std::endl; } } + +/** + * This method sets the mode for the pattern generation. + * + * @param patternGenMode: + * 0 - Disabled + * 1 - Enabled + * @author K.Leleux + */ + +void ExecThread::setPatternGenMode(bool patternGenMode = false) { + //Set the _hasPatternGenMode + std::cout << "Setting Pattern Gen Mode\n"; + _hasPatternGenerator = patternGenMode; +} + diff --git a/fastFeedbackApp/src/framework/ExecThread.h b/fastFeedbackApp/src/framework/ExecThread.h index c76d934..037d6d9 100644 --- a/fastFeedbackApp/src/framework/ExecThread.h +++ b/fastFeedbackApp/src/framework/ExecThread.h @@ -76,6 +76,7 @@ class ExecThread : public Thread { int disconnectDevices(); static ExecThread &getInstance(); + void setPatternGenMode(bool patternGenMode); friend class ExecThreadTest; @@ -97,6 +98,8 @@ class ExecThread : public Thread { /** Flags that iocInit() can proceed -> used at statup time only */ bool _proceedWithIocInit; + + bool _hasPatternGenerator; }; FF_NAMESPACE_END