28 #include <SimoxUtility/json.h>
43 if (not m_configs_json.empty())
45 std::map<std::string, imrec::Config> configs = nlohmann::json::parse(m_configs_json);
74 const std::map<std::string, imrec::Config>& configs,
77 std::unique_lock l{m_configs_mx};
79 if (not configs.empty())
92 const std::string& configs_json,
93 const Ice::Current&
c)
95 const std::map<std::string, imrec::Config>& configs = nlohmann::json::parse(configs_json);
96 configureRecordings(configs,
c);
100 std::map<std::string, visionx::imrec::Config>
103 std::shared_lock l{m_configs_mx};
105 if (not m_configs.has_value())
110 return m_configs.value();
117 std::shared_lock l{m_configs_mx};
118 return m_configs.has_value();
122 std::map<std::string, visionx::imrecman::StartStopStatus>
128 std::shared_lock l{m_configs_mx};
130 std::map<std::string, visionx::imrecman::StartStopStatus> statuses;
132 if (not m_configs.has_value())
137 for (
auto [proxy_name, config] : m_configs.value())
142 ARMARX_DEBUG <<
"Calling startRecording on image provider '" << proxy_name <<
"'.";
143 const bool call_status =
144 getProxy<RecordingImageProviderInterfacePrx>(proxy_name)->startImageRecording(config);
150 ARMARX_DEBUG <<
"Image provider '" << proxy_name <<
"' offline.";
153 statuses[proxy_name] =
status;
162 std::map<std::string, visionx::imrec::Status>
168 std::shared_lock l{m_configs_mx};
170 std::map<std::string, visionx::imrec::Status> statuses;
172 if (not m_configs.has_value())
177 for (
auto& [proxy_name, config] : m_configs.value())
182 ARMARX_DEBUG <<
"Calling getRecordingStatus on image provider '" << proxy_name <<
"'.";
183 status = getProxy<RecordingImageProviderInterfacePrx>(proxy_name)->getImageRecordingStatus();
188 ARMARX_DEBUG <<
"Image provider '" << proxy_name <<
"' offline.";
190 status.framesBuffered = -1;
191 status.framesWritten = -1;
193 statuses[proxy_name] =
status;
202 std::map<std::string, visionx::imrecman::StartStopStatus>
208 std::shared_lock l{m_configs_mx};
210 std::map<std::string, visionx::imrecman::StartStopStatus> statuses;
212 if (not m_configs.has_value())
217 std::map<std::string, Ice::AsyncResultPtr> promises;
219 for (
auto& [proxy_name, config] : m_configs.value())
223 ARMARX_DEBUG <<
"Calling stopRecording on image provider '" << proxy_name <<
"'.";
224 promises[proxy_name] = getProxy<RecordingImageProviderInterfacePrx>(proxy_name)->begin_stopImageRecording();
228 promises[proxy_name] =
nullptr;
232 for (
auto& [proxy_name, promise] : promises)
239 const bool call_status = getProxy<RecordingImageProviderInterfacePrx>(proxy_name)->end_stopImageRecording(promise);
245 ARMARX_DEBUG <<
"Image provider '" << proxy_name <<
"' offline.";
251 ARMARX_DEBUG <<
"Image provider '" << proxy_name <<
"' offline.";
254 statuses[proxy_name] =
status;
266 return "ImageRecordingManager";
273 return GetDefaultName();
283 defs->optional(m_configs_json,
"config_json",
"JSON to initialize default config from.");