J09 Writing signals for gantt diagrams

Gant diagrams require event, event arrays or struct signals. Special content tags allow the diagram to extract the right information.

Gant diagrams is an extended feature (versions >= 1.1)

Enumerated events

Using enumerated events, you can present a simple gant diagram based on its state enum information.

See E03 Adding integer and event signals for more informations about creating event signals.

        Signal event2 = addSignal(signals, "Event2", "Enum events with ints", 
                ProcessType.Discrete, SignalType.Event, SignalDescriptor.DEFAULT);
        Signal event3 = addSignal(signals, "Event3", "Enum events with strings", 
                ProcessType.Discrete, SignalType.Event, SignalDescriptor.DEFAULT);

Enumerated events need either a String or an Integer value. Here some examples how to add samples. Events without (or null) value result into empty gant area.

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

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

Enum array events

Using enum array events, you can add additional informations (e.g. the state + event value).

        Signal event4 = addSignal(signals, "Event4", "2 Enums", 
                ProcessType.Discrete, SignalType.Event, 
                new SignalDescriptor(SignalDescriptor.CONTENT_DEFAULT,2,
                ISample.ACCURACY_DEFAULT,ISample.FORMAT_DEFAULT));
        Signal event5 = addSignal(signals, "Event5", "2 Enums", 
                ProcessType.Discrete, SignalType.Event, 
                new SignalDescriptor(SignalDescriptor.CONTENT_DEFAULT,2,
                ISample.ACCURACY_DEFAULT,ISample.FORMAT_DEFAULT));

Enum array events need either an array of String or int. Here some examples how to add samples. Events without (or null) value result into empty gant area. With addMember, you can add extra infomration for each array element: The name and its content ("STATE" and "EVENT").

        // enum events with arrays
        eventWriter = (IEventSamplesWriter) getWriter(event4);
        eventWriter.addMember("State", "STATE", ISample.FORMAT_SL_TEXT);
        eventWriter.addMember("Event", "EVENT", ISample.FORMAT_SL_TEXT);
        eventWriter.write(10000, false,new String[]{null,"X1"});
        eventWriter.write(30000, false,new String[]{"Starting","X2"});
        eventWriter.attachAssociation(event6.getPath(), "Trigger//", 0);
        eventWriter.write(50000, false,new String[]{"Started","Off"});
        eventWriter.attachAssociation(event5.getPath(), "Trigger//", 5000);
        eventWriter.write(60000, false);
        eventWriter.attachAssociation(event5.getPath(), "Trigger//", 5000);
        eventWriter.write(70000, false,new String[]{"Running","Of2"}); 
        eventWriter.write(80000, false,new String[]{"Stopping","Of3"});    
        eventWriter.write(90000, false,new String[]{"Setopped","Of4"});    
        eventWriter.write(95000, false,new String[]{"Down","X1"});
        
        eventWriter = (IEventSamplesWriter) getWriter(event5);
        eventWriter.addMember("State", "STATE", ISample.FORMAT_SL_TEXT);
        eventWriter.addMember("Event", "EVENT", ISample.FORMAT_SL_TEXT);
        eventWriter.write(10000, false,new String[]{null,"X1"});
        eventWriter.write(50000, false,new String[]{"Starting","X2"});
        eventWriter.write(55000, false,new String[]{"Started","Off"});
        eventWriter.write(65000, false,new String[]{null,"X1"});
        eventWriter.write(68000, false,new String[]{"Running","Of2"}); 
        eventWriter.write(70000, false,new String[]{"Stopping","Of3"});    
        eventWriter.write(90000, false,new String[]{"Setopped","Of4"});    
        eventWriter.write(95000, false,new String[]{"Down","X1"});

Struct signal

Using a struct signal, you can add additional informations of different type (e.g. the state + event value + additional).

See E09 Adding struct signals for more informations about creating struct signals.

        Signal struct1 = addSignal(signals, "Struct1", "A struct signal", 
                ProcessType.Discrete, 
                SignalType.Struct, new SignalDescriptor(
                SignalDescriptor.CONTENT_DEFAULT, -1));
        Signal struct2 = addSignal(signals, "Struct2", "Another struct signal", 
                ProcessType.Discrete, 
                SignalType.Struct, new SignalDescriptor(
                SignalDescriptor.CONTENT_DEFAULT, -1));

The member content infomation ("STATE" and "EVENT") need to be applied in the StructMember instances.

StructMember members[] = new StructMember[3];
        members[0] = new StructMember("State", StructMember.STRUCT_TYPE_LOCAL_ENUM, 
                "STATE", ISamples.FORMAT_DEFAULT);
        members[1] = new StructMember("Value", StructMember.STRUCT_TYPE_ENUM, 
                null, ISamples.FORMAT_DEFAULT);
        members[2] = new StructMember("Other", StructMember.STRUCT_TYPE_INTEGER, 
                null, ISamples.FORMAT_DEFAULT);
        
        IStructSamplesWriter structWriter = (IStructSamplesWriter) getWriter(struct1);
        members[0].setValue(null);
        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(null);
        members[1].setValue("Third");
        members[2].setValue(950);
        structWriter.write(70000, false, members);

Print

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive