| package templates.m2m.sw.runnableItem |
| |
| import com.inchron.realtime.root.model.TimeDistributionType |
| import org.eclipse.app4mc.amalthea.model.Amalthea |
| import org.eclipse.app4mc.amalthea.model.DiscreteValueBetaDistribution |
| import org.eclipse.app4mc.amalthea.model.DiscreteValueGaussDistribution |
| import org.eclipse.app4mc.amalthea.model.DiscreteValueHistogram |
| import org.eclipse.app4mc.amalthea.model.DiscreteValueUniformDistribution |
| import org.eclipse.app4mc.amalthea.model.Process |
| import org.eclipse.app4mc.amalthea.model.Ticks |
| import org.eclipse.app4mc.amalthea.model.util.DeploymentUtil |
| import org.eclipse.app4mc.amalthea.model.util.RuntimeUtil |
| import org.eclipse.app4mc.amalthea.model.util.RuntimeUtil.TimeType |
| import org.eclipse.emf.ecore.util.EcoreUtil |
| import templates.AbstractAmaltheaInchronTransformer |
| import templates.m2m.utils.TimeTransformer |
| |
| class TicksTransformer extends AbstractAmaltheaInchronTransformer { |
| |
| def create inchronModelFactory.createResourceConsumption createResourceConsumption(Process amltTask, |
| Ticks amltTicks) { |
| |
| it.name = "RC" |
| it.timeDistribution = createTimeDistribution(amltTask, amltTicks) |
| |
| } |
| |
| def create inchronModelFactory.createTimeDistribution createTimeDistribution(Process amltTask, Ticks amltTicks) { |
| |
| val timeUtils = new TimeTransformer |
| |
| var amltCores = DeploymentUtil.getAssignedCoreForProcess(amltTask, |
| EcoreUtil.getRootContainer(amltTask) as Amalthea); |
| |
| if (amltCores.size > 0) { |
| |
| val amltCore = amltCores?.get(0) |
| it.min = timeUtils.createTime(RuntimeUtil.getExecutionTimeForTicks(amltTicks, amltCore, TimeType.BCET)) |
| it.mean = timeUtils.createTime(RuntimeUtil.getExecutionTimeForTicks(amltTicks, amltCore, TimeType.ACET)) |
| it.max = timeUtils.createTime(RuntimeUtil.getExecutionTimeForTicks(amltTicks, amltCore, TimeType.WCET)) |
| |
| it.sigma = inchronModelFactory.createTime |
| it.type = TimeDistributionType.MAX |
| it.alpha = 0 |
| it.beta = 0 |
| var amltDistribution = amltTicks?.extended?.get(amltCore) |
| |
| if (amltDistribution === null) { |
| amltDistribution = amltTicks.^default |
| |
| if (amltDistribution instanceof DiscreteValueGaussDistribution) { |
| it.type = TimeDistributionType.NORMAL |
| |
| val sdCycles = amltDistribution.sd |
| |
| it.sigma = timeUtils.createTime( |
| RuntimeUtil.getExecutionTimeForCycles(sdCycles, amltCore?.frequencyDomain?.defaultValue)) |
| |
| } else if (amltDistribution instanceof DiscreteValueUniformDistribution) { |
| it.type = TimeDistributionType.UNIFORM |
| } else if (amltDistribution instanceof DiscreteValueBetaDistribution) { |
| } else if (amltDistribution instanceof DiscreteValueHistogram) { |
| it.type = TimeDistributionType.DISCRETE |
| |
| amltDistribution.entries.forEach [ amltEntry | |
| |
| val amltAvg = (amltEntry.upperBound + amltEntry.lowerBound) / 2; |
| |
| val amltOccurrences = amltEntry.occurrences |
| |
| var inchronDiscreteDistributionEntry = inchronModelFactory.createDiscreteDistributionEntry |
| |
| inchronDiscreteDistributionEntry.count = amltOccurrences |
| |
| inchronDiscreteDistributionEntry.execTime = timeUtils.createTime( |
| RuntimeUtil.getExecutionTimeForCycles(amltAvg, amltCore?.frequencyDomain?.defaultValue)) |
| |
| it.discreteDistribution.add(inchronDiscreteDistributionEntry) |
| ] |
| } |
| } |
| |
| } |
| |
| // if( amltTicks instanceof TimeGaussDistribution ) { |
| // val amltNormal = amltTicks as TimeGaussDistribution |
| // it.type = TimeDistributionType.NORMAL |
| // it.mean = timeUtils.createTime( amltNormal.getMean() ) |
| // it.sigma = timeUtils.createTime( amltNormal.getSd() ) |
| // } |
| // else if( amltTicks instanceof TimeUniformDistribution) { |
| // val amltUniform = amltTicks as TimeUniformDistribution |
| // it.type = TimeDistributionType.UNIFORM |
| // it.min = timeUtils.createTime( amltUniform.lowerBound ) |
| // it.max = timeUtils.createTime( amltUniform.upperBound ) |
| // } |
| // else if( amltTicks instanceof TimeBetaDistribution ) { |
| // val amltBeta = amltTicks as TimeBetaDistribution |
| // /* TODO: Currently INCHRON does not support the beta distribution. |
| // * Mapping to Weibull is WRONG (and also no longer truncated). */ |
| // it.type = TimeDistributionType.WEIBULL |
| // it.alpha = amltBeta.getAlpha() |
| // it.beta = amltBeta.getBeta() |
| // } |
| } |
| |
| // transform to resource consumption |
| } |