FB_WeightedBalancing - SetRandomSeed (Method)

Overview

Type:

Method

Available as of:

V1.4.1.0

This chapter provides information on:

oTask

oDescription

oInterface

oDiagnostic Messages

Task

Initialize the random seed used for the internal random number generation.

Description

The method SetRandomSeed, initializes the random seed used for the internal random number generation. If this method is not manualy called before a call of the AssignTargetsOwners method, the random seed is automatically initialized based on the current status of the CPU timer, using SystemInterface.FC_GetTSC().

NOTE: SystemInterface.FC_GetTSC() returns a value of zero when the project is running in simulation mode. In this case, the seed is internally initialized to one if not previously manually set by calling the SetRandomSeed method.

Interface

Input

Data type

Description

i_uiValue

UNIT

Random seed used for the generation of a sequence of random numbers.

If i_uiValue is set to 0, at the first call of one of AssignTargetsOwners, the function block initializes the seed based on the status of the CPU clock. This results in a different random sequence every time the function block is enabled.

Output

Data type

Description

q_etDiag

GD.ET_Diag

General library-independent statement on the diagnostic. A value unequal to GD.ET_Diag.Ok corresponds to a diagnostic message.

q_etDiagExt

ET_DiagExt

POU-specific output on the diagnostic.

q_etDiag = ET_Diag.Ok -> Status message

q_etDiag <> ET_Diag.Ok -> Diagnostic message

q_sMsg

STRING[80]

Event-triggered message that gives more detailed information on the diagnostic state.

Diagnostic Messages

q_etDiag

q_etDiagExt

Enumeration value of q_etDiagExt

Description

Ok

Ok

0

Ok

UnexpectedProgramBehavior

RandomSeedInvalid

39

The random seed value was initialized to an invalid value.

Ok

Enumeration name:

Ok

Enumeration value:

0

Description:

Ok

Status message: The random seed value was set.

RandomSeedInvalid

Enumeration name:

RandomSeedInvalid

Enumeration value:

39

Description:

The random seed value was initialized to an invalid value.

Status message: The random seed value was internally set to an invalid value.