TrackRunCommand.java

  1. // @formatter:off
  2.  /*******************************************************************************
  3.  *
  4.  * This file is part of JMad.
  5.  *
  6.  * Copyright (c) 2008-2011, CERN. All rights reserved.
  7.  *
  8.  * Licensed under the Apache License, Version 2.0 (the "License");
  9.  * you may not use this file except in compliance with the License.
  10.  * You may obtain a copy of the License at
  11.  *
  12.  *     http://www.apache.org/licenses/LICENSE-2.0
  13.  *
  14.  * Unless required by applicable law or agreed to in writing, software
  15.  * distributed under the License is distributed on an "AS IS" BASIS,
  16.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17.  * See the License for the specific language governing permissions and
  18.  * limitations under the License.
  19.  *
  20.  ******************************************************************************/
  21. // @formatter:on

  22. package cern.accsoft.steering.jmad.kernel.cmd.track;

  23. import java.util.ArrayList;
  24. import java.util.List;

  25. import cern.accsoft.steering.jmad.domain.result.track.TrackResultRequest;
  26. import cern.accsoft.steering.jmad.kernel.cmd.AbstractCommand;
  27. import cern.accsoft.steering.jmad.kernel.cmd.param.GenericParameter;
  28. import cern.accsoft.steering.jmad.kernel.cmd.param.Parameter;
  29. import org.slf4j.Logger;
  30. import org.slf4j.LoggerFactory;

  31. /**
  32.  * command RUN, maxaper= double array, turns= integer, ffile= integer;
  33.  *
  34.  * @author xbuffat
  35.  */

  36. public class TrackRunCommand extends AbstractCommand {

  37.     private static final Logger LOGGER = LoggerFactory.getLogger(TrackRunCommand.class);

  38.     private static final String CMD_NAME = "run";

  39.     private final TrackResultRequest trackRequestResult;

  40.     public TrackRunCommand(TrackResultRequest trackResultRequest) {
  41.         this.trackRequestResult = trackResultRequest;
  42.     }

  43.     @Override
  44.     public String getName() {
  45.         return TrackRunCommand.CMD_NAME;
  46.     }

  47.     @Override
  48.     public List<Parameter> getParameters() {
  49.         List<Parameter> parameters = new ArrayList<>();

  50.         if (this.trackRequestResult.isApertureLimited()) {
  51.             LOGGER.warn("maxaper not available yet, no aperture defined");
  52.             // parameters.add(new
  53.             // GenericParameter<Double[]>("maxaper",this.trackRequestResult.getApertureLimitation()));
  54.         }
  55.         parameters.add(new GenericParameter<>("turns", this.trackRequestResult.getTurns()));
  56.         parameters.add(new GenericParameter<>("ffile", this.trackRequestResult.getPrintFrequency()));

  57.         return parameters;
  58.     }

  59. }