| /** |
| * ******************************************************************************* |
| * 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 |
| |
| 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.label = "read access" |
| 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) |
| } |
| |
| |
| } |