From 12e811ab5d21ac87b82293c5699e46b1b316fe13 Mon Sep 17 00:00:00 2001
From: Helge Brueger <noreply@fortiss.org>
Date: Mon, 5 Jun 2017 22:51:23 +0000
Subject: [PATCH] Added empty functions for GPIO refs 7890

---
 .../trunk/lib/inc/CanConnector.h              | 18 +++++------
 .../trunk/lib/inc/GPIO.h                      | 23 ++++++++++++++
 .../trunk/lib/src/CanConnector.c              | 19 ++++++------
 .../trunk/lib/src/GPIO.c                      | 30 +++++++++++++++++++
 .../generator/executable/GPIExecutable.java   | 22 +++++++-------
 .../generator/executable/GPOExecutable.java   | 17 ++++++++---
 6 files changed, 96 insertions(+), 33 deletions(-)

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 978d29a9..c2042c62 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 e69de29b..f3b686b6 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 d6842f1f..42ec3c81 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 e69de29b..2f10a17e 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 9e378c1c..24fb61a8 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 29946379..137e69ae 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();
 	}
 }
-- 
GitLab