A04 recJs Script Record Format

RecJs files are wave files build on scripts. You might prepare signal references, define test vectors for your design or script a custom reader. Everything is based on the same simple api that is used in signal scripts and serializers.

You need impulse version >= 1.1

How to create a recJs script ?

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

//-recjs (keep this line)
// Vars:
// 	* generator of ISingleDomainRecordGenerator
//  

Use 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.

How to create signals and scopes ?

The API used for recJs scripts is the same as for the java based serializers (Extending impulse). The only difference is the fact that java serializers are derived from an abstract reader class (that implements IRecordGenerator), whereas recJs scripts use these generators as parameter ("generator"). Look at the following example. The java code to init a record and creating a scope looks like this:

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

The recJs counterpart uses the generator parameter.

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

How to add samples ?

Again the only difference is the usages of the generator parameter and diffences between java and java script:

    // 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);
Java reference for scripts Show examples More about Extending impulse