diff --git a/alisa/org.osate.verify/META-INF/MANIFEST.MF b/alisa/org.osate.verify/META-INF/MANIFEST.MF index 194f29b57bc..bd3fc883f09 100644 --- a/alisa/org.osate.verify/META-INF/MANIFEST.MF +++ b/alisa/org.osate.verify/META-INF/MANIFEST.MF @@ -25,7 +25,7 @@ Require-Bundle: org.eclipse.xtext;bundle-version="[2.20.0,3.0.0)";visibility:=re org.junit;bundle-version="[4.11.0,5.0.0)", org.osate.analysis.architecture;bundle-version="[2.0.0,3.0.0)", org.osate.analysis.flows;bundle-version="[5.0.0,6.0.0)", - org.osate.analysis.resource.budgets;bundle-version="[4.0.0,5.0.0)", + org.osate.analysis.resource.budgets;bundle-version="[4.1.0,5.0.0)", org.osate.analysis.resource.management;bundle-version="[4.0.0,5.0.0)", org.eclipse.core.runtime;bundle-version="[3.10.0,4.0.0)", org.eclipse.core.resources;bundle-version="[3.9.1,4.0.0)", diff --git a/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/PortConnectionConsistency.java b/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/PortConnectionConsistency.java index 2f10b4cbe32..2c8a87acb67 100644 --- a/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/PortConnectionConsistency.java +++ b/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/PortConnectionConsistency.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -28,8 +28,6 @@ import org.osate.aadl2.EnumerationLiteral; import org.osate.aadl2.NamedElement; import org.osate.aadl2.RecordValue; -import org.osate.aadl2.contrib.aadlproject.SizeUnits; -import org.osate.aadl2.contrib.util.AadlContribUtils; import org.osate.aadl2.instance.ConnectionInstance; import org.osate.aadl2.instance.ConnectionInstanceEnd; import org.osate.aadl2.instance.FeatureInstance; @@ -82,8 +80,8 @@ public void doHeaders() { } public void checkPortConsistency(FeatureInstance srcFI, FeatureInstance dstFI, ConnectionInstance conni) { - double srcDataSize = AadlContribUtils.getDataSize(srcFI, SizeUnits.BYTES); - double dstDataSize = AadlContribUtils.getDataSize(dstFI, SizeUnits.BYTES); + double srcDataSize = GetProperties.getSourceDataSizeInBytes(srcFI); + double dstDataSize = GetProperties.getSourceDataSizeInBytes(dstFI); RecordValue srcRate = GetProperties.getOutPutRate(srcFI); RecordValue dstRate = GetProperties.getInPutRate(dstFI); @@ -119,12 +117,10 @@ public void checkPortConsistency(FeatureInstance srcFI, FeatureInstance dstFI, C + " Bytes differ"); } } else { - if (srcDataSize == 0 && dstDataSize > 0) { + if (srcDataSize == 0 && dstDataSize > 0) error(conni, "Source data size is missing or zero"); - } - if (dstDataSize == 0 && srcDataSize > 0) { + if (dstDataSize == 0 && srcDataSize > 0) error(conni, "Destination data size is missing or zero"); - } } if (srcRU != null && dstRU != null && srcRU != dstRU) { @@ -153,12 +149,10 @@ public void checkPortConsistency(FeatureInstance srcFI, FeatureInstance dstFI, C "Source data rate " + srcRateValue + " and destination data rate " + dstRateValue + " differ"); } } else { - if (srcRateValue == 0 && dstRateValue > 0) { + if (srcRateValue == 0 && dstRateValue > 0) error(conni, "Source data rate is missing or zero"); - } - if (dstRateValue == 0 && srcRateValue > 0) { + if (dstRateValue == 0 && srcRateValue > 0) error(conni, "Destination data rate is missing or zero"); - } } if (srcC != null && dstC != null) { @@ -167,12 +161,10 @@ public void checkPortConsistency(FeatureInstance srcFI, FeatureInstance dstFI, C + " differ"); } } else { - if (srcC == null && dstC != null) { + if (srcC == null && dstC != null) error(conni, "Source base type is missing"); - } - if (dstC == null && srcC != null) { + if (dstC == null && srcC != null) error(conni, "Destination base type is missing"); - } } if (srcS.length() > 0 && dstS.length() > 0) { @@ -181,12 +173,10 @@ public void checkPortConsistency(FeatureInstance srcFI, FeatureInstance dstFI, C "Source measurement unit " + srcS + " and destination measurement unit " + dstS + " differ"); } } else { - if (srcS.length() == 0 && dstS.length() > 0) { + if (srcS.length() == 0 && dstS.length() > 0) error(conni, "Source measurement unit is missing"); - } - if (dstS.length() == 0 && srcS.length() > 0) { + if (dstS.length() == 0 && srcS.length() > 0) error(conni, "Destination measurement unit is missing"); - } } } @@ -195,9 +185,8 @@ public void checkPortConsistency(FeatureInstance srcFI, FeatureInstance dstFI, C protected void error(NamedElement el, String s) { super.error(el, s); if (previousNE == null || previousNE != el) { - if (previousNE != null) { + if (previousNE != null) handler.logInfo(""); - } handler.logInfo(el.getName() + "," + s); } else { handler.logInfo("," + s); diff --git a/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/PropertyTotals.java b/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/PropertyTotals.java index 50202f4ff67..080f137d4d6 100644 --- a/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/PropertyTotals.java +++ b/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/PropertyTotals.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -23,8 +23,6 @@ */ package org.osate.analysis.architecture; -import java.util.EnumSet; - import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.emf.common.util.EList; @@ -32,13 +30,9 @@ import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.ConnectionInstance; import org.osate.aadl2.instance.ConnectionInstanceEnd; -import org.osate.aadl2.instance.ConnectionKind; import org.osate.aadl2.instance.FeatureCategory; import org.osate.aadl2.instance.FeatureInstance; import org.osate.aadl2.modelsupport.modeltraversal.AadlProcessingSwitchWithProgress; -import org.osate.contribution.sei.sei.Sei; -import org.osate.contribution.sei.sei.Weightunits; -import org.osate.pluginsupport.properties.PropertyUtils; import org.osate.result.AnalysisResult; import org.osate.result.Diagnostic; import org.osate.result.DiagnosticType; @@ -47,6 +41,7 @@ import org.osate.result.ResultFactory; import org.osate.result.util.ResultUtil; import org.osate.ui.handlers.AbstractAaxlHandler; +import org.osate.xtext.aadl2.properties.util.GetProperties; /** * @author phf @@ -79,7 +74,7 @@ private double calcPrice(ComponentInstance ci) { for (ComponentInstance subi : cil) { price += calcPrice(subi); } - price += Sei.getPrice(ci).orElse(0.0); + price += GetProperties.getPrice(ci, 0.0); return price; } @@ -143,19 +138,13 @@ public static AnalysisResult invoke(ComponentInstance ci) { return result; } - private static final EnumSet hasWeight = EnumSet.of(ComponentCategory.SYSTEM, - ComponentCategory.PROCESSOR, ComponentCategory.MEMORY, ComponentCategory.BUS, ComponentCategory.DEVICE, - ComponentCategory.ABSTRACT); - private static Result calcWeight(ComponentInstance ci, boolean needWeight) { Result result = ResultFactory.eINSTANCE.createResult(); result.setModelElement(ci); - final boolean getWeight = hasWeight.contains(ci.getCategory()); - final double net = getWeight ? PropertyUtils.getScaled(Sei::getNetweight, ci, Weightunits.KG).orElse(0.0) : 0.0; + final double net = GetProperties.getNetWeight(ci, 0.0); double weight = 0.0; - final double gross = getWeight ? PropertyUtils.getScaled(Sei::getGrossweight, ci, Weightunits.KG).orElse(0.0) - : 0.0; + final double gross = GetProperties.getGrossWeight(ci, 0.0); double sublimit = 0.0; EList cil = ci.getComponentInstances(); for (ComponentInstance subi : cil) { @@ -166,9 +155,7 @@ private static Result calcWeight(ComponentInstance ci, boolean needWeight) { result.getSubResults().add(subresult); double subweight = ResultUtil.getReal(subresult, 0); weight += subweight; - sublimit += hasWeight.contains(subi.getCategory()) - ? PropertyUtils.getScaled(Sei::getWeightlimit, subi, Weightunits.KG).orElse(0.0) - : 0.0; + sublimit += GetProperties.getWeightLimit(subi, 0.0); } } EList connl = ci.getConnectionInstances(); @@ -179,10 +166,8 @@ private static Result calcWeight(ComponentInstance ci, boolean needWeight) { && ((FeatureInstance) source).getCategory() == FeatureCategory.BUS_ACCESS) || (destination instanceof FeatureInstance && ((FeatureInstance) destination).getCategory() == FeatureCategory.BUS_ACCESS)) { - double netconn = PropertyUtils.getScaled(Sei::getNetweight, connectionInstance, Weightunits.KG) - .orElse(0.0); - double grossconn = PropertyUtils.getScaled(Sei::getGrossweight, connectionInstance, Weightunits.KG) - .orElse(0.0); + double netconn = GetProperties.getNetWeight(connectionInstance, 0.0); + double grossconn = GetProperties.getGrossWeight(connectionInstance, 0.0); weight += netconn > 0 ? netconn : grossconn; if (netconn > 0 || grossconn > 0) { String ResultMsg = String.format( @@ -190,9 +175,7 @@ private static Result calcWeight(ComponentInstance ci, boolean needWeight) { netconn > 0 ? netconn : grossconn); result.getDiagnostics().add(ResultUtil.createInfoDiagnostic(ResultMsg, connectionInstance)); } - sublimit += connectionInstance.getKind() == ConnectionKind.ACCESS_CONNECTION - ? PropertyUtils.getScaled(Sei::getWeightlimit, connectionInstance, Weightunits.KG).orElse(0.0) - : 0.0; + sublimit += GetProperties.getWeightLimit(connectionInstance, 0.0); } } if (weight == 0.0 && cil.isEmpty()) { @@ -223,8 +206,7 @@ private static Result calcWeight(ComponentInstance ci, boolean needWeight) { weight = gross; } } - final double limit = getWeight ? PropertyUtils.getScaled(Sei::getWeightlimit, ci, Weightunits.KG).orElse(0.0) - : 0.0; + final double limit = GetProperties.getWeightLimit(ci, 0.0); if (limit > 0.0) { if (weight > limit) { // problem diff --git a/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/handlers/CheckBindingConstraints.java b/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/handlers/CheckBindingConstraints.java index 9f2def24842..3abc0930955 100644 --- a/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/handlers/CheckBindingConstraints.java +++ b/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/handlers/CheckBindingConstraints.java @@ -52,7 +52,6 @@ import org.osate.aadl2.Element; import org.osate.aadl2.EnumerationLiteral; import org.osate.aadl2.NamedElement; -import org.osate.aadl2.contrib.deployment.DeploymentProperties; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.ConnectionInstance; import org.osate.aadl2.instance.FeatureCategory; @@ -264,10 +263,9 @@ private static List checkRequiredAndProvided(Stream b return bindingElements.flatMap(element -> { Set required = Collections.unmodifiableSet(new HashSet<>(getRequired.apply(element))); if (!required.isEmpty()) { - return DeploymentProperties.getActualConnectionBinding(element).orElse(Collections.emptyList()).stream() - .flatMap(boundElement -> { + return GetProperties.getActualConnectionBinding(element).stream().flatMap(boundElement -> { Set missingSet = new HashSet<>(required); - missingSet.removeAll(getProvided.apply((ComponentInstance) boundElement)); + missingSet.removeAll(getProvided.apply(boundElement)); return missingSet.stream().map(missing -> { StringBuilder message = new StringBuilder(getTitle(element)); message.append(" '"); diff --git a/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/handlers/MissRateProperties.java b/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/handlers/MissRateProperties.java index f67084e5abf..f4e97d8d54d 100644 --- a/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/handlers/MissRateProperties.java +++ b/analyses/org.osate.analysis.architecture/src/org/osate/analysis/architecture/handlers/MissRateProperties.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -34,10 +34,6 @@ import org.osate.contribution.sei.names.SEI; import org.osate.xtext.aadl2.properties.util.GetProperties; -/** - * @deprecated Will be removed in 2.10.0. Dead code. If you are using this for some reason, replace it with {@link SEI#getStreammissrate}. - */ -@Deprecated public class MissRateProperties { public static double getStreamMissRate(final NamedElement ph) throws InvalidModelException, diff --git a/analyses/org.osate.analysis.flows.tests/src/org/osate/analysis/flows/tests/ReferenceProcessorScalingTest.xtend b/analyses/org.osate.analysis.flows.tests/src/org/osate/analysis/flows/tests/ReferenceProcessorScalingTest.xtend index dd52f78b6dc..0b1ee69374a 100644 --- a/analyses/org.osate.analysis.flows.tests/src/org/osate/analysis/flows/tests/ReferenceProcessorScalingTest.xtend +++ b/analyses/org.osate.analysis.flows.tests/src/org/osate/analysis/flows/tests/ReferenceProcessorScalingTest.xtend @@ -68,8 +68,8 @@ class ReferenceProcessorScalingTest extends XtextTest { var checker = new FlowLatencyAnalysisSwitch() var latencyresult = checker.invoke(instance, som,true,true,false,true, false) val resab = latencyresult.results.get(0) - assertEquals(200.0, (resab.values.get(1) as RealValue).value, 0.0) - assertEquals(400.0, (resab.values.get(2) as RealValue).value, 0.0) + assertTrue((resab.values.get(1) as RealValue).value == (200.0)) + assertTrue((resab.values.get(2) as RealValue).value == (400.0)) // instantiate val sysImplu = cls.findFirst[name == 'top.iu'] as SystemImplementation @@ -80,8 +80,8 @@ class ReferenceProcessorScalingTest extends XtextTest { checker = new FlowLatencyAnalysisSwitch() latencyresult = checker.invoke(instanceu, som,true,true,false,true, false) val rescd = latencyresult.results.get(0) - assertEquals(50.0, (rescd.values.get(1) as RealValue).value, 0.0) - assertEquals(100.0, (rescd.values.get(2) as RealValue).value, 0.0) + assertTrue((rescd.values.get(1) as RealValue).value == (50.0)) + assertTrue((rescd.values.get(2) as RealValue).value == (100.0)) } } diff --git a/analyses/org.osate.analysis.flows/META-INF/MANIFEST.MF b/analyses/org.osate.analysis.flows/META-INF/MANIFEST.MF index f767011f560..0ef48cce8d2 100644 --- a/analyses/org.osate.analysis.flows/META-INF/MANIFEST.MF +++ b/analyses/org.osate.analysis.flows/META-INF/MANIFEST.MF @@ -15,8 +15,8 @@ Export-Package: org.osate.analysis.flows, org.osate.analysis.flows.reporting.model Require-Bundle: org.osate.aadl2;bundle-version="[4.0.0,5.0.0)", org.osate.aadl2.modelsupport;bundle-version="[6.0.0,7.0.0)", - org.osate.ui;bundle-version="[6.2.0,7.0.0)", - org.osate.xtext.aadl2.properties;bundle-version="[3.1.0,4.0.0)", + org.osate.ui;bundle-version="[6.1.0,7.0.0)", + org.osate.xtext.aadl2.properties;bundle-version="[3.0.0,4.0.0)", org.osate.contribution.sei;bundle-version="[1.2.0,3.0.0)", org.osate.pluginsupport;bundle-version="[7.1.0,8.0.0)", org.osate.aadl2.contrib;bundle-version="[1.1.0,2.0.0)", diff --git a/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/FlowLatencyAnalysisSwitch.java b/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/FlowLatencyAnalysisSwitch.java index 0e1d5fc6781..b690d2e64a6 100644 --- a/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/FlowLatencyAnalysisSwitch.java +++ b/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/FlowLatencyAnalysisSwitch.java @@ -24,21 +24,17 @@ package org.osate.analysis.flows; import java.util.Collections; -import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.TreeSet; import java.util.function.Function; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.emf.ecore.EObject; import org.eclipse.xtext.EcoreUtil2; -import org.osate.aadl2.Aadl2Package; import org.osate.aadl2.Classifier; import org.osate.aadl2.ComponentCategory; import org.osate.aadl2.ComponentClassifier; @@ -46,14 +42,7 @@ import org.osate.aadl2.FlowEnd; import org.osate.aadl2.NamedElement; import org.osate.aadl2.Property; -import org.osate.aadl2.PropertyAssociation; -import org.osate.aadl2.contrib.aadlproject.SizeUnits; -import org.osate.aadl2.contrib.aadlproject.TimeUnits; -import org.osate.aadl2.contrib.communication.CommunicationProperties; -import org.osate.aadl2.contrib.communication.TransmissionTime; -import org.osate.aadl2.contrib.deployment.DeploymentProperties; -import org.osate.aadl2.contrib.timing.TimingProperties; -import org.osate.aadl2.contrib.util.AadlContribUtils; +import org.osate.aadl2.UnitLiteral; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.ConnectionInstance; import org.osate.aadl2.instance.EndToEndFlowInstance; @@ -66,9 +55,6 @@ import org.osate.aadl2.instance.SystemOperationMode; import org.osate.aadl2.instance.util.InstanceSwitch; import org.osate.aadl2.modelsupport.modeltraversal.AadlProcessingSwitchWithProgress; -import org.osate.aadl2.modelsupport.scoping.Aadl2GlobalScopeUtil; -import org.osate.aadl2.properties.PropertyAcc; -import org.osate.analysis.flows.internal.utils.AnalysisUtils; import org.osate.analysis.flows.internal.utils.FlowLatencyUtil; import org.osate.analysis.flows.model.LatencyCSVReport; import org.osate.analysis.flows.model.LatencyContributor; @@ -77,14 +63,15 @@ import org.osate.analysis.flows.model.LatencyContributorConnection; import org.osate.analysis.flows.model.LatencyReport; import org.osate.analysis.flows.model.LatencyReportEntry; -import org.osate.contribution.sei.arinc653.ScheduleWindow; -import org.osate.contribution.sei.sei.Sei; -import org.osate.pluginsupport.properties.IntegerRangeWithUnits; -import org.osate.pluginsupport.properties.PropertyUtils; -import org.osate.pluginsupport.properties.RealRange; +import org.osate.contribution.sei.names.SEI; import org.osate.result.AnalysisResult; import org.osate.result.Result; +import org.osate.xtext.aadl2.properties.util.ARINC653ScheduleWindow; +import org.osate.xtext.aadl2.properties.util.AadlProject; +import org.osate.xtext.aadl2.properties.util.CommunicationProperties; +import org.osate.xtext.aadl2.properties.util.GetProperties; import org.osate.xtext.aadl2.properties.util.InstanceModelUtil; +import org.osate.xtext.aadl2.properties.util.PropertyUtils; /** * @author phf @@ -218,30 +205,11 @@ private void mapFlowElementInstance(final EndToEndFlowInstance etef, final FlowE } } - private final Set latencyCats = EnumSet.of(ComponentCategory.BUS, ComponentCategory.VIRTUAL_BUS, - ComponentCategory.DEVICE, ComponentCategory.PROCESSOR, ComponentCategory.VIRTUAL_PROCESSOR, - ComponentCategory.SYSTEM, ComponentCategory.MEMORY, ComponentCategory.ABSTRACT); - - private final Set periodCats = EnumSet.of(ComponentCategory.THREAD, - ComponentCategory.THREAD_GROUP, ComponentCategory.PROCESS, ComponentCategory.SYSTEM, - ComponentCategory.DEVICE, ComponentCategory.VIRTUAL_PROCESSOR, ComponentCategory.VIRTUAL_BUS, - ComponentCategory.ABSTRACT); - - private final Set deadlineCats = EnumSet.of(ComponentCategory.THREAD, - ComponentCategory.THREAD_GROUP, ComponentCategory.PROCESS, ComponentCategory.SYSTEM, - ComponentCategory.DEVICE, ComponentCategory.VIRTUAL_PROCESSOR, - ComponentCategory.ABSTRACT); - private void mapComponentInstance(final EndToEndFlowInstance etef, final FlowElementInstance flowElementInstance, LatencyReportEntry entry) { ComponentInstance componentInstance; - final boolean hasLatency = flowElementInstance instanceof FlowSpecificationInstance - || flowElementInstance instanceof ConnectionInstance - || flowElementInstance instanceof EndToEndFlowInstance - || latencyCats.contains(((ComponentInstance) flowElementInstance).getCategory()); - final RealRange expected = hasLatency ? PropertyUtils.getScaledRange( - org.osate.aadl2.contrib.communication.CommunicationProperties::getLatency, flowElementInstance, - TimeUnits.MS).orElse(RealRange.ZEROED) : RealRange.ZEROED; + double expectedMin = GetProperties.getMinimumLatencyinMilliSec(flowElementInstance); + double expectedMax = GetProperties.getMaximumLatencyinMilliSec(flowElementInstance); if (flowElementInstance instanceof FlowSpecificationInstance) { componentInstance = flowElementInstance.getComponentInstance(); @@ -255,23 +223,27 @@ private void mapComponentInstance(final EndToEndFlowInstance etef, final FlowEle /** * Get all the relevant properties. */ - double period = periodCats.contains(componentInstance.getCategory()) ? PropertyUtils.getScaled(TimingProperties::getPeriod, componentInstance, TimeUnits.MS) - .orElse(0.0) : 0.0; - double deadline = deadlineCats.contains(componentInstance.getCategory()) ? PropertyUtils.getScaled(TimingProperties::getDeadline, componentInstance, TimeUnits.MS) - .orElse(0.0) : 0.0; - boolean isAssignedDeadline = isAssignedDeadline(componentInstance); - - final boolean isThreadOrDevice = InstanceModelUtil.isThread(componentInstance) - || InstanceModelUtil.isDevice(componentInstance) || InstanceModelUtil.isAbstract(componentInstance); - final boolean isPeriodic = period > 0 && (isThreadOrDevice + double period = GetProperties.getPeriodinMS(componentInstance); + double deadline = GetProperties.getDeadlineinMilliSec(componentInstance); + boolean isAssignedDeadline = GetProperties.isAssignedDeadline(componentInstance); + + final boolean isPeriodic = period > 0 && ((InstanceModelUtil.isThread(componentInstance) + || InstanceModelUtil.isDevice(componentInstance) || InstanceModelUtil.isAbstract(componentInstance)) ? (!InstanceModelUtil.isSporadicComponent(componentInstance) && !InstanceModelUtil.isTimedComponent(componentInstance) && !InstanceModelUtil.isAperiodicComponent(componentInstance)) : true); - final RealRange responseTime = getResponseTimeInMilliSec(flowElementInstance, componentInstance, +// double executionTimeLower = GetProperties.getScaledMinComputeExecutionTimeinMilliSec(componentInstance); +// double executionTimeHigher = GetProperties.getScaledMaxComputeExecutionTimeinMilliSec(componentInstance); + final double responseTimeLower = getMinResponseTimeInMilliSec(flowElementInstance, componentInstance, + isPeriodic); + final double responseTimeHigher = getMaxResponseTimeInMilliSec(flowElementInstance, componentInstance, + isPeriodic); + + final double executionTimeLower = getMinExecutionTimeInMilliSec(flowElementInstance, componentInstance, isPeriodic); - final RealRange executionTime = getExecutionTimeInMilliSec(flowElementInstance, componentInstance, + final double executionTimeHigher = getMaxExecutionTimeInMilliSec(flowElementInstance, componentInstance, isPeriodic); /** @@ -291,7 +263,7 @@ private void mapComponentInstance(final EndToEndFlowInstance etef, final FlowEle componentInstance, flowElementInstance, report.isMajorFrameDelay()); samplingLatencyContributor.setSamplingPeriod(period); if ((InstanceModelUtil.isThread(componentInstance) || InstanceModelUtil.isDevice(componentInstance)) - && !hasAssignedPropertyValue(componentInstance, "Dispatch_Protocol")) { + && !GetProperties.hasAssignedPropertyValue(componentInstance, "Dispatch_Protocol")) { samplingLatencyContributor.reportInfo("Assume Periodic dispatch because period is set"); } if (FlowLatencyUtil.isPreviousConnectionDelayed(etef, flowElementInstance)) { @@ -306,8 +278,7 @@ private void mapComponentInstance(final EndToEndFlowInstance etef, final FlowEle } else { // sampled. We may under sample ComponentInstance prevComp = FlowLatencyUtil.getPreviousComponent(etef, flowElementInstance); - double prevPeriod = prevComp != null ? PropertyUtils.getScaled(TimingProperties::getPeriod, prevComp, TimeUnits.MS).orElse(0.0) - : 0; + double prevPeriod = prevComp != null ? GetProperties.getPeriodinMS(prevComp) : 0; if (period > 0 && prevPeriod > 0 && period % prevPeriod == 0.0) { samplingLatencyContributor.setSamplingPeriod(prevPeriod); } else { @@ -337,7 +308,7 @@ private void mapComponentInstance(final EndToEndFlowInstance etef, final FlowEle ComponentInstance firstPartition = FlowLatencyUtil.getPartition(componentInstance); if (firstPartition != null) { double partitionLatency = FlowLatencyUtil.getPartitionPeriod(firstPartition); - List schedule = FlowLatencyUtil.getModuleSchedule(firstPartition); + List schedule = FlowLatencyUtil.getModuleSchedule(firstPartition); double partitionDuration = FlowLatencyUtil.getPartitionDuration(firstPartition, schedule); LatencyContributorComponent platencyContributor = new LatencyContributorComponent(firstPartition, flowElementInstance, @@ -378,16 +349,16 @@ private void mapComponentInstance(final EndToEndFlowInstance etef, final FlowEle flowElementInstance, report.isMajorFrameDelay()); - if (responseTime.getMaximum() != 0.0) { - worstCaseValue = responseTime.getMaximum(); + if (responseTimeHigher != 0.0) { + worstCaseValue = responseTimeHigher; worstmethod = LatencyContributorMethod.RESPONSE_TIME; - } else if (executionTime.getMaximum() != 0.0) { + } else if (executionTimeHigher != 0.0) { if (!report.isWorstCaseDeadline()) { // Use execution time for worst-case if preferences specify not deadline or no deadline is specified - worstCaseValue = executionTime.getMaximum(); + worstCaseValue = executionTimeHigher; worstmethod = LatencyContributorMethod.PROCESSING_TIME; } else if (!isAssignedDeadline) { - worstCaseValue = executionTime.getMaximum(); + worstCaseValue = executionTimeHigher; worstmethod = LatencyContributorMethod.PROCESSING_TIME; processingLatencyContributor.reportInfo("Using execution time as deadline was not set"); } @@ -399,9 +370,9 @@ private void mapComponentInstance(final EndToEndFlowInstance etef, final FlowEle worstmethod = LatencyContributorMethod.DEADLINE; } - if ((worstCaseValue == 0.0) && (expected.getMaximum() != 0.0)) { + if ((worstCaseValue == 0.0) && (expectedMax != 0.0)) { // use flow latency if neither deadline nor execution time - worstCaseValue = expected.getMaximum(); + worstCaseValue = expectedMax; worstmethod = LatencyContributorMethod.SPECIFIED; } else if (worstCaseValue == 0.0 && deadline != 0.0) { // if no flow spec value then use default deadline == period @@ -414,35 +385,31 @@ private void mapComponentInstance(final EndToEndFlowInstance etef, final FlowEle * Selection of the best case value, generic cases. */ bestmethod = LatencyContributorMethod.UNKNOWN; - if (responseTime.getMinimum() != 0.0) { - bestCaseValue = responseTime.getMinimum(); + if (responseTimeLower != 0.0) { + bestCaseValue = responseTimeLower; bestmethod = LatencyContributorMethod.RESPONSE_TIME; - } else if (executionTime.getMinimum() != 0.0) { - bestCaseValue = executionTime.getMinimum(); + } else if (executionTimeLower != 0.0) { + bestCaseValue = executionTimeLower; bestmethod = LatencyContributorMethod.PROCESSING_TIME; } // For best case it does not make sense to use deadline - if ((bestCaseValue == 0.0) && (expected.getMinimum() != 0.0)) { - bestCaseValue = expected.getMinimum(); + if ((bestCaseValue == 0.0) && (expectedMin != 0.0)) { + bestCaseValue = expectedMin; bestmethod = LatencyContributorMethod.SPECIFIED; } - // XXX: Fix all the use of the isSporadic/isTimed etc. Get the value once and check against it. - // deal with queuing latency // take into account queuing delay if (incomingConnectionFI != null) { double qs = 0; LatencyContributorComponent ql = new LatencyContributorComponent(componentInstance, flowElementInstance, report.isMajorFrameDelay()); - - if (hasAssignedPropertyValue(incomingConnectionFI, - org.osate.xtext.aadl2.properties.util.CommunicationProperties.QUEUE_SIZE)) { - qs = CommunicationProperties.getQueueSize(incomingConnectionFI).orElse(0); + if (GetProperties.hasAssignedPropertyValue(incomingConnectionFI, CommunicationProperties.QUEUE_SIZE)) { + qs = GetProperties.getQueueSize(incomingConnectionFI); } else if (incomingConnectionFI.getCategory() == FeatureCategory.DATA_PORT - && isThreadOrDevice && (InstanceModelUtil.isSporadicComponent(componentInstance) + && (InstanceModelUtil.isSporadicComponent(componentInstance) || InstanceModelUtil.isTimedComponent(componentInstance) || InstanceModelUtil.isAperiodicComponent(componentInstance))) { // treat data port as a port of queue size 1 when not a sampling thread @@ -480,8 +447,8 @@ private void mapComponentInstance(final EndToEndFlowInstance etef, final FlowEle processingLatencyContributor.setBestCaseMethod(bestmethod); processingLatencyContributor.setMaximum(worstCaseValue); processingLatencyContributor.setMinimum(bestCaseValue); - processingLatencyContributor.setExpectedMaximum(expected.getMaximum()); - processingLatencyContributor.setExpectedMinimum(expected.getMinimum()); + processingLatencyContributor.setExpectedMaximum(expectedMax); + processingLatencyContributor.setExpectedMinimum(expectedMin); if (checkLastImmediate && deadline > 0.0) { processingLatencyContributor.setImmediateDeadline(deadline); @@ -494,10 +461,8 @@ private void mapConnectionInstance(final EndToEndFlowInstance etef, final FlowEl LatencyReportEntry entry) { ConnectionInstance connectionInstance = (ConnectionInstance) flowElementInstance; - final RealRange expected = PropertyUtils - .getScaledRange(org.osate.aadl2.contrib.communication.CommunicationProperties::getLatency, - flowElementInstance, TimeUnits.MS) - .orElse(RealRange.ZEROED); + double expectedMin = GetProperties.getMinimumLatencyinMilliSec(flowElementInstance); + double expectedMax = GetProperties.getMaximumLatencyinMilliSec(flowElementInstance); ComponentInstance componentInstanceSource = InstanceModelUtil.getRelatedComponentSource(connectionInstance); ComponentInstance componentInstanceDestination = InstanceModelUtil @@ -511,7 +476,7 @@ private void mapConnectionInstance(final EndToEndFlowInstance etef, final FlowEl // if we exit a partition then we may have I/O Delay until the end of the partition window or the end of the major frame if (srcPartition != null && srcPartition != dstPartition) { double partitionLatency = FlowLatencyUtil.getPartitionPeriod(srcPartition); - List schedule = FlowLatencyUtil.getModuleSchedule(srcPartition); + List schedule = FlowLatencyUtil.getModuleSchedule(srcPartition); double partitionDuration = FlowLatencyUtil.getPartitionDuration(srcPartition, schedule); if (partitionDuration > 0) { LatencyContributor ioLatencyContributor = new LatencyContributorComponent(srcPartition, @@ -541,11 +506,9 @@ private void mapConnectionInstance(final EndToEndFlowInstance etef, final FlowEl report.isMajorFrameDelay()); processActualConnectionBindingsSampling(connectionInstance, latencyContributor); - ComponentClassifier relatedConnectionData = (ComponentClassifier) FlowLatencyUtil - .getConnectionData(connectionInstance); + Classifier relatedConnectionData = FlowLatencyUtil.getConnectionData(connectionInstance); processActualConnectionBindingsTransmission(connectionInstance, - relatedConnectionData == null ? 0.0 - : AadlContribUtils.getDataSize(relatedConnectionData, SizeUnits.BYTES), + relatedConnectionData == null ? 0.0 : GetProperties.getDataSizeInBytes(relatedConnectionData), latencyContributor); /** * handle the case when there is no binding to virtual bus or bus. @@ -553,20 +516,20 @@ private void mapConnectionInstance(final EndToEndFlowInstance etef, final FlowEl */ // XXX we can add a check whether the latencies coming from the bindings exceeds the connection latency - if (expected.getMaximum() > 0) { + if (expectedMax > 0) { latencyContributor.setWorstCaseMethod(LatencyContributorMethod.SPECIFIED); - latencyContributor.setExpectedMaximum(expected.getMaximum()); + latencyContributor.setExpectedMaximum(expectedMax); } - if (expected.getMinimum() > 0) { + if (expectedMin > 0) { latencyContributor.setBestCaseMethod(LatencyContributorMethod.SPECIFIED); - latencyContributor.setExpectedMinimum(expected.getMinimum()); + latencyContributor.setExpectedMinimum(expectedMin); } if (latencyContributor.getSubContributors().isEmpty()) { - if (expected.getMaximum() > 0) { - latencyContributor.setMaximum(expected.getMaximum()); + if (expectedMax > 0) { + latencyContributor.setMaximum(expectedMax); } - if (expected.getMinimum() > 0) { - latencyContributor.setMinimum(expected.getMinimum()); + if (expectedMin > 0) { + latencyContributor.setMinimum(expectedMin); } } else { latencyContributor.reportInfo("Adding latency subtotal from protocols and hardware - shown with ()"); @@ -574,8 +537,8 @@ private void mapConnectionInstance(final EndToEndFlowInstance etef, final FlowEl // set synchronous if on same processor if (srcHW != null && dstHW != null) { // we have two hardware components. One or both could be a device - ComponentInstance srcTime = (ComponentInstance) TimingProperties.getReferenceTime(srcHW).orElse(null); - ComponentInstance dstTime = (ComponentInstance) TimingProperties.getReferenceTime(dstHW).orElse(null); + ComponentInstance srcTime = GetProperties.getReferenceTime(srcHW); + ComponentInstance dstTime = GetProperties.getReferenceTime(dstHW); if (srcHW == dstHW) { latencyContributor.setSynchronous(); } else if (srcTime != null && dstTime != null) { @@ -607,7 +570,7 @@ private void mapConnectionInstance(final EndToEndFlowInstance etef, final FlowEl if (dstPartition != null && srcPartition != dstPartition) { // add partition latency if the destination is a partition and it is different from the source partition (or null) double partitionLatency = FlowLatencyUtil.getPartitionPeriod(dstPartition); - List schedule = FlowLatencyUtil.getModuleSchedule(dstPartition); + List schedule = FlowLatencyUtil.getModuleSchedule(dstPartition); double partitionDuration = FlowLatencyUtil.getPartitionDuration(dstPartition, schedule); LatencyContributorComponent platencyContributor = new LatencyContributorComponent(dstPartition, flowElementInstance, @@ -638,22 +601,6 @@ private void mapConnectionInstance(final EndToEndFlowInstance etef, final FlowEl } } - private static RealRange getTimeToTransferData(final NamedElement bus, double datasizeinbyte) { - final Optional tt_o = org.osate.aadl2.contrib.communication.CommunicationProperties - .getTransmissionTime(bus); - if (tt_o.isPresent()) { - final TransmissionTime tt = tt_o.get(); - final RealRange fixedRange = PropertyUtils.scaleRange(tt.getFixed(), TimeUnits.MS).orElse(RealRange.ZEROED); - final RealRange perByteRange = PropertyUtils.scaleRange(tt.getPerbyte(), TimeUnits.MS) - .orElse(RealRange.ZEROED); - final double min = fixedRange.getMinimum() + (datasizeinbyte * perByteRange.getMinimum()); - final double max = fixedRange.getMaximum() + (datasizeinbyte * perByteRange.getMaximum()); - return new RealRange(min, max); - } else { - return new RealRange(0.0, 0.0); - } - } - /** * add latency sub-contribution due to transmission by bus (or virtual bus) * works for an instance object and for a classifier. @@ -669,21 +616,21 @@ private void processTransmissionTime(NamedElement targetMedium, double datasizei LatencyContributor latencyContributor, final ConnectionInstance onBehalfOfConnection) { // XXX: [Code Coverage] targetMedium cannot be null. if (targetMedium != null) { - final RealRange busLatency = PropertyUtils - .getScaledRange(org.osate.aadl2.contrib.communication.CommunicationProperties::getLatency, - targetMedium, TimeUnits.MS) - .orElse(RealRange.ZEROED); - final RealRange busTransferTime = getTimeToTransferData(targetMedium, datasizeinbyte); - if (busLatency.getMaximum() == 0 && busTransferTime.getMaximum() == 0) { + + double maxBusLatency = GetProperties.getMaximumLatencyinMilliSec(targetMedium); + double minBusLatency = GetProperties.getMinimumLatencyinMilliSec(targetMedium); + double maxBusTransferTime = GetProperties.getMaximumTimeToTransferData(targetMedium, datasizeinbyte); + double minBusTransferTime = GetProperties.getMinimumTimeToTransferData(targetMedium, datasizeinbyte); + if (maxBusLatency == 0 && maxBusTransferTime == 0) { // connection or protocol has nothing to contribute return; } LatencyContributor subContributor = new LatencyContributorComponent(targetMedium, report.isMajorFrameDelay()); - subContributor.setExpectedMaximum(busLatency.getMaximum()); - subContributor.setExpectedMinimum(busLatency.getMinimum()); - if (busTransferTime.getMaximum() > 0) { - subContributor.setMaximum(busTransferTime.getMaximum()); + subContributor.setExpectedMaximum(maxBusLatency); + subContributor.setExpectedMinimum(minBusLatency); + if (maxBusTransferTime > 0) { + subContributor.setMaximum(maxBusTransferTime); subContributor.reportInfo("Using data transfer time"); if (datasizeinbyte == 0.0) { subContributor.reportInfo("Data size = 0. Possibly data type on port missing"); @@ -694,10 +641,10 @@ private void processTransmissionTime(NamedElement targetMedium, double datasizei if (targetMedium instanceof ComponentInstance) { computedMaxTransmissionLatencies.put( new Pair<>((ComponentInstance) targetMedium, onBehalfOfConnection), - busTransferTime.getMaximum()); + maxBusTransferTime); } - } else if (busLatency.getMaximum() > 0) { - subContributor.setMaximum(busLatency.getMaximum()); + } else if (maxBusLatency > 0) { + subContributor.setMaximum(maxBusLatency); subContributor.setWorstCaseMethod(LatencyContributorMethod.SPECIFIED); subContributor.reportInfo("Using specified bus latency"); @@ -705,19 +652,19 @@ private void processTransmissionTime(NamedElement targetMedium, double datasizei if (targetMedium instanceof ComponentInstance) { computedMaxTransmissionLatencies.put( new Pair<>((ComponentInstance) targetMedium, onBehalfOfConnection), - busTransferTime.getMaximum()); + maxBusTransferTime); } } else { // XXX: [Code Coverage] Only executable if maxBusTransferTime or maxBusLatency is negative. subContributor.setWorstCaseMethod(LatencyContributorMethod.UNKNOWN); } - if (busTransferTime.getMinimum() > 0) { - subContributor.setMinimum(busTransferTime.getMinimum()); + if (minBusTransferTime > 0) { + subContributor.setMinimum(minBusTransferTime); subContributor.setBestCaseMethod(LatencyContributorMethod.TRANSMISSION_TIME); - } else if (busLatency.getMinimum() > 0) { - subContributor.setMinimum(busLatency.getMinimum()); + } else if (minBusLatency > 0) { + subContributor.setMinimum(minBusLatency); subContributor.setBestCaseMethod(LatencyContributorMethod.SPECIFIED); } else { // XXX: [Code Coverage] Only executable if minBusTransferTime or minBusLatency is negative. @@ -745,14 +692,12 @@ private void processActualConnectionBindingsTransmission(final InstanceObject co boolean willDoVirtualBuses = false; boolean willDoBuses = false; // look for actual binding if we have a connection instance or virtual bus instance - final List bindings = DeploymentProperties.getActualConnectionBinding(connOrVB) - .orElse(Collections.emptyList()); - + List bindings = GetProperties.getActualConnectionBinding(connOrVB); if (bindings.isEmpty()) { return; } - for (InstanceObject componentInstance : bindings) { - if (((ComponentInstance) componentInstance).getCategory().equals(ComponentCategory.VIRTUAL_BUS)) { + for (ComponentInstance componentInstance : bindings) { + if (componentInstance.getCategory().equals(ComponentCategory.VIRTUAL_BUS)) { willDoVirtualBuses = true; } else { willDoBuses = true; @@ -764,8 +709,7 @@ private void processActualConnectionBindingsTransmission(final InstanceObject co * We also can have an actual connection binding to a virtual bus * If we have that we want to use that virtual bus overhead */ - List protocols = DeploymentProperties.getRequiredVirtualBusClass(connOrVB) - .orElse(Collections.emptyList()); + List protocols = GetProperties.getRequiredVirtualBusClass(connOrVB); // XXX: [Code Coverage] protocols cannot be null. if ((protocols != null) && (protocols.size() > 0)) { // XXX: [Code Coverage] willDoBuses is always true if willDoVirtualBuses is false. @@ -778,11 +722,10 @@ private void processActualConnectionBindingsTransmission(final InstanceObject co } - for (InstanceObject componentInstance : bindings) { - double wrappedDataSize = transmissionDataSize - + AadlContribUtils.getDataSize((ComponentInstance) componentInstance, SizeUnits.BYTES); + for (ComponentInstance componentInstance : bindings) { + double wrappedDataSize = transmissionDataSize + GetProperties.getDataSizeInBytes(componentInstance); processTransmissionTime(componentInstance, wrappedDataSize, latencyContributor, onBehalfOfConnection); - if (((ComponentInstance) componentInstance).getCategory().equals(ComponentCategory.VIRTUAL_BUS)) { + if (componentInstance.getCategory().equals(ComponentCategory.VIRTUAL_BUS)) { processActualConnectionBindingsTransmission(componentInstance, wrappedDataSize, latencyContributor, onBehalfOfConnection); } @@ -795,17 +738,16 @@ private void processActualConnectionBindingsTransmission(final InstanceObject co * @param protocols * @return */ - private double computeTotalDataSize(List protocols, + private double computeTotalDataSize(List protocols, double transmissionDataSize, LatencyContributor latencyContributor, final ConnectionInstance onBehalfOfConnection) { double total = transmissionDataSize; - for (Classifier cc : protocols) { - double contribution = AadlContribUtils.getDataSize((ComponentClassifier) cc, SizeUnits.BYTES); + for (ComponentClassifier cc : protocols) { + double contribution = GetProperties.getDataSizeInBytes(cc); double wrapped = transmissionDataSize + contribution; processTransmissionTime(cc, wrapped, latencyContributor, onBehalfOfConnection); total = total + contribution; - List reqprotocols = DeploymentProperties.getRequiredVirtualBusClass(cc) - .orElse(Collections.emptyList()); + List reqprotocols = GetProperties.getRequiredVirtualBusClass(cc); if (!reqprotocols.isEmpty()) { total = total + computeTotalDataSize(reqprotocols, wrapped, latencyContributor, onBehalfOfConnection); } @@ -832,10 +774,9 @@ private void processActualConnectionBindingsSampling(final NamedElement connOrVB boolean willDoBuses = false; if (connOrVB instanceof InstanceObject) { // look for actual binding if we have a connection instance or virtual bus instance - List bindings = DeploymentProperties.getActualConnectionBinding(connOrVB) - .orElse(Collections.emptyList()); - for (InstanceObject componentInstance : bindings) { - if (((ComponentInstance) componentInstance).getCategory().equals(ComponentCategory.VIRTUAL_BUS)) { + List bindings = GetProperties.getActualConnectionBinding((InstanceObject) connOrVB); + for (ComponentInstance componentInstance : bindings) { + if (componentInstance.getCategory().equals(ComponentCategory.VIRTUAL_BUS)) { willDoVirtualBuses = true; } else { willDoBuses = true; @@ -847,23 +788,22 @@ private void processActualConnectionBindingsSampling(final NamedElement connOrVB * If we have that we want to use that virtual bus overhead */ if (!willDoVirtualBuses) { - List protocols = DeploymentProperties.getRequiredVirtualBusClass(connOrVB) - .orElse(Collections.emptyList()); + List protocols = GetProperties.getRequiredVirtualBusClass(connOrVB); // XXX: [Code Coverage] protocols cannot be null. if ((protocols != null) && (protocols.size() > 0)) { if (willDoBuses) { latencyContributor.reportInfo("Adding required virtual bus contributions to bound bus"); } - for (Classifier cc : protocols) { + for (ComponentClassifier cc : protocols) { processSamplingAndQueuingTimes(cc, null, latencyContributor); processActualConnectionBindingsSampling(cc, latencyContributor, onBehalfOfConnection); } } } - for (InstanceObject componentInstance : bindings) { + for (ComponentInstance componentInstance : bindings) { processSamplingAndQueuingTimes(componentInstance, onBehalfOfConnection, latencyContributor); - if (((ComponentInstance) componentInstance).getCategory().equals(ComponentCategory.VIRTUAL_BUS)) { + if (componentInstance.getCategory().equals(ComponentCategory.VIRTUAL_BUS)) { processActualConnectionBindingsSampling(componentInstance, latencyContributor, onBehalfOfConnection); } @@ -872,11 +812,6 @@ private void processActualConnectionBindingsSampling(final NamedElement connOrVB } - private final static Set hasPeriod = EnumSet.of(ComponentCategory.THREAD, - ComponentCategory.THREAD_GROUP, ComponentCategory.PROCESS, ComponentCategory.SYSTEM, - ComponentCategory.DEVICE, ComponentCategory.VIRTUAL_PROCESSOR, ComponentCategory.VIRTUAL_BUS, - ComponentCategory.BUS, ComponentCategory.ABSTRACT); - /* * boundBusOrRequiredClassifier is a ComponentInstance if it is a bus bound to connection instance, or a * ComponentClassifier if it is a virtual bus required by a connection connnection or vb. @@ -892,13 +827,7 @@ private void processSamplingAndQueuingTimes(final NamedElement boundBusOrRequire // XXX: [Code Coverage] boundBus cannot be null. if (boundBusOrRequiredClassifier != null) { - final ComponentCategory cc = boundBusOrRequiredClassifier instanceof ComponentInstance - ? ((ComponentInstance) boundBusOrRequiredClassifier).getCategory() - : ((ComponentClassifier) boundBusOrRequiredClassifier).getCategory(); - double period = hasPeriod.contains( - cc) ? PropertyUtils - .getScaled(TimingProperties::getPeriod, boundBusOrRequiredClassifier, TimeUnits.MS).orElse(0.0) - : 0.0; + double period = GetProperties.getPeriodinMS(boundBusOrRequiredClassifier); if (period > 0) { // add sampling latency due to the protocol or bus being periodic LatencyContributor samplingLatencyContributor = new LatencyContributorComponent( @@ -982,8 +911,7 @@ public AnalysisResult invoke(SystemInstance root, SystemOperationMode som, boole if (root.getSystemOperationModes().isEmpty() || root.getSystemOperationModes().get(0).getCurrentModes().isEmpty()) { // no SOM - invokeOnSOM(root, root.getSystemOperationModes().get(0), asynchronousSystem, majorFrameDelay, - worstCaseDeadline, + invokeOnSOM(root, som, asynchronousSystem, majorFrameDelay, worstCaseDeadline, bestCaseEmptyQueue, disableQueuingLatency); } else { // we need to run it for every SOM @@ -1275,61 +1203,63 @@ public AnalysisResult invokeAndSaveResult(SystemInstance root, SystemOperationMo return ar; } - private RealRange getTimeInMilliSec2(final FlowElementInstance fei, final ComponentInstance ci, - final boolean isPeriodic, - final Function>> getExecTime) { + private double getTimeInMilliSec(final FlowElementInstance fei, final ComponentInstance ci, + final boolean isPeriodic, final Function propertyTester, + final Function getExecTime) { /* * If the flow element is a component instance or if the thread is periodic, we use the thread's * computation time. Otherwise we try to use the compute execution time from the flow's input feature. */ - if (!(isPeriodic || fei == ci)) { // the flow element is a FlowSpecificationInstance (It is not periodic or a component instance) + if (isPeriodic || fei == ci) { // the flow element is a component instance + return getExecTime.apply(ci); + } else { // the flow element is a FlowSpecificationInstance final FlowSpecificationInstance fsi = (FlowSpecificationInstance) fei; final FlowEnd allInEnd = fsi.getFlowSpecification().getAllInEnd(); if (allInEnd != null) { // we have an input feature FeatureInstance fi = null; if (allInEnd.getContext() instanceof FeatureGroup) { - final FeatureInstance fgi = ci.findFeatureInstance((FeatureGroup) allInEnd.getContext()); + FeatureInstance fgi = ci.findFeatureInstance((FeatureGroup) allInEnd.getContext()); fi = fgi.findFeatureInstance(allInEnd.getFeature()); } else { fi = ci.findFeatureInstance(allInEnd.getFeature()); } - final FeatureCategory featureCategory = fi.getCategory(); - if (featureCategory == FeatureCategory.EVENT_PORT - || featureCategory == FeatureCategory.EVENT_DATA_PORT) { - final Optional> fromFeature = getExecTime.apply(fi); - if (fromFeature.isPresent()) { - return AnalysisUtils.scaleTimeRange(PropertyUtils.scaleRange(fromFeature.get(), TimeUnits.MS), fi); - } // otherwise fall through and get from component - } // otherwise fall through and get from component + if (propertyTester.apply(fi)) { + return getExecTime.apply(fi); + } } - } - final ComponentCategory componentCategory = ci.getCategory(); - if (componentCategory == ComponentCategory.THREAD || componentCategory == ComponentCategory.DEVICE - || componentCategory == ComponentCategory.SUBPROGRAM - || componentCategory == ComponentCategory.ABSTRACT) { - return AnalysisUtils.scaleTimeRange(PropertyUtils.scaleRange(getExecTime.apply(ci), TimeUnits.MS).orElse(RealRange.ZEROED), ci); - } else { - return RealRange.ZEROED; + return getExecTime.apply(ci); } } - private RealRange getResponseTimeInMilliSec(final FlowElementInstance fei, final ComponentInstance ci, + private double getMinResponseTimeInMilliSec(final FlowElementInstance fei, final ComponentInstance ci, final boolean isPeriodic) { - return getTimeInMilliSec2(fei, ci, isPeriodic, Sei::getResponseTime); + return getTimeInMilliSec(fei, ci, isPeriodic, FlowLatencyAnalysisSwitch::hasResponseTime, + FlowLatencyAnalysisSwitch::getScaledMinResponseTimeinMilliSec); } - private RealRange getExecutionTimeInMilliSec(final FlowElementInstance fei, final ComponentInstance ci, + private double getMaxResponseTimeInMilliSec(final FlowElementInstance fei, final ComponentInstance ci, final boolean isPeriodic) { - return getTimeInMilliSec2(fei, ci, isPeriodic, TimingProperties::getComputeExecutionTime); + return getTimeInMilliSec(fei, ci, isPeriodic, FlowLatencyAnalysisSwitch::hasResponseTime, + FlowLatencyAnalysisSwitch::getScaledMaxResponseTimeinMilliSec); + } + + private double getMinExecutionTimeInMilliSec(final FlowElementInstance fei, final ComponentInstance ci, + final boolean isPeriodic) { + return getTimeInMilliSec(fei, ci, isPeriodic, GetProperties::hasComputeExecutionTime, + GetProperties::getScaledMinComputeExecutionTimeinMilliSec); + } + + private double getMaxExecutionTimeInMilliSec(final FlowElementInstance fei, final ComponentInstance ci, + final boolean isPeriodic) { + return getTimeInMilliSec(fei, ci, isPeriodic, GetProperties::hasComputeExecutionTime, + GetProperties::getScaledMaxComputeExecutionTimeinMilliSec); } private static final void sortBoundConnectionsHelper(final ComponentInstance compInstance, final Map> map) { for (final ConnectionInstance ci : compInstance.getConnectionInstances()) { - final List bindings = DeploymentProperties.getActualConnectionBinding(ci) - .orElse(Collections.emptyList()); - for (final InstanceObject io : bindings) { - final ComponentInstance componentInstance = (ComponentInstance) io; + final List bindings = GetProperties.getActualConnectionBinding(ci); + for (final ComponentInstance componentInstance : bindings) { addToHashedSet(map, componentInstance, ci); processComponentBindings(map, ci, componentInstance); } @@ -1344,20 +1274,20 @@ private static final Map> sortBoundCo final SystemInstance system) { final Map> map = new HashMap<>(); sortBoundConnectionsHelper(system, map); +// for (final ConnectionInstance ci : system.getConnectionInstances()) { +// final List bindings = GetProperties.getActualConnectionBinding(ci); +// for (final ComponentInstance componentInstance : bindings) { +// addToHashedSet(map, componentInstance, ci); +// processComponentBindings(map, ci, componentInstance); +// } +// } return map; } - private static final Set hasConnBindings = EnumSet.of(ComponentCategory.THREAD, - ComponentCategory.THREAD_GROUP, ComponentCategory.PROCESS, ComponentCategory.SYSTEM, - ComponentCategory.VIRTUAL_BUS, ComponentCategory.ABSTRACT); - private static final void processComponentBindings(final Map> map, final ConnectionInstance ci, final ComponentInstance componentInstance) { - final List componentBindings = hasConnBindings.contains(componentInstance.getCategory()) - ? DeploymentProperties.getActualConnectionBinding(componentInstance).orElse(Collections.emptyList()) - : Collections.emptyList(); - for (final InstanceObject io : componentBindings) { - final ComponentInstance componentBinding = (ComponentInstance) io; + final List componentBindings = GetProperties.getActualConnectionBinding(componentInstance); + for (final ComponentInstance componentBinding : componentBindings) { addToHashedSet(map, componentBinding, ci); processComponentBindings(map, ci, componentBinding); } @@ -1486,39 +1416,42 @@ private void fillInQueuingTimes(final SystemInstance system) { } } - // ***************************** - // *** These horrible methods are left over from GetProperties, and check that a property has a value. - // *** They are hard to emulate with the property methods. - // ***************************** - - private static boolean isAssignedDeadline(final NamedElement ne) { - Property deadline = lookupPropertyDefinition(ne, org.osate.xtext.aadl2.properties.util.TimingProperties._NAME, - org.osate.xtext.aadl2.properties.util.TimingProperties.DEADLINE); - return isAssignedPropertyValue(ne, deadline); - } - - private static Property lookupPropertyDefinition(EObject context, String ps, String name) { - return Aadl2GlobalScopeUtil.get(context, Aadl2Package.eINSTANCE.getProperty(), - ((ps != null && !ps.isEmpty()) ? (ps + "::" + name) : name)); - } + /* + * Ideally these methods would be GetProperties, but changing that class really causes havoc with the + * version numbers of the plug-ins. + */ - private static boolean isAssignedPropertyValue(NamedElement element, Property pn) { - try { - final PropertyAcc propertyAccumulator = element.getPropertyValue(pn); - PropertyAssociation firstAssociation = propertyAccumulator.first(); - return firstAssociation != null; - } catch (org.osate.aadl2.properties.PropertyDoesNotApplyToHolderException exception) { - return false; - } + private static boolean hasResponseTime(final NamedElement ne) { + final Property responseTime = GetProperties.lookupPropertyDefinition(ne, SEI._NAME, SEI.RESPONSE_TIME); + return PropertyUtils.hasPropertyValue(ne, responseTime); } - private static Property lookupPropertyDefinition(EObject context, String qpname) { - return Aadl2GlobalScopeUtil.get(context, Aadl2Package.eINSTANCE.getProperty(), qpname); + /** + * get max response time scaled in terms of the processor the thread is + * bound to. + * + * @param ne + * thread component instance + * @return scaled time or 0.0 + */ + private static double getScaledMaxResponseTimeinMilliSec(final NamedElement ne) { + Property computeExecutionTime = GetProperties.lookupPropertyDefinition(ne, SEI._NAME, SEI.RESPONSE_TIME); + UnitLiteral milliSecond = GetProperties.findUnitLiteral(computeExecutionTime, AadlProject.MS_LITERAL); + return PropertyUtils.getScaledRangeMaximum(ne, computeExecutionTime, milliSecond, 0.0); } - private static boolean hasAssignedPropertyValue(NamedElement element, String pname) { - Property pn = lookupPropertyDefinition(element, pname); - return isAssignedPropertyValue(element, pn); + /** + * get min response time scaled in terms of the processor the thread is + * bound to. + * + * @param ne + * thread component instance + * @return scaled time or 0.0 + */ + private static double getScaledMinResponseTimeinMilliSec(final NamedElement ne) { + Property computeExecutionTime = GetProperties.lookupPropertyDefinition(ne, SEI._NAME, SEI.RESPONSE_TIME); + UnitLiteral milliSecond = GetProperties.findUnitLiteral(computeExecutionTime, AadlProject.MS_LITERAL); + return PropertyUtils.getScaledRangeMinimum(ne, computeExecutionTime, milliSecond, 0.0); } } diff --git a/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/internal/utils/FlowLatencyUtil.java b/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/internal/utils/FlowLatencyUtil.java index 6238ad2ecb9..8fd6a55dfdd 100644 --- a/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/internal/utils/FlowLatencyUtil.java +++ b/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/internal/utils/FlowLatencyUtil.java @@ -25,7 +25,6 @@ import java.io.IOException; import java.util.Collection; -import java.util.Collections; import java.util.List; import org.eclipse.core.runtime.IStatus; @@ -39,31 +38,55 @@ import org.osate.aadl2.ComponentCategory; import org.osate.aadl2.ComponentClassifier; import org.osate.aadl2.ComponentType; +import org.osate.aadl2.EnumerationLiteral; +import org.osate.aadl2.NamedElement; +import org.osate.aadl2.NumberValue; +import org.osate.aadl2.Property; +import org.osate.aadl2.PropertyExpression; import org.osate.aadl2.VirtualBus; -import org.osate.aadl2.contrib.aadlproject.TimeUnits; -import org.osate.aadl2.contrib.communication.CommunicationProperties; -import org.osate.aadl2.contrib.communication.Timing; -import org.osate.aadl2.contrib.deployment.DeploymentProperties; -import org.osate.aadl2.contrib.timing.TimingProperties; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.ConnectionInstance; import org.osate.aadl2.instance.ConnectionInstanceEnd; -import org.osate.aadl2.instance.ConnectionKind; import org.osate.aadl2.instance.EndToEndFlowInstance; import org.osate.aadl2.instance.FeatureInstance; import org.osate.aadl2.instance.FlowElementInstance; import org.osate.aadl2.instance.FlowSpecificationInstance; import org.osate.aadl2.instance.InstanceObject; -import org.osate.aadl2.properties.PropertyLookupException; -import org.osate.contribution.sei.arinc653.Arinc653; -import org.osate.contribution.sei.arinc653.ScheduleWindow; -import org.osate.pluginsupport.properties.PropertyUtils; +import org.osate.analysis.flows.model.ConnectionType; +import org.osate.contribution.sei.names.DataModel; import org.osate.result.AnalysisResult; import org.osate.result.Result; import org.osate.result.util.ResultUtil; +import org.osate.xtext.aadl2.properties.util.ARINC653ScheduleWindow; +import org.osate.xtext.aadl2.properties.util.GetProperties; import org.osate.xtext.aadl2.properties.util.InstanceModelUtil; public class FlowLatencyUtil { + //XXX: [Code Coverage] Dead code. + public static String getEndToEndFlowString(EndToEndFlowInstance etef) { + StringBuilder ret; + boolean firstPassed = false; + + ret = new StringBuilder(); + ret.append(etef.getName() + " : "); + + for (FlowElementInstance fei : etef.getFlowElements()) { + if (firstPassed) { + ret.append("->"); + } + ret.append(fei.getName()); + firstPassed = true; + } + + return ret.toString(); + } + + //XXX: [Code Coverage] Dead code. + public static boolean hasPreviousConnection(final EndToEndFlowInstance etef, + final FlowElementInstance flowElementInstance) { + return etef.getFlowElements().indexOf(flowElementInstance) > 0; + } + public static FeatureInstance getIncomingConnectionFeatureInstance(final EndToEndFlowInstance etef, final FlowElementInstance flowElementInstance) { ConnectionInstance previousElement = getPreviousConnection(etef, flowElementInstance); @@ -79,37 +102,83 @@ public static FeatureInstance getIncomingConnectionFeatureInstance(final EndToEn public static boolean isPreviousConnectionImmediate(final EndToEndFlowInstance etef, final FlowElementInstance flowElementInstance) { - final ConnectionInstance previousElement = getPreviousConnection(etef, flowElementInstance); + ConnectionInstance previousElement = getPreviousConnection(etef, flowElementInstance); //XXX: [Code Coverage] Only called if there is a previous connection. - if (previousElement != null && previousElement.getKind() == ConnectionKind.PORT_CONNECTION) { - return PropertyUtils.propertyEquals(CommunicationProperties::getTiming, previousElement, - Timing.IMMEDIATE); + if ((previousElement != null)) { + return (getConnectionType(previousElement) == ConnectionType.IMMEDIATE); } - // No previous element, or it's not a port connection (so no TIMING property); either way, it's not immediate + return false; } public static boolean isNextConnectionImmediate(final EndToEndFlowInstance etef, final FlowElementInstance flowElementInstance) { - final ConnectionInstance nextElement = getNextConnection(etef, flowElementInstance); - if (nextElement != null && nextElement.getKind() == ConnectionKind.PORT_CONNECTION) { - return PropertyUtils.propertyEquals(CommunicationProperties::getTiming, nextElement, Timing.IMMEDIATE); + ConnectionInstance nextElement = getNextConnection(etef, flowElementInstance); + if ((nextElement != null)) { + return (getConnectionType(nextElement) == ConnectionType.IMMEDIATE); } - // No next element, or it's not a port connection (so no TIMING property); either way, it's not immediate + return false; } public static boolean isPreviousConnectionDelayed(final EndToEndFlowInstance etef, final FlowElementInstance flowElementInstance) { - final ConnectionInstance previousElement = getPreviousConnection(etef, flowElementInstance); + ConnectionInstance nextElement = getPreviousConnection(etef, flowElementInstance); //XXX: [Code Coverage] Only called if there is a previous connection. - if (previousElement != null && previousElement.getKind() == ConnectionKind.PORT_CONNECTION) { - return PropertyUtils.propertyEquals(CommunicationProperties::getTiming, previousElement, Timing.DELAYED); + if ((nextElement != null)) { + return (getConnectionType(nextElement) == ConnectionType.DELAYED); + } + + return false; + } + + //XXX: [Code Coverage] Dead code. + public static boolean isNextConnectionDelayed(final EndToEndFlowInstance etef, + final FlowElementInstance flowElementInstance) { + ConnectionInstance nextElement = getNextConnection(etef, flowElementInstance); + if ((nextElement != null)) { + return (getConnectionType(nextElement) == ConnectionType.DELAYED); } - // No previous element, or it's not a port connection (so no TIMING property); either way, it's not delayed + + return false; + } + + //XXX: [Code Coverage] Dead code. + public static boolean isPreviousConnectionSampled(final EndToEndFlowInstance etef, + final FlowElementInstance flowElementInstance) { + ConnectionInstance nextElement = getPreviousConnection(etef, flowElementInstance); + if ((nextElement != null)) { + return (getConnectionType(nextElement) == ConnectionType.SAMPLED); + } + + return false; + } + + //XXX: [Code Coverage] Dead code. + public static boolean isNextConnectionSampled(final EndToEndFlowInstance etef, + final FlowElementInstance flowElementInstance) { + ConnectionInstance nextElement = getNextConnection(etef, flowElementInstance); + if ((nextElement != null)) { + return (getConnectionType(nextElement) == ConnectionType.SAMPLED); + } + return false; } + public static ConnectionType getConnectionType(final ConnectionInstance conn) { + EnumerationLiteral el = GetProperties.getConnectionTiming(conn); + + //XXX: [Code Coverage] el cannot be null. + if ((el != null) && (el.getName().equalsIgnoreCase("immediate"))) { + return ConnectionType.IMMEDIATE; + } + //XXX: [Code Coverage] el cannot be null. + if ((el != null) && (el.getName().equalsIgnoreCase("delayed"))) { + return ConnectionType.DELAYED; + } + return ConnectionType.SAMPLED; + } + /** * get the next element in an end to end flow * @param etef - the end to end flow that contains all the elements @@ -166,6 +235,41 @@ public static ComponentInstance getPreviousComponent(final EndToEndFlowInstance return null; } + /** + * Get the next thread/device period within an end to end flow after the flow element + * given as attribute. + * @param etef - the end to end flow + * @param flowElementInstance - the element to search from + * @return - the flow element period that is a thread and is after flowElementInstance + */ + //XXX: [Code Coverage] Dead code. + public static double getNextThreadOrDevicePeriod(final EndToEndFlowInstance etef, + final FlowElementInstance flowElementInstance) { + ComponentInstance ci = getNextFlowElement(etef, flowElementInstance).getComponentInstance(); + if ((ci != null) + && ((ci.getCategory() == ComponentCategory.THREAD) || (ci.getCategory() == ComponentCategory.DEVICE))) { + return GetProperties.getPeriodinMS(ci); + } + return 0; + } + + /** + * Get the next task within an end to end flow after the flow element + * given as attribute. + * @param etef - the end to end flow + * @param flowElementInstance - the element to search from + * @return - the flow element that is a task and is after flowElementInstance + */ + //XXX: [Code Coverage] Dead code. + public static double getNextSamplingComponentPeriod(final EndToEndFlowInstance etef, + final FlowElementInstance flowElementInstance) { + ComponentInstance ci = getNextFlowElement(etef, flowElementInstance).getComponentInstance(); + if (ci != null) { + return GetProperties.getPeriodinMS(ci); + } + return 0; + } + /** * find the next connection within an end to end flow * @param etef - the end to end flow where to search @@ -215,25 +319,37 @@ public static ComponentInstance getPartition(ComponentInstance componentInstance * get the partition period, either from the virtual processor representing the partition, or from the major frame of the ARINC653 specification of a processor * @return partition period as latency contributor */ - public static double getPartitionPeriod(final ComponentInstance part) { + public static double getPartitionPeriod(ComponentInstance part) { // first look for major frame value on processor - final ComponentInstance module = getModule(part); - final ComponentCategory moduleCategory = module != null ? module.getCategory() : null; - double result = 0.0; - if (moduleCategory == ComponentCategory.PROCESSOR || moduleCategory == ComponentCategory.VIRTUAL_PROCESSOR - || moduleCategory == ComponentCategory.ABSTRACT) { - result = PropertyUtils.getScaled(Arinc653::getModuleMajorFrame, module, TimeUnits.MS).orElse(0.0); + ComponentInstance module = getModule(part); + double res = GetProperties.getARINC653ModuleMajorFrame(module); + if (res == 0.0) { + // look for period on partition + res = GetProperties.getPeriodinMS(part); } + if (res == 0.0) { + // look for major frame value on virtual processor (partition) + res = GetProperties.getARINC653ModuleMajorFrame(part); + } + return res; + } - if (result == 0.0) { - // look for period on partition - result = PropertyUtils.getScaled(TimingProperties::getPeriod, part, TimeUnits.MS).orElse(0.0); - if (result == 0.0) { - // look for major frame value on virtual processor (partition) - result = PropertyUtils.getScaled(Arinc653::getModuleMajorFrame, part, TimeUnits.MS).orElse(0.0); + /** + * Get the major frame from the processor supporting ARINC653 partitions from its schedule + * @param componentInstance system, process, thread or other entity bound to a processor and running inside a partition. + * @return partition period supported by processor + */ + //XXX: [Code Coverage] Dead code. + public static double getARINC653ProcessorMajorFrameFromSchedule(ComponentInstance processorInstance) { + double res = 0.0; + List schedule = GetProperties.getModuleSchedule(processorInstance); + if ((schedule != null) && (schedule.size() > 0)) { + for (ARINC653ScheduleWindow window : schedule) { + res = res + window.getTime(); } + return res; } - return result; + return res; } public static Classifier getConnectionData(ConnectionInstance connectionInstance) { @@ -262,9 +378,7 @@ public static ComponentInstance getModule(ComponentInstance partition) { /** * Try to get the module from the virtual processor partition. */ - - module = (ComponentInstance) DeploymentProperties.getActualProcessorBinding(partition) - .map(list -> list.isEmpty() ? null : list.get(0)).orElse(null); + module = GetProperties.getBoundProcessor(partition); if (module == null) { module = partition.getContainingComponentInstance(); } @@ -281,31 +395,29 @@ public static ComponentInstance getModule(ComponentInstance partition) { * @param partition This can be a virtual processor representing a partition or a component instance tagged with SEI properties * @return offset, no virtual processor as ARINC653 partition, or no processor. */ - public static double getPartitionFrameOffset(final ComponentInstance partition, - final List schedule) { + public static double getPartitionFrameOffset(ComponentInstance partition, List schedule) { + double res = 0.0; //XXX: [Code Coverage] schedule is never null. if ((schedule == null) || (schedule.size() == 0)) { - return 0.0; - } else { - double res = 0.0; - for (final ScheduleWindow window : schedule) { - if (PropertyUtils.equals(window.getPartition(), partition, false)) { - return res; - } - - res = res + PropertyUtils.scale(window.getDuration(), TimeUnits.MS).orElse(0.0); + return res; + } + for (ARINC653ScheduleWindow window : schedule) { + if (window.getPartition() == partition) { + return res; } - // XXX: [Code Coverage] partition is always in schedule. - return 0.0; + + res = res + window.getTime(); } + //XXX: [Code Coverage] partition is always in schedule. + return 0.0; } - public static boolean isInSchedule(ComponentInstance partition, List schedule) { + public static boolean isInSchedule(ComponentInstance partition, List schedule) { if (schedule == null) { return true; } - for (ScheduleWindow window : schedule) { - if (PropertyUtils.equals(window.getPartition(), partition, false)) { + for (ARINC653ScheduleWindow window : schedule) { + if (window.getPartition() == partition) { return true; } } @@ -320,41 +432,32 @@ public static boolean isInSchedule(ComponentInstance partition, List schedule) { + public static double getPartitionDuration(ComponentInstance partition, List schedule) { if ((schedule == null) || (schedule.size() == 0)) { - double wcet = PropertyUtils.getScaled(TimingProperties::getExecutionTime, partition, TimeUnits.MS) - .orElse(0.0); + double wcet = GetProperties.getExecutionTimeInMS(partition); return wcet; } - for (ScheduleWindow window : schedule) { - if (window.getPartition().orElse(null) == partition) { - return PropertyUtils.scale(window.getDuration(), TimeUnits.MS).orElse(0.0); + for (ARINC653ScheduleWindow window : schedule) { + if (window.getPartition() == partition) { + return window.getTime(); } } return 0; } - public static List getModuleSchedule(final ComponentInstance partition) { + public static List getModuleSchedule(ComponentInstance partition) { + ComponentInstance module; + List schedule = null; + //XXX: [Code Coverage] partition cannot be null. if (partition == null) { - return null; - } else { - final ComponentInstance module = getModule(partition); - if (module == null) { - return null; - } else { - final ComponentCategory moduleCategory = module.getCategory(); - if (moduleCategory == ComponentCategory.PROCESSOR - || moduleCategory == ComponentCategory.VIRTUAL_PROCESSOR - || moduleCategory == ComponentCategory.ABSTRACT) { - /* Only keep those windows that have a partition specified */ - final List windows = Arinc653.getModuleSchedule(module).orElse(Collections.emptyList()); - windows.removeIf(sw -> !sw.getPartition().isPresent()); - return windows; - } else { - return Collections.emptyList(); - } - } + return schedule; } + module = getModule(partition); + if (module != null) { + schedule = GetProperties.getModuleSchedule(module); + + } + return schedule; } /** @@ -423,6 +526,22 @@ public static String getMinMaxLabel(boolean doMax) { } } + //XXX: [Code Coverage] Dead code. + public static double getDimension(final NamedElement ne) { + Property dimension = GetProperties.lookupPropertyDefinition(ne, DataModel._NAME, DataModel.Dimension); + List propertyValues; + try { + propertyValues = ne.getPropertyValueList(dimension); + } catch (Exception e) { + return 1.0; + } + double res = 1.0; + for (PropertyExpression propertyExpression : propertyValues) { + res = res * ((NumberValue) propertyExpression).getScaledValue(); + } + return res; + } + // ------------- // Results // ------------- @@ -628,25 +747,13 @@ public static String getContributorType(EObject relatedElement) { return relatedComponentType.getCategory().getName(); } if (relatedElement instanceof ConnectionInstance) { - final ConnectionKind connectionKind = ((ConnectionInstance) relatedElement) - .getKind(); - Timing connectionType; - try { - connectionType = connectionKind == ConnectionKind.PORT_CONNECTION - ? CommunicationProperties.getTiming((ConnectionInstance) relatedElement).orElse(Timing.SAMPLED) - : Timing.SAMPLED; - } catch (final PropertyLookupException e) { - // Property association semantics for FEATURE connections are missing - connectionType = Timing.SAMPLED; - } - - if (connectionType == Timing.DELAYED) { + if (FlowLatencyUtil.getConnectionType((ConnectionInstance) relatedElement) == ConnectionType.DELAYED) { return "delayed connection"; } - if (connectionType == Timing.IMMEDIATE) { + if (FlowLatencyUtil.getConnectionType((ConnectionInstance) relatedElement) == ConnectionType.IMMEDIATE) { return "immediate connection"; } - if (connectionType == Timing.SAMPLED) { + if (FlowLatencyUtil.getConnectionType((ConnectionInstance) relatedElement) == ConnectionType.SAMPLED) { return "connection"; } return "connection"; @@ -654,21 +761,6 @@ public static String getContributorType(EObject relatedElement) { return "component"; } -// public static ConnectionType getConnectionType(final ConnectionInstance conn) { -// EnumerationLiteral el = GetProperties.getConnectionTiming(conn); -// -// //XXX: [Code Coverage] el cannot be null. -// if ((el != null) && (el.getName().equalsIgnoreCase("immediate"))) { -// return ConnectionType.IMMEDIATE; -// } -// //XXX: [Code Coverage] el cannot be null. -// if ((el != null) && (el.getName().equalsIgnoreCase("delayed"))) { -// return ConnectionType.DELAYED; -// } -// return ConnectionType.SAMPLED; -// } -// - public static String getFullComponentContributorName(EObject relatedElement) { if (relatedElement instanceof ConnectionInstance) { return ((ConnectionInstance) relatedElement).getName(); diff --git a/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyCSVReport.java b/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyCSVReport.java index f11189ca821..1e9a72e3e1a 100644 --- a/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyCSVReport.java +++ b/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyCSVReport.java @@ -23,17 +23,16 @@ */ package org.osate.analysis.flows.model; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; +import java.io.ByteArrayInputStream; +import java.io.InputStream; import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.URIConverter; import org.osate.aadl2.instance.InstanceObject; import org.osate.aadl2.instance.SystemInstance; import org.osate.aadl2.modelsupport.resources.OsateResourceUtil; +import org.osate.aadl2.modelsupport.util.AadlUtil; import org.osate.analysis.flows.internal.utils.FlowLatencyUtil; import org.osate.result.AnalysisResult; import org.osate.result.Diagnostic; @@ -102,21 +101,24 @@ private static void addContributor(StringBuffer report, Result contributor, bool } public static void generateCSVReport(AnalysisResult latres) { - StringBuffer reportContent = getReportContent(latres); - Resource res = latres.eResource(); - URI csvuri = res.getURI().trimFileExtension().appendFileExtension("csv"); - URIConverter converter = res.getResourceSet().getURIConverter(); - try (OutputStream output = converter.createOutputStream(csvuri); - OutputStreamWriter writer = new OutputStreamWriter(output)) { - writer.write(reportContent.toString()); - } catch (IOException ioe) { + IFile file; + InputStream input; + StringBuffer reportContent; + + reportContent = getReportContent(latres); + file = getCSVFile(latres); + input = new ByteArrayInputStream(reportContent.toString().getBytes()); + try { + if (file.exists()) { + file.setContents(input, true, true, null); + } else { + AadlUtil.makeSureFoldersExist(file.getFullPath()); + file.create(input, true, null); + } + } catch (final CoreException e) { } } - /** - * @deprecated No longer used, should never have been API. - */ - @Deprecated public static IFile getCSVFile(AnalysisResult ar) { URI arURI = ar.eResource().getURI(); URI csvURI = arURI.trimFileExtension().appendFileExtension("csv"); diff --git a/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyContributorConnection.java b/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyContributorConnection.java index 0f20fa6e0b2..602558192fb 100644 --- a/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyContributorConnection.java +++ b/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyContributorConnection.java @@ -23,10 +23,8 @@ */ package org.osate.analysis.flows.model; -import org.osate.aadl2.contrib.communication.CommunicationProperties; -import org.osate.aadl2.contrib.communication.Timing; import org.osate.aadl2.instance.ConnectionInstance; -import org.osate.aadl2.instance.ConnectionKind; +import org.osate.analysis.flows.internal.utils.FlowLatencyUtil; /** * A latency Result represents something in the flow @@ -47,19 +45,15 @@ public LatencyContributorConnection(ConnectionInstance ci, boolean majorFrameDel @Override protected String getContributorType() { - final ConnectionInstance connInstance = (ConnectionInstance) this.relatedElement; - final Timing connectionType = connInstance.getKind() == ConnectionKind.PORT_CONNECTION - ? CommunicationProperties.getTiming(connInstance).orElse(Timing.SAMPLED) - : null; - if (connectionType == Timing.DELAYED) { + if (FlowLatencyUtil.getConnectionType((ConnectionInstance) this.relatedElement) == ConnectionType.DELAYED) { return "delayed connection"; } - if (connectionType == Timing.IMMEDIATE) { + if (FlowLatencyUtil.getConnectionType((ConnectionInstance) this.relatedElement) == ConnectionType.IMMEDIATE) { return "immediate connection"; } - if (connectionType == Timing.SAMPLED) { + if (FlowLatencyUtil.getConnectionType((ConnectionInstance) this.relatedElement) == ConnectionType.SAMPLED) { return "connection"; } diff --git a/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyReportEntry.java b/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyReportEntry.java index ab60986db56..d82e2befa3a 100644 --- a/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyReportEntry.java +++ b/analyses/org.osate.analysis.flows/src/org/osate/analysis/flows/model/LatencyReportEntry.java @@ -30,8 +30,6 @@ import java.util.ArrayList; import java.util.List; -import org.osate.aadl2.contrib.aadlproject.TimeUnits; -import org.osate.aadl2.contrib.communication.CommunicationProperties; import org.osate.aadl2.instance.ConnectionInstance; import org.osate.aadl2.instance.EndToEndFlowInstance; import org.osate.aadl2.instance.SystemInstance; @@ -43,13 +41,12 @@ import org.osate.analysis.flows.reporting.model.ReportSeverity; import org.osate.analysis.flows.reporting.model.ReportedCell; import org.osate.analysis.flows.reporting.model.Section; -import org.osate.pluginsupport.properties.PropertyUtils; -import org.osate.pluginsupport.properties.RealRange; import org.osate.result.Diagnostic; import org.osate.result.Result; import org.osate.result.ResultFactory; import org.osate.result.ResultType; import org.osate.result.util.ResultUtil; +import org.osate.xtext.aadl2.properties.util.GetProperties; /* * A report entry corresponds to the entry within the report. @@ -82,12 +79,9 @@ public LatencyReportEntry(EndToEndFlowInstance etef, SystemOperationMode som, bo this.asynchronousSystem = asynchronousSystem; this.majorFrameDelay = majorFrameDelay; - final RealRange expectedLatency = PropertyUtils - .getScaledRange(CommunicationProperties::getLatency, relatedEndToEndFlow, TimeUnits.MS) - .orElse(RealRange.ZEROED); + expectedMaxLatency = GetProperties.getMaximumLatencyinMilliSec(this.relatedEndToEndFlow); + expectedMinLatency = GetProperties.getMinimumLatencyinMilliSec(this.relatedEndToEndFlow); - expectedMaxLatency = expectedLatency.getMaximum(); - expectedMinLatency = expectedLatency.getMinimum(); } public void finalizeReportEntry() { diff --git a/analyses/org.osate.analysis.resource.budgets.tests/src/org/osate/analysis/resource/budgets/tests/Issue1383Test.xtend b/analyses/org.osate.analysis.resource.budgets.tests/src/org/osate/analysis/resource/budgets/tests/Issue1383Test.xtend new file mode 100644 index 00000000000..49398f7e515 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets.tests/src/org/osate/analysis/resource/budgets/tests/Issue1383Test.xtend @@ -0,0 +1,215 @@ +/** + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * All Rights Reserved. + * + * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE + * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT + * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. + * + * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * SPDX-License-Identifier: EPL-2.0 + * + * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). + * + * This program includes and/or can make use of certain third party source code, object code, documentation and other + * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system + * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and + * conditions contained in any such Third Party Software or separate license file distributed with such Third Party + * Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici- + * aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li- + * censes only apply to the Third Party Software and not any other portion of this program or this program as a whole. + */ +package org.osate.analysis.resource.budgets.tests + +import com.google.inject.Inject +import com.itemis.xtext.testing.XtextTest +import org.eclipse.xtext.testing.InjectWith +import org.eclipse.xtext.testing.XtextRunner +import org.junit.Test +import org.junit.runner.RunWith +import org.osate.aadl2.AadlPackage +import org.osate.aadl2.SystemImplementation +import org.osate.aadl2.instantiation.InstantiateModel +import org.osate.testsupport.Aadl2InjectorProvider +import org.osate.testsupport.TestHelper + +import static org.junit.Assert.* + +import static extension org.junit.Assert.assertEquals +import org.osate.result.Result +import java.util.List +import org.osate.result.util.ResultUtil +import org.osate.analysis.resource.budgets.power.PowerRequirementAnalysis +import org.osate.result.Diagnostic +import org.osate.result.DiagnosticType + +@RunWith(typeof(XtextRunner)) +@InjectWith(typeof(Aadl2InjectorProvider)) +class Issue1383Test extends XtextTest { + + @Inject + TestHelper testHelper + + val static PROJECT_LOCATION = "org.osate.analysis.resource.budgets.tests/models/Issue1383/" + + @Test + def void testBasicResourceBudgetExample() { + val pkg = testHelper.parseFile(PROJECT_LOCATION + "Example.aadl") + + // instantiate + val cls = pkg.ownedPublicSection.ownedClassifiers + val sysImpl = cls.findFirst[name == "MySystem.Tier0"] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + + // check power requirements + val checker = new PowerRequirementAnalysis() + val analysisResult = checker.invoke(null, instance) + val somResult = analysisResult.results.get(0) + val powerResult = somResult.subResults.get(0) + checkRBValues(powerResult); + + val powerResult2 = somResult.subResults.get(1) + checkRBValues(powerResult2); + + val powerResult3 = somResult.subResults.get(2) + checkRBValues(powerResult3); + + val powerResult4 = somResult.subResults.get(3) + checkRBValues(powerResult4); + + val powerResult5 = somResult.subResults.get(4) + checkRBValues(powerResult5); + } + + @Test + def void testOverloadedCapacity() { + val pkg = testHelper.parseFile(PROJECT_LOCATION + "TestOverCapacity.aadl") + + // instantiate + val cls = pkg.ownedPublicSection.ownedClassifiers + val sysImpl = cls.findFirst[name == "MySystem.Tier0"] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + + // check power requirements + val checker = new PowerRequirementAnalysis() + val analysisResult = checker.invoke(null, instance) + val somResult = analysisResult.results.get(0) + val powerResult = somResult.subResults.get(0) + checkOverValues(powerResult); + + val powerResult2 = somResult.subResults.get(1) + checkOverValues(powerResult2); + + val powerResult3 = somResult.subResults.get(2) + checkOverValues(powerResult3); + + val powerResult4 = somResult.subResults.get(3) + checkOverValues(powerResult4); + + val powerResult5 = somResult.subResults.get(4) + checkOverValues(powerResult5); + } + + @Test + def void testNoSupply() { + val pkg = testHelper.parseFile(PROJECT_LOCATION + "TestNoSupply.aadl") + + // instantiate + val cls = pkg.ownedPublicSection.ownedClassifiers + val sysImpl = cls.findFirst[name == "MySystem.Tier0"] as SystemImplementation + val instance = InstantiateModel.instantiate(sysImpl) + + // check power requirements + val checker = new PowerRequirementAnalysis() + val analysisResult = checker.invoke(null, instance) + val somResult = analysisResult.results.get(0) + val powerResult = somResult.subResults.get(0) + checkNoSupplyValues(powerResult); + + val powerResult2 = somResult.subResults.get(1) + checkNoSupplyValues(powerResult2); + + val powerResult3 = somResult.subResults.get(2) + checkNoSupplyValues(powerResult3); + + val powerResult4 = somResult.subResults.get(3) + checkNoSupplyValues(powerResult4); + } + + private static def void checkNoSupplyValues(Result result){ + val compName = ResultUtil.getString(result, 7) + + if (compName == "hw") + checkValues(result, #[800.0, 0.0, 40000.0, 92500.0, 0.0], #[error("Grid budget total 92.5 W exceeds capacity 40.0 W"), error("budget total 92.5 W exceeds capacity 40.0 W")]) + else if (compName == "sensor1") + checkValues(result, #[450.0, 0.0, 40000.0, 92500.0, 0.0], #[error("Grid budget total 92.5 W exceeds capacity 40.0 W"), error("budget total 92.5 W exceeds capacity 40.0 W")]) + else if (compName == "sensor2") + checkValues(result, #[450.0, 0.0, 40000.0, 92500.0, 0.0], #[error("Grid budget total 92.5 W exceeds capacity 40.0 W"), error("budget total 92.5 W exceeds capacity 40.0 W")]) + else if (compName == "actuator") + checkValues(result, #[90800.0, 0.0, 40000.0, 92500.0, 0.0], #[error("Grid budget total 92.5 W exceeds capacity 40.0 W"), error("budget total 92.5 W exceeds capacity 40.0 W")]) + } + + private static def void checkOverValues(Result result){ + val compName = ResultUtil.getString(result, 7) + + if (compName == "EPSU") + checkValues(result, #[0.0, 80000.0, 40000.0, 92500.0, 80000.0], #[error("Grid budget total 92.5 W exceeds capacity 40.0 W"), error("budget total 92.5 W exceeds supply 80.0 W")]) + else if (compName == "hw") + checkValues(result, #[800.0, 0.0, 40000.0, 92500.0, 80000.0], #[error("Grid budget total 92.5 W exceeds capacity 40.0 W"), error("budget total 92.5 W exceeds supply 80.0 W")]) + else if (compName == "sensor1") + checkValues(result, #[450.0, 0.0, 40000.0, 92500.0, 80000.0], #[error("Grid budget total 92.5 W exceeds capacity 40.0 W"), error("budget total 92.5 W exceeds supply 80.0 W")]) + else if (compName == "sensor2") + checkValues(result, #[450.0, 0.0, 40000.0, 92500.0, 80000.0], #[error("Grid budget total 92.5 W exceeds capacity 40.0 W"), error("budget total 92.5 W exceeds supply 80.0 W")]) + else if (compName == "actuator") + checkValues(result, #[90800.0, 0.0, 40000.0, 92500.0, 80000.0], #[error("Grid budget total 92.5 W exceeds capacity 40.0 W"), error("budget total 92.5 W exceeds supply 80.0 W")]) + } + + private static def void checkRBValues(Result result){ + val compName = ResultUtil.getString(result, 7) + + if (compName == "EPSU") + checkValues(result, #[0.0, 40000.0, 40000.0, 2500.0, 40000.0], #[]) + else if (compName == "hw") + checkValues(result, #[800.0, 0.0, 40000.0, 2500.0, 40000.0], #[]) + else if (compName == "sensor1") + checkValues(result, #[450.0, 0.0, 40000.0, 2500.0, 40000.0], #[]) + else if (compName == "sensor2") + checkValues(result, #[450.0, 0.0, 40000.0, 2500.0, 40000.0], #[]) + else if (compName == "actuator") + checkValues(result, #[800.0, 0.0, 40000.0, 2500.0, 40000.0], #[]) + } + + private static def List error(String msg) { + return #[DiagnosticType.ERROR, msg] + } + + private static def List warning(String msg) { + return #[DiagnosticType.WARNING, msg] + } + + private static def void checkDiagnostic(Diagnostic d, DiagnosticType type, String msg) { + assertEquals(type, d.diagnosticType) + assertEquals(msg, d.message) + } + + private static def void checkValues(Result result, List values, List> diagnostics) { + for (var i = 0; i < values.size; i++) { + val expected = values.get(i) + val actual = ResultUtil.getReal(result, i) + assertEquals(expected, actual, 0.0) + } + + assertEquals(diagnostics.size, result.diagnostics.size) + for (var i = 0; i < diagnostics.size; i++) { + val expected = diagnostics.get(i) + checkDiagnostic(result.diagnostics.get(i), expected.get(0) as DiagnosticType, expected.get(1) as String) + } + } + + private static def void checkIntegerValue(Result result, int idx, long expected) { + val actual = ResultUtil.getInteger(result, idx) + assertEquals(expected, actual) + } +} diff --git a/analyses/org.osate.analysis.resource.budgets/META-INF/MANIFEST.MF b/analyses/org.osate.analysis.resource.budgets/META-INF/MANIFEST.MF index 5fb74dec244..b29f1f41dca 100644 --- a/analyses/org.osate.analysis.resource.budgets/META-INF/MANIFEST.MF +++ b/analyses/org.osate.analysis.resource.budgets/META-INF/MANIFEST.MF @@ -12,9 +12,9 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.115.0,4.0.0)", org.eclipse.emf.ecore;bundle-version="[2.20.0,3.0.0)", org.eclipse.core.resources;bundle-version="[3.13.0,4.0.0)", org.osate.aadl2;bundle-version="[4.0.0,5.0.0)", - org.osate.ui;bundle-version="[6.2.0,7.0.0)", + org.osate.ui;bundle-version="[6.1.0,7.0.0)", org.osate.aadl2.modelsupport;bundle-version="[6.0.0,7.0.0)", - org.osate.xtext.aadl2.properties;bundle-version="[3.1.0,4.0.0)", + org.osate.xtext.aadl2.properties;bundle-version="[3.0.0,4.0.0)", org.osate.analysis.architecture;bundle-version="[2.0.0,3.0.0)", org.osate.analysis.flows;bundle-version="[5.0.0,6.0.0)", org.osate.results;bundle-version="[3.0.0,4.0.0)", @@ -26,6 +26,7 @@ Bundle-ActivationPolicy: lazy Export-Package: org.osate.analysis.resource.budgets, org.osate.analysis.resource.budgets.busload, org.osate.analysis.resource.budgets.handlers, - org.osate.analysis.resource.budgets.logic + org.osate.analysis.resource.budgets.logic, + org.osate.analysis.resource.budgets.power Automatic-Module-Name: org.osate.analysis.resource.budgets Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/analyses/org.osate.analysis.resource.budgets/help/markdown/power.md b/analyses/org.osate.analysis.resource.budgets/help/markdown/power.md new file mode 100644 index 00000000000..a5d0211c8a8 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/help/markdown/power.md @@ -0,0 +1,117 @@ + +#Analyze Electrical Power Usage# + +OSATE supports modeling and analysis of electrical power distribution and consumption. You can introduce an *abstract* component type to represent the concept of electrical power, e.g., call it *Electricity*. We will use it as the type of component features. +Our electrical power analysis framework supports the concept of **power suppliers** and **power consumers**. A **power transmission system** is used to move electrical power from suppliers to consumers. +## Electrical Power Suppliers## +Any component type can be an electrical *power supplier*. However, it only make sense for physical components (**device**, **processor**, **bus**, **memory**) as well as **system**, and **abstract**. +We represent the fact that it supplies electricity by defining an outgoing feature, e.g., an abstract feature **out feature**. The fact that it supplies power is indicated by the property **SEI::PowerSupply**. You associate this property value with the outgoing feature. The values are real values in units of *mW* (milli watts), *W* (watts), *KW* (Kilo watts). +Users should also associate a component type as the type of the feature. This ensures that when connections are made that only features dealing with electricity are connected to each other. +## Electrical Power Consumers## +Any component type can be an electrical *power consumer*. We represent this by an incoming feature, e.g., **in feature**. In this case we use the property **SEI::PowerBudget** to indicate the demand for electrical power. Again the values are reals in units of watts. +## Electrical Power Transmission System## +We use **system**, **device**, or **abstract** components to represent the transmission system for electrical power. It has the property **SEI::PowerCapacity** in units or watts. It indicates the amount of electrical power it is able to handle. +The component type also has abstract features to indicate connection points to suppliers and to consumers. Feature connections are used to make the actual connections. + +##Electrical Power Analysis## +Electrical power analysis is available under the *Analyses/Architecture* menu as *Analyze power requirements*, or by clicking on the battery icon in the tool bar. The command is invoked on the selected instance model. + +The analysis is performed for each component that represents a transmission system. The analysis identifies all suppliers and totals the supply. Similarly, it totals the budgets of all consumers. The analysis then ensures that neither the supply total, nor the budget total exceeds the capacity. It also ensure that the budget total does not exceed the supply total. +The results of the analysis are recorded in a report under the *reports/Power* folder. It shows for each transmission system the capacity, the list of suppliers and their amount, the list of consumers and their budgets, as well as their totals. The report closes with the comparison results. +The result comparisons are also recorded as Eclipse Markers and can be viewed in the Eclipse *Problems* view. +> Note that in the problems view you can define filters to to sort the view by problem marker type, and to only see Markers of certain types. + +##Electrial Power Transmission Subsystems## +Electrical power transmission systems can themselves be consumers of electrical power that they receive from another transmission system rather than directly from a supplier. For example, a transmission subsystem may draw its power from a transmission backbone. This is modeled by an *incoming* feature with a *power budget* property. + +##Examples## +One example is available on [Github/Osate](https://github.com/osate/examples) and is called *ResourceBudgets*. You instantiate the top level system called *MySystem* as a tier0 model or as a tier2 model. It has a single transmission system. + +A second example is available on [Github/Osate](https://github.com/osate/alisa-examples) and is called *MutliTierAircraftExample*. You will find a set of project under *MultiTierAircraft* with the AADL model. The example is from the System Architecture Virtual Integration (SAVI) initiative. It has a backbone transmission system as well as a subsystem within the IMA of the aircraft. +The project AircraftSpecified represents *Tier1*, i.e., a single layer. AircraftIntegrated represents variants of *Tier2*, which includes the Integrated Modular Avionics (IMA) at one level of detail. +> Note: The example also includes a requirement and verification plan specification for automated incremental life cycle assurance under the ALISA plug-ins (see ALISA help for details). + +## Running the Analysis + +The analysis can be run over multiple models at the same time: + +1. Select one or more working set, project, directory, or instance model `.aaxl` file in the `AADL Navigator`. +2. Select `Analyses > Budget > Analyze Power Requirements` from the menu bar or navigator context menu, or select the "Analyze power requirements" icon in the toolbar. + +The analysis finds all the instance models (`.aaxl` files) in the selected items and runs over each one. + +* _The analysis runs for each system operation mode in each model._ +* An output comma-separated-values (`.csv`) file is generated for each analyzed model. The file is located in the `reports/Power` folder. The file has the same name as the model file, but with `__Power` appended to the end. +* If the analysis finds inconsistencies, it will produce error or warning markers on the instance model file. + +## Invoking Programmatically + +The analysis can be invoked programmatically by other tools by calling the method + + AnalysisResult invoke(IProgressMonitor, SystemInstance) + +on an instance of the class `PowerRequirementAnalysis` in the package `org.osate.analysis.resource.budgets.power`. This is found in the plug-in `org.osate.analysis.resource.budgets`. + +As the signature indicates, the method takes a possibly-`null` progress monitor, and the `SystemInstance` object of the model to analyze. All the system operation modes of the model are analyzed. + +A new instance of the class `PowerRequirementAnalysis` should be used for each system instance. + +### Result format + +The format for the `AnalysisResult` tree returned by `invoke()` is as follows: + +`AnalysisResult` + +* `analysis` = "Power Requirements" +* `modelElement` = `SystemInstance` being analyzed +* `resultType` = `SUCCESS` +* `message = `"Power analysis of _name of system instance_"` +* `diagnostics` = _empty list_ +* `parameters` = _empty list_ +* `results` = one `Result` for each system operation mode + + * `modelElement` = `SystemOperationMode` instance object + * `resultType` = `SUCCESS` + * `message` = _empty_ + * `values` = _empty list_ + * `diagnostics` = _empty list_ + * `subResults` = one `Result` for each `ComponentInstance` with `category` of `Feature` or `Connection End` + + * `modelElement` = `FeatureInstance` or `ConnectionEndInstance` instance object + * `resultType` = `SUCCESS` + * `message` = The component's name from `getName()` + * `values[0]` = The budget of the feature or connection end in W (`RealValue`) + * `values[1]` = The supply in form of power budget drawn from other supply. This could be a requires bus access, or an incoming abstract feature. There must be a connection on this feature (`RealValue`) + * `values[2]` = The capacity of the power supplier system in W as specified by `SEI::PowerCapacity` property (`RealValue`) + * `values[3]` = Total Budget across the whole system (`RealValue`) + * `values[4]` = Total Supply across the whole system (`RealValue`) + * `values[5]` = Components that represent a power system with capacity (`StringValue`) + * `values[6]` = System name (`StringValue`) + * `values[7]` = `Feature` or `ConnectionEnd` instance's name (`StringValue`) + * `values[8]` = Budget ... for ... out of total ... (`StringValue`) + * `values[9]` = Supply ... for ... out of total ... (`StringValue`) + * `values[10]` = Total capacity: ... (`StringValue`) + * `diagnostics` = Diagnostics associated with this Feature or Connection End. + * `subResults` = _empty_ \ No newline at end of file diff --git a/analyses/org.osate.analysis.resource.budgets/help/toc_power.xml b/analyses/org.osate.analysis.resource.budgets/help/toc_power.xml new file mode 100644 index 00000000000..9d9906629dc --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/help/toc_power.xml @@ -0,0 +1,28 @@ + + + + + + diff --git a/analyses/org.osate.analysis.resource.budgets/model/power.aird b/analyses/org.osate.analysis.resource.budgets/model/power.aird new file mode 100644 index 00000000000..a91e90ce3fb --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/model/power.aird @@ -0,0 +1,99 @@ + + + + power.ecore + platform:/resource/org.osate.aadl2/model/instance.ecore + platform:/resource/org.osate.aadl2/model/aadl2.ecore + platform:/resource/org.osate.analysis.model/model/analysis.ecore + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + italic + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/analyses/org.osate.analysis.resource.budgets/model/power.ecore b/analyses/org.osate.analysis.resource.budgets/model/power.ecore new file mode 100644 index 00000000000..2edaa166a72 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/model/power.ecore @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + diff --git a/analyses/org.osate.analysis.resource.budgets/model/power.genmodel b/analyses/org.osate.analysis.resource.budgets/model/power.genmodel new file mode 100644 index 00000000000..ef2b938315f --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/model/power.genmodel @@ -0,0 +1,27 @@ + + + power.ecore + + + + + + + + + + + + + + + + + + + diff --git a/analyses/org.osate.analysis.resource.budgets/plugin.xml b/analyses/org.osate.analysis.resource.budgets/plugin.xml index ba6bb6df3d1..25c674e8814 100644 --- a/analyses/org.osate.analysis.resource.budgets/plugin.xml +++ b/analyses/org.osate.analysis.resource.budgets/plugin.xml @@ -101,10 +101,10 @@ censes only apply to the Third Party Software and not any other portion of this - + + * A representation of the model object 'Consumer'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer#getFeatureInstance Feature Instance}
  • + *
+ * + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerConsumer() + * @model + * @generated + * @since 4.1 + */ +public interface PowerConsumer extends PowerElement { + /** + * Returns the value of the 'Feature Instance' reference. + * + * + * @return the value of the 'Feature Instance' reference. + * @see #setFeatureInstance(FeatureInstance) + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerConsumer_FeatureInstance() + * @model + * @generated + */ + FeatureInstance getFeatureInstance(); + + /** + * Sets the value of the '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer#getFeatureInstance Feature Instance}' reference. + * + * + * @param value the new value of the 'Feature Instance' reference. + * @see #getFeatureInstance() + * @generated + */ + void setFeatureInstance(FeatureInstance value); + +} // PowerConsumer diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerElement.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerElement.java new file mode 100644 index 00000000000..d6965d9a364 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerElement.java @@ -0,0 +1,94 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power; + +import org.osate.analysis.model.AnalysisElement; + +/** + * + * A representation of the model object 'Element'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getCapacity Capacity}
  • + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getBudget Budget}
  • + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getSupply Supply}
  • + *
+ * + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerElement() + * @model abstract="true" + * @generated + * @since 4.1 + */ +public interface PowerElement extends AnalysisElement { + /** + * Returns the value of the 'Capacity' attribute. + * + * + * @return the value of the 'Capacity' attribute. + * @see #setCapacity(double) + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerElement_Capacity() + * @model + * @generated + */ + double getCapacity(); + + /** + * Sets the value of the '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getCapacity Capacity}' attribute. + * + * + * @param value the new value of the 'Capacity' attribute. + * @see #getCapacity() + * @generated + */ + void setCapacity(double value); + + /** + * Returns the value of the 'Budget' attribute. + * + * + * @return the value of the 'Budget' attribute. + * @see #setBudget(double) + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerElement_Budget() + * @model + * @generated + */ + double getBudget(); + + /** + * Sets the value of the '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getBudget Budget}' attribute. + * + * + * @param value the new value of the 'Budget' attribute. + * @see #getBudget() + * @generated + */ + void setBudget(double value); + + /** + * Returns the value of the 'Supply' attribute. + * + * + * @return the value of the 'Supply' attribute. + * @see #setSupply(double) + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerElement_Supply() + * @model + * @generated + */ + double getSupply(); + + /** + * Sets the value of the '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getSupply Supply}' attribute. + * + * + * @param value the new value of the 'Supply' attribute. + * @see #getSupply() + * @generated + */ + void setSupply(double value); + +} // PowerElement diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerFactory.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerFactory.java new file mode 100644 index 00000000000..065cfea45e1 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerFactory.java @@ -0,0 +1,71 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage + * @generated + * @since 4.1 + */ +public interface PowerFactory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + PowerFactory eINSTANCE = org.osate.analysis.resource.budgets.internal.models.power.impl.PowerFactoryImpl.init(); + + /** + * Returns a new object of class 'Transmission System'. + * + * + * @return a new object of class 'Transmission System'. + * @generated + */ + PowerTransmissionSystem createPowerTransmissionSystem(); + + /** + * Returns a new object of class 'Supplier'. + * + * + * @return a new object of class 'Supplier'. + * @generated + */ + PowerSupplier createPowerSupplier(); + + /** + * Returns a new object of class 'Consumer'. + * + * + * @return a new object of class 'Consumer'. + * @generated + */ + PowerConsumer createPowerConsumer(); + + /** + * Returns a new object of class 'Model'. + * + * + * @return a new object of class 'Model'. + * @generated + */ + PowerModel createPowerModel(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + PowerPackage getPowerPackage(); + +} //PowerFactory diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerModel.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerModel.java new file mode 100644 index 00000000000..b3facbe82ba --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerModel.java @@ -0,0 +1,39 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power; + +import org.eclipse.emf.common.util.EList; +import org.osate.analysis.model.AnalysisElement; + +/** + * + * A representation of the model object 'Model'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.PowerModel#getRootPowerTransmissionSystem Root Power Transmission System}
  • + *
+ * + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerModel() + * @model + * @generated + * @since 4.1 + */ +public interface PowerModel extends AnalysisElement { + /** + * Returns the value of the 'Root Power Transmission System' containment reference list. + * The list contents are of type {@link org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem}. + * + * + * @return the value of the 'Root Power Transmission System' containment reference list. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerModel_RootPowerTransmissionSystem() + * @model containment="true" + * @generated + */ + EList getRootPowerTransmissionSystem(); + +} // PowerModel diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerPackage.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerPackage.java new file mode 100644 index 00000000000..131364604fb --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerPackage.java @@ -0,0 +1,751 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.osate.analysis.model.ModelPackage; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerFactory + * @model kind="package" + * @generated + * @since 4.1 + */ +public interface PowerPackage extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "power"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://osate.org/analysis/power"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "power"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + PowerPackage eINSTANCE = org.osate.analysis.resource.budgets.internal.models.power.impl.PowerPackageImpl.init(); + + /** + * The meta object id for the '{@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerElementImpl Element}' class. + * + * + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerElementImpl + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerPackageImpl#getPowerElement() + * @generated + */ + int POWER_ELEMENT = 0; + + /** + * The feature id for the 'Capacity' attribute. + * + * + * @generated + * @ordered + */ + int POWER_ELEMENT__CAPACITY = ModelPackage.ANALYSIS_ELEMENT_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Budget' attribute. + * + * + * @generated + * @ordered + */ + int POWER_ELEMENT__BUDGET = ModelPackage.ANALYSIS_ELEMENT_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Supply' attribute. + * + * + * @generated + * @ordered + */ + int POWER_ELEMENT__SUPPLY = ModelPackage.ANALYSIS_ELEMENT_FEATURE_COUNT + 2; + + /** + * The number of structural features of the 'Element' class. + * + * + * @generated + * @ordered + */ + int POWER_ELEMENT_FEATURE_COUNT = ModelPackage.ANALYSIS_ELEMENT_FEATURE_COUNT + 3; + + /** + * The operation id for the 'Is Leaf' operation. + * + * + * @generated + * @ordered + */ + int POWER_ELEMENT___IS_LEAF = ModelPackage.ANALYSIS_ELEMENT___IS_LEAF; + + /** + * The operation id for the 'Get Ordered Children' operation. + * + * + * @generated + * @ordered + */ + int POWER_ELEMENT___GET_ORDERED_CHILDREN = ModelPackage.ANALYSIS_ELEMENT___GET_ORDERED_CHILDREN; + + /** + * The number of operations of the 'Element' class. + * + * + * @generated + * @ordered + */ + int POWER_ELEMENT_OPERATION_COUNT = ModelPackage.ANALYSIS_ELEMENT_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerTransmissionSystemImpl Transmission System}' class. + * + * + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerTransmissionSystemImpl + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerPackageImpl#getPowerTransmissionSystem() + * @generated + */ + int POWER_TRANSMISSION_SYSTEM = 1; + + /** + * The feature id for the 'Capacity' attribute. + * + * + * @generated + * @ordered + */ + int POWER_TRANSMISSION_SYSTEM__CAPACITY = POWER_ELEMENT__CAPACITY; + + /** + * The feature id for the 'Budget' attribute. + * + * + * @generated + * @ordered + */ + int POWER_TRANSMISSION_SYSTEM__BUDGET = POWER_ELEMENT__BUDGET; + + /** + * The feature id for the 'Supply' attribute. + * + * + * @generated + * @ordered + */ + int POWER_TRANSMISSION_SYSTEM__SUPPLY = POWER_ELEMENT__SUPPLY; + + /** + * The feature id for the 'Component Instance' reference. + * + * + * @generated + * @ordered + */ + int POWER_TRANSMISSION_SYSTEM__COMPONENT_INSTANCE = POWER_ELEMENT_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Suppliers' containment reference list. + * + * + * @generated + * @ordered + */ + int POWER_TRANSMISSION_SYSTEM__SUPPLIERS = POWER_ELEMENT_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Consumers' containment reference list. + * + * + * @generated + * @ordered + */ + int POWER_TRANSMISSION_SYSTEM__CONSUMERS = POWER_ELEMENT_FEATURE_COUNT + 2; + + /** + * The number of structural features of the 'Transmission System' class. + * + * + * @generated + * @ordered + */ + int POWER_TRANSMISSION_SYSTEM_FEATURE_COUNT = POWER_ELEMENT_FEATURE_COUNT + 3; + + /** + * The operation id for the 'Is Leaf' operation. + * + * + * @generated + * @ordered + */ + int POWER_TRANSMISSION_SYSTEM___IS_LEAF = POWER_ELEMENT___IS_LEAF; + + /** + * The operation id for the 'Get Ordered Children' operation. + * + * + * @generated + * @ordered + */ + int POWER_TRANSMISSION_SYSTEM___GET_ORDERED_CHILDREN = POWER_ELEMENT___GET_ORDERED_CHILDREN; + + /** + * The number of operations of the 'Transmission System' class. + * + * + * @generated + * @ordered + */ + int POWER_TRANSMISSION_SYSTEM_OPERATION_COUNT = POWER_ELEMENT_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerSupplierImpl Supplier}' class. + * + * + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerSupplierImpl + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerPackageImpl#getPowerSupplier() + * @generated + */ + int POWER_SUPPLIER = 2; + + /** + * The feature id for the 'Capacity' attribute. + * + * + * @generated + * @ordered + */ + int POWER_SUPPLIER__CAPACITY = POWER_ELEMENT__CAPACITY; + + /** + * The feature id for the 'Budget' attribute. + * + * + * @generated + * @ordered + */ + int POWER_SUPPLIER__BUDGET = POWER_ELEMENT__BUDGET; + + /** + * The feature id for the 'Supply' attribute. + * + * + * @generated + * @ordered + */ + int POWER_SUPPLIER__SUPPLY = POWER_ELEMENT__SUPPLY; + + /** + * The feature id for the 'Feature Instance' reference. + * + * + * @generated + * @ordered + */ + int POWER_SUPPLIER__FEATURE_INSTANCE = POWER_ELEMENT_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'Supplier' class. + * + * + * @generated + * @ordered + */ + int POWER_SUPPLIER_FEATURE_COUNT = POWER_ELEMENT_FEATURE_COUNT + 1; + + /** + * The operation id for the 'Is Leaf' operation. + * + * + * @generated + * @ordered + */ + int POWER_SUPPLIER___IS_LEAF = POWER_ELEMENT___IS_LEAF; + + /** + * The operation id for the 'Get Ordered Children' operation. + * + * + * @generated + * @ordered + */ + int POWER_SUPPLIER___GET_ORDERED_CHILDREN = POWER_ELEMENT___GET_ORDERED_CHILDREN; + + /** + * The number of operations of the 'Supplier' class. + * + * + * @generated + * @ordered + */ + int POWER_SUPPLIER_OPERATION_COUNT = POWER_ELEMENT_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerConsumerImpl Consumer}' class. + * + * + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerConsumerImpl + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerPackageImpl#getPowerConsumer() + * @generated + */ + int POWER_CONSUMER = 3; + + /** + * The feature id for the 'Capacity' attribute. + * + * + * @generated + * @ordered + */ + int POWER_CONSUMER__CAPACITY = POWER_ELEMENT__CAPACITY; + + /** + * The feature id for the 'Budget' attribute. + * + * + * @generated + * @ordered + */ + int POWER_CONSUMER__BUDGET = POWER_ELEMENT__BUDGET; + + /** + * The feature id for the 'Supply' attribute. + * + * + * @generated + * @ordered + */ + int POWER_CONSUMER__SUPPLY = POWER_ELEMENT__SUPPLY; + + /** + * The feature id for the 'Feature Instance' reference. + * + * + * @generated + * @ordered + */ + int POWER_CONSUMER__FEATURE_INSTANCE = POWER_ELEMENT_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'Consumer' class. + * + * + * @generated + * @ordered + */ + int POWER_CONSUMER_FEATURE_COUNT = POWER_ELEMENT_FEATURE_COUNT + 1; + + /** + * The operation id for the 'Is Leaf' operation. + * + * + * @generated + * @ordered + */ + int POWER_CONSUMER___IS_LEAF = POWER_ELEMENT___IS_LEAF; + + /** + * The operation id for the 'Get Ordered Children' operation. + * + * + * @generated + * @ordered + */ + int POWER_CONSUMER___GET_ORDERED_CHILDREN = POWER_ELEMENT___GET_ORDERED_CHILDREN; + + /** + * The number of operations of the 'Consumer' class. + * + * + * @generated + * @ordered + */ + int POWER_CONSUMER_OPERATION_COUNT = POWER_ELEMENT_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerModelImpl Model}' class. + * + * + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerModelImpl + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerPackageImpl#getPowerModel() + * @generated + */ + int POWER_MODEL = 4; + + /** + * The feature id for the 'Root Power Transmission System' containment reference list. + * + * + * @generated + * @ordered + */ + int POWER_MODEL__ROOT_POWER_TRANSMISSION_SYSTEM = ModelPackage.ANALYSIS_ELEMENT_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'Model' class. + * + * + * @generated + * @ordered + */ + int POWER_MODEL_FEATURE_COUNT = ModelPackage.ANALYSIS_ELEMENT_FEATURE_COUNT + 1; + + /** + * The operation id for the 'Is Leaf' operation. + * + * + * @generated + * @ordered + */ + int POWER_MODEL___IS_LEAF = ModelPackage.ANALYSIS_ELEMENT___IS_LEAF; + + /** + * The operation id for the 'Get Ordered Children' operation. + * + * + * @generated + * @ordered + */ + int POWER_MODEL___GET_ORDERED_CHILDREN = ModelPackage.ANALYSIS_ELEMENT___GET_ORDERED_CHILDREN; + + /** + * The number of operations of the 'Model' class. + * + * + * @generated + * @ordered + */ + int POWER_MODEL_OPERATION_COUNT = ModelPackage.ANALYSIS_ELEMENT_OPERATION_COUNT + 0; + + + /** + * Returns the meta object for class '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerElement Element}'. + * + * + * @return the meta object for class 'Element'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerElement + * @generated + */ + EClass getPowerElement(); + + /** + * Returns the meta object for the attribute '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getCapacity Capacity}'. + * + * + * @return the meta object for the attribute 'Capacity'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getCapacity() + * @see #getPowerElement() + * @generated + */ + EAttribute getPowerElement_Capacity(); + + /** + * Returns the meta object for the attribute '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getBudget Budget}'. + * + * + * @return the meta object for the attribute 'Budget'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getBudget() + * @see #getPowerElement() + * @generated + */ + EAttribute getPowerElement_Budget(); + + /** + * Returns the meta object for the attribute '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getSupply Supply}'. + * + * + * @return the meta object for the attribute 'Supply'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerElement#getSupply() + * @see #getPowerElement() + * @generated + */ + EAttribute getPowerElement_Supply(); + + /** + * Returns the meta object for class '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem Transmission System}'. + * + * + * @return the meta object for class 'Transmission System'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem + * @generated + */ + EClass getPowerTransmissionSystem(); + + /** + * Returns the meta object for the reference '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem#getComponentInstance Component Instance}'. + * + * + * @return the meta object for the reference 'Component Instance'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem#getComponentInstance() + * @see #getPowerTransmissionSystem() + * @generated + */ + EReference getPowerTransmissionSystem_ComponentInstance(); + + /** + * Returns the meta object for the containment reference list '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem#getSuppliers Suppliers}'. + * + * + * @return the meta object for the containment reference list 'Suppliers'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem#getSuppliers() + * @see #getPowerTransmissionSystem() + * @generated + */ + EReference getPowerTransmissionSystem_Suppliers(); + + /** + * Returns the meta object for the containment reference list '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem#getConsumers Consumers}'. + * + * + * @return the meta object for the containment reference list 'Consumers'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem#getConsumers() + * @see #getPowerTransmissionSystem() + * @generated + */ + EReference getPowerTransmissionSystem_Consumers(); + + /** + * Returns the meta object for class '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier Supplier}'. + * + * + * @return the meta object for class 'Supplier'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier + * @generated + */ + EClass getPowerSupplier(); + + /** + * Returns the meta object for the reference '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier#getFeatureInstance Feature Instance}'. + * + * + * @return the meta object for the reference 'Feature Instance'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier#getFeatureInstance() + * @see #getPowerSupplier() + * @generated + */ + EReference getPowerSupplier_FeatureInstance(); + + /** + * Returns the meta object for class '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer Consumer}'. + * + * + * @return the meta object for class 'Consumer'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer + * @generated + */ + EClass getPowerConsumer(); + + /** + * Returns the meta object for the reference '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer#getFeatureInstance Feature Instance}'. + * + * + * @return the meta object for the reference 'Feature Instance'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer#getFeatureInstance() + * @see #getPowerConsumer() + * @generated + */ + EReference getPowerConsumer_FeatureInstance(); + + /** + * Returns the meta object for class '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerModel Model}'. + * + * + * @return the meta object for class 'Model'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerModel + * @generated + */ + EClass getPowerModel(); + + /** + * Returns the meta object for the containment reference list '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerModel#getRootPowerTransmissionSystem Root Power Transmission System}'. + * + * + * @return the meta object for the containment reference list 'Root Power Transmission System'. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerModel#getRootPowerTransmissionSystem() + * @see #getPowerModel() + * @generated + */ + EReference getPowerModel_RootPowerTransmissionSystem(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + PowerFactory getPowerFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerElementImpl Element}' class. + * + * + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerElementImpl + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerPackageImpl#getPowerElement() + * @generated + */ + EClass POWER_ELEMENT = eINSTANCE.getPowerElement(); + + /** + * The meta object literal for the 'Capacity' attribute feature. + * + * + * @generated + */ + EAttribute POWER_ELEMENT__CAPACITY = eINSTANCE.getPowerElement_Capacity(); + + /** + * The meta object literal for the 'Budget' attribute feature. + * + * + * @generated + */ + EAttribute POWER_ELEMENT__BUDGET = eINSTANCE.getPowerElement_Budget(); + + /** + * The meta object literal for the 'Supply' attribute feature. + * + * + * @generated + */ + EAttribute POWER_ELEMENT__SUPPLY = eINSTANCE.getPowerElement_Supply(); + + /** + * The meta object literal for the '{@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerTransmissionSystemImpl Transmission System}' class. + * + * + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerTransmissionSystemImpl + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerPackageImpl#getPowerTransmissionSystem() + * @generated + */ + EClass POWER_TRANSMISSION_SYSTEM = eINSTANCE.getPowerTransmissionSystem(); + + /** + * The meta object literal for the 'Component Instance' reference feature. + * + * + * @generated + */ + EReference POWER_TRANSMISSION_SYSTEM__COMPONENT_INSTANCE = eINSTANCE.getPowerTransmissionSystem_ComponentInstance(); + + /** + * The meta object literal for the 'Suppliers' containment reference list feature. + * + * + * @generated + */ + EReference POWER_TRANSMISSION_SYSTEM__SUPPLIERS = eINSTANCE.getPowerTransmissionSystem_Suppliers(); + + /** + * The meta object literal for the 'Consumers' containment reference list feature. + * + * + * @generated + */ + EReference POWER_TRANSMISSION_SYSTEM__CONSUMERS = eINSTANCE.getPowerTransmissionSystem_Consumers(); + + /** + * The meta object literal for the '{@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerSupplierImpl Supplier}' class. + * + * + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerSupplierImpl + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerPackageImpl#getPowerSupplier() + * @generated + */ + EClass POWER_SUPPLIER = eINSTANCE.getPowerSupplier(); + + /** + * The meta object literal for the 'Feature Instance' reference feature. + * + * + * @generated + */ + EReference POWER_SUPPLIER__FEATURE_INSTANCE = eINSTANCE.getPowerSupplier_FeatureInstance(); + + /** + * The meta object literal for the '{@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerConsumerImpl Consumer}' class. + * + * + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerConsumerImpl + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerPackageImpl#getPowerConsumer() + * @generated + */ + EClass POWER_CONSUMER = eINSTANCE.getPowerConsumer(); + + /** + * The meta object literal for the 'Feature Instance' reference feature. + * + * + * @generated + */ + EReference POWER_CONSUMER__FEATURE_INSTANCE = eINSTANCE.getPowerConsumer_FeatureInstance(); + + /** + * The meta object literal for the '{@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerModelImpl Model}' class. + * + * + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerModelImpl + * @see org.osate.analysis.resource.budgets.internal.models.power.impl.PowerPackageImpl#getPowerModel() + * @generated + */ + EClass POWER_MODEL = eINSTANCE.getPowerModel(); + + /** + * The meta object literal for the 'Root Power Transmission System' containment reference list feature. + * + * + * @generated + */ + EReference POWER_MODEL__ROOT_POWER_TRANSMISSION_SYSTEM = eINSTANCE.getPowerModel_RootPowerTransmissionSystem(); + + } + +} //PowerPackage diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerSupplier.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerSupplier.java new file mode 100644 index 00000000000..219e9a114ab --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerSupplier.java @@ -0,0 +1,48 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power; + +import org.osate.aadl2.instance.FeatureInstance; + +/** + * + * A representation of the model object 'Supplier'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier#getFeatureInstance Feature Instance}
  • + *
+ * + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerSupplier() + * @model + * @generated + * @since 4.1 + */ +public interface PowerSupplier extends PowerElement { + /** + * Returns the value of the 'Feature Instance' reference. + * + * + * @return the value of the 'Feature Instance' reference. + * @see #setFeatureInstance(FeatureInstance) + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerSupplier_FeatureInstance() + * @model + * @generated + */ + FeatureInstance getFeatureInstance(); + + /** + * Sets the value of the '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier#getFeatureInstance Feature Instance}' reference. + * + * + * @param value the new value of the 'Feature Instance' reference. + * @see #getFeatureInstance() + * @generated + */ + void setFeatureInstance(FeatureInstance value); + +} // PowerSupplier diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerTransmissionSystem.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerTransmissionSystem.java new file mode 100644 index 00000000000..1dbb7701743 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/PowerTransmissionSystem.java @@ -0,0 +1,75 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power; + +import org.eclipse.emf.common.util.EList; +import org.osate.aadl2.instance.ComponentInstance; + +/** + * + * A representation of the model object 'Transmission System'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem#getComponentInstance Component Instance}
  • + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem#getSuppliers Suppliers}
  • + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem#getConsumers Consumers}
  • + *
+ * + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerTransmissionSystem() + * @model + * @generated + * @since 4.1 + */ +public interface PowerTransmissionSystem extends PowerElement { + /** + * Returns the value of the 'Component Instance' reference. + * + * + * @return the value of the 'Component Instance' reference. + * @see #setComponentInstance(ComponentInstance) + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerTransmissionSystem_ComponentInstance() + * @model + * @generated + */ + ComponentInstance getComponentInstance(); + + /** + * Sets the value of the '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem#getComponentInstance Component Instance}' reference. + * + * + * @param value the new value of the 'Component Instance' reference. + * @see #getComponentInstance() + * @generated + */ + void setComponentInstance(ComponentInstance value); + + /** + * Returns the value of the 'Suppliers' containment reference list. + * The list contents are of type {@link org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier}. + * + * + * @return the value of the 'Suppliers' containment reference list. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerTransmissionSystem_Suppliers() + * @model containment="true" + * @generated + */ + EList getSuppliers(); + + /** + * Returns the value of the 'Consumers' containment reference list. + * The list contents are of type {@link org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer}. + * + * + * @return the value of the 'Consumers' containment reference list. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#getPowerTransmissionSystem_Consumers() + * @model containment="true" + * @generated + */ + EList getConsumers(); + +} // PowerTransmissionSystem diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerConsumerImpl.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerConsumerImpl.java new file mode 100644 index 00000000000..b38c892498e --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerConsumerImpl.java @@ -0,0 +1,161 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.osate.aadl2.instance.FeatureInstance; +import org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer; +import org.osate.analysis.resource.budgets.internal.models.power.PowerPackage; + +/** + * + * An implementation of the model object 'Consumer'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerConsumerImpl#getFeatureInstance Feature Instance}
  • + *
+ * + * @generated + * @since 4.1 + */ +public class PowerConsumerImpl extends PowerElementImpl implements PowerConsumer { + /** + * The cached value of the '{@link #getFeatureInstance() Feature Instance}' reference. + * + * + * @see #getFeatureInstance() + * @generated + * @ordered + */ + protected FeatureInstance featureInstance; + + /** + * + * + * @generated + */ + protected PowerConsumerImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PowerPackage.Literals.POWER_CONSUMER; + } + + /** + * + * + * @generated + */ + @Override + public FeatureInstance getFeatureInstance() { + if (featureInstance != null && featureInstance.eIsProxy()) { + InternalEObject oldFeatureInstance = (InternalEObject)featureInstance; + featureInstance = (FeatureInstance)eResolveProxy(oldFeatureInstance); + if (featureInstance != oldFeatureInstance) { + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.RESOLVE, PowerPackage.POWER_CONSUMER__FEATURE_INSTANCE, oldFeatureInstance, featureInstance)); + } + } + } + return featureInstance; + } + + /** + * + * + * @generated + */ + public FeatureInstance basicGetFeatureInstance() { + return featureInstance; + } + + /** + * + * + * @generated + */ + @Override + public void setFeatureInstance(FeatureInstance newFeatureInstance) { + FeatureInstance oldFeatureInstance = featureInstance; + featureInstance = newFeatureInstance; + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.SET, PowerPackage.POWER_CONSUMER__FEATURE_INSTANCE, oldFeatureInstance, featureInstance)); + } + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PowerPackage.POWER_CONSUMER__FEATURE_INSTANCE: + if (resolve) { + return getFeatureInstance(); + } + return basicGetFeatureInstance(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PowerPackage.POWER_CONSUMER__FEATURE_INSTANCE: + setFeatureInstance((FeatureInstance)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PowerPackage.POWER_CONSUMER__FEATURE_INSTANCE: + setFeatureInstance((FeatureInstance)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PowerPackage.POWER_CONSUMER__FEATURE_INSTANCE: + return featureInstance != null; + } + return super.eIsSet(featureID); + } + +} //PowerConsumerImpl diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerElementImpl.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerElementImpl.java new file mode 100644 index 00000000000..1de47e0dc38 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerElementImpl.java @@ -0,0 +1,281 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.osate.analysis.model.impl.AnalysisElementImpl; +import org.osate.analysis.resource.budgets.internal.models.power.PowerElement; +import org.osate.analysis.resource.budgets.internal.models.power.PowerPackage; + +/** + * + * An implementation of the model object 'Element'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerElementImpl#getCapacity Capacity}
  • + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerElementImpl#getBudget Budget}
  • + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerElementImpl#getSupply Supply}
  • + *
+ * + * @generated + * @since 4.1 + */ +public abstract class PowerElementImpl extends AnalysisElementImpl implements PowerElement { + /** + * The default value of the '{@link #getCapacity() Capacity}' attribute. + * + * + * @see #getCapacity() + * @generated + * @ordered + */ + protected static final double CAPACITY_EDEFAULT = 0.0; + + /** + * The cached value of the '{@link #getCapacity() Capacity}' attribute. + * + * + * @see #getCapacity() + * @generated + * @ordered + */ + protected double capacity = CAPACITY_EDEFAULT; + + /** + * The default value of the '{@link #getBudget() Budget}' attribute. + * + * + * @see #getBudget() + * @generated + * @ordered + */ + protected static final double BUDGET_EDEFAULT = 0.0; + + /** + * The cached value of the '{@link #getBudget() Budget}' attribute. + * + * + * @see #getBudget() + * @generated + * @ordered + */ + protected double budget = BUDGET_EDEFAULT; + + /** + * The default value of the '{@link #getSupply() Supply}' attribute. + * + * + * @see #getSupply() + * @generated + * @ordered + */ + protected static final double SUPPLY_EDEFAULT = 0.0; + + /** + * The cached value of the '{@link #getSupply() Supply}' attribute. + * + * + * @see #getSupply() + * @generated + * @ordered + */ + protected double supply = SUPPLY_EDEFAULT; + + /** + * + * + * @generated + */ + protected PowerElementImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PowerPackage.Literals.POWER_ELEMENT; + } + + /** + * + * + * @generated + */ + @Override + public double getCapacity() { + return capacity; + } + + /** + * + * + * @generated + */ + @Override + public void setCapacity(double newCapacity) { + double oldCapacity = capacity; + capacity = newCapacity; + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.SET, PowerPackage.POWER_ELEMENT__CAPACITY, oldCapacity, capacity)); + } + } + + /** + * + * + * @generated + */ + @Override + public double getBudget() { + return budget; + } + + /** + * + * + * @generated + */ + @Override + public void setBudget(double newBudget) { + double oldBudget = budget; + budget = newBudget; + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.SET, PowerPackage.POWER_ELEMENT__BUDGET, oldBudget, budget)); + } + } + + /** + * + * + * @generated + */ + @Override + public double getSupply() { + return supply; + } + + /** + * + * + * @generated + */ + @Override + public void setSupply(double newSupply) { + double oldSupply = supply; + supply = newSupply; + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.SET, PowerPackage.POWER_ELEMENT__SUPPLY, oldSupply, supply)); + } + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PowerPackage.POWER_ELEMENT__CAPACITY: + return getCapacity(); + case PowerPackage.POWER_ELEMENT__BUDGET: + return getBudget(); + case PowerPackage.POWER_ELEMENT__SUPPLY: + return getSupply(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PowerPackage.POWER_ELEMENT__CAPACITY: + setCapacity((Double)newValue); + return; + case PowerPackage.POWER_ELEMENT__BUDGET: + setBudget((Double)newValue); + return; + case PowerPackage.POWER_ELEMENT__SUPPLY: + setSupply((Double)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PowerPackage.POWER_ELEMENT__CAPACITY: + setCapacity(CAPACITY_EDEFAULT); + return; + case PowerPackage.POWER_ELEMENT__BUDGET: + setBudget(BUDGET_EDEFAULT); + return; + case PowerPackage.POWER_ELEMENT__SUPPLY: + setSupply(SUPPLY_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PowerPackage.POWER_ELEMENT__CAPACITY: + return capacity != CAPACITY_EDEFAULT; + case PowerPackage.POWER_ELEMENT__BUDGET: + return budget != BUDGET_EDEFAULT; + case PowerPackage.POWER_ELEMENT__SUPPLY: + return supply != SUPPLY_EDEFAULT; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) { + return super.toString(); + } + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (capacity: "); + result.append(capacity); + result.append(", budget: "); + result.append(budget); + result.append(", supply: "); + result.append(supply); + result.append(')'); + return result.toString(); + } + +} //PowerElementImpl diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerFactoryImpl.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerFactoryImpl.java new file mode 100644 index 00000000000..61d901d1a99 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerFactoryImpl.java @@ -0,0 +1,137 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EFactoryImpl; +import org.eclipse.emf.ecore.plugin.EcorePlugin; +import org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer; +import org.osate.analysis.resource.budgets.internal.models.power.PowerFactory; +import org.osate.analysis.resource.budgets.internal.models.power.PowerModel; +import org.osate.analysis.resource.budgets.internal.models.power.PowerPackage; +import org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier; +import org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem; + +/** + * + * An implementation of the model Factory. + * + * @generated + * @since 4.1 + */ +public class PowerFactoryImpl extends EFactoryImpl implements PowerFactory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static PowerFactory init() { + try { + PowerFactory thePowerFactory = (PowerFactory)EPackage.Registry.INSTANCE.getEFactory(PowerPackage.eNS_URI); + if (thePowerFactory != null) { + return thePowerFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new PowerFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public PowerFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case PowerPackage.POWER_TRANSMISSION_SYSTEM: return createPowerTransmissionSystem(); + case PowerPackage.POWER_SUPPLIER: return createPowerSupplier(); + case PowerPackage.POWER_CONSUMER: return createPowerConsumer(); + case PowerPackage.POWER_MODEL: return createPowerModel(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + @Override + public PowerTransmissionSystem createPowerTransmissionSystem() { + PowerTransmissionSystemImpl powerTransmissionSystem = new PowerTransmissionSystemImpl(); + return powerTransmissionSystem; + } + + /** + * + * + * @generated + */ + @Override + public PowerSupplier createPowerSupplier() { + PowerSupplierImpl powerSupplier = new PowerSupplierImpl(); + return powerSupplier; + } + + /** + * + * + * @generated + */ + @Override + public PowerConsumer createPowerConsumer() { + PowerConsumerImpl powerConsumer = new PowerConsumerImpl(); + return powerConsumer; + } + + /** + * + * + * @generated + */ + @Override + public PowerModel createPowerModel() { + PowerModelImpl powerModel = new PowerModelImpl(); + return powerModel; + } + + /** + * + * + * @generated + */ + @Override + public PowerPackage getPowerPackage() { + return (PowerPackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static PowerPackage getPackage() { + return PowerPackage.eINSTANCE; + } + +} //PowerFactoryImpl diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerModelImpl.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerModelImpl.java new file mode 100644 index 00000000000..78ef0f9cf1e --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerModelImpl.java @@ -0,0 +1,150 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.osate.analysis.model.impl.AnalysisElementImpl; +import org.osate.analysis.resource.budgets.internal.models.power.PowerModel; +import org.osate.analysis.resource.budgets.internal.models.power.PowerPackage; +import org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem; + +/** + * + * An implementation of the model object 'Model'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerModelImpl#getRootPowerTransmissionSystem Root Power Transmission System}
  • + *
+ * + * @generated + * @since 4.1 + */ +public class PowerModelImpl extends AnalysisElementImpl implements PowerModel { + /** + * The cached value of the '{@link #getRootPowerTransmissionSystem() Root Power Transmission System}' containment reference list. + * + * + * @see #getRootPowerTransmissionSystem() + * @generated + * @ordered + */ + protected EList rootPowerTransmissionSystem; + + /** + * + * + * @generated + */ + protected PowerModelImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PowerPackage.Literals.POWER_MODEL; + } + + /** + * + * + * @generated + */ + @Override + public EList getRootPowerTransmissionSystem() { + if (rootPowerTransmissionSystem == null) { + rootPowerTransmissionSystem = new EObjectContainmentEList(PowerTransmissionSystem.class, this, PowerPackage.POWER_MODEL__ROOT_POWER_TRANSMISSION_SYSTEM); + } + return rootPowerTransmissionSystem; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PowerPackage.POWER_MODEL__ROOT_POWER_TRANSMISSION_SYSTEM: + return ((InternalEList)getRootPowerTransmissionSystem()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PowerPackage.POWER_MODEL__ROOT_POWER_TRANSMISSION_SYSTEM: + return getRootPowerTransmissionSystem(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PowerPackage.POWER_MODEL__ROOT_POWER_TRANSMISSION_SYSTEM: + getRootPowerTransmissionSystem().clear(); + getRootPowerTransmissionSystem().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PowerPackage.POWER_MODEL__ROOT_POWER_TRANSMISSION_SYSTEM: + getRootPowerTransmissionSystem().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PowerPackage.POWER_MODEL__ROOT_POWER_TRANSMISSION_SYSTEM: + return rootPowerTransmissionSystem != null && !rootPowerTransmissionSystem.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //PowerModelImpl diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerPackageImpl.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerPackageImpl.java new file mode 100644 index 00000000000..e19b30c0009 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerPackageImpl.java @@ -0,0 +1,388 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.impl.EPackageImpl; +import org.osate.aadl2.Aadl2Package; +import org.osate.aadl2.instance.InstancePackage; +import org.osate.analysis.model.ModelPackage; +import org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer; +import org.osate.analysis.resource.budgets.internal.models.power.PowerElement; +import org.osate.analysis.resource.budgets.internal.models.power.PowerFactory; +import org.osate.analysis.resource.budgets.internal.models.power.PowerModel; +import org.osate.analysis.resource.budgets.internal.models.power.PowerPackage; +import org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier; +import org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem; + +/** + * + * An implementation of the model Package. + * + * @generated + * @since 4.1 + */ +public class PowerPackageImpl extends EPackageImpl implements PowerPackage { + /** + * + * + * @generated + */ + private EClass powerElementEClass = null; + + /** + * + * + * @generated + */ + private EClass powerTransmissionSystemEClass = null; + + /** + * + * + * @generated + */ + private EClass powerSupplierEClass = null; + + /** + * + * + * @generated + */ + private EClass powerConsumerEClass = null; + + /** + * + * + * @generated + */ + private EClass powerModelEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage#eNS_URI + * @see #init() + * @generated + */ + private PowerPackageImpl() { + super(eNS_URI, PowerFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link PowerPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static PowerPackage init() { + if (isInited) { + return (PowerPackage)EPackage.Registry.INSTANCE.getEPackage(PowerPackage.eNS_URI); + } + + // Obtain or create and register package + Object registeredPowerPackage = EPackage.Registry.INSTANCE.get(eNS_URI); + PowerPackageImpl thePowerPackage = registeredPowerPackage instanceof PowerPackageImpl ? (PowerPackageImpl)registeredPowerPackage : new PowerPackageImpl(); + + isInited = true; + + // Initialize simple dependencies + Aadl2Package.eINSTANCE.eClass(); + ModelPackage.eINSTANCE.eClass(); + InstancePackage.eINSTANCE.eClass(); + + // Create package meta-data objects + thePowerPackage.createPackageContents(); + + // Initialize created meta-data + thePowerPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + thePowerPackage.freeze(); + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(PowerPackage.eNS_URI, thePowerPackage); + return thePowerPackage; + } + + /** + * + * + * @generated + */ + @Override + public EClass getPowerElement() { + return powerElementEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getPowerElement_Capacity() { + return (EAttribute)powerElementEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getPowerElement_Budget() { + return (EAttribute)powerElementEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getPowerElement_Supply() { + return (EAttribute)powerElementEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EClass getPowerTransmissionSystem() { + return powerTransmissionSystemEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getPowerTransmissionSystem_ComponentInstance() { + return (EReference)powerTransmissionSystemEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EReference getPowerTransmissionSystem_Suppliers() { + return (EReference)powerTransmissionSystemEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EReference getPowerTransmissionSystem_Consumers() { + return (EReference)powerTransmissionSystemEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + @Override + public EClass getPowerSupplier() { + return powerSupplierEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getPowerSupplier_FeatureInstance() { + return (EReference)powerSupplierEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EClass getPowerConsumer() { + return powerConsumerEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getPowerConsumer_FeatureInstance() { + return (EReference)powerConsumerEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EClass getPowerModel() { + return powerModelEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getPowerModel_RootPowerTransmissionSystem() { + return (EReference)powerModelEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public PowerFactory getPowerFactory() { + return (PowerFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) { + return; + } + isCreated = true; + + // Create classes and their features + powerElementEClass = createEClass(POWER_ELEMENT); + createEAttribute(powerElementEClass, POWER_ELEMENT__CAPACITY); + createEAttribute(powerElementEClass, POWER_ELEMENT__BUDGET); + createEAttribute(powerElementEClass, POWER_ELEMENT__SUPPLY); + + powerTransmissionSystemEClass = createEClass(POWER_TRANSMISSION_SYSTEM); + createEReference(powerTransmissionSystemEClass, POWER_TRANSMISSION_SYSTEM__COMPONENT_INSTANCE); + createEReference(powerTransmissionSystemEClass, POWER_TRANSMISSION_SYSTEM__SUPPLIERS); + createEReference(powerTransmissionSystemEClass, POWER_TRANSMISSION_SYSTEM__CONSUMERS); + + powerSupplierEClass = createEClass(POWER_SUPPLIER); + createEReference(powerSupplierEClass, POWER_SUPPLIER__FEATURE_INSTANCE); + + powerConsumerEClass = createEClass(POWER_CONSUMER); + createEReference(powerConsumerEClass, POWER_CONSUMER__FEATURE_INSTANCE); + + powerModelEClass = createEClass(POWER_MODEL); + createEReference(powerModelEClass, POWER_MODEL__ROOT_POWER_TRANSMISSION_SYSTEM); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) { + return; + } + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + ModelPackage theModelPackage = (ModelPackage)EPackage.Registry.INSTANCE.getEPackage(ModelPackage.eNS_URI); + InstancePackage theInstancePackage = (InstancePackage)EPackage.Registry.INSTANCE.getEPackage(InstancePackage.eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + powerElementEClass.getESuperTypes().add(theModelPackage.getAnalysisElement()); + powerTransmissionSystemEClass.getESuperTypes().add(this.getPowerElement()); + powerSupplierEClass.getESuperTypes().add(this.getPowerElement()); + powerConsumerEClass.getESuperTypes().add(this.getPowerElement()); + powerModelEClass.getESuperTypes().add(theModelPackage.getAnalysisElement()); + + // Initialize classes, features, and operations; add parameters + initEClass(powerElementEClass, PowerElement.class, "PowerElement", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getPowerElement_Capacity(), ecorePackage.getEDouble(), "capacity", null, 0, 1, PowerElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getPowerElement_Budget(), ecorePackage.getEDouble(), "budget", null, 0, 1, PowerElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getPowerElement_Supply(), ecorePackage.getEDouble(), "supply", null, 0, 1, PowerElement.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(powerTransmissionSystemEClass, PowerTransmissionSystem.class, "PowerTransmissionSystem", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getPowerTransmissionSystem_ComponentInstance(), theInstancePackage.getComponentInstance(), null, "ComponentInstance", null, 0, 1, PowerTransmissionSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getPowerTransmissionSystem_Suppliers(), this.getPowerSupplier(), null, "suppliers", null, 0, -1, PowerTransmissionSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getPowerTransmissionSystem_Consumers(), this.getPowerConsumer(), null, "consumers", null, 0, -1, PowerTransmissionSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(powerSupplierEClass, PowerSupplier.class, "PowerSupplier", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getPowerSupplier_FeatureInstance(), theInstancePackage.getFeatureInstance(), null, "FeatureInstance", null, 0, 1, PowerSupplier.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(powerConsumerEClass, PowerConsumer.class, "PowerConsumer", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getPowerConsumer_FeatureInstance(), theInstancePackage.getFeatureInstance(), null, "FeatureInstance", null, 0, 1, PowerConsumer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(powerModelEClass, PowerModel.class, "PowerModel", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getPowerModel_RootPowerTransmissionSystem(), this.getPowerTransmissionSystem(), null, "rootPowerTransmissionSystem", null, 0, -1, PowerModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //PowerPackageImpl diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerSupplierImpl.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerSupplierImpl.java new file mode 100644 index 00000000000..f4be6240980 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerSupplierImpl.java @@ -0,0 +1,161 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power.impl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.osate.aadl2.instance.FeatureInstance; +import org.osate.analysis.resource.budgets.internal.models.power.PowerPackage; +import org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier; + +/** + * + * An implementation of the model object 'Supplier'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerSupplierImpl#getFeatureInstance Feature Instance}
  • + *
+ * + * @generated + * @since 4.1 + */ +public class PowerSupplierImpl extends PowerElementImpl implements PowerSupplier { + /** + * The cached value of the '{@link #getFeatureInstance() Feature Instance}' reference. + * + * + * @see #getFeatureInstance() + * @generated + * @ordered + */ + protected FeatureInstance featureInstance; + + /** + * + * + * @generated + */ + protected PowerSupplierImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PowerPackage.Literals.POWER_SUPPLIER; + } + + /** + * + * + * @generated + */ + @Override + public FeatureInstance getFeatureInstance() { + if (featureInstance != null && featureInstance.eIsProxy()) { + InternalEObject oldFeatureInstance = (InternalEObject)featureInstance; + featureInstance = (FeatureInstance)eResolveProxy(oldFeatureInstance); + if (featureInstance != oldFeatureInstance) { + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.RESOLVE, PowerPackage.POWER_SUPPLIER__FEATURE_INSTANCE, oldFeatureInstance, featureInstance)); + } + } + } + return featureInstance; + } + + /** + * + * + * @generated + */ + public FeatureInstance basicGetFeatureInstance() { + return featureInstance; + } + + /** + * + * + * @generated + */ + @Override + public void setFeatureInstance(FeatureInstance newFeatureInstance) { + FeatureInstance oldFeatureInstance = featureInstance; + featureInstance = newFeatureInstance; + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.SET, PowerPackage.POWER_SUPPLIER__FEATURE_INSTANCE, oldFeatureInstance, featureInstance)); + } + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PowerPackage.POWER_SUPPLIER__FEATURE_INSTANCE: + if (resolve) { + return getFeatureInstance(); + } + return basicGetFeatureInstance(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PowerPackage.POWER_SUPPLIER__FEATURE_INSTANCE: + setFeatureInstance((FeatureInstance)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PowerPackage.POWER_SUPPLIER__FEATURE_INSTANCE: + setFeatureInstance((FeatureInstance)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PowerPackage.POWER_SUPPLIER__FEATURE_INSTANCE: + return featureInstance != null; + } + return super.eIsSet(featureID); + } + +} //PowerSupplierImpl diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerTransmissionSystemImpl.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerTransmissionSystemImpl.java new file mode 100644 index 00000000000..76e98e8a4b2 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/impl/PowerTransmissionSystemImpl.java @@ -0,0 +1,256 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; +import org.osate.aadl2.instance.ComponentInstance; +import org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer; +import org.osate.analysis.resource.budgets.internal.models.power.PowerPackage; +import org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier; +import org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem; + +/** + * + * An implementation of the model object 'Transmission System'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerTransmissionSystemImpl#getComponentInstance Component Instance}
  • + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerTransmissionSystemImpl#getSuppliers Suppliers}
  • + *
  • {@link org.osate.analysis.resource.budgets.internal.models.power.impl.PowerTransmissionSystemImpl#getConsumers Consumers}
  • + *
+ * + * @generated + * @since 4.1 + */ +public class PowerTransmissionSystemImpl extends PowerElementImpl implements PowerTransmissionSystem { + /** + * The cached value of the '{@link #getComponentInstance() Component Instance}' reference. + * + * + * @see #getComponentInstance() + * @generated + * @ordered + */ + protected ComponentInstance componentInstance; + + /** + * The cached value of the '{@link #getSuppliers() Suppliers}' containment reference list. + * + * + * @see #getSuppliers() + * @generated + * @ordered + */ + protected EList suppliers; + + /** + * The cached value of the '{@link #getConsumers() Consumers}' containment reference list. + * + * + * @see #getConsumers() + * @generated + * @ordered + */ + protected EList consumers; + + /** + * + * + * @generated + */ + protected PowerTransmissionSystemImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PowerPackage.Literals.POWER_TRANSMISSION_SYSTEM; + } + + /** + * + * + * @generated + */ + @Override + public ComponentInstance getComponentInstance() { + if (componentInstance != null && componentInstance.eIsProxy()) { + InternalEObject oldComponentInstance = (InternalEObject)componentInstance; + componentInstance = (ComponentInstance)eResolveProxy(oldComponentInstance); + if (componentInstance != oldComponentInstance) { + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.RESOLVE, PowerPackage.POWER_TRANSMISSION_SYSTEM__COMPONENT_INSTANCE, oldComponentInstance, componentInstance)); + } + } + } + return componentInstance; + } + + /** + * + * + * @generated + */ + public ComponentInstance basicGetComponentInstance() { + return componentInstance; + } + + /** + * + * + * @generated + */ + @Override + public void setComponentInstance(ComponentInstance newComponentInstance) { + ComponentInstance oldComponentInstance = componentInstance; + componentInstance = newComponentInstance; + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.SET, PowerPackage.POWER_TRANSMISSION_SYSTEM__COMPONENT_INSTANCE, oldComponentInstance, componentInstance)); + } + } + + /** + * + * + * @generated + */ + @Override + public EList getSuppliers() { + if (suppliers == null) { + suppliers = new EObjectContainmentEList(PowerSupplier.class, this, PowerPackage.POWER_TRANSMISSION_SYSTEM__SUPPLIERS); + } + return suppliers; + } + + /** + * + * + * @generated + */ + @Override + public EList getConsumers() { + if (consumers == null) { + consumers = new EObjectContainmentEList(PowerConsumer.class, this, PowerPackage.POWER_TRANSMISSION_SYSTEM__CONSUMERS); + } + return consumers; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PowerPackage.POWER_TRANSMISSION_SYSTEM__SUPPLIERS: + return ((InternalEList)getSuppliers()).basicRemove(otherEnd, msgs); + case PowerPackage.POWER_TRANSMISSION_SYSTEM__CONSUMERS: + return ((InternalEList)getConsumers()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PowerPackage.POWER_TRANSMISSION_SYSTEM__COMPONENT_INSTANCE: + if (resolve) { + return getComponentInstance(); + } + return basicGetComponentInstance(); + case PowerPackage.POWER_TRANSMISSION_SYSTEM__SUPPLIERS: + return getSuppliers(); + case PowerPackage.POWER_TRANSMISSION_SYSTEM__CONSUMERS: + return getConsumers(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PowerPackage.POWER_TRANSMISSION_SYSTEM__COMPONENT_INSTANCE: + setComponentInstance((ComponentInstance)newValue); + return; + case PowerPackage.POWER_TRANSMISSION_SYSTEM__SUPPLIERS: + getSuppliers().clear(); + getSuppliers().addAll((Collection)newValue); + return; + case PowerPackage.POWER_TRANSMISSION_SYSTEM__CONSUMERS: + getConsumers().clear(); + getConsumers().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PowerPackage.POWER_TRANSMISSION_SYSTEM__COMPONENT_INSTANCE: + setComponentInstance((ComponentInstance)null); + return; + case PowerPackage.POWER_TRANSMISSION_SYSTEM__SUPPLIERS: + getSuppliers().clear(); + return; + case PowerPackage.POWER_TRANSMISSION_SYSTEM__CONSUMERS: + getConsumers().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PowerPackage.POWER_TRANSMISSION_SYSTEM__COMPONENT_INSTANCE: + return componentInstance != null; + case PowerPackage.POWER_TRANSMISSION_SYSTEM__SUPPLIERS: + return suppliers != null && !suppliers.isEmpty(); + case PowerPackage.POWER_TRANSMISSION_SYSTEM__CONSUMERS: + return consumers != null && !consumers.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //PowerTransmissionSystemImpl diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/util/PowerAdapterFactory.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/util/PowerAdapterFactory.java new file mode 100644 index 00000000000..db1ecec0046 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/util/PowerAdapterFactory.java @@ -0,0 +1,215 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; +import org.eclipse.emf.ecore.EObject; +import org.osate.analysis.model.AnalysisElement; +import org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer; +import org.osate.analysis.resource.budgets.internal.models.power.PowerElement; +import org.osate.analysis.resource.budgets.internal.models.power.PowerModel; +import org.osate.analysis.resource.budgets.internal.models.power.PowerPackage; +import org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier; +import org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage + * @generated + * @since 4.1 + */ +public class PowerAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static PowerPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public PowerAdapterFactory() { + if (modelPackage == null) { + modelPackage = PowerPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected PowerSwitch modelSwitch = + new PowerSwitch() { + @Override + public Adapter casePowerElement(PowerElement object) { + return createPowerElementAdapter(); + } + @Override + public Adapter casePowerTransmissionSystem(PowerTransmissionSystem object) { + return createPowerTransmissionSystemAdapter(); + } + @Override + public Adapter casePowerSupplier(PowerSupplier object) { + return createPowerSupplierAdapter(); + } + @Override + public Adapter casePowerConsumer(PowerConsumer object) { + return createPowerConsumerAdapter(); + } + @Override + public Adapter casePowerModel(PowerModel object) { + return createPowerModelAdapter(); + } + @Override + public Adapter caseAnalysisElement(AnalysisElement object) { + return createAnalysisElementAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerElement Element}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerElement + * @generated + */ + public Adapter createPowerElementAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem Transmission System}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem + * @generated + */ + public Adapter createPowerTransmissionSystemAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier Supplier}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier + * @generated + */ + public Adapter createPowerSupplierAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer Consumer}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer + * @generated + */ + public Adapter createPowerConsumerAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.osate.analysis.resource.budgets.internal.models.power.PowerModel Model}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerModel + * @generated + */ + public Adapter createPowerModelAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.osate.analysis.model.AnalysisElement Analysis Element}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.osate.analysis.model.AnalysisElement + * @generated + */ + public Adapter createAnalysisElementAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //PowerAdapterFactory diff --git a/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/util/PowerSwitch.java b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/util/PowerSwitch.java new file mode 100644 index 00000000000..1bb9eefd1c0 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src-gen/org/osate/analysis/resource/budgets/internal/models/power/util/PowerSwitch.java @@ -0,0 +1,249 @@ +/** + * Copyright Text Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file).... + */ +package org.osate.analysis.resource.budgets.internal.models.power.util; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.util.Switch; +import org.osate.analysis.model.AnalysisElement; +import org.osate.analysis.resource.budgets.internal.models.power.PowerConsumer; +import org.osate.analysis.resource.budgets.internal.models.power.PowerElement; +import org.osate.analysis.resource.budgets.internal.models.power.PowerModel; +import org.osate.analysis.resource.budgets.internal.models.power.PowerPackage; +import org.osate.analysis.resource.budgets.internal.models.power.PowerSupplier; +import org.osate.analysis.resource.budgets.internal.models.power.PowerTransmissionSystem; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see org.osate.analysis.resource.budgets.internal.models.power.PowerPackage + * @generated + * @since 4.1 + */ +public class PowerSwitch extends Switch { + /** + * The cached model package + * + * + * @generated + */ + protected static PowerPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public PowerSwitch() { + if (modelPackage == null) { + modelPackage = PowerPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case PowerPackage.POWER_ELEMENT: { + PowerElement powerElement = (PowerElement)theEObject; + T result = casePowerElement(powerElement); + if (result == null) { + result = caseAnalysisElement(powerElement); + } + if (result == null) { + result = defaultCase(theEObject); + } + return result; + } + case PowerPackage.POWER_TRANSMISSION_SYSTEM: { + PowerTransmissionSystem powerTransmissionSystem = (PowerTransmissionSystem)theEObject; + T result = casePowerTransmissionSystem(powerTransmissionSystem); + if (result == null) { + result = casePowerElement(powerTransmissionSystem); + } + if (result == null) { + result = caseAnalysisElement(powerTransmissionSystem); + } + if (result == null) { + result = defaultCase(theEObject); + } + return result; + } + case PowerPackage.POWER_SUPPLIER: { + PowerSupplier powerSupplier = (PowerSupplier)theEObject; + T result = casePowerSupplier(powerSupplier); + if (result == null) { + result = casePowerElement(powerSupplier); + } + if (result == null) { + result = caseAnalysisElement(powerSupplier); + } + if (result == null) { + result = defaultCase(theEObject); + } + return result; + } + case PowerPackage.POWER_CONSUMER: { + PowerConsumer powerConsumer = (PowerConsumer)theEObject; + T result = casePowerConsumer(powerConsumer); + if (result == null) { + result = casePowerElement(powerConsumer); + } + if (result == null) { + result = caseAnalysisElement(powerConsumer); + } + if (result == null) { + result = defaultCase(theEObject); + } + return result; + } + case PowerPackage.POWER_MODEL: { + PowerModel powerModel = (PowerModel)theEObject; + T result = casePowerModel(powerModel); + if (result == null) { + result = caseAnalysisElement(powerModel); + } + if (result == null) { + result = defaultCase(theEObject); + } + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Element'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Element'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePowerElement(PowerElement object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Transmission System'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Transmission System'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePowerTransmissionSystem(PowerTransmissionSystem object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Supplier'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Supplier'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePowerSupplier(PowerSupplier object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Consumer'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Consumer'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePowerConsumer(PowerConsumer object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Model'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Model'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePowerModel(PowerModel object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Analysis Element'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Analysis Element'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseAnalysisElement(AnalysisElement object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //PowerSwitch diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/busload/BusLoadModelBuilder.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/busload/BusLoadModelBuilder.java index 1c03bf77b3f..2d5552d5233 100644 --- a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/busload/BusLoadModelBuilder.java +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/busload/BusLoadModelBuilder.java @@ -47,7 +47,7 @@ import org.osate.analysis.resource.budgets.internal.models.busload.BusloadFactory; import org.osate.analysis.resource.budgets.internal.models.busload.Connection; import org.osate.analysis.resource.budgets.internal.models.busload.VirtualBus; -import org.osate.contribution.sei.sei.Sei; +import org.osate.xtext.aadl2.properties.util.GetProperties; import org.osate.xtext.aadl2.properties.util.InstanceModelUtil; final class BusLoadModelBuilder { @@ -135,7 +135,7 @@ private void addVirtualBus(final BusLoadModel model, final ComponentInstance vb, private void addBusOrVirtualBus(final BusLoadModel model, final BusOrVirtualBus bus, final ComponentInstance ci, final SystemOperationMode som) { - final boolean isBroadcast = Sei.getBroadcastProtocol(ci).orElse(false); + final boolean isBroadcast = GetProperties.isBroadcastProtocol(ci); List budgetedConnections = InstanceModelUtil.getBoundConnections(ci); List budgetedVBs = InstanceModelUtil.getBoundVirtualBuses(ci); diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/busload/NewBusLoadAnalysis.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/busload/NewBusLoadAnalysis.java index 8cf80685ad9..1c833d82f68 100644 --- a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/busload/NewBusLoadAnalysis.java +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/busload/NewBusLoadAnalysis.java @@ -30,16 +30,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.emf.ecore.EObject; -import org.osate.aadl2.Classifier; import org.osate.aadl2.Element; -import org.osate.aadl2.NamedElement; -import org.osate.aadl2.contrib.aadlproject.DataRateUnits; -import org.osate.aadl2.contrib.aadlproject.SizeUnits; -import org.osate.aadl2.contrib.aadlproject.TimeUnits; -import org.osate.aadl2.contrib.communication.CommunicationProperties; -import org.osate.aadl2.contrib.communication.RateSpec.RateUnit_FieldType; -import org.osate.aadl2.contrib.memory.MemoryProperties; -import org.osate.aadl2.contrib.timing.TimingProperties; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.ConnectionInstance; import org.osate.aadl2.instance.ConnectionInstanceEnd; @@ -59,15 +50,13 @@ import org.osate.analysis.resource.budgets.internal.models.busload.Connection; import org.osate.analysis.resource.budgets.internal.models.busload.VirtualBus; import org.osate.analysis.resource.budgets.internal.models.busload.util.BusloadSwitch; -import org.osate.contribution.sei.sei.DataRate; -import org.osate.contribution.sei.sei.MessageRate; -import org.osate.contribution.sei.sei.Sei; -import org.osate.pluginsupport.properties.PropertyUtils; import org.osate.result.AnalysisResult; +import org.osate.result.DiagnosticType; import org.osate.result.Result; import org.osate.result.ResultType; import org.osate.result.util.ResultUtil; import org.osate.ui.dialogs.Dialog; +import org.osate.xtext.aadl2.properties.util.GetProperties; /** * Class for performing "bus load" analysis on a system. Basically it makes sure all the connections and buses @@ -239,8 +228,8 @@ public Nothing caseBusOrVirtualBus(final BusOrVirtualBus bus) { final EObject parent = bus.eContainer(); final double parentOverhead = parent instanceof BusLoadModel ? 0.0 : ((BusOrVirtualBus) parent).getDataOverhead(); - final double localOverheadKBytesps = PropertyUtils - .getScaled(MemoryProperties::getDataSize, busInstance, SizeUnits.KBYTE).orElse(0.0); + final double localOverheadKBytesps = GetProperties.getDataSize(busInstance, + GetProperties.getKBUnitLiteral(busInstance)); bus.setDataOverhead(parentOverhead + localOverheadKBytesps); return Nothing.NONE; @@ -281,9 +270,7 @@ public Nothing caseConnection(final Connection connection) { final double actual = getConnectionActualKBytesps(connectionInstance.getSource(), dataOverheadKBytes); connection.setActual(actual); - final double budget = PropertyUtils - .getScaled(Sei::getBandwidthbudget, connectionInstance, DataRateUnits.KBYTESPS) - .orElse(0.0); + final double budget = GetProperties.getBandWidthBudgetInKBytesps(connectionInstance, 0.0); connection.setBudget(budget); ResultUtil.addRealValue(connectionResult, budget); @@ -291,11 +278,12 @@ public Nothing caseConnection(final Connection connection) { if (budget > 0.0) { if (actual > budget) { - ResultUtil.addError(connectionResult, connectionInstance, "Connection " + connectionInstance.getName() - + " -- Actual bandwidth > budget: " + actual + " KB/s > " + budget + " KB/s"); + error(connectionResult, connectionInstance, "Connection " + connectionInstance.getName() + + " -- Actual bandwidth > budget: " + actual + " KB/s > " + budget + " KB/s"); } } else { - ResultUtil.addWarning(connectionResult, connectionInstance, "Connection " + connectionInstance.getName() + " has no bandwidth budget"); + warning(connectionResult, connectionInstance, + "Connection " + connectionInstance.getName() + " has no bandwidth budget"); } return Nothing.NONE; @@ -329,9 +317,10 @@ public Nothing caseBroadcast(final Broadcast broadcast) { if (unequal) { for (final Connection c : broadcast.getConnections()) { - ResultUtil.addWarning(broadcastResult, c.getConnectionInstance(), "Connection " + c.getConnectionInstance().getName() + " sharing broadcast source " - + broadcast.getSource().getInstanceObjectPath() + " has budget " + c.getBudget() - + " KB/s; using maximum"); + warning(broadcastResult, c.getConnectionInstance(), + "Connection " + c.getConnectionInstance().getName() + " sharing broadcast source " + + broadcast.getSource().getInstanceObjectPath() + " has budget " + c.getBudget() + + " KB/s; using maximum"); } } @@ -362,11 +351,8 @@ public Nothing caseBusOrVirtualBus(final BusOrVirtualBus bus) { bus.setActual(actual); final ComponentInstance busInstance = bus.getBusInstance(); - final double capacity = PropertyUtils - .getScaled(Sei::getBandwidthcapacity, busInstance, DataRateUnits.KBYTESPS) - .orElse(0.0); - final double budget = PropertyUtils.getScaled(Sei::getBandwidthbudget, busInstance, DataRateUnits.KBYTESPS) - .orElse(0.0); + final double capacity = GetProperties.getBandWidthCapacityInKBytesps(busInstance, 0.0); + final double budget = GetProperties.getBandWidthBudgetInKBytesps(busInstance, 0.0); bus.setBudget(budget); ResultUtil.addRealValue(busResult, capacity); @@ -379,25 +365,26 @@ public Nothing caseBusOrVirtualBus(final BusOrVirtualBus bus) { ResultUtil.addIntegerValue(busResult, myDataOverheadInBytes); if (capacity == 0.0) { - ResultUtil.addWarning(busResult, busInstance, getLabel(bus) + busInstance.getName() + " has no capacity"); + warning(busResult, busInstance, + getLabel(bus) + busInstance.getName() + " has no capacity"); } else { if (actual > capacity) { - ResultUtil.addError(busResult, busInstance, getLabel(bus) + busInstance.getName() - + " -- Actual bandwidth > capacity: " + actual + " KB/s > " + capacity + " KB/s"); + error(busResult, busInstance, getLabel(bus) + busInstance.getName() + + " -- Actual bandwidth > capacity: " + actual + " KB/s > " + capacity + " KB/s"); } } if (budget == 0.0) { - ResultUtil.addWarning(busResult, busInstance, getLabel(bus) + busInstance.getName() - + " has no bandwidth budget"); + warning(busResult, busInstance, getLabel(bus) + busInstance.getName() + + " has no bandwidth budget"); } else { if (budget > capacity) { - ResultUtil.addError(busResult, busInstance, getLabel(bus) + busInstance.getName() - + " -- budget > capacity: " + budget + " KB/s > " + capacity + " KB/s"); + error(busResult, busInstance, getLabel(bus) + busInstance.getName() + + " -- budget > capacity: " + budget + " KB/s > " + capacity + " KB/s"); } if (totalBudget > budget) { - ResultUtil.addError(busResult, busInstance, getLabel(bus) + busInstance.getName() - + " -- Required budget > budget: " + totalBudget + " KB/s > " + budget + " KB/s"); + error(busResult, busInstance, getLabel(bus) + busInstance.getName() + + " -- Required budget > budget: " + totalBudget + " KB/s > " + budget + " KB/s"); } } @@ -426,48 +413,21 @@ private static double getConnectionActualKBytesps(final ConnectionInstanceEnd ci if (cie instanceof FeatureInstance) { final FeatureInstance fi = (FeatureInstance) cie; final double datasize = dataOverheadKBytes - + PropertyUtils.getScaled(MemoryProperties::getDataSize, fi, SizeUnits.KBYTE).orElseGet( - () -> PropertyUtils.getScaled(MemoryProperties::getSourceDataSize, fi, SizeUnits.KBYTE) - .orElse(0.0)); - final double srcRate = getOutgoingMessageRatePerSecond(fi); + + GetProperties.getSourceDataSize(fi, GetProperties.getKBUnitLiteral(fi)); + final double srcRate = GetProperties.getOutgoingMessageRatePerSecond(fi); actualDataRate = datasize * srcRate; } return actualDataRate; } - private static double getOutgoingMessageRatePerSecond(final FeatureInstance fi) { - return PropertyUtils.getScaled(Sei::getDataRate, fi, DataRate.PERSECOND) - .orElseGet( - () -> PropertyUtils.getScaled(Sei::getMessageRate, fi, MessageRate.PERSECOND).orElseGet(() -> { - // Try to get rate from the OUTPUT_RATE record - final Classifier containingClassifier = fi.getContainingClassifier(); - return CommunicationProperties.getOutputRate(fi).map(rateSpec -> { - final double maxDataRate = rateSpec.getValueRange().map(rr -> rr.getMaximum()).orElse(0.0); - return rateSpec.getRateUnit().filter(x -> x == RateUnit_FieldType.PERDISPATCH).map(ignore -> { - final double period = getPeriodInSeconds( - ((InstanceObject) fi).getContainingComponentInstance()); - return period == 0.0 ? 0.0 : maxDataRate / period; - }).orElseGet(() -> { - if (maxDataRate > 0.0) { - return maxDataRate; - } else { - // unit is PERSECOND, but the max data rate is missing, so try the period from the containing classifier - double period = getPeriodInSeconds(containingClassifier); - return period == 0.0 ? 0.0 : 1.0 / period; - } - }); - }).orElseGet( - // Cannot get rate from the FeatureInstance, try the period of the containing classifier - () -> { - double period = getPeriodInSeconds(containingClassifier); - return period == 0.0 ? 0.0 : 1.0 / period; - }); - })); + // ==== Error reporting methods for the visitor === + + private static void error(final Result result, final InstanceObject io, final String msg) { + result.getDiagnostics().add(ResultUtil.createDiagnostic(msg, io, DiagnosticType.ERROR)); } - private static double getPeriodInSeconds(final NamedElement containingClassifier) { - return PropertyUtils.getScaled(TimingProperties::getPeriod, containingClassifier, - TimeUnits.SEC).orElse(0.0); + private static void warning(final Result result, final InstanceObject io, final String msg) { + result.getDiagnostics().add(ResultUtil.createDiagnostic(msg, io, DiagnosticType.WARNING)); } @SuppressWarnings("unused") @@ -532,4 +492,5 @@ public Nothing caseBusLoadModel(final BusLoadModel m) { }, null); pw.flush(); } + } diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/handlers/NewAbstractAaxlHandler.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/handlers/NewAbstractAaxlHandler.java new file mode 100644 index 00000000000..fd9e9ca84f5 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/handlers/NewAbstractAaxlHandler.java @@ -0,0 +1,428 @@ +/** + * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). + * All Rights Reserved. + * + * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE + * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT + * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. + * + * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * SPDX-License-Identifier: EPL-2.0 + * + * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). + * + * This program includes and/or can make use of certain third party source code, object code, documentation and other + * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system + * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and + * conditions contained in any such Third Party Software or separate license file distributed with such Third Party + * Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici- + * aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li- + * censes only apply to the Third Party Software and not any other portion of this program or this program as a whole. + */ +package org.osate.analysis.resource.budgets.handlers; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceRuleFactory; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.MultiRule; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IWorkingSet; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.handlers.HandlerUtil; +import org.osate.aadl2.Element; +import org.osate.aadl2.instance.SystemInstance; +import org.osate.aadl2.modelsupport.Activator; +import org.osate.aadl2.modelsupport.FileNameConstants; +import org.osate.aadl2.modelsupport.errorreporting.AnalysisErrorReporterManager; +import org.osate.aadl2.modelsupport.resources.OsateResourceUtil; +import org.osate.analysis.resource.budgets.ResourceBudgetPlugin; +import org.osate.core.AadlNature; +import org.osate.result.AnalysisResult; +import org.osate.result.Diagnostic; +import org.osate.result.Result; +import org.osate.ui.internal.instantiate.InstantiationEngine; + +/** + * Working replacement for {@link #AaxlReadOnlyHandlerAsJob}. Not at all "ready for prime-time", which + * is why it is currently package visibility. Also consider integrating with + * {@code org.osate.ui.handlers.AbstractMultiJobHandler}. + * + * Assumptions: The analysis selection is a bunch of working sets, AADL projects, folders, and aaxl files. + * There is a method for getting a list of unique aaxl files from that. IT is assumed analysis can + * run on each aaxl file independently. Analysis may produce markers on each aaxl file, and may create a + * single output file for each input aaxl file. For each input file, the output file is located + * in "reports/subdir/" rooted in the same directory as the input file. The analysis names "subdir" + * using an abstract method. The output file is named using an abstract method. + * + * We need more experience writing some "modern" osate analyses. I'm sure this draft class will + * need to be modified further. It's possible we will find some analysis that doesn't fit + * the assumptions at all. + * + * @author aarong + * + * @since 3.0 + */ +abstract class NewAbstractAaxlHandler extends AbstractHandler { + private static final String REPORTS_DIR = "/reports"; + + @Override + public final Object execute(final ExecutionEvent event) throws ExecutionException { + /* + * Do as little as possible here so we don't hold up the UI thread. Just get the + * selected items in a raw list and start a new job to figure everything else out. + */ + @SuppressWarnings("unchecked") + final List selectionAsList = HandlerUtil.getCurrentStructuredSelection(event).toList(); + final Job job = new KickoffJob(selectionAsList); + job.setRule(null); // doesn't use resources +// job.setUser(false); // background helper job, don't let the user see it +// job.setSystem(true); // background helper job, don't let the user see it + job.schedule(); + + // Supposed to always return null + return null; + } + + /* + * Job that starts everything else out. Goes through the selection and finds all the + * selected Aaxl files. Figures out the resource locking and output files needed + * to analyze each instance model. + * + * AS STATED ABOVE, THE ASSUMPTION HERE IS THAT EACH INSTANCE MODEL CAN BE ANALYZED INDEPENDENT + * OF THE OTHER ONES. + * + * WE ALSO ASSUME THAT EACH INPUT FILE CREATES A SINGLE OUTPUT FILE (probably a .csv file). + */ + private final class KickoffJob extends Job { + private final List selectionAsList; + + public KickoffJob(final List selectionAsList) { + super("Analysis kickoff"); + this.selectionAsList = selectionAsList; + } + + @Override + protected IStatus run(final IProgressMonitor monitor) { + /* Find the aaxl files and the component implementations from the UI selection */ + final Set aaxlFiles = new HashSet<>(); + final Set forEngine = new HashSet<>(); + findAllInstanceFilesAndComponentImpls(selectionAsList, aaxlFiles, forEngine); + + /* + * Instantiate the component implementations and add those that were successful to the + * set of aaxl files. + */ + if (!forEngine.isEmpty()) { + final InstantiationEngine engine = new InstantiationEngine(forEngine); + final List newAaxlFiles = engine.instantiate(monitor); + aaxlFiles.addAll(newAaxlFiles); + } + final int size = aaxlFiles.size(); + + /* + * Go through all the input files and find all the output files and associated + * scheduling rules. + */ + final IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); + ISchedulingRule prereqRule = null; // Initially empty + final Set outputFolders = new HashSet<>(); + final List outputFiles = new ArrayList<>(size); + final Job myJobs[] = new Job[size]; + + int idx = 0; + for (final IFile aaxlFile : aaxlFiles) { + // Get the output file, its location, and the base filename of the input file + final IPath pathSansExtension = aaxlFile.getFullPath().removeFileExtension(); + final String filename = pathSansExtension.lastSegment(); + final IPath reportsPath = pathSansExtension.removeLastSegments(1).append(REPORTS_DIR); + final IPath outputPath = reportsPath.append("/" + getSubDirName()); + + final IFolder reportsFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(reportsPath); + final IFolder outputFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(outputPath); + outputFolders.add(outputFolder); + + final IFile outputFile = ResourcesPlugin.getWorkspace().getRoot() + .getFile(outputPath.append("/" + getOutputFileForAaxlFile(aaxlFile, filename))); + outputFiles.add(outputFile); + prereqRule = MultiRule.combine(prereqRule, MultiRule.combine( + ruleFactory.createRule(reportsFolder), + MultiRule.combine(ruleFactory.createRule(outputFolder), ruleFactory.createRule(outputFile)))); + + final ISchedulingRule jobRule = MultiRule.combine(ruleFactory.modifyRule(outputFile), + ruleFactory.markerRule(aaxlFile)); + final Job job = createAnalysisJob(aaxlFile, outputFile); + job.setRule(jobRule); + job.setUser(true); + myJobs[idx] = job; + + idx += 1; + } + + /* + * Make sure all the output folders exists before hand. Could add the folder creation rules to the + * jobs below, but they would limit the parallelism too much. So we create them atomically here first, + * before we launch the main worker jobs. + * + * We also create (touch) all the output files before hand because creation requires locking the parent container, + * whereas modifying only requires locking the file itself. + * + * This means that the methods in the subclass that output to the file must use IFile.setContents(). + */ + boolean prereqFailed = false; + try { + ResourcesPlugin.getWorkspace().run(m -> { + for (final IFolder folder : outputFolders) { + makeSureFoldersExist(folder); + } + for (final IFile file : outputFiles) { + if (!file.exists()) { + file.create(EmptyInputStream.INSTANCE, true, null); + } + } + }, prereqRule, IWorkspace.AVOID_UPDATE, null); + } catch (CoreException e) { + prereqFailed = true; + Activator.logThrowable(e); + + PlatformUI.getWorkbench().getDisplay().asyncExec(() -> { + MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), + "Error starting analysis", + "Exception starting analysis, see the error log: " + e.getMessage()); + }); + } + + if (!prereqFailed) { + // now launch the main jobs + for (final Job job : myJobs) { + job.schedule(); + } + } + + return Status.OK_STATUS; + } + } + + /** + * Return the name of the subdirectory under the "reports" directory that the output files + * for this analysis are located in. + * + * @return The name of the subdirectory, e.g., {@code "BusLoad"}. + */ + protected abstract String getSubDirName(); + + /** + * Given an instance model file that is to be analyzed, return the name of the output file + * to generate after analyzing the given file. This name does not include path information, and + * is usually generated by appending a label to the filename and then adding the appropriate file + * extension. For example, the bus load analysis just returns the {@code filename} with the + * extension {@code .csv}. + * + * @param aaxlFile The file bing analyzed. + * + * @param filename The filename part of the file for convenience. This does not include the file + * extension. + * + * @return The output file name. + */ + protected abstract String getOutputFileForAaxlFile(IFile aaxlFile, String filename); + + /** + * Return a job that analyzes the given instance model file and puts the results in the + * given output file. We assume here that the analysis doesn't rely on anything other than + * the given instance model file. More specifically, if multiple instance models were selected + * to launch this action, they can all be analyzed independently of each other. + * + *

Note: If the job needs IScheudlingRules beyond the ability to create markers on the instance model + * file or to write to the output file, it is currently out of luck. This is an area of future + * abstraction if needed.

+ * + * @param aaxlFile The instance model file to analyze. + * + * @param outputFile The file to write output to. This file is guaranteed to exist already. The + * existing contents of the file are not guaranteed. That is, the file may be new and empty, or it + * may contain the results from a previous analysis run, or it could just be garbage. + * + * @return A job class that executes analysis on the given instnace model file. + */ + protected abstract Job createAnalysisJob(IFile aaxlFile, IFile outputFile); + + private static final class EmptyInputStream extends InputStream { + public static final EmptyInputStream INSTANCE = new EmptyInputStream(); + + private EmptyInputStream() { + super(); + } + + @Override + public int read() throws IOException { + return -1; + } + } + + /** + * Given a collection of resources, find all the resources that are instance model ({@code .aaxl}) + * files. Also finds all the COmponentImplementations that are selected and adds those to the + * set referenced by {@code forEngine}. If a resource is an AADL project, working set, or folder then the contents are recursively searched. + * Duplicates are handled: if a resource is encountered more than once it only appears once in + * the returned list. Hidden folders (those that start with {@code .}) are ignored. + * + * @param A collection of Eclipse {@link IResource} objects and {@link IWorkingSet} objects. + * @return A list of {@link IFile} objects that refer to AADL instance model files. + */ + private static void findAllInstanceFilesAndComponentImpls(final Collection rsrcs, + final Set instanceFiles, final Set forEngine) { + findAllInstanceFilesAndComponentImpls(rsrcs.toArray(new Object[rsrcs.size()]), instanceFiles, forEngine); + } + + private static void findAllInstanceFilesAndComponentImpls(final Object[] rsrcs, final Set instanceFiles, + final Set forEngine) { + for (final Object rsrc : rsrcs) { + if (rsrc instanceof IWorkingSet) { + findAllInstanceFilesAndComponentImpls(((IWorkingSet) rsrc).getElements(), instanceFiles, forEngine); + } else if (rsrc instanceof IFile) { + final IFile file = (IFile) rsrc; + final String ext = file.getFileExtension(); + if (ext != null && ext.equals(FileNameConstants.INSTANCE_FILE_EXT)) { + instanceFiles.add(file); + } + } else if (rsrc instanceof SystemInstance) { + instanceFiles.add(OsateResourceUtil.toIFile(((SystemInstance) rsrc).eResource().getURI())); + } else if (rsrc instanceof IContainer) { + final IContainer container = (IContainer) rsrc; + if (container instanceof IProject) { + final IProject project = (IProject) container; + if (!project.isOpen() || !AadlNature.hasNature(project)) { + // Project is closed or is not an AADL project, so ignore it + continue; + } + } + + if (!container.getName().startsWith(".")) { + try { + findAllInstanceFilesAndComponentImpls(container.members(), instanceFiles, forEngine); + } catch (final CoreException e) { + ResourceBudgetPlugin.getDefault().getLog().error(e.getMessage(), e); + } + } + } else { + // pass through to the instantiation engine + forEngine.add(rsrc); + } + } + } + + /** + * make sure the folders exist all along the path + * + * @param path + */ + private static void makeSureFoldersExist(IFolder folder) { + if (!folder.exists()) { + makeSureFoldersExist((IFolder) folder.getParent()); + try { + folder.create(true, true, null); + } catch (final CoreException e) { + ResourceBudgetPlugin.getDefault().getLog().error(e.getMessage(), e); + } + } + } + + public static void generateMarkers(final AnalysisResult analysisResult, + final AnalysisErrorReporterManager errManager) { + // Handle each SOM + analysisResult.getResults().forEach(r -> { + final String somName = r.getMessage(); + final String somPostfix = somName.isEmpty() ? "" : (" in modes " + somName); + generateMarkersForSOM(r, errManager, somPostfix); + }); + } + + private static void generateMarkersForSOM(final Result result, final AnalysisErrorReporterManager errManager, + final String somPostfix) { + generateMarkersFromDiagnostics(result.getDiagnostics(), errManager, somPostfix); + result.getSubResults().forEach(r -> generateMarkersForSOM(r, errManager, somPostfix)); + } + + private static void generateMarkersFromDiagnostics(final List diagnostics, + final AnalysisErrorReporterManager errManager, final String somPostfix) { + diagnostics.forEach(issue -> { + switch (issue.getDiagnosticType()) { + case ERROR: + errManager.error((Element) issue.getModelElement(), issue.getMessage() + somPostfix); + break; + case INFO: + errManager.info((Element) issue.getModelElement(), issue.getMessage() + somPostfix); + break; + case WARNING: + errManager.warning((Element) issue.getModelElement(), issue.getMessage() + somPostfix); + break; + default: + // Do nothing. + } + }); + } + + // === CSV Output methods === + + public static void writeCSVFile(final InputStream inputStream, final IFile outputFile, + final IProgressMonitor monitor) { + try { + if (outputFile.exists()) { + outputFile.setContents(inputStream, true, true, monitor); + } else { + outputFile.create(inputStream, true, monitor); + } + } catch (final CoreException e) { + Activator.logThrowable(e); + } + } + + // ==== Low-level CSV format, this should be abstracted somewhere + + + public static void printItems(final PrintWriter pw, final String item1, final String... items) { + printItem(pw, item1); + for (final String nextItem : items) { + printSeparator(pw); + printItem(pw, nextItem); + } + pw.println(); + } + + public static void printItem(final PrintWriter pw, final String item) { + // TODO: Doesn't handle quotes in the item! + pw.print('"'); + pw.print(item); + pw.print('"'); + } + + public static void printSeparator(final PrintWriter pw) { + pw.print(","); + } +} diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/handlers/NewBusLoadAnalysisHandler.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/handlers/NewBusLoadAnalysisHandler.java index 7fa50185023..7e27c529a12 100644 --- a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/handlers/NewBusLoadAnalysisHandler.java +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/handlers/NewBusLoadAnalysisHandler.java @@ -23,7 +23,10 @@ */ package org.osate.analysis.resource.budgets.handlers; +import java.io.ByteArrayInputStream; +import java.io.InputStream; import java.io.PrintWriter; +import java.io.StringWriter; import java.util.List; import org.eclipse.core.resources.IFile; @@ -36,19 +39,21 @@ import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; import org.osate.aadl2.instance.SystemInstance; +import org.osate.aadl2.instance.SystemOperationMode; import org.osate.aadl2.modelsupport.errorreporting.AnalysisErrorReporterManager; import org.osate.aadl2.modelsupport.errorreporting.MarkerAnalysisErrorReporter; import org.osate.aadl2.modelsupport.util.AadlUtil; +import org.osate.aadl2.util.Aadl2Util; import org.osate.analysis.resource.budgets.busload.NewBusLoadAnalysis; import org.osate.result.AnalysisResult; +import org.osate.result.Diagnostic; import org.osate.result.Result; import org.osate.result.util.ResultUtil; -import org.osate.ui.handlers.AbstractAnalysisHandler; /** * @since 3.0 */ -public final class NewBusLoadAnalysisHandler extends AbstractAnalysisHandler { +public final class NewBusLoadAnalysisHandler extends NewAbstractAaxlHandler { private static final String MARKER_TYPE = "org.osate.analysis.resource.budgets.BusLoadAnalysisMarker"; private static final String REPORT_SUB_DIR = "BusLoad"; @@ -98,7 +103,10 @@ public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreExcepti } generateMarkers(analysisResult, errManager); subMonitor.worked(1); - new ResutWriter(outputFile).writeAnalysisResults(analysisResult, subMonitor.split(1)); + + final String csvContent = getCSVasString(analysisResult); + final InputStream inputStream = new ByteArrayInputStream(csvContent.getBytes()); + writeCSVFile(inputStream, outputFile, subMonitor.split(1)); } catch (final OperationCanceledException e) { cancelled = true; } @@ -108,138 +116,153 @@ public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreExcepti } - // === CSV Output methods === + /* + * This seems like the type of thing we want to do all the time, but the problem is that so far + * there hasn't been a standard way of dealing with the system operation modes. Here we + * have the system operation modes as the first level of results under the AnalysisResult + * object. If we can standardize the handling of SOMs then we can standardize these methods + * somewhere; + * + * this is moved to NewAbstractAaxlHandler.java + */ + + private static String getCSVasString(final AnalysisResult analysisResult) { + final StringWriter writer = new StringWriter(); + final PrintWriter pw = new PrintWriter(writer); + generateCSVforAnalysis(pw, analysisResult); + pw.close(); + return writer.toString(); + } - private final class ResutWriter extends CSVAnalysisResultWriter { - protected ResutWriter(final IFile outputFile) { - super(outputFile); - } + /** + * @since 4.1 + */ + public static void generateCSVforAnalysis(final PrintWriter pw, final AnalysisResult analysisResult) { + pw.println(analysisResult.getMessage()); + pw.println(); + pw.println(); + analysisResult.getResults().forEach(somResult -> generateCSVforSOM(pw, somResult)); + } - @Override - protected void generateContentforSOM(final PrintWriter pw, final Result somResult, - final IProgressMonitor monitor) { - /* - * Go through the children twice: First to print summary information and then to recursively - * print the sub information. - */ - - printItems(pw, "Physical Bus", "Capacity (KB/s)", "Budget (KB/s)", "Required Budget (KB/s)", - "Actual (KB/s)"); - - for (final Result subResult : somResult.getSubResults()) { - // Label, Capacity, Budget, Required Capacity, Actual - printItems(pw, subResult.getMessage(), Double.toString(ResultUtil.getReal(subResult, 0)), - Double.toString(ResultUtil.getReal(subResult, 1)), - Double.toString(ResultUtil.getReal(subResult, 2)), - Double.toString(ResultUtil.getReal(subResult, 3))); - } + /** + * @since 4.1 + */ + public static void generateCSVforSOM(final PrintWriter pw, final Result somResult) { + if (Aadl2Util.isPrintableSOMName((SystemOperationMode) somResult.getModelElement())) { + printItem(pw, "Analysis results in modes " + somResult.getMessage()); pw.println(); + } - // NO DIAGNOSTICS AT THE SOM LEVEL + /* + * Go through the children twice: First to print summary information and then to recursively + * print the sub information. + */ - final SubMonitor subMonitor = SubMonitor.convert(monitor, somResult.getSubResults().size()); - somResult.getSubResults() - .forEach(busResult -> generateContentforBus(pw, busResult, null, subMonitor.split(1))); - pw.println(); // add a second newline, the first is from the end of generateContentForBus() - } + printItems(pw, "Physical Bus", "Capacity (KB/s)", "Budget (KB/s)", "Required Budget (KB/s)", "Actual (KB/s)"); - private void generateContentforBus(final PrintWriter pw, final Result busResult, final Result boundTo, - final IProgressMonitor monitor) { - final SubMonitor subMonitor = SubMonitor.convert(monitor, 2); + for (final Result subResult : somResult.getSubResults()) { + // Label, Capacity, Budget, Required Capacity, Actual + printItems(pw, subResult.getMessage(), Double.toString(ResultUtil.getReal(subResult, 0)), + Double.toString(ResultUtil.getReal(subResult, 1)), + Double.toString(ResultUtil.getReal(subResult, 2)), + Double.toString(ResultUtil.getReal(subResult, 3))); + } + pw.println(); - final long dataOverhead = ResultUtil.getInteger(busResult, 7); - if (boundTo == null) { - printItem(pw, "Bus " + busResult.getMessage() + " has data overhead of " + dataOverhead + " bytes"); - } else { - printItem(pw, "Virtual bus " + busResult.getMessage() + " bound to " + boundTo.getMessage() - + " has data overhead of " + dataOverhead + " bytes"); - } - pw.println(); + // NO DIAGNOSTICS AT THE SOM LEVEL - /* - * Go through the children twice: First to print summary information and then to recursively - * print the sub information. - */ - - printItems(pw, "Bound Virtual Bus/Connection", "Capacity (KB/s)", "Budget (KB/s)", "Required Budget (KB/s)", - "Actual (KB/s)"); - - final int numBus = (int) ResultUtil.getInteger(busResult, 4); - final int numConnections = (int) ResultUtil.getInteger(busResult, 5); - final List subResults = busResult.getSubResults(); - for (final Result subResult : subResults.subList(0, numBus)) { - // Label, Capacity, Budget, Required Capacity, Actual - printItems(pw, subResult.getMessage(), Double.toString(ResultUtil.getReal(subResult, 0)), - Double.toString(ResultUtil.getReal(subResult, 1)), - Double.toString(ResultUtil.getReal(subResult, 2)), - Double.toString(ResultUtil.getReal(subResult, 3))); - } - for (final Result subResult : subResults.subList(numBus, subResults.size())) { - // Label, NO CAPACITY, Budget, NO REQUIRED CAPACITY, Actual - // Capacity, NO BUDGET, Required - printItems(pw, subResult.getMessage(), "", Double.toString(ResultUtil.getReal(subResult, 0)), "", - Double.toString(ResultUtil.getReal(subResult, 1))); - } - pw.println(); + somResult.getSubResults().forEach(busResult -> generateCSVforBus(pw, busResult, null)); + pw.println(); // add a second newline, the first is from the end of generateCSVforBus() + } - generateContentforDiagnostics(pw, busResult.getDiagnostics(), subMonitor.split(1)); - if (!busResult.getDiagnostics().isEmpty()) { - pw.println(); - } + private static void generateCSVforBus(final PrintWriter pw, final Result busResult, final Result boundTo) { + final long dataOverhead = ResultUtil.getInteger(busResult, 7); + if (boundTo == null) { + printItem(pw, "Bus " + busResult.getMessage() + " has data overhead of " + dataOverhead + " bytes"); + } else { + printItem(pw, "Virtual bus " + busResult.getMessage() + " bound to " + boundTo.getMessage() + + " has data overhead of " + dataOverhead + " bytes"); + } + pw.println(); + + /* + * Go through the children twice: First to print summary information and then to recursively + * print the sub information. + */ + + printItems(pw, "Bound Virtual Bus/Connection", "Capacity (KB/s)", "Budget (KB/s)", "Required Budget (KB/s)", + "Actual (KB/s)"); + + final int numBus = (int) ResultUtil.getInteger(busResult, 4); + final int numConnections = (int) ResultUtil.getInteger(busResult, 5); + final List subResults = busResult.getSubResults(); + for (final Result subResult : subResults.subList(0, numBus)) { + // Label, Capacity, Budget, Required Capacity, Actual + printItems(pw, subResult.getMessage(), Double.toString(ResultUtil.getReal(subResult, 0)), + Double.toString(ResultUtil.getReal(subResult, 1)), + Double.toString(ResultUtil.getReal(subResult, 2)), + Double.toString(ResultUtil.getReal(subResult, 3))); + } + for (final Result subResult : subResults.subList(numBus, subResults.size())) { + // Label, NO CAPACITY, Budget, NO REQUIRED CAPACITY, Actual + // Capacity, NO BUDGET, Required + printItems(pw, subResult.getMessage(), "", Double.toString(ResultUtil.getReal(subResult, 0)), "", + Double.toString(ResultUtil.getReal(subResult, 1))); + } + pw.println(); - final SubMonitor loopMonitor = subMonitor.split(1).setWorkRemaining(subResults.size()); - subResults.subList(0, numBus).forEach(br -> generateContentforBus(pw, br, busResult, loopMonitor.split(1))); - subResults.subList(numBus, numBus + numConnections) - .forEach(br -> generateContentforConnection(pw, br, busResult, loopMonitor.split(1))); - subResults.subList(numBus + numConnections, subResults.size()) - .forEach(br -> generateContentforBroadcast(pw, br, busResult, loopMonitor.split(1))); + if (!busResult.getDiagnostics().isEmpty()) { + generateCSVforDiagnostics(pw, busResult.getDiagnostics()); + pw.println(); } - private void generateContentforBroadcast(final PrintWriter pw, final Result broadcastResult, - final Result boundTo, final IProgressMonitor monitor) { - final SubMonitor subMonitor = SubMonitor.convert(monitor, 2); + subResults.subList(0, numBus).forEach(br -> generateCSVforBus(pw, br, busResult)); + subResults.subList(numBus, numBus + numConnections).forEach(br -> generateCSVforConnection(pw, br, busResult)); + subResults.subList(numBus + numConnections, subResults.size()) + .forEach(br -> generateCSVforBroadcast(pw, br, busResult)); + } - printItem(pw, broadcastResult.getMessage() + " over bus " + boundTo.getMessage()); - pw.println(); + private static void generateCSVforBroadcast(final PrintWriter pw, final Result broadcastResult, + final Result boundTo) { + printItem(pw, broadcastResult.getMessage() + " over bus " + boundTo.getMessage()); + pw.println(); - /* - * Go through the children twice: First to print summary information and then to recursively - * print the sub information. - */ + /* + * Go through the children twice: First to print summary information and then to recursively + * print the sub information. + */ - printItems(pw, "Included Connection", "Budget (KB/s)", "Actual (KB/s)"); + printItems(pw, "Included Connection", "Budget (KB/s)", "Actual (KB/s)"); - final List subResults = broadcastResult.getSubResults(); - for (final Result subResult : subResults) { - printItems(pw, subResult.getMessage(), Double.toString(ResultUtil.getReal(subResult, 0)), - Double.toString(ResultUtil.getReal(subResult, 1))); - } + final List subResults = broadcastResult.getSubResults(); + for (final Result subResult : subResults) { + printItems(pw, subResult.getMessage(), Double.toString(ResultUtil.getReal(subResult, 0)), + Double.toString(ResultUtil.getReal(subResult, 1))); + } + pw.println(); + + if (!broadcastResult.getDiagnostics().isEmpty()) { + generateCSVforDiagnostics(pw, broadcastResult.getDiagnostics()); pw.println(); + } - generateContentforDiagnostics(pw, broadcastResult.getDiagnostics(), subMonitor.split(1)); - if (!broadcastResult.getDiagnostics().isEmpty()) { - pw.println(); - } + subResults.forEach(br -> generateCSVforConnection(pw, br, broadcastResult)); + } - final SubMonitor loopMonitor = subMonitor.split(1).setWorkRemaining(subResults.size()); - subResults.forEach(br -> generateContentforConnection(pw, br, broadcastResult, loopMonitor.split(1))); + private static void generateCSVforConnection(final PrintWriter pw, final Result connectionResult, + final Result boundTo) { + // only do something if there are diagnostics + if (!connectionResult.getDiagnostics().isEmpty()) { + printItem(pw, "Connection " + connectionResult.getMessage() + " bound to " + boundTo.getMessage()); + generateCSVforDiagnostics(pw, connectionResult.getDiagnostics()); + pw.println(); } + } - private void generateContentforConnection(final PrintWriter pw, final Result connectionResult, - final Result boundTo, final IProgressMonitor monitor) { - // only do something if there are diagnostics - final SubMonitor subMonitor = SubMonitor.convert(monitor, 1); - - if (!connectionResult.getDiagnostics().isEmpty()) { - printItem(pw, "Connection " + connectionResult.getMessage() + " bound to " + boundTo.getMessage()); - pw.println(); - final SubMonitor loopMonitor = subMonitor.split(1) - .setWorkRemaining(connectionResult.getDiagnostics().size()); - generateContentforDiagnostics(pw, connectionResult.getDiagnostics(), loopMonitor); - pw.println(); - } else { - subMonitor.setWorkRemaining(0); - } + private static void generateCSVforDiagnostics(final PrintWriter pw, final List diagnostics) { + for (final Diagnostic issue : diagnostics) { + printItem(pw, issue.getDiagnosticType().getName() + ": " + issue.getMessage()); + pw.println(); } } } diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/handlers/NewPowerAnalysisHandler.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/handlers/NewPowerAnalysisHandler.java new file mode 100644 index 00000000000..a4630c19ac8 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/handlers/NewPowerAnalysisHandler.java @@ -0,0 +1,211 @@ +/** + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * All Rights Reserved. + * + * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE + * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT + * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. + * + * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * SPDX-License-Identifier: EPL-2.0 + * + * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). + * + * This program includes and/or can make use of certain third party source code, object code, documentation and other + * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system + * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and + * conditions contained in any such Third Party Software or separate license file distributed with such Third Party + * Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici- + * aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li- + * censes only apply to the Third Party Software and not any other portion of this program or this program as a whole. + */ +package org.osate.analysis.resource.budgets.handlers; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.WorkspaceJob; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.core.runtime.jobs.Job; +import org.osate.aadl2.instance.SystemInstance; +import org.osate.aadl2.modelsupport.errorreporting.AnalysisErrorReporterManager; +import org.osate.aadl2.modelsupport.errorreporting.MarkerAnalysisErrorReporter; +import org.osate.aadl2.modelsupport.util.AadlUtil; +import org.osate.analysis.resource.budgets.power.PowerRequirementAnalysis; +import org.osate.result.AnalysisResult; +import org.osate.result.Result; +import org.osate.result.util.ResultUtil; + +/** + * @since 4.1 + */ +public class NewPowerAnalysisHandler extends NewAbstractAaxlHandler { + private static final String MARKER_TYPE = "org.osate.analysis.resource.budgets.PowerAnalysisMarker"; + private static final String REPORT_SUB_DIR = "Power"; + + @Override + protected String getSubDirName() { + return REPORT_SUB_DIR; + } + + @Override + protected String getOutputFileForAaxlFile(final IFile aaxlFile, final String filename) { + return filename + "__Power.csv"; + } + + @Override + protected Job createAnalysisJob(IFile aaxlFile, IFile outputFile) { + return new PowerReqJob(aaxlFile, outputFile); + } + + private final class PowerReqJob extends WorkspaceJob { + private final IFile aaxlFile; + private final IFile outputFile; + + public PowerReqJob(final IFile aaxlFile, final IFile outputFile) { + super("Power Requirements analysis of " + aaxlFile.getName()); + this.aaxlFile = aaxlFile; + this.outputFile = outputFile; + } + + @Override + public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException { + final AnalysisErrorReporterManager errManager = new AnalysisErrorReporterManager( + new MarkerAnalysisErrorReporter.Factory(MARKER_TYPE)); + + // Three phases (1) analysis, (2) marker generation, (3) csv file + final SubMonitor subMonitor = SubMonitor.convert(monitor, 3); + boolean cancelled = false; + + try { + final AnalysisResult analysisResult = new PowerRequirementAnalysis().invoke(subMonitor.split(1), + (SystemInstance) AadlUtil.getElement(aaxlFile)); + if (subMonitor.isCanceled()) { + throw new OperationCanceledException(); + } + generateMarkers(analysisResult, errManager); + subMonitor.worked(1); + + final String csvContent = getCSVasString(analysisResult); + final InputStream inputStream = new ByteArrayInputStream(csvContent.getBytes()); + writeCSVFile(inputStream, outputFile, subMonitor.split(1)); + } catch (final OperationCanceledException e) { + cancelled = true; + } + + return cancelled ? Status.CANCEL_STATUS : Status.OK_STATUS; + } + } + + private static String getCSVasString(final AnalysisResult analysisResult) { + final StringWriter writer = new StringWriter(); + final PrintWriter pw = new PrintWriter(writer); + generateCSVforAnalysis(pw, analysisResult); + pw.close(); + return writer.toString(); + } + + // generate csv report + public static void generateCSVforAnalysis(final PrintWriter pw, final AnalysisResult analysisResult) { + pw.println(analysisResult.getMessage()); + pw.println(); + + analysisResult.getResults().forEach(result -> { // section per result + if (result.getSubResults().size() > 0) { + Result subResult = result.getSubResults().get(0); + + String resourceName = ResultUtil.getString(subResult, 5); + printItem(pw, "Computing Electrical Power for " + resourceName); + pw.println(); + + double capacity = ResultUtil.getReal(subResult, 2); + printItem(pw, "Capacity: " + PowerRequirementAnalysis.toString(capacity)); + pw.println(); + + // Supply + double totalSupply = ResultUtil.getReal(subResult, 4); + printItem(pw, "Supply: " + PowerRequirementAnalysis.toString(totalSupply)); + + result.getSubResults().forEach(sResult -> { + double currentValue = ResultUtil.getReal(sResult, 1); + if (currentValue > 0) { + printSeparator(pw); + printItem(pw, PowerRequirementAnalysis.toString(currentValue) + " for " + + ResultUtil.getString(sResult, 7)); + } + }); + pw.println(); + + // Budget + double totalBudget = ResultUtil.getReal(subResult, 3); + printItem(pw, "Budget: " + PowerRequirementAnalysis.toString(totalBudget)); + + result.getSubResults().forEach(sResult -> { + double currentValue = ResultUtil.getReal(sResult, 0); + + if (currentValue > 0) { + printSeparator(pw); + printItem(pw, PowerRequirementAnalysis.toString(currentValue) + " for " + + ResultUtil.getString(sResult, 7)); + } + }); + pw.println(); + + if (capacity > 0.0 && totalBudget > 0.0) { + if (totalBudget > capacity) { + printItem(pw, + "** " + resourceName + " budget total " + PowerRequirementAnalysis.toString(totalBudget) + + " exceeds capacity " + PowerRequirementAnalysis.toString(capacity)); + pw.println(); + + // errManager.error(ci, somName + ": " + message); + // powerComponentError(section, message); + } else { + printItem(pw, resourceName + " budget total " + PowerRequirementAnalysis.toString(totalBudget) + + " within capacity " + PowerRequirementAnalysis.toString(capacity)); + pw.println(); + + // errManager.info(ci, somName + ": " + message); + // powerComponentSuccess(section, message); + } + } + + String suppliedmsg = ""; + double available = 0.0; + if (totalSupply == 0.0) { + available = capacity; + suppliedmsg = " capacity "; + } else { + available = totalSupply; + suppliedmsg = " supply "; + } + + if (totalBudget > available) { + printItem(pw, "** " + "budget total " + PowerRequirementAnalysis.toString(totalBudget) + " exceeds" + + suppliedmsg + PowerRequirementAnalysis.toString(available)); + pw.println(); + // powerComponentError(section, message); + // errManager.error(ci, somName + ": " + message); + } else { + printItem(pw, "budget total " + PowerRequirementAnalysis.toString(totalBudget) + " within" + + suppliedmsg + PowerRequirementAnalysis.toString(available)); + pw.println(); + // errManager.info(ci, somName + ": " + message); + // powerComponentSuccess(section, message); + } + + pw.println(); + } + }); + } +} \ No newline at end of file diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/ConnectionEnd.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/ConnectionEnd.java new file mode 100644 index 00000000000..6e60dbb6098 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/ConnectionEnd.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * All Rights Reserved. + * + * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE + * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT + * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. + * + * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * SPDX-License-Identifier: EPL-2.0 + * + * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). + * + * This program includes and/or can make use of certain third party source code, object code, documentation and other + * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system + * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and + * conditions contained in any such Third Party Software or separate license file distributed with such Third Party + * Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici- + * aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li- + * censes only apply to the Third Party Software and not any other portion of this program or this program as a whole. + */ +package org.osate.analysis.resource.budgets.internal.busload.model; + +import java.rmi.server.UID; + +import org.osate.aadl2.instance.ConnectionInstanceEnd; + +public class ConnectionEnd extends AnalysisElement { + /** The connection instance end represented. */ + private final ConnectionInstanceEnd connInstanceEnd; + private final double supply; + private final UID id; + + public ConnectionEnd(final ConnectionInstanceEnd connInstanceEnd, double budget, double supply) { + super("connectionEnd"); + this.connInstanceEnd = connInstanceEnd; + this.supply = supply; + this.id = new UID(); + super.setBudget(budget); + } + + public final ConnectionInstanceEnd getConnectionInstanceEnd() { + return connInstanceEnd; + } + + @Override + void visitSelfPrefix(final Visitor visitor) { + visitor.visitConnectionEndPrefix(this); + } + + @Override + void visitSelfPostfix(final Visitor visitor) { + visitor.visitConnectionEndPostfix(this); + } + + public final double getSupply() { + return supply; + } + + public final UID getID() { + return id; + } + + @Override + void visitChildren(Visitor visitor) { + // TODO Auto-generated method stub + + } +} diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/Feature.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/Feature.java new file mode 100644 index 00000000000..92dd7fa4889 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/Feature.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * All Rights Reserved. + * + * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE + * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT + * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. + * + * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * SPDX-License-Identifier: EPL-2.0 + * + * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). + * + * This program includes and/or can make use of certain third party source code, object code, documentation and other + * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system + * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and + * conditions contained in any such Third Party Software or separate license file distributed with such Third Party + * Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici- + * aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li- + * censes only apply to the Third Party Software and not any other portion of this program or this program as a whole. + */ +package org.osate.analysis.resource.budgets.internal.busload.model; + +import java.rmi.server.UID; + +import org.osate.aadl2.instance.FeatureInstance; + +public class Feature extends AnalysisElement { + private final FeatureInstance featureInstance; + private final double supply; + private final UID id; + + public Feature(final FeatureInstance featureInstance, double budget, double supply) { + super("feature"); + this.featureInstance = featureInstance; + this.supply = supply; + this.id = new UID(); + super.setBudget(budget); + } + + public final FeatureInstance getFeatureInstance() { + return featureInstance; + } + + @Override + void visitSelfPrefix(Visitor visitor) { + visitor.visitFeaturePrefix(this); + } + + @Override + void visitSelfPostfix(Visitor visitor) { + visitor.visitFeaturePostfix(this); + } + + public final double getSupply() { + return supply; + } + + public final UID getID() { + return id; + } + + @Override + void visitChildren(Visitor visitor) { + // TODO Auto-generated method stub + + } +} \ No newline at end of file diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/PowerRequirementModel.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/PowerRequirementModel.java new file mode 100644 index 00000000000..06d042acd14 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/PowerRequirementModel.java @@ -0,0 +1,228 @@ +/** + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * All Rights Reserved. + * + * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE + * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT + * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. + * + * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * SPDX-License-Identifier: EPL-2.0 + * + * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). + * + * This program includes and/or can make use of certain third party source code, object code, documentation and other + * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system + * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and + * conditions contained in any such Third Party Software or separate license file distributed with such Third Party + * Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici- + * aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li- + * censes only apply to the Third Party Software and not any other portion of this program or this program as a whole. + */ +package org.osate.analysis.resource.budgets.internal.busload.model; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.osate.aadl2.Element; +import org.osate.aadl2.instance.ComponentInstance; +import org.osate.aadl2.instance.ConnectionInstance; +import org.osate.aadl2.instance.ConnectionInstanceEnd; +import org.osate.aadl2.instance.FeatureInstance; +import org.osate.aadl2.instance.SystemInstance; +import org.osate.aadl2.instance.SystemOperationMode; +import org.osate.aadl2.modelsupport.modeltraversal.ForAllElement; +import org.osate.aadl2.util.Aadl2Util; +import org.osate.xtext.aadl2.properties.util.GetProperties; + +public class PowerRequirementModel extends ModelElement { + private String systemSOMname = new String(); + private String componentName = new String(); + + private double capacityTotal = 0; + private double budgetTotal = 0; + private double supplyTotal = 0; + + private final List rootFeatures = new ArrayList<>(); + private final List rootConnectionEnds = new ArrayList<>(); + + private final Map features = new HashMap<>(); + private final Map connectionEnds = new HashMap<>(); + + /** + * Use {@link #buildModel(SystemInstance, SystemOperationMode)} to get an instance of the + * model. + */ + private PowerRequirementModel() { + super(); + } + + @Override + void visitSelfPrefix(final Visitor visitor) { + rootFeatures.forEach(e -> visitor.visitFeaturePrefix(e)); + rootConnectionEnds.forEach(e -> visitor.visitConnectionEndPrefix(e)); + } + + @Override + void visitChildren(final Visitor visitor) { + // no children + } + + @Override + void visitSelfPostfix(final Visitor visitor) { + rootFeatures.forEach(e -> visitor.visitFeaturePostfix(e)); + rootConnectionEnds.forEach(e -> visitor.visitConnectionEndPostfix(e)); + } + + public static PowerRequirementModel buildModel(final SystemInstance root, final SystemOperationMode som) { + final PowerRequirementModel model = new PowerRequirementModel(); + + final String somName = Aadl2Util.getPrintableSOMName(som); + String systemName = root.getComponentClassifier().getName(); + model.systemSOMname = systemName + " " + somName; + + final ForAllElement mal = new ForAllElement() { + @Override + protected void process(final Element obj) { + final ComponentInstance ci = (ComponentInstance) obj; + + double tmpCapacity = GetProperties.getPowerCapacity(ci, 0.0); + + if (tmpCapacity == 0) { + return; + } else { + model.capacityTotal = tmpCapacity; + } + + model.componentName = ci.getName(); + + for (FeatureInstance fi : ci.getFeatureInstances()) { + double supply = GetProperties.getPowerBudget(fi, 0.0); + if ((supply > 0) && (!fi.getDstConnectionInstances().isEmpty() + || !fi.getSrcConnectionInstances().isEmpty())) { + addFeature(model, fi, som, 0, supply); + model.supplyTotal += supply; + } + + for (ConnectionInstance inconni : fi.getDstConnectionInstances()) { + // incoming connections: does the other end provide power? + ConnectionInstanceEnd srcfi = inconni.getSource(); + supply = GetProperties.getPowerSupply(srcfi, 0.0); + if (supply > 0) { + addConnectionEnd(model, srcfi, som, 0, supply); + model.supplyTotal += supply; + } + } + for (ConnectionInstance outconni : fi.getSrcConnectionInstances()) { + // outgoing connection. Does the other end have a power budget? + ConnectionInstanceEnd dstfi = outconni.getDestination(); + double budget = GetProperties.getPowerBudget(dstfi, 0.0); + if (budget > 0) { + addConnectionEnd(model, dstfi, som, budget, 0); + model.budgetTotal += budget; + } + } + } + // power supply and budget based on access connections to this bus + // we are checking whether there are connections with the component with power capacity as source or destination + // this could be a bus, possibly an abstract component + for (ConnectionInstance ac : ci.getSrcConnectionInstances()) { + // Outgoing from Power system as bus + FeatureInstance dstfi = (FeatureInstance) ac.getDestination(); + double budget = GetProperties.getPowerBudget(dstfi, 0.0); + if (budget > 0) { + addFeature(model, dstfi, som, budget, 0); + model.budgetTotal += budget; + } + double supply = GetProperties.getPowerSupply(dstfi, 0.0); + if (supply > 0) { + addFeature(model, dstfi, som, 0, supply); + model.supplyTotal += supply; + } + } + for (ConnectionInstance ac : ci.getDstConnectionInstances()) { + // Incoming to Power system as bus + FeatureInstance srcfi = (FeatureInstance) ac.getSource(); + double budget = GetProperties.getPowerBudget(srcfi, 0.0); + if (budget > 0) { + addFeature(model, srcfi, som, budget, 0); + model.budgetTotal += budget; + } + double supply = GetProperties.getPowerSupply(srcfi, 0.0); + if (supply > 0) { + addFeature(model, srcfi, som, 0, supply); + model.supplyTotal += supply; + } + } + } + }; + mal.processPreOrderComponentInstance(root); + return model; + } + + public static String addUnits(double value) { + return value > 2000.0 ? value / 1000 + " W" : value + " mW"; + } + + void addFeature(final Feature feature) { + rootFeatures.add(feature); + } + + private static void addFeature(final PowerRequirementModel model, final FeatureInstance feature, + final SystemOperationMode som, double budget, double supply) { + final Feature theFeature = model.getFeature(feature, budget, supply); + model.addFeature(theFeature); + } + + private Feature getFeature(final FeatureInstance fi, double budget, double supply) { + Feature feature = features.get(fi); + if (feature == null) { + feature = new Feature(fi, budget, supply); + features.put(fi, feature); + } + return feature; + } + + void addConnection(final ConnectionEnd connectionEnd) { + rootConnectionEnds.add(connectionEnd); + } + + private static void addConnectionEnd(final PowerRequirementModel model, final ConnectionInstanceEnd connEnd, + final SystemOperationMode som, double budget, double supply) { + final ConnectionEnd theConnEnd = model.getConnectionEnd(connEnd, budget, supply); + model.addConnection(theConnEnd); + } + + private ConnectionEnd getConnectionEnd(final ConnectionInstanceEnd cie, double budget, double supply) { + ConnectionEnd connEnd = connectionEnds.get(cie); + if (connEnd == null) { + connEnd = new ConnectionEnd(cie, budget, supply); + connectionEnds.put(cie, connEnd); + } + return connEnd; + } + + public double getTotalCapacity() { + return this.capacityTotal; + } + + public double getTotalBudget() { + return this.budgetTotal; + } + + public double getTotalSupply() { + return this.supplyTotal; + } + + public String getSystemSOMname() { + return this.systemSOMname; + } + + public String getComponentName() { + return this.componentName; + } +} \ No newline at end of file diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/Visitor.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/Visitor.java new file mode 100644 index 00000000000..24fcf094d3f --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/internal/busload/model/Visitor.java @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * All Rights Reserved. + * + * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE + * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT + * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. + * + * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * SPDX-License-Identifier: EPL-2.0 + * + * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). + * + * This program includes and/or can make use of certain third party source code, object code, documentation and other + * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system + * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and + * conditions contained in any such Third Party Software or separate license file distributed with such Third Party + * Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici- + * aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li- + * censes only apply to the Third Party Software and not any other portion of this program or this program as a whole. + */ +package org.osate.analysis.resource.budgets.internal.busload.model; + +/** + * @since 3.0 + */ +public interface Visitor { + public default void visitModelPrefix(BusLoadModel model) { + } + + public default void visitModelPrefix(PowerRequirementModel model) { + + } + + public default void visitModelPostfix(BusLoadModel model) { + } + + public default void visitModelPostfix(PowerRequirementModel model) { + } + + public default void visitBusOrVirtualBusPrefix(BusOrVirtualBus bus) { + } + + public default void visitBusOrVirtualBusPostfix(BusOrVirtualBus bus) { + } + + public default void visitBusPrefix(final Bus bus) { + visitBusOrVirtualBusPrefix(bus); + } + + public default void visitBusPostfix(final Bus bus) { + visitBusOrVirtualBusPostfix(bus); + } + + public default void visitVirtualBusPrefix(final VirtualBus virtualBus) { + visitBusOrVirtualBusPrefix(virtualBus); + } + + public default void visitVirtualBusPostfix(final VirtualBus virtualBus) { + visitBusOrVirtualBusPostfix(virtualBus); + } + + public default void visitBroadcastPrefix(final Broadcast broadcast) { + } + + public default void visitBroadcastPostfix(final Broadcast broadcast) { + } + + // N.B. Leaf node + public default void visitConnection(Connection connection) { + } + + public default void visitConnectionEndPrefix(ConnectionEnd connEnd) { + visitConnectionEndPrefix(connEnd); + } + + public default void visitConnectionEndPostfix(ConnectionEnd connEnd) { + visitConnectionEndPostfix(connEnd); + } + + public default void visitFeaturePrefix(Feature feature) { + visitFeaturePrefix(feature); + } + + public default void visitFeaturePostfix(Feature feature) { + visitFeaturePostfix(feature); + } +} diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/AbstractLoggingAnalysis.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/AbstractLoggingAnalysis.java index 49de9bf39cc..d51a2cd10e9 100644 --- a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/AbstractLoggingAnalysis.java +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/AbstractLoggingAnalysis.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -23,25 +23,27 @@ */ package org.osate.analysis.resource.budgets.logic; +import org.osate.aadl2.UnitLiteral; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.ConnectionInstance; import org.osate.aadl2.instance.InstanceObject; import org.osate.ui.handlers.AbstractAaxlHandler; import org.osate.xtext.aadl2.properties.util.AadlProject; +import org.osate.xtext.aadl2.properties.util.GetProperties; abstract class AbstractLoggingAnalysis { private final boolean doDetailedLog = true; - + protected final AbstractAaxlHandler errManager; - + protected AbstractLoggingAnalysis(AbstractAaxlHandler handler) { errManager = handler; } - + protected void logHeader(String msg) { errManager.logInfo(msg); } - + protected void detailedLog(InstanceObject obj, double budget, double actual, String msg) { if (doDetailedLog) { String budgetmsg = budget + " " + AadlProject.KBYTESPS_LITERAL + ","; @@ -51,28 +53,28 @@ protected void detailedLog(InstanceObject obj, double budget, double actual, Str errManager.logInfo(objname + ", " + budgetmsg + actualmsg + msg); } } - + protected void detailedLog(String prefix, ComponentInstance ci, double budget, double actual, String resourceName, - Enum unit, String msg) { + UnitLiteral unit, String msg) { if (doDetailedLog) { - String budgetmsg = prefix + String.format("%.3f " + unit.name(), budget) + ","; - String actualmsg = prefix + String.format("%.3f " + unit.name(), actual) + ","; + String budgetmsg = prefix + GetProperties.toStringScaled(budget, unit) + ","; + String actualmsg = prefix + GetProperties.toStringScaled(actual, unit) + ","; errManager.logInfo(prefix + ci.getCategory().getName() + " " + ci.getComponentInstancePath() + ", " + budgetmsg + actualmsg + msg); } } - - protected void detailedLogTotal1(ComponentInstance ci, double budget, Enum unit) { + + protected void detailedLogTotal1(ComponentInstance ci, double budget, UnitLiteral unit) { if (doDetailedLog) { - String budgetmsg = String.format("%.3f " + unit.name(), budget) + ","; + String budgetmsg = GetProperties.toStringScaled(budget, unit) + ","; String front = ci == null ? "Total" : ci.getCategory().getName() + " " + ci.getComponentInstancePath(); errManager.logInfo(front + ", " + budgetmsg); } } - - protected void detailedLogTotal2(ComponentInstance ci, double budget, Enum unit) { + + protected void detailedLogTotal2(ComponentInstance ci, double budget, UnitLiteral unit) { if (doDetailedLog) { - String budgetmsg = String.format("%.3f " + unit.name() + ",", budget); + String budgetmsg = String.format("%.3f " + unit.getName() + ",", budget);// GetProperties.toStringScaled(budget, unit) + ","; String front = ci == null ? "Total" : ci.getCategory().getName() + " " + ci.getComponentInstancePath(); errManager.logInfo(front + ", ," + budgetmsg); } diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/AbstractResourceAnalysis.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/AbstractResourceAnalysis.java index b5a60aac797..597f87d9ccf 100644 --- a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/AbstractResourceAnalysis.java +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/AbstractResourceAnalysis.java @@ -28,22 +28,14 @@ import org.eclipse.emf.common.util.EList; import org.osate.aadl2.ComponentCategory; import org.osate.aadl2.NamedElement; -import org.osate.aadl2.contrib.aadlproject.SizeUnits; -import org.osate.aadl2.contrib.aadlproject.TimeUnits; -import org.osate.aadl2.contrib.timing.TimingProperties; -import org.osate.aadl2.contrib.util.AadlContribUtils; +import org.osate.aadl2.UnitLiteral; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.FeatureCategory; import org.osate.aadl2.instance.FeatureInstance; import org.osate.aadl2.instance.SystemInstance; import org.osate.aadl2.instance.SystemOperationMode; -import org.osate.contribution.sei.sei.Instructionvolumeunits; -import org.osate.contribution.sei.sei.ProcessorSpeedUnits; -import org.osate.contribution.sei.sei.Sei; -import org.osate.pluginsupport.properties.PropertyUtils; -import org.osate.pluginsupport.properties.RealRange; import org.osate.ui.handlers.AbstractAaxlHandler; -import org.osate.xtext.aadl2.properties.util.InstanceModelUtil; +import org.osate.xtext.aadl2.properties.util.GetProperties; abstract class AbstractResourceAnalysis extends AbstractLoggingAnalysis { private final String prefixSymbol = " "; @@ -71,7 +63,7 @@ protected enum ResourceKind { * @return double total, zero, if no budget, -1 if hardware only in * substructure */ - protected double sumBudgets(ComponentInstance ci, ResourceKind rk, final SystemOperationMode som, + protected double sumBudgets(ComponentInstance ci, ResourceKind rk, UnitLiteral unit, final SystemOperationMode som, String prefix) { if (!ci.isActive(som)) { return 0.0; @@ -92,7 +84,7 @@ protected double sumBudgets(ComponentInstance ci, ResourceKind rk, final SystemO } for (Iterator it = subcis.iterator(); it.hasNext();) { ComponentInstance subci = it.next(); - double subresult = sumBudgets(subci, rk, som, isSystemInstance ? "" : prefix + prefixSymbol); + double subresult = sumBudgets(subci, rk, unit, som, isSystemInstance ? "" : prefix + prefixSymbol); if (subresult >= 0) { HWOnly = false; subtotal += subresult; @@ -114,48 +106,46 @@ protected double sumBudgets(ComponentInstance ci, ResourceKind rk, final SystemO if (HWOnly) { return -1; } - - final Enum budgetUnit = rk == ResourceKind.MIPS ? ProcessorSpeedUnits.MIPS : SizeUnits.KBYTE; double budget = getBudget(ci, rk); if (rk.equals(ResourceKind.RAM) || rk.equals(ResourceKind.ROM) || rk.equals(ResourceKind.Memory)) { - double actualsize = getMemoryUseActual(ci, rk.name(), SizeUnits.KBYTE); + double actualsize = getMemoryUseActual(ci, rk.name(), unit); subtotal += actualsize; } String resourceName = ci.getCategory().getName(); String notes = ""; if (rk == ResourceKind.MIPS && ci.getCategory() == ComponentCategory.THREAD) { - subtotal = getThreadExecutioninMIPS(ci); + subtotal = GetProperties.getThreadExecutioninMIPS(ci); } components = components + subcount; budgetedComponents = budgetedComponents + subbudgetcount; if (budget > 0 && subtotal > budget) { - notes = String.format("Error: subtotal/actual exceeds budget %.3f by %.3f " + budgetUnit.name(), budget, + notes = String.format("Error: subtotal/actual exceeds budget %.3f by %.3f " + unit.getName(), budget, (subtotal - budget)); } else if (budget > 0 && subtotal < budget) { notes = String.format( - resourceName + " " + ci.getInstanceObjectPath() + " total %.3f " + budgetUnit.name() - + " below budget %.3f " + budgetUnit.name() + " (%.1f %% slack)", + resourceName + " " + ci.getInstanceObjectPath() + " total %.3f " + unit.getName() + + " below budget %.3f " + unit.getName() + " (%.1f %% slack)", subtotal, budget, (budget - subtotal) / budget * 100); } if (!isSystemInstance) { - detailedLog(prefix, ci, budget, subtotal, resourceName, budgetUnit, notes); + detailedLog(prefix, ci, budget, subtotal, resourceName, unit, notes); } return subtotal == 0 ? budget : subtotal; } - protected double getMemoryUseActual(final ComponentInstance bci, final String resourceName, final SizeUnits unit) { + protected double getMemoryUseActual(ComponentInstance bci, String resourceName, UnitLiteral unit) { double actualsize = 0.0; if (resourceName.equals("ROM")) { - actualsize = getCodeSize(bci, unit); + actualsize = GetProperties.getCodeSize(bci, unit); } else if (resourceName.equals("RAM")) { - actualsize = AadlContribUtils.getDataSize(bci, unit); - actualsize += getHeapSize(bci, unit); - actualsize += getStackSize(bci, unit); + actualsize = GetProperties.getDataSize(bci, unit); + actualsize += GetProperties.getHeapSize(bci, unit); + actualsize += GetProperties.getStackSize(bci, unit); } else { - actualsize = AadlContribUtils.getDataSize(bci, unit); - actualsize += getHeapSize(bci, unit); - actualsize += getStackSize(bci, unit); - actualsize += getCodeSize(bci, unit); + actualsize = GetProperties.getDataSize(bci, unit); + actualsize += GetProperties.getHeapSize(bci, unit); + actualsize += GetProperties.getStackSize(bci, unit); + actualsize += GetProperties.getCodeSize(bci, unit); } return actualsize; } @@ -163,14 +153,13 @@ protected double getMemoryUseActual(final ComponentInstance bci, final String re private double getBudget(NamedElement ne, ResourceKind kind) { switch (kind) { case MIPS: - return PropertyUtils.getScaled(Sei::getMipsbudget, ne, ProcessorSpeedUnits.MIPS).orElse(0.0); + return GetProperties.getMIPSBudgetInMIPS(ne, 0.0); case RAM: - return PropertyUtils.getScaled(Sei::getRambudget, ne, SizeUnits.KBYTE).orElse(0.0); + return GetProperties.getRAMBudgetInKB(ne, 0.0); case ROM: - return PropertyUtils.getScaled(Sei::getRombudget, ne, SizeUnits.KBYTE).orElse(0.0); + return GetProperties.getROMBudgetInKB(ne, 0.0); case Memory: - return PropertyUtils.getScaled(Sei::getRambudget, ne, SizeUnits.KBYTE).orElse(0.0) - + PropertyUtils.getScaled(Sei::getRombudget, ne, SizeUnits.KBYTE).orElse(0.0); + return GetProperties.getRAMBudgetInKB(ne, 0.0) + GetProperties.getROMBudgetInKB(ne, 0.0); } return 0.0; } @@ -193,75 +182,4 @@ private boolean isHardware(ComponentInstance ci) { } return false; } - - protected static double getHeapSize(final NamedElement ne, final SizeUnits unit) { - return org.osate.pluginsupport.properties.PropertyUtils - .getScaled(org.osate.aadl2.contrib.memory.MemoryProperties::getHeapSize, ne, unit) - .orElseGet(() -> org.osate.pluginsupport.properties.PropertyUtils - .getScaled(org.osate.aadl2.contrib.memory.MemoryProperties::getSourceHeapSize, ne, unit) - .orElse(0.0)); - } - - protected static double getStackSize(final NamedElement ne, final SizeUnits unit) { - return org.osate.pluginsupport.properties.PropertyUtils - .getScaled(org.osate.aadl2.contrib.memory.MemoryProperties::getStackSize, ne, unit) - .orElseGet(() -> org.osate.pluginsupport.properties.PropertyUtils - .getScaled(org.osate.aadl2.contrib.memory.MemoryProperties::getSourceStackSize, ne, unit) - .orElse(0.0)); - } - - protected static double getCodeSize(final NamedElement ne, final SizeUnits unit) { - return org.osate.pluginsupport.properties.PropertyUtils - .getScaled(org.osate.aadl2.contrib.memory.MemoryProperties::getCodeSize, ne, unit) - .orElseGet(() -> org.osate.pluginsupport.properties.PropertyUtils - .getScaled(org.osate.aadl2.contrib.memory.MemoryProperties::getSourceCodeSize, ne, unit) - .orElse(0.0)); - } - - protected static double getThreadExecutioninMIPS(ComponentInstance threadinstance) { - if (!InstanceModelUtil.isThread(threadinstance)) { - return 0; - } - double mips = getThreadExecutionIPDinMIPS(threadinstance); - if (mips == 0) { - double period = PropertyUtils.getScaled(TimingProperties::getPeriod, threadinstance, TimeUnits.SEC) - .orElse(0.0); - double exectimeval = PropertyUtils - .getScaledRange(TimingProperties::getComputeExecutionTime, threadinstance, TimeUnits.SEC) - .orElse(RealRange.ZEROED).getMaximum(); - if (exectimeval > 0 && period > 0) { - final ComponentInstance thread = threadinstance; - double mipspersec = TimingProperties.getReferenceProcessor(thread).map(pci -> getMIPSCapacityInMIPS(pci, 0.0)).orElse(0.0); - if (mipspersec == 0) { - mipspersec = getBoundPhysicalProcessorMIPS(threadinstance); - } - double time = exectimeval / period; - mips = time * mipspersec; - } - } - return mips; - } - - protected static double getThreadExecutionIPDinMIPS(final ComponentInstance threadinstance) { - final double period = PropertyUtils.getScaled(TimingProperties::getPeriod, threadinstance, TimeUnits.SEC) - .orElse(0.0); - final double mipd = PropertyUtils - .getScaledRange(Sei::getInstructionsperdispatch, threadinstance, Instructionvolumeunits.MIPD) - .orElse(RealRange.ZEROED).getMaximum(); - return (mipd > 0 && period > 0) ? mipd / period : 0.0; - } - - protected static double getBoundPhysicalProcessorMIPS(final ComponentInstance thread) { - final Iterator pcis = InstanceModelUtil.getBoundPhysicalProcessors(thread).iterator(); - return pcis.hasNext() ? getMIPSCapacityInMIPS(pcis.next(), 0.0) : 0.0; - } - - protected static double getMIPSCapacityInMIPS(final NamedElement ne, final double defaultValue) { - return PropertyUtils.getScaled(Sei::getMipscapacity, ne, ProcessorSpeedUnits.MIPS).orElseGet( - () -> PropertyUtils.getScaled( - TimingProperties::getProcessorCapacity, ne, - org.osate.aadl2.contrib.aadlproject.ProcessorSpeedUnits.MIPS). - orElse(defaultValue)); - } - } \ No newline at end of file diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/BoundResourceAnalysis.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/BoundResourceAnalysis.java index 196a505d023..83ecc6a25da 100644 --- a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/BoundResourceAnalysis.java +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/BoundResourceAnalysis.java @@ -23,7 +23,6 @@ */ package org.osate.analysis.resource.budgets.logic; -import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -34,9 +33,7 @@ import org.eclipse.emf.common.util.EList; import org.osate.aadl2.ComponentCategory; import org.osate.aadl2.Element; -import org.osate.aadl2.contrib.aadlproject.SizeUnits; -import org.osate.aadl2.contrib.deployment.DeploymentProperties; -import org.osate.aadl2.contrib.memory.MemoryProperties; +import org.osate.aadl2.UnitLiteral; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.InstanceObject; import org.osate.aadl2.instance.SystemInstance; @@ -45,11 +42,9 @@ import org.osate.aadl2.modelsupport.modeltraversal.SOMIterator; import org.osate.aadl2.properties.PropertyDoesNotApplyToHolderException; import org.osate.aadl2.util.Aadl2Util; -import org.osate.contribution.sei.sei.ProcessorSpeedUnits; -import org.osate.contribution.sei.sei.Sei; -import org.osate.pluginsupport.properties.PropertyUtils; import org.osate.ui.dialogs.Dialog; import org.osate.ui.handlers.AbstractAaxlHandler; +import org.osate.xtext.aadl2.properties.util.GetProperties; import org.osate.xtext.aadl2.properties.util.InstanceModelUtil; //TODO-LW: assumes connection ends are features @@ -146,17 +141,17 @@ private void checkProcessorLoad(ComponentInstance curProcessor, final SystemOper return; } - double MIPScapacity = getMIPSCapacityInMIPS(curProcessor, 0.0); + UnitLiteral mipsliteral = GetProperties.getMIPSUnitLiteral(curProcessor); + double MIPScapacity = GetProperties.getMIPSCapacityInMIPS(curProcessor, 0.0); if (MIPScapacity == 0 && InstanceModelUtil.isVirtualProcessor(curProcessor)) { - MIPScapacity = PropertyUtils.getScaled(Sei::getMipsbudget, curProcessor, ProcessorSpeedUnits.MIPS) - .orElse(0.0); + MIPScapacity = GetProperties.getMIPSBudgetInMIPS(curProcessor); } EList boundComponents = InstanceModelUtil.getBoundSWComponents(curProcessor); if (boundComponents.size() == 0 && MIPScapacity > 0) { errManager.infoSummary(curProcessor, som.getName(), "No application components bound to " + curProcessor.getComponentInstancePath() - + " with MIPS capacity " + toStringScaled(MIPScapacity, ProcessorSpeedUnits.MIPS)); + + " with MIPS capacity " + GetProperties.toStringScaled(MIPScapacity, mipsliteral)); return; } if (MIPScapacity == 0 && InstanceModelUtil.isVirtualProcessor(curProcessor)) { @@ -171,36 +166,36 @@ private void checkProcessorLoad(ComponentInstance curProcessor, final SystemOper if (InstanceModelUtil.isVirtualProcessor(curProcessor)) { logHeader("\n\nDetailed Workload Report: " + Aadl2Util.getPrintableSOMName(som) + " for Virtual Processor " + curProcessor.getComponentInstancePath() + " with Capacity " - + toStringScaled(MIPScapacity, ProcessorSpeedUnits.MIPS) + "\n\nComponent,Budget,Actual"); + + GetProperties.toStringScaled(MIPScapacity, mipsliteral) + "\n\nComponent,Budget,Actual"); } else { logHeader("\n\nDetailed Workload Report: " + Aadl2Util.getPrintableSOMName(som) + " for Processor " + curProcessor.getComponentInstancePath() + " with Capacity " - + toStringScaled(MIPScapacity, ProcessorSpeedUnits.MIPS) + "\n\nComponent,Budget,Actual"); + + GetProperties.toStringScaled(MIPScapacity, mipsliteral) + "\n\nComponent,Budget,Actual"); } double totalMIPS = 0.0; for (Iterator it = boundComponents.iterator(); it.hasNext();) { ComponentInstance bci = it.next(); - double actualmips = sumBudgets(bci, ResourceKind.MIPS, som, ""); + double actualmips = sumBudgets(bci, ResourceKind.MIPS, mipsliteral, som, ""); if (actualmips > 0) { totalMIPS += actualmips; } } - logHeader("Total,," + toStringScaled(totalMIPS, ProcessorSpeedUnits.MIPS)); + logHeader("Total,," + GetProperties.toStringScaled(totalMIPS, mipsliteral)); if (totalMIPS > MIPScapacity) { errManager.errorSummary(curProcessor, null, " Processor " + curProcessor.getComponentInstancePath() + ": Total MIPS " - + toStringScaled(totalMIPS, ProcessorSpeedUnits.MIPS) + + GetProperties.toStringScaled(totalMIPS, mipsliteral) + " of bound tasks exceeds MIPS capacity " - + toStringScaled(MIPScapacity, ProcessorSpeedUnits.MIPS)); + + GetProperties.toStringScaled(MIPScapacity, mipsliteral)); } else if (totalMIPS == 0.0) { errManager.warningSummary(curProcessor, null, " Processor " + curProcessor.getComponentInstancePath() + ": Bound app's have no MIPS budget."); } else { errManager.infoSummary(curProcessor, null, " Processor " + curProcessor.getComponentInstancePath() + ": Total MIPS " - + toStringScaled(totalMIPS, ProcessorSpeedUnits.MIPS) + " of bound tasks within " - + "MIPS capacity " + toStringScaled(MIPScapacity, ProcessorSpeedUnits.MIPS) + " of " + + GetProperties.toStringScaled(totalMIPS, mipsliteral) + " of bound tasks within " + + "MIPS capacity " + GetProperties.toStringScaled(MIPScapacity, mipsliteral) + " of " + curProcessor.getComponentInstancePath()); } } @@ -223,9 +218,9 @@ private void checkMemoryLoads(SystemInstance si, final SystemOperationMode som) @Override protected void process(Element obj) { if (canHaveMemory(obj)) { - if (getROMCapacityInKB(obj) > 0.0 - || getRAMCapacityInKB(obj) > 0.0 - || getMemorySize(obj) > 0.0) { + if (GetProperties.getROMCapacityInKB((InstanceObject) obj, 0.0) > 0.0 + || GetProperties.getRAMCapacityInKB((InstanceObject) obj, 0.0) > 0.0 + || GetProperties.getMemorySizeInKB((InstanceObject) obj) > 0.0) { count = count + 1; } } @@ -257,10 +252,11 @@ protected void process(Element obj) { * @param curMemory Component Instance of memory */ private void checkMemoryLoad(ComponentInstance curMemory, final SystemOperationMode som) { + UnitLiteral kbliteral = GetProperties.getKBUnitLiteral(curMemory); EList boundComponents = getMemoryBindings(curMemory); - final double MemoryCapacity = getMemorySize(curMemory); - final double ROMCapacity = getROMCapacityInKB(curMemory); - final double RAMCapacity = getRAMCapacityInKB(curMemory); + double MemoryCapacity = GetProperties.getMemorySize(curMemory, kbliteral); + double ROMCapacity = GetProperties.getROMCapacityInKB(curMemory, 0.0); + double RAMCapacity = GetProperties.getRAMCapacityInKB(curMemory, 0.0); if (MemoryCapacity > 0.0) { doMemoryLoad(curMemory, som, MemoryCapacity, boundComponents, ResourceKind.Memory); // Memory @@ -285,10 +281,11 @@ private void doMemoryLoad(ComponentInstance curMemory, final SystemOperationMode String somName = null; String resourceName = rk.name(); boolean isROM = rk.equals(ResourceKind.ROM); + UnitLiteral kbliteral = GetProperties.getKBUnitLiteral(curMemory); if (boundComponents.size() == 0 && Memorycapacity > 0) { errManager.infoSummary(curMemory, somName, " No application components bound to " + curMemory.getComponentInstancePath() + " with " - + resourceName + " capacity " + toStringScaled(Memorycapacity, SizeUnits.KBYTE)); + + resourceName + " capacity " + GetProperties.toStringScaled(Memorycapacity, kbliteral)); return; } if (Memorycapacity == 0) { @@ -297,13 +294,13 @@ private void doMemoryLoad(ComponentInstance curMemory, final SystemOperationMode } logHeader("\n\nDetailed Workload Report: " + Aadl2Util.getPrintableSOMName(som) + " for memory " + curMemory.getComponentInstancePath() + " with Capacity " - + toStringScaled(Memorycapacity, SizeUnits.KBYTE) + "\n\nComponent,Budget,Actual"); + + GetProperties.toStringScaled(Memorycapacity, kbliteral) + "\n\nComponent,Budget,Actual"); Set budgeted = new HashSet<>(); for (ComponentInstance bci : boundComponents) { String notes = ""; double totalactual = sumMemoryActualPropertyValue(bci, isROM); - double budget = isROM ? getROMBudgetInKB(bci) : getRAMBudgetInKB(bci); - double actualsize = getMemoryUseActual(bci, resourceName, SizeUnits.KBYTE); + double budget = isROM ? GetProperties.getROMBudgetInKB(bci, 0.0) : GetProperties.getRAMBudgetInKB(bci, 0.0); + double actualsize = getMemoryUseActual(bci, resourceName, kbliteral); if (actualsize > 0) { // only compare if there were actuals @@ -343,13 +340,14 @@ private void doMemoryLoad(ComponentInstance curMemory, final SystemOperationMode totalMemory += actualsize; } else { // add only the current actual; the children actual have been added before - double currentActual = isROM ? getROMActualInKB(bci) : getRAMActualInKB(bci); + double currentActual = isROM ? GetProperties.getROMActualInKB(bci, 0.0) + : GetProperties.getRAMActualInKB(bci, 0.0); detailedLog(bci, budget, currentActual, notes); totalMemory += currentActual; } } } - detailedLogTotal2(null, totalMemory, SizeUnits.KBYTE); + detailedLogTotal2(null, totalMemory, kbliteral); if (Memorycapacity == 0) { errManager.errorSummary(curMemory, somName, " " + resourceName + curMemory.getComponentInstancePath() + " has no memory capacity specified"); @@ -370,7 +368,7 @@ private void doMemoryLoad(ComponentInstance curMemory, final SystemOperationMode private double sumMemoryActualPropertyValue(ComponentInstance ci, boolean isROM) { try { - double total = isROM ? getROMActualInKB(ci) : getRAMActualInKB(ci); + double total = isROM ? GetProperties.getROMActualInKB(ci, 0.0) : GetProperties.getRAMActualInKB(ci, 0.0); EList subcis = ci.getComponentInstances(); for (Iterator it = subcis.iterator(); it.hasNext();) { ComponentInstance subci = it.next(); @@ -403,8 +401,8 @@ private static EList getMemoryBindings(final ComponentInstanc boundComponents = new ForAllElement() { @Override protected boolean suchThat(Element obj) { - final List boundMemoryList = DeploymentProperties - .getActualMemoryBinding((ComponentInstance) obj).orElse(Collections.emptyList()); + List boundMemoryList = GetProperties + .getActualMemoryBinding((ComponentInstance) obj); if (boundMemoryList.isEmpty()) { return false; } @@ -422,37 +420,4 @@ protected boolean suchThat(Element obj) { } return topobjects; } - - private static double getROMCapacityInKB(Element obj) { - return PropertyUtils.getScaled(Sei::getRomcapacity, (InstanceObject) obj, SizeUnits.KBYTE).orElse(0.0); - } - - private static double getRAMCapacityInKB(Element obj) { - return PropertyUtils.getScaled(Sei::getRamcapacity, (InstanceObject) obj, SizeUnits.KBYTE).orElse(0.0); - } - - private static double getROMBudgetInKB(Element obj) { - return PropertyUtils.getScaled(Sei::getRombudget, (InstanceObject) obj, SizeUnits.KBYTE).orElse(0.0); - } - - private static double getRAMBudgetInKB(Element obj) { - return PropertyUtils.getScaled(Sei::getRambudget, (InstanceObject) obj, SizeUnits.KBYTE).orElse(0.0); - } - - private static double getROMActualInKB(Element obj) { - return PropertyUtils.getScaled(Sei::getRomactual, (InstanceObject) obj, SizeUnits.KBYTE).orElse(0.0); - } - - private static double getRAMActualInKB(Element obj) { - return PropertyUtils.getScaled(Sei::getRamactual, (InstanceObject) obj, SizeUnits.KBYTE).orElse(0.0); - } - - private static double getMemorySize(Element obj) { - return PropertyUtils.getScaled(MemoryProperties::getMemorySize, (InstanceObject) obj, SizeUnits.KBYTE) - .orElse(0.0); - } - - private static String toStringScaled(double d, Enum u) { - return String.format("%.3f " + u.name(), d); - } } \ No newline at end of file diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/BusLoadAnalysis.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/BusLoadAnalysis.java index 27ce3038b93..74005d0413d 100644 --- a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/BusLoadAnalysis.java +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/BusLoadAnalysis.java @@ -32,8 +32,6 @@ import org.osate.aadl2.ComponentCategory; import org.osate.aadl2.Element; import org.osate.aadl2.UnitLiteral; -import org.osate.aadl2.contrib.aadlproject.SizeUnits; -import org.osate.aadl2.contrib.util.AadlContribUtils; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.ConnectionInstance; import org.osate.aadl2.instance.ConnectionInstanceEnd; @@ -209,7 +207,7 @@ private void checkBandWidthLoad(final ComponentInstance curBus, SystemOperationM } } - detailedLogTotal2(null, totalBandWidth, SizeUnits.KBYTE); + detailedLogTotal2(null, totalBandWidth, kbspsliteral); if (totalBandWidth > busCapacityOrBudget) { errManager.errorSummary(curBus, null, curBus.getComponentInstancePath() + " bandwidth capacity " + busCapacityOrBudget + " " @@ -259,7 +257,7 @@ private double calcBandwidthKBytesps(ConnectionInstanceEnd cie) { // TODO-LW add other cases if (cie instanceof FeatureInstance) { FeatureInstance fi = (FeatureInstance) cie; - double datasize = AadlContribUtils.getDataSize(fi, SizeUnits.KBYTE); + double datasize = GetProperties.getSourceDataSize(fi, GetProperties.getKBUnitLiteral(fi)); double srcRate = GetProperties.getOutgoingMessageRatePerSecond(fi); res = datasize * srcRate; EList fil = fi.getFeatureInstances(); diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/GenericAnalysis.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/GenericAnalysis.java new file mode 100644 index 00000000000..76b15cf77ff --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/GenericAnalysis.java @@ -0,0 +1,21 @@ +package org.osate.analysis.resource.budgets.logic; + +import org.osate.aadl2.instance.InstanceObject; +import org.osate.result.DiagnosticType; +import org.osate.result.Result; +import org.osate.result.util.ResultUtil; + +/** + * @since 4.1 + */ +public class GenericAnalysis { + // ==== Error reporting methods for the visitor === + + public static void error(final Result result, final InstanceObject io, final String msg) { + result.getDiagnostics().add(ResultUtil.createDiagnostic(msg, io, DiagnosticType.ERROR)); + } + + public static void warning(final Result result, final InstanceObject io, final String msg) { + result.getDiagnostics().add(ResultUtil.createDiagnostic(msg, io, DiagnosticType.WARNING)); + } +} \ No newline at end of file diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/NotBoundResourceAnalysis.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/NotBoundResourceAnalysis.java index a4804808894..fd08601cbeb 100644 --- a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/NotBoundResourceAnalysis.java +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/logic/NotBoundResourceAnalysis.java @@ -27,18 +27,14 @@ import org.eclipse.emf.common.util.EList; import org.osate.aadl2.ComponentCategory; -import org.osate.aadl2.NamedElement; -import org.osate.aadl2.contrib.aadlproject.SizeUnits; -import org.osate.aadl2.contrib.memory.MemoryProperties; +import org.osate.aadl2.UnitLiteral; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.SystemInstance; import org.osate.aadl2.instance.SystemOperationMode; import org.osate.aadl2.modelsupport.modeltraversal.ForAllElement; import org.osate.aadl2.util.Aadl2Util; -import org.osate.contribution.sei.sei.ProcessorSpeedUnits; -import org.osate.contribution.sei.sei.Sei; -import org.osate.pluginsupport.properties.PropertyUtils; import org.osate.ui.handlers.AbstractAaxlHandler; +import org.osate.xtext.aadl2.properties.util.GetProperties; /** * @since 2.0 @@ -56,13 +52,15 @@ public NotBoundResourceAnalysis(AbstractAaxlHandler handler) { public void analyzeResourceBudget(final SystemInstance si, final SystemOperationMode som) { init(); + UnitLiteral kbliteral = GetProperties.getKBUnitLiteral(si); + UnitLiteral mipsliteral = GetProperties.getMIPSUnitLiteral(si); @SuppressWarnings("unchecked") EList proclist = (EList) (EList) new ForAllElement() .processPreOrderComponentInstance(si, ComponentCategory.PROCESSOR); logHeader("\n\nDetailed Processor MIPS Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n"); logHeader("Component,Capacity"); - capacity = sumCapacity(proclist, ResourceKind.MIPS, "processor", ProcessorSpeedUnits.MIPS); - detailedLogTotal1(null, capacity, ProcessorSpeedUnits.MIPS); + capacity = sumCapacity(proclist, ResourceKind.MIPS, "processor", mipsliteral); + detailedLogTotal1(null, capacity, mipsliteral); @SuppressWarnings("unchecked") EList vproclist = (EList) (EList) new ForAllElement() .processPreOrderComponentInstance(si, ComponentCategory.VIRTUAL_PROCESSOR); @@ -70,66 +68,66 @@ public void analyzeResourceBudget(final SystemInstance si, final SystemOperation logHeader( "\n\nDetailed Virtual Processor MIPS Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n"); logHeader("Component,Capacity"); - vcapacity = sumVPMIPSBudget(vproclist); - detailedLogTotal1(null, vcapacity, ProcessorSpeedUnits.MIPS); + vcapacity = sumVPMIPSBudget(vproclist, mipsliteral); + detailedLogTotal1(null, vcapacity, mipsliteral); } logHeader("\n\nDetailed MIPS Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n"); logHeader("Component,Budget,Actual,Notes"); - budgetTotal = sumBudgets(si, ResourceKind.MIPS, som, ""); + budgetTotal = sumBudgets(si, ResourceKind.MIPS, mipsliteral, som, ""); if (budgetTotal >= 0) { - detailedLogTotal2(null, budgetTotal, ProcessorSpeedUnits.MIPS); + detailedLogTotal2(null, budgetTotal, mipsliteral); errManager.infoSummaryReportOnly(si, null, "Resource Summary: " + Aadl2Util.getPrintableSOMName(som)); - report(si, "MIPS", ProcessorSpeedUnits.MIPS, som); + report(si, "MIPS", mipsliteral, som); } init(); @SuppressWarnings("unchecked") EList memlist = (EList) (EList) new ForAllElement() .processPreOrderComponentInstance(si, ComponentCategory.MEMORY); - capacity = capacityTotal(memlist, ResourceKind.Memory, "Memory"); + capacity = capacityTotal(memlist, ResourceKind.Memory, "Memory", kbliteral); if (capacity > 0) { logHeader("\n\nDetailed Memory Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n"); logHeader("Component,Capacity"); - capacity = sumCapacity(memlist, ResourceKind.Memory, "Memory", SizeUnits.KBYTE); - detailedLogTotal1(null, capacity, SizeUnits.KBYTE); + capacity = sumCapacity(memlist, ResourceKind.Memory, "Memory", kbliteral); + detailedLogTotal1(null, capacity, kbliteral); logHeader("\n\nDetailed Memory Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n"); logHeader("Component,Budget,Actual,Notes"); - budgetTotal = sumBudgets(si, ResourceKind.Memory, som, ""); + budgetTotal = sumBudgets(si, ResourceKind.Memory, kbliteral, som, ""); if (budgetTotal >= 0) { - detailedLogTotal2(null, budgetTotal, SizeUnits.KBYTE); - report(si, "Memory", SizeUnits.KBYTE, som); + detailedLogTotal2(null, budgetTotal, kbliteral); + report(si, "Memory", kbliteral, som); } } init(); - capacity = capacityTotal(memlist, ResourceKind.RAM, "RAM"); + capacity = capacityTotal(memlist, ResourceKind.RAM, "RAM", kbliteral); if (capacity > 0) { logHeader("\n\nDetailed RAM Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n"); logHeader("Component,Capacity"); - capacity = sumCapacity(memlist, ResourceKind.RAM, "RAM", SizeUnits.KBYTE); - detailedLogTotal1(null, capacity, SizeUnits.KBYTE); + capacity = sumCapacity(memlist, ResourceKind.RAM, "RAM", kbliteral); + detailedLogTotal1(null, capacity, kbliteral); logHeader("\n\nDetailed RAM Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n"); logHeader("Component,Budget,Actual,Notes"); - budgetTotal = sumBudgets(si, ResourceKind.RAM, som, ""); + budgetTotal = sumBudgets(si, ResourceKind.RAM, kbliteral, som, ""); if (budgetTotal >= 0) { - detailedLogTotal2(null, budgetTotal, SizeUnits.KBYTE); - report(si, "RAM", SizeUnits.KBYTE, som); + detailedLogTotal2(null, budgetTotal, kbliteral); + report(si, "RAM", kbliteral, som); } } init(); - capacity = capacityTotal(memlist, ResourceKind.ROM, "ROM"); + capacity = capacityTotal(memlist, ResourceKind.ROM, "ROM", kbliteral); if (capacity > 0) { logHeader("\n\nDetailed ROM Capacity Report " + Aadl2Util.getPrintableSOMName(som) + "\n"); logHeader("Component,Capacity"); - capacity = sumCapacity(memlist, ResourceKind.ROM, "ROM", SizeUnits.KBYTE); - detailedLogTotal1(null, capacity, SizeUnits.KBYTE); + capacity = sumCapacity(memlist, ResourceKind.ROM, "ROM", kbliteral); + detailedLogTotal1(null, capacity, kbliteral); logHeader("\n\nDetailed ROM Budget Report " + Aadl2Util.getPrintableSOMName(som) + "\n"); logHeader("Component,Budget,Actual,Notes"); - budgetTotal = sumBudgets(si, ResourceKind.ROM, som, ""); + budgetTotal = sumBudgets(si, ResourceKind.ROM, kbliteral, som, ""); if (budgetTotal >= 0) { - detailedLogTotal2(null, budgetTotal, SizeUnits.KBYTE); - report(si, "ROM", SizeUnits.KBYTE, som); + detailedLogTotal2(null, budgetTotal, kbliteral); + report(si, "ROM", kbliteral, som); } } } @@ -143,40 +141,40 @@ private void init() { budgetTotal = 0; } - private double getCapacity(ComponentInstance ne, ResourceKind kind) { + private double getCapacity(ComponentInstance ne, ResourceKind kind, UnitLiteral unit) { switch (kind) { case MIPS: if (ne.getCategory().equals(ComponentCategory.PROCESSOR)) { - return getProcessorMIPS(ne); + return GetProperties.getProcessorMIPS(ne); } if (ne.getCategory().equals(ComponentCategory.VIRTUAL_PROCESSOR)) { - return PropertyUtils.getScaled(Sei::getMipsbudget, ne, ProcessorSpeedUnits.MIPS).orElse(0.0); + return GetProperties.getMIPSBudgetInMIPS(ne); } case RAM: - return PropertyUtils.getScaled(Sei::getRamcapacity, ne, SizeUnits.KBYTE).orElse(0.0); + return GetProperties.getRAMCapacityInKB(ne, 0.0); case ROM: - return PropertyUtils.getScaled(Sei::getRomcapacity, ne, SizeUnits.KBYTE).orElse(0.0); + return GetProperties.getROMCapacityInKB(ne, 0.0); case Memory: - return PropertyUtils.getScaled(MemoryProperties::getMemorySize, ne, SizeUnits.KBYTE).orElse(0.0); + return GetProperties.getMemorySize(ne, unit); } return 0.0; } - private double sumVPMIPSBudget(EList ilist) { + private double sumVPMIPSBudget(EList ilist, UnitLiteral unit) { double total = 0.0; for (Iterator it = ilist.iterator(); it.hasNext();) { ComponentInstance io = it.next(); - double budget = PropertyUtils.getScaled(Sei::getMipsbudget, io, ProcessorSpeedUnits.MIPS).orElse(0.0); + double budget = GetProperties.getMIPSBudgetInMIPS(io); total += budget; - detailedLogTotal2(io, budget, ProcessorSpeedUnits.MIPS); + detailedLogTotal2(io, budget, unit); } return total; } - private double sumCapacity(EList ilist, ResourceKind rk, String resourceName, Enum unit) { + private double sumCapacity(EList ilist, ResourceKind rk, String resourceName, UnitLiteral unit) { double total = 0.0; for (ComponentInstance io : ilist) { - double capacity = getCapacity(io, rk); + double capacity = getCapacity(io, rk, unit); total += capacity; detailedLogTotal1(io, capacity, unit); resources++; @@ -187,10 +185,11 @@ private double sumCapacity(EList ilist, ResourceKind rk, Stri return total; } - private double capacityTotal(EList ilist, ResourceKind rk, String resourceName) { + private double capacityTotal(EList ilist, ResourceKind rk, String resourceName, + UnitLiteral unit) { double total = 0.0; for (ComponentInstance io : ilist) { - double capacity = getCapacity(io, rk); + double capacity = getCapacity(io, rk, unit); total += capacity; resources++; if (capacity > 0) { @@ -200,14 +199,14 @@ private double capacityTotal(EList ilist, ResourceKind rk, St return total; } - private void report(SystemInstance si, String resourceName, Enum unit, final SystemOperationMode som) { + private void report(SystemInstance si, String resourceName, UnitLiteral unit, final SystemOperationMode som) { String somName = Aadl2Util.getPrintableSOMName(som); if (budgetTotal < 0) { budgetTotal = 0; } - String modelStats = resourceName + " capacity " + String.format("%.3f " + unit.name(), capacity) + " : " - + resourceName + " budget " + String.format("%.3f " + unit.name(), budgetTotal); + String modelStats = resourceName + " capacity " + GetProperties.toStringScaled(capacity, unit) + " : " + + resourceName + " budget " + GetProperties.toStringScaled(budgetTotal, unit); if (budgetTotal > capacity) { modelStats = "System " + si.getName() + " budgets over capacity: " + modelStats; errManager.errorSummary(si, somName, " " + modelStats); @@ -227,10 +226,4 @@ private void report(SystemInstance si, String resourceName, Enum unit, final errManager.infoSummary(si, somName, modelStats); } } - - private static double getProcessorMIPS(final NamedElement ne) { - return PropertyUtils.getScaled(Sei::getMipscapacity, ne, ProcessorSpeedUnits.MIPS).orElseGet( - () -> PropertyUtils.getScaled(org.osate.aadl2.contrib.timing.TimingProperties::getProcessorCapacity, ne, - org.osate.aadl2.contrib.aadlproject.ProcessorSpeedUnits.MIPS).orElse(0.0)); - } } \ No newline at end of file diff --git a/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/power/PowerRequirementAnalysis.java b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/power/PowerRequirementAnalysis.java new file mode 100644 index 00000000000..fe716d60205 --- /dev/null +++ b/analyses/org.osate.analysis.resource.budgets/src/org/osate/analysis/resource/budgets/power/PowerRequirementAnalysis.java @@ -0,0 +1,385 @@ +/** + * Copyright (c) 2004-2020 Carnegie Mellon University and others. (see Contributors file). + * All Rights Reserved. + * + * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY + * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE + * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT + * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. + * + * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * SPDX-License-Identifier: EPL-2.0 + * + * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). + * + * This program includes and/or can make use of certain third party source code, object code, documentation and other + * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system + * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and + * conditions contained in any such Third Party Software or separate license file distributed with such Third Party + * Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici- + * aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li- + * censes only apply to the Third Party Software and not any other portion of this program or this program as a whole. + */ +package org.osate.analysis.resource.budgets.power; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.common.util.EList; +import org.osate.aadl2.Element; +import org.osate.aadl2.instance.ComponentInstance; +import org.osate.aadl2.instance.ConnectionInstanceEnd; +import org.osate.aadl2.instance.FeatureInstance; +import org.osate.aadl2.instance.InstanceObject; +import org.osate.aadl2.instance.SystemInstance; +import org.osate.aadl2.instance.SystemOperationMode; +import org.osate.aadl2.modelsupport.AadlConstants; +import org.osate.aadl2.modelsupport.errorreporting.AnalysisErrorReporterManager; +import org.osate.aadl2.modelsupport.errorreporting.MarkerAnalysisErrorReporter; +import org.osate.aadl2.modelsupport.modeltraversal.SOMIterator; +import org.osate.aadl2.util.Aadl2Util; +import org.osate.analysis.resource.budgets.internal.busload.model.ConnectionEnd; +import org.osate.analysis.resource.budgets.internal.busload.model.Feature; +import org.osate.analysis.resource.budgets.internal.busload.model.PowerRequirementModel; +import org.osate.analysis.resource.budgets.internal.busload.model.Visitor; +import org.osate.analysis.resource.budgets.logic.GenericAnalysis; +import org.osate.result.AnalysisResult; +import org.osate.result.Result; +import org.osate.result.ResultType; +import org.osate.result.util.ResultUtil; +import org.osate.ui.dialogs.Dialog; + +/** + * Class for performing "power requirements" analysis on a system. Basically it makes sure the selected system + * has enough actual capacity to fulfill the power demand. + * + *

The format for the returned {@code AnalysisResult} object is as follows: + * + *

For the {@code AnalysisResult} object itself: + *

    + *
  • analysis = "Power Requirements" + *
  • modelElement = {@code SystemInstance} being analyzed + *
  • resultType = SUCCESS + *
  • message = "Power requirements analysis of ..." + *
  • diagnostics = empty list + *
  • parameters = empty list + *
  • results = one {@code Result} for each system operation mode + *
      + *
    • modelElement = {@code SystemOperationMode} instance object + *
    • resultType = SUCCESS + *
    • message = empty string + *
    • values = empty list + *
    • diagnostics = empty list + *
    • subResults = one {@code Result} for each {@code ComponentInstance} with category of {@code Feature} or {@code ConnectionEnd} + *
        + *
      • modelElement = {@code Feature} or {@code ConnectionEnd} instance object + *
      • resultType = SUCCESS + *
      • message = The component's name from {@link ComponentInstance#getName()} + *
      • values[0] = The budget of {@code Feature} or {@code ConnectionEnd} instance object (power provided by this component) (RealValue) + *
      • values[1] = The supply in form of power budget drawn from other supply. This could be a requires bus access, or an incoming abstract feature. There must be a connection on this feature (RealValue) + *
      • values[2] = The capacity of the power supplier system in W as specified by SEI::PowerCapacity property (RealValue) + *
      • values[3] = Total Budget across the whole system (RealValue) + *
      • values[4] = Total Supply across the whole system (RealValue) + *
      • values[5] = components that represent a power system with capacity (StringValue) + *
      • values[6] = "System name ..." (StringValue) + *
      • values[7] = {@code Feature} or {@code ConnectionEnd} instance's name (StringValue) + *
      • values[8] = "Budget ... for ... out of total ..." (StringValue) + *
      • values[9] = "Supply ... for ... out of total ..." (StringValue) + *
      • values[10] = "Total capacity: ..." (StringValue) + *
      • diagnostics = Diagnostics associated with this {@code Feature} or {@code ConnectionEnd} instance object + *
      • subResults is empty + *
      + *
    + *
+ * + * @since 4.1 + */ + +public class PowerRequirementAnalysis extends GenericAnalysis { + private static final String INITIAL_MODE_LABEL = "Initial Mode"; + private static final String CHOOSE_MODE_LABEL = "Choose Mode..."; + private static final String ALL_MODES_LABEL = "All Modes"; + + private static final String[] ALL_MODE_CHOICE_LABELS = { INITIAL_MODE_LABEL, CHOOSE_MODE_LABEL, ALL_MODES_LABEL }; + + private static final int INITIAL_MODE = 0; + private static final int CHOOSE_MODE = 1; + + private static final int DEFAULT_MODE_CHOICE = INITIAL_MODE; + + private int lastDefaultModeChoice = DEFAULT_MODE_CHOICE; + + public PowerRequirementAnalysis() { + super(); + } + + public AnalysisResult invoke(final IProgressMonitor monitor, final SystemInstance systemInstance) { + final IProgressMonitor pm = monitor == null ? new NullProgressMonitor() : monitor; + return analyzeBody(pm, systemInstance); + } + + private AnalysisResult analyzeBody(final IProgressMonitor monitor, final Element obj) { + if (obj instanceof InstanceObject) { + final SystemInstance root = ((InstanceObject) obj).getSystemInstance(); + + final AnalysisResult analysisResult = ResultUtil.createAnalysisResult("Power Requirements", root); + analysisResult.setResultType(ResultType.SUCCESS); + analysisResult.setMessage("Power requirements analysis of " + root.getFullName()); + + final SystemInstance si = root; + final int whichMode; + + if (si.getSystemOperationModes().size() > 1) { + whichMode = Dialog.askQuestion("Choose Mode", + "Please choose in which mode(s) the model should be analyzed.", ALL_MODE_CHOICE_LABELS, + lastDefaultModeChoice); + } else { + // A system with no modes still has at least one SOM named NORMAL_SOM_NAME aka "no modes" + whichMode = INITIAL_MODE; + } + + if (whichMode != -1) { + lastDefaultModeChoice = whichMode; + + SystemOperationMode chosenSOM = null; + if (!si.getSystemOperationModes().isEmpty()) { + // the SOM list should not be empty + if (whichMode == INITIAL_MODE) { + // this may also be "No Modes" aka NORMAL_SOM_NAME + chosenSOM = si.getInitialSystemOperationMode(); + } else if (whichMode == CHOOSE_MODE) { + List ar = new ArrayList(); + si.getSystemOperationModes().forEach((som) -> ar.add(som.getFullName())); + int choosen = Dialog.askQuestion("Choose Mode", + "Please choose in which mode(s) the model should be analyzed.", + ar.toArray(new String[ar.size()]), + lastDefaultModeChoice); + + chosenSOM = si.getSystemOperationModes().get(choosen); + } + } + + final AnalysisErrorReporterManager errManager = new AnalysisErrorReporterManager( + new MarkerAnalysisErrorReporter.Factory(AadlConstants.AADLOBJECTMARKER)); + if (chosenSOM != null) { + final Result somResult = ResultUtil.createResult( + Aadl2Util.isPrintableSOMName(chosenSOM) ? Aadl2Util.getPrintableSOMMembers(chosenSOM) : "", + chosenSOM, ResultType.SUCCESS); + analysisResult.getResults().add(somResult); + + final PowerRequirementModel model = PowerRequirementModel.buildModel(root, chosenSOM); + + // Analyze the model + model.visit(new PowerRequirementAnalysisVisitor(somResult, model.getTotalCapacity(), + model.getTotalBudget(), model.getTotalSupply(), model.getSystemSOMname(), + model.getComponentName())); + } else { + final SOMIterator soms = new SOMIterator(si); + while (soms.hasNext()) { + final SystemOperationMode som = soms.nextSOM(); + final Result somResult = ResultUtil.createResult( + Aadl2Util.isPrintableSOMName(som) ? Aadl2Util.getPrintableSOMMembers(som) : "", som, + ResultType.SUCCESS); + analysisResult.getResults().add(somResult); + + final PowerRequirementModel model = PowerRequirementModel.buildModel(root, som); + + // Analyze the model + model.visit(new PowerRequirementAnalysisVisitor(somResult, model.getTotalCapacity(), + model.getTotalBudget(), model.getTotalSupply(), model.getSystemSOMname(), + model.getComponentName())); + } + } + } + + monitor.done(); + + return analysisResult; + } else { + Dialog.showError("Power Requirements Analysis Error", "Can only check system instances"); + return null; + } + } + + // ==== Analysis Visitor ==== + + private class PowerRequirementAnalysisVisitor implements Visitor { + private Result currentResult; + + private final double capacity, tBudget, tSupply; + private final String systemSOMname, componentName; + + public PowerRequirementAnalysisVisitor(final Result rootResult, double capacity, double budget, double supply, + String systemSOMname, String componentName) { + this.currentResult = rootResult; + this.capacity = capacity; + this.tBudget = budget; + this.tSupply = supply; + this.systemSOMname = systemSOMname; + this.componentName = componentName; + } + + @Override + public void visitConnectionEndPrefix(final ConnectionEnd connEnd) { + final ConnectionInstanceEnd connInstanceEnd = connEnd.getConnectionInstanceEnd(); + + // Create a new result object for the connection end + final Result connEndResult = ResultUtil.createResult(connInstanceEnd.getName() + connEnd.getID().toString(), + connInstanceEnd, + ResultType.SUCCESS); + + currentResult.getSubResults().add(connEndResult); + } + + @Override + public void visitConnectionEndPostfix(final ConnectionEnd connEnd) { + // unroll the result stack + + EList results = currentResult.getSubResults(); + String visitConnEndID = connEnd.getID().toString(); + + results.forEach(result -> { + String msg = result.getMessage(); + + if (msg.contains(visitConnEndID)) { + result.setMessage(msg.replaceAll(visitConnEndID, "")); + + double budget = connEnd.getBudget(); + double supply = connEnd.getSupply(); + String name = connEnd.getConnectionInstanceEnd().getContainingComponentInstance().getName(); + + ResultUtil.addRealValue(result, budget); + ResultUtil.addRealValue(result, supply); + ResultUtil.addRealValue(result, capacity); + ResultUtil.addRealValue(result, tBudget); + ResultUtil.addRealValue(result, tSupply); + + ResultUtil.addStringValue(result, this.componentName); + ResultUtil.addStringValue(result, "System name " + this.systemSOMname); + ResultUtil.addStringValue(result, name); + + String stBudget = PowerRequirementAnalysis.toString(tBudget); + + ResultUtil.addStringValue(result, + "Budget " + PowerRequirementAnalysis.toString(budget) + " for " + name + + " out of total " + stBudget); + + ResultUtil.addStringValue(result, + "Supply " + PowerRequirementAnalysis.toString(supply) + " from " + name + + " out of total " + PowerRequirementAnalysis.toString(tSupply)); + + String stCapacity = PowerRequirementAnalysis.toString(capacity); + + ResultUtil.addStringValue(result, "Total capacity: " + stCapacity); + + // diagnostics -> markers + final ConnectionInstanceEnd connEndInstance = connEnd.getConnectionInstanceEnd(); + + if (capacity > 0.0 && tBudget > 0.0 && tBudget > capacity) { + error(result, connEndInstance, + this.componentName + " budget total " + stBudget + " exceeds capacity " + stCapacity); + } + + double available = 0.0; + String suppliedmsg = ""; + if (tSupply == 0.0) { + available = capacity; + suppliedmsg = "capacity "; + } else { + available = tSupply; + suppliedmsg = "supply "; + } + + if (tBudget > available) { + error(result, connEndInstance, "budget total " + stBudget + " exceeds " + suppliedmsg + + PowerRequirementAnalysis.toString(available)); + } + } + }); + } + + @Override + public void visitFeaturePrefix(final Feature feature) { + final FeatureInstance featureInstance = feature.getFeatureInstance(); + + // Create a new result object for the connection end + final Result featureResult = ResultUtil.createResult(featureInstance.getName() + feature.getID(), + featureInstance, + ResultType.SUCCESS); + + currentResult.getSubResults().add(featureResult); + } + + @Override + public void visitFeaturePostfix(final Feature feature) { + // unroll the result stack + String visitFeatureID = feature.getID().toString(); + + currentResult.getSubResults().forEach(result -> { + String msg = result.getMessage(); + + if (msg.contains(visitFeatureID)) { + result.setMessage(msg.replaceAll(visitFeatureID, "")); + + double budget = feature.getBudget(); + double supply = feature.getSupply(); + String name = feature.getFeatureInstance().getContainingComponentInstance().getName(); + + ResultUtil.addRealValue(result, budget); // 0 + ResultUtil.addRealValue(result, supply); // 1 + ResultUtil.addRealValue(result, capacity);// 2 + ResultUtil.addRealValue(result, tBudget); // 3 + ResultUtil.addRealValue(result, tSupply); // 4 + + ResultUtil.addStringValue(result, this.componentName); // 5 + ResultUtil.addStringValue(result, "System name " + this.systemSOMname); // 6 + ResultUtil.addStringValue(result, name); // 7 + + String stBudget = PowerRequirementAnalysis.toString(tBudget); + + ResultUtil.addStringValue(result, + "Budget " + PowerRequirementAnalysis.toString(budget) + " for " + name + + " out of total " + stBudget); + + ResultUtil.addStringValue(result, + "Supply " + PowerRequirementAnalysis.toString(supply) + " from " + name + + " out of total " + PowerRequirementAnalysis.toString(tSupply)); + + String stCapacity = PowerRequirementAnalysis.toString(capacity); + + ResultUtil.addStringValue(result, "Total capacity: " + stCapacity); + + // diagnostics -> markers + final FeatureInstance featureInstance = feature.getFeatureInstance(); + + if (capacity > 0.0 && tBudget > 0.0 && tBudget > capacity) { + error(result, featureInstance, + this.componentName + " budget total " + stBudget + " exceeds capacity " + stCapacity); + } + + double available = 0.0; + String suppliedmsg = ""; + if (tSupply == 0.0) { + available = capacity; + suppliedmsg = "capacity "; + } else { + available = tSupply; + suppliedmsg = "supply "; + } + + if (tBudget > available) { + error(result, featureInstance, "budget total " + stBudget + " exceeds " + suppliedmsg + + PowerRequirementAnalysis.toString(available)); + } + } + }); + } + } + + public static String toString(double value) { + return value > 2000.0 ? value / 1000 + " W" : value + " mW"; + } +} \ No newline at end of file diff --git a/analyses/org.osate.analysis.resource.management/META-INF/MANIFEST.MF b/analyses/org.osate.analysis.resource.management/META-INF/MANIFEST.MF index dd6598b8837..de832aff530 100644 --- a/analyses/org.osate.analysis.resource.management/META-INF/MANIFEST.MF +++ b/analyses/org.osate.analysis.resource.management/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.osate.analysis.resource.management;singleton:=true -Bundle-Version: 4.0.1.qualifier +Bundle-Version: 4.0.0.qualifier Bundle-ClassPath: . Bundle-Activator: org.osate.analysis.resource.management.ResourcemanagementPlugin Bundle-Vendor: CMU/SEI @@ -14,10 +14,8 @@ Export-Package: org.osate.analysis.resource.management, Require-Bundle: org.osate.analysis.binpacking;bundle-version="[3.0.0,4.0.0)", org.osate.aadl2;bundle-version="[4.0.0,5.0.0)", org.osate.aadl2.modelsupport;bundle-version="[6.0.0,7.0.0)", - org.osate.ui;bundle-version="[6.2.0,7.0.0)", - org.osate.xtext.aadl2.properties;bundle-version="[3.1.0,4.0.0)", - org.osate.aadl2.contrib;bundle-version="[1.1.0, 2.0.0)", - org.osate.pluginsupport;bundle-version="[7.0.0, 8.0.0)" + org.osate.ui;bundle-version="[6.0.0,7.0.0)", + org.osate.xtext.aadl2.properties;bundle-version="[3.0.0,4.0.0)" Bundle-ActivationPolicy: lazy Automatic-Module-Name: org.osate.analysis.resource.management Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/analyses/org.osate.analysis.resource.management/pom.xml b/analyses/org.osate.analysis.resource.management/pom.xml index 35fb924416c..47d9a6060c0 100644 --- a/analyses/org.osate.analysis.resource.management/pom.xml +++ b/analyses/org.osate.analysis.resource.management/pom.xml @@ -12,7 +12,7 @@ org.osate org.osate.analysis.resource.management - 4.0.1-SNAPSHOT + 4.0.0-SNAPSHOT eclipse-plugin diff --git a/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/resource/management/handlers/Binpack.java b/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/resource/management/handlers/Binpack.java index 31f92e3a4b6..60fb8b7b9bc 100644 --- a/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/resource/management/handlers/Binpack.java +++ b/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/resource/management/handlers/Binpack.java @@ -53,10 +53,6 @@ import org.osate.aadl2.PropertyExpression; import org.osate.aadl2.RecordValue; import org.osate.aadl2.SystemClassifier; -import org.osate.aadl2.contrib.aadlproject.SizeUnits; -import org.osate.aadl2.contrib.aadlproject.TimeUnits; -import org.osate.aadl2.contrib.timing.TimingProperties; -import org.osate.aadl2.contrib.util.AadlContribUtils; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.ConnectionInstance; import org.osate.aadl2.instance.ConnectionKind; @@ -210,8 +206,7 @@ public void process(Element obj) { protected boolean suchThat(Element obj) { final ComponentCategory cat = ((ComponentInstance) obj).getCategory(); if (cat == ComponentCategory.THREAD || cat == ComponentCategory.DEVICE) { - return org.osate.pluginsupport.properties.PropertyUtils - .getScaled(TimingProperties::getPeriod, (ComponentInstance) obj, TimeUnits.MS).orElse(0.0) == 0.0; + return GetProperties.getPeriodinMS((ComponentInstance) obj) == 0.0; } else { return false; } @@ -254,7 +249,7 @@ public void process(Element obj) { Classifier cl = srcAP.getClassifier(); if (cl instanceof DataClassifier) { DataClassifier srcDC = (DataClassifier) cl; - if (AadlContribUtils.getDataSize(srcDC, SizeUnits.BYTES) == 0) { + if (GetProperties.getSourceDataSizeInBytes(srcDC) == 0) { logWarning("Data size of connection source port " + src.getComponentInstancePath() + " not specified"); } @@ -561,7 +556,7 @@ public void process(Element obj) { double dataSize = 0.0; double threadPeriod = 0.0; try { - dataSize = AadlContribUtils.getDataSize(srcDC, SizeUnits.BYTES); + dataSize = GetProperties.getSourceDataSizeInBytes(srcDC); } catch (Exception e) { errManager.warning(connInst, "No Data Size for connection"); } diff --git a/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/scheduling/RuntimeProcessWalker.java b/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/scheduling/RuntimeProcessWalker.java index 6e386b4c7a8..c900f9240f4 100644 --- a/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/scheduling/RuntimeProcessWalker.java +++ b/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/scheduling/RuntimeProcessWalker.java @@ -32,12 +32,9 @@ import org.eclipse.emf.ecore.util.EcoreUtil; import org.osate.aadl2.ComponentCategory; import org.osate.aadl2.Element; -import org.osate.aadl2.contrib.aadlproject.TimeUnits; -import org.osate.aadl2.contrib.timing.TimingProperties; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.properties.PropertyNotPresentException; import org.osate.analysis.resource.management.handlers.Schedule; -import org.osate.pluginsupport.properties.PropertyUtils; import org.osate.xtext.aadl2.properties.util.GetProperties; import org.osate.xtext.aadl2.properties.util.InstanceModelUtil; @@ -118,7 +115,7 @@ public void addThread(ComponentInstance elt) { return; } - double deadlineval = PropertyUtils.getScaled(TimingProperties::getDeadline, elt, TimeUnits.MS).orElse(0.0); + double deadlineval = GetProperties.getDeadlineinMilliSec(elt); RuntimeProcess curComponent = new RuntimeProcess(); curComponent.setProcessorName(currentProcessor.getInstanceObjectPath()); // convert time into MicroSeconds so it does not get rounded down diff --git a/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/scheduling/inversion/PriorityInversion.java b/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/scheduling/inversion/PriorityInversion.java index c8a1d96c57d..df144a59d48 100644 --- a/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/scheduling/inversion/PriorityInversion.java +++ b/analyses/org.osate.analysis.resource.management/src/org/osate/analysis/scheduling/inversion/PriorityInversion.java @@ -29,14 +29,11 @@ import org.eclipse.emf.common.util.EList; import org.osate.aadl2.ComponentCategory; import org.osate.aadl2.Element; -import org.osate.aadl2.contrib.aadlproject.TimeUnits; -import org.osate.aadl2.contrib.timing.TimingProperties; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.SystemInstance; import org.osate.aadl2.modelsupport.errorreporting.AnalysisErrorReporterManager; import org.osate.aadl2.modelsupport.modeltraversal.ForAllElement; import org.osate.aadl2.properties.PropertyNotPresentException; -import org.osate.pluginsupport.properties.PropertyUtils; import org.osate.xtext.aadl2.properties.util.GetProperties; import org.osate.xtext.aadl2.properties.util.InstanceModelUtil; @@ -86,10 +83,8 @@ protected boolean suchThat(Element obj) { // we will sort the thread list by period and // check to make sure the assigned priority is monotonically decreasing ECollections.sort(boundThreads, (obj1, obj2) -> { - final double a = PropertyUtils - .getScaled(TimingProperties::getPeriod, (ComponentInstance) obj1, TimeUnits.MS).orElse(0.0); - final double b = PropertyUtils - .getScaled(TimingProperties::getPeriod, (ComponentInstance) obj2, TimeUnits.MS).orElse(0.0); + final double a = GetProperties.getPeriodinMS((ComponentInstance) obj1); + final double b = GetProperties.getPeriodinMS((ComponentInstance) obj2); if (a > b) { return 1; } @@ -127,8 +122,7 @@ public void checkDecreasingPriority(List threadList) { for (Element e : threadList) { ComponentInstance thread = (ComponentInstance) e; - double period = PropertyUtils - .getScaled(TimingProperties::getPeriod, thread, TimeUnits.MS).orElse(0.0); + double period = GetProperties.getPeriodinMS(thread); long priority = GetProperties.getPriority(thread, Long.MIN_VALUE); if (priority == Long.MIN_VALUE) { diff --git a/analyses/org.osate.codegen.checker/META-INF/MANIFEST.MF b/analyses/org.osate.codegen.checker/META-INF/MANIFEST.MF index 07b1a4e9f5f..1979dc32eed 100644 --- a/analyses/org.osate.codegen.checker/META-INF/MANIFEST.MF +++ b/analyses/org.osate.codegen.checker/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Codegen Checker Bundle-SymbolicName: org.osate.codegen.checker;singleton:=true -Bundle-Version: 1.0.6.qualifier +Bundle-Version: 1.0.5.qualifier Bundle-Activator: org.osate.codegen.checker.Activator Bundle-Vendor: CMU/SEI Require-Bundle: org.eclipse.ui;bundle-version="[3.115.0,4.0.0)", @@ -11,9 +11,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.115.0,4.0.0)", org.eclipse.emf;bundle-version="[2.6.0,3.0.0)", org.osate.aadl2.instantiation;bundle-version="[1.1.0,2.0.0)", org.osate.aadl2;bundle-version="[4.0.0,5.0.0)", - org.eclipse.help;bundle-version="[3.6.0,4.0.0)", - org.osate.aadl2.contrib;bundle-version="[1.1.0, 2.0.0)", - org.osate.pluginsupport;bundle-version="[7.0.0, 8.0.0)" + org.eclipse.help;bundle-version="[3.6.0,4.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Import-Package: org.eclipse.core.internal.resources, diff --git a/analyses/org.osate.codegen.checker/pom.xml b/analyses/org.osate.codegen.checker/pom.xml index 4ffb8985035..0c20cfdf6a1 100644 --- a/analyses/org.osate.codegen.checker/pom.xml +++ b/analyses/org.osate.codegen.checker/pom.xml @@ -12,7 +12,7 @@ org.osate org.osate.codegen.checker - 1.0.6-SNAPSHOT + 1.0.5-SNAPSHOT eclipse-plugin diff --git a/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/DataCheck.java b/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/DataCheck.java index e04e9a36453..0679e44ffe4 100644 --- a/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/DataCheck.java +++ b/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/DataCheck.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -28,22 +28,20 @@ import java.util.stream.Collectors; import org.osate.aadl2.ComponentCategory; -import org.osate.aadl2.contrib.aadlproject.SizeUnits; -import org.osate.aadl2.contrib.util.AadlContribUtils; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.SystemInstance; import org.osate.codegen.checker.report.ErrorReport; +import org.osate.xtext.aadl2.properties.util.GetProperties; public class DataCheck extends AbstractCheck { - @Override public void perform(SystemInstance si) { /** * Get data that do not have size */ final List dataWithoutSize = si.getAllComponentInstances().stream() .filter(comp -> (comp.getCategory() == ComponentCategory.DATA) - && (AadlContribUtils.getDataSize(comp, SizeUnits.BYTES) == 0.0)) + && (GetProperties.getDataSizeInBytes(comp) == 0.0)) .collect(Collectors.toList()); for (ComponentInstance data : dataWithoutSize) { diff --git a/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/ProcessorCheck.java b/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/ProcessorCheck.java index 85edb8f7520..96c71252509 100644 --- a/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/ProcessorCheck.java +++ b/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/ProcessorCheck.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -28,14 +28,11 @@ import java.util.stream.Collectors; import org.osate.aadl2.ComponentCategory; -import org.osate.aadl2.contrib.aadlproject.TimeUnits; -import org.osate.aadl2.contrib.timing.TimingProperties; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.SystemInstance; import org.osate.aadl2.util.OsateDebug; import org.osate.codegen.checker.report.ErrorReport; import org.osate.codegen.checker.utils.PokProperties; -import org.osate.pluginsupport.properties.PropertyUtils; import org.osate.xtext.aadl2.properties.util.GetProperties; public class ProcessorCheck extends AbstractCheck { @@ -90,8 +87,7 @@ public void perform(SystemInstance si) { final List virtualProcessorsWithoutPeriod = si .getAllComponentInstances(ComponentCategory.VIRTUAL_PROCESSOR).stream() .filter(comp -> ((comp.getCategory() == ComponentCategory.VIRTUAL_PROCESSOR) - && (PropertyUtils.getScaled(TimingProperties::getPeriod, comp, TimeUnits.MS) - .orElse(0.0) == 0))) + && (GetProperties.getPeriodinMS(comp) == 0))) .collect(Collectors.toList()); for (ComponentInstance vp : virtualProcessorsWithoutPeriod) { addError(new ErrorReport(vp, "Virtual processor must define the property Timing_Properties::Period")); diff --git a/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/ThreadCheck.java b/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/ThreadCheck.java index 5b2d85e212d..287eb69a8e9 100644 --- a/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/ThreadCheck.java +++ b/analyses/org.osate.codegen.checker/src/org/osate/codegen/checker/checks/ThreadCheck.java @@ -33,12 +33,9 @@ import org.osate.aadl2.NamedElement; import org.osate.aadl2.SubprogramCall; import org.osate.aadl2.ThreadImplementation; -import org.osate.aadl2.contrib.aadlproject.TimeUnits; -import org.osate.aadl2.contrib.timing.TimingProperties; import org.osate.aadl2.instance.ComponentInstance; import org.osate.aadl2.instance.SystemInstance; import org.osate.codegen.checker.report.ErrorReport; -import org.osate.pluginsupport.properties.PropertyUtils; import org.osate.xtext.aadl2.properties.util.AadlProject; import org.osate.xtext.aadl2.properties.util.GetProperties; @@ -68,16 +65,14 @@ public void perform(SystemInstance si) { * Each thread needs to specify period */ final List threadMissingPeriod = allThreads.stream() - .filter(comp -> (PropertyUtils.getScaled(TimingProperties::getPeriod, comp, TimeUnits.MS) - .orElse(0.0) == 0.0)) + .filter(comp -> (GetProperties.getPeriodinMS(comp) == 0.0)) .collect(Collectors.toList()); for (ComponentInstance thr : threadMissingPeriod) { addError(new ErrorReport(thr, "Thread must define the property Timing_Properties::Period")); } final List threadMissingDeadline = allThreads.stream() - .filter(comp -> (PropertyUtils.getScaled(TimingProperties::getDeadline, comp, TimeUnits.MS) - .orElse(0.0) == 0.0)) + .filter(comp -> (GetProperties.getDeadlineinMilliSec(comp) == 0.0)) .collect(Collectors.toList()); for (ComponentInstance thr : threadMissingDeadline) { addError(new ErrorReport(thr, "Thread must define the property Timing_Properties::Deadline")); diff --git a/analyses/org.osate.importer/META-INF/MANIFEST.MF b/analyses/org.osate.importer/META-INF/MANIFEST.MF index 84f0c70df14..309247c9e52 100644 --- a/analyses/org.osate.importer/META-INF/MANIFEST.MF +++ b/analyses/org.osate.importer/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Architecture importer generic package Bundle-SymbolicName: org.osate.importer;singleton:=true -Bundle-Version: 2.0.1.qualifier +Bundle-Version: 2.0.0.qualifier Bundle-Activator: org.osate.importer.Activator Bundle-Vendor: CMU/SEI Bundle-Localization: plugin @@ -28,7 +28,6 @@ Import-Package: org.eclipse.core.resources, org.osate.aadl2.properties, org.osate.aadl2.util, org.osate.contribution.sei.names, - org.osate.contribution.sei.sei, org.osate.pluginsupport, org.osate.ui, org.osate.ui.dialogs, diff --git a/analyses/org.osate.importer/pom.xml b/analyses/org.osate.importer/pom.xml index 077bd338eb6..0d8932023cf 100644 --- a/analyses/org.osate.importer/pom.xml +++ b/analyses/org.osate.importer/pom.xml @@ -12,7 +12,7 @@ org.osate org.osate.importer - 2.0.1-SNAPSHOT + 2.0.0-SNAPSHOT eclipse-plugin diff --git a/analyses/org.osate.importer/src/org/osate/importer/properties/CriticalityProperty.java b/analyses/org.osate.importer/src/org/osate/importer/properties/CriticalityProperty.java index 7631f0ffc4e..cbbedd7b9e8 100644 --- a/analyses/org.osate.importer/src/org/osate/importer/properties/CriticalityProperty.java +++ b/analyses/org.osate.importer/src/org/osate/importer/properties/CriticalityProperty.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -32,10 +32,6 @@ import org.osate.xtext.aadl2.properties.util.GetProperties; import org.osate.xtext.aadl2.properties.util.PropertyUtils; -/** - * @deprecated Will be removed in 2.10.0.. Use {@code org.osate.contribution.sei.arinc653.Arinc653.getDal()} and {@code org.osate.contribution.sei.arinc653.SupportedDalType}. - */ -@Deprecated public class CriticalityProperty { private static Property criticalityProperty = null; diff --git a/analyses/org.osate.importer/src/org/osate/importer/properties/InspectProperty.java b/analyses/org.osate.importer/src/org/osate/importer/properties/InspectProperty.java index 44bb01b25fd..43d14133be9 100644 --- a/analyses/org.osate.importer/src/org/osate/importer/properties/InspectProperty.java +++ b/analyses/org.osate.importer/src/org/osate/importer/properties/InspectProperty.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -24,15 +24,39 @@ package org.osate.importer.properties; +import org.osate.aadl2.BooleanLiteral; import org.osate.aadl2.NamedElement; +import org.osate.aadl2.Property; +import org.osate.aadl2.PropertyExpression; +import org.osate.aadl2.properties.PropertyLookupException; +import org.osate.contribution.sei.names.SEI; +import org.osate.xtext.aadl2.properties.util.GetProperties; -/** - * @deprecated Will be removed in 2.10.0. - */ -@Deprecated public class InspectProperty { + + private static Property inspectProperty = null; + public static boolean shallInspect(final NamedElement ph) { - return org.osate.contribution.sei.sei.Sei.getVdidInspect(ph).orElse(false); + PropertyExpression pv; + boolean val; + + if (inspectProperty == null) { + inspectProperty = GetProperties.lookupPropertyDefinition(ph, SEI._NAME, SEI.VDID_INSPECT); + } + + val = false; + + try { + pv = ph.getSimplePropertyValue(inspectProperty); + + if (pv instanceof BooleanLiteral) { + val = ((BooleanLiteral) pv).getValue(); + } + } catch (PropertyLookupException e) { + return false; + } + System.out.println("return inspect: " + val + " on comp " + ph); + return val; } } diff --git a/analyses/org.osate.importer/src/org/osate/importer/properties/SlocProperty.java b/analyses/org.osate.importer/src/org/osate/importer/properties/SlocProperty.java index c61f40f0976..c0dc0230d78 100644 --- a/analyses/org.osate.importer/src/org/osate/importer/properties/SlocProperty.java +++ b/analyses/org.osate.importer/src/org/osate/importer/properties/SlocProperty.java @@ -1,18 +1,18 @@ /** - * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). + * Copyright (c) 2004-2021 Carnegie Mellon University and others. (see Contributors file). * All Rights Reserved. - * + * * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT. - * + * * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * SPDX-License-Identifier: EPL-2.0 - * + * * Created, in part, with funding and support from the United States Government. (see Acknowledgments file). - * + * * This program includes and/or can make use of certain third party source code, object code, documentation and other * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and @@ -24,15 +24,39 @@ package org.osate.importer.properties; +import org.osate.aadl2.IntegerLiteral; import org.osate.aadl2.NamedElement; +import org.osate.aadl2.Property; +import org.osate.aadl2.PropertyExpression; +import org.osate.aadl2.properties.PropertyLookupException; +import org.osate.contribution.sei.names.SEI; +import org.osate.xtext.aadl2.properties.util.GetProperties; -/** - * @deprecated Will be removed in 2.10.0.. - */ -@Deprecated public class SlocProperty { + + private static Property slocProperty = null; + public static long getSloc(final NamedElement ph) { - return org.osate.contribution.sei.sei.Sei.getNsloc(ph).orElse(0L); + PropertyExpression pv; + long val; + + if (slocProperty == null) { + slocProperty = GetProperties.lookupPropertyDefinition(ph, SEI._NAME, SEI.NSLOC); + } + + val = 0; + + try { + pv = ph.getSimplePropertyValue(slocProperty); + + if (pv instanceof IntegerLiteral) { + val = ((IntegerLiteral) pv).getValue(); + } + } catch (PropertyLookupException e) { + return 0; + } + // System.out.println ("return sloc: " + val); + return val; } } diff --git a/core/org.osate.help/aadlhelp.xml b/core/org.osate.help/aadlhelp.xml index 57e4af1e0f0..54cba84004a 100644 --- a/core/org.osate.help/aadlhelp.xml +++ b/core/org.osate.help/aadlhelp.xml @@ -57,6 +57,7 @@ censes only apply to the Third Party Software and not any other portion of this + diff --git a/core/org.osate.help/html/plugins/index.html b/core/org.osate.help/html/plugins/index.html index bcea577e995..302e6b61211 100644 --- a/core/org.osate.help/html/plugins/index.html +++ b/core/org.osate.help/html/plugins/index.html @@ -48,10 +48,6 @@

OSATE plug-ins

Weight (Mass) Analysis: analyzes the weight of components in an instance model. -
  • - Electrical Power Analysis: analyzes - electrical power budgets against electrical power supply within the capacity of the electrical power transmission system. -
  • Resource Budget Analysis for MIPS, RAM, ROM, and Network Bandwidth: compares resource budgets against capacities, in case of components bound to a resource, only for those budgets bound to a given resource. diff --git a/core/org.osate.help/html/plugins/sei.html b/core/org.osate.help/html/plugins/sei.html index 92ef9990536..e86d7a2335b 100644 --- a/core/org.osate.help/html/plugins/sei.html +++ b/core/org.osate.help/html/plugins/sei.html @@ -131,12 +131,6 @@

    Weight Analysis Plug-In

    specified weight limits. For details see here.

    -

    Analyze Electrical Power Consumption

    -

    -The Weight Analysis sums up the weight of different components in terms of net and gross weight and compares the results against -specified weight limits. For details see here. -

    -

    MIPS, RAM, ROM, and Network Bandwidth Budget Analysis

    The Budget Analysis sums up the budgets of components with resource demand and compares the total against the resource capacity - in case of bindings the budgets of those components bound to the resource. For details see here.