Skip to content

Commit

Permalink
Simulator updates with further ports
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobaxelsson committed Jan 16, 2015
1 parent c829590 commit b467dc2
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>moped</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
Empty file.
2 changes: 1 addition & 1 deletion simulator/configs/system1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<vin>default</vin-->
<name>MOPED</name>
<brand>SICS</brand>
<vin>20UYA31581L000000</vin>
<vin>20JAX31581L000000</vin>
<ecm>
<server>
<!--<ip>localhost</ip>-->
Expand Down
4 changes: 4 additions & 0 deletions simulator/src/main/java/fresta/pirte/PIRTE.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import fresta.port.instances.VirtualPublishRPort;
import fresta.port.instances.VirtualLEDRPort;
import fresta.port.instances.VirtualVoltagePPort;
import fresta.port.instances.VirtualAcceleratorRPort;
import fresta.port.instances.VirtualSteeringRPort;
import autosar.RTE;
import sics.plugin.PlugInComponent;
import sics.port.EcuVirtualPPort;
Expand Down Expand Up @@ -56,6 +58,8 @@ public PIRTE(int id) {
this.id = id;

vrports.put(0, new VirtualPublishRPort(0));
vpports.put(new Integer(3), new VirtualAcceleratorRPort(3));
vpports.put(new Integer(4), new VirtualSteeringRPort(4));
vpports.put(new Integer(5), new VirtualFrontWheelPPort(5));
vpports.put(new Integer(6), new VirtualRearWheelPPort(6));
vpports.put(new Integer(7), new VirtualVoltagePPort(7));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package fresta.port.instances;

import gui.CarModel;
import sics.port.EcuVirtualRPort;

public class VirtualAcceleratorRPort extends EcuVirtualRPort {

public VirtualAcceleratorRPort(int id) {
super(id);
}

@Override
public void deliver(Object data) {
CarModel.motorPower = ((int) data) / 100.0;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fresta.port.instances;

import gui.CarModel;
import sics.port.EcuVirtualRPort;

public class VirtualLEDRPort extends EcuVirtualRPort {
Expand All @@ -15,6 +16,8 @@ public void deliver(Object data) {
String pin = dataStr.substring(0, barIndex);
String value = dataStr.substring(barIndex+1);

CarModel.lamp[Integer.parseInt(pin)] = (value == "1");

// Currently, this method just prints the value of the LED pin.
// TODO: Show the LEDs in the graphical GUI.
System.out.println("LED + " + pin + " = " + value);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package fresta.port.instances;

import gui.CarModel;
import sics.port.EcuVirtualRPort;

public class VirtualSteeringRPort extends EcuVirtualRPort {

public VirtualSteeringRPort(int id) {
super(id);
}

@Override
public void deliver(Object data) {
CarModel.steeringAngle = ((int) data) / 100.0;
}
}
13 changes: 13 additions & 0 deletions simulator/src/main/java/gui/CarModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class CarModel extends SimulatorModel implements PhysicalObjectModel {
/** The steering angle. */
public static double steeringAngle; // Current steering angle, as -1 .. 1 of
// maxSteeringAngle

/** Lamps */
public static boolean lamp[]; // True when lamp is on, False otherwise

// Variables calculated by the simulation.
/** The vehicle speed. */
Expand Down Expand Up @@ -77,9 +80,19 @@ public class CarModel extends SimulatorModel implements PhysicalObjectModel {
// hazardLightOn
public static boolean hazardLightOn;

// battery voltage
public static double voltage;

/** The limited speed. */
static double limitedSpeed;

public CarModel() {
lamp = new boolean[3];
lamp[0] = false;
lamp[1] = false;
lamp[2] = false;
}

/*
* (non-Javadoc)
*
Expand Down
2 changes: 1 addition & 1 deletion simulator/target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven
#Fri Jan 16 12:00:41 CET 2015
#Fri Jan 16 15:33:42 CET 2015
version=1.0
groupId=se.sics.sse.fresta
artifactId=simulator

0 comments on commit b467dc2

Please sign in to comment.