UNIVERSITY OF NEW SOUTH WALES School of Computer Science & Engineering Hardware control systems using Java November 2002 Oliver Mather Student Number 3015072 Bachelor of Engineering (Software) The University of Newcastle Supervisor: Assoc. Prof.
Abstract The purpose of this thesis is to apply Java technology to facilitate the creation of more reliable, portable, flexible and logical hardware control systems. This has been achieved by integrating Java tools and libraries throughout the development processes of several software projects. In particular, the development of enhancements to the Automated Patrol Telescope control software was conducted.
Acknowledgements Special thanks must be extended to my supervisor, Michael Ashley, and to Keith Bannister for their consistent patience and assistance throughout the year. Thankyou, also, to my SEARFE colleagues, Michelle Storey and George Warr. Most of all, thanks to all my family and friends for their help with just about everything. Everyone who has helped out is included in the puzzle below (names can be found up, down, right, left, and diagonally).
Contents 1 2 3 4 5 6 7 Introduction 11 1.1 Overview 1.2 Automated Patrol Telescope 1.3 Additional projects APT hardware 13 2.1 Introduction 2.2 APT building 2.3 Mistral 2.4 Telescope 2.5 CCD 2.6 Telescope movement 2.7 Masterswitch 2.8 Web cameras 2.9 Controller Area Network (CAN) 2.10 Roof 2.11 ROTSE APT software 25 3.1 Introduction 3.2 Portable Telescope Control System (PTCS) 3.3 Command line tools 3.4 Java Automation System (JAS) 3.5 APT server APT Masterswitch implementation 31 4.1 Introduction 4.
SkinnedTextField 63 8.1 Introduction 8.2 Requirements 8.3 Design 8.4 TextSkin 8.5 SkinnedTextFieldDemo 8.6 Suggestions and enhancements 9 CSIRO SEARFE project 69 9.1 Background 9.2 Introduction 9.3 Requirements 9.4 Hardware 9.5 Architecture 9.6 User interface 9.7 Suggestions and enhancements 9.8 Conclusion 10 Conclusion 83 10.1 Introduction 10.2 Java as a hardware control system language 10.3 Failure and fault analysis 10.4 Logging analysis Bibliography 87 A. Glossary 89 B.
List of Figures Figure 2-1 APT building Figure 2-2 Telescope Figure 2-3 Focus motor interface Figure 2-4 Right ascension motor Figure 2-5 Declination motor Figure 2-6 Incremental encoder Figure 2-7 Anti backlash motor Figure 2-8 Inner RA limit switches Figure 2-9 APC Masterswitch power distribution unit AP9212 Figure 2-10 Sky camera image Figure 2-11 Telescope Image Figure 2-12 Infrared camera image Figure 2-13 Nearby ROTSE Enclosure Figure 2-14 APT architectural diagram Figure 3-1 Mistral APT Command Line
Figure 9-6 Scan status panel Figure 9-7 Signal strength vs. scan number Figure 9-8 Signal strength vs. frequency and scan number Figure 9-9 Signal strength vs. frequency Figure 9-10 3D plot Figure B-1 JASCommand object Figure B-2 APT command sets Figure B-3 Implementing a ChannelMonitor Figure D-1 SNMP message Figure D-2 SNMP architecture Figure E-1 Celestial sphere, sourced from [ 4 ]. Figure E-2 Equatorial coordinates, sourced from [ 4 ].
1 Introduction 1.1 Overview This thesis documents the application of the Java language across several projects, the majority of which, are dedicated toward the Automated Patrol Telescope. However, much of the technology developed as part of these projects can be applied to other similar hardware control systems. 1.2 Automated Patrol Telescope These Chapters document efforts made to improve various software systems resulting in a more reliable control system for the Automated Patrol Telescope.
2 APT hardware 2.1 Introduction The APT is a term often used not simply to refer the Telescope itself, but rather to a complex system of integrated components. As a system, these components interact to provide comprehensive software remote control of the telescope and its environment. This Chapter provides an overview of the devices and how they interact to provide automated control. The APT architectural diagram, shown in Figure 2-14, is a useful aid in understanding the content of this Chapter. 2.
Control of the sliding roof, discussed in more detail in 2.10, gives the telescope rapid access to any part of the sky. The building also contains a control room, adjacent to the telescope, where much of the computer equipment is located. 2.3 Mistral Mistrali is an Intel desktop computer running the GNU Linux operating system which runs the majority of the software used to control the telescope and other devices inside the building.
Figure 2-2 Telescope Originally a Baker-Nunn satellite tracking camera, the telescope was donated to The University of New South Wales by the Smithsonian Institute in 1986. Since then, it has been significantly modified. The optics were redesigned to allow the use of standard 5-mm astronomical filters (see Appendix E.4), and also to produce a flat focal plane. This is discussed in more detail in Appendix E.5. Currently the telescope is fitted with a green ‘V’ filter.
2.5 CCD The CCD, or Charge Coupled Device, is a digital camera, similar to those commonly found in the marketplace today. The telescope is equipped with a Wright Instruments CCD camera with a resolution of 1152 x 770 pixels (digitised at 16 bits/pixel). The CCD is controlled using a Linux character device driver developed by Michael Ashley. 2.5.1 Focus control Focus is achieved by adjusting the distance of the CCD from the primary mirror inside the telescope.
Figure 2-5 Declination motor Figure 2-4 Right ascension motor Each servo motor is powered by its own DC servo amplifier which receives an analogue voltage from the Macrostation (see 2.6.4). In October 2002, the motors were upgraded to improve the average telescope slew time from approximately 120 seconds to 30 seconds for a 100 degree slew. Connected to each motor, is an Incremental Encoder (Figure 2-6), which is used to accurately measure the shaft rotation.
pushing the mount in the opposite direction to which it is travelling. Note that this motion will not be recorded by the software, which only monitors the encoders attached to the motor shafts. In order to compensate for this slack space, the anti-backlash motor, show in Figure 2-7, provides a constant tension in one direction, forcing the worm gear to remain in contact with one side of the main gear, eliminating any free movement of the telescope mount.
Figure 2-8 Inner RA limit switches 2.6.3 Tilt sensor The tilt sensor is used for calibration of the telescope. This is necessary to correctly interpret the data from the encoders, the encoders can only count the amount of movement or each axis. This information is meaningless unless used in conjunction with a known reference point. The tilt sensor has two digital outputs indicating if the telescope is east or north of the zenith.
2.7 Masterswitch Figure 2-9 APC Masterswitch power distribution unit AP9212 In principle, the Masterswitch is a very simple device. It allows software control of eight 240V power outlets. Currently, the Masterswitch is responsible for supplying power to the following devices within the APT enclosure. 1. 2. 3. 4. 5. 6. 7. 8. Anti-Backlash Motor RA Servo Dec Servo Macro Station CCD Camera Lens Fan Room Lamp Infra-Red Lamp The Masterswitch power is sourced from the UPS. 2.7.
The Management Interface Board also supports up to 16 user accounts, although this functionality is not required as the JAS provides user authentication. The Masterswitch control for the APT was originally done using TELNET. This has been rewritten as part of this thesis to use the SNMP protocol, covered in detail in Chapter 4. 2.8 Web cameras There are currently three web cameras installed at the site, detailed information on each camera is shown below.
2.9 Controller Area Network (CAN) Controller Area Network (CAN) is a serial bus system especially suited to interconnect smart devices to build smart systems or sub-systems [ 2 ]. A CAN is a collection of nodes, where each node can support digital I/O and analogue lines. Originally designed for the automotive industry, CANs are used in a broad range of industries such as factory automation, machine control, building automation, maritime, medical and railway applications.
2.11 ROTSE Figure 2-13 Nearby ROTSE Enclosure The ROTSE (Robotic Optical Transient Search Experiment) enclosure is situated just a few metres from the APT building. The ROTSE Telescope, like the APT has a wide field of view (1.8 x 1.8 degrees) and is equipped with a very fast slewing mounting. This makes it ideal for tracking Gamma Ray Bursts, as discussed in Appendix E.3. When it is fully operational , ROTSE will share much of the hardware and infrastructure of the APT system.
Anti Backlash Motor Lens Fan Outer Limit 6 S Inner Limit Dec Motor Up per Limit Focus Motor Interface Video 240V AC Analog I/O Anti Backlash Power Encoder Inner Limit N Low er Limit Outer Limit 1 Digital I/O IR Lamp Serial RS 232 Outer Limit CCD Camera Fibre Optic 10 base T Focus Motor 8 W Inner Limit APT Lamp 5 7 RA Motor CAN Bus E Mirror Heater Fibre Channel Encoder Inner Limit Outer Limit DC Coax Parallel Cable RA Servo Amplifier Dec Servo Amplifier 2 3 Sky Cam 2GH
3 APT software 3.1 Introduction As stated in 2.3, the GNU Linux operating system is an integral part of the APT system. It provides a centralised platform for the APT control software. Fundamental services such as the file system, networking and device drivers provide the basis for control software to be built. 3.2 Portable Telescope Control System (PTCS) PTCS is a generic telescope control system designed to support multiple telescopes in multiple operating environments.
3.
3.4 Java Automation System (JAS) 3.4.1 Introduction The Java Automation System (JAS), developed by Keith Bannister in [ 52 ], was designed to provide multi-user, secure, distributed automation of the APT system. In early 2002, the JAS was redesigned to improve its functionality and to further abstract its dependence on the JSDT package. The Java Shared Data Toolkit (JSDT), discussed in detail in [ 52 ], is essentially the middleware which facilitates network communication of the JAS.
public void sendToOthers(JASMessage message) { ... } public void sendToClient(JASMessage message, String clientName) { ... } JASMessages can contain any serializable Java Object. Telemetry information is typically sent as a Java Map object within a JASMessage. 3.4.2.2 Command execution In many ways the command execution environment of the JAS is similar to that of an operating system. Any object implementing the Command interface can be executed by a Process within a ProcessSpace.
subsystems as a set of key-value properties. The Masterswitch, discussed in detail in Chapter 4, is controlled in this way.
4 APT Masterswitch implementation 4.1 Introduction Currently the Masterswitch is controlled via an “Expect” script which runs a telnet session to interface to the device. Expect is a scripting language designed to respond to text on the screen. The JAS interfaces to the Masterswitch using the APTSystem framework. Each time a Masterswitch outlet property is set, the APTSystem calls the aptSetProperties script which inturn invokes the expect script. Eventually resulting in the outlet changing state. I.e.
These requirements were translated into the Java interfaces shown below: // Java interface to the APC AP9212 Masterswitch public interface Masterswitch { // Outlet States public static final public static final public static final public static final public static final public static final public static final String String String String String String String OUTLET_ON OUTLET_OFF OUTLET_REBOOT OUTLET_UNKNOWN OUTLET_ON_WITH_DELAY OUTLET_OFF_WITH_DELAY OUTLET_REBOOT_WITH_DELAY = = = = = = = "On"; "Off"; "Re
The AdventNet package is clearly of the highest quality. Feature rich, and backed by comprehensive documentation. However, the Masterswitch SNMP implementation will only require a basic set of SNMP operations, all supported by the open source packages. Of the open source alternatives, the JSNMP package was chosen primarily for its superior documentation, support and activity within the SNMP community. Also, the AgentAPI is used to parse the APC PowerNet MIB, [ 28 ].
which is represented internally as “.1.3.6.1.4.1.318.1.1.4.5.2.1.3”.This string is then appended with “.” to specify the outlet. The OID, and some data, if the operation is a SET, are packaged into a PDU which is then sent to the Masterswitch using the JSNMP SnmpSession object. The SNMP agent on the Masterswitch interface board then performs the appropriate action, resulting in an SNMP response being returned.
• Provide initialised references to the Masterswitch Object to be used by Commands to interact with the hardware 4.4.1 Commands Two commands were added to the APT Command set using the procedure defined in Appendix B.4. Given the simplicity of these commands, they only need to override the execute() method. // Switch Outlet Command public class MasterswitchSwitchOutletCommand() extends APTCommand{ public MasterswitchSwitchOutletCommand(int outlet, String newState ) {...} ...
4.4.2 Messages Masterswitch status information is broadcast to clients on the CHANNEL_MASTERSWITCH, initialised at the APTServer start-up . ... // APTServer.java // Create the Masterswitch Channel JASChannel masterswitchChannel = client.makeChannel(Channels.CHANNEL_MASTERSWITCH); masterswitchChannel.join(); // Initalise the Masterswitch JASMasterswitch.getJASMasterswitch( masterswitchChannel ); ...
public static final String KEY_OUTLET_1_STATE = "Outlet 1"; ... public static final String KEY_OUTLET_8_STATE = "Outlet 8"; ... // MasterswitchListener methods public void outletStateChanged(int outlet, String newState) { ... // Send a JASStatusMessage containing the new information to all clients // on the masterswitch channel JASStatusMessage msg = new JASStatusMessage(); Map map = msg.getValueMap(); map.clear(); map.put( keyForOutletState(outlet) , newState); try { masterswitchChannel.
4.6 Conclusion The design proposed and developed is being successfully used in the live system, providing a more reliable fine grained control of the hardware. SNMP Trap messages are also logged which may provide very useful information in the event of a serious hardware failure or devices in the enclosure.
5 APT user interface implementation 5.1 Introduction The existing user interface (shown below), was originally developed by Keith Bannister to provide an interface to the APT demonstrating the use of the JAS system. Since it was produced, the JAS System has matured and many features have been added. A higher quality user interface needs to be developed to fully utilise the remote operation capabilities of the APT. This new interface aims to be more intuitive, responsive and functional than its predecessor.
5.2 Architecture The user interface has been isolated as much as possible from the JAS to ease its portability to future versions of the JAS, or even other distributed control systems. Although many components reference JAS interfaces and objects, most JAS routines are found in the JASComms class. The diagram below shows the flow of data throughout the system.
time. This way, any connected users would be able to discern exactly what the system was doing, an invaluable tool for debugging and monitoring. A solution, suggested by Keith Bannister, would be to create a JASMessageSender (see Appendix B.2) as a registered ProcessListener on the server side, to broadcast ProcessEvents as JASMessages to clients. Thus allowing all connected users to monitor JAS processes. Figure 5-3 Process manager 5.
• • POWER: The status of the roofs power supply. It is either ON, or OFF MOVING:Possible values are OPENING, CLOSING, STOPPED, UNKNOWN These values are obtained by listening on the ROOF Channel, their values can be seen using the Roof Properties Frame, shown in Figure 5-5. The MOVING and POS are interpreted using the table in Figure 5-4 to create the roof status icon on the main status bar.
5.5 Chat system Given the distributed nature and complexity of the APT control system it is desirable to be able to communicate with other users currently logged in. For example, a higher priority user would be able to ask the current user what they were working on before overriding their control. This level of communication would also be very useful in a classroom environment. Students would be communicate remotely with other users controlling the telescope.
Figure 5-8 APT chat system 44
5.6 Look and Feel The Java Language comes with a rich user interface toolkit, the Java Foundation Classes, also known as JFC-Swing. Swing provides a rich set of widgets iand class libraries to build a professional user interface. One of its key features is the pluggable look and feel framework. This allows the programmer to dynamically switch between any look and feel. A Look and Feel is a collection of widget styles, colours, fonts, and input device semantics.
5.6.2 Problems • SwingUtilities.updateComponentTreeUI() in certain circumstances does not function as desired. For example, components that are not visible when this method is called will not be refreshed correctly and will retain the previous Look and Feel settings. This can be overcome by updateComponents(). a more explicit and rigorous implementation 5.6.
Figure 5-11 Aqua Look and Feel with Blue Digits textSkin 5.7 Conclusion This GUI is significantly more attractive, responsive and easier to use than its predecessor, providing a clear representation of the APT system and its components. Although very little additional functionality has been implemented, the framework exists to do so. As a finer grained level of control is provided by the JAS, the GUI can evolve to support these enhancements.
6 APT software deployment 6.1 Introduction The APT software is a very complex system of integrated software components and is constantly under development. The Java APT source code alone is approximately 8000 lines across 300 source files. The system also depends on several external packages such as the JAS and JSDT. Unfortunately, there is no test platformi and consequently the system spends the majority of its time running a test version of the software.
Web Start is designed to address several of the problems traditionally associated with the deployment of standalone applications: • Installation Issues • Upgrading to the latest version • Different versions of the JVM Once Web Start (or any JNLP client) is configured on the users machine, any Web Start application can be downloaded, installed, and executed from a single click on a web page. A JNLP enabled application is specified by an xml configuration file labelled .jnlp.
6.3.2 Security By default, all Web Start applications are run in a restricted sandbox with the following limitations (sourced from [ 49 ] ): • No access to local disk. • All jars must be downloaded from the same host. Note, however, that you can download extensions and JREs from any host as long as they are signed and trusted. • Network connections are allowed only to host from which your jars were downloaded. ("Phone home restriction.") • No security manager can be installed.
6.3.3 Resource loading Resources such as images, sounds, and any other additional application files cannot simply be referenced in the same way a normal application would. There are two major restrictions: • All resources must be packaged in jar files. Primarily to support versioning and download management for JNLP clients. • File paths cannot be used to reference the contents of these jar files.
CVS Repository apt lib jas jcan jsdt cvs checkout workspace unsigned jars ant sign-jars ant upload src ant prepare ant upload mistral mcba5 /lib /lib jas__V1.0.jar jas__V2.0.jar ... jas__V1.0.jar jas__V2.0.jar ... ant upload-mistral /apt__V1.0 /apt__V1.0 /apt__V2.0 /apt__V2.0 /apt__V3.0 /apt__V3.0 apt-client.jnlp runServer apt.jar config.jar ... apt-client.jnlp runServer apt.jar config.jar ... ant upload-mistral apt-client.
Once the workspace has been checked out from CVS the developer should manually edit the build.xml (see Appendix F.2.3) file and modify the version-key property. This property is used throughout the build process. This key must be unique, which is best achieved by simple incrementing the version count or perhaps using the developers name. Throughout the build process, covered below, a dist/apt__V directory is created.
doc-tar.gz Packages the JavaDocs and content of the doc directory code into the archive apt__V/apt-docs__V.tar.gz 6.5 Version synchronisation The APT System is a very dynamic software application, software changes on the server are likely to create incompatibilities with the client code. In addition to the flexibility of running multiple versions of the server, it is also necessary to synchronise the client code, so we can guarantee that the correct, corresponding version is run.
6.5.1 External libraries The solution discussed previously must be further developed to account for the versioning of the library files that the APT system uses. The upgrading of third party jar files must not compromise the ability of older versions or the APT to use the original versions of these libraries. A possible solution could be to simply package all the required jar files within the APT deployment directory, such that each version of the APT has its own copy of the libraries.
The ant upload targets discussed previously are simply calls to the scp command line tool. The deploy directory is uploaded to mcba5, and then to mistral to optimize network bandwidth for developers operating on slow connectionsi. The entire application can be compiled and deployed from a 56K modem connection in approximately 8 minutes. 6.
7 APT suggestions and enhancements 7.1 Introduction This Chapter contains a collection of improvements designed to increase the reliability and functionality of the APT system. These improvements range from hardware and software upgrades to the development process itself. 7.2 Hardware 7.2.1 Automated changing of astronomical filters Currently, the switching of astronomical filters (see Appendix E.4) on the APT is a very tedious process.
7.3.2 Maintenance The APT system relies heavily on several external software libraries and tools. Such as PTCS, DRAMA, JAS, JSDT, JSNMP, Ant, CVS, the Linux operating System, and many more. Maintaining these libraries and tools to the latest release version will reap may benefits such as improved features, reliability and performance. 7.3.3 Client SP server For security reasons, the SP server only accepts connections from the localhost. Currently there is only an SP server run on mistral.
diagram was developed. Also, additional hardware and software components will inevitably need to be added to provide information such as cable voltages, temperature monitoring etc. 7.3.7 JAS JXTA implementation The JAS is primarily based on the JSDTi which has subsequently been discontinued, presumably in favour of project JXTA. The JXTA architecture provides several constructs similar to those provided by the JSDT which would allow an alternative transport layer for the JAS to be implemented.
Note that this command could be implemented as a SP command or as a very simple Java application, bypassing the JAS entirely. 7.4 Conclusion The APT software control systems are maturing into a highly sophisticated synergy of a diverse collection of hardware and software components. The suggestions introduced in this Chapter are capable of further improving the systems functionality and reliability.
8 SkinnedTextField 8.1 Introduction Given the complex architecture of the APT System, the development of a rich user interface in Java will require a high level of programming skills and proficiency with the Java Swing framework. In order to gain Insight into the internal architecture of Swing itself, I decided to develop a customised, reusable Swing component, the SkinnedTextField, which uses images, as opposed to fonts, to render each letter within a text label.
/* Abbreviated SkinnedTextField API */ public class SkinnedTextField { ... public SkinnedTextField() { ... } public void setSkin(TextSkin newSkin) { ... } public void setSkinMode(boolean mode) { ... } public synchronized void setText(String newText) { ... } public void getText() { ... } ... } Figure 8-1 SkinnedTextField API 8.4 TextSkin The TextSkin Object, used by the SkinnedTextField has a very straightforward API.
In order to support skins downloaded from [ 36], as well as those I have extended to include additional characters, Skins are loaded by matching only those that are discovered in the zip file. 8.4.2 TextSkin zip format TextSkins can be loaded from any zip file containing a collection of gif images complying with the naming conventions detailed below: • • • All files must be in the root path of the zip file. Zip files must be named using .
BackLitLCD Figure 8-3 SkinnedTextFieldDemo 57ChevySkin 66
Figure 8-4 SkinnedTextField menu Unfortunately, the Web Start deployment of SkinnedTextFieldDemo can not be distributed with Skins pre-loaded because the Skins must be deployed as zip files within jar files. A limitation of using Web Start.
8.6 Suggestions and enhancements • Support for Classes of SkinnedTextFields. This would allow users display to have different areas of their application using different skins at the same time. Currently only one skin is supported across all instances of SkinnedTextField. This could be implemented by allowing multiple instances of SkinnedTextFieldManager. • Dynamic creation of blank images. When incomplete skins are used and the global default image is required, the component can appear odd.
9 CSIRO SEARFE project 9.1 Background The SEARFE (Students Exploring Australia’s Radio-Frequency Environment) project is designed to act as an educational resource for high school physics students as well as contributing to a national study of radio interference throughout Australia, geared towards Australia’s bid for the SKA telescope. The SKA is an international project to design, and ultimately build a radio astronomical telescope with an effective collecting area of one square kilometre [ 37 ].
This prototype was used as a basis for preparing the requirements of the Spectrum Scanner application. 9.3 Requirements The primary purpose of the software is to interface to the radio receiver and allow recording of signal strength readings across a given frequency range whilst providing a mechanism for visualising the data as it is acquired.
9.4 Hardware Figure 9-1 AOR – AR3000A Radio Receiver The software interfaces to a AOR-AR3000A professional radio receiver.
ScanData Data Scan Scan Data GUI Visad Visad Visad Plots Data Data Data File File File Status Status Status Widgets Widgets Widgets Spectrum Scanner AR3000A Acquire Scan RS232 Command Set Figure 9-2 Spectrum scanner software architecture 9.5.1 Data files The data files are written incrementally by the ScanData object to ensure that data is correctly recorded even if there is a software or hardware failure during a scan.
9.6 User interface The main application window shown in Figure 9-3 provides access to all the data files currently loaded in memory, access to the receiver console, and can launch the Spectrum Scan Wizard, used to configure the receiver for a scan. Figure 9-3 Main control window 9.6.1 Scan wizard The Spectrum Scan Wizard consists of three consecutive panels allowing the user to input scan conditions, parameters and specify which plots to use to display the data as it is obtained.
Figure 9-4 Scan conditions panel 74
Figure 9-5 Receiver parameters 75
Figure 9-6 Scan status panel 9.6.2 Data visualisation VisAD was chosen as a graphical package primarily because of its ability to plot image graphs, as shown in Figure 9-8. The VisAD library is a freely available “Java component library for interactive and collaborative visualisation and analysis of numerical data” [ 41 ]. Four kinds of plots were defined for use in the Spectrum Scanner application. These are shown in Figure 9-7 through Figure 9-10.
Figure 9-7 Signal strength vs.
Figure 9-8 Signal strength vs.
Figure 9-9 Signal strength vs.
Figure 9-10 3D plot 9.7 Suggestions and enhancements Version 2.0 of the Spectrum Scanner satisfies all the requirements outlined in 9.3. Since its deployment, very few issues and bugs have arisen. Most feature requests are for improved usability and data analysis facilities. 9.7.1 Visualisations • The VisAD plots are only configured to plot the entire data set, as opposed to a more manageable subset of this data. Users often want to perform a very large scan and zoom in to analyse a particular range.
• The XML data files also utilise XML style sheets to automatically format the data into comma delimited text. These style sheets could be improved to allow the data to be displayed in a presentable form on the web. Easing collaborative analysis. • Each visualisation window is always placed on the top left corner of the users desktop, often covering other plots, causing confusion. A tiling or cascading window placement strategy could be implemented to overcome this. 9.7.
10 Conclusion 10.1 Introduction Despite the fact that Java’s platform independence and design principles are focussed on abstracting and isolating the programmer as much as possible from the architecture of its host system, it has been used to successfully implement hardware control components for both the APT and the Spectrum Scanner application.
10.3 Failure and fault analysis As the complexity of any system grows, so does the likelihood of a individual components failure. The consequences of this failure are unique to every system. This highlights the need to analyse the system and identify faults that can occur and how these faults will propagate through the system, on both a hardware and a software level.
An implementation based on the java.util.logging framework is capable of achieving this. Searches could be performed on LogRecord objects using sophisticated implementations of the Filter interface. Although the Chainsaw (http://logui.sourceforge.net/) project adopts similar concepts using the log4ji framework, there is a potentially significant market for such a tool. i http://jakarta.apache.
Bibliography [ 1 ] Delta Tau Website. http://www.deltatau.com/ [ 2 ] CAN in Automation workgroup. http://www.can-cia.de [ 3 ] PCI Watchdog Website. http://www.pciwatchdog.com [ 4 ] Celestial Coordinate Systems. http://library.thinkquest.org/29033/begin/coordinate.htm [ 5 ] Times. http://library.thinkquest.org/29033/begin/time.htm. [ 6 ] Markus Kuhn, Paul Eggert. What are all those different kinds of time? http://www.faqs.org/faqs/astronomy/faq/part3/section-4.html [ 7 ] Rick Fisher.
[ 39 ] AOR. AR – 3000A Professional Monitor Receiver Instruction Manual. [ 40 ] Java Communications API Website. http://java.sun.com/products/javacomm/ [ 41 ] VisAD Website. http://www.ssec.wisc.edu/~billh/visad.html [ 42 ] A Guide to Australia – Australian Towns/Cities Latitude and Longitude http://life.csu.edu.au/geo/findlatlong.html [ 43 ] Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. Design Patterns. [ 44 ] John Zukowski.
A.
B. JAS programming techniques B.1. Introduction This appendix is intended to be a simple programming guide for interacting with the APT using the JAS. It is intended to be used as a reference for code patterns and techniques when adding or modifying the APT-JAS application. B.2. JAS message sender Many of the subsystems at the APT are responsible for sending telemetry information to clients. The JASChannel object supports two methods for sending JASMessages: • • JASChannel.
The core of the JAS system revolves around its ability to execute commands. To add a command to the APT system is a relatively simple process. Several JASChannels are designed to receive Commands. B.4.1. JASCommand object public class MyCommand extends APTCommand { // Command parameters as private variables private int someData; private transient Logger logger = Logger.getLogger( getClass().getName() ); public Object execute(Process parent) { // Execute something... ...
LogCommand.class, MasterswitchSwitchOutletCommand.class, MasterswitchRenameOutletCommand.class }; Figure B-2 APT command sets B.5. JAS channel monitoring In many cases, it is useful to be able to determine, when a client joins or leaves a JAS Channel. For example, when the Roof softwarei detects that a new client has joined Channels.ROOF all the roof telemetry is sent to that client. From this point onward, roof information is only sent when it has been requestedii, or when it changes.
C. Software tools C.1. CVS - Windows Instructions for accessing the APT CVS repository on Linux based machines is available from Keith Bannister’s APT Software page [ 53 ]. These instructions are included to simplify the installation and configuration of CVS and SSH on Windows. Note that these instructions below will not work for the cvsanon user. C.1.1. Install SSH An excellent ssh implementation for windows can be downloaded from http://www.networksimplicity.com/openssh/.
set CVS_RSH=C:\Program Files\NetworkSimplicity\ssh\ssh.exe C.1.3. Checkout the code Create a cvs-workspace directory on your local machine. C:\mkdir cvs-workspace cd cvs-workspace Now, checkout the modules. cvs –d :ext:username@mcba5.phys.unsw.edu.au:/home/cvsroot checkout apt Note that the –d :ext:username@mcba5.phys.unsw.edu.au:/home/cvsroot string can be omitted if CVSROOT=:ext:username@mcba5.phys.unsw.edu.au:/home/cvsroot. C.1.4.
D. SNMP overview D.1. Architecture The Simple Network Management Protocol (SNMP), is a standard designed to allow the remote management of devices across a network. This standard, defined in [ 18 ], facilitates communication between an SNMP Agent (managed device), and a Network Management Station (NMS). Device management is achieved by a simple system of getting and setting of attributes on the remote device.
o • Trap o Each of the Request messages will immediately generate a response message. Agents can asynchronously send Traps (similar to interrupts) to notify the NMS of some event which occurred on the managed device.
E. Astronomy primer E.1. Celestial coordinate systems Several Celestial Coordinate Systems are used by astronomers to record the positions of objects in the sky. Some material in this section is an abridgement of the content in [ 4 ]. Both the Equatorial and Horizon coordinate systems are very similar to the well known Terrestrial coordinate system which uses longitude and latitude to specify a position on the earth.
Figure E-2 Equatorial coordinates, sourced from [ 4 ]. Right Ascension is analogous to the longitude of the earth. It is essentially the angle formed from the vernal equinox, eastwards along the celestial equator, to the hour circle corresponding to the position of the object you wish to describe, as shown in Figure E-2. Right ascension is measured in hours, minutes and secondsi. Declination on the celestial sphere is analogous to latitude on the earth.
E.2. E.2.1. Astronomical times Universal time Universal time (UT) is the precise measurement of time used as the basis for civil time keeping [ 5 ]. By definition, it is the solar time at the Greenwich meridian, also know as Greenwich Mean Time (GMT)i. Such that the sun passes directly over the Greenwich meridian at noon, UT. Universal time is calculated in several ways: • • • • E.2.2. UT0 is the universal time calculated from astronomical observations.
E.2.5. Dynamical time Dynamical Time, introduced in 1984 as a replacement for ephemeris time, more accurately defines a uniform astronomical time scale. Terrestrial Dynamical Time (TDT) is a time scale tied to the earth, whereas Barycentric Dynamical Time (TDB) is used as a time reference for the barycentreii of the solar system. When the difference of these two values (less than a few milliseconds) is considered negligible, TDT is simply referred to as TT.
The APT has the following filters available: • • • • • • E.5. Ultraviolet (R) Blue (B) Visible (V) Visible Red (VR) Infrared (I) Clear Flat fielding Flat Fielding refers to the process of calibrating the CCD to account for irregularities in the optics and errors within the CCD itself. A reference image is taken when the CCD is expected to return an image of constant intensity, such as the twilight sky. Any flaws in this reference image can be used to correct images obtained in the future.
F. Selected code listings F.1. F.1.1. Masterswitch module Masterswitch.java /** * $Id: Masterswitch.java,v 1.4 2002/10/22 08:23:11 oliverm Exp $ * Author: Oliver Mather * */ package apt.masterswitch; import java.util.Date; /** * Description: * *
* This is an interface to the APC AP9212 Masterswitch * www.apc.com *
* It is a device that supplies 8 x 240V Power Outlets. These outlets can be * powered on and off remotely.
* valid for MasterSwitch firmware version 1.X. */ public static final String OUTLET_ON_WITH_DELAY = "On with delay"; /** *
* Setting an outlet to this state will turn the outlet off * after the sPDUOutletPowerOffTime OID has elapsed. This option is not * valid for MasterSwitch firmware version 1.X.
* @param outlet The Masterswitch outlet. This is a number between 1 and 8 * @return The String value corresponding to the outlets state. These values are defined in Masterswitch * @exception MasterswitchException */ public String setOutletState(int outlet, String outletState) throws MasterswitchException; /** * The hardware revision of the PDU (Power Distribution Unit). This value * is set at the factory. *
* @throws apt.masterswitch.
/** * $Id: AbstractMasterswitch.java,v 1.2 2002/10/22 08:23:11 oliverm Exp $ * Author: Oliver Mather * */ package apt.masterswitch; import import import import import import java.util.ArrayList; java.util.List; java.util.Iterator; java.util.Collections; java.util.logging.Logger; java.util.logging.Level; /** * Description: *
* This implements some of the common tasks required by * full Masterswitch implementations. Such as MasterswitchListener * event management code *
* * @see apt.masterswitch.
if( listener instanceof MasterswitchListener ) { if( listeners.contains(listener) ) { logger.log(Level.INFO, "Cannot add MasterswitchListener, it has already been added" ); } else { listeners.add( listener ); } } else { logger.log(Level.WARNING, "Cannot add MasterswitchListener, it is not of the correct instance type"); } } public void removeMasterswitchListener( MasterswitchListener listener ) { listeners.
F.1.3. MasterswitchListener.java /** * $Id: MasterswitchListener.java,v 1.2 2002/10/22 08:23:11 oliverm Exp $ * Author: Oliver Mather * */ package apt.masterswitch; /** * Description: *
* The listener interface for receiving Masterswitch Events. *
* @author $Author: oliverm $ Oliver Mather * @version $Revision: 1.2 $ * @see apt.masterswitch.
F.1.4. MasterswitchException.java /** * $Id: MasterswitchException.java,v 1.2 2002/10/22 08:23:11 oliverm Exp $ * Author: Oliver Mather * */ package apt.masterswitch; /** * Description: *
* The exception object used to encapsulate any errors that can be * encountered by the operation of the masterswitch. *
* Specific details of the error condition are contained in the message * string and/or by a Throwable object. *
* @author $Author: oliverm $ PAGE 112
F.1.5. SNMPMasterswitch.java /** * $Id: SNMPMasterswitch.java,v 1.6 2002/10/22 08:23:11 oliverm Exp $ * Author: Oliver Mather * */ package apt.masterswitch.snmp; import org.opennms.protocols.snmp.*; import import import import import import import java.util.*; java.util.logging.Logger; java.util.logging.Level; java.net.InetAddress; java.net.UnknownHostException; java.net.SocketException; java.io.FileNotFoundException; import import import import import import pt.ipb.agentapi.mibs.MibModule; pt.ipb.
private static final String sPDUOutletCtlName = "sPDUOutletCtlName"; // This is similar to sPDUOutletName, except only sPDUOutletName can be SET // sPDUOutletConfig Table private static final String private static final String private static final String private static final String sPDUOutletPowerOnTime sPDUOutletName sPDUOutletPowerOffTime sPDUOutletRebootDuration private private private private private sPDUIdentHardwareRev sPDUIdentFirmwareRev sPDUIdentDateOfManufacture sPDUIdentModelNumber sPDUIdentSe
throw new MasterswitchException("Cannot initialise Masterswitch",e); } catch (FileNotFoundException e) { log.log(Level.WARNING, "Cannot load \""+MIB_FILENAME+"\", File not found ",e); throw new MasterswitchException("Cannot initialise Masterswitch",e); } timer = new Timer(true); // Initialise Trap Listener on port 162 log.log(Level.INFO, "Attempting to start SNMP Trap Daemon for event notification..."); // Java Snmp Trap Daemon // SnmpTrapDaemon trapd = SnmpTrapDaemonImpl.
private SnmpSyntax doSNMPSet( String oid, SnmpSyntax data ) throws MasterswitchException { SnmpVarBind[] vblist = { new SnmpVarBind(oid,data) }; SnmpPduRequest pdu = new SnmpPduRequest(SnmpPduPacket.SET, vblist); log.log(Level.FINE, "SNMP Set OID = "+oid+": " + data); return doSNMP( pdu ); } private SnmpSyntax doSNMP( SnmpPduRequest pdu ) throws MasterswitchException { pdu.setRequestId(SnmpPduPacket.
} else if(outletInt == SNMP_OUTLET_OFF ) { return OUTLET_OFF; } else if(outletInt == SNMP_OUTLET_REBOOT ) { return OUTLET_REBOOT; } else if(outletInt == SNMP_OUTLET_UNKNOWN ) { return OUTLET_UNKNOWN; } else if(outletInt == SNMP_OUTLET_ON_WITH_DELAY ) { return OUTLET_ON_WITH_DELAY; } else if(outletInt == SNMP_OUTLET_OFF_WITH_DELAY ) { return OUTLET_OFF_WITH_DELAY; } else if(outletInt == SNMP_OUTLET_REBOOT_WITH_DELAY ) { return OUTLET_REBOOT_WITH_DELAY; } else { log.log(Level.
log.log(Level.WARNING, "Request ignored by apt.masterswitch.masterswitch. Another user is probably logged in"); } String returnedState = outletIntToOutletStr(returnedVal.getValue()); return returnedState; } /** * The hardware revision of the PDU (Power Distribution Unit). This value * is set at the factory. */ public synchronized String getHardwareRevision() throws MasterswitchException{ String oid = mibModule.getNode(sPDUIdentHardwareRev).getOID().toJavaValue().
int command, SnmpPduPacket pdu) { SnmpPduRequest req = null; if(pdu instanceof SnmpPduRequest) { req = (SnmpPduRequest)pdu; //req.getErrorStatus() } if(pdu.getCommand() != SnmpPduPacket.RESPONSE) { log.log( Level.WARNING, "Error: Received non-response command " + pdu.getCommand()); value = null; waitingForResponse = false; synchronized(session) { session.notifyAll(); } return; } // Passed the checks so lets get the first varbind and // print out it's value SnmpVarBind vb = pdu.getVarBindAt(0); //log.
log.log(Level.WARNING, "An unexpected error occured with the SNMP Session"); log.log(Level.WARNING, "The error code is " + err); value = null; waitingForResponse = false; // Wake up the blocking thread synchronized(session) { session.notifyAll(); } } public void snmpTrapDaemonStarted() { log.log(Level.INFO, "Listening to SNMP traps..."); if( watcherRunning ) { timer.cancel(); watcherRunning = false; } } public void snmpTrapDaemonStopped() { log.log(Level.INFO, "Not listening to SNMP traps"); log.
System.out.println("fireOutletNameChanged("+((int)(i+1))+", "+currName+");"); fireOutletNameChanged(i+1, currName); } } for (int i = 0; i < outletStates.length; i++) { String currState = getOutletState(i+1); if( !outletStates[i].equals( currState) ) { outletStates[i] = currState; System.out.println("fireOutletStateChanged("+((int)(i+1))+", "+currState+");"); fireOutletStateChanged(i+1, currState); } } } catch (MasterswitchException e) { log.log(Level.
F.1.6. SnmpTrapDaemon.java /** * $Id: SnmpTrapDaemon.java,v 1.3 2002/10/22 08:23:11 oliverm Exp $ * Author: Oliver Mather * */ package apt.masterswitch.snmp; /** * Description: *
* This interface specifies the methods required for an * SNMP TrapDaemon. *
An SNMP Trap Daemon will listen on UDP port 162 for SNMP traps, generating * an event to notify SnmpTrapListeners that an event has occurred. *
* This interfaces it used by {@link apt.masterswitch.snmp.
F.1.7. AbstractSnmpTrapDaemon.java /** * $Id: AbstractSnmpTrapDaemon.java,v 1.3 2002/10/22 08:23:11 oliverm Exp $ * Author: Oliver Mather * */ package apt.masterswitch.snmp; import import import import import java.util.List; java.util.ArrayList; java.util.Iterator; java.util.logging.Level; java.util.logging.Logger; /** * Description: *
* This implements some of the common tasks required by * full SnmpTrapDaemon implementations.
protected void fireSnmpTrapDaemonStarted() { Iterator i = listeners.iterator(); while (i.hasNext()) { SnmpTrapListener listener = (SnmpTrapListener) i.next(); listener.snmpTrapDaemonStarted(); } } protected void fireSnmpTrapDaemonStopped() { Iterator i = listeners.iterator(); while (i.hasNext()) { SnmpTrapListener listener = (SnmpTrapListener) i.next(); listener.snmpTrapDaemonStopped(); } } protected void fireSnmpTrapReceived() { Iterator i = listeners.iterator(); while (i.
F.1.8. SnmpTrapDaemonImpl.java /** * $Id: SnmpTrapDaemonImpl.java,v 1.4 2002/10/22 08:23:11 oliverm Exp $ * Author: Oliver Mather * */ package apt.masterswitch.snmp; import org.opennms.protocols.snmp.*; import import import import java.util.logging.Level; java.util.logging.Logger; java.net.InetAddress; java.net.SocketException; /** * Description: * *
* This is an implementation of the SnmpTrapListener interface * primarily based on the org.opennms.protocols.snmp.
logger.log( Level.INFO, "Java SnmpTrapDaemon Started"); fireSnmpTrapDaemonStarted(); } catch (SocketException e) { logger.log( Level.WARNING, "Could not initialise SnmpTrapSession"); logger.log( Level.WARNING, "Check the permissions for UDP port 162, you may have to run this code as root",e); fireSnmpTrapDaemonStopped(); } } /** * Stop listening to SNMP Traps by closing the * org.opennms.protocols.snmp.
* allow the handler to determine the host, port, * and community string of the received PDU.
* * @param session The SNMP session * @param agent The Trap sender * @param port The port of the sender * @param community The community string * @param pdu The SNMP trap pdu * */ public void snmpReceivedTrap(SnmpTrapSession session, InetAddress agent, int port, SnmpOctetString community, SnmpPduTrap pdu) { logger.log( logger.log( logger.log( logger.log( logger.log( logger.log( logger.log( Level.INFO, Level.F.1.9. LinuxSnmpTrapDaemonImpl.java /** * $Id: LinuxSnmpTrapDaemonImpl.java,v 1.2 2002/10/22 08:23:11 oliverm Exp $ * Author: Oliver Mather * */ package apt.masterswitch.snmp; import import import import import import java.io.InputStream; java.io.InputStreamReader; java.io.BufferedReader; java.io.IOException; java.util.logging.Logger; java.util.logging.
buffer = new BufferedReader(reader,1); readerThread = new StdErrReader(); readerThread.start(); running = true; logger.log( Level.INFO, "Linux SnmpTrapDaemon Started"); fireSnmpTrapDaemonStarted(); } catch (IOException e) { logger.log( Level.INFO, "Could not start Linuz SnmpTrapDaemon, IO err",e); } } else { logger.log( Level.INFO, "Linux SnmpTrapDaemon Stopped"); } } /** * Stop listening to SNMP traps *
* Kill the /usr/sbin/snmptrapd
process *
* This will trigger the {@link apt.
} } /** * output of "man snmptrapd" * ************************************************************* SNMPTRAPD(8) SNMPTRAPD(8) NAME snmptrapd - Receive and log snmp trap messages. SYNOPSIS snmptrapd [common options] [-P] [-o file] [-s] [-f] [-p port] [-e] [-l [d0-7]] [-a] [-C] [-c confFile] [-F FORMAT] DESCRIPTION Snmptrapd is an SNMP application that receives and logs snmp trap messages sent to the SNMP-TRAP port (162) on the local machine.
%W %q %P Trap description Trap sub-type (numeric, in decimal) Security information from the PDU (community name for v1/v2c, user and context for v3) %v list of trap's variables In addition to these values, you may also specify an optional field width and precision, just as in printf, and a flag value. The following flags are legal: left justify 0 use leading zeros # use alternate form The "use alternate form" flag changes the behavior of some format flags.
F.1.10. SnmpTrapListener.java /** * $Id: SnmpTrapListener.java,v 1.3 2002/10/22 08:23:11 oliverm Exp $ * Author: Oliver Mather * */ package apt.masterswitch.snmp; /** * Description: *
* The listener interface for receiving SnmpTrapDaemon Events. *
* @author $Author: oliverm $ Oliver Mather * @version $Revision: 1.3 $ * @see apt.masterswitch.snmp.
F.2. APT deployment system F.2.1. apt-client-base.jnlp APT Client ver:#version-key# UNSW School of Physics PAGE 133F.2.2. apt-client-keith.jnlp Keiths APT Client ver:#version-key# PAGE 135Note: if you install an additional library here, please add it to the check below at the init target --> PAGE 138 PAGE 139 PAGE 140
F.2.4. lib build.xml PAGE 142SCP Setup Note that to use scp, authenticed remote ssh must be setup on mcba5 AND mistral. This is done by the following two commands: Your machine: scp ~/.ssh/id_dsa.pub apt@mcba5.phys.unsw.edu.au:~/.ssh/temp-pub-key User apt on mcba5: cat ~/.ssh/temp-pub-key >> ~/.ssh/authorized_keys2 rm ~/.ssh/temp-pub-key Versioning To preseve the multi-versioning of these build files, ANY new lib that is added must not overwrite an existing lib.
/> 143 ${scp.mistral.
F.3. CSIRO / SEARFE F.3.1. Sample data file PAGE 145F.4. F.4.1. TextSkin TextSkin zipfile listing [oliverm@mcba5:~] unzip -l BacklitLCD.zip Archive: BacklitLCD.zip Length Date Time Name ----------------1086 07-08-02 12:08 MBacklitLCD.gif 1063 05-01-02 20:17 1BacklitLCD.gif 1086 05-01-02 20:17 2BacklitLCD.gif 1091 05-01-02 20:17 3BacklitLCD.gif 1068 05-01-02 20:18 4BacklitLCD.gif 1083 05-01-02 20:18 5BacklitLCD.gif 1093 05-01-02 20:18 6BacklitLCD.gif 1068 05-01-02 20:19 7BacklitLCD.gif 1106 05-01-02 20:19 8BacklitLCD.gif 1097 05-01-02 20:19 9BacklitLCD.
G. CDROM directory structure apt The base directory for the apt files cvs-workspace Build environments for the apt, jas, jcan, jsdt and lib modules as of 4-11-2002 masterswitch Masterswitch documentation and jsnmp code workspace searfe The base directory for the CSIRO searfe project aor-software Miscelaneous files and manuals for the AORAR3000A receiver commapi The Java Communication API for win32 (version 2.