| <?xml version="1.0" encoding="UTF-8" ?> |
| <!DOCTYPE FBType SYSTEM "http://www.holobloc.com/xml/LibraryElement.dtd"> |
| <FBType Comment="Adds two REAL values" Name="FB_RANDOM"> |
| <Identification Classification="Mathematic" Function="RANDOM" Standard="61499-1" Type="Mathematical function"/> |
| <VersionInfo Author="GE" Date="2012-05-31" Organization="4DIAC-Consortium" Version="1.0"/> |
| <CompilerInfo header="package fb.rt.mathnew;"> |
| <Compiler Language="Cpp" Product="GCC" Vendor="GNU" Version=">3.0"/> |
| <Compiler Language="Cpp" Product="Unknown" Vendor="MSVCpp" Version="1"/> |
| </CompilerInfo> |
| <InterfaceList> |
| <EventInputs> |
| <Event Comment="Initializes the random with the specified seed, if not called the generated values will always be identical" Name="INIT" Type="Event"> |
| <With Var="SEED"/> |
| </Event> |
| <Event Comment="Calculates a new random number between 0 and 1" Name="REQ" Type="Event"/> |
| </EventInputs> |
| <EventOutputs> |
| <Event Name="INITO" Type="Event"/> |
| <Event Comment="Execution Confirmation" Name="CNF" Type="Event"> |
| <With Var="VAL"/> |
| </Event> |
| </EventOutputs> |
| <InputVars> |
| <VarDeclaration Comment="the seed to initialize the random, a seed of 0 (zero) uses the current systemtime as seed" InitialValue="0" Name="SEED" Type="UINT"/> |
| </InputVars> |
| <OutputVars> |
| <VarDeclaration Comment="Function output" Name="VAL" Type="REAL"/> |
| </OutputVars> |
| </InterfaceList> |
| <BasicFB> |
| <ECC> |
| <ECState Comment="Initial State" Name="START" x="855.0" y="285.0"/> |
| <ECState Comment="Normal execution" Name="REQ" x="215.0" y="755.0"> |
| <ECAction Algorithm="REQ" Output="CNF"/> |
| </ECState> |
| <ECState Comment="" Name="State" x="2015.0" y="430.0"> |
| <ECAction Algorithm="INIT" Output="INITO"/> |
| </ECState> |
| <ECTransition Comment="" Condition="REQ" Destination="REQ" Source="START" x="555.0" y="600.0"/> |
| <ECTransition Comment="" Condition="1" Destination="START" Source="REQ" x="215.0" y="425.0"/> |
| <ECTransition Comment="" Condition="INIT" Destination="State" Source="START" x="1705.0" y="320.0"/> |
| <ECTransition Comment="" Condition="1" Destination="START" Source="State" x="1585.0" y="680.0"/> |
| </ECC> |
| <Algorithm Comment="ALG" Name="INIT"> |
| <Other Language="AnyText" Text="// WARNING - Don't forget to add #include <time.h> if (SEED() == 0) { srand( (unsigned int) time(NULL) ); } else { srand( SEED() ); }"/> |
| </Algorithm> |
| <Algorithm Comment="Normally executed algorithm" Name="REQ"> |
| <Other Language="AnyText" Text="VAL() = (TForteFloat) ((rand() % 32767) / 100000.0); // RAND_MAX is a constant defined in <cstdlib>. Its default value may vary between implementations but it is granted to be at least 32767. "/> |
| </Algorithm> |
| </BasicFB> |
| </FBType> |