XR01 Example signals for charts

This recJs script creates some example signals to be used for displaing charts. Download the script and open with the impulse viewer.

//-recjs (keep this line)
// generator: of ISingleDomainRecordGenerator  (http://toem.de/index.php/projects/impulse/scripts/reference)
//  
 
// Init the record
generator.initRecord("Example Record",TimeBase.ns);

 
// We forget the input and create a record with scopes and some signals
var signals  = generator.addScope(null, "External Signals");
var intsig = generator.addSignal(signals, "Sin", "", ProcessType.Discrete, SignalType.Integer, SignalDescriptor.DEFAULT);
var struct = generator.addSignal(signals, "Birt", "", ProcessType.Discrete, SignalType.Struct, SignalDescriptor.DEFAULT);
var floatArray = generator.addSignal(signals, "XY", "", ProcessType.Discrete, SignalType.FloatArray, new SignalDescriptor(SignalDescriptor.CONTENT_DEFAULT,2,ISample.FLOAT_WIDTH_64,ISample.FORMAT_DEFAULT));


// 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 <:IStructSamplesWriter:> = generator.getWriter(struct);
var members<:[Lde.toem.impulse.values.StructMember;:>  = writer.createMembers(7);
writer.createMember(members,0,"A",    IStructSample.STRUCT_TYPE_INTEGER,null,-1);
writer.createMember(members,1,"B",    IStructSample.STRUCT_TYPE_INTEGER,null,-1);
writer.createMember(members,2,"C",    IStructSample.STRUCT_TYPE_INTEGER,null,-1);
writer.createMember(members,3,"D",    IStructSample.STRUCT_TYPE_INTEGER,null,-1);
writer.createMember(members,4,"E",    IStructSample.STRUCT_TYPE_INTEGER,null,-1);
writer.createMember(members,5,"F",    IStructSample.STRUCT_TYPE_INTEGER,null,-1);
writer.createMember(members,6,"Label",    IStructSample.STRUCT_TYPE_TEXT,"LABEL",-1);
members[0].setIntValue(1);
members[1].setIntValue(8);
members[2].setIntValue(5);
members[3].setIntValue(12);
members[4].setIntValue(12);
members[5].setIntValue(12);
members[6].setStringValue("Series 1");
writer.write(0,false,members);
members[0].setIntValue(14);
members[1].setIntValue(15);
members[2].setIntValue(16);
members[3].setIntValue(17);
members[4].setIntValue(18);
members[5].setIntValue(19);
members[6].setStringValue("Series 2");
writer.write(1,false,members);
members[0].setIntValue(34);
members[1].setIntValue(35);
members[2].setIntValue(46);
members[3].setIntValue(27);
members[4].setIntValue(38);
members[5].setIntValue(29);
members[6].setStringValue("Series 3");
writer.write(1,false,members);

// xy signal
writer <:IFloatSamplesWriter:> = generator.getWriter(floatArray);
writer.addMember( "x", null, ISample.FORMAT_DEFAULT);
writer.addMember( "y", null, ISample.FORMAT_DEFAULT);  
var array = java.lang.reflect.Array.newInstance(java.lang.Double.TYPE, 2);
for (t=0; t < 100000; t += 10) {
    array[0] =  Math.sin((t + 100) / 3000.0) * 10.0;
    array[1] =  Math.cos((t + 100) / 3000.0) * 10.0;       
    writer.writeDoubleArray(t, false, array);
}
      
// And close finally
generator.close(100000);

// add a configuration
importPackage(Packages.de.toem.impulse.cells.configuration);
var config = generator.addConfiguration( "Demo", "");
var samples <:SamplesConfiguration:> = generator.addSamplesConfiguration( config, intsig);
samples.style = SamplesConfiguration.STYLE_LINE;
samples = generator.addSamplesConfiguration( config, struct);
samples.style = SamplesConfiguration.STYLE_CHART;
samples.preferedHeight = true;
samples.preferedHeightValue = 100;
samples.styleDescriptor = new Link("\Pie Chart (Birt)");
samples.preferedHeight = true;
samples.preferedHeightValue = 250;
samples = generator.addSamplesConfiguration( config, floatArray);
samples.style = SamplesConfiguration.STYLE_CHART;
samples.styleDescriptor =  new Link("\Xy Chart (Nebula)");
samples.preferedHeight = true;
samples.preferedHeightValue = 200;



Download Script About the recJs format Open JavaDoc Reference

Result

Print

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive