Class PlcThread
Modified 08-MAR-2026 11:05:32.00
Code rt_c_plcthread.c
Keeps data of a plc thread. Prio and ScanTime are input to the plc process
which starts all threads. The rest of the parameters are output from the
plc thread and updated periodically.

Object graph


RtBody attributes pwr_sClass_PlcThread
String104 Description   Description of the plc thread.
Int32 Prio   Priority of the plc thread.
Float32 Deadline   Deadline for the plc thread.
ThreadOptionsMask Options   Plc thread options.
Specification of the action when the execution time exceeds
the scantime.
Float32 ScanTime   Scan time for the plc thread.
Float32 ActualScanTime   Actual scan time for the last scan.
Float32 ScanTimeMin   Minimum actual scan time since start of thread.
Float32 ScanTimeMean   Mean scan time for last x cycles (x defined by 'ScanTimeMeanCount').
Float32 ScanTimeMax   Maximum actual scan time since start of thread.
Int32 ScanTimeMeanCount   Number of cycles to base 'ScanTimeMean' on.
Int32 Count   Total number of cycles since start of thread.
Float32 Last   Actual execution time for last cycle (exlusive wait time).
Float32 Sum   Total execution time since start of thread.
Float32 Min   Minimum execution time for a cycle since start of thread.
Float32 Mean   Mean execution time since start of plc thread.
Float32 Coverage   Relation between mean execution time and supposed scan time(percentage).
Float32 Max   Maximum execution time for a cycle since start of thread.
Int32 Count_1_8   Number of cycles where exection is less than 1/8:th of 'ScanTime'.
Int32 Count_1_4   Number of cycles where exection is less than 1/4:th of 'ScanTime'.
Int32 Count_1_2   Number of cycles where exection is less than 1/2:th of 'ScanTime'.
Int32 Count_1_1   Number of cycles where exection is less than 'ScanTime'.
Int32 Count_2_1   Number of cycles where exection is less than 2 times 'ScanTime'.
Int32 Count_4_1   Number of cycles where exection is less than 4 times 'ScanTime'.
Int32 Count_8_1   Number of cycles where exection is less than 8 times 'ScanTime'.
Int32 CountHigh   Number of cycles where exection is more than 8 times 'ScanTime'.
Int32 SlipCount   Number of cycles where a cycle did not start on time.
Float32 Limit_1_8   1/8:th of 'ScanTime'.
Float32 Limit_1_4   1/4:th of 'ScanTime'.
Float32 Limit_1_2   1/2:th of 'ScanTime'.
Float32 Limit_1_1   1/1:th of 'ScanTime'.
Float32 Limit_2_1   2/1:th of 'ScanTime'.
Float32 Limit_4_1   4/1:th of 'ScanTime'.
Float32 Limit_8_1   8/1:th of 'ScanTime'.
RefId Dlid   Direct link.
Time ScanTimeStart   Absoulute time when 'ScanTimeMean' was last calculated.
Pointer to Boolean TimerStart   Used for timer-handling
Enum IoProcess   IO Process number.

DevBody attributes 
Boolean IsDefault   Inserted as default thread in PlcPgm objects.


Template Object
IoProcess 1
Prio 22


Attributes detail


Description Attribute
Class Attribute
Type String104
Flags
Body RtBody
 Description of the plc thread.

Prio Attribute
Class Attribute
Type Int32
Flags
Body RtBody
 Priority of the plc thread.

Deadline Attribute
Class Attribute
Type Float32
Flags
Body RtBody
 Deadline for the plc thread.

Options Attribute
Class Attribute
Type ThreadOptionsMask
Flags
Body RtBody
 Plc thread options.
 Specification of the action when the execution time exceeds
 the scantime.

ScanTime Attribute
Class Attribute
Type Float32
Flags
Body RtBody
 Scan time for the plc thread.

ActualScanTime Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 Actual scan time for the last scan.

ScanTimeMin Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 Minimum actual scan time since start of thread.

ScanTimeMean Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 Mean scan time for last x cycles (x defined by 'ScanTimeMeanCount').

ScanTimeMax Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 Maximum actual scan time since start of thread.

ScanTimeMeanCount Attribute
Class Attribute
Type Int32
Flags STATE | INVISIBLE
Body RtBody
 Number of cycles to base 'ScanTimeMean' on.

Count Attribute
Class Attribute
Type Int32
Flags STATE | INVISIBLE
Body RtBody
 Total number of cycles since start of thread.

Last Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 Actual execution time for last cycle (exlusive wait time).

Sum Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 Total execution time since start of thread.

Min Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 Minimum execution time for a cycle since start of thread.

Mean Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 Mean execution time since start of plc thread.

Coverage Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 Relation between mean execution time and supposed scan time(percentage).

Max Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 Maximum execution time for a cycle since start of thread.

Count_1_8 Attribute
Class Attribute
Type Int32
Flags STATE | INVISIBLE
Body RtBody
 Number of cycles where exection is less than 1/8:th of 'ScanTime'.

Count_1_4 Attribute
Class Attribute
Type Int32
Flags STATE | INVISIBLE
Body RtBody
 Number of cycles where exection is less than 1/4:th of 'ScanTime'.

Count_1_2 Attribute
Class Attribute
Type Int32
Flags STATE | INVISIBLE
Body RtBody
 Number of cycles where exection is less than 1/2:th of 'ScanTime'.

Count_1_1 Attribute
Class Attribute
Type Int32
Flags STATE | INVISIBLE
Body RtBody
 Number of cycles where exection is less than 'ScanTime'.

Count_2_1 Attribute
Class Attribute
Type Int32
Flags STATE | INVISIBLE
Body RtBody
 Number of cycles where exection is less than 2 times 'ScanTime'.

Count_4_1 Attribute
Class Attribute
Type Int32
Flags STATE | INVISIBLE
Body RtBody
 Number of cycles where exection is less than 4 times 'ScanTime'.

Count_8_1 Attribute
Class Attribute
Type Int32
Flags STATE | INVISIBLE
Body RtBody
 Number of cycles where exection is less than 8 times 'ScanTime'.

CountHigh Attribute
Class Attribute
Type Int32
Flags STATE | INVISIBLE
Body RtBody
 Number of cycles where exection is more than 8 times 'ScanTime'.

SlipCount Attribute
Class Attribute
Type Int32
Flags STATE | INVISIBLE
Body RtBody
 Number of cycles where a cycle did not start on time.

Limit_1_8 Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 1/8:th of 'ScanTime'.

Limit_1_4 Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 1/4:th of 'ScanTime'.

Limit_1_2 Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 1/2:th of 'ScanTime'.

Limit_1_1 Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 1/1:th of 'ScanTime'.

Limit_2_1 Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 2/1:th of 'ScanTime'.

Limit_4_1 Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 4/1:th of 'ScanTime'.

Limit_8_1 Attribute
Class Attribute
Type Float32
Flags STATE | INVISIBLE
Body RtBody
 8/1:th of 'ScanTime'.

Dlid Attribute
Class Attribute
Type RefId
Flags STATE | INVISIBLE
Body RtBody
 Direct link.

ScanTimeStart Attribute
Class Attribute
Type Time
Flags STATE | INVISIBLE
Body RtBody
 Absoulute time when 'ScanTimeMean' was last calculated.

TimerStart Attribute
Class Attribute
Type Pointer to Boolean
Flags POINTER | STATE | INVISIBLE | PRIVATE
Body RtBody
 Used for timer-handling

IoProcess Attribute
Class Attribute
Type Enum
Flags
Body RtBody
 The process number is normally PlcProcess (1) for plc threads.
 In some IO system though, a plc thread should act as a
 separate IO process. This is done when an Agent, Rack or Card
 should be handled by several plc threads.

IsDefault Attribute
Class Attribute
Type Boolean
Flags
Body DevBody
 If IsDefault is set, this thread will be inserted as default thread in
 PlcPgm objects when they are created.