TrackStartCommand.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.track.RelativeParticleCoordinate;
  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. /**
  30.  * command START, x= double, px= double, y= double, py= double, t= double, pt= double;
  31.  *
  32.  * @author xbuffat
  33.  */

  34. public class TrackStartCommand extends AbstractCommand {

  35.     private static final String CMD_NAME = "start";

  36.     private final RelativeParticleCoordinate relatvieParticleCoordinate;

  37.     public TrackStartCommand(RelativeParticleCoordinate relativeParticleCoordinate) {
  38.         this.relatvieParticleCoordinate = relativeParticleCoordinate;
  39.     }

  40.     @Override
  41.     public String getName() {
  42.         return TrackStartCommand.CMD_NAME;
  43.     }

  44.     @Override
  45.     public List<Parameter> getParameters() {
  46.         List<Parameter> parameters = new ArrayList<>();
  47.         if(this.relatvieParticleCoordinate.isActionAngle())
  48.         {
  49.             parameters.add(new GenericParameter<>("fx", this.relatvieParticleCoordinate.getXRelatviePosition()));
  50.             parameters.add(new GenericParameter<>("phix", this.relatvieParticleCoordinate.getXRelativeMomentum()));
  51.             parameters.add(new GenericParameter<>("fy", this.relatvieParticleCoordinate.getYRelativePosition()));
  52.             parameters.add(new GenericParameter<>("phiy", this.relatvieParticleCoordinate.getYRelatvieMomentum()));
  53.             parameters.add(new GenericParameter<>("ft", this.relatvieParticleCoordinate.getRelativeTimeDifference()));
  54.             parameters.add(new GenericParameter<>("phit", this.relatvieParticleCoordinate.getRelativeTimeDifference()));
  55.         }
  56.         else
  57.         {
  58.             parameters.add(new GenericParameter<>("x", this.relatvieParticleCoordinate.getXRelatviePosition()));
  59.             parameters.add(new GenericParameter<>("px", this.relatvieParticleCoordinate.getXRelativeMomentum()));
  60.             parameters.add(new GenericParameter<>("y", this.relatvieParticleCoordinate.getYRelativePosition()));
  61.             parameters.add(new GenericParameter<>("py", this.relatvieParticleCoordinate.getYRelatvieMomentum()));
  62.             parameters.add(new GenericParameter<>("t", this.relatvieParticleCoordinate.getRelativeTimeDifference()));
  63.             parameters.add(new GenericParameter<>("pt", this.relatvieParticleCoordinate.getRelativeTimeDifference()));
  64.         }

  65.         return parameters;
  66.     }

  67. }