29 #include "longinRecord.h" 30 #include "stringinRecord.h" 35 static int getCurrentTime(
double * pseconds)
46 static struct ai_channel {
50 {
"TIME", getCurrentTime},
53 static long init_ai(dbCommon *pcommon)
55 aiRecord *
prec = (aiRecord *)pcommon;
58 if (prec->inp.type !=
INST_IO) {
59 recGblRecordError(S_db_badField, (
void *)prec,
60 "devAiGeneralTime::init_ai: Illegal INP field");
65 for (i = 0; i <
NELEMENTS(ai_channels); i++) {
66 struct ai_channel *pchan = &ai_channels[
i];
73 recGblRecordError(S_db_badField, (
void *)prec,
74 "devAiGeneralTime::init_ai: Bad parm");
80 static long read_ai(aiRecord *prec)
82 struct ai_channel *pchan = (
struct ai_channel *)prec->dpvt;
84 if (!pchan)
return -1;
86 if (pchan->get(&prec->val) == 0) {
103 static void resetErrors(
void)
108 static struct bo_channel {
112 {
"RSTERRCNT", resetErrors},
115 static long init_bo(dbCommon *pcommon)
117 boRecord *prec = (boRecord *)pcommon;
120 if (prec->out.type !=
INST_IO) {
121 recGblRecordError(S_db_badField, (
void *)prec,
122 "devAiGeneralTime::init_ai: Illegal INP field");
124 return S_db_badField;
127 for (i = 0; i <
NELEMENTS(bo_channels); i++) {
128 struct bo_channel *pchan = &bo_channels[
i];
136 recGblRecordError(S_db_badField, (
void *)prec,
137 "devBoGeneralTime::init_bo: Bad parm");
140 return S_db_badField;
143 static long write_bo(boRecord *prec)
145 struct bo_channel *pchan = (
struct bo_channel *)prec->dpvt;
147 if (!pchan)
return -1;
162 static int errorCount(
void)
167 static struct li_channel {
171 {
"GETERRCNT", errorCount},
174 static long init_li(dbCommon *pcommon)
176 longinRecord *prec = (longinRecord *)pcommon;
179 if (prec->inp.type !=
INST_IO) {
180 recGblRecordError(S_db_badField, (
void *)prec,
181 "devLiGeneralTime::init_li: Illegal INP field");
183 return S_db_badField;
186 for (i = 0; i <
NELEMENTS(li_channels); i++) {
187 struct li_channel *pchan = &li_channels[
i];
194 recGblRecordError(S_db_badField, (
void *)prec,
195 "devLiGeneralTime::init_li: Bad parm");
198 return S_db_badField;
201 static long read_li(longinRecord *prec)
203 struct li_channel *pchan = (
struct li_channel *)prec->dpvt;
205 if (!pchan)
return -1;
207 prec->val = pchan->get();
219 static const char * timeProvider(
void)
224 static const char * highestProvider(
void)
229 static const char * eventProvider(
void)
234 static struct si_channel {
236 const char * (*get)(void);
238 {
"BESTTCP", timeProvider},
239 {
"TOPTCP", highestProvider},
240 {
"BESTTEP", eventProvider},
243 static long init_si(dbCommon *pcommon)
245 stringinRecord *prec = (stringinRecord *)pcommon;
248 if (prec->inp.type !=
INST_IO) {
249 recGblRecordError(S_db_badField, (
void *)prec,
250 "devSiGeneralTime::init_si: Illegal INP field");
252 return S_db_badField;
255 for (i = 0; i <
NELEMENTS(si_channels); i++) {
256 struct si_channel *pchan = &si_channels[
i];
263 recGblRecordError(S_db_badField, (
void *)prec,
264 "devSiGeneralTime::init_si: Bad parm");
267 return S_db_badField;
270 static long read_si(stringinRecord *prec)
272 struct si_channel *pchan = (
struct si_channel *)prec->dpvt;
275 if (!pchan)
return -1;
279 strncpy(prec->val, name,
sizeof(prec->val));
280 prec->val[
sizeof(prec->val) - 1] =
'\0';
282 strcpy(prec->val,
"No working providers");
The generalTime framework provides a mechanism for several time providers to be present within the sy...
const char * generalTimeCurrentProviderName(void)
Return the nume of the provider that last returned a valid current time, or NULL if none...
std::tr1::shared_ptr< detail::SharedPut > put
const char * generalTimeHighestCurrentName(void)
Return the name of the registered current time provider that has the highest priority.
stringindset devSiGeneralTime
#define epicsTimeOK
Success.
Miscellaneous macro definitions.
int epicsStrCaseCmp(const char *s1, const char *s2)
epicsUInt32 secPastEpoch
seconds since 0000 Jan 1, 1990
epicsExportAddress(dset, devAiGeneralTime)
longindset devLiGeneralTime
int epicsStdCall epicsTimeGetCurrent(epicsTimeStamp *pDest)
Get current time into *pDest.
const char * generalTimeEventProviderName(void)
Return the name of the provider that last returned a valid Time Event time, or NULL of none...
void generalTimeResetErrorCounts(void)
Reset the internal counter of the number of times the time returned was earlier than when previously ...
EPICS time stamp, for use from C code.
int generalTimeGetErrorCounts(void)
Return the internal counter of the number of times the time returned was earlier than when previously...
epicsUInt32 nsec
nanoseconds within second