Search in sources :

Example 1 with DefaultAnnexSubclauseImpl

use of org.osate.aadl2.impl.DefaultAnnexSubclauseImpl in project VERDICT by ge-high-assurance.

the class WzrdClosure method getAppendOffset.

// get the desired starting offset (as in the .aadl) of the generated code-block
private void getAppendOffset(boolean hasAnnex, IPath filePath) {
    DefaultLocationInFileProvider defLoc = new DefaultLocationInFileProvider();
    if (!hasAnnex) {
        ITextRegion region = defLoc.getFullTextRegion(sys);
        try {
            offset = region.getOffset() + region.getLength();
            offTab = getOffsetTab(filePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
        offset = offset - offTab.addOffset;
    } else {
        List<EObject> objs = sys.eContents();
        for (int i = 0; i < objs.size(); i++) {
            if (objs.get(i) instanceof DefaultAnnexSubclauseImpl) {
                if (!((DefaultAnnexSubclauseImpl) objs.get(i)).getName().equals("verdict")) {
                    continue;
                }
                ITextRegion region = defLoc.getFullTextRegion(objs.get(i));
                try {
                    offset = region.getOffset() + region.getLength();
                    offTab = getOffsetTab(filePath);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                // 1 appear here since no semicolon if annex is present
                offset = offset - offTab.addOffset + 1;
                break;
            }
        }
    }
}
Also used : DefaultLocationInFileProvider(org.eclipse.xtext.resource.DefaultLocationInFileProvider) DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) ITextRegion(org.eclipse.xtext.util.ITextRegion) EObject(org.eclipse.emf.ecore.EObject) IOException(java.io.IOException)

Example 2 with DefaultAnnexSubclauseImpl

use of org.osate.aadl2.impl.DefaultAnnexSubclauseImpl in project VERDICT by ge-high-assurance.

the class WzrdDashboard method createContents.

@Override
protected Control createContents(Composite parent) {
    try {
        // re-extract SystemTypeImpl instances from the current (possibly modified) resource
        loadSystems(resource);
    } catch (Exception e) {
        e.printStackTrace();
    }
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(4, false));
    Composite childComposite = new Composite(composite, SWT.NONE);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.horizontalSpan = 4;
    childComposite.setLayout(new GridLayout(1, false));
    childComposite.setLayoutData(gridData);
    // the following clabels define the color legends appearing at the top of dashboard
    CLabel labelFirstLegend = new CLabel(childComposite, SWT.NONE);
    labelFirstLegend.setText("Component with no Cyber-relation Defined");
    labelFirstLegend.setImage(images[0]);
    CLabel labelSecondLegend = new CLabel(childComposite, SWT.NONE);
    labelSecondLegend.setText("Component with One or More Cyber-relation(s) Defined");
    labelSecondLegend.setImage(images[1]);
    CLabel labelThirdLegend = new CLabel(childComposite, SWT.NONE);
    labelThirdLegend.setText("Top-Level System");
    labelThirdLegend.setImage(images[2]);
    // creates a button for each SystemTypeImpl instance in the invoking .aadl file
    for (int i = 0; i < systems.size(); i++) {
        Button aButton = new Button(composite, SWT.PUSH);
        aButton.setText(systems.get(i).getFullName());
        aButton.setToolTipText(composeToolTip(i));
        if (checkIfSystem(systems.get(i))) {
            // system with a corresponding .impl in invoking .aadl
            aButton.setBackground(new Color(Display.getCurrent(), 145, 169, 216));
        } else {
            switch(colorTag) {
                case // component with cyber-relation defined
                0:
                    aButton.setBackground(new Color(Display.getCurrent(), 158, 196, 155));
                    break;
                case // a spare legend, currently not used
                1:
                    aButton.setBackground(new Color(Display.getCurrent(), 247, 135, 135));
                    break;
                case // component with no cyber-relation defined
                2:
                    aButton.setBackground(new Color(Display.getCurrent(), 242, 174, 39));
                    break;
            }
        }
        colorTag = -1;
        // this listener performs necessary activities when a button is selected
        aButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent event) {
                for (int j = 0; j < systems.size(); j++) {
                    if (systems.get(j).getFullName().equals(aButton.getText())) {
                        List<EObject> objs = systems.get(j).eContents();
                        for (int k = 0; k < objs.size(); k++) {
                            if (objs.get(k) instanceof DefaultAnnexSubclauseImpl) {
                                if (!((DefaultAnnexSubclauseImpl) objs.get(k)).getName().equals("verdict")) {
                                    continue;
                                }
                                break;
                            }
                        }
                        // invoking cyber-property editor corresponding to the button
                        StatementEditor editor = new StatementEditor(systems.get(j), fileModel, shell, sourceRect, "dashboard");
                        // run the editor if the invoked editor instance is valid
                        if (editor.isValid()) {
                            composite.setEnabled(false);
                            editor.run();
                            composite.setEnabled(true);
                        }
                        try {
                            // re-extract SystemTypeImpl instances from the current (possibly modified) resource
                            loadSystems(resource);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!aButton.isDisposed()) {
                            // update the toolTipText of the button
                            aButton.setToolTipText(composeToolTip(j));
                            // save the .aadl editor if any unsaved content exists-------------------
                            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                            IEditorPart openEditor = page.getActiveEditor();
                            if (openEditor != null) {
                                page.saveEditor(openEditor, false);
                            }
                            // update button colour
                            if (checkIfSystem(systems.get(j))) {
                                // system with a corresponding .impl in invoking
                                aButton.setBackground(new Color(Display.getCurrent(), 145, 169, 216));
                            // .aadl
                            } else {
                                switch(colorTag) {
                                    case 0:
                                        // component with cyber-relation defined
                                        aButton.setBackground(new Color(Display.getCurrent(), 158, 196, 155));
                                        break;
                                    case 1:
                                        // a spare legend, currently not used
                                        aButton.setBackground(new Color(Display.getCurrent(), 247, 135, 135));
                                        break;
                                    case 2:
                                        // component with no cyber-relation defined
                                        aButton.setBackground(new Color(Display.getCurrent(), 242, 174, 39));
                                        break;
                                }
                            }
                        }
                    }
                }
            }
        });
    }
    return composite;
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) Composite(org.eclipse.swt.widgets.Composite) DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Color(org.eclipse.swt.graphics.Color) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IEditorPart(org.eclipse.ui.IEditorPart) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with DefaultAnnexSubclauseImpl

use of org.osate.aadl2.impl.DefaultAnnexSubclauseImpl in project VERDICT by ge-high-assurance.

the class WzrdTableLoader method getStatements.

// Extract the existing statements of the current component from .aadl script
private List<Statement> getStatements(SystemTypeImpl sys) {
    List<EObject> objs = sys.eContents();
    List<Statement> stmts = new ArrayList<Statement>();
    for (int i = 0; i < objs.size(); i++) {
        if (objs.get(i) instanceof DefaultAnnexSubclauseImpl) {
            if (!((DefaultAnnexSubclauseImpl) objs.get(i)).getName().equals("verdict")) {
                continue;
            }
            Verdict vd = ((VerdictContractSubclause) ((DefaultAnnexSubclauseImpl) objs.get(i)).getParsedAnnexSubclause()).getContract();
            stmts = vd.getElements();
            break;
        }
    }
    return stmts;
}
Also used : DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict) VerdictContractSubclause(com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause)

Example 4 with DefaultAnnexSubclauseImpl

use of org.osate.aadl2.impl.DefaultAnnexSubclauseImpl in project VERDICT by ge-high-assurance.

the class StatementEditor method loadExistingMissions.

// reload the system content to take care of any change saved by used in
// .aadl script in course of current Wizard session
private List<MissionInfo> loadExistingMissions(SystemTypeImpl sys) {
    List<MissionInfo> missions = new ArrayList<MissionInfo>();
    TreeIterator<EObject> tree = sys.eAllContents();
    while (tree.hasNext()) {
        EObject tmp = tree.next();
        if (tmp instanceof DefaultAnnexSubclauseImpl) {
            if (!((DefaultAnnexSubclauseImpl) tmp).getName().equals("verdict")) {
                continue;
            }
            Verdict vd = ((VerdictContractSubclause) ((DefaultAnnexSubclauseImpl) tmp).getParsedAnnexSubclause()).getContract();
            List<Statement> stmts = vd.getElements();
            for (int i = 0; i < stmts.size(); i++) {
                if (stmts.get(i) instanceof CyberMissionImpl) {
                    MissionInfo newMission = new MissionInfo();
                    newMission.setMissionID(((CyberMissionImpl) stmts.get(i)).getId());
                    List<String> cyberReqs = ((CyberMissionImpl) stmts.get(i)).getCyberReqs();
                    for (int j = 0; j < cyberReqs.size(); j++) {
                        for (int k = 0; k < tableContent.size(); k++) {
                            if (tableContent.get(k).getFormulaID().equals(cyberReqs.get(j))) {
                                newMission.addToRow(k);
                            }
                        }
                    }
                    newMission.setComment(((CyberMissionImpl) stmts.get(i)).getNote());
                    newMission.setDescription(((CyberMissionImpl) stmts.get(i)).getDescription());
                    missions.add(newMission);
                }
            }
        }
    }
    return missions;
}
Also used : DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) Statement(com.ge.research.osate.verdict.dsl.verdict.Statement) ArrayList(java.util.ArrayList) VerdictContractSubclause(com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause) EObject(org.eclipse.emf.ecore.EObject) CyberMissionImpl(com.ge.research.osate.verdict.dsl.verdict.impl.CyberMissionImpl) Verdict(com.ge.research.osate.verdict.dsl.verdict.Verdict)

Example 5 with DefaultAnnexSubclauseImpl

use of org.osate.aadl2.impl.DefaultAnnexSubclauseImpl in project AMASE by loonwerks.

the class FaultsVerifyAllHandler method isProbabilisticAnalysis.

private boolean isProbabilisticAnalysis() {
    List<Classifier> classifiers = getClassifiers();
    if (classifiers == null) {
        return false;
    }
    // TODO: Finish addressing this issue.
    for (Classifier cl : classifiers) {
        // Get impl of this level
        if (cl instanceof ComponentImplementationImpl) {
            List<AnnexSubclause> asList = cl.getOwnedAnnexSubclauses();
            for (AnnexSubclause as : asList) {
                if (as.getName().equalsIgnoreCase("safety")) {
                    if (as instanceof DefaultAnnexSubclauseImpl) {
                        DefaultAnnexSubclauseImpl defaultAnnex = (DefaultAnnexSubclauseImpl) as;
                        SafetyContractSubclauseImpl safetyAnnex = (SafetyContractSubclauseImpl) defaultAnnex.getParsedAnnexSubclause();
                        // Get analysis stmt
                        List<SpecStatement> specs = ((SafetyContract) safetyAnnex.getContract()).getSpecs();
                        for (SpecStatement spec : specs) {
                            if (spec instanceof AnalysisStatement) {
                                if (!(((AnalysisStatement) spec).getBehavior() instanceof ProbabilityBehavior)) {
                                    return false;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return true;
}
Also used : SafetyContractSubclauseImpl(edu.umn.cs.crisys.safety.safety.impl.SafetyContractSubclauseImpl) AnalysisStatement(edu.umn.cs.crisys.safety.safety.AnalysisStatement) ComponentImplementationImpl(org.osate.aadl2.impl.ComponentImplementationImpl) DefaultAnnexSubclauseImpl(org.osate.aadl2.impl.DefaultAnnexSubclauseImpl) ProbabilityBehavior(edu.umn.cs.crisys.safety.safety.ProbabilityBehavior) SpecStatement(edu.umn.cs.crisys.safety.safety.SpecStatement) Classifier(org.osate.aadl2.Classifier) SafetyContract(edu.umn.cs.crisys.safety.safety.SafetyContract) AnnexSubclause(org.osate.aadl2.AnnexSubclause)

Aggregations

DefaultAnnexSubclauseImpl (org.osate.aadl2.impl.DefaultAnnexSubclauseImpl)9 ArrayList (java.util.ArrayList)6 EObject (org.eclipse.emf.ecore.EObject)6 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)5 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)5 VerdictContractSubclause (com.ge.research.osate.verdict.dsl.verdict.VerdictContractSubclause)5 CyberMissionImpl (com.ge.research.osate.verdict.dsl.verdict.impl.CyberMissionImpl)2 SafetyContract (edu.umn.cs.crisys.safety.safety.SafetyContract)2 SpecStatement (edu.umn.cs.crisys.safety.safety.SpecStatement)2 SafetyContractSubclauseImpl (edu.umn.cs.crisys.safety.safety.impl.SafetyContractSubclauseImpl)2 AnnexSubclause (org.osate.aadl2.AnnexSubclause)2 Classifier (org.osate.aadl2.Classifier)2 SystemTypeImpl (org.osate.aadl2.impl.SystemTypeImpl)2 CyberRelImpl (com.ge.research.osate.verdict.dsl.verdict.impl.CyberRelImpl)1 CyberReqImpl (com.ge.research.osate.verdict.dsl.verdict.impl.CyberReqImpl)1 AnalysisStatement (edu.umn.cs.crisys.safety.safety.AnalysisStatement)1 ProbabilityBehavior (edu.umn.cs.crisys.safety.safety.ProbabilityBehavior)1 FaultStatementImpl (edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl)1 IOException (java.io.IOException)1 List (java.util.List)1