Applications Group: New developers' Getting Started Training

1 Technical infrastructure (09:00 -10:50)

1.1 Eclipse

Warning: Can't find topic Applications.EclipseConfiguration

Full Article here

1.2 Workspace

Warning: Can't find topic Applications.EclipseConfiguration

More information available at Eclipse Configuration and Maven and Eclipse.

1.3 Maven

Maven is a build-system used at GSI. Within the Maven pom file you specify the properties of your product, like:
  • GAV ( group, artifact, version) to populate your product so that it can be found by others in a unique way
  • SCM (sourcecode management system) so that maven and other developers know, where to find your product in the SVN repository
  • a description of your product
  • authors and contributors
  • Dependencies
The build instructions are inherited from one of our maven parents. To create a new maven project you can use the csco-java-bundle-template.
  • In eclipse got to File -> New -> Other...
    • select "Maven Project" -> Next
    • optionally choose your project location and working set -> Next
    • type filter "csco" -> choose csco-java-bundle-template -> Next
    • Enter your GAV
      • e.g. Group: de.gsi.cs.co.ap.playground
      • e.g. Artifact: myNewMavenArtifact
      • e.g. Version: 0.0.1-SNAPSHOT
    • enter a name value
    • enter a description of your project -> Finish
  • look up your new maven project in eclipse
    • set up your properties
      • scm.path and scm.repo -> depends on where your project is located in the SVN repository
      • edit your project developers

ALERT! For this workshop, update your dependency on the artifact "cscoap-common-gui-elements" to the latest available snapshot version (at the time of writing, that's 0.1.5-SNAPSHOT)!

1.4 Projekt(-struktur)

  • MVC
    • Model: contains all database access methods for reading and persisting
    • View: shows data, informs Model that data has changed
    • Controller: contains logic / instantiates and knows both
  • Tests
    • tests are always stored in their own source-folder (src/test/java)
    • it is always recommended to create JUnit tests already before you actually write your code
      • by writing tests before coding, you will think up your API so that it is usable afterwards
      • if you can't specify any tests, think about the task you're working on
    • A simple test case looks like:
package de.gsi.your.project.path;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

import org.junit.Before;
import org.junit.Test;

public class MyClassTest {

    private MyClass myInstance;

    @Before
    public void init() throws Exception {
        myInstance = new MyClass ();
    }

    @Test
    public void myTest() throws Exception {
        int myResult = myInstance.getMyResult();
        assertThat(myResult, is(4711));
    }

}

1.5 SVN (Basics)

Warning: Can't find topic Applications.APHowToSvn

SVN in eclipse:
  • add remote SVN repository
    • go to window -> Oerspective -> Open Perspective... -> Other
      • choose SVN Repository Exploring
    • in the left "SVN Repsoitories" Views toolbar click the yellow tube symbol with the green plus
      • enter the SVN URL
      • enter your username and password (all passwords in eclipse are stored in a secure password storage with a master password, you will be asked for on the first use)
  • share new project
    • right click on project -> Team -> Share Project...
    • choose SVN -> Next
    • choose your svn connection (here https://www-acc.gsi.de/svn/playground) -> Next
    • choose Advanced Mode
      • at "Project Repository Layout" choose "Use single project layout" -> Next
    • enter a meaningful commit message (e.g. create new Project) -> Finish
    • in the next dialog
      • enter a meaningful commit message (e.g. initial commit of project content)
      • deselect folder ".settings" and files ".classpath", ".project" and all files contained in folder ".settigns"
        • these files and folders are generated by eclipse and are not needed in the SVN repository
        • they can be added to svn ignore list later
  • after a change on the already shared project
    • right click on project -> Team -> Commit...
    • in the next dialog
      • enter a meaningfull commit message
      • check the files and folders to be populated to the SVN repository
  • checkout other projects
    • got to File -> New -> Other...
    • select "Check out Maven Projects from SCM" -> Next
    • Browse to your project location
      • choose trunk -> Ok
  • working with others
    • merging commits from other developers into local working copy
    • right click on project -> Team -> Synchronize with Repository
    • optionally but recommended: look up the changes that were made
    • update your local project
    • go back to Java perspective (top right corner of eclipse)

2 JAPC (11:05 - 12:10)

JAPC is an unified Java API for Parameter Control relating to equipment access. It was developed at CERN and has been adapted at GSI. JAPC supports device access as follows:
  • Set (synchronous)
  • Get (synchronous, asynchronous)
  • Subscribe
More information available at JAPC. A graphical overview of the plugin architecture you can find here, page 2. Following the proceeding of implementing access to FESA equipment is introduced by some basic examples for synchronous get and subscribe:

2.1 JAPC configuration

Warning: Can't find topic Applications.CSCOJavaTraining

2.2 Parameter for JAPC calls

JAPC calls use two different parameters:

2.2.1 Parameter

"Parameter" is used to detect the correct plugin for access to FESA equipment.
final String devicename = "XYRT1BR1";
final String propertyname = "Status";
final String parametername = Parameters
  .buildParameterName(devicename, propertyname);
final Parameter parameter = ParameterFactory.newInstance()
  .newParameter(parametername);

2.2.2 Selector

"Selector" is used to specify the context of acquired equipment details.
final static Selector NULL_SELECTOR = SelectorFactory
  .newSelector("");
final static Selector MULTIPLEXED_SELECTOR = SelectorFactory
  .newSelector("FAIR.BP.3");

2.3 Get/Read (synchronous)

try {
    final String propertyname = "Status";
    final String parametername = Parameters
        .buildParameterName(devicename, propertyname);
    final Parameter parameter = ParameterFactory.newInstance()
        .newParameter(parametername);

    final AcquiredParameterValue parameterValue = parameter
        .getValue(NULL_SELECTOR);
    final MapParameterValue mapParameterValue =
        (MapParameterValue) parameterValue.getValue();
} catch (final ParameterException e) {
    LOGGER.error(e.getMessage());
}

2.4 Get Value

All values acquired from FESA equipment are delivered as a map of multiple field values. Depending on the predefined type value the current value has to be read out.
// all property fields delivered from JAPC
mapParameterValue.getNames();

// Example: readout "Status/powerstate"
try {
    final int powerstate = mapParameterValue.getInt("powerState");
} catch (final ValueConversionException e) {
    LOGGER.error(e.getMessage());
}

2.5 Subscribe

Subscription is handled by a "private channel" for the user who wants to execute the asynchronous connection. This channel is generated by start of subscription. Second parameter is the listener of the periodic update.

2.5.1 Start Subscription

final String parametername = Parameters
    .buildParameterName(devicename, propertyname);
try {
    final Parameter parameter = ParameterFactory.newInstance()
        .newParameter(parametername);
    final SubscriptionHandle subscriptionHandle = parameter
        .createSubscription(MULTIPLEXED_SELECTOR, this);
    subscriptionHandle.startMonitoring();
} catch (final ParameterException e) {
    LOGGER.error(e.getMessage());
}

2.5.2 Stop Subscription

When periodic update is not used any longer the connection has to be closed.

subscriptionHandle.stopMonitoring();

2.5.3 ParameterValueListener

The listener consists of two methods:
2.5.3.1 valueReceived

This method is called on success.

public void valueReceived(final String parameterName,
        final AcquiredParameterValue value) {
    final String propertyname = parameterName
        .substring(parameterName.indexOf("/") + 1);
    final AcquiredParameterValue parameterValue = value;
    final MapParameterValue mapParameterValue =
        (MapParameterValue) parameterValue.getValue();
}
2.5.3.2 exceptionOccured

This method is called on failure, e.g. if the device is offline.

public void exceptionOccured(final String parameterName,
        final String description, final ParameterException exception) {
    String message;
    if (exception == null) {
        parameterException = new ParameterException (description);
        message = parameterException.getMessage();
    } else {
        message = exception.getMessage();
    }
    LOGGER.error(message);
}

2.6. Logging

More information available at Use Diagnostic Logging

2.6.1 Example

Define Logger:

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

Logger output on error level:

LOGGER.error(e.getMessage());

3 LSA (12:55-14:05)

3.1 Basic concepts

3.1.1 Parameter

Parameters in LSA describe something for which a value shall be assigned, calculated or measured.

Most important characteristics of a parameter are its name and its value's format (the latter is defined in the parameter's type).
  • Parameters are named using the notation "<device>/<property[#field]>".
  • A parameter has a type that defines some characteristics shared across all parameters of that type.
The device associated with a parameter can be one of the following:
  • Actually existing, addressable equipment such as a power converter
  • Actually existing, but non-addressable equipment such as a magnet
  • A "virtual device" such as the beam. The virtual "beam device" typically has properties such as the vertical or horizontal tune, chromaticity, etc.
Examples for parameters currently used at SIS18:
  • A parameter describing a physical value ("virtual")
    • The parameter named "SIS18BEAM/QH" which describes the beam's horizontal tune in SIS18's ring section
  • A parameter describing an intermediate calculation result (also "virtual")
    • The parameter "GS11MU2/I" which references the SIS18 GS11MU2 dipole's current as a function over time
  • A parameter referencing a device's property ("non-virtual")
    • The parameter named "GS11MU2/RAMPVALS" which describes the device front-end's property and it's specific technical data format
GS11MU2-I-ParamModi.png

Figure: SIS18 GS11MU2 dipole's current as a function over time

More information:

LSA Training Course part 1: parameter hierarchy and makerules, page 4

This is an excerpt from LSA Frequently Asked Questions.

3.1.2 Parameter hierarchy

Parameters are organized in a parameter model that describes the relations between parameters. The parameter model is an oriented graph of parameters. The roots of that graph are the top level parameters (physics parameters such as horizontal tune, chromaticity, etc...). Those root parameters have dependent ones (such as magnet strengths, magnet currents). The leaves of the graph are the hardware parameters (such as the current in the power converters).

The position of a parameter within the hierarchy is defined by
  • it's source parameters, i.e. the parameters it is calculated from
  • it's dependent parameters, i.e. the parameters which need it's value for their own calculation
SIS18BEAM-AOQ-ParamModi.png

Figure: Position of the parameter "SIS18BEAM/AOQ" (mass to charge ratio) within the currently used SIS18 parameter hierarchy.

On the "source parameter" side on the left, it can be seen that "SIS18BEAM/AOQ" is calculated using "SIS18BEAM/A" (atomic mass) and "SIS18BEAM/Q" (charge). "SIS18BEAM/A" is in turn determined by the information which element and isotope is concerned.

"SIS18BEAM/AOQ" is a direct input in the calculation of four other parameters, as one can determine by the number of arrows running from it's representation on the right hand "dependent parameters" view. One of those is visible in the screenshot, "SIS18BEAM/GAMMA", which represents the relativistic gamma factor. Apart from direct dependents, the hierarchy graph in ParamModi also shows all indirect dependencies down to the leaf nodes.

More information:

Progress and Challenges during the Development of the Settings Management System for FAIR, page 2

This is an excerpt from LSA Frequently Asked Questions.

3.1.3 Context

A context represents a period of time during which a parameter can be associated with a value.

We distinguish five types of contexts with different characteristics
  • Beam Process
  • Cycle
  • Super cycle
  • Beam Production Chain
  • Pattern
Beam process (used by both CERN and GSI)

A beam process defines a specific procedure (injection, ramp, extraction…) that happens in a defined section of an accelerator or transfer line (e.g. SIS18RING, SIS18_TE_ES).

Beam processes are executed as atomic operations within the control system; once started, a beam process is always executed to its end.

There is a distinction between beam-in beam processes, which define the state of the machine with beam, and beam-out beamprocesses, which define the state of the machine when there is no beam.

Beam Process Types are used to define certain characteristics that all beam processes of this type share.
Cycle (used at CERN and at GSI until SIS18 beam time 2016)

It defines a beam (from injection to extraction) including the beam-out part. Cycles are usually organized in supercycles because they do not necessarily preserve the state of the machine. The state of the machine at the end of the cycle is not necessarily the same as the one at the start because, for example, of possible remnant effects in the magnets. A special type of cycles is the standalone cycle which doesn't need a supercycle as a container.
Super Cycle (used at CERN)

Defines a series of Cycles used to produce beams for known clients. The main characteristic of the Super Cycle is that it can be repeated in a cycling machine. The state of the machine at the start of the Super Cycle is the same as the state at the end of the Super Cycle.

Beam_process_cycle_super_cycle_scheduling.png

Figure: Eight beam processes scheduled in two cycles scheduled in a super cycle
Beam Production Chain (used at GSI)

A Beam Production Chain describes the the whole lifespan of a beam from its initial creation at the source until it is destroyed at the target or dump. Unlike the Cycle or the SuperCycle, a Beam Production Chain can span accross multiple accelerators (e.g. first linear accelerator, then ring accelerator, then storage ring). The intention of this way of scheduling is to make a complex facility easier to manage for operators and maximize machine utilization / parallelization of beam production.
Pattern (used at GSI)

Comparable to what the Super Cycle is for its Cycles, the Pattern is used to define which Beam Production Chains will be executed within the facility during the time in which the Pattern is active. While there is one pattern that is executed many times or indefinately (until its execution is stopped), there can optionally be alternative patterns which get executed on request (e.g. when a certain an experiment is supplied with beam on request).

BPCs_and_Patterns_v2_fully_transparent.png

Figure: Example for parallel beam operation showing scheduling of beam production chains into patterns. HESR accumulating the anti-protons is omitted.

This is an excerpt from LSA Frequently Asked Questions.

3.1.4 Setting

A setting represents the value of a parameter for a given context.

relation_parameter_context_setting.png

Figure: Relation between parameter, context and setting

That setting's value is made up of two parts: the target and the correction. The target part is usually what has been generated. It is the theoretical value. The correction part is the empiric part that results from all modifications (trims) applied during operation to the value in order to establish the correct beam characteristics.

FAQ_WIL_Fig3.png

Figure: Visualization of a settingShown is the current in a SIS18 power converter during the ramp

When a trim is performed on a given setting (on a value for a given parameter at a given beam process) the requisite changes are propagated to the settings of the dependent parameters. At the level of the trim the correction value is updated while the modification is propagated to the target value of the dependents. There is an extensive API to manipulate settings. Applications like ParamModi utilize that API to modify and visualize the settings.

This is an excerpt from LSA Frequently Asked Questions.

3.2 Usage examples

3.2.1 A genuine cycle to play with

Holger Liebermann provided a copy of a cycle he prepared for machine experiments with LSA in May this year. It will be used in the following examples. The cycle's name is "SIS18_INTER_MANI_RAMP_FAST_238U73.GSI_H8H4.TRAINING".

SIS18_trainig_cycle_dipole_ramp.png

Figure: Dipole ramp for GS11MU2 from a cycle prepared for 2016 beam time machine experiments

Looking at the dipole ramp, one can easily spot the intermediate flat-top where bunch-merging is supposed to take place, going from H=8 to H=4 and how acceleration shall continue from there.

3.2.2 Reading Settings

3.2.2.1 Preparation

Please make sure that you run your application in two-tier mode on the development (DEV) database as shown in the following screenshot. You can access this window using the main menu and selecting "Run" -> "Run Configurations".

Configuration_2-tier_DEV_DB.png

Figure: Eclipse configuration for using two-tier mode and the DEV database
3.2.2.2 Task description

Determine the magnetic rigidity of the beam during injection into the ring from Holger Liebermann's cycle.

Here's the info you need:
  • The name of the cycle from which the settings shall be read is "SIS18_INTER_MANI_RAMP_FAST_238U73.GSI_H8H4.TRAINING".
  • One of the parameters that describe the beam's magnetic rigidity, i.e. the one we want to look at in SIS18, is called "SIS18BEAM/BRHO_START_END".
  • The injection beam can be identified using its purpose value, which is "RING_INJECTION".
3.2.2.3 Step 1: Retrieve the parameter from the ParameterService

final ParameterService parameterService = ServiceLocator
    .getService(ParameterService.class);

final Parameter parameter = parameterService
    .findParameterByName("SIS18BEAM/BRHO_START_END");
3.2.2.4 Step 2: Retrieve the cycle from the ContextService

ContextService contextService = ServiceLocator
    .getService(ContextService.class);

StandAloneCycle cycle = contextService
    .findStandAloneCycle("SIS18_INTER_MANI_RAMP_FAST_238U73.GSI_H8H4.TRAINING");
3.2.2.5 Step 3: Retrieve the cycle's settings from the SettingService

SettingService settingService = ServiceLocator
    .getService(SettingService.class);

ContextSettings settings = settingService
    .findContextSettings(cycle, Arrays.asList(parameter));
3.2.2.6 Step 4: Extract the injection beam process from the cycle

final BeamProcess beamProcess = Contexts
    .filterBeamProcessesByPurposes(cycle.getBeamProcesses(),
    GsiBeamProcessPurpose.RING_INJECTION).iterator().next();

3.2.2.7 Step 5: Print the parameter's settings for the beam process

final Setting setting = settings.getSetting(beamProcess, parameter);
System.out.println(setting);
3.2.2.8 Example output
Setting [id:35708468] [trimId:2014891] [valueType:DOUBLE_ARRAY] [creationDate:2016-04-26 16:54:29.232] 
SIS18BEAM/BRHO_START_END@SIS18_INTER_MANI_RAMP_FAST_238U73.GSI_H8H4.TRAINING$SIS18_RING_INJECTION$BP7
Target : (double[]:2) -> 1.1516801298794128, 1.1516801298794128
Correction : null

3.2.2.9 Full source code listing

package de.gi.cs.co.ap.playground.myNewMavenArtifact;

import java.util.Arrays;

import cern.lsa.client.ContextService;
import cern.lsa.client.ParameterService;
import cern.lsa.client.ServiceLocator;
import cern.lsa.client.SettingService;
import cern.lsa.domain.settings.BeamProcess;
import cern.lsa.domain.settings.ContextSettings;
import cern.lsa.domain.settings.Contexts;
import cern.lsa.domain.settings.Parameter;
import cern.lsa.domain.settings.Setting;
import cern.lsa.domain.settings.StandAloneCycle;
import de.gsi.cs.co.ap.common.dependencies.config.PropertyConfig;
import de.gsi.cs.co.lsa.settings.domain.GsiBeamProcessPurpose;

/**
 * @author Max Mustermann
 */
public class TemplateApplicationStep1 {

    /**
     * @param args some command line arguments
     */
    public static void main(final String[] args) {
        PropertyConfig.loadDefaultProperties();

        final ParameterService parameterService = ServiceLocator
            .getService(ParameterService.class);
        final Parameter parameter = parameterService
            .findParameterByName("SIS18BEAM/BRHO_START_END");

        final ContextService contextService = ServiceLocator
            .getService(ContextService.class);
        final StandAloneCycle cycle = contextService
            .findStandAloneCycle(
            "SIS18_INTER_MANI_RAMP_FAST_238U73.GSI_H8H4.TRAINING");

        final BeamProcess beamProcess = Contexts
            .filterBeamProcessesByPurposes(cycle.getBeamProcesses(),
            GsiBeamProcessPurpose.RING_INJECTION).iterator().next();

        final SettingService settingService = ServiceLocator
            .getService(SettingService.class);
        final ContextSettings settings = settingService
            .findContextSettings(cycle, Arrays.asList(parameter));
        final Setting setting = settings.getSetting(beamProcess, parameter);
        System.out.println(setting);
    }
}

3.2.3 Writing Settings

3.2.3.1 Task description

Modify the energy of the beam specified for injection to the ring and see how it influences magnetic rigidity

Hint: You can simply go on coding beneath what you implemented in section 3.2.2 (Reading Settings).

Here's the info you need:
  • The name of the cycle containing the settings we will be working with is "SIS18_INTER_MANI_RAMP_FAST_238U73.GSI_H8H4.TRAINING".
  • One of the parameters that describe the beam's magnetic rigidity, i.e. the one we want to look at in SIS18, is called "SIS18BEAM/BRHO_START_END".
  • The parameter that describes the beam's energy in SIS18 is called "SIS18BEAM/E".
  • The injection beam can be identified using its purpose value, which is "RING_INJECTION".

3.2.3.2 Step 1: Retrieve the energy parameter from the ParameterService

final Parameter energyParameter = parameterService
    .findParameterByName("SIS18BEAM/E");
3.2.3.3 Step 2: Create a scalar setting value

6 MeV was what Holger had specified. To see a difference, please alter the value.

final double energyValue = 6000000.0;
final Scalar energyScalar = ValueFactory.createScalar(energyValue);
3.2.3.4 Step 3: Create the trim request which specifies what shall be written

final TrimRequest trimRequest = new TrimRequestBuilder ()
  .setContext(Contexts.getStandAloneContext(beamProcess))
  .addValue(energyParameter, beamProcess, energyScalar)
  .setSettingPart(SettingPartEnum.TARGET)
  .build();
3.2.3.5 Step 4: Execute the trim request

final TrimService trimService = ServiceLocator.getService(TrimService.class);
try {
  trimService.trimSettings(trimRequest);
} catch (TrimException | DriveException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
}

ALERT! Trimming the injection energy causes a lot of calculations to take place and quite some values to be persisted on the database (several hundred parameter values are changed), so please have a look at your neighbor's screen and wait till his request is done. It should take about 30 seconds on the development cluster. Otherwise your request might be slowed down or blocked.
3.2.3.6 Step 5: Read the setting again and print the result

final ContextSettings newSettings = settingService
    .findContextSettings(cycle, Arrays.asList(parameter));
final Setting newSetting = newSettings.getSetting(beamProcess, parameter);

System.out.println("WAS BEFORE:");
System.out.println(setting);
System.out.println("IS NOW:");
System.out.println(newSetting);
3.2.3.7 Example output
WAS BEFORE:
Setting [id:35696582] [trimId:2014888] [valueType:DOUBLE_ARRAY] [creationDate:2016-04-26 16:28:06.357] 
SIS18BEAM/BRHO_START_END@SIS18_INTER_MANI_RAMP_FAST_238U73.GSI_H8H4.TRAINING$SIS18_RING_INJECTION$BP7
Target : (double[]:2) -> 1.1516801298794128, 1.1516801298794128
Correction : null

IS NOW:
Setting [id:35701522] [trimId:2014889] [valueType:DOUBLE_ARRAY] [creationDate:2016-04-26 16:29:08.642] 
SIS18BEAM/BRHO_START_END@SIS18_INTER_MANI_RAMP_FAST_238U73.GSI_H8H4.TRAINING$SIS18_RING_INJECTION$BP7
Target : (double[]:2) -> 1.1612688707455596, 1.1612688707455596
Correction : null
3.2.3.8 Full source code listing

package de.gi.cs.co.ap.playground.myNewMavenArtifact;

import java.util.Arrays;

import cern.accsoft.commons.value.Scalar;
import cern.accsoft.commons.value.ValueFactory;
import cern.lsa.client.ContextService;
import cern.lsa.client.ParameterService;
import cern.lsa.client.ServiceLocator;
import cern.lsa.client.SettingService;
import cern.lsa.client.TrimService;
import cern.lsa.domain.exploitation.DriveException;
import cern.lsa.domain.settings.BeamProcess;
import cern.lsa.domain.settings.ContextSettings;
import cern.lsa.domain.settings.Contexts;
import cern.lsa.domain.settings.Parameter;
import cern.lsa.domain.settings.Setting;
import cern.lsa.domain.settings.SettingPartEnum;
import cern.lsa.domain.settings.StandAloneCycle;
import cern.lsa.domain.settings.TrimException;
import cern.lsa.domain.settings.TrimRequest;
import cern.lsa.domain.settings.factory.TrimRequestBuilder;
import de.gsi.cs.co.ap.common.dependencies.config.PropertyConfig;
import de.gsi.cs.co.lsa.settings.domain.GsiBeamProcessPurpose;

/**
 * @author Max Mustermann
 */
public class TemplateApplicationStep2 {

    /**
     * @param args some command line arguments
     */
    public static void main(final String[] args) {
        PropertyConfig.loadDefaultProperties();

        final ParameterService parameterService = ServiceLocator
            .getService(ParameterService.class);
        final Parameter parameter = parameterService
            .findParameterByName("SIS18BEAM/BRHO_START_END");

        final ContextService contextService = ServiceLocator
            .getService(ContextService.class);
        final StandAloneCycle cycle = contextService
            .findStandAloneCycle(
            "SIS18_INTER_MANI_RAMP_FAST_238U73.GSI_H8H4.TRAINING");

        final BeamProcess beamProcess = Contexts
            .filterBeamProcessesByPurposes(cycle.getBeamProcesses(),
            GsiBeamProcessPurpose.RING_INJECTION)
            .iterator().next();

        final SettingService settingService = ServiceLocator
            .getService(SettingService.class);
        final ContextSettings settings = settingService
            .findContextSettings(cycle, Arrays.asList(parameter));
        final Setting setting = settings.getSetting(beamProcess, parameter);

        final Parameter energyParameter = parameterService
            .findParameterByName("SIS18BEAM/E");
        final double energyValue = 6000000;
        final Scalar energyScalar = ValueFactory.createScalar(energyValue);

        final TrimRequest trimRequest = new TrimRequestBuilder ()
                .setContext(Contexts.getStandAloneContext(beamProcess))
                .addValue(energyParameter, beamProcess, energyScalar)
                .setSettingPart(SettingPartEnum.TARGET)
                .build();

        final TrimService trimService = ServiceLocator
            .getService(TrimService.class);
        try {
            trimService.trimSettings(trimRequest);
        } catch (TrimException | DriveException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        final ContextSettings newSettings = settingService
            .findContextSettings(cycle, Arrays.asList(parameter));
        final Setting newSetting = newSettings.getSetting(beamProcess, parameter);
        System.out.println("WAS BEFORE:");
        System.out.println(setting);
        System.out.println("IS NOW:");
        System.out.println(newSetting);
    }
}

3.2.4 Advanced Trim Example

3.2.4.1 Covered topics

This example covers advanced topics such as
  • point and function trims (in contrast to scalar trims used in the previous example)
  • optics handling
  • advanced LSA client API usage
3.2.4.2 Source code

Feel free to run and study TrimDemo.java. It should help you get some inspiration when writing your own application. You're very welcome to contact the LSA team at GSI concerning questions that may arise.
3.2.4.3 Task description

Perform function and point trims of the steerer function settings.
  • First view the settings for one of the correctors using the SettingsViewer provided by ParamModi.
  • Choose one of the horizontal or vertical correctors (different one than in the example code, this one has already been trimmed).
  • Execute the two different types of trim shown in the example by commenting out the other one. The corresponding source code sections are marked with example 1 and example 2. After executing each example watch the changes in the settings.

3.2.5 Further reading

For more information...

4 Helpful libraries (14:15 - 15:00)

- Bibliotheken (Ralph Steinhagen)

5 Outlook

6 Wrap up

I AttachmentSorted ascending Action Size Date Who Comment
Configuration_2-tier_DEV_DB.pngpng Configuration_2-tier_DEV_DB.png manage 93 K 15 Apr 2016 - 16:50 HannoHuether  
GS11MU2-I-ParamModi.pngpng GS11MU2-I-ParamModi.png manage 12 K 15 Apr 2016 - 11:40 HannoHuether  
SIS18_trainig_cycle_dipole_ramp.pngpng SIS18_trainig_cycle_dipole_ramp.png manage 12 K 15 Apr 2016 - 16:27 HannoHuether  
TrimDemo.javajava TrimDemo.java manage 10 K 26 Apr 2016 - 17:41 JuttaFitzek Advanced Trim Example (function trim and point trim of the steerer function settings)
Topic revision: r38 - 15 Apr 2020, JuttaFitzek
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback