init notmative types repo, which is moved from alphaCPP repo
This commit is contained in:
5
test/Makefile
Normal file
5
test/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
TOP = ..
|
||||
include $(TOP)/configure/CONFIG
|
||||
DIRS += nt
|
||||
include $(TOP)/configure/RULES_DIRS
|
||||
|
||||
20
test/nt/Makefile
Normal file
20
test/nt/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
TOP=../..
|
||||
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
PROD_HOST += ntfieldTest
|
||||
ntfieldTest_SRCS += ntfieldTest.cpp
|
||||
ntfieldTest_LIBS += nt pvData Com
|
||||
|
||||
PROD_HOST += ntnameValueTest
|
||||
ntnameValueTest_SRCS += ntnameValueTest.cpp
|
||||
ntnameValueTest_LIBS += nt pvData Com
|
||||
|
||||
PROD_HOST += nttableTest
|
||||
nttableTest_SRCS += nttableTest.cpp
|
||||
nttableTest_LIBS += nt pvData Com
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
#----------------------------------------
|
||||
# ADD RULES AFTER THIS LINE
|
||||
|
||||
176
test/nt/ntfieldTest.cpp
Normal file
176
test/nt/ntfieldTest.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvDataCPP is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/*
|
||||
* ntfieldTest.cpp
|
||||
*
|
||||
* Created on: 2011.11
|
||||
* Author: Marty Kraimer
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <list>
|
||||
|
||||
#include <epicsAssert.h>
|
||||
|
||||
#include <pv/nt.h>
|
||||
|
||||
#include <epicsExit.h>
|
||||
#include <pv/CDRMonitor.h>
|
||||
|
||||
using namespace epics::pvData;
|
||||
|
||||
static FieldCreate * fieldCreate = 0;
|
||||
static PVDataCreate * pvDataCreate = 0;
|
||||
static StandardField *standardField = 0;
|
||||
static StandardPVField *standardPVField = 0;
|
||||
static NTField *ntField = 0;
|
||||
static PVNTField *pvntField = 0;
|
||||
static String builder("");
|
||||
|
||||
static void testNTField(FILE * fd)
|
||||
{
|
||||
StructureConstPtr structureConstPtr = ntField->createEnumerated("value");
|
||||
builder.clear();
|
||||
structureConstPtr->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(ntField->isEnumerated(structureConstPtr));
|
||||
|
||||
structureConstPtr = ntField->createTimeStamp();
|
||||
builder.clear();
|
||||
structureConstPtr->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(ntField->isTimeStamp(structureConstPtr));
|
||||
|
||||
structureConstPtr = ntField->createAlarm();
|
||||
builder.clear();
|
||||
structureConstPtr->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(ntField->isAlarm(structureConstPtr));
|
||||
|
||||
structureConstPtr = ntField->createDisplay();
|
||||
builder.clear();
|
||||
structureConstPtr->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(ntField->isDisplay(structureConstPtr));
|
||||
|
||||
structureConstPtr = ntField->createAlarmLimit();
|
||||
builder.clear();
|
||||
structureConstPtr->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(ntField->isAlarmLimit(structureConstPtr));
|
||||
|
||||
structureConstPtr = ntField->createControl();
|
||||
builder.clear();
|
||||
structureConstPtr->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(ntField->isControl(structureConstPtr));
|
||||
|
||||
StructureArrayConstPtr structureArrayConstPtr
|
||||
= ntField->createEnumeratedArray("value");
|
||||
builder.clear();
|
||||
structureArrayConstPtr->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
|
||||
structureArrayConstPtr = ntField->createTimeStampArray("value");
|
||||
builder.clear();
|
||||
structureArrayConstPtr->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
|
||||
structureArrayConstPtr = ntField->createAlarmArray("value");
|
||||
builder.clear();
|
||||
structureArrayConstPtr->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
}
|
||||
|
||||
static void testPVNTField(FILE * fd)
|
||||
{
|
||||
String choices[] = {"one","two","three"};
|
||||
PVStructure::shared_pointer pvStructure = PVStructure::shared_pointer(
|
||||
pvntField->createEnumerated(0,"enumerated",choices, 3));
|
||||
builder.clear();
|
||||
pvStructure->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(ntField->isEnumerated(pvStructure->getStructure()));
|
||||
|
||||
pvStructure = PVStructure::shared_pointer(pvntField->createTimeStamp(0));
|
||||
builder.clear();
|
||||
pvStructure->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(ntField->isTimeStamp(pvStructure->getStructure()));
|
||||
|
||||
pvStructure = PVStructure::shared_pointer(pvntField->createAlarm(0));
|
||||
builder.clear();
|
||||
pvStructure->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(ntField->isAlarm(pvStructure->getStructure()));
|
||||
|
||||
pvStructure = PVStructure::shared_pointer(pvntField->createDisplay(0));
|
||||
builder.clear();
|
||||
pvStructure->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(ntField->isDisplay(pvStructure->getStructure()));
|
||||
|
||||
pvStructure = PVStructure::shared_pointer(pvntField->createAlarmLimit(0));
|
||||
builder.clear();
|
||||
pvStructure->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(ntField->isAlarmLimit(pvStructure->getStructure()));
|
||||
|
||||
PVStructureArray::shared_pointer pvStructureArray = PVStructureArray::shared_pointer(
|
||||
pvntField->createEnumeratedArray(0,"enumArray"));
|
||||
builder.clear();
|
||||
pvStructureArray->toString(&builder);
|
||||
fprintf(fd,"\n%s\n",builder.c_str());
|
||||
builder.clear();
|
||||
pvStructureArray->getStructureArray()->getStructure()->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
|
||||
pvStructureArray = PVStructureArray::shared_pointer(
|
||||
pvntField->createTimeStampArray(0,"timeStampArray"));
|
||||
builder.clear();
|
||||
pvStructureArray->toString(&builder);
|
||||
fprintf(fd,"\n%s\n",builder.c_str());
|
||||
builder.clear();
|
||||
pvStructureArray->getStructureArray()->getStructure()->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
|
||||
pvStructureArray = PVStructureArray::shared_pointer(
|
||||
pvntField->createAlarmArray(0,"alarmArray"));
|
||||
builder.clear();
|
||||
pvStructureArray->toString(&builder);
|
||||
fprintf(fd,"\n%s\n",builder.c_str());
|
||||
builder.clear();
|
||||
pvStructureArray->getStructureArray()->getStructure()->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
char *fileName = 0;
|
||||
if(argc>1) fileName = argv[1];
|
||||
FILE * fd = stdout;
|
||||
if(fileName!=0 && fileName[0]!=0) {
|
||||
fd = fopen(fileName,"w+");
|
||||
}
|
||||
fieldCreate = getFieldCreate();
|
||||
pvDataCreate = getPVDataCreate();
|
||||
standardField = getStandardField();
|
||||
standardPVField = getStandardPVField();
|
||||
ntField = NTField::get();
|
||||
pvntField = PVNTField::get();
|
||||
testNTField(fd);
|
||||
testPVNTField(fd);
|
||||
epicsExitCallAtExits();
|
||||
CDRMonitor::get().show(fd,true);
|
||||
return(0);
|
||||
}
|
||||
|
||||
92
test/nt/ntnameValueTest.cpp
Normal file
92
test/nt/ntnameValueTest.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvDataCPP is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/*
|
||||
* ntnameValueTest.cpp
|
||||
*
|
||||
* Created on: 2011.11
|
||||
* Author: Marty Kraimer
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <list>
|
||||
|
||||
#include <epicsAssert.h>
|
||||
|
||||
#include <pv/nt.h>
|
||||
|
||||
#include <epicsExit.h>
|
||||
#include <pv/CDRMonitor.h>
|
||||
|
||||
using namespace epics::pvData;
|
||||
|
||||
|
||||
static PVDataCreate * pvDataCreate = 0;
|
||||
static NTField *ntField = 0;
|
||||
static PVNTField *pvntField = 0;
|
||||
static String builder("");
|
||||
|
||||
static void test(FILE * fd)
|
||||
{
|
||||
PVStructure::shared_pointer pvStructure = NTNameValue::create(true,true,true);
|
||||
builder.clear();
|
||||
pvStructure->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
builder.clear();
|
||||
pvStructure->getStructure()->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
NTNameValue ntNameValue(pvStructure);
|
||||
PVStringArray *names = ntNameValue.getNames();
|
||||
PVStringArray *values = ntNameValue.getValues();
|
||||
int n = 2;
|
||||
String name[] = {String("name 0"),String("name 1")};
|
||||
String value[] = {String("value 0"),String("value 1")};
|
||||
names->put(0,n,name,0);
|
||||
values->put(0,n,value,0);
|
||||
PVString *function = ntNameValue.getFunction();
|
||||
function->put("test");
|
||||
PVAlarm pvAlarm;
|
||||
ntNameValue.attachAlarm(pvAlarm);
|
||||
Alarm alarm;
|
||||
alarm.setMessage("test alarm");
|
||||
alarm.setSeverity(majorAlarm);
|
||||
alarm.setStatus(clientStatus);
|
||||
pvAlarm.set(alarm);
|
||||
PVTimeStamp pvTimeStamp;
|
||||
ntNameValue.attachTimeStamp(pvTimeStamp);
|
||||
TimeStamp timeStamp(1000,1000,10);
|
||||
pvTimeStamp.set(timeStamp);
|
||||
builder.clear();
|
||||
pvStructure->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(NTNameValue::isNTNameValue(pvStructure.get()));
|
||||
NTNameValue::shared_pointer pntNameValue
|
||||
= NTNameValue::shared_pointer(new NTNameValue(pvStructure));
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
char *fileName = 0;
|
||||
if(argc>1) fileName = argv[1];
|
||||
FILE * fd = stdout;
|
||||
if(fileName!=0 && fileName[0]!=0) {
|
||||
fd = fopen(fileName,"w+");
|
||||
}
|
||||
pvDataCreate = getPVDataCreate();
|
||||
ntField = NTField::get();
|
||||
pvntField = PVNTField::get();
|
||||
test(fd);
|
||||
epicsExitCallAtExits();
|
||||
CDRMonitor::get().show(fd,true);
|
||||
return(0);
|
||||
}
|
||||
|
||||
114
test/nt/nttableTest.cpp
Normal file
114
test/nt/nttableTest.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* EPICS pvDataCPP is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
/*
|
||||
* nttableTest.cpp
|
||||
*
|
||||
* Created on: 2011.11
|
||||
* Author: Marty Kraimer
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <list>
|
||||
|
||||
#include <epicsAssert.h>
|
||||
|
||||
#include <pv/nt.h>
|
||||
|
||||
#include <epicsExit.h>
|
||||
#include <pv/CDRMonitor.h>
|
||||
|
||||
using namespace epics::pvData;
|
||||
|
||||
|
||||
static FieldCreate * fieldCreate = 0;
|
||||
static PVDataCreate * pvDataCreate = 0;
|
||||
static NTField *ntField = 0;
|
||||
static PVNTField *pvntField = 0;
|
||||
static String builder("");
|
||||
|
||||
static void test(FILE * fd)
|
||||
{
|
||||
int n = 2;
|
||||
FieldConstPtr fields[2];
|
||||
fields[0] = fieldCreate->createScalarArray("position",pvDouble);
|
||||
fields[1] = ntField->createAlarmArray("alarms");
|
||||
PVStructure::shared_pointer pvStructure = NTTable::create(
|
||||
true,true,true,n,fields);
|
||||
builder.clear();
|
||||
pvStructure->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
builder.clear();
|
||||
pvStructure->getStructure()->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
NTTable ntTable(pvStructure);
|
||||
PVDoubleArray *pvPositions
|
||||
= static_cast<PVDoubleArray *>(ntTable.getPVField(0));
|
||||
double positions[2];
|
||||
positions[0] = 1.0;
|
||||
positions[1] = 2.0;
|
||||
pvPositions->put(0,n,positions,0);
|
||||
PVStructureArray *pvAlarms
|
||||
= static_cast<PVStructureArray *>(ntTable.getPVField(1));
|
||||
PVAlarm pvAlarm;
|
||||
Alarm alarm;
|
||||
PVStructurePtr palarms[n];
|
||||
for(int i=0; i<n; i++) {
|
||||
palarms[i] = pvntField->createAlarm(0);
|
||||
pvAlarm.attach(palarms[i]);
|
||||
alarm.setMessage("test");
|
||||
alarm.setSeverity(majorAlarm);
|
||||
alarm.setStatus(clientStatus);
|
||||
pvAlarm.set(alarm);
|
||||
}
|
||||
pvAlarms->put(0,n,palarms,0);
|
||||
String labels[n];
|
||||
labels[0] = pvPositions->getField()->getFieldName();
|
||||
labels[1] = pvAlarms->getField()->getFieldName();
|
||||
PVStringArray *label = ntTable.getLabel();
|
||||
label->put(0,n,labels,0);
|
||||
|
||||
PVString *function = ntTable.getFunction();
|
||||
function->put("test");
|
||||
ntTable.attachAlarm(pvAlarm);
|
||||
alarm.setMessage("test alarm");
|
||||
alarm.setSeverity(majorAlarm);
|
||||
alarm.setStatus(clientStatus);
|
||||
pvAlarm.set(alarm);
|
||||
PVTimeStamp pvTimeStamp;
|
||||
ntTable.attachTimeStamp(pvTimeStamp);
|
||||
TimeStamp timeStamp(1000,1000,10);
|
||||
pvTimeStamp.set(timeStamp);
|
||||
builder.clear();
|
||||
pvStructure->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
assert(NTTable::isNTTable(pvStructure.get()));
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
char *fileName = 0;
|
||||
if(argc>1) fileName = argv[1];
|
||||
FILE * fd = stdout;
|
||||
if(fileName!=0 && fileName[0]!=0) {
|
||||
fd = fopen(fileName,"w+");
|
||||
}
|
||||
fieldCreate = getFieldCreate();
|
||||
pvDataCreate = getPVDataCreate();
|
||||
ntField = NTField::get();
|
||||
pvntField = PVNTField::get();
|
||||
test(fd);
|
||||
epicsExitCallAtExits();
|
||||
CDRMonitor::get().show(fd,true);
|
||||
return(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user