Skip to content
Snippets Groups Projects
Commit 8d7e5856 authored by Stefan's avatar Stefan
Browse files

Read controlcenter IP/ Port from raspi model

parent 5ef1eb57
No related branches found
No related tags found
1 merge request!1Feature/control center
......@@ -15,11 +15,14 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.extension.controlcenter;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.platform.raspberry.generator.framework.IReadableGeneratorExtension;
import org.fortiss.af3.platform.raspberry.model.controlcenter.ControlCenterDownstreamInput;
/** Executable for controlcenter {@link ControlCenterDownstreamInput}. */
public class ControlCenterDownstreamInputGeneratorExtension extends
DownstreamGeneratorExtensionBase<ControlCenterDownstreamInput> {
ControlcenterGeneratorExtensionBase<ControlCenterDownstreamInput> implements
IReadableGeneratorExtension {
/** Constructor. */
public ControlCenterDownstreamInputGeneratorExtension(ControlCenterDownstreamInput modelElement) {
super(modelElement);
......@@ -27,7 +30,18 @@ public class ControlCenterDownstreamInputGeneratorExtension extends
/** {@inheritDoc} */
@Override
protected String getButtonIdentifier() {
return "ControlCenterDownstreamInput";
public String getReadCode(String postfix, String singletonPostfix, InputPort logicalSignal,
String targetVariable) {
// TODO Auto-generated method stub
// return targetVariable + " = gamepad_get_button_state(" + getButtonIdentifier() + ");\n";
return targetVariable + " = 7891;\n";
}
/** {@inheritDoc} */
@Override
public String
getNoValReadCode(String postfix, String singletonPostfix, InputPort logicalSignal) {
// TODO Auto-generated method stub
return null;
}
}
......@@ -19,6 +19,7 @@ import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.platform.raspberry.generator.extension.library.PiHALLibraryGeneratorExtensionBase;
import org.fortiss.af3.platform.raspberry.generator.framework.ISingletonInitializationGeneratorExtension;
import org.fortiss.af3.platform.raspberry.generator.framework.ISingletonTerminationGeneratorExtension;
import org.fortiss.af3.platform.raspberry.model.impl.RaspberryPiImpl;
/**
* Base class for all executables of the controlcenter .
......@@ -50,11 +51,13 @@ abstract class ControlcenterGeneratorExtensionBase<T extends EObject> extends
@Override
public final String getSingletonInitializationCode(String singletonPostfix) {
// String prefixedVar = "gamepad_config_" + singletonPostfix;
RaspberryPiImpl piimpl = (RaspberryPiImpl)modelElement.eContainer();
StringBuilder sb = new StringBuilder();
sb.append("// initialize the control center configuration\n");
sb.append("af3_cc_activate(\"192.168.178.99\",9999);\n\n");
sb.append("af3_cc_activate(\"" + piimpl.getControlcenterServerAddress() + "\"," +
piimpl.getControlcenterServerPort() + ");\n\n");
return sb.toString();
}
/** {@inheritDoc} */
......
/*-------------------------------------------------------------------------+
| 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.controlcenter;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.platform.raspberry.generator.framework.IReadableGeneratorExtension;
/**
* Base class for executables reading control center downstream.
*
* @author duenhuber
*/
abstract class DownstreamGeneratorExtensionBase<T extends EObject> extends
ControlcenterGeneratorExtensionBase<T> implements IReadableGeneratorExtension {
/** Constructor. */
public DownstreamGeneratorExtensionBase(T modelElement) {
super(modelElement);
}
/** {@inheritDoc} */
@Override
public final String getReadCode(String postfix, String singletonPostfix,
InputPort logicalSignal, String targetVariable) {
// TODO call receive variable
// return targetVariable + " = gamepad_get_button_state(" + getButtonIdentifier() + ");\n";
return targetVariable + " = 1;\n";
}
/** {@inheritDoc} */
@Override
public final String getNoValReadCode(String postfix, String singletonPostfix,
InputPort logicalSignal) {
return null;
}
/** Returns the button identifier as defined in {@code controlcenter.h}. */
protected abstract String getButtonIdentifier();
}
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