Skip to content
Snippets Groups Projects
Commit 4cd92151 authored by Stefan's avatar Stefan
Browse files

Beginn V2V code generation implementation


add example implementation for Platoon Message Input and Platoon Message
output

Add AF3 test program ...V2V.af3_23

Signed-off-by: default avatarStefan <stefan.duenhuber@gmail.com>
parent 6ce9e049
No related branches found
No related tags found
1 merge request!1Feature/control center
Showing
with 716 additions and 3 deletions
#include "v2v_udp_basic.h"
#include "af3_v2v.h"
#include "v2v_message_types.h"
#include "v2v_message_handlers.h"
......@@ -830,6 +830,34 @@
</objectClass>
</target>
</transformationProvider>
<transformationProvider
transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.v2v.V2VPlatoonOutputTransformation">
<source>
<objectClass
objectClass="org.fortiss.af3.platform.raspberry.model.v2v.V2VPlatoonOutput">
</objectClass>
</source>
<target>
<objectClass
objectClass="org.fortiss.af3.platform.raspberry.generator.extension.v2v.V2VPlatoonOutputGeneratorExtension">
</objectClass>
</target>
</transformationProvider>
<transformationProvider
transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.v2v.V2VPlatoonInputTransformation">
<source>
<objectClass
objectClass="org.fortiss.af3.platform.raspberry.model.v2v.V2VPlatoonInput">
</objectClass>
</source>
<target>
<objectClass
objectClass="org.fortiss.af3.platform.raspberry.generator.extension.v2v.V2VPlatoonInputGeneratorExtension">
</objectClass>
</target>
</transformationProvider>
</extension>
</plugin>
......@@ -34,8 +34,6 @@ public class ControlCenterDownstreamInputGeneratorExtension extends
/** {@inheritDoc} */
@Override
public String getReadCode(InputPort logicalSignal, String targetVariable) {
// TODO add NoVal Parameter to getVariable
String portInputName = modelElement.getName();
// get the value depending on the logical signal data type
if(logicalSignal.getVariableType() instanceof TDouble) {
return "af3_cc_get_double(\"" + modelElement.getName() + "\" , " + "&" +
......@@ -48,7 +46,7 @@ public class ControlCenterDownstreamInputGeneratorExtension extends
", &noval_" + targetVariable + " );\n";
} else {
return "FIXME(\"Data type " + logicalSignal.getVariableType() + " of Port " +
portInputName + " not supported for control centert.\");\n";
modelElement.getName() + " not supported for control centert.\");\n";
}
}
......
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.extension.v2v;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.platform.raspberry.generator.extension.library.PiHALLibraryGeneratorExtensionBase;
/**
* Base class for all executables of the controlcenter .
*
* @author duenhuber
*/
abstract class V2VGeneratorExtensionBase<T extends EObject> extends
PiHALLibraryGeneratorExtensionBase<T> {
/** Constructor. */
public V2VGeneratorExtensionBase(T modelElement) {
super(modelElement);
}
/** {@inheritDoc} */
@Override
public final String getSingletonVariableDeclarationCode() {
// no declartion needed yet
return null;
}
/** {@inheritDoc} */
@Override
public final String getSingletonAuxiliaryFunctions() {
return null;
}
/** {@inheritDoc} */
@Override
public final String getSingletonInitializationCode() {
// get model
// RaspberryPiImpl piimpl = (RaspberryPiImpl)modelElement.eContainer();
// build string
StringBuilder sb = new StringBuilder();
sb.append("// initialize the v2v communicaton\n");
// sb.append("af3_module_initialize(\"" + piimpl.getName() + "\", 0, NULL, NULL );\n");
// sb.append("af3_cc_activate(\"" + piimpl.getControlcenterServerAddress() + "\"," +
// piimpl.getControlcenterServerPort() + ");\n\n");
return sb.toString();
}
/** {@inheritDoc} */
@Override
public final String getSingletonTerminationCode() {
return "af3_v2v_deactivate();\n";
}
/** {@inheritDoc} */
@Override
public final String getSingletonIdentifier() {
// use header file as singleton identifier
return getHeaderFileName();
}
/** {@inheritDoc} */
@Override
public final String getHeaderFileName() {
return "v2v.h";
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.extension.v2v;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.platform.raspberry.generator.framework.IReadableGeneratorExtension;
import org.fortiss.af3.platform.raspberry.model.v2v.V2VPlatoonInput;
/** Executable for v2v communication {@link V2VPlatoonInput}. */
public class V2VPlatoonInputGeneratorExtension extends V2VGeneratorExtensionBase<V2VPlatoonInput>
implements IReadableGeneratorExtension {
/** Constructor. */
public V2VPlatoonInputGeneratorExtension(V2VPlatoonInput modelElement) {
super(modelElement);
}
/** {@inheritDoc} */
@Override
public String getReadCode(InputPort logicalSignal, String targetVariable) {
// TODO Auto-generated method stub
return "//V2 Platoon Input";
}
/** {@inheritDoc} */
@Override
public String getNoValReadCode(InputPort logicalSignal) {
// TODO Auto-generated method stub
return null;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.extension.v2v;
import org.fortiss.af3.component.model.OutputPort;
import org.fortiss.af3.platform.raspberry.generator.framework.IWriteableGeneratorExtension;
import org.fortiss.af3.platform.raspberry.model.v2v.V2VPlatoonOutput;
/** Executable for controlcenter {@link V2VPlatoonOutput}. */
public class V2VPlatoonOutputGeneratorExtension extends V2VGeneratorExtensionBase<V2VPlatoonOutput>
implements IWriteableGeneratorExtension {
/** Constructor. */
public V2VPlatoonOutputGeneratorExtension(V2VPlatoonOutput modelElement) {
super(modelElement);
}
/** {@inheritDoc} */
@Override
public String getWriteCode(OutputPort logicalSignal, String value) {
return "af3_v2v_send_msg(V2V_MSG_TYPE_PLATOON, (uint8_t*) &" + value + " ) ;\n";
}
/** {@inheritDoc} */
@Override
public String getNoValWriteCode(OutputPort logicalSignal) {
// return "af3_cc_send_noval(\"" + logicalSignal.getName() +
// "\" , local_logical_clock );\n";
return null;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.transform.v2v;
import org.fortiss.af3.platform.raspberry.generator.extension.v2v.V2VPlatoonInputGeneratorExtension;
import org.fortiss.af3.platform.raspberry.generator.transform.RasPiGeneratorTransformationBase;
import org.fortiss.af3.platform.raspberry.model.v2v.V2VPlatoonInput;
/** Transformation for {@link V2VPlatoonInput}. */
public class V2VPlatoonInputTransformation extends RasPiGeneratorTransformationBase {
/** Constructor. */
public V2VPlatoonInputTransformation() {
super(V2VPlatoonInput.class, V2VPlatoonInputGeneratorExtension.class);
}
}
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.transform.v2v;
import org.fortiss.af3.platform.raspberry.generator.extension.v2v.V2VPlatoonOutputGeneratorExtension;
import org.fortiss.af3.platform.raspberry.generator.transform.RasPiGeneratorTransformationBase;
import org.fortiss.af3.platform.raspberry.model.v2v.V2VPlatoonOutput;
/** Transformation for {@link V2VPlatoonOutput}. */
public class V2VPlatoonOutputTransformation extends RasPiGeneratorTransformationBase {
/** Constructor. */
public V2VPlatoonOutputTransformation() {
super(V2VPlatoonOutput.class, V2VPlatoonOutputGeneratorExtension.class);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment