Creating charts from CAN bus messages

This screen cast shows the creation and configuration of BIRT and XY charts, using data from CAN bus messages.

Screen Cast: Creating charts from
CAN bus messages

A Pie chart from the CAN bus message IDs

The first example creates a PIE chart, showing the received CAN bus message IDs. The used script is shown below. The script

  1. creates the members of a struct signal,
  2. analyzes all in samples (read the id of the messages) and counts them in a dictionary
  3. writes the counter values in the struct and finally into the output signal.
// input: an array of all input signals
// in0: primary input of type ISamplePointer,IReadableSamples
// in1..: additional inputs of type ISamplePointer,IReadableSamples
// out: output signal of type ITextSamplesWriter
// console: console output of type MessageConsoleStream
// iter: iterator of type ISamplesIterator
// progress: progess control of type  IScriptProgress

// struct signal
if (members == null) {
    var members <:[Lde.toem.impulse.values.StructMember;:> = out.createMembers(7);
    out.createMember(members, 0, "12", IStructSample.STRUCT_TYPE_INTEGER, null, -1);
    out.createMember(members, 1, "24", IStructSample.STRUCT_TYPE_INTEGER, null, -1);
    out.createMember(members, 2, "61", IStructSample.STRUCT_TYPE_INTEGER, null, -1);
    out.createMember(members, 3, "62", IStructSample.STRUCT_TYPE_INTEGER, null, -1);
    out.createMember(members, 4, "Label", IStructSample.STRUCT_TYPE_TEXT, "LABEL", -1);

    var counter = {};

} else {

// analyze input
while (iter.hasNext()) {;
    var id = in1.intValueOf("Id");
    if (counter[id] == null)
        counter[id] = 1;
        counter[id] = counter[id] + 1;

// create output

out.write(0, false, members);

An XY chart from 2 separate integer signals

The second example shows how to create a XY chart from simple float or integer signals using the array combiner production. As the XY chart requires an array signal (float array or integer array containing the x and y values), the separate input signals need to be combined with the array combiner.


User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive