Home

XR08 recJs Example: Gantt and Event colors


Outline

This recJs example script shows colored events, gantt plots including labels and relations.

Platforms
32/64bit 32/64bit 32/64bit
Requirements
  • None
Parameters:
  • None
Content of example record files
  • recJs/r08_colors_label_relation.recJs


Output



Usage

  1. Copy the script code onto a file resource with "recJs" ending or use the impulse record examples.
  2. Open the impulse viewer with the file resource (e.g. double-click the file in the eclipse explorer).

R003 recJs Reader 10 Signal Script Script Examples impulse JDK Open JavaDoc



Script

The script creates several event signals with multiple colors.

//-recjs (keep this line)
// generator   : Record generator (de.toem.impulse.samples.ISingleDomainRecordGenerator)
// file        : File object of the executed recJs file (java.io.File)
// p0..p9      : Parameters from the reader configuration (java.lang.String)
// progress    : Progress control (de.toem.impulse.cells.ports.IPortProgress)
// console     : Console output (de.toem.impulse.scripting.IScriptConsole) 
 
// Init the record
generator.initRecord("Example Record",TimeBase.ns);


// Create a record with scopes and some signals
var signals = generator.addScope(null, "External Signals");
var int1 = generator.addSignal(signals, "Sin", "", ProcessType.Discrete, SignalType.Integer, SignalDescriptor.DEFAULT);
var int2 = generator.addSignal(signals, "Load1", "", ProcessType.Discrete, SignalType.Integer, SignalDescriptor.DEFAULT);
var int3 = generator.addSignal(signals, "Load2", "", ProcessType.Discrete, SignalType.Integer, SignalDescriptor.DEFAULT);

var core1 = generator.addScope(null, "Core 1");
var task_1_1 = generator.addSignal(core1, "Task 1", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.EventGantt);
var task_1_2 = generator.addSignal(core1, "Task 2", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.EventGantt);
var task_1_3 = generator.addSignal(core1, "Automatic colors", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.EventGantt);
var task_1_4 = generator.addSignal(core1, "Fixed Colors", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.EventGantt);
var task_1_5 = generator.addSignal(core1, "Shade Colors", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.EventGantt);
var task_1_6 = generator.addSignal(core1, "Automatic colors event", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.DEFAULT);
var task_1_7 = generator.addSignal(core1, "Fixed Colors event", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.DEFAULT);
var task_1_8 = generator.addSignal(core1, "Shade Colors event", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.DEFAULT);
var task_1_9 = generator.addSignal(core1, "Task with Labels", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.EventGantt);
var task_1_10 = generator.addSignal(core1, "User format", "", ProcessType.Discrete, SignalType.Float, new SignalDescriptor(SignalDescriptor.CONTENT_DEFAULT,ISample.FORMAT_DECIMAL_F1));
// We start at 0 ns
var t = 0; // 0 ns
generator.open(t);

// get the writers
var integerWriter /*:IIntegerSamplesWriter:*/ = generator.getWriter(int1);

// And continue until 1000 ns
integerWriter.writeInt(t, false, 0);
t=14000;
integerWriter.writeInt(t, false, 0);
for (; t < 94000; t ++) {

    // write time as integer
    integerWriter.writeInt(t, false,  (100 * Math.sin(t/1000.0)));
}
integerWriter.writeInt(t, false, 0);
integerWriter.writeInt(100000, false, 0);

// Add marker
var marker /*:Marker:*/ = new Marker(Marker.BOOKMARK,"My Bookmark",""); 
marker.setLocation(new Link("@@@Time='40us'"));  
marker.setRelation(new Link(int2.getPath()+"@@@Time='80us'")); 
integerWriter.addMarker(marker);

// task 1
var eventWriter /*:IEventSamplesWriter:*/=  generator.getWriter(task_1_1);
eventWriter.write(13000, false,"Running");
eventWriter.write(24000, false,"Waiting");
eventWriter.write(25000, false);
eventWriter.attachRelation(task_1_3.getPath(), "", 0);
eventWriter.write(35000, false,"Running");
eventWriter.write(65000, false);
eventWriter.attachRelation(task_1_3.getPath(), "", 0);
eventWriter.write(73000, false,"Running");
eventWriter.write(80000, false,"Storing");
eventWriter.write(84000, false,"Waiting");
eventWriter.write(88000, false,"Running");
eventWriter.write(06000, false);

// task 2
eventWriter = generator.getWriter(task_1_2);
eventWriter.write(10000, false,"A");
eventWriter.write(14000, false,"Comb");
eventWriter.attachRelation(int1.getPath(), "Enable", 0);
eventWriter.write(17000, false,"X1");
eventWriter.write(20000, false);
eventWriter.attachRelation(task_1_4.getPath(), "", 0);
eventWriter.write(30000, false,"A");
eventWriter.write(34000, false,"Comb");
eventWriter.write(37000, false,"X1");
eventWriter.write(40000, false);
eventWriter.attachRelation(task_1_4.getPath(), "", 0);
eventWriter.write(50000, false,"A");
eventWriter.write(54000, false,"Comb");
eventWriter.write(57000, false,"X1");
eventWriter.write(60000, false);
eventWriter.attachRelation(task_1_4.getPath(), "", 0);
eventWriter.write(70000, false,"A");
eventWriter.write(74000, false,"Comb");
eventWriter.write(77000, false,"X1");
eventWriter.write(80000, false);
eventWriter.attachRelation(task_1_4.getPath(), "", 0);
eventWriter.write(90000, false,"A");
eventWriter.write(94000, false,"Comb");
eventWriter.attachRelation(int1.getPath(), "Disable", 0);
eventWriter.write(97000, false,"X1");
eventWriter.write(100000, false);


var n;

// COLOR areas
// cid = id&0xffff
// for cid = 0x0000 - 0xbfff : 16 automatic colors
// for cid = 0xc000 - 0xefff : 32 fixed colors
// for cid = 0xf000 - 0xffff : 8  background colors

// GANTT
eventWriter = generator.getWriter(task_1_3);
for (n=0;n<32;n++)
	eventWriter.write(n*1000*3, false,n);
eventWriter.write(32*1000, false,0);

eventWriter = generator.getWriter(task_1_4);
for (n=0;n<32;n++)
	eventWriter.write(n*1000*3, false,0xc000+n);
eventWriter.write(32*1000, false,0);

eventWriter = generator.getWriter(task_1_5);
for (n=0;n<32;n++)
	eventWriter.write(n*1000*3, false,0xf000+n);
eventWriter.write(32*1000, false,0);

// EVENTS
eventWriter = generator.getWriter(task_1_6);
for (n=0;n<32;n++)
	eventWriter.write(n*1000*3, false,n);
eventWriter.write(32*1000, false,0);

eventWriter = generator.getWriter(task_1_7);
for (n=0;n<32;n++)
	eventWriter.write(n*1000*3, false,0xc000+n);
eventWriter.write(32*1000, false,0);

eventWriter = generator.getWriter(task_1_8);
for (n=0;n<32;n++)
	eventWriter.write(n*1000*3, false,0xf000+n);
eventWriter.write(32*1000, false,0);

// LABELS and ASSOCIATIONS
var eventWriter /*:IEventSamplesWriter:*/=  generator.getWriter(task_1_9);
eventWriter.write(13000, false,"Running");
eventWriter.write(24000, false,"Waiting");
eventWriter.write(25000, false);
eventWriter.attachRelation(task_1_3.getPath(), "test/ff0000/line/no", 10000);
eventWriter.attachRelation(task_1_3.getPath(), "test/00ff00/cubic/normal", 20000);
eventWriter.attachRelation(task_1_3.getPath(), "test/ff00ff/line/normal", 30000);
eventWriter.attachRelation(task_1_3.getPath(), "test/ffff00/cubic/no", 40000);
eventWriter.attachLabel("hi label/ff0000/add",0,0);
eventWriter.write(35000, false,"Running");
eventWriter.write(65000, false);
eventWriter.attachRelation(task_1_3.getPath(), "", 0);
eventWriter.write(73000, false,"Running");
eventWriter.write(80000, false,"Storing");
eventWriter.write(84000, false,"Waiting");
eventWriter.write(88000, false,"Running");
eventWriter.attachLabel("hi label/00ff00/star",0,0);
eventWriter.write(06000, false);

eventWriter = generator.getWriter(task_1_10);
for (n=0;n<6;n++)
	eventWriter.write(n*1000*24, false,10.234*n);


// And close finally
generator.close(100000);


toem

technical software and tooling

Company

Contact Us

This email address is being protected from spambots. You need JavaScript enabled to view it.