Task Libraries

The Tsentry library is composed of a set of classes to facilitate the creation and usage of real-time processes on the Windows NT/2000/XP platform.  While the list of included classes is extensive and in some cases very specialized, several interfaces have been written for use in a general Tsentry system:

  • tpriProc – Interface for a generic Tsentry process, including process initialization, periodic timers, priority selection, etc.

  • tpriGsm – Support for creating, mapping, interfacing, and destroying global shared memory segments.

  • tpriGsmDDCom  –  Support for a data dictionary for externally referencing global shared memory by variable string name, as well as allowing for prescribed initial, minimum, and maximum values, formatting string, description, etc.

  • tpriLogMsg – Support for multiple queues into which any process can drop text messages for later processing or asynchronous display.

  • tpriTimer – Support for setting and testing timers.

  • tpriAppThread – Support for creating, managing, and destroying application threads.

  • tpriIniFile – Support for ini file read and write access.


tpriProc – TSENTRY Process class

The Tsentry process class encapsulates the functionality required of a generic Tsentry process.

The following public member functions are provided as part of the tpriProc class:

static int Create(int create = 0);

Attach the current process to a tpriProc class object.

static int Destroy();

Detach the current process from its tpriProc class object.
static int PrIni(int argc, char **argv);

Initialize the current process based on the command line and the default parameters read from the initialization file.
static int PrWait();

  • Sleep until any of the following events occur:

  1. The next timer interval has expired.

  2. An Activate for this process is requested.

  3. A Resume for this process occurs.

static int Activate(char *appName);

Request the process manager to activate the specified process. 

static int Resume(char *appName = NULL);

tatic int Resume(int startOrder);

static int Resume(HANDLE hResume);

Wake the specified process if it is currently sleeping.

 

static int Suspend(char *appName);

static int Suspend(int startOrder);

Suspend a process so that it does not awake from the next call to PrWait().

 

static int Deactivate(char *appName = NULL);

Request that the process manager to deactivate the specified process.

 

int countRunningProcs();

Return the number of currently running processes.

 

static HANDLE openResumeHandle(char *appName);

Open a handle to allow for fast resumes of another process.

 

static int closeResumeHandle(HANDLE hResume);

Close a resume handled opened with openResumeHandle(..).

 

static int getAppName(char *pBuf, unsigned int szBuf);

Export the application name of the current process to the supplied buffer.

 

static int getAppName(char *pBuf, unsigned int szBuf, int startOrder);

Export the application name of the current process to the supplied buffer.

 

static int getBinName(char *pBuf, unsigned int szBuf,char *appName = NULL);

Export the binary file name of the specified process to the supplied buffer.

 

static float getIntervalPct(char *appName = NULL);

Return the current value of the percent interval utilized for the specified process.

 

static float getIntervalPctMax(char *appName = NULL);

Return the current value of the maximum percent interval utilized for the specified process.

 

static int getDbgLevel(char *appName = NULL);

Return the debug level for the specified process.

 

static int setDbgLevel(char *appName, int dbglvl);

Set the debug level for the specified process.

 

static tpriProcGroup getProcGroup(char *appName = NULL);

Return the process group identifier for the specified process.

 

static DWORD getPid (char *appName = NULL);

Return the process ID for the specified process.

 

static int getRestart(char *appName = NULL);

Return the auto-restart flag for the specified process.

 

static int setRestart(char *appName, int restart);

Set the auto-restart flag for the specified process.

 

static long getRepRate(char *appName = NULL);

Return the periodic repetition rate for the specified process (ms).

 

static int getRunMode(char *appName = NULL);

Return the run mode (Win32, RTSS) for the specified process.

 

static tpriProcState getState(char *appName = NULL);

Return the current state for the specified process.

 

static inline tpriProcState getMgrState();

Return the current state of the process manager.

 

static int getStartOrder(char *appName = NULL);

Return the start order for the specified process.

 

static __int64 getStateTime64(char *appName = NULL);

Return the amount of time the specified process has been in its current state (100 ns increments).

 

static long getStateTime(char *appName = NULL);

Return the amount of time the specified process has been in its current state (1 second increments).

 

static const char *getStateDesc(tpriProcState state);

Return a description of the specified state.

 

static const char *getStateDesc(char *appName = NULL);

Return a description of the current state for the specified process.

 

static int exportProdef(prodef *pprodef, char *appName = NULL);

static int exportProdef(prodef *pprodef, int startOrder);

Export a copy of the entire process definition of the specified process.

 

static inline void setState(tpriProcState newState);

Set the state for the current process.

 

static void setDispStatus(const char *fmt, ...);

Set the display status string for the current process.

 

static int getDispStatus(char *pBuf, unsigned int szBuf, char *appName = NULL);

Export the current display status for the specified process.

 

static int clearErrorState(char *appName = NULL);

Clear the error state associated with the specified process.

 

static time_t time(time_t *timer);

Return the current time (seconds since 1/1/1970 12:00 am UTC).

 

static struct tm *lcltime(struct tm *ltm);

Return the current local time.

 

static void ftime(struct _timeb *timeptr);

Return the current time (seconds and milliseconds since 1/1/1970 12:00 am UTC).

 

static inline void setWDog(int wd);

Set the watchdog flag associated with the current process.

tpriGsm – Global shared memory (GSM) class

The tpriGsm class facilitates the mapping and access of shared memory segments within a Tsentry process.  For the most part, this class need not be directly used, as the data dictionary provides higher-level functions to automate the use of all global memory segments; however for specific applications, more specialized functionality may be required and thus a direct interface to the tpriGsm class is provided.

The following public member functions are provided as part of the tpriGsm class:

tpriGsm(char *gsmName, int gsmSize = 0);

Create and/or map a shared memory segment with the given name and size.

 

tpriGsm(char *gsmName, void *pVaddr, int gsmSize);

Wrap a tpriGsm object around an existing memory segment.

 

~tpriGsm();

Destroy a tpriGsm object.

 

void *getVaddr(int offset = 0);

Return the virtual address of the shared memory segment at the given byte offset.

 

int getStatus();

Return the current status of the shared memory segment.

 

int getLastError();

Return the most recent error associated with the shared memory segment.

 

char *getName();

Return the name of the shared memory segment.

 

void mapGsm(char *gsmName, int gsmSize);

Map the shared memory segment into the current process under the specified name.

 

int clearGsm();

Zero the entire shared memory segment.

 

int saveGsm(char *fileName);

Write a binary copy of the shared memory segment to the specified disk file.

 

int restoreGsm(char *fileName);

Read a binary copy of the shared memory segment from the specified disk file.

tpriGsmDDCom - GSM Data Dictionary Class

The data dictionary allows global common variables to be referenced by their string name.  At runtime, the Data Dictionary is itself maintained in a shared memory segment, and thus the tpriGsmDDCom class is derived from the tpriGsm class.

tpriLogMsg – Log Message Class

tpriIniFile - Ini File Support Class

tpriTimer – Timer Support Functions

tpriAppThread – Application Thread Functions

tpriUtil – Utility Support Functions

tpriVop – Variable Operation Class

tpriRps – Rules Processing Classes

© 2022 TelePro, Inc.
3811 Illinois Avenue, Suite 100, St. Charles, IL 60174