From c70ce6aaf1ea2313edd5754c063d866c2aba4975 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 1 Dec 2006 03:56:16 +0000 Subject: [PATCH] Termino de encapsular todo lo que puedo encapsular en el estado en que esta el sistema autonomo. Tambien subo una prueba hecha en breve que usa las cosas encapsuladas (aunque no hace demasiado, pero me garantiza que al menos no tiene errores sintacticos y que "compila"). --- trunk/src/SistemaAutonomo.tz | 41 ++++++++++++++++++++++++++++++++ trunk/src/SistemaAutonomoDemo.tz | 35 +++++++++++++++++++++++++++ trunk/src/plugin.cpp | 4 ++-- 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 trunk/src/SistemaAutonomo.tz create mode 100644 trunk/src/SistemaAutonomoDemo.tz diff --git a/trunk/src/SistemaAutonomo.tz b/trunk/src/SistemaAutonomo.tz new file mode 100644 index 0000000..d3246c8 --- /dev/null +++ b/trunk/src/SistemaAutonomo.tz @@ -0,0 +1,41 @@ +@use Control. + +@plugin "plugin.so" (SAbrFunctions). + +Object : Teoria (aka Teorias) { + + + variables: + ptr (pointer). + + + to init named name (string) with-action action (int) + executed k = 1 (int) succeeded p = 1 (int): + ptr = TeoriaNew(name, action, k, p). + + + to add-dato-inicial name theName (string) value theValue (float): + TeoriaAddDatoInicial(ptr, theName, theValue). + + + to add-dato-final name theName (string) value theValue (float): + TeoriaAddDatoFinal(ptr, theName, theValue). + + - to get-ptr: + return ptr. + + + to destroy: + TeoriaDelete(ptr). +} + +Object : SistemaAutonomo { + + + variables: + ptr (pointer). + + + to init: + ptr = SistemaAutonomoNew(). + + + to add teoria theTeoria (object): + SistemaAutonomoAddTeoria(ptr, (theTeoria get-ptr)). + + + to destroy: + SistemaAutonomoDelete(ptr). +} + diff --git a/trunk/src/SistemaAutonomoDemo.tz b/trunk/src/SistemaAutonomoDemo.tz new file mode 100644 index 0000000..37d3d5a --- /dev/null +++ b/trunk/src/SistemaAutonomoDemo.tz @@ -0,0 +1,35 @@ +@use Control. +@use SistemaAutonomo. + +Controller SistemaAutonomoController. + +Control : SistemaAutonomoController { + + + to init: + teorias (list). + sa (object). + + sa = new SistemaAutonomo. + teorias = 3 new Teorias. + teorias{0} init named "t1" with-action 1. + teorias{1} init named "t2" with-action 2. + teorias{2} init named "t3" with-action 3. + + (teorias{0}) add-dato-inicial name "sensor1" value 10.5. + (teorias{0}) add-dato-inicial name "sensor2" value 0.5. + (teorias{1}) add-dato-inicial name "sensor1" value 0.5. + (teorias{1}) add-dato-inicial name "sensor2" value 10.5. + (teorias{2}) add-dato-inicial name "sensor1" value 5.5. + (teorias{2}) add-dato-inicial name "sensor2" value 5.5. + + sa add teoria (teorias{0}). + sa add teoria (teorias{1}). + sa add teoria (teorias{2}). + + free teorias{0}. + free teorias{1}. + free teorias{2}. + free sa. + +} + diff --git a/trunk/src/plugin.cpp b/trunk/src/plugin.cpp index 383cffc..31d2ce1 100644 --- a/trunk/src/plugin.cpp +++ b/trunk/src/plugin.cpp @@ -17,7 +17,7 @@ int SAbrTeoriaNew(brEval args[], brEval* result, void* data) return EC_OK; } -// void TeoriaAddDatoInicial(pointer{Teoria}, string, double) +// void TeoriaAddDatoInicial(pointer{Teoria}, string, float) int SAbrTeoriaAddDatoInicial(brEval args[], brEval* result, void* data) { CTeoria* t = (CTeoria*) BRPOINTER(args); @@ -25,7 +25,7 @@ int SAbrTeoriaAddDatoInicial(brEval args[], brEval* result, void* data) return EC_OK; } -// void TeoriaAddDatoFinal(pointer{Teoria}, string, double) +// void TeoriaAddDatoFinal(pointer{Teoria}, string, float) int SAbrTeoriaAddDatoFinal(brEval args[], brEval* result, void* data) { CTeoria* t = (CTeoria*) BRPOINTER(args); -- 2.43.0