Commit 56cc1e9e authored by Claes's avatar Claes Committed by Esteban Blanc

Project pwrtest02 added

parent 05542d4a
pwrtest02 is a test project for the development package.
It contains scripts to create and configure a project, and a
number of test programs.
The cpp test programs has to be built with a development tree, thus the
project is generated here and the testprograms built. The test programs
are gathered in $pwrp_load/pwrtest02.tar.gz.
For manual build:
pwre commands to build and clean the project
> pwre module project
> pwre build pwrtest02 build src
> pwre build pwrtest02 build src clean
build_from_git.sh will configure and build the project and build the
test programs.
For manual handling and running the project environment it set up by
test02_setup.sh
When the project is built, the test programs will generate log-files on
$pwrp_log. They can be examined by test_xtt, eg
test_xtt -f $pwrp_log/\*.tlog
include $(pwre_dir_symbols)
ifndef variables_mk
include $(pwre_croot)/src/tools/bld/src/variables.mk
endif
ifndef rules_mk
include $(pwre_croot)/src/tools/bld/src/rules.mk
endif
all : init copy lib exe | silent
init :
copy :
lib :
exe : build_project | silent
clean : clean_project
realclean : clean
silent :
@ :
build_project :
@ $(pwre_croot)/project/pwrtest02/build_from_git.sh
clean_project:
@ echo "Cleaing project"
@ if [ -e $(pwre_croot)/project/pwrtest02/bld ]; then rm $(pwre_croot)/project/pwrtest02/bld; fi
@ if [ -e $(pwre_croot)/project/pwrtest02/src/db/directory.wb_load ]; then rm $(pwre_croot)/project/pwrtest02/src/db/directory.wb_load; fi
@ if [ -e $(pwre_croot)/project/pwrtest02/src/db/cvolpwrtest02.wb_load ]; then rm $(pwre_croot)/project/pwrtest02/src/db/cvolpwrtest02.wb_load; fi
@ if [ -e $(pwre_croot)/project/pwrtest02/src/db/volpwrtest02.db ]; then rm -r $(pwre_croot)/project/pwrtest02/src/db/volpwrtest02.db; fi
@ if [ "`eval ls $(pwre_croot)/project/pwrtest02/src/db/*.lock 2>/dev/null`" != "" ]; then rm $(pwre_croot)/project/pwrtest02/src/db/*.lock; fi
@ if [ "`eval ls $(pwre_croot)/project/pwrtest02/src/db/* 2>/dev/null`" != "" ]; then rm -r $(pwre_croot)/project/pwrtest02/src/db/*; fi
@ if [ -e $(release_root)/bld/project/pwrtest02/bld ]; then rm -r $(release_root)/bld/project/pwrtest02/bld; fi
#!/bin/bash
#
# Build pwrtest02 from git clone
#
cd $pwre_sroot/pwrtest02
nodename=`eval uname -n`
unamestr=`eval uname`
onamestr=`eval uname -o`
machine=`eval uname -m`
if [ $unamestr == "Darwin" ]; then
os="os_macos"
hw="hw_x86_64"
opsys=256
elif [ $unamestr == "FreeBSD" ]; then
os="os_freebsd"
hw="hw_x86_64"
opsys=1024
elif [ $unamestr == "OpenBSD" ]; then
os="os_openbsd"
hw="hw_x86_64"
opsys=2048
elif [ $onamestr == "Cygwin" ]; then
os="os_cygwin"
hw="hw_x86"
opsys=4096
else
if [ $machine == "x86_64" ]; then
machine="x86_64"
opsys=128
elif [ ${machine:0:3} == "arm" ]; then
machine="arm"
opsys=512
else
machine="x86"
opsys=64
fi
os="os_linux"
hw="hw_"$machine
fi
platform=${hw:3}_${os:3}
#srcdir=$pwre_croot/src/tools/docker/pwrtest02
srcdir=/home/claes/wb
export pwrp_root=$pwre_croot/project/pwrtest02
broot=$pwre_broot/$os/$hw/bld/project/pwrtest02/bld
if [ ! -e $broot ]; then
mkdir -p $broot
fi
if [ ! -e $pwrp_root/bld ]; then
ln -s $broot $pwrp_root/bld
fi
export pwrp_exe=$pwrp_root/bld/$platform/exe
export pwrp_lib=$pwrp_root/bld/$platform/lib
export pwrp_obj=$pwrp_root/bld/$platform/obj
export pwrp_lis=$pwrp_root/bld/$platform/lis
export pwrp_inc=$pwrp_root/bld/common/inc
export pwrp_load=$pwrp_root/bld/common/load
export pwrp_tmp=$pwrp_root/bld/common/tmp
export pwrp_web=$pwrp_root/bld/common/web
export pwrp_log=$pwrp_root/bld/common/log
echo "* Create directories"
if [ ! -e $pwrp_obj ]; then
mkdir -p $pwrp_obj
fi
if [ ! -e $pwrp_exe ]; then
mkdir -p $pwrp_exe
fi
if [ ! -e $pwrp_lib ]; then
mkdir -p $pwrp_lib
fi
if [ ! -e $pwrp_lis ]; then
mkdir -p $pwrp_lis
fi
if [ ! -e $pwrp_load ]; then
mkdir -p $pwrp_load
fi
if [ ! -e $pwrp_inc ]; then
mkdir -p $pwrp_inc
fi
if [ ! -e $pwrp_lis ]; then
mkdir -p $pwrp_lis
fi
if [ ! -e $pwrp_tmp ]; then
mkdir -p $pwrp_tmp
fi
if [ ! -e $pwrp_web ]; then
mkdir -p $pwrp_web
fi
if [ ! -e $pwrp_log ]; then
mkdir -p $pwrp_log
fi
export pwrp_db=$pwre_sroot/pwrtest02/src/db
export pwrp_pop=$pwre_sroot/pwrtest02/src/pop
if [ ! -e $pwrp_db ]; then
mkdir -p $pwrp_db
fi
if [ ! -e $pwrp_pop ]; then
mkdir -p $pwrp_pop
fi
echo "* Configure adm"
export pwra_db=$pwre_broot/$os/$hw/bld/project/adm/db
if [ ! -e $pwra_db ]; then
mkdir -p $pwra_db
cp $pwre_croot/src/tools/pkg/deb/adm/* $pwra_db/
fi
if [ "`eval grep CVolPwrtest02 $pwra_db/pwr_volumelist.dat`" == "" ]; then
echo "CVolPwrtest02 0.0.240.210 pwrtest02" >> $pwra_db/pwr_volumelist.dat
fi
if [ "`eval grep VolPwrTest02 $pwra_db/pwr_volumelist.dat`" == "" ]; then
echo "VolPwrTest02 0.254.254.210 pwrtest02" >> $pwra_db/pwr_volumelist.dat
fi
if [ ! -e $pwra_db/pwr_projectlist.dat ] || [ "`eval grep base $pwra_db/pwr_projectlist.dat`" == "" ]; then
echo "%base V0.0.0 $pwre_broot" > $pwra_db/pwr_projectlist.dat
fi
if [ "`eval grep pwrtest02 $pwra_db/pwr_projectlist.dat`" == "" ]; then
echo "pwrtest02 V0.0.0 $pwrp_root Test-pwrtest02 \"\"" >> $pwra_db/pwr_projectlist.dat
fi
source $pwra_db/pwr_setup.sh
source $pwra_db/pwra_env.sh set project pwrtest02
#set -o xtrace
echo "* Configure directory volume"
wb_cmd create volume/database=wbload/directory
wb_cmd @$srcdir/configure_directory pwrtest02
echo "* Configure class volume"
ls $srcdir/configure_cvolpwrtest02.pwr_com
wb_cmd -c cvolpwrtest02 @$srcdir/configure_cvolpwrtest02
wb_cmd -q create snapshot/file=\"$pwrp_db/cvolpwrtest02.wb_load\"/out=\"$pwrp_load/cvolpwrtest02.dbs\"
co_convert -so -d $pwrp_inc $pwrp_db/cvolpwrtest02.wb_load
echo "* Configure root volume"
wb_cmd -v volpwrtest02 @$srcdir/configure_volpwrtest02
wb_cmd -v volpwrtest02 build node/name=pwrt02
echo "* Build test programs"
cp $srcdir/wa_ldhtest.cpp $pwrp_appl
cp $srcdir/wa_ldhtest.h $pwrp_appl
cp $srcdir/wa_pwrwbtest.py $pwrp_appl
cp $srcdir/ra_test.py $pwrp_appl
cp $srcdir/makefile $pwrp_appl
cd $pwrp_appl
make
echo "* Run test programs"
export PYTHONPATH=$pwr_eexe
wa_ldhtest volpwrtest02
wa_pwrwbtest.py
echo "* Build package"
cd $pwrp_exe
tar -czf $pwrp_load/pwrtest02.tar.gz wa_ldhtest wa_pwrwbtest.py ra_test.py
exit
echo "* Set opsys $opsys"
cat > initdir.pwr_com <<EOF
set attr/name=Bus999-PwrTest02/attr=OperatingSystem/value="$opsys"/noconf
save
exit
EOF
wb_cmd @initdir
echo "* Build class volume"
co_convert -so -d $pwrp_inc $pwrp_db/cvolpwrtest02.wb_load
co_convert -po -d $pwrp_inc $pwrp_db/cvolpwrtest02.wb_load
wb_cmd -q create snapshot/file=\"$pwrp_db/cvolpwrtest02.wb_load\"/out=\"$pwrp_load/cvolpwrtest02.dbs\"
echo "* Load volpwrtest01a"
wb_cmd wb load/nofocode/load=\"$pwrp_db/volpwrtest01a.wb_dmp\"/out=\"$pwrp_db/volpwrtest01a.lis\"
echo "* Set opsys $opsys"
cat > initvol.pwr_com <<EOF
set attr/name=VolPwrTest02:/attr=OperatingSystem/value="$opsys"/noconf
save
exit
EOF
wb_cmd -v volpwrtest02 @initvol
wb_cmd -v volpwrtest02 build node pwrtest02 /force
echo "* Build package"
wb_cmd distr/node=pwrtest02/package
exit
my : demo_all
include $(pwr_exe)/pwrp_rules.mk
#asan = -fsanitize=address -lasan
demo_modules = $(pwrp_exe)/wa_ldhtest \
$(pwrp_exe)/wa_pwrwbtest.py \
$(pwrp_exe)/ra_test.py
pwre_conf_libpwrco=-lpwr_co
pwre_conf_libpwrrt=-lpwr_rt -lpwr_statussrv -lpwr_co -lpwr_msg_dummy
pwre_conf_libpwrdtt=-lpwr_dtt
pwre_conf_libpwrotherio=-lpwr_usbio_dummy -lpwr_usb_dummy -lpwr_cifx_dummy -lpwr_nodave_dummy -lpwr_epl_dummy
pwre_conf_libpwrprofibus=-lpwr_pnak_dummy
pwre_conf_libpwrpowerlink=
pwre_conf_libpwrpowerlinkcn=
pwre_conf_libpwrxtt=-lpwr_xtt -lpwr_ge -lpwr_cow -lpwr_flow -lpwr_glow
pwre_conf_libpwrxttgtk= -lpwr_xtt_gtk -lpwr_ge_gtk -lpwr_cow_gtk -lpwr_flow_gtk -lpwr_glow_gtk
pwre_conf_libpwrxttqt= -lpwr_xtt_qt -lpwr_ge_qt -lpwr_cow_qt -lpwr_flow_qt -lpwr_glow_qt
pwre_conf_libpwrxttmotif= -lpwr_xtt_motif -lpwr_ge_motif -lpwr_cow_motif -lpwr_flow_motif -lpwr_glow_motif
pwre_conf_libpwrwb=-lpwr_wb
pwre_conf_libpwrwbgtk=-lpwr_wb_gtk
pwre_conf_libpwrwbqt=-lpwr_wb_qt
pwre_conf_libpwrwbmotif=-lpwr_wb_motif
pwre_conf_libpwropc=-lpwr_opc
pwre_conf_libpwrremote=-lpwr_remote
pwre_conf_libpwrnmps=-lpwr_nmps
pwre_conf_libpwrtlog=-lpwr_tlog
pwre_conf_libpwrsev=-lpwr_sev
pwre_conf_lib= -lrpcsvc -lasound -lpthread -lm -ldb -lz -lcrypt -lrt -lX11 -lsqlite3 -lhdf5_openmpi -lmpi -lrabbitmq -lusb-1.0 -lrsvg-2
pwre_conf_libwb= -ldb_cxx
pwre_conf_libmq=
pwre_conf_libwmq=
pwre_conf_libpnak=
pwre_conf_libgtk= \`pkg-config --libs gtk+-2.0\`
pwre_conf_libqt=
pwre_conf_libgst= \`pkg-config --libs gstreamer-video-1.0 gstreamer-1.0\`
wb_msg_eobjs=$(pwr_obj)/pwr_msg_wb.o
rt_msg_eobjs=$(pwr_obj)/pwr_msg_rt.o $(pwr_obj)/pwr_msg_rs.o $(pwr_obj)/pwr_msg_co.o $(pwr_obj)/pwr_msg_flow.o $(pwr_obj)/pwr_msg_glow.o $(pwr_obj)/pwr_msg_ge.o
demo_all : $(demo_modules)
$(pwrp_exe)/wa_ldhtest : $(pwrp_appl)/wa_ldhtest.cpp
@ echo "Building wa_ldhtest"
@ g++ -g -o $(target) $(source) -DOS_LINUX=1 -Wall -I$(pwr_inc) -I$(pwrp_inc) -L$(pwr_lib) \
$(wb_msg_eobjs) $(rt_msg_eobjs) $(pwre_conf_libdir) \
$(pwr_obj)/rt_io_user.o $(pwr_obj)/wb_procom.o \
$(pwre_conf_libdir) $(pwre_conf_libpwrwbgtk) $(pwre_conf_libpwrxttgtk) \
$(pwre_conf_libpwrwb) \
$(pwre_conf_libpwrxtt) $(pwre_conf_libpwrwbgtk) $(pwre_conf_libpwrwb) \
$(pwre_conf_libpwrxttgtk) $(pwre_conf_libpwrxtt) \
`pkg-config --libs gtk+-2.0` \
$(pwre_conf_libpwrrt) $(pwre_conf_libwb) $(pwre_conf_lib) $(asan)
$(pwrp_exe)/wa_pwrwbtest.py : $(pwrp_appl)/wa_pwrwbtest.py
@ echo "Building wa_pwrwbtest"
@ cp -p $(source) $(target)
$(pwrp_exe)/ra_test.py : $(pwrp_appl)/ra_test.py
@ echo "Building ra_test"
@ cp -p $(source) $(target)
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
import sys
import math
import time
import pwrrt
import pwrtest
class Ctx:
#
# Static pwrrt methods
#
#
# pwrrt.init()
#
def init(self):
try:
pwrrt.init('ra_pwrrttest')
except RuntimeError as e:
self.logger.vlog('E', 'init, Unexpected exception %s', str(e))
raise e
self.logger.log('S', 'init, successfull completion')
#
# Check system status
#
def systemStatus(self):
a = pwrrt.attribute('Nodes-Pwrtest02.SystemStatus')
sts = a.value()
msg = pwrrt.getMsg(sts)
if sts % 2 == 0:
self.logger.log('E', 'System status', msg);
return
self.logger.log('S', 'System status', msg)
#
# Check plc threads
#
def plcThreads(self):
d = (
((1, 'PlcTest-H1-Dv1.ActualValue', 1),
(1, 'PlcTest-H1-Dv2.ActualValue', 1),
(1, 'PlcTest-H1-Dv3.ActualValue', 0),
(0, 'PlcTest-H1-Dv4.ActualValue', 1)),
((1, 'PlcTest-H2-Dv1.ActualValue', 1),
(1, 'PlcTest-H2-Dv2.ActualValue', 1),
(1, 'PlcTest-H2-Dv3.ActualValue', 0),
(0, 'PlcTest-H2-Dv4.ActualValue', 1)),
((1, 'PlcTest-H3-Dv1.ActualValue', 1),
(1, 'PlcTest-H3-Dv2.ActualValue', 1),
(1, 'PlcTest-H3-Dv3.ActualValue', 0),
(0, 'PlcTest-H3-Dv4.ActualValue', 1)),
((1, 'PlcTest-H4-Dv1.ActualValue', 1),
(1, 'PlcTest-H4-Dv2.ActualValue', 1),
(1, 'PlcTest-H4-Dv3.ActualValue', 0),
(0, 'PlcTest-H4-Dv4.ActualValue', 1))
)
for i in range(len(d)):
for j in range(len(d[i])):
if d[i][j][0] == 1:
a = pwrrt.attribute(d[i][j][1])
a.setValue(d[i][j][2])
time.sleep(0.1)
for i in range(len(d)):
for j in range(len(d[i])):
if d[i][j][0] == 0:
a = pwrrt.attribute(d[i][j][1])
val = a.value()
if val != d[i][j][2]:
self.logger.vlog('E', 'Plc thread %s, test value mismatch', str(i))
else:
self.logger.vlog('S', 'PlcThread %s test ok', str(i))
ctx = Ctx()
ctx.logger = pwrtest.logger('wbtest-rt', '$pwrp_log/pwrtest02_rt.tlog')
try:
ctx.init()
except:
quit()
pwrrt.login('pwrp', 'pwrp')
ctx.systemStatus()
ctx.plcThreads()
/*
Test ldh 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 "wb_ldh_msg.h"
#include "co_cdh_msg.h"
#include "co_tree_msg.h"
#include "wb_ldh.h"
#include "pwr_baseclasses.h"
#include "pwr_basecomponentclasses.h"
#include "pwr_cvolpwrtest02classes.h"
#include "wa_ldhtest.h"
pwr_tStatus wa_ldhtest::check_object(pwr_tOid oid)
{
pwr_tOid p, child, next, prev;
pwr_tStatus sts;
sts = ldh_GetParent(m_ldhses, oid, &p);
if (ODD(sts)) {
int found = 0;
for (sts = ldh_GetChild(m_ldhses, p, &child);
ODD(sts);
sts = ldh_GetNextSibling(m_ldhses, child, &child)) {
if (cdh_ObjidIsEqual(oid, child)) {
found = 1;
break;
}
}
if (!found)
return LDH__NO_CHILD;
}
sts = ldh_GetNextSibling(m_ldhses, oid, &next);
if (ODD(sts)) {
sts = ldh_GetPreviousSibling(m_ldhses, next, &prev);
if (EVEN(sts))
return sts;
if (cdh_ObjidIsNotEqual(oid, prev))
return LDH__NO_SIBLING;
}
sts = ldh_GetPreviousSibling(m_ldhses, oid, &prev);
if (ODD(sts)) {
sts = ldh_GetNextSibling(m_ldhses, prev, &next);
if (EVEN(sts))
return sts;
if (cdh_ObjidIsNotEqual(oid, next))
return LDH__NO_SIBLING;
}
for (sts = ldh_GetChild(m_ldhses, oid, &child);
ODD(sts);
sts = ldh_GetNextSibling(m_ldhses, child, &child)) {
sts = ldh_GetParent(m_ldhses, child, &p);
if (cdh_ObjidIsNotEqual(oid, p))
return LDH__NO_CHILD;
}
return LDH__SUCCESS;
}
typedef struct {
pwr_tOName name;
pwr_tStatus sts1;
pwr_tStatus sts2;
pwr_tOid oid;
} sObjidToName;
// NameToObjid and ObjidToName
void wa_ldhtest::ObjidToName(void)
{
sObjidToName d[] = {
{"Test02-Ldh", LDH__SUCCESS, LDH__SUCCESS, pwr_cNOid},
{"Test02-Ldh-", LDH__SUCCESS, LDH__SUCCESS, pwr_cNOid},
{"Test02-Ldh-LongName90123456789012345678901", LDH__SUCCESS, LDH__SUCCESS, pwr_cNOid},
{"Test02-Ldh-TooLongName234567890123456789012", LDH__BADNAME, 0, pwr_cNOid}
};
pwr_tOName oname;
int size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &d[i].oid, d[i].name);
if (m_sts != d[i].sts1) {
m_log->log('E', "ObjidToName, NameToObjid wrong sts", d[i].name, m_sts);
return;
}
else if (ODD(m_sts)) {
m_sts = ldh_ObjidToName(m_ldhses, d[i].oid, ldh_eName_Hierarchy, oname, sizeof(oname), &size);
if (m_sts != d[i].sts2) {
m_log->log('E', "ObjidToName, wrong sts", d[i].name, m_sts);
return;
}
else if (ODD(m_sts)) {
if (strcmp(oname, d[i].name) != 0) {
m_log->vlog('E', "ObjidToName, wrong object %s != %s, idx %d", oname, d[i].name, i);
return;
}
}
}
}
m_log->log('S', "ObjidToName", LDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
pwr_tOName dest;
pwr_tCid cid;
pwr_tStatus sts;
pwr_tOid oid;
} sCreateObject;
void wa_ldhtest::CreateObject(void)
{
sCreateObject d[] = {
{"Test", "", pwr_cClass_PlantHier, LDH__SUCCESS, pwr_cNOid},
{"H1", "Test", pwr_cClass_PlantHier, LDH__SUCCESS, pwr_cNOid},
{"H2", "Test", pwr_cClass_PlantHier, LDH__SUCCESS, pwr_cNOid},
{"H3", "Test", pwr_cClass_PlantHier, LDH__SUCCESS, pwr_cNOid},
{"", "Test-H3", pwr_cClass_PlantHier, LDH__SUCCESS, pwr_cNOid},
{"LongName90123456789012345678901", "Test-H3", pwr_cClass_PlantHier, LDH__SUCCESS, pwr_cNOid},
{"TooLongName234567890123456789012", "Test-H3", pwr_cClass_PlantHier, LDH__BADNAME, pwr_cNOid},
{"Invalid#Name", "Test-H3", pwr_cClass_PlantHier, LDH__BADNAME, pwr_cNOid}
};
pwr_tOid dest;
pwr_tOName oname, name;
int size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
if (strcmp(d[i].dest, "") != 0) {
strcpy(name, d[i].dest);
strcat(name, "-");
strcat(name, d[i].name);
m_sts = ldh_NameToObjid(m_ldhses, &dest, d[i].dest);
if (EVEN(m_sts)) {
m_log->log('E', "CreateObject, destination ldh_NameToObjid", d[i].name, m_sts);
return;
}
}
else {
strcpy(name, d[i].name);
dest.oix = 0;
dest.vid = m_vid;
}
m_sts = ldh_CreateObject(m_ldhses, &d[i].oid, d[i].name, d[i].cid, dest,
ldh_eDest_IntoLast);
if (m_sts != d[i].sts) {
m_log->log('E', "CreateObject", d[i].name, m_sts);
return;
}
if (ODD(m_sts)) {
m_sts = ldh_ObjidToName(m_ldhses, d[i].oid, ldh_eName_Hierarchy, oname, sizeof(oname), &size);
if (EVEN(m_sts)) {
m_log->log('E', "CreateObject ldh_ObjidToName", d[i].name, m_sts);
return;
}
if (strcmp(oname, name) != 0) {
m_log->vlog('E', "CreateObject, wrong object %s != %s, idx %d", name, oname, i);
return;
}
m_sts = check_object(d[i].oid);
if (EVEN(m_sts)) {
m_log->log('E', "CreateObject, check object", d[i].name, m_sts);
return;
}
}
if (i == 0)
m_test = d[i].oid;
else if (i == 1)
m_test_h1 = d[i].oid;
else if (i == 2)
m_test_h2 = d[i].oid;
}
m_sts = ldh_DeleteObjectTree(m_ldhses, d[3].oid, 0);
if (EVEN(m_sts)) {
m_log->log('E', "CreateObject, ldh_DeleteObjectTree", "", m_sts);
return;
}
m_log->log('S', "CreateObject", LDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
pwr_tOName dest;
pwr_tCid cid;
pwr_tStatus sts;
pwr_tOid oid;
} sDeleteObject;
void wa_ldhtest::DeleteObject(void)
{
sDeleteObject d[] = {
{"Del1", "Test-H2", pwr_cClass_PlantHier, LDH__SUCCESS, pwr_cNOid},
{"Del2", "Test-H2", pwr_cClass_AArray100, LDH__SUCCESS, pwr_cNOid},
{"Del3", "Test-H2", pwr_cClass_Pwrt02_Roller, LDH__SUCCESS, pwr_cNOid},
{"Del4", "Test-H2", pwr_cClass_Pwrt02_Motor, LDH__SUCCESS, pwr_cNOid},
{"Del5", "Test-H2", pwr_cClass_Pwrt02_Component, LDH__SUCCESS, pwr_cNOid}
};
pwr_tOName name;
pwr_tOid dest;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
if (strcmp(d[i].dest, "") != 0) {
strcpy(name, d[i].dest);
strcat(name, "-");
strcat(name, d[i].name);
m_sts = ldh_NameToObjid(m_ldhses, &dest, d[i].dest);
if (EVEN(m_sts)) {
m_log->log('E', "DeleteObject, destination ldh_NameToObjid", d[i].dest, m_sts);
return;
}
}
else {
strcpy(name, d[i].name);
dest.oix = 0;
dest.vid = m_vid;
}
m_sts = ldh_CreateObject(m_ldhses, &d[i].oid, d[i].name, d[i].cid, dest,
ldh_eDest_IntoLast);
if (m_sts != d[i].sts) {
m_log->log('E', "DeleteObject, ldh_CreateObject", d[i].name, m_sts);
return;
}
}
for (int i = (int)sizeof(d)/sizeof(d[0]) - 1; i >= 0 ; i--) {
m_sts = ldh_DeleteObject(m_ldhses, d[i].oid);
if (EVEN(m_sts)) {
m_log->log('E', "DeleteObject", m_sts);
return;
}
}
// Try to delete an nonexisting object
pwr_tOid oid;
oid.oix = 0xffffffff;
oid.vid = m_vid;
m_sts = ldh_DeleteObject(m_ldhses, oid);
if (ODD(m_sts)) {
m_log->log('E', "DeleteObject returned noexisting object");
return;
}
else if (m_sts != LDH__NOSUCHOBJ) {
m_log->log('E', "DeleteObject wrong sts", m_sts);
return;
}
m_log->log('S', "DeleteObject", LDH__SUCCESS);
}
void wa_ldhtest::DeleteObjectTree(void)
{
pwr_tOName name;
pwr_tAName cname;
pwr_tOid oid, coid;
// First create and then delete an object.
strcpy(name, "TestObject");
m_sts = ldh_CreateObject(m_ldhses, &oid, name, pwr_cClass_AArray100, m_test,
ldh_eDest_IntoLast);
if (EVEN(m_sts)) {
m_log->log('E', "DeleteObjectTree, error in ldh_CreateObject", m_sts);
return;
}
for (int i = 0; i < 10; i++) {
sprintf(cname, "ch%d", i);
m_sts = ldh_CreateObject(m_ldhses, &coid, cname, pwr_cClass_AArray100, oid,
ldh_eDest_IntoLast);
if (EVEN(m_sts)) {
m_log->log('E', "DeleteObjectTree, error in ldh_CreateObject", m_sts);
return;
}
}
m_sts = ldh_DeleteObjectTree(m_ldhses, oid, 0);
if (EVEN(m_sts)) {
m_log->log('E', "DeleteObject", m_sts);
return;
}
// Try to delete an nonexisting object
oid.oix = 0xffffffff;
oid.vid = m_vid;
m_sts = ldh_DeleteObjectTree(m_ldhses, oid, 0);
if (ODD(m_sts)) {
m_log->log('E', "DeleteObjectTree returned noexisting object");
return;
}
else if (m_sts != LDH__NOSUCHOBJ) {
m_log->log('E', "DeleteObjectTree wrong sts", m_sts);
return;
}
m_log->log('S', "DeleteObjectTree", LDH__SUCCESS);
}
void wa_ldhtest::ChangeObjectName(void)
{
pwr_tOName name;
pwr_tOid oid, oid2;
// First create and then rename an object.
strcpy(name, "TestObject");
m_sts = ldh_CreateObject(m_ldhses, &oid, name, pwr_cClass_AArray100, m_test,
ldh_eDest_IntoLast);
if (EVEN(m_sts)) {
m_log->log('E', "RenameObject, error in ldh_CreateObject", m_sts);
return;
}
m_sts = ldh_ChangeObjectName(m_ldhses, oid, (char *)"NewName");
if (EVEN(m_sts)) {
m_log->log('E', "ChangeObjectName", m_sts);
return;
}
m_sts = ldh_NameToObjid(m_ldhses, &oid, "Test-NewName");
if (EVEN(m_sts)) {
m_log->log('E', "ChangeObjectName, object not found", m_sts);
return;
}
// Try to rename an nonexisting object
oid2.oix = 0xffffffff;
oid2.vid = m_vid;
m_sts = ldh_ChangeObjectName(m_ldhses, oid2, (char *)"NewName2");
if (ODD(m_sts)) {
m_log->log('E', "ChangeObjectName returned noexisting object");
return;
}
else if (m_sts != LDH__NOSUCHOBJ) {
m_log->log('E', "ChangeObjectName wrong sts", m_sts);
return;
}
m_sts = ldh_DeleteObjectTree(m_ldhses, oid, 0);
m_log->log('S', "ChangeObjectName", LDH__SUCCESS);
}
void wa_ldhtest::MoveObject(void)
{
pwr_tOName name;
pwr_tAName cname;
pwr_tOid oid, oid2, p1, p2, c[100];
// First create and then move an object.
strcpy(name, "TestObject");
m_sts = ldh_CreateObject(m_ldhses, &oid, name, pwr_cClass_AArray100, m_test_h1,
ldh_eDest_IntoLast);
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject, error in ldh_CreateObject", m_sts);
return;
}
m_sts = ldh_MoveObject(m_ldhses, oid, m_test_h2, ldh_eDest_IntoLast);
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject", m_sts);
return;
}
m_sts = ldh_NameToObjid(m_ldhses, &oid, "Test-H2-TestObject");
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject object not found", m_sts);
return;
}
m_sts = check_object(oid);
// Try to move an nonexisting object
oid2.oix = 0xffffffff;
oid2.vid = m_vid;
m_sts = ldh_MoveObject(m_ldhses, oid2, oid, ldh_eDest_IntoLast);
if (ODD(m_sts)) {
m_log->log('E', "MoveObject moved noexisting object");
return;
}
else if (m_sts != LDH__NOSUCHOBJ) {
m_log->log('E', "MoveObject wrong sts", m_sts);
return;
}
m_sts = ldh_DeleteObject(m_ldhses, oid);
// Move several objects
strcpy(name, "P1");
m_sts = ldh_CreateObject(m_ldhses, &p1, name, pwr_cClass_AArray100, m_test_h1,
ldh_eDest_IntoLast);
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject, error in ldh_CreateObject", m_sts);
return;
}
strcpy(name, "P2");
m_sts = ldh_CreateObject(m_ldhses, &p2, name, pwr_cClass_AArray100, m_test_h1,
ldh_eDest_IntoLast);
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject, error in ldh_CreateObject", m_sts);
return;
}
for (int i = 0; i < 100; i++) {
sprintf(cname, "c%d", i);
m_sts = ldh_CreateObject(m_ldhses, &c[i], cname, pwr_cClass_AArray100, p1,
ldh_eDest_IntoLast);
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject, error in ldh_CreateObject", m_sts);
return;
}
}
for (int i = 0; i < 100; i++) {
m_sts = ldh_MoveObject(m_ldhses, c[i], p2, ldh_eDest_IntoLast);
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject, error in ldh_MoveObject", m_sts);
return;
}
}
m_sts = check_object(p1);
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject, error in p1", m_sts);
return;
}
m_sts = check_object(p2);
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject, error in p2", m_sts);
return;
}
for (int i = 0; i < 100; i++) {
m_sts = check_object(c[i]);
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject, error in check_object", m_sts);
return;
}
}
m_sts = ldh_DeleteObjectTree(m_ldhses, p1, 0);
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject, error in DeleteObjectTree(p1)", m_sts);
return;
}
m_sts = ldh_DeleteObjectTree(m_ldhses, p2, 0);
if (EVEN(m_sts)) {
m_log->log('E', "MoveObject, error in DeleteObjectTree(p2)", m_sts);
return;
}
m_log->log('S', "MoveObject", LDH__SUCCESS);
}
void wa_ldhtest::GetRootList(void)
{
pwr_tOName name;
int size;
m_sts = ldh_GetRootList(m_ldhses, &m_root);
if (EVEN(m_sts)) {
m_log->log('E', "GetRootList", m_sts);
return;
}
m_sts = ldh_ObjidToName(m_ldhses, m_root, ldh_eName_Hierarchy, name, sizeof(name), &size);
if (EVEN(m_sts)) {
m_log->log('E', "GetRootList", "ObjidToName failed", m_sts);
return;
}
if (strcmp(name, "RootObject") != 0) {
m_log->log('E', "GetRootList", "Wrong root object");
return;
}
m_log->log('S', "GetRootList", LDH__SUCCESS);
}
typedef struct {
pwr_tOName pname;
pwr_tObjName cname;
pwr_tCid cid;
pwr_tStatus sts;
int create;
pwr_tOid poid;
pwr_tOid coid;
} sGetChild;
void wa_ldhtest::GetChild(void)
{
sGetChild d[] = {
{"RootObject", "Child1", pwr_cClass_PlantHier, LDH__SUCCESS, 0, pwr_cNOid, pwr_cNOid},
{"RootObject-ChildLess", "", pwr_cClass_PlantHier, LDH__NO_CHILD, 0, pwr_cNOid, pwr_cNOid},
{"ChTest", "Ch1", pwr_cClass_PlantHier, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1", "Ch2", pwr_cClass_AArray100, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1-Ch2", "Ch3", pwr_cClass_AArray100, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1-Ch2-Ch3", "Ch4", pwr_cClass_AArray100, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1-Ch2-Ch3-Ch4", "Ch5", pwr_cClass_AArray100, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1-Ch2-Ch3-Ch4-Ch5", "Ch6", pwr_cClass_AArray100, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1-Ch2-Ch3-Ch4-Ch5-Ch6", "Ch7", pwr_cClass_AArray100, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1-Ch2-Ch3-Ch4-Ch5-Ch6-Ch7", "Ch8", pwr_cClass_AArray100, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1-Ch2-Ch3-Ch4-Ch5-Ch6-Ch7-Ch8", "Ch9", pwr_cClass_AArray100, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1-Ch2-Ch3-Ch4-Ch5-Ch6-Ch7-Ch8-Ch9", "Ch10", pwr_cClass_AArray100, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1-Ch2-Ch3-Ch4-Ch5-Ch6-Ch7-Ch8-Ch9-Ch10", "Ch11", pwr_cClass_AArray100, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1-Ch2-Ch3-Ch4-Ch5-Ch6-Ch7-Ch8-Ch9-Ch10-Ch11", "Ch12", pwr_cClass_AArray100, LDH__SUCCESS, 1, pwr_cNOid, pwr_cNOid},
{"ChTest-Ch1-Ch2-Ch3-Ch4-Ch5-Ch6-Ch7-Ch8-Ch9-Ch10-Ch11-Ch12", "", pwr_cClass_AArray100, LDH__NO_CHILD, 0, pwr_cNOid, pwr_cNOid}
};
pwr_tAName cname;
pwr_tOid coid, poid, oid;
oid.oix = 0;
oid.vid = m_vid;
m_sts = ldh_CreateObject(m_ldhses, &poid, "ChTest", pwr_cClass_PlantHier, oid,
ldh_eDest_IntoLast);
if (EVEN(m_sts)) {
m_log->log('E', "GetChild, ldh_CreateObject ChTest", m_sts);
return;
}
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &d[i].poid, d[i].pname);
if (EVEN(m_sts)) {
m_log->log('E', "GetChild, ldh_NameToObjid", d[i].pname, m_sts);
return;
}
sprintf(cname, "%s-%s", d[i].pname, d[i].cname);
if (d[i].create) {
m_sts = ldh_CreateObject(m_ldhses, &d[i].coid, cname, d[i].cid, d[i].poid,
ldh_eDest_IntoLast);
if (m_sts != d[i].sts) {
m_log->log('E', "GetChild, ldh_CreateObject", d[i].cname, m_sts);
return;
}
}
else if (strcmp(d[i].cname, "") != 0) {
m_sts = ldh_NameToObjid(m_ldhses, &d[i].coid, cname);
if (EVEN(m_sts)) {
m_log->log('E', "GetChild, ldh_NameToObjid", d[i].cname, m_sts);
return;
}
}
}
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_GetChild(m_ldhses ,d[i].poid, &coid);
if (m_sts != d[i].sts) {
m_log->vlog('E', "GetChild, wrong sts", d[i].pname, m_sts);
return;
}
if (ODD(m_sts)) {
if (cdh_ObjidIsNotEqual(coid, d[i].coid)) {
m_log->log('E', "GetChild, wrong object", d[i].cname);
return;
}
}
}
// Enter nonexisting parent
coid.oix = 0xffffffff;
coid.vid = m_vid;
m_sts = ldh_GetChild(m_ldhses, coid, &coid);
if (ODD(m_sts)) {
m_log->log('E', "GetChild returned noexisting object");
return;
}
else if (m_sts != LDH__NOSUCHOBJ) {
m_log->log('E', "GetChild wrong sts", m_sts);
return;
}
//m_child = d[0].coid;
m_sts = ldh_DeleteObjectTree(m_ldhses, poid, 0);
m_log->log('S', "GetChild", LDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
pwr_tStatus sts;
} sGetParent;
void wa_ldhtest::GetParent(void)
{
sGetParent d[] = {
{"RootObject", LDH__NO_PARENT},
{"RootObject-Child1", LDH__SUCCESS},
{"RootObject-ChildLess", LDH__SUCCESS}
};
pwr_tOName pname, name;
pwr_tOid coid, poid;
int size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &coid, d[i].name);
if (EVEN(m_sts)) {
m_log->log('E', "GetChild, gdh_NameToObjid", d[i].name, m_sts);
return;
}
m_sts = ldh_GetParent(m_ldhses, coid, &poid);
if (m_sts != d[i].sts) {
m_log->log('E', "GetParent, wrong sts", d[i].name, m_sts);
return;
}
if (ODD(m_sts)) {
m_sts = ldh_ObjidToName(m_ldhses, poid, ldh_eName_Hierarchy, pname, sizeof(pname), &size);
if (EVEN(m_sts)) {
m_log->log('E', "GetChild, ldh_ObjidToName", d[i].name, m_sts);
return;
}
strcpy(name, d[i].name);
char *s = strrchr(name, '-');
if (!s) {
m_log->log('E', "GetParent, erroneous name", d[i].name);
return;
}
*s = 0;
if (strcmp(name, pname) != 0) {
m_log->log('E', "GetParent, wrong object", d[i].name);
return;
}
}
}
// Enter nonexisting parent
poid.oix = 0xffffffff;
poid.vid = m_root.vid;
m_sts = ldh_GetParent(m_ldhses, poid, &poid);
if (ODD(m_sts)) {
m_log->log('E', "GetParent returned noexisting object");
return;
}
else if (m_sts != LDH__NOSUCHOBJ) {
m_log->log('E', "GetParent wrong sts", m_sts);
return;
}
m_log->log('S', "GetParent", LDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
pwr_tOName nextname;
pwr_tStatus sts;
} sGetNextSibling;
void wa_ldhtest::GetNextSibling(void)
{
sGetNextSibling d[] = {
{"RootObject-Child1", "RootObject-Child2", LDH__SUCCESS},
{"RootObject-Child2", "RootObject-Child3", LDH__SUCCESS},
{"RootObject-Child3", "RootObject-Child4", LDH__SUCCESS},
{"RootObject-Child4", "RootObject-ChildLess", LDH__SUCCESS},
{"RootObject-ChildLess", "", LDH__NO_SIBLING}
};
pwr_tOid oid, nextoid, noid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &oid, d[i].name);
if (EVEN(m_sts)) {
m_log->log('E', "GetNextSibling, ldh_NameToObjid", d[i].name, m_sts);
return;
}
m_sts = ldh_GetNextSibling(m_ldhses, oid, &nextoid);
if (m_sts != d[i].sts) {
m_log->log('E', "GetNextSibling, wrong sts", d[i].name, m_sts);
return;
}
if (ODD(m_sts)) {
m_sts = ldh_NameToObjid(m_ldhses, &noid, d[i].nextname);
if (EVEN(m_sts)) {
m_log->log('E', "GetNextSibling, ldh_NameToObjid", d[i].name, m_sts);
return;
}
if (cdh_ObjidIsNotEqual(noid, nextoid)) {
m_log->log('E', "GetNextSibling, wrong object", d[i].name);
return;
}
}
}
m_log->log('S', "GetNextSibling", LDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
pwr_tOName previousname;
pwr_tStatus sts;
} sGetPreviousSibling;
void wa_ldhtest::GetPreviousSibling(void)
{
sGetPreviousSibling d[] = {
{"RootObject-ChildLess", "RootObject-Child4", LDH__SUCCESS},
{"RootObject-Child4", "RootObject-Child3", LDH__SUCCESS},
{"RootObject-Child3", "RootObject-Child2", LDH__SUCCESS},
{"RootObject-Child2", "RootObject-Child1", LDH__SUCCESS},
{"RootObject-Child1", "", LDH__NOSUCHOBJ}
};
pwr_tOid oid, previousoid, poid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &oid, d[i].name);
if (EVEN(m_sts)) {
m_log->log('E', "GetPreviousSibling, ldh_NameToObjid", d[i].name, m_sts);
return;
}
m_sts = ldh_GetPreviousSibling(m_ldhses, oid, &previousoid);
if (m_sts != d[i].sts) {
m_log->log('E', "GetPreviousSibling, wrong sts", d[i].name, m_sts);
return;
}
if (ODD(m_sts)) {
m_sts = ldh_NameToObjid(m_ldhses, &poid, d[i].previousname);
if (EVEN(m_sts)) {
m_log->log('E', "GetPreviousSibling, ldh_NameToObjid", d[i].name, m_sts);
return;
}
if (cdh_ObjidIsNotEqual(poid, previousoid)) {
m_log->log('E', "GetPreviousSibling, wrong object", d[i].name);
return;
}
}
}
m_log->log('S', "GetPreviousSibling", LDH__SUCCESS);
}
typedef struct {
pwr_tOName aname;
pwr_tOName result;
pwr_tStatus sts;
} sNameToAttrRef;
void wa_ldhtest::NameToAttrRef(void)
{
sNameToAttrRef d[] = {
{"RootObject-Child1.Photo", "RootObject-Child1.Photo", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped", "RootObject-Child1-P1.CircuitBreaker.NotTripped", LDH__SUCCESS},
{"RootObject-Child1-A1.Value", "RootObject-Child1-A1.Value", LDH__SUCCESS},
{"RootObject-Child1-A1.Value[99]", "RootObject-Child1-A1.Value[99]", LDH__SUCCESS}
};
pwr_tAttrRef aref;
char *aname2;
int size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToAttrRef(m_ldhses, d[i].aname, &aref);
if (m_sts != d[i].sts) {
m_log->log('E', "NameToAttrRef, wrong sts", d[i].aname, m_sts);
return;
}
if (ODD(m_sts)) {
m_sts = ldh_AttrRefToName(m_ldhses, &aref, cdh_mNName, &aname2, &size);
if (EVEN(m_sts)) {
m_log->log('E', "NameToAttrRef, ldh_AttrRefToName", d[i].aname, m_sts);
return;
}
if (strcmp(aname2, d[i].result) != 0) {
m_log->vlog('E', "NameToAttrRef, %s != %s, idx %d", aname2, d[i].result, i);
return;
}
}
}
m_log->log('S', "NameToAttrRef", LDH__SUCCESS);
}
typedef struct {
pwr_tOName aname;
int nametype;
pwr_tOName result;
pwr_tStatus sts;
} sAttrRefToName;
void wa_ldhtest::AttrRefToName(void)
{
sAttrRefToName d[] = {
{"RootObject-Child1.Photo", cdh_mNName, "RootObject-Child1.Photo", LDH__SUCCESS},
{"RootObject-Child1.Photo", cdh_mName_object, "Child1", LDH__SUCCESS},
{"RootObject-Child1.Photo", cdh_mName_attribute, ".Photo", LDH__SUCCESS},
{"RootObject-Child1.Photo", cdh_mName_object | cdh_mName_attribute, "Child1.Photo", LDH__SUCCESS},
{"RootObject-Child1.Photo", cdh_mName_volumeStrict, "VolPwrtest02:RootObject-Child1.Photo", LDH__SUCCESS},
{"RootObject-Child1.Photo", cdh_mName_pathStrict, "RootObject-Child1.Photo", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped", cdh_mNName, "RootObject-Child1-P1.CircuitBreaker.NotTripped", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped", cdh_mName_object, "P1", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped", cdh_mName_attribute, ".CircuitBreaker.NotTripped", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped", cdh_mName_object | cdh_mName_attribute, "P1.CircuitBreaker.NotTripped", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped", cdh_mName_volumeStrict, "VolPwrtest02:RootObject-Child1-P1.CircuitBreaker.NotTripped", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped", cdh_mName_pathStrict, "RootObject-Child1-P1.CircuitBreaker.NotTripped", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped.Photo", cdh_mNName, "RootObject-Child1-P1.CircuitBreaker.NotTripped.Photo", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped.Photo", cdh_mName_object, "P1", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped.Photo", cdh_mName_attribute, ".CircuitBreaker.NotTripped.Photo", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped.Photo", cdh_mName_volumeStrict, "VolPwrtest02:RootObject-Child1-P1.CircuitBreaker.NotTripped.Photo", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped.Photo", cdh_mName_pathStrict, "RootObject-Child1-P1.CircuitBreaker.NotTripped.Photo", LDH__SUCCESS},
{"RootObject-Child1-A1.Value", cdh_mNName, "RootObject-Child1-A1.Value", LDH__SUCCESS},
{"RootObject-Child1-A1.Value", cdh_mName_object, "A1", LDH__SUCCESS},
{"RootObject-Child1-A1.Value", cdh_mName_attribute, ".Value", LDH__SUCCESS},
{"RootObject-Child1-A1.Value", cdh_mName_volumeStrict, "VolPwrtest02:RootObject-Child1-A1.Value", LDH__SUCCESS},
{"RootObject-Child1-A1.Value", cdh_mName_pathStrict, "RootObject-Child1-A1.Value", LDH__SUCCESS},
{"RootObject-Child1-A1.Value[99]", cdh_mNName, "RootObject-Child1-A1.Value[99]", LDH__SUCCESS},
{"RootObject-Child1-A1.Value[99]", cdh_mName_object, "A1", LDH__SUCCESS},
{"RootObject-Child1-A1.Value[99]", cdh_mName_attribute, ".Value[99]", LDH__SUCCESS},
{"RootObject-Child1-A1.Value[99]", cdh_mName_object | cdh_mName_attribute | cdh_mName_index, "A1.Value[99]", LDH__SUCCESS},
{"RootObject-Child1-A1.Value[99]", cdh_mName_volumeStrict, "VolPwrtest02:RootObject-Child1-A1.Value[99]", LDH__SUCCESS},
{"RootObject-Child1-A1.Value[99]", cdh_mName_pathStrict, "RootObject-Child1-A1.Value[99]", LDH__SUCCESS}
};
pwr_tAttrRef aref;
char *aname2;
int size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToAttrRef(m_ldhses, d[i].aname, &aref);
if (EVEN(m_sts)) {
m_log->log('E', "AttrRefToName, ldh_NameToAttrRef", m_sts);
return;
}
m_sts = ldh_AttrRefToName(m_ldhses, &aref, d[i].nametype, &aname2, &size);
if (m_sts != d[i].sts) {
m_log->log('E', "AttrRefToName, wrong sts", d[i].aname, m_sts);
return;
}
if (ODD(m_sts)) {
if (strcmp(aname2, d[i].result) != 0) {
m_log->vlog('E', "AttrRefToName, %s != %s, idx %d", aname2, d[i].result, i);
return;
}
}
}
m_log->log('S', "AttrRefToName", LDH__SUCCESS);
}
typedef struct {
pwr_tOName aname;
pwr_tOName oname;
pwr_tStatus sts;
} sAttrArefToObjectAref;
void wa_ldhtest::AttrArefToObjectAref(void)
{
sAttrArefToObjectAref d[] = {
{"RootObject-Child1.Photo", "RootObject-Child1", LDH__SUCCESS},
{"RootObject-Child1-A1.Value[99]", "RootObject-Child1-A1", LDH__SUCCESS},
{"RootObject-Child1-P1.CircuitBreaker.NotTripped", "RootObject-Child1-P1.CircuitBreaker", LDH__SUCCESS}
};
pwr_tAttrRef aref, oaref;
char *aname;
int size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToAttrRef(m_ldhses, d[i].aname, &aref);
if (EVEN(m_sts)) {
m_log->log('E', "AttrArefToObjectAref", "ldh_NameToAttrRef", m_sts);
return;
}
m_sts = ldh_AttrArefToObjectAref(m_ldhses, &aref, &oaref);
if (m_sts != d[i].sts) {
m_log->log('E', "AttrArefToObjetAref, wrong sts", d[i].aname, m_sts);
return;
}
if (ODD(m_sts)) {
m_sts = ldh_AttrRefToName(m_ldhses, &oaref, cdh_mName_pathStrict, &aname, &size);
if (EVEN(m_sts)) {
m_log->log('E', "AttrArefToObjectAref, ldh_AttrRefToName", m_sts);
return;
}
if (strcmp(aname, d[i].oname) != 0) {
m_log->vlog('E', "AttrArefToObjectAref wrong name, %s != %s", aname, d[i].oname);
return;
}
}
}
m_log->log('S', "AttrArefToObjectAref", LDH__SUCCESS);
}
typedef struct {
pwr_tCid cid;
pwr_tOName name;
pwr_tStatus sts;
} sGetClassList;
void wa_ldhtest::GetClassList(void)
{
sGetClassList d[] = {
{pwr_cClass_Node, "Nodes-Pwrtest02", LDH__SUCCESS},
{pwr_cClass_Security, "Nodes-Pwrtest02-Security", LDH__SUCCESS},
{pwr_cClass_OpPlace, "Nodes-Pwrtest02-OpPlaces-Op", LDH__SUCCESS},
{pwr_cClass_plc, "PlcTest-H1-Plc", LDH__SUCCESS},
{pwr_cClass_and, "PlcTest-H1-Plc-W-And0", LDH__SUCCESS},
{pwr_cClass_Dv, "Test02-First-Dv1", LDH__SUCCESS},
{pwr_cClass_Component, "", LDH__NOSUCHOBJ}
};
pwr_tOid oid;
pwr_tOName oname;
int size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_GetClassList(m_ldhses, d[i].cid, &oid);
if (m_sts != d[i].sts) {
m_log->log('E', "GetClassList", d[i].name, m_sts);
return;
}
if (ODD(m_sts)) {
m_sts = ldh_ObjidToName(m_ldhses, oid, ldh_eName_Hierarchy, oname, sizeof(oname), &size);
if (EVEN(m_sts)) {
m_log->log('E', "GetClassList ldh_ObjidToName", d[i].name, m_sts);
return;
}
if (strcmp(oname, d[i].name) != 0) {
m_log->vlog('E', "GetClassList, wrong object, %s != %s", d[i].name, oname);
return;
}
}
}
m_log->log('S', "GetClassList", LDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
pwr_tOName next;
pwr_tStatus sts;
} sGetNextObject;
void wa_ldhtest::GetNextObject(void)
{
sGetNextObject d[] = {
{"Test02-First-Dv1", "Test02-First-Dv2", LDH__SUCCESS},
{"Test02-First-Dv2", "Test02-First-Dv3", LDH__SUCCESS},
{"Test02-First-Dv3", "Test02-First-Dv4", LDH__SUCCESS},
{"Test02-First-Aggr1", "Test02-First-Aggr2", LDH__SUCCESS},
{"Test02-First-Aggr2", "Test02-First-Aggr3", LDH__SUCCESS},
{"Test02-First-Aggr3", "Test02-First-Aggr4", LDH__SUCCESS},
{"Test02-First-Aggr4", "", LDH__NOSUCHOBJ}
};
pwr_tOid oid, nextoid;
pwr_tOName nextname;
int size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &oid, d[i].name);
if (EVEN(m_sts)) {
m_log->log('E', "GetNextObject, ldh_NameToObjid", d[i].next, m_sts);
return;
}
m_sts = ldh_GetNextObject(m_ldhses, oid, &nextoid);
if (m_sts != d[i].sts) {
m_log->log('E', "GetNextObject", d[i].next, m_sts);
return;
}
if (ODD(m_sts)) {
m_sts = ldh_ObjidToName(m_ldhses, nextoid, ldh_eName_Hierarchy, nextname, sizeof(nextname), &size);
if (EVEN(m_sts)) {
m_log->log('E', "GetNextObject ldh_ObjidToName", d[i].next, m_sts);
return;
}
if (strcmp(nextname, d[i].next) != 0) {
m_log->vlog('E', "GetNextObject, wrong object, %s != %s", d[i].next, nextname);
return;
}
}
}
m_log->log('S', "GetNextObject", LDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
pwr_tOName previous;
pwr_tStatus sts;
} sGetPreviousObject;
#if 0
void wa_ldhtest::GetPreviousObject(void)
{
sGetPreviousObject d[] = {
{"Test02-First-Dv4", "Test02-First-Dv3", LDH__SUCCESS},
{"Test02-First-Dv3", "Test02-First-Dv2", LDH__SUCCESS},
{"Test02-First-Dv1", "", LDH__NOSUCHOBJ},
{"Test02-First-Aggr4", "Test02-First-Aggr3", LDH__SUCCESS},
{"Test02-First-Aggr3", "Test02-First-Aggr2", LDH__SUCCESS},
{"Test02-First-Aggr2", "Test02-First-Aggr1", LDH__SUCCESS},
{"Test02-First-Aggr1", "", LDH__NOSUCHOBJ}
};
pwr_tOid oid, previousoid;
pwr_tOName previousname;
int size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &oid, d[i].name);
if (EVEN(m_sts)) {
m_log->log('E', "GetPreviousObject, ldh_NameToObjid", d[i].previous, m_sts);
return;
}
m_sts = ldh_GetPreviousObject(m_ldhses, oid, &previousoid);
if (m_sts != d[i].sts) {
m_log->log('E', "GetPreviousObject", d[i].previous, m_sts);
return;
}
if (ODD(m_sts)) {
m_sts = ldh_ObjidToName(m_ldhses, previousoid, ldh_eName_Hierarchy, previousname, sizeof(previousname), &size);
if (EVEN(m_sts)) {
m_log->log('E', "GetPreviousObject ldh_ObjidToName", d[i].previous, m_sts);
return;
}
if (strcmp(previousname, d[i].previous) != 0) {
m_log->vlog('E', "GetPreviousObject, wrong object, %s != %s", d[i].previous, previousname);
return;
}
}
}
m_log->log('S', "GetPreviousObject", LDH__SUCCESS);
}
#endif
typedef struct {
pwr_tCid cid;
pwr_tOName name;
pwr_tOName next;
pwr_tStatus sts;
} sGetNextAttrRef;
void wa_ldhtest::GetNextAttrRef(void)
{
sGetNextAttrRef d[] = {
{pwr_cClass_Dv, "Test02-First-Dv1", "Test02-First-Dv2", LDH__SUCCESS},
{pwr_cClass_Dv, "Test02-First-Dv2", "Test02-First-Dv3", LDH__SUCCESS},
{pwr_cClass_Dv, "Test02-First-Dv3", "Test02-First-Dv4", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-Comp1", "Test02-First-C1.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-C1.Super", "Test02-First-M1.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-M1.Super", "Test02-First-M1.Contactor1.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-M1.Contactor1.Super", "Test02-First-R1.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Super", "Test02-First-R1.Motors[0].Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[0].Super", "Test02-First-R1.Motors[0].Contactor2.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[0].Contactor2.Super", "Test02-First-R1.Motors[1].Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[1].Super", "Test02-First-R1.Motors[1].Contactor1.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[1].Contactor1.Super", "Test02-First-R1.Motors[2].Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[2].Super", "Test02-First-R1.Motors[2].Contactor2.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[2].Contactor2.Super", "Test02-First-R1.Motors[3].Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[3].Super", "Test02-First-R1.Motors[3].Contactor1.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[3].Contactor1.Super", "Test02-First-R1.Motors[4].Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[4].Super", "Test02-First-R1.Motors[4].Contactor2.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[4].Contactor2.Super", "Test02-First-R1.Motors[5].Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[5].Super", "Test02-First-R1.Motors[5].Contactor1.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[5].Contactor1.Super", "Test02-First-R1.Motors[6].Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[6].Super", "Test02-First-R1.Motors[6].Contactor2.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[6].Contactor2.Super", "Test02-First-R1.Motors[7].Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[7].Super", "Test02-First-R1.Motors[7].Contactor1.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[7].Contactor1.Super", "Test02-First-R1.Motors[8].Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[8].Super", "Test02-First-R1.Motors[8].Contactor1.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[8].Contactor1.Super", "Test02-First-R1.Motors[9].Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[9].Super", "Test02-First-R1.Motors[9].Contactor2.Super", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Test02-First-R1.Motors[9].Contactor2.Super", "", LDH__NO_TYPE}
};
pwr_tAttrRef aref, nextaref;
char *nextname;
int size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToAttrRef(m_ldhses, d[i].name, &aref);
if (EVEN(m_sts)) {
m_log->log('E', "GetNextAttrRef, ldh_NameToAttrRef", d[i].next, m_sts);
return;
}
m_sts = ldh_GetNextAttrRef(m_ldhses, d[i].cid, &aref, &nextaref);
if (m_sts != d[i].sts && m_sts != TREE__FOUND) {
m_log->log('E', "GetNextAttrRef", d[i].next, m_sts);
return;
}
if (ODD(m_sts)) {
m_sts = ldh_AttrRefToName(m_ldhses, &nextaref, cdh_mNName, &nextname, &size);
if (EVEN(m_sts)) {
m_log->log('E', "GetNextAttrRef gdh_AttrrefToName", d[i].next, m_sts);
return;
}
if (strcmp(nextname, d[i].next) != 0) {
m_log->vlog('E', "GetNextAttrRef, wrong object, %s != %s", d[i].next, nextname);
return;
}
}
}
m_log->log('S', "GetNextAttrRef", LDH__SUCCESS);
}
typedef struct {
pwr_tCid cid;
pwr_tObjName cname;
pwr_tStatus sts;
} sClassNameToId;
void wa_ldhtest::ClassNameToId(void)
{
sClassNameToId d[] = {
{pwr_cClass_Node, "$Node", LDH__SUCCESS},
{pwr_cClass_Security, "$Security", LDH__SUCCESS},
{pwr_cClass_OpPlace, "OpPlace", LDH__SUCCESS},
{pwr_cClass_plc, "PlcPgm", LDH__SUCCESS},
{pwr_cClass_and, "And", LDH__SUCCESS},
{pwr_cClass_Dv, "Dv", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Pwrt02_Component", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Motor, "Pwrt02_Motor", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Roller, "Pwrt02_Roller", LDH__SUCCESS},
{pwr_cClass_Component, "NoValidClassName", LDH__NOCLASS}
};
pwr_tCid cid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_ClassNameToId(m_ldhses, &cid, d[i].cname);
if (m_sts != d[i].sts) {
m_log->log('E', "ClassNameToId", d[i].cname, m_sts);
return;
}
if (ODD(m_sts)) {
if (d[i].cid != cid) {
m_log->vlog('E', "ClassNameToId, wrong cid %s, %d != %d", d[i].cname, d[i].cid, cid);
return;
}
}
}
m_log->log('S', "ClassNameToId", LDH__SUCCESS);
}
typedef struct {
pwr_tCid cid;
pwr_tObjName cname;
pwr_tStatus sts;
} sClassIdToName;
void wa_ldhtest::ClassIdToName(void)
{
sClassIdToName d[] = {
{pwr_cClass_Node, "$Node", LDH__SUCCESS},
{pwr_cClass_Security, "$Security", LDH__SUCCESS},
{pwr_cClass_OpPlace, "OpPlace", LDH__SUCCESS},
{pwr_cClass_plc, "PlcPgm", LDH__SUCCESS},
{pwr_cClass_and, "And", LDH__SUCCESS},
{pwr_cClass_Dv, "Dv", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, "Pwrt02_Component", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Motor, "Pwrt02_Motor", LDH__SUCCESS},
{pwr_cClass_Pwrt02_Roller, "Pwrt02_Roller", LDH__SUCCESS},
{0, "NoValidClassName", LDH__NOCLASS}
};
pwr_tObjName cname;
int size;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_ClassIdToName(m_ldhses, d[i].cid, cname, sizeof(cname), &size);
if (m_sts != d[i].sts) {
m_log->vlog('E', "ClassIdToName, idx %d, sts %d", i, m_sts);
return;
}
if (ODD(m_sts)) {
if (strcmp(d[i].cname, cname) != 0) {
m_log->vlog('E', "ClassIdToName, wrong name, %s != %s", d[i].cname, cname);
return;
}
}
}
m_log->log('S', "ClassIdToName", LDH__SUCCESS);
}
typedef struct {
pwr_tCid cid;
pwr_tCid supercid;
pwr_tStatus sts;
} sGetSuperClass;
void wa_ldhtest::GetSuperClass(void)
{
sGetSuperClass d[] = {
{pwr_cClass_BasePumpAggr, pwr_cClass_BaseMotorAggr, LDH__SUCCESS},
{pwr_cClass_BaseMotorAggr, pwr_cClass_Aggregate, LDH__SUCCESS},
{pwr_cClass_Aggregate, 0, LDH__NOCLASS},
{pwr_cClass_BaseTempSensor, pwr_cClass_BaseSensor, LDH__SUCCESS},
{pwr_cClass_BaseSensor, pwr_cClass_Component, LDH__SUCCESS},
{pwr_cClass_Component, 0, LDH__NOCLASS},
{pwr_cClass_Pwrt02_Roller, pwr_cClass_Pwrt02_Component, LDH__SUCCESS},
{pwr_cClass_Pwrt02_Component, 0, LDH__NOCLASS},
{0xffffffff, 0, LDH__NOCLASS}
};
pwr_tCid supercid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_GetSuperClass(m_ldhses, d[i].cid, &supercid);
if (m_sts != d[i].sts) {
m_log->log('E', "GetSuperClass", m_sts);
return;
}
if (ODD(m_sts)) {
if (d[i].supercid != supercid) {
m_log->vlog('E', "GetSuperClass, wrong cid, idx %d", i);
return;
}
}
}
m_log->log('S', "GetSuperClass", LDH__SUCCESS);
}
typedef struct {
pwr_tOName tname;
pwr_tObjName name1;
pwr_tInt32 value1;
pwr_tObjName name2;
pwr_tInt32 value2;
pwr_tStatus sts;
} sGetEnumValueDef;
void wa_ldhtest::GetEnumValueDef(void)
{
sGetEnumValueDef d[] = {
{"pwrb:Type-YesNoEnum", "No", 0, "Yes", 1, LDH__SUCCESS},
{"pwrb:Type-ColorThemeEnum", "Standard", 0, "Custom", 100, LDH__SUCCESS},
{"CVolPwrtest02:Type-Pwrt02_MotorEnum", "Off", 0, "On", 1, LDH__SUCCESS}
};
pwr_tOid oid;
ldh_sValueDef *vd;
pwr_tTid tid;
int rows;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &oid, d[i].tname);
if (EVEN(m_sts)) {
m_log->log('E', "GetEnumValueDef", "ldh_NameToObjid", m_sts);
return;
}
tid = cdh_TypeObjidToId(oid);
m_sts = ldh_GetEnumValueDef(m_ldhses, tid, &vd, &rows);
if (m_sts != d[i].sts) {
m_log->log('E', "GetEnumValueDef", "wrong status", m_sts);
if (ODD(m_sts))
free(vd);
return;
}
if (ODD(m_sts)) {
if (strcmp(vd[0].Name, d[i].name1) != 0 ||
vd[0].Value.Value != d[i].value1 ||
strcmp(vd[rows-1].Name, d[i].name2) != 0 ||
vd[rows-1].Value.Value != d[i].value2) {
m_log->log('E', "GetEnumValueDef", "name of value doesn't match");
free(vd);
return;
}
free(vd);
}
}
m_log->log('S', "GetEnumValueDef", LDH__SUCCESS);
}
typedef struct {
pwr_tOName tname;
pwr_tObjName name1;
pwr_tUInt32 value1;
pwr_tObjName name2;
pwr_tUInt32 value2;
pwr_tStatus sts;
} sGetMaskBitDef;
void wa_ldhtest::GetMaskBitDef(void)
{
sGetMaskBitDef d[] = {
{"pwrb:Type-CardMask1_1", "Channel1", 1, "Channel16", 32768, LDH__SUCCESS},
{"pwrb:Type-CardMask2_1", "Channel17", 1, "Channel32", 32768, LDH__SUCCESS},
{"pwrb:Type-PidModeMask", "Manual", 1, "Cascade", 4, LDH__SUCCESS},
{"CVolPwrtest02:Type-Pwrt02_MotorMask", "Off", 1, "Running", 8, LDH__SUCCESS}
};
pwr_tOid oid;
ldh_sBitDef *bd;
pwr_tTid tid;
int rows;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &oid, d[i].tname);
if (EVEN(m_sts)) {
m_log->log('E', "GetMaskBitDef", "ldh_NameToObjid", m_sts);
return;
}
tid = cdh_TypeObjidToId(oid);
m_sts = ldh_GetMaskBitDef(m_ldhses, tid, &bd, &rows);
if (m_sts != d[i].sts) {
m_log->log('E', "GetMaskBitDef", "wrong status", m_sts);
if (ODD(m_sts))
free(bd);
return;
}
if (ODD(m_sts)) {
if (strcmp(bd[0].Name, d[i].name1) != 0 ||
bd[0].Bit->Value != d[i].value1 ||
strcmp(bd[rows-1].Name, d[i].name2) != 0 ||
bd[rows-1].Bit->Value != d[i].value2) {
m_log->log('E', "GetMaskBitDef", "name or value doesn't match");
free(bd);
return;
}
free(bd);
}
}
m_log->log('S', "GetMaskBitDef", LDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
pwr_tCid cid;
pwr_tStatus sts;
} sGetObjectClass;
void wa_ldhtest::GetObjectClass(void)
{
sGetObjectClass d[] = {
{"Test02-Ldh-A1", pwr_cClass_AArray100, LDH__SUCCESS},
{"Test02-Ldh-P1", pwr_cClass_BaseFcPPO3PumpAggr, LDH__SUCCESS},
{"Test02-Ldh-Av1", pwr_cClass_Av, LDH__SUCCESS},
{"Test02-Ldh-Dv1", pwr_cClass_Dv, LDH__SUCCESS},
{"VolPwrTest02:", pwr_cClass_RootVolume, LDH__SUCCESS},
{"Test02", pwr_cClass_PlantHier, LDH__SUCCESS}
};
pwr_tOid oid;
pwr_tCid cid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &oid, d[i].name);
if (EVEN(m_sts)) {
m_log->log('E', "GetObjectClass, ldh_NameToObjid", d[i].name, m_sts);
return;
}
m_sts = ldh_GetObjectClass(m_ldhses, oid, &cid);
if (m_sts != d[i].sts) {
m_log->log('E', "GetObjectClass", m_sts);
return;
}
if (ODD(m_sts)) {
if (d[i].cid != cid) {
m_log->vlog('E', "GetObjectClass, object class doesn't match, idx %d", i);
return;
}
}
}
m_log->log('S', "GetObjectClass", LDH__SUCCESS);
}
typedef struct {
pwr_tOName name;
pwr_tTid tid;
pwr_tOName tname;
pwr_tStatus sts;
} sGetAttrRefTid;
void wa_ldhtest::GetAttrRefTid(void)
{
sGetAttrRefTid d[] = {
{"Test02-Ldh-A1.Value", pwr_eType_Float32, "", LDH__SUCCESS},
{"Test02-Ldh-A1.Value[0]", pwr_eType_Float32, "", LDH__SUCCESS},
{"Test02.Description", 0, "pwrs:Type-$String80", LDH__SUCCESS},
{"Test02-Ldh-P1.CircuitBreaker.NotTripped.ActualValue", pwr_eType_Boolean, "", LDH__SUCCESS},
{"Test02-Ldh-Av1.ActualValue", pwr_eType_Float32, "", LDH__SUCCESS},
{"Test02-Ldh-Dv1.ActualValue", pwr_eType_Boolean, "", LDH__SUCCESS},
{"Test02-Ldh-A1", pwr_cClass_AArray100, "", LDH__SUCCESS},
{"Test02-Ldh-P1", pwr_cClass_BaseFcPPO3PumpAggr, "", LDH__SUCCESS},
{"Test02-Ldh-Av1", pwr_cClass_Av, "", LDH__SUCCESS},
{"Test02-Ldh-Dv1", pwr_cClass_Dv, "", LDH__SUCCESS},
{"VolPwrTest02:", pwr_cClass_RootVolume, "", LDH__SUCCESS},
{"Test02", pwr_cClass_PlantHier, "", LDH__SUCCESS}
};
pwr_tAttrRef aref;
pwr_tTid tid, dtid;
pwr_tOid toid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToAttrRef(m_ldhses, d[i].name, &aref);
if (EVEN(m_sts)) {
m_log->log('E', "GetAttrRefTid, ldh_NameToAttrref", d[i].name, m_sts);
return;
}
if (d[i].tid == 0) {
m_sts = ldh_NameToObjid(m_ldhses, &toid, d[i].tname);
if (EVEN(m_sts)) {
m_log->log('E', "GetAttrRefTid, ldh_NameToObjid", d[i].name, m_sts);
return;
}
dtid = cdh_TypeObjidToId(toid);
}
else
dtid = d[i].tid;
m_sts = ldh_GetAttrRefTid(m_ldhses, &aref, &tid);
if (m_sts != d[i].sts) {
m_log->log('E', "GetAttrRefTid", d[i].name, m_sts);
return;
}
if (ODD(m_sts)) {
if (dtid != tid) {
m_log->log('E', "GetAttrRefTid, tid doesn't match", d[i].name);
return;
}
}
}
m_log->log('S', "GetAttrRefTid", LDH__SUCCESS);
}
void wa_ldhtest::GetVolumeList(void)
{
pwr_tObjName name;
pwr_tVid vid;
int size;
m_sts = ldh_GetVolumeList(m_ldhwb, &vid);
if (EVEN(m_sts)) {
m_log->log('E', "GetVolumeList", m_sts);
return;
}
m_sts = ldh_VolumeIdToName(m_ldhwb, vid, name, sizeof(name), &size);
if (EVEN(m_sts)) {
m_log->log('E', "GetVolumeList, ldh_VolumeIdToName", m_sts);
return;
}
if (strcmp(name, "VolPwrtest02") != 0) {
m_log->log('E', "GetVolumeList, wrong volume", name);
return;
}
m_log->log('S', "GetVolumeList", LDH__SUCCESS);
}
typedef struct {
char vid[20];
char nextvid[20];
pwr_tStatus sts;
} sGetNextVolume;
void wa_ldhtest::GetNextVolume(void)
{
sGetNextVolume d[] = {
{"_V0.254.254.210", "_V0.0.0.1", LDH__SUCCESS},
{"_V0.0.0.1", "_V0.0.0.2", LDH__SUCCESS},
{"_V0.0.1.4", "_V0.0.240.210", LDH__SUCCESS},
{"_V1.254.254.203", "", LDH__NOSUCHVOL}
};
pwr_tVid vid, nextvid, nvid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToVolumeId(d[i].vid, &vid);
if (EVEN(m_sts)) {
m_log->log('E', "GetNextVolume, cdh_StringToVolumeId", d[i].vid, m_sts);
return;
}
if (strcmp(d[i].nextvid, "") != 0) {
m_sts = cdh_StringToVolumeId(d[i].nextvid, &nextvid);
if (EVEN(m_sts)) {
m_log->log('E', "GetNextVolume, cdh_StringToVolumeId", d[i].nextvid, m_sts);
return;
}
}
m_sts = ldh_GetNextVolume(m_ldhwb, vid, &nvid);
if (m_sts != d[i].sts) {
m_log->log('E', "GetNextVolume", d[i].vid, m_sts);
return;
}
if (ODD(m_sts)) {
if (nvid != nextvid) {
char nvid_str[40];
char nextvid_str[40];
m_log->vlog('E', "GetNextVolume, wrong volume %s != %s, idx %d",
cdh_VolumeIdToString(nvid_str, sizeof(nvid_str), nvid, 0, 0),
cdh_VolumeIdToString(nextvid_str, sizeof(nextvid_str), nextvid, 0, 0), i);
return;
}
}
}
m_log->log('S', "GetNextVolume", LDH__SUCCESS);
}
typedef struct {
pwr_tObjName name;
char vid[20];
pwr_tCid cid;
pwr_tStatus sts;
} sGetVolumeClass;
void wa_ldhtest::GetVolumeClass(void)
{
sGetVolumeClass d[] = {
{"VolPwrTest02", "_V0.254.254.210", pwr_eClass_RootVolume, LDH__SUCCESS},
{"rt", "_V254.254.254.245", pwr_eClass_SharedVolume, LDH__SUCCESS},
{"pwrs", "_V0.0.0.1", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"pwrb", "_V0.0.0.2", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"Simul", "_V0.0.0.8", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"BaseComponent", "_V0.0.0.10", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"NMps", "_V0.0.1.1", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"Profibus", "_V0.0.250.7", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"CVolPwrtest02", "_V0.0.240.210", pwr_eClass_ClassVolume, LDH__SUCCESS}
};
pwr_tVid vid;
pwr_tCid cid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToVolumeId(d[i].vid, &vid);
if (EVEN(m_sts)) {
m_log->log('E', "GetVolumeClass, cdh_StringToVolumeId", d[i].name, m_sts);
return;
}
m_sts = ldh_GetVolumeClass(m_ldhwb, vid, &cid);
if (m_sts != d[i].sts) {
m_log->log('E', "GetVolumeClass", d[i].vid, m_sts);
return;
}
if (ODD(m_sts)) {
if (d[i].cid != cid) {
m_log->vlog('E', "GetVolumeClass, class doesn't match %s, idx %d", d[i].name, i);
return;
}
}
}
m_log->log('S', "GetVolumeClass", LDH__SUCCESS);
}
typedef struct {
pwr_tObjName name;
char vid[20];
pwr_tCid cid;
pwr_tStatus sts;
} sGetVidInfo;
void wa_ldhtest::GetVidInfo(void)
{
sGetVidInfo d[] = {
{"VolPwrTest02", "_V0.254.254.210", pwr_eClass_RootVolume, LDH__SUCCESS},
{"rt", "_V254.254.254.245", pwr_eClass_SharedVolume, LDH__SUCCESS},
{"pwrs", "_V0.0.0.1", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"pwrb", "_V0.0.0.2", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"Simul", "_V0.0.0.8", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"BaseComponent", "_V0.0.0.10", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"NMps", "_V0.0.1.1", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"Profibus", "_V0.0.250.7", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"CVolPwrtest02", "_V0.0.240.210", pwr_eClass_ClassVolume, LDH__SUCCESS}
};
pwr_tVid vid;
ldh_sVolumeInfo info;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToVolumeId(d[i].vid, &vid);
if (EVEN(m_sts)) {
m_log->log('E', "GetVidInfo, cdh_StringToVolumeId", d[i].name, m_sts);
return;
}
m_sts = ldh_GetVidInfo(m_ldhwb, vid, &info);
if (m_sts != d[i].sts) {
m_log->log('E', "GetVidInfo", d[i].vid, m_sts);
return;
}
if (ODD(m_sts)) {
if (vid != info.Volume ||
d[i].cid != info.Class) {
m_log->log('E', "GetVidInfo, data doesn't match", d[i].name);
return;
}
}
}
m_log->log('S', "GetVidInfo", LDH__SUCCESS);
}
void wa_ldhtest::GetVolumeInfo(void)
{
ldh_sVolumeInfo info;
m_sts = ldh_GetVolumeInfo(m_volctx, &info);
if (EVEN(m_sts)) {
m_log->log('E', "GetVolumeInfo", m_sts);
return;
}
if (info.Volume != m_vid ||
info.Class != pwr_eClass_RootVolume) {
m_log->log('E', "GetVolumeInfo, data doesn't match");
return;
}
m_log->log('S', "GetVolumeInfo", LDH__SUCCESS);
}
void wa_ldhtest::Close(void)
{
m_sts = ldh_DetachVolume(m_ldhwb, m_volctx);
if (EVEN(m_sts)) {
m_log->log('F', "Close, ldh_DetachVolume", m_sts);
exit(0);
}
m_sts = ldh_CloseSession(m_ldhses);
if (EVEN(m_sts)) {
m_log->log('F', "Close, ldh_CloseSession", m_sts);
exit(0);
}
m_log->log('S', "Close", LDH__SUCCESS);
}
typedef struct {
pwr_tObjName name;
char vid[20];
pwr_tCid cid;
pwr_tStatus sts;
} sAttachVolume;
void wa_ldhtest::AttachVolume(void)
{
sAttachVolume d[] = {
{"VolPwrTest02", "_V0.254.254.210", pwr_eClass_RootVolume, LDH__SUCCESS},
{"rt", "_V254.254.254.245", pwr_eClass_SharedVolume, LDH__SUCCESS},
{"pwrs", "_V0.0.0.1", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"pwrb", "_V0.0.0.2", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"Simul", "_V0.0.0.8", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"BaseComponent", "_V0.0.0.10", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"NMps", "_V0.0.1.1", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"Profibus", "_V0.0.250.7", pwr_eClass_ClassVolume, LDH__SUCCESS},
{"CVolPwrtest02", "_V0.0.240.210", pwr_eClass_ClassVolume, LDH__SUCCESS}
};
pwr_tVid vid;
ldh_tVolContext volctx;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToVolumeId(d[i].vid, &vid);
if (EVEN(m_sts)) {
m_log->log('E', "AttachVolume, cdh_StringToVolumeId", d[i].name, m_sts);
return;
}
m_sts = ldh_AttachVolume(m_ldhwb, vid, &volctx);
if (m_sts != d[i].sts) {
m_log->log('E', "AttachVolume", d[i].vid, m_sts);
return;
}
if (ODD(m_sts)) {
m_sts = ldh_DetachVolume(m_ldhwb, volctx);
if (EVEN(m_sts)) {
m_log->log('E', "AttachVolume, ldh_DetachVolume", d[i].vid, m_sts);
return;
}
}
}
m_log->log('S', "AttachVolume", LDH__SUCCESS);
}
void wa_ldhtest::OpenWB(void)
{
m_sts = ldh_OpenWB(&m_ldhwb, m_vname, 0);
if (EVEN(m_sts)) {
m_log->log('F', "Init, ldh_OpenWB", m_sts);
delete this;
exit(0);
}
m_log->log('S', "OpenWB", LDH__SUCCESS);
}
typedef struct {
ldh_eAccess access;
ldh_eUtility utility;
} sOpenSession;
void wa_ldhtest::OpenSession(void)
{
sOpenSession d[] = {
{ldh_eAccess_ReadWrite, ldh_eUtility_Pwr},
{ldh_eAccess_ReadOnly, ldh_eUtility_Pwr},
{ldh_eAccess_SharedReadWrite, ldh_eUtility_Pwr}
};
pwr_tVid vid;
ldh_tVolContext volctx;
ldh_tSession ldhses;
char vidstr[20] = "_V0.254.254.210";
m_sts = cdh_StringToVolumeId(vidstr, &vid);
if (EVEN(m_sts)) {
m_log->log('E', "OpenSession, cdh_StringToVolumeId", m_sts);
return;
}
m_sts = ldh_AttachVolume(m_ldhwb, vid, &volctx);
if (EVEN(m_sts)) {
m_log->log('E', "OpenSession, ldh_AttachVolume", m_sts);
return;
}
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_OpenSession(&ldhses, volctx, d[i].access, d[i].utility);
if (EVEN(m_sts)) {
m_log->log('E', "OpenSession, ldh_AttachVolume", m_sts);
return;
}
m_sts = ldh_CloseSession(ldhses);
if (EVEN(m_sts)) {
m_log->log('E', "OpenSession, ldh_CloseSession", m_sts);
return;
}
}
m_sts = ldh_DetachVolume(m_ldhwb, volctx);
if (EVEN(m_sts)) {
m_log->log('E', "OpenSession, ldh_DetachVolume", m_sts);
return;
}
m_log->log('S', "OpenSession", LDH__SUCCESS);
}
typedef struct {
pwr_tOName src;
pwr_tOName dest;
ldh_eDest dtype;
pwr_tObjName name;
pwr_tStatus sts;
pwr_tOid oid;
} sCopyObject;
void wa_ldhtest::CopyObject(void)
{
sCopyObject d[] = {
{"Test02-First", "Test02-First", ldh_eDest_IntoLast, "Tmp", LDH__SUCCESS},
{"Test02-First-Dv1", "Test02-First-Tmp", ldh_eDest_IntoFirst, "Dv1", LDH__SUCCESS},
{"Test02-First-Dv2", "Test02-First-Tmp", ldh_eDest_IntoLast, "Dv2", LDH__SUCCESS},
{"Test02-First-Aggr1", "Test02-First-Tmp", ldh_eDest_IntoLast, "Aggr1", LDH__SUCCESS},
{"Test02-First-Aggr2", "Test02-First-Tmp", ldh_eDest_IntoLast, "Aggr2", LDH__SUCCESS},
{"Test02-First-R1", "Test02-First-Tmp", ldh_eDest_IntoLast, "R1", LDH__SUCCESS},
{"Test02-First-C1", "Test02-First-Tmp", ldh_eDest_IntoLast, "C1", LDH__SUCCESS},
{"Test02-First-M1", "Test02-First-Tmp", ldh_eDest_IntoLast, "M1", LDH__SUCCESS}
};
pwr_tOid soid, doid;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &soid, d[i].src);
if (EVEN(m_sts)) {
m_log->log('E', "CopyObject, ldh_NameToObjid", d[i].src, m_sts);
return;
}
m_sts = ldh_NameToObjid(m_ldhses, &doid, d[i].dest);
if (EVEN(m_sts)) {
m_log->log('E', "CopyObject, ldh_NameToObjid", d[i].dest, m_sts);
return;
}
m_sts = ldh_CopyObject(m_ldhses, &d[i].oid, d[i].name, soid, doid, d[i].dtype);
if (EVEN(m_sts)) {
m_log->log('E', "CopyObject", m_sts);
return;
}
m_sts = check_object(d[i].oid);
if (EVEN(m_sts)) {
m_log->log('E', "CopyObject, error in check_object", m_sts);
return;
}
}
m_sts = ldh_DeleteObjectTree(m_ldhses, d[0].oid, 0);
if (EVEN(m_sts)) {
m_log->log('E', "CopyObject, error in DeleteObjectTree", m_sts);
return;
}
m_log->log('S', "CopyObject", LDH__SUCCESS);
}
typedef struct {
pwr_tOName src;
pwr_tOName dest;
ldh_eDest dtype;
pwr_tOid oid;
pwr_tStatus sts;
} sCopyObjectTrees;
void wa_ldhtest::CopyObjectTrees(void)
{
sCopyObjectTrees d[] = {
{"Test02-First", "Test02-Ldh", ldh_eDest_IntoLast, LDH__SUCCESS},
{"Test02-First", "Test02-Ldh", ldh_eDest_IntoFirst, LDH__SUCCESS},
{"Test02-First", "Test02-Ldh-P1", ldh_eDest_After, LDH__SUCCESS},
{"Test02-First", "Test02-Ldh-P1", ldh_eDest_Before, LDH__SUCCESS}
};
pwr_tAttrRef saref[2];
pwr_tOid soid, doid;
pwr_tObjName sname;
pwr_tOName dname;
char *s;
memset(saref, 0, sizeof(saref));
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToObjid(m_ldhses, &soid, d[i].src);
if (EVEN(m_sts)) {
m_log->log('E', "CopyObject, src ldh_NameToObjid", d[i].src, m_sts);
return;
}
saref[0] = cdh_ObjidToAref(soid);
m_sts = ldh_NameToObjid(m_ldhses, &doid, d[i].dest);
if (EVEN(m_sts)) {
m_log->log('E', "CopyObjectTrees, dest ldh_NameToObjid", d[i].dest, m_sts);
return;
}
m_sts = ldh_CopyObjectTrees(m_ldhses, saref, doid, d[i].dtype, 0, 1, 0, 0);
if (EVEN(m_sts)) {
m_log->log('E', "CopyObjectTrees", m_sts);
return;
}
cdh_CutNameSegments(sname, d[i].src, 1);
strcpy(dname, d[i].dest);
switch (d[i].dtype) {
case ldh_eDest_IntoFirst:
case ldh_eDest_IntoLast:
break;
case ldh_eDest_After:
case ldh_eDest_Before:
s = strrchr(dname, '-');
if (s)
*s = 0;
break;
default:
;
}
strcat(dname, "-");
strcat(dname, sname);
m_sts = ldh_NameToObjid(m_ldhses, &d[i].oid, dname);
if (EVEN(m_sts)) {
m_log->log('E', "CopyObjectTrees, tree ldh_NameToObjid", m_sts);
return;
}
m_sts = ldh_DeleteObjectTree(m_ldhses, d[i].oid, 0);
if (EVEN(m_sts)) {
m_log->log('E', "CopyObjectTrees, error in DeleteObjectTree", m_sts);
return;
}
}
m_log->log('S', "CopyObjectTrees", LDH__SUCCESS);
}
typedef struct {
pwr_tObjName name;
char vidstr[20];
pwr_tCid vclass;
ldh_eVolRep volrep;
pwr_tStatus sts;
} sCreateVolume;
void wa_ldhtest::CreateVolume(void)
{
sCreateVolume d[] = {
{"CVolTest1", "_V0.0.44.44", pwr_eClass_ClassVolume, ldh_eVolRep_Wbl, LDH__NOSUCHVOL} // Error status for not configured volume?
};
pwr_tVid vid;
ldh_tSession ldhses;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = cdh_StringToVolumeId(d[i].vidstr, &vid);
if (EVEN(m_sts)) {
m_log->log('E', "CreateVolume, cdh_StringToVolumeId", d[i].name, m_sts);
return;
}
m_sts = ldh_CreateVolume(m_ldhwb, &ldhses, vid, d[i].name, d[i].vclass,
d[i].volrep, 0);
if (m_sts != d[i].sts) {
m_log->log('E', "CreateVolume", m_sts);
return;
}
m_sts = ldh_DeleteVolume(m_ldhwb, vid); // Does nothing
if (EVEN(m_sts)) {
m_log->log('E', "CreateVolume, ldh_DeleteVolume", m_sts);
return;
}
}
m_log->log('S', "CreateVolume", LDH__SUCCESS);
}
typedef struct {
pwr_tOName aname;
int valtype;
int ival;
float fval;
pwr_tString80 sval;
pwr_tStatus sts;
} sGetObjectPar;
void wa_ldhtest::GetObjectPar(void)
{
sGetObjectPar d[] = {
{"Test02-Pwrwb-Av1.InitialValue", 2, 0, 22.22, "", LDH__SUCCESS},
{"Test02-Pwrwb-Dv1.InitialValue", 1, 0, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Dv2.InitialValue", 1, 1, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-L1.Value.InitialValue", 2, 0, 33.33, "", LDH__SUCCESS},
{"Test02-Pwrwb-L1.LimitHH.Limit", 2, 0, 94, "", LDH__SUCCESS},
{"Test02-Pwrwb-L1.Description", 3, 0, 0, "BaseLevelSensor used for python tests", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Boolean", 1, 1, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Int8", 1, 22, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Int16", 1, 333, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Int32", 1, 4444, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Int64", 1, 55555, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.UInt8", 1, 66, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.UInt16", 1, 777, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.UInt32", 1, 8888, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.UInt64", 1, 99999, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Float32", 2, 0, 22.22, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Float64", 2, 0, 4444.4444, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.String80", 3, 0, 0, "Why don't you have wings to fly with?", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Time", 3, 0, 0, "15-MAY-2020 08:27:50.50", LDH__SUCCESS},
{"Test02-Pwrwb-Values.DeltaTime", 3, 0, 0, "27 8:27:50.05", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Objid", 3, 0, 0, "VolPwrtest02:Test02-Pwrwb-Values", LDH__SUCCESS},
{"Test02-Pwrwb-Values.AttrRef", 3, 0, 0, "VolPwrtest02:Test02-Pwrwb-Values.AttrRef", LDH__SUCCESS},
{"Test02-Pwrwb-Values.BooleanArray[4]", 1, 1, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Int8Array[4]", 1, 22, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Int16Array[4]", 1, 333, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Int32Array[4]", 1, 4444, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Int64Array[4]", 1, 55555, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.UInt8Array[4]", 1, 66, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.UInt16Array[4]", 1, 777, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.UInt32Array[4]", 1, 8888, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.UInt64Array[4]", 1, 99999, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Float32Array[4]", 2, 0, 22.22, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.Float64Array[4]", 2, 0, 4444.4444, "", LDH__SUCCESS},
{"Test02-Pwrwb-Values.String80Array[4]", 3, 0, 0, "Why don't you have wings to fly with?", LDH__SUCCESS},
{"Test02-Pwrwb-Values.TimeArray[4]", 3, 0, 0, "15-MAY-2020 08:27:50.50", LDH__SUCCESS},
{"Test02-Pwrwb-Values.DeltaTimeArray[4]", 3, 0, 0, "27 8:27:50.05", LDH__SUCCESS},
{"Test02-Pwrwb-Values.ObjidArray[4]", 3, 0, 0, "VolPwrtest02:Test02-Pwrwb-Values", LDH__SUCCESS},
{"Test02-Pwrwb-Values.AttrRefArray[4]", 3, 0, 0, "VolPwrtest02:Test02-Pwrwb-Values.AttrRefArray[4]", LDH__SUCCESS}
};
pwr_tAttrRef aref;
pwr_tTid tid;
char *buff;
int size;
char *s;
int index = 0;
int offs;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToAttrRef(m_ldhses, d[i].aname, &aref);
if (EVEN(m_sts)) {
m_log->log('E', "GetObjectPar, ldh_NameToAttrRef", d[i].aname, m_sts);
return;
}
m_sts = ldh_GetAttrRefTid(m_ldhses, &aref, &tid);
if (EVEN(m_sts)) {
m_log->log('E', "GetObjectPar, ldh_GetAttrRefTid", d[i].aname, m_sts);
return;
}
s = strchr(d[i].aname, '.');
m_sts = ldh_GetObjectPar(m_ldhses, aref.Objid, "RtBody", s+1, &buff, &size);
if (EVEN(m_sts)) {
m_log->log('E', "GetObjectPar", d[i].aname, m_sts);
return;
}
if (d[i].aname[strlen(d[i].aname)-1] == ']') {
s = strrchr(d[i].aname, '[');
if (s)
sscanf(s+1, "%d", &index);
}
switch (d[i].valtype) {
case 1:
switch (tid) {
case pwr_eType_Boolean: {
offs = index * sizeof(pwr_tBoolean);
if ((pwr_tBoolean)d[i].ival != *(pwr_tBoolean *)(buff+offs)) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %d != %d", d[i].aname, d[i].ival, *(pwr_tBoolean *)(buff+offs));
return;
}
break;
}
case pwr_eType_Int8: {
offs = index * sizeof(pwr_tInt8);
if ((pwr_tInt8)d[i].ival != *(pwr_tInt8 *)(buff+offs)) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %d != %d", d[i].aname, d[i].ival, *(pwr_tInt8 *)(buff+offs));
return;
}
break;
}
case pwr_eType_Int16: {
offs = index * sizeof(pwr_tInt16);
if ((pwr_tInt16)d[i].ival != *(pwr_tInt16 *)(buff+offs)) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %d != %d", d[i].aname, d[i].ival, *(pwr_tInt16 *)(buff+offs));
return;
}
break;
}
case pwr_eType_Int32: {
offs = index * sizeof(pwr_tInt32);
if ((pwr_tInt32)d[i].ival != *(pwr_tInt32 *)(buff+offs)) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %d != %d", d[i].aname, d[i].ival, *(pwr_tInt32 *)(buff+offs));
return;
}
break;
}
case pwr_eType_Int64: {
offs = index * sizeof(pwr_tInt64);
if ((pwr_tInt64)d[i].ival != *(pwr_tInt64 *)(buff+offs)) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %d != %d", d[i].aname, d[i].ival, *(pwr_tInt64 *)(buff+offs));
return;
}
break;
}
case pwr_eType_UInt8: {
offs = index * sizeof(pwr_tUInt8);
if ((pwr_tUInt8)d[i].ival != *(pwr_tUInt8 *)(buff+offs)) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %d != %d", d[i].aname, d[i].ival, *(pwr_tUInt8 *)(buff+offs));
return;
}
break;
}
case pwr_eType_UInt16: {
offs = index * sizeof(pwr_tUInt16);
if ((pwr_tUInt16)d[i].ival != *(pwr_tUInt16 *)(buff+offs)) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %d != %d", d[i].aname, d[i].ival, *(pwr_tUInt16 *)(buff+offs));
return;
}
break;
}
case pwr_eType_UInt32: {
offs = index * sizeof(pwr_tUInt32);
if ((pwr_tUInt32)d[i].ival != *(pwr_tUInt32 *)(buff+offs)) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %d != %d", d[i].aname, d[i].ival, *(pwr_tUInt32 *)(buff+offs));
return;
}
break;
}
case pwr_eType_UInt64: {
offs = index * sizeof(pwr_tUInt64);
if ((pwr_tUInt64)d[i].ival != *(pwr_tUInt64 *)(buff+offs)) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %d != %d", d[i].aname, d[i].ival, *(pwr_tUInt64 *)(buff+offs));
return;
}
break;
}
}
break;
case 2:
switch (tid) {
case pwr_eType_Float32: {
offs = index * sizeof(pwr_tFloat32);
if (fabs((pwr_tFloat32)d[i].fval - *(pwr_tFloat32 *)(buff+offs)) > FLT_EPSILON*1000) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %f != %f", d[i].aname, d[i].fval, *(pwr_tFloat32 *)(buff+offs));
return;
}
break;
}
case pwr_eType_Float64: {
offs = index * sizeof(pwr_tFloat64);
if (fabs((pwr_tFloat64)d[i].fval - *(pwr_tFloat64 *)(buff+offs)) > FLT_EPSILON*10000) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %f != %f", d[i].aname, d[i].fval, *(pwr_tFloat64 *)(buff+offs));
return;
}
break;
}
}
break;
case 3:
switch (tid) {
case pwr_eType_String: {
offs = index * sizeof(pwr_tFloat32);
if (strcmp(d[i].sval, (buff+offs)) != 0) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %s != %s", d[i].aname, d[i].sval, (buff+offs));
return;
}
break;
}
case pwr_eType_Time: {
char timstr[40];
offs = index * sizeof(pwr_tTime);
time_AtoAscii((pwr_tTime *)(buff+offs), time_eFormat_DateAndTime, timstr, sizeof(timstr));
if (strcmp(d[i].sval, timstr) != 0) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %s != %s", d[i].aname, d[i].sval, timstr);
return;
}
break;
}
case pwr_eType_DeltaTime: {
char timstr[40];
offs = index * sizeof(pwr_tTime);
time_DtoAscii((pwr_tDeltaTime *)(buff+offs), 1, timstr, sizeof(timstr));
if (strcmp(d[i].sval, timstr) != 0) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %s != %s", d[i].aname, d[i].sval, timstr);
return;
}
break;
}
case pwr_eType_Objid: {
pwr_tOName oname;
int size;
offs = index * sizeof(pwr_tOid);
m_sts = ldh_ObjidToName(m_ldhses, *(pwr_tOid *)(buff+offs), ldh_eName_VolPath, oname, sizeof(oname), &size);
if (strcmp(d[i].sval, oname) != 0) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %s != %s", d[i].aname, d[i].sval, oname);
return;
}
break;
}
case pwr_eType_AttrRef: {
char *aname;
int size;
offs = index * sizeof(pwr_tAttrRef);
m_sts = ldh_AttrRefToName(m_ldhses, (pwr_tAttrRef *)(buff+offs), cdh_mName_volumeStrict, &aname, &size);
if (strcmp(d[i].sval, aname) != 0) {
m_log->vlog('E', "GetObjectPar, %s, value doesn't match %s != %s", d[i].aname, d[i].sval, aname);
return;
}
break;
}
}
break;
}
free(buff);
}
m_log->log('S', "GetObjectPar", LDH__SUCCESS);
}
typedef struct {
pwr_tOName aname;
int valtype;
int ival;
float fval;
pwr_tString80 sval;
pwr_tStatus sts;
} sSetObjectPar;
void wa_ldhtest::SetObjectPar(void)
{
sSetObjectPar d[] = {
{"Test02-Pwrwb-SetValues.Boolean", 1, 1, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.Int8", 1, 22, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.Int16", 1, 333, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.Int32", 1, 4444, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.Int64", 1, 55555, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.UInt8", 1, 66, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.UInt16", 1, 777, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.UInt32", 1, 8888, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.UInt64", 1, 99999, 0, "", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.Float32", 2, 0, 22.22, "", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.Float64", 2, 0, 4444.4444, "", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.String80", 3, 0, 0, "Why don't you have wings to fly with?", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.Time", 3, 0, 0, "15-MAY-2020 08:27:50.50", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.DeltaTime", 3, 0, 0, "27 8:27:50.05", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.Objid", 3, 0, 0, "VolPwrtest02:Test02-Pwrwb-SetValues", LDH__SUCCESS},
{"Test02-Pwrwb-SetValues.AttrRef", 3, 0, 0, "VolPwrtest02:Test02-Pwrwb-SetValues.AttrRef", LDH__SUCCESS}
};
pwr_tAttrRef aref;
pwr_tTid tid;
char buff[80];
int size;
char *s;
for (unsigned int i = 0; i < sizeof(d)/sizeof(d[0]); i++) {
m_sts = ldh_NameToAttrRef(m_ldhses, d[i].aname, &aref);
if (EVEN(m_sts)) {
m_log->log('E', "SetObjectPar, ldh_NameToAttrRef", d[i].aname, m_sts);
return;
}
m_sts = ldh_GetAttrRefTid(m_ldhses, &aref, &tid);
if (EVEN(m_sts)) {
m_log->log('E', "SetObjectPar, ldh_GetAttrRefTid", d[i].aname, m_sts);
return;
}
switch (d[i].valtype) {
case 1:
switch (tid) {
case pwr_eType_Boolean: {
pwr_tBoolean val = (pwr_tBoolean)d[i].ival;
memcpy(buff, &val, sizeof(val));
size = sizeof(pwr_tBoolean);
break;
}
case pwr_eType_Int8: {
pwr_tInt8 val = (pwr_tInt8)d[i].ival;
memcpy(buff, &val, sizeof(val));
size = sizeof(pwr_tInt8);
break;
}
case pwr_eType_Int16: {
pwr_tInt16 val = (pwr_tInt16)d[i].ival;
memcpy(buff, &val, sizeof(val));
size = sizeof(pwr_tInt16);
break;
}
case pwr_eType_Int32: {
pwr_tInt32 val = (pwr_tInt32)d[i].ival;
memcpy(buff, &val, sizeof(val));
size = sizeof(pwr_tInt32);
break;
}
case pwr_eType_Int64: {
pwr_tInt64 val = (pwr_tInt64)d[i].ival;
memcpy(buff, &val, sizeof(val));
size = sizeof(pwr_tInt64);
break;
}
case pwr_eType_UInt8: {
pwr_tUInt8 val = (pwr_tUInt8)d[i].ival;
memcpy(buff, &val, sizeof(val));
size = sizeof(pwr_tUInt8);
break;
}
case pwr_eType_UInt16: {
pwr_tUInt16 val = (pwr_tUInt16)d[i].ival;
memcpy(buff, &val, sizeof(val));
size = sizeof(pwr_tUInt16);
break;
}
case pwr_eType_UInt32: {
pwr_tUInt32 val = (pwr_tUInt32)d[i].ival;
memcpy(buff, &val, sizeof(val));
size = sizeof(pwr_tUInt32);
break;
}
case pwr_eType_UInt64: {
pwr_tUInt64 val = (pwr_tUInt64)d[i].ival;
memcpy(buff, &val, sizeof(val));
size = sizeof(pwr_tUInt64);
break;
}
}
break;
case 2:
switch (tid) {
case pwr_eType_Float32: {
pwr_tFloat32 val = (pwr_tFloat32)d[i].fval;
memcpy(buff, &val, sizeof(val));
size = sizeof(pwr_tFloat32);
break;
}
case pwr_eType_Float64: {
pwr_tFloat64 val = (pwr_tFloat64)d[i].ival;
memcpy(buff, &val, sizeof(val));
size = sizeof(pwr_tFloat64);
break;
}
}
break;
case 3:
switch (tid) {
case pwr_eType_String: {
memcpy(buff, d[i].sval, sizeof(d[i].sval));
size = sizeof(pwr_tString80);
break;
}
case pwr_eType_Time: {
pwr_tTime time;
time_AsciiToA(d[i].sval, &time);
memcpy(buff, &time, sizeof(time));
size = sizeof(pwr_tTime);
break;
}
case pwr_eType_DeltaTime: {
pwr_tDeltaTime time;
time_AsciiToD(d[i].sval, &time);
memcpy(buff, &time, sizeof(time));
size = sizeof(pwr_tDeltaTime);
break;
}
case pwr_eType_Objid: {
pwr_tOid oid;
m_sts = ldh_NameToObjid(m_ldhses, &oid, d[i].sval);
memcpy(buff, &oid, sizeof(oid));
size = sizeof(pwr_tOid);
break;
}
case pwr_eType_AttrRef: {
pwr_tAttrRef aref;
m_sts = ldh_NameToAttrRef(m_ldhses, d[i].sval, &aref);
memcpy(buff, &aref, sizeof(aref));
size = sizeof(pwr_tAttrRef);
break;
}
}
break;
}
s = strchr(d[i].aname, '.');
m_sts = ldh_SetObjectPar(m_ldhses, aref.Objid, "RtBody", s+1, buff, size);
if (EVEN(m_sts)) {
m_log->log('E', "SetObjectPar", d[i].aname, m_sts);
return;
}
char *rbuff;
int rsize;
m_sts = ldh_GetObjectPar(m_ldhses, aref.Objid, "RtBody", s+1, &rbuff, &rsize);
if (EVEN(m_sts)) {
m_log->log('E', "SetObjectPar", d[i].aname, m_sts);
return;
}
if (memcmp(buff, rbuff, size) != 0) {
m_log->log('E', "SetObjectPar, value differs", d[i].aname, m_sts);
return;
}
free(rbuff);
}
m_log->log('S', "SetObjectPar", LDH__SUCCESS);
}
void wa_ldhtest::Init(void)
{
m_sts = ldh_VolumeNameToId(m_ldhwb, m_vname, &m_vid);
if (EVEN(m_sts)) {
m_log->log('F', "Init, ldh_VolumeNameToId", m_sts);
exit(0);
}
m_sts = ldh_AttachVolume(m_ldhwb, m_vid, &m_volctx);
if (EVEN(m_sts)) {
m_log->log('F', "Init, ldh_AttachVolume", m_sts);
exit(0);
}
m_sts = ldh_OpenSession(&m_ldhses, m_volctx, ldh_eAccess_ReadWrite, ldh_eUtility_Pwr);
if (EVEN(m_sts)) {
m_log->log('F', "Init, ldh_OpenSession", m_sts);
exit(0);
}
m_log->log('S', "Init", LDH__SUCCESS);
}
// Constructor
wa_ldhtest::wa_ldhtest()
{
strcpy(m_vname, "");
m_log = new tst_log(&m_sts, "wb_test-Ldh", "$pwrp_log/ldh.tlog");
if (EVEN(m_sts))
printf("** Unable to open log file");
}
// Destructor
wa_ldhtest::~wa_ldhtest()
{
ldh_DeleteObjectTree(m_ldhses, m_test, 0);
delete m_log;
}
int main(int argc, char *argv[])
{
wa_ldhtest ldh;
if (argc > 1)
ldh.vname(argv[1]);
setenv("TZ", "Europe/Stockholm", 1);
tzset();
ldh.OpenWB();
ldh.AttachVolume();
ldh.OpenSession();
ldh.Init();
ldh.ObjidToName();
ldh.CreateObject();
ldh.DeleteObject();
ldh.DeleteObjectTree();
ldh.ChangeObjectName();
ldh.MoveObject();
ldh.GetRootList();
ldh.GetChild();
ldh.GetParent();
ldh.GetNextSibling();
ldh.GetPreviousSibling();
ldh.NameToAttrRef();
ldh.AttrRefToName();
ldh.AttrArefToObjectAref();
ldh.GetClassList();
ldh.GetNextObject();
ldh.GetNextAttrRef();
ldh.ClassNameToId();
ldh.ClassIdToName();
ldh.GetSuperClass();
ldh.GetEnumValueDef();
ldh.GetMaskBitDef();
ldh.GetObjectClass();
ldh.GetAttrRefTid();
ldh.GetVolumeList();
ldh.GetNextVolume();
ldh.GetVolumeClass();
ldh.GetVidInfo();
ldh.GetVolumeInfo();
ldh.CopyObject();
ldh.CopyObjectTrees();
ldh.CreateVolume();
ldh.GetObjectPar();
ldh.SetObjectPar();
ldh.Close();
}
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "co_tst_log.h"
class wa_ldhtest {
pwr_tStatus m_sts;
ldh_tWorkbench m_ldhwb;
ldh_tSession m_ldhses;
ldh_tVolContext m_volctx;
pwr_tObjName m_vname;
pwr_tVid m_vid;
tst_log *m_log;
pwr_tOid m_test;
pwr_tOid m_test_h1;
pwr_tOid m_test_h2;
pwr_tOid m_root;
pwr_tStatus check_object(pwr_tOid oid);
public:
wa_ldhtest();
~wa_ldhtest();
void vname(char *n) {strncpy(m_vname, n, sizeof(m_vname));}
void Init();
void Close();
void ObjidToName();
void CreateObject();
void DeleteObject();
void DeleteObjectTree();
void ChangeObjectName();
void MoveObject();
void GetRootList();
void GetChild();
void GetParent();
void GetNextSibling();
void GetPreviousSibling();
void NameToAttrRef();
void AttrRefToName();
void AttrArefToObjectAref();
void GetClassList();
void GetNextObject();
void GetNextAttrRef();
void ClassNameToId();
void ClassIdToName();
void GetSuperClass();
void GetEnumValueDef();
void GetMaskBitDef();
void GetObjectClass();
void GetAttrRefTid();
void GetVolumeList();
void GetNextVolume();
void GetVolumeClass();
void GetVidInfo();
void GetVolumeInfo();
void AttachVolume();
void OpenWB();
void OpenSession();
void CopyObject();
void CopyObjectTrees();
void CreateVolume();
void GetObjectPar();
void SetObjectPar();
};
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
import sys
import math
import pwrwb
import pwrtest
class Ctx:
#
# Static pwrrt methods
#
#
# pwrwb.init()
#
def init(self):
try:
pwrwb.open('VolPwrtest02')
except RuntimeError as e:
self.logger.vlog('E', 'init, Unexpected exception %s', str(e))
raise e
self.logger.log('S', 'init, successfull completion')
#
# pwrwb.login()/logout()
#
def login(self):
d = (
('pwrp', 'no', 0, '%USER-E-NOTAUTHORIZED, user is not authorized'),
('no', 'pwrp', 0, '%USER-E-NOSUCHUSER, no such user'),
('pwrp', '', 0, '%USER-E-NOTAUTHORIZED, user is not authorized'),
('pwrp', 'pwrp', 167510022, '')
)
i = 0
for i in range(len(d)):
try:
pwrwb.login(d[i][0], d[i][1])
user = pwrwb.getUser()
priv = pwrwb.getPriv()
if user != d[i][0]:
self.logger.vlog('E', 'login, getUser, wrong user %s, %s',
user, d[i][1])
pwrwb.logout()
return
if priv != d[i][2]:
self.logger.vlog('E', 'login, getPriv, wrong priv %s, %s',
str(priv), str(d[i][2]))
pwrwb.logout()
return
pwrwb.logout()
except RuntimeError as e:
if str(e) != d[i][3]:
self.logger.vlog('E', 'login, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'login, successfull completion')
#
# pwrrt.volume()
#
def volume(self):
d = (
('pwrs', ''),
('pwrb', ''),
('VolPwrtest02', ''),
('CVolPwrtest02', ''),
('1_254_254_203', '%LDH-E-NOSUCHVOL, no such volume exists'),
('rt', ''),
('VolNoVolume', '%LDH-E-NOSUCHVOL, no such volume exists'),
)
i = 0
for i in range(len(d)):
try:
vol = pwrwb.volume(d[i][0])
if vol.name() != d[i][0]:
self.logger.vlog('E', "volume, Name doesn't match, %s != %s, idx %s",
vol.name(), d[i][0], str(i))
return
except RuntimeError as e:
if str(e) != d[i][1]:
self.logger.vlog('E', 'volume, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'volume, successfull completion')
#
# pwrwb.volumes()
#
def volumes(self):
d = ('VolPwrtest02', 'pwrs', 'pwrb', 'Simul', 'BaseComponent',
'NMps', 'Profibus', 'CVolPwrtest02')
vol = pwrwb.volumes()
try:
i = 0
for dv in d:
found = False
for v in vol:
if v.name() == dv:
found = True
if not found:
self.logger.vlog('E', "volumes, Volume not found, %s",
v.name())
return
i += 1
except RuntimeError as e:
self.logger.vlog('E', 'volumes, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'volumes, successfull completion')
#
# pwrwb.object()
#
def object(self):
d = (
('Test02-Pwrwb-Av1', 'VolPwrtest02:Test02-Pwrwb-Av1', ''),
('VolPwrTest02:Test02-Pwrwb-Av1', 'VolPwrtest02:Test02-Pwrwb-Av1', ''),
('Test02-Pwrwb-Dv1', 'VolPwrtest02:Test02-Pwrwb-Dv1', ''),
('Test02-Pwrwb-Dv2', 'VolPwrtest02:Test02-Pwrwb-Dv2', ''),
('Test02-Pwrwb-L1', 'VolPwrtest02:Test02-Pwrwb-L1', ''),
('Test02-Pwrwb', 'VolPwrtest02:Test02-Pwrwb', ''),
('Test02', 'VolPwrtest02:Test02', ''),
('Test02-Pwrwb-NoObject', '', '%LDH-E-NOSUCHOBJ, no such object exists'),
('VolPwrtest02:', 'VolPwrtest02:', '')
)
i = 0
for i in range(len(d)):
try:
o = pwrwb.object(d[i][0])
name = o.fullName()
if name != d[i][1]:
self.logger.vlog('E', "object, Name doesn't match, %s != %s, idx %s",
name, d[i][1], str(i))
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'object, Unexpected exception %s, idx %s',
str(e), str(i))
print 'Not correct error code'
return
self.logger.log('S', 'object, successfull completion')
#
# pwrwb.attribute()
#
def attribute(self):
d = (
('Test02-Pwrwb-Av1.InitialValue', 22.22, ''),
('Test02-Pwrwb-Av1.NoSuchAttr', 22.22, '%LDH-E-NOSUCHATTR, no such attribute exists'),
('Test02-Pwrwb-Dv1.InitialValue', 0, ''),
('Test02-Pwrwb-Dv2.InitialValue', 1, ''),
('Test02-Pwrwb-L1.Value.InitialValue', 33.33, ''),
('Test02-Pwrwb-L1.LimitHH.Limit', 94, ''),
('Test02-Pwrwb-L1.Description', 'BaseLevelSensor used for python tests', '')
)
i = 0
for i in range(len(d)):
try:
a = pwrwb.attribute(d[i][0])
value = a.value()
if type(value).__name__ == 'str':
if value != d[i][1]:
self.logger.vlog('E', "attribute, Value doesn't match, %s != %s, idx %s",
value, d[i][1], str(i))
return
else:
if not abs(value - d[i][1]) < 0.001:
self.logger.vlog('E', "attribute, Value doesn't match, %s != %s, idx %s",
str(value), str(d[i][1]), str(i))
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'attribute, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'attribute, successfull completion')
#
# pwrwb.getSessionVolume()
#
def getSessionVolume(self):
try:
v = pwrwb.getSessionVolume()
if v.name() != 'VolPwrtest02':
self.logger.vlog('E', "getSessionVolume, Volume doesn't match, %s",
v.name())
except RuntimeError as e:
self.logger.vlog('E', 'getSessionVolume, Unexpected exception %s', str(e))
return
self.logger.log('S', 'getSessionVolume, successfull completion')
#
# pwrwb.getUser()
#
def getUser(self):
try:
user = pwrwb.getUser()
if user != 'pwrp':
self.logger.vlog('E', "getUser, user doesn't match, %s", user)
except RuntimeError as e:
self.logger.vlog('E', 'getUser, Unexpected exception %s', str(e))
return
self.logger.log('S', 'getUser, successfull completion')
#
# pwrwb.sessionIsEmpty()
#
def sessionIsEmpty(self):
try:
empty = pwrwb.sessionIsEmpty()
if empty != 1:
self.logger.vlog('E', "sessionIsEmpty, wrong value %d", empty)
except RuntimeError as e:
self.logger.vlog('E', 'sessionIsEmpty, Unexpected exception %s', str(e))
return
self.logger.log('S', 'sessionIsEmpty, successfull completion')
#
# pwrwb.revertSession()
#
def revertSession(self):
d = (
('Test02-Pwrwb-Av1.InitialValue', 22.22, 44.44),
('Test02-Pwrwb-Dv1.InitialValue', 0, 1),
('Test02-Pwrwb-Dv2.InitialValue', 1, 0),
('Test02-Pwrwb-L1.Value.InitialValue', 33.33, 66.66),
('Test02-Pwrwb-L1.LimitHH.Limit', 94, 102),
('Test02-Pwrwb-L1.Description', 'BaseLevelSensor used for python tests', 'Some level sensor...')
)
i = 0
for i in range(len(d)):
try:
a = pwrwb.attribute(d[i][0])
a.setValue(d[i][2])
except RuntimeError as e:
self.logger.vlog('E', 'revertSession, Unexpected exception %s, idx %s',
str(e), str(i))
return
empty = pwrwb.sessionIsEmpty()
if empty != 0:
self.logger.vlog('E', "revertSession sessionIsEmpty, wrong value %d", empty)
pwrwb.revertSession()
empty = pwrwb.sessionIsEmpty()
if empty != 1:
self.logger.vlog('E', "revertSession sessionIsEmpty, wrong value %d", empty)
for i in range(len(d)):
try:
a = pwrwb.attribute(d[i][0])
value = a.value()
if type(value).__name__ == 'str':
if value != d[i][1]:
self.logger.vlog('E', "revertSession, Value doesn't match, %s != %s, idx %s",
value, d[i][1], str(i))
return
else:
if not abs(value - d[i][1]) < 0.001:
self.logger.vlog('E', "revertSession, Value doesn't match, %s != %s, idx %s",
str(value), str(d[i][1]), str(i))
return
except RuntimeError as e:
self.logger.vlog('E', 'revertSession, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'revertSession, successfull completion')
#
# Oid functions
#
#
# Oid()
#
def Oid(self):
d = (
('Test02-Pwrwb-Av1', 'VolPwrtest02:Test02-Pwrwb-Av1', ''),
('VolPwrtest02:Test02-Pwrwb-Av1', 'VolPwrtest02:Test02-Pwrwb-Av1', ''),
('Test02-Pwrwb-Dv1', 'VolPwrtest02:Test02-Pwrwb-Dv1', ''),
('Test02-Pwrwb-Dv2', 'VolPwrtest02:Test02-Pwrwb-Dv2', ''),
('Test02-Pwrwb-L1', 'VolPwrtest02:Test02-Pwrwb-L1', ''),
('Test02-Pwrwb', 'VolPwrtest02:Test02-Pwrwb', ''),
('Test02', 'VolPwrtest02:Test02', ''),
('Test02-Pwrwb-NoObject', '', '%LDH-E-NOSUCHOBJ, no such object exists'),
('VolPwrtest02:', 'VolPwrtest02:', '')
)
i = 0
for i in range(len(d)):
try:
o = pwrwb.Oid(d[i][0])
name = o.fullName()
if name != d[i][1]:
self.logger.vlog('E', "Oid, Name doesn't match, %s != %s, idx %s",
name, d[i][1], str(i))
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Oid, Unexpected exception %s, idx %s',
str(e), str(i))
print 'Not correct error code'
return
self.logger.log('S', 'Oid, successfull completion')
#
# Oid.child()
#
def Oid_child(self):
d = (
('RootObject', 'Child1'),
('RootObject-Child1', 'A1'),
('RootObject-Child1-A1', ''),
('RootObject-ChildLess','')
)
i = 0
for i in range(len(d)):
try:
o = pwrwb.object(d[i][0])
child = o.child()
if child is None:
if d[i][1] != '':
self.logger.vlog('E', 'Oid.child, child is missing, idx %s',
str(i))
else:
name = child.name()
if name != d[i][1]:
self.logger.vlog('E', "Oid.child, name doesn't match, %s != %s, idx %s",
name, d[i][1], str(i))
return
except RuntimeError as e:
self.logger.vlog('E', 'Oid.child, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Oid.child, successfull completion')
#
# Oid.next()
#
def Oid_next(self):
d = (
('RootObject-Child1', 'Child2'),
('RootObject-Child2', 'Child3'),
('RootObject-Child3', 'Child4'),
('RootObject-Child4', 'ChildLess'),
('RootObject-ChildLess', '')
)
i = 0
for i in range(len(d)):
try:
o = pwrwb.object(d[i][0])
next = o.next()
if next is None:
if d[i][1] != '':
self.logger.vlog('E', 'Oid.next, next is missing, idx %s',
str(i))
else:
name = next.name()
if name != d[i][1]:
self.logger.vlog('E', "Oid.next, name doesn't match, %s != %s, idx %s",
name, d[i][1], str(i))
return
except RuntimeError as e:
self.logger.vlog('E', 'Oid.next, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Oid.next, successfull completion')
#
# Oid.parent()
#
def Oid_parent(self):
d = (
('RootObject-Child1-A1', 'Child1', ''),
('RootObject-Child1', 'RootObject', ''),
('RootObject', '', ''),
('NoSuchObject', '', '%LDH-E-NOSUCHOBJ, no such object exists')
)
i = 0
for i in range(len(d)):
try:
o = pwrwb.object(d[i][0])
parent = o.parent()
if parent is None:
if d[i][1] != '':
self.logger.vlog('E', 'Oid.parent, parent is missing, idx %s',
str(i))
else:
name = parent.name()
if name != d[i][1]:
self.logger.vlog('E', "Oid.parent, name doesn't match, %s != %s, idx %s",
name, d[i][1], str(i))
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Oid.parent, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Oid.parent, successfull completion')
#
# Oid.children()
#
def Oid_children(self):
d = (
('RootObject', ('Child1','Child2','Child3','Child4','ChildLess'), ''),
('RootObject-Child1', ('A1','A2','P1'), ''),
('RootObject-ChildLess', (), '')
)
i = 0
for i in range(len(d)):
try:
o = pwrwb.object(d[i][0])
children = o.children()
j = 0
for c in children:
if c.name() != d[i][1][j]:
self.logger.vlog('E', "Oid.children, Name doesn't match, %s != %s",
c.name(), d[i][1][j])
return
j += 1
except RuntimeError as e:
self.logger.vlog('E', 'Oid.children, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Oid.children, successfull completion')
#
# Oid.name()
#
def Oid_name(self):
d = (
('RootObject', 'RootObject', ''),
('RootObject-Child1', 'Child1', ''),
('Test02-Ldh-LongName90123456789012345678901', 'LongName90123456789012345678901', ''),
('Test02-Ldh-', '', ''),
('Test02-Ldh-sdf*sdf', '', '%LDH-E-BADNAME, bad object name'),
('VolPwrtest02:', 'VolPwrtest02', '')
)
i = 0
for i in range(len(d)):
try:
o = pwrwb.object(d[i][0])
name = o.name()
if name != d[i][1]:
self.logger.vlog('E', "Oid.name, Name doesn't match, %s != %s",
name, d[i][1])
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Oid.name, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Oid.name, successfull completion')
#
# Oid.fullName()
#
def Oid_fullName(self):
d = (
('RootObject', 'VolPwrtest02:RootObject', ''),
('RootObject-Child1', 'VolPwrtest02:RootObject-Child1', ''),
('Test02-Ldh-LongName90123456789012345678901', 'VolPwrtest02:Test02-Ldh-LongName90123456789012345678901', ''),
('Test02-Ldh-', 'VolPwrtest02:Test02-Ldh-', ''),
('Test02-Ldh-sdf*sdf', '', '%LDH-E-BADNAME, bad object name'),
('VolPwrtest02:', 'VolPwrtest02:', '')
)
i = 0
for i in range(len(d)):
try:
o = pwrwb.object(d[i][0])
name = o.fullName()
if name != d[i][1]:
self.logger.vlog('E', "Oid.fullName, Name doesn't match, %s != %s",
name, d[i][1])
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Oid.fullName, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Oid.fullName, successfull completion')
#
# Oid.oidStr()
#
def Oid_oidStr(self):
d = (
('RootObject', '_O0.254.254.210:1', ''),
('RootObject-Child1', '_O0.254.254.210:2', ''),
('VolPwrTest02:', '_O0.254.254.210:0', ''),
('pwrb:Class-And', '_O0.0.0.2:2149842944', ''),
('pwrs:', '_O0.0.0.1:0', '')
)
i = 0
for i in range(len(d)):
try:
o = pwrwb.object(d[i][0])
name = o.oidStr()
if name != d[i][1]:
self.logger.vlog('E', "Oid.oidStr, Name doesn't match, %s != %s",
name, d[i][1])
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Oid.oidStr, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Oid.oidStr, successfull completion')
#
# Oid.attribute()
#
def Oid_attribute(self):
d = (
('RootObject', 'Description', 'RootObject.Description'),
('RootObject-Child1', 'Description', 'Child1.Description'),
('Test02-Pwrwb-Dv1', 'ActualValue', 'Dv1.ActualValue'),
('Test02-Pwrwb-L1', 'LimitLL', 'L1.LimitLL'),
('Test02-Pwrwb-L1', 'Value.ActualValue', 'L1.Value.ActualValue')
)
i = 0
for i in range(len(d)):
try:
o = pwrwb.object(d[i][0])
a = o.attribute(d[i][1])
if a.name() != d[i][2]:
self.logger.vlog('E', "Oid.attribute, "
"Name doesn't match, %s != %s",
a.name(), d[i][2])
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Oid.attribute, '
'Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Oid.attribute, successfull completion')
#
# Aref functions
#
#
# Aref()
#
def Aref(self):
d = (
('Test02-Pwrwb-Av1.InitialValue', 22.22, ''),
('Test02-Pwrwb-Av1.NoSuchAttr', 22.22, '%LDH-E-NOSUCHATTR, no such attribute exists'),
('Test02-Pwrwb-Dv1.InitialValue', 0, ''),
('Test02-Pwrwb-Dv2.InitialValue', 1, ''),
('Test02-Pwrwb-L1.Value.InitialValue', 33.33, ''),
('Test02-Pwrwb-L1.LimitHH.Limit', 94, ''),
('Test02-Pwrwb-L1.Description', 'BaseLevelSensor used for python tests', '')
)
i = 0
for i in range(len(d)):
try:
a = pwrwb.Aref(d[i][0])
value = a.value()
if type(value).__name__ == 'str':
if value != d[i][1]:
self.logger.vlog('E', "Aref, "
"Value doesn't match, %s != %s, idx %s",
value, d[i][1], str(i))
return
else:
if not abs(value - d[i][1]) < 0.001:
self.logger.vlog('E', "Aref, "
"Value doesn't match, %s != %s, idx %s",
str(value), str(d[i][1]), str(i))
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Aref, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Aref, successfull completion')
#
# Aref.name()
#
def Aref_name(self):
d = (
('RootObject.Description', 'RootObject.Description', ''),
('RootObject-Child1.DefGraph', 'Child1.DefGraph', ''),
('Test02-Ldh-LongName90123456789012345678901.InitialValue', 'LongName90123456789012345678901.InitialValue', ''),
('Test02-Ldh-.ValueIndex', '.ValueIndex', ''),
('Test02-Ldh-sdf*sdf', '', '%LDH-E-NOSUCHATTR, no such attribute exists')
)
i = 0
for i in range(len(d)):
try:
a = pwrwb.attribute(d[i][0])
name = a.name()
if name != d[i][1]:
self.logger.vlog('E', "Aref.name, Name doesn't match, %s != %s",
name, d[i][1])
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Aref.name, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Aref.name, successfull completion')
#
# Aref.fullName()
#
def Aref_fullName(self):
d = (
('RootObject.Description', 'VolPwrtest02:RootObject.Description', ''),
('RootObject-Child1.DefGraph', 'VolPwrtest02:RootObject-Child1.DefGraph', ''),
('Test02-Ldh-LongName90123456789012345678901.InitialValue', 'VolPwrtest02:Test02-Ldh-LongName90123456789012345678901.InitialValue', ''),
('Test02-Ldh-.ValueIndex', 'VolPwrtest02:Test02-Ldh-.ValueIndex', ''),
('Test02-Ldh-sdf*sdf', '', '%LDH-E-NOSUCHATTR, no such attribute exists')
)
i = 0
for i in range(len(d)):
try:
a = pwrwb.attribute(d[i][0])
name = a.fullName()
if name != d[i][1]:
self.logger.vlog('E', "Aref.fullName, "
"Name doesn't match, %s != %s",
name, d[i][1])
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Aref.fullName, '
'Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Aref.fullName, successfull completion')
#
# Aref.arefStr()
#
def Aref_arefStr(self):
d = (
('RootObject', '_A0.254.254.210:1(_T0.1:0.17.1)[0.656]', ''),
('RootObject-Child1', '_A0.254.254.210:2(_T0.1:0.17.1)[0.656]', ''),
('VolPwrTest02:', '_A0.254.254.210:0(_T0.1:0.47.1)[0.160]', ''),
('pwrb:Class-And', '_A0.0.0.2:2149842944(_T0.1:0.1.1)[0.24]', ''),
('pwrs:', '_A0.0.0.1:0(_T0.1:0.52.1)[0.208]', '')
)
i = 0
for i in range(len(d)):
try:
a = pwrwb.attribute(d[i][0])
name = a.arefStr()
if name != d[i][1]:
self.logger.vlog('E', "Aref.arefStr, "
"Name doesn't match, %s != %s",
name, d[i][1])
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Aref.arefStr, '
'Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Aref.arefStr, successfull completion')
#
# Aref.tid()
#
def Aref_tid(self):
d = (
('RootObject.Description', 'pwrs:Type-$String80', ''),
('RootObject-Child1.DefGraph', 'pwrs:Type-$AttrRef', ''),
('Test02-Pwrwb-Dv1.InitialValue', 'pwrs:Type-$Boolean', ''),
('Test02-Pwrwb-L1.Value', 'pwrb:Class-Ai', ''),
('Test02-Pwrwb-L1.Value.ActualValue', 'pwrs:Type-$Float32', ''),
('Test02-Pwrwb-Values.Boolean', 'pwrs:Type-$Boolean', ''),
('Test02-Pwrwb-Values.Int8', 'pwrs:Type-$Int8', ''),
('Test02-Pwrwb-Values.Int16', 'pwrs:Type-$Int16', ''),
('Test02-Pwrwb-Values.Int32', 'pwrs:Type-$Int32', ''),
('Test02-Pwrwb-Values.Int64', 'pwrs:Type-$Int64', ''),
('Test02-Pwrwb-Values.UInt8', 'pwrs:Type-$UInt8', ''),
('Test02-Pwrwb-Values.UInt16', 'pwrs:Type-$UInt16', ''),
('Test02-Pwrwb-Values.UInt32', 'pwrs:Type-$UInt32', ''),
('Test02-Pwrwb-Values.UInt64', 'pwrs:Type-$UInt64', ''),
('Test02-Pwrwb-Values.Float32', 'pwrs:Type-$Float32', ''),
('Test02-Pwrwb-Values.Float64', 'pwrs:Type-$Float64', ''),
('Test02-Pwrwb-Values.String80', 'pwrs:Type-$String80', ''),
('Test02-Pwrwb-Values.Time', 'pwrs:Type-$Time', ''),
('Test02-Pwrwb-Values.DeltaTime', 'pwrs:Type-$DeltaTime', ''),
('Test02-Pwrwb-Values.Objid', 'pwrs:Type-$Objid', ''),
('Test02-Pwrwb-Values.AttrRef', 'pwrs:Type-$AttrRef', '')
)
i = 0
for i in range(len(d)):
try:
a = pwrwb.attribute(d[i][0])
tid = a.tid()
if tid.fullName() != d[i][1]:
self.logger.vlog('E', "Aref.tid, "
"Name doesn't match, %s != %s",
tid.fullName(), d[i][1])
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Aref.tid, '
'Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Aref.tid, successfull completion')
#
# Aref.value()
#
def Aref_value(self):
d = (
('Test02-Pwrwb-Av1.InitialValue', 22.22, ''),
('Test02-Pwrwb-Av1.NoSuchAttr', 22.22, '%LDH-E-NOSUCHATTR, no such attribute exists'),
('Test02-Pwrwb-Dv1.InitialValue', 0, ''),
('Test02-Pwrwb-Dv2.InitialValue', 1, ''),
('Test02-Pwrwb-L1.Value.InitialValue', 33.33, ''),
('Test02-Pwrwb-L1.LimitHH.Limit', 94, ''),
('Test02-Pwrwb-L1.Description', 'BaseLevelSensor used for python tests', ''),
('Test02-Pwrwb-Values.Boolean', 1, ''),
('Test02-Pwrwb-Values.Int8', 22, ''),
('Test02-Pwrwb-Values.Int16', 333, ''),
('Test02-Pwrwb-Values.Int32', 4444, ''),
('Test02-Pwrwb-Values.Int64', 55555, ''),
('Test02-Pwrwb-Values.UInt8', 66, ''),
('Test02-Pwrwb-Values.UInt16', 777, ''),
('Test02-Pwrwb-Values.UInt32', 8888, ''),
('Test02-Pwrwb-Values.UInt64', 99999, ''),
('Test02-Pwrwb-Values.Float32', 22.22, ''),
('Test02-Pwrwb-Values.Float64', 4444.4444, ''),
('Test02-Pwrwb-Values.String80', "Why don't you have wings to fly with?", ''),
('Test02-Pwrwb-Values.Time', '15-MAY-2020 08:27:50.50', ''),
('Test02-Pwrwb-Values.DeltaTime', '27 8:27:50.05', ''),
('Test02-Pwrwb-Values.Objid', 'VolPwrtest02:Test02-Pwrwb-Values', ''),
('Test02-Pwrwb-Values.AttrRef', 'VolPwrtest02:Test02-Pwrwb-Values.AttrRef', ''),
('Test02-Pwrwb-Values.BooleanArray[4]', 1, ''),
('Test02-Pwrwb-Values.Int8Array[4]', 22, ''),
('Test02-Pwrwb-Values.Int16Array[4]', 333, ''),
('Test02-Pwrwb-Values.Int32Array[4]', 4444, ''),
('Test02-Pwrwb-Values.Int64Array[4]', 55555, ''),
('Test02-Pwrwb-Values.UInt8Array[4]', 66, ''),
('Test02-Pwrwb-Values.UInt16Array[4]', 777, ''),
('Test02-Pwrwb-Values.UInt32Array[4]', 8888, ''),
('Test02-Pwrwb-Values.UInt64Array[4]', 99999, ''),
('Test02-Pwrwb-Values.Float32Array[4]', 22.22, ''),
('Test02-Pwrwb-Values.Float64Array[4]', 4444.4444, ''),
('Test02-Pwrwb-Values.String80Array[4]', "Why don't you have wings to fly with?", ''),
('Test02-Pwrwb-Values.TimeArray[4]', '15-MAY-2020 08:27:50.50', ''),
('Test02-Pwrwb-Values.DeltaTimeArray[4]', '27 8:27:50.05', ''),
('Test02-Pwrwb-Values.ObjidArray[4]', 'VolPwrtest02:Test02-Pwrwb-Values', ''),
('Test02-Pwrwb-Values.AttrRefArray[4]', 'VolPwrtest02:Test02-Pwrwb-Values.AttrRefArray[4]', '')
)
i = 0
for i in range(len(d)):
try:
a = pwrwb.attribute(d[i][0])
value = a.value()
if type(value).__name__ == 'NoneType':
self.logger.vlog('E', "Aref.value, None value returned, idx %s",
str(i))
return
elif type(value).__name__ == 'str':
if value != d[i][1]:
self.logger.vlog('E', "Aref.value, "
"Value doesn't match, %s != %s, idx %s",
value, d[i][1], str(i))
return
elif type(value).__name__ == 'Oid' or type(value).__name__ == 'Aref' :
if value.fullName() != d[i][1]:
self.logger.vlog('E', "Aref.value, "
"Value doesn't match, %s != %s, idx %s",
value.fullName(), d[i][1], str(i))
return
else:
if not abs(value - d[i][1]) < 0.001:
self.logger.vlog('E', "Aref.value, "
"Value doesn't match, %s != %s, idx %s",
str(value), str(d[i][1]), str(i))
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'aref.value, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Aref.value, successfull completion')
#
# Aref.setValue()
#
def Aref_setValue(self):
d = (
('Test02-Pwrwb-SetValues.Boolean', 1, ''),
('Test02-Pwrwb-SetValues.Int8', 22, ''),
('Test02-Pwrwb-SetValues.Int16', 333, ''),
('Test02-Pwrwb-SetValues.Int32', 4444, ''),
('Test02-Pwrwb-SetValues.Int64', 55555, ''),
('Test02-Pwrwb-SetValues.UInt8', 66, ''),
('Test02-Pwrwb-SetValues.UInt16', 777, ''),
('Test02-Pwrwb-SetValues.UInt32', 8888, ''),
('Test02-Pwrwb-SetValues.UInt64', 99999, ''),
('Test02-Pwrwb-SetValues.Float32', 22.22, ''),
('Test02-Pwrwb-SetValues.Float64', 4444.4444, ''),
('Test02-Pwrwb-SetValues.String80', "Why don't you have wings to fly with?", ''),
('Test02-Pwrwb-SetValues.Time', '15-MAY-2020 08:27:50.50', ''),
('Test02-Pwrwb-SetValues.DeltaTime', '27 8:27:50.05', ''),
('Test02-Pwrwb-SetValues.Objid', pwrwb.Oid('VolPwrTest02:Test02-Pwrwb-SetValues'), ''),
('Test02-Pwrwb-SetValues.AttrRef', pwrwb.Aref('VolPwrTest02:Test02-Pwrwb-SetValues.AttrRef'), ''),
('Test02-Pwrwb-SetValues.BooleanArray[4]', 1, ''),
('Test02-Pwrwb-SetValues.Int8Array[4]', 22, ''),
('Test02-Pwrwb-SetValues.Int16Array[4]', 333, ''),
('Test02-Pwrwb-SetValues.Int32Array[4]', 4444, ''),
('Test02-Pwrwb-SetValues.Int64Array[4]', 55555, ''),
('Test02-Pwrwb-SetValues.UInt8Array[4]', 66, ''),
('Test02-Pwrwb-SetValues.UInt16Array[4]', 777, ''),
('Test02-Pwrwb-SetValues.UInt32Array[4]', 8888, ''),
('Test02-Pwrwb-SetValues.UInt64Array[4]', 99999, ''),
('Test02-Pwrwb-SetValues.Float32Array[4]', 22.22, ''),
('Test02-Pwrwb-SetValues.Float64Array[4]', 4444.4444, ''),
('Test02-Pwrwb-SetValues.String80Array[4]', "Why don't you have wings to fly with?", ''),
('Test02-Pwrwb-SetValues.TimeArray[4]', '15-MAY-2020 08:27:50.50', ''),
('Test02-Pwrwb-SetValues.DeltaTimeArray[4]', '27 8:27:50.05', ''),
('Test02-Pwrwb-SetValues.ObjidArray[4]', pwrwb.Oid('VolPwrTest02:Test02-Pwrwb-SetValues'), ''),
('Test02-Pwrwb-SetValues.AttrRefArray[4]', pwrwb.Aref('VolPwrTest02:Test02-Pwrwb-SetValues.AttrRefArray[4]'), '')
)
i = 0
for i in range(len(d)):
try:
a = pwrwb.attribute(d[i][0])
a.setValue(d[i][1])
value = a.value()
if type(value).__name__ == 'str':
if value != d[i][1]:
self.logger.vlog('E', "Aref.setValue, "
"Value doesn't match, %s != %s, idx %s",
value, d[i][1], str(i))
return
elif type(value).__name__ == 'Oid' or type(value).__name__ == 'Aref' :
if value.fullName() != d[i][1].fullName():
self.logger.vlog('E', "Aref.setValue, "
"Value doesn't match, %s != %s, idx %s",
value.fullName(), d[i][1], str(i))
return
else:
if not abs(value - d[i][1]) < 0.001:
self.logger.vlog('E', "Aref.setValue, "
"Value doesn't match, %s != %s, idx %s",
str(value), str(d[i][1]), str(i))
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Aref.setValue, '
'Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Aref.setValue, successfull completion')
#
# Cid functions
#
#
# Cid()
#
def Cid(self):
d = (
('Av', ''),
('$PlantHier', ''),
('$ClassDef', ''),
('$Attribute', ''),
('$ClassVolume', ''),
('Aggregate', ''),
('BaseLevelSensor', ''),
('Pwrt02_Values', ''),
('Pwrt02_Pump', '%LDH-E-NOCLASS, the class does not exist'),
('No', '%LDH-E-NOCLASS, the class does not exist')
)
i = 0
for i in range(len(d)):
try:
c = pwrwb.Cid(d[i][0])
name = c.name()
if name != d[i][0]:
self.logger.vlog('E', "Cid, Name doesn't match, %s != %s, idx %s",
name, d[i][0], str(i))
return
except RuntimeError as e:
if str(e) != d[i][1]:
print str(e), d[i][1]
self.logger.vlog('E', 'Cid, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Cid, successfull completion')
#
# Cid.fullName()
#
def Cid_fullName(self):
d = (
('Av', 'pwrb:Class-Av', ""),
('$PlantHier', 'pwrs:Class-$PlantHier', ''),
('$ClassDef', 'pwrs:Class-$ClassDef', ''),
('$Attribute', 'pwrs:Class-$Attribute', ''),
('$ClassVolume', 'pwrs:Class-$ClassVolume', ''),
('Aggregate', 'BaseComponent:Class-Aggregate', ''),
('BaseLevelSensor', 'BaseComponent:Class-BaseLevelSensor', ''),
('Pwrt02_Values', 'CVolPwrtest02:Class-Pwrt02_Values', ''),
('Pwrt02_Pump', 'CVolPwrtest02:Class-Pwrt02_Pump', '%LDH-E-NOCLASS, the class does not exist'),
('No', '', '%LDH-E-NOCLASS, the class does not exist')
)
i = 0
for i in range(len(d)):
try:
c = pwrwb.Cid(d[i][0])
name = c.fullName()
if name != d[i][1]:
self.logger.vlog('E', "Cid.fullName, Name doesn't match, %s != %s",
name, d[i][1])
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Cid.fullName, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Cid.fullName, successfull completion')
#
# Cid.object()
#
def Cid_object(self):
d = (
('MessageHandler', 'VolPwrtest02:Nodes-Pwrtest02-Servers-MessageHandler'),
('IOHandler', 'VolPwrtest02:Nodes-Pwrtest02-Servers-IOHandler'),
('$PlantHier', 'VolPwrtest02:RootObject'),
('AArray100', 'VolPwrtest02:RootObject-Child1-A1'),
('BaseFcPPO3PumpAggr', 'VolPwrtest02:RootObject-Child1-P1'),
('$WorkBenchVolume', 'None')
)
i = 0
for i in range(len(d)):
try:
c = pwrwb.Cid(d[i][0])
o = c.object()
if o is None:
if d[i][1] != 'None':
self.logger.vlog('E', "Cid.object, No instance should be found, %s",
d[i][0])
return
else:
name = o.fullName()
if name != d[i][1]:
self.logger.vlog('E', "Cid.object, Name doesn't match, %s != %s",
name, d[i][1])
return
except RuntimeError as e:
self.logger.vlog('E', 'Cid.object, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Cid.object, successfull completion')
#
# Cid.nextObject()
#
def Cid_nextObject(self):
d = (
('VolPwrtest02:Nodes-Pwrtest02-Servers-MessageHandler', 'None'),
('VolPwrtest02:Nodes-Pwrtest02-Servers-IOHandler', 'None'),
('VolPwrtest02:RootObject', 'VolPwrtest02:RootObject-Child1'),
('VolPwrtest02:RootObject-Child1', 'VolPwrtest02:RootObject-Child2'),
('VolPwrtest02:RootObject-Child2', 'VolPwrtest02:RootObject-Child3'),
('VolPwrtest02:RootObject-Child3', 'VolPwrtest02:RootObject-Child4'),
('VolPwrtest02:RootObject-Child4', 'VolPwrtest02:RootObject-ChildLess')
)
i = 0
for i in range(len(d)):
try:
o = pwrwb.Oid(d[i][0])
c = o.cid()
n = c.nextObject(o)
if n is None:
if d[i][1] != 'None':
self.logger.vlog('E', "Cid.nextObject, No instance should be found, %s",
d[i][0])
return
else:
name = n.fullName()
if name != d[i][1]:
self.logger.vlog('E', "Cid.nextObject, Name doesn't match, %s != %s",
name, d[i][1])
return
except RuntimeError as e:
self.logger.vlog('E', 'Cid.nextObject, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Cid.nextObject, successfull completion')
#
# Cid.objects()
#
def Cid_objects(self):
d = (
('$PlantHier', ('RootObject', 'Child1', 'Child2', 'Child3', 'Child4', 'ChildLess')),
('AArray100', ('A1', 'A2'))
)
i = 0
for i in range(len(d)):
j = 0
try:
c = pwrwb.Cid(d[i][0])
objectlist = c.objects()
for o in objectlist:
if j >= len(d[i][1]):
break
if o.name() != d[i][1][j]:
self.logger.vlog('E', "Cid.objects, Name doesn't match, %s != %s",
o.fullName(), d[i][1][j])
return
j += 1
except RuntimeError as e:
self.logger.vlog('E', 'Cid.objects, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Cid.objects, successfull completion')
#
# Cid.attrObject()
#
def Cid_attrObject(self):
d = (
('$Node', 'VolPwrtest02:Nodes-Pwrtest02'),
('$Security', 'VolPwrtest02:Nodes-Pwrtest02-Security'),
('OpPlace', 'VolPwrtest02:Nodes-Pwrtest02-OpPlaces-Op'),
('PlcPgm', 'VolPwrtest02:PlcTest-H1-Plc'),
('And', 'VolPwrtest02:PlcTest-H1-Plc-W-And0'),
('Dv', 'VolPwrtest02:Test02-First-Dv1'),
('Pwrt02_Values', 'VolPwrtest02:H1-Values')
)
i = 0
for i in range(len(d)):
try:
c = pwrwb.Cid(d[i][0])
o = c.attrObject()
if o is None:
if d[i][1] != 'None':
self.logger.vlog('E', "Cid.attrObject, No instance should be found, %s",
d[i][0])
return
else:
name = o.fullName()
if name != d[i][1]:
self.logger.vlog('E', "Cid.attrObject, Name doesn't match, %s != %s",
name, d[i][1])
return
except RuntimeError as e:
self.logger.vlog('E', 'Cid.attrObject, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Cid.attrObject, successfull completion')
#
# Cid.nextAttrObject()
#
def Cid_nextAttrObject(self):
d = (
('MessageHandler', 'VolPwrtest02:Nodes-PwrTest02-Servers-MessageHandler', 'None'),
('IOHandler', 'VolPwrtest02:Nodes-PwrTest02-Servers-IOHandler', 'None'),
('$PlantHier', 'VolPwrtest02:RootObject', 'VolPwrtest02:RootObject-Child1'),
('$PlantHier', 'VolPwrtest02:RootObject-Child1', 'VolPwrtest02:RootObject-Child2'),
('$PlantHier', 'VolPwrtest02:RootObject-Child2', 'VolPwrtest02:RootObject-Child3'),
('$PlantHier', 'VolPwrtest02:RootObject-Child3', 'VolPwrtest02:RootObject-Child4'),
('$PlantHier', 'VolPwrtest02:RootObject-Child4', 'VolPwrtest02:RootObject-ChildLess'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-Comp1', 'VolPwrtest02:Test02-First-C1.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-C1.Super', 'VolPwrtest02:Test02-First-M1.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-M1.Super', 'VolPwrtest02:Test02-First-M1.Contactor1.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-M1.Contactor1.Super', 'VolPwrtest02:Test02-First-R1.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Super', 'VolPwrtest02:Test02-First-R1.Motors[0].Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[0].Super', 'VolPwrtest02:Test02-First-R1.Motors[0].Contactor2.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[0].Contactor2.Super', 'VolPwrtest02:Test02-First-R1.Motors[1].Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[1].Super', 'VolPwrtest02:Test02-First-R1.Motors[1].Contactor1.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[1].Contactor1.Super', 'VolPwrtest02:Test02-First-R1.Motors[2].Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[2].Super', 'VolPwrtest02:Test02-First-R1.Motors[2].Contactor2.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[2].Contactor2.Super', 'VolPwrtest02:Test02-First-R1.Motors[3].Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[3].Super', 'VolPwrtest02:Test02-First-R1.Motors[3].Contactor1.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[3].Contactor1.Super', 'VolPwrtest02:Test02-First-R1.Motors[4].Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[4].Super', 'VolPwrtest02:Test02-First-R1.Motors[4].Contactor2.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[4].Contactor2.Super', 'VolPwrtest02:Test02-First-R1.Motors[5].Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[5].Super', 'VolPwrtest02:Test02-First-R1.Motors[5].Contactor1.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[5].Contactor1.Super', 'VolPwrtest02:Test02-First-R1.Motors[6].Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[6].Super', 'VolPwrtest02:Test02-First-R1.Motors[6].Contactor2.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[6].Contactor2.Super', 'VolPwrtest02:Test02-First-R1.Motors[7].Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[7].Super', 'VolPwrtest02:Test02-First-R1.Motors[7].Contactor1.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[7].Contactor1.Super', 'VolPwrtest02:Test02-First-R1.Motors[8].Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[8].Super', 'VolPwrtest02:Test02-First-R1.Motors[8].Contactor1.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[8].Contactor1.Super', 'VolPwrtest02:Test02-First-R1.Motors[9].Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[9].Super', 'VolPwrtest02:Test02-First-R1.Motors[9].Contactor2.Super'),
('Pwrt02_Component', 'VolPwrtest02:Test02-First-R1.Motors[9].Contactor2.Super', 'None')
)
i = 0
for i in range(len(d)):
try:
a = pwrwb.Aref(d[i][1])
c = pwrwb.Cid(d[i][0])
n = c.nextAttrObject(a)
if n is None:
if d[i][2] != 'None':
self.logger.vlog('E', "Cid.nextAttrObject, No instance should be found, %s",
d[i][1])
return
else:
name = n.fullName()
if name != d[i][2]:
self.logger.vlog('E', "Cid.nextAttrObject, Name doesn't match, %s != %s, idx %s",
name, d[i][2], str(i))
return
except RuntimeError as e:
self.logger.vlog('E', 'Cid.nextAttrObject, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Cid.nextAttrObject, successfull completion')
#
# Cid.attrObjects()
#
def Cid_attrObjects(self):
d = (
('$PlantHier', ('RootObject', 'Child1', 'Child2', 'Child3', 'Child4', 'ChildLess')),
('AArray100', ('A1', 'A2')),
('Pwrt02_Component',(
'Comp1',
'C1.Super',
'M1.Super',
'M1.Contactor1.Super',
'R1.Super',
'R1.Motors[0].Super',
'R1.Motors[0].Contactor2.Super',
'R1.Motors[1].Super',
'R1.Motors[1].Contactor1.Super',
'R1.Motors[2].Super',
'R1.Motors[2].Contactor2.Super',
'R1.Motors[3].Super',
'R1.Motors[3].Contactor1.Super',
'R1.Motors[4].Super',
'R1.Motors[4].Contactor2.Super',
'R1.Motors[5].Super',
'R1.Motors[5].Contactor1.Super',
'R1.Motors[6].Super',
'R1.Motors[6].Contactor2.Super',
'R1.Motors[7].Super',
'R1.Motors[7].Contactor1.Super',
'R1.Motors[8].Super',
'R1.Motors[8].Contactor1.Super',
'R1.Motors[9].Super',
'R1.Motors[9].Contactor2.Super'))
)
i = 0
for i in range(len(d)):
j = 0
try:
c = pwrwb.Cid(d[i][0])
objectlist = c.attrObjects()
for a in objectlist:
if j >= len(d[i][1]):
break
if a.name() != d[i][1][j]:
self.logger.vlog('E', "Cid.attrObjects, Name doesn't match, %s != %s, idx %s",
a.fullName(), d[i][1][j], str(i))
return
j += 1
except RuntimeError as e:
self.logger.vlog('E', 'Cid.attrObjects, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Cid.attrObjects, successfull completion')
#
# Cid.attributes()
#
def Cid_attributes(self):
d = (
('$PlantHier', ('Description', 'DefGraph', 'DefTrend', 'HelpTopic',
'DataSheet', 'CircuitDiagram', 'Photo',
'ConfigurationStatus', 'SafetyLevel')),
('And' ,('In1', 'In2', 'In3', 'In4', 'In5', 'In6', 'In7', 'In8', 'Status'))
)
i = 0
for i in range(len(d)):
j = 0
try:
c = pwrwb.Cid(d[i][0])
alist = c.attributes()
for a in alist:
if j >= len(d[i][1]):
break
if a.name() != d[i][1][j]:
self.logger.vlog('E', "Cid.attributes, Name doesn't match, %s != %s",
a.name(), d[i][1][j])
return
j += 1
except RuntimeError as e:
self.logger.vlog('E', 'Cid.attributes, Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Cid.attributes, successfull completion')
#
# Tid.name()
#
def Tid_name(self):
d = (
('RootObject.Description', '$String80', ''),
('RootObject-Child1.DefGraph', '$AttrRef', ''),
('Test02-Pwrwb-Dv1.InitialValue', '$Boolean', ''),
('Test02-Pwrwb-L1.Value', 'Ai', ''),
('Test02-Pwrwb-L1.Value.ActualValue', '$Float32', ''),
('Test02-Pwrwb-Values.Boolean', '$Boolean', ''),
('Test02-Pwrwb-Values.Int8', '$Int8', ''),
('Test02-Pwrwb-Values.Int16', '$Int16', ''),
('Test02-Pwrwb-Values.Int32', '$Int32', ''),
('Test02-Pwrwb-Values.Int64', '$Int64', ''),
('Test02-Pwrwb-Values.UInt8', '$UInt8', ''),
('Test02-Pwrwb-Values.UInt16', '$UInt16', ''),
('Test02-Pwrwb-Values.UInt32', '$UInt32', ''),
('Test02-Pwrwb-Values.UInt64', '$UInt64', ''),
('Test02-Pwrwb-Values.Float32', '$Float32', ''),
('Test02-Pwrwb-Values.Float64', '$Float64', ''),
('Test02-Pwrwb-Values.String80', '$String80', ''),
('Test02-Pwrwb-Values.Time', '$Time', ''),
('Test02-Pwrwb-Values.DeltaTime', '$DeltaTime', ''),
('Test02-Pwrwb-Values.Objid', '$Objid', ''),
('Test02-Pwrwb-Values.AttrRef', '$AttrRef', '')
)
i = 0
for i in range(len(d)):
try:
a = pwrwb.attribute(d[i][0])
tid = a.tid()
if tid.name() != d[i][1]:
self.logger.vlog('E', "Tid.name, "
"Name doesn't match, %s != %s",
tid.name(), d[i][1])
return
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'Tid.name, '
'Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'Tid.name, successfull completion')
#
# ADef.name()
#
def ADef_name(self):
d = (
('And',
(('In1', 8, 4, 1, 1104), # name, offset, size, elements, flags
('In2', 24, 4, 1, 1104),
('In3', 40, 4, 1, 1104),
('In4', 56, 4, 1, 1104),
('In5', 72, 4, 1, 1104),
('In6', 88, 4, 1, 1104),
('In7', 104, 4, 1, 1104),
('In8', 120, 4, 1, 1104),
('Status', 124, 4, 1, 1044))),
('Pwrt02_Values',
(('Boolean', 0, 4, 1, 0),
('Int8', 4, 1, 1, 0),
('Int16', 8, 2, 1, 0),
('Int32', 12, 4, 1, 0),
('Int64', 16, 8, 1, 0),
('UInt8', 24, 1, 1, 0),
('UInt16', 28, 2, 1, 0),
('UInt32', 32, 4, 1, 0),
('UInt64', 40, 8, 1, 0),
('Float32', 48, 4, 1, 0),
('Float64', 56, 8, 1, 0),
('String80', 64, 80, 1, 0),
('ProString40', 144, 40, 1, 0),
('Time', 184, 16, 1, 0),
('DeltaTime', 200, 16, 1, 0),
('Objid', 216, 8, 1, 0),
('AttrRef', 224, 24, 1, 0),
('BooleanArray', 248, 20, 5, 2),
('Int8Array', 268, 5, 5, 2),
('Int16Array', 276, 10, 5, 2),
('Int32Array', 288, 20, 5, 2),
('Int64Array', 312, 40, 5, 2),
('UInt8Array', 352, 5, 5, 2),
('UInt16Array', 360, 10, 5, 2),
('UInt32Array', 372, 20, 5, 2),
('UInt64Array', 392, 40, 5, 2),
('Float32Array', 432, 20, 5, 2),
('Float64Array', 456, 40, 5, 2),
('String80Array', 496, 400, 5, 2),
('TimeArray', 896, 80, 5, 2),
('DeltaTimeArray', 976, 80, 5, 2),
('ObjidArray', 1056, 40, 5, 2),
('AttrRefArray', 1096, 120, 5, 2)))
)
i = 0
for i in range(len(d)):
try:
cid = pwrwb.Cid(d[i][0])
adeflist = cid.attributes()
j = 0
for adef in adeflist:
if adef.name() == 'PlcNode':
continue
if adef.name() != d[i][1][j][0]:
self.logger.vlog('E', "ADef.name, "
"name doesn't match, %s != %s",
adef.name(), d[i][1][j][0])
return
if adef.offset() != d[i][1][j][1]:
self.logger.vlog('E', "ADef.name, "
"offset doesn't match, %s != %s",
adef.name(), str(d[i][1][j][1]))
return
if adef.size() != d[i][1][j][2]:
self.logger.vlog('E', "ADef.name, "
"size doesn't match, %s != %s",
adef.name(), str(d[i][1][j][2]))
return
if adef.elements() != d[i][1][j][3]:
self.logger.vlog('E', "ADef.name, "
"elements doesn't match, %s != %s",
adef.name(), str(d[i][1][j][3]))
return
if (adef.flags() & ~(1<<24)) != d[i][1][j][4]:
self.logger.vlog('E', "ADef.name, "
"flags doesn't match, %s != %s",
adef.name(), str(d[i][1][j][4]))
return
j += 1
except RuntimeError as e:
if str(e) != d[i][2]:
self.logger.vlog('E', 'ADef.name, '
'Unexpected exception %s, idx %s',
str(e), str(i))
return
self.logger.log('S', 'ADef.name, successfull completion')
ctx = Ctx()
ctx.logger = pwrtest.logger('wb_test-pwrwb', '$pwrp_log/pwrwb.tlog')
try:
ctx.init()
except:
quit()
ctx.login()
pwrwb.login('pwrp', 'pwrp')
ctx.volume()
ctx.volumes()
ctx.object()
ctx.attribute()
ctx.getSessionVolume()
ctx.getUser()
ctx.sessionIsEmpty()
ctx.revertSession()
ctx.Oid()
ctx.Oid_child()
ctx.Oid_next()
ctx.Oid_parent()
ctx.Oid_children()
ctx.Oid_name()
ctx.Oid_fullName()
ctx.Oid_oidStr()
ctx.Oid_attribute()
ctx.Aref()
ctx.Aref_name()
ctx.Aref_fullName()
ctx.Aref_arefStr()
ctx.Aref_tid()
ctx.Aref_value()
ctx.Aref_setValue()
ctx.Cid()
ctx.Cid_fullName()
ctx.Cid_object()
ctx.Cid_nextObject()
ctx.Cid_objects()
ctx.Cid_attrObject()
ctx.Cid_nextAttrObject()
ctx.Cid_attrObjects()
ctx.Cid_attributes()
ctx.Tid_name()
ctx.ADef_name()
#! /bin/bash
#
# Local setup
# Printer command for plc documents
#export pwr_foe_gre_print="lpr -P lp1"
export PWR_BUS_ID=999
if [ -e "$pwrp_root/src/login/sysinfo.txt" ]; then
echo "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"
echo "Welcome to"
echo "`$pwr_exe/pwrp_env.sh show project`"
echo ""
cat $pwrp_login/sysinfo.txt
echo "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"
fi
Revision history
2020-07-14 cs Project created
#!/bin/bash
nodename=`eval uname -n`
unamestr=`eval uname`
onamestr=`eval uname -o`
machine=`eval uname -m`
if [ $unamestr == "Darwin" ]; then
os="os_macos"
hw="hw_x86_64"
opsys=256
elif [ $unamestr == "FreeBSD" ]; then
os="os_freebsd"
hw="hw_x86_64"
opsys=1024
elif [ $unamestr == "OpenBSD" ]; then
os="os_openbsd"
hw="hw_x86_64"
opsys=2048
elif [ $onamestr == "Cygwin" ]; then
os="os_cygwin"
hw="hw_x86"
opsys=4096
else
if [ $machine == "x86_64" ]; then
machine="x86_64"
opsys=128
elif [ ${machine:0:3} == "arm" ]; then
machine="arm"
opsys=512
else
machine="x86"
opsys=64
fi
os="os_linux"
hw="hw_"$machine
fi
export pwra_db=$pwre_broot/$os/$hw/bld/project/adm/db
source $pwra_db/pwr_setup.sh
source $pwra_db/pwra_env.sh set project pwrtest02
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