Home

U001 Creating charts from CAN bus messages

Content outdated

We are in the process of migrating all content to impulse version 2.0.

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
progress.cont();
if (members == null) {
    var members <:[Lde.toem.impulse.values.StructMember;:> = out.createMembers(7);
    out.createMember(members, 0, "12", ISample.STRUCT_TYPE_INTEGER, null, -1);
    out.createMember(members, 1, "24", ISample.STRUCT_TYPE_INTEGER, null, -1);
    out.createMember(members, 2, "61", ISample.STRUCT_TYPE_INTEGER, null, -1);
    out.createMember(members, 3, "62", ISample.STRUCT_TYPE_INTEGER, null, -1);
    out.createMember(members, 4, "Label", ISample.STRUCT_TYPE_TEXT, "LABEL", -1);

    var counter = {};

} else {
    out.close();
    out.open(0);
}

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

// create output
members[0].setIntValue(counter[12]);
members[1].setIntValue(counter[24]);
members[2].setIntValue(counter[60]);
members[3].setIntValue(counter[61]);
members[4].setStringValue("Messages");

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.