=============================================================

Test applications

=============================================================


* iomonitor
* iobridge


=============================================================

Digital IO via the comedi device (linux only)

=============================================================


The class cDevice provides an interface to communicate with the digital IO devices
via the open-source comedi framework. The provided tutorial demonstrates access to two 
conveyor belts (labeled cb6 and cb14) of the lrt lab experiment Fischertechnik 
production-line via two Advantech digital io PCI cards.

In order to test the basic functions of cDevice (i.e. execution of events and time functions) 
a simple supervisor has been designed. Once simulated by the faudes-simulator-plug-in, it
provides a control, which causes a work piece to shuttle between the two 
conveyor belts. If a work piece arrives at a sensor, it will rest for 2 sec before 
it continues its movement.

Files: 

data/conveyor_super.gen           generator to control the tro conveyor belts
data/conveyor_super.sim           simulator to run the controller
data/conveyor_comedi.dev          device configuration to access advantech io cards
conveyor_suprvisor.sh             script to run the experiment


Checklist to run the experiment:

1) get the comedi kernel module

Follow the installation guide provided by comedi. You must have kernel sources 
installaled in order to compile the comedi module. You will need superuser
privileges to install the modules.

   - current versins 0.7.74 and 0.7.22 have been tested with kernel 2.6.13
   - get kernel sources of aktive kernel, do a "make cloneconfig" and a "make"
     to ensure the sources are ok; no need to actually install the new kernel
   - configure, make, and make install, make dev  comedi and comedilib
   - copy binaries comedi_config and comedy_test to eg /usr/local/bin
   - also useful is info from the demos, copy to eg /usr/local/bin/comedi_info



2) compile libFAUDES
			
Change to the libfaudes-directory, ensure that the main Makefile includes the iodevice,
simulator and timed plug-ins and that plugins/iodevice/Makefile.plugin has comedi support enabled. 
You may want to disable all other plugins to circumvent various issues of the build system.
Do a "make dist-clean", "make configure" and "make".

3) initialize the comedi kernel module

This can be done by executing the script comedi_lrt.sh. The script must be installed in 
/usr/local/bin and must be executed via sudo.


4) test the device via the libfaudes iomonitor

Run libfaudes/bin/iomonitor on the provided conveyor_comedi.dev and inspect 
sensosor or test actuators.


5) run the experiment

You may use the proived script to run the experiment.



=============================================================

Networked IO via the simplenet device 

=============================================================


** simpelnet_test.sh

Runs a simplemachine with all events mapped via a simplenet device. 
The script will open two xterm windows, one to report plant sensors
(beta and mue) and one to accept plant actuators (alpha and lambda).
Within both windows, communicaton is directly mapped from the respective
tcp socket to console input/output.

** simpelnet_machine.sh
** simpelnet_supervisor.sh

Runs a simplemachine plant and a corresponding supervisor, respectively. 
All events passed on via a simplenet device. Thus, you may run each simulator
on a seperate pc.

** simpelnet_simpleloop.sh

Opens two xterm windows to run both the simplemachine plant and supervisor
on one pc. Events are synchronized via a simplenet device.

** simpelnet_machinesab.sh

Runs two simple machines A and B. This script is meant to support
the DESTool project Machines which runs the corresponding supervisor.


=============================================================

Remote Control of Lab Experiment

=============================================================



** conveyor_bridge.sh

Runs an iobridge to map events from the lrt lab experiment to a simplenet
device. Thus, events can be accessed via an according remote device.

** conveyor_remote.sh

Runs a simulator with a controller for the lab experiment with a simplenet 
device for accesses to the above iobridge.



=============================================================

HIL-simulation project "Elevator"

=============================================================


The elevator setup consists of an analog circuit that mimiques
the baviour of a simple two-level elevator by PT1 dynamics
for cabin and door movements. Digital signals are generated by 
lower and upper thresholds and connected to a PC. At the LRT lab,
wiring is prepared for either a desktop PC using parallel IO via
the comedi framework (see above) or a Wago IPC with a kbus based 
interface (see below)

Related generator files:
- DES plant model   (components) ./data/elevator_plant_*.gen
- DES specification (components) ./data/elevator_spec_*.gen
- DES supervisors   (components) ./data/elevator_super_*.gen

The supervisors are synthesised by the luafaudes:
- (lua script) ./data/elevator_synthesis.lua

A devicefile is provided for the LRT setup using the desktop pc:
- (device conf) ./data/elevator_comedi.dev
- (simulator conf file) ./data/elevator_supervisor.sim

There are scripts to facilitate operation of the elevator:

** ./elevator_simulate.sh

Interactive simulation of the supervisor for inspection.

** ./elevator_supervisor.sh

Hardware-in-the-loop simulation on the actual elevator.

==================================================

HIL-simulation project "Elevator" with WAGO IPC

==================================================

This tutorial refers to exactly the same plant
and specification as discussed above. However, the device 
configuration file specifies access to the elevator hardware 
via the Wago kbus on a Wago IPC. To run the tutorial, you 
may proceed as follows:

1) Compile libFAUDES with minimal plug-ins, aka
timed, simfaudes, and iodevice with WAGO support enabled
in the iodevice/Makefile.plugin.  This requires the WAGO
supplied archive kbusdemo.tgz to be in the wago directory.
A separate Makefile in supplied to independantly test/trigger
compilation of WAGO libraries. Your build environment 
must complie with the target platform. Ubunto 10.04 LTS 
turned out fine with an 2010 image of an 
Wago IPC-P14 (Intel Celeron)

2) Upload the tutorial data and relevant executables
to the IPC by the script wago_upload.sh. You
may need to adapt the script and the faudes device file.

3) Logon to the IPC via telnet to test the configuration
with 
  
  ./bin/iomonitor ./data/elevator_wago.dev

Error messages from the dynamic linker or otherwise
strange behaviour indicate that incompatibilities
between your build environment (g++, libc etc) and
the target platform. 

Frequent kbus errors may indicate that more than
one application accesses the kbus; e.g. a soft IPC 
background task or a modbus server. Inspect active 
processes by "ps ax" and disable any programms 
that write to the kbus form "/etc/init.d"

4) Run the provided supervisor on the plant by

  ./bin/simfaudes -q                           \ 
      -d ./data/elevator_wago.dev              \
      ./data/elevator_supervisor.sim

On some IPCs, console output is particularly slow, 
so you may add "&> prot" to redirect cout and 
cerr to a file.



=============================================================

Serial process image device

=============================================================

The SpiDevice and the respective demo scenario "decdemo"
are documented in the user reference.

=============================================================

Modbus/TCP devices

=============================================================


The class mbDevice provides an interface to communicate with the digital 
IO devices connected via the Modbus/TCP protocolo; see www.modbus.org.
At the time of writing, it is used for the factory simulator
FlexFact of the applications project. For elementary tests within
libfaudes, device configurations of the "decdemo" plant are provided:

./data/decdemo_plant_modbus.dev     (plant device conf.)
./data/decdemo_test_modbus.dev      (plant access device conf.)

To run the test, simulate the plant by

simfaudes -d decdemo_plant_modbus.dev decdemo_plant.sim

and inspect the process image via

iomonitor decdemo_test_modbus.dev




