|
39 | 39 | #include "Framework/DataProcessorInfo.h" |
40 | 40 | #include "Framework/DriverInfo.h" |
41 | 41 | #include "Framework/DriverControl.h" |
| 42 | +#include "ControlServiceHelpers.h" |
42 | 43 |
|
43 | 44 | #include "ComputingResourceHelpers.h" |
44 | 45 | #include "DataProcessingStatus.h" |
@@ -578,35 +579,6 @@ struct LogProcessingState { |
578 | 579 | bool hasNewMetric = false; |
579 | 580 | }; |
580 | 581 |
|
581 | | -void processCommand(DeviceInfos& infos, pid_t pid, std::string const& command, std::string const& arg) |
582 | | -{ |
583 | | - auto doToMatchingPid = [](std::vector<DeviceInfo>& infos, pid_t pid, auto lambda) { |
584 | | - for (auto& deviceInfo : infos) { |
585 | | - if (deviceInfo.pid == pid) { |
586 | | - lambda(deviceInfo); |
587 | | - break; |
588 | | - } |
589 | | - } |
590 | | - }; |
591 | | - LOGP(debug, "Found control command {} from pid {} with argument {}.", command, pid, arg); |
592 | | - if (command == "QUIT" && arg == "ALL") { |
593 | | - for (auto& deviceInfo : infos) { |
594 | | - deviceInfo.readyToQuit = true; |
595 | | - } |
596 | | - } else if (command == "QUIT" && arg == "ME") { |
597 | | - doToMatchingPid(infos, pid, [](DeviceInfo& info) { info.readyToQuit = true; }); |
598 | | - } else if (command == "NOTIFY_STREAMING_STATE" && arg == "IDLE") { |
599 | | - // FIXME: this should really be a policy... |
600 | | - doToMatchingPid(infos, pid, [](DeviceInfo& info) { info.readyToQuit = true; info.streamingState = StreamingState::Idle; }); |
601 | | - } else if (command == "NOTIFY_STREAMING_STATE" && arg == "STREAMING") { |
602 | | - // FIXME: this should really be a policy... |
603 | | - doToMatchingPid(infos, pid, [](DeviceInfo& info) { info.streamingState = StreamingState::Streaming; }); |
604 | | - } else if (command == "NOTIFY_STREAMING_STATE" && arg == "EOS") { |
605 | | - // FIXME: this should really be a policy... |
606 | | - doToMatchingPid(infos, pid, [](DeviceInfo& info) { info.streamingState = StreamingState::EndOfStreaming; }); |
607 | | - } |
608 | | -}; |
609 | | - |
610 | 582 | LogProcessingState processChildrenOutput(DriverInfo& driverInfo, |
611 | 583 | DeviceInfos& infos, |
612 | 584 | DeviceSpecs const& specs, |
@@ -671,8 +643,8 @@ LogProcessingState processChildrenOutput(DriverInfo& driverInfo, |
671 | 643 | // the DataRelayer view. |
672 | 644 | DeviceMetricsHelper::processMetric(metricMatch, metrics, newMetricCallback); |
673 | 645 | result.didProcessMetric = true; |
674 | | - } else if (logLevel == LogParsingHelpers::LogLevel::Info && parseControl(token, match)) { |
675 | | - processCommand(infos, info.pid, match[1].str(), match[2].str()); |
| 646 | + } else if (logLevel == LogParsingHelpers::LogLevel::Info && ControlServiceHelpers::parseControl(token, match)) { |
| 647 | + ControlServiceHelpers::processCommand(infos, info.pid, match[1].str(), match[2].str()); |
676 | 648 | result.didProcessControl = true; |
677 | 649 | } else if (logLevel == LogParsingHelpers::LogLevel::Info && DeviceConfigHelper::parseConfig(token, configMatch)) { |
678 | 650 | DeviceConfigHelper::processConfig(configMatch, info); |
|
0 commit comments