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

Changes for Metrics template #288

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
39 changes: 39 additions & 0 deletions src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,45 @@ void CoreSDKTest::MetricsStopContent()
}
}

void CoreSDKTest::MetricsReady()
{
Firebolt::Error error = Firebolt::Error::None;
std::optional<std::string> entityId;
bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().ready(&error);

if (error == Firebolt::Error::None) {
cout << "Metrics Ready status = " << (status ? "true" : "false") << endl;
} else {
cout << "Metrics Ready status = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::MetricsSignIn()
{
Firebolt::Error error = Firebolt::Error::None;
std::optional<std::string> entityId;
bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signIn(&error);

if (error == Firebolt::Error::None) {
cout << "Metrics signIn status = " << (status ? "true" : "false") << endl;
} else {
cout << "Metrics signIn status = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::MetricsSignOut()
{
Firebolt::Error error = Firebolt::Error::None;
std::optional<std::string> entityId;
bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signOut(&error);

if (error == Firebolt::Error::None) {
cout << "Metrics signOut status = " << (status ? "true" : "false") << endl;
} else {
cout << "Metrics signOut status = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::GetSecondScreenDevice()
{
Firebolt::Error error = Firebolt::Error::None;
Expand Down
3 changes: 3 additions & 0 deletions src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class CoreSDKTest {

static void MetricsStartContent();
static void MetricsStopContent();
static void MetricsReady();
static void MetricsSignIn();
static void MetricsSignOut();

static void GetSecondScreenDevice();
static void GetSecondScreenProtocols();
Expand Down
18 changes: 17 additions & 1 deletion src/sdks/core/src/cpp/sdk/cpptest/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ void ShowLifecycleMenu()

void ShowMetricsMenu()
{
printf("Options: \n"
printf("Options: \n"
"\tR : Ready\n"
"\tI : SignIn\n"
"\tO : SignOut\n"
"\tS : Start Content\n"
"\tT : Stop Content\n"
"\tQ : Quit\n");
Expand Down Expand Up @@ -386,6 +389,19 @@ void HandleMetricsMethod()
printf("Enter option : ");
opt = toupper(getchar());
switch (opt) {
case 'R': {
CoreSDKTest::MetricsReady();
break;
}
case 'I': {
CoreSDKTest::MetricsSignIn();
break;
}
case 'O': {
CoreSDKTest::MetricsSignOut();
break;
}

case 'S': {
CoreSDKTest::MetricsStartContent();
break;
Expand Down
37 changes: 37 additions & 0 deletions src/sdks/core/src/cpp/templates/Metrics/include/module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include "error.h"
/* ${IMPORTS} */

${if.declarations}namespace Firebolt {
namespace ${info.Title} {
${if.enums}

// Enums
/* ${ENUMS} */${end.if.enums}
${if.types}
// Types
/* ${TYPES} */${end.if.types}
${if.providers}/* ${PROVIDERS} */${end.if.providers}${if.xuses}/* ${XUSES} */${end.if.xuses}
${if.methods}struct I${info.Title} {

virtual ~I${info.Title}() = default;
virtual bool ready( Firebolt::Error *err = nullptr ) = 0 ;
virtual bool signIn( Firebolt::Error *err = nullptr ) = 0 ;
virtual bool signOut( Firebolt::Error *err = nullptr ) = 0 ;

// Methods & Events
/* ${METHODS:declarations} */
};${end.if.methods}

} //namespace ${info.Title}
}${end.if.declarations}









59 changes: 43 additions & 16 deletions src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,68 +18,95 @@

#include "${info.title.lowercase}_impl.h"


${if.implementations}
namespace Firebolt {
namespace ${info.Title} {
${if.providers}
/* ${PROVIDERS} */${end.if.providers}
void ${info.Title}Impl::signIn()

/* ready - Inform the platform that your app is minimally usable. This method is called automatically by `Lifecycle.ready()` */
bool ${info.Title}Impl::ready( Firebolt::Error *err )
{
Firebolt::Error status = Firebolt::Error::NotConnected;
bool success = false;
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport();
if (transport != nullptr) {

JsonObject jsonParameters;

WPEFramework::Core::JSON::Boolean jsonResult;
status = transport->Invoke("${info.title.lowercase}.signIn", jsonParameters, jsonResult);
status = transport->Invoke("${info.title.lowercase}.ready", jsonParameters, jsonResult);
if (status == Firebolt::Error::None) {
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title.signIn is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false"));
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "Metrics.ready is successfully invoked");
success = jsonResult.Value();
}

} else {
FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "Error in getting Transport err = %d", status);
}
if (err != nullptr) {
*err = status;
}

return success;
}

void ${info.Title}Impl::signOut()

/* signIn - Log a sign In event, called by Discovery.signIn(). */
bool ${info.Title}Impl::signIn( Firebolt::Error *err )
{
Firebolt::Error status = Firebolt::Error::NotConnected;
bool success = false;
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport();
if (transport != nullptr) {

JsonObject jsonParameters;

WPEFramework::Core::JSON::Boolean jsonResult;
status = transport->Invoke("${info.title.lowercase}.signOut", jsonParameters, jsonResult);
status = transport->Invoke("${info.title.lowercase}.signIn", jsonParameters, jsonResult);
if (status == Firebolt::Error::None) {
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title}.signOut is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false"));
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "Metrics.signOut is successfully invoked");
success = jsonResult.Value();
}

} else {
FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "Error in getting Transport err = %d", status);
}
}
if (err != nullptr) {
*err = status;
}
return success;

void ${info.Title}Impl::ready()
}
/* signOut - Log a sign out event, called by Discovery.signOut(). */
bool ${info.Title}Impl::signOut( Firebolt::Error *err )
{
Firebolt::Error status = Firebolt::Error::NotConnected;
bool success = false;
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport();
if (transport != nullptr) {

JsonObject jsonParameters;

WPEFramework::Core::JSON::Boolean jsonResult;
status = transport->Invoke("${info.title.lowercase}.ready", jsonParameters, jsonResult);
status = transport->Invoke("${info.title.lowercase}.signOut", jsonParameters, jsonResult);
if (status == Firebolt::Error::None) {
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title}.ready is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false"));
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "Metrics.signOut is successfully invoked");
success = jsonResult.Value();
}

} else {
FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "Error in getting Transport err = %d", status);
}
if (err != nullptr) {
*err = status;
}

return success;
}


// Methods
/* ${METHODS} */

Expand Down
11 changes: 8 additions & 3 deletions src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "FireboltSDK.h"
#include "IModule.h"

/* ${IMPORTS} */
#include "${info.title.lowercase}.h"

Expand All @@ -41,9 +42,13 @@ namespace ${info.Title} {

~${info.Title}Impl() override = default;

static void signIn();
static void signOut();
static void ready();

bool ready( Firebolt::Error *err = nullptr ) ;
bool signIn( Firebolt::Error *err = nullptr ) ;
bool signOut( Firebolt::Error *err = nullptr ) ;



// Methods & Events
/* ${METHODS:declarations-override} */
};${end.if.methods}
Expand Down