Home

GDA Developer Guide

image

Contents

1. 7 1 CORBA in the GDA 37 GDA Developer Guide Release 8 10 gda device detector phantom corba impl PhantomImpl PhantomAdaptor gda device detector phantom corba impl PhantomAdaptor 7 1 6 Validating CORBA JARs The compiled code in a CORBA JAR can get out of sync with the IDL file that was used to generate the code A CORBA JAR can be validated using gda build py For example validate the CORBA JAR in all plugins gda build py corba validate jar validate the CORBA JAR in the specified plugins only gda build py i core corba validate jar This recompiles the IDL file to produce Java source code then compiles the Java source code to produce class files The newly compiled class files are compared to those inside the CORBA JAR Any mismatches are reported 7 1 7 Viewing objects bound in the name server After a GDA object server has been started JacORB s NameManager can be used to view the objects bound in the name server The NameManager can be started using the gda launcher using the command gda namemanager This will launch the NameManager B JacORB NameManager 7156 File Edit Help RootContext Name Kind Type Host LeftFrontjack_Motor gda device motor corb IDl gda device motor c 172 23 4 197 Jack gda device scannable IDL gda device scannabl 172 23 4 197 FrontjackScannable gda device scannable IDL gda device scannabl 172 23 4 197 GDAMetadata gda data metadata cor IDL gda data m
2. HR RI hades The name of the resulting CORBA proxy implementation is based on the name of the device class The con vention is new name old name lowercased apart from first letter Impl For example a device class called PowerSupply has a CORBA proxy generated with name PowersupplyImpl 6 4 CORBAising the object 33 GDA Developer Guide Release 8 10 34 Chapter 6 Client GUI development CHAPTER SEVEN REMOTING 7 1 CORBA in the GDA 7 1 1 Introduction This section describes how to create a new object and CORBA enable it that is create the additional files interfaces and classes needed for the clients to interact with the object remotely 7 1 2 Writing the Java code Create the Java interface for the object External hyperlinks like gda device detector Phantom Write an implementation of your interface For example gda device detector phantom PhantomV73 Note that if the interface is some package Xxx the implementation should be in some package xxx SomeClass In the case of the Phantom the PhantomV73 class fits into the Device Scannable Detector hierarchy but an object implementing the PhantomV73Controller interface is used to actually interact with the hardware or a simulation of it 7 1 3 Creating CORBA specific files Create an IDL that matches the Java interface For example phantom idl A few points e Note that whereas the Java interface is called Phantom the CORBA interfa
3. This registers certain objects you create in the Spring context as the application wide singleton instances e g the metadata Objects in Spring XML files are by default singletons In a perfect world the metadata and other singletons could be injected into other objects rather than the other objects calling Whatever getInstance In practice it s difficult to do this because 1 there are too many objects that need the singletons and 2 not all of those objects will be defined in the Spring XML file It s good to define the objects in the Spring XML file as this gives us complete control over their configuration and means we can swap the real objects for mock objects But this means we need to register those objects with some kind of registry 8 1 13 Property editors Propert yEditor Javadoc is a standard Java interface concerned with converting text representations of prop erty values into their real types among other things In Spring they are used to convert the text values used in Spring configuration files into the type required by the bean being instantiated Spring has built in support for many types already but by putting this in your Spring configuration lt import resource classpath gda spring propertyeditors registration xml gt you will also be able to set properties of these types e double 2D double array e org apache commons math linear RealMatrix Commons Math matrix and a
4. builder Contains scripts to compile the source and to build the client and the CORBA java code from the IDL source documentation Contains the documentation source Compile this by running make all The compiled docu mentation in various forms will be placed in a sub folder called build example config Contains the example configuration Configuartion folder have a standard structure which will be explained below features Standard Eclipse Java IDE workspace directory Contains the features projects licenses Licensing information of the third party software used in the GDA plugins Standard Eclipse Java IDE workspace directory Contains the plugins projects thirdparty Contains some third party software required to compile the GDA This software is referenced by the GDA build target which should be set when compiling the source code from an Eclipse IDE This is referenced automatically by the build scripts For new developers the folder of most interest will probably be the example config where the beamline specific configuration will need be defined 3 2 1 Adding new or existing plugins When creating a new plugin the plugin project must be located in the plugins directory or the build and startup scripts will not work properly Existing plugins can be imported into the workspace from the Eclipse IDE by running the import wizard File gt Import gt General gt Existing Projects Ensure that the Copy Into Workspace checkbox is sel
5. Note The dimension arguments must correspond to the dimensions of the nested scan Both the inner and our scans are from 2 0 to 2 0 in steps of 0 2 therefore each dimension consists of 21 points 12 Chapter 2 Introduction to the GDA GDA Developer Guide Release 8 10 Plot the outer scan data over the range of the combined scan This consists of 441 21x21 points The value of the outer scan increments every 21 points gt gt gt data plot DataSet arange 441 data 1 1 0 954 0 95 0 85 0 87 0 75 1 0 7 7 0 65 4 0 6 4 0 54 y axis 0 45 045 0 35 4 0 3 7 0 25 4 0 25 50 75 100 125 150 175 200 225 250 275 300 325 350 375 400 425 x axis Plot the inner scan data over the range of the combined scan This consists of 441 21x21 points The inner scan data consist of 21 adjacent Gaussians gt gt gt data plot DataSet arange 441 data 3 2 3 Using the plotting functions in GDA 13 GDA Developer Guide Release 8 10 y axis Plot an image gt gt gt Plotter plotImage Data Vector 0 95 4 0 9 17 0 85 4 0 87 0 757 0 77 0 65 4 0 6 4 0 554 0 5 4 0 45 4 0 44 0 35 7 0 37 0 25 4 0 2 4 0 15 4 0 1 4 0 05 4 25 50 75 100 125 150 175 200 225 x axis test1 250 275 300 325 350 375 400 425 14 Chapter 2 Introduction to the GDA GDA Developer Guide Release 8 10 Do the same for the second scan test2 data 3
6. such as scannables e The remote interface defined by the CORBA IDL files and the adapter and implementation classes often differ from the methods implemented by the real object An object exported using RmiServiceExporter and a proxy automatically generated by RmiProxyFactoryBean would not account for these differences e CORBA adapter and implementation classes often include additional logic not present in the real object They also sometimes carry out type conversion Again using the standard RMI exporter proxy beans would not take these differences into account e CORBA adapter and implementation classes often carry out conversions between real ex ception types such as DeviceException and CORBA specific exception types such as 7 2 Alternatives to CORBA 39 GDA Developer Guide Release 8 10 CorbaDeviceException This means that the exceptions that a client needs to be prepared to handle are often quite limited Using an automatically generated RMI proxy would mean that the client may need to be modified to deal with other exception types However if you are developing new objects and wish to invoke methods remotely using this mechanism may be sufficient Using GdaRmiServiceExporter and GdaRmiProxyFactoryBean Spring s RmiServiceExporter and RmiProxyFactoryBean classes are not appropriate when the server side object implements TObservable for two reasons e Although the object
7. 01 x Change the period and phase of ss and rescan gt gt gt ss period 0 2 gt gt gt ss phase 1 0 gt gt gt scan ss 2 0 2 0 0 02 8 Chapter 2 Introduction to the GDA GDA Developer Guide Release 8 10 Current File Name 183 dat 2 0000E00 1 7500E00 1 5000E00 1 2500E00 1 0000E00 7 5000E 01 5 0000E 01 Yarious Units 2 5000E 01 0 0000E00 2 5000E 01 5 0000E 01 7 5000E 01 1 0000E00 2 000E00 1 750E00 1 500E00 1 250E00 1 000E00 0 000E00 1 000E00 1 250E00 1 500E00 1 750E00 2 000E00 7 500E 01 5 000E 01 2 500E 01 2 500E 01 5 000E 01 7 500E 01 x Change the magnitude phase and noise of the sine and rescan gt gt gt ss magnitude 2 0 gt gt gt ss phase 0 5 gt gt gt ss noise 0 2 gt gt gt scan ss 2 0 2 0 0 02 Current File Name 184 dat 2 0000E00 1 7500E00 1 5000E00 1 2500E00 1 0000E00 7 5000E 01 5 0000E 01 2 5000E 01 0 0000E00 2 5000E 01 5 0000E 01 7 5000E 01 1 0000E00 1 2500E00 1 5000E00 1 7500E00 2 0000E00 Warious Units 2 000E00 1 750E00 1 500E00 1 250E00 1 000E00 1 000E00 1 250E00 1 500E00 1 750E00 2 000E00 7 500E 01 5 000E 01 2 500E 01 2 500E 01 5 000E 01 7 500E 01 Multiple scans can also be nested to an arbitrary level To illustrate a nested scan with two levels i e an inner scan nested within an outer scan we can define the outer scan to set
8. Le o o MT N o G o o o o o o o N wo o a va va va n n a n n va a 1 1 1 1 1 drd land a N wm mm x Make a new instance of ScannableGaussian setting values for its additional optional properties and scan it gt gt gt sg2 ScannableGaussian sg2 0 0 centre 0 75 width 1 54 height 2 0 noise 0 gt gt gt scan Sg2 2 0 2 0 0 02 2 2 Example devices 7 GDA Developer Guide Release 8 10 Current File Name 181 dat 2 0000E00 1 7500E00 1 5000E00 1 2500E00 1 0000E00 Warious Units 7 5000E 01 5 0000E 01 2 5000E 01 o o o o un un o o o o a o a a a Z 5 5 a 5 a a a a a a D D rx Y Y Y a Y 7 Y a a a D D w w w w w w a G Ss in a Sa Ss Z a Z Z Z gt in gt in gt a in A a Z L Z L Z S E N in LN L a S S 5 En ai i 1 1 1 1 r w ai a wi r T i i x Make an instance of a ScannableSine class and scan it gt gt gt ss ScannableSine ss 0 0 gt gt gt scan ss 2 0 2 0 0 02 Current File Name 182 dat 2 0000E00 1 7500E00 1 5000E00 1 2500 00 x 1 0000 00 7 5000E 01 5 0000E 01 Various Units 2 5000E 01 0 000000 2 5000E 01 5 0000E 01 7 5000E 01 1 0000E00 2 000E00 1 750E00 1 500E00 1 250E00 1 000E00 0 000E00 1 000E00 1 250E00 1 500E00 1 750E00 2 000E00 7 500E 01 5 000E 01 2 500E 01 2 500E 01 5 000E 01 7 500E
9. Note that the main logging system has its own configuration files gda jython userScrlipglobal read write directory for users to write their own scripts gda data scan dat alwthetderectdey where data files are to be written This can be made to be dynamic using the visit variable and configuring the ICAT system gda data scan dat alwthetdata fdamathchiclascans write gda rcp workspace where workspaces are created for the RCP client This will need to use variable interpolation if multiple RCP clients are to be allowed A properties file can include another properties file by using the include directive For more information see the Includes section in the Commons Configuration User s Guide 8 4 Metadata 8 4 1 ICAT The ICAT subsystem talks to a database an RDBMS or an xml file which maps user id s to beamlines and experiments It is used to find which experiments the user who started each client belongs to and so where any data should be written to by scans collected under the command of that client If no ICAT is used then data is always written to the same folder as defined by the gda data scan datawriter datadir java property Some examples of different ICAT systems To always write to the same data dir gda data scratch data gda data scan datawriter datadir gda data For no ICAT but to change the data directory in every different experiment gda data scratch data gda data metadata icat type gd
10. Plotter plot Data Vector DataSet arange 121 test2 test2 resize 11 11 lt nowiki gt Plotter plot Data Vector DataSet arange 121 testl Plotter plotImage Data Vector test2 Plot the individual data sets over the complete scan range 2 3 Using the plotting functions in GDA 15 GDA Developer Guide Release 8 10 gt gt gt data plot DataSet arange 121 data 0 gt gt gt data plot DataSet arange 121 data 1 gt gt gt data plot DataSet arange 121 data 2 gt gt gt data plot DataSet arange 121 data 3 Alternative plotting command using Plotter 121 data gt gt gt Plotter plot 441 data gt gt gt Plotter plot gt gt gt Plotter plot gt gt gt Plotter plot Data Vector DataSet arange Data Vector DataSet arange Data Vector DataSet arange 121 Data Vector DataSet arange 441 data data Make a new data set the product of test and test2 and plot resulting in a 2D Gaussian both as flat image heat map and as rotatable 3D gt gt gt test3 testl x test2 gt gt gt Plotter plotImage Data Vector test3 gt gt gt Plotter plot3D Data Vector test3 16 Chapter 2 Introduction to the GDA GDA Developer Guide Release 8 10 X ARS Make a different combination of data and plot test4 testl test2 Plotter plotImage Data Vector test4 Plotter plot3D
11. gt Then do this lt bean id S1_top_motor class gda spring EpicsMotorFactoryBean gt lt property name deviceName value S1 YP gt lt bean gt EpicsMotorFactoryBean is a Spring factory bean the S1_top_motor object will actually be an EpicsMotor In addition to EpicsMotorFactoryBean there is also EpicsMonitorFactoryBean and EpicsPositionerFactoryBean they all need a deviceName 8 1 6 Importing one file into another lt import resource S1 xml gt Effectively the lt import gt is replaced with the contents of the imported file All the beans are in the same Spring context i e no need to duplicate the PropertyPlaceholderConfigurer the FindableNameSetterPostProcessor etc 8 1 7 Please use the ref attribute Instead of this lt bean id sl_bottom class gda device scannable ScannableMotor gt lt property name motorName value S1_bottom_motor gt lt bean gt you can do this 42 Chapter 8 GDA configuration GDA Developer Guide Release 8 10 lt bean id sl_bottom class gda device scannable ScannableMotor gt lt property name motor ref S1_bottom_motor gt lt bean gt Note the property is motor not motorName and this uses the ref attribute which plugs the S1_bottom_motor motor into the s1_bottom object so the ScannableMotor doesn t need to use the Finder to get the underlying motor it s already wired up using Spring Since Spring has thi
12. gt gt from scannableClasses import gt gt gt sgw ScannableGaussianWidth sgw scannableGaussian0 gt gt gt scan sgw 0 2 2 0 0 2 scannableGaussian0 1 0 1 0 0 02 This nested scan has an outer scan which sets the width of the contained scannable Gaussian to different values from 0 2 to 2 0 in steps of 0 2 The inner scannable is then plotted for each width from 1 0 to 1 0 in steps of 0 02 5 6 Demonstrate use of Scannable in terminal 29 GDA Developer Guide Release 8 10 30 Chapier 5 Writing new Device classes in Jython and Java CHAPTER SIX CLIENT GUI DEVELOPMENT 6 1 Introduction Having written new devices in Java and created instances of them on the server they can now be examined and controlled from the interactive Jython interpreter However the GDA also allows developers to build custom graphical components for direct interaction with the server side devices These custom GUI components can be added to the core GDA client This mechanism allows for a much more flexible means of examining and controlling new devices The process of extending the GDA client in this way requires two development steps e Writing the GUI component currently in Swing e Setting up the communication between the client side GUI component and the server side device These processes will be illustrated using an example of a simple power supply device which has two states On and Off 6 2 Writing the Swing GUI com
13. is org myls gda gui PowerSupplyTestFrame and can be run from the command line or from within Eclipse Appearance of the PowerSupplyPanel when the power supply is in state Off El Power s 31 GDA Developer Guide Release 8 10 Clicking the On button changes the state of the remote power supply to On This change is detected by the client side panel which updates to the stet below Power gt 6 3 Adding the new component to the GDA client The new GUI component is added to the GDA client by defining an instance of it the Spring beans configuration file client_beans xml in the documentation xml directory This configuration file is for including custom non core GDA components to the GDA client Another client configuration file client xml is used to define which of the predefined GDA graphical components to include in the client The client_beans xml configuration file is a Spring beans container and follows the Spring beans XML schema The bean definition for the PowerSupplyPanel is lt bean id powerSupplyPanel class org myls gda gui PowerSupplyPanel gt lt property name name value gdaPowerSupplyPanell gt lt property name psuName value gdaPowerSupplyl gt lt bean gt The new view appears in the GDA client as the panel gdaPowerSupplyPanel1 6 4 CORBAising the object See the corba manual next to this file for m
14. requires the adapter class to be named some package xxx corba impl Xxx Adapter Implementation class For Phantom this is PhantomImpl The implementation class must extend your CORBA object s POA class for Phantom this is called CorbaPhan tomPOA e The class needs two fields The real object a Phantom in the case of the Phantom A POA field e You need a 2 arg constructor which takes the real object and the POA Impl Factory will use this construc tor s Each method that you implement should delegate to the real object any exceptions must be converted into CORBA specific exceptions e g DeviceException to CorbaDeviceException See PhantomImpl for examples of how to implement these methods Adapter class For Phantom this is PhantomAdapter The adapter class may extend other adapter classes but always needs to implement your Java interface e g Phan tom e The class needs three fields A CORBA object e g a CorbaPhantom for the Phantom A NetService The object s name 36 Chapter 7 Remoting GDA Developer Guide Release 8 10 e You need a 3 arg constructor which takes a CORBA object the object s name and a NetService Adapter Factory will use this constructor e Each method that you implement should delegate to the CORBA object any CORBA exceptions must be converted into corresponding non CORBA exceptions e g CorbaDeviceException to DeviceException See PhantomAdapter fo
15. rmi RmiServiceExporter gt lt property name serviceName value gda ProsilicaServer gt lt property name service ref server gt lt property name servicelnterface value gda images camera prosilica server ProsilicaImageSer lt bean gt On the client side Spring s RmiProxyFactoryBean can be used to generate a proxy to the object on the server It will create a proxy object that implements the service interface each method makes a call to the remote object For example lt bean id prosilica_server class org springframework remoting rmi RmiProxyFactoryBean gt lt property name serviceUrl value rmi otherserver gda ProsilicaServer gt lt property name servicelnterface value gda images camera prosilica server ProsilicalmageSer lt property name refreshStubOnConnectFailure value true gt lt bean gt The refreshStubOnConnectFailure property causes the client to reconnect to the server if for example the server is restarted This allows a hot restart of the server without the need for the client to be restarted Note that using RmiProxyFactoryBean means that every call to a method in the service interface will result in a remote method invocation This is not appropriate for example for objects that implement IObservable for eventing See the next section for a solution to this There are currently a number of issues that prevent this mechanism from being used instead of CORBA for objects
16. time e g to wait 2 seconds gt gt gt pos w 2 all single value position so far multi input can move to multi value position e g pos mi 2 3 multi extra read only output values e g pos me can combine mie one input two read only outputs pos mie 4 10 3 Default detectors list_defaults add_default pil remove_default pil 51 GDA Developer Guide Release 8 10 10 4 Beam focusing fwhm full width half maximum minimise fwhmarea area of spot on detector in pixels Scan to show the images being plotted gt gt gt scan f 430 600 20 pil 20 To display the images images plotted on Data Vector panel to focus on region of interest peak2d setRoi 50 50 150 150 10 4 1 wide scan gt gt gt scan f 430 600 20 pil 20 peak2d finds 490 as the minimum data plotted as it s collected 10 4 2 finer scan gt gt gt go minval gt gt gt rscan f 20 20 2 5 pil 20 peak2d finds 482 5 as the minimum 10 4 3 get feature details gt gt gt minval 52 Chapter 10 GDA Demo CHAPTER ELEVEN DEVELOPING FOR THE GDA 11 1 Commit messages Start with one short line preferably less than 50 characters summarising the changes Follow this with one empty line then a more detailed description Here is an example SUBSYSTEM Short 50 chars or less summary of changes More detailed explanatory text if necessary Wrap it to about 72 characters or so
17. will be made available using RMI so that clients can invoke methods on it any events that the object generates will not be propagated to the client e On the client a remote method invocation will be performed for every method in an object s service interface including the Observable methods which will not work To export an object that generates events the GdaRmiServiceExporter and GdaRmiProxyFactoryBean classes should be used instead of RmiServiceExporter and RmiProxyFactoryBean respectively GdaRmiServiceExporter exports an object using RMI in much the same way as RmiServiceExporter except that any events generated by the object will be propagated through CORBA to clients GdaRmiProxyFactoryBean creates a proxy that handles Observable method calls locally The proxy is automatically connected to the CORBA event dispatch system and registers to receive events related to the server side object It also maintains a client side list of observers When events are received by the client side proxy they will be dispatched to observers Care must be taken to ensure that the names of the server side and client side objects match or events will not be received On the server the GdaRmiServiceExporter will arrange for events to be sent using the name of the underlying object So for this lt bean id A class gt lt bean gt lt bean class uk ac gda remoting server GdaRmiServiceExporter gt lt p
18. 0 gt lt property name inputNames gt lt list gt lt value gt x lt value gt lt list gt lt property gt lt property name extraNames gt lt list gt lt value gt y lt value gt lt list gt lt property gt lt property name level value 3 gt lt property name outputFormat gt lt list gt lt value gt 5 5G lt value gt lt value gt 5 5G lt value gt lt list gt lt property gt lt property name units gt lt list gt lt value gt mm lt value gt lt value gt counts lt value gt lt list gt lt property gt lt bean gt Now instantiate a ScannableGaussian using a predefined Gaussian Spring bean Spring beans definition of a test Gaussian object lt bean id testGaussian class org myls gda device scannable Gaussian gt lt property name testGaussian value testGaussian gt lt property name centre value 0 0 gt lt property name width value 1 0 gt lt property name height value 1 0 gt lt property name noise value 0 1 gt lt bean gt This test Gaussian bean can be used to create an instance of a ScannableGaussian using constructor injection with the test Gaussian as a constructor argument lt bean id scannableGaussian2 gt lt property name name value scannableGassian2 gt lt constructor arg ref testGaussian gt lt bean gt 5 4 2 Exercise Start with an empty server_bea
19. 1 6 0000E 01 5 0000E 01 Various Units 4 0000E 01 3 0000E 01 2 0000E 01 1 0000E 01 0 000000 2 000E00 1 750E00 1 500E00 1 250E00 1 000E00 0 000E004 1 000E00 1 250E00 1 500E00 1 750E00 2 000 00 7 500E 01 5 000E 01 2 500E 01 2 500E 01 5 000E 014 7 500E 01 x Change its centre to 1 and rescan gt gt gt sg centre 1 gt gt gt scan sg 2 0 2 0 0 02 6 Chapter 2 Introduction to the GDA GDA Developer Guide Release 8 10 Current File Name 179 dat 1 0000E00 9 0000E 01 8 0000E 01 7 0000E 01 6 0000E 01 5 0000E 01 Various Units 4 0000E 01 3 0000E 01 2 0000E 01 1 0000E 01 0 0000E00 o o o o o ot o d d o o o o o 2 2 2 2 S 5 a 3 z F S a a Z 2 2 o o o o o lu lu lu o ui Lu ui o o o o o o Le o ue o o o o o o o o o La o Lu o o MT N o o o o o o o o o N wo P o a va va va ML n in n va va va a 1 1 1 1 1 a E e N wo x Move again add some noise and rescan gt gt gt sg centre 0 5 gt gt gt sg noise 0 2 gt gt gt scan sg 2 0 2 0 0 02 Current File Name 180 dat 1 0000E00 9 0000E 01 8 0000E 01 7 0000E 01 4 2 Z 6 0000 01 M 2 5 0000E 01 w 4 0000E 01 3 0000E 01 2 0000E 01 1 0000E 01 0 0000E00 o o o o o d o d o o o o o 2 2 2 S 3 F 5 E 3 E S amp 3 a 2 2 2 o o o o o ul lu lu o ul lu lu o o o o o o ue o MT o o o o o o o o uw o
20. Data Vector test4 2 3 Using the plotting functions in GDA 17 GDA Developer Guide Release 8 10 Plot the expanded resized data sets gt gt gt Plotter plot Data Vector DataSet arange 121 data 1 gt gt gt Plotter plot Data Vector DataSet arange 121 data 3 Do a nested scan of an outer Gaussian containing an inner sine gt gt gt scan scannableGaussian0 2 0 2 0 0 2 scannableSine 2 0 2 0 0 2 gt gt gt data loadSRS gt gt gt testl data 1 gt gt gt test2 datal 3 gt gt gt testl resize 21 21 gt gt gt test2 resize 21 21 gt gt gt test3 testl x test2 gt gt gt test4 testl test2 gt gt gt Plotter plotImage Data Vector test3 18 Chapter 2 Introduction to the GDA GDA Developer Guide Release 8 10 gt gt gt Plotter plot3D Data Vector test3 gt gt gt Plotter plotImage Data Vector test4 2 3 Using the plotting functions in GDA 19 GDA Developer Guide Release 8 10 gt gt gt Plotter plot3D Data Vector test4 20 Chapter 2 Introduction to the GDA CHAPTER THREE GDA CONFIGURATION 3 1 Introduction This section will outline the GDA installation and the various ways in which the GDA is configured 3 2 Installation Folder Structure Following the Quick Start guide and using the example downloadable from the opengda website the directory structure will have the folders
21. GDA Developer Guide Release 8 10 Jun Aishima Mark Basham Peter Chang Joachim Diepstraten Richard Fearn Matthew Gerring Paul Gibbons Karl Levik Geoff Mant Vasanthi Nagalingam Bill Pulford Eric Ren Tobias Richter Duncan Sneddon Robert Walton Matthew Webber Richard Woolliscroft Fajin Yuan December 06 2010 CONTENTS 1 Starting to develop the GDA 3 Lek Vanilla GDA e A ow Se ee eG A ea oe O 3 2 Introduction to the GDA 5 2 1 Example usage of the main Jython GDA commands 5 22 Example devices ss s ii a eh eB A a e Ge R Be a 6 23 Using the plotting functions In GDA s esi eere deoder eme e wii ee RR N 10 3 GDA configuration 21 Sel T S s 16 51T seg ie 2ST hb SASS eee ba A do Bet 21 3 2 Installation Folder Structure s 244544 do SO He E A RP Oe He Ee 21 33 Gontiguration Folder Structured aa os v ewe eye bbe eA pais A be eRe Seeds we i 22 4 Jython Script types 23 5 Writing new Device classes in Jython and Java 25 dl AMTOJUCHO ied oe ae ech Ee dela doe ese Hae RA ee Oe be Be ee Woes e YO 25 5 2 The Scannable interface and ScannableBase classes oo o 25 5 3 Description of the Scannable properties and relations between them 26 34 Add anew devicetotheseryer ecs p ex or eG a RA A 27 5 5 Examples of other Scannable classes and tests in GDA o ooo o 28 5 6 Demonstrate use of Scannable in terminal 29 6 Client GUI dev
22. In some contexts the first line is treated as the subject of an email and the rest of the text as the body The blank line separating the summary from the body is critical unless you omit the body entirely tools like rebase can get confused if you run the two together Write your commit message in the present tense Fix bug and not Fixed bug This convention matches up with commit messages generated by commands like git merge and git revert Further paragraphs come after blank lines Bullet points are okay too Typically a hyphen or asterisk is used for the bullet preceded by a single space with blank lines in between but conventions vary here Use a hanging indent Examples of SUBSYSTEM e CORE the code that is released on the website e DLS Diamond specific code e CONFIG configuration The following links provide advice on writing good commit messages e A Note About Git Commit Messages by Tim Pope e Creating good commit messages in the Git User s Manual e FreeBSD s Committer s Guide has some useful advice Search for Good commit messages s ScummVM Commit Guidelines 53 GDA Developer Guide Release 8 10 54 Chapter 11 Developing for the GDA CHAPTER TWELVE INDICES AND TABLES
23. a data metadata icat Nulllcat gda data scan datawriter datadir gda data visit change this for every experiment gda defVisit myVisit To use an ICAT to dynamically change the output directory depending on who is running the GDA client which has the baton control of the beamline gda data scratch data gda data scan datawriter datadir S gda data Syear Svisit gda data metadata icat type gda data metadata icat DLSIcat gda data metadata icat url jdbc oracle thin DESCRIPTION ADDRESS HOST S oracle h gda data metadata icat shift_tolerance 1440 gda data metadata dlsicat user icatusername gda data metadata dlsicat password icatpassword The DLSIcat class provides connectivity to the ICAT database There is an alternate class in the uk ac gda core plugin called XMLIcat which uses an XML file as a database This is primarily for use 46 Chapter 8 GDA configuration GDA Developer Guide Release 8 10 in unit testing or offsite demonstrations but could also be used by other facilities if they do a database dump into that format At Diamond the scripts in d1s_sw dasc bin iKittenScripts can be used to diagnose problems with ICAT For example e getCurrentVisit will show the ID of the current visit if there is one e getFedldsForCurrentVisit will show details of users on the current visit e getDetailsOfVisit will show information about a particular visit 8 5 Access Control GDA uses an
24. ackground and detailed description of GDA first read the GDA Users Manual in documenta tion docs This includes an introduction to GDA the GDA scripting environment a description of scanning data acquisition advanced plotting techniques and data analysis techniques A more detailed description of developing new components in GDA in Jython is provided in the GDA Jython training course in documentation docs This has practical examples of developing new components in Jython scanning them and plotting and analysing their output Here we describe further examples of user defined scannables in Jython and scanning and manipulating them from the Jython terminal 2 1 Example usage of the main Jython GDA commands List all scannable objects gt gt gt pos Help gt gt gt help List all devices gt gt gt ls List all scannable devices devices that implement the Scannable interface gt gt gt ls Scannable Import demo scannable definitions gt gt gt import scannableClasses gt gt gt from scannableClasses import Make a new instance of SimpleScannable gt gt gt simple SimpleScannable simple 0 0 Scan simple from 0 to 1 in steps of 0 01 gt gt gt scan simple 0 0 1 0 0 01 Get current position of simple gt gt gt pos simple Move simple to 0 5 gt gt gt pos simple 0 5 GDA Developer Guide Release 8 10 Delete an existing object gt gt gt del si
25. and the ObjectServer xml files to customise the objects representing hardware 3 3 1 File permissions The var and users directory are likely to require broader permissions from the rest of the GDA installation to allow processes run by any user to edit the files in those directories It is recommended in a production environment to use a var directory outside of the GDA installation as some of the files kept there may need to be used consistent across different versions of the GDA This make upgrading to new GDA versions easier 22 Chapter 3 GDA configuration CHAPTER FOUR JYTHON SCRIPT TYPES There are three different types of Jython scripts which may be written As their purposes are different it is helpful to place them in different directories and to even have different permissions on those directories Core Scripts Located in plugins uk ac gda core scripts These are general purpose scripts to be shared by all beamlines They are not intended to be edited by users or beamline staff Scripts should be placed within the gdascripts folder to clearly show that the modules are not Java classes which have a gda top level directory Beamline scripts Located in gda config scripts These are beamline specific scripts These will be data collection or analysis utilities which are not expected to be edited by users They may be written by beamline staff localStation py is located in this directory and run by the JythonServer
26. ce is called CorbaPhantom e Java and CORBA types are different for example a Java int corresponds to a CORBA long e Input parameters must be prefixed with in for example double getDemandVoltage in long electrodeNum ber raises device corba CorbaDeviceException 35 GDA Developer Guide Release 8 10 Compile the IDL to create CORBA classes It is no longer necessary to add the IDL file to an Ant script the make corba jar target automatically picks up all IDLs From the root of the GDA project type ant make corba jar Or if this fails try ant f build classic xml make corba Jar which will create a new gda corba jar that will include new classes for your object For Phantom these classes include e CorbaPhantomOperations interface containing the Phantom specific operations e g setupForCollection e CorbaPhantom interface representing the CORBA version of Phantom extends CorbaPhantomOperations plus some other CORBA interfaces e _CorbaPhantomStub implements CorbaPhantom and makes the CORBA remote requests e CorbaPhantomHelper various utility methods for working with CorbaPhantom objects Write the CORBA implementation adapter classes These classes must be located in the correct package so they are found e The interface for the device will be in some package Xxx e The ImplFactory requires the implementation class to be named some package xxx corba impl XxxImpl e The AdapterFactory AdapterFactory
27. ct uk ac gda core src gda spring namespaces gda gda gda Key Type choose Namespace Name Key enter http www diamond ac uk schema gda gda gda gda 1 0 xsd 8 1 2 FindableNameSetterPostProcessor Putting this lt bean class gda spring FindableNameSetterPostProcessor gt in your Spring XML file causes all Findable objects to have their name property set to be the same as the Spring id Therefore you don t except in a couple of special cases need lt property name name value gt 41 GDA Developer Guide Release 8 10 8 1 3 Making properties from java properties available Use this lt context property placeholder location file gda config properties java properties gt It allows you to use properties in your Spring XML files For example lt property name hostname value gda images camerahost gt 8 1 4 Instantiating EPICS devices directly For example lt bean id S1_top_motor class gda device motor EpicsMotor gt lt property name pvName value BL0O4J AL SLITS 01 Y PLUS gt lt bean gt 8 1 5 Instantiating using the EPICS interface behind the scenes This is for those who don t like having PVs in their XML files Put this somewhere in the Spring XML file it doesn t need an ID lt bean class gda configuration epics EpicsConfiguration gt lt constructor arg value gda config xml epics interface xml gt lt bean
28. ected Once the project has been imported if it has not been placed into the plugins folder perform a Refactor gt Move to relocate the new plugin project 21 GDA Developer Guide Release 8 10 3 3 Configuration Folder Structure The example config follows the standard folder structure This structure needs to be adhered to as the locations of the sub folders in the directory are assumed from the java property gda config The contents of the configuration directory is css Configuration files for the CSS synoptic perspective RCP client only lookupTables Location of lookup tables for the Scannable objects which use them properties Java Jacorb and JCA EPICS API properties files The Jacorb file has to be placed in a sub folder named etc scripts Location of beamline specific Jython scripts users For the example config contains log files user scripts and is where data will be written to It is likely that these files will want to be placed in other locations Use Java properties to define the directories where these types of files are to be located See the later section for more information about these Java properties var For files which are changed whilst the GDA is running xml The XML files which define the contents of the ObjectServer processes It is likely that for new developers when starting out with the GDA the items of most interest will be the java properties file to customise folder locations etc
29. elopment 31 Bl Untwoduction a seed NR dn ee bee AR AEA Re we N ee ee eee 31 6 2 Writing theSwing GUL component ea segs cba eS Ree Pewee Eee EE Le Hae 31 6 3 Adding the new component to the GDA client o o e 32 G4 CORBAISING the ODJSCL 6 4 ok eet ee Bee eee ek ee A 32 7 Remoting 35 TA CORBA mthe GDA jis Sn Gace be hea BERGA Be eee Ge bs as 35 7 2 Alternatives to CORBA lt w 344 Rb bea e ee ee ee 39 8 GDA configuration 41 Sal SPHNSCOMMSUTANOM sug eid oe ww See WS He Eee EEE Be Ee OS e Sys 41 2 EOSS ssa eaa PbS eee e a Ee Roe eae ee dw e o 44 8 3 Java Properties and Customising the GDA o 0000000 0G 45 SA Metadata sose a ket e a a taa E R RRR a lee be abo we a bt 46 8 5 ACCESS COMMON ca a id ae e a a a de ee ae ea eK ate ale A 47 9 Introduction to integrating EPICS in GDA 49 Sd Contipurine L es CAI lt argade eemeta ee ee See ek oR RE eS IA 49 10 GDA Demo 51 10 1 Basic commands 33 3 a gk a ee eB 51 10 2 Other seannables o s be ee Ke RGR A ROR See a EA 51 10 3 Detaultidetectors p k ssip p rd e a la AR ea o R a Ge E e 51 10 4 Beat TOCusinG sd a E EA A A SR 52 11 Developing for the GDA 53 Ii Commitmessag s cuore A A Lew 53 12 Indices and tables 55 GDA Developer Guide Release 8 10 Contents CONTENTS 1 GDA Developer Guide Release 8 10 2 CONTENTS CHAPTER ONE STARTING TO DEVELOP THE GDA A few notes for new developers 1 O
30. etadata 172 23 4 197 testLinearsMX gdavedevice scannable IDL gda device scannabl 172 23 4 197 GDAHashtable gda util findableHashta IDL gda util findableHas 172 23 4 197 scannableSinel gdav device scannable IDL gda device scannabl 172 23 4 197 scannableSine2 gda device scannable IDL gda device scannabl 172 23 4 197 plot_server uk ac diamond scisoft IDL uk ac diamond scis 172 23 4 197 testLinearM otorX gda device motor corb IDL gda device motor c 172 23 4 197 SimpleServiet gda util simpleServiet c IDL gda device corba C 172 23 4 197 scannableGaussianO gda device scannable IDL gda device scannabl 172 23 4 197 scannableGaussian1 gda device scannable IDL gda device scannabl 172 23 4 197 command_server gda jython corba impl IDL gda jython corba Co 172 23 4 197 scannableGaussian2 gda device scannable IDL gda device scannabl 172 23 4 197 scannableGaussian3 gda device scannable IDL gda device scannabl 172 23 4 197 scannableSine gda device scannable IDL gda device scannabl 172 23 4 197 LeftJackScannable gdavedevice scannable IDL gda device scannabl 172 23 4 197 simpleScannable gda device scannable IDL gda device scannabl 172 23 4 197 ScanDataStore gdaveutil simpleServet c IDL gda device corba C 172 23 4 197 RightFrontjack_Motor gda device motorscorb IDL gda device motor c 172 23 4 197 By default the gda launcher will try to automatica
31. h are read by the server at startup The devices can then be scanned and manipulated in GDA from the Jython terminal Developing software for new devices for GDA is a likely requirement at each site using GDA to accommodate specific beamline components into the GDA software framework Users should first read Chapter 5 Scanning in the GDA Users manual for an introduction to the basic data acquisition techniques used in GDA Below we describe developing new classes which implement the Scannable interface This will likely be required development at each site using GDA in order to accommodate specific beamline components into the GDA software framework 5 2 The Scannable interface and ScannableBase classes All Scannable classes implement the Scannable interface A core base class implementing the Scannable interface is available in GDA as the class gda devive scannable ScannableBase New user defined Scannable implementa tions should extend ScannableBase Instances of these will then be visible in the GDA terminal after issuing the command Is Scannable The most important methods for a Scannable to implement are 25 GDA Developer Guide Release 8 10 e getPosition e asynchronousMoveTo e isBusy Other fields in the Scannable that must be defined are name initial position e inputNames e extraNames e outputFormats e units A full description of the parameters available in a Scannable implementation is availab
32. interface called gda Jython authoriser Authoriser to discover whether users are au thorised to perform certain actions It provides two separate tests e Users may be local beamline staff in which case they are never shown the reduced GUI even when another user holds the baton Authorisers can report on whether a given user is staff e Each user has a device permission level an integer default is 2 for staff 1 for everyone else though these can be overridden in java properties Authorisers can return this integer level The authoriser is configured by setting a property to the class name representing the desired Authoriser class to use e g gda gui AcquisitionGUI authorisationMethod gda jython authoriser LDAPAuthoriser Any request to the authoriser will go to an instance of the class specified here A common implementation is the FileAuthoriser in fact the provided LDAPAut horiser implementation uses a FileAuthoriser to provide a local override FileAuthoriser uses two files which it looks for in gda user permissions dir or gda config xml if the first property isn t defined Both have the same format which is lt user_permissions gt lt user_id gt N lt user_id gt lt user_permissions gt Where user_id identifies a particular user and N is the numeric permission level Entries in the file user_permissions xml indicate what users exist and their device permissions If a user id is also found in the beamlinestaff
33. le in Chapter 5 Scanning of the GDA Users Manual A test class that has static methods for constructing instances of several different types of dummy or testable software Scannables is available in the documentation configuration src directory org myls gda device scannable ScannableClassGenerator It has methods e genarateScannableGaussian e generateScannableGaussian Gaussian e generateScannableSine e generateScannableSine Sine Wave This generator constructs instances of the two Scannable classes ScannableGaussian and ScannableSine These scannables classes differ in the value returned by getPosition For ScannableGaussian the method returns the value of a Gaussian of the specified position width and height 1 with additional noise if defined at the specified x value Override public Object getPosition throws DeviceException we assume the position is a double it is only for testing double x Double super getPosition double x2 x centre double sigma 0 425 width FWHM gt sd double noiseVal height Math random noise double y Math exp x2 x2 sigma sigma noiseVal return new Double x y 5 3 Description of the Scannable properties and relations between them This material is derived from Chapter 5 Scanning in the GDA Users manual it is repeated here for conve nience It is obligatory to set the values of several fields in the constr
34. lly determine the location of the JacORB configuration direc tory which contains the etc jacorb properties file that specifies the location of the name server This directory is typically SGDA_CONFIG properties If the directory cannot be determined automatically for any reason or if you want to use a specific JacORB configuration file the JacORB directory can be specified manually 38 Chapter 7 Remoting GDA Developer Guide Release 8 10 gda namemanager Jacorb path to jacorb dir The standard NameManager supplied with JacORB does not show all bound objects due to a bug The org jacorb naming namemanager plugin contains a patch for this bug If this plugin is present in your GDA installation it will automatically be included on the classpath The plugin must be compiled for the patch to take effect 7 2 Alternatives to CORBA 7 2 1 Using RMI Using a standard RMI exporter proxy For newly written objects RMI can be used to make those objects available over the network Spring s RmiServiceExporter can be used on the server side to make an object remotely available It must be told which object is being exported the name to export the object with and the service interface the interface defining the methods that should be available to clients For example lt the object that is to be made remotely available gt lt bean id server class gt lt bean gt lt bean class org springframework remoting
35. mple See the Jython training manual for more detailed descriptions and further examples 2 2 Example devices A Jython module containing several demonstration scannable objects is contained in the user scripts folder doc umentation users scripts scannableClasses py This file can be opened viewed and edited in the Jython Editor view in the GDA client If this view is not visible at startup select the JythonEditor view from the View menu in GDA New users can gain familiarity with the Jython terminal by following the examples below Users should type in the Jython commands below from the GDA Jython Scripting Terminal Each command follows the Jython terminal prompt gt gt gt A short description precedes each command or set of commands To superimpose successive scans on previous scans the Create new graph and Clear old graphs should be left unchecked Import all the classes from the demonstration scannableClasses module if not already done so above gt gt gt import scannableClasses gt gt gt from scannableClasses import Help is available for most of these classes gt gt gt help ScannableGaussian gt gt gt help ScannableSine Make an instance of ScannableGaussian gt gt gt sg ScannableGaussian sg 0 0 Scan it from 2 to 2 in steps of 0 02 gt gt gt scan sg 2 0 240 0 02 Current File Name 178 dat 1 0000E00 y 9 0000E 01 8 0000E 01 7 0000E 0
36. n3 no properties or constructor arguments are defined in the bean The scannable is constructed using the default no argument constructor All necessary properties are set to defaults in the Java class Similar examples are provided by several instances of the scannableSine class in the Spring configuration file e scannableSine0 the name and properties of the sine are set in the bean definition Default values for other properties such as input and extra names and output formats are defined in the Java class e scannableSinel the properties of the sine are assigned to the object by a test sine bean defined in the bean configuration file testSineWave bean e scannableSine2 no properties other than the name are defined in the bean definition All other properties are set in the zero argument constructor in the Java class 5 4 1 Example ScannableGaussian with setter injection Fields of the ScannableGaussian are set as properties in the Spring beans configuration file and default values defined Atomic fields are defined with name and value attributes fields array fields are defined using the list tag 5 4 Add a new device to the server 27 GDA Developer Guide Release 8 10 lt bean id scannableGaussianl class org myls gda device scannable ScannableGaussian gt g my g lt property name name valuew simpleScannablel gt lt property name position value 0
37. nce you have a version of the GDA source and a beamline or example configuration downloaded checked out you may compile by either opening the source in an Eclipse IDE or run the compile script The compile script will place the compiled classes in the same location as the Eclipse IDE 2 The GDA server runs as a regular Java process so uses the compiled classes located in the projects in the plugins and features directories 3 However the client is an RCP product and once compiled runs using its own compiled classes inside the client directory created when the client is compiled using the gda build script 4 You may run the client from the Eclipse IDE and this will not use any source code or other files from inside the client directory This would run entirely from compiled code in the plugins and features directory 1 1 Vanilla GDA For an empty GDA installation to add your own objects make the following changes to the example config 1 remove all scripts in the scripts directory except localStation py remove all scripts in the users scripts directory in xml client client xml remove all the objects below the comment in xml server remove all files and sub folders except server xml RN AeA WwW N in xml server server xml remove the imports near the bottom of the file GDA Developer Guide Release 8 10 4 Chapter 1 Starting to develop the GDA CHAPTER TWO INTRODUCTION TO THE GDA For general b
38. nfiguration 8 2 2 Client side logging configuration GDA has a default client side logging configuration file located in the uk ac gda core plugin in the file src gda util logging configurations client default xml A client side logging configuration file for a particular GDA configuration can be specified using the gda client logging xml property The default client side configuration will be applied first followed by the custom configuration 8 2 3 Using property placeholders in Logback configuration files You can make properties defined in java properties available for use in a Logback configuration file by adding the following element to the top of the file inside the lt configuration gt element lt property file gda config properties java properties gt Use of gda config works here because gda config is a system property You can then use property placeholders elsewhere in the file For example lt appender name SOCKET class ch qos logback classic net SocketAppender gt lt RemoteHost gt gda logserver host lt RemoteHost gt lt Port gt gda logserver port lt Port gt lt appender gt 8 3 Java Properties and Customising the GDA Properties to be shared throughout the code base are stored as name value pairs in the java properties file located in the config properties folder This is a common way to customise GDA behaviour Variable interpolation may be used when defining the ja
39. ns xml file add Scannable components one by one and test them in the GDA Jython console requires server restart to incorporate the new components 5 5 Examples of other Scannable classes and tests in GDA e DummyMotor from core gda device motor Dummy Motor e ScannableMotorTest from core test gda device scannable ScannableMotorTest s TotalDummyMotor from core used by test gda device motor TotalDummyMotor 28 Chapter 5 Writing new Device classes in Jython and Java GDA Developer Guide Release 8 10 5 6 Demonstrate use of Scannable in terminal The new components are now available to be controlled from the GDA client 5 6 1 Scan 1D The example scanabbles can be scanned and manipulated from the Jython terminal in the GDA GUI Scan the example scannable scannableGaussian0 from 2 to 2 in steps of 0 01 gt gt gt scan scannableGaussian0 2 0 2 0 0 1 Change the width of scannableGaussian0 from 1 to 2 and rescan gt gt gt scannableGaussian0 setWidth 2 gt gt gt scan scannableGaussian0 2 0 2 0 0 1 Change the centre of scannableGaussian0 to 1 0 and rescan gt gt gt scannableGaussian0 setCentre 1 gt gt gt scan scannableGaussian0 2 0 2 0 0 1 5 6 2 Nested scan Import the demo scannable classes defined in the user q demonstration module scannableClasses py located in documentation users scripts and viewable from from the JythonEditor view gt gt gt import scannableClasses gt
40. ny other types supported by the PropertyEditors listed in the GdaPropertyEditorRegistrar class 8 1 14 Example Spring configuration The Diamond 104 1 beamline uses Spring exclusively for its configuation If you have access to the GDA Subver sion repository you can view the 104 1 configuration The Spring contexts for the two object servers are split into multiple XML files which are all in the xml server directory 8 2 Logging Logging messages can be generated not only by GDA classes but also by third party libraries such as Commons Configuration GDA classes typically use the SLF4J API for logging Log entries from code that uses Commons Logging or Log4j are redirected into SLF4J using two SLF4J bindings Commons Logging over SLF4J and Log4j over SLF4J GDA uses Logback as the SLF4J implementation so logging entries are passed from SLF4J to Logback 44 Chapter 8 GDA configuration GDA Developer Guide Release 8 10 8 2 1 Server side logging configuration The server side logging configuration is used for object servers and for the event server GDA has a default server side logging configuration file located in the uk ac gda core plugin in the file src gda util logging configurations server default xml A server side logging configuration file for a particular GDA configuration can be specified using the gda server logging xml property The default server side configuration will be applied first followed by the custom co
41. object when it is started to customise the Jython environment for that beamline User scripts Located in a folder defined by the java property gda jython userscriptdir This is example config users scripts in the example These are script written by users for their experiment This is a separate folder from the other types of scripts as this directory may want to be emptied at the end of an experiment 23 GDA Developer Guide Release 8 10 24 Chapter 4 Jython Script types CHAPTER FIVE WRITING NEW DEVICE CLASSES IN JYTHON AND JAVA 5 1 Introduction New devices can be written using core classes in GDA These can be written in either Jython or Java For both Jython and Java 1 Define new devices in code 2 Load onto server object server For Jython 1 Define classes in Jython scripts that extend ScannableMotionBase 2 Load them into the object server by importing the Jython module and make instances of the Jython defined devices For Java 1 Write new devices in Java implementing different device interfaces Here we illustrate by writing new Scannable devices 2 Import instances of the classes defined in Spring beans configuration files To illustrate the process of developing new devices in Java and incorporating them into GDA we describe the process of developing several new devices that implement the Scannable interface These devices are then included in the system by editing configuration files whic
42. ogfiles Note It is an absolute requirement that the length of the outputFormat array is the sum of the lengths of the inputNames and outputNames arrays for the Scannable to work properly 5 4 Add a new device to the server The new device is added to the server by defining it as a bean in a Spring beans configuration file In the distribu tion this file is server_beans xml in the xml directory This file can be consulted for the syntax used to define new object instances as beans in the Spring beans configuration file The beans defined in this file are loaded into the object server at server startup and can be accessed and manipulated by the GDA client Both getter and constructor dependency injection can be used Each object on the server must have a name property which is its unique identifier in the server object namespace As an example we define several instances of the ScannableGaussian class using different bean definitions e scannableGaussian0 all properties set in the bean definition e scannableGaussianl only the properties of the Gaussian are set in the bean Other properties such as input and extra names and output formats are set to defaults in the Java constructor e scannableGaussian2 the scannable is defined using a constructor argument which is a test Gaussian bean defijned in the Spring configuration file This demonstrates constructor dependency injection by Spring e scannableGaussia
43. ore specifics 6 4 1 Writing the CORBA classes for GUl server communication Several generic CORBA classes are provided which external developers can extend These include CORBA adaptors Impl classes and base classes 6 4 2 Creating CORBA proxies for client server communication The new device is now available on the server and can be controlled from the Jython interpreter in the Scripting Terminal view For example scannable objects can be scanned and the result of the scan displayed automatically in plot window However it may the case that specialised GUI panel needs to be developed to control and simply the new device In that case communication must be set up between the client GUD and the object on the server In GDA this communication is CORBA based CORBA proxies for custom devices are built using the Ant target make corba jar This target calls compile corba classes which in turn calls compile idl definitions This invokes a CORBA idl2java compiler in this case org jacorb idl parser Therefore for each custom device that has been written it is also necessary to define an IDL for that class An example of an IDL for a simple power supply device is Module org Module myls Module gda Module device 32 Chapter 6 Client GUI development GDA Developer Guide Release 8 10 Module powersupply Module corba interface CorbaPowerSupply void setOn in Boolean on boolean getOn
44. otting refer to Chapter 6 Plotting in the GDA Users Manual and Section 6 Data analysis and visualisation in the GDA Jython training course Here we show a few basic plotting examples using the example Scannable classes in the module scannable Classes Make new ScannableSine gt gt gt del ss gt gt gt ss ScannableSine ss 0 0 period 0 5 Scan a scannable gt gt gt scan ss 4 0 4 0 0 05 Make a new ScanFile Holder object delete first if already have data object gt gt gt del data gt gt gt data ScanFileHolder Read the last scan into the ScanFileHolder gt gt gt data loadSRS Print information about the scan gt gt gt data info Plot column 1 against column 0 gt gt gt data plot 0 1 The plot and associated functions are available in the Data Vector view in the GDA client 10 Chapter 2 Introduction to the GDA GDA Developer Guide Release 8 10 0 9 0 8 0 7 4 0 6 DS 0 4 0 3 7 0 24 0 1 y axis o 0 2 0 3 4 0 4 0 5 4 0 6 0 7 4 0 6 0 9 4 e AA a T a S a Sa a A x axis Individual columns of the scan can be accessed from the complete scan gt gt gt datasetl data 1 and plotted against other data columns gt gt gt Plotter plot Data Vector data 0 dataset1 lt nowiki gt Characteristics of individual data columns can be accessed using different function
45. ponent All custom GDA GUI components must extend the GDA class AcqusitionPanel in the uk ac gda core plugin package gda gui This enables correct behaviour of the new component in the GDA client and enables some of the components of client server communication The example power supply GUI component extending AcquisitionPanel is in the documentation src tree org myls gda gui PowerSupplyPanel It comprises two JButtons On and Off Its behaviour is to toggle the state of the server side power supply between the two states using the buttons When the state of the underlying power supply is Off the Off button is disabled and the On button enabled Clicking on the On button changes the state of the server side power supply to On through CORBA implemented client server communi cation The GUI component is registered as an observer of the power supply and responds to any changes in state of the server side device In this example the state of the server side power supply has been changed by the user The GUI component responds to the changed state by disabling the On JButton and enabling the Off button This behaviour is implemented in GDA using the Observer and Observable interfaces The PowerSupplyPanel registers itself as on Observer of the server side power supply which sends changes in state back to the Power SupplyPanel A standalone application which wraps the PowerSupplyPanel component
46. r examples of how to implement these methods 7 1 4 How the remote call works Once the CORBA work has been done the object can be used like this MyObject myObject Finder getInstance find My_Object_Name myOb ject myMethod foobar The way this is handled is as follows e myObject myMethod foobar calls the corresponding method in the adapter e The adapter calls the CORBA stub The CORBA stub makes the remote call across the network e On the server the corresponding method in the implementation class is called by CORBA s The implementation class calls the real object 7 1 5 Reference Phantom idl ifndef _PHANTOM_IDL_ define _PHANTOM_IDL_ include lt detector idl gt module module module module module x x gda device detector phantom corba An interface for a distributed motor class interface CorbaPhantom void setUpForCollection in long numberOfFrames device corba CorbaDevice any retrieveData in long cineNumber raises Exception string command in string commandString raises L IND endif ImplFactory gda factory corba util ImplFactory AdaptorFactory gda factory corba util AdaptorFactory PhantomImpl device detector corba CorbaDetector in long framesPerSecond in long width in lon in long start in long count raises device corba CorbaDevice device corba Corb Exception
47. roperty name serviceName value gt lt property name service ref A gt lt property name servicelnterface value gt lt bean gt events will be sent with the object name A On the client the GdaRmiProxyFactoryBean must also be called A as otherwise it will not receive events from the server side object called A lt bean id A class uk ac gda remoting client GdaRmiProxyFactoryBean gt lt bean gt 40 Chapter 7 Remoting CHAPTER EIGHT GDA CONFIGURATION 8 1 Spring configuration 8 1 1 The gda namespace Using the namespace in your XML files To use elements from the gda namespace you will need to declare the namespace by adding the following attribute to the lt beans gt element in your Spring configuration xmlns gda http www diamond ac uk schema gda gda You will also need to add these entries to the xsi schemaLocation attribute http www diamond ac uk schema gda gda http www diamond ac uk schema gda gda gda gda 1 0 xsd Adding the namespace to your XML Catalog in Eclipse If you use elements from the gda namespace in your XML files you should add the schema for the gda names pace to the Eclipse XML Catalog so that Eclipse can validate XML files containing these custom elements To do this e Open the Eclipse preferences Window Preferences e Go to XML XML Catalog e Click Add s Enter the following details Location click Workspace and sele
48. s gt gt gt datasetl min 0 9999 gt gt gt datasetl max 0 9999 Datasets can be transformed gt gt gt datasetl datasetl min ct ct gt gt gt datasetl min 0 0 gt gt gt datasetl max 1 998 gt gt gt datasetl datasetl max gt gt gt datasetl min 0 0 gt gt gt datasetl max 1 0 The two commands above result in the dataset being normalised to the range 0 1 This is demonstrated by re plotting the data gt gt gt Plotter plot Data Vector data 0 datasetl 2 3 Using the plotting functions in GDA 11 GDA Developer Guide Release 8 10 0 65 0 6 0 5 04 y axis 0 3 0 25 4 3 5 3 2 5 2 1 5 1 0 5 0 05 1 165 2 2 58 3 S 4 x axis Generate double nested scan data Scan scannableGaussianl within a scan of scannableGaussian0 Both scans range from 2 0 to 2 0 with a step of 0 2 Both scans therefore consist individually of 11 data points gt gt gt scan scannableGaussian0 2 0 2 0 0 2 scannableGaussianl 2 0 2 0 0 2 Read the scan into a ScanFileHolder and print its information gt gt gt data loadSRS gt gt gt data info Plot each scan independently gt gt gt data plot data 0 data 1 gt gt gt data plot data 2 data 3 Extract the signal y i e Gaussian from the first scan gt gt gt testl data 1 Resize the data to a square grid gt gt gt testl resize 21 21
49. s dependency injection capability there s no need to use the Finder in new classes Spring can be used to do the wiring 8 1 8 Making remote objects available through CORBA You ll need this in your server side configuration lt corba export namespace stnBase gt You need to declare the corba namespace by putting this at the top of the XML file xmlns corba http www diamond ac uk schema gda corba and adding these entries to the xsi schemaLocation attribute http www diamond ac uk schema gda corba http www diamond ac uk schema gda corba gda corba 1 0 Due to a limitation of Spring property placeholders cannot be used in the namespace attribute when using lt corba export gt So this for example lt corba export namespace gda beamline name gt will not work Property placeholders are typically resolved by a PropertyPlaceholderConfigurer which is a BeanFactoryPostProcessor that operates on bean definitions in an application context The lt corba export gt element itself is not transformed into a bean definition it uses the namespace value to add bean definitions for remote objects It is not possible for the PropertyPlaceholderConfigurer to resolve placeholders used in the namespace attribute before that value is used to find remote objects 8 1 9 Importing remote objects from another object server You ll need this in your client side configuration lt corba import namespace stnBase gt As
50. the value of the inner scan The example class ScannableGaussianWidth in the scannableClasses module in directory documention users scripts takes an existing ScannableGaussian instance and sets the width of the scannableGaussian to its own current value The enclosed scannableGaussian can be scanned at each width across a user defined range Instantiate a new ScannableGaussianWidth object gt gt gt sgw ScannableGaussianWidth sgw 0 0 scannableGaussian0 Perform the nested scan gt gt gt scan sgw 1 10 1 scannableGaussian0 0 100 10 The results of this scan in the Terminal plot window are shown below 2 2 Example devices 9 GDA Developer Guide Release 8 10 1 0000E00 Current File Name 163 dat 3 0000E 01 8 0000E 01 7 0000E 01 6 0000E 01 5 0000E 01 various Units 4 0000E 01 3 0000E 01 2 0000 01 1 0000E 01 f 1 000E00 9 000E 01 8 000E 01 7 000E 01 6 000E 01 5 000E 01 4 000E 01 3 000E 01 2 000E 01 1 000E 01 0 000E00 1 000E 01 2 000E 01 3 000E 01 x 2 3 Using the plotting functions in GDA 4 000E 01 5 000E 01 6 000E 01 7 000E 01 8 000E 01 9 000E 01 1 000E00 Apart from the basic plotting window in the Terminal view which displays the current scan GDA also has some advanced plotting capabilities for previously recorded scans These are designed for post scan analysis and visu alisation For a detailed description of advanced pl
51. uctor of all Scannables These obligatory fields are e name e inputNames e extraNames e outputFormat 26 Chapter 5 Writing new Device classes in Jython and Java GDA Developer Guide Release 8 10 e currentPosition The fields inputNames outputNames and outputFormat together define what numbers this Scannable repre sents what they are called and the format for printing their values out to file or console The inputNames array defines the size of the array that this Scannable s rawAsynchronousMoveTo expects Each element of the inputNames array is a label for that element which is used in file headers etc Note that this array can be empty size 0 if required The extraNames array is used in a similar manner to the inputNames array but lists additional elements in the array returned by the Scannable s rawGetPosition method i e the array returned by getRawPosition may be larger than the array required by rawAsynchronousMoveTo This allows for the possibility that a Scannable may hold and return more information than it needs in order to move pr perform whatever operation it does inside its rawAsynchronousMoveTo method This array is normally empty size 0 269 The outputFormat array lists the formatting strings for the elements of both the inputNames and extraNames arrays It is used when printing the output from the rawGetPosition method to the console and l
52. va properties in the same manner as Spring or Logback xml files The following are the principal java properties which may need customising However there are many more Java properties assumed to be set by D flags when running the server processes Property Description gda root the plugins directory of the GDA installation The features and third party directories are assumed to be at the same level gda conf ijglocation of the configuration directory A standard sub structure to this directory is assumed Note that the RCP client will also rely on the gda config and gda data variables being set in its ini file Properties which must be set by a D flag when running the GDA Java processes third party software require ment These flags are added automatically by the Python start script 8 3 Java Properties and Customising the GDA 45 GDA Developer Guide Release 8 10 Property Description jacorb config dir S gda config properties this is the directory containing the etc directory for JacORB gov aps jca JCALibrary pyofoe EPICS The JCA library properties file Properties most likely to be customised Property Description gda data the top level data directory The sub directories where data files are actually written is derived by the gda data scan datawriter datadir property which should use variable interpolation gda logs dir global read write directory for any logging processes
53. with lt corba export gt to use the corba namespace you need to declare it at the top of the XML file The good thing about using corba import is that hidden beans are added to the Spring context for all of the remote objects so you can use them in any ref attributes elsewhere in the file 8 1 10 Enabling role based access control using lt gda rbac gt To enable role based access control RBAC add the following element to your Spring configuration lt gda rbac gt You must also set the gda accesscontrol useAccessControl property to true 8 1 11 The corba namespace As with the gda namespace if you use the lt corba export gt or lt corba import gt elements described above you should add the schema for the corba namespace to the Eclipse XML Catalog To do this follow the instructions for the gda namespace above but use the following values 8 1 Spring configuration 43 GDA Developer Guide Release 8 10 e Location uk ac gda core src gda spring namespaces corba gda corba 1 0 xsd e Key http www diamond ac uk schema gda corba gda corba 1 0 xsd Due to an issue with SpringSource Tool Suite you may still get the following warning which can be ignored Unable to locate Spring NamespaceHandler for element corba export of schema namespace http www diamond ac uk schema gda corba 8 1 12 SingletonRegistrationPostProcessor lt bean class gda spring SingletonRegistrationPostProcessor gt
54. xml file then that user is considered to be a member of local staff Note that although the two files have the same format the integer permission found in beamlinestaff xml is never used 8 5 Access Control 47 GDA Developer Guide Release 8 10 48 Chapter 8 GDA configuration CHAPTER NINE INTRODUCTION TO INTEGRATING EPICS IN GDA EPICS EPICS EPICS Integration of EPICS within GDA covers the creation of Scannables and Detectors that talk to EPICS as a Channel Access client allowing devices to be incorporated into a full Data Acquisition system 9 1 Configuring JCA and CAJ 9 1 1 Introduction This section describes how to create a new object and CORBA enable it that is create the additional files interfaces and classes needed for the clients to interact with the object remotely 49 GDA Developer Guide Release 8 10 50 Chapier 9 Introduction to integrating EPICS in GDA CHAPTER TEN GDA DEMO 10 1 Basic commands To get help help scannable software abstraction of angles slits energy temperature probe detector pos show current positions of all scannables e g POS x POS y pos Z shows extended syntax no brackets Move pos x 10 Is look at objects of certain types e g ls Motor Easy to write dummy scannables e g x y z for testing 10 2 Other scannables t shows time since initialisation dt shows time since last data point captured w waits for specified

Download Pdf Manuals

image

Related Search

Related Contents

operating instructions ue 200 - 800 ule 400 – 800 se 200  Samsung HW-C450 Käyttöopas  "user manual"  HÔTEL DES VENTES DE COULOMMIERS SAMEDI  Manuale di istruzioni  PROTOCOLE DE GESTION DU PANNEAU ELECTRONIQUE D  tournantes » en procès Mode d`emploi pour la rentrée universitaire  USER`S MANUAL TC200/ TC210/ TC300/ TC310 Series  Toshiba 27HL85 Flat Panel Television User Manual  Manual de Operação e Processo para a Produção de Laminados na  

Copyright © All rights reserved.
Failed to retrieve file