TOC PREV NEXT INDEX

Put your logo here!


2.12 TIME SYSTEM

2.12.1 Purpose

The Time system of CCS provides the following facilities:

· Time library - retrieve and manipulate time and timemodes,
· Timer functionality - schedule processes and send commands synchronized to time,
· Time synchronization - system clock and time synchronization via time server connected to the LAN

The CCS Time system is provided for Workstations as the CCS tims module and for LCUs the same functions that are contained in tims, were ported to VxWorks. Allowing a standard time accessibility from both platforms. The tims source code for VxWorks is contained under the `time' directory of the lcc3 module (<module-root>/lcu/src/time).

The Time synchronization feature provided by the time system is not part of the tims module. Instead, it is based on the Network Time Protocol and the VLT ntp module. Refer to the next section (2.13) in this document for a detailed explanation about time synchronization inside the VLT project.

The complete functionality of the tims system is fully supported under CCS_LITE.

2.12.2 Basic Concepts

2.12.2.1 Simulation mode

The Time System supports a simulation mode. This mode is independent from the synchronization mechanism, and operates only inside a single CCS environment. Assuming two CCS environments running on the same workstation, one being in simulation mode, the second one would still report the true UTC, or they could both operate independently in simulation mode at two different simulated times.

In that mode, the system clock still shows UTC (synchronized on Time Server or not), but time system subroutines return a different time, calculated by adding or subtracting an offset maintained by the time system. The offset is calculated when the simulation mode is entered, and is kept in the time system internal data.

2.12.2.2 Tims functionality

The tims functionality is basically a library providing a set of routines related to time. The time modes used in tims are: UTC, Local and Simulation. The UTC or Local mode is determined by the current state of time synchronization.

When the Time System is switched to Simulation mode the user must provide the new time to be shown by the time system from now on. An offset with the real UTC is internally calculated and maintained in the time system data area. It is used by any subsequent call to a time system function.

Furthermore tims provides routines to:

· manipulate time values,
· return formatted time strings.
2.12.2.3 Timer functionality

The timer functionality of the CCS Time System provides features to synchronize actions to a specific time. Following actions are provided: Scheduling processes, sending CCS message system commands or replies. The actions can be repeated at a specified interval. The timer functionality is build on top of the Rtap Timekeeper, and supports the simulation mode. However, to avoid unpredictable behavior, active requests to the time system must be flushed before switching to/from simulation mode.

2.12.3 Configuration

2.12.3.1 Timer configuration

In order to use the timer functionality of the Time system following entries must be present in the RtapEnvTable(FULL CCS case):

6 1 Y E N A Y 80 128 RtapTimeKeeper

0 2 Y P N N N 50 128 msgServer

or in the CcsEnvTable (CCS_LITE case):

5 3 N N N Y Y 100 128 timsTimeKeeper

0 3 N N N N N 100 128 msgServer

The same entries should also be present on the remote environments that are used e.g. as scheduling targets.

2.12.4 Examples

#include "vltPort.h"

/* System Headers */

#include <stdio.h>

/* Local Headers */

#include "timer.h"

void main (int argc, char ** argv)

{

ccsERROR error;

ccsCOMPL_STAT stat;

ccsTIMEVAL UTC;

ccsTIMEVAL interval;

ccsTIMEVAL startTime;

timsMODE mode;

ccsRUNOPT runoptions

ccsRUNOPT *runopPtr=&runoptions;

char buffer[80];

stat = ccsInit("timsTest",0,NULL,NULL,&error);

if (stat != SUCCESS)

{

/* Error handling */

}

...........

stat = timsGetUTC ( &UTC, &mode, &error);

if (stat != SUCCESS)

{

/* Error handling */

}

interval.tv_sec = 30;

interval.tv_usec = 50000;

timsAddTime(&UTC,&interval,&startTime,&error);

if (timerScheduleTask ("wte13",

"myTask",

runopPtr,

timerSCHEDULE_PER_ON_UTC,

&startTime,

&interval,

&requestId,

&error) == FAILURE)

{

/* ... error processing ... */

}

else

{

stat = timsTimeToString(&startTime,timsABS_TIME,buffer,&error);

if (stat != SUCCESS)

{

/* error handling */

}

else

printf("Will start process at: %s\n",buffer);

}

.............

stat = ccsExit(&error);

}

2.12.5 Reference

PROCEDURES

timsAddTime(). Add two time values
timsGetMode(). Retrieves the Time System mode.
timsGetUTC(). Retrieves the system time and the Time System mode.
timsIsoStringToTime(). Converts an ISO string to time value.
timsJDToUTC(). Converts time from Julian Date to UTC
timsMJDToUTC(). Converts time from Modified Julian Date to UTC
timsSetMode(). Set's the Time System mode.
timsSetUTC(). Set's the system time in simulation mode.
timsStringToTime(). Converts string to time value. Obsolete, not provided under CCS_LITE.
timsSubTime(). Subtract two time values.
timsTimeToIso String(). Converts time value to ISO string
timsTimeToString(). Converts time value to string. Obsolete, not provided under CCS_LITE.
timsUTCToJD(). Converts time from UT into Julian Date
timsUTCToMD(). Converts time from UT into Modified Julian Date
timsUTCToST(). Converts UTC time value to sidereal time (Not in present release)
timerCancelRequest(). Cancel a request to the timer system.
timerGetReport(). Formatted report on timer requests.
timerScheduleProcess(). Schedules a process synchronized to time.
timerSendCommand(). Sends command message synchronized to time.
timerSendReply(). Sends reply synchronized to time.
timerSleep(). Suspend process with microseconds resolution.



INCLUDE FILES

tims.h Contains constants, types and function prototypes of the tims system
timer.h Contains constants, types and function prototype related to the timer.

UTILITIES

timsDate Tool to query the time and modes and set simulation time.



Quadralay Corporation
http://www.webworks.com
Voice: (512) 719-3399
Fax: (512) 719-3606
sales@webworks.com
TOC PREV NEXT INDEX