| /******************************************************************************* |
| * Copyright (c) 2018, 2020 Robert Bosch GmbH. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Robert Bosch GmbH - initial API and implementation |
| *******************************************************************************/ |
| |
| package templates |
| |
| import SampleModel.Model |
| import SampleModel.SampleModelFactory |
| import org.eclipse.app4mc.amalthea.model.AmaltheaFactory |
| import org.eclipse.app4mc.amalthea.model.MappingModel |
| import org.eclipse.app4mc.amalthea.model.TaskScheduler |
| import org.eclipse.app4mc.transformation.extensions.ICustomObjectsStore |
| import org.eclipse.app4mc.transformation.extensions.base.templates.AbstractTransformer |
| import org.eclipse.app4mc.transformation.extensions.base.templates.ISubTransformer |
| import org.osgi.service.component.annotations.Component |
| import org.osgi.service.component.annotations.Reference |
| import org.osgi.service.component.annotations.ServiceScope |
| |
| @Component(scope=ServiceScope.PROTOTYPE, service=MappingTransformer) |
| public class MappingTransformer extends AbstractTransformer implements ISubTransformer { |
| |
| @Reference |
| ICustomObjectsStore customObjsStore |
| |
| def HWTransformer hwTransformer() { |
| return customObjsStore.getInstance(HWTransformer) |
| } |
| |
| def OSTransformer osTransformer() { |
| return customObjsStore.getInstance(OSTransformer) |
| } |
| |
| /*- Factory initialization */ |
| val outputModelFactory = SampleModelFactory.eINSTANCE |
| |
| val amaltheaFactory = AmaltheaFactory.eINSTANCE |
| |
| public def transfromMappingModel(MappingModel amltMappingModel, Model simulationModel) { |
| |
| amltMappingModel?.schedulerAllocation?.forEach [ amltSA | |
| |
| if (amltSA.scheduler instanceof TaskScheduler) { |
| val simulationModelScheduler = osTransformer.createScheduler(amltSA.scheduler as TaskScheduler) |
| |
| if (simulationModelScheduler.eContainer === null) { |
| simulationModel.schedulers.add(simulationModelScheduler) |
| } |
| |
| } |
| |
| ] |
| |
| } |
| |
| } |