Skip to content

Function Blocks

FB_FIFO_ULINT_Array

Properties

Property Type Access Description
EntryCount DINT RO Number of entries currently in buffer
LastInValue ULINT RO Newest value in buffer
NextOutValue ULINT RO Oldest value in buffer

Methods

Method Return Type Access Description
AddEntry BOOL PUBLIC Adds a value to the buffer
RemoveEntry BOOL PUBLIC Removes the oldest value from the buffer

AddEntry()

1
2
3
4
5
METHOD AddEntry : BOOL

VAR_INPUT
    Entry : ULINT;
END_VAR

Adds Entry to the buffer. Returns TRUE on success, FALSE if buffer is full.

RemoveEntry()

METHOD RemoveEntry : BOOL

Removes the oldest value from the buffer. Returns TRUE on success, FALSE if buffer was already empty.

FB_MessageListener

(FINAL, extends Tc3_EventLogger.FB_ListenerBase2)

Internal function block whose purpose is to listen to the event logger, filtering only trace messages. Parses events into ST_TraceMessage which is then passed up to the parent function block via callback (FB_TraceListenerBase).

Properties

Property Type Access Description
Listener I_TraceListener RW Function block who should receive callback when event is raised

FB_SimpleRateLimiter

Limits the rate of change of Y toward TargetValue in both the positive and negative direction.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
FUNCTION_BLOCK FB_SimpleRateLimiter
VAR_INPUT
    Enable        : BOOL;
    TargetValue   : LREAL;
    Minimum       : LREAL;
    Maximum       : LREAL;
    Rate_Increase : LREAL; //Units per second
    Rate_Decrease : LREAL; //Units per second
END_VAR

VAR_OUTPUT
    Y : LREAL;
END_VAR

FB_TraceListenerBase

(Abstract, extends FB_CyclicFB, implements I_TraceListener)

Base trace log listener block which can be inherited to provide alternate means of relaying trace messages. Contains local instance of FB_MessageListener which will automatically handle event filtering.

Note

See I_TraceListener and ST_TraceMessage for more information.

Why would I want this?

Trace messages are always logged by the TC3 Event Logger system. In some cases, you might want to forward or persist them by some other means. This function block provides an easy mechanism to do this. Create a new function block which extends FB_TraceListenerBase and override the OnTraceReceived() method. From there you can, for instance, write the messages to a CSV file or send them via REST API to another system.

Methods

Method Return Type Access Description
OnTraceReceived null PUBLIC Abstract callback method to be overridden to implement alternate event handling

FB_Tree_IndexBased

(Implements I_Tree_IndexBased)

Stores parent-child relationships of a 'tree' of nodes by name.

Note

See I_Tree_IndexBased for more information.

Methods

Method Return Type Access Description
GetIndexByName DINT PUBLIC Returns the node ID of the node with the name specified

ANY Buffers

Base

This is a set of utilities that are used with an array of any datatype.

Type Description
BUFFER Elements can be added until full, simpel buffer with FULL detection and reset functionality
FIFO (aka RING without overwrite) Elements can be added until full, oldest added element can be fetched, the buffer is constantly looped like a ring buffer for best efficiency
LIFO (aka STACK) Elements can be added until full, newest added element can be fetched
RING Elements can be added, oldest element can be fetched, when full when written, the oldest element is OVERWRITTEN
ARRAY Elements can be added, removed, exchanged at a certain location in the array

Class Diagram

The buffer style functions all extend from FB_AnyBase. This holds the common use of each buffer type. The ARRAY type stands on its own.

classDiagram

class FB_AnyBase{
    _LowerBoundary : DINT
    _UpperBoundary : DINT
    _Enable        : BOOL
    _Empty         : BOOL
    _Full          : BOOL

    CheckBoundary()
}

FB_BaseFB<|--FB_AnyBase

Properties

Name Type Description
LowerBoundary DINT This is the lower boundary of the array being used
UpperBoundary DINT This is the upper boundary of the array being used
Enable BOOL This will enable the methods
Empty BOOL Is the buffer type empty
Full BOOL Is the buffer type full

Methods

Name Return Type Description
CheckBoundary BOOL This will check the boundaries entered to make sure they are good

Trace

Anytime the properties that are used are not good, a message is sent to the event system using the FB_BaseFB Trace method and the _Error bit is set. Depending on the type of function, traces are sent if object is _FULL when trying to add data.

Buffer ANY

Elements can be added until full, simple buffer with FULL detection and reset functionality

This object does not give the user the ability to read the array. This would be done outside this functionality.

Class Diagram

classDiagram

FB_BaseFB<|--FB_AnyBase

class FB_BufferAny{
    Push()
    Reset()   
}

FB_AnyBase<|--FB_BufferAny

Methods

Name Return Type Description
Push BOOL This will add data into the array at the next index. It will cause an _ERROR when it is already _FULL
Reset BOOL This will empty the array and put the index to the beginning

FIFO ANY

(aka RING without overwrite) Elements can be added until full, oldest added element can be fetched, the buffer is constantly looped like a ring buffer for best efficiency

Class Diagram

classDiagram


FB_BaseFB<|--FB_AnyBase

class FB_FIFOAny{
    Push()
    Pop()
    Reset()   
}

FB_AnyBase<|--FB_FIFOAny

Methods

Name Return Type Description
Push BOOL This will add data into the array at the next index. It will cause an _ERROR when it is already _FULL
Pop BOOL This will extract the oldest data in the array. It will cause an _ERROR if called when _EMPTY
Reset BOOL This will empty the array and put the index to the beginning

LIFO ANY

(aka STACK) Elements can be added until full, newest added element can be fetched

Class Diagrm

classDiagram


FB_BaseFB<|--FB_AnyBase

class FB_LIFOAny{
    Push()
    Pop()
    Reset()   
}

FB_AnyBase<|--FB_LIFOAny

Methods

Name Return Type Description
Push BOOL This will add data into the array at the next index. It will cause an _ERROR when it is already _FULL
Pop BOOL This will extract the newest data in the array. It will cause an _ERROR if called when _EMPTY
Reset BOOL This will empty the array and put the index to the beginning

Ring ANY

Elements can be added, oldest element can be fetched, when full when written, the oldest element is OVERWRITTEN

Class Diagram

classDiagram


FB_BaseFB<|--FB_AnyBase

class FB_RingAny{
    Push()
    Pop()
    Reset()   
}

FB_AnyBase<|--FB_RingAny

Methods

Name Return Type Description
Push BOOL This will add data into the array at the next index. If _FULL, then oldest element is OVERWRITTEN
Pop BOOL This will extract the oldest data in the array. It will cause an _ERROR if called when _EMPTY
Reset BOOL This will empty the array and put the index to the beginning

ANY Array

Elements can be added, removed, exchanged at a certain location in the array

Class Diagram

classDiagram


FB_BaseFB<|--FB_ArrayAny

class FB_ArrayAny{
    Enable : BOOL
    LowerBoundary : DINT
    UpperBoundary : DINT

    Delete()
    Insert()
    Exchange()
    Reset()   
}

Properties

Name Type Description
LowerBoundary DINT This is the lower boundary of the array being used
UpperBoundary DINT This is the upper boundary of the array being used
Enable BOOL This will enable the methods

Methods

Name Return Type Passed Params Description
Delete BOOL ArrayIn:ANY,DataIn:ANY,Location:DINT This will delete the data at the location in the array and shift up the rest below and make the UpperBound value 0
Insert BOOL ArrayIn:ANY,DataIn:ANY,Location:DINT This will insert the DataIn at the location in the array and shift down the rest of the array. This will lose the data on the end of the array
Exchange BOOL ArrayIn:ANY,DataIn:ANY,Location:DINT This will insert the DataIn at the location in the array losing what was at the location. No shifting of the other data
Reset ArrayIn : ANY This will empty the array and put the index to the beginning

FB_Component_JsonFileHandler

Basic handler for Json files. LoadFile() will load document or create file in Path if not existent.

Same patter is followed in all UpdateXYZ() and ReadXYZ() methods, if member does not exist member will be created in file.

Properties

Name Type Description
Path String Path to Json document e.g. C:\MyJsonFile.json

Methods

All methods return TRUE if command has been accepted.

Name Return Type Description
LoadFile BOOL Loads Json document from Path, creates json file it not present in Path.
ReadBool BOOL Read member from json file and display in Value output, creates member if not found in file.
ReadDInt BOOL Read member from json file and display in Value output, creates member if not found in file.
ReadLREAL BOOL Read member from json file and display in Value output, creates member if not found in file.
ReadString BOOL Read member from json file and display in Value output, creates member if not found in file.
UpdateBool BOOL Update member in json file, creates member if not found in file.
UpdateDInt BOOL Update member in json file, creates member if not found in file.
UpdateLreal BOOL Update member in json file, creates member if not found in file.
UpdateString BOOL Update member in json file, creates member if not found in file.