WiP: Extended sysmgr api

WiP: did some tests
This commit is contained in:
Mateusz
2019-09-02 13:18:06 +02:00
parent 8b4cf5e35a
commit 883b8f2550
10 changed files with 67 additions and 21 deletions

View File

@@ -75,25 +75,29 @@ namespace sys {
bool SystemManager::SuspendSystem(Service *caller) {
for(const auto &w : servicesList){
if(w->GetName() != caller->GetName()){
for (auto w = servicesList.rbegin(); w != servicesList.rend(); ++w)
{
if((*w)->parent == "" && (*w)->GetName() != caller->GetName()){
auto ret = Bus::SendUnicast(std::make_shared<SystemMessage>(SystemMessageType::SwitchPowerMode,ServicePowerMode::SuspendToRAM),
w->GetName(), caller);
if(!ret){
LOG_FATAL("Service %s failed to enter low-power mode",w->GetName().c_str());
(*w)->GetName(), caller,1000);
auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);
if (ret.first != ReturnCodes::Success && (resp->retCode != ReturnCodes::Success)){
LOG_FATAL("Service %s failed to enter low-power mode",(*w)->GetName().c_str());
}
}
}
}
bool SystemManager::ResumeSystem(Service *caller) {
for(const auto &w : servicesList){
if(w->GetName() != caller->GetName()){
if(w->parent == "" && w->GetName() != caller->GetName()){
auto ret = Bus::SendUnicast(std::make_shared<SystemMessage>(SystemMessageType::SwitchPowerMode,ServicePowerMode::Active),
w->GetName(), caller);
if(!ret){
w->GetName(), caller,1000);
auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);
if (ret.first != ReturnCodes::Success && (resp->retCode != ReturnCodes::Success)){
LOG_FATAL("Service %s failed to exit low-power mode",w->GetName().c_str());
}
}
@@ -102,6 +106,26 @@ namespace sys {
}
}
bool SystemManager::SuspendService(const std::string &name, sys::Service *caller) {
auto ret = Bus::SendUnicast(std::make_shared<SystemMessage>(SystemMessageType::SwitchPowerMode,ServicePowerMode::SuspendToRAM),
name, caller,1000);
auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);
if (ret.first != ReturnCodes::Success && (resp->retCode != ReturnCodes::Success)){
LOG_FATAL("Service %s failed to exit low-power mode",name.c_str());
}
}
bool SystemManager::ResumeService(const std::string &name, sys::Service *caller){
auto ret = Bus::SendUnicast(std::make_shared<SystemMessage>(SystemMessageType::SwitchPowerMode,ServicePowerMode::Active),
name, caller,1000);
auto resp = std::static_pointer_cast<ResponseMessage>(ret.second);
if (ret.first != ReturnCodes::Success && (resp->retCode != ReturnCodes::Success)){
LOG_FATAL("Service %s failed to exit low-power mode",name.c_str());
}
}
bool SystemManager::CreateService(std::shared_ptr<Service> service, Service *caller, TickType_t timeout) {