GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LSE / V2-0-1 > lsew / linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

LSE_time.c File Reference

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

#include <time.h>
#include "LSE/LSE_time.h"
#include "LSE_time.ih"

Classes

struct  _LSE_timeContext
 Holds the time context information. More...

Defines

#define SA_OFFSET   0x3a4fc880
 Offset between the UNIX and Spectrum-Astro time epochs.

Typedefs

typedef struct
_LSE_timeContext 
LSE_timeContext
 Typedef for struct _LSE_timeContext.

Functions

static void lse_construct (LSE_timeFlagSpec *tfs)
 Sets the time specification sequence.
static void lse_set (unsigned int seconds, unsigned int flags, unsigned int frequency)
 Sets the initial time, flags word and frequency.
static void lse_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 
lse_timestampGet (void)
 Returns the time since the Spectrum-Astro epoch.
static unsigned int lse_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 lse_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 LSE_timeConstruct (const LSE_timeServices *services, void *prm)
 Constructs/initializes the LSE time emulation services.
void LSE_timeSet (unsigned int seconds, unsigned int flags, unsigned int frequency)
 Sets the initial time and frequency.
unsigned int LSE_timeSecsGet (void)
 Get the current number of elapsed seconds since the Spectrum-Astro Epoch.
unsigned long long int LSE_timeTimestampGet (void)
 Get the current timestamp, i.e. the number of elapsed seconds and micro-seconds since the Spectrum-Astro Epoch.
unsigned int LSE_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

LSE_timeServices LseTimeServices
 The list of time services needed when filling in such information in the datagrams.
static LSE_timeContext LseTimeContext = { 0, 0, 0, 0, 0, 0, 0, -1, 0, 0}
 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: LSE_time.c,v 1.7 2009/05/15 00:33:49 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 lse_construct ( LSE_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 lse_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 lse_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 LSE_timeConstruct ( const LSE_timeServices services,
void *  prm 
)

Constructs/initializes the LSE 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 LSE_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 LSE_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 LSE_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 lse_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 LSE_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 lse_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 lse_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

LSE_timeServices LseTimeServices

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 LSE_timeServicesConstruct.


Generated on Mon Jul 26 12:59:21 2010 by  doxygen 1.5.3