blob: ceae20d22c857dd6ff8837443ab4616bcd015225 [file] [log] [blame]
/**
********************************************************************************
* 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.ModeGroup
import org.eclipse.app4mc.amalthea.model.ModeLabel
import org.eclipse.app4mc.amalthea.model.ModeLiteral
import templates.AbstractAmaltheaInchronTransformer
import templates.utils.AmltCacheModel
import com.inchron.realtime.root.model.Mode
import com.google.inject.Singleton
@Singleton
class ModeLabelTransformer extends AbstractAmaltheaInchronTransformer {
var AmltCacheModel cacheModel
public def create inchronModelFactory.createModeGroup createModeGroup(ModeLabel amltModeLabel){
cacheModel = customObjsStore.getInstance(AmltCacheModel)
it.name=amltModeLabel.name
var amltModeLiteralInitialValue= amltModeLabel.initialValue
amltModeLiteralInitialValue?.containingMode?.literals?.forEach[literal, index|{
var inchronMode= createMode(literal, it)
inchronMode.value=index
}]
if (amltModeLabel.initialValue !== null){
it.initialMode = createMode(amltModeLabel.initialValue, it)
} else if (amltModeLabel?.mode?.literals.get(0) !==null) {
it.initialMode = createMode(amltModeLabel.mode.literals.get(0), it)
}
cacheModel.addInchronModeGroup(it)
}
public def create inchronModelFactory.createMode createMode(ModeLiteral amltModeLiteral , ModeGroup inchronModeGroup){
it.name=amltModeLiteral.name
inchronModeGroup.modes.add(it)
}
public def Mode getInchronMode(ModeLabel amltModeLabel, ModeLiteral amltModeLiteral){
var inchronModeGroup=createModeGroup(amltModeLabel)
var inchronMode=createMode(amltModeLiteral,inchronModeGroup)
return inchronMode
}
}