blob: 93039120a8db66ac4ebe0aa799f108400c0a0a5f [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.VariableWriteAccessType
import com.inchron.realtime.root.model.memory.DataAccessType
import org.eclipse.app4mc.amalthea.model.ChannelSend
import templates.AbstractAmaltheaInchronTransformer
import templates.m2m.sw.ChannelTransformer
@Singleton
class ChannelSendTransformer extends AbstractAmaltheaInchronTransformer {
@Inject ChannelTransformer channelTransformer
@Inject TransmissionPolicyTransformer transmissionPolicyTransformer
private static Integer enumerator = 0
def create inchronModelFactory.createVariableWriteAccess createVariableWriteAccess(ChannelSend amltChannelSend) {
it.connection = channelTransformer.createDataFlowConnection(amltChannelSend.data)
it.isBuffered = true
it.number = amltChannelSend.elements
it.name = it.connection.name + "_" + enumerator
it.label = it.connection.name + "_" + enumerator
//set data access policy
if (amltChannelSend.transmissionPolicy !== null){
it.dataAccess = transmissionPolicyTransformer.createExplicitDataAccess(amltChannelSend.transmissionPolicy)
} else {
it.dataAccess = inchronMemoryFactory.createExplicitDataAccess
}
it.dataAccess.accessType = DataAccessType.WRITE;
//assign type
it.type = VariableWriteAccessType.GENERIC
//add read access to dataflow connection's receiver list
if (it.connection.provider !== null){
logger.error("Transformation for Channel to Inchron DataFlowConnection supports only one writer per channel")
} else {
it.connection.provider = it
}
enumerator = enumerator + 1
}
}