@@ -208,7 +208,7 @@ bool FlexCell::update()
208208 if (m_bendAnimation > 0 )
209209 {
210210 vrmlNode->bendAnimation (m_bendAnimation);
211- m_bendAnimation = - 1 ;
211+ m_bendAnimation = 0 ;
212212 }
213213 }
214214 else if (m_isReplaying)
@@ -231,26 +231,33 @@ bool FlexCell::update()
231231
232232void FlexCell::initSSE ()
233233{
234- m_hostname = new opencover::ui::EditFieldConfigValue (m_menu," SSEHost" , " localhost" , *config (), " " , config::Flag::PerModel);
235- m_port = new opencover::ui::EditFieldConfigValue (m_menu," SSEPort" , " 8000" , *config (), " " , config::Flag::PerModel);
236- m_url = new opencover::ui::EditFieldConfigValue (m_menu," SSEEndpoint" , " /ext/services/trumpf_flowstate_rabbitmq_sse_adapter/events" , *config (), " " , config::Flag::PerModel);
234+ if (!m_hostname)
235+ {
236+ m_hostname = new opencover::ui::EditFieldConfigValue (m_menu," SSEHost" , " localhost" , *config (), " " , config::Flag::PerModel);
237+ m_port = new opencover::ui::EditFieldConfigValue (m_menu," SSEPort" , " 8000" , *config (), " " , config::Flag::PerModel);
238+ m_url = new opencover::ui::EditFieldConfigValue (m_menu," SSEEndpoint" , " /ext/services/trumpf_flowstate_rabbitmq_sse_adapter/events" , *config (), " " , config::Flag::PerModel);
239+ m_url->setUpdater ([this ]() {
240+ // Restart SSE connection on URL change
241+ shutdownSSE ();
242+ initSSE ();
243+ config ()->save ();
244+
245+ });
246+ m_port->setUpdater ([this ]() {
247+ // Restart SSE connection on port change
248+ shutdownSSE ();
249+ initSSE ();
250+ config ()->save ();
251+
252+ });
253+ m_hostname->setUpdater ([this ]() {
254+ // Restart SSE connection on hostname change
255+ shutdownSSE ();
256+ initSSE ();
257+ config ()->save ();
258+ });
259+ }
237260
238- m_url->setUpdater ([this ]() {
239- // Restart SSE connection on URL change
240- shutdownSSE ();
241- initSSE ();
242- });
243- m_port->setUpdater ([this ]() {
244- // Restart SSE connection on port change
245- shutdownSSE ();
246- initSSE ();
247- });
248- m_hostname->setUpdater ([this ]() {
249- // Restart SSE connection on hostname change
250- shutdownSSE ();
251- initSSE ();
252- });
253- config ()->save ();
254261 // Read SSE endpoint from environment variable
255262 const char * endpoint = std::getenv (" SSE_ENDPOINT" );
256263 m_endpointUrl = endpoint ? endpoint : " http://" + m_hostname->getValue () + " :" + m_port->getValue () + m_url->getValue ();
@@ -319,6 +326,7 @@ size_t FlexCell::sseWriteCallback(char* ptr, size_t size, size_t nmemb, void* us
319326 {
320327 try
321328 {
329+ std::lock_guard<std::mutex> lock (self->m_rabbitMutex );
322330 json j = json::parse (data);
323331
324332 RobotPosition pos;
@@ -335,7 +343,9 @@ size_t FlexCell::sseWriteCallback(char* ptr, size_t size, size_t nmemb, void* us
335343 }
336344 if (j.contains (" bendAnimation" ) && j[" bendAnimation" ].is_number_integer ())
337345 {
338- self->m_bendAnimation = j[" bendAnimation" ].get <int >();
346+ auto anim = j[" bendAnimation" ].get <int >();
347+ if (anim > 0 )
348+ self->m_bendAnimation = anim;
339349 }
340350 if (j.contains (" partAttachedToRobot" ) && j[" partAttachedToRobot" ].is_boolean ())
341351 {
@@ -362,7 +372,6 @@ size_t FlexCell::sseWriteCallback(char* ptr, size_t size, size_t nmemb, void* us
362372
363373 // Update live buffer - keep only latest for minimal latency
364374 {
365- std::lock_guard<std::mutex> lock (self->m_rabbitMutex );
366375 self->m_livePositions .clear ();
367376 self->m_livePositions .push_back (pos);
368377 }
0 commit comments