blob: 78062fb04658982db80e01cba6bb53393a647dff [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 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 app4mc.example.transform.m2m.transformers
import app4mc.example.transform.samplemodel.Model
import org.eclipse.app4mc.amalthea.model.Cache
import org.eclipse.app4mc.amalthea.model.ProcessingUnit
import org.eclipse.app4mc.transformation.ServiceConstants
import org.eclipse.app4mc.transformation.transformers.AbstractTransformer
import org.osgi.service.component.annotations.Activate
import org.osgi.service.component.annotations.Component
import org.osgi.service.component.annotations.ConfigurationPolicy
import org.osgi.service.component.annotations.Reference
import org.slf4j.LoggerFactory
import org.slf4j.Logger
@Component(
configurationPid = ServiceConstants.SESSION_CONFIGURATION_PID,
configurationPolicy = ConfigurationPolicy.REQUIRE,
service=#[ProcessingUnitTransformer,AbstractTransformer]
)
class ProcessingUnitTransformer extends AbstractTransformer {
static final Logger LOG = LoggerFactory.getLogger(typeof(AmaltheaModel2ModelTransformer));
@Reference CacheTransformer cacheTransformer
@Activate
def package void activate() {
LOG.debug("ProcessingUnitTransformer activated : "+this.hashCode)
}
def transfromProcessingUnit(ProcessingUnit hwModule, Model outputModel) {
hwModule.caches.forEach [ puSpecificCache |
// local cache : object creation
val outputCache = cacheTransformer.transfromCache(puSpecificCache)
outputModel.caches.add(outputCache)
]
hwModule?.accessElements?.forEach [ hwAccessElement |
val referredCaches = hwAccessElement?.accessPath?.pathElements.filter [
it instanceof Cache
]
referredCaches?.forEach [ referredCache |
val outputCache = cacheTransformer.transfromCache(referredCache as Cache)
LOG.info("Cache referred in path elements is : " + outputCache)
]
]
}
}