4_cgenerator.cpp File Reference


Detailed Description

Tutorial, std monolitic synthesis .

The faudes::cGenerator class is inherited from the faudes::Generator class and only differs by definition of the controllabilty flag for events. Because of the inheritance, the cGenerator class's methods are a superset of the Generator. This tutorial demonstrates cGeberator specific methods as well as std monolithic controller synthesis.

This tutorial demonstrates monolitiy supervisory controller synthesis.

#include "libfaudes.h"


// we make the faudes namespace available to our program
using namespace faudes;




// main program

int main() {


  // Constructors & Assignment Operator

  // Create an empty cGenerator object

  cGenerator cgen1;

  // Create a cGenerator by reading a Generator file 
  // Events default to uncontrollable

  cGenerator cgen2("data/simplemachine.gen");

  // Create a cGenerator by reading a cGenerator file 

  cGenerator cgen3("data/csimplemachine.gen");

  // Copy constructor & assignment operator
  // (same behaviour as in Generator class)

  cGenerator cgen4(cgen3); 
  cgen4 = cgen3;           

  cgen4.Write("tmp_csimplemachine.gen");

  // Controllable events

  // Insert an event and set it controllable 

  cgen1.InsControllableEvent(1); // by index
  cgen1.InsControllableEvent("newcevent1"); // by symbolic name

  // Insert an event and set it uncontrollable 

  cgen1.InsUncontrollableEvent(2); // by index
  cgen1.InsUncontrollableEvent("newcevent2"); // by symbolic name

  // Set an existing event controllable

  cgen1.SetControllable(2); // by index
  cgen1.SetControllable((const std::string&) "newcevent2"); // by symbolic name

  // Set an existing event uncontrollable

  cgen1.ClrControllable(1); // by index
  cgen1.ClrControllable((const std::string&) "newcevent1"); // by symbolic name

  // Test wether an event is controllable

  bool bool_eventcontrollable = cgen1.Controllable(1); // by index
  bool_eventcontrollable = cgen1.Controllable("newcevent1"); // by symbolic name

  // Retrieve an EventSet containing all the controllabe events of the
  // cGenerator

  EventSet eset_cevents = cgen2.ControllableEvents();

  // Retrieve an EventSet containing all the uncontrollabe events of the
  // cGenerator

  EventSet eset_ucevents = cgen2.UncontrollableEvents();

  // SIMPLE SYNTHESIS EXAMPLE
 
  // compose plant dynamics from two very simple machines 
  Generator tempgen, machinea, machineb;
  cGenerator cplant; 
 
  tempgen.Read("data/verysimplemachine.gen");
  tempgen.Version("1",machinea);
  tempgen.Version("2",machineb);
  Parallel(machinea,machineb,cplant);

  // declare controllable events
  EventSet contevents;
  contevents.Insert("alpha_1");
  contevents.Insert("alpha_2");
  cplant.SetControllable(contevents);

  // write to file
  cplant.Write("tmp_cplant12.gen");

  // report to console

  std::cout << "################################\n";
  std::cout << "# tutorial, plant model \n";
  cplant.DWrite();
  std::cout << "################################\n";

  // read specification 

  Generator specification;
  specification.Read("data/buffer.gen");
  InvProject(specification,cplant.Alphabet()); // self-loop
  specification.Name("simple machines specification");

  // write to file
  specification.Write("tmp_specification12.gen");

  // report to console

  std::cout << "################################\n";
  std::cout << "# tutorial, specification \n";
  specification.DWrite();
  std::cout << "################################\n";

  // run synthesis algorithm
  
  cGenerator supervisor;
  cSupConNB(cplant,specification,supervisor);
  supervisor.Name("simple machines supervisor");
  supervisor.Write("tmp_supervisor12.gen");

  // report to console

  std::cout << "################################\n";
  std::cout << "# tutorial, supervisor\n";
  supervisor.DWrite();
  std::cout << "################################\n";


  return 0;
}



Definition in file 4_cgenerator.cpp.

#include "libfaudes.h"

Go to the source code of this file.

Functions

int main ()


Function Documentation

int main  ) 
 

Definition at line 34 of file 4_cgenerator.cpp.


Generated on Fri May 9 11:26:47 2008 for libFAUDES 2.09b by  doxygen 1.4.4