R003 recJs Reader


Outline

recJs files are text files that contain a signal script to generate the resulting record.

Platforms
32/64bit 32/64bit 32/64bit
Requirements
  • None
Known limitations
  • None
Status
  • Stable
Operations
  • Load
Default Parameters:
  • None
Configuration:
  • Can use an optional configuration to define a set of parameters (P0-P9) for the script.


Video

Screen Cast: A04 recJs Script Record Format



How to create a recJs script ?

Just create a file/resource with the file ending "recJs" (e.g. my_wave.recJs) and put the following text into the header of the file ("//-recjs" is important to get the file identified) :

//-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.pattern.threading.IProgress)
// console     : Console output (de.toem.impulse.scripting.IScriptConsole)

Instead of writing from scratch you may import existing examples to work with. Just get to Import->impulse->Import example record files and select a folder to import.

10 Signal Script Script Examples



Using the build-in java script editor

You may use the built-in recJs editor or any other eclipse java script editor. Right click on the resource and select "Open With -> impulse recJs Editor". As soon as you save the file, its signals will be updated and changes get visible in a parallel impulse viewer. If there are errors in the script, log messages will be send to the console view.



The impulse JDK

No matter if you develop a reader, a recJs script, a search expression or a Signal Script production, impulse provides you always with the same interfaces to read, compare, analyze or generate signal data.


impulse JDK Open JavaDoc Reference


How to create a record ?

Looking at the of the recJs-file you can get a first impression about the interface to impulse:

generator
Record generator object of type ISingleDomainRecordGenerator. Its interface allow you to create scopes and signals.
file
File object of the executed recJs file.
progress
Progress indication object of type IProgress. This object allows you to indicate the current progress and to control the timeout.
p0..p9
Parameters of type String that can be modified in serializer configuration.
console
Console output of type IScriptConsole.
To create a record , the following steps are required:
  • Initialize the record
  • Add the record content (scopes, signals and proxies)
    • Open the writer
    • Write samples
    • Close the writer

Below you find a short example for a recJs file.

// Init the record
generator.initRecord("Example Record",TimeBase.ns);
   
// Create a record with scopes and some signals
var signals = generator.addScope(null, "Signals");
var int = generator.addSignal(signals, "Sin", "An integer", ProcessType.Discrete, SignalType.Integer, SignalDescriptor.DEFAULT);

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

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

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

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


Usage

The recML/recMZ reader can be used to open workspace resources and together with resource adapters.



Configuration

You can modify the reader behavior under Preferences->impulse->Serializer->recJs:

  • You may modify the default parameters (see "Default Parameters"); 
  • You may add a default reader configuration and modify its parameters. Then you can select between multiple configurations (containing different parameter sets) when using the serializer.


Parse errors

The reader will provide a parse error message if the input can not be read. The message usually contains the error position, the reason for the failure and a stack trace.

If you can not resolve the problem (e.g. obvious format error in the input file), please send this message together with the input file to "This email address is being protected from spambots. You need JavaScript enabled to view it.".

	Reader: de.toem.impulse.serializer.recjs 
	Error at position: 0
	Text at position: "null"
	Message: ReferenceError: "gg" is not defined in  at line number 103
	Type: class javax.script.ScriptException
	Stack trace: 
	
	jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470)
	jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:454)
	jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406)
	jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
	jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
	javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	de.toem.impulse.serializer.base.RecJs$1.eval(RecJs.java:82)
	de.toem.impulse.scripting.Scripting.run(Scripting.java:224)
	de.toem.impulse.scripting.Scripting.run(Scripting.java:129)
	de.toem.impulse.serializer.base.RecJs.parse(RecJs.java:91)
	de.toem.impulse.serializer.AbstractParsingRecordReader.read(AbstractParsingRecordReader.java:117)
	de.toem.impulse.serializer.AbstractRecordReader.read(AbstractRecordReader.java:199)
	de.toem.pattern.element.Element$1.execute(Element.java:1067)
	de.toem.eclipse.hooks.actives.EclipseActives$3.run(EclipseActives.java:73)
toem

technical software and tooling

Company

Contact Us

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