move all examples to separate top level build areas.

Documentation needs updating.
This commit is contained in:
Marty Kraimer
2014-02-05 11:57:35 -05:00
parent 5d0718ab3a
commit 94bd84211b
116 changed files with 879 additions and 845 deletions

View File

@@ -0,0 +1,29 @@
TOP=..
include $(TOP)/configure/CONFIG
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
#==================================================
# Build an IOC support library
#
DBD += exampleServer.dbd
INC += exampleServer.h
LIBRARY_IOC += exampleServerSupport
exampleServerSupport_SRCS += exampleServer.cpp
exampleServerSupport_SRCS += exampleServerRegister.cpp
exampleServerSupport_LIBS += pvData
exampleServerSupport_LIBS += pvAccess
exampleServerSupport_LIBS += pvDatabase
exampleServerSupport_LIBS += $(EPICS_BASE_IOC_LIBS)
#===========================
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE

View File

@@ -0,0 +1,79 @@
/* exampleServer.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
* @date 2013.04.02
*/
#include <pv/standardPVField.h>
#include <pv/exampleServer.h>
namespace epics { namespace exampleServer {
using namespace epics::pvData;
using namespace epics::pvDatabase;
using std::tr1::static_pointer_cast;
ExampleServerPtr ExampleServer::create(
String const & recordName)
{
StandardPVFieldPtr standardPVField = getStandardPVField();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
PVStructurePtr pvArgument = standardPVField->scalar(pvString,"");
PVStructurePtr pvResult = standardPVField->scalar(pvString,"timeStamp");
StringArray names;
names.reserve(2);
PVFieldPtrArray fields;
fields.reserve(2);
names.push_back("argument");
fields.push_back(pvArgument);
names.push_back("result");
fields.push_back(pvResult);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(names,fields);
ExampleServerPtr pvRecord(
new ExampleServer(recordName,pvStructure));
if(!pvRecord->init()) pvRecord.reset();
return pvRecord;
}
ExampleServer::ExampleServer(
String const & recordName,
PVStructurePtr const & pvStructure)
: PVRecord(recordName,pvStructure)
{
}
ExampleServer::~ExampleServer()
{
}
void ExampleServer::destroy()
{
PVRecord::destroy();
}
bool ExampleServer::init()
{
initPVRecord();
PVFieldPtr pvField;
pvArgumentValue = getPVStructure()->getStringField("argument.value");
if(pvArgumentValue.get()==NULL) return false;
pvResultValue = getPVStructure()->getStringField("result.value");
if(pvResultValue.get()==NULL) return false;
pvTimeStamp.attach(getPVStructure()->getSubField("result.timeStamp"));
return true;
}
void ExampleServer::process()
{
pvResultValue->put(String("Hello ") + pvArgumentValue->get());
timeStamp.getCurrent();
pvTimeStamp.set(timeStamp);
}
}}

View File

@@ -0,0 +1,49 @@
/* exampleServer.h */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
* @date 2013.04.02
*/
#ifndef EXAMPLECOUNTER_H
#define EXAMPLECOUNTER_H
#include <pv/pvDatabase.h>
#include <pv/timeStamp.h>
#include <pv/pvTimeStamp.h>
namespace epics { namespace exampleServer {
class ExampleServer;
typedef std::tr1::shared_ptr<ExampleServer> ExampleServerPtr;
class ExampleServer :
public epics::pvDatabase::PVRecord
{
public:
POINTER_DEFINITIONS(ExampleServer);
static ExampleServerPtr create(
epics::pvData::String const & recordName);
virtual ~ExampleServer();
virtual void destroy();
virtual bool init();
virtual void process();
private:
ExampleServer(epics::pvData::String const & recordName,
epics::pvData::PVStructurePtr const & pvStructure);
epics::pvData::PVStringPtr pvArgumentValue;
epics::pvData::PVStringPtr pvResultValue;
epics::pvData::PVTimeStamp pvTimeStamp;
epics::pvData::TimeStamp timeStamp;
};
}}
#endif /* EXAMPLECOUNTER_H */

View File

@@ -0,0 +1 @@
registrar("exampleServerRegister")

View File

@@ -0,0 +1,67 @@
/*exampleServerRegister.cpp */
/**
* Copyright - See the COPYRIGHT that is included with this distribution.
* EPICS pvData is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
*/
/**
* @author mrk
* @date 2013.07.24
*/
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <iostream>
#include <cantProceed.h>
#include <epicsStdio.h>
#include <epicsMutex.h>
#include <epicsEvent.h>
#include <epicsThread.h>
#include <iocsh.h>
#include <epicsExport.h>
#include <pv/pvIntrospect.h>
#include <pv/pvData.h>
#include <pv/pvAccess.h>
#include <pv/pvDatabase.h>
#include <pv/exampleServer.h>
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvDatabase;
using namespace epics::exampleServer;
using std::cout;
using std::endl;
static const iocshArg testArg0 = { "recordName", iocshArgString };
static const iocshArg *testArgs[] = {
&testArg0};
static const iocshFuncDef exampleServerFuncDef = {
"exampleServerCreateRecord", 1, testArgs};
static void exampleServerCallFunc(const iocshArgBuf *args)
{
char *recordName = args[0].sval;
ExampleServerPtr record = ExampleServer::create(recordName);
bool result = PVDatabase::getMaster()->addRecord(record);
if(!result) cout << "recordname" << " not added" << endl;
}
static void exampleServerRegister(void)
{
static int firstTime = 1;
if (firstTime) {
firstTime = 0;
iocshRegister(&exampleServerFuncDef, exampleServerCallFunc);
}
}
epicsExportRegistrar(exampleServerRegister);