Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add publish rate parameter #25

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/bennu/executables/bennu-simulink-provider/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ struct Dto
class BennuSimulinkProvider : public Provider
{
public:
BennuSimulinkProvider(const Endpoint& serverEndpoint, const Endpoint& publishEndpoint, bool debug) :
double publishRate_setting;
areyna1 marked this conversation as resolved.
Show resolved Hide resolved
BennuSimulinkProvider(const Endpoint& serverEndpoint, const Endpoint& publishEndpoint, bool debug, double publishRate) :
Provider(serverEndpoint, publishEndpoint),
mLock(),
mDebug(debug)
{
publishRate_setting = publishRate;
mPublishSemaphore = sem_open(PUBLISH_SEM, O_CREAT, 0644, 0);
if(SEM_FAILED == mPublishSemaphore)
{
Expand Down Expand Up @@ -284,7 +286,8 @@ class BennuSimulinkProvider : public Provider
{
publishData();
std::cout << std::flush;
std::this_thread::sleep_for(std::chrono::seconds(1));
// std::this_thread::sleep_for(std::chrono::seconds(1));
areyna1 marked this conversation as resolved.
Show resolved Hide resolved
std::this_thread::sleep_for(durationToDuration(this->publishRate_setting));
areyna1 marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -333,6 +336,7 @@ int main(int argc, char** argv)
("debug", po::bool_switch(&debug), "print debugging information")
("server-endpoint", po::value<std::string>()->default_value("tcp://127.0.0.1:5555"), "server listening endpoint")
("publish-endpoint", po::value<std::string>()->default_value("udp://239.0.0.1:40000"), "publishing endpoint");
("publish-rate", po::value<double>()->default_value(0.1), "rate at which updates published from provider to simulation");
areyna1 marked this conversation as resolved.
Show resolved Hide resolved

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
Expand All @@ -348,6 +352,8 @@ int main(int argc, char** argv)
sEndpoint.str = vm["server-endpoint"].as<std::string>();
pEndpoint.str = vm["publish-endpoint"].as<std::string>();
BennuSimulinkProvider bsp(sEndpoint, pEndpoint, debug);
areyna1 marked this conversation as resolved.
Show resolved Hide resolved
double publishRate = vm["publish-rate"].as<double>();
BennuSimulinkProvider bsp(sEndpoint, pEndpoint, debug, publishRate);
bsp.run();
return 0;
}