Commit 420d1f60 authored by Sascha Niklas Schneiders's avatar Sascha Niklas Schneiders
Browse files

added new tests, fixed possible nullpointer

parent 1c0c0db4
......@@ -69,6 +69,7 @@ public class EmbeddedMontiArcLanguage extends EmbeddedMontiArcLanguageTOP implem
addResolver(new CommonResolvingFilter<>(JMethodSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(ResolutionDeclarationSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(UnitNumberResolutionSymbol.KIND));
//addResolvingFilter(CommonResolvingFilter.create(ComponentKind.KIND));
//addResolvingFilter(CommonResolvingFilter.create(TagSymbol.KIND));
setModelNameCalculator(new EmbeddedMontiArcModelNameCalculator());
}
......
......@@ -77,7 +77,7 @@ public class InstanceInformation {
Log.debug(componentInstanceSymbol.getComponentType().toString(), "ComponentInstanceSymbol");
Log.debug(portName, "PortName");
PortArraySymbol namedArray = componentInstanceSymbol.getComponentType().getPortArray(portName);
if (namedArray.getNameSizeDependsOn().isPresent())
if (namedArray!=null&&namedArray.getNameSizeDependsOn().isPresent())
Log.debug(namedArray.getNameSizeDependsOn().get(), "PortArray Depends On:");
int counter = 0;
......
......@@ -629,5 +629,24 @@ public class SymtabTest extends AbstractSymtabTest {
}
@Test
public void testSubComponentDefinitionInstanciation() {
Scope symTab = createSymTab("src/test/resources");
ComponentSymbol cs = symTab.<ComponentSymbol>resolve("testing.SubComponent", ComponentSymbol.KIND).orElse(null);
assertNotNull(cs);
}
@Test
public void testBumperBotEmergency() {
Scope symTab = createSymTab("src/test/resources");
ComponentSymbol cs = symTab.<ComponentSymbol>resolve("bumperBotEmergency.BumperBotEmergency", ComponentSymbol.KIND).orElse(null);
assertNotNull(cs);
}
}
package bumperBotEmergency;
view BumpControlOverview {
component BumpSensor {}
instance BumpSensor bumpSensor;
component BumpControl {}
instance BumpControl bumpControl;
component Timer {}
instance Timer timer;
connect bumpSensor -> bumpControl;
connect timer -> bumpControl;
connect bumpControl -> timer;
}
package bumperBotEmergency;
// Simple BumperBot
component BumperBot {
component Sensors {
port
out Boolean bumpPressed;
component BumpSensor {
port
out Boolean pressed;
}
instance BumpSensor bumpSensor;
connect bumpSensor.pressed -> bumpPressed;
}
instance Sensors sensors;
connect sensors.bumpPressed -> controller.bumpPressed;
component Controller {
port
in Boolean bumpPressed,
out MotorCmd rightMotorCmd,
out MotorCmd leftMotorCmd;
component BumpControl {
port
in Boolean bumpPressed,
in TimerSignal timerSig,
out TimerCmd timerCmd,
out MotorCmd leftMotorCmd,
out MotorCmd rightMotorCmd;
}
instance BumpControl bumpControl;
component Timer {
port
out TimerSignal signal,
in TimerCmd cmd;
}
instance Timer timer;
// connections of the bump control
connect bumpPressed -> bumpControl.bumpPressed;
connect timer.signal -> bumpControl.timerSig;
connect bumpControl.timerCmd -> timer.cmd;
connect bumpControl.rightMotorCmd -> rightMotorCmd;
connect bumpControl.leftMotorCmd -> leftMotorCmd;
}
instance Controller controller;
connect controller.leftMotorCmd -> actuators.leftMotorCmd;
connect controller.rightMotorCmd -> actuators.rightMotorCmd;
component Actuators {
port
in MotorCmd rightMotorCmd,
in MotorCmd leftMotorCmd;
component LeftMotor {
port
in MotorCmd cmd;
}
instance LeftMotor leftMotor;
component RightMotor {
port
in MotorCmd cmd;
}
instance RightMotor rightMotor;
connect rightMotorCmd -> rightMotor.cmd;
connect leftMotorCmd -> leftMotor.cmd;
}
instance Actuators actuators;
}
package bumperBotEmergency;
// Synthesized architecture for ArcV specification
component BumperBotEmergency {
component Sensors {
port
out Boolean bumpPressed,
out Boolean emergencyPressed;
component BumpSensor {
port
out Boolean pressed;
}
instance BumpSensor bumpSensor;
component EmergencySwitch {
port
out Boolean pressed;
}
instance EmergencySwitch emergencySwitch;
connect bumpSensor.pressed -> bumpPressed;
connect emergencySwitch.pressed -> emergencyPressed;
}
instance Sensors sensors;
connect sensors.bumpPressed -> controller.bumpPressed;
connect sensors.emergencyPressed -> controller.emergencyPressed;
component Controller {
port
in Boolean bumpPressed,
in Boolean emergencyPressed,
out MotorCmd rightMotorCmd,
out MotorCmd leftMotorCmd;
component BumpControl {
port
in Boolean bumpPressed,
in TimerSignal timerSig,
out TimerCmd timerCmd,
out MotorCmd leftMotorCmd,
out MotorCmd rightMotorCmd;
}
instance BumpControl bumpControl;
component Timer {
port
out TimerSignal signal,
in TimerCmd cmd;
}
instance Timer timer;
component MotorStop {
port
out MotorCmd motorCmd;
}
instance MotorStop motorStop;
component MotorArbiter {
port
out MotorCmd rightMotorCmd,
out MotorCmd leftMotorCmd,
in MotorCmd fstAltRightMotorCmd,
in MotorCmd fstAltLeftMotorCmd,
in MotorCmd sndAltRightMotorCmd,
in MotorCmd sndAltLeftMotorCmd,
in Boolean selection;
}
instance MotorArbiter motorArbiter;
// connections of the bump control
connect bumpPressed -> bumpControl.bumpPressed;
connect timer.signal -> bumpControl.timerSig;
connect bumpControl.timerCmd -> timer.cmd;
// connections of the arbiter
connect motorStop.motorCmd -> motorArbiter.fstAltRightMotorCmd;
connect motorStop.motorCmd -> motorArbiter.fstAltLeftMotorCmd;
connect bumpControl.rightMotorCmd -> motorArbiter.sndAltRightMotorCmd;
connect bumpControl.leftMotorCmd -> motorArbiter.sndAltLeftMotorCmd;
connect emergencyPressed -> motorArbiter.selection;
connect motorArbiter.rightMotorCmd -> rightMotorCmd;
connect motorArbiter.leftMotorCmd -> leftMotorCmd;
}
instance Controller controller;
connect controller.leftMotorCmd -> actuators.leftMotorCmd;
connect controller.rightMotorCmd -> actuators.rightMotorCmd;
component Actuators {
port
in MotorCmd rightMotorCmd,
in MotorCmd leftMotorCmd;
component LeftMotor {
port
in MotorCmd cmd;
}
instance LeftMotor leftMotor;
component RightMotor {
port
in MotorCmd cmd;
}
instance RightMotor rightMotor;
connect rightMotorCmd -> rightMotor.cmd;
connect leftMotorCmd -> leftMotor.cmd;
}
instance Actuators actuators;
}
package bumperBotEmergency;
/**
This view shows the emergency switch and its relation to the MotorArbiter.
**/
view BumperBotEmergencySystem {
component Sensors {
component EmergencySwitch {
port
out ? pressed;
}
instance EmergencySwitch emergencySwitch;
}
instance Sensors sensors;
component MotorArbiter {
port
in ? selection;
}
instance MotorArbiter motorArbiter;
connect emergencySwitch.pressed -> motorArbiter.selection;
}
package bumperBotEmergency;
/**
This is an undesired case where the motors are inside the sensors layer.
**/
view BumperBotMotorWrongPlace {
component Sensors {
component LeftMotor {}
instance LeftMotor leftMotor;
component RightMotor {}
instance RightMotor rightMotor;
}
instance Sensors sensors;
}
package bumperBotEmergency;
/**
The sensors of the bumper bot (without emergency).
**/
view BumperBotSensors {
component Sensors {
component BumpSensor {}
instance BumpSensor bumpSensor;
}
instance Sensors sensors;
}
package bumperBotEmergency;
/**
This view shows connected components independent of the layers of the
architecture.
**/
view BumperBotStructure {
component Sensors {
component BumpSensor {}
instance BumpSensor bumpSensor;
}
instance Sensors sensors;
component Controller {
component BumpControl {}
instance BumpControl bumpControl;
component Timer {}
instance Timer timer;
}
instance Controller controller;
component Actuators {
component LeftMotor {}
instance LeftMotor leftMotor;
component RightMotor {}
instance RightMotor rightMotor;
}
instance Actuators actuators;
connect bumpSensor -> bumpControl;
connect timer -> bumpControl;
connect bumpControl -> timer;
connect bumpControl -> leftMotor;
connect bumpControl -> rightMotor;
}
package bumperBotEmergency;
/**
This view shows the high level and incomplete structure of the bumper bot
system with layers but without information of the emergency stop system.
**/
view BumperBotStructureOnly {
component Sensors {
component BumpSensor {}
instance BumpSensor bumpSensor;
}
instance Sensors sensors;
component Controller {
component BumpControl {}
instance BumpControl bumpControl;
component Timer {}
instance Timer timer;
}
instance Controller controller;
component Actuators {
component LeftMotor {}
instance LeftMotor leftMotor;
component RightMotor {}
instance RightMotor rightMotor;
}
instance Actuators actuators;
}
package bumperBotEmergency;
/**
This view shows the path that a STOP signal sent by component MotorStop
can travel through the MotorArbiter to the actuators.
**/
view MotorArbiterConnectionsEmergency {
component MotorStop {
port
out ? motorCmd;
}
instance MotorStop motorStop;
component MotorArbiter {
port
in MotorCmd fstAltLeftMotorCmd,
in MotorCmd fstAltRightMotorCmd,
out ? leftMotorCmd,
out ? rightMotorCmd;
}
instance MotorArbiter motorArbiter;
component Actuators {
component LeftMotor {
port
in MotorCmd cmd;
}
instance LeftMotor leftMotor;
component RightMotor {
port
in MotorCmd cmd;
}
instance RightMotor rightMotor;
}
instance Actuators actuators;
connect motorArbiter.leftMotorCmd -> leftMotor.cmd;
connect motorArbiter.rightMotorCmd -> rightMotor.cmd;
connect motorStop.motorCmd -> motorArbiter.fstAltLeftMotorCmd;
connect motorStop.motorCmd -> motorArbiter.fstAltRightMotorCmd;
}
package bumperBotEmergency;
/**
This view shows the signal flow path from the control component bump control
through the mode arbiter to the two motors.
**/
view MotorArbiterConnectionsOldBehavior {
component BumpControl {
port
out ? leftMotorCmd,
out ? rightMotorCmd;
}
instance BumpControl bumpControl;
component MotorArbiter {
port
in MotorCmd sndAltLeftMotorCmd,
in MotorCmd sndAltRightMotorCmd,
out ? leftMotorCmd,
out ? rightMotorCmd;
}
instance MotorArbiter motorArbiter;
component LeftMotor {
port
in MotorCmd cmd;
}
instance LeftMotor leftMotor;
component RightMotor {
port
in MotorCmd cmd;
}
instance RightMotor rightMotor;
connect motorArbiter.leftMotorCmd -> leftMotor.cmd;
connect motorArbiter.rightMotorCmd -> rightMotor.cmd;
connect bumpControl.leftMotorCmd -> motorArbiter.sndAltLeftMotorCmd;
connect bumpControl.rightMotorCmd -> motorArbiter.sndAltRightMotorCmd;
}
package testing;
component SubComponent{
ports in Boolean in1,
out Boolean out1;
component A{
ports in Boolean in1,
out Boolean out1;
}
instance A a;
connect in1 -> a.in1;
connect a.out1 -> out1;
}
\ No newline at end of file
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