API Utils - Krystian-L-Lis/Stage GitHub Wiki

#API #Utils

RawRGBA

Type: Alias
Description:
DWORD alias that represents a colour as a 32-bit value.


I_RGBA

Type: Interface
Extends: I_Debug
Description: Provides methods and properties for working with RGBA colour values.

Members

Alpha

Type: Property
Accessors: Get, Set
Description: Gets or sets the alpha (transparency) channel.
Signature: PROPERTY Alpha: BYTE


Blue

Type: Property
Accessors: Get, Set
Description: Gets or sets the blue channel.
Signature: PROPERTY Blue: BYTE


Green

Type: Property
Accessors: Get, Set
Description: Gets or sets the green channel.
Signature: PROPERTY Green: BYTE


Red

Type: Property
Accessors: Get, Set
Description: Gets or sets the red channel.
Signature: PROPERTY Red: BYTE


Raw

Type: Property
Accessors: Get, Set
Description: Gets or sets the raw combined RGBA DWORD.
Signature: PROPERTY Raw: DWORD


Clone

Type: Method
Description: Copies the RGBA values from another I_RGBA instance.
Signature:

METHOD Clone
VAR_INPUT
    iOther: I_RGBA;
END_VAR

Set

Type: Method
Description: Sets the RGBA values.
Signature:

METHOD Set
VAR_INPUT
    nRed: BYTE;
    nGreen: BYTE;
    nBlue: BYTE;
    nAlpha: BYTE;
END_VAR

RGBA

Type: Function Block
Implements: I_RGBA
Description:
Provides methods and properties for working with RGBA colour values.

Members

FB_Init

Type: Method
Description: Initializes the function block with RGBA values.
Signature:

METHOD FB_init : BOOL
VAR_INPUT
    nRed: BYTE;
    nGreen: BYTE;
    nBlue: BYTE;
    nAlpha: BYTE;
END_VAR

Alpha

Type: Property
Accessors: Get, Set
From: I_RGBA
Description: Gets or sets the alpha (transparency) channel.
Signature: PROPERTY Alpha: BYTE


Blue

Type: Property
Accessors: Get, Set
From: I_RGBA
Description: Gets or sets the blue channel.
Signature: PROPERTY Blue: BYTE


Green

Type: Property
Accessors: Get, Set
From: I_RGBA
Description: Gets or sets the green channel.
Signature: PROPERTY Green: BYTE


Red

Type: Property
Accessors: Get, Set
From: I_RGBA
Description: Gets or sets the red channel.
Signature: PROPERTY Red: BYTE


Raw

Type: Property
Accessors: Get, Set
From: I_RGBA
Description: Gets or sets the raw combined RGBA DWORD.
Signature: PROPERTY Raw: DWORD


Clone

Type: Method
From: I_RGBA
Description: Copies the RGBA values from another I_RGBA instance.
Signature:

METHOD Clone
VAR_INPUT
    iOther: I_RGBA;
END_VAR

Set

Type: Method
From: I_RGBA
Description: Sets the RGBA values.
Signature:

METHOD Set
VAR_INPUT
    nRed: BYTE;
    nGreen: BYTE;
    nBlue: BYTE;
    nAlpha: BYTE;
END_VAR

GetUnixTime

Type: Function
Description:
Fetches the current system time in Unix timestamp format (100ns since January 1, 1970).
Signature:

FUNCTION GetUnixTime : ULINT
VAR_INPUT
	nOffset: LINT := 0;
END_VAR

Math

Type: Program
Description:
Aggregate of various mathematical methods.

Members

Random

Type: Method
Description:
Returns a random value in range 0.0 - 1.0. Uses different seed for each call.
Signature: METHOD Random : LREAL


LowPassFilter

Type: Method
Description: Simple low pass filter.
Signature:

METHOD LowPassFilter : LREAL
VAR_INPUT
	rX: LREAL; // Input value
	rPrvY: LREAL; // Previous value
	
	rCoefficient: LREAL; // Weight coefficient
END_VAR

LinearScale

Type: Method
Description: Takes value and scales it according to provided parameters.
Signature:

METHOD LinearScale: LREAL
VAR_INPUT
	rX: LREAL; // Input value.
	rMinX: LREAL; // Min input value.
	rMaxX: LREAL; // Max input value.
	rMinY: LREAL := 0; // Min output value.
	rMaxY: LREAL := 1; // Max output value.
END_VAR

ExptDecay

Type: Method
Description: Time-compensated smoothing coefficient. A = 1 - (1 - B)^dt.
Signature:

METHOD ExptDecay : LREAL
VAR_INPUT
    rBlendFactor: LREAL;   // In [0, 1] — how fast to blend toward input
    rDeltaTime: LREAL := 0.01;   // In seconds
END_VAR

GetTaskCycleTime

Type: Function
Description: Get task cycle time in seconds.
Signature:

METHOD GetTaskCycleTime : LREAL
VAR_IN_OUT CONSTANT
	taskInfo: ARRAY[*] OF PlcTaskSystemInfo; // Just assign _TaskInfo as _TaskInfo cannot be accessed from lib :(
END_VAR

⚠️ **GitHub.com Fallback** ⚠️