How to plug a new Instrument

From Intrument Element Wiki

Jump to: navigation, search

Contents

Programming a new Instrument

To program a new instrument consist in the implementation of 2 or 3 interfaces, depending on the kind of control that need to be developed. What follows is a description of each one. Once you have implemented these interfaces you can enter the name of the class that you develop in the configuration file as specified in section 1.5 of this page.

Instrument Control

This class represents the abstraction of a generic instrument and it allows the remote control. Please note that an Instrument Manager (IM) can be seen as an instrument too. An Instrument Manager (IM) is the implementation of a common interface to an instrument or possible a group of real instruments or a simulation of real instruments. An IM is completely described by parameters, attributes, commands, and finite state machine:

  • Parameters hold configuration information
  • Attributes hold instrument variables
  • Command hold actions
  • Finite state machine adds constraints over the commands

IMs can be organized in a hierarchy as happens in most of the available control systems (EPICS, TANGO, PVSS, ...):

IM1

|

| |

IM2 IM3

You can refer to the javadoc of this interface for more information.

Image:InstrumentControl.jpg

EXAMPLE: Voltmeter If the Instrument manager represents a virtualization of a voltmeter (it is a measuring instrument for measuring the voltage between two points in an electric circuit. more info at: http://en.wikipedia.org/wiki/Voltmeter . A simplified mapping of parameters, attributes, commands, and finite state machine could be:

  • Parameters: Maximum Voltage, Minimum voltage
  • Attributes: measured Voltage
  • Commands: Perform a measure
  • Finite State Machine: IM-Linked (the IM is connected the instrument), IM-Unlinked, Error.

InstrumentFunctionality

This interface represents a generic Instrument Manager from the functionality point of view. A generic Input service, like the Error Receiver, the State Receiver, Event Listeners and the Input manager should use this interface in order to present the received information to the particular IM. You can refer to this link for more information.

Image:InstrumentFunctionality.jpg




Parameter Listener

This interface contains the functionality of a generic event listener. Listeners can work in pull or push way. This object can be used in order to retrieve parameters that belong to the physical instrument. You can refer to this link for more information. Image:ParameterListener.jpg


Complete Example

the class HelloWolrdIE represents a complete Object interaction. You can refer to this link for more information


Image:helloworld.jpg


Configuration Parameters

Instrument Configuration Parameters are olded by the following files:

  • Brain.properties : it holds configuration information about your instrument
  • log4jDefault.properties : it holds additional logging information

you can find both the files in:

  • <yourWebAppName>/conf/advanced if your Instrument Element has already been deployed in a Tomcat
  • <yourProjectName>/src/main/webapp/conf/advanced if you are programming your new instrument


in the Brain.properties you can specify the following information:

#Specify which problem solver engine should be used
BrainType=org.ie.impl.imimpl.HelloWorldIE

#Put true if you want that your Instrument Element will never be destroyed, any time the 
#destroy() method will be called a getIstance() will be automatically triggered.  
StartAsService=false


#Any other properties that you may want to specify will be loaded in the 
#Instrument Element Context and will be available in your classes 
#example: 
#MyProp=MyValue
 

remember that both BrainType and StartAsService are mandatory properties wile you can specify any other properties that you may need. You will be able to retrieve these properties in the code using the following command:

Properties prop=(Properties)IEContext.lookup(InstrumentElementConstants.ADVANCED_CONFIGURATION_PROPERTIES);


in the log4jDefault.properties file you can specify information related to the log4j configuration of the logger. What follows are example of configurations:

# An example log4j configuration file that outputs to file.  The
# output information consists of relative time, log level, thread
# name, logger name, nested diagnostic context and the message in that
# order.

# For the general syntax of property based configuration files see the
# documentation of org.apache.log4j.PropertyConfigurator.
# you can find more information at: http://logging.apache.org/log4j/index.html
 
#log4j.rootLogger=DEBUG, A1

# A1 is set to be a ConsoleAppender which outputs to file. 
#log4j.appender.A1=org.apache.log4j.FileAppender
#log4j.appender.A1.file=./IE.log


# A1 is set to be a SocketAppender. 
#log4j.appender.A1=org.apache.log4j.net.SocketAppender

# hostname and port
#log4j.appender.A1.RemoteHost=localhost
#log4j.appender.A1.Port=4445
#log4j.appender.A1.RemoteHost=137.138.186.175
#log4j.appender.A1.Port=4560

# A1 uses PatternLayout.
#log4j.appender.A1.layout=org.apache.log4j.PatternLayout

# The conversion pattern uses format specifiers. You might want to
# change the pattern an watch the output format change.
#log4j.appender.A1.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n

#Set the interesting lever for each packages
log4j.logger.org.apache=error
#log4j.logger.org.ie=debug
log4j.logger.org.ie=info
Personal tools