Skip to content
Snippets Groups Projects
Commit e9d8d5cf authored by Zabir Haider Khan's avatar Zabir Haider Khan
Browse files

No commit message

No commit message
parent 7c04e00a
No related branches found
No related tags found
No related merge requests found
Showing
with 507 additions and 78 deletions
......@@ -21,12 +21,13 @@ import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.fun
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation;
import org.fortiss.af3.component.model.OutputPort;
import org.fortiss.af3.deployment.model.Deployment;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
import org.fortiss.af3.expression.utils.ExpressionModelElementFactory;
import org.fortiss.af3.platform.language.executable.IInitializableExecutable;
import org.fortiss.af3.platform.language.executable.ITerminatableExecutable;
import org.fortiss.af3.platform.language.executable.IWritableExecutableWithNoValSupport;
import org.fortiss.af3.platform.language.executable.TransmitterExecutableBase;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.ITermExecutable;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.IWriteExecutableWithNoValSupport;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.InitExecutable;
import org.fortiss.af3.platform.raspberry.model.ActuatorOut;
import org.fortiss.af3.platform.raspberry.model.annotation.PinNumber;
......@@ -38,7 +39,7 @@ import org.fortiss.af3.platform.raspberry.model.annotation.PinNumber;
* @ConQAT.Rating RED Hash:
*/
public class ActuatorOutExecutable extends TransmitterExecutableBase<ActuatorOut> implements
IInitializableExecutable, ITerminatableExecutable, IWritableExecutableWithNoValSupport {
InitExecutable, ITermExecutable, IWriteExecutableWithNoValSupport {
/**
* @param modelElement
......@@ -51,13 +52,13 @@ public class ActuatorOutExecutable extends TransmitterExecutableBase<ActuatorOut
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization() {
return funcCall("init_" + modelElement.getName());
return funcCall("init_Actuator");// + modelElement.getName()
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getTermination() {
return funcCall("term_" + modelElement.getName());
return funcCall("term_Actuator");
}
/** {@inheritDoc} */
......@@ -72,7 +73,52 @@ public class ActuatorOutExecutable extends TransmitterExecutableBase<ActuatorOut
/** {@inheritDoc} */
@Override
public IExpressionTerm getNoValWriteAccessor(OutputPort logicalSignal) {
return funcCall("set_noval_" + modelElement.getName());
return funcCall("set_noval_Actuator");
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value,
Deployment depl) {
PinNumber ias = getAnnotation(modelElement, PinNumber.class);
int pinNr = ias.getPinNumber();
return funcCall("write_Actuator", ExpressionModelElementFactory.createVar(pinNr + ""));
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getTermination(IExpressionTerm signal) {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getTermination(Deployment depl) {
// TODO Auto-generated method stub
return funcCall("term_Actuator");
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization(IExpressionTerm term) {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization(IExpressionTerm port, IExpressionTerm portName,
IExpressionTerm readOrWrite) {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization(Deployment depl) {
// TODO Auto-generated method stub
return funcCall("init_Actuator");
}
}
......@@ -17,17 +17,25 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.executable;
import static org.fortiss.af3.deployment.utils.DeploymentUtils.findECUforDeployedComponent;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.component.model.Channel;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.component.model.OutputPort;
import org.fortiss.af3.deployment.model.Deployment;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
import org.fortiss.af3.expression.utils.ExpressionModelElementFactory;
import org.fortiss.af3.platform.language.executable.IInitializableExecutable;
import org.fortiss.af3.platform.language.executable.IReadableExecutableWithNoValSupport;
import org.fortiss.af3.platform.language.executable.ITerminatableExecutable;
import org.fortiss.af3.platform.language.executable.IWritableExecutableWithNoValSupport;
import org.fortiss.af3.platform.language.executable.TransceiverExecutableBase;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.IPlatformArchitectureElement;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.IReadExecutableWithNoValSupport;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.ITermExecutable;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.IWriteExecutableWithNoValSupport;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.InitExecutable;
import org.fortiss.af3.platform.raspberry.model.BusMasterPort;
import org.fortiss.af3.platform.raspberry.model.annotation.CoreAddress;
......@@ -39,8 +47,8 @@ import org.fortiss.af3.platform.raspberry.model.annotation.CoreAddress;
* @ConQAT.Rating RED Hash:
*/
public class BusMasterPortExecutable extends TransceiverExecutableBase<BusMasterPort> implements
IInitializableExecutable, ITerminatableExecutable, IReadableExecutableWithNoValSupport,
IWritableExecutableWithNoValSupport {
InitExecutable, ITermExecutable, IReadExecutableWithNoValSupport,
IWriteExecutableWithNoValSupport {
/**
* @param modelElement
......@@ -52,46 +60,151 @@ public class BusMasterPortExecutable extends TransceiverExecutableBase<BusMaster
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization() {
return funcCall("init_" + modelElement.getName());
public IExpressionTerm getInitialization(Deployment depl) {
int coreId = getParentCoreId(depl);
return funcCall("init_" + modelElement.getName(),
ExpressionModelElementFactory.createVar(coreId + ""));
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getTermination() {
return funcCall("term_" + modelElement.getName());
public IExpressionTerm getTermination(Deployment depl) {
int coreId = getParentCoreId(depl);
return funcCall("term_" + modelElement.getName(),
ExpressionModelElementFactory.createVar(coreId + ""));
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value) {
return funcCall("write_" + modelElement.getName() + "_" + logicalSignal.getName(), value);
public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value,
Deployment depl) {
int coreAddress = getTargetCoreAddress(logicalSignal, depl);
return funcCall("write_" + modelElement.getName(),
ExpressionModelElementFactory.createVar(coreAddress + ""),
ExpressionModelElementFactory.createVar(logicalSignal.getName() + ""));
// return funcCall("write_" + modelElement.getName(), value);
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) {
CoreAddress ias =
org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation(
modelElement.getPlatformElement(), CoreAddress.class);
public IExpressionTerm getValueReadAccessor(InputPort logicalSignal, Deployment depl) {
int coreAddress = getSourceCoreAddress(logicalSignal, depl);
int coreAddress = ias.getCoreAddress();
// return funcCall("read_" + modelElement.getName() + "_" + logicalSignal.getName());
return funcCall("read_" + modelElement.getName(),
ExpressionModelElementFactory.createVar(coreAddress + ""));
ExpressionModelElementFactory.createVar(coreAddress + ""),
ExpressionModelElementFactory.createVar(logicalSignal.getName() + ""));
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getNoValWriteAccessor(OutputPort logicalSignal) {
return funcCall("set_noval_" + modelElement.getName() + "_" + logicalSignal.getName());
return funcCall("set_noval_" + modelElement.getName());// + "_" + logicalSignal.getName()
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) {
return funcCall("is_noval_" + modelElement.getName() + "_" + logicalSignal.getName());
return funcCall("is_noval_" + modelElement.getName());// + "_" + logicalSignal.getName()
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getValueReadAccessor(InputPort logicalSignal) {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getNoValGuardAccessor(IExpressionTerm signal, IExpressionTerm buffer) {
// TODO Auto-generated method stub
return null;
}
/**
* @param logicalSignal
* @return
* returns core ID
*/
private int getSourceCoreAddress(InputPort logicalSignal, Deployment depl) {
EList<Channel> channels = logicalSignal.getIncomingChannels();
// get one of the channels, usually only one channel will be connected per input port
Component sourceComponent = channels.get(0).getSource().getComponent();
ExecutionUnit sourceCore = findECUforDeployedComponent(sourceComponent, depl);
CoreAddress ias = getAnnotation(sourceCore, CoreAddress.class);
return ias.getCoreAddress();// sourceCore.getId();
}
/**
* @param logicalSignal
* @return
* returns core ID
*/
private int getTargetCoreAddress(OutputPort logicalSignal, Deployment depl) {
EList<Channel> channels = logicalSignal.getOutgoingChannels();
// get one of the channels, usually only one channel will be connected per output port
Component targetComponent = channels.get(0).getTarget().getComponent();
ExecutionUnit targetCore = findECUforDeployedComponent(targetComponent, depl);
CoreAddress ias = getAnnotation(targetCore, CoreAddress.class);
return ias.getCoreAddress();
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value) {
// TODO Auto-generated method stub
return null;
}
/**
* @param depl
* @return
* returns parent core ID
*/
private int getParentCoreId(Deployment depl) {
IPlatformArchitectureElement parentElement = modelElement.getPlatformElement();
CoreAddress ias = getAnnotation(parentElement, CoreAddress.class);
return ias.getCoreAddress();
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getTermination() {
// TODO Auto-generated method stub
return funcCall("term_" + modelElement.getName());
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization() {
// TODO Auto-generated method stub
return funcCall("init_" + modelElement.getName());
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getTermination(IExpressionTerm signal) {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization(IExpressionTerm term) {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization(IExpressionTerm port, IExpressionTerm portName,
IExpressionTerm readOrWrite) {
// TODO Auto-generated method stub
return null;
}
}
......@@ -55,6 +55,8 @@ import org.fortiss.af3.component.model.Port;
import org.fortiss.af3.component.model.generator.ComponentFunction;
import org.fortiss.af3.component.model.generator.ComponentProgram;
import org.fortiss.af3.component.model.generator.LocalFunction;
import org.fortiss.af3.deployment.generator.DeploymentExecutableTransformationContext;
import org.fortiss.af3.deployment.model.Deployment;
import org.fortiss.af3.expression.model.DataDictionary;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
import org.fortiss.af3.expression.model.terms.imperative.Assignment;
......@@ -68,18 +70,18 @@ import org.fortiss.af3.generator.common.model.source.StaticContentSourceUnit;
import org.fortiss.af3.platform.AF3PlatformActivator;
import org.fortiss.af3.platform.language.executable.ExecutableBase;
import org.fortiss.af3.platform.language.executable.ExecutionUnitExecutableBase;
import org.fortiss.af3.platform.language.executable.IInitializableExecutable;
import org.fortiss.af3.platform.language.executable.IReadableExecutable;
import org.fortiss.af3.platform.language.executable.IReadableExecutableWithNoValSupport;
import org.fortiss.af3.platform.language.executable.ITerminatableExecutable;
import org.fortiss.af3.platform.language.executable.IWritableExecutable;
import org.fortiss.af3.platform.language.executable.IWritableExecutableWithNoValSupport;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.platform.model.GenericPlatformUnit;
import org.fortiss.af3.platform.model.PlatformConnectorUnit;
import org.fortiss.af3.platform.model.generic.GenericReceiver;
import org.fortiss.af3.platform.model.generic.GenericTransceiver;
import org.fortiss.af3.platform.model.generic.GenericTransmitter;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.IReadExecutable;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.IReadExecutableWithNoValSupport;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.ITermExecutable;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.IWriteExecutable;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.IWriteExecutableWithNoValSupport;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.InitExecutable;
import org.fortiss.af3.platform.raspberry.model.Core;
import org.fortiss.af3.platform.raspberry.templates.RaspberryTemplateLoader;
import org.fortiss.tooling.kernel.extension.data.ITransformationContext;
......@@ -147,12 +149,17 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
// createReadInputFunction(deployedPorts, usedTransceivers, deployedComponents));
// Create the system functions.
ComponentFunction init = createInitializeFunction(deployedComponents, usedUnits);
DeploymentExecutableTransformationContext depctx =
(DeploymentExecutableTransformationContext)context;
Deployment depl = depctx.getDeploymentExecutable().getDeployment();
ComponentFunction init = createInitializeFunction(deployedComponents, usedUnits, depl);
ComponentFunction step =
createStepFunction(deployedComponents, deployedPorts, usedTransceivers);
createStepFunction(deployedComponents, deployedPorts, usedTransceivers, depl);
ComponentProgram program = createComponentProgram("system", init, step);
program.getLocalFunctions().add(createTerminationFunction(usedUnits));
program.getLocalFunctions().add(createReadInputFunction(deployedPorts, usedTransceivers));
program.getLocalFunctions().add(createTerminationFunction(usedUnits, depl));
program.getLocalFunctions().add(
createReadInputFunction(deployedPorts, usedTransceivers, depl));
program.getLocalFunctions().add(createMainFunction());
// Fill the system program with the component sub-programs
try {
......@@ -225,7 +232,7 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
/** Creates the initialize function. */
protected ComponentFunction createInitializeFunction(
List<Pair<ExecutionUnit, Component>> deployedComponents,
Set<PlatformConnectorUnit> usedUnits) {
Set<PlatformConnectorUnit> usedUnits, Deployment depl) {
List<IStatementTerm> body = new ArrayList<IStatementTerm>();
for(Pair<ExecutionUnit, Component> p : deployedComponents) {
body.add(assignment(funcCall(getInitializeFunctionName(p.getSecond()))));
......@@ -234,21 +241,22 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
for(PlatformConnectorUnit pu : usedUnits) {
ExecutableBase<? extends PlatformConnectorUnit> exec =
getPlatformArchitectureExecutable().getExecutable(pu);
if(exec instanceof IInitializableExecutable) {
body.add(assignment(((IInitializableExecutable)exec).getInitialization()));
if(exec instanceof InitExecutable) {
body.add(assignment(((InitExecutable)exec).getInitialization(depl)));
}
}
return createComponentFunction("initialize_system", null, sequence(body));
}
/** Creates the termination function. */
protected LocalFunction createTerminationFunction(Set<PlatformConnectorUnit> usedUnits) {
protected LocalFunction createTerminationFunction(Set<PlatformConnectorUnit> usedUnits,
Deployment depl) {
List<IStatementTerm> body = new ArrayList<IStatementTerm>();
for(PlatformConnectorUnit pu : usedUnits) {
ExecutableBase<? extends PlatformConnectorUnit> exec =
getPlatformArchitectureExecutable().getExecutable(pu);
if(exec instanceof ITerminatableExecutable) {
body.add(assignment(((ITerminatableExecutable)exec).getTermination()));
if(exec instanceof ITermExecutable) {
body.add(assignment(((ITermExecutable)exec).getTermination(depl)));
}
}
return createLocalFunction("terminate_system", null, sequence(body));
......@@ -258,7 +266,7 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
protected ComponentFunction createStepFunction(
List<Pair<ExecutionUnit, Component>> deployedComponents,
List<Pair<PlatformConnectorUnit, Port>> deployedPorts,
Set<GenericTransceiver> usedTransceivers) {
Set<GenericTransceiver> usedTransceivers, Deployment depl) {
List<IStatementTerm> body = new ArrayList<IStatementTerm>();
// Search for local channels, i.e. channels that begin and end at components deployed to
......@@ -285,11 +293,11 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
for(Pair<ExecutionUnit, Component> p : deployedComponents) {
Component comp = p.getSecond();
if(comp.getSubComponents().isEmpty() && comp.isStronglyCausal()) {
writeOutputsForComponent(comp, deployedPorts, body);
writeOutputsForComponent(comp, deployedPorts, body, depl);
}
body.add(assignment(funcCall(getPerformStepFunctionName(p.getSecond()))));
if(!comp.getSubComponents().isEmpty() || !comp.isStronglyCausal()) {
writeOutputsForComponent(comp, deployedPorts, body);
writeOutputsForComponent(comp, deployedPorts, body, depl);
}
}
// Notify transceivers about end of output writing.
......@@ -304,7 +312,8 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
* @param body
*/
private void writeOutputsForComponent(Component comp,
List<Pair<PlatformConnectorUnit, Port>> deployedPorts, List<IStatementTerm> body) {
List<Pair<PlatformConnectorUnit, Port>> deployedPorts, List<IStatementTerm> body,
Deployment depl) {
// Write outputs to transmitter and transceivers.
for(Pair<PlatformConnectorUnit, Port> p : deployedPorts) {
if(p.getSecond().getComponent() != comp) {
......@@ -312,8 +321,8 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
}
ExecutableBase<? extends PlatformConnectorUnit> exec =
getPlatformArchitectureExecutable().getExecutable(p.getFirst());
if(exec instanceof IWritableExecutable && p.getSecond() instanceof OutputPort) {
createWriteAccess((IWritableExecutable)exec, (OutputPort)p.getSecond(), body);
if(exec instanceof IWriteExecutable && p.getSecond() instanceof OutputPort) {
createWriteAccess((IWriteExecutable)exec, (OutputPort)p.getSecond(), body, depl);
}
}
}
......@@ -340,7 +349,7 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
/** Creates the read input function. */
protected LocalFunction createReadInputFunction(
List<Pair<PlatformConnectorUnit, Port>> deployedPorts,
Set<GenericTransceiver> usedTransceivers) {
Set<GenericTransceiver> usedTransceivers, Deployment depl) {
List<IStatementTerm> body = new ArrayList<IStatementTerm>();
// Notify transceivers about start input reading.
for(GenericTransceiver gt : usedTransceivers) {
......@@ -350,8 +359,8 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
for(Pair<PlatformConnectorUnit, Port> p : deployedPorts) {
ExecutableBase<? extends PlatformConnectorUnit> exec =
getPlatformArchitectureExecutable().getExecutable(p.getFirst());
if(exec instanceof IReadableExecutable && p.getSecond() instanceof InputPort) {
createReadAccess((IReadableExecutable)exec, (InputPort)p.getSecond(), body);
if(exec instanceof IReadExecutable && p.getSecond() instanceof InputPort) {
createReadAccess((IReadExecutable)exec, (InputPort)p.getSecond(), body, depl);
}
}
// Notify transceivers about end of input reading.
......@@ -362,12 +371,12 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
}
/** Creates the read code for the given executable and port */
protected void
createReadAccess(IReadableExecutable exec, InputPort p, List<IStatementTerm> body) {
IStatementTerm valueAssign = getPortValueAssignment(p, exec.getValueReadAccessor(p));
if(exec instanceof IReadableExecutableWithNoValSupport) {
protected void createReadAccess(IReadExecutable exec, InputPort p, List<IStatementTerm> body,
Deployment depl) {
IStatementTerm valueAssign = getPortValueAssignment(p, exec.getValueReadAccessor(p, depl));
if(exec instanceof IReadExecutableWithNoValSupport) {
IExpressionTerm guard =
((IReadableExecutableWithNoValSupport)exec).getNoValGuardAccessor(p);
((IReadExecutableWithNoValSupport)exec).getNoValGuardAccessor(p);
StatementSequence thenBlock = sequence(getPortNoValAssignment(p));
StatementSequence elseBlock = sequence(valueAssign);
body.add(ifthenelse(guard, thenBlock, elseBlock));
......@@ -377,13 +386,13 @@ public class CoreExecutable extends ExecutionUnitExecutableBase<Core, CSourcePac
}
/** Creates the write code for the given executable and port. */
protected void createWriteAccess(IWritableExecutable exec, OutputPort p,
List<IStatementTerm> body) {
Assignment valueAssign = assignment(exec.getValueWriteAccessor(p, getPortValue(p)));
if(exec instanceof IWritableExecutableWithNoValSupport) {
protected void createWriteAccess(IWriteExecutable exec, OutputPort p,
List<IStatementTerm> body, Deployment depl) {
Assignment valueAssign = assignment(exec.getValueWriteAccessor(p, getPortValue(p), depl));
if(exec instanceof IWriteExecutableWithNoValSupport) {
IExpressionTerm guard = testPortVariableForNoVal(p);
Assignment thenBlock =
assignment(((IWritableExecutableWithNoValSupport)exec).getNoValWriteAccessor(p));
assignment(((IWriteExecutableWithNoValSupport)exec).getNoValWriteAccessor(p));
body.add(ifthenelse(guard, sequence(thenBlock), sequence(valueAssign)));
} else {
body.add(valueAssign);
......
......@@ -21,12 +21,13 @@ import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.fun
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.deployment.model.Deployment;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
import org.fortiss.af3.expression.utils.ExpressionModelElementFactory;
import org.fortiss.af3.platform.language.executable.IInitializableExecutable;
import org.fortiss.af3.platform.language.executable.IReadableExecutableWithNoValSupport;
import org.fortiss.af3.platform.language.executable.ITerminatableExecutable;
import org.fortiss.af3.platform.language.executable.ReceiverExecutableBase;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.IReadExecutableWithNoValSupport;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.ITermExecutable;
import org.fortiss.af3.platform.raspberry.generator.executable.interfaces.InitExecutable;
import org.fortiss.af3.platform.raspberry.model.SensorIn;
import org.fortiss.af3.platform.raspberry.model.annotation.PinNumber;
......@@ -37,8 +38,8 @@ import org.fortiss.af3.platform.raspberry.model.annotation.PinNumber;
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public class SensorInExecutable extends ReceiverExecutableBase<SensorIn> implements
IInitializableExecutable, ITerminatableExecutable, IReadableExecutableWithNoValSupport {
public class SensorInExecutable extends ReceiverExecutableBase<SensorIn> implements InitExecutable,
ITermExecutable, IReadExecutableWithNoValSupport {
/**
* @param modelElement
......@@ -48,21 +49,16 @@ public class SensorInExecutable extends ReceiverExecutableBase<SensorIn> impleme
// TODO Auto-generated constructor stub
}
// @Override
// public IExpressionTerm getValueReadAccessor(IExpressionTerm signal, IExpressionTerm buffer) {
// return funcCall("read_gpio", signal, buffer);
// }
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization() {
return funcCall("init_" + modelElement.getName());
return funcCall("init_Sensor");// + modelElement.getName()
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getTermination() {
return funcCall("term_" + modelElement.getName());
return funcCall("term_Sensor");
}
/** {@inheritDoc} */
......@@ -71,13 +67,64 @@ public class SensorInExecutable extends ReceiverExecutableBase<SensorIn> impleme
PinNumber ias = getAnnotation(modelElement, PinNumber.class);
int pinNr = ias.getPinNumber();
return funcCall("read_Sensor",// + modelElement.getName()
ExpressionModelElementFactory.createVar(pinNr + ""));
return funcCall("read_Sensor", ExpressionModelElementFactory.createVar(pinNr + ""));
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) {
return funcCall("is_noval_" + modelElement.getName());
return funcCall("is_noval_Sensor");
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getValueReadAccessor(InputPort logicalSignal, Deployment depl) {
PinNumber ias = getAnnotation(modelElement, PinNumber.class);
int pinNr = ias.getPinNumber();
return funcCall("read_Sensor", ExpressionModelElementFactory.createVar(pinNr + ""));
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getNoValGuardAccessor(IExpressionTerm signal, IExpressionTerm buffer) {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getTermination(IExpressionTerm signal) {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getTermination(Deployment depl) {
// TODO Auto-generated method stub
return funcCall("term_Sensor");
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization(IExpressionTerm term) {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization(IExpressionTerm port, IExpressionTerm portName,
IExpressionTerm readOrWrite) {
// TODO Auto-generated method stub
return null;
}
/** {@inheritDoc} */
@Override
public IExpressionTerm getInitialization(Deployment depl) {
// TODO Auto-generated method stub
return funcCall("init_Sensor");
}
}
package org.fortiss.af3.platform.raspberry.generator.executable.interfaces;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.deployment.model.Deployment;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
/**
* Interface for platform-specific executables, which support reading of a
* non-null value.
*
* @author zverlov
* @author $Author: zverlov $
* @version $Rev: 3134 $
* @ConQAT.Rating GREEN Hash: 9FCAD4E527DAF1B2A47B5FB0B252F468
*/
public interface IReadExecutable {
/**
* Returns a read access term to this executable for the given port's value.
*/
IExpressionTerm getValueReadAccessor(InputPort logicalSignal, Deployment depl);
}
package org.fortiss.af3.platform.raspberry.generator.executable.interfaces;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
/**
* Interface for platform-specific executables, which also support reading of <code>null</code>
* values.
*
* @author zverlov
* @author $Author: zverlov $
* @version $Rev: 5274 $
* @ConQAT.Rating GREEN Hash: C508B83AB8E3F78306F62115213C7B5B
*/
public interface IReadExecutableWithNoValSupport extends IReadExecutable {
/**
* Returns the read access term to the platform-specific executable's <code>null</code> value
* guard.
*/
IExpressionTerm getNoValGuardAccessor(IExpressionTerm signal, IExpressionTerm buffer);
/**
* @param p
* @return
*/
IExpressionTerm getNoValGuardAccessor(InputPort p);
}
package org.fortiss.af3.platform.raspberry.generator.executable.interfaces;
import org.fortiss.af3.deployment.model.Deployment;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
/**
* Interface implemented by platform-specific executables, which need
* termination when system goes down.
*
* @author zverlov
* @author $Author: zverlov $
* @version $Rev: 4114 $
* @ConQAT.Rating GREEN Hash: 9CD3B3AB64293053C6EE40AEED83A686
*/
public interface ITermExecutable {
/**
* Returns an termination term of the platform-specific executable. Usually
* a function call to the hardware abstraction layer is returned here.
*/
public abstract IExpressionTerm getTermination(IExpressionTerm signal);
/**
* @param depl
* @return
*/
IExpressionTerm getTermination(Deployment depl);
/**
* @return
*/
IExpressionTerm getTermination();
}
package org.fortiss.af3.platform.raspberry.generator.executable.interfaces;
import org.fortiss.af3.component.model.OutputPort;
import org.fortiss.af3.deployment.model.Deployment;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
/**
* Interface for platform-specific executables, which support writing of a
* non-null value.
*
* @author zverlov
* @author $Author: zverlov $
* @version $Rev: 5274 $
* @ConQAT.Rating YELLOW Hash: 5F918B896286A3F5A3B240C3917B2A45
*/
public interface IWriteExecutable {
/**
* Returns a write access term to this executable for the given value and
* output port.
*/
/* IExpressionTerm getValueWriteAccessor(IExpressionTerm signal, IExpressionTerm port); */
/**
* Returns a Write Accessor.
*/
/*
* IExpressionTerm getValueWriteAccessor(IExpressionTerm signal, IExpressionTerm port,
* IExpressionTerm pin, ActuatorType_t actuatorType);
*/
/**
* @param logicalSignal
* @param value
* @param depl
* @return
*/
IExpressionTerm getValueWriteAccessor(OutputPort logicalSignal, IExpressionTerm value,
Deployment depl);
}
package org.fortiss.af3.platform.raspberry.generator.executable.interfaces;
import org.fortiss.af3.component.model.OutputPort;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
/**
* Interface for platform-specific executables, which also support writing of <code>null</code>
* values.
*
* @author zverlov
* @author $Author: zverlov $
* @version $Rev: 5274 $
* @ConQAT.Rating GREEN Hash: EE592DF39E033B60DBBFC8EF071A43C3
*/
public interface IWriteExecutableWithNoValSupport extends IWriteExecutable {
/**
* Returns a write access term to this executable for the given output port.
*/
IExpressionTerm getNoValWriteAccessor(OutputPort p);
}
/*--------------------------------------------------------------------------+
$Id: PikeosPartitionExecutable.java 10808 2014-05-27 09:00:26Z zverlov $
| |
| Copyright 2014 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.executable.interfaces;
import org.fortiss.af3.deployment.model.Deployment;
import org.fortiss.af3.expression.model.terms.IExpressionTerm;
/**
* Interface implemented by platform-specific executables, which need
* initialization during system start-up.
*
* @author chaudhary
* @author $Author: chaudhary $
* @version $Rev: 10810 $
* @ConQAT.Rating GREEN Hash: E1C77D8E8AD1D2AA9F058E3034D6B88E
*/
public interface InitExecutable {
/**
* Returns the expression term for ports initialization.
*
* @param term
* the expression term
* @return expression term for ports initialization
*/
public abstract IExpressionTerm getInitialization(IExpressionTerm term);
/**
* Returns the expression term for ports initialization.
*
* @param port
* the port which needs to be initialized
* @param portName
* name of the port
* @param readOrWrite
* input or output port
* @return expression term for ports initialization
*/
public abstract IExpressionTerm getInitialization(IExpressionTerm port,
IExpressionTerm portName, IExpressionTerm readOrWrite);
/**
* @param depl
* @return
*/
IExpressionTerm getInitialization(Deployment depl);
/**
* @return
*/
IExpressionTerm getInitialization();
}
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