mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
1720 websocket freeze issue (#1724)
* fixed web server freeze issue
* Revert "fixed web server freeze issue"
This reverts commit 7883453f6a
.
* Fixed Webserver freeze issue
---------
Co-authored-by: Marcus Rockwell <marcusrockwell@gmail.com>
This commit is contained in:
parent
abddad8424
commit
7bc531273c
@ -13,6 +13,7 @@ PURPOSE: (Represent the state of a variable server websocket connection.)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "trick/WebSocketSession.hh"
|
#include "trick/WebSocketSession.hh"
|
||||||
|
#include "trick/Executive.hh"
|
||||||
#include "VariableServerVariable.hh"
|
#include "VariableServerVariable.hh"
|
||||||
|
|
||||||
class VariableServerSession : public WebSocketSession {
|
class VariableServerSession : public WebSocketSession {
|
||||||
@ -38,6 +39,7 @@ class VariableServerSession : public WebSocketSession {
|
|||||||
int sendSieMessage(void);
|
int sendSieMessage(void);
|
||||||
int sendUnitsMessage(const char* vname);
|
int sendUnitsMessage(const char* vname);
|
||||||
REF2* make_error_ref(const char* in_name);
|
REF2* make_error_ref(const char* in_name);
|
||||||
|
void updateNextTime(long long simTimeTics);
|
||||||
double stageTime;
|
double stageTime;
|
||||||
bool dataStaged;
|
bool dataStaged;
|
||||||
|
|
||||||
@ -45,6 +47,7 @@ class VariableServerSession : public WebSocketSession {
|
|||||||
bool cyclicSendEnabled;
|
bool cyclicSendEnabled;
|
||||||
long long nextTime;
|
long long nextTime;
|
||||||
long long intervalTimeTics;
|
long long intervalTimeTics;
|
||||||
|
SIM_MODE mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
WebSocketSession* makeVariableServerSession( struct mg_connection *nc );
|
WebSocketSession* makeVariableServerSession( struct mg_connection *nc );
|
||||||
|
@ -24,6 +24,7 @@ VariableServerSession::VariableServerSession( struct mg_connection *nc ) : WebSo
|
|||||||
intervalTimeTics = exec_get_time_tic_value(); // Default time interval is one second.
|
intervalTimeTics = exec_get_time_tic_value(); // Default time interval is one second.
|
||||||
nextTime = 0;
|
nextTime = 0;
|
||||||
cyclicSendEnabled = false;
|
cyclicSendEnabled = false;
|
||||||
|
mode = Initialization;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DESTRUCTOR
|
// DESTRUCTOR
|
||||||
@ -31,6 +32,10 @@ VariableServerSession::~VariableServerSession() {
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VariableServerSession::updateNextTime(long long simTimeTics) {
|
||||||
|
nextTime = (simTimeTics - (simTimeTics % intervalTimeTics) + intervalTimeTics);
|
||||||
|
}
|
||||||
|
|
||||||
/* Base class virtual function: marshallData
|
/* Base class virtual function: marshallData
|
||||||
When HTTP_Server::time_homogeneous is set, WebSocketSession::marshallData() is
|
When HTTP_Server::time_homogeneous is set, WebSocketSession::marshallData() is
|
||||||
called from the main sim thread in a "top_of_frame" job, to ensure that all of
|
called from the main sim thread in a "top_of_frame" job, to ensure that all of
|
||||||
@ -41,11 +46,23 @@ VariableServerSession::~VariableServerSession() {
|
|||||||
(The specified period between messages).
|
(The specified period between messages).
|
||||||
*/
|
*/
|
||||||
void VariableServerSession::marshallData() {
|
void VariableServerSession::marshallData() {
|
||||||
long long simulation_time_tics = exec_get_time_tics() + exec_get_freeze_time_tics();
|
long long simulation_time_tics = exec_get_time_tics();
|
||||||
|
SIM_MODE new_mode = the_exec->get_mode();
|
||||||
|
|
||||||
|
if(new_mode == Freeze) {
|
||||||
|
simulation_time_tics += exec_get_freeze_time_tics();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(new_mode != mode) {
|
||||||
|
mode = new_mode;
|
||||||
|
updateNextTime(simulation_time_tics);
|
||||||
|
}
|
||||||
|
|
||||||
if ( cyclicSendEnabled && ( simulation_time_tics >= nextTime )) {
|
if ( cyclicSendEnabled && ( simulation_time_tics >= nextTime )) {
|
||||||
stageValues();
|
stageValues();
|
||||||
nextTime = (simulation_time_tics - (simulation_time_tics % intervalTimeTics) + intervalTimeTics);
|
updateNextTime(simulation_time_tics);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Base class virtual function: sendMessage
|
/* Base class virtual function: sendMessage
|
||||||
|
Loading…
Reference in New Issue
Block a user