GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > THS / V1-4-1

Constituent: ths     Tag: sun-gcc


Interface   Data Structures   File List   Data Fields   Globals  

THS.h File Reference

Public defs for Time Hack Services. More...

#include "LSF/LSF_statsHdr.h"

Include dependency graph for THS.h:

This graph shows which files directly or indirectly include this file:


Data Structures

struct  _THS_GemTableFlagsBf
 Structure to map out the bit fields time hack flags stored as 32 bits in gemTable. More...
struct  _THS_GemTableFlags
 Union for different access of 32 bit flags in gemTable. More...

Typedefs

typedef enum _THS_OPTION THS_OPTION
 Masks for option mask into THS_init.
typedef enum _THS_FSW_FLAGS THS_THS_FSW_FLAGS
 Masks for FSW flags in gem table.
typedef _THS_GemTableFlagsBf THS_GemTableFlagsBf
 Typedef for struct _THS_GemTableFlagsBf.
typedef _THS_GemTableFlags THS_GemTableFlags
 Typedef for struct _THS_GemTableFlags.
typedef unsigned int( THS_SendSlaveRtn )(void *lsmArg, short lsmID, short thsId, int nid, void *payload, int payloadLen, void *payloadFreeRtn, void *payloadFreeRtnArg)
 stash away routine (from LCM) to send msg to EPU

Enumerations

enum  _THS_OPTION {
  THS_GEM_HACK = 1,
  THS_CPU_HACK = 2,
  THS_SIU_HACK = 4
}
enum  _THS_FSW_FLAGS {
  THS_FSW_FLAG_TT_SIM = 1,
  THS_FSW_FLAG_CPU_PPS_SIM = 2,
  THS_FSW_FLAG_GEM_PPS_SIM = 4,
  THS_FSW_FLAG_NO_HACK_TABLE = 8
}

Functions

unsigned int THS_init (int optionMask)
 Inits the TimeHackService module.
unsigned int THS_wait ()
 Wait for TimeHackService module to be fully operational.
unsigned int THS_timetone (unsigned int absTimeSec, unsigned short saFlags)
 Provide absTime for next entry in table (on next PPS).
WCT_time THS_gemAbsTimeEvent (int gemStrobeIn, int gemClk)
 Calculate absolute time for event from strobe and clk provided with event (20MHz clk).
unsigned int THS_timetoneFromEvent (int gemStrobeIn, int *absTimeSecs, int *flag)
 get timetone/flags from table for this event
unsigned int THS_prevTimetoneFromEvent (int gemStrobeIn, int *absTimeSecs, int *flags, int *absTimeSecsPrev, int *flagsPrev, int *gemStrobeInPrev)
 get timetone/flags from table for this event and for prev entry in table
unsigned int THS_prevTimtoneFromEvent (int gemStrobeIn, int *absTimeSecs, int *flags, int *absTimeSecsPrev, int *flagsPrev, int *gemStrobeInPrev)
 THIS IS MIS-SPELLING, it just calls THS_prevTimetoneFromEvent.
unsigned int THS_cpuSetWarning (unsigned int expectedClkHz, unsigned int expectedDeltaClkHz)
 Set range for cpu clock warning messages.
unsigned int THS_gemSetWarning (unsigned int expectedClkHz, unsigned int expectedDeltaClkHz)
 Set range for gem clock warning messages.
void THS_setPpsWarnEvery (unsigned int warnPpsEvery)
 Set how often get warning when no PPS.
void THS_setTimetoneWarnEvery (unsigned int _warnTimetoneEvery)
 Set how often get warning when no timetone.
void THS_setSlaveSend (THS_SendSlaveRtn rtn, void *arg, int lsmId)
 stash away routine (from LCM) to send msg to EPU
unsigned int THS_slaveProcessMsg (int func, void *payload, unsigned int len)
 routine called from ITC dispatch in LSM to process each message it receives (this routine is run on EPU when it receives message)
void THS_setGemUpdateMsgs (int maxMsgs)
 set size of memory pool for gemUpdate msgs, must be called before THS_init
unsigned int THS_lsfStatFirstEvt (LSF_statsHdr *statsHdr, unsigned long long seq, unsigned int gemClock, unsigned int gemStrobe)
 Sets first event parms within LSF_statsHdr.
void THS_lsfStatIncEvt (LSF_statsHdr *statsHdr, int increment)
 Increment event counter in LSF_statsHdr structure.
unsigned int THS_lsfStatLastEvt (LSF_statsHdr *statsHdr, unsigned long long seq, unsigned int gemClock, unsigned int gemStrobe)
 Sets last event parms within LSF_statsHdr.
void THS_lsfStatClear (LSF_statsHdr *statsHdr)
 Clear the LSF_statsHdr structure.

Detailed Description

Public defs for Time Hack Services.

Author:
Ed Bacho -- ebacho@slac.stanford.edu
This module handles calculation of absolute time using the "time hack". The absolute (or true) time is provided once a second through a combination of a 1PPS (1 pulse per sec) hardware pulse and a time tone message ("at the tone the time will be") that preceeds it. The time provided in the time tone message from the scapecraft is in microSec since 1/1/2001.

This file has routines for adjusting the time on the CPU clock by using the WCT_set/get routines, therefore one can only get the current time thru WCT_get(). THese are based on a sub-multiple of the CPU's 33 MHz PCI clock.

The determination of the absolute time from event and LCB times is handled in other time hack files.

This module only truely works on the Rad750 which has the PPS input thru the PID registers. The mv2304 version starts up a task to simulate the PPS but it should therefore show no drift (since its locked with the clock)

Inputs:

Output:


Typedef Documentation

void(* THS_SendSlaveRtn)(void *arg, void *payload, int payloadLen)
 

stash away routine (from LCM) to send msg to EPU

Parameters:
arg - given arg to be included with call
payload - buffer with message to send
payloadLen - length of buffer
Returns:
none
This is routine used by THS to send messages between SIU and EPU. It must be passed down from module above that knows how to do this (most likly LSM using ITC calls)


Enumeration Type Documentation

enum _THS_FSW_FLAGS
 

Enumerator:
THS_FSW_FLAG_TT_SIM  Timtone value is simulated
THS_FSW_FLAG_CPU_PPS_SIM  no PPS interrupt, PPS simulated, might not be accurate
THS_FSW_FLAG_GEM_PPS_SIM  GEM did not get PPS, need to calc new GEM stobe val
THS_FSW_FLAG_NO_HACK_TABLE  These values did not come from HackTable

enum _THS_OPTION
 

Enumerator:
THS_GEM_HACK  enable time hack for gem clock (20 MHz)
THS_CPU_HACK  enable time hack for cpu clock (33/4 MHz)
THS_SIU_HACK  this cpu is the SIU


Function Documentation

unsigned int THS_cpuSetWarning unsigned int  expectedClkHz,
unsigned int  expectedDeltaClkHz
 

Set range for cpu clock warning messages.

Parameters:
expectedClkHz - expected clock in Hz, <=0 uses default, (16.6MHz on mv2304, 8.3MHz on Rad750)
expectedDeltaClkHz - expected delta clk in Hz, <0 uses default of 2% of clock
Returns:
status

WCT_time THS_gemAbsTimeEvent int  gemStrobeIn,
int  gemClk
 

Calculate absolute time for event from strobe and clk provided with event (20MHz clk).

Parameters:
gemStrobeIn stobe counter from GEM from event data
gemClk clk counter from GEM from event data
Returns:
64b value of number of nanoSec since 1/1/2001
This routine takes the stobe and clk values from the GEM (part of event data) and converts it to an absolute time. Since this value is calulated through a table saved for the last N secs, it is only valid for the last N secs else will error and retun 0.

unsigned int THS_gemSetWarning unsigned int  expectedClkHz,
unsigned int  expectedDeltaClkHz
 

Set range for gem clock warning messages.

Parameters:
expectedClkHz - expected clock in Hz, <=0 uses default of 20MHz
expectedDeltaClkHz - expected delta clk in Hz, <0 uses default of 1% of clock
Returns:
status

unsigned int THS_init int  mask  ) 
 

Inits the TimeHackService module.

Parameters:
mask time hack options, 1=CPU time hack, 2=Gem Time Hack, 4=CpuIsSiu
Returns:
status
This routine does basic init for THS and requires a few modules to be init (PBS,MSG, ??). It setup the Pid TImers for the PPS interrupt and prepares to handle timeones. Howver, it takes several seconds for time hack to be operational and THS_start() can be used to determine if it is operational.

void THS_lsfStatClear LSF_statsHdr *  statsHdr  ) 
 

Clear the LSF_statsHdr structure.

Parameters:
statsHdr pointer to LSF_statsHdr structure to fill in
Returns:
nothing

unsigned int THS_lsfStatFirstEvt LSF_statsHdr *  statsHdr,
unsigned long long  seq,
unsigned int  gemClock,
unsigned int  gemStrobe
 

Sets first event parms within LSF_statsHdr.

Parameters:
statsHdr pointer to LSF_statsHdr structure to fill in
seq extended seqence number of the event
gemClock evt clock register read from GEM contributor of event
gemStrobe evt PPS cock register read from GEM contributor of event
Returns:
status
This is convenient routine to fill in event info that is stored in a LSF_statsHdr structure within an LSF packet for eventual output as science data on the SSR.

void THS_lsfStatIncEvt LSF_statsHdr *  statsHdr,
int  increment
 

Increment event counter in LSF_statsHdr structure.

Parameters:
statsHdr pointer to LSF_statsHdr structure to fill in
increment number of events to increase evt count by
Returns:
nothing
This is convenient routine to increment the event counter within LSF_statsHdr structure. Note that this in the number of events seen by the callback, the raw events rather than the number of prescaled events.

unsigned int THS_lsfStatLastEvt LSF_statsHdr *  statsHdr,
unsigned long long  seq,
unsigned int  gemClock,
unsigned int  gemStrobe
 

Sets last event parms within LSF_statsHdr.

Parameters:
statsHdr pointer to LSF_statsHdr structure to fill in
seq extended seqence number of the event
gemClock evt clock register read from GEM contributor of event
gemStrobe evt PPS cock register read from GEM contributor of event
Returns:
status
This is convenient routine to fill in event info that is stored in a LSF_statsHdr structure within an LSF packet for eventual output as science data on the SSR.

unsigned int THS_prevTimetoneFromEvent int  gemStrobeIn,
int *  absTimeSecs,
int *  flags,
int *  absTimeSecsPrev,
int *  flagsPrev,
int *  gemStrobeInPrev
 

get timetone/flags from table for this event and for prev entry in table

Parameters:
gemStrobeIn stobe counter from GEM from event data
absTimeSecs returns time from timetone message in secs for this event
flags returns flags from timetone message for this event, bits defines as THS_GemTableFlags
absTimeSecsPrev returns time from prev entry in table
flagsPrev returns flags from prev entry in table, bits defines as THS_GemTableFlags
gemStrobeInPrev returne gemStrobe register value from prev entry in table
Returns:
status

void THS_setGemUpdateMsgs int  maxMsgs  ) 
 

set size of memory pool for gemUpdate msgs, must be called before THS_init

Parameters:
maxMsgs number of gem table update messages in memory pool
Returns:
none

void THS_setPpsWarnEvery unsigned int  warnPpsEvery  ) 
 

Set how often get warning when no PPS.

Parameters:
warnPpsEvery 0=warn once when no pps detect, n=warn every N sec
Returns:
none

void THS_setSlaveSend THS_SendSlaveRtn  rtn,
void *  arg,
int  lsmID
 

stash away routine (from LCM) to send msg to EPU

Parameters:
rtn - pointer to function to use to send off message to EPU
arg - 1st arg passed into rtn
lsmID - 2nd arg passed into rtn
Returns:
none
Given routine should be called as: (rtn)(arg, lsmId, int nid, void *payload, int payloadLen, void* payloadFreeRtn, void *payloadFreeRtnArg);

void THS_setTimetoneWarnEvery unsigned int  warnTimetoneEvery  ) 
 

Set how often get warning when no timetone.

Parameters:
warnTimetoneEvery 0=warn once when no tt detect, n=warn every N sec
Returns:
none

unsigned int THS_slaveProcessMsg int  func,
void *  payload,
unsigned int  len
 

routine called from ITC dispatch in LSM to process each message it receives (this routine is run on EPU when it receives message)

Parameters:
func func code for message
payload - buffer with received message
len - length of given buffer
Returns:
none

unsigned int THS_timetone unsigned int  absTimeSec,
unsigned short  saFlags
 

Provide absTime for next entry in table (on next PPS).

Parameters:
absTimeSec - absolute time for next PPS pulse in secs since 1/1/2001
saFlags - flags from Spectrum Astro (i.e. in Magic 7 telecommand)
Returns:
status
This routine provides the absolute time for next PPS. This should come from the spacecrasft once a sec approx 500-800 milliSec before PPS.

unsigned int THS_timetoneFromEvent int  gemStrobeIn,
int *  absTimeSecs,
int *  flags
 

get timetone/flags from table for this event

Parameters:
gemStrobeIn stobe counter from GEM from event data
absTimeSecs returns time from timetone message in secs for this event
flags returns flags from timetone message for this event, bits defines as THS_GemTableFlags
Returns:
status
Routines to get absTIme and flag from table entry associated with given gemStrobe value from an event. Since this value is calulated through a table saved for the last N secs, it is only valid for the last N secs else will return error .

unsigned int THS_wait  ) 
 

Wait for TimeHackService module to be fully operational.

Returns:
status
Since time hack requires a number of subsystems to be operating. These includes LCB driver, 1553 driver, and time tone messages from the scapecraft. Since this module requires two timeTone message from the spacecraft it might take 2 seconds before it is operational. THe routine does a slow poll waiting for the THS to be operational.

The sequence is: THS_init();

start up bunch of things including Sw to call THS_timeTone() every second as result of message from spacecraft Hw to cause PPS interrupt every second

THS_wait() (this routine waits till receives two THS_timeTone() followed by PPS interrupt)


Generated on Tue Nov 29 20:28:35 2005 by  doxygen 1.4.4