blob: 1e6155e183eac67341dbfc8967f5d6c9ab3579f1 [file] [log] [blame]
/**
* *******************************************************************************
* Copyright (c) 2019 Robert Bosch GmbH and others.
*
* 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.runnableItem
import com.google.inject.Inject
import com.google.inject.Singleton
import com.inchron.realtime.root.model.VariableReadAccessPolicy
import com.inchron.realtime.root.model.VariableReadAccessType
import com.inchron.realtime.root.model.memory.DataAccessType
import org.eclipse.app4mc.amalthea.model.ChannelReceive
import org.eclipse.app4mc.amalthea.model.ReceiveOperation
import templates.AbstractAmaltheaInchronTransformer
import templates.m2m.sw.ChannelTransformer
@Singleton
class ChannelReceiveTransformer extends AbstractAmaltheaInchronTransformer {
@Inject ChannelTransformer channelTransformer
@Inject TransmissionPolicyTransformer transmissionPolicyTransformer
private static Integer enumerator = 0;
def create inchronModelFactory.createVariableReadAccess createVariableReadAccess(ChannelReceive amltChannelReceive) {
it.connection = channelTransformer.createDataFlowConnection(amltChannelReceive.data)
it.dataMustBeNew = amltChannelReceive.dataMustBeNew
it.index = amltChannelReceive.elementIndex
it.isBuffered = true
it.name = it.connection.name + "_" + enumerator
it.label = it.connection.name + "_" + enumerator
it.lowerBound = amltChannelReceive.lowerBound
it.number = amltChannelReceive.elements
//set data access policy
if (amltChannelReceive.transmissionPolicy !== null){
it.dataAccess = transmissionPolicyTransformer.createExplicitDataAccess(amltChannelReceive.transmissionPolicy)
} else {
it.dataAccess = inchronMemoryFactory.createExplicitDataAccess
}
it.dataAccess.accessType = DataAccessType.READ;
//assign operation type: FIFO, LIFO, TAKE, READ
if (amltChannelReceive.receiveOperation === ReceiveOperation.FIFO_READ) {
it.isTake = false;
it.policy = VariableReadAccessPolicy.FIFO
}
else if (amltChannelReceive.receiveOperation === ReceiveOperation.FIFO_TAKE) {
it.isTake = true;
it.policy = VariableReadAccessPolicy.LIFO
}
else if (amltChannelReceive.receiveOperation === ReceiveOperation.LIFO_READ) {
it.isTake = false;
it.policy = VariableReadAccessPolicy.FIFO
}
else if (amltChannelReceive.receiveOperation === ReceiveOperation.LIFO_TAKE) {
it.isTake = true;
it.policy = VariableReadAccessPolicy.LIFO
}
//assign type
it.type = VariableReadAccessType.GENERIC
//add read access to dataflow connection's receiver list
it.connection.requesters.add(it)
enumerator = enumerator + 1
}
}