blob: 6356c7eb1c1a56fe17b2e82134526c93c7fef2f1 [file] [log] [blame]
/**
********************************************************************************
* Copyright (c) 2020-2021 Robert Bosch GmbH.
*
* 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 org.eclipse.app4mc.slg.ros2.transformers.sw;
import java.util.Arrays;
import org.eclipse.app4mc.amalthea.model.ActivityGraphItem;
import org.eclipse.app4mc.amalthea.model.ChannelReceive;
import org.eclipse.app4mc.amalthea.model.ChannelSend;
import org.eclipse.app4mc.amalthea.model.InterProcessTrigger;
import org.eclipse.app4mc.amalthea.model.LabelAccess;
import org.eclipse.app4mc.amalthea.model.RunnableCall;
import org.eclipse.app4mc.amalthea.model.Ticks;
import org.eclipse.app4mc.slg.commons.m2t.generators.TranslationUnit;
import org.eclipse.app4mc.slg.commons.m2t.transformers.ActivityGraphItemTransformer;
import org.eclipse.xtend2.lib.StringConcatenation;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@Singleton
public class RosActivityGraphItemTransformer extends ActivityGraphItemTransformer {
@Inject private RosChannelSendTransformer channelSendTransformer;
@Inject private RosInterProcessTriggerTransformer ipTransformer;
@Override
protected TranslationUnit _transform(final ChannelSend cs) {
return this.channelSendTransformer.transform(cs);
}
protected TranslationUnit _transform(final InterProcessTrigger ip) {
return this.ipTransformer.transform(ip);
}
@Override
protected TranslationUnit _transform(final ActivityGraphItem ActivityGraphItem) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("/*[feature ");
Class<? extends org.eclipse.app4mc.amalthea.model.ActivityGraphItem> _class = ActivityGraphItem.getClass();
_builder.append(_class);
_builder.append(" in not supported]*/");
final String message = _builder.toString();
return new TranslationUnit("undefined", message, message, message);
}
@Override
public TranslationUnit transform(final ActivityGraphItem cs) {
if (cs instanceof ChannelReceive) {
return _transform((ChannelReceive) cs);
} else if (cs instanceof ChannelSend) {
return _transform((ChannelSend) cs);
} else if (cs instanceof LabelAccess) {
return _transform((LabelAccess) cs);
} else if (cs instanceof Ticks) {
return _transform((Ticks) cs);
} else if (cs instanceof InterProcessTrigger) {
return _transform((InterProcessTrigger) cs);
} else if (cs instanceof RunnableCall) {
return _transform((RunnableCall) cs);
} else if (cs != null) {
return _transform(cs);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(cs).toString());
}
}
}