timer and timeStamp added to misc. copyright and license info added

This commit is contained in:
Marty Kraimer
2010-11-23 07:30:13 -05:00
parent 28aad96b34
commit 9db054cc54
100 changed files with 1376 additions and 7236 deletions

7
documentation/COPYRIGHT Normal file
View File

@@ -0,0 +1,7 @@
/****************************************************
Copyright (c) 2008 All rights reserved
Copyright (c) 2008 Martin R. Kraimer
COSYLAB (Control System Laboratory)
(Cosylab) Ljubljana Slovenia
Copyright 2010 Brookhaven National Laboratory
*************************************************** */

72
documentation/LICENSE Normal file
View File

@@ -0,0 +1,72 @@
Copyright (c) 2008 Martin R. Kraimer
Copyright (c) 2007 Control System Laboratory,
(COSYLAB) Ljubljana Slovenia
Copyright 2010 Brookhaven National Laboratory
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
________________________________________________________________________
This software is in part copyrighted by the University of Chicago (UofC)
In no event shall UofC be liable to any party for direct, indirect,
special, incidental, or consequential damages arising out of the use of
this software, its documentation, or any derivatives thereof, even if
UofC has been advised of the possibility of such damage.
UofC specifically disclaims any warranties, including, but not limited
to, the implied warranties of merchantability, fitness for a particular
purpose, and non-infringement. This software is provided on an "as is"
basis, and UofC has no obligation to provide maintenance, support,
updates, enhancements, or modifications.
________________________________________________________________________
This software is in part copyrighted by the BERLINER SPEICHERRING
GESELLSCHAFT FUER SYNCHROTRONSTRAHLUNG M.B.H. (BESSY), BERLIN, GERMANY.
In no event shall BESSY be liable to any party for direct, indirect,
special, incidental, or consequential damages arising out of the use of
this software, its documentation, or any derivatives thereof, even if
BESSY has been advised of the possibility of such damage.
BESSY specifically disclaims any warranties, including, but not limited
to, the implied warranties of merchantability, fitness for a particular
purpose, and non-infringement. This software is provided on an "as is"
basis, and BESSY has no obligation to provide maintenance, support,
updates, enhancements, or modifications.
________________________________________________________________________
This software is in part copyrighted by the Deutsches Elektronen-Synchroton,
Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
In no event shall DESY be liable to any party for direct, indirect,
special, incidental, or consequential damages arising out of the use of
this software, its documentation, or any derivatives thereof, even if
DESY has been advised of the possibility of such damage.
DESY specifically disclaims any warranties, including, but not limited
to, the implied warranties of merchantability, fitness for a particular
purpose, and non-infringement. This software is provided on an "as is"
basis, and DESY has no obligation to provide maintenance, support,
updates, enhancements, or modifications.
________________________________________________________________________

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,10 @@
/*AbstractPVArray.h*/
/**
* 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.
*/
#ifndef ABSTRACTPVARRAY_H
#define ABSTRACTPVARRAY_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*AbstractPVField.h*/
/**
* 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.
*/
#ifndef ABSTRACTPVFIELD_H
#define ABSTRACTPVFIELD_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*AbstractPVScalar.h*/
/**
* 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.
*/
#ifndef ABSTRACTPVSCALAR_H
#define ABSTRACTPVSCALAR_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*AbstractPVScalarArray.h*/
/**
* 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.
*/
#ifndef ABSTRACTPVSCALARARRAY_H
#define ABSTRACTPVSCALARARRAY_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVBoolean.h*/
/**
* 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.
*/
#ifndef BASEPVBOOLEAN_H
#define BASEPVBOOLEAN_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVBooleanArrray.h*/
/**
* 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.
*/
#ifndef BASEPVBOOLEANARRAY_H
#define BASEPVBOOLEANARRAY_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVByte.h*/
/**
* 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.
*/
#ifndef BASEPVBYTE_H
#define BASEPVBYTE_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVByteArray.h*/
/**
* 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.
*/
#ifndef BASEPVBYTEARRAY_H
#define BASEPVBYTEARRAY_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVDouble.h*/
/**
* 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.
*/
#ifndef BASEPVDOUBLE_H
#define BASEPVDOUBLE_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVDoubleArray.h*/
/**
* 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.
*/
#ifndef BASEPVDOUBLEARRAY_H
#define BASEPVDOUBLEARRAY_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVFloat.h*/
/**
* 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.
*/
#ifndef BASEPVFLOAT_H
#define BASEPVFLOAT_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVFloatArray.h*/
/**
* 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.
*/
#ifndef BASEPVFLOATARRAY_H
#define BASEPVFLOATARRAY_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVInt.h*/
/**
* 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.
*/
#ifndef BASEPVINT_H
#define BASEPVINT_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVIntArray.h*/
/**
* 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.
*/
#ifndef BASEPVINTARRAY_H
#define BASEPVINTARRAY_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVLong.h*/
/**
* 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.
*/
#ifndef BASEPVLONG_H
#define BASEPVLONG_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVLongArray.h*/
/**
* 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.
*/
#ifndef BASEPVLONGARRAY_H
#define BASEPVLONGARRAY_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVShort.h*/
/**
* 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.
*/
#ifndef BASEPVSHORT_H
#define BASEPVSHORT_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVShortArray.h*/
/**
* 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.
*/
#ifndef BASEPVSHORTARRAY_H
#define BASEPVSHORTARRAY_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVString.h*/
/**
* 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.
*/
#ifndef BASEPVSTRING_H
#define BASEPVSTRING_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVStringArray.h*/
/**
* 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.
*/
#ifndef BASEPVSTRINGARRAY_H
#define BASEPVSTRINGARRAY_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVStructure.h*/
/**
* 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.
*/
#ifndef BASEPVSTRUCTURE_H
#define BASEPVSTRUCTURE_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/*BasePVStructureArray.h*/
/**
* 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.
*/
#ifndef BASEPVSTRUCTUREARRAY_H
#define BASEPVSTRUCTUREARRAY_H
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/* Convert.cpp */
/**
* 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.
*/
#include <cstdio>
#include <string>
#include <vector>

View File

@@ -1,4 +1,9 @@
/*FieldCreateFactory.cpp*/
/**
* 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.
*/
#include <cstddef>
#include <cstdlib>
#include <string>

View File

@@ -1,4 +1,9 @@
/*PVAuxInfo.cpp*/
/**
* 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.
*/
#include <cstddef>
#include <cstdlib>
#include <string>

View File

@@ -1,4 +1,9 @@
/*PVDataCreateFactory.cpp*/
/**
* 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.
*/
#include <cstddef>
#include <cstdlib>
#include <string>

View File

@@ -1,4 +1,9 @@
/* StandardField.cpp */
/**
* 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.
*/
#include <string>
#include <cstdio>
#include <stdexcept>

View File

@@ -1,4 +1,9 @@
/* StandardPVField.cpp */
/**
* 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.
*/
#include <string>
#include <stdexcept>
#include <lock.h>

View File

@@ -1,4 +1,9 @@
/*TypeFunc.cpp*/
/**
* 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.
*/
#include <cstddef>
#include <cstdlib>
#include <string>

View File

@@ -1,4 +1,9 @@
/*factory.h*/
/**
* 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.
*/
#ifndef FACTORY_H
#define FACTORY_H

View File

@@ -19,6 +19,7 @@ INC += executor.h
INC += showConstructDestruct.h
INC += timeStamp.h
INC += timeFunction.h
INC += timer.h
LIBSRCS += byteBuffer.cpp
LIBSRCS += bitSet.cpp
@@ -30,6 +31,7 @@ LIBSRCS += thread.cpp
LIBSRCS += executor.cpp
LIBSRCS += timeStamp.cpp
LIBSRCS += timeFunction.cpp
LIBSRCS += timer.cpp
LIBRARY=pvMisc

View File

@@ -1,3 +1,9 @@
/* bitSet.cpp */
/**
* 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.
*/
#include "string.h"
#include "stdio.h"
#include "bitSet.h"

View File

@@ -1,4 +1,9 @@
/* bitSet.h */
/**
* 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.
*/
#ifndef BITSET_H
#define BITSET_H
#include <stdexcept>

View File

@@ -1,3 +1,8 @@
/**
* 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.
*/
/*
* byteBuffer.cpp
*

View File

@@ -1,4 +1,9 @@
/* byteBuffer.h */
/**
* 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.
*/
#ifndef BYTEBUFFER_H
#define BYTEBUFFER_H

View File

@@ -1,3 +1,8 @@
/**
* 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.
*/
/*
* epicsException.hpp
*

View File

@@ -1,4 +1,9 @@
/* event.cpp */
/**
* 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.
*/
#include <cstddef>
#include <cstdlib>
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/* event.h */
/**
* 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.
*/
#ifndef EVENT_H
#define EVENT_H
#include <memory>

View File

@@ -1,4 +1,9 @@
/* executor.h */
/* executor.cpp */
/**
* 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.
*/
#include <cstddef>
#include <cstdlib>
#include <cstddef>
@@ -186,6 +191,10 @@ Executor::~Executor() {
totalDestruct++;
}
Executor *Executor::create(String threadName,ThreadPriority priority)
{
return new Executor(threadName,priority);
}
ExecutorNode * Executor::createNode(Command*command)
{return pImpl->createNode(command);}

View File

@@ -1,4 +1,9 @@
/* executor.h */
/**
* 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.
*/
#ifndef EXECUTOR_H
#define EXECUTOR_H
#include <memory>
@@ -19,12 +24,13 @@ public:
class Executor : private NoDefaultMethods {
public:
Executor(String threadName,ThreadPriority priority);
static ConstructDestructCallback *getConstructDestructCallback();
static Executor *create(String threadName,ThreadPriority priority);
ExecutorNode * createNode(Command *command);
void execute(ExecutorNode *node);
void destroy();
private:
Executor(String threadName,ThreadPriority priority);
~Executor();
class ExecutorPvt *pImpl;
};

View File

@@ -1,4 +1,9 @@
/* linkedList.h */
/**
* 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.
*/
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
#include "linkedListVoid.h"

View File

@@ -1,4 +1,9 @@
/* linkedListVoid.cpp */
/**
* 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.
*/
#include <cstddef>
#include <cstdlib>
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/* linkedListVoid.h */
/**
* 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.
*/
#include "pvType.h"
#include "showConstructDestruct.h"

View File

@@ -1,4 +1,9 @@
/* lock.h */
/**
* 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.
*/
#ifndef LOCK_H
#define LOCK_H
#include <epicsMutex.h>

View File

@@ -1,4 +1,9 @@
/* noDefaultMethods.h */
/**
* 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.
*/
#ifndef NO_DEFAULT_METHODS_H
#define NO_DEFAULT_METHODS_H
namespace epics { namespace pvData {

View File

@@ -1,4 +1,9 @@
/* pvType.h */
/**
* 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.
*/
#include <string>
#ifndef PVTYPE_H
#define PVTYPE_H

View File

@@ -1,4 +1,9 @@
/* requester.h */
/**
* 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.
*/
#include <string>
#ifndef REQUESTER_H
#define REQUESTER_H

View File

@@ -1,4 +1,9 @@
/* serialize.h */
/**
* 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.
*/
#ifndef SERIALIZE_H
#define SERIALIZE_H
#include "bitSet.h"

View File

@@ -1,3 +1,8 @@
/**
* 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.
*/
/*
* serializeHelper.cpp
*

View File

@@ -1,3 +1,8 @@
/**
* 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.
*/
/*
* serializeHelper.h
*

View File

@@ -1,4 +1,9 @@
/* showConstructDestruct.cpp */
/**
* 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.
*/
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>

View File

@@ -1,4 +1,9 @@
/* showConstructDestruct.h */
/**
* 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.
*/
#ifndef SHOWCONSTRUCTDESTRUCT_H
#define SHOWCONSTRUCTDESTRUCT_H
#include <stddef.h>

View File

@@ -1,4 +1,9 @@
/* thread.cpp */
/**
* 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.
*/
#include <cstddef>
#include <cstdlib>
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/* thread.h */
/**
* 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.
*/
#ifndef THREAD_H
#define THREAD_H
#include "noDefaultMethods.h"

View File

@@ -1,4 +1,9 @@
/* timeFunction.cpp */
/**
* 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.
*/
#include "noDefaultMethods.h"
#include "pvType.h"
#include "timeStamp.h"
@@ -27,15 +32,15 @@ TimeFunction::~TimeFunction() {}
double TimeFunction::timeCall()
{
TimeStamp startTime(0,0);
TimeStamp endTime(0,0);
TimeStamp startTime;
TimeStamp endTime;
double perCall = 0.0;
long ntimes = 1;
while(true) {
startTime.getCurrent();
for(long i=0; i<ntimes; i++) requester->function();
endTime.getCurrent();
double diff = TimeStamp::diffInSeconds(&endTime,&startTime);
double diff = TimeStamp::diff(endTime,startTime);
if(diff>=1.0) {
perCall = diff/(double)ntimes;
break;

View File

@@ -1,4 +1,9 @@
/* timeFunction.h */
/**
* 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.
*/
#ifndef TIMEFUNCTION_H
#define TIMEFUNCTION_H
#include "noDefaultMethods.h"

View File

@@ -1,4 +1,15 @@
/* timeStamp.cpp */
/**
* 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.
*/
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <epicsTime.h>
#include "noDefaultMethods.h"
#include "pvType.h"
@@ -6,40 +17,126 @@
namespace epics { namespace pvData {
static uint64 TS_EPOCH_SEC_PAST_1970=7305*86400;
int32 milliSecPerSec = 1000;
int32 microSecPerSec = milliSecPerSec*milliSecPerSec;
int32 nanoSecPerSec = milliSecPerSec*microSecPerSec;
int64 posixEpochAtEpicsEpoch = POSIX_TIME_AT_EPICS_EPOCH;
TimeStamp::TimeStamp(uint64 secondsPastEpoch,uint32 nanoSeconds)
TimeStamp::TimeStamp(int64 secondsPastEpoch,int32 nanoSeconds)
: secondsPastEpoch(secondsPastEpoch),nanoSeconds(nanoSeconds)
{}
TimeStamp::~TimeStamp() {}
int64 TimeStamp::getEpicsSecondsPastEpoch()
{
return secondsPastEpoch - TS_EPOCH_SEC_PAST_1970;
}
void TimeStamp::put(uint64 seconds,uint32 nano)
{
secondsPastEpoch = seconds;
nanoSeconds = nano;
}
void TimeStamp::getCurrent()
{
epicsTimeStamp epicsTime;
epicsTimeGetCurrent(&epicsTime);
secondsPastEpoch = epicsTime.secPastEpoch;
secondsPastEpoch += TS_EPOCH_SEC_PAST_1970;
secondsPastEpoch += posixEpochAtEpicsEpoch;
nanoSeconds = epicsTime.nsec;
}
double TimeStamp::diffInSeconds(TimeStamp *left,TimeStamp *right)
double TimeStamp::toSeconds() const
{
double diff = left->secondsPastEpoch - right->secondsPastEpoch;
int64 nano =left->nanoSeconds - right->nanoSeconds;
diff += ((double)nano)/1e9;
return diff;
double value = secondsPastEpoch;
double nano = nanoSeconds;
value += nano/1e9;
return value;
}
int64 TimeStamp::diffInt(TimeStamp const & left,TimeStamp const&right )
{
int64 sl = left.secondsPastEpoch;
int32 nl = left.nanoSeconds;
int64 sr = right.secondsPastEpoch;
int32 nr = right.nanoSeconds;
int64 sdiff = sl - sr;
sdiff *= nanoSecPerSec;
sdiff += nl - nr;
return sdiff;
}
bool TimeStamp::operator==(TimeStamp const &right) const
{
int64 sdiff = diffInt(*this,right);
if(sdiff==0) return true;
return false;
}
bool TimeStamp::operator!=(TimeStamp const &right) const
{
int64 sdiff = diffInt(*this,right);
if(sdiff!=0) return true;
return false;
}
bool TimeStamp::operator<=(TimeStamp const &right) const
{
int64 sdiff = diffInt(*this,right);
if(sdiff<=0) return true;
return false;
}
bool TimeStamp::operator< (TimeStamp const &right) const
{
int64 sdiff = diffInt(*this,right);
if(sdiff<0) return true;
return false;
}
bool TimeStamp::operator>=(TimeStamp const &right) const
{
int64 sdiff = diffInt(*this,right);
if(sdiff>=0) return true;
return false;
}
bool TimeStamp::operator>(TimeStamp const &right) const
{
int64 sdiff = diffInt(*this,right);
if(sdiff>0) return true;
return false;
}
double TimeStamp::diff(TimeStamp const & a,TimeStamp const & b)
{
double result = a.secondsPastEpoch - b.secondsPastEpoch;
result += (a.nanoSeconds - b.nanoSeconds)/1e9;
return result;
}
TimeStamp & TimeStamp::operator+=(int64 seconds)
{
secondsPastEpoch += seconds;
return *this;
}
TimeStamp & TimeStamp::operator-=(int64 seconds)
{
secondsPastEpoch -= seconds;
return *this;
}
TimeStamp & TimeStamp::operator+=(double seconds)
{
int64 secs = seconds;
int64 nano = (seconds - secs)*1e9;
nanoSeconds += nano;
if(nanoSeconds>nanoSecPerSec) {
nanoSeconds -= nanoSecPerSec;
secondsPastEpoch += 1;
} else if(nanoSeconds<-nanoSecPerSec) {
nanoSeconds += -nanoSecPerSec;
secondsPastEpoch -= 1;
}
secondsPastEpoch += secs;
return *this;
}
TimeStamp & TimeStamp::operator-=(double seconds)
{
return operator+=(-seconds);
}
int64 TimeStamp::getMilliseconds()

View File

@@ -1,25 +1,57 @@
/* timeStamp.h */
/**
* 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.
*/
#ifndef TIMESTAMP_H
#define TIMESTAMP_H
#include "noDefaultMethods.h"
#include "epicsTime.h"
#include "pvType.h"
namespace epics { namespace pvData {
class TimeStamp : private NoDefaultMethods {
extern int32 milliSecPerSec;
extern int32 microSecPerSec;
extern int32 nanoSecPerSec;
extern int64 posixEpochAtEpicsEpoch;
class TimeStamp {
public:
TimeStamp(uint64 secondsPastEpoch,uint32 nanoSeconds);
~TimeStamp();
int64 getSecondsPastEpoch(){return secondsPastEpoch;}
int32 getNanoSeconds() {return nanoSeconds;}
int64 getEpicsSecondsPastEpoch();
void put(uint64 secondsPastEpoch,uint32 nanoSeconds);
TimeStamp()
:secondsPastEpoch(0),nanoSeconds(0) {}
//default constructors and destructor are OK
//This class should not be extended
TimeStamp(int64 secondsPastEpoch,int32 nanoSeconds = 0);
TimeStamp(epicsTimeStamp &epics);
int64 getSecondsPastEpoch() const {return secondsPastEpoch;}
int64 getEpicsSecondsPastEpoch() const {
return secondsPastEpoch - posixEpochAtEpicsEpoch;
}
int32 getNanoSeconds() const {return nanoSeconds;}
void put(int64 secondsPastEpoch,int32 nanoSeconds = 0) {
this->secondsPastEpoch = secondsPastEpoch;
this->nanoSeconds = nanoSeconds;
}
void getCurrent();
static double diffInSeconds(TimeStamp *left,TimeStamp *right);
double toSeconds() const ;
bool operator==(TimeStamp const &) const;
bool operator!=(TimeStamp const &) const;
bool operator<=(TimeStamp const &) const;
bool operator< (TimeStamp const &) const;
bool operator>=(TimeStamp const &) const;
bool operator> (TimeStamp const &) const;
static double diff(TimeStamp const & a,TimeStamp const & b);
TimeStamp & operator+=(int64 seconds);
TimeStamp & operator-=(int64 seconds);
TimeStamp & operator+=(double seconds);
TimeStamp & operator-=(double seconds);
// milliseconds since epoch
int64 getMilliseconds();
void put(int64 milliseconds);
private:
static int64 diffInt(TimeStamp const &left,TimeStamp const &right );
int64 secondsPastEpoch;
int32 nanoSeconds;
};

332
pvDataApp/misc/timer.cpp Normal file
View File

@@ -0,0 +1,332 @@
/* timer.cpp */
/**
* 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.
*/
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <stdexcept>
#include "pvType.h"
#include "lock.h"
#include "noDefaultMethods.h"
#include "showConstructDestruct.h"
#include "linkedList.h"
#include "thread.h"
#include "timeStamp.h"
#include "timer.h"
#include "event.h"
namespace epics { namespace pvData {
static volatile int64 totalNodeConstruct = 0;
static volatile int64 totalNodeDestruct = 0;
static volatile int64 totalTimerConstruct = 0;
static volatile int64 totalTimerDestruct = 0;
static Mutex *globalMutex = 0;
static int64 getTotalTimerNodeConstruct()
{
Lock xx(globalMutex);
return totalNodeConstruct;
}
static int64 getTotalTimerNodeDestruct()
{
Lock xx(globalMutex);
return totalNodeDestruct;
}
static int64 getTotalTimerConstruct()
{
Lock xx(globalMutex);
return totalTimerConstruct;
}
static int64 getTotalTimerDestruct()
{
Lock xx(globalMutex);
return totalTimerDestruct;
}
static ConstructDestructCallback *pCDCallbackTimerNode;
static ConstructDestructCallback *pCDCallbackTimer;
static void init()
{
static Mutex mutex = Mutex();
Lock xx(&mutex);
if(globalMutex==0) {
globalMutex = new Mutex();
pCDCallbackTimerNode = new ConstructDestructCallback(
"timerNode",
getTotalTimerNodeConstruct,getTotalTimerNodeDestruct,0);
pCDCallbackTimer = new ConstructDestructCallback(
"timer",
getTotalTimerConstruct,getTotalTimerDestruct,0);
}
}
ConstructDestructCallback * TimerNode::getConstructDestructCallback()
{
init();
return pCDCallbackTimerNode;
}
ConstructDestructCallback * Timer::getConstructDestructCallback()
{
init();
return pCDCallbackTimer;
}
class TimerNodePvt;
typedef LinkedListNode<TimerNodePvt> ListNode;
typedef LinkedList<TimerNodePvt> List;
class TimerNodePvt {
public:
TimerNode *timerNode;
TimerCallback *callback;
ListNode *listNode;
TimeStamp timeToRun;
TimerPvt *timerPvt;
double period;
TimerNodePvt(TimerNode *timerNode,TimerCallback *callback);
~TimerNodePvt();
};
TimerNodePvt::TimerNodePvt(TimerNode *timerNode,TimerCallback *callback)
: timerNode(timerNode),callback(callback),
listNode(new ListNode(this)),timeToRun(TimeStamp()),
timerPvt(0), period(0.0)
{}
TimerNodePvt::~TimerNodePvt()
{
delete listNode;
}
struct TimerPvt : public RunnableReady {
public:
TimerPvt(String threadName,ThreadPriority priority);
~TimerPvt();
virtual void run(ThreadReady *threadReady);
public: // only used by this source module
List *list;
Mutex mutex;
Event *waitForWork;
Event *waitForDone;
Thread *thread;
volatile bool alive;
};
TimerPvt::TimerPvt(String threadName,ThreadPriority priority)
: list(new List()),
mutex(Mutex()),
waitForWork(new Event(eventEmpty)),
waitForDone(new Event(eventEmpty)),
thread(new Thread(threadName,priority,this)),
alive(true)
{
thread->start();
}
TimerPvt::~TimerPvt()
{
delete thread;
delete waitForDone;
delete waitForWork;
delete list;
}
static void addElement(TimerPvt *timer,TimerNodePvt *node)
{
List *list = timer->list;
ListNode *nextNode = list->getHead();
if(nextNode==0) {
list->addTail(node->listNode);
return;
}
while(true) {
TimerNodePvt *listNode = nextNode->getObject();
if((node->timeToRun)<(listNode->timeToRun)) {
list->insertBefore(listNode->listNode,node->listNode);
return;
}
nextNode = list->getNext(listNode->listNode);
if(nextNode==0) {
list->addTail(node->listNode);
return;
}
}
}
TimerNode::TimerNode(TimerCallback *callback)
: pImpl(new TimerNodePvt(this,callback))
{
init();
Lock xx(globalMutex);
totalNodeConstruct++;
}
TimerNode *TimerNode::create(TimerCallback *callback)
{
return new TimerNode(callback);
}
TimerNode::~TimerNode()
{
delete pImpl;
Lock xx(globalMutex);
totalNodeDestruct++;
}
void TimerNode::destroy()
{
cancel();
delete this;
}
void TimerNode::cancel()
{
TimerPvt *timerPvt = pImpl->timerPvt;
if(timerPvt==0) return;
Lock xx(&timerPvt->mutex);
if(pImpl->timerPvt==0) return;
pImpl->timerPvt->list->remove(pImpl);
pImpl->timerPvt = 0;
}
bool TimerNode::isScheduled()
{
TimerPvt *pvt = pImpl->timerPvt;
if(pvt==0) return false;
Lock xx(&pvt->mutex);
return pImpl->listNode->isOnList();
}
void TimerPvt::run(ThreadReady *threadReady)
{
threadReady->ready();
TimeStamp currentTime;
while(alive) {
currentTime.getCurrent();
TimeStamp *timeToRun = 0;
double period = 0.0;
TimerNodePvt *nodeToCall = 0;
{
Lock xx(&mutex);
ListNode *listNode = list->getHead();
if(listNode!=0) {
TimerNodePvt *timerNodePvt = listNode->getObject();
timeToRun = &timerNodePvt->timeToRun;
double diff = TimeStamp::diff(
*timeToRun,currentTime);
if(diff<=0.0) {
nodeToCall = timerNodePvt;
list->removeHead();
period = timerNodePvt->period;
if(period>0) {
timerNodePvt->timeToRun += period;
addElement(this,timerNodePvt);
} else {
timerNodePvt->timerPvt = 0;
}
listNode = list->getHead();
if(listNode!=0) {
timerNodePvt = listNode->getObject();
timeToRun = &timerNodePvt->timeToRun;
} else {
timeToRun = 0;
}
}
}
}
if(nodeToCall!=0) {
nodeToCall->callback->callback();
}
if(!alive) break;
if(timeToRun==0) {
waitForWork->wait();
} else {
double delay = TimeStamp::diff(*timeToRun,currentTime);
waitForWork->wait(delay);
}
}
waitForDone->signal();
}
Timer::Timer(String threadName, ThreadPriority priority)
: pImpl(new TimerPvt(threadName,priority))
{
init();
Lock xx(globalMutex);
totalTimerConstruct++;
}
Timer * Timer::create(String threadName, ThreadPriority priority)
{
return new Timer(threadName,priority);
}
Timer::~Timer() {
delete pImpl;
Lock xx(globalMutex);
totalTimerDestruct++;
}
void Timer::destroy()
{
{
Lock xx(&pImpl->mutex);
pImpl->alive = false;
pImpl->waitForWork->signal();
pImpl->waitForDone->wait();
}
List *list = pImpl->list;
ListNode *node = 0;
while((node = list->removeHead())!=0) {
node->getObject()->callback->timerStopped();
}
delete this;
}
void Timer::scheduleAfterDelay(TimerNode *timerNode,double delay)
{
schedulePeriodic(timerNode,delay,0.0);
}
void Timer::schedulePeriodic(TimerNode *timerNode,double delay,double period)
{
TimerNodePvt *timerNodePvt = timerNode->pImpl;
if(timerNodePvt->listNode->isOnList()) {
throw std::logic_error(String("already queued"));
}
if(!pImpl->alive) {
timerNodePvt->callback->timerStopped();
return;
}
TimeStamp *timeStamp = &timerNodePvt->timeToRun;
timeStamp->getCurrent();
*timeStamp += delay;
timerNodePvt->period = period;
bool isFirst = false;
{
Lock xx(&pImpl->mutex);
timerNodePvt->timerPvt = pImpl;
addElement(pImpl,timerNodePvt);
TimerNodePvt *first = pImpl->list->getHead()->getObject();
if(first==timerNodePvt) isFirst = true;
}
if(isFirst) pImpl->waitForWork->signal();
}
}}

57
pvDataApp/misc/timer.h Normal file
View File

@@ -0,0 +1,57 @@
/* timer.h */
/**
* 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.
*/
#ifndef TIMER_H
#define TIMER_H
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "pvType.h"
#include "thread.h"
#include "noDefaultMethods.h"
#include "showConstructDestruct.h"
namespace epics { namespace pvData {
class TimerCallback {
public:
virtual void callback() = 0;
virtual void timerStopped() = 0;
};
class TimerNode : private NoDefaultMethods {
public:
static ConstructDestructCallback *getConstructDestructCallback();
static TimerNode *create(TimerCallback *timerCallback);
void destroy();
void cancel();
bool isScheduled();
private:
TimerNode(TimerCallback *timerCallback);
~TimerNode();
class TimerNodePvt *pImpl;
friend class Timer;
};
class Timer : private NoDefaultMethods {
public:
static ConstructDestructCallback *getConstructDestructCallback();
static Timer * create(String threadName, ThreadPriority priority);
void destroy();
void scheduleAfterDelay(TimerNode *timerNode,double delay);
void schedulePeriodic(TimerNode *timerNode,double delay,double period);
private:
Timer(String threadName, ThreadPriority priority);
~Timer();
class TimerPvt *pImpl;
friend class TimerNode;
};
}}
#endif /* TIMER_H */

View File

@@ -2,6 +2,10 @@ TOP=../..
include $(TOP)/configure/CONFIG
PROD_HOST += testTimeStamp
testTimeStamp_SRCS += testTimeStamp.cpp
testTimeStamp_LIBS += pvMisc Com
PROD_HOST += testLinkedList
testLinkedList_SRCS += testLinkedList.cpp
testLinkedList_LIBS += pvMisc Com
@@ -10,6 +14,10 @@ PROD_HOST += testThread
testThread_SRCS += testThread.cpp
testThread_LIBS += pvMisc Com
PROD_HOST += testTimer
testTimer_SRCS += testTimer.cpp
testTimer_LIBS += pvMisc Com
PROD_HOST += testBitSet
testBitSet_SRCS += testBitSet.cpp
testBitSet_LIBS += pvMisc Com

View File

@@ -1,4 +1,9 @@
/* testBaseException.cpp */
/**
* 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.
*/
/* Author: Matej Sekoranja Date: 2010.10.18 */
#include <stddef.h>

View File

@@ -1,4 +1,9 @@
/* testBitSet.cpp */
/**
* 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.
*/
/* Author: Matej Sekoranja Date: 2010.10.18 */
#include <stddef.h>

View File

@@ -1,3 +1,8 @@
/**
* 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.
*/
/*
* testByteBuffer.cpp
*

View File

@@ -1,3 +1,8 @@
/**
* 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.
*/
/*
* testLinkedList.cpp
*
@@ -270,8 +275,8 @@ static void testOrderedQueue(FILE * fd ) {
}
static void testTime(FILE *auxFd) {
TimeStamp startTime(0,0);
TimeStamp endTime(0,0);
TimeStamp startTime;
TimeStamp endTime;
int numNodes = 1000;
LinkedList<Basic> *basicList = new BasicList();
@@ -288,7 +293,7 @@ static void testTime(FILE *auxFd) {
while(basicNode!=0) basicNode = basicList->removeHead();
}
endTime.getCurrent();
double diff = TimeStamp::diffInSeconds(&endTime,&startTime);
double diff = TimeStamp::diff(endTime,startTime);
diff /= 1000.0;
fprintf(auxFd,"diff %f milliSeconds\n",diff);
diff = diff/1000.0; // convert from milliseconds to seconds
@@ -303,8 +308,8 @@ static void testTime(FILE *auxFd) {
}
static void testTimeLocked(FILE *auxFd) {
TimeStamp startTime(0,0);
TimeStamp endTime(0,0);
TimeStamp startTime;
TimeStamp endTime;
Mutex *mutex = new Mutex();
int numNodes = 1000;
@@ -332,7 +337,7 @@ static void testTimeLocked(FILE *auxFd) {
}
}
endTime.getCurrent();
double diff = TimeStamp::diffInSeconds(&endTime,&startTime);
double diff = TimeStamp::diff(endTime,startTime);
diff *= 1000.0;
fprintf(auxFd,"diff %f milliSeconds\n",diff);
diff = diff/1000.0; // convert from milliseconds to seconds
@@ -348,8 +353,8 @@ static void testTimeLocked(FILE *auxFd) {
typedef std::list<Basic *> stdList;
static void testArrayListTime(FILE *auxFd) {
TimeStamp startTime(0,0);
TimeStamp endTime(0,0);
TimeStamp startTime;
TimeStamp endTime;
int numNodes = 1000;
stdList basicList;
@@ -368,7 +373,7 @@ static void testArrayListTime(FILE *auxFd) {
}
}
endTime.getCurrent();
double diff = TimeStamp::diffInSeconds(&endTime,&startTime);
double diff = TimeStamp::diff(endTime,startTime);
diff *= 1000.0;
fprintf(auxFd,"diff %f milliSeconds\n",diff);
diff = diff/1000.0; // convert from milliseconds to seconds
@@ -381,8 +386,8 @@ static void testArrayListTime(FILE *auxFd) {
}
static void testArrayListTimeLocked(FILE *auxFd) {
TimeStamp startTime(0,0);
TimeStamp endTime(0,0);
TimeStamp startTime;
TimeStamp endTime;
int numNodes = 1000;
Mutex *mutex = new Mutex();
@@ -406,7 +411,7 @@ static void testArrayListTimeLocked(FILE *auxFd) {
}
}
endTime.getCurrent();
double diff = TimeStamp::diffInSeconds(&endTime,&startTime);
double diff = TimeStamp::diff(endTime,startTime);
diff *= 1000.0;
fprintf(auxFd,"diff %f milliSeconds\n",diff);
diff = diff/1000.0; // convert from milliseconds to seconds

View File

@@ -1,3 +1,8 @@
/**
* 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.
*/
/*
* testSerialization.cpp
*

View File

@@ -1,3 +1,8 @@
/**
* 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.
*/
/*
* testThread.cpp
*
@@ -60,7 +65,7 @@ void Basic::command()
static void testBasic(FILE *fd) {
Executor *executor = new Executor(String("basic"),middlePriority);
Executor *executor = Executor::create(String("basic"),middlePriority);
Basic *basic = new Basic(executor);
basic->run();
delete basic;
@@ -84,7 +89,7 @@ private:
};
static void testThreadContext(FILE *fd,FILE *auxFd) {
Executor *executor = new Executor(String("basic"),middlePriority);
Executor *executor = Executor::create(String("basic"),middlePriority);
Basic *basic = new Basic(executor);
MyFunc myFunc(basic);
TimeFunction timeFunction(&myFunc);

View 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.
*/
/*
* testTimeStamp.cpp
*
* Created on: 2010.11
* Author: Marty Kraimer
*/
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <list>
#include <epicsAssert.h>
#include "timeStamp.h"
using namespace epics::pvData;
void testTimeStamp(FILE *fd,FILE *auxfd)
{
assert(nanoSecPerSec==1000000000);
TimeStamp current;
current.getCurrent();
fprintf(auxfd,"current %lli %i milliSec %lli\n",
current.getSecondsPastEpoch(),
current.getNanoSeconds(),
current.getMilliseconds());
TimeStamp right;
TimeStamp left;
right.put(current.getSecondsPastEpoch(),current.getNanoSeconds());
left.put(current.getSecondsPastEpoch(),current.getNanoSeconds());
double diff;
diff = TimeStamp::diff(left,right);
fprintf(fd,"diff %e\n",diff);
assert(diff==0.0);
assert((left==right));
assert(!(left!=right));
assert((left<=right));
assert(!(left<right));
assert((left>=right));
assert(!(left>right));
left.put(current.getSecondsPastEpoch()+1,current.getNanoSeconds());
diff = TimeStamp::diff(left,right);
fprintf(fd,"diff %e\n",diff);
assert(!(left==right));
assert((left!=right));
assert(!(left<=right));
assert(!(left<right));
assert((left>=right));
assert((left>right));
left.put(current.getSecondsPastEpoch()-1,current.getNanoSeconds());
diff = TimeStamp::diff(left,right);
fprintf(fd,"diff %e\n",diff);
assert(diff==-1.0);
assert(!(left==right));
assert((left!=right));
assert((left<=right));
assert((left<right));
assert(!(left>=right));
assert(!(left>right));
left.put(current.getSecondsPastEpoch(),current.getNanoSeconds()-nanoSecPerSec);
diff = TimeStamp::diff(left,right);
fprintf(fd,"diff %e\n",diff);
assert(diff==-1.0);
assert(!(left==right));
assert((left!=right));
assert((left<=right));
assert((left<right));
assert(!(left>=right));
assert(!(left>right));
left.put(current.getSecondsPastEpoch(),current.getNanoSeconds()-1);
diff = TimeStamp::diff(left,right);
fprintf(fd,"diff %e\n",diff);
assert(diff<0.0);
assert(!(left==right));
assert((left!=right));
assert((left<=right));
assert((left<right));
assert(!(left>=right));
assert(!(left>right));
left.put(current.getSecondsPastEpoch(),current.getNanoSeconds());
left += .1;
diff = TimeStamp::diff(left,right);
fprintf(fd,"diff %e\n",diff);
left.put(current.getSecondsPastEpoch(),current.getNanoSeconds());
int64 inc = -1;
left += inc;
diff = TimeStamp::diff(left,right);
assert(diff==-1.0);
}
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+");
}
char *auxFileName = 0;
if(argc>2) auxFileName = argv[2];
FILE *auxfd = stdout;
if(auxFileName!=0 && auxFileName[0]!=0) {
auxfd = fopen(auxFileName,"w+");
}
testTimeStamp(fd,auxfd);
return (0);
}

View File

@@ -0,0 +1,117 @@
/**
* 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.
*/
/*
* testTimer.cpp
*
* Created on: 2010.11
* Author: Marty Kraimer
*/
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <epicsAssert.h>
#include "timeStamp.h"
#include "event.h"
#include "timer.h"
#include "thread.h"
#include "showConstructDestruct.h"
using namespace epics::pvData;
static TimeStamp currentTimeStamp;
static double oneDelay = 4.0;
static double twoDelay = 2.0;
class MyCallback : public TimerCallback {
public:
MyCallback(String name,FILE *fd,FILE *auxfd,Event *wait)
: name(name),fd(fd),auxfd(auxfd),wait(wait),
timerNode(TimerNode::create(this)),timeStamp(TimeStamp())
{
}
~MyCallback()
{
timerNode->destroy();
}
virtual void callback()
{
timeStamp.getCurrent();
wait->signal();
}
virtual void timerStopped()
{
fprintf(fd,"timerStopped %s\n",name.c_str());
}
TimerNode *getTimerNode() { return timerNode;}
TimeStamp &getTimeStamp() { return timeStamp;}
private:
String name;
FILE *fd;
FILE *auxfd;
Event *wait;
TimerNode *timerNode;
TimeStamp timeStamp;
};
static void testBasic(FILE *fd, FILE *auxfd)
{
String one("one");
String two("two");
Event *eventOne = new Event(eventEmpty);
Event *eventTwo = new Event(eventEmpty);
Timer *timer = Timer::create(String("timer"),middlePriority);
MyCallback *callbackOne = new MyCallback(
one,fd,auxfd,eventOne);
MyCallback *callbackTwo = new MyCallback(
two,fd,auxfd,eventTwo);
currentTimeStamp.getCurrent();
timer->scheduleAfterDelay(callbackOne->getTimerNode(),oneDelay);
timer->scheduleAfterDelay(callbackTwo->getTimerNode(),twoDelay);
eventOne->wait();
eventTwo->wait();
double diff;
diff = TimeStamp::diff(
callbackOne->getTimeStamp(),currentTimeStamp);
fprintf(auxfd,"one requested %f diff %f seconds\n",oneDelay,diff);
diff = TimeStamp::diff(
callbackTwo->getTimeStamp(),currentTimeStamp);
fprintf(auxfd,"two requested %f diff %f seconds\n",twoDelay,diff);
timer->destroy();
delete callbackOne;
delete callbackTwo;
delete eventOne;
delete eventTwo;
}
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+");
}
char *auxFileName = 0;
if(argc>2) auxFileName = argv[2];
FILE *auxfd = stdout;
if(auxFileName!=0 && auxFileName[0]!=0) {
auxfd = fopen(auxFileName,"w+");
}
oneDelay = .4;
twoDelay = .2;
testBasic(fd,auxfd);
oneDelay = .2;
twoDelay = .4;
testBasic(fd,auxfd);
oneDelay = .0;
twoDelay = .0;
testBasic(fd,auxfd);
getShowConstructDestruct()->constuctDestructTotals(fd);
return (0);
}

View File

@@ -3,11 +3,13 @@ TOP=../..
include $(TOP)/configure/CONFIG
INC += enumerated.h
INC += pvTimeStamp.h
LIBSRCS += enumerated.cpp
enumerated_LIBS += pvFactory pvMisc Com
#LIBSRCS += enumerated.cpp
#LIBSRCS += pvTimeStamp.cpp
#enumerated_LIBS += pvFactory pvMisc Com
LIBRARY=pvProperty
#LIBRARY=pvProperty
include $(TOP)/configure/RULES

View File

@@ -1,4 +1,9 @@
/* enumerated.cpp */
/**
* 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.
*/
#include <string>
#include <stdexcept>
#include "pvType.h"

View File

@@ -1,28 +1,37 @@
/* enumerated.h */
/**
* 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.
*/
#include <string>
#include <stdexcept>
#include "pvTypes.h"
#include "pvData.h"
#ifndef ENUMERATED_H
#define ENUMERATED_H
#include "pvIntrospect.h"
#include "pvData.h"
#include "noDefaultMethods.h"
namespace epics { namespace pvData {
class Enumerated : private NoDefaultMethods {
class Enumerated ;
public:
static Enumerated* create(PVField *pvField);
//default constructors and destructor are OK
//This class should not be extended
//returns (false,true) if pvField(isNot, is valid enumerated structure
bool attach(PVField *pvField);
~Enumerated();
PVInt *getIndex() { return pvIndex;}
// each of the following throws logic_error is not attached to PVField
void putIndex(int32 index);
int32 getIndex();
String getChoice();
PVStringArray *getChoices() { return pvChoices;}
PVStructure *getPV() { return pvStructure;}
bool choicesMutable();
StringArray getChoices();
int32 getNumberChoices();
// also throws logic_error of immutable
void putChoices(StringArray choices,int32 numberChoices);
private:
Enumerated(PVStructure *pvStructure,
PVInt *pvIndex,PVStringArray *pvChoices);
PVStructure *pvStructure;
PVInt *pvIndex;
PVStringArray *pvChoices;
StringArrayData stringArrayData;
};
}}

View File

@@ -0,0 +1,33 @@
/* pvTimeStamp.h */
/**
* 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.
*/
#include <string>
#include <stdexcept>
#ifndef PVTIMESTAMP_H
#define PVTIMESTAMP_H
#include "pvTypes.h"
#include "timeStamp.h"
#include "pvData.h"
namespace epics { namespace pvData {
class PVTimeStamp {
public:
//default constructors and destructor are OK
//This class should not be extended
//returns (false,true) if pvField(isNot, is valid timeStamp structure
bool attach(PVField *pvField);
// throws logic_error is not attached to PVField
TimeStamp &get();
// throws logic_error is not attached to PVField
void put (TimeStamp &timeStamp);
private:
PVLong* pvSecs;
PVInt* pvNano;
};
}}
#endif /* PVTIMESTAMP_H */

View File

@@ -1,4 +1,9 @@
/* convert.h */
/**
* 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.
*/
#include <string>
#include <stdexcept>
#ifndef CONVERT_H

View File

@@ -1,4 +1,9 @@
/* pvData.h */
/**
* 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.
*/
#include <string>
#include <stdexcept>
#include <map>

View File

@@ -1,4 +1,9 @@
/* pvIntrospect.h */
/**
* 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.
*/
#include <string>
#include <stdexcept>
#ifndef PVINTROSPECT_H

View File

@@ -1,4 +1,9 @@
/* standardField.h */
/**
* 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.
*/
#include <string>
#include <stdexcept>
#ifndef STANDARDFIELD_H

View File

@@ -1,4 +1,9 @@
/* standardPVField.h */
/**
* 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.
*/
#include <string>
#include <stdexcept>
#ifndef STANDARDPVFIELD_H

View File

@@ -1,4 +1,9 @@
/* testIntrospect.cpp */
/**
* 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.
*/
/* Author: Marty Kraimer Date: 2010.09 */
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/* testPVAuxInfo.cpp */
/**
* 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.
*/
/* Author: Marty Kraimer Date: 2010.11 */
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/* testPVdata.cpp */
/**
* 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.
*/
/* Author: Marty Kraimer Date: 2010.11 */
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/* testPVStructureArray.cpp */
/**
* 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.
*/
/* Author: Marty Kraimer Date: 2010.10 */
#include <cstddef>

View File

@@ -1,4 +1,9 @@
/* testPVType.cpp */
/**
* 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.
*/
/* Author: Marty Kraimer Date: 2010.09 */
#include <cstddef>

View File

@@ -8,3 +8,5 @@ system ("./testIntrospect.pl");
system ("./testPVData.pl");
system ("./testPVStructureArray.pl");
system ("./testPVAuxInfo.pl");
system ("./testTimeStamp.pl");
system ("./testTimer.pl");

View File

@@ -5,16 +5,16 @@ time per iteration 0.000025 microseconds
time per addTail/removeHead 0.000000 microseconds
Time test locked
diff 183.634382 milliSeconds
time per iteration 183.634382 microseconds
time per addTail/removeHead 0.091817 microseconds
diff 186.459567 milliSeconds
time per iteration 186.459567 microseconds
time per addTail/removeHead 0.093230 microseconds
Time ArrayList test
diff 647.257745 milliSeconds
time per iteration 647.257745 microseconds
time per addTail/removeHead 0.323629 microseconds
diff 652.028489 milliSeconds
time per iteration 652.028489 microseconds
time per addTail/removeHead 0.326014 microseconds
Time ArrayList test locked
diff 810.656009 milliSeconds
time per iteration 810.656009 microseconds
time per addTail/removeHead 0.405328 microseconds
diff 799.889631 milliSeconds
time per iteration 799.889631 microseconds
time per addTail/removeHead 0.399945 microseconds

View File

@@ -1 +1 @@
time per call 38.976797 microseconds
time per call 36.953844 microseconds

6
test/testTimeStamp Normal file
View File

@@ -0,0 +1,6 @@
diff 0.000000e+00
diff 1.000000e+00
diff -1.000000e+00
diff -1.000000e+00
diff -1.000000e-09
diff 1.000000e-01

12
test/testTimeStamp.pl Executable file
View File

@@ -0,0 +1,12 @@
eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*-
if $running_under_some_shell; # testTimeStamp.pl
use Env;
system ("rm testTimeStamp");
system ("rm testTimeStampDiff");
system ("../bin/${EPICS_HOST_ARCH}/testTimeStamp testTimeStamp testTimeStampAux");
system ("diff testTimeStamp testTimeStampGold >> testTimeStampDiff");
if(-z "testTimeStampDiff") {
print "testTimeStamp OK\n";
} else {
print "testTimeStamp Failed\n";
}

1
test/testTimeStampAux Normal file
View File

@@ -0,0 +1 @@
current 1290514910 631889964 milliSec 1290514910631

0
test/testTimeStampDiff Normal file
View File

6
test/testTimeStampGold Normal file
View File

@@ -0,0 +1,6 @@
diff 0.000000e+00
diff 1.000000e+00
diff -1.000000e+00
diff -1.000000e+00
diff -1.000000e-09
diff 1.000000e-01

4
test/testTimer Normal file
View File

@@ -0,0 +1,4 @@
event: totalConstruct 15 totalDestruct 15
thread: totalConstruct 3 totalDestruct 3
timerNode: totalConstruct 6 totalDestruct 6
timer: totalConstruct 3 totalDestruct 3

12
test/testTimer.pl Executable file
View File

@@ -0,0 +1,12 @@
eval 'exec perl -S $0 ${1+"$@"}' # -*- Mode: perl -*-
if $running_under_some_shell; # testTimer.pl
use Env;
system ("rm testTimer");
system ("rm testTimerDiff");
system ("../bin/${EPICS_HOST_ARCH}/testTimer testTimer testTimerAux");
system ("diff testTimer testTimerGold >> testTimerDiff");
if(-z "testTimerDiff") {
print "testTimer OK\n";
} else {
print "testTimer Failed\n";
}

6
test/testTimerAux Normal file
View File

@@ -0,0 +1,6 @@
one requested 0.400000 diff 0.400227 seconds
two requested 0.200000 diff 0.200181 seconds
one requested 0.200000 diff 0.200259 seconds
two requested 0.400000 diff 0.400413 seconds
one requested 0.000000 diff 0.000058 seconds
two requested 0.000000 diff 0.000082 seconds

0
test/testTimerDiff Normal file
View File

4
test/testTimerGold Normal file
View File

@@ -0,0 +1,4 @@
event: totalConstruct 15 totalDestruct 15
thread: totalConstruct 3 totalDestruct 3
timerNode: totalConstruct 6 totalDestruct 6
timer: totalConstruct 3 totalDestruct 3