| /** |
| ******************************************************************************** |
| * Copyright (c) 2018-2019 Robert Bosch GmbH. |
| * |
| * 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 |
| * |
| * Contributors: |
| * Robert Bosch GmbH - initial API and implementation |
| ******************************************************************************** |
| */ |
| |
| package templates.m2m.sw; |
| |
| import com.inchron.realtime.root.model.Mode |
| import org.eclipse.app4mc.amalthea.model.ModeLiteral |
| import org.eclipse.app4mc.amalthea.model.ModeValue |
| import org.eclipse.app4mc.amalthea.model.ModeValueConjunction |
| import org.eclipse.app4mc.amalthea.model.ModeValueDisjunction |
| import org.eclipse.app4mc.amalthea.model.Process |
| import templates.AbstractAmaltheaInchronTransformer |
| import templates.utils.AmltCacheModel |
| import com.google.inject.Inject |
| import com.google.inject.Singleton |
| |
| @Singleton |
| public class ModeValueDisjunctionTransformer extends AbstractAmaltheaInchronTransformer { |
| |
| var AmltCacheModel cacheModel |
| |
| @Inject ModeLabelTransformer modeLabelTransformer |
| |
| public def create inchronModelFactory.createModeCondition createModeCondition(ModeValueDisjunction amltModeValueDisjunction,Process amltTask ){ |
| cacheModel = customObjsStore.getInstance(AmltCacheModel) |
| |
| it.name="ModeCondition_"+amltTask.name+"_"+it.hashCode |
| |
| amltModeValueDisjunction?.entries?.forEach[amltModeValueDisjunctionEntry|{ |
| |
| val inchronModeConjunction=inchronModelFactory.createModeConjunction |
| //Adding ModeConjunction |
| it.conjunctions.add(inchronModeConjunction) |
| |
| if(amltModeValueDisjunctionEntry instanceof ModeValue){ |
| val amltModeLiteral=amltModeValueDisjunctionEntry.value |
| var amltModeLabel=amltModeValueDisjunctionEntry.valueProvider |
| //Adding Mode |
| inchronModeConjunction.modes.add(modeLabelTransformer.getInchronMode(amltModeLabel, amltModeLiteral)) |
| } else if(amltModeValueDisjunctionEntry instanceof ModeValueConjunction){ |
| amltModeValueDisjunctionEntry?.entries?.forEach[amltModeValueEntry|{ |
| var amltModeLiteral=amltModeValueEntry.value |
| var amltModeLabel=amltModeValueEntry.valueProvider |
| //Adding Mode |
| inchronModeConjunction.modes.add(modeLabelTransformer.getInchronMode(amltModeLabel, amltModeLiteral)) |
| }] |
| } |
| }] |
| } |
| |
| |
| |
| public def Mode getInchronMode(ModeLiteral amltModeLiteral ){ |
| |
| val amltModeName=amltModeLiteral?.containingMode?.name |
| |
| val inchronModeGroup=cacheModel.getInchronModeGroup(amltModeName) |
| |
| if(inchronModeGroup !==null){ |
| val inchronMode= inchronModeGroup.modes.findFirst[inchronMode|{ |
| (amltModeLiteral.name.equals(inchronMode.name)) |
| }] |
| return inchronMode |
| } |
| |
| return null |
| |
| |
| } |
| } |