| /******************************************************************************* |
| * Copyright (c) 2008-2010, Istvan Rath and Daniel Varro |
| * 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: |
| * Istvan Rath - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.frameworkgui.views.console.commands.xform; |
| |
| import java.util.List; |
| |
| import org.eclipse.viatra2.framework.IFramework; |
| import org.eclipse.viatra2.frameworkgui.views.console.commands.IVIATRAConsoleCommandProvider; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Machine; |
| |
| /** |
| * VIATRA2 console command to facilitate the execution of a GTASM machine. |
| * @author istvan rath |
| * |
| */ |
| public class RunMachine extends AbstractRunnerCommand implements IVIATRAConsoleCommandProvider { |
| |
| |
| public void executeCommand(IFramework fw, List<String> parameters) { |
| // 0. check if we have exactly two parameters |
| if (parameters.size()!=2) { |
| fw.getLogger().error("[RunMachine] Wrong number of parameters supplied."); |
| return; |
| } |
| // 1. check if machine exists in the framwork and is runnable |
| String machineFQN = parameters.get(0); |
| Machine m = (Machine)fw.getMachineByFQN(machineFQN); |
| if (m==null) { |
| fw.getLogger().error("[RunMachine] machine "+machineFQN+" not found."); |
| return; |
| } |
| commenceRunning(fw, m, parameters.get(1), m.getFqn(), false); |
| } |
| |
| public String getCommandSignature() { |
| return "runmachine(machineFQN,parameterMappings)"; |
| } |
| |
| public String getDescription() { |
| return "Executes a GTASM Machine in a normal VIATRA2 transaction."; |
| } |
| |
| public String getHelpText() { |
| return "Use runmachine(<<machine fqn>>,<<parametermapping>>) to execute a GTASM machine in a normal transaction.\n"+ |
| "Parameter mappings take the following syntax: <<parametername=value>> and are separated by ; characters.\n"+ |
| "Example: runmachine(helloworld, target=John;message=Hello)"; |
| } |
| |
| } |