GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> EFC / V4-5-0 > iefc / rhel6-64
#include <time.h>
#include <EFC/EFC_time.h>
#include <EFC_time.ih>
#include <EDS/EBF_gem.h>
Classes | |
struct | _EFC_timeContext |
Holds the time context information. More... | |
Defines | |
#define | SA_OFFSET 0x3a4fc880 |
Offset between the UNIX and Spectrum-Astro time epochs. | |
Typedefs | |
typedef enum _TIME_FLAGS_S | TIME_FLAGS_S |
Typedef for enum _TIME_FLAGS_S. | |
typedef enum _TIME_FLAGS_V | TIME_FLAGS_V |
Typedef for enum _TIME_FLAGS_V. | |
typedef enum _TIME_FLAGS_M | TIME_FLAGS_M |
Typedef for enum _TIME_FLAGS_M. | |
typedef struct _EFC_timeContext | EFC_timeContext |
Typedef for struct _EFC_timeContext. | |
Enumerations | |
enum | _TIME_FLAGS_S { TIME_FLAGS_S_SIMULATED_VALUE = 1, TIME_FLAGS_S_SIMULATED_PPS_CPU = 1, TIME_FLAGS_S_SIMULATED_PPS_GEM = 1, TIME_FLAGS_S_NO_MESSAGE = 1, TIME_FLAGS_S_CNT_GPS_NO_LOCK = 12, TIME_FLAGS_S_IS_SOURCE_GPS = 1, TIME_FLAGS_S_SA_RSVD = 15 } |
Enumerates the timetone flags word, right-shift values. More... | |
enum | _TIME_FLAGS_V { TIME_FLAGS_V_SIMULATED_VALUE = 0, TIME_FLAGS_V_SIMULATED_PPS_CPU = 1, TIME_FLAGS_V_SIMULATED_PPS_GEM = 2, TIME_FLAGS_V_NO_MESSAGE = 3, TIME_FLAGS_V_CNT_GPS_NO_LOCK = 4, TIME_FLAGS_V_IS_SOURCE_GPS = 16, TIME_FLAGS_V_SA_RSVD = 17 } |
Enumerates the timetone flags word, right-shift values. More... | |
enum | _TIME_FLAGS_M { TIME_FLAGS_M_SIMULATED_VALUE = 0x1, TIME_FLAGS_M_SIMULATED_PPS_CPU = 0x2, TIME_FLAGS_M_SIMULATED_PPS_GEM = 0x4, TIME_FLAGS_M_NO_MESSAGE = 0x8, TIME_FLAGS_M_CNT_GPS_NO_LOCK = 0x0000FFF0, TIME_FLAGS_M_IS_SOURCE_GPS = 0x00010000, TIME_FLAGS_M_SA_RSVD = 0xfffe0000 } |
Enumerates the timetone flags word, in place mask values. More... | |
Functions | |
static void | efc_construct (EFC_timeFlagSpec *tfs) |
Sets the time specification sequence. | |
static void | efc_set (unsigned int seconds, unsigned int flags, unsigned int frequency) |
Sets the initial time, flags word and frequency. | |
static void | efc_elapsedSet (unsigned int elapsed_reg, unsigned int pps_reg) |
Uses the elapsed clock tick and 1-PPS GEM registers to calculate the elapsed time since the last 1-PPS strobe. | |
static unsigned long long int | efc_timestampGet (void) |
Returns the time since the Spectrum-Astro epoch. | |
static unsigned int | efc_timetoneGet (unsigned int pps, unsigned int *secs, unsigned int *flags) |
Fills in the seconds and flag values of a simulated timetone message corresponding to the specified 1-PPS strobe value. | |
static unsigned int | efc_timetonesGet (unsigned int cur_pps, unsigned int *cur_secs, unsigned int *cur_flags, unsigned int *prv_secs, unsigned int *prv_flags, unsigned int *prv_pps) |
Fills in the timetone message corresponding to cur_pps and the most recent timetone message occuring prior to cur_pps. | |
void | EFC_timeConstruct (const EFC_timeServices *services, void *prm) |
Constructs/initializes the EFC time emulation services. | |
void | EFC_timeSet (unsigned int seconds, unsigned int flags, unsigned int frequency) |
Sets the initial time and frequency. | |
unsigned int | EFC_timeSecsGet (void) |
Get the current number of elapsed seconds since the Spectrum-Astro Epoch. | |
unsigned long long int | EFC_timeTimestampGet (void) |
Get the current timestamp, i.e. the number of elapsed seconds and micro-seconds since the Spectrum-Astro Epoch. | |
unsigned int | EFC_timeOffset (void) |
Gets the offset from standard UNIX time to Spectrum Astro time. | |
static __inline unsigned int | complete_flags (unsigned int new_flags, unsigned int prv_flags) |
If the new flag value is not error-free (IS_SOURCE_GPS) modifies it to update the error count. | |
Variables | |
EFC_timeServices | EfcTimeServices |
The list of time services needed when filling in such information in the datagrams. | |
static EFC_timeContext | EfcTimeContext |
Captures the static context needed by the default implementation. |
CVS $Id: EFC_time.c,v 1.3 2011/03/27 04:55:30 russell Exp $
Typedef for enum _TIME_FLAGS_M.
Typedef for enum _TIME_FLAGS_S.
Typedef for enum _TIME_FLAGS_V.
enum _TIME_FLAGS_M |
Enumerates the timetone flags word, in place mask values.
enum _TIME_FLAGS_S |
Enumerates the timetone flags word, right-shift values.
enum _TIME_FLAGS_V |
Enumerates the timetone flags word, right-shift values.
unsigned int complete_flags | ( | unsigned int | new_flags, | |
unsigned int | prv_flags | |||
) | [static] |
If the new flag value is not error-free (IS_SOURCE_GPS) modifies it to update the error count.
new_flags | The new flag value | |
prv_flags | The previous flag value |
References TIME_FLAGS_M_CNT_GPS_NO_LOCK, TIME_FLAGS_M_IS_SOURCE_GPS, and TIME_FLAGS_V_CNT_GPS_NO_LOCK.
Referenced by efc_elapsedSet().
static void efc_construct | ( | EFC_timeFlagSpec * | tfs | ) | [static] |
Sets the time specification sequence.
tfs | Pointer to the time flag specification sequence. Maybe NULL, in which case, the flag word is always 0. |
References _EFC_timeFlagSpec::cnt, _EFC_timeContext::cur_flags, _EFC_timeFlagSpec::flags, _EFC_timeContext::tfs, and _EFC_timeContext::tfs_cnt.
static void efc_elapsedSet | ( | unsigned int | elapsed_reg, | |
unsigned int | pps_reg | |||
) | [static] |
Uses the elapsed clock tick and 1-PPS GEM registers to calculate the elapsed time since the last 1-PPS strobe.
elapsed_reg | The GEM's elapsed tick register | |
pps_reg | The GEM's 1-PPS strobe register |
References _EFC_timeFlagSpec::cnt, complete_flags(), _EFC_timeContext::cur_flags, _EFC_timeFlagSpec::flags, _EFC_timeContext::frequency, _EFC_timeFlagSpec::nxt, _EFC_timeContext::prv_flags, _EFC_timeContext::prv_idx, _EFC_timeContext::tfs, _EFC_timeContext::tfs_cnt, and _EFC_timeContext::ticks.
static void efc_set | ( | unsigned int | seconds, | |
unsigned int | flags, | |||
unsigned int | frequency | |||
) | [static] |
Sets the initial time, flags word and frequency.
seconds | The initial time, specified in the number of seconds since the Spectrum-Astro epoch. If specified as 0, then the time is not adjusted. If specified as -1, then the default (current time) is used. | |
flags | The initial value of the flags word. There is no default. A reasonable value is 0, i.e. no errors. | |
frequency | The frequency, in Hertz. If specified as 0, then the frequency will not be changed. If specified as -1, then the default (20MHz) is used. |
References _EFC_timeContext::cur_flags, EFC_TIME_K_DEFAULT, _EFC_timeFlagSpec::flags, _EFC_timeContext::frequency, _EFC_timeContext::init, _EFC_timeContext::prv_flags, SA_OFFSET, _EFC_timeContext::seconds, _EFC_timeContext::tfs, and TIME_FLAGS_M_IS_SOURCE_GPS.
void EFC_timeConstruct | ( | const EFC_timeServices * | services, | |
void * | prm | |||
) |
Constructs/initializes the EFC time emulation services.
services | A pointer to the virtual functions. If NULL, the standard services are used. | |
prm | Arbitrary user parameter passed to the constructor |
References _EFC_timeServices::construct.
unsigned int EFC_timeOffset | ( | void | ) |
Gets the offset from standard UNIX time to Spectrum Astro time.
References SA_OFFSET.
unsigned int EFC_timeSecsGet | ( | void | ) |
Get the current number of elapsed seconds since the Spectrum-Astro Epoch.
References _EFC_timeServices::timestampGet.
void EFC_timeSet | ( | unsigned int | seconds, | |
unsigned int | flags, | |||
unsigned int | frequency | |||
) |
Sets the initial time and frequency.
seconds | The initial time, specified in the number of seconds since the Spectrum-Astro epoch. If specified as 0, then the time is not adjusted | |
flags | The initial value of the timetone message's flag word. There is no default value, but bit 16 (source = GPS) would be a good choice as a default (no errors). | |
frequency | The frequency, in Hertz. If specified as 0, then the frequency will not be changed |
References _EFC_timeServices::set.
static unsigned long long int efc_timestampGet | ( | void | ) | [static] |
Returns the time since the Spectrum-Astro epoch.
References _EFC_time::f, _EFC_timeContext::frequency, _EFC_timeContext::seconds, _EFC_timeContext::ticks, and _EFC_time::ull.
unsigned long long int EFC_timeTimestampGet | ( | void | ) |
Get the current timestamp, i.e. the number of elapsed seconds and micro-seconds since the Spectrum-Astro Epoch.
References _EFC_timeServices::timestampGet.
static unsigned int efc_timetoneGet | ( | unsigned int | pps, | |
unsigned int * | secs, | |||
unsigned int * | flags | |||
) | [static] |
Fills in the seconds and flag values of a simulated timetone message corresponding to the specified 1-PPS strobe value.
pps | The value of 1-PPS strobe register to use as a key | |
secs | Filled in with the elapsed time, in seconds from the Spectrum-Astro epoch corresponding to the pps | |
flags | The flag word, currently set to 0, i.e. no errors |
References _EFC_timeContext::cur_flags, _EFC_timeContext::init, _EFC_timeContext::prv_flags, _EFC_timeContext::prv_idx, _EFC_timeContext::seconds, and TIME_FLAGS_M_IS_SOURCE_GPS.
Referenced by efc_timetonesGet().
static unsigned int efc_timetonesGet | ( | unsigned int | cur_pps, | |
unsigned int * | cur_secs, | |||
unsigned int * | cur_flags, | |||
unsigned int * | prv_secs, | |||
unsigned int * | prv_flags, | |||
unsigned int * | prv_pps | |||
) | [static] |
Fills in the timetone message corresponding to cur_pps and the most recent timetone message occuring prior to cur_pps.
cur_pps | The value of the GEM's 1-PPS register to use as a key in locating the timetone messages | |
cur_secs | Filled in with the time since the Spectrum-Astro epoch corresponding the current timetone message | |
cur_flags | Filled in with status flags/values (see THS) corresponding the current timetone message | |
prv_secs | Filled in with the time since the Spectrum-Astro epoch corresponding the previous timetone message | |
prv_flags | Filled in with status flags/values (see THS) corresponding the previous timetone message | |
prv_pps | Filled in with the value of GEM's 1-PPS register corresponding the previous timetone message |
References efc_timetoneGet(), _EFC_timeContext::frequency, and _EFC_timeContext::prv_flags.
EFC_timeContext EfcTimeContext [static] |
Initial value:
{ 0, 0, 0, 0, TIME_FLAGS_M_IS_SOURCE_GPS, TIME_FLAGS_M_IS_SOURCE_GPS, 0, 0, 0}
Initial value:
{ (EFC_timeServicesConstruct)efc_construct, efc_set, efc_elapsedSet, efc_timestampGet, efc_timetoneGet, efc_timetonesGet }