XR10 recJs Example: Traffic Light state chart


Outline

This example script creates example signals for a YAKINDU state start.

Platforms
32/64bit 32/64bit 32/64bit
Requirements
  • YAKINDU extension
Parameters:
  • None
Content of example record files
  • recJs/r10_TrafficLight.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 an event signal with text events for the state chart.

//-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.ms);

 
// We forget the input and create a record with scopes and some signals
var signals  = generator.addScope(null, "Signals");
var intsig = generator.addSignal(signals, "Sin", "", ProcessType.Discrete, SignalType.Integer, SignalDescriptor.DEFAULT);
var event = generator.addSignal(signals, "Events", "", ProcessType.Discrete, SignalType.Event, new SignalDescriptor(ISample.CONTENT_EVENT,ISample.FORMAT_TEXT));


// We start at 0 ns
var t = 0; // 0 ns
generator.open(t);

// int signal
var writer /*:IIntegerSamplesWriter:*/ = generator.getWriter(intsig);
writer.writeInt(t, false, 0);
t=14000;
writer.writeInt(t, false, 0);
for (; t < 94000; t ++) {

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


// struct signal
writer /*:IEventSamplesWriter:*/ = generator.getWriter(event);


writer.write(20, false, "dummy");
writer.write(2000, false, "onOff");
writer.write(18000, false, "pedestrianRequest");
writer.write(60000, false, "pedestrianRequest");
writer.write(61000, false, "pedestrianRequest");
writer.write(80000, false, "pedestrianRequest");
writer.write(90000, false, "onOff");


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.