Commit ccdc4f7d authored by Claes's avatar Claes Committed by Esteban Blanc

Regression tests in project pwrtest01 added

parent cfa755ec
/*
Test aproc functions.
*/
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <math.h>
#include "pwr_class.h"
#include "co_msg.h"
#include "co_dcli.h"
#include "co_time.h"
#include "rt_gdh.h"
#include "ra_aproctest.h"
#include "rt_pwr_msg.h"
#include "rt_plc_msg.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_cvolpwrtest01classes.h"
static float aproctest_wait=0.01;
void ra_aproctest::RegisterObject(void)
{
pwr_tOid oid;
m_sts = gdh_NameToObjid("Nodes-PwrTest01c-Applications-ra_aproctest", &oid);
if (EVEN(m_sts)) {
m_log->log('E', "RegisterObject gdh_NameToObjid", m_sts);
return;
}
m_sts = aproc_RegisterObject(oid);
if (EVEN(m_sts)) {
m_log->log('E', "RegisterObject", m_sts);
return;
}
time_Sleep(aproctest_wait);
if (cdh_ObjidIsNotEqual(m_nodep->ProcObject[m_anix-1], oid)) {
m_log->log('E', "RegisterObject, objid doesn't match");
return;
}
m_log->log('S', "RegisterObject", PWR__SUCCESS);
}
void ra_aproctest::TimeStamp(void)
{
errh_SetStatus(PWR__ARUN);
for (int i = 0; i < 10; i++) {
aproc_TimeStamp(0.005, 0.010);
time_Sleep(.005);
if (m_nodep->ProcStatus[m_anix-1] != PWR__ARUN) {
m_log->log('E', "RegisterObject, process status doesn't match");
return;
}
}
time_Sleep(1.0);
if (m_nodep->ProcStatus[m_anix-1] != PWR__PTIMEOUT) {
m_log->log('E', "RegisterObject, no timeout occurred");
return;
}
errh_SetStatus(0);
m_log->log('S', "RegisterObject", PWR__SUCCESS);
}
// Constructor
ra_aproctest::ra_aproctest()
{
pwr_tOid oid;
m_anix = errh_eAnix_appl3;
m_log = new tst_log(&m_sts, "rt-Aproc", "$pwrp_log/aproc.log");
if (EVEN(m_sts))
printf("** Unable to open log file");
m_sts = gdh_Init("ra_aproctest");
if (EVEN(m_sts)) {
m_log->log('F', "aproc gdh_Init", m_sts);
exit(0);
}
m_sts = gdh_GetNodeObject(pwr_cNNid, &oid);
if (EVEN(m_sts)) {
m_log->log('F', "aproc gdh_GetNodeObject", m_sts);
exit(0);
}
m_sts = gdh_ObjidToPointer(oid, (void **)&m_nodep);
if (EVEN(m_sts)) {
m_log->log('F', "aproc gdh_ObjidToPointer", m_sts);
exit(0);
}
m_sts = errh_Init("ra_aproctest", m_anix);
if (m_sts != 1) {
m_log->log('E', "aproc errh_Init", m_sts);
return;
}
errh_SetStatus(PWR__APPLSTARTUP);
}
// Destructor
ra_aproctest::~ra_aproctest()
{
delete m_log;
}
int main()
{
ra_aproctest aproc;
aproc.RegisterObject();
aproc.TimeStamp();
}
#include "pwr.h"
#include "rt_aproc.h"
#include "co_tst_log.h"
class ra_aproctest {
pwr_tStatus m_sts;
tst_log *m_log;
pwr_sNode *m_nodep;
errh_eAnix m_anix;
public:
ra_aproctest();
~ra_aproctest();
tst_log *log() {return m_log;}
void RegisterObject();
void TimeStamp();
};
This diff is collapsed.
This diff is collapsed.
#include "pwr.h"
#include "co_cdh.h"
#include "co_tst_log.h"
class ra_cdhtest {
pwr_tStatus m_sts;
tst_log *m_log;
public:
ra_cdhtest();
~ra_cdhtest();
tst_log *log() {return m_log;}
void ObjidCompare();
void ObjidIsEqual();
void ObjidIsNotEqual();
void ObjidIsNull();
void ObjidIsNotNull();
void ClassObjidToId();
void ClassIdToObjid();
void TypeObjidToId();
void TypeIdToObjid();
void TypeIdToIndex();
void ObjidToAref();
void AttrValueToString();
void StringToAttrValue();
void MaskToBinaryString();
void StringToClassId();
void StringToObjid();
void StringToAref();
void StringToTypeId();
void StringToVolumeId();
void StringToObjectIx();
void ClassIdToString();
void TypeIdToString();
void ObjectIxToString();
void ArefToString();
void NodeIdToString();
void OidToString();
void OidToFnString();
void VolumeIdToString();
void VolumeIdToFnString();
void SubidToString();
void DlidToString();
void Low();
void OpSysToStr();
void OpSysToDirStr();
void StringToObjectName();
void CutNameSegments();
void AttrSize();
void AttrElemSize();
};
This diff is collapsed.
#include "pwr.h"
#include "rt_errh.h"
#include "co_tst_log.h"
class ra_errhtest {
pwr_tStatus m_sts;
tst_log *m_log;
pwr_sNode *m_nodep;
errh_eAnix m_anix;
public:
ra_errhtest();
~ra_errhtest();
tst_log *log() {return m_log;}
void set_anix(errh_eAnix anix);
void Init();
void Success();
void Info();
void Warning();
void Error();
void Fatal();
void CErrLog();
void SetAnix();
void SetStatus();
void LogSuccess();
void LogInfo();
void LogError();
void LogFatal();
};
/*
Test gdh functions.
*/
#include <stdio.h>
#include "ra_gdh_test.h"
void GetRootList()
{
}
int main()
{
pwr_tStatus sts, system_sts;
pwr_tOid noid;
pwr_tOName name;
sts = gdh_Init("ra_gdh");
if (EVEN(sts)) {
printf("E pwrtest01 status, gdh_Init error status: %u\n", sts);
exit(0);
}
GetRootList();
}
This diff is collapsed.
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "co_tst_log.h"
class ra_gdhtest {
pwr_tStatus m_sts;
tst_log *m_log;
pwr_tOid m_root;
pwr_tOid m_child;
pwr_tOid m_dynroot;
pwr_tStatus check_object(pwr_tOid oid);
public:
ra_gdhtest();
~ra_gdhtest();
void Init();
void ObjidToName(void);
void ObjidToPointer(void);
void MountObjidToPointer(void);
void AttrRefToPointer(void);
void NameToPointer(void);
void CreateObject(void);
void DeleteObject(void);
void DeleteObjectTree(void);
void RenameObject(void);
void MoveObject(void);
void GetRootList(void);
void GetChild(void);
void GetParent(void);
void GetNextSibling(void);
void GetPreviousSibling(void);
void GetNodeIndex(void);
void GetObjectNodeIndex(void);
void GetNodeObject(void);
void GetAttributeCharacteristics(void);
void GetAttributeCharAttrref(void);
void NameToAttrref(void);
void AttrrefToName(void);
void ClassAttrToAttrref(void);
void AttrArefToObjectAref(void);
void ArefANameToAref(void);
void AttrValueToString(void);
void AttrStringToValue(void);
void ArefDisabled(void);
void GetClassList(void);
void GetNextObject(void);
void GetPreviousObject(void);
void GetClassListAttrRef(void);
void GetNextAttrRef(void);
void ClassNameToId(void);
void GetSuperClass(void);
void GetEnumValueDef(void);
void GetMaskBitDef(void);
void FWriteObject(void);
void GetSecurityInfo(void);
void TranslateRtdbPointer(void);
void GetObjectSize(void);
void GetDynamicAttrSize(void);
void GetObjectClass(void);
void GetAttrRefTid(void);
void GetObjectLocation(void);
void GetObjectDLCount(void);
void GetVolumeList(void);
void GetNextVolume(void);
void VolumeIdToName(void);
void GetVolumeInfo(void);
void DLRefObjectInfoAttrref(void);
void GetTimeDL(void);
void SetTimeDL(void);
void GetDeltaTimeDL(void);
void SetDeltaTimeDL(void);
void GetStrDL(void);
void SetStrDL(void);
void GetObjectInfoTime(void);
void SetObjectInfoTime(void);
void GetObjectInfoDeltaTime(void);
void SetObjectInfoDeltaTime(void);
void GetObjectInfoStr(void);
void SetObjectInfoStr(void);
};
This diff is collapsed.
#include "pwr.h"
#include "rt_mh_outunit.h"
#include "co_tst_log.h"
#define SUP_ASIZE 5
#define SUP_ISIZE 1
#define SUP_CYCLES 10
typedef struct {
pwr_tBoolean *dp;
pwr_tOid oid;
int active;
int eactive;
int prio;
mh_sEventId eventid;
mh_mEventStatus status;
mh_mEventStatus estatus;
int check;
} sSup;
class ra_mhappltest {
static ra_mhappltest *m_mh;
pwr_tStatus m_sts;
tst_log *m_log;
pwr_tOid m_user;
int m_clean;
int m_checkstatus;
int m_errcnt;
static pwr_tStatus mh_ack_bc(mh_sAck* MsgP);
static pwr_tStatus mh_return_bc(mh_sReturn* MsgP);
static pwr_tStatus mh_alarm_bc(mh_sMessage* MsgP);
static pwr_tStatus mh_block_bc(mh_sBlock* MsgP);
static pwr_tStatus mh_cancel_bc(mh_sReturn* MsgP);
static pwr_tStatus mh_info_bc(mh_sMessage* MsgP);
static pwr_tStatus mh_clear_alarmlist_bc(pwr_tNodeIndex nix);
static pwr_tStatus mh_clear_blocklist_bc(pwr_tNodeIndex nix);
static pwr_tStatus mh_alarmstatus_bc(mh_sAlarmStatus* MsgP);
void clean();
void receive();
int find_sup(mh_sEventId *id);
void outunit_connect();
public:
ra_mhappltest();
~ra_mhappltest();
tst_log *log() {return m_log;}
void ApplConnect(void);
void ApplTest(void);
void ApplGetMsgInfo(void);
void ApplDisconnect(void);
};
This diff is collapsed.
#include "pwr.h"
#include "rt_mh_outunit.h"
#include "co_tst_log.h"
#define SUP_ASIZE 5
#define SUP_ISIZE 1
#define SUP_CYCLES 10
typedef struct {
pwr_tBoolean *dp;
pwr_tOid oid;
int active;
int eactive;
int prio;
mh_sEventId eventid;
mh_mEventStatus status;
mh_mEventStatus estatus;
int check;
} sSup;
class ra_mhtest {
static ra_mhtest *m_mh;
pwr_tStatus m_sts;
tst_log *m_log;
pwr_tOid m_user;
int m_clean;
int m_checkstatus;
sSup m_sup[SUP_ASIZE+SUP_ISIZE][32];
int m_errcnt;
static pwr_tStatus mh_ack_bc(mh_sAck* MsgP);
static pwr_tStatus mh_return_bc(mh_sReturn* MsgP);
static pwr_tStatus mh_alarm_bc(mh_sMessage* MsgP);
static pwr_tStatus mh_block_bc(mh_sBlock* MsgP);
static pwr_tStatus mh_cancel_bc(mh_sReturn* MsgP);
static pwr_tStatus mh_info_bc(mh_sMessage* MsgP);
static pwr_tStatus mh_clear_alarmlist_bc(pwr_tNodeIndex nix);
static pwr_tStatus mh_clear_blocklist_bc(pwr_tNodeIndex nix);
static pwr_tStatus mh_alarmstatus_bc(mh_sAlarmStatus* MsgP);
unsigned int rand();
void clean();
void receive();
sSup *find_sup(mh_sEventId *id);
public:
ra_mhtest();
~ra_mhtest();
tst_log *log() {return m_log;}
void OutunitConnect();
void OutunitTest();
};
/*
Test nettime functions.
*/
#include <stdio.h>
#include <stddef.h>
#include <math.h>
#include "co_msg.h"
#include "co_dcli.h"
#include "rt_net.h"
#include "ra_nettimetest.h"
#include "co_time_msg.h"
#include "co_cdh_msg.h"
#include "rt_gdh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_cvolpwrtest01classes.h"
typedef struct {
net_sTime nettime;
pwr_tTime result;
} sNetTimeToTime;
void ra_nettimetest::NetTimeToTime(void)
{
sNetTimeToTime d[] = {
{{2682419400,500000000}, {2682419400,500000000}},
{{2145913199,500000000}, {2145913199,500000000}},
{{2145913200,000000000}, {2145913200,000000000}}
};
pwr_tTime result;
net_sTime nettime;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
result = net_NetTimeToTime(&d[i].nettime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tTime)) != 0) {
m_log->vlog('E', "NetTimeToTime, result differs idx %d", i);
return;
}
nettime = net_TimeToNetTime(&result);
if (memcmp(&nettime, &d[i].nettime, sizeof(net_sTime)) != 0) {
m_log->vlog('E', "NetTimeToTime, result differs idx %d", i);
return;
}
}
m_log->log('S', "NetTimeToTime", TIME__SUCCESS);
}
typedef struct {
net_sTime nettime;
pwr_tDeltaTime result;
} sNetTimeToDeltaTime;
void ra_nettimetest::NetTimeToDeltaTime(void)
{
sNetTimeToDeltaTime d[] = {
{{0,1}, {0,1}},
{{100,1}, {100,1}},
{{0,1}, {0,1}},
{{100,0}, {100,0}},
{{0,500000000}, {0,500000000}},
{{22222,500000000}, {22222,500000000}}
};
pwr_tDeltaTime result;
net_sTime nettime;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
result = net_NetTimeToDeltaTime(&d[i].nettime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tTime)) != 0) {
m_log->vlog('E', "NetTimeToDeltaTime, result differs idx %d", i);
return;
}
nettime = net_DeltaTimeToNetTime(&result);
if (memcmp(&nettime, &d[i].nettime, sizeof(net_sTime)) != 0) {
m_log->vlog('E', "NetTimeToDeltaTime, result differs idx %d", i);
return;
}
}
m_log->log('S', "NetTimeToDeltaTime", TIME__SUCCESS);
}
// Constructor
ra_nettimetest::ra_nettimetest()
{
m_log = new tst_log(&m_sts, "rt-NetTime", "$pwrp_log/nettime.log");
if (EVEN(m_sts))
printf("** Unable to open log file");
}
// Destructor
ra_nettimetest::~ra_nettimetest()
{
delete m_log;
}
int main()
{
ra_nettimetest time;
pwr_tStatus sts;
sts = gdh_Init("ra_nettimetest");
if (EVEN(sts)) {
time.log()->log('S', "NetTime gdh_Init", sts);
exit(0);
}
time.NetTimeToTime();
time.NetTimeToDeltaTime();
}
#include "pwr.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_tst_log.h"
class ra_nettimetest {
pwr_tStatus m_sts;
tst_log *m_log;
public:
ra_nettimetest();
~ra_nettimetest();
tst_log *log() {return m_log;}
void NetTimeToTime();
void NetTimeToDeltaTime();
};
#include <float.h>
#include <math.h>
#include "pwr.h"
#include "rt_plc.h"
#include "ra_plc_user.h"
void Pwrt01_NotEqual_exec(plc_sThread *tp, pwr_sClass_Pwrt01_NotEqual *o)
{
o->In1 = *o->In1P;
o->In2 = *o->In2P;
if ((isnan(o->In1) && isnan(o->In2)) ||
(isinf(o->In1) && isinf(o->In2)))
o->Status = 0;
else
o->Status = !(fabsf(o->In1 - o->In2) < o->MaxValue * FLT_EPSILON);
}
...@@ -5,5 +5,12 @@ ...@@ -5,5 +5,12 @@
#include "pwr_othermanufacturerclasses.h" #include "pwr_othermanufacturerclasses.h"
#include "pwr_inorclasses.h" #include "pwr_inorclasses.h"
#include "pwr_siemensclasses.h" #include "pwr_siemensclasses.h"
#include "pwr_simulclasses.h"
#include "pwr_miscellaneousclasses.h" #include "pwr_miscellaneousclasses.h"
#include "simul.h"
#include "misc.h" #include "misc.h"
#include "pwr_cvolpwrtest01classes.h"
void Pwrt01_NotEqual_exec(plc_sThread *tp, pwr_sClass_Pwrt01_NotEqual *o);
This diff is collapsed.
This diff is collapsed.
#include "pwr.h"
#include "rt_qcom.h"
#include "co_tst_log.h"
class ra_qcomtest {
pwr_tStatus m_sts;
tst_log *m_log;
public:
ra_qcomtest();
~ra_qcomtest();
tst_log *log() {return m_log;}
void AidCompare();
void AidIsEqual();
void AidIsNotEqual();
void AidIsNull();
void AidIsNotNull();
void QidCompare();
void QidIsEqual();
void QidIsNotEqual();
void QidIsNull();
void QidIsNotNull();
void QidToString();
void Alloc();
void CreateQ();
void Put();
void Get();
void MyBus();
void NextNode();
void MyNode();
void Forwarding();
void Signalling();
void BindEvent();
void Request();
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#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();
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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