FB_ALY_Calendar

The Calendar creates a recurring event at certain times. The repeat mode can be set individually. The modes of daily, weekly, monthly or annual repetition are available.
A timestamp is required as a reference value, as the algorithm needs a time context in which to work. This reference timestamp is set automatically, if there is another algorithm in the configuration. Therefore, it is not possible to use the Calendar individually.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_TimeClock_1Ch
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    bEvent: BOOL;
    fbTimeUntilNextEvent: FB_ALY_Timespan
END_VAR

FB_ALY_Calendar 1: Outputs

Name

Type

Description

ipResultMessage

I_TcMessage

Contains more detailed information on the current return value. For this special interface pointer, it is ensured internally that it is always valid/assigned.

bError

BOOL

The output is TRUE if an error occurs.

bNewResult

BOOL

When a new result has been calculated, the output is TRUE.

bConfigured

BOOL

Displays TRUE when the function block is successfully configured.

bEvent

BOOL

TRUE when the time for the event is reached.

fbTimeUntilNextSwitch

FB_ALY_Timespan

Timespan until the next event.

FB_ALY_Calendar 2:Methods

Name

Definition location

Description

Call()

Local

Method for calculating the outputs for a specific configuration.

ConfigureDaily()

Local

Configuration of the algorithm for daily events.

ConfigureWeekly()

Local

Configuration of the algorithm for weekly events.

ConfigureMonthly()

Local

Configuration of the algorithm for monthly events.

ConfigureYearly()

Local

Configuration of the algorithm for yearly events.

Reset()

Local

Resets all internal states or the calculations performed so far.

Sample

VAR
    fbCalendar : FB_ALY_Calendar;
    fbSystemTime : FB_ALY_GetSystemTime;
    eRecurrenceMode : E_ALY_RecurrenceMode := E_ALY_RecurrenceMode.Yearly;
    tTimeEvent : LTIME := LTIME#8H;
    bConfigure : BOOL := TRUE;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;

    CASE eRecurrenceMode OF
        E_ALY_RecurrenceMode.Daily:
            fbCalendar.ConfigureDaily(tTimeEvent);
        E_ALY_RecurrenceMode.Weekly:
            fbCalendar.ConfigureWeekly(tTimeEvent, E_ALY_DayOfWeekMask.MondayToFriday);
        E_ALY_RecurrenceMode.Monthly:
            fbCalendar.ConfigureMonthly(tTimeEvent, 0, E_ALY_RecurrenceSpecification.First, E_ALY_DayOfWeek.Monday);
        E_ALY_RecurrenceMode.Yearly:
            fbCalendar.ConfigureYearly(tTimeEvent, 18, E_ALY_RecurrenceSpecification.SpecificDay, E_ALY_DayOfWeek.Unspecified, E_ALY_MonthOfYearMask.November);
    END_CASE
END_IF

// Get current system time
fbSystemTime.Call();

// Call algorithm
fbCalendar.Call(fbSystemTime.tSystemTime);

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics