Flexray - Overview¶
API Documentation
Explanation¶
This component allows to simulate FlexRay networks and bus systems. The implementation ist based on the FlexRay Communications System Protocol Specification Version 3.0.1. It allows the usage of two independent channels A and B which share the same network configuration. For the details, configuration possibilities and frame structure, please take a look at Features.
Usage¶
Sender-Receiver Example
This is an example where you can see how to setup of the FERAL environment and the network for a simulation.
SenderReceiverExample.java
public static void main(String[] args) {
// Define the simulation parameters constants
final long SIMULATION_DURATION_NS = SimulationTime._1MS.mul(55).getRawTimeNS();
final long SENDER_INTERVALL_NS = SimulationTime._1MS.mul(10).getRawTimeNS();
// Setup FERAL environment
Scenario simulationScenario = new SimulationScenario();
Director director = new DiscreteEventMOCC("root director", simulationScenario);
// Create some participants/endpoints (this would be the devices under test)
// - Create FlexRay sender
SenderEventWorker sender = new SenderEventWorker(director, 0, SENDER_INTERVALL_NS, FlexRayChannel.A);
// - Create FlexRay receiver
ReceiverEventWorker receiver = new ReceiverEventWorker(director, expectedEvents);
// ### The FlexRay specific part begins here ###
// - Create FlexRay Network with 2 nodes
FlexRayNetwork network = new FlexRayNetwork(director, 2);
// - Setup network speed - 10MBit
network.setBitRate(10_000_000);
// - Setup network settings (optional)
// - e.g. length of static slots in macroticks
network.getConfig().setGdStaticSlot(11);
// Get interfaces to connect with the network
var inputInterface = network.getTopology().getApplicationInterface(0);
var outputInterface = network.getTopology().getApplicationInterface(1);
// Add the message type for the interface:
// - s:2 -> static slot 2
// - app1 -> name of the port which will be created
// - 1 -> message size
// Note: input to the network -> TX, output from the network -> RX
inputInterface.addTxMessageType("s:2", "app1", 1);
outputInterface.addRxMessageType("s:2", "app1", 1);
// - Setup links from/to network
// - Connect the output port of the sender named "comm" to the input port of the
// inputInterface named "app1"; same with the output
new Link(sender.getOutputPort("comm"), inputInterface.getInputPort("app1"));
new Link(outputInterface.getOutputPort("app1"), receiver.getInputPort("comm"));
/* The simulation setup is complete an dcan be started */
simulationScenario.startSimulation(SIMULATION_DURATION_NS);
}