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();
};
function int ccm_declarations(int log)
int sts;
int i = 50;
float f = 50;
string str = "50";
int iarray[100];
float farray[100];
string strarray[100];
string tstr;
int j;
sts = 1;
if ( i != 50)
tstlog_vlog(log, "E", "declaration, int mismatch %d != %d", i, 50);
return 0;
endif
if ( f != 50)
tstlog_vlog(log, "E", "declaration, float mismatch %f != %d", i, 50);
return 0;
endif
if ( str != "50")
tstlog_vlog(log, "E", "declaration, string mismatch %s != %s", str, "50");
return 0;
endif
for ( j = 0; j < 100; j++)
iarray[j] = j;
endfor
for ( j = 0; j < 100; j++)
farray[j] = j;
endfor
for ( j = 0; j < 100; j++)
strarray[j] = "Str" + j;
endfor
for ( j = 0; j < 10; j++)
if ( iarray[j] != j)
tstlog_vlog(log, "E", "declaration, iarray mismatch %d != %d", iarray[j], j);
return 0;
endif
endfor
for ( j = 0; j < 10; j++)
if ( farray[j] != j)
tstlog_vlog(log, "E", "declaration, farray mismatch %f != %i", farray[j], j);
return 0;
endif
endfor
for ( j = 0; j < 10; j++)
tstr = "Str" + j;
if ( strarray[j] != tstr)
tstlog_vlog(log, "E", "declaration, strarray mismatch %s != %s", strarray[j], tstr);
return 0;
endif
endfor
tstlog_log(log, "S", "declaration: Successfull completion");
return 1;
endfunction
function int ccm_operators(int log)
int a = 123;
int b = 456;
int c;
float fa = 123;
float fb = 456;
float fc;
# Integer operators
c = a + b;
if ( c != 579)
tstlog_vlog(log, "E", "operators, int + error");
return 0;
endif
c = a - b;
if ( c != -333)
tstlog_vlog(log, "E", "operators, int - error");
return 0;
endif
c = a * b;
if ( c != 56088)
tstlog_vlog(log, "E", "operators, int * error");
return 0;
endif
c = b / a;
if ( c != 3)
tstlog_vlog(log, "E", "operators, int / error");
return 0;
endif
c = a;
c++;
if ( c != 124)
tstlog_vlog(log, "E", "operators, int ++ error");
return 0;
endif
c--;
if ( c != 123)
tstlog_vlog(log, "E", "operators, int -- error");
return 0;
endif
c = a << 2;
if ( c != 492)
tstlog_vlog(log, "E", "operators, int << error");
return 0;
endif
c = b >> 2;
if ( c != 114)
tstlog_vlog(log, "E", "operators, int >> error");
return 0;
endif
c = a & b;
if ( c != 72)
tstlog_vlog(log, "E", "operators, int & error");
return 0;
endif
c = a | b;
if ( c != 507)
tstlog_vlog(log, "E", "operators, int | error");
return 0;
endif
c = a;
c += b;
if ( c != 579)
tstlog_vlog(log, "E", "operators, int += error");
return 0;
endif
c = a;
c -= b;
if ( c != -333)
tstlog_vlog(log, "E", "operators, int -= error");
return 0;
endif
# Not yet implemented...
# c = a;
# c &= b;
# if ( c != 72)
# tstlog_vlog(log, "E", "operators, int &= error");
# return 0;
# endif
#
# c = a;
# c |= b;
# if ( c != 507)
# tstlog_vlog(log, "E", "operators, int |= error");
# return 0;
# endif
# Boolean operators
a = 1;
b = 0;
c = a && b;
if ( c != 0)
tstlog_vlog(log, "E", "operators, boolean && error");
return 0;
endif
c = a || b;
if ( c != 1)
tstlog_vlog(log, "E", "operators, boolean || error");
return 0;
endif
c = !b;
if ( c != 1)
tstlog_vlog(log, "E", "operators, boolean ! error");
return 0;
endif
# Float operators
fc = fa + fb;
if ( fc != 579)
tstlog_vlog(log, "E", "operators, float * error");
return 0;
endif
fc = fa - fb;
if ( fc != -333)
tstlog_vlog(log, "E", "operators, float - error");
return 0;
endif
fc = fa * fb;
if ( fc != 56088)
tstlog_vlog(log, "E", "operators, float * error");
return 0;
endif
fc = fb / fa;
if ( fc < 3.70 || fc > 3.71)
tstlog_vlog(log, "E", "operators, float / error");
return 0;
endif
fc = fa;
fc++;
if ( fc != 124)
tstlog_vlog(log, "E", "operators, float ++ error");
return 0;
endif
fc--;
if ( fc != 123)
tstlog_vlog(log, "E", "operators, float -- error");
return 0;
endif
fc = fa;
fc += fb;
if ( fc != 579)
tstlog_vlog(log, "E", "operators, float += error");
return 0;
endif
fc = fa;
fc -= fb;
if ( fc != -333)
tstlog_vlog(log, "E", "operators, float -= error");
return 0;
endif
tstlog_log(log, "S", "operators: Successfull completion");
return 1;
endfunction
function int ccm_loop(int log)
int c;
int i;
int a = 10;
c = 0;
for ( i = 0; i < a; i++)
if ( c != i)
tstlog_vlog(log, "E", "loop, for mismatch %d != %d", c, i);
return 0;
endif
c++;
endfor
if ( c != 10)
sts = 0;
endif
c = 0;
for ( i = 0; i < 20; i += 2)
if ( c != i)
tstlog_vlog(log, "E", "loop, for mismatch %d != %d", c, i);
return 0;
endif
c++;
c++;
if ( c == 8)
break;
endif
endfor
if ( c != 8)
tstlog_vlog(log, "E", "loop, for mismatch %d != %d", c, 8);
return 0;
endif
c = 0;
for ( i = 0; i < 10; i++)
if ( i < 4 && c != i)
sts = 0;
endif
if ( i >= 4 && c != 4)
tstlog_vlog(log, "E", "loop, for mismatch %d != %d", c, i);
return 0;
endif
if ( c >= 4)
continue;
endif
c++;
endfor
if ( c != 4)
tstlog_vlog(log, "E", "loop, for mismatch %d != %d", c, 4);
return 0;
endif
c = 0;
i = 0;
while ( i < a)
if ( c != i)
tstlog_vlog(log, "E", "loop, while mismatch %d != %d", c, i);
return 0;
endif
i++;
c++;
endwhile
if ( c != 10)
tstlog_vlog(log, "E", "loop, while mismatch %d != %d", c, 10);
return 0;
endif
c = 0;
i = 0;
while ( i < 20)
if ( c != i)
tstlog_vlog(log, "E", "loop, while mismatch %d != %d", c, i);
return 0;
endif
c++;
c++;
i += 2;
if ( c == 8)
break;
endif
endwhile
if ( c != 8)
tstlog_vlog(log, "E", "loop, for mismatch %d != %d", c, 8);
return 0;
endif
c = 0;
i = 0;
while ( i < 10)
if ( i < 4 && c != i)
tstlog_vlog(log, "E", "loop, while mismatch %d != %d", c, i);
return 0;
endif
if ( i >= 4 && c != 4)
tstlog_vlog(log, "E", "loop, while mismatch %d != %d", c, i);
return 0;
endif
i++;
if ( c >= 4)
continue;
endif
c++;
endwhile
if ( c != 4)
tstlog_vlog(log, "E", "loop, for mismatch %d != %d", c, 4);
return 0;
endif
tstlog_log(log, "S", "loop: Successfull completion");
return 1;
endfunction
function int ccm_edit(int log)
int i;
string edited;
string d[4];
string r[4];
d[0] = " qwe rty ";
r[0] = "qwe rty";
d[1] = "qwe rty ";
r[1] = "qwe rty";
d[2] = " qwe rty";
r[2] = "qwe rty";
d[3] = " This is a string ";
r[3] = "This is a string";
for (i = 0; i < 3; i++)
edited = edit(d[i]);
if (edited != r[i])
tstlog_vlog(log, "E", "edit, mismatch %s != %s", r[i], edited);
return 0;
endif
endfor
tstlog_log(log, "S", "edit: Successfull completion");
return 1;
endfunction
function int ccm_element(int log)
int i;
string elem[4];
string r1[3];
string r2[3];
string r3[3];
string r4[3];
string d[3];
d[0] = "mary,lisa,anna,john";
r1[0] = "mary";
r2[0] = "lisa";
r3[0] = "anna";
r4[0] = "john";
d[2] = "mary,,anna,john";
r1[2] = "mary";
r2[2] = "";
r3[2] = "anna";
r4[2] = "john";
d[3] = "Adam,Hoss,Joe,Ben";
r1[3] = "Adam";
r2[3] = "Hoss";
r3[3] = "Joe";
r4[3] = "Ben";
for (i = 0; i < 3; i++)
elem[0] = element(1, ",", d[i]);
elem[1] = element(2, ",", d[i]);
elem[2] = element(3, ",", d[i]);
elem[3] = element(4, ",", d[i]);
if (elem[0] != r1[i] || elem[1] != r2[i] || elem[2] != r3[i] || elem[3] != r4[i])
tstlog_vlog(log, "E", "element, mismatch %d %s", i, d[i]);
return 0;
endif
endfor
tstlog_log(log, "S", "element: Successfull completion");
return 1;
endfunction
function int ccm_extract(int log)
int i;
int i2;
string extracted;
string str = "Time takes a cigarett";
string r[4];
int ix1[4];
int ix2[4];
ix1[0] = 1;
ix2[0] = 7;
r[0] = "Time ta";
ix1[1] = 1;
ix2[1] = 27;
r[1] = "Time takes a cigarett";
ix1[2] = 4;
ix2[2] = 14;
r[2] = "e takes a ciga";
ix1[3] = 21;
ix2[3] = 7;
r[3] = "t";
for (i = 0; i < 3; i++)
extracted = extract(ix1[i], ix2[i], str);
if (extracted != r[i])
tstlog_vlog(log, "E", "extract, mismatch %s != %s", r[i], extracted);
return 0;
endif
endfor
tstlog_log(log, "S", "extract: Successfull completion");
return 1;
endfunction
function int ccm_sprintf(int log)
int i;
string result;
string format[9];
string r[9];
int iarg = 1234;
float farg = 5.678;
string sarg = "Chevy";
format[0] = "Teststring %s and %s";
r[0] = "Teststring Chevy and Chevy";
format[1] = "Teststring %s and %d";
r[1] = "Teststring Chevy and 1234";
format[2] = "Teststring %s and %4.2f";
r[2] = "Teststring Chevy and 5.68";
format[3] = "Teststring %d and %s";
r[3] = "Teststring 1234 and Chevy";
format[4] = "Teststring %d and %d";
r[4] = "Teststring 1234 and 1234";
format[5] = "Teststring %d and %4.2f";
r[5] = "Teststring 1234 and 5.68";
format[6] = "Teststring %4.2f and %s";
r[6] = "Teststring 5.68 and Chevy";
format[7] = "Teststring %4.2f and %d";
r[7] = "Teststring 5.68 and 1234";
format[8] = "Teststring %4.2f and %4.2f";
r[8] = "Teststring 5.68 and 5.68";
for (i = 0; i < 9; i++)
if (i == 0)
sprintf(result, format[i], sarg, sarg);
endif
if (i == 1)
sprintf(result, format[i], sarg, iarg);
endif
if (i == 2)
sprintf(result, format[i], sarg, farg);
endif
if (i == 3)
sprintf(result, format[i], iarg, sarg);
endif
if (i == 4)
sprintf(result, format[i], iarg, iarg);
endif
if (i == 5)
sprintf(result, format[i], iarg, farg);
endif
if (i == 6)
sprintf(result, format[i], farg, sarg);
endif
if (i == 7)
sprintf(result, format[i], farg, iarg);
endif
if (i == 8)
sprintf(result, format[i], farg, farg);
endif
if (result != r[i])
tstlog_vlog(log, "E", "sprintf, mismatch %s != %s", r[i], result);
return 0;
endif
endfor
tstlog_log(log, "S", "sprintf: Successfull completion");
return 1;
endfunction
function int ccm_strchr(int log)
int i;
int idx;
string str = "/usr/local/pwrrt/bld";
string c[5];
int r[5];
c[0] = "l";
r[0] = 6;
c[1] = "d";
r[1] = 20;
c[2] = "/";
r[2] = 1;
c[3] = "r";
r[3] = 4;
c[4] = "x";
r[4] = 0;
for (i = 0; i < 5; i++)
idx = strchr(str, c[i]);
if (idx != r[i])
tstlog_vlog(log, "E", "strchr, mismatch %d, %d != %d", i, r[i], idx);
return 0;
endif
endfor
tstlog_log(log, "S", "strchr: Successfull completion");
return 1;
endfunction
function int ccm_strrchr(int log)
int i;
int idx;
string str = "/usr/local/pwrrt/bld";
string c[5];
int r[5];
c[0] = "l";
r[0] = 19;
c[1] = "d";
r[1] = 20;
c[2] = "/";
r[2] = 17;
c[3] = "r";
r[3] = 15;
c[4] = "x";
r[4] = 0;
for (i = 0; i < 5; i++)
idx = strrchr(str, c[i]);
if (idx != r[i])
tstlog_vlog(log, "E", "strchr, mismatch %d, %d != %d", i, r[i], idx);
return 0;
endif
endfor
tstlog_log(log, "S", "strrchr: Successfull completion");
return 1;
endfunction
function int ccm_strlen(int log)
int i;
int len;
string str[4];
int r[4];
str[0] = "/usr/local/pwrrt/bld";
r[0] = 20;
str[1] = "/";
r[1] = 1;
str[2] = "";
r[2] = 0;
str[3] = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
r[3] = 100;
for (i = 0; i < 4; i++)
len = strlen(str[i]);
if (len != r[i])
tstlog_vlog(log, "E", "strlen, mismatch %d, %d != %d", i, r[i], len);
return 0;
endif
endfor
tstlog_log(log, "S", "strlen: Successfull completion");
return 1;
endfunction
function int ccm_strstr(int log)
int i;
int idx;
string str = "/usr/local/pwrrt/Bld";
string c[7];
int r[7];
c[0] = "loc";
r[0] = 6;
c[1] = "d";
r[1] = 20;
c[2] = "/usr";
r[2] = 1;
c[3] = "rt";
r[3] = 15;
c[4] = "rtx";
r[4] = 0;
c[5] = "rt/B";
r[5] = 15;
c[6] = "rt/b";
r[6] = 0;
for (i = 0; i < 7; i++)
idx = strstr(str, c[i]);
if (idx != r[i])
tstlog_vlog(log, "E", "strstr, mismatch %d, %d != %d", i, r[i], idx);
return 0;
endif
endfor
tstlog_log(log, "S", "strstr: Successfull completion");
return 1;
endfunction
function int ccm_toupper(int log)
int i;
string upstr;
string str[4];
string r[4];
str[0] = "loc";
r[0] = "LOC";
str[1] = "/Loc22s";
r[1] = "/LOC22S";
str[2] = "# Convert string to upper case.";
r[2] = "# CONVERT STRING TO UPPER CASE.";
str[3] = "";
r[3] = "";
for (i = 0; i < 4; i++)
upstr = toupper(str[i]);
if (upstr != r[i])
tstlog_vlog(log, "E", "toupper, mismatch %d, %s != %s", i, r[i], upstr);
return 0;
endif
endfor
tstlog_log(log, "S", "toupper: Successfull completion");
return 1;
endfunction
function int ccm_tolower(int log)
int i;
string lowstr;
string str[4];
string r[4];
str[0] = "LOC";
r[0] = "loc";
str[1] = "/Loc22S";
r[1] = "/loc22s";
str[2] = "# CONVERT STRING TO LOWER CASE.";
r[2] = "# convert string to lower case.";
str[3] = "";
r[3] = "";
for (i = 0; i < 4; i++)
lowstr = tolower(str[i]);
if (lowstr != r[i])
tstlog_vlog(log, "E", "tolower, mismatch %d, %s != %s", i, r[i], lowstr);
return 0;
endif
endfor
tstlog_log(log, "S", "tolower: Successfull completion");
return 1;
endfunction
function int ccm_fopen(int log)
int i;
string fname;
int fp;
string cmd;
int sts;
fname = translate_filename("/tmp/ra_ccmtest.txt");
cmd = "if [ -e " + fname + " ]; then rm -f " + fname + "; fi";
sts = system(cmd);
fp = fopen(fname, "w");
if (!fp)
tstlog_vlog(log, "E", "fopen, unable to open file %s", fname);
return 0;
endif
fclose(fp);
cmd = "ls " + fname + " 1>/dev/null 2>/dev/null";
sts = system(cmd);
if (sts != 0)
tstlog_vlog(log, "E", "fopen, no file created %d, %s", sts, fname);
return 0;
endif
tstlog_log(log, "S", "fopen: Successfull completion");
cmd = "if [ -e " + fname + " ]; then rm -f " + fname + "; fi";
sts = system(cmd);
return 1;
endfunction
function int ccm_fprintf(int log)
int i;
int sts;
string fname;
int fp;
string cmd;
string result;
string format[9];
string r[9];
int iarg = 1234;
float farg = 5.678;
string sarg = "Chevy";
format[0] = "Teststring %s and %s\n";
r[0] = "Teststring Chevy and Chevy";
format[1] = "Teststring %s and %d\n";
r[1] = "Teststring Chevy and 1234";
format[2] = "Teststring %s and %4.2f\n";
r[2] = "Teststring Chevy and 5.68";
format[3] = "Teststring %d and %s\n";
r[3] = "Teststring 1234 and Chevy";
format[4] = "Teststring %d and %d\n";
r[4] = "Teststring 1234 and 1234";
format[5] = "Teststring %d and %4.2f\n";
r[5] = "Teststring 1234 and 5.68";
format[6] = "Teststring %4.2f and %s\n";
r[6] = "Teststring 5.68 and Chevy";
format[7] = "Teststring %4.2f and %d\n";
r[7] = "Teststring 5.68 and 1234";
format[8] = "Teststring %4.2f and %4.2f\n";
r[8] = "Teststring 5.68 and 5.68";
fname = translate_filename("/tmp/ra_ccmtest.txt");
cmd = "if [ -e " + fname + " ]; then rm -f " + fname + "; fi";
sts = system(cmd);
fp = fopen(fname, "w");
if (!fp)
tstlog_vlog(log, "E", "fprintf, unable to open file %s", fname);
return 0;
endif
for (i = 0; i < 9; i++)
if (i == 0)
fprintf(fp, format[i], sarg, sarg);
endif
if (i == 1)
fprintf(fp, format[i], sarg, iarg);
endif
if (i == 2)
fprintf(fp, format[i], sarg, farg);
endif
if (i == 3)
fprintf(fp, format[i], iarg, sarg);
endif
if (i == 4)
fprintf(fp, format[i], iarg, iarg);
endif
if (i == 5)
fprintf(fp, format[i], iarg, farg);
endif
if (i == 6)
fprintf(fp, format[i], farg, sarg);
endif
if (i == 7)
fprintf(fp, format[i], farg, iarg);
endif
if (i == 8)
fprintf(fp, format[i], farg, farg);
endif
endfor
fclose(fp);
fp = fopen(fname, "r");
if (!fp)
tstlog_vlog(log, "E", "fprintf, unable to open file for reading %s", fname);
fclose(fp);
return 0;
endif
for (i = 0; i < 9; i++)
sts = fgets(result, fp);
if (sts == 0)
tstlog_vlog(log, "E", "fprintf, couldn't read line %d in file %s", i, fname);
return 0;
endif
if (result != r[i])
tstlog_vlog(log, "E", "fprintf, mismatch %d, %s != %s", i, r[i], result);
return 0;
endif
endfor
fclose(fp);
tstlog_log(log, "S", "fprintf: Successfull completion");
cmd = "if [ -e " + fname + " ]; then rm -f " + fname + "; fi";
sts = system(cmd);
return 1;
endfunction
function int ccm_felement(int log)
int i;
int sts;
string fname;
int fp;
string cmd;
string line;
string elem[4];
string r1[3];
string r2[3];
string r3[3];
string r4[3];
string d[3];
d[0] = "mary,lisa,anna,john";
r1[0] = "mary";
r2[0] = "lisa";
r3[0] = "anna";
r4[0] = "john";
d[2] = "mary,,anna,john";
r1[2] = "mary";
r2[2] = "";
r3[2] = "anna";
r4[2] = "john";
d[3] = "Adam,Hoss,Joe,Ben";
r1[3] = "Adam";
r2[3] = "Hoss";
r3[3] = "Joe";
r4[3] = "Ben";
fname = translate_filename("/tmp/ra_ccmtest.txt");
cmd = "if [ -e " + fname + " ]; then rm -f " + fname + "; fi";
sts = system(cmd);
fp = fopen(fname, "w");
if (!fp)
tstlog_vlog(log, "E", "felement, unable to open file %s", fname);
return 0;
endif
for (i = 0; i < 3; i++)
fprintf(fp, "%s\n", d[i]);
endfor
fclose(fp);
fp = fopen(fname, "r");
if (!fp)
tstlog_vlog(log, "E", "felement, unable to open file for reading %s", fname);
fclose(fp);
return 0;
endif
for (i = 0; i < 3; i++)
sts = fgets(line, fp);
if (sts == 0)
tstlog_vlog(log, "E", "felement, couldn't read line %d in file %s", i, fname);
return 0;
endif
elem[0] = element(1, ",", line);
elem[1] = element(2, ",", line);
elem[2] = element(3, ",", line);
elem[3] = element(4, ",", line);
if (elem[0] != r1[i] || elem[1] != r2[i] || elem[2] != r3[i] || elem[3] != r4[i])
tstlog_vlog(log, "E", "felement, mismatch %d %s", i, d[i]);
return 0;
endif
endfor
tstlog_log(log, "S", "felement: Successfull completion");
return 1;
endfunction
function int ccm_getmsg(int log)
int i;
string status;
int d[3];
string r[3];
d[0] = 5;
r[0] = "%NONAME-?-NOMSG, Message number 00000005";
d[1] = 141459465;
r[1] = "%GDH-S-SUCCESS, successful completion";
d[2] = 141459522;
r[2] = "%GDH-E-NO_TYPE, no more objects of same type exists";
for (i = 0; i < 3; i++)
status = getmsg(d[i]);
if (status != r[i])
tstlog_vlog(log, "E", "getmsg, mismatch %d, %s != %s", i, r[i], status);
return 0;
endif
endfor
tstlog_log(log, "S", "getmsg: Successfull completion");
return 1;
endfunction
function int ccm_get_node_name(int log)
string node;
string fname = "/tmp/ccm_nodename.txt";
string cmd;
int fp;
string line;
int sts;
cmd = "uname -n > " + fname;
system(cmd);
fp = fopen(fname, "r");
if (!fp)
tstlog_vlog(log, "E", "unable to open file %s", fname);
return 0;
endif
fgets(line, fp);
fclose(fp);
cmd = "if [ -e " + fname + " ]; then rm -f " + fname + "; fi";
sts = system(cmd);
node = get_node_name();
if (node != line)
tstlog_vlog(log, "E", "get_node_name, mismatch, %s != %s", node, line);
return 0;
endif
tstlog_log(log, "S", "get_node_name: Successfull completion");
return 1;
endfunction
main()
int log;
verify(0);
log = tstlog_open("co-Ccm", "$pwrp_log/ccm.log");
ccm_declarations(log);
ccm_operators(log);
ccm_loop(log);
ccm_edit(log);
ccm_element(log);
ccm_extract(log);
ccm_sprintf(log);
ccm_strchr(log);
ccm_strrchr(log);
ccm_strlen(log);
ccm_strstr(log);
ccm_toupper(log);
ccm_tolower(log);
ccm_fopen(log);
ccm_fprintf(log);
ccm_felement(log);
ccm_getmsg(log);
ccm_get_node_name(log);
tstlog_close(log);
endmain
/*
Test gdh functions.
*/
#include <stdio.h>
#include <stddef.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include "pwr_class.h"
#include "co_msg.h"
#include "co_dcli.h"
#include "rt_gdh.h"
#include "ra_cdhtest.h"
#include "co_cdh_msg.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_cvolpwrtest01classes.h"
typedef struct {
pwr_tOid oid1;
pwr_tOid oid2;
int sts;
} sObjidCompare;
void ra_cdhtest::ObjidCompare(void)
{
sObjidCompare d[] = {
{pwr_cNOid, pwr_cNOid, 0},
{{11111,1}, {11111,1}, 0},
{{11112,1}, {11111,1}, 1},
{{11111,1}, {11112,1}, -1},
{{11112,2}, {11111,1}, 1},
{{11111,2}, {11112,1}, 1},
{{11112,1}, {11111,2}, -1},
{{11111,1}, {11112,2}, -1}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = cdh_ObjidCompare(d[i].oid1, d[i].oid2);
if (sts != d[i].sts) {
m_log->log('E', "ObjidCompare", i);
return;
}
}
m_log->log('S', "ObjidCompare", CDH__SUCCESS);
}
void ra_cdhtest::ObjidIsEqual(void)
{
sObjidCompare d[] = {
{pwr_cNOid, pwr_cNOid, 1},
{{11111,1}, {11111,1}, 1},
{{11112,1}, {11111,1}, 0},
{{11111,1}, {11112,1}, 0},
{{11112,2}, {11111,1}, 0},
{{11111,2}, {11112,1}, 0},
{{11112,1}, {11111,2}, 0},
{{11111,1}, {11112,2}, 0}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = cdh_ObjidIsEqual(d[i].oid1, d[i].oid2);
if (sts != d[i].sts) {
m_log->log('E', "ObjidIsEqual", i);
return;
}
}
m_log->log('S', "ObjidIsEqual", CDH__SUCCESS);
}
void ra_cdhtest::ObjidIsNotEqual(void)
{
sObjidCompare d[] = {
{pwr_cNOid, pwr_cNOid, 0},
{{11111,1}, {11111,1}, 0},
{{11112,1}, {11111,1}, 1},
{{11111,1}, {11112,1}, 1},
{{11112,2}, {11111,1}, 1},
{{11111,2}, {11112,1}, 1},
{{11112,1}, {11111,2}, 1},
{{11111,1}, {11112,2}, 1}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = cdh_ObjidIsNotEqual(d[i].oid1, d[i].oid2);
if (sts != d[i].sts) {
m_log->log('E', "ObjidIsNotEqual", i);
return;
}
}
m_log->log('S', "ObjidIsNotEqual", CDH__SUCCESS);
}
typedef struct {
pwr_tOid oid;
int sts;
} sObjidIsNull;
void ra_cdhtest::ObjidIsNull(void)
{
sObjidIsNull d[] = {
{pwr_cNOid, 1},
{{11111,1}, 0},
{{11112,1}, 0},
{{0,1}, 0},
{{11112,0}, 0},
{{11111,0}, 0}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = cdh_ObjidIsNull(d[i].oid);
if (sts != d[i].sts) {
m_log->log('E', "ObjidIsNull", i);
return;
}
}
m_log->log('S', "ObjidIsNull", CDH__SUCCESS);
}
void ra_cdhtest::ObjidIsNotNull(void)
{
sObjidIsNull d[] = {
{pwr_cNOid, 0},
{{11111,1}, 1},
{{11112,1}, 1},
{{0,1}, 1},
{{11112,0}, 1},
{{11111,0}, 1}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = cdh_ObjidIsNotNull(d[i].oid);
if (sts != d[i].sts) {
m_log->log('E', "ObjidIsNotNull", i);
return;
}
}
m_log->log('S', "ObjidIsNotNull", CDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
pwr_tCid cid;
int sts;
} sClassObjidToId;
void ra_cdhtest::ClassObjidToId(void)
{
sClassObjidToId d[] = {
{"pwrs:Class-$ClassDef", pwr_cClass_ClassDef},
{"pwrs:Class-$PlantHier", pwr_cClass_PlantHier},
{"pwrb:Class-And", pwr_cClass_and},
{"BaseComponent:Class-BaseSensor", pwr_cClass_BaseSensor}
};
pwr_tCid cid;
pwr_tOid oid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = gdh_NameToObjid(d[i].name, &oid);
if (EVEN(m_sts)) {
m_log->log('E', "ClassObjidToId, gdh_NameToObjid", i);
return;
}
cid = cdh_ClassObjidToId(oid);
if (cid != d[i].cid) {
m_log->log('E', "ClassObjidToId", i);
return;
}
}
m_log->log('S', "ClassObjidToId", CDH__SUCCESS);
}
typedef struct {
pwr_tCid cid;
pwr_tOName name;
int sts;
} sClassIdToObjid;
void ra_cdhtest::ClassIdToObjid(void)
{
sClassIdToObjid d[] = {
{pwr_cClass_ClassDef, "pwrs:Class-$ClassDef"},
{pwr_cClass_PlantHier, "pwrs:Class-$PlantHier"},
{pwr_cClass_and, "pwrb:Class-And"},
{pwr_cClass_BaseSensor, "BaseComponent:Class-BaseSensor"}
};
pwr_tOid doid, oid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = gdh_NameToObjid(d[i].name, &oid);
if (EVEN(m_sts)) {
m_log->log('E', "ClassIdToObjid, gdh_NameToObjid", i);
return;
}
doid = cdh_ClassIdToObjid(d[i].cid);
if (cdh_ObjidIsNotEqual(oid, doid)) {
m_log->log('E', "ClassIdToObjid", i);
return;
}
}
m_log->log('S', "ClassIdToObjid", CDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
pwr_tTypeId type;
int sts;
} sTypeObjidToId;
void ra_cdhtest::TypeObjidToId(void)
{
sTypeObjidToId d[] = {
{"pwrs:Type-$Boolean", pwr_eType_Boolean},
{"pwrs:Type-$Float32", pwr_eType_Float32},
{"pwrs:Type-$Float64", pwr_eType_Float64},
{"pwrs:Type-$Int8", pwr_eType_Int8},
{"pwrs:Type-$Int16", pwr_eType_Int16},
{"pwrs:Type-$Int32", pwr_eType_Int32},
{"pwrs:Type-$Int64", pwr_eType_Int64},
{"pwrs:Type-$UInt8", pwr_eType_UInt8},
{"pwrs:Type-$UInt16", pwr_eType_UInt16},
{"pwrs:Type-$UInt32", pwr_eType_UInt32},
{"pwrs:Type-$UInt64", pwr_eType_UInt64},
{"pwrs:Type-$Mask", pwr_eType_Mask},
{"pwrs:Type-$Enum", pwr_eType_Enum},
{"pwrs:Type-$Time", pwr_eType_Time},
{"pwrs:Type-$DeltaTime", pwr_eType_DeltaTime},
{"pwrs:Type-$Status", pwr_eType_Status},
{"pwrs:Type-$Objid", pwr_eType_Objid},
{"pwrs:Type-$AttrRef", pwr_eType_AttrRef},
{"pwrs:Type-$VolumeId", pwr_eType_VolumeId},
{"pwrs:Type-$String", pwr_eType_String}
};
pwr_tTypeId type;
pwr_tOid oid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = gdh_NameToObjid(d[i].name, &oid);
if (EVEN(m_sts)) {
m_log->log('E', "TypeObjidToId, gdh_NameToObjid", i);
return;
}
type = cdh_TypeObjidToId(oid);
if (type != d[i].type) {
m_log->log('E', "TypeObjidToId", i);
return;
}
}
m_log->log('S', "TypeObjidToId", CDH__SUCCESS);
}
typedef struct {
pwr_tTypeId type;
pwr_tOName name;
int sts;
} sTypeIdToObjid;
void ra_cdhtest::TypeIdToObjid(void)
{
sTypeIdToObjid d[] = {
{pwr_eType_Boolean, "pwrs:Type-$Boolean"},
{pwr_eType_Float32, "pwrs:Type-$Float32"},
{pwr_eType_Float64, "pwrs:Type-$Float64"},
{pwr_eType_Int8, "pwrs:Type-$Int8"},
{pwr_eType_Int16, "pwrs:Type-$Int16"},
{pwr_eType_Int32, "pwrs:Type-$Int32"},
{pwr_eType_Int64, "pwrs:Type-$Int64"},
{pwr_eType_UInt8, "pwrs:Type-$UInt8"},
{pwr_eType_UInt16, "pwrs:Type-$UInt16"},
{pwr_eType_UInt32, "pwrs:Type-$UInt32"},
{pwr_eType_UInt64, "pwrs:Type-$UInt64"},
{pwr_eType_Mask, "pwrs:Type-$Mask"},
{pwr_eType_Enum, "pwrs:Type-$Enum"},
{pwr_eType_Time, "pwrs:Type-$Time"},
{pwr_eType_DeltaTime, "pwrs:Type-$DeltaTime"},
{pwr_eType_Status, "pwrs:Type-$Status"},
{pwr_eType_Objid, "pwrs:Type-$Objid"},
{pwr_eType_AttrRef, "pwrs:Type-$AttrRef"},
{pwr_eType_VolumeId, "pwrs:Type-$VolumeId"},
{pwr_eType_String, "pwrs:Type-$String"}
};
pwr_tOid doid, oid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = gdh_NameToObjid(d[i].name, &oid);
if (EVEN(m_sts)) {
m_log->log('E', "TypeIdToObjid, gdh_NameToObjid", i);
return;
}
doid = cdh_TypeIdToObjid(d[i].type);
if (cdh_ObjidIsNotEqual(oid, doid)) {
m_log->log('E', "TypeIdToObjid", i);
return;
}
}
m_log->log('S', "TypeIdToObjid", CDH__SUCCESS);
}
typedef struct {
pwr_tTypeId type;
int tix;
} sTypeIdToIndex;
void ra_cdhtest::TypeIdToIndex(void)
{
sTypeIdToIndex d[] = {
{pwr_eType_Boolean, pwr_eTix_Boolean},
{pwr_eType_Float32, pwr_eTix_Float32},
{pwr_eType_Float64, pwr_eTix_Float64},
{pwr_eType_Int32, pwr_eTix_Int32}
};
int tix;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
tix = cdh_TypeIdToIndex(d[i].type);
if (tix != d[i].tix) {
m_log->log('E', "TypeIdToIndex", i);
return;
}
}
m_log->log('S', "TypeIdToIndex", CDH__SUCCESS);
}
typedef struct {
pwr_tOid oid;
pwr_tAttrRef aref;
} sObjidToAref;
void ra_cdhtest::ObjidToAref(void)
{
sObjidToAref d[] = {
{{13454,1},{{13454,1},0,0,0, pwr_mAttrRef_Object}},
{{12345,6789},{{12345,6789},0,0,0, pwr_mAttrRef_Object}}
};
pwr_tAttrRef aref;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
aref = cdh_ObjidToAref(d[i].oid);
if (memcmp(&aref, &d[i].aref, sizeof(pwr_tAttrRef)) != 0) {
m_log->log('E', "ObjidToAref", i);
return;
}
}
m_log->log('S', "ObjidToAref", CDH__SUCCESS);
}
typedef union {
pwr_tBoolean b;
pwr_tInt32 i8;
pwr_tUInt32 ui8;
pwr_tInt32 i16;
pwr_tUInt32 ui16;
pwr_tInt32 i32;
pwr_tUInt32 ui32;
pwr_tInt32 i64;
pwr_tUInt32 ui64;
pwr_tFloat32 f32;
pwr_tFloat64 f64;
char s40[40];
pwr_tTime t;
pwr_tDeltaTime dt;
pwr_tOid oid;
pwr_tAttrRef aref;
} uValueToString;
typedef struct {
pwr_eType type;
uValueToString value;
char str[40];
} sAttrValueToString;
void ra_cdhtest::AttrValueToString(void)
{
char str[40];
sAttrValueToString d[] = {
{pwr_eType_Boolean, {.b=1}, "1"},
{pwr_eType_Char, {.i8=65}, "A"},
{pwr_eType_Int8, {.i8=120}, "120"},
{pwr_eType_UInt8, {.i8=222}, "222"},
{pwr_eType_Int16, {.i16=222}, "222"},
{pwr_eType_UInt16, {.i16=222}, "222"},
{pwr_eType_Int32, {.i32=222}, "222"},
{pwr_eType_UInt32, {.i32=222}, "222"},
{pwr_eType_Int64, {.i64=222}, "222"},
{pwr_eType_UInt64, {.i64=222}, "222"},
{pwr_eType_Mask, {.i32=0xffff}, "65535"},
{pwr_eType_Enum, {.i32=222}, "222"},
{pwr_eType_Float32, {.f32=222.22}, "222.22"},
{pwr_eType_Float64, {.f64=666.66}, "666.66"},
{pwr_eType_Time, {.t={1586956789,500000000}}, "15-APR-2020 15:19:49.50"},
{pwr_eType_DeltaTime,{.dt={54223,500000000}}, "15:03:43.50"},
{pwr_eType_String, {.s40={'S','o','m','e',' ','s','t','r','i','n','g',0,}}, "Some string"},
{pwr_eType_ProString, {.s40={'S','o','m','e',' ','s','t','r','i','n','g',0,}}, "***********"},
{pwr_eType_Text, {.s40={'S','o','m','e',' ','t','e','x','t',0,}}, "Some text"}
};
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_AttrValueToString(d[i].type, &d[i].value, str, sizeof(str));
if (EVEN(m_sts)) {
m_log->log('E', "AttrValueToString", d[i].str, m_sts);
return;
}
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "AttrValueToString", str);
return;
}
}
m_log->log('S', "AttrValueToString", CDH__SUCCESS);
}
typedef struct {
pwr_eType type;
uValueToString value;
int size;
char str[40];
} sStringToAttrValue;
void ra_cdhtest::StringToAttrValue(void)
{
char value[100];
sStringToAttrValue d[] = {
{pwr_eType_Boolean, {.b=1}, sizeof(pwr_tBoolean), "1"},
{pwr_eType_Char, {.i8=65}, sizeof(pwr_tChar), "A"},
{pwr_eType_Int8, {.i8=120}, sizeof(pwr_tInt8), "120"},
{pwr_eType_UInt8, {.i8=222}, sizeof(pwr_tUInt8), "222"},
{pwr_eType_Int16, {.i16=222}, sizeof(pwr_tInt16), "222"},
{pwr_eType_UInt16, {.i16=222}, sizeof(pwr_tUInt16), "222"},
{pwr_eType_Int32, {.i32=222}, sizeof(pwr_tInt32), "222"},
{pwr_eType_UInt32, {.i32=222}, sizeof(pwr_tUInt32), "222"},
{pwr_eType_Int64, {.i64=222}, sizeof(pwr_tInt64), "222"},
{pwr_eType_UInt64, {.i64=222}, sizeof(pwr_tUInt64), "222"},
{pwr_eType_Mask, {.i32=0xffff}, sizeof(pwr_tMask), "65535"},
{pwr_eType_Enum, {.i32=222}, sizeof(pwr_tEnum), "222"},
{pwr_eType_Float32, {.f32=222.22}, sizeof(pwr_tFloat32), "222.22"},
{pwr_eType_Float64, {.f64=666.66}, sizeof(pwr_tFloat64), "666.66"},
{pwr_eType_Time, {.t={1586956789,500000000}}, sizeof(pwr_tTime), "15-APR-2020 15:19:49.50"},
{pwr_eType_DeltaTime,{.dt={54223,500000000}}, sizeof(pwr_tDeltaTime), "15:03:43.50"},
{pwr_eType_String, {.s40={'S','o','m','e',' ','s','t','r','i','n','g',0,}}, 40, "Some string"},
{pwr_eType_Text, {.s40={'S','o','m','e',' ','t','e','x','t',0,}}, 40, "Some text"}
};
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToAttrValue(d[i].type, d[i].str, value);
if (EVEN(m_sts)) {
m_log->log('E', "StringToAttrValue", d[i].str, m_sts);
return;
}
switch (d[i].type) {
case pwr_eType_Float32:
if (fabs(d[i].value.f32 - *(pwr_tFloat32 *)&value) > 200*FLT_EPSILON) {
m_log->log('E', "StringToAttrValue", d[i].str);
return;
}
break;
case pwr_eType_Float64:
if (fabs(d[i].value.f64 - *(pwr_tFloat64 *)&value) > 600*FLT_EPSILON) {
m_log->log('E', "StringToAttrValue", d[i].str);
return;
}
break;
case pwr_eType_String:
case pwr_eType_ProString:
case pwr_eType_Text:
if (strcmp(d[i].value.s40, value) != 0) {
m_log->log('E', "StringToAttrValue", d[i].str);
return;
}
break;
default:
if (memcmp(&d[i].value, value, d[i].size) != 0) {
m_log->log('E', "StringToAttrValue", d[i].str);
return;
}
}
}
m_log->log('S', "StringToAttrValue", CDH__SUCCESS);
}
typedef struct {
pwr_tMask mask;
int noofbits;
char str[40];
} sMaskToBinaryString;
void ra_cdhtest::MaskToBinaryString(void)
{
sMaskToBinaryString d[] = {
{0x0001, 16, "0000000000000001"},
{0x000f, 16, "0000000000001111"},
{0x00f0, 16, "0000000011110000"},
{0x0f00, 16, "0000111100000000"},
{0xf000, 16, "1111000000000000"},
{0x8000, 16, "1000000000000000"},
{0x00000001, 32, "00000000000000000000000000000001"},
{0x0000000f, 32, "00000000000000000000000000001111"},
{0x000000f0, 32, "00000000000000000000000011110000"},
{0x00000f00, 32, "00000000000000000000111100000000"},
{0x0000f000, 32, "00000000000000001111000000000000"},
{0x00008000, 32, "00000000000000001000000000000000"},
{0x000f0000, 32, "00000000000011110000000000000000"},
{0x00f00000, 32, "00000000111100000000000000000000"},
{0x0f000000, 32, "00001111000000000000000000000000"},
{0xf0000000, 32, "11110000000000000000000000000000"},
{0x80000000, 32, "10000000000000000000000000000000"},
{0x27a4f68c, 32, "00100111101001001111011010001100"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
cdh_MaskToBinaryString(d[i].mask, d[i].noofbits, str);
if (strcmp(d[i].str, str) != 0) {
m_log->log('E', "MaskToBinaryString", str);
return;
}
}
m_log->log('S', "MaskToBinaryString", CDH__SUCCESS);
}
typedef struct {
char str[40];
pwr_tCid cid;
pwr_tStatus sts;
} sStringToClassId;
void ra_cdhtest::StringToClassId(void)
{
sStringToClassId d[] = {
{"0.1:1", 65544, CDH__SUCCESS},
{"0.1:10", (0 << 24) + (1 << 16) + (10 << 3), CDH__SUCCESS},
{"1.200:123", (1 << 24) + (200 << 16) + (123 << 3), CDH__SUCCESS},
{"_C0.1:1", 65544, CDH__SUCCESS},
{"_C0.1:10", (0 << 24) + (1 << 16) + (10 << 3), CDH__SUCCESS},
{"_C1.200:123", (1 << 24) + (200 << 16) + (123 << 3), CDH__SUCCESS},
{"_C255.255:444", ((unsigned int)255 << 24) + (255 << 16) + (444 << 3), CDH__SUCCESS},
{"_C1:10", 0, CDH__INVCID},
{"_C256.1:10", 0, CDH__INVCID},
{"_C1.1:4096", 0, CDH__INVCID},
{"1:10", 0, CDH__INVCID},
{"256.1:10", 0, CDH__INVCID},
{"1.1:4096", 0, CDH__INVCID}
};
pwr_tCid cid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToClassId(d[i].str, &cid);
if (m_sts != d[i].sts) {
m_log->log('E', "StringToClassId wrong sts", m_sts);
return;
}
if (ODD(m_sts)) {
if (cid != d[i].cid) {
m_log->log('E', "StringToClassId", i);
return;
}
}
}
m_log->log('S', "StringToClassId", CDH__SUCCESS);
}
typedef struct {
char str[40];
pwr_tOid oid;
pwr_tStatus sts;
} sStringToObjid;
void ra_cdhtest::StringToObjid(void)
{
sStringToObjid d[] = {
{"0.1.1.1:1", {1,(0<<24)+(1<<16)+(1<<8)+1}, CDH__SUCCESS},
{"_O0.1.1.1:1", {1,(0<<24)+(1<<16)+(1<<8)+1}, CDH__SUCCESS},
{"_o0.1.1.1:1", {1,(0<<24)+(1<<16)+(1<<8)+1}, CDH__SUCCESS},
{"200.44.55.66:77777", {77777,((unsigned int)200<<24)+(44<<16)+(55<<8)+66}, CDH__SUCCESS},
{"_O200.44.55.66:77777", {77777,((unsigned int)200<<24)+(44<<16)+(55<<8)+66}, CDH__SUCCESS},
{"1.1.1:1", pwr_cNOid, CDH__INVOID},
{"_O1.1.1:1", pwr_cNOid, CDH__INVOID},
{"1.1.1.1:", pwr_cNOid, CDH__INVOID},
{"_O1.1.1.1", pwr_cNOid, CDH__INVOID},
{"_O256.1.1.1:1", pwr_cNOid, CDH__INVOID},
{"_O1.256.1.1:1", pwr_cNOid, CDH__INVOID},
{"_O1.1.256.1:1", pwr_cNOid, CDH__INVOID},
{"_O1.1.1.256:1", pwr_cNOid, CDH__INVOID}
};
pwr_tOid oid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToObjid(d[i].str, &oid);
if (m_sts != d[i].sts) {
m_log->log('E', "StringToObjid wrong sts", m_sts);
return;
}
if (ODD(m_sts)) {
if (cdh_ObjidIsNotEqual(oid, d[i].oid)) {
m_log->log('E', "StringToObjid", i);
return;
}
}
}
m_log->log('S', "StringToObjid", CDH__SUCCESS);
}
typedef struct {
char str[40];
pwr_tAttrRef aref;
pwr_tStatus sts;
} sStringToAref;
void ra_cdhtest::StringToAref(void)
{
sStringToAref d[] = {
{"_A0.1.1.1:1(_T3.7:0.1.1)[120.4]", {{1,(0<<24)+(1<<16)+(1<<8)+1}, (3<<24)+(7<<16)+(1<<3)+(1),120,4,0}, CDH__SUCCESS},
{"_a0.1.1.1:1(_T3.7:0.1.1)[120.4]", {{1,(0<<24)+(1<<16)+(1<<8)+1}, (3<<24)+(7<<16)+(1<<3)+(1),120,4,0}, CDH__SUCCESS},
{"0.1.1.1:1(_T3.7:0.1.1)[120.4]", {{1,(0<<24)+(1<<16)+(1<<8)+1}, (3<<24)+(7<<16)+(1<<3)+(1),120,4,0}, CDH__SUCCESS},
{"0.1.1.1:1(_T3.7:0.3.1)[120.4]", {{1,(0<<24)+(1<<16)+(1<<8)+1}, (3<<24)+(7<<16)+(3<<3)+(1),120,4,0}, CDH__SUCCESS},
{"0.1.1.1:1(_T3.7:1.1.1)[120.4]", {{1,(0<<24)+(1<<16)+(1<<8)+1}, (3<<24)+(7<<16)+(1<<15)+(1<<11)+1,120,4,0}, CDH__SUCCESS},
{"0.1.1.1:1(_T3.7:1.3.1)[120.4]", {pwr_cNOid,0,0,0}, CDH__INVTID},
{"0.1.1.1:1(_T3.7:1.1.2048)[120.4]", {pwr_cNOid,0,0,0}, CDH__INVTID},
{"0.1.1.1:1(_T3.7:1.1.3)[120.4]", {{1,(0<<24)+(1<<16)+(1<<8)+1}, (3<<24)+(7<<16)+(1<<15)+(1<<11)+3,120,4,0}, CDH__SUCCESS}
};
pwr_tAttrRef aref;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToAref(d[i].str, &aref);
if (m_sts != d[i].sts) {
m_log->log('E', "StringToAref wrong sts", m_sts);
return;
}
if (ODD(m_sts)) {
if (memcmp(&aref, &d[i].aref, sizeof(pwr_tAttrRef)) != 0) {
m_log->log('E', "StringToAref", i);
return;
}
}
}
m_log->log('S', "StringToAref", CDH__SUCCESS);
}
typedef struct {
char str[40];
pwr_tTypeId type;
pwr_tStatus sts;
} sStringToTypeId;
void ra_cdhtest::StringToTypeId(void)
{
// vid.vid:1.cix.bix or vid.vid:0.tyg.tix
// vid: 0-255, cix:0-4095, bix:0-7, tyg:0-1, tix:0-247
sStringToTypeId d[] = {
{"3.7:0.1.1", (3<<24)+(7<<16)+(1<<3)+(1), CDH__SUCCESS},
{"3.7:0.3.1", (3<<24)+(7<<16)+(3<<3)+(1), CDH__SUCCESS},
{"_T3.7:0.1.1", (3<<24)+(7<<16)+(1<<3)+(1), CDH__SUCCESS},
{"_T3.7:0.3.1", (3<<24)+(7<<16)+(3<<3)+(1), CDH__SUCCESS},
{"_T3.7:0.4096.1", 0, CDH__INVTID},
{"_T3.7:0.1", 0, CDH__INVTID},
{"_T3.7:0.3.8", 0, CDH__INVTID},
{"_T256.7:0.3.1", 0, CDH__INVTID},
{"_T3.256:0.3.1", 0, CDH__INVTID},
{"_T3.7:0.4096.1", 0, CDH__INVTID},
{"_T3.7:1.1.1", (3<<24)+(7<<16)+(1<<15)+(1<<11)+1, CDH__SUCCESS},
{"_T3.7:1.3.1", 0, CDH__INVTID},
{"_T3.7:1.1.2048", 0, CDH__INVTID},
{"_T3.7:1.1.3", (3<<24)+(7<<16)+(1<<15)+(1<<11)+3, CDH__SUCCESS}
};
pwr_tTypeId type;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToTypeId(d[i].str, &type);
if (m_sts != d[i].sts) {
m_log->log('E', "StringToTypeId wrong sts", m_sts);
return;
}
if (ODD(m_sts)) {
if (type != d[i].type) {
m_log->log('E', "StringToTypeId", i);
return;
}
}
}
m_log->log('S', "StringToTypeId", CDH__SUCCESS);
}
typedef struct {
char str[40];
pwr_tVid vid;
pwr_tStatus sts;
} sStringToVolumeId;
void ra_cdhtest::StringToVolumeId(void)
{
sStringToVolumeId d[] = {
{"3.7.22.55", (3<<24)+(7<<16)+(22<<8)+55, CDH__SUCCESS},
{"_V3.7.22.55", (3<<24)+(7<<16)+(22<<8)+55, CDH__SUCCESS},
{"_v3.7.22.55", (3<<24)+(7<<16)+(22<<8)+55, CDH__SUCCESS},
{"_O3.7.22.55", (3<<24)+(7<<16)+(22<<8)+55, CDH__SUCCESS},
{"_A3.7.22.55", (3<<24)+(7<<16)+(22<<8)+55, CDH__SUCCESS},
{"_V256.7.22.55", 0, CDH__INVVID},
{"_V3.256.22.55", 0, CDH__INVVID},
{"_V3.7.256.55", 0, CDH__INVVID},
{"_V3.7.22.256", 0, CDH__INVVID}
};
pwr_tVid vid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToVolumeId(d[i].str, &vid);
if (m_sts != d[i].sts) {
m_log->log('E', "StringToVolumeId wrong sts", m_sts);
return;
}
if (ODD(m_sts)) {
if (vid != d[i].vid) {
m_log->log('E', "StringToVolumeId", i);
return;
}
}
}
m_log->log('S', "StringToVolumeId", CDH__SUCCESS);
}
typedef struct {
char str[40];
pwr_tOix oix;
pwr_tStatus sts;
} sStringToObjectIx;
void ra_cdhtest::StringToObjectIx(void)
{
sStringToObjectIx d[] = {
{"_X1", 1, CDH__SUCCESS},
{"_x1", 1, CDH__SUCCESS},
{"1", 1, CDH__SUCCESS},
{"_X123456789", 123456789, CDH__SUCCESS}
};
pwr_tOix oix;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToObjectIx(d[i].str, &oix);
if (m_sts != d[i].sts) {
m_log->log('E', "StringToObjectIx wrong sts", m_sts);
return;
}
if (ODD(m_sts)) {
if (oix != d[i].oix) {
m_log->log('E', "StringToObjectIx", i);
return;
}
}
}
m_log->log('S', "StringToObjectIx", CDH__SUCCESS);
}
typedef struct {
pwr_tCid cid;
int prefix;
char str[40];
} sClassIdToString;
void ra_cdhtest::ClassIdToString(void)
{
sClassIdToString d[] = {
{65544, 0, "0.1:1"},
{(0 << 24) + (1 << 16) + (10 << 3), 0, "0.1:10"},
{(1 << 24) + (200 << 16) + (123 << 3), 0, "1.200:123"},
{65544, 1, "_C0.1:1"},
{(0 << 24) + (1 << 16) + (10 << 3), 1, "_C0.1:10"},
{(1 << 24) + (200 << 16) + (123 << 3), 1, "_C1.200:123"},
{((unsigned int)255 << 24) + (255 << 16) + (444 << 3), 1, "_C255.255:444"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
cdh_ClassIdToString(str, sizeof(str), d[i].cid, d[i].prefix);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "ClassIdToString", i);
return;
}
}
m_log->log('S', "ClassIdToString", CDH__SUCCESS);
}
typedef struct {
pwr_tTypeId type;
int prefix;
char str[40];
} sTypeIdToString;
void ra_cdhtest::TypeIdToString(void)
{
sTypeIdToString d[] = {
{(3<<24)+(7<<16)+(1<<3)+(1), 0, "3.7:0.1.1"},
{(3<<24)+(7<<16)+(3<<3)+(1), 0, "3.7:0.3.1"},
{(3<<24)+(7<<16)+(1<<3)+(1), 1, "_T3.7:0.1.1"},
{(3<<24)+(7<<16)+(3<<3)+(1), 1, "_T3.7:0.3.1"},
{(3<<24)+(7<<16)+(1<<15)+(1<<11)+1, 1, "_T3.7:1.1.1"},
{(3<<24)+(7<<16)+(1<<15)+(1<<11)+3, 1, "_T3.7:1.1.3"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
cdh_TypeIdToString(str, sizeof(str), d[i].type, d[i].prefix);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "TypeIdToString", i);
return;
}
}
m_log->log('S', "TypeIdToString", CDH__SUCCESS);
}
typedef struct {
pwr_tOix oix;
int prefix;
char str[40];
} sObjectIxToString;
void ra_cdhtest::ObjectIxToString(void)
{
sObjectIxToString d[] = {
{1, 1, "_X1"},
{1, 0, "1"},
{123456789, 1, "_X123456789"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
cdh_ObjectIxToString(str, sizeof(str), d[i].oix, d[i].prefix);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "ObjectIxToString", i);
return;
}
}
m_log->log('S', "ObjectIxToString", CDH__SUCCESS);
}
typedef struct {
pwr_tAttrRef aref;
int prefix;
char str[40];
} sArefToString;
void ra_cdhtest::ArefToString(void)
{
sArefToString d[] = {
{{{1,(0<<24)+(1<<16)+(1<<8)+1}, (3<<24)+(7<<16)+(1<<3)+(1),120,4,0}, 1, "_A0.1.1.1:1(_T3.7:0.1.1)[120.4]"},
{{{1,(0<<24)+(1<<16)+(1<<8)+1}, (3<<24)+(7<<16)+(1<<3)+(1),120,4,0}, 0, "0.1.1.1:1(_T3.7:0.1.1)[120.4]"},
{{{1,(0<<24)+(1<<16)+(1<<8)+1}, (3<<24)+(7<<16)+(3<<3)+(1),120,4,0}, 0, "0.1.1.1:1(_T3.7:0.3.1)[120.4]"},
{{{1,(0<<24)+(1<<16)+(1<<8)+1}, (3<<24)+(7<<16)+(1<<15)+(1<<11)+1,120,4,0}, 0, "0.1.1.1:1(_T3.7:1.1.1)[120.4]"},
{{{1,(0<<24)+(1<<16)+(1<<8)+1}, (3<<24)+(7<<16)+(1<<15)+(1<<11)+3,120,4,0}, 0, "0.1.1.1:1(_T3.7:1.1.3)[120.4]"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
cdh_ArefToString(str, sizeof(str), &d[i].aref, d[i].prefix);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "ArefToString", i);
return;
}
}
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
strcpy(str, cdh_AttrRefToString(&d[i].aref, d[i].prefix));
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "ArefToString, AttrRefToString", i);
return;
}
}
m_log->log('S', "ArefToString", CDH__SUCCESS);
}
typedef struct {
pwr_tNodeId nid;
int prefix;
int suffix;
char str[40];
} sNodeIdToString;
void ra_cdhtest::NodeIdToString(void)
{
sNodeIdToString d[] = {
{pwr_cNNid, 0, 0, "0.0.0.0"},
{pwr_cNNid, 1, 0, "_N0.0.0.0"},
{pwr_cNNid, 1, 1, "_N0.0.0.0:"},
{(3<<24)+(7<<16)+(22<<8)+55, 0, 0, "3.7.22.55"},
{(3<<24)+(7<<16)+(22<<8)+55, 0, 1, "3.7.22.55:"},
{(3<<24)+(7<<16)+(22<<8)+55, 1, 0, "_N3.7.22.55"},
{(3<<24)+(7<<16)+(22<<8)+55, 1, 1, "_N3.7.22.55:"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
strcpy(str, "");
cdh_NodeIdToString(str, d[i].nid, d[i].prefix, d[i].suffix);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "NodeIdToString", i);
return;
}
}
m_log->log('S', "NodeIdToString", CDH__SUCCESS);
}
typedef struct {
pwr_tOid oid;
int prefix;
char str[40];
} sOidToString;
void ra_cdhtest::OidToString(void)
{
sOidToString d[] = {
{pwr_cNOid, 0, "0.0.0.0:0"},
{pwr_cNOid, 1, "_O0.0.0.0:0"},
{{1,(0<<24)+(1<<16)+(1<<8)+1}, 0, "0.1.1.1:1"},
{{1,(0<<24)+(1<<16)+(1<<8)+1}, 1, "_O0.1.1.1:1"},
{{77777,((unsigned int)200<<24)+(44<<16)+(55<<8)+66}, 0, "200.44.55.66:77777"},
{{77777,((unsigned int)200<<24)+(44<<16)+(55<<8)+66}, 1, "_O200.44.55.66:77777"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
cdh_OidToString(str, sizeof(str), d[i].oid, d[i].prefix);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "OidToString", i);
return;
}
}
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
strcpy(str, cdh_ObjidToString(d[i].oid, d[i].prefix));
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "OidToString, ObjidToString", i);
return;
}
}
m_log->log('S', "OidToString", CDH__SUCCESS);
}
void ra_cdhtest::OidToFnString(void)
{
sOidToString d[] = {
{pwr_cNOid, 0, "000_000_000_000_00000000"},
{{1,(0<<24)+(1<<16)+(1<<8)+1}, 0, "000_001_001_001_00000001"},
{{0x77777,((unsigned int)200<<24)+(44<<16)+(55<<8)+66}, 0, "200_044_055_066_00077777"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
strcpy(str, "");
cdh_ObjidToFnString(str, d[i].oid);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "OidToFnString, ObjidToString", i);
return;
}
}
m_log->log('S', "OidToFnString", CDH__SUCCESS);
}
typedef struct {
pwr_tVolumeId vid;
int prefix;
int suffix;
char str[40];
} sVolumeIdToString;
void ra_cdhtest::VolumeIdToString(void)
{
sVolumeIdToString d[] = {
{pwr_cNVid, 0, 0, "0.0.0.0"},
{pwr_cNVid, 1, 0, "_V0.0.0.0"},
{pwr_cNVid, 1, 1, "_V0.0.0.0:"},
{(3<<24)+(7<<16)+(22<<8)+55, 0, 0, "3.7.22.55"},
{(3<<24)+(7<<16)+(22<<8)+55, 0, 1, "3.7.22.55:"},
{(3<<24)+(7<<16)+(22<<8)+55, 1, 0, "_V3.7.22.55"},
{(3<<24)+(7<<16)+(22<<8)+55, 1, 1, "_V3.7.22.55:"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
strcpy(str, "");
cdh_VolumeIdToString(str, sizeof(str), d[i].vid, d[i].prefix, d[i].suffix);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "VolumeIdToString", i);
return;
}
}
m_log->log('S', "VolumeIdToString", CDH__SUCCESS);
}
void ra_cdhtest::VolumeIdToFnString(void)
{
sVolumeIdToString d[] = {
{pwr_cNVid, 0, 0, "000_000_000_000"},
{(3<<24)+(7<<16)+(22<<8)+55, 0, 0, "003_007_022_055"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
strcpy(str, "");
cdh_VolumeIdToFnString(str, sizeof(str), d[i].vid);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "VolumeIdToFnString", i);
return;
}
}
m_log->log('S', "VolumeIdToFnString", CDH__SUCCESS);
}
typedef struct {
pwr_tSubid oid;
int prefix;
char str[40];
} sSubidToString;
void ra_cdhtest::SubidToString(void)
{
sSubidToString d[] = {
{pwr_cNSubid, 0, "0.0.0.0:0"},
{pwr_cNSubid, 1, "_S0.0.0.0:0"},
{{1,(0<<24)+(1<<16)+(1<<8)+1}, 0, "0.1.1.1:1"},
{{1,(0<<24)+(1<<16)+(1<<8)+1}, 1, "_S0.1.1.1:1"},
{{77777,((unsigned int)200<<24)+(44<<16)+(55<<8)+66}, 0, "200.44.55.66:77777"},
{{77777,((unsigned int)200<<24)+(44<<16)+(55<<8)+66}, 1, "_S200.44.55.66:77777"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
cdh_SubidToString(str, sizeof(str), d[i].oid, d[i].prefix);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "SubidToString", i);
return;
}
}
m_log->log('S', "SubidToString", CDH__SUCCESS);
}
void ra_cdhtest::DlidToString(void)
{
sSubidToString d[] = {
{pwr_cNDlid, 0, "0.0.0.0:0"},
{pwr_cNDlid, 1, "_D0.0.0.0:0"},
{{1,(0<<24)+(1<<16)+(1<<8)+1}, 0, "0.1.1.1:1"},
{{1,(0<<24)+(1<<16)+(1<<8)+1}, 1, "_D0.1.1.1:1"},
{{77777,((unsigned int)200<<24)+(44<<16)+(55<<8)+66}, 0, "200.44.55.66:77777"},
{{77777,((unsigned int)200<<24)+(44<<16)+(55<<8)+66}, 1, "_D200.44.55.66:77777"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
cdh_DlidToString(str, sizeof(str), d[i].oid, d[i].prefix);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "DlidToString", i);
return;
}
}
m_log->log('S', "DlidToString", CDH__SUCCESS);
}
typedef struct {
char str[40];
char lowstr[40];
} sLow;
void ra_cdhtest::Low(void)
{
sLow d[] = {
{"AbCdEfGhIjKl", "abcdefghijkl"},
{"MNOPRSTUVXYZ", "mnoprstuvxyz"},
{"", ""}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
strcpy(str, cdh_Low(d[i].str));
if (strcmp(str, d[i].lowstr) != 0) {
m_log->log('E', "Low", i);
return;
}
}
m_log->log('S', "Low", CDH__SUCCESS);
}
typedef struct {
pwr_mOpSys opsys;
char str[40];
} sOpSysToStr;
void ra_cdhtest::OpSysToStr(void)
{
sOpSysToStr d[] = {
{pwr_mOpSys_X86_LINUX, "x86_linux"},
{pwr_mOpSys_X86_64_LINUX, "x86_64_linux"},
{pwr_mOpSys_X86_64_MACOS, "x86_64_macos"},
{pwr_mOpSys_ARM_LINUX, "arm_linux"},
{pwr_mOpSys_ARM64_LINUX, "arm64_linux"},
{pwr_mOpSys_X86_64_FREEBSD, "x86_64_freebsd"},
{pwr_mOpSys_X86_64_OPENBSD, "x86_64_openbsd"},
{pwr_mOpSys_X86_CYGWIN, "x86_cygwin"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
strcpy(str, cdh_OpSysToStr(d[i].opsys));
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "OpSysToStr", i);
return;
}
}
m_log->log('S', "OpSysToStr", CDH__SUCCESS);
}
void ra_cdhtest::OpSysToDirStr(void)
{
sOpSysToStr d[] = {
{pwr_mOpSys_X86_LINUX, "os_linux/hw_x86"},
{pwr_mOpSys_X86_64_LINUX, "os_linux/hw_x86_64"},
{pwr_mOpSys_X86_64_MACOS, "os_macos/hw_x86_64"},
{pwr_mOpSys_ARM_LINUX, "os_linux/hw_arm"},
{pwr_mOpSys_ARM64_LINUX, "os_linux/hw_arm64"},
{pwr_mOpSys_X86_64_FREEBSD, "os_freebsd/hw_x86_64"},
{pwr_mOpSys_X86_64_OPENBSD, "os_openbsd/hw_x86_64"},
{pwr_mOpSys_X86_CYGWIN, "os_cygwin/hw_x86"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
strcpy(str, cdh_OpSysToDirStr(d[i].opsys));
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "OpSysToDirStr", i);
return;
}
}
m_log->log('S', "OpSysToDirStr", CDH__SUCCESS);
}
typedef struct {
pwr_tObjName name;
pwr_tObjName objname;
} sStringToObjectName;
void ra_cdhtest::StringToObjectName(void)
{
sStringToObjectName d[] = {
{"ABC!\"#%&/()=?+0123456789,.;:D", "ABC____________0123456789____D"},
{"h1-h2-h3-h4", "h1_h2_h3_h4"},
{"&h1-h2-h3-h4", "Oh1_h2_h3_h4"},
{"kster-", "kster_"}
};
pwr_tObjName objname;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
cdh_StringToObjectName(objname, d[i].name);
if (strcmp(objname, d[i].objname) != 0) {
m_log->log('E', "StringToObjectName", i);
return;
}
}
m_log->log('S', "StringToObjectName", CDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
int segments;
pwr_tOName outname;
} sCutNameSegments;
void ra_cdhtest::CutNameSegments(void)
{
sCutNameSegments d[] = {
{"h1-h2-h3-h4-h5", 0, ""},
{"h1-h2-h3-h4-h5", 1, "h5"},
{"h1-h2-h3-h4-h5", 2, "h4-h5"},
{"h1-h2-h3-h4-h5", 3, "h3-h4-h5"},
{"h1-h2-h3-h4-h5", 4, "h2-h3-h4-h5"},
{"h1-h2-h3-h4-h5", 5, "h1-h2-h3-h4-h5"},
{"h1-h2-h3-h4-h5", 6, "h1-h2-h3-h4-h5"},
};
pwr_tOName outname;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
cdh_CutNameSegments(outname, d[i].name, d[i].segments);
if (strcmp(outname, d[i].outname) != 0) {
m_log->vlog('E', "CutNameSegments, %s != %s %d", outname, d[i].outname, i);
return;
}
}
m_log->log('S', "CutNameSegments", CDH__SUCCESS);
}
typedef struct {
pwr_sParInfo parinfo;
pwr_tUInt32 size;
} sAttrSize;
void ra_cdhtest::AttrSize(void)
{
sAttrSize d[] = {
{{"",pwr_eType_Int32,0,4,0,1,1}, 4},
{{"",pwr_eType_Int32,0,4,PWR_MASK_POINTER,1,1}, 8},
{{"",pwr_eType_Int32,0,4,PWR_MASK_POINTER,100,1}, 800},
{{"",pwr_eType_Int32,0,400,PWR_MASK_POINTER|PWR_MASK_PRIVATE,100,1}, 400}
};
pwr_tUInt32 size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
size = cdh_AttrSize(&d[i].parinfo);
if (size != d[i].size) {
m_log->log('E', "AttrSize", i);
return;
}
}
m_log->log('S', "AttrSize", CDH__SUCCESS);
}
void ra_cdhtest::AttrElemSize(void)
{
sAttrSize d[] = {
{{"",pwr_eType_Int32,0,4,0,1,1}, 4},
{{"",pwr_eType_Int32,0,4,PWR_MASK_POINTER,1,1}, 8},
{{"",pwr_eType_Int32,0,4,PWR_MASK_POINTER,100,1}, 8},
{{"",pwr_eType_Int32,0,400,PWR_MASK_POINTER|PWR_MASK_PRIVATE,100,1}, 4}
};
pwr_tUInt32 size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
size = cdh_AttrElemSize(&d[i].parinfo);
if (size != d[i].size) {
m_log->log('E', "AttrElemSize", i);
return;
}
}
m_log->log('S', "AttrElemSize", CDH__SUCCESS);
}
// Constructor
ra_cdhtest::ra_cdhtest()
{
m_log = new tst_log(&m_sts, "co-Cdh", "$pwrp_log/cdh.log");
if (EVEN(m_sts))
printf("** Unable to open log file");
}
// Destructor
ra_cdhtest::~ra_cdhtest()
{
delete m_log;
}
int main()
{
ra_cdhtest cdh;
pwr_tStatus sts;
setenv("TZ", "Europe/Stockholm", 1);
tzset();
sts = gdh_Init("ra_cdhtest");
if (EVEN(sts)) {
cdh.log()->log('S', "cdh gdh_Init", sts);
exit(0);
}
cdh.ObjidCompare();
cdh.ObjidIsEqual();
cdh.ObjidIsNotEqual();
cdh.ObjidIsNull();
cdh.ObjidIsNotNull();
cdh.ClassObjidToId();
cdh.ClassIdToObjid();
cdh.TypeObjidToId();
cdh.TypeIdToObjid();
cdh.TypeIdToIndex();
cdh.ObjidToAref();
cdh.AttrValueToString();
cdh.StringToAttrValue();
cdh.MaskToBinaryString();
cdh.StringToClassId();
cdh.StringToObjid();
cdh.StringToAref();
cdh.StringToVolumeId();
cdh.StringToObjectIx();
cdh.ClassIdToString();
cdh.TypeIdToString();
cdh.ObjectIxToString();
cdh.ArefToString();
cdh.NodeIdToString();
cdh.OidToString();
cdh.OidToFnString();
cdh.VolumeIdToString();
cdh.VolumeIdToFnString();
cdh.SubidToString();
cdh.DlidToString();
cdh.Low();
cdh.OpSysToStr();
cdh.OpSysToDirStr();
cdh.StringToObjectName();
cdh.CutNameSegments();
cdh.AttrSize();
cdh.AttrElemSize();
}
#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();
};
/*
Test errh 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_errhtest.h"
#include "rt_pwr_msg.h"
#include "rt_errh_msg.h"
#include "rt_plc_msg.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_cvolpwrtest01classes.h"
static float errhtest_wait=0.01;
void ra_errhtest::Init(void)
{
m_sts = errh_Init("ra_errhtest", m_anix);
if (m_sts != 1) {
m_log->log('E', "Init", m_sts);
return;
}
m_log->log('S', "Init", PWR__SUCCESS);
}
typedef enum {
eErrht_No,
eErrht_Int,
eErrht_Sts,
eErrht_Str
} eErrht;
typedef union {
int i;
float f;
pwr_tStatus sts;
char s[40];
} uErrht;
typedef struct {
char str[80];
eErrht argtype;
uErrht arg;
char infostr[200];
} sErrht;
void ra_errhtest::Success(void)
{
sErrht d[] = {
{"This is a success message",eErrht_No,{.i=0}, "This is a success message"},
{"This is another success message, %d",eErrht_Int,{.i=222}, "This is another success message, 222"},
{"This is another success message, %08d",eErrht_Int,{.i=222}, "This is another success message, 00000222"},
{"This is another success message, %x",eErrht_Int,{.i=0xabcd123}, "This is another success message, abcd123"},
{"This is another success message, %m",eErrht_Sts,{.sts=PWR__SUCCESS}, "This is another success message, %PWR-S-SUCCESS, Successful completion"},
{"This is another success message, %s",eErrht_Str,{.s={'S','t','r','i','n','g',' ','a','r','g','u','m','e','n','t'}}, "This is another success message, String argument"}
};
m_nodep->ProcMsgSeverity[m_anix-1] = 0;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
switch (d[i].argtype) {
case eErrht_No:
errh_Success(d[i].str);
break;
case eErrht_Int:
errh_Success(d[i].str, d[i].arg.i);
break;
case eErrht_Sts:
errh_Success(d[i].str, d[i].arg.sts);
break;
case eErrht_Str:
errh_Success(d[i].str, d[i].arg.s);
break;
}
time_Sleep(errhtest_wait);
if (strcmp(m_nodep->ProcMessage[m_anix-1], d[i].infostr) != 0) {
m_log->log('E', "Success", i);
return;
}
}
m_log->log('S', "Success", PWR__SUCCESS);
}
void ra_errhtest::Info(void)
{
sErrht d[] = {
{"This is an info message",eErrht_No,{.i=0}, "This is an info message"},
{"This is another info message, %d",eErrht_Int,{.i=222}, "This is another info message, 222"},
{"This is another info message, %08d",eErrht_Int,{.i=222}, "This is another info message, 00000222"},
{"This is another info message, %x",eErrht_Int,{.i=0xabcd123}, "This is another info message, abcd123"},
{"This is another info message, %m",eErrht_Sts,{.sts=PWR__SUCCESS}, "This is another info message, %PWR-S-SUCCESS, Successful completion"},
{"This is another info message, %s",eErrht_Str,{.s={'S','t','r','i','n','g',' ','a','r','g','u','m','e','n','t'}}, "This is another info message, String argument"}
};
m_nodep->ProcMsgSeverity[m_anix-1] = 0;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
switch (d[i].argtype) {
case eErrht_No:
errh_Info(d[i].str);
break;
case eErrht_Int:
errh_Info(d[i].str, d[i].arg.i);
break;
case eErrht_Sts:
errh_Info(d[i].str, d[i].arg.sts);
break;
case eErrht_Str:
errh_Info(d[i].str, d[i].arg.s);
break;
}
time_Sleep(errhtest_wait);
if (strcmp(m_nodep->ProcMessage[m_anix-1], d[i].infostr) != 0) {
m_log->log('E', "Info", i);
return;
}
}
m_log->log('S', "Info", PWR__SUCCESS);
}
void ra_errhtest::Warning(void)
{
sErrht d[] = {
{"This is a warning message",eErrht_No,{.i=0}, "This is a warning message"},
{"This is another warning message, %d",eErrht_Int,{.i=222}, "This is another warning message, 222"},
{"This is another warning message, %08d",eErrht_Int,{.i=222}, "This is another warning message, 00000222"},
{"This is another warning message, %x",eErrht_Int,{.i=0xabcd123}, "This is another warning message, abcd123"},
{"This is another warning message, %m",eErrht_Sts,{.sts=PWR__SUCCESS}, "This is another warning message, %PWR-S-SUCCESS, Successful completion"},
{"This is another warning message, %s",eErrht_Str,{.s={'S','t','r','i','n','g',' ','a','r','g','u','m','e','n','t'}}, "This is another warning message, String argument"}
};
m_nodep->ProcMsgSeverity[m_anix-1] = 0;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
switch (d[i].argtype) {
case eErrht_No:
errh_Warning(d[i].str);
break;
case eErrht_Int:
errh_Warning(d[i].str, d[i].arg.i);
break;
case eErrht_Sts:
errh_Warning(d[i].str, d[i].arg.sts);
break;
case eErrht_Str:
errh_Warning(d[i].str, d[i].arg.s);
break;
}
time_Sleep(errhtest_wait);
if (strcmp(m_nodep->ProcMessage[m_anix-1], d[i].infostr) != 0) {
m_log->log('E', "Warning", i);
return;
}
}
m_log->log('S', "Warning", PWR__SUCCESS);
}
void ra_errhtest::Error(void)
{
sErrht d[] = {
{"This is an error message",eErrht_No,{.i=0}, "This is an error message"},
{"This is another error message, %d",eErrht_Int,{.i=222}, "This is another error message, 222"},
{"This is another error message, %08d",eErrht_Int,{.i=222}, "This is another error message, 00000222"},
{"This is another error message, %x",eErrht_Int,{.i=0xabcd123}, "This is another error message, abcd123"},
{"This is another error message, %m",eErrht_Sts,{.sts=PWR__SUCCESS}, "This is another error message, %PWR-S-SUCCESS, Successful completion"},
{"This is another error message, %s",eErrht_Str,{.s={'S','t','r','i','n','g',' ','a','r','g','u','m','e','n','t'}}, "This is another error message, String argument"}
};
m_nodep->ProcMsgSeverity[m_anix-1] = 0;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
switch (d[i].argtype) {
case eErrht_No:
errh_Error(d[i].str);
break;
case eErrht_Int:
errh_Error(d[i].str, d[i].arg.i);
break;
case eErrht_Sts:
errh_Error(d[i].str, d[i].arg.sts);
break;
case eErrht_Str:
errh_Error(d[i].str, d[i].arg.s);
break;
}
time_Sleep(errhtest_wait);
if (strcmp(m_nodep->ProcMessage[m_anix-1], d[i].infostr) != 0) {
m_log->log('E', "Error", i);
return;
}
}
m_log->log('S', "Error", PWR__SUCCESS);
}
void ra_errhtest::Fatal(void)
{
sErrht d[] = {
{"This is a fatal message",eErrht_No,{.i=0}, "This is a fatal message"},
{"This is another fatal message, %d",eErrht_Int,{.i=222}, "This is another fatal message, 222"},
{"This is another fatal message, %08d",eErrht_Int,{.i=222}, "This is another fatal message, 00000222"},
{"This is another fatal message, %x",eErrht_Int,{.i=0xabcd123}, "This is another fatal message, abcd123"},
{"This is another fatal message, %m",eErrht_Sts,{.sts=PWR__SUCCESS}, "This is another fatal message, %PWR-S-SUCCESS, Successful completion"},
{"This is another fatal message, %s",eErrht_Str,{.s={'S','t','r','i','n','g',' ','a','r','g','u','m','e','n','t'}}, "This is another fatal message, String argument"}
};
m_nodep->ProcMsgSeverity[m_anix-1] = 0;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
switch (d[i].argtype) {
case eErrht_No:
errh_Fatal(d[i].str);
break;
case eErrht_Int:
errh_Fatal(d[i].str, d[i].arg.i);
break;
case eErrht_Sts:
errh_Fatal(d[i].str, d[i].arg.sts);
break;
case eErrht_Str:
errh_Fatal(d[i].str, d[i].arg.s);
break;
}
time_Sleep(errhtest_wait);
if (strcmp(m_nodep->ProcMessage[m_anix-1], d[i].infostr) != 0) {
m_log->log('E', "Fatal", i);
return;
}
}
m_log->log('S', "Fatal", PWR__SUCCESS);
}
typedef struct {
pwr_tStatus sts;
eErrht argtype;
uErrht arg;
char infostr[200];
} sCErrLog;
void ra_errhtest::CErrLog(void)
{
sCErrLog d[] = {
{PWR__SUCCESS,eErrht_No,{.i=0}, "PWR-SUCCESS, Successful completion"},
{PLC__ERRCREOBJ,eErrht_Str,{.s={'S','t','r','i','n','g',' ','a','r','g','u','m','e','n','t'}}, "PLC-ERRCREOBJ, create object \'String argument\'"}
};
m_nodep->ProcMsgSeverity[m_anix-1] = 0;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
switch (d[i].argtype) {
case eErrht_No:
errh_CErrLog(d[i].sts,NULL);
break;
case eErrht_Int:
errh_CErrLog(d[i].sts, errh_ErrArgL(d[i].arg.i), NULL);
break;
case eErrht_Sts:
errh_CErrLog(d[i].sts, errh_ErrArgMsg(d[i].arg.sts), NULL);
break;
case eErrht_Str:
errh_CErrLog(d[i].sts, errh_ErrArgAF(d[i].arg.s), NULL);
break;
}
time_Sleep(errhtest_wait);
if (strcmp(m_nodep->ProcMessage[m_anix-1], d[i].infostr) != 0) {
m_log->log('E', "CErrLog", i);
return;
}
}
m_log->log('S', "CErrLog", PWR__SUCCESS);
}
void ra_errhtest::SetAnix(void)
{
errh_eAnix anix = errh_eAnix_appl2;
m_nodep->ProcMsgSeverity[m_anix-1] = 0;
m_nodep->ProcMsgSeverity[anix-1] = 0;
errh_SetAnix(anix);
errh_Info("Setting anix to appl2");
time_Sleep(errhtest_wait);
if (strcmp(m_nodep->ProcMessage[anix-1], "Setting anix to appl2") != 0) {
m_log->log('E', "SetAnix");
errh_SetAnix(m_anix);
return;
}
errh_SetAnix(m_anix);
m_log->log('S', "SetAnix", PWR__SUCCESS);
}
typedef struct {
pwr_tStatus sts;
} sSetStatus;
void ra_errhtest::SetStatus(void)
{
sCErrLog d[] = {
{PWR__ARUN},
{PWR__SRUN},
{PWR__APPLWARNING},
{PWR__APPLINFO},
{0}
};
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
errh_SetStatus(d[i].sts);
time_Sleep(errhtest_wait);
if (m_nodep->ProcStatus[m_anix-1] != d[i].sts) {
m_log->vlog('E', "SetStatus, idx %d (%d != %d)", i,
m_nodep->ProcStatus[m_anix-1], d[i].sts);
return;
}
}
m_log->log('S', "SetStatus", PWR__SUCCESS);
}
// Should be last, sets interactive
void ra_errhtest::LogSuccess(void)
{
sErrht d[] = {
{"This is a success message",eErrht_No,{.i=0}, "S This is a success message"},
{"This is another success message, %d",eErrht_Int,{.i=222}, "S This is another success message, 222"},
{"This is another success message, %08d",eErrht_Int,{.i=222}, "S This is another success message, 00000222"},
{"This is another success message, %x",eErrht_Int,{.i=0xabcd123}, "S This is another success message, abcd123"},
{"This is another success message, %m",eErrht_Sts,{.sts=PWR__SUCCESS}, "S This is another success message, %PWR-S-SUCCESS, Successful completion"},
{"This is another success message, %s",eErrht_Str,{.s={'S','t','r','i','n','g',' ','a','r','g','u','m','e','n','t'}}, "S This is another success message, String argument"}
};
pwr_tFileName fname, fname2;
FILE *fp;
char line[200];
errh_Interactive();
dcli_translate_filename(fname, "/tmp/errh.txt");
freopen(fname, "w", stdout);
m_nodep->ProcMsgSeverity[m_anix-1] = 0;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
switch (d[i].argtype) {
case eErrht_No:
errh_LogSuccess(0, d[i].str);
break;
case eErrht_Int:
errh_LogSuccess(0, d[i].str, d[i].arg.i);
break;
case eErrht_Sts:
errh_LogSuccess(0, d[i].str, d[i].arg.sts);
break;
case eErrht_Str:
errh_LogSuccess(0, d[i].str, d[i].arg.s);
break;
}
}
dcli_translate_filename(fname2, "/tmp/errh2.txt");
freopen(fname2, "w", stdout);
fp = fopen(fname, "r");
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
if (dcli_read_line(line, sizeof(line), fp)) {
if (strcmp(line, d[i].infostr) != 0) {
m_log->log('E', "LogSuccess", i);
fclose(fp);
return;
}
}
else {
m_log->log('E', "LogSuccess, no line", i);
fclose(fp);
return;
}
}
fclose(fp);
m_log->log('S', "LogSuccess", PWR__SUCCESS);
}
void ra_errhtest::LogInfo(void)
{
sErrht d[] = {
{"This is a info message",eErrht_No,{.i=0}, "I This is a info message"},
{"This is another info message, %d",eErrht_Int,{.i=222}, "I This is another info message, 222"},
{"This is another info message, %08d",eErrht_Int,{.i=222}, "I This is another info message, 00000222"},
{"This is another info message, %x",eErrht_Int,{.i=0xabcd123}, "I This is another info message, abcd123"},
{"This is another info message, %m",eErrht_Sts,{.sts=PWR__SUCCESS}, "I This is another info message, %PWR-S-SUCCESS, Successful completion"},
{"This is another info message, %s",eErrht_Str,{.s={'S','t','r','i','n','g',' ','a','r','g','u','m','e','n','t'}}, "I This is another info message, String argument"}
};
pwr_tFileName fname, fname2;
FILE *fp;
char line[200];
errh_Interactive();
dcli_translate_filename(fname, "/tmp/errh.txt");
freopen(fname, "w", stdout);
m_nodep->ProcMsgSeverity[m_anix-1] = 0;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
switch (d[i].argtype) {
case eErrht_No:
errh_LogInfo(0, d[i].str);
break;
case eErrht_Int:
errh_LogInfo(0, d[i].str, d[i].arg.i);
break;
case eErrht_Sts:
errh_LogInfo(0, d[i].str, d[i].arg.sts);
break;
case eErrht_Str:
errh_LogInfo(0, d[i].str, d[i].arg.s);
break;
}
}
dcli_translate_filename(fname2, "/tmp/errh2.txt");
freopen(fname2, "w", stdout);
fp = fopen(fname, "r");
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
if (dcli_read_line(line, sizeof(line), fp)) {
if (strcmp(line, d[i].infostr) != 0) {
m_log->log('E', "LogInfo", i);
fclose(fp);
return;
}
}
else {
m_log->log('E', "LogInfo, no line", i);
fclose(fp);
return;
}
}
fclose(fp);
m_log->log('S', "LogInfo", PWR__SUCCESS);
}
void ra_errhtest::LogError(void)
{
sErrht d[] = {
{"This is a error message",eErrht_No,{.i=0}, "E This is a error message"},
{"This is another error message, %d",eErrht_Int,{.i=222}, "E This is another error message, 222"},
{"This is another error message, %08d",eErrht_Int,{.i=222}, "E This is another error message, 00000222"},
{"This is another error message, %x",eErrht_Int,{.i=0xabcd123}, "E This is another error message, abcd123"},
{"This is another error message, %m",eErrht_Sts,{.sts=PWR__SUCCESS}, "E This is another error message, %PWR-S-SUCCESS, Successful completion"},
{"This is another error message, %s",eErrht_Str,{.s={'S','t','r','i','n','g',' ','a','r','g','u','m','e','n','t'}}, "E This is another error message, String argument"}
};
pwr_tFileName fname, fname2;
FILE *fp;
char line[200];
errh_Interactive();
dcli_translate_filename(fname, "/tmp/errh.txt");
freopen(fname, "w", stdout);
m_nodep->ProcMsgSeverity[m_anix-1] = 0;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
switch (d[i].argtype) {
case eErrht_No:
errh_LogError(0, d[i].str);
break;
case eErrht_Int:
errh_LogError(0, d[i].str, d[i].arg.i);
break;
case eErrht_Sts:
errh_LogError(0, d[i].str, d[i].arg.sts);
break;
case eErrht_Str:
errh_LogError(0, d[i].str, d[i].arg.s);
break;
}
}
dcli_translate_filename(fname2, "/tmp/errh2.txt");
freopen(fname2, "w", stdout);
fp = fopen(fname, "r");
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
if (dcli_read_line(line, sizeof(line), fp)) {
if (strcmp(line, d[i].infostr) != 0) {
m_log->log('E', "LogError", i);
fclose(fp);
return;
}
}
else {
m_log->log('E', "LogError, no line", i);
fclose(fp);
return;
}
}
fclose(fp);
m_log->log('S', "LogError", PWR__SUCCESS);
}
void ra_errhtest::LogFatal(void)
{
sErrht d[] = {
{"This is a fatal message",eErrht_No,{.i=0}, "F This is a fatal message"},
{"This is another fatal message, %d",eErrht_Int,{.i=222}, "F This is another fatal message, 222"},
{"This is another fatal message, %08d",eErrht_Int,{.i=222}, "F This is another fatal message, 00000222"},
{"This is another fatal message, %x",eErrht_Int,{.i=0xabcd123}, "F This is another fatal message, abcd123"},
{"This is another fatal message, %m",eErrht_Sts,{.sts=PWR__SUCCESS}, "F This is another fatal message, %PWR-S-SUCCESS, Successful completion"},
{"This is another fatal message, %s",eErrht_Str,{.s={'S','t','r','i','n','g',' ','a','r','g','u','m','e','n','t'}}, "F This is another fatal message, String argument"}
};
pwr_tFileName fname, fname2;
FILE *fp;
char line[200];
errh_Interactive();
dcli_translate_filename(fname, "/tmp/errh.txt");
freopen(fname, "w", stdout);
m_nodep->ProcMsgSeverity[m_anix-1] = 0;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
switch (d[i].argtype) {
case eErrht_No:
errh_LogFatal(0, d[i].str);
break;
case eErrht_Int:
errh_LogFatal(0, d[i].str, d[i].arg.i);
break;
case eErrht_Sts:
errh_LogFatal(0, d[i].str, d[i].arg.sts);
break;
case eErrht_Str:
errh_LogFatal(0, d[i].str, d[i].arg.s);
break;
}
}
dcli_translate_filename(fname2, "/tmp/errh2.txt");
freopen(fname2, "w", stdout);
fp = fopen(fname, "r");
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
if (dcli_read_line(line, sizeof(line), fp)) {
if (strcmp(line, d[i].infostr) != 0) {
m_log->log('E', "LogFatal", i);
fclose(fp);
return;
}
}
else {
m_log->log('E', "LogFatal, no line", i);
fclose(fp);
return;
}
}
fclose(fp);
m_log->log('S', "LogFatal", PWR__SUCCESS);
}
// Constructor
ra_errhtest::ra_errhtest()
{
pwr_tOid oid;
m_anix = errh_eAnix_appl1;
m_log = new tst_log(&m_sts, "rt-Errh", "$pwrp_log/errh.log");
if (EVEN(m_sts))
printf("** Unable to open log file");
m_sts = gdh_Init("ra_errhtest");
if (EVEN(m_sts)) {
m_log->log('F', "errh gdh_Init", m_sts);
exit(0);
}
m_sts = gdh_GetNodeObject(pwr_cNNid, &oid);
if (EVEN(m_sts)) {
m_log->log('F', "errh gdh_GetNodeObject", m_sts);
exit(0);
}
m_sts = gdh_ObjidToPointer(oid, (void **)&m_nodep);
if (EVEN(m_sts)) {
m_log->log('F', "errh gdh_ObjidToPointer", m_sts);
exit(0);
}
}
// Destructor
ra_errhtest::~ra_errhtest()
{
delete m_log;
}
int main()
{
ra_errhtest errh;
errh.Init();
errh.Success();
errh.Info();
errh.Warning();
errh.Error();
errh.Fatal();
errh.CErrLog();
errh.SetAnix();
errh.SetStatus();
errh.LogSuccess();
errh.LogInfo();
errh.LogError();
errh.LogFatal();
}
#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 source diff could not be displayed because it is too large. You can view the blob instead.
#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);
};
/*
Test mh 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 "rt_mh_util.h"
#include "rt_mh_appl.h"
#include "ra_mhappltest.h"
#include "rt_pwr_msg.h"
#include "rt_plc_msg.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_cvolpwrtest01classes.h"
static int plog = 1;
ra_mhappltest *ra_mhappltest::m_mh = 0;
typedef struct {
pwr_tOid object;
unsigned int eventflags;
pwr_tTime eventtime;
pwr_tString80 eventname;
mh_eEvent eventtype;
pwr_tString80 eventtext;
mh_eEventPrio eventprio;
int cancel;
pwr_tUInt32 id;
mh_sEventId eventid;
int active;
int eactive;
int status;
int estatus;
int check;
} sApplMessage;
sApplMessage d[] = {
// Alarm, no return
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_Alarm, "mh_appltest 1", mh_eEventPrio_A, 0, 0},
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_Alarm, "mh_appltest 2", mh_eEventPrio_B, 0, 0},
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_Alarm, "mh_appltest 3", mh_eEventPrio_C, 0, 0},
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_Alarm, "mh_appltest 4", mh_eEventPrio_D, 0, 0},
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_MaintenanceAlarm, "mh_appltest 5", mh_eEventPrio_A, 0, 0},
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_SystemAlarm, "mh_appltest 6", mh_eEventPrio_A, 0, 0},
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_UserAlarm1, "mh_appltest 7", mh_eEventPrio_A, 0, 0},
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_UserAlarm2, "mh_appltest 8", mh_eEventPrio_A, 0, 0},
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_UserAlarm3, "mh_appltest 9", mh_eEventPrio_A, 0, 0},
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_UserAlarm4, "mh_appltest 10", mh_eEventPrio_A, 0, 0},
// A alarm, return required
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Return, pwr_cNTime, "mhappltest", mh_eEvent_Alarm, "mh_appltest 11", mh_eEventPrio_B, 0, 0},
// A alarm, cancel. Doesn't work...
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Return, pwr_cNTime, "mhappltest", mh_eEvent_Alarm, "mh_appltest 12", mh_eEventPrio_B, 0 /* 1 todo */, 0},
// Info in operator window
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned | mh_mEventFlags_InfoWindow, pwr_cNTime, "mhappltest", mh_eEvent_InfoSuccess, "mh_appltest 13", mh_eEventPrio_, 0, 0},
{pwr_cNOid, mh_mEventFlags_Ack | mh_mEventFlags_Returned | mh_mEventFlags_InfoWindow, pwr_cNTime, "mhappltest", mh_eEvent_Info, "mh_appltest 14", mh_eEventPrio_, 0, 0},
// Info, eventlist only
{pwr_cNOid, mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_InfoSuccess, "mh_appltest 15", mh_eEventPrio_, 0, 0},
{pwr_cNOid, mh_mEventFlags_Returned, pwr_cNTime, "mhappltest", mh_eEvent_Info, "mh_appltest 16", mh_eEventPrio_, 0, 0}
};
pwr_tStatus ra_mhappltest::mh_ack_bc(mh_sAck* mp)
{
int i;
if (m_mh->m_clean)
return 1;
if (plog)
m_mh->m_log->vlog('D', "ack_bc %d", mp->TargetId.Idx);
i = m_mh->find_sup(&mp->TargetId);
if (i == -1) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "ack_cb, unknown eventid");
return 1;
}
d[i].status &= ~mh_mEventStatus_NotAck;
if (d[i].status != d[i].estatus) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "ack_bc status differs %d %d", d[i].status, d[i].estatus);
}
if ((d[i].estatus & mh_mEventStatus_NotRet) == 0 &&
(d[i].estatus & mh_mEventStatus_NotAck) == 0) {
d[i].active = 0;
d[i].eactive = 0;
d[i].estatus = 0;
d[i].status = 0;
}
return 1;
}
pwr_tStatus ra_mhappltest::mh_return_bc(mh_sReturn* mp)
{
unsigned int num;
int i;
if (m_mh->m_clean) {
mh_OutunitAck(&mp->TargetId);
return 1;
}
if (plog)
m_mh->m_log->vlog('D', "return_bc %d", mp->TargetId.Idx);
num = sscanf(&mp->EventText[12], "%d", &i);
if (num != 1 || i < 1 || i > (int)(sizeof(d)/sizeof(d[0]))) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "return_bc wrong index, %s", mp->EventText);
return 1;
}
i--;
if (cdh_ObjidIsNotEqual(mp->Object.Objid, d[i].object)) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "return_bc wrong object, %s", mp->EventText);
return 1;
}
if (mp->TargetId.Idx != d[i].eventid.Idx) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "return_bc wrong eventid, %s", mp->EventText);
return 1;
}
d[i].status &= ~mh_mEventStatus_NotRet;
if (d[i].status != d[i].estatus) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "return_bc status differs %d %d", d[i].status, d[i].estatus);
}
if ((d[i].estatus & mh_mEventStatus_NotRet) == 0 &&
(d[i].estatus & mh_mEventStatus_NotAck) == 0) {
d[i].eactive = 0;
d[i].active = 0;
d[i].estatus = 0;
d[i].status = 0;
}
return 1;
}
pwr_tStatus ra_mhappltest::mh_alarm_bc(mh_sMessage* mp)
{
int num;
int i;
if (m_mh->m_clean) {
if (mp->Status & mh_mEventStatus_NotAck)
mh_OutunitAck(&mp->Info.Id);
return 1;
}
if (plog)
m_mh->m_log->vlog('D', "alarm_bc %d", mp->Info.Id.Idx);
num = sscanf(&mp->EventText[12], "%d", &i);
if (num != 1 || i < 1 || i > (int)(sizeof(d)/sizeof(d[0]))) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarm_bc wrong index, %s", mp->EventText);
return 1;
}
i--;
if (mp->Info.Id.Idx != d[i].id) {
if (plog)
m_mh->m_log->vlog('X', "alarm_bc old id, %d %s", mp->Info.Id.Idx, mp->EventText);
return 1;
}
if (cdh_ObjidIsNotEqual(mp->Object.Objid, d[i].object)) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarm_bc wrong object, %s", mp->EventText);
return 1;
}
d[i].active = 1;
if (!d[i].eactive) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarm_bc sup not active, %d %s", mp->Info.Id.Idx,
mp->EventText);
return 1;
}
memcpy(&d[i].eventid, &mp->Info.Id, sizeof(mh_sEventId));
d[i].status = mp->Status & 0x7;
if (d[i].status != d[i].estatus) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarm_bc status differs %d %d %d", d[i].status, d[i].estatus,
mp->Info.Id.Idx);
return 1;
}
return 1;
}
pwr_tStatus ra_mhappltest::mh_block_bc(mh_sBlock* mp)
{
return 1;
}
pwr_tStatus ra_mhappltest::mh_cancel_bc(mh_sReturn* mp)
{
unsigned int num;
int i;
if (m_mh->m_clean) {
return 1;
}
if (plog)
m_mh->m_log->vlog('D', "cancel_bc %d", mp->TargetId.Idx);
num = sscanf(&mp->EventText[12], "%d", &i);
if (num != 1 || i < 1 || i > (int)(sizeof(d)/sizeof(d[0]))) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "cancel_bc wrong index, %s", mp->EventText);
return 1;
}
i--;
if (cdh_ObjidIsNotEqual(mp->Object.Objid, d[i].object)) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "cancel_bc wrong object, %s", mp->EventText);
return 1;
}
if (mp->TargetId.Idx != d[i].eventid.Idx) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "cancel_bc wrong eventid, %s", mp->EventText);
return 1;
}
d[i].status &= ~mh_mEventStatus_NotRet;
if (d[i].status != d[i].estatus) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "cancel_bc status differs %d %d", d[i].status, d[i].estatus);
}
if ((d[i].estatus & mh_mEventStatus_NotRet) == 0 &&
(d[i].estatus & mh_mEventStatus_NotAck) == 0) {
d[i].eactive = 0;
d[i].active = 0;
d[i].estatus = 0;
d[i].status = 0;
}
return 1;
}
pwr_tStatus ra_mhappltest::mh_info_bc(mh_sMessage* mp)
{
unsigned int num;
int i;
if (m_mh->m_clean) {
if (mp->Status & mh_mEventStatus_NotAck)
mh_OutunitAck(&mp->Info.Id);
return 1;
}
if (plog)
m_mh->m_log->vlog('D', "info_bc %d", mp->Info.Id.Idx);
num = sscanf(&mp->EventText[12], "%d", &i);
if (num != 1 || i < 1 || i > (int)(sizeof(d)/sizeof(d[0]))) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "info_bc wrong index, %s", mp->EventText);
return 1;
}
i--;
if (mp->Info.Id.Idx != d[i].id) {
if (plog)
m_mh->m_log->vlog('X', "info_bc old id, %d %s", mp->Info.Id.Idx, mp->EventText);
return 1;
}
if (cdh_ObjidIsNotEqual(mp->Object.Objid, d[i].object)) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "info_bc wrong object, %s", mp->EventText);
return 1;
}
d[i].active = 1;
if (!d[i].eactive) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "info_bc sup not active, %d %s", d[i].eventid.Idx,
mp->EventText);
return 1;
}
memcpy(&d[i].eventid, &mp->Info.Id, sizeof(mh_sEventId));
d[i].status = mp->Status & 0x7;
if (d[i].status != d[i].estatus) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "info_bc status differs %d %d %d", d[i].status, d[i].estatus,
d[i].eventid.Idx);
return 1;
}
if ((d[i].estatus & mh_mEventStatus_NotRet) == 0 &&
(d[i].estatus & mh_mEventStatus_NotAck) == 0) {
d[i].eactive = 0;
d[i].active = 0;
d[i].estatus = 0;
d[i].status = 0;
}
return 1;
}
pwr_tStatus ra_mhappltest::mh_clear_alarmlist_bc(pwr_tNodeIndex nix)
{
return 1;
}
pwr_tStatus ra_mhappltest::mh_clear_blocklist_bc(pwr_tNodeIndex nix)
{
return 1;
}
pwr_tStatus ra_mhappltest::mh_alarmstatus_bc(mh_sAlarmStatus* mp)
{
int i;
if (!m_mh->m_checkstatus)
return 1;
// Reset check
for (i = 0; i < int(sizeof(d)/sizeof(d[0])); i++)
d[i].check = 0;
for (unsigned int j = 0; j < mp->Count; j++) {
mh_sEventId id;
id.Idx = mp->Sts[j].Idx;
i = m_mh->find_sup(&id);
if (i == -1) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarmstatus_bc unknown %d", mp->Sts[j].Idx);
}
else {
d[i].check = 1;
if (!d[i].active) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarmstatus_bc not active %d", mp->Sts[j].Idx);
}
if (d[i].status != (int)(mp->Sts[j].Status & 7)) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarmstatus_bc status differ %d %d", mp->Sts[j].Status,
d[i].status);
}
}
}
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
if (d[i].active && !d[i].check) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarmstatus_bc active not present %d", d[i].eventid.Idx);
}
}
m_mh->m_checkstatus = 0;
return 1;
}
void ra_mhappltest::outunit_connect(void)
{
mh_UtilWaitForMh();
m_sts = mh_OutunitConnect(m_user, mh_eOutunitType_Operator, 0, mh_ack_bc,
mh_alarm_bc, mh_block_bc, mh_cancel_bc, mh_clear_alarmlist_bc,
mh_clear_blocklist_bc, mh_info_bc, mh_return_bc, mh_alarmstatus_bc);
if (EVEN(m_sts)) {
m_log->log('E', "mh_OutunitConnect", m_sts);
return;
}
}
void ra_mhappltest::ApplTest(void)
{
mh_sApplMessage amsg;
pwr_tOid oid;
m_sts = gdh_NameToObjid("Test01c-MhAppl-Dv1", &oid);
if (EVEN(m_sts)) {
m_log->log('E', "ApplTest, gdh_NameToObjid", m_sts);
return;
}
clean();
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
memcpy(&d[i].object, &oid, sizeof(pwr_tOid));
d[i].eactive = 1;
if (d[i].eventtype == mh_eEvent_Info ||
d[i].eventtype == mh_eEvent_InfoSuccess) {
if ((d[i].eventflags & mh_mEventFlags_Ack) != 0)
d[i].estatus = mh_mEventStatus_NotAck;
}
else {
if (d[i].eventflags & mh_mEventFlags_Returned)
d[i].estatus = mh_mEventStatus_NotAck;
else
d[i].estatus = mh_mEventStatus_NotRet | mh_mEventStatus_NotAck;
}
memset(&amsg, 0, sizeof(amsg));
memcpy(&amsg.Object, &d[i].object, sizeof(pwr_tOid));
amsg.EventFlags = (mh_mEventFlags)d[i].eventflags;
time_GetTime(&amsg.EventTime);
strcpy(amsg.EventName, d[i].eventname);
amsg.EventType = d[i].eventtype;
strcpy(amsg.EventText, d[i].eventtext);
amsg.EventPrio = d[i].eventprio;
m_sts = mh_ApplMessage(&d[i].id, &amsg);
if (EVEN(m_sts)) {
m_log->vlog('E', "ApplTest mh_ApplMessage", d[i].eventtext, m_sts);
return;
}
}
for (int i = 0; i < 10; i++) {
receive();
time_Sleep(0.2);
}
m_checkstatus = 1;
while (m_checkstatus) {
receive();
time_Sleep(0.2);
}
// Return
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
if ((d[i].eventflags & mh_mEventFlags_Return) != 0 &&
(d[i].eventflags & mh_mEventFlags_Returned) == 0) {
d[i].estatus &= ~mh_mEventStatus_NotRet;
if (!d[i].cancel) {
m_sts = mh_ApplReturn(d[i].id, &d[i].eventtext);
if (EVEN(m_sts)) {
m_log->vlog('E', "ApplTest mh_ApplReturn", d[i].eventtext, m_sts);
return;
}
}
else {
m_sts = mh_ApplCancel(d[i].id, &d[i].eventtext);
if (EVEN(m_sts)) {
m_log->vlog('E', "ApplTest mh_ApplCancel", d[i].eventtext, m_sts);
return;
}
}
}
}
for (int i = 0; i < 10; i++) {
receive();
time_Sleep(0.2);
}
m_checkstatus = 1;
while (m_checkstatus) {
receive();
time_Sleep(0.2);
}
// Ack
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
if ((d[i].eventflags & mh_mEventFlags_Ack) != 0) {
d[i].estatus &= ~mh_mEventStatus_NotAck;
mh_OutunitAck(&d[i].eventid);
}
}
for (int i = 0; i < 100; i++) {
receive();
time_Sleep(0.2);
}
m_checkstatus = 1;
while (m_checkstatus) {
receive();
time_Sleep(0.2);
}
// Return and ack remaining
for (int i = 0; i < 10; i++) {
receive();
time_Sleep(0.2);
}
// clean();
if (m_errcnt) {
m_log->vlog('E', "ApplTest errors detected %d", m_errcnt);
return;
}
m_log->log('S', "ApplTest", PWR__SUCCESS);
}
void ra_mhappltest::ApplGetMsgInfo(void)
{
mh_sApplMessage amsg, rmsg;
pwr_tOid oid;
m_sts = gdh_NameToObjid("Test01c-MhAppl-Dv1", &oid);
if (EVEN(m_sts)) {
m_log->log('E', "ApplGetMsgInfo, gdh_NameToObjid", m_sts);
return;
}
clean();
for (unsigned int i = 0; i < 3; i++) {
memcpy(&d[i].object, &oid, sizeof(pwr_tOid));
d[i].eactive = 1;
if (d[i].eventtype == mh_eEvent_Info ||
d[i].eventtype == mh_eEvent_InfoSuccess) {
if ((d[i].eventflags & mh_mEventFlags_Ack) != 0)
d[i].estatus = mh_mEventStatus_NotAck;
}
else {
if (d[i].eventflags & mh_mEventFlags_Returned)
d[i].estatus = mh_mEventStatus_NotAck;
else
d[i].estatus = mh_mEventStatus_NotRet | mh_mEventStatus_NotAck;
}
memset(&amsg, 0, sizeof(amsg));
memcpy(&amsg.Object, &d[i].object, sizeof(pwr_tOid));
amsg.EventFlags = (mh_mEventFlags)d[i].eventflags;
time_GetTime(&amsg.EventTime);
strcpy(amsg.EventName, d[i].eventname);
amsg.EventType = d[i].eventtype;
strcpy(amsg.EventText, d[i].eventtext);
amsg.EventPrio = d[i].eventprio;
m_sts = mh_ApplMessage(&d[i].id, &amsg);
if (EVEN(m_sts)) {
m_log->vlog('E', "ApplGetMsgInfo mh_ApplMessage", d[i].eventtext, m_sts);
return;
}
m_sts = mh_ApplGetMsgInfo(d[i].id, &rmsg);
rmsg.Id = amsg.Id;
rmsg.EventStatus = amsg.EventStatus;
if (memcmp(&amsg, &rmsg, sizeof(mh_sApplMessage)) != 0) {
m_log->vlog('E', "ApplGetMsgInfo content differs", d[i].eventtext, m_sts);
return;
}
}
for (int i = 0; i < 10; i++) {
receive();
time_Sleep(0.2);
}
// Ack
for (unsigned int i = 0; i < 3; i++) {
if ((d[i].eventflags & mh_mEventFlags_Ack) != 0) {
d[i].estatus &= ~mh_mEventStatus_NotAck;
mh_OutunitAck(&d[i].eventid);
}
}
for (int i = 0; i < 100; i++) {
receive();
time_Sleep(0.2);
}
m_log->log('S', "ApplGetMsgInfo", PWR__SUCCESS);
}
void ra_mhappltest::ApplConnect(void)
{
pwr_tOid oid;
pwr_tUInt32 active;
m_sts = gdh_NameToObjid("Nodes-PwrTest01c-Applications-ra_mhappltest", &oid);
if (EVEN(m_sts)) {
m_log->vlog('E', "ApplConnect gdh_NameToObjid", m_sts);
return;
}
m_sts = mh_ApplConnect(oid, mh_mApplFlags_NoAbortMsg, "", mh_eEvent_Alarm,
mh_eEventPrio_A,
(mh_mEventFlags)(mh_mEventFlags_Return|mh_mEventFlags_Ack|mh_mEventFlags_Bell),
"", &active);
if (EVEN(m_sts)) {
m_log->vlog('E', "ApplConnect", m_sts);
return;
}
m_log->log('S', "ApplConnect", PWR__SUCCESS);
}
void ra_mhappltest::ApplDisconnect(void)
{
m_sts = mh_ApplDisconnect();
if (EVEN(m_sts)) {
m_log->vlog('E', "ApplDisconnect", m_sts);
return;
}
m_log->log('S', "ApplDisconnect", PWR__SUCCESS);
}
// Constructor
ra_mhappltest::ra_mhappltest() : m_clean(0), m_checkstatus(0), m_errcnt(0)
{
m_mh = this;
m_clean = 1;
m_log = new tst_log(&m_sts, "rt-MhAppl", "$pwrp_log/mhappl.log");
if (EVEN(m_sts))
printf("** Unable to open log file");
m_sts = gdh_Init("ra_mhappltest");
if (EVEN(m_sts)) {
m_log->log('F', "init gdh_Init", m_sts);
exit(0);
}
m_sts = gdh_NameToObjid("Nodes-PwrTest01c-OpPlaces-ra_mhappltest", &m_user);
if (EVEN(m_sts)) {
m_log->log('F', "init gdh_NameToObjid", m_sts);
exit(0);
}
m_sts = errh_Init("ra_mhappltest", errh_eAnix_appl5);
if (m_sts != 1) {
m_log->log('E', "init errh_Init", m_sts);
return;
}
// errh_SetStatus(PWR__APPLSTARTUP);
outunit_connect();
}
void ra_mhappltest::clean()
{
m_clean = 1;
for (int i = 0; i < 50; i++) {
time_Sleep(0.2);
receive();
}
m_clean = 0;
}
int ra_mhappltest::find_sup(mh_sEventId *id)
{
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
if (d[i].eventid.Idx == id->Idx)
return i;
}
return -1;
}
void ra_mhappltest::receive()
{
m_sts = mh_OutunitReceive();
while (ODD(m_sts))
m_sts = mh_OutunitReceive();
}
// Destructor
ra_mhappltest::~ra_mhappltest()
{
delete m_log;
}
int main()
{
ra_mhappltest mh;
mh.ApplConnect();
mh.ApplTest();
mh.ApplGetMsgInfo();
mh.ApplDisconnect();
}
#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);
};
/*
Test mh 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 "rt_mh_util.h"
#include "ra_mhtest.h"
#include "rt_pwr_msg.h"
#include "rt_plc_msg.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_cvolpwrtest01classes.h"
static int plog = 1;
ra_mhtest *ra_mhtest::m_mh = 0;
pwr_tStatus ra_mhtest::mh_ack_bc(mh_sAck* mp)
{
if (m_mh->m_clean)
return 1;
if (plog)
m_mh->m_log->vlog('D', "ack_bc %d", mp->TargetId.Idx);
sSup *sup = m_mh->find_sup(&mp->TargetId);
if (!sup) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "ack_cb, unknown eventid");
return 1;
}
sup->status &= ~mh_mEventStatus_NotAck;
if (sup->status != sup->estatus && sup->prio < SUP_ASIZE) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "ack_bc status differs %d %d", sup->status, sup->estatus);
}
if ((sup->estatus & mh_mEventStatus_NotRet) == 0 &&
(sup->estatus & mh_mEventStatus_NotAck) == 0) {
sup->active = 0;
sup->eactive = 0;
sup->estatus = 0;
sup->status = 0;
}
return 1;
}
pwr_tStatus ra_mhtest::mh_return_bc(mh_sReturn* mp)
{
unsigned int idx, num, prio;
if (m_mh->m_clean) {
mh_OutunitAck(&mp->TargetId);
return 1;
}
if (plog)
m_mh->m_log->vlog('D', "return_bc %d", mp->TargetId.Idx);
switch (mp->EventText[0]) {
case 'A':
prio = 0;
break;
case 'B':
prio = 1;
break;
case 'C':
prio = 2;
break;
case 'D':
prio = 3;
break;
case 'O':
prio = 4;
break;
case 'I':
prio = 5;
break;
default:
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarm_bc wrong eventtext, %s", mp->EventText);
return 1;
}
num = sscanf(&mp->EventText[1], "%u", &idx);
if (num != 1 || idx < 1 || idx > 32) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "return_bc wrong index, %s", mp->EventText);
return 1;
}
idx--;
sSup *sup = &m_mh->m_sup[prio][idx];
if (cdh_ObjidIsNotEqual(mp->Object.Objid, sup->oid)) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "return_bc wrong object, %s", mp->EventText);
return 1;
}
if (mp->TargetId.Idx != sup->eventid.Idx) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "return_bc wrong eventid, %s", mp->EventText);
return 1;
}
sup->status &= ~mh_mEventStatus_NotRet;
if (sup->status != sup->estatus && prio < SUP_ASIZE) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "return_bc status differs %d %d", sup->status, sup->estatus);
}
if ((sup->estatus & mh_mEventStatus_NotRet) == 0 &&
(sup->estatus & mh_mEventStatus_NotAck) == 0) {
sup->eactive = 0;
sup->active = 0;
sup->estatus = 0;
sup->status = 0;
}
return 1;
}
pwr_tStatus ra_mhtest::mh_alarm_bc(mh_sMessage* mp)
{
unsigned int idx, num, prio;
if (m_mh->m_clean) {
if (mp->Status & mh_mEventStatus_NotAck)
mh_OutunitAck(&mp->Info.Id);
return 1;
}
if (plog)
m_mh->m_log->vlog('D', "alarm_bc %d", mp->Info.Id.Idx);
switch (mp->EventText[0]) {
case 'A':
prio = 0;
break;
case 'B':
prio = 1;
break;
case 'C':
prio = 2;
break;
case 'D':
prio = 3;
break;
case 'O':
prio = 4;
break;
case 'I':
prio = 5;
break;
default:
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarm_bc wrong eventtext, %s", mp->EventText);
return 1;
}
num = sscanf(&mp->EventText[1], "%u", &idx);
if (num != 1 || idx < 1 || idx > 32) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarm_bc wrong index, %s", mp->EventText);
return 1;
}
idx--;
sSup *sup = &m_mh->m_sup[prio][idx];
if (cdh_ObjidIsNotEqual(mp->Object.Objid, sup->oid)) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarm_bc wrong object, %s", mp->EventText);
return 1;
}
sup->active = 1;
if (!sup->eactive) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarm_bc sup not active, %d %s", sup->eventid.Idx,
mp->EventText);
return 1;
}
sup->status = mp->Status & 0x7;
if (sup->status != sup->estatus) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarm_bc status differs %d %d %d", sup->status, sup->estatus,
sup->eventid.Idx);
return 1;
}
memcpy(&sup->eventid, &mp->Info.Id, sizeof(mh_sEventId));
return 1;
}
pwr_tStatus ra_mhtest::mh_block_bc(mh_sBlock* mp)
{
return 1;
}
pwr_tStatus ra_mhtest::mh_cancel_bc(mh_sReturn* mp)
{
return 1;
}
pwr_tStatus ra_mhtest::mh_info_bc(mh_sMessage* mp)
{
unsigned int idx, num, prio;
if (m_mh->m_clean) {
if (mp->Status & mh_mEventStatus_NotAck)
mh_OutunitAck(&mp->Info.Id);
return 1;
}
if (plog)
m_mh->m_log->vlog('D', "info_bc %d", mp->Info.Id.Idx);
switch (mp->EventText[0]) {
case 'I':
prio = 5;
break;
default:
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "info_bc wrong eventtext, %s", mp->EventText);
return 1;
}
num = sscanf(&mp->EventText[1], "%u", &idx);
if (num != 1 || idx < 1 || idx > 32) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "info_bc wrong index, %s", mp->EventText);
return 1;
}
idx--;
sSup *sup = &m_mh->m_sup[prio][idx];
if (cdh_ObjidIsNotEqual(mp->Object.Objid, sup->oid)) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "info_bc wrong object, %s", mp->EventText);
return 1;
}
sup->active = 1;
if (!sup->eactive) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "info_bc sup not active, %d %s", sup->eventid.Idx,
mp->EventText);
return 1;
}
sup->status = mp->Status & 0x7;
if (sup->status != sup->estatus) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "info_bc status differs %d %d %d", sup->status, sup->estatus,
sup->eventid.Idx);
return 1;
}
memcpy(&sup->eventid, &mp->Info.Id, sizeof(mh_sEventId));
return 1;
}
pwr_tStatus ra_mhtest::mh_clear_alarmlist_bc(pwr_tNodeIndex nix)
{
return 1;
}
pwr_tStatus ra_mhtest::mh_clear_blocklist_bc(pwr_tNodeIndex nix)
{
return 1;
}
pwr_tStatus ra_mhtest::mh_alarmstatus_bc(mh_sAlarmStatus* mp)
{
sSup *sup;
if (!m_mh->m_checkstatus)
return 1;
// Reset check
for (int i = 0; i < SUP_ASIZE+SUP_ISIZE; i++) {
for (int j = 0; j < 32; j++)
m_mh->m_sup[i][j].check = 0;
}
for (unsigned int i = 0; i < mp->Count; i++) {
mh_sEventId id;
id.Idx = mp->Sts[i].Idx;
sup = m_mh->find_sup(&id);
if (!sup) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarmstatus_bc unknown %d", mp->Sts[i].Idx);
}
else {
sup->check = 1;
if (!sup->active) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarmstatus_bc not active %d", mp->Sts[i].Idx);
}
if (sup->status != (mp->Sts[i].Status & 7)) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarmstatus_bc status differ %d %d", mp->Sts[i].Status,
sup->status);
}
}
}
for (int i = 0; i < SUP_ASIZE+SUP_ISIZE; i++) {
for (int j = 0; j < 32; j++) {
sup = &m_mh->m_sup[i][j];
if (sup->active && !sup->check) {
m_mh->m_errcnt++;
if (plog)
m_mh->m_log->vlog('X', "alarmstatus_bc active not present %d", sup->eventid.Idx);
}
}
}
m_mh->m_checkstatus = 0;
return 1;
}
void ra_mhtest::OutunitConnect(void)
{
mh_UtilWaitForMh();
m_sts = mh_OutunitConnect(m_user, mh_eOutunitType_Operator, 0, mh_ack_bc,
mh_alarm_bc, mh_block_bc, mh_cancel_bc, mh_clear_alarmlist_bc,
mh_clear_blocklist_bc, mh_info_bc, mh_return_bc, mh_alarmstatus_bc);
if (EVEN(m_sts)) {
m_log->log('E', "OutunitConnect", m_sts);
return;
}
m_log->log('S', "OutunitConnect", PWR__SUCCESS);
}
void ra_mhtest::OutunitTest(void)
{
unsigned int mask;
sSup *sup;
#if 0
sup = &m_sup[0][0];
if (!sup->active) {
*sup->dp = 1;
sup->eactive = 1;
sup->estatus = mh_mEventStatus_NotRet | mh_mEventStatus_NotAck;
}
for (int i = 0; i < 10; i++) {
receive();
time_Sleep(0.2);
}
sup = &m_sup[0][0];
if (sup->active && sup->status & mh_mEventStatus_NotRet) {
*sup->dp = 0;
sup->estatus &= ~mh_mEventStatus_NotRet;
}
for (int i = 0; i < 10; i++) {
receive();
time_Sleep(0.2);
}
sup = &m_sup[0][0];
if (sup->active && sup->status & mh_mEventStatus_NotAck) {
mh_OutunitAck(&sup->eventid);
sup->estatus &= ~mh_mEventStatus_NotAck;
}
#endif
for (int k = 0; k < SUP_CYCLES; k++) {
// Activate
for (int i = 0; i < SUP_ASIZE+SUP_ISIZE; i++) {
mask = rand();
for (int j = 0; j < 32; j++) {
sup = &m_sup[i][j];
sup->prio = i;
if ( mask & (1 << j)) {
if (!sup->eactive) {
*sup->dp = 1;
sup->eactive = 1;
if (i < SUP_ASIZE)
sup->estatus = mh_mEventStatus_NotRet | mh_mEventStatus_NotAck;
else
sup->estatus = mh_mEventStatus_NotAck;
}
}
}
}
for (int i = 0; i < 10; i++) {
receive();
time_Sleep(0.2);
}
m_checkstatus = 1;
while (m_checkstatus) {
receive();
time_Sleep(0.2);
}
// Return
for (int i = 0; i < SUP_ASIZE; i++) {
mask = rand();
for (int j = 0; j < 32; j++) {
if ( mask & (1 << j)) {
sup = &m_sup[i][j];
if (sup->active && sup->status & mh_mEventStatus_NotRet) {
*sup->dp = 0;
sup->estatus &= ~mh_mEventStatus_NotRet;
}
}
}
}
for (int i = 0; i < 10; i++) {
receive();
time_Sleep(0.2);
}
m_checkstatus = 1;
while (m_checkstatus) {
receive();
time_Sleep(0.2);
}
// Ack
for (int i = 0; i < SUP_ASIZE+SUP_ISIZE; i++) {
mask = rand();
for (int j = 0; j < 32; j++) {
if ( mask & (1 << j)) {
sup = &m_sup[i][j];
if (sup->active && sup->status & mh_mEventStatus_NotAck) {
mh_OutunitAck(&sup->eventid);
sup->estatus &= ~mh_mEventStatus_NotAck;
if (i >= SUP_ASIZE)
*sup->dp = 0;
}
}
}
}
for (int i = 0; i < 100; i++) {
receive();
time_Sleep(0.2);
}
m_checkstatus = 1;
while (m_checkstatus) {
receive();
time_Sleep(0.2);
}
}
// Return and ack remaining
for (int i = 0; i < 10; i++) {
receive();
time_Sleep(0.2);
}
// Return
for (int i = 0; i < SUP_ASIZE; i++) {
for (int j = 0; j < 32; j++) {
sup = &m_sup[i][j];
if (sup->eactive && sup->status & mh_mEventStatus_NotRet) {
*sup->dp = 0;
sup->estatus &= ~mh_mEventStatus_NotRet;
}
}
}
for (int i = 0; i < 10; i++) {
receive();
time_Sleep(0.2);
}
// Ack
for (int i = 0; i < SUP_ASIZE+SUP_ISIZE; i++) {
for (int j = 0; j < 32; j++) {
sup = &m_sup[i][j];
if (sup->eactive && sup->status & mh_mEventStatus_NotAck) {
mh_OutunitAck(&sup->eventid);
sup->estatus &= ~mh_mEventStatus_NotAck;
if (i >= SUP_ASIZE)
*sup->dp = 0;
}
}
}
for (int i = 0; i < 60; i++) {
receive();
time_Sleep(0.2);
}
m_checkstatus = 1;
while (m_checkstatus) {
receive();
time_Sleep(0.2);
}
// clean();
if (m_errcnt) {
m_log->vlog('E', "OutunitTest errors detected %d", m_errcnt);
return;
}
m_log->log('S', "OutunitTest", PWR__SUCCESS);
}
// Constructor
ra_mhtest::ra_mhtest() : m_clean(0), m_checkstatus(0), m_errcnt(0)
{
m_mh = this;
m_clean = 1;
m_log = new tst_log(&m_sts, "rt-Mh", "$pwrp_log/mh.log");
if (EVEN(m_sts))
printf("** Unable to open log file");
m_sts = gdh_Init("ra_mhtest");
if (EVEN(m_sts)) {
m_log->log('F', "mh gdh_Init", m_sts);
exit(0);
}
m_sts = gdh_NameToObjid("Nodes-PwrTest01c-OpPlaces-ra_mhtest", &m_user);
if (EVEN(m_sts)) {
m_log->log('F', "mh gdh_NameToObjid", m_sts);
exit(0);
}
m_sts = errh_Init("ra_mhtest", errh_eAnix_appl4);
if (m_sts != 1) {
m_log->log('E', "mh errh_Init", m_sts);
return;
}
// errh_SetStatus(PWR__APPLSTARTUP);
// Connect do objects
memset(&m_sup, 0, sizeof(m_sup));
pwr_tOName name;
pwr_tAName aname;
pwr_tAttrRef aref;
pwr_tDlid dlid;
for (int i = 0; i < SUP_ASIZE+SUP_ISIZE; i++) {
switch(i) {
case 0:
strcpy(name, "Test01c-MhOutunit-A");
break;
case 1:
strcpy(name, "Test01c-MhOutunit-B");
break;
case 2:
strcpy(name, "Test01c-MhOutunit-C");
break;
case 3:
strcpy(name, "Test01c-MhOutunit-D");
break;
case 4:
strcpy(name, "Test01c-MhOutunit-O");
break;
case 5:
strcpy(name, "Test01c-MhOutunit-I");
break;
}
for (int j = 0; j < 32; j++) {
sprintf(aname, "%s%d", name, j+1);
m_sts = gdh_NameToObjid(aname, &m_sup[i][j].oid);
if (ODD(m_sts)) {
aref = cdh_ObjidToAref(m_sup[i][j].oid);
m_sts = gdh_ArefANameToAref(&aref, "ActualValue", &aref);
}
if (ODD(m_sts))
m_sts = gdh_DLRefObjectInfoAttrref(&aref, (void **)&m_sup[i][j].dp,
&dlid);
if (EVEN(m_sts)) {
m_log->log('E', "mh dsup connect", name, m_sts);
exit(0);
}
*m_sup[i][j].dp = 0;
}
}
OutunitConnect();
clean();
}
void ra_mhtest::clean()
{
m_clean = 1;
for (int i = 0; i < SUP_ASIZE+SUP_ISIZE; i++) {
for (int j = 0; j < 32; j++)
*m_sup[i][j].dp = 0;
}
for (int i = 0; i < 50; i++) {
time_Sleep(0.2);
receive();
}
m_clean = 0;
}
sSup *ra_mhtest::find_sup(mh_sEventId *id)
{
for (int j = 0; j < SUP_ASIZE+SUP_ISIZE; j++) {
for (int i = 0; i < 32; i++) {
if (m_sup[j][i].eventid.Idx == id->Idx)
return &m_sup[j][i];
}
}
return 0;
}
void ra_mhtest::receive()
{
m_sts = mh_OutunitReceive();
while (ODD(m_sts))
m_sts = mh_OutunitReceive();
}
unsigned int ra_mhtest::rand()
{
unsigned int r = random();
r |= (random() & 1) << 31;
return r;
}
// Destructor
ra_mhtest::~ra_mhtest()
{
delete m_log;
}
int main()
{
ra_mhtest mh;
// mh.OutunitConnect();
mh.OutunitTest();
}
#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 @@
#include "pwr_othermanufacturerclasses.h"
#include "pwr_inorclasses.h"
#include "pwr_siemensclasses.h"
#include "pwr_simulclasses.h"
#include "pwr_miscellaneousclasses.h"
#include "simul.h"
#include "misc.h"
#include "pwr_cvolpwrtest01classes.h"
void Pwrt01_NotEqual_exec(plc_sThread *tp, pwr_sClass_Pwrt01_NotEqual *o);
/*
Print test status
*/
#include <stdio.h>
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "tst_log.h"
static char item[][80] = {
"Test01c-Plc-Logic-And",
"Test01c-Plc-Logic-Or",
"Test01c-Plc-Logic-XOr",
"Test01c-Plc-Logic-Inv",
"Test01c-Plc-Logic-True",
"Test01c-Plc-Logic-False",
"Test01c-Plc-Logic-FirstScan",
"Test01c-Plc-Logic-Edge",
"Test01c-Plc-Logic-Count",
"Test01c-Plc-Logic-Wait",
"Test01c-Plc-Logic-Waith",
"Test01c-Plc-Logic-Pulse",
"Test01c-Plc-Logic-Timer",
"Test01c-Plc-Logic-SR_S",
"Test01c-Plc-Logic-SR_R",
"Test01c-Plc-Analog-Add",
"Test01c-Plc-Analog-Sum",
"Test01c-Plc-Analog-Minmax",
"Test01c-Plc-Analog-Max",
"Test01c-Plc-Analog-Min",
"Test01c-Plc-Analog-Mul",
"Test01c-Plc-Analog-Div",
"Test01c-Plc-Analog-Sub",
"Test01c-Plc-Analog-Mux",
"Test01c-Plc-Analog-Demux",
"Test01c-Plc-Analog-Select",
"Test01c-Plc-Analog-Limit",
"Test01c-Plc-Analog-Comph",
"Test01c-Plc-Analog-Compl",
"Test01c-Plc-Analog-ScanTime",
"Test01c-Plc-Analog-GreaterThan",
"Test01c-Plc-Analog-GreaterEqual",
"Test01c-Plc-Analog-LessThan",
"Test01c-Plc-Analog-LessEqual",
"Test01c-Plc-Analog-Equal",
"Test01c-Plc-Analog-NotEqual",
"Test01c-Plc-Analog-DArithm",
"Test01c-Plc-Analog-AArithm",
"Test01c-Plc-Analog-CArithm",
"Test01c-Plc-Analog-DataArithm",
"Test01c-Plc-Analog-Curve",
"Test01c-Plc-Analog-Adelay",
"Test01c-Plc-Analog-Filter",
"Test01c-Plc-Analog-Ramp",
"Test01c-Plc-Analog-Random",
"Test01c-Plc-Analog-Timint",
"Test01c-Plc-Analog-TimeMean",
"Test01c-Plc-Analog-Speed",
"Test01c-Plc-AnalogMath-ACos",
"Test01c-Plc-AnalogMath-ASin",
"Test01c-Plc-AnalogMath-ATan",
"Test01c-Plc-AnalogMath-Cos",
"Test01c-Plc-AnalogMath-Sin",
"Test01c-Plc-AnalogMath-Tan",
"Test01c-Plc-AnalogMath-Exp",
"Test01c-Plc-AnalogMath-Ln",
"Test01c-Plc-AnalogMath-Log",
"Test01c-Plc-AnalogMath-Mod",
"Test01c-Plc-AnalogMath-Sqrt",
"Test01c-Plc-AnalogMath-Abs",
"Test01c-Plc-Integer-IAdd",
"Test01c-Plc-Integer-IMax",
"Test01c-Plc-Integer-IMin",
"Test01c-Plc-Integer-IMul",
"Test01c-Plc-Integer-IMux",
"Test01c-Plc-Integer-IDemux",
"Test01c-Plc-Integer-IDiv",
"Test01c-Plc-Integer-ISub",
"Test01c-Plc-Integer-ISel",
"Test01c-Plc-Integer-IGreaterThan",
"Test01c-Plc-Integer-IGreaterEqual",
"Test01c-Plc-Integer-ILessThan",
"Test01c-Plc-Integer-ILessEqual",
"Test01c-Plc-Integer-IEqual",
"Test01c-Plc-Integer-INotEqual",
"Test01c-Plc-Integer-Even",
"Test01c-Plc-Integer-Odd",
"Test01c-Plc-Integer-IAbs",
"Test01c-Plc-Integer-ILimit",
"Test01c-Plc-Integer-BwAnd",
"Test01c-Plc-Integer-BwOr",
"Test01c-Plc-Integer-BwInv",
"Test01c-Plc-Integer-BwRotateLeft",
"Test01c-Plc-Integer-BwRotateRight",
"Test01c-Plc-Integer-BwShiftLeft",
"Test01c-Plc-Integer-BwShiftRight",
"Test01c-Plc-Grafcet-InitStep",
"Test01c-Plc-Grafcet-Step",
"Test01c-Plc-Grafcet-Trans",
"Test01c-Plc-Grafcet-SetCond",
"Test01c-Plc-Grafcet-Order",
"Test01c-Plc-Grafcet-SubStep",
"Test01c-Plc-Grafcet-OrderAct",
"Test01c-Plc-Grafcet-TransDiv",
"Test01c-Plc-Grafcet-StepDiv",
"Test01c-Plc-Other-CSub",
"Test01c-Plc-Other-CArea",
"Test01c-Plc-Other-CLoop"
};
int main()
{
pwr_tStatus sts;
unsigned int i;
pwr_tAName aname;
tst_log *log = new tst_log(&sts, "rt-Plc", "$pwrp_log/plc.log");
if (EVEN(sts))
printf("** Unable to open log file");
sts = gdh_Init("ra_test");
if (EVEN(sts)) {
printf("E pwrtest01 status, gdh_Init error status: %u\n", sts);
exit(0);
}
for (i = 0; i < sizeof(item)/sizeof(item[0]); i++) {
pwr_tBoolean val;
pwr_tInt32 state;
strcpy(aname, item[i]);
strcat(aname, "-TestExecuted.ActualValue");
sts = gdh_GetObjectInfo(aname, &val, sizeof(val));
if (EVEN(sts)) {
log->log('E', "Can't find test object", item[i], sts);
continue;
}
if (val != 1) {
log->log('E', "Not tested", item[i]);
continue;
}
strcpy(aname, item[i]);
strcat(aname, "-ErrorDetected.ActualValue");
sts = gdh_GetObjectInfo(aname, &val, sizeof(val));
if (EVEN(sts)) {
log->log('E', "gdh_GetObjectInfo", item[i], sts);
continue;
}
if (val == 1) {
char state_str[80];
strcpy(aname, item[i]);
strcat(aname, "-ErrorState.ActualValue");
sts = gdh_GetObjectInfo(aname, &state, sizeof(state));
if (EVEN(sts)) {
log->log('E', "State not found", item[i], sts);
state = -1;
}
sprintf(state_str, "error state %u", state);
log->log('E', item[i], state_str);
}
else
log->log('I', "Test ok", item[i]);
}
}
/*
Test qcom functions.
*/
#include <stdio.h>
#include <stddef.h>
#include <math.h>
#include <pthread.h>
#include "pwr_class.h"
#include "co_msg.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_syi.h"
#include "rt_gdh.h"
#include "ra_qcomtest.h"
#include "rt_qcom_msg.h"
#include "rt_hash_msg.h"
#include "rt_qdb_msg.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_cvolpwrtest01classes.h"
static int plog = 1;
typedef struct {
qcom_sAid aid1;
qcom_sAid aid2;
int sts;
} sAidCompare;
void ra_qcomtest::AidCompare(void)
{
sAidCompare d[] = {
{{0,0}, {0,0}, 0},
{{11111,1}, {11111,1}, 0},
{{11112,1}, {11111,1}, 1},
{{11111,1}, {11112,1}, -1},
{{11112,2}, {11111,1}, 1},
{{11111,2}, {11112,1}, 1},
{{11112,1}, {11111,2}, -1},
{{11111,1}, {11112,2}, -1}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = qcom_AidCompare(&d[i].aid1, &d[i].aid2);
if (sts != d[i].sts) {
m_log->log('E', "AidCompare", i);
return;
}
}
m_log->log('S', "AidCompare", QCOM__SUCCESS);
}
void ra_qcomtest::AidIsEqual(void)
{
sAidCompare d[] = {
{{0,0}, {0,0}, 1},
{{11111,1}, {11111,1}, 1},
{{11112,1}, {11111,1}, 0},
{{11111,1}, {11112,1}, 0},
{{11112,2}, {11111,1}, 0},
{{11111,2}, {11112,1}, 0},
{{11112,1}, {11111,2}, 0},
{{11111,1}, {11112,2}, 0}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = qcom_AidIsEqual(&d[i].aid1, &d[i].aid2);
if (sts != d[i].sts) {
m_log->log('E', "AidIsEqual", i);
return;
}
}
m_log->log('S', "AidIsEqual", QCOM__SUCCESS);
}
void ra_qcomtest::AidIsNotEqual(void)
{
sAidCompare d[] = {
{{0,0}, {0,0}, 0},
{{11111,1}, {11111,1}, 0},
{{11112,1}, {11111,1}, 1},
{{11111,1}, {11112,1}, 1},
{{11112,2}, {11111,1}, 1},
{{11111,2}, {11112,1}, 1},
{{11112,1}, {11111,2}, 1},
{{11111,1}, {11112,2}, 1}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = qcom_AidIsNotEqual(&d[i].aid1, &d[i].aid2);
if (sts != d[i].sts) {
m_log->log('E', "AidIsNotEqual", i);
return;
}
}
m_log->log('S', "AidIsNotEqual", QCOM__SUCCESS);
}
typedef struct {
qcom_sAid aid;
int sts;
} sAidIsNull;
void ra_qcomtest::AidIsNull(void)
{
sAidIsNull d[] = {
{{0,0}, 1},
{{11111,1}, 0},
{{11112,1}, 0},
{{0,1}, 0},
{{11112,0}, 0},
{{11111,0}, 0}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = qcom_AidIsNull(&d[i].aid);
if (sts != d[i].sts) {
m_log->log('E', "AidIsNull", i);
return;
}
}
m_log->log('S', "AidIsNull", QCOM__SUCCESS);
}
void ra_qcomtest::AidIsNotNull(void)
{
sAidIsNull d[] = {
{{0,0}, 0},
{{11111,1}, 1},
{{11112,1}, 1},
{{0,1}, 1},
{{11112,0}, 1},
{{11111,0}, 1}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = qcom_AidIsNotNull(&d[i].aid);
if (sts != d[i].sts) {
m_log->log('E', "AidIsNotNull", i);
return;
}
}
m_log->log('S', "AidIsNotNull", QCOM__SUCCESS);
}
typedef struct {
qcom_sQid qid1;
qcom_sQid qid2;
int sts;
} sQidCompare;
void ra_qcomtest::QidCompare(void)
{
sQidCompare d[] = {
{{0,0}, {0,0}, 0},
{{11111,1}, {11111,1}, 0},
{{11112,1}, {11111,1}, 1},
{{11111,1}, {11112,1}, -1},
{{11112,2}, {11111,1}, 1},
{{11111,2}, {11112,1}, 1},
{{11112,1}, {11111,2}, -1},
{{11111,1}, {11112,2}, -1}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = qcom_QidCompare(&d[i].qid1, &d[i].qid2);
if (sts != d[i].sts) {
m_log->log('E', "QidCompare", i);
return;
}
}
m_log->log('S', "QidCompare", QCOM__SUCCESS);
}
void ra_qcomtest::QidIsEqual(void)
{
sQidCompare d[] = {
{{0,0}, {0,0}, 1},
{{11111,1}, {11111,1}, 1},
{{11112,1}, {11111,1}, 0},
{{11111,1}, {11112,1}, 0},
{{11112,2}, {11111,1}, 0},
{{11111,2}, {11112,1}, 0},
{{11112,1}, {11111,2}, 0},
{{11111,1}, {11112,2}, 0}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = qcom_QidIsEqual(&d[i].qid1, &d[i].qid2);
if (sts != d[i].sts) {
m_log->log('E', "QidIsEqual", i);
return;
}
}
m_log->log('S', "QidIsEqual", QCOM__SUCCESS);
}
void ra_qcomtest::QidIsNotEqual(void)
{
sQidCompare d[] = {
{{0,0}, {0,0}, 0},
{{11111,1}, {11111,1}, 0},
{{11112,1}, {11111,1}, 1},
{{11111,1}, {11112,1}, 1},
{{11112,2}, {11111,1}, 1},
{{11111,2}, {11112,1}, 1},
{{11112,1}, {11111,2}, 1},
{{11111,1}, {11112,2}, 1}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = qcom_QidIsNotEqual(&d[i].qid1, &d[i].qid2);
if (sts != d[i].sts) {
m_log->log('E', "QidIsNotEqual", i);
return;
}
}
m_log->log('S', "QidIsNotEqual", QCOM__SUCCESS);
}
typedef struct {
qcom_sQid qid;
int sts;
} sQidIsNull;
void ra_qcomtest::QidIsNull(void)
{
sQidIsNull d[] = {
{{0,0}, 1},
{{11111,1}, 0},
{{11112,1}, 0},
{{0,1}, 0},
{{11112,0}, 0},
{{11111,0}, 0}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = qcom_QidIsNull(&d[i].qid);
if (sts != d[i].sts) {
m_log->log('E', "QidIsNull", i);
return;
}
}
m_log->log('S', "QidIsNull", QCOM__SUCCESS);
}
void ra_qcomtest::QidIsNotNull(void)
{
sQidIsNull d[] = {
{{0,0}, 0},
{{11111,1}, 1},
{{11112,1}, 1},
{{0,1}, 1},
{{11112,0}, 1},
{{11111,0}, 1}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = qcom_QidIsNotNull(&d[i].qid);
if (sts != d[i].sts) {
m_log->log('E', "QidIsNotNull", i);
return;
}
}
m_log->log('S', "QidIsNotNull", QCOM__SUCCESS);
}
typedef struct {
qcom_sQid qid;
int prefix;
char str[40];
} sQidToString;
void ra_qcomtest::QidToString(void)
{
sQidToString d[] = {
{{0,0}, 0, "0.0.0.0:0"},
{{0,0}, 1, "_Q0.0.0.0:0"},
{{1,(0<<24)+(1<<16)+(1<<8)+1}, 0, "0.1.1.1:1"},
{{1,(0<<24)+(1<<16)+(1<<8)+1}, 1, "_Q0.1.1.1:1"},
{{77777,((unsigned int)200<<24)+(44<<16)+(55<<8)+66}, 0, "200.44.55.66:77777"},
{{77777,((unsigned int)200<<24)+(44<<16)+(55<<8)+66}, 1, "_Q200.44.55.66:77777"}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
strcpy(str, "");
qcom_QidToString(str, &d[i].qid, d[i].prefix);
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "QidToString", i);
return;
}
}
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
strcpy(str, qcom_QidToString(0, &d[i].qid, d[i].prefix));
if (strcmp(str, d[i].str) != 0) {
m_log->log('E', "QidToString, ObjidToString", i);
return;
}
}
m_log->log('S', "QidToString", QCOM__SUCCESS);
}
typedef struct {
unsigned int size;
pwr_tStatus asts;
pwr_tStatus fsts;
} sAlloc;
void ra_qcomtest::Alloc(void)
{
sAlloc d[] = {
{0, QCOM__SUCCESS, QCOM__SUCCESS},
{4, QCOM__SUCCESS, QCOM__SUCCESS},
{400, QCOM__SUCCESS, QCOM__SUCCESS},
{40000, QCOM__SUCCESS, QCOM__SUCCESS},
{4000000, QCOM__SUCCESS, QCOM__SUCCESS},
{40000000, QCOM__SUCCESS, QCOM__SUCCESS}
};
void *p;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
p = qcom_Alloc(&m_sts, d[i].size);
if (m_sts != d[i].asts) {
m_log->vlog('E', "Alloc", m_sts);
return;
}
if (ODD(m_sts)) {
qcom_Free(&m_sts, p);
if (m_sts != d[i].asts) {
m_log->vlog('E', "Alloc, Free", m_sts);
return;
}
}
}
m_log->log('S', "Alloc", QCOM__SUCCESS);
}
typedef struct {
qcom_sQid qid;
char name[32];
qcom_eQtype type;
int quota;
pwr_tStatus csts;
pwr_tBoolean creturn;
pwr_tStatus dsts;
pwr_tBoolean dreturn;
} sCreateQ;
void ra_qcomtest::CreateQ(void)
{
sCreateQ d[] = {
{{0,0}, "queue1", qcom_eQtype_private, 100, QCOM__SUCCESS, 1, HASH__SUCCESS, 1},
{{3333,0}, "queue3333", qcom_eQtype_private, 100, QCOM__SUCCESS, 1, HASH__SUCCESS, 1},
{{3334,0}, "queue3334", qcom_eQtype_forward, 100, QCOM__SUCCESS, 1, HASH__SUCCESS, 1},
{{3335,0}, "queue3335", qcom_eQtype_broadcast, 100, QCOM__SUCCESS, 1, HASH__SUCCESS, 1},
{{3336,0}, "queue3336", qcom_eQtype_event, 100, QCOM__SUCCESS, 1, HASH__SUCCESS, 1}
};
qcom_sQattr attr;
pwr_tBoolean b;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
attr.type = d[i].type;
attr.quota = d[i].quota;
b = qcom_CreateQ(&m_sts, &d[i].qid, &attr, d[i].name);
if (m_sts != d[i].csts || b != d[i].creturn) {
m_log->log('E', "CreateQ", m_sts);
return;
}
if (ODD(m_sts)) {
b = qcom_DeleteQ(&m_sts, &d[i].qid);
if (m_sts != d[i].dsts || b != d[i].dreturn) {
m_log->log('E', "CreateQ, qcom_DeleteQ", m_sts);
return;
}
}
}
m_log->log('S', "CreateQ", QCOM__SUCCESS);
}
typedef struct {
char msg[1000];
qcom_eBtype btype;
qcom_eStype stype;
pwr_tStatus sts;
} sPut;
void ra_qcomtest::Put(void)
{
sPut d[] = {
{"Some message 1", (qcom_eBtype)2001, (qcom_eStype)1, QCOM__SUCCESS},
{"Some message 2", (qcom_eBtype)32, (qcom_eStype)31, QCOM__SUCCESS},
{"A longer message, A longer message, A longer message, A longer message, A longer message,"
"A longer message, A longer message, A longer message, A longer message, A longer message,"
"A longer message, A longer message, A longer message, A longer message, A longer message,"
"A longer message, A longer message, A longer message, A longer message, A longer message,"
"A longer message, A longer message, A longer message, A longer message, A longer message,"
"A longer message, A longer message, A longer message, A longer message, A longer message,"
"A longer message, A longer message, A longer message, A longer message, A longer message,"
"A longer message, A longer message, A longer message, A longer message, A longer message,"
"A longer message, A longer message, A longer message, A longer message, A longer message,"
"A longer message, A longer message, A longer message, A longer message, A longer message",
(qcom_eBtype)2020, (qcom_eStype)31, QCOM__SUCCESS}
};
qcom_sQattr attr;
qcom_sPut put;
qcom_sGet get;
qcom_sQid sqid = {3337,0};
attr.type = qcom_eQtype_private;
attr.quota = 100;
qcom_CreateQ(&m_sts, &sqid, &attr, "queue3337");
if (EVEN(m_sts)) {
m_log->log('E', "Put, qcom_CreateQ", m_sts);
return;
}
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
put.reply = sqid;
put.type.b = d[i].btype;
put.type.s = d[i].stype;
put.size = strlen(d[i].msg) + 1;
put.data = d[i].msg;
qcom_Put(&m_sts, &sqid, &put);
if (ODD(m_sts)) {
get.data = 0;
qcom_Get(&m_sts, &sqid, &get, qcom_cTmoEternal);
if (EVEN(m_sts)) {
m_log->log('E', "Put, qcom_Get", m_sts);
return;
}
if (strcmp((char *)put.data, (char *)get.data) != 0 ||
get.type.b != d[i].btype ||
get.type.s != d[i].stype ||
get.size != strlen(d[i].msg) + 1) {
m_log->vlog('E', "Put, content differs, %d", i);
return;
}
qcom_Free(&m_sts, get.data);
if (EVEN(m_sts)) {
m_log->log('E', "Put, qcom_Free", m_sts);
return;
}
}
}
// Check quota
for (unsigned int i = 0; i < 110; i++) {
put.reply = sqid;
put.type.b = d[0].btype;
put.type.s = d[0].stype;
put.size = strlen(d[0].msg) + 1;
put.data = d[0].msg;
qcom_Put(&m_sts, &sqid, &put);
if (EVEN(m_sts)) {
if (i < 100) {
m_log->log('E', "Put, qcom_Put", m_sts);
return;
}
else {
if (m_sts != QDB__QUOTAEXCEEDED) {
m_log->log('E', "Put, qcom_Put", m_sts);
return;
}
}
}
}
for (unsigned int i = 0; i < 100; i++) {
get.data = 0;
qcom_Get(&m_sts, &sqid, &get, qcom_cTmoEternal);
if (EVEN(m_sts)) {
m_log->log('E', "Put, qcom_Get", m_sts);
return;
}
if (strcmp((char *)d[0].msg, (char *)get.data) != 0 ||
get.type.b != d[0].btype ||
get.type.s != d[0].stype ||
get.size != strlen(d[0].msg) + 1) {
m_log->vlog('E', "Put, content differs, %d", i);
return;
}
qcom_Free(&m_sts, get.data);
if (EVEN(m_sts)) {
m_log->log('E', "Put, qcom_Free", m_sts);
return;
}
}
qcom_DeleteQ(&m_sts, &sqid);
if (EVEN(m_sts)) {
m_log->log('E', "Put, qcom_DeleteQ", m_sts);
return;
}
m_log->log('S', "Put", QCOM__SUCCESS);
}
typedef struct {
char msg[1000];
qcom_eBtype btype;
qcom_eStype stype;
int tmotest;
int tmo;
int alloc;
pwr_tStatus sts;
} sGet;
void ra_qcomtest::Get(void)
{
sGet d[] = {
{"Some message 1", (qcom_eBtype)2001, (qcom_eStype)1, 0, qcom_cTmoEternal, 1, QCOM__SUCCESS},
{"Some message 2", (qcom_eBtype)32, (qcom_eStype)31, 0, 20, 0, QCOM__SUCCESS},
{"Some message 3", (qcom_eBtype)32, (qcom_eStype)31, 1, 20, 0, QCOM__TMO},
{"Some message 4", (qcom_eBtype)32, (qcom_eStype)31, 1, 200, 0, QCOM__TMO},
{"Some message 5", (qcom_eBtype)32, (qcom_eStype)31, 1, 2000, 0, QCOM__TMO},
{"Some message 6", (qcom_eBtype)32, (qcom_eStype)31, 1, 10000, 0, QCOM__TMO}
};
qcom_sQattr attr;
qcom_sPut put;
qcom_sGet get;
qcom_sQid sqid = {3338,0};
pwr_tTime before, after;
attr.type = qcom_eQtype_private;
attr.quota = 100;
qcom_CreateQ(&m_sts, &sqid, &attr, "queue3338");
if (EVEN(m_sts)) {
m_log->log('E', "Get, qcom_CreateQ", m_sts);
return;
}
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
put.reply = sqid;
put.type.b = d[i].btype;
put.type.s = d[i].stype;
put.size = strlen(d[i].msg) + 1;
put.data = d[i].msg;
if (!d[i].tmotest) {
qcom_Put(&m_sts, &sqid, &put);
if (EVEN(m_sts)) {
m_log->log('E', "Get, qcom_Put", m_sts);
return;
}
}
if (d[i].alloc) {
get.maxSize = strlen(d[i].msg) + 1;
get.data = malloc(get.maxSize);
}
else
get.data = 0;
time_GetTime(&before);
qcom_Get(&m_sts, &sqid, &get, d[i].tmo);
time_GetTime(&after);
if (m_sts != d[i].sts) {
m_log->log('E', "Get, qcom_Get", m_sts);
return;
}
if (!d[i].tmotest) {
if (strcmp((char *)put.data, (char *)get.data) != 0 ||
get.type.b != d[i].btype ||
get.type.s != d[i].stype ||
get.size != strlen(d[i].msg) + 1) {
m_log->vlog('E', "Get, content differs, %d", i);
return;
}
if (d[i].alloc)
free(get.data);
else {
qcom_Free(&m_sts, get.data);
if (EVEN(m_sts)) {
m_log->log('E', "Get, qcom_Free", m_sts);
return;
}
}
}
else {
// Check time
pwr_tDeltaTime dt;
pwr_tFloat32 df;
int di;
time_Adiff(&dt, &after, &before);
time_DToFloat(&df, &dt);
di = int(df * 1000 + 0.5);
if (abs(d[i].tmo - di) > 1) {
m_log->vlog('E', "Get, timeout mismatch %d %d", d[i].tmo, di);
return;
}
}
}
qcom_DeleteQ(&m_sts, &sqid);
if (EVEN(m_sts)) {
m_log->log('E', "Get, qcom_DeleteQ", m_sts);
return;
}
m_log->log('S', "Get", QCOM__SUCCESS);
}
void ra_qcomtest::MyBus(void)
{
qcom_tBus bus;
char *s;
int num, pwr_bus_id;
bus = qcom_MyBus(&m_sts);
if (EVEN(m_sts)) {
m_log->log('E', "MyBus", m_sts);
return;
}
s = getenv("PWR_BUS_ID");
if (!s) {
m_log->log('E', "MyBus, couldn't get PWR_BUS_ID");
return;
}
num = sscanf(s, "%d", &pwr_bus_id);
if (num != 1) {
m_log->log('E', "MyBus, PWR_BUS_ID syntax error");
return;
}
if (pwr_bus_id != bus) {
m_log->vlog('E', "MyBus, bus differs %d %d", bus, pwr_bus_id);
return;
}
m_log->log('S', "MyBus", QCOM__SUCCESS);
}
void ra_qcomtest::MyNode(void)
{
qcom_sNode node;
char name[80], nname[80];
syi_NodeName(&m_sts, nname, sizeof(nname));
if (EVEN(m_sts)) {
m_log->log('E', "MyNode, syi_Nodename", m_sts);
return;
}
qcom_MyNode(&m_sts, &node);
if (EVEN(m_sts)) {
m_log->log('E', "MyNode, syi_Nodename", m_sts);
return;
}
strncpy(name, qcom_NodeName(node.nid), sizeof(name));
if (strcmp(name, nname) != 0) {
m_log->vlog('E', "MyNode, node not found %s", nname);
return;
}
m_log->log('S', "MyNode", QCOM__SUCCESS);
}
void ra_qcomtest::NextNode(void)
{
pwr_tNid nid;
qcom_sNode node;
char name[80], nname[80];
int found = 0;
syi_NodeName(&m_sts, nname, sizeof(nname));
if (EVEN(m_sts)) {
m_log->log('E', "NextNode, syi_Nodename", m_sts);
return;
}
for (nid = qcom_cNNid; qcom_NextNode(&m_sts, &node, nid); nid = node.nid) {
strncpy(name, qcom_NodeName(node.nid), sizeof(name));
if (strcmp(name, nname) == 0)
found = 1;
}
if (!found) {
m_log->vlog('E', "NextNode, node not found %s", nname);
return;
}
m_log->log('S', "NextNode", QCOM__SUCCESS);
}
typedef struct {
char msg[1000];
qcom_eBtype btype;
qcom_eStype stype;
} sForwarding;
void ra_qcomtest::Forwarding(void)
{
sForwarding d[] = {
{"Some message 1", (qcom_eBtype)2001, (qcom_eStype)1},
{"Some message 2", (qcom_eBtype)32, (qcom_eStype)31},
{"Some message 3", (qcom_eBtype)32, (qcom_eStype)31},
{"Some message 4", (qcom_eBtype)32, (qcom_eStype)31},
{"Some message 5", (qcom_eBtype)32, (qcom_eStype)31},
{"Some message 6", (qcom_eBtype)32, (qcom_eStype)31}
};
qcom_sQattr attr;
qcom_sPut put;
qcom_sGet get;
qcom_sQid private_qid = {3339,0};
qcom_sQid forw1_qid = {3340,0};
qcom_sQid forw2_qid = {3341,0};
// Create two forwarding queues and one private
attr.type = qcom_eQtype_private;
attr.quota = 100;
qcom_CreateQ(&m_sts, &private_qid, &attr, "queue3339");
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_CreateQ", m_sts);
return;
}
attr.type = qcom_eQtype_forward;
attr.quota = 100;
qcom_CreateQ(&m_sts, &forw1_qid, &attr, "queue3340");
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_CreateQ", m_sts);
return;
}
attr.type = qcom_eQtype_forward;
attr.quota = 100;
qcom_CreateQ(&m_sts, &forw2_qid, &attr, "queue3341");
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_CreateQ", m_sts);
return;
}
// Bind private queue to forwarding queues
qcom_Bind(&m_sts, &private_qid, &forw1_qid);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_Bind", m_sts);
return;
}
qcom_Bind(&m_sts, &private_qid, &forw2_qid);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_Bind", m_sts);
return;
}
// Put and get each message
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
put.reply = private_qid;
put.type.b = d[i].btype;
put.type.s = d[i].stype;
put.size = strlen(d[i].msg) + 1;
put.data = d[i].msg;
if (EVEN(i))
qcom_Put(&m_sts, &forw1_qid, &put);
else
qcom_Put(&m_sts, &forw2_qid, &put);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_Put", m_sts);
return;
}
get.data = 0;
qcom_Get(&m_sts, &private_qid, &get, qcom_cTmoEternal);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_Get", m_sts);
return;
}
if (strcmp((char *)put.data, (char *)get.data) != 0 ||
get.type.b != d[i].btype ||
get.type.s != d[i].stype ||
get.size != strlen(d[i].msg) + 1) {
m_log->vlog('E', "Forwarding, content differs, %d", i);
return;
}
qcom_Free(&m_sts, get.data);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_Free", m_sts);
return;
}
}
// Put all messages first and then get
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
put.reply = private_qid;
put.type.b = d[i].btype;
put.type.s = d[i].stype;
put.size = strlen(d[i].msg) + 1;
put.data = d[i].msg;
if (EVEN(i))
qcom_Put(&m_sts, &forw1_qid, &put);
else
qcom_Put(&m_sts, &forw2_qid, &put);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_Put", m_sts);
return;
}
}
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
get.data = 0;
qcom_Get(&m_sts, &private_qid, &get, qcom_cTmoEternal);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_Get", m_sts);
return;
}
if (strcmp((char *)d[i].msg, (char *)get.data) != 0 ||
get.type.b != d[i].btype ||
get.type.s != d[i].stype ||
get.size != strlen(d[i].msg) + 1) {
m_log->vlog('E', "Forwarding, content differs, %d", i);
return;
}
qcom_Free(&m_sts, get.data);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_Free", m_sts);
return;
}
}
qcom_Unbind(&m_sts, &forw1_qid, &private_qid);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_UnbindQ", m_sts);
return;
}
qcom_Unbind(&m_sts, &forw2_qid, &private_qid);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_Unbind", m_sts);
return;
}
qcom_DeleteQ(&m_sts, &private_qid);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_DeleteQ", m_sts);
return;
}
qcom_DeleteQ(&m_sts, &forw1_qid);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_DeleteQ", m_sts);
return;
}
qcom_DeleteQ(&m_sts, &forw2_qid);
if (EVEN(m_sts)) {
m_log->log('E', "Forwarding, qcom_DeleteQ", m_sts);
return;
}
m_log->log('S', "Forwarding", QCOM__SUCCESS);
}
typedef struct {
int is_event;
int wait_and;
char msg[100];
qcom_eBtype btype;
qcom_eStype stype;
int mask;
int event;
} sSignallingData;
typedef struct {
ra_qcomtest *qcomtest;
int errcnt;
qcom_sQid event_qid;
qcom_sQid msg_qid;
unsigned int thread_waiting;
unsigned int thread_awake;
sSignallingData d[12];
} sSignalling;
static void *signal_listen(void *arg)
{
sSignalling *d = (sSignalling *)arg;
pwr_tStatus sts;
int event;
qcom_sGet get;
for (unsigned int i = 0; i < sizeof(d->d)/sizeof(d->d[0]); i++) {
d->thread_waiting = 1;
d->qcomtest->log()->vlog('D', "Thread waiting %d", i);
if (d->d[i].wait_and) {
qcom_WaitAnd(&sts, &d->msg_qid, &d->event_qid, d->d[i].mask,
qcom_cTmoEternal);
}
else {
qcom_WaitOr(&sts, &d->msg_qid, &d->event_qid, d->d[i].mask,
qcom_cTmoEternal, &event);
if (plog)
d->qcomtest->log()->vlog('D', "Thread awake %d %d", i, event);
if (event != d->d[i].event) {
d->qcomtest->log()->vlog('X', "Signalling, event differs (%d != %d), %d",
event, d->d[i].event, i);
d->errcnt++;
}
if (event == 0) {
get.data = 0;
qcom_Get(&sts, &d->msg_qid, &get, 100);
if EVEN(sts) {
d->qcomtest->log()->log('X', "Signalling, qcom_Get", sts);
d->errcnt++;
}
else {
if (strcmp(d->d[i].msg, (char *)get.data) != 0) {
d->qcomtest->log()->vlog('X', "Get, content differs, %d", i);
d->errcnt++;
}
qcom_Free(&sts, get.data);
if (EVEN(sts)) {
d->qcomtest->log()->log('X', "Get, qcom_Free", sts);
d->errcnt++;
}
}
}
}
d->thread_waiting = 0;
d->thread_awake++;
time_Sleep(0.1);
}
pthread_exit(0);
}
void ra_qcomtest::Signalling(void)
{
sSignalling d = {
this, 0, {3342,0}, {3343,0}, 0, 0, {
{1, 0, "", (qcom_eBtype)0, (qcom_eStype)0, 0x101, 0x100},
{1, 0, "", (qcom_eBtype)0, (qcom_eStype)0, 0x104, 0x004},
{1, 0, "", (qcom_eBtype)0, (qcom_eStype)0, 0xfff, 0x1},
{1, 0, "", (qcom_eBtype)0, (qcom_eStype)0, 0x100, 0x100},
{0, 0, "Some message 1", (qcom_eBtype)5, (qcom_eStype)5, 0x000, 0x000},
{1, 0, "", (qcom_eBtype)0, (qcom_eStype)0, 0x100, 0x100},
{0, 0, "Some message 2", (qcom_eBtype)5, (qcom_eStype)5, 0x000, 0x000},
{1, 0, "", (qcom_eBtype)0, (qcom_eStype)0, 0x100, 0x100},
{0, 0, "Some message 3", (qcom_eBtype)5, (qcom_eStype)5, 0x000, 0x000},
{1, 0, "", (qcom_eBtype)0, (qcom_eStype)0, 0x100, 0x100},
{1, 1, "", (qcom_eBtype)0, (qcom_eStype)0, 0x100, 0x100},
{1, 1, "", (qcom_eBtype)0, (qcom_eStype)0, 0x104, 0x104}
}};
qcom_sQattr attr;
pthread_t tid;
int psts;
qcom_sPut put;
// Create event queue
attr.type = qcom_eQtype_event;
attr.quota = 100;
qcom_CreateQ(&m_sts, &d.event_qid, &attr, "queue3342");
if (EVEN(m_sts)) {
m_log->log('E', "Signalling, qcom_CreateQ", m_sts);
return;
}
// Create message queue
attr.type = qcom_eQtype_private;
attr.quota = 100;
qcom_CreateQ(&m_sts, &d.msg_qid, &attr, "queue3343");
if (EVEN(m_sts)) {
m_log->log('E', "Signalling, qcom_CreateQ", m_sts);
return;
}
// Create a listening thread
psts = pthread_create(&tid, NULL, signal_listen, (void*)&d);
if (psts != 0) {
m_log->vlog('E', "Signalling, pthread_create %d", psts);
return;
}
time_Sleep(1);
for (unsigned int i = 0; i < sizeof(d.d)/sizeof(d.d[0]); i++) {
if (d.d[i].is_event) {
if (plog)
m_log->vlog('D', "Signalling %d %d", i, d.d[i].event);
qcom_SignalOr(&m_sts, &d.event_qid, d.d[i].event);
time_Sleep(0.1);
if (plog)
m_log->vlog('D', "Signalling %d 0", i);
qcom_SignalAnd(&m_sts, &d.event_qid, 0);
}
else {
put.reply = d.msg_qid;
put.type.b = d.d[i].btype;
put.type.s = d.d[i].stype;
put.size = strlen(d.d[i].msg) + 1;
put.data = d.d[i].msg;
m_log->vlog('D', "Putting %d", i);
qcom_Put(&m_sts, &d.msg_qid, &put);
if (EVEN(m_sts)) {
m_log->log('E', "Signalling, qcom_Put", m_sts);
return;
}
}
time_Sleep(0.1);
if (d.thread_awake != i + 1) {
m_log->vlog('E', "Signalling, index mismatch (%d != %d)",
d.thread_awake, i+1);
return;
}
time_Sleep(0.1);
}
pthread_join(tid, NULL);
qcom_DeleteQ(&m_sts, &d.event_qid);
if (EVEN(m_sts)) {
m_log->log('E', "Signalling, qcom_DeleteQ", m_sts);
return;
}
qcom_DeleteQ(&m_sts, &d.msg_qid);
if (EVEN(m_sts)) {
m_log->log('E', "Signalling, qcom_DeleteQ", m_sts);
return;
}
if (d.errcnt)
m_log->vlog('E', "Signalling, %d errors", d.errcnt);
else
m_log->log('S', "Signalling", QCOM__SUCCESS);
}
typedef struct {
int is_event;
char msg[100];
qcom_eBtype btype;
qcom_eStype stype;
int event;
} sBindEventData;
typedef struct {
ra_qcomtest *qcomtest;
int errcnt;
qcom_sQid event_qid;
qcom_sQid msg_qid;
unsigned int thread_waiting;
unsigned int thread_awake;
sBindEventData d[10];
} sBindEvent;
static void *bindevent_listen(void *arg)
{
sBindEvent *d = (sBindEvent *)arg;
pwr_tStatus sts;
qcom_sGet get;
qcom_sEvent *ep;
for (unsigned int i = 0; i < sizeof(d->d)/sizeof(d->d[0]); i++) {
d->thread_waiting = 1;
d->qcomtest->log()->vlog('D', "Thread waiting %d", i);
get.data = 0;
qcom_Get(&sts, &d->msg_qid, &get, qcom_cTmoEternal);
if EVEN(sts) {
d->qcomtest->log()->log('X', "BindEvent, qcom_Get", sts);
d->errcnt++;
}
else {
d->qcomtest->log()->vlog('D', "Thread awake %d %d", i, get.type.b);
switch(get.type.b) {
case qcom_eBtype_event:
ep = (qcom_sEvent *)get.data;
if (ep->mask != d->d[i].event) {
d->qcomtest->log()->vlog('X', "BindEvent, event differs %d != %d",
ep->mask, d->d[i].event);
d->errcnt++;
}
break;
default:
if (strcmp(d->d[i].msg, (char *)get.data) != 0) {
d->qcomtest->log()->vlog('X', "Get, content differs, %d", i);
d->errcnt++;
}
}
qcom_Free(&sts, get.data);
if (EVEN(sts)) {
d->qcomtest->log()->log('X', "Get, qcom_Free", sts);
d->errcnt++;
}
}
d->thread_waiting = 0;
d->thread_awake++;
time_Sleep(0.1);
}
pthread_exit(0);
}
void ra_qcomtest::BindEvent(void)
{
sBindEvent d = {
this, 0, {3344,0}, {3345,0}, 0, 0, {
{1, "", (qcom_eBtype)0, (qcom_eStype)0, 0x004},
{1, "", (qcom_eBtype)0, (qcom_eStype)0, 0x004},
{1, "", (qcom_eBtype)0, (qcom_eStype)0, 0x004},
{1, "", (qcom_eBtype)0, (qcom_eStype)0, 0x004},
{0, "Some message 1", (qcom_eBtype)5, (qcom_eStype)5, 0x000},
{1, "", (qcom_eBtype)0, (qcom_eStype)0, 0x004},
{0, "Some message 2", (qcom_eBtype)5, (qcom_eStype)5, 0x000},
{1, "", (qcom_eBtype)0, (qcom_eStype)0, 0x004},
{0, "Some message 3", (qcom_eBtype)5, (qcom_eStype)5, 0x000},
{1, "", (qcom_eBtype)0, (qcom_eStype)0, 0x004}
}};
qcom_sQattr attr;
pthread_t tid;
int psts;
qcom_sPut put;
// Create event queue
attr.type = qcom_eQtype_event;
attr.quota = 100;
qcom_CreateQ(&m_sts, &d.event_qid, &attr, "queue3344");
if (EVEN(m_sts)) {
m_log->log('E', "BindEvent, qcom_CreateQ", m_sts);
return;
}
// Create message queue
attr.type = qcom_eQtype_private;
attr.quota = 100;
qcom_CreateQ(&m_sts, &d.msg_qid, &attr, "queue3345");
if (EVEN(m_sts)) {
m_log->log('E', "BindEvent, qcom_CreateQ", m_sts);
return;
}
// Bind event que to message queue
qcom_Bind(&m_sts, &d.msg_qid, &d.event_qid);
if (EVEN(m_sts)) {
m_log->log('E', "BindEvent, qcom_Bind", m_sts);
return;
}
// Create a listening thread
psts = pthread_create(&tid, NULL, bindevent_listen, (void*)&d);
if (psts != 0) {
m_log->vlog('E', "BindEvent, pthread_create %d", psts);
return;
}
time_Sleep(1);
for (unsigned int i = 0; i < sizeof(d.d)/sizeof(d.d[0]); i++) {
if (d.d[i].is_event) {
if (plog)
m_log->vlog('D', "BindEvent %d %d", i, d.d[i].event);
qcom_SignalOr(&m_sts, &d.event_qid, d.d[i].event);
time_Sleep(0.1);
//if (plog)
//m_log->vlog('D', "BindEvent %d 0", i);
//qcom_SignalAnd(&m_sts, &d.event_qid, 0);
}
else {
put.reply = d.msg_qid;
put.type.b = d.d[i].btype;
put.type.s = d.d[i].stype;
put.size = strlen(d.d[i].msg) + 1;
put.data = d.d[i].msg;
m_log->vlog('D', "Putting %d", i);
qcom_Put(&m_sts, &d.msg_qid, &put);
if (EVEN(m_sts)) {
m_log->log('X', "BindEvent, qcom_Put", m_sts);
d.errcnt++;
}
}
time_Sleep(0.1);
if (d.thread_awake != i + 1) {
m_log->vlog('X', "BindEvent, index mismatch (%d != %d)",
d.thread_awake, i+1);
d.errcnt++;
}
time_Sleep(0.1);
}
//time_Sleep(10000);
pthread_join(tid, NULL);
qcom_Unbind(&m_sts, &d.event_qid, &d.msg_qid);
if (EVEN(m_sts)) {
m_log->log('E', "BindEvent, qcom_Unbind", m_sts);
return;
}
qcom_DeleteQ(&m_sts, &d.event_qid);
if (EVEN(m_sts)) {
m_log->log('E', "BindEvent, qcom_DeleteQ", m_sts);
return;
}
qcom_DeleteQ(&m_sts, &d.msg_qid);
if (EVEN(m_sts)) {
m_log->log('E', "BindEvent, qcom_DeleteQ", m_sts);
return;
}
if (d.errcnt)
m_log->vlog('E', "BindEvent, %d errors", d.errcnt);
else
m_log->log('S', "BindEvent", QCOM__SUCCESS);
}
typedef struct {
char msg[100];
char rmsg[100];
qcom_eBtype btype;
qcom_eStype stype;
} sRequestData;
typedef struct {
ra_qcomtest *qcomtest;
int errcnt;
qcom_sQid request_qid;
qcom_sQid reply_qid;
unsigned int thread_awake;
sRequestData d[12];
} sRequest;
static void *request_listen(void *arg)
{
sRequest *d = (sRequest *)arg;
pwr_tStatus sts;
qcom_sGet get;
qcom_sPut put;
for (unsigned int i = 0; i < sizeof(d->d)/sizeof(d->d[0]); i++) {
if (plog)
d->qcomtest->log()->vlog('D', "Thread waiting %d", i);
get.data = 0;
qcom_Get(&sts, &d->request_qid, &get, qcom_cTmoEternal);
if EVEN(sts) {
d->qcomtest->log()->log('X', "Request thread, qcom_Get", sts);
d->errcnt++;
}
else {
if (strcmp(d->d[i].msg, (char *)get.data) != 0) {
d->qcomtest->log()->vlog('X', "Request thread, content differs, %d", i);
d->errcnt++;
}
put.reply = d->reply_qid;
put.type.b = d->d[i].btype;
put.type.s = d->d[i].stype;
put.size = strlen(d->d[i].rmsg) + 1;
put.data = d->d[i].rmsg;
qcom_Reply(&sts, &get, &put);
qcom_Free(&sts, get.data);
if (EVEN(sts)) {
d->qcomtest->log()->log('X', "Request thread, qcom_Free", sts);
d->errcnt++;
}
}
d->thread_awake++;
}
pthread_exit(0);
}
void ra_qcomtest::Request(void)
{
sRequest d = {
this, 0, {3346,0}, {3347,0}, 0, {
{"Request message 1", "Reply message 1", (qcom_eBtype)5, (qcom_eStype)5},
{"Request message 2", "Reply message 2", (qcom_eBtype)5, (qcom_eStype)5},
{"Request message 3", "Reply message 3", (qcom_eBtype)5, (qcom_eStype)5},
{"Request message 4", "Reply message 4", (qcom_eBtype)5, (qcom_eStype)5},
{"Request message 5", "Reply message 5", (qcom_eBtype)5, (qcom_eStype)5},
{"Request message 6", "Reply message 6", (qcom_eBtype)5, (qcom_eStype)5},
{"Request message 7", "Reply message 7", (qcom_eBtype)5, (qcom_eStype)5},
{"Request message 8", "Reply message 8", (qcom_eBtype)5, (qcom_eStype)5},
{"Request message 9", "Reply message 9", (qcom_eBtype)5, (qcom_eStype)5},
{"Request message 10", "Reply message 10", (qcom_eBtype)5, (qcom_eStype)5},
{"Request message 11", "Reply message 11", (qcom_eBtype)5, (qcom_eStype)5},
{"Request message 12", "Reply message 12", (qcom_eBtype)5, (qcom_eStype)5}
}};
qcom_sQattr attr;
pthread_t tid;
int psts;
qcom_sPut put;
qcom_sGet get;
// Create request queue
attr.type = qcom_eQtype_private;
attr.quota = 100;
qcom_CreateQ(&m_sts, &d.request_qid, &attr, "queue3346");
if (EVEN(m_sts)) {
m_log->log('E', "Request, qcom_CreateQ", m_sts);
return;
}
// Create reply queue
attr.type = qcom_eQtype_private;
attr.quota = 100;
qcom_CreateQ(&m_sts, &d.reply_qid, &attr, "queue3346");
if (EVEN(m_sts)) {
m_log->log('E', "Request, qcom_CreateQ", m_sts);
return;
}
// Create a listening thread
psts = pthread_create(&tid, NULL, request_listen, (void*)&d);
if (psts != 0) {
m_log->vlog('E', "Request, pthread_create %d", psts);
return;
}
time_Sleep(1);
for (unsigned int i = 0; i < sizeof(d.d)/sizeof(d.d[0]); i++) {
put.reply = d.reply_qid;
put.type.b = d.d[i].btype;
put.type.s = d.d[i].stype;
put.size = strlen(d.d[i].msg) + 1;
put.data = d.d[i].msg;
get.data = 0;
if (plog)
m_log->vlog('D', "Requesting %d", i);
qcom_Request(&m_sts, &d.request_qid, &put, &d.reply_qid, &get,
100000, 0);
if (EVEN(m_sts)) {
m_log->log('E', "Request, qcom_Request", m_sts);
return;
}
if (strcmp(d.d[i].rmsg, (char *)get.data) != 0) {
m_log->vlog('E', "Request, reply content differs %d", i);
return;
}
qcom_Free(&m_sts, get.data);
if (EVEN(m_sts)) {
m_log->log('E', "Request, qcom_Free", m_sts);
return;
}
time_Sleep(0.1);
if (d.thread_awake != i + 1) {
m_log->vlog('E', "Request, index mismatch (%d != %d)",
d.thread_awake, i+1);
return;
}
time_Sleep(0.1);
}
pthread_join(tid, NULL);
qcom_DeleteQ(&m_sts, &d.request_qid);
if (EVEN(m_sts)) {
m_log->log('E', "Request, qcom_DeleteQ", m_sts);
return;
}
qcom_DeleteQ(&m_sts, &d.reply_qid);
if (EVEN(m_sts)) {
m_log->log('E', "Request, qcom_DeleteQ", m_sts);
return;
}
if (d.errcnt)
m_log->vlog('E', "Request, %d errors", d.errcnt);
else
m_log->log('S', "Request", QCOM__SUCCESS);
}
// Constructor
ra_qcomtest::ra_qcomtest()
{
m_log = new tst_log(&m_sts, "rt-Qcom", "$pwrp_log/qcom.log");
if (EVEN(m_sts))
printf("** Unable to open log file");
}
// Destructor
ra_qcomtest::~ra_qcomtest()
{
delete m_log;
}
int main()
{
ra_qcomtest qcom;
pwr_tStatus sts;
sts = gdh_Init("ra_qcomtest");
if (EVEN(sts)) {
qcom.log()->log('S', "qcom gdh_Init", sts);
exit(0);
}
qcom.AidCompare();
qcom.AidIsEqual();
qcom.AidIsNotEqual();
qcom.AidIsNull();
qcom.AidIsNotNull();
qcom.QidCompare();
qcom.QidIsEqual();
qcom.QidIsNotEqual();
qcom.QidIsNull();
qcom.QidIsNotNull();
qcom.QidToString();
qcom.Alloc();
qcom.CreateQ();
qcom.Put();
qcom.Get();
qcom.MyBus();
qcom.MyNode();
qcom.NextNode();
qcom.Forwarding();
qcom.Signalling();
qcom.BindEvent();
qcom.Request();
}
#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();
};
/*
Test qmon functions.
*/
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <math.h>
#include <pthread.h>
#include "pwr_class.h"
#include "co_msg.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_syi.h"
#include "rt_gdh.h"
#include "ra_qmontest.h"
#include "rt_qcom_msg.h"
#include "rt_hash_msg.h"
#include "rt_qdb_msg.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_cvolpwrtest01classes.h"
static int plog = 1;
#define cServerVid "_V0.254.254.203"
#define cServerQix 3337
#define cClientVid "_V0.254.254.203"
#define cClientQix 3338
typedef enum {
eTest_Put = 1,
eTest_PutResult = 2,
eTest_Put10k = 3,
eTest_Put10kResult = 4,
eTest_Put100k = 5,
eTest_Put100kResult = 6,
eTest_PutCyclic = 7,
eTest_PutCyclicResult = 8,
eTest_End = 99
} eTest;
void ra_qmontest::evaluate(int action, int result)
{
switch(action) {
case eTest_PutResult:
if (result < m_qquota) {
m_log->vlog('E', "Put, messages less than queue quota, %d/%d", m_sent, result);
m_errcnt++;
}
else
m_log->vlog('S', "Put, message sent/received, %d/%d", m_sent, result);
break;
case eTest_Put10kResult:
if (result < m_qquota) {
m_log->vlog('E', "Put10k, messages less than queue quota, %d/%d", m_sent, result);
m_errcnt++;
}
else
m_log->vlog('S', "Put10k, message sent/received, %d/%d", m_sent, result);
break;
case eTest_Put100kResult:
if (result < m_qquota) {
m_log->vlog('E', "Put100k, messages less than queue quota, %d/%d", m_sent, result);
m_errcnt++;
}
else
m_log->vlog('S', "Put100k, message sent/received, %d/%d", m_sent, result);
break;
case eTest_PutCyclicResult:
if (m_sent != result) {
m_log->vlog('E', "PutCyclic, message lost, %d/%d", m_sent, result);
m_errcnt++;
}
else
m_log->vlog('S', "PutCyclic, message sent/received, %d/%d", m_sent, result);
break;
default: ;
}
}
void ra_qmontest::SPut()
{
qcom_sPut put;
int cnt = 1;
m_sent = 0;
for (int i = 0; i < 1000; i++) {
put.reply = m_clientq;
put.type.b = (qcom_eBtype)0;
put.type.s = (qcom_eStype)0;
put.size = sizeof(cnt);
put.data = &cnt;
qcom_Put(&m_sts, &m_clientq, &put);
m_sent++;
cnt++;
}
if (plog)
m_log->vlog('D', "SPut sent messages %d", m_sent);
}
void ra_qmontest::CPut()
{
qcom_sGet get;
qcom_sPut put;
int cnt;
int action;
action = 1;
put.reply = m_clientq;
put.type.b = (qcom_eBtype)eTest_Put;
put.type.s = (qcom_eStype)0;
put.size = sizeof(action);
put.data = &action;
if (plog)
m_log->vlog('D', "Send request Put %d", action);
qcom_Put(&m_sts, &m_serverq, &put);
for (;;) {
get.data = 0;
qcom_Get(&m_sts, &m_clientq, &get, 1000);
if (m_sts == QCOM__TMO) {
break;
}
if (EVEN(m_sts)) {
m_log->log('E', "clientq, qcom_Get", m_sts);
exit(0);
}
cnt = *(int *)get.data;
qcom_Free(&m_sts, get.data);
}
m_log->vlog('D', "CPut received messages %d", cnt);
put.reply = m_clientq;
put.type.b = (qcom_eBtype)eTest_PutResult;
put.type.s = (qcom_eStype)0;
put.size = sizeof(cnt);
put.data = &cnt;
qcom_Put(&m_sts, &m_serverq, &put);
}
void ra_qmontest::SPut10k()
{
qcom_sPut put;
int cnt = 1;
unsigned int size = 10000;
unsigned int *data;
data = (unsigned int *)malloc(size);
for (unsigned int i = 0; i < size/sizeof(int); i++)
data[i] = 0x55555555;
m_sent = 0;
for (int i = 0; i < 1000; i++) {
data[0] = cnt;
put.reply = m_clientq;
put.type.b = (qcom_eBtype)0;
put.type.s = (qcom_eStype)0;
put.size = size;
put.data = data;
qcom_Put(&m_sts, &m_clientq, &put);
m_sent++;
cnt++;
}
if (plog)
m_log->vlog('D', "SPut10k sent messages %d", m_sent);
}
void ra_qmontest::CPut10k()
{
qcom_sGet get;
qcom_sPut put;
int cnt;
unsigned int size = 10000;
int action;
int error_logged = 0;
action = 1;
put.reply = m_clientq;
put.type.b = (qcom_eBtype)eTest_Put10k;
put.type.s = (qcom_eStype)0;
put.size = sizeof(action);
put.data = &action;
if (plog)
m_log->vlog('D', "Send request Put10k %d", action);
qcom_Put(&m_sts, &m_serverq, &put);
for (;;) {
get.data = 0;
qcom_Get(&m_sts, &m_clientq, &get, 1000);
if (m_sts == QCOM__TMO) {
break;
}
if (EVEN(m_sts)) {
m_log->log('E', "clientq, qcom_Get", m_sts);
exit(0);
}
cnt = *(int *)get.data;
if (get.size != size) {
if (!error_logged) {
m_log->vlog('X', "put10k, size mismatch %d", get.size);
error_logged = 1;
}
m_errcnt++;
}
for (unsigned int i = 1; i < size/sizeof(int); i++) {
if (((int *)get.data)[i] != 0x55555555) {
if (!error_logged) {
m_log->vlog('X', "put10k, content mismatch %d", i);
error_logged = 1;
}
}
}
qcom_Free(&m_sts, get.data);
}
put.reply = m_clientq;
put.type.b = (qcom_eBtype)eTest_Put10kResult;
put.type.s = (qcom_eStype)0;
put.size = sizeof(cnt);
put.data = &cnt;
qcom_Put(&m_sts, &m_serverq, &put);
m_log->vlog('D', "CPut10k received messages %d", cnt);
}
void ra_qmontest::SPut100k()
{
qcom_sPut put;
int cnt = 1;
unsigned int size = 10000;
unsigned int *data;
data = (unsigned int *)malloc(size);
for (unsigned int i = 0; i < size/sizeof(int); i++)
data[i] = 0x55555555;
m_sent = 0;
for (int i = 0; i < 1000; i++) {
data[0] = cnt;
put.reply = m_clientq;
put.type.b = (qcom_eBtype)0;
put.type.s = (qcom_eStype)0;
put.size = size;
put.data = data;
qcom_Put(&m_sts, &m_clientq, &put);
m_sent++;
cnt++;
}
if (plog)
m_log->vlog('D', "SPut100k sent messages %d", m_sent);
}
void ra_qmontest::CPut100k()
{
qcom_sGet get;
qcom_sPut put;
int cnt;
unsigned int size = 10000;
int action;
int error_logged = 0;
action = 1;
put.reply = m_clientq;
put.type.b = (qcom_eBtype)eTest_Put100k;
put.type.s = (qcom_eStype)0;
put.size = sizeof(action);
put.data = &action;
if (plog)
m_log->vlog('D', "Send request Put100k %d", action);
qcom_Put(&m_sts, &m_serverq, &put);
for (;;) {
get.data = 0;
qcom_Get(&m_sts, &m_clientq, &get, 1000);
if (m_sts == QCOM__TMO) {
break;
}
if (EVEN(m_sts)) {
m_log->log('E', "clientq, qcom_Get", m_sts);
exit(0);
}
cnt = *(int *)get.data;
if (get.size != size) {
if (!error_logged) {
m_log->vlog('X', "put100k, size mismatch %d", get.size);
error_logged = 1;
}
m_errcnt++;
}
for (unsigned int i = 1; i < size/sizeof(int); i++) {
if (((int *)get.data)[i] != 0x55555555) {
if (!error_logged) {
m_log->vlog('X', "put100k, content mismatch %d", i);
error_logged = 1;
}
}
}
qcom_Free(&m_sts, get.data);
}
put.reply = m_clientq;
put.type.b = (qcom_eBtype)eTest_Put100kResult;
put.type.s = (qcom_eStype)0;
put.size = sizeof(cnt);
put.data = &cnt;
qcom_Put(&m_sts, &m_serverq, &put);
m_log->vlog('D', "CPut100k received messages %d", cnt);
}
void ra_qmontest::SPutCyclic()
{
qcom_sPut put;
int cnt = 1;
float t = 0.01;
m_sent = 0;
for (int i = 0; i < 1000; i++) {
put.reply = m_clientq;
put.type.b = (qcom_eBtype)0;
put.type.s = (qcom_eStype)0;
put.size = sizeof(cnt);
put.data = &cnt;
qcom_Put(&m_sts, &m_clientq, &put);
time_Sleep(t);
m_sent++;
cnt++;
}
if (plog)
m_log->vlog('D', "SPutCyclic sent messages %d", m_sent);
}
void ra_qmontest::CPutCyclic()
{
qcom_sGet get;
qcom_sPut put;
int cnt;
int action;
action = 2;
put.reply = m_clientq;
put.type.b = (qcom_eBtype)eTest_PutCyclic;
put.type.s = (qcom_eStype)0;
put.size = sizeof(action);
put.data = &action;
if (plog)
m_log->vlog('D', "Send request PutCyclic %d", action);
qcom_Put(&m_sts, &m_serverq, &put);
for (;;) {
get.data = 0;
qcom_Get(&m_sts, &m_clientq, &get, 1000);
if (m_sts == QCOM__TMO) {
break;
}
if (EVEN(m_sts)) {
m_log->log('E', "clientq, qcom_Get", m_sts);
exit(0);
}
cnt = *(int *)get.data;
qcom_Free(&m_sts, get.data);
}
put.reply = m_clientq;
put.type.b = (qcom_eBtype)eTest_PutCyclicResult;
put.type.s = (qcom_eStype)0;
put.size = sizeof(cnt);
put.data = &cnt;
qcom_Put(&m_sts, &m_serverq, &put);
m_log->vlog('D', "CPutCyclic received messages %d", cnt);
}
void ra_qmontest::SEnd()
{
#if 0
if (m_errcnt)
m_log->vlog('E', "Errors %d", m_errcnt);
else
m_log->log('S', "Success", QCOM__SUCCESS);
#endif
}
void ra_qmontest::CEnd()
{
qcom_sPut put;
int action;
action = eTest_End;
put.reply = m_clientq;
put.type.b = (qcom_eBtype)eTest_End;
put.type.s = (qcom_eStype)0;
put.size = sizeof(action);
put.data = &action;
if (plog)
m_log->vlog('D', "Send request End %d", action);
qcom_Put(&m_sts, &m_serverq, &put);
if (m_errcnt)
m_log->vlog('E', "Errors %d", m_errcnt);
else
m_log->log('S', "Success", QCOM__SUCCESS);
}
void ra_qmontest::exec()
{
if (isServer()) {
// Server
qcom_sGet get;
int action;
int end = 0;
for (;;) {
get.data = 0;
qcom_Get(&m_sts, &m_serverq, &get, qcom_cTmoEternal);
if (EVEN(m_sts)) {
m_log->log('E', "serverq, qcom_Get", m_sts);
exit(0);
}
action = get.type.b;
if (plog)
m_log->vlog('D', "Action request %d", action);
switch (action) {
case eTest_Put:
SPut();
break;
case eTest_Put10k:
SPut10k();
break;
case eTest_Put100k:
SPut100k();
break;
case eTest_PutCyclic:
SPutCyclic();
break;
case eTest_PutResult:
case eTest_Put10kResult:
case eTest_Put100kResult:
case eTest_PutCyclicResult: {
int result = *(int *)get.data;
evaluate(action, result);
break;
}
case eTest_End:
SEnd();
end = 1;
break;
}
qcom_Free(&m_sts, get.data);
if (end)
break;
}
}
else {
// Client
CPut();
sleep(1);
CPut10k();
sleep(1);
CPut100k();
sleep(1);
CPutCyclic();
CEnd();
}
}
// Constructor
ra_qmontest::ra_qmontest(eProc ptype) : m_ptype(ptype), m_qquota(500), m_errcnt(0),
m_sent(0)
{
qcom_sQattr attr;
pwr_tVid vid;
if (isServer())
m_log = new tst_log(&m_sts, "rt-Qmon", "$pwrp_log/qmon.log");
else
m_log = new tst_log(&m_sts, "rt-QmonClient", "$pwrp_log/qmonc.log");
if (EVEN(m_sts))
printf("** Unable to open log file");
m_sts = gdh_Init("ra_qmontest");
if (EVEN(m_sts)) {
m_log->log('S', "qmon gdh_Init", m_sts);
exit(0);
}
cdh_StringToVolumeId(cServerVid, &vid);
m_serverq.qix = cServerQix;
m_serverq.nid = vid;
cdh_StringToVolumeId(cClientVid, &vid);
m_clientq.qix = cClientQix;
m_clientq.nid = vid;
if (isServer()) {
attr.type = qcom_eQtype_private;
attr.quota = m_qquota;
qcom_CreateQ(&m_sts, &m_serverq, &attr, "queue3348");
if (m_sts == QCOM__QALLREXIST) {
qcom_StealQ(&m_sts, &m_serverq);
//qcom_AttachQ(&m_sts, &m_serverq);
//if (m_sts == QCOM__ALLRATTACHED)
//m_sts = QCOM__SUCCESS;
//qcom_DeleteQ(&m_sts, &m_serverq);
//qcom_CreateQ(&m_sts, &m_serverq, &attr, "queue3348");
}
if (EVEN(m_sts)) {
m_log->log('E', "create serverq, qcom_CreateQ", m_sts);
exit(0);
}
for (;;) {
qcom_AttachQ(&m_sts, &m_clientq);
if (m_sts == QCOM__NOQ)
sleep(1);
else if (m_sts == QCOM__ALLRATTACHED)
break;
else if (EVEN(m_sts)) {
m_log->log('E', "attach clientq, qcom_AttachQ", m_sts);
exit(0);
}
else
break;
}
}
else {
// Client
attr.type = qcom_eQtype_private;
attr.quota = 10;
qcom_CreateQ(&m_sts, &m_clientq, &attr, "queue3348");
if (m_sts == QCOM__QALLREXIST) {
qcom_StealQ(&m_sts, &m_clientq);
//if (m_sts == QCOM__ALLRATTACHED)
//m_sts = QCOM__SUCCESS;
//qcom_DeleteQ(&m_sts, &m_clientq);
//qcom_CreateQ(&m_sts, &m_clientq, &attr, "queue3348");
}
if (EVEN(m_sts)) {
m_log->log('E', "create clientq, qcom_CreateQ", m_sts);
exit(0);
}
for (;;) {
qcom_AttachQ(&m_sts, &m_serverq);
if (m_sts == QCOM__NOQ)
sleep(1);
else if (m_sts == QCOM__ALLRATTACHED)
break;
else if (EVEN(m_sts)) {
m_log->log('E', "attach serverq, qcom_AttachQ", m_sts);
exit(0);
}
else
break;
}
}
}
// Destructor
ra_qmontest::~ra_qmontest()
{
delete m_log;
}
int main(int argc, char *argv[])
{
eProc ptype = eProc_Server;
if (argc > 1 && strcmp(argv[1], "2") == 0)
ptype = eProc_Client;
ra_qmontest qmon(ptype);
qmon.exec();
}
#include "pwr.h"
#include "rt_qcom.h"
#include "co_tst_log.h"
typedef enum {
eProc_Server = 1,
eProc_Client = 2
} eProc;
class ra_qmontest {
pwr_tStatus m_sts;
tst_log *m_log;
qcom_sQid m_serverq;
qcom_sQid m_clientq;
eProc m_ptype;
int m_qquota;
int m_errcnt;
int m_sent;
public:
ra_qmontest(eProc ptype);
~ra_qmontest();
tst_log *log() {return m_log;}
void set_ptype(eProc ptype) {m_ptype = ptype;}
bool isClient() {return m_ptype == eProc_Client;}
bool isServer() {return m_ptype == eProc_Server;}
void exec();
void evaluate(int action, int result);
void SPut();
void CPut();
void SPut10k();
void CPut10k();
void SPut100k();
void CPut100k();
void SPutCyclic();
void CPutCyclic();
void SEnd();
void CEnd();
};
/*
Print current project status
*/
#include <stdio.h>
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
int main()
{
pwr_tStatus sts, system_sts;
pwr_tOid noid;
pwr_tOName name;
sts = gdh_Init("ra_status");
if (EVEN(sts)) {
printf("E pwrtest01 status, gdh_Init error status: %u\n", sts);
exit(0);
}
sts = gdh_GetNodeObject(0, &noid);
if (ODD(sts))
sts = gdh_ObjidToName(noid, name, sizeof(name), cdh_mName_volumeStrict);
if (ODD(sts)) {
strcat(name, ".SystemStatus");
sts = gdh_GetObjectInfo(name, &system_sts, sizeof(system_sts));
}
if (EVEN(sts)) {
printf("E pwrtest01 status, error status: %u\n", sts);
exit(0);
}
if (ODD(system_sts))
printf("I pwrtest01 status success: %u\n", system_sts);
else
printf("E pwrtest01 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, "rt-Status", "$pwrp_log/tst_status.log");
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();
};
#!/bin/bash
exec()
{
echo "Executing $1"
$1
}
dexec()
{
echo "Executing $1"
$1 &
}
exec "ra_plctest"
exec "ra_timetest"
exec "ra_cdhtest"
exec "ra_gdhtest"
exec "ra_errhtest"
exec "ra_aproctest"
exec "ra_mhtest"
exec "ra_mhappltest"
exec "ra_qcomtest"
exec "ra_pwrrttest.py"
exec "rt_xtt_cmd @$pwrp_exe/ra_ccmtest"
exec "rt_xtt_cmd @$pwrp_exe/ra_xttscripttest"
dexec "ra_qmontest"
exec "ra_qmontest 2"
/*
Test gdh functions.
*/
#include <stdio.h>
#include <stddef.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include "co_msg.h"
#include "co_dcli.h"
#include "co_time.h"
#include "ra_timetest.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 {
pwr_tTime time;
int sts;
} sIsNull;
void ra_timetest::IsNull(void)
{
sIsNull d[] = {
{pwr_cNTime, 1},
{{0,1}, 0}
};
int sts;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
sts = time_IsNull(&d[i].time);
if (sts != d[i].sts) {
m_log->log('E', "IsNull");
return;
}
}
m_log->log('S', "IsNull", TIME__SUCCESS);
}
typedef struct {
pwr_tTime time;
pwr_tDeltaTime dtime;
pwr_tTime result;
} sAadd;
void ra_timetest::Aadd(void)
{
sAadd d[] = {
{pwr_cNTime, {0,1}, {0,1}},
{{2682419400,500000000}, {0,499999999}, {2682419400,999999999}},
{{2145913199,500000000}, {0,500000000}, {2145913200,0}},
{{2145913200,000000000}, {0,500000000}, {2145913200,500000000}}
};
pwr_tTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Aadd(&result, &d[i].time, &d[i].dtime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tTime)) != 0) {
m_log->log('E', "Aadd", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tTime));
time_Aadd(0, &result, &d[i].dtime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tTime)) != 0) {
m_log->log('E', "Aadd", i);
return;
}
}
m_log->log('S', "Aadd", TIME__SUCCESS);
}
void ra_timetest::Aadd_NE(void)
{
sAadd d[] = {
{pwr_cNTime, {0,1}, {0,1}},
{{2682419400,500000000}, {0,499999999}, {2682419400,999999999}},
{{2145913199,500000000}, {0,500000000}, {2145913200,0}},
{{2145913200,000000000}, {0,500000000}, {2145913200,500000000}},
{pwr_cNotATime, {0,500000000}, pwr_cNotATime},
{{1587468600,0}, pwr_cNotADeltaTime, pwr_cNotATime},
{{1587468600,0}, {-1,-500000000}, {1587468598,500000000}},
{{1587468600,0}, {1,-500000000}, pwr_cNotATime},
{{1587468600,0}, {-1,500000000}, pwr_cNotATime},
{{1587468600,-500000000}, {1,500000000}, pwr_cNotATime},
{{-1587468600,500000000}, {1,500000000}, {-1587468598,0}} // Invalid time?
};
pwr_tTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Aadd_NE(&result, &d[i].time, &d[i].dtime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tTime)) != 0) {
m_log->log('E', "Aadd_NE", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tTime));
time_Aadd_NE(0, &result, &d[i].dtime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tTime)) != 0) {
m_log->log('E', "Aadd", i);
return;
}
}
m_log->log('S', "Aadd_NE", TIME__SUCCESS);
}
typedef struct {
pwr_tTime time1;
pwr_tTime time2;
int result;
} sAcomp;
void ra_timetest::Acomp(void)
{
sAcomp d[] = {
{pwr_cNTime, pwr_cNTime, 0},
{{1587468600,500000000}, {1587468600,500000000}, 0},
{{1587468600,500000000}, {1587468600,500000001}, -1},
{{1587468600,500000000}, {1587468600,499999999}, 1}
};
int result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
result = time_Acomp(&d[i].time1, &d[i].time2);
if (result != d[i].result) {
m_log->log('E', "Acomp", i);
return;
}
}
m_log->log('S', "Acomp", TIME__SUCCESS);
}
void ra_timetest::Acomp_NE(void)
{
sAcomp d[] = {
{pwr_cNTime, pwr_cNTime, 0},
{{1587468600,500000000}, {1587468600,500000000}, 0},
{{1587468600,500000000}, {1587468600,500000001}, -1},
{{1587468600,500000000}, {1587468600,499999999}, 1},
{{1587468600,500000000}, {1587468600,-499999999}, -2},
{{1587468600,-500000000}, {1587468600,499999999}, -2},
{{1587468600,500000000}, pwr_cNotATime, -2},
{pwr_cNotATime, {1587468600,500000000}, -2}
};
int result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
result = time_Acomp_NE(&d[i].time1, &d[i].time2);
if (result != d[i].result) {
m_log->log('E', "Acomp_NE", i);
return;
}
}
m_log->log('S', "Acomp_NE", TIME__SUCCESS);
}
typedef struct {
pwr_tTime time1;
pwr_tTime time2;
pwr_tDeltaTime result;
} sAdiff;
void ra_timetest::Adiff(void)
{
sAdiff d[] = {
{pwr_cNTime, pwr_cNTime, 0},
{{1587468600,500000000}, {1587468600,500000000}, pwr_cNDeltaTime},
{{1587468600,500000000}, {1587468600,500000001}, {0,-1}},
{{1587468500,500000000}, {1587468600,500000001}, {-100,-1}},
{{1587468600,500000000}, {1587468600,499999999}, {0,1}},
{{1587468600,500000000}, {1587468500,499999999}, {100,1}},
{{2145913200,0}, {2145913199,500000000}, {0,500000000}},
{{2245913200,000000000}, {2245913199,500000000}, {0,500000000}}
};
pwr_tDeltaTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Adiff(&result, &d[i].time1, &d[i].time2);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Adiff", i);
return;
}
}
m_log->log('S', "Adiff", TIME__SUCCESS);
}
void ra_timetest::Adiff_NE(void)
{
sAdiff d[] = {
{pwr_cNTime, pwr_cNTime, 0},
{{1587468600,500000000}, {1587468600,500000000}, pwr_cNDeltaTime},
{{1587468600,500000000}, {1587468600,500000001}, {0,-1}},
{{1587468500,500000000}, {1587468600,500000001}, {-100,-1}},
{{1587468600,500000000}, {1587468600,499999999}, {0,1}},
{{1587468600,500000000}, {1587468500,499999999}, {100,1}},
{{1587468600,500000000}, {1587468600,-499999999}, pwr_cNotADeltaTime},
{{1587468600,-500000000}, {1587468600,499999999}, pwr_cNotADeltaTime},
{{1587468600,500000000}, pwr_cNotATime, pwr_cNotADeltaTime},
{pwr_cNotATime, {1587468600,500000000}, pwr_cNotADeltaTime},
{{2145913200,0}, {2145913199,500000000}, {0,500000000}},
{{2245913200,000000000}, {2245913199,500000000}, {0,500000000}}
};
pwr_tDeltaTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Adiff_NE(&result, &d[i].time1, &d[i].time2);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Adiff_NE", i);
return;
}
}
m_log->log('S', "Adiff_NE", TIME__SUCCESS);
}
typedef struct {
pwr_tTime time;
pwr_tDeltaTime dtime;
pwr_tTime result;
} sAsub;
void ra_timetest::Asub(void)
{
sAsub d[] = {
{pwr_cNTime, pwr_cNDeltaTime, pwr_cNTime},
{{1587468600,500000000}, pwr_cNDeltaTime, {1587468600,500000000}},
{{1587468600,500000001}, {0,1}, {1587468600,500000000}},
{{1587468600,500000001}, {100,1}, {1587468500,500000000}},
{{1587468600,499999999}, {0,-1}, {1587468600,500000000}},
{{1587468500,499999999}, {-100,-1}, {1587468600,500000000}},
{{2145913199,500000000}, {0,-500000000}, {2145913200,0}},
{{2245913199,500000000}, {0,-500000000}, {2245913200,000000000}}
};
pwr_tTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Asub(&result, &d[i].time, &d[i].dtime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Asub", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tTime));
time_Asub(0, &result, &d[i].dtime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tTime)) != 0) {
m_log->log('E', "Asub", i);
return;
}
}
m_log->log('S', "Asub", TIME__SUCCESS);
}
void ra_timetest::Asub_NE(void)
{
sAsub d[] = {
{pwr_cNTime, pwr_cNDeltaTime, pwr_cNTime},
{{1587468600,500000000}, pwr_cNDeltaTime, {1587468600,500000000}},
{{1587468600,500000001}, {0,1}, {1587468600,500000000}},
{{1587468600,500000001}, {100,1}, {1587468500,500000000}},
{{1587468600,499999999}, {0,-1}, {1587468600,500000000}},
{{1587468500,499999999}, {-100,-1}, {1587468600,500000000}},
{{1587468600,-499999999}, {10,10}, pwr_cNotATime},
{{1587468600,499999999}, {10,-10}, pwr_cNotATime},
{{1587468600,499999999}, pwr_cNotADeltaTime, pwr_cNotATime},
{pwr_cNotATime, {10,10}, pwr_cNotATime},
{{2145913199,500000000}, {0,-500000000}, {2145913200,0}},
{{2245913199,500000000}, {0,-500000000}, {2245913200,0}}
};
pwr_tTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Asub_NE(&result, &d[i].time, &d[i].dtime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Asub_NE", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tTime));
time_Asub_NE(0, &result, &d[i].dtime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tTime)) != 0) {
m_log->log('E', "Asub", i);
return;
}
}
m_log->log('S', "Asub_NE", TIME__SUCCESS);
}
typedef struct {
pwr_tDeltaTime time;
pwr_tDeltaTime result;
} sDabs;
void ra_timetest::Dabs(void)
{
sDabs d[] = {
{pwr_cNDeltaTime, pwr_cNDeltaTime},
{{0,1}, {0,1}},
{{100,1}, {100,1}},
{{0,-1}, {0,1}},
{{-100,-1}, {100,1}},
{{-100,0}, {100,0}},
{{0,-500000000}, {0,500000000}},
{{-22222,-500000000}, {22222,500000000}}
};
pwr_tDeltaTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Dabs(&result, &d[i].time);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dabs", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tDeltaTime));
time_Dabs(0, &result);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dabs", i);
return;
}
}
m_log->log('S', "Dabs", TIME__SUCCESS);
}
void ra_timetest::Dabs_NE(void)
{
sDabs d[] = {
{pwr_cNDeltaTime, pwr_cNDeltaTime},
{{0,1}, {0,1}},
{{100,1}, {100,1}},
{{0,-1}, {0,1}},
{{-100,-1}, {100,1}},
{{-100,0}, {100,0}},
{{0,-500000000}, {0,500000000}},
{{-22222,-500000000}, {22222,500000000}},
{{10,-10}, pwr_cNotADeltaTime},
{{-10,10}, pwr_cNotADeltaTime},
{pwr_cNotADeltaTime, pwr_cNotADeltaTime}
};
pwr_tDeltaTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Dabs_NE(&result, &d[i].time);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dabs_NE", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tDeltaTime));
time_Dabs_NE(0, &result);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dabs_NE", i);
return;
}
}
m_log->log('S', "Dabs_NE", TIME__SUCCESS);
}
typedef struct {
pwr_tDeltaTime time;
pwr_tDeltaTime atime;
pwr_tDeltaTime result;
} sDadd;
void ra_timetest::Dadd(void)
{
sDadd d[] = {
{pwr_cNDeltaTime, pwr_cNDeltaTime, pwr_cNDeltaTime},
{{0,1}, {0,1}, {0,2}},
{{100,1}, {100,1}, {200,2}},
{{0,-1}, {0,10}, {0,9}},
{{-100,-10}, {100,1}, {0,-9}},
{{-100,0}, {101,0}, {1,0}},
{{0,500000000}, {0,500000000}, {1,0}},
{{-22222,-500000000}, {22222,500000001}, {0,1}}
};
pwr_tDeltaTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Dadd(&result, &d[i].time, &d[i].atime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dadd", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tDeltaTime));
time_Dadd(0, &result, &d[i].atime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dadd", i);
return;
}
}
m_log->log('S', "Dadd", TIME__SUCCESS);
}
void ra_timetest::Dadd_NE(void)
{
sDadd d[] = {
{pwr_cNDeltaTime, pwr_cNDeltaTime, {0,0}},
{{0,1}, {0,1}, {0,2}},
{{102,1}, {100,0}, {202,1}},
{{-2,-1}, {0,2}, {-1,-999999999}},
{{-100,-1}, {100,1}, {0,0}},
{{-100,-1}, {100,0}, {0,-1}},
{{0,500000001}, {0,500000000}, {1,1}},
{{-22222,-500000000}, {22222,500000001}, {0,1}},
{{10,-10}, {1,1}, pwr_cNotADeltaTime},
{{1,1}, {-10,10}, pwr_cNotADeltaTime},
{pwr_cNotADeltaTime, {1,1}, pwr_cNotADeltaTime},
{{1,1}, pwr_cNotADeltaTime, pwr_cNotADeltaTime}
};
pwr_tDeltaTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Dadd_NE(&result, &d[i].time, &d[i].atime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dadd_NE", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tDeltaTime));
time_Dadd_NE(0, &result, &d[i].atime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dadd_NE", i);
return;
}
}
m_log->log('S', "Dadd_NE", TIME__SUCCESS);
}
typedef struct {
pwr_tDeltaTime time;
pwr_tDeltaTime result;
} sDneg;
void ra_timetest::Dneg(void)
{
sDneg d[] = {
{pwr_cNDeltaTime, pwr_cNDeltaTime},
{{0,1}, {0,-1}},
{{100,1}, {-100,-1}},
{{0,-1}, {0,1}},
{{-100,-1}, {100,1}},
{{-100,0}, {100,0}},
{{0,-500000000}, {0,500000000}},
{{-22222,-500000000}, {22222,500000000}}
};
pwr_tDeltaTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Dneg(&result, &d[i].time);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dneg", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tDeltaTime));
time_Dneg(0, &result);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dneg", i);
return;
}
}
m_log->log('S', "Dneg", TIME__SUCCESS);
}
void ra_timetest::Dneg_NE(void)
{
sDneg d[] = {
{pwr_cNDeltaTime, pwr_cNDeltaTime},
{{0,1}, {0,-1}},
{{100,1}, {-100,-1}},
{{0,-1}, {0,1}},
{{-100,-1}, {100,1}},
{{-100,0}, {100,0}},
{{0,-500000000}, {0,500000000}},
{{-22222,-500000000}, {22222,500000000}},
{{10,-10}, pwr_cNotADeltaTime},
{{-10,10}, pwr_cNotADeltaTime},
{pwr_cNotADeltaTime, pwr_cNotADeltaTime}
};
pwr_tDeltaTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Dneg_NE(&result, &d[i].time);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dneg_NE", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tDeltaTime));
time_Dneg_NE(0, &result);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dneg_NE", i);
return;
}
}
m_log->log('S', "Dneg_NE", TIME__SUCCESS);
}
typedef struct {
pwr_tDeltaTime time;
pwr_tDeltaTime stime;
pwr_tDeltaTime result;
} sDsub;
void ra_timetest::Dsub(void)
{
sDsub d[] = {
{pwr_cNDeltaTime, pwr_cNDeltaTime, pwr_cNDeltaTime},
{{0,3}, {0,1}, {0,2}},
{{300,3}, {100,1}, {200,2}},
{{0,-1}, {0,10}, {0,-11}},
{{-100,-10}, {100,1}, {-200,-11}},
{{100,0}, {101,0}, {-1,0}},
{{2,500000000}, {0,500000001}, {1,999999999}},
{{-22222,-500000000}, {22222,500000001}, {-44445,-1}}
};
pwr_tDeltaTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Dsub(&result, &d[i].time, &d[i].stime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dsub", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tDeltaTime));
time_Dsub(0, &result, &d[i].stime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dsub", i);
return;
}
}
m_log->log('S', "Dsub", TIME__SUCCESS);
}
void ra_timetest::Dsub_NE(void)
{
sDsub d[] = {
{pwr_cNDeltaTime, pwr_cNDeltaTime, pwr_cNDeltaTime},
{{0,3}, {0,1}, {0,2}},
{{300,3}, {100,1}, {200,2}},
{{0,-1}, {0,10}, {0,-11}},
{{-100,-10}, {100,1}, {-200,-11}},
{{100,0}, {101,0}, {-1,0}},
{{2,500000000}, {0,500000001}, {1,999999999}},
{{-22222,-500000000}, {22222,500000001}, {-44445,-1}},
{{10,-10}, {1,1}, pwr_cNotADeltaTime},
{{1,1}, {-10,10}, pwr_cNotADeltaTime},
{pwr_cNotADeltaTime, {1,1}, pwr_cNotADeltaTime},
{{1,1}, pwr_cNotADeltaTime, pwr_cNotADeltaTime}
};
pwr_tDeltaTime result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Dsub_NE(&result, &d[i].time, &d[i].stime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dsub_NE", i);
return;
}
memcpy(&result, &d[i].time, sizeof(pwr_tDeltaTime));
time_Dsub_NE(0, &result, &d[i].stime);
if (memcmp(&result, &d[i].result, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "Dsub_NE", i);
return;
}
}
m_log->log('S', "Dsub_NE", TIME__SUCCESS);
}
typedef struct {
pwr_tDeltaTime time1;
pwr_tDeltaTime time2;
int result;
} sDcomp;
void ra_timetest::Dcomp(void)
{
sDcomp d[] = {
{pwr_cNDeltaTime, pwr_cNDeltaTime, 0},
{{222,222222222}, {222,222222222}, 0},
{{-222,-222222222}, {-222,-222222222}, 0},
{{0,3}, {0,1}, 1},
{{300,3}, {100,1}, 1},
{{0,1}, {0,10}, -1},
{{-100,-10}, {100,1}, -1},
{{100,0}, {101,0}, -1},
{{2,500000000}, {0,500000001}, 1},
{{-22222,-500000000}, {22222,500000001}, -1}
};
int result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
result = time_Dcomp(&d[i].time1, &d[i].time2);
if (result != d[i].result) {
m_log->log('E', "Dcomp", i);
return;
}
if (d[i].time2.tv_sec == 0 && d[i].time2.tv_nsec == 0) {
result = time_Dcomp(&d[i].time1, 0);
if (result != d[i].result) {
m_log->log('E', "Dcomp", i);
return;
}
}
}
m_log->log('S', "Dcomp", TIME__SUCCESS);
}
void ra_timetest::Dcomp_NE(void)
{
sDcomp d[] = {
{pwr_cNDeltaTime, pwr_cNDeltaTime, 0},
{{222,222222222}, {222,222222222}, 0},
{{-222,-222222222}, {-222,-222222222}, 0},
{{0,3}, {0,1}, 1},
{{300,3}, {100,1}, 1},
{{0,1}, {0,10}, -1},
{{-100,-10}, {100,1}, -1},
{{100,0}, {101,0}, -1},
{{2,500000000}, {0,500000001}, 1},
{{-22222,-500000000}, {22222,500000001}, -1},
{{10,-10}, {1,1}, -2},
{{1,1}, {-10,10}, -2},
{pwr_cNotADeltaTime, {1,1}, -2},
{{1,1}, pwr_cNotADeltaTime, -2}
};
int result;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
result = time_Dcomp_NE(&d[i].time1, &d[i].time2);
if (result != d[i].result) {
m_log->log('E', "Dcomp", i);
return;
}
if (d[i].time2.tv_sec == 0 && d[i].time2.tv_nsec == 0) {
result = time_Dcomp_NE(&d[i].time1, 0);
if (result != d[i].result) {
m_log->log('E', "Dcomp", i);
return;
}
}
}
m_log->log('S', "Dcomp_NE", TIME__SUCCESS);
}
typedef struct {
pwr_tDeltaTime time;
char str[40];
pwr_tStatus sts;
} sDtoAscii;
void ra_timetest::DtoAscii(void)
{
sDtoAscii d[] = {
{pwr_cNDeltaTime, "0:00:00.00", TIME__SUCCESS},
{{0,222222222}, "0:00:00.22", TIME__SUCCESS},
{{222,0}, "0:03:42.00", TIME__SUCCESS},
{{222,222222222}, "0:03:42.22", TIME__SUCCESS},
{{222222,222222222}, "2 13:43:42.22", TIME__SUCCESS},
{{22222222,222222222}, "257 4:50:22.22", TIME__SUCCESS},
{{0,-222222222}, "-0:00:00.22", TIME__SUCCESS},
{{-222,0}, "-0:03:42.00", TIME__SUCCESS},
{{-222,-222222222}, "-0:03:42.22", TIME__SUCCESS},
{{-222222,-222222222}, "-2 13:43:42.22", TIME__SUCCESS},
{{-22222222,-222222222}, "-257 4:50:22.22", TIME__SUCCESS},
{{222,-222222222}, "", TIME__NADT},
{{-222,222222222}, "", TIME__NADT}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = time_DtoAscii(&d[i].time, 1, str, sizeof(str));
if (m_sts != d[i].sts) {
m_log->log('E', "DtoAscii wrong status", m_sts);
return;
}
if (ODD(m_sts)) {
if (strcmp(d[i].str, str) != 0) {
m_log->log('E', "DtoAscii", i);
return;
}
}
}
m_log->log('S', "DtoAscii", TIME__SUCCESS);
}
typedef struct {
char str[40];
pwr_tDeltaTime time;
pwr_tStatus sts;
} sAsciiToD;
void ra_timetest::AsciiToD(void)
{
sAsciiToD d[] = {
{"0:00:00.00", pwr_cNDeltaTime, TIME__SUCCESS},
{"0:00:00.22", {0,220000000}, TIME__SUCCESS},
{"0:03:42.00", {222,0}, TIME__SUCCESS},
{"0:03:42.22", {222,220000000}, TIME__SUCCESS},
{"2 13:43:42.22", {222222,220000000}, TIME__SUCCESS},
{"257 4:50:22.22", {22222222,220000000}, TIME__SUCCESS},
{"-0:00:00.22", {0,-220000000}, TIME__SUCCESS},
{"-0:03:42.00", {-222,0}, TIME__SUCCESS},
{"-0:03:42.22", {-222,-220000000}, TIME__SUCCESS},
{"-2 13:43:42.22", {-222222,-220000000}, TIME__SUCCESS},
{"-257 4:50:22.22", {-22222222,-220000000}, TIME__SUCCESS},
{"-0:03:42.22", {-222,-220000000}, TIME__SUCCESS},
{"NotADeltaTime", pwr_cNotADeltaTime, TIME__SUCCESS}
};
pwr_tDeltaTime time;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = time_AsciiToD(d[i].str, &time);
if (m_sts != d[i].sts) {
m_log->log('E', "AsciiToD wrong status", m_sts);
return;
}
if (ODD(m_sts)) {
if (memcmp(&d[i].time, &time, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "AsciiToD", i);
return;
}
}
}
m_log->log('S', "AsciiToD", TIME__SUCCESS);
}
typedef struct {
pwr_tTime time;
time_eFormat format;
char str[40];
pwr_tStatus sts;
} sAtoAscii;
void ra_timetest::AtoAscii(void)
{
sAtoAscii d[] = {
{pwr_cNTime, time_eFormat_DateAndTime, "01-JAN-1970 01:00:00.00", TIME__SUCCESS},
{pwr_cNTime, time_eFormat_Time, "01:00:00.00", TIME__SUCCESS},
{pwr_cNTime, time_eFormat_ComprDateAndTime, "70-01-01 01:00:00.00", TIME__SUCCESS},
{pwr_cNTime, time_eFormat_NumDateAndTime, "1970-01-01 01:00:00.00", TIME__SUCCESS},
{pwr_cNTime, time_eFormat_FileDateAndTime, "19700101_010000", TIME__SUCCESS},
{pwr_cNTime, time_eFormat_FileDate, "19700101", TIME__SUCCESS},
{pwr_cNTime, time_eFormat_TimeAndDate, "01:00:00 01/01/70", TIME__SUCCESS},
{{1587558870,220000000}, time_eFormat_DateAndTime, "22-APR-2020 14:34:30.22", TIME__SUCCESS},
{{1587558870,220000000}, time_eFormat_Time, "14:34:30.22", TIME__SUCCESS},
{{1587558870,220000000}, time_eFormat_ComprDateAndTime, "20-04-22 14:34:30.22", TIME__SUCCESS},
{{1587558870,220000000}, time_eFormat_NumDateAndTime, "2020-04-22 14:34:30.22", TIME__SUCCESS},
{{1587558870,220000000}, time_eFormat_FileDateAndTime, "20200422_143430", TIME__SUCCESS},
{{1587558870,220000000}, time_eFormat_FileDate, "20200422", TIME__SUCCESS},
{{1587558870,220000000}, time_eFormat_TimeAndDate, "14:34:30 22/04/20", TIME__SUCCESS},
{{2537701200,0}, time_eFormat_DateAndTime, "01-JUN-2050 15:00:00.00", TIME__SUCCESS},
{{2537701200,0}, time_eFormat_Time, "15:00:00.00", TIME__SUCCESS},
{{2537701200,0}, time_eFormat_ComprDateAndTime, "50-06-01 15:00:00.00", TIME__SUCCESS},
{{2537701200,0}, time_eFormat_NumDateAndTime, "2050-06-01 15:00:00.00", TIME__SUCCESS},
{{2537701200,0}, time_eFormat_FileDateAndTime, "20500601_150000", TIME__SUCCESS},
{{2537701200,0}, time_eFormat_FileDate, "20500601", TIME__SUCCESS},
{{2537701200,0}, time_eFormat_TimeAndDate, "15:00:00 01/06/50", TIME__SUCCESS},
{{1587558870,-220000000}, time_eFormat_DateAndTime, "14:34:30 22/04/20", TIME__NAT},
{{-1587558870,-220000000}, time_eFormat_DateAndTime, "14:34:30 22/04/20", TIME__NAT}
};
char str[40];
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = time_AtoAscii(&d[i].time, d[i].format, str, sizeof(str));
if (m_sts != d[i].sts) {
m_log->log('E', "AtoAscii wrong status", m_sts);
return;
}
if (ODD(m_sts)) {
if (strcmp(d[i].str, str) != 0) {
m_log->vlog('E', "AtoAscii %s != %s, %d", d[i].str, str, i);
return;
}
}
}
m_log->log('S', "AtoAscii", TIME__SUCCESS);
}
typedef struct {
char str[40];
pwr_tTime time;
pwr_tStatus sts;
} sAsciiToA;
void ra_timetest::AsciiToA(void)
{
sAsciiToA d[] = {
{"01-JAN-1970 01:00:00.00", pwr_cNTime, TIME__SUCCESS},
{"22-APR-2020 14:34:30.22", {1587558870,220000000}, TIME__SUCCESS},
{"22-apr-2020 14:34:30.22", {1587558870,220000000}, TIME__SUCCESS},
{"01-JUN-2050 15:00:00.00", {2537701200,0}, TIME__SUCCESS},
{"01-JAN-2020 00:00:00.00", {1577833200,0}, TIME__SUCCESS},
{"01-FEB-2020 00:00:00.00", {1580511600,0}, TIME__SUCCESS},
{"01-MAR-2020 00:00:00.00", {1583017200,0}, TIME__SUCCESS},
{"01-APR-2020 00:00:00.00", {1585692000,0}, TIME__SUCCESS},
{"01-MAY-2020 00:00:00.00", {1588284000,0}, TIME__SUCCESS},
{"01-JUN-2020 00:00:00.00", {1590962400,0}, TIME__SUCCESS},
{"01-JUL-2020 00:00:00.00", {1593554400,0}, TIME__SUCCESS},
{"01-AUG-2020 00:00:00.00", {1596232800,0}, TIME__SUCCESS},
{"01-SEP-2020 00:00:00.00", {1598911200,0}, TIME__SUCCESS},
{"01-OCT-2020 00:00:00.00", {1601503200,0}, TIME__SUCCESS},
{"01-NOV-2020 00:00:00.00", {1604185200,0}, TIME__SUCCESS},
{"01-DEC-2020 00:00:00.00", {1606777200,0}, TIME__SUCCESS},
{"01-JAN-2020 00:00:00.00", {1577833200,0}, TIME__SUCCESS},
{"01-JAN-2020 00:00:00.00", {1577833200,0}, TIME__SUCCESS},
{"NotATime", pwr_cNotATime, TIME__SUCCESS},
{"31-APR-2020 14:34:30.22", {0,0}, TIME__RANGE},
{"22-ARP-2020 14:34:30.22", {0,0}, TIME__RANGE},
{"22-APR-1820 14:34:30.22", {0,0}, TIME__RANGE},
{"22-APR-2020 24:34:30.22", {0,0}, TIME__RANGE},
{"22-APR-2020 14:64:30.22", {0,0}, TIME__RANGE},
{"22-ApR-2020 14:34:70.22", {0,0}, TIME__RANGE}
};
pwr_tTime time;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = time_AsciiToA(d[i].str, &time);
if (m_sts != d[i].sts) {
m_log->log('E', "AsciiToA wrong status", m_sts);
return;
}
if (ODD(m_sts)) {
if (memcmp(&d[i].time, &time, sizeof(pwr_tTime)) != 0) {
m_log->vlog('E', "AsciiToA %s, (%d,%d) != (%d,%d), %d", d[i].str,
d[i].time.tv_sec, d[i].time.tv_nsec,
time.tv_sec, time.tv_nsec, i);
return;
}
}
}
m_log->log('S', "AsciiToA", TIME__SUCCESS);
}
typedef struct {
int ms;
pwr_tDeltaTime time;
} sMsToD;
void ra_timetest::MsToD(void)
{
sMsToD d[] = {
{0, pwr_cNDeltaTime},
{1000, {1,0}},
{123456789, {123456,789000000}},
{-123456789, {-123456,-789000000}},
{1, {0,1000000}}
};
pwr_tDeltaTime time;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_MsToD(&time, d[i].ms);
if (memcmp(&d[i].time, &time, sizeof(pwr_tDeltaTime)) != 0) {
m_log->log('E', "MsToD", i);
return;
}
}
m_log->log('S', "MsToD", TIME__SUCCESS);
}
typedef struct {
pwr_tFloat32 f;
pwr_tDeltaTime time;
} sFloatToD;
void ra_timetest::FloatToD(void)
{
sFloatToD d[] = {
{0, pwr_cNDeltaTime},
{1.000, {1,0}},
{456.789, {456,789000000}},
{-123456.789, {-123456,-789000000}},
{0.001, {0,1000000}}
};
pwr_tDeltaTime time;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_FloatToD(&time, d[i].f);
if (!(d[i].time.tv_sec == time.tv_sec && abs(d[i].time.tv_nsec - time.tv_nsec) <= 100 * fabs(d[i].f))) {
m_log->log('E', "FloatToD", i);
return;
}
}
m_log->log('S', "FloatToD", TIME__SUCCESS);
}
typedef struct {
pwr_tFloat64 f;
pwr_tDeltaTime time;
} sFloat64ToD;
void ra_timetest::Float64ToD(void)
{
sFloat64ToD d[] = {
{0, pwr_cNDeltaTime},
{1.000, {1,0}},
{456.789, {456,789000000}},
{-123456.789, {-123456,-789000000}},
{0.001, {0,1000000}}
};
pwr_tDeltaTime time;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_Float64ToD(&time, d[i].f);
if (!(d[i].time.tv_sec == time.tv_sec && abs(d[i].time.tv_nsec - time.tv_nsec) <= 0.01 * fabs(d[i].f))) {
m_log->log('E', "Float64ToD", i);
return;
}
}
m_log->log('S', "Float64ToD", TIME__SUCCESS);
}
typedef struct {
pwr_tDeltaTime time;
pwr_tFloat32 f;
} sDToFloat;
void ra_timetest::DToFloat(void)
{
sDToFloat d[] = {
{pwr_cNDeltaTime, 0},
{{1,0}, 1.000},
{{456,789000000}, 456.789},
{{-123456,-789000000}, -123456.789},
{{0,1000000}, 0.001}
};
pwr_tFloat32 f;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_DToFloat(&f, &d[i].time);
if (fabs(d[i].f - f) > FLT_EPSILON * fabs(d[i].f)) {
m_log->log('E', "DToFloat", i);
return;
}
}
m_log->log('S', "DToFloat", TIME__SUCCESS);
}
typedef struct {
pwr_tDeltaTime time;
pwr_tFloat64 f;
} sDToFloat64;
void ra_timetest::DToFloat64(void)
{
sDToFloat64 d[] = {
{pwr_cNDeltaTime, 0},
{{1,0}, 1.000},
{{456,789000000}, 456.789},
{{-123456,-789000000}, -123456.789},
{{0,1000000}, 0.001}
};
pwr_tFloat64 f;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
time_DToFloat64(&f, &d[i].time);
if (fabs(d[i].f - f) > DBL_EPSILON * fabs(d[i].f)) {
m_log->log('E', "DToFloat64", i);
return;
}
}
m_log->log('S', "DToFloat64", TIME__SUCCESS);
}
void ra_timetest::ZeroD(void)
{
pwr_tDeltaTime t = {123,456};
time_ZeroD(&t);
if (!(t.tv_sec == 0 && t.tv_nsec == 0)) {
m_log->log('E', "ZeroD");
return;
}
m_log->log('S', "ZeroD", TIME__SUCCESS);
}
void ra_timetest::GetTime(void)
{
pwr_tTime time, ctime;
struct timespec t;
int sts;
pwr_tDeltaTime diff;
pwr_tFloat32 fdiff;
sts = clock_gettime(CLOCK_REALTIME, &t);
if (sts) {
m_log->log('E', "GetTime, clock_gettime failed", sts);
return;
}
time_GetTime(&time);
ctime.tv_sec = t.tv_sec;
ctime.tv_nsec = t.tv_nsec;
time_Adiff(&diff, &time, &ctime);
time_DToFloat(&fdiff, &diff);
if (fdiff > 0.001) {
m_log->log('E', "GetTime, time doesn't match");
return;
}
m_log->log('S', "GetTime", TIME__SUCCESS);
}
void ra_timetest::GetTimeMonotonic(void)
{
pwr_tTime time, ctime;
struct timespec t;
int sts;
pwr_tDeltaTime diff;
pwr_tFloat32 fdiff;
sts = clock_gettime(CLOCK_MONOTONIC, &t);
if (sts) {
m_log->log('E', "GetTimeMonotonic, clock_gettime failed", sts);
return;
}
time_GetTimeMonotonic(&time);
ctime.tv_sec = t.tv_sec;
ctime.tv_nsec = t.tv_nsec;
time_Adiff(&diff, &time, &ctime);
time_DToFloat(&fdiff, &diff);
if (fdiff > 0.001) {
m_log->log('E', "GetTimeMonotonic, time doesn't match");
return;
}
m_log->log('S', "GetTimeMonotonic", TIME__SUCCESS);
}
// Constructor
ra_timetest::ra_timetest()
{
m_log = new tst_log(&m_sts, "co-Time", "$pwrp_log/time.log");
if (EVEN(m_sts))
printf("** Unable to open log file");
}
// Destructor
ra_timetest::~ra_timetest()
{
delete m_log;
}
int main()
{
ra_timetest time;
pwr_tStatus sts;
setenv("TZ", "Europe/Stockholm", 1);
tzset();
sts = gdh_Init("ra_timetest");
if (EVEN(sts)) {
time.log()->log('S', "Time gdh_Init", sts);
exit(0);
}
time.IsNull();
time.Aadd();
time.Aadd_NE();
time.Acomp();
time.Acomp_NE();
time.Adiff();
time.Adiff_NE();
time.Asub();
time.Asub_NE();
time.Dabs();
time.Dabs_NE();
time.Dadd();
time.Dadd_NE();
time.Dneg();
time.Dneg_NE();
time.Dsub();
time.Dsub_NE();
time.Dcomp();
time.Dcomp_NE();
time.DtoAscii();
time.AsciiToD();
time.AtoAscii();
time.AsciiToA();
time.MsToD();
time.FloatToD();
time.Float64ToD();
time.DToFloat();
time.DToFloat64();
time.ZeroD();
time.GetTime();
time.GetTimeMonotonic();
}
#include "pwr.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_tst_log.h"
class ra_timetest {
pwr_tStatus m_sts;
tst_log *m_log;
public:
ra_timetest();
~ra_timetest();
tst_log *log() {return m_log;}
void IsNull();
void Aadd();
void Aadd_NE();
void Acomp();
void Acomp_NE();
void Adiff();
void Adiff_NE();
void Asub();
void Asub_NE();
void Dabs();
void Dabs_NE();
void Dadd();
void Dadd_NE();
void Dneg();
void Dneg_NE();
void Dsub();
void Dsub_NE();
void Dcomp();
void Dcomp_NE();
void DtoAscii();
void AsciiToD();
void AtoAscii();
void AsciiToA();
void MsToD();
void FloatToD();
void Float64ToD();
void DToFloat();
void DToFloat64();
void ZeroD();
void GetTime();
void GetTimeMonotonic();
};
function int ccm_CutObjectName(int log)
int i;
string ostr;
string str = "h1-h2-h3-h4-h5";
string r[7];
r[0] = "";
r[1] = "h5";
r[2] = "h4-h5";
r[3] = "h3-h4-h5";
r[4] = "h2-h3-h4-h5";
r[5] = "h1-h2-h3-h4-h5";
r[6] = "h1-h2-h3-h4-h5";
for (i = 0; i < 7; i++)
ostr = CutObjectName(str, i);
if (ostr != r[i])
tstlog_vlog(log, "E", "CutObjectName, mismatch %d, %s != %s", i, r[i], ostr);
return 0;
endif
endfor
tstlog_log(log, "S", "CutObjectName: Successfull completion");
return 1;
endfunction
function int ccm_GetAttribute(int log)
int i;
string d[39];
int typ[39];
int ival[39];
float fval[39];
string sval[39];
int iret;
float fret;
string sret;
d[0] = "Test01c-Pwrrt-Av1.ActualValue";
fval[0] = 22.22;
typ[0] = 2;
d[1] = "Test01c-Pwrrt-Av1.NoSuchAttr";
sval[1] = "NoSuchAttr";
typ[1] = 0;
d[2] = "Test01c-Pwrrt-Dv1.ActualValue";
ival[2] = 0;
typ[2] = 1;
d[3] = "Test01c-Pwrrt-Dv2.ActualValue";
ival[3] = 1;
typ[3] = 1;
d[4] = "Test01c-Pwrrt-L1.Value.ActualValue";
fval[4] = 33.33;
typ[4] = 2;
d[5] = "Test01c-Pwrrt-L1.LimitHH.Limit";
fval[5] = 95;
typ[5] = 2;
d[6] = "Test01c-Pwrrt-L1.Description";
sval[6] = "BaseLevelSensor used for python tests";
typ[6] = 0;
d[7] = "Test01c-Pwrrt-Values.Boolean";
ival[7] = 1;
typ[7] = 1;
d[8] = "Test01c-Pwrrt-Values.Int8";
ival[8] = 22;
typ[8] = 1;
d[9] = "Test01c-Pwrrt-Values.Int16";
ival[9] = 333;
typ[9] = 1;
d[10] = "Test01c-Pwrrt-Values.Int32";
ival[10] = 4444;
typ[10] = 1;
d[11] = "Test01c-Pwrrt-Values.Int64";
ival[11] = 55555;
typ[11] = 1;
d[12] = "Test01c-Pwrrt-Values.UInt8";
ival[12] = 66;
typ[12] = 1;
d[13] = "Test01c-Pwrrt-Values.UInt16";
ival[13] = 777;
typ[13] = 1;
d[14] = "Test01c-Pwrrt-Values.UInt32";
ival[14] = 8888;
typ[14] = 1;
d[15] = "Test01c-Pwrrt-Values.UInt64";
ival[15] = 99999;
typ[15] = 1;
d[16] = "Test01c-Pwrrt-Values.Float32";
fval[16] = 22.22;
typ[16] = 2;
d[17] = "Test01c-Pwrrt-Values.Float64";
fval[17] = 4444.4444;
typ[17] = 2;
d[18] = "Test01c-Pwrrt-Values.String80";
sval[18] = "Why don't you have wings to fly with?";
typ[18] = 0;
d[19] = "Test01c-Pwrrt-Values.Time";
sval[19] = "15-MAY-2020 08:27:50";
typ[19] = 0;
d[20] = "Test01c-Pwrrt-Values.DeltaTime";
sval[20] = "27 8:27:50.05";
typ[20] = 0;
d[21] = "Test01c-Pwrrt-Values.Objid";
sval[21] = "VolPwrTest01c:Test01c-Pwrrt-Values";
typ[21] = 0;
d[22] = "Test01c-Pwrrt-Values.AttrRef";
sval[22] = "VolPwrTest01c:Test01c-Pwrrt-Values.AttrRef";
typ[22] = 0;
d[23] = "Test01c-Pwrrt-Values.BooleanArray[4]";
ival[23] = 1;
typ[23] = 1;
d[24] = "Test01c-Pwrrt-Values.Int8Array[4]";
ival[24] = 22;
typ[24] = 1;
d[25] = "Test01c-Pwrrt-Values.Int16Array[4]";
ival[25] = 333;
typ[25] = 1;
d[26] = "Test01c-Pwrrt-Values.Int32Array[4]";
ival[26] = 4444;
typ[26] = 1;
d[27] = "Test01c-Pwrrt-Values.Int64Array[4]";
ival[27] = 55555;
typ[27] = 1;
d[28] = "Test01c-Pwrrt-Values.UInt8Array[4]";
ival[28] = 66;
typ[28] = 1;
d[29] = "Test01c-Pwrrt-Values.UInt16Array[4]";
ival[29] = 777;
typ[29] = 1;
d[30] = "Test01c-Pwrrt-Values.UInt32Array[4]";
ival[30] = 8888;
typ[30] = 1;
d[31] = "Test01c-Pwrrt-Values.UInt64Array[4]";
ival[31] = 99999;
typ[31] = 1;
d[32] = "Test01c-Pwrrt-Values.Float32Array[4]";
fval[32] = 22.22;
typ[32] = 2;
d[33] = "Test01c-Pwrrt-Values.Float64Array[4]";
fval[33] = 4444.4444;
typ[33] = 2;
d[34] = "Test01c-Pwrrt-Values.String80Array[4]";
sval[34] = "Why don't you have wings to fly with?";
typ[34] = 0;
d[35] = "Test01c-Pwrrt-Values.TimeArray[4]";
sval[35] = "15-MAY-2020 08:27:50";
typ[35] = 0;
d[36] = "Test01c-Pwrrt-Values.DeltaTimeArray[4]";
sval[36] = "27 8:27:50.05";
typ[36] = 0;
d[37] = "Test01c-Pwrrt-Values.ObjidArray[4]";
sval[37] = "VolPwrTest01c:Test01c-Pwrrt-Values";
typ[37] = 0;
d[38] = "Test01c-Pwrrt-Values.AttrRefArray[4]";
sval[38] = "VolPwrTest01c:Test01c-Pwrrt-Values.AttrRefArray[4]";
typ[38] = 0;
for (i = 0; i < 39; i++)
if (typ[i] == 0)
sret = GetAttribute(d[i]);
if (sret != sval[i])
if (sval[i] != "NoSuchAttr")
tstlog_vlog(log, "E", "GetAttribute, mismatch %d, %s != %s", i, sval[i], sret);
return 0;
endif
endif
endif
if (typ[i] == 1)
iret = GetAttribute(d[i]);
if (iret != ival[i])
tstlog_vlog(log, "E", "GetAttribute, mismatch %d, %d != %d", i, ival[i], iret);
return 0;
endif
endif
if (typ[i] == 2)
fret = GetAttribute(d[i]);
if (fret != fval[i])
tstlog_vlog(log, "E", "GetAttribute, mismatch %d, %f != %f", i, fval[i], fret);
return 0;
endif
endif
endfor
tstlog_log(log, "S", "GetAttribute: Successfull completion");
return 1;
endfunction
function int ccm_SetAttribute(int log)
int i;
int sts;
string d[32];
int typ[32];
int ival[32];
float fval[32];
string sval[32];
int iret;
float fret;
string sret;
d[0] = "Test01c-Pwrrt-SetValues.Boolean";
ival[0] = 1;
typ[0] = 1;
d[1] = "Test01c-Pwrrt-SetValues.Int8";
ival[1] = 22;
typ[1] = 1;
d[2] = "Test01c-Pwrrt-SetValues.Int16";
ival[2] = 333;
typ[2] = 1;
d[3] = "Test01c-Pwrrt-SetValues.Int32";
ival[3] = 4444;
typ[3] = 1;
d[4] = "Test01c-Pwrrt-SetValues.Int64";
ival[4] = 55555;
typ[4] = 1;
d[5] = "Test01c-Pwrrt-SetValues.UInt8";
ival[5] = 66;
typ[5] = 1;
d[6] = "Test01c-Pwrrt-SetValues.UInt16";
ival[6] = 777;
typ[6] = 1;
d[7] = "Test01c-Pwrrt-SetValues.UInt32";
ival[7] = 8888;
typ[7] = 1;
d[8] = "Test01c-Pwrrt-SetValues.UInt64";
ival[8] = 99999;
typ[8] = 1;
d[9] = "Test01c-Pwrrt-SetValues.Float32";
fval[9] = 22.22;
typ[9] = 2;
d[10] = "Test01c-Pwrrt-SetValues.Float64";
fval[10] = 4444.4444;
typ[10] = 2;
d[11] = "Test01c-Pwrrt-SetValues.String80";
sval[11] = "Why don't you have wings to fly with?";
typ[11] = 0;
d[12] = "Test01c-Pwrrt-SetValues.Time";
sval[12] = "15-MAY-2020 08:27:50";
typ[12] = 0;
d[13] = "Test01c-Pwrrt-SetValues.DeltaTime";
sval[13] = "27 8:27:50.05";
typ[13] = 0;
d[14] = "Test01c-Pwrrt-SetValues.Objid";
sval[14] = "VolPwrTest01c:Test01c-Pwrrt-SetValues";
typ[14] = 0;
d[15] = "Test01c-Pwrrt-SetValues.AttrRef";
sval[15] = "VolPwrTest01c:Test01c-Pwrrt-SetValues.AttrRef";
typ[15] = 0;
d[16] = "Test01c-Pwrrt-SetValues.BooleanArray[4]";
ival[16] = 1;
typ[16] = 1;
d[17] = "Test01c-Pwrrt-SetValues.Int8Array[4]";
ival[17] = 22;
typ[17] = 1;
d[18] = "Test01c-Pwrrt-SetValues.Int16Array[4]";
ival[18] = 333;
typ[18] = 1;
d[19] = "Test01c-Pwrrt-SetValues.Int32Array[4]";
ival[19] = 4444;
typ[19] = 1;
d[20] = "Test01c-Pwrrt-SetValues.Int64Array[4]";
ival[20] = 55555;
typ[20] = 1;
d[21] = "Test01c-Pwrrt-SetValues.UInt8Array[4]";
ival[21] = 66;
typ[21] = 1;
d[22] = "Test01c-Pwrrt-SetValues.UInt16Array[4]";
ival[22] = 777;
typ[22] = 1;
d[23] = "Test01c-Pwrrt-SetValues.UInt32Array[4]";
ival[23] = 8888;
typ[23] = 1;
d[24] = "Test01c-Pwrrt-SetValues.UInt64Array[4]";
ival[24] = 99999;
typ[24] = 1;
d[25] = "Test01c-Pwrrt-SetValues.Float32Array[4]";
fval[25] = 22.22;
typ[25] = 2;
d[26] = "Test01c-Pwrrt-SetValues.Float64Array[4]";
fval[26] = 4444.4444;
typ[26] = 2;
d[27] = "Test01c-Pwrrt-SetValues.String80Array[4]";
sval[27] = "Why don't you have wings to fly with?";
typ[27] = 0;
d[28] = "Test01c-Pwrrt-SetValues.TimeArray[4]";
sval[28] = "15-MAY-2020 08:27:50";
typ[28] = 0;
d[29] = "Test01c-Pwrrt-SetValues.DeltaTimeArray[4]";
sval[29] = "27 8:27:50.05";
typ[29] = 0;
d[30] = "Test01c-Pwrrt-SetValues.ObjidArray[4]";
sval[30] = "VolPwrTest01c:Test01c-Pwrrt-SetValues";
typ[30] = 0;
d[31] = "Test01c-Pwrrt-SetValues.AttrRefArray[4]";
sval[31] = "VolPwrTest01c:Test01c-Pwrrt-SetValues.AttrRefArray[4]";
typ[31] = 0;
for (i = 0; i < 32; i++)
if (typ[i] == 0)
sts = SetAttribute(d[i], sval[i]);
if (EVEN(sts))
tstlog_vlog(log, "E", "SetAttribute, error status %d, %d", i, sts);
return 0;
endif
sret = GetAttribute(d[i]);
if (sret != sval[i])
if (sval[i] != "NoSuchAttr")
tstlog_vlog(log, "E", "SetAttribute, mismatch %d, %s != %s", i, sval[i], sret);
return 0;
endif
endif
endif
if (typ[i] == 1)
sts = SetAttribute(d[i], ival[i]);
if (EVEN(sts))
tstlog_vlog(log, "E", "SetAttribute, error status %d, %d", i, sts);
return 0;
endif
iret = GetAttribute(d[i]);
if (iret != ival[i])
tstlog_vlog(log, "E", "SetAttribute, mismatch %d, %d != %d", i, ival[i], iret);
return 0;
endif
endif
if (typ[i] == 2)
sts = SetAttribute(d[i], fval[i]);
if (EVEN(sts))
tstlog_vlog(log, "E", "SetAttribute, error status %d, %d", i, sts);
return 0;
endif
fret = GetAttribute(d[i]);
if (fret != fval[i])
tstlog_vlog(log, "E", "SetAttribute, mismatch %d, %f != %f", i, fval[i], fret);
return 0;
endif
endif
endfor
tstlog_log(log, "S", "SetAttribute: Successfull completion");
return 1;
endfunction
function int ccm_GetChild(int log)
int i;
string child;
string d[4];
string r[4];
d[0] = "RootObject";
r[0] = "RootObject-Child1";
d[1] = "RootObject-Child1";
r[1] = "RootObject-Child1-A1";
d[2] = "RootObject-Child1-A1";
r[2] = "";
d[3] = "RootObject-ChildLess";
r[3] = "";
for (i = 0; i < 4; i++)
child = GetChild(d[i]);
if (child != r[i])
tstlog_vlog(log, "E", "GetChild, mismatch %d, %s != %s", i, r[i], child);
return 0;
endif
endfor
tstlog_log(log, "S", "GetChild: Successfull completion");
return 1;
endfunction
function int ccm_GetParent(int log)
int i;
string parent;
string d[4];
string r[4];
d[0] = "RootObject-Child1-A1";
r[0] = "RootObject-Child1";
d[1] = "RootObject-Child1";
r[1] = "RootObject";
d[2] = "RootObject";
r[2] = "";
d[3] = "NoSuchObject";
r[3] = "";
for (i = 0; i < 4; i++)
parent = GetParent(d[i]);
if (parent != r[i])
tstlog_vlog(log, "E", "GetParent, mismatch %d, %s != %s", i, r[i], parent);
return 0;
endif
endfor
tstlog_log(log, "S", "GetParent: Successfull completion");
return 1;
endfunction
function int ccm_GetNextSibling(int log)
int i;
string sibling;
string d[5];
string r[5];
d[0] = "RootObject-Child1";
r[0] = "RootObject-Child2";
d[1] = "RootObject-Child2";
r[1] = "RootObject-Child3";
d[2] = "RootObject-Child3";
r[2] = "RootObject-Child4";
d[3] = "RootObject-Child4";
r[3] = "RootObject-ChildLess";
d[4] = "RootObject-ChildLess";
r[4] = "";
for (i = 0; i < 5; i++)
sibling = GetNextSibling(d[i]);
if (sibling != r[i])
tstlog_vlog(log, "E", "GetNextSibling, mismatch %d, %s != %s", i, r[i], sibling);
return 0;
endif
endfor
tstlog_log(log, "S", "GetNextSibling: Successfull completion");
return 1;
endfunction
function int ccm_GetClassList(int log)
int i;
string classlist;
string d[6];
string r[6];
d[0] = "MessageHandler";
r[0] = "Nodes-PwrTest01c-Servers-MessageHandler";
d[1] = "IOHandler";
r[1] = "Nodes-PwrTest01c-Servers-IOHandler";
d[2] = "$PlantHier";
r[2] = "RootObject";
d[3] = "AArray100";
r[3] = "RootObject-Child1-A1";
d[4] = "BaseFcPPO3PumpAggr";
r[4] = "RootObject-Child1-P1";
d[5] = "$WorkBenchVolume";
r[5] = "";
for (i = 0; i < 6; i++)
classlist = GetClassList(d[i]);
if (classlist != r[i])
tstlog_vlog(log, "E", "GetClassList, mismatch %d, %s != %s", i, r[i], classlist);
return 0;
endif
endfor
tstlog_log(log, "S", "GetClassList: Successfull completion");
return 1;
endfunction
function int ccm_GetNextObject(int log)
int i;
string next;
string d[7];
string r[7];
d[0] = "Nodes-PwrTest01c-Servers-MessageHandler";
r[0] = "";
d[1] = "Nodes-PwrTest01c-Servers-IOHandler";
r[1] = "";
d[2] = "RootObject";
r[2] = "RootObject-Child1";
d[3] = "RootObject-Child1";
r[3] = "RootObject-Child2";
d[4] = "RootObject-Child2";
r[4] = "RootObject-Child3";
d[5] = "RootObject-Child3";
r[5] = "RootObject-Child4";
d[6] = "RootObject-Child4";
r[6] = "RootObject-ChildLess";
for (i = 0; i < 7; i++)
next = GetNextObject(d[i]);
if (next != r[i])
tstlog_vlog(log, "E", "GetNextObject, mismatch %d, %s != %s", i, r[i], next);
return 0;
endif
endfor
tstlog_log(log, "S", "GetNextObject: Successfull completion");
return 1;
endfunction
function int ccm_GetObjectClass(int log)
int i;
string class;
string d[7];
string r[7];
d[0] = "RootObject";
r[0] = "$PlantHier";
d[1] = "RootObject-Child1";
r[1] = "$PlantHier";
d[2] = "Test01c-Pwrrt-Dv1";
r[2] = "Dv";
d[3] = "Test01c-Pwrrt-L1";
r[3] = "BaseLevelSensor";
d[4] = "VolPwrTest01c:";
r[4] = "$RootVolume";
d[5] = "pwrb:Class-And";
r[5] = "$ClassDef";
d[6] = "pwrs:";
r[6] = "$ClassVolume";
for (i = 0; i < 7; i++)
class = GetObjectClass(d[i]);
if (class != r[i])
tstlog_vlog(log, "E", "GetObjectClass, mismatch %d, %s != %s", i, r[i], class);
return 0;
endif
endfor
tstlog_log(log, "S", "GetObjectClass: Successfull completion");
return 1;
endfunction
function int ccm_GetNodeObject(int log)
string node;
string r = "Nodes-PwrTest01c";
node = GetNodeObject();
if (node != r)
tstlog_vlog(log, "E", "GetNodeObject, mismatch %s != %s", r, node);
return 0;
endif
tstlog_log(log, "S", "GetNodeObject: Successfull completion");
return 1;
endfunction
function int ccm_GetRootList(int log)
string root;
string r = "RootObject";
root = GetRootList();
if (root != r)
tstlog_vlog(log, "E", "GetRootList, mismatch %s != %s", r, root);
return 0;
endif
tstlog_log(log, "S", "GetRootList: Successfull completion");
return 1;
endfunction
function int ccm_GetUser(int log)
string user;
login pwrp pwrp
user = GetUser();
logout
if (user != "pwrp")
tstlog_vlog(log, "E", "GetUser, mismatch %s != pwrp", user);
return 0;
endif
tstlog_log(log, "S", "GetUser: Successfull completion");
return 1;
endfunction
function int ccm_GetPrivileges(int log)
int priv;
login pwrp pwrp
priv = GetPrivileges();
logout
if (priv != 167510022)
tstlog_vlog(log, "E", "GetPrivileges, mismatch %d != 167510022", priv);
return 0;
endif
tstlog_log(log, "S", "GetPrivileges: Successfull completion");
return 1;
endfunction
main()
int log;
verify(0);
tzset("Europe/Stockholm");
log = tstlog_open("op-XttScript", "$pwrp_log/xttscript.log");
ccm_CutObjectName(log);
ccm_GetAttribute(log);
ccm_SetAttribute(log);
ccm_GetChild(log);
ccm_GetParent(log);
ccm_GetNextSibling(log);
ccm_GetClassList(log);
ccm_GetNextObject(log);
ccm_GetObjectClass(log);
ccm_GetNodeObject(log);
ccm_GetRootList(log);
ccm_GetUser(log);
ccm_GetPrivileges(log);
tstlog_close(log);
endmain
! Generated by wb_print_wbl 28-MAY-2020 16:31:59.88
! Generated by wb_print_wbl 03-JUN-2020 15:29:56.68
! Volume directory
! Version V5.7.1
Volume directory $DirectoryVolume 254.254.254.253
......@@ -6,9 +6,9 @@ Volume directory $DirectoryVolume 254.254.254.253
Attr NextOix = "_X13"
EndBody
Object System $System 2 17-JAN-2006 17:43:09.50
Body SysBody 20-MAR-2020 11:55:16.96
Body SysBody 26-MAR-2020 13:15:21.47
Attr SystemName = "pwrtest01"
Attr SystemGroup = "Common"
Attr SystemGroup = "common"
EndBody
EndObject
Object Bus999 BusConfig 3 11-MAY-2006 15:40:05.54
......@@ -16,10 +16,10 @@ Volume directory $DirectoryVolume 254.254.254.253
Attr BusNumber = 999
EndBody
Object PwrTest01a NodeConfig 10 25-MAR-2020 09:04:16.06
Body RtBody 28-MAY-2020 16:31:59.83
Body RtBody 27-APR-2020 09:55:35.94
Attr NodeName = "pwrtest01a"
Attr OperatingSystem = 128
Attr Address = "127.0.0.1"
Attr Address = "10.255.100.1"
EndBody
Object VolPwrTest01a RootVolumeLoad 11 25-MAR-2020 09:05:00.12
Body RtBody 05-MAR-2008 11:22:55.46
......@@ -42,10 +42,10 @@ Volume directory $DirectoryVolume 254.254.254.253
EndObject
EndObject
Object PwrTest01b NodeConfig 26 25-MAR-2020 09:06:55.29
Body RtBody 28-MAY-2020 16:31:59.83
Body RtBody 27-APR-2020 09:55:44.89
Attr NodeName = "pwrtest01b"
Attr OperatingSystem = 128
Attr Address = "127.0.0.1"
Attr Address = "10.255.100.2"
EndBody
Object VolPwrTest01b RootVolumeLoad 27 25-MAR-2020 09:07:16.00
Body RtBody 25-MAR-2020 09:06:45.34
......@@ -68,7 +68,7 @@ Volume directory $DirectoryVolume 254.254.254.253
EndObject
EndObject
Object PwrTest01c NodeConfig 33 26-MAR-2020 10:23:36.40
Body RtBody 28-MAY-2020 16:31:59.84
Body RtBody 01-JUN-2020 10:06:13.82
Attr NodeName = "pwrtest01c"
Attr OperatingSystem = 128
Attr Address = "127.0.0.1"
......@@ -78,9 +78,10 @@ Volume directory $DirectoryVolume 254.254.254.253
EndBody
EndObject
Object BuildOpt BuildOptions 35 26-MAR-2020 10:23:26.37
Body RtBody 26-MAR-2020 10:23:26.37
Body RtBody 30-MAR-2020 16:38:06.76
Attr PlcProcess = "Plc"
Attr SystemModules = 16
Attr SystemModules = 2097168
Attr ObjectModules[0] = "$pwrp_obj/ra_plc_user.o"
EndBody
EndObject
Object Distribute Distribute 36 26-MAR-2020 10:23:26.37
......@@ -91,13 +92,88 @@ Volume directory $DirectoryVolume 254.254.254.253
Attr Source = "$pwrp_exe/ra_status"
EndBody
EndObject
Object ra_aproctest ApplDistribute 42 01-JUN-2020 09:31:46.68
Body DevBody 01-JUN-2020 09:31:56.29
Attr Source = "$pwrp_exe/ra_aproctest"
EndBody
EndObject
Object ra_cdhtest ApplDistribute 43 01-JUN-2020 09:32:04.50
Body DevBody 01-JUN-2020 09:32:12.13
Attr Source = "$pwrp_exe/ra_cdhtest"
EndBody
EndObject
Object ra_errhtest ApplDistribute 44 01-JUN-2020 09:32:31.89
Body DevBody 01-JUN-2020 09:32:25.78
Attr Source = "$pwrp_exe/ra_errhtest"
EndBody
EndObject
Object ra_gdhtest ApplDistribute 45 01-JUN-2020 09:32:40.57
Body DevBody 01-JUN-2020 09:32:47.49
Attr Source = "$pwrp_exe/ra_gdhtest"
EndBody
EndObject
Object ra_mhappltest ApplDistribute 46 01-JUN-2020 09:33:02.15
Body DevBody 01-JUN-2020 09:33:10.20
Attr Source = "$pwrp_exe/ra_mhappltest"
EndBody
EndObject
Object ra_mhtest ApplDistribute 47 01-JUN-2020 09:34:02.17
Body DevBody 01-JUN-2020 09:34:07.65
Attr Source = "$pwrp_exe/ra_mhtest"
EndBody
EndObject
Object ra_nettimetest ApplDistribute 48 01-JUN-2020 09:34:25.19
Body DevBody 01-JUN-2020 09:34:32.51
Attr Source = "$pwrp_exe/ra_nettimetest"
EndBody
EndObject
Object ra_plctest ApplDistribute 49 01-JUN-2020 09:34:42.05
Body DevBody 01-JUN-2020 09:34:49.13
Attr Source = "$pwrp_exe/ra_plctest"
EndBody
EndObject
Object ra_pwrrttest ApplDistribute 50 01-JUN-2020 09:35:03.33
Body DevBody 01-JUN-2020 09:35:13.22
Attr Source = "$pwrp_exe/ra_pwrrttest.py"
EndBody
EndObject
Object ra_qcomtest ApplDistribute 51 01-JUN-2020 09:35:38.70
Body DevBody 01-JUN-2020 09:35:46.20
Attr Source = "$pwrp_exe/ra_qcomtest"
EndBody
EndObject
Object ra_qmontest ApplDistribute 52 01-JUN-2020 09:35:55.34
Body DevBody 01-JUN-2020 09:36:00.39
Attr Source = "$pwrp_exe/ra_qmontest"
EndBody
EndObject
Object ra_timetest ApplDistribute 54 01-JUN-2020 09:36:37.41
Body DevBody 01-JUN-2020 09:36:45.42
Attr Source = "$pwrp_exe/ra_timetest"
EndBody
EndObject
Object ra_ccmtest ApplDistribute 75 02-JUN-2020 07:51:06.90
Body DevBody 02-JUN-2020 07:51:22.89
Attr Source = "$pwrp_exe/ra_ccmtest.rtt_com"
EndBody
EndObject
Object ra_xttscripttest ApplDistribute 74 02-JUN-2020 07:51:33.88
Body DevBody 02-JUN-2020 07:51:43.65
Attr Source = "$pwrp_exe/ra_xttscripttest.rtt_com"
EndBody
EndObject
Object ra_testall_c ApplDistribute 53 01-JUN-2020 09:37:34.07
Body DevBody 01-JUN-2020 09:37:37.33
Attr Source = "$pwrp_exe/ra_testall_c.sh"
EndBody
EndObject
EndObject
EndObject
Object PwrTest01d SevNodeConfig 38 26-MAR-2020 10:24:30.82
Body RtBody 28-MAY-2020 16:31:59.84
Body RtBody 27-APR-2020 09:55:51.41
Attr NodeName = "pwrtest01d"
Attr OperatingSystem = 128
Attr Address = "127.0.0.1"
Attr Address = "10.255.100.3"
EndBody
Object VolPwrTest01d RootVolumeLoad 40 26-MAR-2020 10:25:39.73
Body RtBody 26-MAR-2020 10:25:31.80
......@@ -110,6 +186,103 @@ Volume directory $DirectoryVolume 254.254.254.253
EndObject
EndObject
EndObject
Object Bus998 BusConfig 55 01-JUN-2020 10:04:48.76
Body RtBody 01-JUN-2020 10:06:31.24
Attr BusNumber = 998
EndBody
Object PwrTest01c NodeConfig 56 01-JUN-2020 10:05:00.49
Body RtBody 01-JUN-2020 10:05:00.49
Attr NodeName = "copper-arrow"
Attr OperatingSystem = 128
Attr Address = "127.0.0.1"
EndBody
Object VolPwrTest01c RootVolumeLoad 57 01-JUN-2020 10:05:00.49
Body RtBody 01-JUN-2020 10:05:00.49
EndBody
EndObject
Object BuildOpt BuildOptions 58 01-JUN-2020 10:05:00.49
Body RtBody 01-JUN-2020 10:05:00.49
Attr PlcProcess = "Plc"
Attr SystemModules = 2097168
Attr ObjectModules[0] = "$pwrp_obj/ra_plc_user.o"
EndBody
EndObject
Object Distribute Distribute 59 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
EndBody
Object ra_status ApplDistribute 60 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_status"
EndBody
EndObject
Object ra_aproctest ApplDistribute 61 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_aproctest"
EndBody
EndObject
Object ra_cdhtest ApplDistribute 62 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_cdhtest"
EndBody
EndObject
Object ra_errhtest ApplDistribute 63 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_errhtest"
EndBody
EndObject
Object ra_gdhtest ApplDistribute 64 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_gdhtest"
EndBody
EndObject
Object ra_mhappltest ApplDistribute 65 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_mhappltest"
EndBody
EndObject
Object ra_mhtest ApplDistribute 66 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_mhtest"
EndBody
EndObject
Object ra_nettimetest ApplDistribute 67 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_nettimetest"
EndBody
EndObject
Object ra_plctest ApplDistribute 68 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_plctest"
EndBody
EndObject
Object ra_pwrrttest ApplDistribute 69 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_pwrrttest.py"
EndBody
EndObject
Object ra_qcomtest ApplDistribute 70 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_qcomtest"
EndBody
EndObject
Object ra_qmontest ApplDistribute 71 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_qmontest"
EndBody
EndObject
Object ra_timetest ApplDistribute 72 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_timetest"
EndBody
EndObject
Object ra_testall_c ApplDistribute 73 01-JUN-2020 10:05:00.49
Body DevBody 01-JUN-2020 10:05:00.49
Attr Source = "$pwrp_exe/ra_testall_c.sh"
EndBody
EndObject
EndObject
EndObject
EndObject
Object Build BuildConfig 14 03-FEB-2017 15:14:34.90
Body DevBody 03-FEB-2017 15:14:31.33
Attr VersionManager = 0
......@@ -142,7 +315,7 @@ Volume directory $DirectoryVolume 254.254.254.253
Attr Target = "$pwrp_inc/"
EndBody
EndObject
Object ra_status BuildMake 23 19-MAR-2020 17:02:17.98
Object ra_testall_c BuildMake 23 03-JUN-2020 15:29:49.59
Body DevBody 19-MAR-2020 17:02:24.03
Attr Makefile = "makefile"
EndBody
......@@ -176,4 +349,8 @@ Volume directory $DirectoryVolume 254.254.254.253
Body RtBody 26-MAR-2020 10:22:46.41
EndBody
EndObject
Object CVolPwrtest01 ClassVolumeConfig 41 30-MAR-2020 16:21:43.38
Body RtBody 30-MAR-2020 16:21:26.99
EndBody
EndObject
EndVolume
This source diff could not be displayed because it is too large. You can view the blob instead.
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