osiTime=>epicsTime
This commit is contained in:
@@ -32,7 +32,6 @@ of this distribution.
|
||||
#include "caeventmask.h"
|
||||
#include "callback.h"
|
||||
#include "dbStaticLib.h"
|
||||
#include "tsStamp.h"
|
||||
#include "dbAddr.h"
|
||||
#include "dbAccess.h"
|
||||
#include "db_field_log.h"
|
||||
|
||||
@@ -72,8 +72,8 @@ bool CASG::verify () const
|
||||
int CASG::block ( double timeout )
|
||||
{
|
||||
unsigned long initialSeqNo = this->seqNo;
|
||||
osiTime cur_time;
|
||||
osiTime beg_time;
|
||||
epicsTime cur_time;
|
||||
epicsTime beg_time;
|
||||
double delay;
|
||||
double remaining;
|
||||
int status;
|
||||
@@ -92,7 +92,7 @@ int CASG::block ( double timeout )
|
||||
|
||||
epicsThreadPrivateSet (cacRecursionLock, &cacRecursionLock);
|
||||
|
||||
cur_time = osiTime::getCurrent ();
|
||||
cur_time = epicsTime::getCurrent ();
|
||||
|
||||
this->client.flush ();
|
||||
|
||||
@@ -133,7 +133,7 @@ int CASG::block ( double timeout )
|
||||
/*
|
||||
* force a time update
|
||||
*/
|
||||
cur_time = osiTime::getCurrent ();
|
||||
cur_time = epicsTime::getCurrent ();
|
||||
|
||||
delay = cur_time - beg_time;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* EPICS
|
||||
*/
|
||||
#include "epicsAssert.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "envDefs.h"
|
||||
|
||||
/*
|
||||
@@ -1332,18 +1332,18 @@ void arrayTest ( chid chan )
|
||||
void pend_event_delay_test(dbr_double_t request)
|
||||
{
|
||||
int status;
|
||||
TS_STAMP end_time;
|
||||
TS_STAMP start_time;
|
||||
epicsTimeStamp end_time;
|
||||
epicsTimeStamp start_time;
|
||||
dbr_double_t delay;
|
||||
dbr_double_t accuracy;
|
||||
|
||||
tsStampGetCurrent(&start_time);
|
||||
epicsTimeGetCurrent(&start_time);
|
||||
status = ca_pend_event(request);
|
||||
if (status != ECA_TIMEOUT) {
|
||||
SEVCHK(status, NULL);
|
||||
}
|
||||
tsStampGetCurrent(&end_time);
|
||||
delay = tsStampDiffInSeconds(&end_time,&start_time);
|
||||
epicsTimeGetCurrent(&end_time);
|
||||
delay = epicsTimeDiffInSeconds(&end_time,&start_time);
|
||||
accuracy = 100.0*(delay-request)/request;
|
||||
printf("CA pend event delay = %f sec results in error = %f %%\n",
|
||||
request, accuracy);
|
||||
@@ -1354,16 +1354,16 @@ void caTaskExistTest ()
|
||||
{
|
||||
int status;
|
||||
|
||||
TS_STAMP end_time;
|
||||
TS_STAMP start_time;
|
||||
epicsTimeStamp end_time;
|
||||
epicsTimeStamp start_time;
|
||||
dbr_double_t delay;
|
||||
|
||||
tsStampGetCurrent ( &start_time );
|
||||
epicsTimeGetCurrent ( &start_time );
|
||||
printf ( "entering ca_task_exit()\n" );
|
||||
status = ca_task_exit ();
|
||||
SEVCHK ( status, NULL );
|
||||
tsStampGetCurrent ( &end_time );
|
||||
delay = tsStampDiffInSeconds ( &end_time, &start_time );
|
||||
epicsTimeGetCurrent ( &end_time );
|
||||
delay = epicsTimeDiffInSeconds ( &end_time, &start_time );
|
||||
printf ( "in ca_task_exit() for %f sec\n", delay );
|
||||
}
|
||||
|
||||
@@ -1671,20 +1671,20 @@ int acctst ( char *pName, unsigned channelCount, unsigned repetitionCount )
|
||||
}
|
||||
|
||||
{
|
||||
TS_STAMP end_time;
|
||||
TS_STAMP start_time;
|
||||
epicsTimeStamp end_time;
|
||||
epicsTimeStamp start_time;
|
||||
dbr_double_t delay;
|
||||
dbr_double_t request = 15.0;
|
||||
dbr_double_t accuracy;
|
||||
|
||||
tsStampGetCurrent(&start_time);
|
||||
epicsTimeGetCurrent(&start_time);
|
||||
printf ("waiting for events for %f sec\n", request);
|
||||
status = ca_pend_event (request);
|
||||
if ( status != ECA_TIMEOUT ) {
|
||||
SEVCHK ( status, NULL );
|
||||
}
|
||||
tsStampGetCurrent ( &end_time );
|
||||
delay = tsStampDiffInSeconds ( &end_time, &start_time );
|
||||
epicsTimeGetCurrent ( &end_time );
|
||||
delay = epicsTimeDiffInSeconds ( &end_time, &start_time );
|
||||
accuracy = 100.0 * ( delay - request ) / request;
|
||||
printf ( "CA pend event delay accuracy = %f %%\n", accuracy );
|
||||
}
|
||||
|
||||
@@ -35,13 +35,13 @@ bhe::~bhe ()
|
||||
*
|
||||
* updates beacon period, and looks for beacon anomalies
|
||||
*/
|
||||
bool bhe::updatePeriod ( osiTime programBeginTime )
|
||||
bool bhe::updatePeriod ( epicsTime programBeginTime )
|
||||
{
|
||||
double currentPeriod;
|
||||
bool netChange = false;
|
||||
osiTime current = osiTime::getCurrent ();
|
||||
epicsTime current = epicsTime::getCurrent ();
|
||||
|
||||
if ( this->timeStamp == osiTime () ) {
|
||||
if ( this->timeStamp == epicsTime () ) {
|
||||
|
||||
if ( this->piiu ) {
|
||||
this->piiu->beaconAnomalyNotify ();
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* zero (so we can correctly compute the period
|
||||
* between the 1st and 2nd beacons)
|
||||
*/
|
||||
inline bhe::bhe ( const osiTime &initialTimeStamp, const inetAddrID &addr ) :
|
||||
inline bhe::bhe ( const epicsTime &initialTimeStamp, const inetAddrID &addr ) :
|
||||
inetAddrID (addr), piiu (0), timeStamp (initialTimeStamp), averagePeriod (-1.0)
|
||||
{
|
||||
# ifdef DEBUG
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
#include "cadef.h"
|
||||
#include "epicsAssert.h"
|
||||
#include "osiTime.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
static unsigned channelCount = 0u;
|
||||
static unsigned connCount = 0u;
|
||||
static bool subsequentConnect = false;
|
||||
|
||||
osiTime begin;
|
||||
epicsTime begin;
|
||||
|
||||
extern "C" void caConnTestConnHandler ( struct connection_handler_args args )
|
||||
{
|
||||
@@ -18,14 +18,14 @@ extern "C" void caConnTestConnHandler ( struct connection_handler_args args )
|
||||
if ( connCount == 0u ) {
|
||||
if ( subsequentConnect ) {
|
||||
printf ("the first channel connected\n");
|
||||
begin = osiTime::getCurrent ();
|
||||
begin = epicsTime::getCurrent ();
|
||||
}
|
||||
}
|
||||
connCount++;
|
||||
// printf ( "." );
|
||||
// fflush ( stdout );
|
||||
if ( connCount == channelCount ) {
|
||||
osiTime current = osiTime::getCurrent ();
|
||||
epicsTime current = epicsTime::getCurrent ();
|
||||
double delay = current - begin;
|
||||
printf ( "all channels connected after %f sec ( %f sec per channel)\n",
|
||||
delay, delay / channelCount );
|
||||
@@ -61,7 +61,7 @@ void caConnTest ( const char *pNameIn, unsigned channelCountIn, double delayIn )
|
||||
while ( 1 ) {
|
||||
connCount = 0u;
|
||||
subsequentConnect = false;
|
||||
begin = osiTime::getCurrent ();
|
||||
begin = epicsTime::getCurrent ();
|
||||
|
||||
printf ( "initializing CA client library\n" );
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "cadef.h"
|
||||
#include "dbDefs.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
/*
|
||||
* event_handler()
|
||||
|
||||
@@ -106,7 +106,7 @@ cac::cac ( bool enablePreemptiveCallbackIn ) :
|
||||
strncpy ( this->pUserName, tmp, len );
|
||||
}
|
||||
|
||||
this->programBeginTime = osiTime::getCurrent ();
|
||||
this->programBeginTime = epicsTime::getCurrent ();
|
||||
|
||||
status = envGetDoubleConfigParam ( &EPICS_CA_CONN_TMO, &this->connTMO );
|
||||
if ( status ) {
|
||||
@@ -412,7 +412,7 @@ bhe * cac::lookupBeaconInetAddr (const inetAddrID &ina)
|
||||
/*
|
||||
* cac::createBeaconHashEntry ()
|
||||
*/
|
||||
bhe *cac::createBeaconHashEntry (const inetAddrID &ina, const osiTime &initialTimeStamp)
|
||||
bhe *cac::createBeaconHashEntry (const inetAddrID &ina, const epicsTime &initialTimeStamp)
|
||||
{
|
||||
epicsAutoMutex autoMutex ( this->defaultMutex );
|
||||
bhe *pBHE;
|
||||
@@ -461,7 +461,7 @@ void cac::beaconNotify ( const inetAddrID &addr )
|
||||
* shortly after the program started up)
|
||||
*/
|
||||
netChange = FALSE;
|
||||
this->createBeaconHashEntry ( addr, osiTime::getCurrent () );
|
||||
this->createBeaconHashEntry ( addr, epicsTime::getCurrent () );
|
||||
}
|
||||
|
||||
if ( ! netChange ) {
|
||||
@@ -548,8 +548,8 @@ int cac::pend ( double timeout, int early )
|
||||
*/
|
||||
int cac::pendPrivate (double timeout, int early)
|
||||
{
|
||||
osiTime cur_time;
|
||||
osiTime beg_time;
|
||||
epicsTime cur_time;
|
||||
epicsTime beg_time;
|
||||
double delay;
|
||||
|
||||
this->flush ();
|
||||
@@ -568,7 +568,7 @@ int cac::pendPrivate (double timeout, int early)
|
||||
return ECA_TIMEOUT;
|
||||
}
|
||||
|
||||
beg_time = cur_time = osiTime::getCurrent ();
|
||||
beg_time = cur_time = epicsTime::getCurrent ();
|
||||
|
||||
delay = 0.0;
|
||||
while ( true ) {
|
||||
@@ -603,7 +603,7 @@ int cac::pendPrivate (double timeout, int early)
|
||||
return ECA_NORMAL;
|
||||
}
|
||||
|
||||
cur_time = osiTime::getCurrent ();
|
||||
cur_time = epicsTime::getCurrent ();
|
||||
|
||||
if ( timeout != 0.0 ) {
|
||||
delay = cur_time - beg_time;
|
||||
@@ -929,7 +929,7 @@ tcpiiu * cac::constructTCPIIU ( const osiSockAddr &addr, unsigned minorVersion )
|
||||
}
|
||||
}
|
||||
else {
|
||||
pBHE = this->createBeaconHashEntry ( addr.ia, osiTime () );
|
||||
pBHE = this->createBeaconHashEntry ( addr.ia, epicsTime () );
|
||||
if ( ! pBHE ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
osiTime programBeginTime = osiTime::getCurrent ();
|
||||
epicsTime programBeginTime = epicsTime::getCurrent ();
|
||||
SOCKET sock;
|
||||
osiSockAddr addr;
|
||||
osiSocklen_t addrSize;
|
||||
@@ -164,7 +164,7 @@ int main ( int argc, char **argv )
|
||||
* shortly after the program started up)
|
||||
*/
|
||||
netChange = false;
|
||||
pBHE = new bhe ( osiTime::getCurrent (), ina );
|
||||
pBHE = new bhe ( epicsTime::getCurrent (), ina );
|
||||
if ( pBHE ) {
|
||||
if ( beaconTable.add ( *pBHE ) < 0 ) {
|
||||
pBHE->destroy ();
|
||||
@@ -174,7 +174,7 @@ int main ( int argc, char **argv )
|
||||
|
||||
if ( netChange ) {
|
||||
char date[64];
|
||||
osiTime current = osiTime::getCurrent ();
|
||||
epicsTime current = epicsTime::getCurrent ();
|
||||
current.strftime ( date, sizeof ( date ), "%a %b %d %Y %H:%M:%S");
|
||||
char host[64];
|
||||
ipAddrToA ( &ina, host, sizeof ( host ) );
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "epicsAssert.h"
|
||||
#include "cadef.h"
|
||||
#include "caProto.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
#include "caDiagnostics.h"
|
||||
|
||||
@@ -348,8 +348,8 @@ unsigned *pInlineIter
|
||||
*/
|
||||
LOCAL void measure_get_latency (ti *pItems, unsigned iterations)
|
||||
{
|
||||
TS_STAMP end_time;
|
||||
TS_STAMP start_time;
|
||||
epicsTimeStamp end_time;
|
||||
epicsTimeStamp start_time;
|
||||
double delay;
|
||||
double X = 0u;
|
||||
double XX = 0u;
|
||||
@@ -361,16 +361,16 @@ LOCAL void measure_get_latency (ti *pItems, unsigned iterations)
|
||||
int status;
|
||||
|
||||
for (pi=pItems; pi<&pItems[iterations]; pi++) {
|
||||
tsStampGetCurrent (&start_time);
|
||||
epicsTimeGetCurrent (&start_time);
|
||||
status = ca_array_get (pi->type, pi->count,
|
||||
pi->chix, &pi->val);
|
||||
SEVCHK (status, NULL);
|
||||
status = ca_pend_io (100.0);
|
||||
SEVCHK (status, NULL);
|
||||
|
||||
tsStampGetCurrent(&end_time);
|
||||
epicsTimeGetCurrent(&end_time);
|
||||
|
||||
delay = tsStampDiffInSeconds(&end_time,&start_time);
|
||||
delay = epicsTimeDiffInSeconds(&end_time,&start_time);
|
||||
|
||||
X += delay;
|
||||
XX += delay*delay;
|
||||
@@ -426,15 +426,15 @@ LOCAL void printSearchStat ( const ti *pi, unsigned iterations )
|
||||
*/
|
||||
void timeIt ( tf *pfunc, ti *pItems, unsigned iterations, unsigned nBytes )
|
||||
{
|
||||
TS_STAMP end_time;
|
||||
TS_STAMP start_time;
|
||||
epicsTimeStamp end_time;
|
||||
epicsTimeStamp start_time;
|
||||
double delay;
|
||||
unsigned inlineIter;
|
||||
|
||||
tsStampGetCurrent (&start_time);
|
||||
epicsTimeGetCurrent (&start_time);
|
||||
(*pfunc) (pItems, iterations, &inlineIter);
|
||||
tsStampGetCurrent (&end_time);
|
||||
delay = tsStampDiffInSeconds (&end_time, &start_time);
|
||||
epicsTimeGetCurrent (&end_time);
|
||||
delay = epicsTimeDiffInSeconds (&end_time, &start_time);
|
||||
if (delay>0.0) {
|
||||
printf ("Elapsed Per Item = %12.8f sec, %10.1f Items per sec",
|
||||
delay/(iterations*inlineIter), (iterations*inlineIter)/delay);
|
||||
|
||||
@@ -84,7 +84,7 @@ of this distribution.
|
||||
|
||||
#include "shareLib.h"
|
||||
#include "epicsTypes.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -303,7 +303,7 @@ struct dbr_sts_double{
|
||||
struct dbr_time_string{
|
||||
dbr_short_t status; /* status of value */
|
||||
dbr_short_t severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
dbr_string_t value; /* current value */
|
||||
};
|
||||
|
||||
@@ -311,7 +311,7 @@ struct dbr_time_string{
|
||||
struct dbr_time_short{
|
||||
dbr_short_t status; /* status of value */
|
||||
dbr_short_t severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
dbr_short_t RISC_pad; /* RISC alignment */
|
||||
dbr_short_t value; /* current value */
|
||||
};
|
||||
@@ -320,7 +320,7 @@ struct dbr_time_short{
|
||||
struct dbr_time_float{
|
||||
dbr_short_t status; /* status of value */
|
||||
dbr_short_t severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
dbr_float_t value; /* current value */
|
||||
};
|
||||
|
||||
@@ -328,7 +328,7 @@ struct dbr_time_float{
|
||||
struct dbr_time_enum{
|
||||
dbr_short_t status; /* status of value */
|
||||
dbr_short_t severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
dbr_short_t RISC_pad; /* RISC alignment */
|
||||
dbr_enum_t value; /* current value */
|
||||
};
|
||||
@@ -337,7 +337,7 @@ struct dbr_time_enum{
|
||||
struct dbr_time_char{
|
||||
dbr_short_t status; /* status of value */
|
||||
dbr_short_t severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
dbr_short_t RISC_pad0; /* RISC alignment */
|
||||
dbr_char_t RISC_pad1; /* RISC alignment */
|
||||
dbr_char_t value; /* current value */
|
||||
@@ -347,7 +347,7 @@ struct dbr_time_char{
|
||||
struct dbr_time_long{
|
||||
dbr_short_t status; /* status of value */
|
||||
dbr_short_t severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
dbr_long_t value; /* current value */
|
||||
};
|
||||
|
||||
@@ -355,7 +355,7 @@ struct dbr_time_long{
|
||||
struct dbr_time_double{
|
||||
dbr_short_t status; /* status of value */
|
||||
dbr_short_t severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
dbr_long_t RISC_pad; /* RISC alignment */
|
||||
dbr_double_t value; /* current value */
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include "cadef.h"
|
||||
#include "dbDefs.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
void event_handler (struct event_handler_args args);
|
||||
int evtime (char *pname);
|
||||
@@ -66,10 +66,10 @@ void event_handler(struct event_handler_args args)
|
||||
# define COUNT 0x8000
|
||||
double interval;
|
||||
double delay;
|
||||
TS_STAMP ts;
|
||||
epicsTimeStamp ts;
|
||||
|
||||
if(iteration_count%COUNT == 0){
|
||||
tsStampGetCurrent(&ts);
|
||||
epicsTimeGetCurrent(&ts);
|
||||
current_time = ts.secPastEpoch;
|
||||
if(last_time != 0){
|
||||
interval = current_time - last_time;
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "bucketLib.h"
|
||||
#include "envDefs.h"
|
||||
#include "epicsPrint.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "tsFreeList.h"
|
||||
#include "tsDLList.h"
|
||||
#include "osiSock.h"
|
||||
@@ -883,11 +883,11 @@ private:
|
||||
|
||||
class bhe : public tsSLNode < bhe >, public inetAddrID {
|
||||
public:
|
||||
epicsShareFunc bhe ( const osiTime &initialTimeStamp, const inetAddrID &addr );
|
||||
epicsShareFunc bhe ( const epicsTime &initialTimeStamp, const inetAddrID &addr );
|
||||
tcpiiu *getIIU () const;
|
||||
void bindToIIU ( tcpiiu & );
|
||||
epicsShareFunc void destroy ();
|
||||
epicsShareFunc bool updatePeriod ( osiTime programBeginTime );
|
||||
epicsShareFunc bool updatePeriod ( epicsTime programBeginTime );
|
||||
epicsShareFunc double period () const;
|
||||
epicsShareFunc void show ( unsigned level) const;
|
||||
epicsShareFunc void * operator new ( size_t size );
|
||||
@@ -895,7 +895,7 @@ public:
|
||||
|
||||
private:
|
||||
tcpiiu *piiu;
|
||||
osiTime timeStamp;
|
||||
epicsTime timeStamp;
|
||||
double averagePeriod;
|
||||
|
||||
static tsFreeList < class bhe, 1024 > freeList;
|
||||
@@ -1067,7 +1067,7 @@ public:
|
||||
void beaconNotify ( const inetAddrID &addr );
|
||||
bhe *lookupBeaconInetAddr ( const inetAddrID &ina );
|
||||
bhe *createBeaconHashEntry ( const inetAddrID &ina,
|
||||
const osiTime &initialTimeStamp );
|
||||
const epicsTime &initialTimeStamp );
|
||||
void repeaterSubscribeConfirmNotify ();
|
||||
|
||||
// IIU routines
|
||||
@@ -1134,7 +1134,7 @@ private:
|
||||
< CASG > sgTable;
|
||||
resTable
|
||||
< bhe, inetAddrID > beaconTable;
|
||||
osiTime programBeginTime;
|
||||
epicsTime programBeginTime;
|
||||
double connTMO;
|
||||
// defaultMutex can be applied if iiuListMutex is already applied
|
||||
mutable epicsMutex defaultMutex;
|
||||
|
||||
@@ -23,7 +23,7 @@ LOCAL int parseDirectoryFP (FILE *pf, const char *pFileName);
|
||||
//
|
||||
extern int main (int argc, const char **argv)
|
||||
{
|
||||
osiTime begin(osiTime::getCurrent());
|
||||
epicsTime begin(epicsTime::getCurrent());
|
||||
directoryServer *pCAS;
|
||||
unsigned debugLevel = 0u;
|
||||
double executionTime;
|
||||
@@ -82,14 +82,14 @@ extern int main (int argc, const char **argv)
|
||||
}
|
||||
}
|
||||
else {
|
||||
double delay = osiTime::getCurrent() - begin;
|
||||
double delay = epicsTime::getCurrent() - begin;
|
||||
//
|
||||
// loop here untime the specified execution time
|
||||
// expires
|
||||
//
|
||||
while (delay < executionTime) {
|
||||
fileDescriptorManager.process (delay);
|
||||
delay = osiTime::getCurrent() - begin;
|
||||
delay = epicsTime::getCurrent() - begin;
|
||||
}
|
||||
}
|
||||
pCAS->show(2u);
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
// Author: Jeff HIll (LANL)
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.1 1997/06/13 09:20:26 jhill
|
||||
// installed
|
||||
//
|
||||
// Revision 1.2 1997/04/10 19:39:26 jhill
|
||||
// API changes
|
||||
//
|
||||
@@ -32,7 +35,7 @@ exServer *pExampleCAS;
|
||||
//
|
||||
int excas (unsigned debugLevel, unsigned delaySec)
|
||||
{
|
||||
osiTime begin(osiTime::getCurrent());
|
||||
epicsTime begin(epicsTime::getCurrent());
|
||||
exServer *pCAS;
|
||||
|
||||
pCAS = new exServer(32u,5u,500u);
|
||||
@@ -52,15 +55,15 @@ int excas (unsigned debugLevel, unsigned delaySec)
|
||||
}
|
||||
}
|
||||
else {
|
||||
osiTime total( ((float)delaySec) );
|
||||
osiTime delay(osiTime::getCurrent() - begin);
|
||||
epicsTime total( ((float)delaySec) );
|
||||
epicsTime delay(epicsTime::getCurrent() - begin);
|
||||
//
|
||||
// loop here untill the specified execution time
|
||||
// expires
|
||||
//
|
||||
while (delay < total) {
|
||||
taskDelay(10);
|
||||
delay = osiTime::getCurrent() - begin;
|
||||
delay = epicsTime::getCurrent() - begin;
|
||||
}
|
||||
}
|
||||
pCAS->show(debugLevel);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
char exPV::hasBeenInitialized = 0;
|
||||
gddAppFuncTable<exPV> exPV::ft;
|
||||
osiTime exPV::currentTime;
|
||||
epicsTime exPV::currentTime;
|
||||
|
||||
//
|
||||
// special gddDestructor guarantees same form of new and delete
|
||||
|
||||
@@ -40,7 +40,7 @@ void exScalarPV::scan()
|
||||
// throughput under sunos4 because gettimeofday() is
|
||||
// slow)
|
||||
//
|
||||
this->currentTime = osiTime::getCurrent();
|
||||
this->currentTime = epicsTime::getCurrent();
|
||||
|
||||
pDD = new gddScalar (gddAppType_value, aitEnumFloat64);
|
||||
if ( ! pDD.valid () ) {
|
||||
|
||||
@@ -247,7 +247,7 @@ protected:
|
||||
bool interest;
|
||||
bool preCreate;
|
||||
bool scanOn;
|
||||
static osiTime currentTime;
|
||||
static epicsTime currentTime;
|
||||
|
||||
virtual caStatus updateValue (smartConstGDDPointer pValue) = 0;
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ void exVectorPV::scan()
|
||||
// throughput under sunos4 because gettimeofday() is
|
||||
// slow)
|
||||
//
|
||||
this->currentTime = osiTime::getCurrent();
|
||||
this->currentTime = epicsTime::getCurrent();
|
||||
|
||||
pDD = new gddAtomic (gddAppType_value, aitEnumFloat64,
|
||||
1u, this->info.getElementCount());
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//
|
||||
extern int main (int argc, const char **argv)
|
||||
{
|
||||
osiTime begin (osiTime::getCurrent());
|
||||
epicsTime begin (epicsTime::getCurrent());
|
||||
exServer *pCAS;
|
||||
unsigned debugLevel = 0u;
|
||||
double executionTime;
|
||||
@@ -67,14 +67,14 @@ extern int main (int argc, const char **argv)
|
||||
}
|
||||
}
|
||||
else {
|
||||
double delay = osiTime::getCurrent() - begin;
|
||||
double delay = epicsTime::getCurrent() - begin;
|
||||
//
|
||||
// loop here untill the specified execution time
|
||||
// expires
|
||||
//
|
||||
while (delay < executionTime) {
|
||||
fileDescriptorManager.process(delay);
|
||||
delay = osiTime::getCurrent() - begin;
|
||||
delay = epicsTime::getCurrent() - begin;
|
||||
}
|
||||
}
|
||||
pCAS->show(2u);
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
// Author: Jeff HIll (LANL)
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.2 1997/04/10 19:39:26 jhill
|
||||
// API changes
|
||||
//
|
||||
// Revision 1.1 1996/12/06 22:20:22 jhill
|
||||
// moved down one level
|
||||
//
|
||||
@@ -29,7 +32,7 @@ exServer *pExampleCAS;
|
||||
//
|
||||
int excas (unsigned debugLevel, unsigned delaySec)
|
||||
{
|
||||
osiTime begin(osiTime::getCurrent());
|
||||
epicsTime begin(epicsTime::getCurrent());
|
||||
exServer *pCAS;
|
||||
|
||||
pCAS = new exServer(32u,5u,500u);
|
||||
@@ -49,15 +52,15 @@ int excas (unsigned debugLevel, unsigned delaySec)
|
||||
}
|
||||
}
|
||||
else {
|
||||
osiTime total( ((float)delaySec) );
|
||||
osiTime delay(osiTime::getCurrent() - begin);
|
||||
epicsTime total( ((float)delaySec) );
|
||||
epicsTime delay(epicsTime::getCurrent() - begin);
|
||||
//
|
||||
// loop here untill the specified execution time
|
||||
// expires
|
||||
//
|
||||
while (delay < total) {
|
||||
taskDelay(10);
|
||||
delay = osiTime::getCurrent() - begin;
|
||||
delay = epicsTime::getCurrent() - begin;
|
||||
}
|
||||
}
|
||||
pCAS->show(debugLevel);
|
||||
|
||||
@@ -392,7 +392,7 @@ outBuf::flushCondition casDGClient::xSend (char *pBufIn,
|
||||
//
|
||||
// !! this time fetch may be slowing things down !!
|
||||
//
|
||||
//this->lastSendTS = osiTime::getCurrent();
|
||||
//this->lastSendTS = epicsTime::getCurrent();
|
||||
nBytesSent = totalBytes;
|
||||
return outBuf::flushProgress;
|
||||
}
|
||||
@@ -423,7 +423,7 @@ inBuf::fillCondition casDGClient::xRecv (char *pBufIn, bufSizeT nBytesToRecv,
|
||||
//
|
||||
// !! this time fetch may be slowing things down !!
|
||||
//
|
||||
//this->lastRecvTS = osiTime::getCurrent();
|
||||
//this->lastRecvTS = epicsTime::getCurrent();
|
||||
}
|
||||
else {
|
||||
break;
|
||||
|
||||
@@ -2048,7 +2048,7 @@ outBuf::flushCondition casStrmClient::xSend (char *pBufIn, bufSizeT nBytesAvaila
|
||||
//
|
||||
// !! this time fetch may be slowing things down !!
|
||||
//
|
||||
//this->lastSendTS = osiTime::getCurrent();
|
||||
//this->lastSendTS = epicsTime::getCurrent();
|
||||
return outBuf::flushProgress;
|
||||
}
|
||||
else {
|
||||
@@ -2062,7 +2062,7 @@ outBuf::flushCondition casStrmClient::xSend (char *pBufIn, bufSizeT nBytesAvaila
|
||||
//
|
||||
// !! this time fetch may be slowing things down !!
|
||||
//
|
||||
//this->lastSendTS = osiTime::getCurrent();
|
||||
//this->lastSendTS = epicsTime::getCurrent();
|
||||
nActualBytes = totalBytes;
|
||||
return outBuf::flushProgress;
|
||||
}
|
||||
@@ -2081,7 +2081,7 @@ inBuf::fillCondition casStrmClient::xRecv(char *pBufIn, bufSizeT nBytes,
|
||||
//
|
||||
// this is used to set the time stamp for write GDD's
|
||||
//
|
||||
this->lastRecvTS = osiTime::getCurrent();
|
||||
this->lastRecvTS = epicsTime::getCurrent();
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#undef epicsAssertAuthor
|
||||
#define epicsAssertAuthor "Jeff Hill johill@lanl.gov"
|
||||
#include "epicsAssert.h" // EPICS assert() macros
|
||||
#include "osiTime.h" // EPICS os independent time
|
||||
#include "epicsTime.h" // EPICS os independent time
|
||||
#include "alarm.h" // EPICS alarm severity/condition
|
||||
#include "errMdef.h" // EPICS error codes
|
||||
#include "resourceLib.h" // EPICS hashing templates
|
||||
@@ -500,8 +500,8 @@ public:
|
||||
|
||||
protected:
|
||||
unsigned minor_version_number;
|
||||
osiTime lastSendTS;
|
||||
osiTime lastRecvTS;
|
||||
epicsTime lastSendTS;
|
||||
epicsTime lastRecvTS;
|
||||
|
||||
caStatus sendErrWithEpicsStatus(const caHdr *pMsg,
|
||||
caStatus epicsStatus, caStatus clientStatus);
|
||||
|
||||
@@ -23,7 +23,6 @@ of this distribution.
|
||||
#include "epicsInterrupt.h"
|
||||
#include "osiTimer.h"
|
||||
#include "epicsRingPointer.h"
|
||||
#include "tsStamp.h"
|
||||
#include "errlog.h"
|
||||
#include "dbStaticLib.h"
|
||||
#include "dbBase.h"
|
||||
|
||||
@@ -50,7 +50,7 @@ of this distribution.
|
||||
#include "errlog.h"
|
||||
#include "cantProceed.h"
|
||||
#include "cvtFast.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "alarm.h"
|
||||
#include "ellLib.h"
|
||||
#include "dbStaticLib.h"
|
||||
@@ -1347,7 +1347,7 @@ long epicsShareAPI dbGetSevr(struct link *plink,short *severity)
|
||||
return(0);
|
||||
}
|
||||
|
||||
long epicsShareAPI dbGetTimeStamp(struct link *plink,TS_STAMP *pstamp)
|
||||
long epicsShareAPI dbGetTimeStamp(struct link *plink,epicsTimeStamp *pstamp)
|
||||
{
|
||||
DBADDR *paddr;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ of this distribution.
|
||||
#define INCdbAccessh
|
||||
|
||||
#include "dbDefs.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "caeventmask.h"
|
||||
#include "dbFldTypes.h"
|
||||
#include "link.h"
|
||||
|
||||
@@ -30,6 +30,7 @@ of this distribution.
|
||||
#ifndef INCdbAccessDefsh
|
||||
#define INCdbAccessDefsh
|
||||
|
||||
#include "epicsTime.h"
|
||||
#include "shareLib.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -116,7 +117,7 @@ epicsShareExtern volatile int interruptAccept;
|
||||
long precision; /* number of decimal places*/\
|
||||
long field_width; /* field width */
|
||||
#define DBRtime \
|
||||
TS_STAMP time; /* time stamp*/
|
||||
epicsTimeStamp time; /* time stamp*/
|
||||
#define DBRenumStrs \
|
||||
unsigned long no_str; /* number of strings*/\
|
||||
long padenumStrs; /*padding to force 8 byte align*/\
|
||||
@@ -262,7 +263,7 @@ epicsShareFunc long epicsShareAPI dbGetUnits(
|
||||
epicsShareFunc long epicsShareAPI dbGetSevr(
|
||||
struct link *plink,short *severity);
|
||||
epicsShareFunc long epicsShareAPI dbGetTimeStamp(
|
||||
struct link *plink,TS_STAMP *pstamp);
|
||||
struct link *plink,epicsTimeStamp *pstamp);
|
||||
|
||||
typedef void(*SPC_ASCALLBACK)(struct dbCommon *);
|
||||
/*dbSpcAsRegisterCallback called by access security */
|
||||
|
||||
@@ -14,6 +14,9 @@ of this distribution.
|
||||
/* Modification Log:
|
||||
* -----------------
|
||||
* $Log$
|
||||
* Revision 1.26 2001/01/18 19:07:49 mrk
|
||||
* changes for osiThread=>epicsThread
|
||||
*
|
||||
* Revision 1.25 2001/01/12 00:27:16 jhill
|
||||
* fixed bugs introduced by APS's osi => epics name changes
|
||||
*
|
||||
@@ -54,7 +57,7 @@ of this distribution.
|
||||
* new way to build
|
||||
*
|
||||
* Revision 1.12 2000/01/04 20:26:16 mrk
|
||||
* replace osiClock calls with tsStamp calls
|
||||
* replace osiClock calls with epicsTime calls
|
||||
*
|
||||
* Revision 1.11 1999/12/14 22:01:33 mrk
|
||||
* changes for osiSem changes
|
||||
@@ -113,7 +116,7 @@ of this distribution.
|
||||
#include "epicsThread.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "ellLib.h"
|
||||
#include "errlog.h"
|
||||
#include "alarm.h"
|
||||
@@ -779,7 +782,7 @@ int epicsShareAPI dbBkpt(dbCommon *precord)
|
||||
|
||||
pqe->entrypoint = precord;
|
||||
pqe->count = 1;
|
||||
tsStampGetCurrent(&pqe->time);
|
||||
epicsTimeGetCurrent(&pqe->time);
|
||||
pqe->sched = 0;
|
||||
|
||||
#ifdef BKPT_DIAG
|
||||
@@ -945,11 +948,11 @@ long epicsShareAPI dbstat(void)
|
||||
struct LS_LIST *pnode;
|
||||
struct BP_LIST *pbl;
|
||||
struct EP_LIST *pqe;
|
||||
TS_STAMP time;
|
||||
epicsTimeStamp time;
|
||||
|
||||
epicsMutexMustLock(bkpt_stack_sem);
|
||||
|
||||
tsStampGetCurrent(&time);
|
||||
epicsTimeGetCurrent(&time);
|
||||
|
||||
/*
|
||||
* Traverse list, reporting stopped records
|
||||
@@ -964,7 +967,7 @@ long epicsShareAPI dbstat(void)
|
||||
/* for each entrypoint detected, print out entrypoint statistics */
|
||||
pqe = (struct EP_LIST *) ellFirst(&pnode->ep_queue);
|
||||
while (pqe != NULL) {
|
||||
double diff = tsStampDiffInSeconds(&time,&pqe->time);
|
||||
double diff = epicsTimeDiffInSeconds(&time,&pqe->time);
|
||||
if (diff) {
|
||||
printf(" Entrypoint: %-28.28s #C: %5.5lu C/S: %7.1f\n",
|
||||
pqe->entrypoint->name, pqe->count,diff);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "ellLib.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "epicsThread.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "shareLib.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -61,7 +61,7 @@ struct EP_LIST {
|
||||
ELLNODE *prev_list;
|
||||
struct dbCommon *entrypoint; /* pointer to entry point in lockset */
|
||||
unsigned long count; /* number of times record processed */
|
||||
TS_STAMP time; /* time record first logged */
|
||||
epicsTimeStamp time; /* time record first logged */
|
||||
char sched; /* schedule record for next dbContTask() pass */
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ of this distribution.
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "epicsThread.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "errlog.h"
|
||||
#include "taskwd.h"
|
||||
#include "alarm.h"
|
||||
@@ -371,7 +371,7 @@ long epicsShareAPI dbCaGetSevr(struct link *plink,short *severity)
|
||||
return(0);
|
||||
}
|
||||
|
||||
long epicsShareAPI dbCaGetTimeStamp(struct link *plink,TS_STAMP *pstamp)
|
||||
long epicsShareAPI dbCaGetTimeStamp(struct link *plink,epicsTimeStamp *pstamp)
|
||||
{
|
||||
caLink *pca;
|
||||
|
||||
@@ -379,7 +379,7 @@ long epicsShareAPI dbCaGetTimeStamp(struct link *plink,TS_STAMP *pstamp)
|
||||
if(plink->type != CA_LINK) return(-1);
|
||||
pca = (caLink *)plink->value.pv_link.pvt;
|
||||
if(!pca->chid || ca_state(pca->chid)!=cs_conn) return(-1);
|
||||
memcpy(pstamp,&pca->timeStamp,sizeof(TS_STAMP));
|
||||
memcpy(pstamp,&pca->timeStamp,sizeof(epicsTimeStamp));
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ static void eventCallback(struct event_handler_args arg)
|
||||
}
|
||||
pdbr_time_double = (struct dbr_time_double *)arg.dbr;
|
||||
pca->sevr = (unsigned short)pdbr_time_double->severity;
|
||||
memcpy(&pca->timeStamp,&pdbr_time_double->stamp,sizeof(TS_STAMP));
|
||||
memcpy(&pca->timeStamp,&pdbr_time_double->stamp,sizeof(epicsTimeStamp));
|
||||
if(precord) {
|
||||
struct pv_link *ppv_link = &(plink->value.pv_link);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ epicsShareFunc long epicsShareAPI dbCaGetNelements(
|
||||
epicsShareFunc long epicsShareAPI dbCaGetSevr(
|
||||
struct link *plink,short *severity);
|
||||
epicsShareFunc long epicsShareAPI dbCaGetTimeStamp(
|
||||
struct link *plink,TS_STAMP *pstamp);
|
||||
struct link *plink,epicsTimeStamp *pstamp);
|
||||
epicsShareFunc int epicsShareAPI dbCaIsLinkConnected(struct link *plink);
|
||||
epicsShareFunc int epicsShareAPI dbCaGetLinkDBFtype(struct link *plink);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ typedef struct caLink
|
||||
short dbrType;
|
||||
short link_action;
|
||||
unsigned short sevr;
|
||||
TS_STAMP timeStamp;
|
||||
epicsTimeStamp timeStamp;
|
||||
char gotInNative;
|
||||
char gotOutNative;
|
||||
char gotInString;
|
||||
|
||||
@@ -230,7 +230,7 @@
|
||||
prompt("Time")
|
||||
special(SPC_NOMOD)
|
||||
interest(4)
|
||||
extra("TS_STAMP time")
|
||||
extra("epicsTimeStamp time")
|
||||
}
|
||||
field(FLNK,DBF_FWDLINK) {
|
||||
prompt("Forward Process Link")
|
||||
|
||||
@@ -20,7 +20,6 @@ of this distribution.
|
||||
#include "dbDefs.h"
|
||||
#include "errlog.h"
|
||||
#include "cvtFast.h"
|
||||
#include "tsStamp.h"
|
||||
#include "dbBase.h"
|
||||
#include "link.h"
|
||||
#include "dbFldTypes.h"
|
||||
|
||||
@@ -36,7 +36,6 @@ of this distribution.
|
||||
#include "dbBase.h"
|
||||
#include "dbFldTypes.h"
|
||||
#include "link.h"
|
||||
#include "tsStamp.h"
|
||||
#include "dbCommon.h"
|
||||
#include "caeventmask.h"
|
||||
#include "db_field_log.h"
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "dbDefs.h"
|
||||
#include "errlog.h"
|
||||
#include "cvtFast.h"
|
||||
#include "tsStamp.h"
|
||||
#include "alarm.h"
|
||||
#include "dbBase.h"
|
||||
#include "link.h"
|
||||
|
||||
@@ -67,7 +67,6 @@ since this will delay all other threads.
|
||||
#include "dbDefs.h"
|
||||
#include "dbBase.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsThread.h"
|
||||
#include "cantProceed.h"
|
||||
#include "ellLib.h"
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "errlog.h"
|
||||
#include "errMdef.h"
|
||||
#include "ellLib.h"
|
||||
#include "tsStamp.h"
|
||||
#include "dbBase.h"
|
||||
#include "dbStaticLib.h"
|
||||
#include "dbFldTypes.h"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "string.h"
|
||||
|
||||
#include "epicsMutex.h"
|
||||
#include "osiTime.h"
|
||||
#include "epicsTime.h"
|
||||
#include "tsFreeList.h"
|
||||
#include "errMdef.h"
|
||||
|
||||
@@ -72,11 +72,11 @@ int dbPutNotifyBlocker::initiatePutNotify ( cacNotify ¬ify,
|
||||
// wait for current put notify to complete
|
||||
this->lock ();
|
||||
if ( this->pPN ) {
|
||||
osiTime begin = osiTime::getCurrent ();
|
||||
epicsTime begin = epicsTime::getCurrent ();
|
||||
do {
|
||||
this->unlock ();
|
||||
this->block.wait ( 1.0 );
|
||||
if ( osiTime::getCurrent () - begin > 30.0 ) {
|
||||
if ( epicsTime::getCurrent () - begin > 30.0 ) {
|
||||
pIO->destroy ();
|
||||
return ECA_PUTCBINPROG;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
#include "epicsEvent.h"
|
||||
#include "epicsInterrupt.h"
|
||||
#include "epicsThread.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "cantProceed.h"
|
||||
#include "epicsRingPointer.h"
|
||||
#include "epicsPrint.h"
|
||||
@@ -495,19 +495,19 @@ static void periodicTask(void *arg)
|
||||
{
|
||||
scan_list *psl = (scan_list *)arg;
|
||||
|
||||
TS_STAMP start_time,end_time;
|
||||
epicsTimeStamp start_time,end_time;
|
||||
double diff;
|
||||
double delay;
|
||||
|
||||
tsStampGetCurrent(&start_time);
|
||||
epicsTimeGetCurrent(&start_time);
|
||||
while(TRUE) {
|
||||
if(interruptAccept)scanList(psl);
|
||||
tsStampGetCurrent(&end_time);
|
||||
diff = tsStampDiffInSeconds(&end_time,&start_time);
|
||||
epicsTimeGetCurrent(&end_time);
|
||||
diff = epicsTimeDiffInSeconds(&end_time,&start_time);
|
||||
delay = psl->rate - diff;
|
||||
delay = (delay<=0.0) ? .1 : delay;
|
||||
epicsThreadSleep(delay);
|
||||
tsStampGetCurrent(&start_time);
|
||||
epicsTimeGetCurrent(&start_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ of this distribution.
|
||||
#include "errlog.h"
|
||||
#include "ellLib.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "tsStamp.h"
|
||||
#include "ellLib.h"
|
||||
#include "dbBase.h"
|
||||
#include "dbStaticLib.h"
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
#include "dbDefs.h"
|
||||
#include "errlog.h"
|
||||
#include "ellLib.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "dbStaticLib.h"
|
||||
#include "dbBase.h"
|
||||
#include "dbCommon.h"
|
||||
@@ -213,7 +213,7 @@ struct dbr_sts_double{
|
||||
struct dbr_time_string{
|
||||
short status; /* status of value */
|
||||
short severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
char value[MAX_STRING_SIZE]; /* current value */
|
||||
};
|
||||
|
||||
@@ -221,7 +221,7 @@ struct dbr_time_string{
|
||||
struct dbr_time_short{
|
||||
short status; /* status of value */
|
||||
short severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
short RISC_pad; /* RISC alignment */
|
||||
short value; /* current value */
|
||||
};
|
||||
@@ -230,7 +230,7 @@ struct dbr_time_short{
|
||||
struct dbr_time_float{
|
||||
short status; /* status of value */
|
||||
short severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
float value; /* current value */
|
||||
};
|
||||
|
||||
@@ -238,7 +238,7 @@ struct dbr_time_float{
|
||||
struct dbr_time_enum{
|
||||
short status; /* status of value */
|
||||
short severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
short RISC_pad; /* RISC alignment */
|
||||
short value; /* current value */
|
||||
};
|
||||
@@ -247,7 +247,7 @@ struct dbr_time_enum{
|
||||
struct dbr_time_char{
|
||||
short status; /* status of value */
|
||||
short severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
short RISC_pad0; /* RISC alignment */
|
||||
char RISC_pad1; /* RISC alignment */
|
||||
unsigned char value; /* current value */
|
||||
@@ -257,7 +257,7 @@ struct dbr_time_char{
|
||||
struct dbr_time_long{
|
||||
short status; /* status of value */
|
||||
short severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
long value; /* current value */
|
||||
};
|
||||
|
||||
@@ -265,7 +265,7 @@ struct dbr_time_long{
|
||||
struct dbr_time_double{
|
||||
short status; /* status of value */
|
||||
short severity; /* severity of alarm */
|
||||
TS_STAMP stamp; /* time stamp */
|
||||
epicsTimeStamp stamp; /* time stamp */
|
||||
long RISC_pad; /* RISC alignment */
|
||||
double value; /* current value */
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ union native_value{
|
||||
typedef struct db_field_log {
|
||||
unsigned short stat; /* Alarm Status */
|
||||
unsigned short sevr; /* Alarm Severity */
|
||||
TS_STAMP time; /* time stamp */
|
||||
epicsTimeStamp time; /* time stamp */
|
||||
union native_value field; /* field value */
|
||||
}db_field_log;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include "dbDefs.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "epicsPrint.h"
|
||||
#include "dbBase.h"
|
||||
#include "dbFldTypes.h"
|
||||
@@ -331,10 +331,10 @@ void epicsShareAPI recGblGetTimeStamp(void* prec)
|
||||
if(pr->tsel.type!=CONSTANT)
|
||||
{
|
||||
dbGetLink(&(pr->tsel), DBR_SHORT,&(pr->tse),0,0);
|
||||
status = tsStampGetEvent(&pr->time,(unsigned)pr->tse);
|
||||
status = epicsTimeGetEvent(&pr->time,(unsigned)pr->tse);
|
||||
}
|
||||
else
|
||||
status = tsStampGetEvent(&pr->time,(unsigned)pr->tse);
|
||||
status = epicsTimeGetEvent(&pr->time,(unsigned)pr->tse);
|
||||
if(status) errlogPrintf("%s recGblGetTimeStamp failed\n",pr->name);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,23 +18,23 @@ of this distribution.
|
||||
#include "errlog.h"
|
||||
#include "callback.h"
|
||||
#include "taskwd.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
typedef struct myPvt {
|
||||
CALLBACK callback;
|
||||
double requestedDiff;
|
||||
TS_STAMP start;
|
||||
epicsTimeStamp start;
|
||||
}myPvt;
|
||||
|
||||
static void myCallback(CALLBACK *pCallback)
|
||||
{
|
||||
myPvt *pmyPvt;
|
||||
TS_STAMP end;
|
||||
epicsTimeStamp end;
|
||||
double diff;
|
||||
|
||||
callbackGetUser(pmyPvt,pCallback);
|
||||
tsStampGetCurrent(&end);
|
||||
diff = tsStampDiffInSeconds(&end,&pmyPvt->start);
|
||||
epicsTimeGetCurrent(&end);
|
||||
diff = epicsTimeDiffInSeconds(&end,&pmyPvt->start);
|
||||
printf("myCallback requestedDiff %f diff %f\n",pmyPvt->requestedDiff,diff);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ void callbackTest(void)
|
||||
{
|
||||
myPvt *nowait[ncallbacks];
|
||||
myPvt *wait[ncallbacks];
|
||||
TS_STAMP start;
|
||||
epicsTimeStamp start;
|
||||
int i;
|
||||
|
||||
taskwdInit();
|
||||
@@ -55,7 +55,7 @@ void callbackTest(void)
|
||||
callbackSetCallback(myCallback,&nowait[i]->callback);
|
||||
callbackSetUser(nowait[i],&nowait[i]->callback);
|
||||
callbackSetPriority(i%3,&nowait[i]->callback);
|
||||
tsStampGetCurrent(&start);
|
||||
epicsTimeGetCurrent(&start);
|
||||
nowait[i]->start = start;
|
||||
nowait[i]->requestedDiff = 0.0;
|
||||
callbackRequest(&nowait[i]->callback);
|
||||
@@ -63,7 +63,7 @@ void callbackTest(void)
|
||||
callbackSetCallback(myCallback,&wait[i]->callback);
|
||||
callbackSetUser(wait[i],&wait[i]->callback);
|
||||
callbackSetPriority(i%3,&wait[i]->callback);
|
||||
tsStampGetCurrent(&start);
|
||||
epicsTimeGetCurrent(&start);
|
||||
wait[i]->start = start;
|
||||
wait[i]->requestedDiff = (double)i;
|
||||
callbackRequestDelayed(&wait[i]->callback,wait[i]->requestedDiff);
|
||||
|
||||
@@ -125,7 +125,7 @@ int main(int argc,char **argv)
|
||||
fprintf(outFile,"#include \"ellLib.h\"\n");
|
||||
fprintf(outFile,"#include \"epicsMutex.h\"\n");
|
||||
fprintf(outFile,"#include \"link.h\"\n");
|
||||
fprintf(outFile,"#include \"tsStamp.h\"\n");
|
||||
fprintf(outFile,"#include \"epicsTime.h\"\n");
|
||||
pdbMenu = (dbMenu *)ellFirst(&pdbbase->menuList);
|
||||
while(pdbMenu) {
|
||||
fprintf(outFile,"\n#ifndef INC%sH\n",pdbMenu->name);
|
||||
|
||||
@@ -5,11 +5,14 @@
|
||||
// $Id$
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.12 1999/08/05 22:15:42 jhill
|
||||
// removed knowledge of class osiTime
|
||||
//
|
||||
// Revision 1.11 1999/05/10 23:38:33 jhill
|
||||
// convert to and from other time stamp formats
|
||||
//
|
||||
// Revision 1.10 1999/05/03 16:20:51 jhill
|
||||
// allow aitTimeStamp to convert to TS_STAMP (without binding to libCom)
|
||||
// allow aitTimeStamp to convert to epicsTimeStamp (without binding to libCom)
|
||||
//
|
||||
// Revision 1.9 1998/05/05 21:08:26 jhill
|
||||
// fixed warning
|
||||
@@ -189,14 +192,14 @@ int aitString::init(const char* p, aitStrType typeIn, unsigned strLengthIn, unsi
|
||||
// to link with libCom
|
||||
//
|
||||
|
||||
struct TS_STAMP {
|
||||
struct epicsTimeStamp {
|
||||
aitUint32 secPastEpoch; /* seconds since 0000 Jan 1, 1990 */
|
||||
aitUint32 nsec; /* nanoseconds within second */
|
||||
};
|
||||
|
||||
aitTimeStamp::operator struct TS_STAMP () const
|
||||
aitTimeStamp::operator struct epicsTimeStamp () const
|
||||
{
|
||||
TS_STAMP ts;
|
||||
epicsTimeStamp ts;
|
||||
|
||||
if (this->tv_sec>aitTimeStamp::epicsEpochSecPast1970) {
|
||||
ts.secPastEpoch = this->tv_sec - aitTimeStamp::epicsEpochSecPast1970;
|
||||
@@ -209,7 +212,7 @@ aitTimeStamp::operator struct TS_STAMP () const
|
||||
return ts;
|
||||
}
|
||||
|
||||
void aitTimeStamp::get (struct TS_STAMP &ts) const
|
||||
void aitTimeStamp::get (struct epicsTimeStamp &ts) const
|
||||
{
|
||||
if (this->tv_sec>aitTimeStamp::epicsEpochSecPast1970) {
|
||||
ts.secPastEpoch = this->tv_sec - aitTimeStamp::epicsEpochSecPast1970;
|
||||
@@ -221,13 +224,13 @@ void aitTimeStamp::get (struct TS_STAMP &ts) const
|
||||
}
|
||||
}
|
||||
|
||||
aitTimeStamp::aitTimeStamp (const struct TS_STAMP &ts)
|
||||
aitTimeStamp::aitTimeStamp (const struct epicsTimeStamp &ts)
|
||||
{
|
||||
this->tv_sec = ts.secPastEpoch + aitTimeStamp::epicsEpochSecPast1970;
|
||||
this->tv_nsec = ts.nsec;
|
||||
}
|
||||
|
||||
aitTimeStamp aitTimeStamp::operator = (const struct TS_STAMP &rhs)
|
||||
aitTimeStamp aitTimeStamp::operator = (const struct epicsTimeStamp &rhs)
|
||||
{
|
||||
this->tv_sec = rhs.secPastEpoch + aitTimeStamp::epicsEpochSecPast1970;
|
||||
this->tv_nsec = rhs.nsec;
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.21 1999/10/28 18:12:54 jhill
|
||||
* removed use of macro max() because it was classing with the C++ RTL
|
||||
*
|
||||
* Revision 1.20 1999/08/05 22:17:11 jhill
|
||||
* removed knowledge of class osiTime
|
||||
*
|
||||
@@ -15,7 +18,7 @@
|
||||
* convert to and from other time stamp formats
|
||||
*
|
||||
* Revision 1.18 1999/05/03 16:20:51 jhill
|
||||
* allow aitTimeStamp to convert to TS_STAMP (without binding to libCom)
|
||||
* allow aitTimeStamp to convert to epicsTimeStamp (without binding to libCom)
|
||||
*
|
||||
* Revision 1.17 1999/04/30 00:09:47 jhill
|
||||
* proper borrow
|
||||
@@ -96,7 +99,7 @@ inline char* strDup(const char* x)
|
||||
|
||||
|
||||
struct timespec;
|
||||
struct TS_STAMP;
|
||||
struct epicsTimeStamp;
|
||||
class gdd;
|
||||
|
||||
class epicsShareClass aitTimeStamp {
|
||||
@@ -156,12 +159,12 @@ public:
|
||||
aitTimeStamp operator = (const struct timespec &rhs);
|
||||
|
||||
//
|
||||
// convert to and from EPICS TS_STAMP format
|
||||
// convert to and from EPICS epicsTimeStamp format
|
||||
//
|
||||
operator struct TS_STAMP () const;
|
||||
void get (struct TS_STAMP &) const;
|
||||
aitTimeStamp (const struct TS_STAMP &ts);
|
||||
aitTimeStamp operator = (const struct TS_STAMP &rhs);
|
||||
operator struct epicsTimeStamp () const;
|
||||
void get (struct epicsTimeStamp &) const;
|
||||
aitTimeStamp (const struct epicsTimeStamp &ts);
|
||||
aitTimeStamp operator = (const struct epicsTimeStamp &rhs);
|
||||
|
||||
static aitTimeStamp getCurrent();
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.33 2000/10/13 01:17:51 jhill
|
||||
* made gdd param to copy const
|
||||
*
|
||||
* Revision 1.32 2000/06/12 17:32:11 jhill
|
||||
* moved stdlib.h (an ANSI C file) outside of OS depen switch
|
||||
*
|
||||
@@ -153,7 +156,7 @@ class gddContainer;
|
||||
class gddArray;
|
||||
class gddScalar;
|
||||
|
||||
struct TS_STAMP;
|
||||
struct epicsTimeStamp;
|
||||
struct timespec;
|
||||
|
||||
// Not Complete in this prototype:
|
||||
@@ -255,11 +258,11 @@ public:
|
||||
|
||||
void getTimeStamp(struct timespec* const ts) const;
|
||||
void getTimeStamp(aitTimeStamp* const ts) const;
|
||||
void getTimeStamp(struct TS_STAMP* const ts) const;
|
||||
void getTimeStamp(struct epicsTimeStamp* const ts) const;
|
||||
|
||||
void setTimeStamp(const struct timespec* const ts);
|
||||
void setTimeStamp(const aitTimeStamp* const ts);
|
||||
void setTimeStamp(const struct TS_STAMP* const ts);
|
||||
void setTimeStamp(const struct epicsTimeStamp* const ts);
|
||||
|
||||
void setStatus(aitUint32);
|
||||
void setStatus(aitUint16 high, aitUint16 low);
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.9 2000/10/13 01:17:52 jhill
|
||||
* made gdd param to copy const
|
||||
*
|
||||
* Revision 1.8 1999/08/10 19:57:15 jhill
|
||||
* moved inlines in order to eliminate g++ warnings
|
||||
*
|
||||
@@ -108,8 +111,8 @@ inline void gdd::setTimeStamp(const struct timespec* const ts) { time_stamp=*ts;
|
||||
inline void gdd::getTimeStamp(aitTimeStamp* const ts) const { *ts = time_stamp; }
|
||||
inline void gdd::setTimeStamp(const aitTimeStamp* const ts) { time_stamp=*ts; }
|
||||
|
||||
inline void gdd::getTimeStamp(struct TS_STAMP* const ts) const { time_stamp.get(*ts); }
|
||||
inline void gdd::setTimeStamp(const struct TS_STAMP* const ts) { time_stamp=*ts; }
|
||||
inline void gdd::getTimeStamp(struct epicsTimeStamp* const ts) const { time_stamp.get(*ts); }
|
||||
inline void gdd::setTimeStamp(const struct epicsTimeStamp* const ts) { time_stamp=*ts; }
|
||||
|
||||
inline void gdd::setStatus(aitUint32 s) { status=s; }
|
||||
inline void gdd::getStatus(aitUint32& s) const { s=status; }
|
||||
|
||||
@@ -13,7 +13,6 @@ of this distribution.
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ellLib.h"
|
||||
#include "tsStamp.h"
|
||||
#include "errlog.h"
|
||||
#include "alarm.h"
|
||||
#include "dbBase.h"
|
||||
|
||||
@@ -133,17 +133,16 @@ INC += osdPoolStatus.h
|
||||
INC += osdThread.h
|
||||
|
||||
INC += epicsThread.h
|
||||
INC += osiTime.h
|
||||
INC += epicsTime.h
|
||||
INC += osdTime.h
|
||||
INC += osiSigPipeIgnore.h
|
||||
INC += osdSigPipeIgnore.h
|
||||
INC += tsStamp.h
|
||||
INC += osiProcess.h
|
||||
INC += osiUnistd.h
|
||||
INC += osiWireFormat.h
|
||||
|
||||
SRCS += epicsThread.cpp
|
||||
SRCS += osiTime.cpp
|
||||
SRCS += epicsTime.cpp
|
||||
|
||||
SRCS += osdSock.c
|
||||
SRCS += osiSock.c
|
||||
@@ -159,7 +158,6 @@ SRCS += osdTime.cpp
|
||||
SRCS += osdSigPipeIgnore.c
|
||||
SRCS += osdProcess.c
|
||||
SRCS += osdNetIntf.c
|
||||
#tsStamp code is part of osiTime and osdTime
|
||||
|
||||
SRC_DIRS += $(LIBCOM)/taskwd
|
||||
INC += taskwd.h
|
||||
|
||||
@@ -171,7 +171,7 @@ epicsShareFunc void fdManager::process (double delay)
|
||||
}
|
||||
|
||||
tv.tv_sec = static_cast<long> (minDelay);
|
||||
tv.tv_usec = static_cast<long> ((minDelay-tv.tv_sec)*osiTime::uSecPerSec);
|
||||
tv.tv_usec = static_cast<long> ((minDelay-tv.tv_sec)*epicsTime::uSecPerSec);
|
||||
|
||||
/*
|
||||
* win32 requires this (others will
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "shareLib.h" // reset share lib defines
|
||||
#include "tsDLList.h"
|
||||
#include "resourceLib.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "osiSock.h"
|
||||
#include "osiTimer.h"
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ extern "C" epicsShareFunc fdctx * epicsShareAPI fdmgr_init (void)
|
||||
extern "C" epicsShareFunc fdmgrAlarmId epicsShareAPI fdmgr_add_timeout (
|
||||
fdctx *pfdctx, struct timeval *ptimeout, pCallBackFDMgr pFunc, void *pParam)
|
||||
{
|
||||
double delay = ptimeout->tv_sec + ptimeout->tv_usec / static_cast <const double> (osiTime::uSecPerSec);
|
||||
double delay = ptimeout->tv_sec + ptimeout->tv_usec / static_cast <const double> (epicsTime::uSecPerSec);
|
||||
oldFdmgr *pfdm = static_cast <oldFdmgr *> (pfdctx);
|
||||
osiTimerForOldFdmgr *pTimer;
|
||||
unsigned id;
|
||||
@@ -339,7 +339,7 @@ extern "C" epicsShareFunc int epicsShareAPI fdmgr_clear_callback (
|
||||
extern "C" epicsShareFunc int epicsShareAPI fdmgr_pend_event (fdctx *pfdctx, struct timeval *ptimeout)
|
||||
{
|
||||
oldFdmgr *pfdm = static_cast <oldFdmgr *> (pfdctx);
|
||||
double delay = ptimeout->tv_sec + ptimeout->tv_usec / static_cast <const double> (osiTime::uSecPerSec);
|
||||
double delay = ptimeout->tv_sec + ptimeout->tv_usec / static_cast <const double> (epicsTime::uSecPerSec);
|
||||
|
||||
# ifdef noExceptionsFromCXX
|
||||
pfdm->process (delay);
|
||||
|
||||
@@ -87,17 +87,17 @@ public:
|
||||
epicsTime (const time_t_wrapper &tv);
|
||||
epicsTime operator = (const time_t_wrapper &rhs);
|
||||
|
||||
// convert to and from ANSI C's "struct tm" (with nano seconds)
|
||||
// convert to and from ANSI Cs "struct tm" (with nano seconds)
|
||||
operator tm_nano_sec () const;
|
||||
epicsTime (const tm_nano_sec &ts);
|
||||
epicsTime operator = (const tm_nano_sec &rhs);
|
||||
|
||||
// convert to and from POSIX RT's "struct timespec"
|
||||
// convert to and from POSIX RTs "struct timespec"
|
||||
operator struct timespec () const;
|
||||
epicsTime (const struct timespec &ts);
|
||||
epicsTime operator = (const struct timespec &rhs);
|
||||
|
||||
// convert to and from BSD's "struct timeval"
|
||||
// convert to and from BSDs "struct timeval"
|
||||
operator struct timeval () const;
|
||||
epicsTime (const struct timeval &ts);
|
||||
epicsTime operator = (const struct timeval &rhs);
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
epicsTime (const ntpTimeStamp &ts);
|
||||
epicsTime operator = (const ntpTimeStamp &rhs);
|
||||
|
||||
// convert to and from GDD's aitTimeStamp format
|
||||
// convert to and from GDDs aitTimeStamp format
|
||||
operator aitTimeStamp () const;
|
||||
epicsTime (const aitTimeStamp &ts);
|
||||
epicsTime operator = (const aitTimeStamp &rhs);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* EPICS
|
||||
*/
|
||||
#define epicsExportSharedSymbols
|
||||
#include "osiTime.h"
|
||||
#include "epicsTime.h"
|
||||
#include "errlog.h"
|
||||
|
||||
extern "C" {
|
||||
@@ -45,7 +45,7 @@ static unsigned long timeoffset;
|
||||
* Allow for this to be called before clockInit() and before
|
||||
* system time and date have been initialized.
|
||||
*/
|
||||
int tsStampGetCurrent (TS_STAMP *pDest)
|
||||
int epicsTimeGetCurrent (epicsTimeStamp *pDest)
|
||||
{
|
||||
struct timeval curtime;
|
||||
rtems_interval t;
|
||||
@@ -56,27 +56,27 @@ int tsStampGetCurrent (TS_STAMP *pDest)
|
||||
if (sc == RTEMS_SUCCESSFUL)
|
||||
break;
|
||||
else if (sc != RTEMS_NOT_DEFINED)
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
sc = rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &t);
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
rtems_task_wake_after (t);
|
||||
}
|
||||
pDest->nsec = curtime.tv_usec * 1000;
|
||||
pDest->secPastEpoch = curtime.tv_sec - timeoffset;
|
||||
return tsStampOK;
|
||||
return epicsTimeOK;
|
||||
}
|
||||
|
||||
/*
|
||||
* tsStampGetEvent ()
|
||||
* epicsTimeGetEvent ()
|
||||
*/
|
||||
int tsStampGetEvent (TS_STAMP *pDest, unsigned eventNumber)
|
||||
int epicsTimeGetEvent (epicsTimeStamp *pDest, unsigned eventNumber)
|
||||
{
|
||||
if (eventNumber==tsStampEventCurrentTime) {
|
||||
return tsStampGetCurrent (pDest);
|
||||
if (eventNumber==epicsTimeEventCurrentTime) {
|
||||
return epicsTimeGetCurrent (pDest);
|
||||
}
|
||||
else {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
#include "osiSock.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "osiTime.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
//
|
||||
// osiTime::osdGetCurrent ()
|
||||
// epicsTime::osdGetCurrent ()
|
||||
//
|
||||
extern "C" epicsShareFunc int tsStampGetCurrent (TS_STAMP *pDest)
|
||||
extern "C" epicsShareFunc int epicsTimeGetCurrent (epicsTimeStamp *pDest)
|
||||
{
|
||||
# if defined(CLOCK_REALTIME)
|
||||
struct timespec ts;
|
||||
@@ -21,7 +21,7 @@ extern "C" epicsShareFunc int tsStampGetCurrent (TS_STAMP *pDest)
|
||||
if (status) {
|
||||
return -1;
|
||||
}
|
||||
*pDest = osiTime (ts);
|
||||
*pDest = epicsTime (ts);
|
||||
return 0;
|
||||
# else
|
||||
int status;
|
||||
@@ -31,20 +31,20 @@ extern "C" epicsShareFunc int tsStampGetCurrent (TS_STAMP *pDest)
|
||||
if (status!=0) {
|
||||
return -1;
|
||||
}
|
||||
*pDest = osiTime (tv);
|
||||
*pDest = epicsTime (tv);
|
||||
return 0;
|
||||
# endif
|
||||
}
|
||||
|
||||
//
|
||||
// tsStampGetEvent ()
|
||||
// epicsTimeGetEvent ()
|
||||
//
|
||||
extern "C" epicsShareFunc int epicsShareAPI tsStampGetEvent (TS_STAMP *pDest, unsigned eventNumber)
|
||||
extern "C" epicsShareFunc int epicsShareAPI epicsTimeGetEvent (epicsTimeStamp *pDest, unsigned eventNumber)
|
||||
{
|
||||
if (eventNumber==tsStampEventCurrentTime) {
|
||||
return tsStampGetCurrent (pDest);
|
||||
if (eventNumber==epicsTimeEventCurrentTime) {
|
||||
return epicsTimeGetCurrent (pDest);
|
||||
}
|
||||
else {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@
|
||||
// EPICS
|
||||
//
|
||||
#define epicsExportSharedSymbols
|
||||
#include "osiTime.h"
|
||||
#include "epicsTime.h"
|
||||
#include "errlog.h"
|
||||
#include "epicsAssert.h"
|
||||
|
||||
@@ -83,13 +83,13 @@ static void osdTimeExit ()
|
||||
*/
|
||||
static unsigned __stdcall osdTimeSynchThreadEntry (LPVOID)
|
||||
{
|
||||
static const DWORD tmoTenSec = 10 * osiTime::mSecPerSec;
|
||||
static const DWORD tmoTenSec = 10 * epicsTime::mSecPerSec;
|
||||
int status;
|
||||
|
||||
while ( ! osdTimeSyncThreadExit ) {
|
||||
Sleep (tmoTenSec);
|
||||
status = osdTimeSych ();
|
||||
if (status!=tsStampOK) {
|
||||
if (status!=epicsTimeOK) {
|
||||
errlogPrintf ("osdTimeSych (): failed?\n");
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ static void osdTimeInit ()
|
||||
ReleaseMutex ( osdTimeMutex );
|
||||
|
||||
unixStyleStatus = osdTimeSych ();
|
||||
if ( unixStyleStatus != tsStampOK ) {
|
||||
if ( unixStyleStatus != epicsTimeOK ) {
|
||||
CloseHandle ( osdTimeMutex );
|
||||
osdTimeMutex = NULL;
|
||||
return;
|
||||
@@ -197,7 +197,7 @@ static void osdTimeInit ()
|
||||
//
|
||||
static int osdTimeSych ()
|
||||
{
|
||||
static const DWORD tmoTwentySec = 20 * osiTime::mSecPerSec;
|
||||
static const DWORD tmoTwentySec = 20 * epicsTime::mSecPerSec;
|
||||
LONGLONG new_sec_offset, new_frac_offset;
|
||||
LARGE_INTEGER parm;
|
||||
LONGLONG secondsSinceBoot;
|
||||
@@ -209,13 +209,13 @@ static int osdTimeSych ()
|
||||
if (!osdTimeMutex) {
|
||||
osdTimeInit ();
|
||||
if (!osdTimeMutex) {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
}
|
||||
|
||||
win32SemStat = WaitForSingleObject (osdTimeMutex, tmoTwentySec);
|
||||
if ( win32SemStat != WAIT_OBJECT_0 ) {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -228,7 +228,7 @@ static int osdTimeSych ()
|
||||
// has forced its code to load
|
||||
if (QueryPerformanceCounter (&parm)==0) {
|
||||
ReleaseMutex (osdTimeMutex);
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
|
||||
perf_last = parm.QuadPart;
|
||||
@@ -313,18 +313,18 @@ static int osdTimeSych ()
|
||||
|
||||
win32Stat = ReleaseMutex (osdTimeMutex);
|
||||
if (!win32Stat) {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
|
||||
return tsStampOK;
|
||||
return epicsTimeOK;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTime::osdGetCurrent ()
|
||||
// epicsTime::osdGetCurrent ()
|
||||
//
|
||||
extern "C" epicsShareFunc int epicsShareAPI tsStampGetCurrent (TS_STAMP *pDest)
|
||||
extern "C" epicsShareFunc int epicsShareAPI epicsTimeGetCurrent (epicsTimeStamp *pDest)
|
||||
{
|
||||
static const DWORD tmoTwentySec = 20 * osiTime::mSecPerSec;
|
||||
static const DWORD tmoTwentySec = 20 * epicsTime::mSecPerSec;
|
||||
LONGLONG time_cur, time_sec, time_remainder;
|
||||
LARGE_INTEGER parm;
|
||||
BOOL status;
|
||||
@@ -335,13 +335,13 @@ extern "C" epicsShareFunc int epicsShareAPI tsStampGetCurrent (TS_STAMP *pDest)
|
||||
if (!osdTimeMutex) {
|
||||
osdTimeInit ();
|
||||
if (!osdTimeMutex) {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
}
|
||||
|
||||
status = WaitForSingleObject (osdTimeMutex, tmoTwentySec);
|
||||
if ( status != WAIT_OBJECT_0 ) {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -352,7 +352,7 @@ extern "C" epicsShareFunc int epicsShareAPI tsStampGetCurrent (TS_STAMP *pDest)
|
||||
status = QueryPerformanceCounter (&parm);
|
||||
if (!status) {
|
||||
ReleaseMutex (osdTimeMutex);
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
time_cur = parm.QuadPart;
|
||||
if (perf_last > time_cur) {
|
||||
@@ -389,26 +389,26 @@ extern "C" epicsShareFunc int epicsShareAPI tsStampGetCurrent (TS_STAMP *pDest)
|
||||
perf_last = time_cur;
|
||||
|
||||
pDest->secPastEpoch = (unsigned long) (time_sec%ULONG_MAX);
|
||||
pDest->nsec = (unsigned long) ((time_remainder*osiTime::nSecPerSec)/perf_freq);
|
||||
pDest->nsec = (unsigned long) ((time_remainder*epicsTime::nSecPerSec)/perf_freq);
|
||||
|
||||
status = ReleaseMutex (osdTimeMutex);
|
||||
if (!status) {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
|
||||
return tsStampOK;
|
||||
return epicsTimeOK;
|
||||
}
|
||||
|
||||
//
|
||||
// tsStampGetEvent ()
|
||||
// epicsTimeGetEvent ()
|
||||
//
|
||||
extern "C" epicsShareFunc int epicsShareAPI tsStampGetEvent (TS_STAMP *pDest, unsigned eventNumber)
|
||||
extern "C" epicsShareFunc int epicsShareAPI epicsTimeGetEvent (epicsTimeStamp *pDest, unsigned eventNumber)
|
||||
{
|
||||
if (eventNumber==tsStampEventCurrentTime) {
|
||||
return tsStampGetCurrent (pDest);
|
||||
if (eventNumber==epicsTimeEventCurrentTime) {
|
||||
return epicsTimeGetCurrent (pDest);
|
||||
}
|
||||
else {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ of this distribution.
|
||||
|
||||
#include "epicsEvent.h"
|
||||
#include "cantProceed.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "errlog.h"
|
||||
#include "epicsAssert.h"
|
||||
|
||||
@@ -46,12 +46,12 @@ if(status) { \
|
||||
static void convertDoubleToWakeTime(double timeout,struct timespec *wakeTime)
|
||||
{
|
||||
struct timespec wait;
|
||||
TS_STAMP stamp;
|
||||
epicsTimeStamp stamp;
|
||||
|
||||
if(timeout<0.0) timeout = 0.0;
|
||||
else if(timeout>3600.0) timeout = 3600.0;
|
||||
tsStampGetCurrent(&stamp);
|
||||
tsStampToTimespec(wakeTime, &stamp);
|
||||
epicsTimeGetCurrent(&stamp);
|
||||
epicsTimeToTimespec(wakeTime, &stamp);
|
||||
wait.tv_sec = timeout;
|
||||
wait.tv_nsec = (long)((timeout - (double)wait.tv_sec) * 1e9);
|
||||
wakeTime->tv_sec += wait.tv_sec;
|
||||
|
||||
@@ -19,7 +19,7 @@ of this distribution.
|
||||
|
||||
#include "epicsMutex.h"
|
||||
#include "cantProceed.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "errlog.h"
|
||||
#include "epicsAssert.h"
|
||||
|
||||
@@ -52,12 +52,12 @@ if(status) { \
|
||||
static void convertDoubleToWakeTime(double timeout,struct timespec *wakeTime)
|
||||
{
|
||||
struct timespec wait;
|
||||
TS_STAMP stamp;
|
||||
epicsTimeStamp stamp;
|
||||
|
||||
if(timeout<0.0) timeout = 0.0;
|
||||
else if(timeout>3600.0) timeout = 3600.0;
|
||||
tsStampGetCurrent(&stamp);
|
||||
tsStampToTimespec(wakeTime, &stamp);
|
||||
epicsTimeGetCurrent(&stamp);
|
||||
epicsTimeToTimespec(wakeTime, &stamp);
|
||||
wait.tv_sec = timeout;
|
||||
wait.tv_nsec = (long)((timeout - (double)wait.tv_sec) * 1e9);
|
||||
wakeTime->tv_sec += wait.tv_sec;
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
#include "osiSock.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "osiTime.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
|
||||
//
|
||||
// osiTime::osdGetCurrent ()
|
||||
// epicsTime::osdGetCurrent ()
|
||||
//
|
||||
extern "C" epicsShareFunc int epicsShareAPI tsStampGetCurrent (TS_STAMP *pDest)
|
||||
extern "C" epicsShareFunc int epicsShareAPI epicsTimeGetCurrent (epicsTimeStamp *pDest)
|
||||
{
|
||||
# ifdef _POSIX_TIMERS
|
||||
struct timespec ts;
|
||||
@@ -20,33 +20,33 @@ extern "C" epicsShareFunc int epicsShareAPI tsStampGetCurrent (TS_STAMP *pDest)
|
||||
|
||||
status = clock_gettime (CLOCK_REALTIME, &ts);
|
||||
if (status) {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
|
||||
*pDest = osiTime (ts);
|
||||
return tsStampOK;
|
||||
*pDest = epicsTime (ts);
|
||||
return epicsTimeOK;
|
||||
# else
|
||||
int status;
|
||||
struct timeval tv;
|
||||
|
||||
status = gettimeofday (&tv, NULL);
|
||||
if (status) {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
*pDest = osiTime (tv);
|
||||
return tsStampOK;
|
||||
*pDest = epicsTime (tv);
|
||||
return epicsTimeOK;
|
||||
# endif
|
||||
}
|
||||
|
||||
//
|
||||
// tsStampGetEvent ()
|
||||
// epicsTimeGetEvent ()
|
||||
//
|
||||
extern "C" epicsShareFunc int epicsShareAPI tsStampGetEvent (TS_STAMP *pDest, unsigned eventNumber)
|
||||
extern "C" epicsShareFunc int epicsShareAPI epicsTimeGetEvent (epicsTimeStamp *pDest, unsigned eventNumber)
|
||||
{
|
||||
if (eventNumber==tsStampEventCurrentTime) {
|
||||
return tsStampGetCurrent (pDest);
|
||||
if (eventNumber==epicsTimeEventCurrentTime) {
|
||||
return epicsTimeGetCurrent (pDest);
|
||||
}
|
||||
else {
|
||||
return tsStampERROR;
|
||||
return epicsTimeERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,24 +26,24 @@ of this distribution.
|
||||
#include "errlog.h"
|
||||
#include "epicsThread.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "iocClock.h"
|
||||
|
||||
#define BILLION 1000000000
|
||||
#define iocClockSyncRate 10.0
|
||||
|
||||
static int iocClockGetCurrent(TS_STAMP *pDest);
|
||||
static int iocClockGetEvent(TS_STAMP *pDest, unsigned eventNumber);
|
||||
static int iocClockGetCurrent(epicsTimeStamp *pDest);
|
||||
static int iocClockGetEvent(epicsTimeStamp *pDest, unsigned eventNumber);
|
||||
|
||||
typedef struct iocClockPvt {
|
||||
epicsMutexId lock;
|
||||
TS_STAMP clock;
|
||||
epicsTimeStamp clock;
|
||||
unsigned long lastTick;
|
||||
epicsUInt32 nanosecondsPerTick;
|
||||
int tickRate;
|
||||
int ticksToSkip;
|
||||
ptsStampGetCurrent getCurrent;
|
||||
ptsStampGetEvent getEvent;
|
||||
pepicsTimeGetCurrent getCurrent;
|
||||
pepicsTimeGetEvent getEvent;
|
||||
char *pserverAddr;
|
||||
}iocClockPvt;
|
||||
static iocClockPvt *piocClockPvt = 0;
|
||||
@@ -53,7 +53,7 @@ extern char* sysBootLine;
|
||||
static void syncNTP(void)
|
||||
{
|
||||
struct timespec Currtime;
|
||||
TS_STAMP epicsTime;
|
||||
epicsTimeStamp epicsTime;
|
||||
STATUS status;
|
||||
int prevStatusBad = 0;
|
||||
int firstTime=1;
|
||||
@@ -75,9 +75,9 @@ static void syncNTP(void)
|
||||
errlogPrintf("iocClockSyncWithNTPserver: sntpcTimeGet OK\n");
|
||||
prevStatusBad = 0;
|
||||
}
|
||||
tsStampFromTimespec(&epicsTime,&Currtime);
|
||||
epicsTimeFromTimespec(&epicsTime,&Currtime);
|
||||
epicsMutexMustLock(piocClockPvt->lock);
|
||||
diffTime = tsStampDiffInSeconds(&epicsTime,&piocClockPvt->clock);
|
||||
diffTime = epicsTimeDiffInSeconds(&epicsTime,&piocClockPvt->clock);
|
||||
if(diffTime>=0.0) {
|
||||
piocClockPvt->clock = epicsTime;
|
||||
} else {/*dont go back in time*/
|
||||
@@ -118,8 +118,8 @@ void iocClockInit()
|
||||
return;
|
||||
}
|
||||
|
||||
void iocClockRegister(ptsStampGetCurrent getCurrent,
|
||||
ptsStampGetEvent getEvent)
|
||||
void iocClockRegister(pepicsTimeGetCurrent getCurrent,
|
||||
pepicsTimeGetEvent getEvent)
|
||||
{
|
||||
if(piocClockPvt) {
|
||||
printf("iocClockRegister: iocClock already initialized\n");
|
||||
@@ -130,7 +130,7 @@ void iocClockRegister(ptsStampGetCurrent getCurrent,
|
||||
piocClockPvt->getEvent = getEvent;
|
||||
}
|
||||
|
||||
int iocClockGetCurrent(TS_STAMP *pDest)
|
||||
int iocClockGetCurrent(epicsTimeStamp *pDest)
|
||||
{
|
||||
unsigned long currentTick,nticks,nsecs;
|
||||
|
||||
@@ -162,26 +162,26 @@ int iocClockGetCurrent(TS_STAMP *pDest)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int iocClockGetEvent(TS_STAMP *pDest, unsigned eventNumber)
|
||||
int iocClockGetEvent(epicsTimeStamp *pDest, unsigned eventNumber)
|
||||
{
|
||||
if (eventNumber==tsStampEventCurrentTime) {
|
||||
if (eventNumber==epicsTimeEventCurrentTime) {
|
||||
*pDest = piocClockPvt->clock;
|
||||
return(0);
|
||||
}
|
||||
return(tsStampERROR);
|
||||
return(epicsTimeERROR);
|
||||
}
|
||||
|
||||
int tsStampGetCurrent (TS_STAMP *pDest)
|
||||
int epicsTimeGetCurrent (epicsTimeStamp *pDest)
|
||||
{
|
||||
if(piocClockPvt->getCurrent) return((*piocClockPvt->getCurrent)(pDest));
|
||||
return(tsStampERROR);
|
||||
return(epicsTimeERROR);
|
||||
}
|
||||
|
||||
int tsStampGetEvent (TS_STAMP *pDest, unsigned eventNumber)
|
||||
int epicsTimeGetEvent (epicsTimeStamp *pDest, unsigned eventNumber)
|
||||
{
|
||||
if(piocClockPvt->getEvent)
|
||||
return((*piocClockPvt->getEvent)(pDest,eventNumber));
|
||||
return(tsStampERROR);
|
||||
return(epicsTimeERROR);
|
||||
}
|
||||
|
||||
/* Unless
|
||||
@@ -191,17 +191,17 @@ int tsStampGetEvent (TS_STAMP *pDest, unsigned eventNumber)
|
||||
*/
|
||||
void date()
|
||||
{
|
||||
TS_STAMP now;
|
||||
epicsTimeStamp now;
|
||||
char nowText[40];
|
||||
size_t rtn;
|
||||
|
||||
rtn = tsStampGetCurrent(&now);
|
||||
rtn = epicsTimeGetCurrent(&now);
|
||||
if(rtn) {
|
||||
printf("tsStampGetCurrent failed\n");
|
||||
printf("epicsTimeGetCurrent failed\n");
|
||||
return;
|
||||
}
|
||||
nowText[0] = 0;
|
||||
rtn = tsStampToStrftime(nowText,sizeof(nowText),
|
||||
rtn = epicsTimeToStrftime(nowText,sizeof(nowText),
|
||||
"%Y/%m/%d %H:%M:%S.%06f",&now);
|
||||
printf("%s\n",nowText);
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ described on the COPYRIGHT_UniversityOfChicago file included as part
|
||||
of this distribution.
|
||||
****************************************************************************/
|
||||
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
typedef int (*ptsStampGetCurrent)(TS_STAMP *pDest);
|
||||
typedef int (*ptsStampGetEvent)(TS_STAMP *pDest,unsigned eventNumber);
|
||||
typedef int (*pepicsTimeGetCurrent)(epicsTimeStamp *pDest);
|
||||
typedef int (*pepicsTimeGetEvent)(epicsTimeStamp *pDest,unsigned eventNumber);
|
||||
|
||||
void iocClockInit(void);
|
||||
void iocClockRegister(ptsStampGetCurrent getCurrent,ptsStampGetEvent getEvent);
|
||||
void iocClockRegister(pepicsTimeGetCurrent getCurrent,pepicsTimeGetEvent getEvent);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// this is not needed
|
||||
// tsStampGetCurrent and tsStampGetEvent are implemented in iocClock.c
|
||||
// epicsTimeGetCurrent and epicsTimeGetEvent are implemented in iocClock.c
|
||||
|
||||
@@ -1,866 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Author Jeffrey O. Hill
|
||||
* johill@lanl.gov
|
||||
* 505 665 1831
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
* and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
*
|
||||
* Initial development by:
|
||||
* The Controls and Automation Group (AT-8)
|
||||
* Ground Test Accelerator
|
||||
* Accelerator Technology Division
|
||||
* Los Alamos National Laboratory
|
||||
*
|
||||
* Co-developed with
|
||||
* The Controls and Computing Group
|
||||
* Accelerator Systems Division
|
||||
* Advanced Photon Source
|
||||
* Argonne National Laboratory
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "locationException.h"
|
||||
#include "epicsAssert.h"
|
||||
#include "envDefs.h"
|
||||
#include "osiTime.h"
|
||||
#include "tsStamp.h"
|
||||
|
||||
//
|
||||
// useful public constants
|
||||
//
|
||||
const unsigned osiTime::mSecPerSec = 1000u;
|
||||
const unsigned osiTime::uSecPerSec = 1000u*osiTime::mSecPerSec;
|
||||
const unsigned osiTime::nSecPerSec = 1000u*osiTime::uSecPerSec;
|
||||
const unsigned osiTime::nSecPerUSec = 1000u;
|
||||
const unsigned osiTime::secPerMin = 60u;
|
||||
|
||||
static const unsigned ntpEpochYear = 1900;
|
||||
static const unsigned ntpEpocMonth = 0; // January
|
||||
static const unsigned ntpEpocDayOfTheMonth = 1; // the 1st day of the month
|
||||
static const double ULONG_MAX_PLUS_ONE = (static_cast<double>(ULONG_MAX) + 1.0);
|
||||
|
||||
//
|
||||
// force this module to include code that can convert
|
||||
// to GDD's aitTimeStamp, but dont require that it must
|
||||
// link with gdd. Therefore, gdd.h is not included here.
|
||||
//
|
||||
class aitTimeStamp {
|
||||
public:
|
||||
unsigned long tv_sec;
|
||||
unsigned long tv_nsec;
|
||||
};
|
||||
|
||||
static const unsigned tmStructEpochYear = 1900;
|
||||
|
||||
static const unsigned epicsEpochYear = 1990;
|
||||
static const unsigned epicsEpocMonth = 0; // January
|
||||
static const unsigned epicsEpocDayOfTheMonth = 1; // the 1st day of the month
|
||||
|
||||
//
|
||||
// forward declarations for utility routines
|
||||
//
|
||||
static char *fracFormat (const char *pFormat, unsigned long *width);
|
||||
|
||||
//
|
||||
// osiTime (const unsigned long secIn, const unsigned long nSecIn)
|
||||
//
|
||||
inline osiTime::osiTime (const unsigned long secIn, const unsigned long nSecIn) :
|
||||
secPastEpoch ( nSecIn / nSecPerSec + secIn ), nSec ( nSecIn % nSecPerSec ) {}
|
||||
|
||||
//
|
||||
// osiTimeLoadTimeInit
|
||||
//
|
||||
class osiTimeLoadTimeInit {
|
||||
public:
|
||||
osiTimeLoadTimeInit ();
|
||||
|
||||
double epicsEpochOffset; // seconds
|
||||
#ifdef NTP_SUPPORT
|
||||
double ntpEpochOffset; // seconds
|
||||
#endif
|
||||
double time_tSecPerTick; // seconds (both NTP and EPICS use int sec)
|
||||
};
|
||||
|
||||
static const osiTimeLoadTimeInit lti;
|
||||
|
||||
//
|
||||
// osiTimeLoadTimeInit ()
|
||||
//
|
||||
osiTimeLoadTimeInit::osiTimeLoadTimeInit ()
|
||||
{
|
||||
static const time_t ansiEpoch = 0;
|
||||
double secWest;
|
||||
|
||||
{
|
||||
time_t current = time (NULL);
|
||||
time_t error;
|
||||
tm date;
|
||||
|
||||
gmtime_r (¤t, &date);
|
||||
error = mktime (&date);
|
||||
assert (error!=(time_t)-1);
|
||||
secWest = difftime (error, current);
|
||||
}
|
||||
|
||||
{
|
||||
time_t first = static_cast<time_t> (0);
|
||||
time_t last = static_cast<time_t> (1);
|
||||
this->time_tSecPerTick = difftime (last, first);
|
||||
}
|
||||
|
||||
{
|
||||
struct tm tmEpicsEpoch;
|
||||
time_t epicsEpoch;
|
||||
|
||||
tmEpicsEpoch.tm_sec = 0;
|
||||
tmEpicsEpoch.tm_min = 0;
|
||||
tmEpicsEpoch.tm_hour = 0;
|
||||
tmEpicsEpoch.tm_mday = epicsEpocDayOfTheMonth;
|
||||
tmEpicsEpoch.tm_mon = epicsEpocMonth;
|
||||
tmEpicsEpoch.tm_year = epicsEpochYear-tmStructEpochYear;
|
||||
tmEpicsEpoch.tm_isdst = -1; // dont know if its daylight savings time
|
||||
|
||||
epicsEpoch = mktime (&tmEpicsEpoch);
|
||||
assert (epicsEpoch!=(time_t)-1);
|
||||
this->epicsEpochOffset = difftime (epicsEpoch, ansiEpoch) - secWest;
|
||||
}
|
||||
|
||||
#ifdef NTP_SUPPORT
|
||||
/* unfortunately, on NT mktime cant calculate a time_t for a date before 1970 */
|
||||
{
|
||||
struct tm tmEpochNTP;
|
||||
time_t ntpEpoch;
|
||||
|
||||
tmEpochNTP.tm_sec = 0;
|
||||
tmEpochNTP.tm_min = 0;
|
||||
tmEpochNTP.tm_hour = 0;
|
||||
tmEpochNTP.tm_mday = ntpEpocDayOfTheMonth;
|
||||
tmEpochNTP.tm_mon = ntpEpocMonth;
|
||||
tmEpochNTP.tm_year = ntpEpochYear-tmStructEpochYear;
|
||||
tmEpochNTP.tm_isdst = -1; // dont know if its daylight savings time
|
||||
|
||||
ntpEpoch = mktime (&tmEpochNTP);
|
||||
assert (ntpEpoch!=(time_t)-1);
|
||||
|
||||
this->ntpEpochOffset = static_cast<long> (difftime (ansiEpoch, ntpEpoch) + this->epicsEpochOffset - secWest);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// osiTime::addNanoSec ()
|
||||
//
|
||||
// many of the UNIX timestamp formats have nano sec stored as a long
|
||||
//
|
||||
inline void osiTime::addNanoSec (long nSecAdj)
|
||||
{
|
||||
double secAdj = static_cast <double> (nSecAdj) / nSecPerSec;
|
||||
*this += secAdj;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTime (const time_t_wrapper &tv)
|
||||
//
|
||||
osiTime::osiTime (const time_t_wrapper &ansiTimeTicks)
|
||||
{
|
||||
static double uLongMax = static_cast<double> (ULONG_MAX);
|
||||
double sec;
|
||||
|
||||
//
|
||||
// map time_t, which ansi C defines as some arithmetic type, into type double
|
||||
//
|
||||
sec = ansiTimeTicks.ts * lti.time_tSecPerTick - lti.epicsEpochOffset;
|
||||
|
||||
//
|
||||
// map into the the EPICS time stamp range (which allows rollover)
|
||||
//
|
||||
if (sec < 0.0) {
|
||||
if (sec < -uLongMax) {
|
||||
sec = sec + static_cast<unsigned long>(-sec/uLongMax)*uLongMax;
|
||||
}
|
||||
sec += uLongMax;
|
||||
}
|
||||
else if (sec > uLongMax) {
|
||||
sec = sec - static_cast<unsigned long>(sec/uLongMax)*uLongMax;
|
||||
}
|
||||
|
||||
this->secPastEpoch = static_cast <unsigned long> (sec);
|
||||
this->nSec = static_cast <unsigned long> ( (sec-this->secPastEpoch) * nSecPerSec );
|
||||
}
|
||||
|
||||
//
|
||||
// operator time_t_wrapper ()
|
||||
//
|
||||
osiTime::operator time_t_wrapper () const
|
||||
{
|
||||
double tmp;
|
||||
time_t_wrapper wrap;
|
||||
|
||||
tmp = (this->secPastEpoch + lti.epicsEpochOffset) / lti.time_tSecPerTick;
|
||||
tmp += (this->nSec / lti.time_tSecPerTick) / nSecPerSec;
|
||||
|
||||
//
|
||||
// map type double into time_t which ansi C defines as some arithmetic type
|
||||
//
|
||||
wrap.ts = static_cast <time_t> (tmp);
|
||||
|
||||
return wrap;
|
||||
}
|
||||
|
||||
//
|
||||
// convert to and from ANSI C struct tm (with nano seconds)
|
||||
//
|
||||
osiTime::operator tm_nano_sec () const
|
||||
{
|
||||
tm_nano_sec tm;
|
||||
time_t_wrapper ansiTimeTicks;
|
||||
|
||||
ansiTimeTicks = *this;
|
||||
|
||||
//
|
||||
// reentrant version of localtime() - from POSIX RT
|
||||
//
|
||||
// WRS returns int and others return &tm.ansi_tm on
|
||||
// succes?
|
||||
//
|
||||
localtime_r (&ansiTimeTicks.ts, &tm.ansi_tm);
|
||||
|
||||
tm.nSec = this->nSec;
|
||||
|
||||
return tm;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTime (const tm_nano_sec &tm)
|
||||
//
|
||||
osiTime::osiTime (const tm_nano_sec &tm)
|
||||
{
|
||||
static const time_t mktimeFailure = static_cast <time_t> (-1);
|
||||
time_t_wrapper ansiTimeTicks;
|
||||
struct tm tmp = tm.ansi_tm;
|
||||
|
||||
ansiTimeTicks.ts = mktime (&tmp);
|
||||
if (ansiTimeTicks.ts == mktimeFailure) {
|
||||
throwWithLocation ( formatProblemWithStructTM () );
|
||||
}
|
||||
|
||||
*this = osiTime (ansiTimeTicks);
|
||||
|
||||
unsigned long nSecAdj = tm.nSec % nSecPerSec;
|
||||
unsigned long secAdj = tm.nSec / nSecPerSec;
|
||||
*this = osiTime (this->secPastEpoch+secAdj, this->nSec+nSecAdj);
|
||||
}
|
||||
|
||||
//
|
||||
// operator struct timespec ()
|
||||
//
|
||||
osiTime::operator struct timespec () const
|
||||
{
|
||||
struct timespec ts;
|
||||
time_t_wrapper ansiTimeTicks;
|
||||
|
||||
ansiTimeTicks = *this;
|
||||
ts.tv_sec = ansiTimeTicks.ts;
|
||||
ts.tv_nsec = static_cast<long> (this->nSec);
|
||||
return ts;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTime (const struct timespec &ts)
|
||||
//
|
||||
osiTime::osiTime (const struct timespec &ts)
|
||||
{
|
||||
time_t_wrapper ansiTimeTicks;
|
||||
|
||||
ansiTimeTicks.ts = ts.tv_sec;
|
||||
*this = osiTime (ansiTimeTicks);
|
||||
this->addNanoSec (ts.tv_nsec);
|
||||
}
|
||||
|
||||
//
|
||||
// operator struct timeval ()
|
||||
//
|
||||
osiTime::operator struct timeval () const
|
||||
{
|
||||
struct timeval ts;
|
||||
time_t_wrapper ansiTimeTicks;
|
||||
|
||||
ansiTimeTicks = *this;
|
||||
ts.tv_sec = ansiTimeTicks.ts;
|
||||
ts.tv_usec = static_cast<long> (this->nSec / nSecPerUSec);
|
||||
return ts;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTime (const struct timeval &ts)
|
||||
//
|
||||
osiTime::osiTime (const struct timeval &ts)
|
||||
{
|
||||
time_t_wrapper ansiTimeTicks;
|
||||
|
||||
ansiTimeTicks.ts = ts.tv_sec;
|
||||
*this = osiTime (ansiTimeTicks);
|
||||
this->addNanoSec (ts.tv_usec * nSecPerUSec);
|
||||
}
|
||||
|
||||
//
|
||||
// operator aitTimeStamp ()
|
||||
//
|
||||
osiTime::operator aitTimeStamp () const
|
||||
{
|
||||
aitTimeStamp ts;
|
||||
time_t_wrapper ansiTimeTicks;
|
||||
|
||||
ansiTimeTicks = *this;
|
||||
ts.tv_sec = ansiTimeTicks.ts;
|
||||
ts.tv_nsec = this->nSec;
|
||||
return ts;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTime (const aitTimeStamp &ts)
|
||||
//
|
||||
osiTime::osiTime (const aitTimeStamp &ts)
|
||||
{
|
||||
time_t_wrapper ansiTimeTicks;
|
||||
|
||||
ansiTimeTicks.ts = ts.tv_sec;
|
||||
*this = osiTime (ansiTimeTicks);
|
||||
|
||||
unsigned long secAdj = ts.tv_nsec / nSecPerSec;
|
||||
unsigned long nSecAdj = ts.tv_nsec % nSecPerSec;
|
||||
*this = osiTime (this->secPastEpoch+secAdj, this->nSec+nSecAdj);
|
||||
}
|
||||
|
||||
//
|
||||
// osiTime::ntpTimeStamp ()
|
||||
//
|
||||
#ifdef NTP_SUPPORT
|
||||
osiTime::operator ntpTimeStamp () const
|
||||
{
|
||||
ntpTimeStamp ts;
|
||||
|
||||
if (lti.ntpEpochOffset>=0) {
|
||||
unsigned long offset = static_cast<unsigned long> (lti.ntpEpochOffset);
|
||||
// underflow expected
|
||||
ts.l_ui = this->secPastEpoch - offset;
|
||||
}
|
||||
else {
|
||||
unsigned long offset = static_cast<unsigned long> (-lti.ntpEpochOffset);
|
||||
// overflow expected
|
||||
ts.l_ui = this->secPastEpoch + offset;
|
||||
}
|
||||
|
||||
ts.l_uf = static_cast<unsigned long> ( ( this->nSec * ULONG_MAX_PLUS_ONE ) / nSecPerSec );
|
||||
|
||||
return ts;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// osiTime::osiTime (const ntpTimeStamp &ts)
|
||||
//
|
||||
#ifdef NTP_SUPPORT
|
||||
osiTime::osiTime (const ntpTimeStamp &ts)
|
||||
{
|
||||
|
||||
if (lti.ntpEpochOffset>=0) {
|
||||
unsigned long offset = static_cast<unsigned long> (lti.ntpEpochOffset);
|
||||
// overflow expected
|
||||
this->secPastEpoch = ts.l_ui + this->secPastEpoch + offset;
|
||||
}
|
||||
else {
|
||||
unsigned long offset = static_cast<unsigned long> (-lti.ntpEpochOffset);
|
||||
// underflow expected
|
||||
this->secPastEpoch = ts.l_ui + this->secPastEpoch - offset;
|
||||
}
|
||||
|
||||
this->nSec = static_cast<unsigned long> ( ( ts.l_uf / ULONG_MAX_PLUS_ONE ) * nSecPerSec );
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// size_t osiTime::strftime (char *pBuff, size_t bufLength, const char *pFormat)
|
||||
//
|
||||
size_t osiTime::strftime (char *pBuff, size_t bufLength, const char *pFormat) const
|
||||
{
|
||||
// copy format (needs to be writable)
|
||||
char format[256];
|
||||
strcpy (format, pFormat);
|
||||
|
||||
// look for "%0<n>f" at the end (used for fractional second formatting)
|
||||
unsigned long fracWid;
|
||||
char *fracPtr = fracFormat (format, &fracWid);
|
||||
|
||||
// if found, hide from strftime
|
||||
if (fracPtr != NULL) *fracPtr = '\0';
|
||||
|
||||
// format all but fractional seconds
|
||||
tm_nano_sec tmns = *this;
|
||||
size_t numChar = ::strftime (pBuff, bufLength, format, &tmns.ansi_tm);
|
||||
if (numChar == 0 || fracPtr == NULL) return numChar;
|
||||
|
||||
// check there are enough chars for the fractional seconds
|
||||
if (numChar + fracWid < bufLength)
|
||||
{
|
||||
// divisors for fraction (see below)
|
||||
const int div[9+1] = {(int)1e9,(int)1e8,(int)1e7,(int)1e6,(int)1e5,
|
||||
(int)1e4,(int)1e3,(int)1e2,(int)1e1,(int)1e0};
|
||||
|
||||
// round and convert nanosecs to integer of correct range
|
||||
int ndp = fracWid <= 9 ? fracWid : 9;
|
||||
int frac = ((tmns.nSec + div[ndp]/2) % ((int)1e9)) / div[ndp];
|
||||
|
||||
// restore fractional format and format fraction
|
||||
*fracPtr = '%';
|
||||
*(format + strlen (format) - 1) = 'u';
|
||||
sprintf (pBuff+numChar, fracPtr, frac);
|
||||
}
|
||||
return numChar + fracWid;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTime::show (unsigned)
|
||||
//
|
||||
void osiTime::show (unsigned) const
|
||||
{
|
||||
char bigBuffer[256];
|
||||
|
||||
size_t numChar = strftime (bigBuffer, sizeof(bigBuffer),
|
||||
"%a %b %d %Y %H:%M:%S.%09f");
|
||||
if (numChar>0) {
|
||||
printf ("osiTime: %s\n", bigBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// osiTime::operator + (const double &rhs)
|
||||
//
|
||||
// rhs has units seconds
|
||||
//
|
||||
osiTime osiTime::operator + (const double &rhs) const
|
||||
{
|
||||
unsigned long newSec, newNSec, secOffset, nSecOffset;
|
||||
double fnsec;
|
||||
|
||||
if (rhs >= 0) {
|
||||
secOffset = static_cast <unsigned long> (rhs);
|
||||
fnsec = rhs - secOffset;
|
||||
nSecOffset = static_cast <unsigned long> (fnsec * nSecPerSec);
|
||||
|
||||
newSec = this->secPastEpoch + secOffset; // overflow expected
|
||||
newNSec = this->nSec + nSecOffset;
|
||||
if (newNSec >= nSecPerSec) {
|
||||
newSec++; // overflow expected
|
||||
newNSec -= nSecPerSec;
|
||||
}
|
||||
}
|
||||
else {
|
||||
secOffset = static_cast <unsigned long> (-rhs);
|
||||
fnsec = rhs + secOffset;
|
||||
nSecOffset = static_cast <unsigned long> (-fnsec * nSecPerSec);
|
||||
|
||||
newSec = this->secPastEpoch - secOffset; // underflow expected
|
||||
if (this->nSec>=nSecOffset) {
|
||||
newNSec = this->nSec - nSecOffset;
|
||||
}
|
||||
else {
|
||||
// borrow
|
||||
newSec--; // underflow expected
|
||||
newNSec = this->nSec + (nSecPerSec - nSecOffset);
|
||||
}
|
||||
}
|
||||
return osiTime (newSec, newNSec);
|
||||
}
|
||||
|
||||
//
|
||||
// operator -
|
||||
//
|
||||
// To make this code robust during timestamp rollover events
|
||||
// time stamp differences greater than one half full scale are
|
||||
// interpreted as rollover situations:
|
||||
//
|
||||
// when RHS is greater than THIS:
|
||||
// RHS-THIS > one half full scale => return THIS + (ULONG_MAX-RHS)
|
||||
// RHS-THIS <= one half full scale => return -(RHS-THIS)
|
||||
//
|
||||
// when THIS is greater than or equal to RHS
|
||||
// THIS-RHS > one half full scale => return -(RHS + (ULONG_MAX-THIS))
|
||||
// THIS-RHS <= one half full scale => return THIS-RHS
|
||||
//
|
||||
double osiTime::operator - (const osiTime &rhs) const
|
||||
{
|
||||
double nSecRes, secRes;
|
||||
|
||||
//
|
||||
// first compute the difference between the nano-seconds members
|
||||
//
|
||||
// nano sec member is not allowed to be greater that 1/2 full scale
|
||||
// so the unsigned to signed conversion is ok
|
||||
//
|
||||
if (this->nSec>=rhs.nSec) {
|
||||
nSecRes = this->nSec - rhs.nSec;
|
||||
}
|
||||
else {
|
||||
nSecRes = rhs.nSec - this->nSec;
|
||||
nSecRes = -nSecRes;
|
||||
}
|
||||
|
||||
//
|
||||
// next compute the difference between the seconds memebers
|
||||
// and invert the sign of the nano seconds result if there
|
||||
// is a range violation
|
||||
//
|
||||
if (this->secPastEpoch<rhs.secPastEpoch) {
|
||||
secRes = rhs.secPastEpoch - this->secPastEpoch;
|
||||
if (secRes > ULONG_MAX/2) {
|
||||
//
|
||||
// In this situation where the difference is more than
|
||||
// 68 years assume that the seconds counter has rolled
|
||||
// over and compute the "wrap around" difference
|
||||
//
|
||||
secRes = 1 + (ULONG_MAX-secRes);
|
||||
nSecRes = -nSecRes;
|
||||
}
|
||||
else {
|
||||
secRes = -secRes;
|
||||
}
|
||||
}
|
||||
else {
|
||||
secRes = this->secPastEpoch - rhs.secPastEpoch;
|
||||
if (secRes > ULONG_MAX/2) {
|
||||
//
|
||||
// In this situation where the difference is more than
|
||||
// 68 years assume that the seconds counter has rolled
|
||||
// over and compute the "wrap around" difference
|
||||
//
|
||||
secRes = 1 + (ULONG_MAX-secRes);
|
||||
secRes = -secRes;
|
||||
nSecRes = -nSecRes;
|
||||
}
|
||||
}
|
||||
|
||||
return secRes + nSecRes/nSecPerSec;
|
||||
}
|
||||
|
||||
//
|
||||
// operator <=
|
||||
//
|
||||
bool osiTime::operator <= (const osiTime &rhs) const
|
||||
{
|
||||
bool rc;
|
||||
|
||||
if (this->secPastEpoch<rhs.secPastEpoch) {
|
||||
if (rhs.secPastEpoch-this->secPastEpoch < ULONG_MAX/2) {
|
||||
//
|
||||
// In this situation where the difference is less than
|
||||
// 69 years compute the expected result
|
||||
//
|
||||
rc = true;
|
||||
}
|
||||
else {
|
||||
//
|
||||
// In this situation where the difference is more than
|
||||
// 69 years assume that the seconds counter has rolled
|
||||
// over and compute the "wrap around" result
|
||||
//
|
||||
rc = false;
|
||||
}
|
||||
}
|
||||
else if (this->secPastEpoch>rhs.secPastEpoch) {
|
||||
if (this->secPastEpoch-rhs.secPastEpoch < ULONG_MAX/2) {
|
||||
//
|
||||
// In this situation where the difference is less than
|
||||
// 69 years compute the expected result
|
||||
//
|
||||
rc = false;
|
||||
}
|
||||
else {
|
||||
//
|
||||
// In this situation where the difference is more than
|
||||
// 69 years assume that the seconds counter has rolled
|
||||
// over and compute the "wrap around" result
|
||||
//
|
||||
rc = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this->nSec<=rhs.nSec) {
|
||||
rc = true;
|
||||
}
|
||||
else {
|
||||
rc = false;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
//
|
||||
// operator <
|
||||
//
|
||||
bool osiTime::operator < (const osiTime &rhs) const
|
||||
{
|
||||
bool rc;
|
||||
|
||||
if (this->secPastEpoch<rhs.secPastEpoch) {
|
||||
if (rhs.secPastEpoch-this->secPastEpoch < ULONG_MAX/2) {
|
||||
//
|
||||
// In this situation where the difference is less than
|
||||
// 69 years compute the expected result
|
||||
//
|
||||
rc = true;
|
||||
}
|
||||
else {
|
||||
//
|
||||
// In this situation where the difference is more than
|
||||
// 69 years assume that the seconds counter has rolled
|
||||
// over and compute the "wrap around" result
|
||||
//
|
||||
rc = false;
|
||||
}
|
||||
}
|
||||
else if (this->secPastEpoch>rhs.secPastEpoch) {
|
||||
if (this->secPastEpoch-rhs.secPastEpoch < ULONG_MAX/2) {
|
||||
//
|
||||
// In this situation where the difference is less than
|
||||
// 69 years compute the expected result
|
||||
//
|
||||
rc = false;
|
||||
}
|
||||
else {
|
||||
//
|
||||
// In this situation where the difference is more than
|
||||
// 69 years assume that the seconds counter has rolled
|
||||
// over and compute the "wrap around" result
|
||||
//
|
||||
rc = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this->nSec<rhs.nSec) {
|
||||
rc = true;
|
||||
}
|
||||
else {
|
||||
rc = false;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
//
|
||||
// ANSI C interface
|
||||
//
|
||||
// its too bad that these cant be implemented with inline functions
|
||||
// at least when running the GNU compiler
|
||||
//
|
||||
epicsShareFunc int epicsShareAPI tsStampToTime_t (time_t *pDest, const TS_STAMP *pSrc)
|
||||
{
|
||||
# ifdef noExceptionsFromCXX
|
||||
time_t_wrapper dst = osiTime (*pSrc);
|
||||
*pDest = dst.ts;
|
||||
# else
|
||||
try {
|
||||
time_t_wrapper dst = osiTime (*pSrc);
|
||||
*pDest = dst.ts;
|
||||
}
|
||||
catch (...) {
|
||||
return tsStampERROR;
|
||||
}
|
||||
# endif
|
||||
return tsStampOK;
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampFromTime_t (TS_STAMP *pDest, time_t src)
|
||||
{
|
||||
time_t_wrapper dst;
|
||||
dst.ts = src;
|
||||
# ifdef noExceptionsFromCXX
|
||||
*pDest = osiTime (dst);
|
||||
# else
|
||||
try {
|
||||
*pDest = osiTime (dst);
|
||||
}
|
||||
catch (...) {
|
||||
return tsStampERROR;
|
||||
}
|
||||
# endif
|
||||
return tsStampOK;
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampToTM (struct tm *pDest, unsigned long *pNSecDest, const TS_STAMP *pSrc)
|
||||
{
|
||||
tm_nano_sec tmns;
|
||||
# ifdef noExceptionsFromCXX
|
||||
tmns = osiTime (*pSrc);
|
||||
# else
|
||||
try {
|
||||
tmns = osiTime (*pSrc);
|
||||
}
|
||||
catch (...) {
|
||||
return tsStampERROR;
|
||||
}
|
||||
# endif
|
||||
*pDest = tmns.ansi_tm;
|
||||
*pNSecDest = tmns.nSec;
|
||||
return tsStampOK;
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampFromTM (TS_STAMP *pDest, const struct tm *pSrc, unsigned long nSecSrc)
|
||||
{
|
||||
tm_nano_sec tmns;
|
||||
tmns.ansi_tm = *pSrc;
|
||||
tmns.nSec = nSecSrc;
|
||||
|
||||
# ifdef noExceptionsFromCXX
|
||||
*pDest = osiTime (tmns);
|
||||
# else
|
||||
try {
|
||||
*pDest = osiTime (tmns);
|
||||
}
|
||||
catch (...) {
|
||||
return tsStampERROR;
|
||||
}
|
||||
# endif
|
||||
return tsStampOK;
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampToTimespec (struct timespec *pDest, const TS_STAMP *pSrc)
|
||||
{
|
||||
# ifdef noExceptionsFromCXX
|
||||
*pDest = osiTime (*pSrc);
|
||||
# else
|
||||
try {
|
||||
*pDest = osiTime (*pSrc);
|
||||
}
|
||||
catch (...) {
|
||||
return tsStampERROR;
|
||||
}
|
||||
# endif
|
||||
return tsStampOK;
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampFromTimespec (TS_STAMP *pDest, const struct timespec *pSrc)
|
||||
{
|
||||
# ifdef noExceptionsFromCXX
|
||||
*pDest = osiTime (*pSrc);
|
||||
# else
|
||||
try {
|
||||
*pDest = osiTime (*pSrc);
|
||||
}
|
||||
catch (...) {
|
||||
return tsStampERROR;
|
||||
}
|
||||
# endif
|
||||
return tsStampOK;
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampToTimeval (struct timeval *pDest, const TS_STAMP *pSrc)
|
||||
{
|
||||
# ifdef noExceptionsFromCXX
|
||||
*pDest = osiTime (*pSrc);
|
||||
# else
|
||||
try {
|
||||
*pDest = osiTime (*pSrc);
|
||||
}
|
||||
catch (...) {
|
||||
return tsStampERROR;
|
||||
}
|
||||
# endif
|
||||
return tsStampOK;
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampFromTimeval (TS_STAMP *pDest, const struct timeval *pSrc)
|
||||
{
|
||||
# ifdef noExceptionsFromCXX
|
||||
*pDest = osiTime (*pSrc);
|
||||
# else
|
||||
try {
|
||||
*pDest = osiTime (*pSrc);
|
||||
}
|
||||
catch (...) {
|
||||
return tsStampERROR;
|
||||
}
|
||||
# endif
|
||||
return tsStampOK;
|
||||
}
|
||||
epicsShareFunc double epicsShareAPI tsStampDiffInSeconds (const TS_STAMP *pLeft, const TS_STAMP *pRight)
|
||||
{
|
||||
return osiTime (*pLeft) - osiTime (*pRight);
|
||||
}
|
||||
epicsShareFunc void epicsShareAPI tsStampAddSeconds (TS_STAMP *pDest, double seconds)
|
||||
{
|
||||
*pDest = osiTime (*pDest) + seconds;
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampEqual (const TS_STAMP *pLeft, const TS_STAMP *pRight)
|
||||
{
|
||||
return osiTime (*pLeft) == osiTime (*pRight);
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampNotEqual (const TS_STAMP *pLeft, const TS_STAMP *pRight)
|
||||
{
|
||||
return osiTime (*pLeft) != osiTime (*pRight);
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampLessThan (const TS_STAMP *pLeft, const TS_STAMP *pRight)
|
||||
{
|
||||
return osiTime (*pLeft) < osiTime (*pRight);
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampLessThanEqual (const TS_STAMP *pLeft, const TS_STAMP *pRight)
|
||||
{
|
||||
return osiTime (*pLeft) <= osiTime (*pRight);
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampGreaterThan (const TS_STAMP *pLeft, const TS_STAMP *pRight)
|
||||
{
|
||||
return osiTime (*pLeft) > osiTime (*pRight);
|
||||
}
|
||||
epicsShareFunc int epicsShareAPI tsStampGreaterThanEqual (const TS_STAMP *pLeft, const TS_STAMP *pRight)
|
||||
{
|
||||
return osiTime (*pLeft) >= osiTime (*pRight);
|
||||
}
|
||||
epicsShareFunc size_t epicsShareAPI tsStampToStrftime (char *pBuff, size_t bufLength, const char *pFormat, const TS_STAMP *pTS)
|
||||
{
|
||||
return osiTime(*pTS).strftime (pBuff, bufLength, pFormat);
|
||||
}
|
||||
epicsShareFunc void epicsShareAPI tsStampShow (const TS_STAMP *pTS, unsigned interestLevel)
|
||||
{
|
||||
osiTime(*pTS).show (interestLevel);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// utility routines
|
||||
//
|
||||
|
||||
// return pointer to trailing "%0<n>f" (<n> is a number) in a format string,
|
||||
// NULL if none; also return <n> and a pointer to the "f"
|
||||
static char *fracFormat (const char *pFormat, unsigned long *width)
|
||||
{
|
||||
// initialize returned field width
|
||||
*width = 0;
|
||||
|
||||
// point at char past format string
|
||||
const char *ptr = pFormat + strlen (pFormat);
|
||||
|
||||
// if (last) char not 'f', no match
|
||||
if (*(--ptr) != 'f') return NULL;
|
||||
|
||||
// skip digits, extracting <n> (must start with 0)
|
||||
while (isdigit (*(--ptr))); // NB, empty loop body
|
||||
++ptr; // points to first digit, if any
|
||||
if (*ptr != '0') return NULL;
|
||||
if (sscanf (ptr, "%lu", width) != 1) return NULL;
|
||||
|
||||
// if (prev) char not '%', no match
|
||||
if (*(--ptr) != '%') return NULL;
|
||||
|
||||
// return pointer to '%'
|
||||
return (char *) ptr;
|
||||
}
|
||||
@@ -1,388 +0,0 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Author Jeffrey O. Hill
|
||||
// johill@lanl.gov
|
||||
// 505 665 1831
|
||||
//
|
||||
// Experimental Physics and Industrial Control System (EPICS)
|
||||
//
|
||||
// Copyright 1991, the Regents of the University of California,
|
||||
// and the University of Chicago Board of Governors.
|
||||
//
|
||||
// This software was produced under U.S. Government contracts:
|
||||
// (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
// and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
//
|
||||
// Initial development by:
|
||||
// The Controls and Automation Group (AT-8)
|
||||
// Ground Test Accelerator
|
||||
// Accelerator Technology Division
|
||||
// Los Alamos National Laboratory
|
||||
//
|
||||
// Co-developed with
|
||||
// The Controls and Computing Group
|
||||
// Accelerator Systems Division
|
||||
// Advanced Photon Source
|
||||
// Argonne National Laboratory
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef osiTimehInclude
|
||||
#define osiTimehInclude
|
||||
|
||||
//
|
||||
// ANSI
|
||||
//
|
||||
#include <time.h>
|
||||
|
||||
#include "shareLib.h"
|
||||
#include "epicsTypes.h"
|
||||
#include "tsStamp.h"
|
||||
#include "locationException.h"
|
||||
|
||||
struct timespec; // POSIX real time
|
||||
struct timeval; // BSD
|
||||
class aitTimeStamp; // GDD
|
||||
|
||||
//
|
||||
// an extended ANSI C RTL "struct tm" which includes
|
||||
// additional nano seconds within a second.
|
||||
//
|
||||
struct tm_nano_sec {
|
||||
struct tm ansi_tm; /* ANSI C time details */
|
||||
unsigned long nSec; /* nano seconds extension */
|
||||
};
|
||||
|
||||
//
|
||||
// wrapping this in a struct allows conversion to and
|
||||
// from ANSI time_t but does not allow unexpected
|
||||
// conversions to occur
|
||||
//
|
||||
struct time_t_wrapper {
|
||||
time_t ts;
|
||||
};
|
||||
|
||||
//
|
||||
// This comment is from the NTP header files:
|
||||
//
|
||||
// NTP uses two fixed point formats. The first (l_fp) is the "long"
|
||||
// format and is 64 bits long with the decimal between bits 31 and 32.
|
||||
// This is used for time stamps in the NTP packet header (in network
|
||||
// byte order) and for internal computations of offsets (in local host
|
||||
// byte order). We use the same structure for both signed and unsigned
|
||||
// values, which is a big hack but saves rewriting all the operators
|
||||
// twice. Just to confuse this, we also sometimes just carry the
|
||||
// fractional part in calculations, in both signed and unsigned forms.
|
||||
// Anyway, an l_fp looks like:
|
||||
//
|
||||
// 0 1 2 3
|
||||
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Integral Part |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
// | Fractional Part |
|
||||
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
//
|
||||
//
|
||||
struct ntpTimeStamp {
|
||||
epicsUInt32 l_ui; /* sec past NTP epoch */
|
||||
epicsUInt32 l_uf; /* fractional seconds */
|
||||
};
|
||||
|
||||
class osiTime;
|
||||
|
||||
//
|
||||
// type osiTimeEvent
|
||||
//
|
||||
class epicsShareClass osiTimeEvent
|
||||
{
|
||||
friend class osiTime;
|
||||
public:
|
||||
osiTimeEvent (const int &eventName);
|
||||
private:
|
||||
unsigned eventNumber;
|
||||
};
|
||||
|
||||
//
|
||||
// type osiTime
|
||||
//
|
||||
// high resolution osiTime stamp class (struct) which can be used
|
||||
// from both C++ and also from ANSI C
|
||||
//
|
||||
class epicsShareClass osiTime
|
||||
{
|
||||
public:
|
||||
|
||||
//
|
||||
// exceptions
|
||||
//
|
||||
class unableToFetchCurrentTime {};
|
||||
class formatProblemWithStructTM {};
|
||||
|
||||
//
|
||||
// fetch the current time
|
||||
//
|
||||
static osiTime getEvent (const osiTimeEvent &event);
|
||||
static osiTime getCurrent ();
|
||||
|
||||
//
|
||||
// create an osiTime for the EPICS epoch
|
||||
//
|
||||
osiTime ();
|
||||
osiTime (const osiTime &t);
|
||||
osiTime & operator = (const osiTime &rhs);
|
||||
|
||||
//
|
||||
// convert to and from EPICS TS_STAMP format
|
||||
//
|
||||
operator TS_STAMP () const;
|
||||
osiTime (const TS_STAMP &ts);
|
||||
osiTime & operator = (const TS_STAMP &rhs);
|
||||
|
||||
//
|
||||
// convert to and from ANSI C's "time_t"
|
||||
//
|
||||
// "time_t" is wrapped in another structure to avoid
|
||||
// unsuspected type conversions
|
||||
// fetch value as an integer
|
||||
//
|
||||
operator time_t_wrapper () const;
|
||||
osiTime (const time_t_wrapper &tv);
|
||||
osiTime & operator = (const time_t_wrapper &rhs);
|
||||
|
||||
//
|
||||
// convert to and from ANSI C's "struct tm" (with nano seconds)
|
||||
//
|
||||
operator tm_nano_sec () const;
|
||||
osiTime (const tm_nano_sec &ts);
|
||||
osiTime & operator = (const tm_nano_sec &rhs);
|
||||
|
||||
//
|
||||
// convert to and from POSIX RT's "struct timespec"
|
||||
//
|
||||
operator struct timespec () const;
|
||||
osiTime (const struct timespec &ts);
|
||||
osiTime & operator = (const struct timespec &rhs);
|
||||
|
||||
//
|
||||
// convert to and from BSD's "struct timeval"
|
||||
//
|
||||
operator struct timeval () const;
|
||||
osiTime (const struct timeval &ts);
|
||||
osiTime & operator = (const struct timeval &rhs);
|
||||
|
||||
//
|
||||
// convert to and from NTP timestamp format
|
||||
//
|
||||
operator ntpTimeStamp () const;
|
||||
osiTime (const ntpTimeStamp &ts);
|
||||
osiTime & operator = (const ntpTimeStamp &rhs);
|
||||
|
||||
//
|
||||
// convert to and from GDD's aitTimeStamp format
|
||||
//
|
||||
operator aitTimeStamp () const;
|
||||
osiTime (const aitTimeStamp &ts);
|
||||
osiTime & operator = (const aitTimeStamp &rhs);
|
||||
|
||||
//
|
||||
// arithmetic operators
|
||||
//
|
||||
double operator- (const osiTime &rhs) const; // returns seconds
|
||||
osiTime operator+ (const double &rhs) const; // add rhs seconds
|
||||
osiTime operator- (const double &rhs) const; // subtract rhs seconds
|
||||
osiTime & operator+= (const double &rhs); // add rhs seconds
|
||||
osiTime & operator-= (const double &rhs); // subtract rhs seconds
|
||||
|
||||
//
|
||||
// comparison operators
|
||||
//
|
||||
bool operator == (const osiTime &rhs) const;
|
||||
bool operator != (const osiTime &rhs) const;
|
||||
bool operator <= (const osiTime &rhs) const;
|
||||
bool operator < (const osiTime &rhs) const;
|
||||
bool operator >= (const osiTime &rhs) const;
|
||||
bool operator > (const osiTime &rhs) const;
|
||||
|
||||
//
|
||||
// convert current state to user-specified string
|
||||
//
|
||||
size_t strftime (char *pBuff, size_t bufLength, const char *pFormat) const;
|
||||
|
||||
//
|
||||
// dump current state to standard out
|
||||
//
|
||||
void show (unsigned interestLevel) const;
|
||||
|
||||
//
|
||||
// useful public constants
|
||||
//
|
||||
static const unsigned secPerMin;
|
||||
static const unsigned mSecPerSec;
|
||||
static const unsigned uSecPerSec;
|
||||
static const unsigned nSecPerSec;
|
||||
static const unsigned nSecPerUSec;
|
||||
|
||||
// depricated
|
||||
static void synchronize ();
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// private because:
|
||||
// a) application does not break when EPICS epoch is changed
|
||||
// b) no assumptions about internal storage or internal precision
|
||||
// in the application
|
||||
// c) it would be easy to forget which argument is nanoseconds
|
||||
// and which argument is seconds (no help from compiler)
|
||||
//
|
||||
osiTime (const unsigned long secPastEpoch, const unsigned long nSec);
|
||||
void addNanoSec (long nanoSecAdjust);
|
||||
|
||||
unsigned long secPastEpoch; // seconds since O000 Jan 1, 1990
|
||||
unsigned long nSec; // nanoseconds within second
|
||||
};
|
||||
|
||||
//
|
||||
// type osiTime inline member functions
|
||||
//
|
||||
|
||||
inline osiTime::osiTime (const TS_STAMP &ts) :
|
||||
secPastEpoch ( ts.secPastEpoch ), nSec ( ts.nsec ) {}
|
||||
|
||||
//
|
||||
// getCurrent ()
|
||||
//
|
||||
inline osiTime osiTime::getCurrent ()
|
||||
{
|
||||
TS_STAMP current;
|
||||
int status;
|
||||
|
||||
status = tsStampGetCurrent (¤t);
|
||||
if (status) {
|
||||
throwWithLocation ( unableToFetchCurrentTime () );
|
||||
}
|
||||
|
||||
return osiTime (current);
|
||||
}
|
||||
|
||||
inline osiTime osiTime::getEvent (const osiTimeEvent &event)
|
||||
{
|
||||
TS_STAMP current;
|
||||
int status;
|
||||
|
||||
status = tsStampGetEvent (¤t, event.eventNumber);
|
||||
if (status) {
|
||||
throwWithLocation ( unableToFetchCurrentTime () );
|
||||
}
|
||||
|
||||
return osiTime (current);
|
||||
}
|
||||
|
||||
inline void osiTime::synchronize () {} // depricated
|
||||
|
||||
inline osiTime::osiTime () : secPastEpoch(0u), nSec(0u) {}
|
||||
|
||||
inline osiTime::osiTime (const osiTime &t) : secPastEpoch (t.secPastEpoch), nSec (t.nSec) {}
|
||||
|
||||
inline osiTime & osiTime::operator = ( const osiTime &t )
|
||||
{
|
||||
this->secPastEpoch = t.secPastEpoch;
|
||||
this->nSec = t.nSec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline osiTime osiTime::operator - (const double &rhs) const
|
||||
{
|
||||
return osiTime::operator + (-rhs);
|
||||
}
|
||||
|
||||
inline osiTime & osiTime::operator += (const double &rhs)
|
||||
{
|
||||
*this = osiTime::operator + (rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline osiTime & osiTime::operator -= (const double &rhs)
|
||||
{
|
||||
*this = osiTime::operator + (-rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool osiTime::operator == (const osiTime &rhs) const
|
||||
{
|
||||
if (this->secPastEpoch == rhs.secPastEpoch && this->nSec == rhs.nSec) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool osiTime::operator != (const osiTime &rhs) const
|
||||
{
|
||||
return !osiTime::operator == (rhs);
|
||||
}
|
||||
|
||||
inline bool osiTime::operator >= (const osiTime &rhs) const
|
||||
{
|
||||
return ! ( *this < rhs );
|
||||
}
|
||||
|
||||
inline bool osiTime::operator > (const osiTime &rhs) const
|
||||
{
|
||||
return ! ( *this <= rhs );
|
||||
}
|
||||
|
||||
inline osiTime & osiTime::operator = (const tm_nano_sec &rhs)
|
||||
{
|
||||
*this = osiTime (rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline osiTime & osiTime::operator = (const struct timespec &rhs)
|
||||
{
|
||||
*this = osiTime (rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline osiTime & osiTime::operator = (const aitTimeStamp &rhs)
|
||||
{
|
||||
*this = osiTime (rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline osiTime & osiTime::operator = (const TS_STAMP &rhs)
|
||||
{
|
||||
*this = osiTime (rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline osiTime::operator TS_STAMP () const
|
||||
{
|
||||
TS_STAMP ts;
|
||||
ts.secPastEpoch = this->secPastEpoch;
|
||||
ts.nsec = this->nSec;
|
||||
return ts;
|
||||
}
|
||||
|
||||
#ifdef NTP_SUPPORT
|
||||
inline osiTime & osiTime::operator = (const ntpTimeStamp &rhs)
|
||||
{
|
||||
*this = osiTime (rhs);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline osiTime & osiTime::operator = (const time_t_wrapper &rhs)
|
||||
{
|
||||
*this = osiTime (rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#include "osdTime.h"
|
||||
|
||||
#endif // osiTimehInclude
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* ANSI C manipulation of type TS_STAMP
|
||||
*
|
||||
* Author: Jeff Hill.
|
||||
*
|
||||
* Original TS_STAMP definition by Roger Cole
|
||||
*
|
||||
* Notes:
|
||||
* 1) all functions return -1 on failure and 0 on success
|
||||
* 2) the implementation of these routines is provided by
|
||||
* C++ type osiTime
|
||||
*/
|
||||
|
||||
#ifndef tsStamph
|
||||
#define tsStamph
|
||||
|
||||
#include <time.h>
|
||||
#include "osdTime.h"
|
||||
|
||||
#include "shareLib.h"
|
||||
#include "epicsTypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define tsStampOK 0
|
||||
#define tsStampERROR (-1)
|
||||
|
||||
#define tsStampEventCurrentTime 0
|
||||
|
||||
struct timeval;
|
||||
struct timespec;
|
||||
|
||||
/*
|
||||
* The number of nanoseconds past 0000 Jan 1, 1990, GMT (or UTC).
|
||||
*/
|
||||
typedef struct TS_STAMP {
|
||||
epicsUInt32 secPastEpoch; /* seconds since 0000 Jan 1, 1990 */
|
||||
epicsUInt32 nsec; /* nanoseconds within second */
|
||||
} TS_STAMP;
|
||||
|
||||
|
||||
/*
|
||||
* fetch a time stamp
|
||||
*/
|
||||
epicsShareFunc int epicsShareAPI tsStampGetCurrent (TS_STAMP *pDest);
|
||||
epicsShareFunc int epicsShareAPI tsStampGetEvent (TS_STAMP *pDest, unsigned eventNumber);
|
||||
|
||||
/*
|
||||
* convert to and from ANSI C's "time_t"
|
||||
*/
|
||||
epicsShareFunc int epicsShareAPI tsStampToTime_t (time_t *pDest, const TS_STAMP *pSrc);
|
||||
epicsShareFunc int epicsShareAPI tsStampFromTime_t (TS_STAMP *pDest, time_t src);
|
||||
|
||||
/*
|
||||
* convert to and from ANSI C's "struct tm" with nano seconds
|
||||
*/
|
||||
epicsShareFunc int epicsShareAPI tsStampToTM (struct tm *pDest, unsigned long *pNSecDest, const TS_STAMP *pSrc);
|
||||
epicsShareFunc int epicsShareAPI tsStampFromTM (TS_STAMP *pDest, const struct tm *pSrc, unsigned long nSecSrc);
|
||||
|
||||
/*
|
||||
* convert to and from POSIX RT's "struct timespec"
|
||||
*/
|
||||
epicsShareFunc int epicsShareAPI tsStampToTimespec (struct timespec *pDest, const TS_STAMP *pSrc);
|
||||
epicsShareFunc int epicsShareAPI tsStampFromTimespec (TS_STAMP *pDest, const struct timespec *pSrc);
|
||||
|
||||
/*
|
||||
* convert to and from BSD's "struct timeval"
|
||||
*/
|
||||
epicsShareFunc int epicsShareAPI tsStampToTimeval (struct timeval *pDest, const TS_STAMP *pSrc);
|
||||
epicsShareFunc int epicsShareAPI tsStampFromTimeval (TS_STAMP *pDest, const struct timeval *pSrc);
|
||||
|
||||
/*
|
||||
* arithmetic operations
|
||||
*/
|
||||
epicsShareFunc double epicsShareAPI tsStampDiffInSeconds (const TS_STAMP *pLeft, const TS_STAMP *pRight); /* returns *pLeft - *pRight in seconds */
|
||||
epicsShareFunc void epicsShareAPI tsStampAddSeconds (TS_STAMP *pDest, double secondsToAdd); /* adds seconds to *pDest */
|
||||
|
||||
/*
|
||||
* comparison operations
|
||||
*/
|
||||
epicsShareFunc int epicsShareAPI tsStampEqual (const TS_STAMP *pLeft, const TS_STAMP *pRight); /* returns boolean result */
|
||||
epicsShareFunc int epicsShareAPI tsStampNotEqual (const TS_STAMP *pLeft, const TS_STAMP *pRight); /* returns boolean result */
|
||||
epicsShareFunc int epicsShareAPI tsStampLessThan (const TS_STAMP *pLeft, const TS_STAMP *pRight); /* returns boolean result (true if *pLeft < *pRight) */
|
||||
epicsShareFunc int epicsShareAPI tsStampLessThanEqual (const TS_STAMP *pLeft, const TS_STAMP *pRight); /* returns boolean result (true if *pLeft <= *pRight) */
|
||||
epicsShareFunc int epicsShareAPI tsStampGreaterThan (const TS_STAMP *pLeft, const TS_STAMP *pRight); /* returns boolean result (true if *pLeft > *pRight) */
|
||||
epicsShareFunc int epicsShareAPI tsStampGreaterThanEqual (const TS_STAMP *pLeft, const TS_STAMP *pRight); /* returns boolean result (true if *pLeft >= *pRight) */
|
||||
|
||||
/*
|
||||
* convert to ASCII string
|
||||
*/
|
||||
epicsShareFunc size_t epicsShareAPI tsStampToStrftime (char *pBuff, size_t bufLength, const char *pFormat, const TS_STAMP *pTS);
|
||||
|
||||
/*
|
||||
* dump current state to standard out
|
||||
*/
|
||||
epicsShareFunc void epicsShareAPI tsStampShow (const TS_STAMP *, unsigned interestLevel);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* tsStamph */
|
||||
@@ -7,6 +7,10 @@ PROD_LIBS += Com
|
||||
USR_LIBS_hpux += cma
|
||||
|
||||
|
||||
epicsTimeTestHost_SRCS += epicsTimeTestMain.cpp epicsTimeTest.cpp
|
||||
PROD += epicsTimeTestHost
|
||||
OBJS_IOC += epicsTimeTest
|
||||
|
||||
epicsThreadTestHost_SRCS += epicsThreadTestMain.cpp epicsThreadTest.cpp
|
||||
PROD += epicsThreadTestHost
|
||||
OBJS_IOC += epicsThreadTest
|
||||
@@ -30,9 +34,5 @@ OBJS_IOC += epicsMutexTest
|
||||
#fdmgrTest_SRCS += fdmgrTest.c
|
||||
#PROD += fdmgrTest
|
||||
|
||||
osiTimeTestHost_SRCS += osiTimeTestMain.c osiTimeTest.cpp
|
||||
PROD += osiTimeTestHost
|
||||
OBJS_IOC += osiTimeTest
|
||||
|
||||
include $(TOP)/configure/RULES
|
||||
|
||||
|
||||
161
src/libCom/test/epicsTimeTest.cpp
Normal file
161
src/libCom/test/epicsTimeTest.cpp
Normal file
@@ -0,0 +1,161 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "epicsTime.h"
|
||||
#include "epicsThread.h"
|
||||
#include "errlog.h"
|
||||
|
||||
extern "C" {
|
||||
int epicsTimeTest (void);
|
||||
}
|
||||
|
||||
int epicsTimeTest (void)
|
||||
{
|
||||
unsigned i, errors, sum_errors=0, sum_errloops=0;
|
||||
epicsTime begin = epicsTime::getCurrent();
|
||||
const unsigned wasteTime = 100000u;
|
||||
const int nTimes = 100;
|
||||
epicsTimeStamp stamp;
|
||||
struct timespec ts;
|
||||
struct tm tmAnsi;
|
||||
tm_nano_sec ansiDate;
|
||||
unsigned long nanoSec;
|
||||
double diff;
|
||||
|
||||
printf ("epicsTime Test (%3d loops)\n========================\n\n", nTimes);
|
||||
|
||||
for (int iTimes=0; iTimes < nTimes; ++iTimes) {
|
||||
for (i=0; i<wasteTime; i++) {
|
||||
epicsTime tmp = epicsTime::getCurrent();
|
||||
}
|
||||
|
||||
epicsTime end = epicsTime::getCurrent();
|
||||
|
||||
diff = end - begin;
|
||||
|
||||
if (iTimes == 0) {
|
||||
printf ("Time per call to epicsTime::getCurrent() "
|
||||
"(%d calls) = %6.3f usec\n\n", wasteTime,
|
||||
diff*1e6/wasteTime);
|
||||
stamp = begin;
|
||||
ansiDate = begin;
|
||||
ts = begin;
|
||||
printf ("The following should be your local time\ndisplayed using "
|
||||
"four different internal representations:\n\n");
|
||||
epicsTimeToTM (&tmAnsi, &nanoSec, &stamp);
|
||||
|
||||
printf ("epicsTimeStamp = %s %lu nSec \n", asctime(&tmAnsi), nanoSec);
|
||||
printf ("struct tm = %s %f\n", asctime(&ansiDate.ansi_tm),
|
||||
ansiDate.nSec/(double)epicsTime::nSecPerSec);
|
||||
tmAnsi = *localtime (&ts.tv_sec);
|
||||
printf ("struct timespec = %s %f\n", asctime(&ansiDate.ansi_tm),
|
||||
ts.tv_nsec/(double)epicsTime::nSecPerSec);
|
||||
begin.show (0);
|
||||
printf ("\n");
|
||||
} else {
|
||||
if (iTimes % 10 == 0)
|
||||
printf (" ... now at loop %3d\n", iTimes);
|
||||
}
|
||||
|
||||
epicsTime copy = end;
|
||||
errors = 0;
|
||||
|
||||
if (!(copy==end)) {
|
||||
printf ("#%3d: Failed copy==end by %12.9f\n",
|
||||
iTimes, fabs(copy-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(copy<=end)) {
|
||||
printf ("#%3d: Failed copy<=end by %12.9f\n",
|
||||
iTimes, (copy-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(copy>=end)) {
|
||||
printf ("#%3d: Failed copy>=end by %12.9f\n",
|
||||
iTimes, (end-copy));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(end>begin)) {
|
||||
printf ("#%3d: Failed end>begin by %12.9f\n",
|
||||
iTimes, (begin-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(end>=begin)) {
|
||||
printf ("#%3d: Failed end>=begin by %12.9f\n",
|
||||
iTimes, (begin-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(begin<end)) {
|
||||
printf ("#%3d: Failed begin<end by %12.9f\n",
|
||||
iTimes, (begin-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(begin<=end)) {
|
||||
printf ("#%3d: Failed begin<=end by %12.9f\n",
|
||||
iTimes, (begin-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(begin!=end)) {
|
||||
printf ("#%3d: Failed begin!=end\n",iTimes);
|
||||
errors += 1;
|
||||
}
|
||||
if (!(end-begin==diff)) {
|
||||
printf ("#%3d: Failed end-begin==diff by %12.9f\n",
|
||||
iTimes, fabs(end-begin-diff));
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
begin += diff;
|
||||
if (!(begin==end)) {
|
||||
printf ("#%3d: Failed (begin+=diff)==end by %12.9f\n",
|
||||
iTimes, fabs(begin-end));
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
begin -= diff;
|
||||
if (!(begin+diff==end)) {
|
||||
printf ("#%3d: Failed begin+diff==end by %12.9f\n",
|
||||
iTimes, fabs(begin+diff-end));
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
//
|
||||
// test struct tm conversions
|
||||
//
|
||||
ansiDate = begin;
|
||||
begin = ansiDate;
|
||||
if (!(begin+diff==end)) {
|
||||
printf ("#%3d: Failed begin+diff==end "
|
||||
"after tm conversions by %12.9f\n",
|
||||
iTimes, fabs(begin+diff-end));
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
//
|
||||
// test struct timespec conversion
|
||||
//
|
||||
ts = begin;
|
||||
begin = ts;
|
||||
if (!(begin+diff==end)) {
|
||||
printf ("#%3d: Failed begin+diff==end "
|
||||
"after timespec conversions by %12.9f\n",
|
||||
iTimes, fabs(begin+diff-end));
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
if (errors) {
|
||||
printf ("#%3d: begin ", iTimes); begin.show(0);
|
||||
printf ("#%3d: end ", iTimes); end.show(0);
|
||||
printf ("#%3d: diff %12.9f\n\n", iTimes, diff);
|
||||
sum_errors += errors;
|
||||
sum_errloops += 1;
|
||||
}
|
||||
}
|
||||
|
||||
printf ("epicsTime Test Summary: %d errors found "
|
||||
"in %d out of %d loops.\n",
|
||||
sum_errors, sum_errloops, nTimes);
|
||||
|
||||
return (sum_errors?1:0);
|
||||
}
|
||||
8
src/libCom/test/epicsTimeTestMain.cpp
Normal file
8
src/libCom/test/epicsTimeTestMain.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" int epicsTimeTest (void);
|
||||
|
||||
int main (int , char **)
|
||||
{
|
||||
return epicsTimeTest ();
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "fdmgr.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "epicsAssert.h"
|
||||
|
||||
static const unsigned uSecPerSec = 1000000;
|
||||
@@ -39,14 +39,14 @@ void fdCreateDestroyHandler (void *pArg, int fd, int open)
|
||||
}
|
||||
|
||||
typedef struct cbStuctTimer {
|
||||
osiTime time;
|
||||
epicsTime time;
|
||||
int done;
|
||||
} cbStruct;
|
||||
|
||||
void alarmCB (void *parg)
|
||||
{
|
||||
cbStruct *pCBS = (cbStruct *) parg;
|
||||
osiTimeGetCurrent (&pCBS->time);
|
||||
epicsTimeGetCurrent (&pCBS->time);
|
||||
pCBS->done = 1;
|
||||
}
|
||||
|
||||
@@ -55,12 +55,12 @@ void testTimer (fdctx *pfdm, double delay)
|
||||
int status;
|
||||
fdmgrAlarmId aid;
|
||||
struct timeval tmo;
|
||||
osiTime begin;
|
||||
epicsTime begin;
|
||||
cbStruct cbs;
|
||||
double measuredDelay;
|
||||
double measuredError;
|
||||
|
||||
osiTimeGetCurrent (&begin);
|
||||
epicsTimeGetCurrent (&begin);
|
||||
cbs.done = 0;
|
||||
tmo.tv_sec = (unsigned long) delay;
|
||||
tmo.tv_usec = (unsigned long) ((delay - tmo.tv_sec) * uSecPerSec);
|
||||
@@ -74,7 +74,7 @@ void testTimer (fdctx *pfdm, double delay)
|
||||
assert (status==0);
|
||||
}
|
||||
|
||||
measuredDelay = osiTimeDiffInSeconds (&cbs.time, &begin);
|
||||
measuredDelay = epicsTimeDiffInSeconds (&cbs.time, &begin);
|
||||
measuredError = fabs (measuredDelay-delay);
|
||||
printf ("measured delay for %lf sec was off by %lf sec (%lf %%)\n",
|
||||
delay, measuredError, 100.0*measuredError/delay);
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "osiTime.h"
|
||||
#include "epicsThread.h"
|
||||
#include "errlog.h"
|
||||
|
||||
extern "C" {
|
||||
int osiTimeTest (void);
|
||||
}
|
||||
|
||||
int osiTimeTest (void)
|
||||
{
|
||||
unsigned i, errors, sum_errors=0, sum_errloops=0;
|
||||
osiTime begin = osiTime::getCurrent();
|
||||
const unsigned wasteTime = 100000u;
|
||||
const int nTimes = 100;
|
||||
TS_STAMP stamp;
|
||||
struct timespec ts;
|
||||
struct tm tmAnsi;
|
||||
tm_nano_sec ansiDate;
|
||||
unsigned long nanoSec;
|
||||
double diff;
|
||||
|
||||
printf ("osiTime Test (%3d loops)\n========================\n\n", nTimes);
|
||||
|
||||
for (int iTimes=0; iTimes < nTimes; ++iTimes) {
|
||||
for (i=0; i<wasteTime; i++) {
|
||||
osiTime tmp = osiTime::getCurrent();
|
||||
}
|
||||
|
||||
osiTime end = osiTime::getCurrent();
|
||||
|
||||
diff = end - begin;
|
||||
|
||||
if (iTimes == 0) {
|
||||
printf ("Time per call to osiTime::getCurrent() "
|
||||
"(%d calls) = %6.3f usec\n\n", wasteTime,
|
||||
diff*1e6/wasteTime);
|
||||
|
||||
stamp = begin;
|
||||
ansiDate = begin;
|
||||
ts = begin;
|
||||
|
||||
printf ("The following should be your local time\ndisplayed using "
|
||||
"four different internal representations:\n\n");
|
||||
|
||||
tsStampToTM (&tmAnsi, &nanoSec, &stamp);
|
||||
|
||||
printf ("TS_STAMP = %s %lu nSec \n", asctime(&tmAnsi), nanoSec);
|
||||
printf ("struct tm = %s %f\n", asctime(&ansiDate.ansi_tm),
|
||||
ansiDate.nSec/(double)osiTime::nSecPerSec);
|
||||
tmAnsi = *localtime (&ts.tv_sec);
|
||||
printf ("struct timespec = %s %f\n", asctime(&ansiDate.ansi_tm),
|
||||
ts.tv_nsec/(double)osiTime::nSecPerSec);
|
||||
begin.show (0);
|
||||
printf ("\n");
|
||||
} else {
|
||||
if (iTimes % 10 == 0)
|
||||
printf (" ... now at loop %3d\n", iTimes);
|
||||
}
|
||||
|
||||
osiTime copy = end;
|
||||
errors = 0;
|
||||
|
||||
if (!(copy==end)) {
|
||||
printf ("#%3d: Failed copy==end by %12.9f\n",
|
||||
iTimes, fabs(copy-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(copy<=end)) {
|
||||
printf ("#%3d: Failed copy<=end by %12.9f\n",
|
||||
iTimes, (copy-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(copy>=end)) {
|
||||
printf ("#%3d: Failed copy>=end by %12.9f\n",
|
||||
iTimes, (end-copy));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(end>begin)) {
|
||||
printf ("#%3d: Failed end>begin by %12.9f\n",
|
||||
iTimes, (begin-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(end>=begin)) {
|
||||
printf ("#%3d: Failed end>=begin by %12.9f\n",
|
||||
iTimes, (begin-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(begin<end)) {
|
||||
printf ("#%3d: Failed begin<end by %12.9f\n",
|
||||
iTimes, (begin-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(begin<=end)) {
|
||||
printf ("#%3d: Failed begin<=end by %12.9f\n",
|
||||
iTimes, (begin-end));
|
||||
errors += 1;
|
||||
}
|
||||
if (!(begin!=end)) {
|
||||
printf ("#%3d: Failed begin!=end\n",iTimes);
|
||||
errors += 1;
|
||||
}
|
||||
if (!(end-begin==diff)) {
|
||||
printf ("#%3d: Failed end-begin==diff by %12.9f\n",
|
||||
iTimes, fabs(end-begin-diff));
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
begin += diff;
|
||||
if (!(begin==end)) {
|
||||
printf ("#%3d: Failed (begin+=diff)==end by %12.9f\n",
|
||||
iTimes, fabs(begin-end));
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
begin -= diff;
|
||||
if (!(begin+diff==end)) {
|
||||
printf ("#%3d: Failed begin+diff==end by %12.9f\n",
|
||||
iTimes, fabs(begin+diff-end));
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
//
|
||||
// test struct tm conversions
|
||||
//
|
||||
ansiDate = begin;
|
||||
begin = ansiDate;
|
||||
if (!(begin+diff==end)) {
|
||||
printf ("#%3d: Failed begin+diff==end "
|
||||
"after tm conversions by %12.9f\n",
|
||||
iTimes, fabs(begin+diff-end));
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
//
|
||||
// test struct timespec conversion
|
||||
//
|
||||
ts = begin;
|
||||
begin = ts;
|
||||
if (!(begin+diff==end)) {
|
||||
printf ("#%3d: Failed begin+diff==end "
|
||||
"after timespec conversions by %12.9f\n",
|
||||
iTimes, fabs(begin+diff-end));
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
if (errors) {
|
||||
printf ("#%3d: begin ", iTimes); begin.show(0);
|
||||
printf ("#%3d: end ", iTimes); end.show(0);
|
||||
printf ("#%3d: diff %12.9f\n\n", iTimes, diff);
|
||||
sum_errors += errors;
|
||||
sum_errloops += 1;
|
||||
}
|
||||
}
|
||||
|
||||
printf ("osiTime Test Summary: %d errors found "
|
||||
"in %d out of %d loops.\n",
|
||||
sum_errors, sum_errloops, nTimes);
|
||||
|
||||
return (sum_errors?1:0);
|
||||
}
|
||||
|
||||
/* **************************** Emacs Editing Sequences ***************** */
|
||||
/* Local Variables: */
|
||||
/* tab-width: 4 */
|
||||
/* c-basic-offset: 4 */
|
||||
/* c-comment-only-line-offset: 0 */
|
||||
/* c-file-offsets: ((substatement-open . 0) (label . 0)) */
|
||||
/* End: */
|
||||
@@ -1,11 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int osiTimeTest (void);
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
#ifdef HP_UX
|
||||
_main();
|
||||
#endif
|
||||
return osiTimeTest ();
|
||||
}
|
||||
@@ -17,7 +17,7 @@ of this distribution.
|
||||
#include "epicsThread.h"
|
||||
#include "osiTimer.h"
|
||||
#include "errlog.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
static void expire(void *pPrivate);
|
||||
static void destroy(void *pPrivate);
|
||||
@@ -30,7 +30,7 @@ static osiTimerQueueId timerQueue;
|
||||
typedef struct myPvt {
|
||||
osiTimerId timer;
|
||||
double requestedDiff;
|
||||
TS_STAMP start;
|
||||
epicsTimeStamp start;
|
||||
}myPvt;
|
||||
|
||||
|
||||
@@ -39,14 +39,14 @@ typedef struct myPvt {
|
||||
void timerTest(void)
|
||||
{
|
||||
myPvt *timer[ntimers];
|
||||
TS_STAMP start;
|
||||
epicsTimeStamp start;
|
||||
int i;
|
||||
|
||||
timerQueue = osiTimerQueueCreate(epicsThreadPriorityLow);
|
||||
for(i=0; i<ntimers ; i++) {
|
||||
timer[i] = calloc(1,sizeof(myPvt));
|
||||
timer[i]->timer = osiTimerCreate(&jumpTable,timerQueue,(void *)timer[i]);
|
||||
tsStampGetCurrent(&start);
|
||||
epicsTimeGetCurrent(&start);
|
||||
timer[i]->start = start;
|
||||
timer[i]->requestedDiff = (double)i;
|
||||
osiTimerArm(timer[i]->timer,(double)i);
|
||||
@@ -58,11 +58,11 @@ void timerTest(void)
|
||||
void expire(void *pPrivate)
|
||||
{
|
||||
myPvt *pmyPvt = (myPvt *)pPrivate;
|
||||
TS_STAMP end;
|
||||
epicsTimeStamp end;
|
||||
double diff;
|
||||
|
||||
tsStampGetCurrent(&end);
|
||||
diff = tsStampDiffInSeconds(&end,&pmyPvt->start);
|
||||
epicsTimeGetCurrent(&end);
|
||||
diff = epicsTimeDiffInSeconds(&end,&pmyPvt->start);
|
||||
printf("myCallback requestedDiff %f diff %f\n",pmyPvt->requestedDiff,diff);
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ void osiTimer::arm (double initialDelay)
|
||||
//
|
||||
// calculate absolute expiration time
|
||||
//
|
||||
this->exp = osiTime::getCurrent () + initialDelay;
|
||||
this->exp = epicsTime::getCurrent () + initialDelay;
|
||||
|
||||
//
|
||||
// insert into the pending queue
|
||||
@@ -351,7 +351,7 @@ double osiTimer::delay () const
|
||||
//
|
||||
void osiTimer::show (unsigned level) const
|
||||
{
|
||||
osiTime cur = osiTime::getCurrent ();
|
||||
epicsTime cur = epicsTime::getCurrent ();
|
||||
printf ("osiTimer at %p for \"%s\" with again = %d\n",
|
||||
this, this->name(), this->again());
|
||||
if (level>=1u) {
|
||||
@@ -384,7 +384,7 @@ double osiTimer::timeRemaining () const
|
||||
this->queue.mutex.lock ();
|
||||
switch (this->curState) {
|
||||
case statePending:
|
||||
delay = this->exp - osiTime::getCurrent();
|
||||
delay = this->exp - epicsTime::getCurrent();
|
||||
if ( delay < 0.0 ) {
|
||||
delay = 0.0;
|
||||
}
|
||||
@@ -529,7 +529,7 @@ double osiTimerQueue::delayToFirstExpire () const
|
||||
//
|
||||
// no timer in the queue - return a long delay - 30 min
|
||||
//
|
||||
delay = 30u * osiTime::secPerMin;
|
||||
delay = 30u * epicsTime::secPerMin;
|
||||
}
|
||||
|
||||
this->mutex.unlock ();
|
||||
@@ -549,7 +549,7 @@ void osiTimerQueue::process ()
|
||||
|
||||
void osiTimerQueue::privateProcess ()
|
||||
{
|
||||
osiTime cur ( osiTime::getCurrent () );
|
||||
epicsTime cur ( epicsTime::getCurrent () );
|
||||
osiTimer *pTmr;
|
||||
|
||||
this->mutex.lock ();
|
||||
@@ -717,7 +717,7 @@ extern "C" epicsShareFunc double epicsShareAPI osiTimerTimeRemaining (osiTimerId
|
||||
return pTmr->timeRemaining ();
|
||||
}
|
||||
|
||||
extern "C" epicsShareFunc TS_STAMP epicsShareAPI osiTimerExpirationDate (osiTimerId idIn)
|
||||
extern "C" epicsShareFunc epicsTimeStamp epicsShareAPI osiTimerExpirationDate (osiTimerId idIn)
|
||||
{
|
||||
osiTimerForC *pTmr = static_cast<osiTimerForC *> (idIn);
|
||||
assert (pTmr);
|
||||
|
||||
@@ -33,11 +33,11 @@
|
||||
|
||||
#include "shareLib.h" /* reset share lib defines */
|
||||
#include "epicsThread.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "osiTime.h"
|
||||
#include "epicsTime.h"
|
||||
#include "tsDLList.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsEvent.h"
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
* respectively
|
||||
*/
|
||||
epicsShareFunc double timeRemaining () const; /* returns seconds, but inefficent */
|
||||
epicsShareFunc osiTime expirationDate () const; /* efficent */
|
||||
epicsShareFunc epicsTime expirationDate () const; /* efficent */
|
||||
|
||||
/*
|
||||
* called when the osiTimer expires
|
||||
@@ -161,7 +161,7 @@ private:
|
||||
enum state {statePending, stateExpired, stateIdle,
|
||||
numberOfTimerLists, stateLimbo};
|
||||
|
||||
osiTime exp; /* experation time */
|
||||
epicsTime exp; /* experation time */
|
||||
state curState; /* current state */
|
||||
osiTimerQueue &queue; /* pointer to current timer queue */
|
||||
|
||||
@@ -212,7 +212,7 @@ private:
|
||||
*/
|
||||
epicsShareExtern osiTimerQueue osiDefaultTimerQueue;
|
||||
|
||||
inline osiTime osiTimer::expirationDate () const
|
||||
inline epicsTime osiTimer::expirationDate () const
|
||||
{
|
||||
return this->exp;
|
||||
}
|
||||
@@ -243,7 +243,7 @@ epicsShareFunc osiTimerId epicsShareAPI osiTimerCreate (const osiTimerJumpTable
|
||||
epicsShareFunc void epicsShareAPI osiTimerArm (osiTimerId, double delay);
|
||||
epicsShareFunc void epicsShareAPI osiTimerCancel (osiTimerId);
|
||||
epicsShareFunc double epicsShareAPI osiTimerTimeRemaining (osiTimerId);
|
||||
epicsShareFunc TS_STAMP epicsShareAPI osiTimerExpirationDate (osiTimerId);
|
||||
epicsShareFunc epicsTimeStamp epicsShareAPI osiTimerExpirationDate (osiTimerId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ epicsShareFunc char * epicsShareAPI tsStampToText(const TS_STAMP *pTS,enum tsTex
|
||||
{
|
||||
switch (textType) {
|
||||
case TS_TEXT_MMDDYY:
|
||||
tsStampToStrftime(textBuffer,28,"%m/%d/%y %H:%M:%S.%09f",pTS);
|
||||
epicsTimeToStrftime(textBuffer,28,"%m/%d/%y %H:%M:%S.%09f",pTS);
|
||||
break;
|
||||
case TS_TEXT_MONDDYYYY:
|
||||
tsStampToStrftime(textBuffer,32,"%b %d, %Y %H:%M:%S.%09f",pTS);
|
||||
epicsTimeToStrftime(textBuffer,32,"%b %d, %Y %H:%M:%S.%09f",pTS);
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
@@ -22,6 +22,6 @@ epicsShareFunc char * epicsShareAPI tsStampToText(const TS_STAMP *pTS,enum tsTex
|
||||
|
||||
epicsShareFunc long epicsShareAPI tsLocalTime(TS_STAMP *pStamp)
|
||||
{
|
||||
return tsStampGetCurrent(pStamp);
|
||||
return epicsTimeGetCurrent(pStamp);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef tsDefsh
|
||||
#define tsDefsh
|
||||
|
||||
#include "epicsTime.h"
|
||||
#include "shareLib.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -17,7 +18,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "tsStamp.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* TS_TEXT_xxx text type codes for converting between text and time stamp
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tsStamp.h"
|
||||
#include "cadef.h"
|
||||
#include "dbDefs.h"
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ of this distribution.
|
||||
#include "dbDefs.h"
|
||||
#include "epicsThread.h"
|
||||
#include "epicsPrint.h"
|
||||
#include "tsStamp.h"
|
||||
#include "ellLib.h"
|
||||
#include "dbDefs.h"
|
||||
#include "dbBase.h"
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include "epicsPrint.h"
|
||||
|
||||
#include "alarm.h"
|
||||
#include "tsStamp.h"
|
||||
#include "dbAccess.h"
|
||||
#include "dbScan.h"
|
||||
#include "dbEvent.h"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "osiSock.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "errlog.h"
|
||||
#include "db_access_routines.h"
|
||||
#include "db_access.h"
|
||||
@@ -916,7 +916,7 @@ unsigned cid
|
||||
return NULL;
|
||||
}
|
||||
ellInit(&pchannel->eventq);
|
||||
tsStampGetCurrent(&pchannel->time_at_creation);
|
||||
epicsTimeGetCurrent(&pchannel->time_at_creation);
|
||||
pchannel->addr = *pAddr;
|
||||
pchannel->client = client;
|
||||
/*
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "dbDefs.h"
|
||||
#include "osiSock.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "errlog.h"
|
||||
#include "taskwd.h"
|
||||
#include "db_access.h"
|
||||
@@ -84,7 +84,7 @@ void camsgtask (struct client *client)
|
||||
break;
|
||||
}
|
||||
|
||||
tsStampGetCurrent (&client->time_at_last_recv);
|
||||
epicsTimeGetCurrent (&client->time_at_last_recv);
|
||||
client->recv.cnt += (unsigned long) nchars;
|
||||
|
||||
status = camessage (client, &client->recv);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "dbDefs.h"
|
||||
#include "osiSock.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "errlog.h"
|
||||
#include "net_convert.h"
|
||||
|
||||
@@ -149,7 +149,7 @@ void cas_send_msg (struct client *pclient, int lock_needed)
|
||||
}
|
||||
|
||||
pclient->send.stk = 0;
|
||||
tsStampGetCurrent (&pclient->time_at_last_send);
|
||||
epicsTimeGetCurrent (&pclient->time_at_last_send);
|
||||
}
|
||||
|
||||
if(lock_needed){
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "osiSock.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "errlog.h"
|
||||
#include "taskwd.h"
|
||||
#include "addrList.h"
|
||||
@@ -117,8 +117,8 @@ struct client *create_base_client ()
|
||||
client->recv.cnt = 0ul;
|
||||
client->evuser = NULL;
|
||||
client->disconnect = FALSE; /* for TCP only */
|
||||
tsStampGetCurrent(&client->time_at_last_send);
|
||||
tsStampGetCurrent(&client->time_at_last_recv);
|
||||
epicsTimeGetCurrent(&client->time_at_last_send);
|
||||
epicsTimeGetCurrent(&client->time_at_last_recv);
|
||||
client->proto = IPPROTO_UDP;
|
||||
client->minor_version_number = CA_UKN_MINOR_VERSION;
|
||||
|
||||
@@ -485,7 +485,7 @@ LOCAL void log_one_client (struct client *client, unsigned level)
|
||||
double recv_delay;
|
||||
unsigned long bytes_reserved;
|
||||
char *state[] = {"up", "down"};
|
||||
TS_STAMP current;
|
||||
epicsTimeStamp current;
|
||||
char clientHostName[256];
|
||||
|
||||
ipAddrToDottedIP (&client->addr, clientHostName, sizeof(clientHostName));
|
||||
@@ -500,9 +500,9 @@ LOCAL void log_one_client (struct client *client, unsigned level)
|
||||
pproto = "UKN";
|
||||
}
|
||||
|
||||
tsStampGetCurrent(¤t);
|
||||
send_delay = tsStampDiffInSeconds(¤t,&client->time_at_last_send);
|
||||
recv_delay = tsStampDiffInSeconds(¤t,&client->time_at_last_recv);
|
||||
epicsTimeGetCurrent(¤t);
|
||||
send_delay = epicsTimeDiffInSeconds(¤t,&client->time_at_last_send);
|
||||
recv_delay = epicsTimeDiffInSeconds(¤t,&client->time_at_last_recv);
|
||||
|
||||
printf( "%s(%s): User=\"%s\", V%d.%u, Channel Count=%d\n",
|
||||
clientHostName,
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#include "dbDefs.h"
|
||||
#include "errlog.h"
|
||||
#include "taskwd.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
#include "envDefs.h"
|
||||
#include "freeList.h"
|
||||
|
||||
@@ -69,14 +69,14 @@ LOCAL void clean_addrq()
|
||||
{
|
||||
struct channel_in_use *pciu;
|
||||
struct channel_in_use *pnextciu;
|
||||
TS_STAMP current;
|
||||
epicsTimeStamp current;
|
||||
double delay;
|
||||
double maxdelay = 0;
|
||||
unsigned ndelete=0;
|
||||
double timeout = TIMEOUT;
|
||||
int s;
|
||||
|
||||
tsStampGetCurrent(¤t);
|
||||
epicsTimeGetCurrent(¤t);
|
||||
|
||||
epicsMutexMustLock(prsrv_cast_client->addrqLock);
|
||||
pnextciu = (struct channel_in_use *)
|
||||
@@ -85,7 +85,7 @@ LOCAL void clean_addrq()
|
||||
while( (pciu = pnextciu) ) {
|
||||
pnextciu = (struct channel_in_use *)pciu->node.next;
|
||||
|
||||
delay = tsStampDiffInSeconds(¤t,&pciu->time_at_creation);
|
||||
delay = epicsTimeDiffInSeconds(¤t,&pciu->time_at_creation);
|
||||
if (delay > timeout) {
|
||||
|
||||
ellDelete(&prsrv_cast_client->addrq, &pciu->node);
|
||||
@@ -260,7 +260,7 @@ int cast_server(void)
|
||||
else {
|
||||
prsrv_cast_client->recv.cnt = (unsigned long) status;
|
||||
prsrv_cast_client->recv.stk = 0ul;
|
||||
tsStampGetCurrent(&prsrv_cast_client->time_at_last_recv);
|
||||
epicsTimeGetCurrent(&prsrv_cast_client->time_at_last_recv);
|
||||
|
||||
/*
|
||||
* If we are talking to a new client flush to the old one
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "dbDefs.h"
|
||||
#include "osiSock.h"
|
||||
#include "osiPoolStatus.h"
|
||||
#include "tsStamp.h"
|
||||
#include "errlog.h"
|
||||
#include "envDefs.h"
|
||||
#include "addrList.h"
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "dbNotify.h"
|
||||
#include "caProto.h"
|
||||
#include "ellLib.h"
|
||||
#include "epicsTime.h"
|
||||
#include "epicsAssert.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
@@ -101,8 +102,8 @@ struct client {
|
||||
ELLLIST addrq;
|
||||
ELLLIST putNotifyQue;
|
||||
struct sockaddr_in addr;
|
||||
TS_STAMP time_at_last_send;
|
||||
TS_STAMP time_at_last_recv;
|
||||
epicsTimeStamp time_at_last_send;
|
||||
epicsTimeStamp time_at_last_recv;
|
||||
void *evuser;
|
||||
char *pUserName;
|
||||
char *pHostName;
|
||||
@@ -138,7 +139,7 @@ struct channel_in_use {
|
||||
RSRVPUTNOTIFY *pPutNotify; /* potential active put notify */
|
||||
const unsigned cid; /* client id */
|
||||
const unsigned sid; /* server id */
|
||||
TS_STAMP time_at_creation; /* for UDP timeout */
|
||||
epicsTimeStamp time_at_creation; /* for UDP timeout */
|
||||
struct dbAddr addr;
|
||||
ASCLIENTPVT asClientPVT;
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#endif
|
||||
|
||||
#include "cadef.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
int ca_test(char *pname, char *pvalue);
|
||||
LOCAL int cagft(char *pname);
|
||||
@@ -520,7 +520,7 @@ LOCAL void print_returned(chtype type, const void *pbuffer, unsigned count)
|
||||
struct dbr_time_string *pvalue
|
||||
= (struct dbr_time_string *) pbuffer;
|
||||
|
||||
tsStampToStrftime(tsString,sizeof(tsString),
|
||||
epicsTimeToStrftime(tsString,sizeof(tsString),
|
||||
"%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp);
|
||||
printf("%2d %2d",pvalue->status,pvalue->severity);
|
||||
printf("\tTimeStamp: %s",tsString);
|
||||
@@ -534,7 +534,7 @@ LOCAL void print_returned(chtype type, const void *pbuffer, unsigned count)
|
||||
= (struct dbr_time_enum *)pbuffer;
|
||||
dbr_enum_t *pshort = &pvalue->value;
|
||||
|
||||
tsStampToStrftime(tsString,sizeof(tsString),
|
||||
epicsTimeToStrftime(tsString,sizeof(tsString),
|
||||
"%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp);
|
||||
printf("%2d %2d",pvalue->status,pvalue->severity);
|
||||
printf("\tTimeStamp: %s",tsString);
|
||||
@@ -551,7 +551,7 @@ LOCAL void print_returned(chtype type, const void *pbuffer, unsigned count)
|
||||
= (struct dbr_time_short *)pbuffer;
|
||||
dbr_short_t *pshort = &pvalue->value;
|
||||
|
||||
tsStampToStrftime(tsString,sizeof(tsString),
|
||||
epicsTimeToStrftime(tsString,sizeof(tsString),
|
||||
"%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp);
|
||||
printf("%2d %2d",
|
||||
pvalue->status,
|
||||
@@ -570,7 +570,7 @@ LOCAL void print_returned(chtype type, const void *pbuffer, unsigned count)
|
||||
= (struct dbr_time_float *)pbuffer;
|
||||
dbr_float_t *pfloat = &pvalue->value;
|
||||
|
||||
tsStampToStrftime(tsString,sizeof(tsString),
|
||||
epicsTimeToStrftime(tsString,sizeof(tsString),
|
||||
"%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp);
|
||||
printf("%2d %2d",pvalue->status,pvalue->severity);
|
||||
printf("\tTimeStamp: %s",tsString);
|
||||
@@ -587,7 +587,7 @@ LOCAL void print_returned(chtype type, const void *pbuffer, unsigned count)
|
||||
= (struct dbr_time_char *)pbuffer;
|
||||
dbr_char_t *pchar = &pvalue->value;
|
||||
|
||||
tsStampToStrftime(tsString,sizeof(tsString),
|
||||
epicsTimeToStrftime(tsString,sizeof(tsString),
|
||||
"%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp);
|
||||
printf("%2d %2d",pvalue->status,pvalue->severity);
|
||||
printf("\tTimeStamp: %s",tsString);
|
||||
@@ -604,7 +604,7 @@ LOCAL void print_returned(chtype type, const void *pbuffer, unsigned count)
|
||||
= (struct dbr_time_long *)pbuffer;
|
||||
dbr_long_t *plong = &pvalue->value;
|
||||
|
||||
tsStampToStrftime(tsString,sizeof(tsString),
|
||||
epicsTimeToStrftime(tsString,sizeof(tsString),
|
||||
"%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp);
|
||||
printf("%2d %2d",pvalue->status,pvalue->severity);
|
||||
printf("\tTimeStamp: %s",tsString);
|
||||
@@ -621,7 +621,7 @@ LOCAL void print_returned(chtype type, const void *pbuffer, unsigned count)
|
||||
= (struct dbr_time_double *)pbuffer;
|
||||
dbr_double_t *pdouble = &pvalue->value;
|
||||
|
||||
tsStampToStrftime(tsString,sizeof(tsString),
|
||||
epicsTimeToStrftime(tsString,sizeof(tsString),
|
||||
"%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp);
|
||||
printf("%2d %2d",pvalue->status,pvalue->severity);
|
||||
printf("\tTimeStamp: %s",tsString);
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.40 2000/12/15 15:34:40 mrk
|
||||
* remove unnecessary calls to TSinit
|
||||
*
|
||||
* Revision 1.39 2000/10/11 23:08:56 anj
|
||||
* Fixed bug in TSgetMasterTime() - round-trip adjustment was garbage
|
||||
* Replaced TSprintf() with printf() where logging inappropriate
|
||||
@@ -587,7 +590,7 @@ long TSinit(void)
|
||||
|
||||
if(TSinitialized) return(0);
|
||||
/*register with iocClock */
|
||||
iocClockRegister((ptsStampGetCurrent)TScurrentTimeStamp,getEvent);
|
||||
iocClockRegister((pepicsTimeGetCurrent)TScurrentTimeStamp,getEvent);
|
||||
TSinitialized = 1;
|
||||
/* 0=default, 1=none, 2=direct */
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.7 2000/02/02 20:06:25 mrk
|
||||
* new way to build
|
||||
*
|
||||
* Revision 1.6 1999/12/14 21:35:34 jhill
|
||||
* use osiTime.h to get TS_STAMP
|
||||
*
|
||||
@@ -79,7 +82,7 @@ of this distribution.
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "tsStamp.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
#ifdef TS_DRIVER
|
||||
#define TS_EXTERN
|
||||
|
||||
Reference in New Issue
Block a user