XR03 Events

Content outdated

We are in the process of migrating all content to impulse version 2.0.

This next script contains events and logs. 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);

 
// Create a record with scopes and some signals
var signals = generator.addScope(null, "Signals");
var int1 = generator.addSignal(signals, "Integer1", "An integer", ProcessType.Discrete, SignalType.Integer, SignalDescriptor.DEFAULT);


var event1 = generator.addSignal(signals, "Event1", "Simple events", ProcessType.Discrete, SignalType.Event, SignalDescriptor.DEFAULT);
var event2 = generator.addSignal(signals, "Event2", "Enum events with ints",ProcessType.Discrete, SignalType.Event, SignalDescriptor.DEFAULT);
var event3 = generator.addSignal(signals, "Event3", "Enum events with strings",ProcessType.Discrete, SignalType.Event, SignalDescriptor.DEFAULT);
var struct1 = generator.addSignal(signals, "Struct1", "A struct signal", ProcessType.Discrete,SignalType.Struct, new SignalDescriptor( SignalDescriptor.CONTENT_DEFAULT, -1));
var struct2 = generator.addSignal(signals, "Struct2", "Another struct signal", ProcessType.Discrete,SignalType.Struct, new SignalDescriptor( SignalDescriptor.CONTENT_DEFAULT, -1));

// 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
for (; t < 100000; t ++) {

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

// simple events
var eventWriter<:IEventSamplesWriter:> =  generator.getWriter(event1);
eventWriter.write(12000, false);
eventWriter.write(22000, false);

// enum events with strings
eventWriter =  generator.getWriter(event2);
eventWriter.write(13000, false,"Start");
eventWriter.write(14000, false,"Continue");
eventWriter.write(15000, false,"Stop");
eventWriter.write(25000, false,"Destroy");     
eventWriter.write(30000, false,"Start");  
eventWriter.write(44000, false,"Continue");
eventWriter.write(45000, false,"Stop");
eventWriter.write(55000, false,"Destroy");     
eventWriter.write(60000, false,"Start");  

// enum events with ints
eventWriter = generator.getWriter(event3);
eventWriter.write(13000, false,1);
eventWriter.write(14000, false,2);
eventWriter.write(15000, false,3);
eventWriter.write(25000, false,4);    


// structs
var structWriter <:IStructSamplesWriter:>=  generator.getWriter(struct1);

var members<:[Lde.toem.impulse.values.StructMember;:> = structWriter.createMembers(3);
structWriter.createMember(members,0,"State", IStructSample.STRUCT_TYPE_LOCAL_ENUM,"STATE", ISample.FORMAT_DEFAULT);
structWriter.createMember(members,1,"Value", IStructSample.STRUCT_TYPE_ENUM,null, ISample.FORMAT_DEFAULT);
structWriter.createMember(members,2,"Other", IStructSample.STRUCT_TYPE_INTEGER,null, ISample.FORMAT_DEFAULT);

members[0].setValue("Off");
members[1].setValue("Inspect");
members[2].setValue(100);
structWriter.write(10000, false, members);
members[0].setValue("On");
members[1].setValue("First");
members[2].setValue(200);
structWriter.write(20000, false, members);
structWriter.attachAssociation(struct2.getPath(), "Delayed//", 20000);
members[0].setValue("Running");
members[1].setValue("First");
members[2].setValue(700);
structWriter.write(30000, false, members);
members[0].setValue("Waiting");
members[1].setValue("Second");
members[2].setValue(750);
structWriter.write(40000, false, members);
members[0].setValue("Running");
members[1].setValue("Second");
members[2].setValue(750);
structWriter.write(50000, false, members);
members[0].setValue("Stopping");
members[1].setValue("Third");
members[2].setValue(950);
structWriter.write(60000, false, members);
members[0].setValue("Off");
members[1].setValue("Third");
members[2].setValue(950);
structWriter.write(70000, false, members);

structWriter =  generator.getWriter(struct2);
members[0].setValue("Off");
members[1].setValue("Inspect");
members[2].setValue(100);
structWriter.write(30000, false, members);
members[0].setValue("On");
members[1].setValue("First");
members[2].setValue(200);
structWriter.write(40000, false, members);
members[0].setValue("Running");
members[1].setValue("First");
members[2].setValue(700);
structWriter.write(50000, false, members);
members[0].setValue("Waiting");
members[1].setValue("Second");
members[2].setValue(750);
structWriter.write(60000, false, members);
members[0].setValue("Running");
members[1].setValue("Second");
members[2].setValue(750);
structWriter.write(70000, false, members);
members[0].setValue("Stopping");
members[1].setValue("Third");
members[2].setValue(950);
structWriter.write(80000, false, members);
members[0].setValue("Off");
members[1].setValue("Third");
members[2].setValue(950);
structWriter.write(90000, false, members);

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


Download Script About the recJs format Open JavaDoc Reference

Result

toem

technical software and tooling

Company

Contact Us

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