FB_RandomTargetsGenerator - SetRandomSeed (Method)

Overview

Type:

Method

Available as of:

V1.1.0.0

This chapter provides information on:

Task

Set the internal seed, used for the generation of the random sequence of targets.

Description

The method SetRandomSeed sets the internal seed, used for the generation of the random sequence of targets, to a constant value provided by you.

Calling the method multiple times would force a reinitialization of the internal random sequence generator. In particular, calling this method providing a seed value equal to the one currently used by the function block, restarts the current random sequence.

If the seed is left or set to 0, at the next call of a target generation method the 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 1 if not previously set by you calling the SetRandomSeed method.

Interface

Input

Data type

Description

i_uiValue

UINT

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 the methods used to generate random targets, the function block initializes the seed based on the current status of the CPU timer. 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

A feedback value is indeterminable.

Ok

Enumeration name:

Ok

Enumeration value:

0

Description:

Success

Status message: Registration of the function block was successful.

RandomSeedInvalid

Enumeration name:

RandomSeedInvalid

Enumeration value:

39

Description:

The random seed value was initialized to an invalid value.

Issue

Cause

Solution

The random seed value was internally set to an invalid value.

-

Contact your Schneider Electric representative.