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

CCCS-15: Add a Data-amount Control to the Signal Source #16

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/Src/Emitter/Bin/emitter",
"args": [],
"args": ["50"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/Src/Emitter/Bin",
"environment": [],
Expand All @@ -52,7 +52,7 @@
],
"preLaunchTask": "Build Emitter",
"miDebuggerPath": "/usr/bin/gdb"
}
}
],
"compounds": [
{
Expand Down
2 changes: 1 addition & 1 deletion Src/Emitter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ COPY --from=built /app/Emitter/Bin/emitter /app/emitter

EXPOSE 8080

CMD ["/app/emitter"]
CMD ["/app/emitter", "10"]

50 changes: 28 additions & 22 deletions Src/Emitter/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,37 @@ void ConfigureLog()
el::Loggers::reconfigureLogger("default", defaultConf);
}

int main()
int main(int argc, char **argv)
{
ConfigureLog();

LOG(DEBUG) << "Emitter started";
LOG(INFO) << "Emitter started";
int msg_count = 20;

if (argc > 1)
{
LOG(DEBUG) << "Emitter started" << std::endl
<< "{";
LOG(INFO) << "Emitter started" << std::endl
<< "{";
for (int i = 0; i < argc; ++i)
{
LOG(DEBUG) << " [" << i << "]: " << argv[i];
LOG(INFO) << " [" << i << "]: " << argv[i];
}
LOG(DEBUG) << "}";
LOG(INFO) << "}";

msg_count = atoi(argv[1]);
}
else
{
LOG(DEBUG) << "Emitter started with msg_count = " << msg_count;
LOG(INFO) << "Emitter started with msg_count = " << msg_count;
}

MemoryStatus ms = MemoryMonitor::ForCurrentProcess();

LOG(INFO) << "PID: " << getpid();
LOG(INFO) << ms.To2String();

sleep(5);
Expand All @@ -53,9 +75,9 @@ int main()
return 1;
}

// Send one measure
for (int i = 1; i <= msg_count; i++)
{
Measure *msg = new Measure(20040501, 23.1, "First measure");
Measure *msg = new Measure(20040501, 23.1 + i / 10, "Measure");
unsigned char *p = nullptr;
int sz = 0;

Expand All @@ -65,26 +87,10 @@ int main()

LOG(DEBUG) << "Sent: " << msg->To2String();
LOG(INFO) << "Sent: " << msg->To2String();
}

sleep(1);

// Send another measure
{
Measure *msg = new Measure(20040501, 23.7, "Second measure");
unsigned char *p = nullptr;
int sz = 0;

BinaryWrapper::WrapMessage(msg, p, sz);

client.Send(p, sz);

LOG(DEBUG) << "Sent: " << msg->To2String();
LOG(INFO) << "Sent: " << msg->To2String();
sleep(1);
}

sleep(1);

// Send communication closing signal
{
CommTerm *msg = new CommTerm();
Expand Down