blob: 83b38953fce5af28e24890c4d831053d6ed54ee1 [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
}]
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
}
}