XR09 recJs Example: Relations
Outline
This recJs example script shows several event and struct signals with relations.
Platforms |
|
|||
Requirements |
|
|||
Parameters: |
|
|||
Content of example record files |
|
Output
Usage
- Copy the script code onto a file resource with "recJs" ending or use the impulse record examples.
- 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 event, integer and struct signals including relations between the signals.
//-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.ns); var is = generator.addSignal(null, "Init", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.DEFAULT); var gs = generator.addSignal(null, "Generator", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.EventGantt); var bs = generator.addSignal(null, "Buffer", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.EventGantt); var cs = generator.addSignal(null, "Count", "", ProcessType.Discrete, SignalType.Integer, SignalDescriptor.DEFAULT); var ss = generator.addSignal(null, "Send", "", ProcessType.Discrete, SignalType.Event, SignalDescriptor.EventGantt); var logs = generator.addSignal(null, "Logs", "", ProcessType.Discrete, SignalType.Struct, SignalDescriptor.DEFAULT); var i /*:IEventSamplesWriter:*/= generator.getWriter(is); var g /*:IEventSamplesWriter:*/= generator.getWriter(gs); var b /*:IEventSamplesWriter:*/= generator.getWriter(bs); var c /*:IEventSamplesWriter:*/= generator.getWriter(cs); var s /*:IEventSamplesWriter:*/= generator.getWriter(ss); var log /*:IStructSamplesWriter:*/ = generator.getWriter(logs); var members /*:[Lde.toem.impulse.values.StructMember;:*/ = log.createMembers(7); log.createMember(members,0,"Statemachine", ISample.STRUCT_TYPE_INTEGER,null,ISample.FORMAT_HEXADECIMAL); log.createMember(members,1,"Data", ISample.STRUCT_TYPE_INTEGER,null,ISample.FORMAT_HEXADECIMAL); log.createMember(members,2,"Par", ISample.STRUCT_TYPE_INTEGER,null,-1); log.createMember(members,3,"IO", ISample.STRUCT_TYPE_INTEGER,null,-1); log.createMember(members,4,"Seg4", ISample.STRUCT_TYPE_INTEGER,null,ISample.FORMAT_HEXADECIMAL); log.createMember(members,5,"Seg8", ISample.STRUCT_TYPE_INTEGER,null,ISample.FORMAT_HEXADECIMAL); log.createMember(members,6,"Label", ISample.STRUCT_TYPE_TEXT,null,-1); var t = 0; // 0 ns generator.open(t); c.write(t, false,0); i.write(t+100, false,"Start"); i.attachRelation(ISample.AT_ASSOC_DELTA,gs.getPath(), "", 100); function doit(t){ g.write(t+200, false,"Active"); g.attachRelation(ISample.AT_ASSOC_DELTA,gs.getPath(), "Duration", 500); g.write(t+700, false,"Create"); g.write(t+800, false,"Deliver"); g.attachRelation(ISample.AT_ASSOC_DELTA,bs.getPath(), "Deliver", 200); g.write(t+900, false); g.attachRelation(ISample.AT_ASSOC_DELTA,gs.getPath(), "Wait", 300); b.write(t+1000, false,"Active"); c.write(t+1100, false,1); b.write(t+1200, false); g.write(t+1200, false,"Active"); g.attachRelation(ISample.AT_ASSOC_DELTA,gs.getPath(), "Duration", 500); g.write(t+1700, false,"Create"); g.write(t+1800, false,"Deliver"); g.attachRelation(ISample.AT_ASSOC_DELTA,bs.getPath(), "Deliver", 200); g.write(t+1900, false); b.write(t+2000, false,"Active"); c.write(t+2100, false,2); b.write(t+2300, false,"Deliver"); b.attachRelation(ISample.AT_ASSOC_DELTA,ss.getPath(), "Deliver", 100); c.write(t+2300, false,1); b.write(t+2600, false,"Deliver"); b.attachRelation(ISample.AT_ASSOC_DELTA,ss.getPath(), "Deliver", 100); c.write(t+2600, false,0); b.write(t+2800, false); s.write(t+2400, false,"Active"); s.write(t+2500, false,"Send"); s.attachRelation(ISample.AT_ASSOC_DELTA,bs.getPath(), "Response", 100); s.write(t+2600, false,"Active"); s.write(t+2700, false,"Send"); s.attachRelation(ISample.AT_ASSOC_DELTA,bs.getPath(), "Response", 100); s.write(t+2900, false); } doit(0); doit(2000); doit(4000); doit(6000); doit(8000); var id = 0; var addr = 0x1000; for (t=0;t<10000;t+=900){ members[0].setIntValue(addr++); members[1].setIntValue(0x100); members[2].setIntValue(5); members[3].setIntValue(1); members[4].setIntValue(4); members[5].setIntValue(8); members[6].setStringValue("A1"); log.write(t,t%1000 == 0,id,ISample.GO_FIRST,0,members); members[4].setIntValue(8); log.write(t+400,t%1000 == 0,id,ISample.GO_INTER,0,members); members[1].setIntValue(0x200); log.write(t + 700,t%1000 == 0,id,ISample.GO_LAST,0,members); id++; } generator.close(100000);