Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

tpriAppThread – Application Thread Functions

Expand
titleOverview

These functions allow the user to create, manage, and destroy an (additional) application thread. These functions may be called by any application task.

Expand
titleClass Interface

The following public functions are provided as part of the tpriAppThread support:

  • tpriAppThread();
    Create an application thread instance

  • ~tpriAppThread();
    Destroy an application thread instance

  • int StartAppThread(
       int iTimer1,
       int iTimer2,
       PTHREAD_START_ROUTINE userThreadFunction,
       LPVOID userThreadFunctionArg,
       int iPriority,
       unsigned long CreateFlags);
    Start execution of an application thread, where:
       iTimer1 = initial (first time) repeat interval (ms)
       iTimer2 = Subsequent repeat interval (ms)
       userThreadFunction -- thread function to be executed
       userThreadArg -- list of function arguments
       iPriority -- thread priority
       CreateFlags -- thread creation flags, as passed to Microsoft
          CreateThread function.
    return value: 0 = successful

  • int ThreadShutdownRequest()
    Setting this class variable to non-zero will cause the thread to exit on its next execution.

Expand
titleExample

The following code snippet is an example of creating and starting an application thread:

Code Block
int fstatus = 0;
   class tpriEgd *pEgd;
   class tpriAppThread *pTap;             // class pointer
   int TimedProduceCmd(void *pParam);     // function prototype
   int iTimer1 = 1000;
   int iTimer2 = 25;

   pEgd = this;
   pTAP = new class tpriAppThread;

   fstatus = pTAP->StartAppThread(
                iTimer1, 
                iTimer2, 
                (LPTHREAD_START_ROUTINE)TimedProduceCmd, 
                (LPVOID)pEgd,
                THREAD_PRIORITY_TIME_CRITICAL, 
                NULL);
   if (fstatus != 0)
      {
      LogMsg("MyFunc", DBERR,
             "StartAppThread error: %d\n", fstatus);
      }

tpriUtil – Utility Support Functions

Expand
titleOverview

This library provides basic support and utility functions.  These functions may be called by Win32 and/or RTSS application processes. 

Expand
titleLibrary Functions

The following public function drives the output LEDs of a ppLED test module.  This module is connected to the parallel port #1 of the system:

Code Block
int ppLed(int val, int mask);
where:
    val  = word data containing updated data bits
  bits in val should be set on or off as desired
    mask = bit mask describing bit(s) to be modified
Examples:
   ppLed(0x01, 0x01)   set lsb on, all others unmodified
   ppLed(0x00, 0x01)   set lsb off, all others unmodified
   ppLed(0x01, 0x03)   set 2 lsbs to b00000001 
     all others unmodified
   ppLed(0xff, 0x03)   set 2 lsbs to b00000011 
     all others unmodified

The following public function transforms an input string by substituting string segments of the form %XXX% with their system environment ‘YYY’ defined strings.  If called by a RTSS process, no string substitution takes place.

Code Block
char *tpriEnvStr (char *inString,
char *outString = NULL,
int outsize = 2048);
Transform inString to outString by substitution of system environment variables.

Return is always a character pointer to the resulting string. If outString is not equal to NULL, the string is also copied into outString. If outString is specified, then the size of outString should be specified in the parameter outsize. The value of the outsize parameter cannot be greater than 2048 bytes.

Code Block
public: int tpriCleanDir(
char *pDir,
timestamp age,
char *pPattern /* = NULL */
)
  • Description:
    Finds and deletes all files in a specified directory older than the specified amount of time.

Parameters:

  • pDir
    Pointer to directory name to search.

  • age
    Maximum age of file to leave in directory.

  • pPattern
    String pattern for file search; only files whose name matches this pattern will be deleted.  A NULL pointer is equivalent to "*", matching all files.

  • Return Value:
    Zero to indicate success.

tpriVop – Variable Operation Class

Expand
titleOverview

The tpriVop class provides the functionality for parsing a variable operation from a string, validating the operation, and evaluating the operation.

Expand
titleVariable Operation Format

A variable operation is a string expression containing variables from global common and/or constant values.  The condition is considered true if the expression evaluates to a non-zero value, otherwise the condition is considered false.  All expressions must be specified as one of the following:

  • The fully qualified name of variable in global common whose type is int, float, double, long, short, char, or char[].

  • A constant value such as a scalar numeric value, a single ASCII character enclosed in single quotes, or a string of characters enclosed in double quotes.

  • An expression in the following form and enclosed in parentheses:
    (Expression1 Operator Expression2)

where:

Expression1 and Expression2 are any two sub-expressions, and Operator is one of the following operators:

&&

Logical AND operator

||

Logical OR operator

Less than

<=

Less than or equal to

Greater than

>=

Greater than or equal to

==

Equal to

!=

Not equal to

+

Add

-

Subtract

*

Multiply

/

Divide

The following special conditions apply:

  • The result of an expression containing one of the logical operators (<, <=, >, >=, ==, or !=) evaluates to the value 1 if true and 0 if false.

  • Variables of different types can be combined in a single expression; in this case the variables will be converted to a type consistent with their native types and the operation.

  • Global common variables that are character arrays are treated as strings and within a single expression or sub-expression can only be used with other character array variables or string constants.

  • Character arrays and string constants can only be used with logical operators (<, <=, >, >=, ==, or !=) and are evaluated in a manner consistent with the strcmp(..) C function. 

Following are examples of valid expressions:

Code Block
(mycommon.myfloat > 0)
(mycommon.mychar == 'a')
(mycommon.myfloat >= mycommon.myint)
(mycommon.mystring != "samplestring")
(mycommon.myfloat > (mycommon.myint - 3.141))
((mycommon.myfloat > mycommon.myint) && (mycommon.mystring != "string"))
Expand
titlePublic Constructors

tpriVop()

Description:

Class constructor.

Inputs:

None.

Return value:

None.

Expand
titlePublic Functions

virtual int Reset()

Description:

Reset the contents of the variable operation object to an uninitialized state.

Inputs:

None.

Return value:

Zero for success, non-zero for error.

virtual int Format(char *buf, int size)

Description:

Format the operation into a string.

Inputs:

char *buf

Output buffer.

int size

Size of output buffer.

Return value:

Zero for success, non-zero for error.

virtual char *Parse(char *buf, int bValidate = 1)

Description:

Parse the operation from a string.

Inputs:

char *buf

Input buffer.

int bValidate

Flag to force immediate validation.

Return value:

Zero for success, non-zero for error.

virtual char *Validate()

Description:

Validate the variable operation.

Inputs:

None.

Return value:

[-1] Fatal validation error.

[+1] Non-fatal validation error (warning).

[0] Success.

virtual char *Evaluate()

Description:

Evaluate the variable operation.  A pointer to the output value can be retrieved with the GetOutputValue() function.

Inputs:

None.

Return value:

Zero for success, non-zero for error.

unsigned short GetNativeType()

Description:

Return the native type for the variable operation.  By default, the variable operation is evaluated to a native value whose type is most appropriate for the operation and operands in the variable operation; this function returns the variant type of this native value.  

Inputs:

None.

Return value:

Native type for the variable operation.  This value will equal one of the Windows Variant types (VT_XX).

long GetNativeSize()

Description:

Return the native type for the variable operation.  By default, the variable operation is evaluated to a native value whose type is most appropriate for the operation and operands in the variable operation; this function returns the size in bytes of this native value.

Inputs:

None.

Return value:

Native size for the variable operation.

int SetOutputInfo(unsigned short vType, long size)

Description:

Set the output type information for the variable operation.  During evaluation, the native value is converted to this type for output.

Inputs:

unsigned short vType

Desired output type.

long size

Desired output size.

Return value:

Zero for success, non-zero for error.

unsigned short tpriVop::GetOutputType()

Description:

Return the output type for the variable operation.  This is the type of the value that is pointed to by the GetOutputValue() function.  

Inputs:

None.

Return value:

Output type for the variable operation.  This value will equal one of the Windows Variant types (VT_XX).

void *GetOutputValue()

Description:

Return a pointer to the output value.  Once the operation has been evaluated this will point to the output value of the operation.  

Inputs:

None.

Return value:

Pointer to the output value.

int SetDepth(int ndepth)

Description:

Set the output type information for the variable operation.  During evaluation, the native value is converted to this type for output.

Inputs:

int ndepth

Desired logging depth.  This is the depth at which all LogMsg calls should be logged, i.e. the number of spaces x2 inserted into the message buffer before the message text itself.

Return value:

Zero for success, non-zero for error.

tpriRps – Rules Processing Classes

Expand
titleOverview

The Rules Processing System API consists of a set of hierarchical classes defined in the TSENTRY tpriNtRt C/C++ library.  With the exception of the classes defined to read and write the XML rule definition files, which utilize the Microsoft .NET Framework, the rules processing system API classes are all coded in ANSI C/C++ in order to make them as portable as possible.

Expand
titleClasses

Brief descriptions of each of the individual rules processing classes are provided below:

Class Name

Class Description

tpriRpsAction

Defines base class for rule actions.

tpriRpsModifyVarAction

Defines specific type of rule action which modifies a variable in global shared memory.

tpriRpsCriteria

Defines base class for rule criteria.

tpriRpsVarCriteria

Defines specific type of rule criteria whose condition is a Boolean statement containing variables from global shared memory.

tpriRpsCriteriaGroup

Defines specific type of rule criteria which consists of several sub-criteria.

tpriRpsRule

Defines base class for rule, which is itself a criteria group.

tpriRpsFile

Defines base class for persistent storage of rule definition to a disk file.

tpriRpsXmlFile

Defines specific implementation of rule file stored as an XML file.

tpriRpsRuleGroup

Defines base class for a group of rules associated with one another.

tpriRpsProcessor

Defines base class for a rules processor, which is itself a rule group.