-
-
Notifications
You must be signed in to change notification settings - Fork 49
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 infrastructure to monitor the VT IOP loading progress #533
base: main
Are you sure you want to change the base?
Conversation
a16446a
to
4af0534
Compare
isobus/src/isobus_virtual_terminal_server_managed_working_set.cpp
Outdated
Show resolved
Hide resolved
isobus/include/isobus/isobus/isobus_virtual_terminal_working_set_base.hpp
Outdated
Show resolved
Hide resolved
isobus/src/isobus_virtual_terminal_server_managed_working_set.cpp
Outdated
Show resolved
Hide resolved
4af0534
to
0a6d623
Compare
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice that you are working on this feature! It has a lot of added value in the VT
My 2 cents are as followed: I think you have everything to determine the things you are looking for. Adding extra class variables might be a bit overkill and perhaps a bit more risky. I've attached two suggestions for the functions how they can be without using the other added variables. I'm curious to hear what you think
float VirtualTerminalServerManagedWorkingSet::iop_load_percentage() const | ||
{ | ||
if (iopSize == 0) | ||
{ | ||
return 0.0f; | ||
} | ||
|
||
auto totalTransferredSize = transferredIopSize; | ||
if (totalTransferredSize < iopSize) | ||
{ | ||
// if IOP transfer is not completed check if there is an ongoing IOP transfer to us | ||
auto sessions = CANNetworkManager::CANNetwork.get_active_transport_protocol_sessions(0); | ||
for (const auto &session : sessions) | ||
{ | ||
if (session->get_source()->get_address() == get_control_function()->get_address() && | ||
(static_cast<std::uint32_t>(CANLibParameterGroupNumber::ECUtoVirtualTerminal) == session->get_parameter_group_number())) | ||
{ | ||
totalTransferredSize += session->get_total_bytes_transferred(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return (totalTransferredSize / static_cast<float>(iopSize)) * 100.0f; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float VirtualTerminalServerManagedWorkingSet::iop_load_percentage() const | |
{ | |
if (iopSize == 0) | |
{ | |
return 0.0f; | |
} | |
auto totalTransferredSize = transferredIopSize; | |
if (totalTransferredSize < iopSize) | |
{ | |
// if IOP transfer is not completed check if there is an ongoing IOP transfer to us | |
auto sessions = CANNetworkManager::CANNetwork.get_active_transport_protocol_sessions(0); | |
for (const auto &session : sessions) | |
{ | |
if (session->get_source()->get_address() == get_control_function()->get_address() && | |
(static_cast<std::uint32_t>(CANLibParameterGroupNumber::ECUtoVirtualTerminal) == session->get_parameter_group_number())) | |
{ | |
totalTransferredSize += session->get_total_bytes_transferred(); | |
break; | |
} | |
} | |
} | |
return (totalTransferredSize / static_cast<float>(iopSize)) * 100.0f; | |
} | |
float VirtualTerminalServerManagedWorkingSet::iop_load_percentage() const | |
{ | |
if (processingState != ObjectPoolProcessingThreadState::None) | |
{ | |
return 100.0f; | |
} | |
// if IOP transfer is not completed check if there is an ongoing IOP transfer to us | |
auto sessions = CANNetworkManager::CANNetwork.get_active_transport_protocol_sessions(0); | |
for (const auto &session : sessions) | |
{ | |
if (session->get_source()->get_address() == get_control_function()->get_address() && | |
(static_cast<std::uint32_t>(CANLibParameterGroupNumber::ECUtoVirtualTerminal) == session->get_parameter_group_number()) && | |
(session->get_total_bytes_transferred() >= 1) && | |
(session->get_data().get_byte(0) == static_cast<std::uint8_t>(VirtualTerminalBase::Function::ObjectPoolTransferMessage))) | |
{ | |
return session->get_percentage_bytes_transferred(); | |
} | |
} | |
return 0.0f; | |
} |
bool VirtualTerminalServerManagedWorkingSet::is_object_pool_transfer_in_progress() const | ||
{ | ||
return objectPoolTransferInProgress; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool VirtualTerminalServerManagedWorkingSet::is_object_pool_transfer_in_progress() const | |
{ | |
return objectPoolTransferInProgress; | |
} | |
bool VirtualTerminalServerManagedWorkingSet::is_object_pool_transfer_in_progress() const | |
{ | |
return iop_load_percentage() != 0.0f; | |
} |
Describe your changes
Added counters to being able to monitor the VT IOP download progress (which is usually done in several smaller chunks)
How has this been tested?
Built AgIsoVT with this version of stack and tested the IOP load indicators.