Commit 6abfad54 authored by Martin Eisenmann's avatar Martin Eisenmann

Rework Single and MultiUnitMainGenerator

Brought MultiUnitMainGenerator up to speed with the
SingleUnitMainGenerator and extracted overlap into superclass.
Signed-off-by: Martin Eisenmann's avatarEisenmann <eisenmann@fortiss.org>
parent c49fda3f
CanBusGeneratorExtension.java 4bed3c88e71923515d7d9dc9235bc40a49ce237f YELLOW
CanConnectorGeneratorExtension.java 3bc4ec4e49677b9b58ed72102c0ff03efb1056c2 RED
CanConnectorGeneratorExtension.java 900c836414d63ccf2cba904b396e4d5b2efe51a5 YELLOW
CanTransmissionCatalog.java f678cb0f16d4ba46a0f5ae5dd35b569c1211f499 YELLOW
ConsoleOutputGeneratorExtension.java 1246aa81a2865a798207f13e66bfeebc8fbf0cb8 YELLOW
MultiUnitMainGenerator.java 9b07ae320e31b7de7be9dfc9c6f6e9b8e6084738 RED
PWMActuatorGeneratorExtension.java a4925aac8b6b7d650ef60fca32b18bba894c3b03 YELLOW
RaspberryPIGeneratorExtension.java 690bf97a0fbc064e685a65af664c2d64811cf2f0 YELLOW
SingleUnitMainGenerator.java fd160c75143e4314c016c93663507600fce3d07f YELLOW
SingleUnitMainGenerator.java b7c0a59b508d993ad22473d01fd78143c168d280 YELLOW
......@@ -36,23 +36,23 @@ public class CanConnectorGeneratorExtension extends TransceiverExecutableBase<Ca
super(modelElement);
}
/** Init CAN bus on the given interface. */
public IExpressionTerm getInitialization() {
// init CAN bus on the given interface
return funcCall("can_init");
}
/** Check for NOVAL on the given signal port. */
public IExpressionTerm getNoValGuardAccessor(InputPort logicalSignal) {
// check for NOVAL on the given signal port
return funcCall("can_is_noval", literalString(logicalSignal.getName()));
}
/** Set NOVAL on the given signal port. */
public IExpressionTerm getNoValWriteAccessor(OutputPort logicalSignal) {
// set NOVAL on the given signal port
return funcCall("can_set_noval", literalString(logicalSignal.getName()));
}
/** Terminate the bus on the given interface */
public IExpressionTerm getTermination() {
// terminate the bus on the given interface
return funcCall("can_term");
}
......
......@@ -293,12 +293,13 @@ public class RaspberryPIGeneratorExtension
CSourcePackage srcGenPack = (CSourcePackage)generatorResult.getSrcGenPackage();
if(canCatalog != null) {
MultiUnitMainGenerator mg = new MultiUnitMainGenerator(ca2hw, canCatalog, modelElement,
atomics, deployedComponents, deployedPorts, context);
atomics, deployedComponents, deployedPorts, platformConnector2ExtensionBase,
includedHeaders);
srcGenPack.addUnit(mg.createMultiUnitMain());
} else {
SingleUnitMainGenerator mg =
new SingleUnitMainGenerator(modelElement, deployedComponents, deployedPorts,
platformConnector2ExtensionBase, includedHeaders, context);
platformConnector2ExtensionBase, includedHeaders);
srcGenPack.addUnit(mg.createSingleUnitMain());
}
}
......
......@@ -5,6 +5,7 @@ MainFile(UNIT_NAME,
CAN_ID_LOCAL_UNIT,
SYSTEM_INIT_CODE,
SENSOR_VARIABLES,
AUXILIARY_FUNCTIONS,
REMOTE_UNIT_SETUP_CODE,
SYSTEM_INCLUDES,
COMPONENT_PORTS,
......@@ -14,7 +15,7 @@ MainFile(UNIT_NAME,
THREAD_SLEEPTIME_IN_MICROS) ::= <<
// due to current data dictionary declaration of GENTYPE_boolean
// system include must be first
/******************** BEGIN_@GENERATED ***********************/
/******************** BEGIN_@GENERATED SYSTEM_INCLUDES ********/
$SYSTEM_INCLUDES$
/********************* END_@GENERATED ************************/
......@@ -39,13 +40,19 @@ const int cycle_time = $CYCLE_TIME_IN_MILLIS$;
#define BRICK_HOST "localhost"
#define BRICK_PORT 4223
/******************** BEGIN_@GENERATED ***********************/
/******************** BEGIN_@GENERATED COMPONENT_PORTS *******/
$COMPONENT_PORTS$
/********************* END_@GENERATED ************************/
/******************** BEGIN_@GENERATED SENSOR_VARIABLES*******/
$SENSOR_VARIABLES$
/********************* END_@GENERATED ************************/
/******************** BEGIN_@GENERATED ***********************/
/******************** BEGIN_@GENERATED AUXILIARY_FUNCTIONS****/
$AUXILIARY_FUNCTIONS$
/********************* END_@GENERATED ************************/
/******************** BEGIN_@GENERATED COMPONENT_IMPL ********/
$COMPONENT_IMPL$
/********************* END_@GENERATED ************************/
......@@ -55,7 +62,7 @@ static void initialize_af3_subsystem() {
af3_component_remote_proxy_module_initialize();
can_thread_add_reception_listener(default_recv_remote_impl);
/******************** BEGIN_@GENERATED ***********************/
/******************** BEGIN_@GENERATED COMPONENT_SETUP *******/
$COMPONENT_SETUP$
/********************* END_@GENERATED ************************/
}
......@@ -80,7 +87,7 @@ int main(int argc, char** argv) {
}
can_thread_set_thread_sleep_in_micros($THREAD_SLEEPTIME_IN_MICROS$);
/******************** BEGIN_@GENERATED ***********************/
/******************** BEGIN_@GENERATED SYSTEM_INIT_CODE ******/
$SYSTEM_INIT_CODE$
/********************* END_@GENERATED ************************/
......@@ -97,7 +104,7 @@ int main(int argc, char** argv) {
#if $COORDINATOR_OR_WORKER$ == 1
// create list of remote units
list_t* remote_units = list_util_create_list();
/******************** BEGIN_@GENERATED ***********************/
/******************** BEGIN_@GENERATED REMOTE_UNIT_SETUP *****/
$REMOTE_UNIT_SETUP_CODE$
/********************* END_@GENERATED ************************/
// run the unit coordinator protocol mode
......
......@@ -35,7 +35,7 @@ public final class RasPiCTemplates {
int canIdLocalUnit, String sensorVariables, String systemInitCode,
String remoteUnitSetupCode, String systemIncludes, String componentPorts,
String componentSetup, String componentImpl, int cycletimeInMillis,
int threadSleepTimeInMicros) {
int threadSleepTimeInMicros, String auxFunction) {
StringTemplate template = makeTemplate("MultiUnitMainFile.stg", "MainFile");
template.setAttribute("UNIT_NAME", unitName);
template.setAttribute("COORDINATOR_OR_WORKER", coordinatorOrWorker ? "1" : "0");
......@@ -44,6 +44,7 @@ public final class RasPiCTemplates {
template.setAttribute("SYSTEM_INIT_CODE", systemInitCode);
template.setAttribute("REMOTE_UNIT_SETUP_CODE", remoteUnitSetupCode);
template.setAttribute("SYSTEM_INCLUDES", systemIncludes);
template.setAttribute("AUXILIARY_FUNCTIONS", auxFunction);
template.setAttribute("COMPONENT_PORTS", componentPorts);
template.setAttribute("COMPONENT_SETUP", componentSetup);
template.setAttribute("COMPONENT_IMPL", componentImpl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment