luafaudes

Tutorials

luafaudes Tutorial: 4_composition.lua

To run the below Lua script, cd to the tutorial section of the respective plugin and enter ./luafaudes 4_composition.lua at the command prompt. The script will read input data from ./tutorial/data/.

-- Test/demonstrate composition functions

-- ------------------------------------------
-- Prepare two simple machines
-- ------------------------------------------

-- Announce
print("################# Prepare two simple machines");

-- Read original machine
machine  = faudes.System("data/verysimplemachine.gen")

-- Prepare two copies
machine1 = faudes.System()
machine2 = faudes.System()
faudes.Version(machine,"1",machine1)
faudes.Version(machine,"2",machine2)

-- Report
machine1:Write()
machine2:Write()

-- ------------------------------------------
-- Std parallel
-- ------------------------------------------

-- Announce
print("################# Std parallel composition (here: shuffle product)");


-- Compose overall plant
machines = faudes.Generator()
faudes.Parallel(machine1,machine2,machines)

-- Report
machines:Write()

-- Record test case
FAUDES_TEST_DUMP("parallel",machines)

-- ------------------------------------------
-- Std parallel with attributes
-- ------------------------------------------

-- Announce
print("################# Std parallel composition (here: shuffle product, incl attributes)");


-- Compose overall plant
cmachines = faudes.System()
faudes.Parallel(machine1,machine2,cmachines)

-- Report
cmachines:Write()

-- Record test case
FAUDES_TEST_DUMP("parallel incl. attr.",cmachines)

-- ------------------------------------------
-- Omega parallel
-- ------------------------------------------

-- Announce
print("################# Omega parallel composition (incl attributes)");


-- Compose overall plant
omachines = faudes.System()
faudes.OmegaParallel(machine1,machine2,omachines)

-- Report
omachines:Write()
omachines:GraphWrite("tmp_omachines.svg")

-- Record test case
FAUDES_TEST_DUMP("omegaparallel incl. attr.",omachines)


libFAUDES 2.14g --- 2009-12-3 --- plugins "example synthesis observer diagnosis hiosys multitasking timed simulator iodevice luabindings"