diff --git a/org.fortiss.af3.platform.raspberry/trunk/lib/inc/CanConnector.h b/org.fortiss.af3.platform.raspberry/trunk/lib/inc/CanConnector.h index 978d29a9a1960401271f842ec38e34b30025f2bb..c2042c622be595d5b610edbc283a836785d3185b 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/lib/inc/CanConnector.h +++ b/org.fortiss.af3.platform.raspberry/trunk/lib/inc/CanConnector.h @@ -6,7 +6,7 @@ #include "inc-gen/data_dictionary.h" // types -typedef const char* PORT_T; +typedef const char* CAN_PORT_T; // init, terminate, prepare void can_init(); @@ -19,17 +19,17 @@ void prepare_output_CanConnector(); void finish_output_CanConnector(); // noval -GEN_TYPE_boolean can_is_noval(PORT_T port); -GEN_TYPE_boolean can_set_noval(PORT_T port); +GEN_TYPE_boolean can_is_noval(CAN_PORT_T port); +GEN_TYPE_boolean can_set_noval(CAN_PORT_T port); // readers -GEN_TYPE_boolean can_read_bool(PORT_T port); -GEN_TYPE_double can_read_double(PORT_T port); -GEN_TYPE_int can_read_int(PORT_T port); +GEN_TYPE_boolean can_read_bool(CAN_PORT_T port); +GEN_TYPE_double can_read_double(CAN_PORT_T port); +GEN_TYPE_int can_read_int(CAN_PORT_T port); // writers -void can_write_bool(PORT_T port, GEN_TYPE_boolean value); -void can_write_double(PORT_T port, GEN_TYPE_double value); -void can_write_int(PORT_T port, GEN_TYPE_int value); +void can_write_bool(CAN_PORT_T port, GEN_TYPE_boolean value); +void can_write_double(CAN_PORT_T port, GEN_TYPE_double value); +void can_write_int(CAN_PORT_T port, GEN_TYPE_int value); #endif // __CANCONNECTOR_H diff --git a/org.fortiss.af3.platform.raspberry/trunk/lib/inc/GPIO.h b/org.fortiss.af3.platform.raspberry/trunk/lib/inc/GPIO.h index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f3b686b671a445d44547fc905225daba2fff7fbe 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/lib/inc/GPIO.h +++ b/org.fortiss.af3.platform.raspberry/trunk/lib/inc/GPIO.h @@ -0,0 +1,23 @@ +#ifndef __GPIO_H +#define __GPIO_H + +#include "inc-gen/data_dictionary.h" + +// types +typedef int GPIO_PIN_T; + +// init, term +void gpio_init(GPIO_PIN_T pin); +void gpio_term(GPIO_PIN_T pin); + +// noval +GEN_TYPE_boolean gpio_is_noval(GPIO_PIN_T pin); +void gpio_set_noval(GPIO_PIN_T pin); + +// readers +GEN_TYPE_boolean gpio_read(GPIO_PIN_T pin); + +// writers +void gpio_write(GPIO_PIN_T pin, GEN_TYPE_boolean value); + +#endif // __GPIO_H diff --git a/org.fortiss.af3.platform.raspberry/trunk/lib/src/CanConnector.c b/org.fortiss.af3.platform.raspberry/trunk/lib/src/CanConnector.c index d6842f1f3815ceeeab3514322d115db728cff915..42ec3c814dd62f76fd6878ea574d89afaccff451 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/lib/src/CanConnector.c +++ b/org.fortiss.af3.platform.raspberry/trunk/lib/src/CanConnector.c @@ -2,7 +2,7 @@ #include "inc/CanConnector.h" // init, terminate -void can_init(const char* message) { +void can_init() { printf("initializing CAN\n"); } @@ -27,36 +27,37 @@ void finish_output_CanConnector() { } // noval -GEN_TYPE_boolean can_is_noval(PORT_T port) { +GEN_TYPE_boolean can_is_noval(CAN_PORT_T port) { return true; } -GEN_TYPE_boolean can_set_noval(PORT_T port) { +GEN_TYPE_boolean can_set_noval(CAN_PORT_T port) { return true; } // readers -GEN_TYPE_boolean can_read_bool(PORT_T port) { +GEN_TYPE_boolean can_read_bool(CAN_PORT_T port) { return false; } -GEN_TYPE_double can_read_double(PORT_T port) { +GEN_TYPE_double can_read_double(CAN_PORT_T port) { return 0.0; } -GEN_TYPE_int can_read_int(PORT_T port) { +GEN_TYPE_int can_read_int(CAN_PORT_T port) { return 0; } // writers -void can_write_bool(PORT_T port, GEN_TYPE_boolean value) { +void can_write_bool(CAN_PORT_T port, GEN_TYPE_boolean value) { } -void can_write_double(PORT_T port, GEN_TYPE_double value) { +void can_write_double(CAN_PORT_T port, GEN_TYPE_double value) { } -void can_write_int(PORT_T port, GEN_TYPE_int value) { +void can_write_int(CAN_PORT_T port, GEN_TYPE_int value) { } + diff --git a/org.fortiss.af3.platform.raspberry/trunk/lib/src/GPIO.c b/org.fortiss.af3.platform.raspberry/trunk/lib/src/GPIO.c index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2f10a17e4b69ea6ff69f2f28ee4a433c7541770c 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/lib/src/GPIO.c +++ b/org.fortiss.af3.platform.raspberry/trunk/lib/src/GPIO.c @@ -0,0 +1,30 @@ +#include "inc/GPIO.h" + +// init, term +void gpio_init(GPIO_PIN_T pin) { + +} + +void gpio_term(GPIO_PIN_T pin) { + +} + +// noval +GEN_TYPE_boolean gpio_is_noval(GPIO_PIN_T pin) { + return false; +} + +void gpio_set_noval(GPIO_PIN_T pin) { + +} + +// readers +GEN_TYPE_boolean gpio_read(GPIO_PIN_T pin) { + return false; +} + +// writers +void gpio_write(GPIO_PIN_T pin, GEN_TYPE_boolean value) { + +} + diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/GPIExecutable.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/GPIExecutable.java index 9e378c1ca97add98983794a9f2347425d3e8cd94..24fb61a8c1aa26847833bff7e6d2600c54c5ec8d 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/GPIExecutable.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/GPIExecutable.java @@ -17,6 +17,9 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable; +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall; +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.intConst; + import org.fortiss.af3.component.model.InputPort; import org.fortiss.af3.expression.model.terms.IExpressionTerm; import org.fortiss.af3.platform.generic.generator.executable.GenericReceiverExecutable; @@ -43,31 +46,28 @@ public class GPIExecutable extends GenericReceiverExecutable { /** {@inheritDoc} */ @Override public IExpressionTerm getInitialization() { - - // --------------------------------------- - // Example: How to extract PIN information - GPIOPin annotation = AnnotationUtils.getAnnotation(modelElement, GPIOPin.class); - int pinNumber = annotation.getPinNumber(); - // --------------------------------------- - - return super.getInitialization(); + return funcCall("gpio_init", intConst(getPinFromModelElement(modelElement))); } /** {@inheritDoc} */ @Override public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) { - return super.getNoValGuardAccessor(logicalSignal); + return funcCall("gpio_is_noval", intConst(getPinFromModelElement(modelElement))); } /** {@inheritDoc} */ @Override public IExpressionTerm getTermination() { - return super.getTermination(); + return funcCall("gpio_term", intConst(getPinFromModelElement(modelElement))); } /** {@inheritDoc} */ @Override public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) { - return super.getValueReadAccessor(logicalSignal); + return funcCall("gpio_read", intConst(getPinFromModelElement(modelElement))); + } + + private static int getPinFromModelElement(GenericReceiver modelElement) { + return AnnotationUtils.getAnnotation(modelElement, GPIOPin.class).getPinNumber(); } } diff --git a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/GPOExecutable.java b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/GPOExecutable.java index 299463791429845d4d74f91a31f217980ec0705b..137e69aea1f00ff5cfc1e859ab33f2b5cd13afc4 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/GPOExecutable.java +++ b/org.fortiss.af3.platform.raspberry/trunk/src/org/fortiss/af3/platform/raspberry/generator/executable/GPOExecutable.java @@ -17,11 +17,16 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +--------------------------------------------------------------------------*/ package org.fortiss.af3.platform.raspberry.generator.executable; +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall; +import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.intConst; + import org.fortiss.af3.component.model.OutputPort; import org.fortiss.af3.expression.model.terms.IExpressionTerm; import org.fortiss.af3.platform.generic.generator.executable.GenericTransmitterExecutable; +import org.fortiss.af3.platform.model.annotation.GPIOPin; import org.fortiss.af3.platform.model.generic.GenericTransmitter; import org.fortiss.af3.platform.raspberry.model.GPO; +import org.fortiss.tooling.base.utils.AnnotationUtils; /** * Executable for {@link GPO}. @@ -41,24 +46,28 @@ public class GPOExecutable extends GenericTransmitterExecutable { /** {@inheritDoc} */ @Override public IExpressionTerm getInitialization() { - return super.getInitialization(); + return funcCall("gpio_init", intConst(getPinFromModelElement(modelElement))); } /** {@inheritDoc} */ @Override public IExpressionTerm getNoValWriteAccessor(OutputPort logicalSignal) { - return super.getNoValWriteAccessor(logicalSignal); + return funcCall("gpio_set_noval", intConst(getPinFromModelElement(modelElement))); } /** {@inheritDoc} */ @Override public IExpressionTerm getTermination() { - return super.getTermination(); + return funcCall("gpio_term", intConst(getPinFromModelElement(modelElement))); } /** {@inheritDoc} */ @Override public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value) { - return super.getValueWriteAccessor(logicalSignal, value); + return funcCall("gpio_term", intConst(getPinFromModelElement(modelElement)), value); + } + + private static int getPinFromModelElement(GenericTransmitter modelElement) { + return AnnotationUtils.getAnnotation(modelElement, GPIOPin.class).getPinNumber(); } }