Search in sources :

Example 6 with Lifeline

use of org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline in project titan.EclipsePlug-ins by eclipse.

the class MSCModel method getModelFrame.

/**
 * @return the frame
 */
public Frame getModelFrame() {
    if (this.model == null) {
        return null;
    }
    this.frame = new Frame(this);
    this.frame.setName(this.model.getTestCase().getTestCaseName());
    List<EventObject> events = this.model.getLifelineInformation();
    if (sutLifeline == null) {
        this.sutLifeline = new Lifeline();
    }
    for (EventObject event : events) {
        int eventNumber = event.getEventNumber();
        sutLifeline.setCurrentEventOccurrence(eventNumber);
        extractLifeLineAndHeaderNodes(event, eventNumber);
    }
    sutLifeline.setCurrentEventOccurrence(model.getNumberOfEvents());
    return this.frame;
}
Also used : Frame(org.eclipse.titan.log.viewer.views.msc.ui.core.Frame) Lifeline(org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline)

Example 7 with Lifeline

use of org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline in project titan.EclipsePlug-ins by eclipse.

the class MSCModel method extractNodes.

/**
 * Extracts the nodes from the provided event object.
 *
 * @param ievent the event to extract the data from.
 * @param occurrence the number at which time this event happened in its order.
 *
 * @return the resulting list of nodes.
 */
private MSCNode[] extractNodes(final IEventObject ievent, final int occurrence) {
    if (!(ievent instanceof EventObject)) {
        return new MSCNode[] {};
    }
    EventObject event = (EventObject) ievent;
    String ref = event.getReference();
    String target = event.getTarget();
    String name = event.getName();
    String time = event.getTime();
    String type = event.getEventType();
    String sourcePort = event.getPort();
    String targetPort = event.getTargetPort();
    switch(event.getType()) {
        // TC start
        case TC_START:
            return testCaseStart(name, time, this.frame.lifeLinesCount(), occurrence);
        // TC end
        case TC_END:
            return testCaseEnd(name, time, this.frame.lifeLinesCount(), occurrence);
        // Creation of System Component
        case SYSTEM_CREATE:
            ref = Constants.SUT_REFERENCE;
            return createComponent(ref, time, this.lifelines.get(ref), occurrence);
        // Creation of Host Controller (HC)
        case HC_CREATE:
            ref = Constants.HC_REFERENCE;
            return createComponent(ref, time, this.lifelines.get(ref), occurrence);
        // Creation of Main Test Component (MTC)
        case MTC_CREATE:
            {
                ref = Constants.MTC_REFERENCE;
                Lifeline lifeLine = this.lifelines.get(ref);
                return createComponent(ref, time, lifeLine, occurrence);
            }
        // Creation of Parallel Test Component (PTC)
        case PTC_CREATE:
            return createComponent(ref, time, this.lifelines.get(ref), occurrence);
        // Termination of System Component
        case SYSTEM_TERMINATE:
            ref = Constants.SUT_REFERENCE;
            return terminateComponent(ref, time, occurrence);
        // Termination of Host Controller (HC)
        case HC_TERMINATE:
            ref = Constants.HC_REFERENCE;
            return terminateComponent(ref, time, occurrence);
        // Termination of Main Test Component (MTC)
        case MTC_TERMINATE:
            ref = Constants.MTC_REFERENCE;
            return terminateComponent(ref, time, occurrence);
        // Termination of Parallel Test Component (PTC)
        case PTC_TERMINATE:
            return terminateComponent(ref, time, occurrence);
        // Messages
        case SEND:
            return addSignal(new SendSignal(), ref, target, name, time, occurrence);
        case RECEIVE:
            return addSignal(new ReceiveSignal(), ref, target, name, time, occurrence);
        // Enqueued messages
        case ENQUEUED:
            return addEnqueued(ref, target, name, time, occurrence);
        // Silent events
        case SILENT_EVENT:
            LogRecord logrecord = null;
            try {
                logrecord = ValueReader.getInstance().readLogRecordFromLogFile(this.logFilePath, event);
            } catch (final IOException valueException) {
                return addSilentEvent(ref, "", type, time, occurrence);
            } catch (final ParseException e) {
                return addSilentEvent(ref, "", type, time, occurrence);
            }
            String messageText = getMessageTextFromRecord(logrecord);
            return addSilentEvent(ref, messageText, type, time, occurrence);
        // Functions
        case FUNCTION:
            return addFunctionNode(new Function(), ref, target, name, time, occurrence);
        // Function done
        case PTC_DONE:
            return addFunctionNode(new FunctionDone(), ref, target, name, time, occurrence);
        // Setverdict
        case SETVERDICT:
        case SETVERDICT_INCONC:
        case SETVERDICT_NONE:
        case SETVERDICT_PASS:
            return addSetVerdict(ref, name, time, occurrence);
        // Port mappings
        case MAPPING_PORT:
            return addPortEventNode(new PortMapping(sourcePort, targetPort), ref, target, time, occurrence);
        // Port unmappings
        case UNMAPPING_PORT:
            return addPortEventNode(new PortUnmapping(sourcePort, targetPort), ref, target, time, occurrence);
        // Port connections
        case CONNECTING_PORT:
            return addPortEventNode(new PortConnection(sourcePort, targetPort), ref, target, time, occurrence);
        // Port disconnections
        case DISCONNECTING_PORT:
            return addPortEventNode(new PortDisconnection(sourcePort, targetPort), ref, target, time, occurrence);
        default:
            return new MSCNode[] {};
    }
}
Also used : Lifeline(org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline) MSCNode(org.eclipse.titan.log.viewer.views.msc.ui.core.MSCNode) PortUnmapping(org.eclipse.titan.log.viewer.views.msc.ui.core.PortUnmapping) SendSignal(org.eclipse.titan.log.viewer.views.msc.ui.core.SendSignal) IOException(java.io.IOException) ReceiveSignal(org.eclipse.titan.log.viewer.views.msc.ui.core.ReceiveSignal) PortConnection(org.eclipse.titan.log.viewer.views.msc.ui.core.PortConnection) Function(org.eclipse.titan.log.viewer.views.msc.ui.core.Function) LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) FunctionDone(org.eclipse.titan.log.viewer.views.msc.ui.core.FunctionDone) ParseException(java.text.ParseException) PortMapping(org.eclipse.titan.log.viewer.views.msc.ui.core.PortMapping) PortDisconnection(org.eclipse.titan.log.viewer.views.msc.ui.core.PortDisconnection)

Example 8 with Lifeline

use of org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline in project titan.EclipsePlug-ins by eclipse.

the class MSCModel method getNodes.

/**
 * Collects the nodes that belong to the range provided.
 *
 * @param startIndex the index of the first event to process.
 * @param endIndex the index of the last event to process.
 *
 * @return the list of the found nodes.
 */
public List<MSCNode> getNodes(final int startIndex, final int endIndex) {
    if (sutLifeline == null) {
        this.sutLifeline = new Lifeline();
    }
    List<IEventObject> events = this.model.getEvents(startIndex, endIndex);
    List<MSCNode> result = new ArrayList<MSCNode>();
    for (int i = 0; i < 3; i++) {
        MSCNode[] nodes = extractNodes(events.get(i), i);
        for (MSCNode node : nodes) {
            if (!(node instanceof Lifeline) && !(node instanceof LifelineHeader)) {
                result.add(node);
            }
        }
    }
    for (int i = 3; i < events.size(); i++) {
        MSCNode[] nodes = extractNodes(events.get(i), startIndex + i);
        for (MSCNode node : nodes) {
            if (!(node instanceof Lifeline) && !(node instanceof LifelineHeader)) {
                result.add(node);
            }
        }
    }
    return result;
}
Also used : Lifeline(org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline) MSCNode(org.eclipse.titan.log.viewer.views.msc.ui.core.MSCNode) ArrayList(java.util.ArrayList) LifelineHeader(org.eclipse.titan.log.viewer.views.msc.ui.core.LifelineHeader)

Example 9 with Lifeline

use of org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline in project titan.EclipsePlug-ins by eclipse.

the class MSCView method setModel.

public void setModel(final ExecutionModel model, final int firstRow) {
    if ((this.logFileMetaData == null) || (model == null)) {
        return;
    }
    // Create MSCModel
    String sutName = PreferencesHandler.getInstance().getPreferences(this.logFileMetaData.getProjectName()).getSutName();
    if (sutName.length() == 0) {
        sutName = MSCConstants.SUT_NAME;
    }
    this.model = model;
    MSCModel mscModel = new MSCModel(model, this.logFileMetaData, sutName);
    Frame frame = mscModel.getModelFrame();
    // Change order of components according to preferences
    List<String> visualOrderComponents = PreferencesHandler.getInstance().getPreferences(this.logFileMetaData.getProjectName()).getVisualOrderComponents();
    for (int i = visualOrderComponents.size() - 1; i >= 0; i--) {
        String currentComp = visualOrderComponents.get(i);
        if (currentComp.contentEquals(Constants.SUT)) {
            currentComp = sutName;
        } else if (currentComp.contentEquals(Constants.MTC)) {
            currentComp = MSCConstants.MTC_NAME;
        }
        for (int j = 1; j < frame.lifeLinesCount(); j++) {
            Lifeline lifeLine = frame.getLifeline(j);
            if (lifeLine.getName().contentEquals(currentComp)) {
                // Move to first position
                frame.moveLifeLineToPosition(lifeLine, 1);
            }
        }
    }
    setPartName(frame.getName());
    setFrame(frame, true);
    setContentDescription(this.logFileMetaData.getProjectRelativePath());
    int verdict = model.getTestCase().getVerdict();
    switch(verdict) {
        case Constants.VERDICT_PASS:
            setTitleImage(Activator.getDefault().getIcon(Constants.ICONS_PASS));
            break;
        case Constants.VERDICT_FAIL:
            setTitleImage(Activator.getDefault().getIcon(Constants.ICONS_FAIL));
            break;
        case Constants.VERDICT_ERROR:
            setTitleImage(Activator.getDefault().getIcon(Constants.ICONS_ERROR));
            break;
        case Constants.VERDICT_INCONCLUSIVE:
            setTitleImage(Activator.getDefault().getIcon(Constants.ICONS_INCONCLUSIVE));
            break;
        // Verdict NONE is default
        default:
            setTitleImage(Activator.getDefault().getIcon(Constants.ICONS_NONE));
            break;
    }
    if (this.mscWidget != null) {
        this.mscWidget.setSelection(new StructuredSelection(firstRow));
    }
}
Also used : Frame(org.eclipse.titan.log.viewer.views.msc.ui.core.Frame) Lifeline(org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MSCModel(org.eclipse.titan.log.viewer.views.msc.model.MSCModel)

Example 10 with Lifeline

use of org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline in project titan.EclipsePlug-ins by eclipse.

the class MSCModel method terminateLifeLineComponent.

private void terminateLifeLineComponent(final String ref, final String time, final int occurrence) {
    // Get life line
    Lifeline tmpLifeline = this.lifelines.get(ref);
    if (tmpLifeline == null) {
        return;
    }
    // Get name
    String name = getComponentNameFromReference(ref);
    if (!name.contentEquals(this.sutName) && !name.contentEquals(MSCConstants.MTC_NAME) && !name.contentEquals(ref)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        name = name + " (" + ref + ")";
    }
    // Create and add stop
    String verdict = getComponentVerdictFromReference(ref);
    ComponentTermination stop = new ComponentTermination(occurrence, tmpLifeline, verdict);
    stop.setName(name);
    tmpLifeline.setStop(stop);
}
Also used : Lifeline(org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline) ComponentTermination(org.eclipse.titan.log.viewer.views.msc.ui.core.ComponentTermination)

Aggregations

Lifeline (org.eclipse.titan.log.viewer.views.msc.ui.core.Lifeline)14 MSCNode (org.eclipse.titan.log.viewer.views.msc.ui.core.MSCNode)9 TimeStampNode (org.eclipse.titan.log.viewer.views.msc.ui.core.TimeStampNode)7 ComponentTermination (org.eclipse.titan.log.viewer.views.msc.ui.core.ComponentTermination)2 Frame (org.eclipse.titan.log.viewer.views.msc.ui.core.Frame)2 LifelineHeader (org.eclipse.titan.log.viewer.views.msc.ui.core.LifelineHeader)2 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 LogRecord (org.eclipse.titan.log.viewer.parsers.data.LogRecord)1 MSCModel (org.eclipse.titan.log.viewer.views.msc.model.MSCModel)1 Enqueued (org.eclipse.titan.log.viewer.views.msc.ui.core.Enqueued)1 Function (org.eclipse.titan.log.viewer.views.msc.ui.core.Function)1 FunctionDone (org.eclipse.titan.log.viewer.views.msc.ui.core.FunctionDone)1 PortConnection (org.eclipse.titan.log.viewer.views.msc.ui.core.PortConnection)1 PortDisconnection (org.eclipse.titan.log.viewer.views.msc.ui.core.PortDisconnection)1 PortMapping (org.eclipse.titan.log.viewer.views.msc.ui.core.PortMapping)1 PortUnmapping (org.eclipse.titan.log.viewer.views.msc.ui.core.PortUnmapping)1