GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > EFC / V4-2-2

Constituent: efc     Tag: linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

EFC_time.c File Reference

Emulation routines for the WCT time and THS routines. More...

#include <time.h>
#include "EFC/EFC_time.h"
#include "EFC_time.ih"
#include "EDS/EBF_gem.h"
#include "LSE/LSEW_ctxTim.h"

Include dependency graph for EFC_time.c:


Data Structures

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 _EFC_timeContext EFC_timeContext
 Typedef for struct _EFC_timeContext.

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.

Detailed Description

Emulation routines for the WCT time and THS routines.

Author:
JJRussell - russell@slac.stanford.edu
   CVS $Id: EFC_time.c,v 1.1 2007/10/10 23:40:43 russell Exp $

Note:
This file should only be compiled for host platforms

Function Documentation

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.

Returns:
The, potentially, modified version of new_flags
Parameters:
new_flags The new flag value
prv_flags The previous flag value

static void efc_construct EFC_timeFlagSpec tfs  )  [static]
 

Sets the time specification sequence.

Parameters:
tfs Pointer to the time flag specification sequence. Maybe NULL, in which case, the flag word is always 0.

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.

Parameters:
elapsed_reg The GEM's elapsed tick register
pps_reg The GEM's 1-PPS strobe register

static void efc_set unsigned int  seconds,
unsigned int  flags,
unsigned int  frequency
[static]
 

Sets the initial time, flags word and frequency.

Parameters:
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.

void EFC_timeConstruct const EFC_timeServices services,
void *  prm
 

Constructs/initializes the EFC time emulation services.

Parameters:
services A pointer to the virtual functions. If NULL, the standard services are used.
prm Arbitrary user parameter passed to the constructor

unsigned int EFC_timeOffset void   ) 
 

Gets the offset from standard UNIX time to Spectrum Astro time.

This value is a constant, the value of which is being hidden in this routine. The value needs to be subtracted from the standard Unix time to get the Spectrum Astro time.
Note:
Since this is a constant, it is safe to cache this value.

unsigned int EFC_timeSecsGet void   ) 
 

Get the current number of elapsed seconds since the Spectrum-Astro Epoch.

Returns:
The current number of elapsed seconds since the Spectrum-Astro Epoch

void EFC_timeSet unsigned int  seconds,
unsigned int  flags,
unsigned int  frequency
 

Sets the initial time and frequency.

Parameters:
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

static unsigned long long int efc_timestampGet void   )  [static]
 

Returns the time since the Spectrum-Astro epoch.

Returns:
The time since the Spectrum-Astro epoch as a 64-bit value with number of seconds in the upper 32 bits and the number of micro seconds in the lower 32 bits.
This function finds its primary use in providing the timestamp for the CCSDS secondary packet header.

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.

Returns:
The current timestamp, i.e. the number of elapsed seconds and micro-seconds since the Spectrum-Astro Epoch.

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.

Returns:
Status, currently always success
Parameters:
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

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.

Returns:
Status
Parameters:
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


Variable Documentation

EFC_timeContext EfcTimeContext [static]
 

Initial value:

 
{ 0, 
  0, 
  0, 
  0, 
  LSE_CTXTIMFLAGS_M_IS_SOURCE_GPS, 
  LSE_CTXTIMFLAGS_M_IS_SOURCE_GPS,
  0, 
  0,
  0}
Captures the static context needed by the default implementation.

EFC_timeServices EfcTimeServices
 

Initial value:

The list of time services needed when filling in such information in the datagrams.

This acts like a C++ virtual function table. It is initialized with default set of functions. These can be overriden using EFC_timeServicesConstruct.


Generated on Fri Sep 5 01:21:14 2008 by  doxygen 1.4.4