Commit 05542d4a authored by Claes's avatar Claes Committed by Esteban Blanc

pwrdemo rt_status creating logfile

parent 4ce23d13
...@@ -8,6 +8,6 @@ demo_modules = $(pwrp_exe)/ra_status ...@@ -8,6 +8,6 @@ demo_modules = $(pwrp_exe)/ra_status
demo_all : $(demo_modules) demo_all : $(demo_modules)
$(pwrp_exe)/ra_status : $(pwrp_appl)/ra_status.c $(pwrp_exe)/ra_status : $(pwrp_appl)/ra_status.cpp
@ echo "Building ra_status" @ echo "Building ra_status"
@ g++ -g -o $(target) $(source) -I$(pwr_inc) -L$(pwr_lib) -lpwr_rt -lpwr_co -lpwr_msg_dummy -lrpcsvc -lpthread -lm -lrt @ g++ -g -o $(target) $(source) -I$(pwr_inc) -L$(pwr_lib) -lpwr_rt -lpwr_co -lpwr_msg_dummy -lrpcsvc -lpthread -lm -lrt
/*
Print current project status
*/
#include <stdio.h>
#include "pwr.h"
#include "rt_gdh.h"
int main()
{
pwr_tStatus sts, system_sts;
sts = gdh_Init("ra_status");
if (EVEN(sts)) {
printf("E pwrdemo status, gdh_Init error status: %u\n", sts);
exit(0);
}
sts = gdh_GetObjectInfo("Nodes-DemoNode.SystemStatus", &system_sts,
sizeof(system_sts));
if (EVEN(sts)) {
printf("E pwrdemo status, gdh_GetObjectInfo error status: %u\n", sts);
exit(0);
}
if (ODD(system_sts))
printf("I pwrdemo status success: %u\n", system_sts);
else
printf("E pwrdemo status error: %u\n", system_sts);
}
/*
Print current project status
*/
#include <stdio.h>
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "ra_status.h"
void ra_status::test_status()
{
pwr_tStatus sts, system_sts;
pwr_tOid noid;
pwr_tOName name;
m_sts = gdh_GetNodeObject(0, &noid);
if (EVEN(m_sts)) {
m_log->log('E', "gdh_GetNodeObject", m_sts);
return;
}
m_sts = gdh_ObjidToName(noid, name, sizeof(name), cdh_mName_volumeStrict);
if (EVEN(m_sts)) {
m_log->log('E', "gdh_ObjidToName", m_sts);
return;
}
strcat(name, ".SystemStatus");
m_sts = gdh_GetObjectInfo(name, &system_sts, sizeof(system_sts));
if (EVEN(m_sts)) {
m_log->log('E', "gdh_GetObjectInfo", m_sts);
return;
}
switch (errh_Severity(system_sts)) {
case errh_eSeverity_Success:
m_log->log('S', "Success system status", system_sts);
break;
case errh_eSeverity_Info:
m_log->log('I', "Info system status", system_sts);
break;
case errh_eSeverity_Warning:
m_log->log('W', "Warning system status", system_sts);
break;
case errh_eSeverity_Error:
m_log->log('E', "Error system status", system_sts);
break;
case errh_eSeverity_Fatal:
m_log->log('F', "Fatal system status", system_sts);
break;
}
}
// Constructor
ra_status::ra_status()
{
m_log = new tst_log(&m_sts, "pwrdemo-Status", "$pwrp_tmp/pwrdemo_status.tlog");
if (EVEN(m_sts))
printf("** Unable to open log file");
m_sts = gdh_Init("ra_status");
if (EVEN(m_sts)) {
m_log->log('F', "gdh_Init", m_sts);
exit(0);
}
}
// Destructor
ra_status::~ra_status()
{
delete m_log;
}
int main()
{
ra_status s;
s.test_status();
}
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "co_tst_log.h"
class ra_status {
pwr_tStatus m_sts;
tst_log *m_log;
public:
ra_status();
~ra_status();
void test_status();
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment