1 / 26

Developing the Beamline Video System Software Solutions using Java Technology

Developing the Beamline Video System Software Solutions using Java Technology. Kenneth R. Sharp Stanford Synchrotron Radiation Laboratory January 8, 2002. Introduction.

majed
Download Presentation

Developing the Beamline Video System Software Solutions using Java Technology

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Developing the Beamline Video SystemSoftware Solutions using Java Technology Kenneth R. Sharp Stanford Synchrotron Radiation Laboratory January 8, 2002

  2. Introduction The simple user interface of the Beamline Video System (left) requires a complex n-tiered client-server architecture to link the user’s web browser to the Axis Video Servers at the beamlines. This presentation examines the implementation of that architecture.

  3. HTML Java Applet Java Applet Beamlines JavaScript JavaScript Axis Server (Hutch) Java Applet Java Applet Axis Server (Control) SMB Web Server Internet Java Servlets Component Architecture

  4. Video System Goals and Challenges Goals • Web browser interface – no additional software for user to install • Display selected views from multiple Axis servers in a single web page • Limit beamline access to current user or staff • Simple UI to change Presets, Image Size and Resolution • Ability to Enable/Disable Camera View and Date/Time Stamp • Display Current Preset Name as Video Caption • Snapshot feature to capture images of user’s current crystal Challenges • Limited JPEG streams available from each Axis server • “Server Push” works only with Netscape browsers • Inability to use Apache web server Rewrite Rules • Need to hide all Axis CGI calls from user-accessible HTML • Need to synchronize User Authentication with BLU-ICE/DCS and Unix • Mix of root and non-root Axis CGI calls • Poor performance of Linux firmware on Axis servers

  5. Video System Solutions Java Servlets • Middleware runs on SMB web server, uses Apache Tomcat • Uses session objects to manage user access • Proxies all requests from web browsers to Axis Servers • Hides Axis Server IP Address and CGI Commands from User • Has root access to Axis Servers • Uses multiple threads to match image streams to user requests Java Applets and Java Script • Client software runs on web browsers • Applets, compiled Java programs, use Client Pull to request and display video images at up to 4 frames per second • JavaScript, Java source code included in the HTML, handles user interface events such as changing a preset from a drop-down menu

  6. Web Browser SMB HTML & JavaScript Tomcat (Servlet Container) Beamline 1 Axis Server (Hutch) Video System Servlets Java Applets Axis Server (Control) Apache (User Authentication and SSL) Beamline n Axis Server (Hutch) Internet Axis Server (Control) Video System n-tiered Architecture MySQL Beamline Configuration Database . . .

  7. BLU-ICE/DCS • Video System directly calls Axis Server CGI to control cameras and images. Video System does not use DCS. • Video System and BLU-ICE/DCS both query Beamline Configuration Database (MySQL) to match user to beamline. • BLU-ICE retrieves images and controls camera presets by direct calls to Axis Server CGI. BLU-ICE does not use DCS for these purposes. • BLU-ICE calls Java Servlet to update the image caption to the new preset. • Future versions of Video System may use DCS to provide more sophisticated levels of control over the cameras.

  8. Java and TCL • BLU-ICE is written in TCL (Tool Command Language) and C • In the Olden Days (Mid to Late 90’s) • Scripting Languages (Perl, TCL, Python, etc.) were for “quick and dirty” jobs connecting existing processes, rapid GUI development for Unix, or simple CGI. • Traditional Languages (C, C++, Java, etc.) were for applications that implemented complex algorithms and data structures or were more resource intensive. Users of these languages tended towards a more formal approach to programming. • TCL was Unix-only, extensible only with C, and did not implement such things as multi-threaded applications. • Currently: • The lines have blurred. • Scripting languages are approaching traditional languages in terms of broad application development capabilities. • Traditional languages have tools that assist in rapid application development. • Java/TCL integrations (TCL-Blend and JACL) are available. • Language selection is to some degree becoming a matter of personal choice and experience

  9. Advantages to Java • Complete Object-Oriented Programming Language with features such as: Strong-Typing, Encapsulation, Inheritance, Exception Handling, etc. Syntax similar to C++, but simpler • One language can be used for both client and server applications. • Fully featured Integrated Development Environments (IDEs) available for editing, compiling, and debugging. Examples: Webgain’s Visual Café, Borland’s JBuilder, IBM’s Visual Age • APIs for: GUI, standard I/O, SQL Database queries, multi-threading, socket/networking, etc. • Portable – Java code is compiled to “bytecode” which is run on various computers by system-specific Java Virtual Machines (JVMs). Video System code was developed and tested on Windows 2000 computer and ran untouched on SMB Irix system. MySQL class library driver downloaded once and runs on both Windows and Unix

  10. Visual Café IDE

  11. Types of Java Programs • Command Line Applications • Stand-Alone GUI Applications • Servlets (applications running within web server context) • Applets (applications running within web browser context) • JavaScript (language variant with source code included in HTML; run by web browser)

  12. A Simple Command Line Application public class HelloWorld { public static void main(String[] args){ System.out.println("Hello World"); try { System.out.println("Hello: " + args[0]); } catch (ArrayIndexOutOfBoundsException e) {} } }

  13. A Simple Stand-Alone GUI import java.awt.*; public class Frame1 extends Frame { public Frame1() { //{{INIT_MENUS //}} //{{REGISTER_LISTENERS SymWindow aSymWindow = new SymWindow(); this.addWindowListener(aSymWindow); SymAction lSymAction = new SymAction(); button1.addActionListener(lSymAction); //}} //{{INIT_CONTROLS setLayout(null); setSize(405,305); setVisible(false); label1.setText("Hello World?"); add(label1); label1.setFont(new Font("Dialog", Font.BOLD, 16)); label1.setBounds(132,24,108,40); checkbox1.setState(true); checkbox1.setLabel("World"); add(checkbox1); checkbox1.setFont(new Font("Dialog", Font.BOLD, 12)); checkbox1.setBounds(132,65,100,40); textField1.setBounds(156,108,100,36); label2.setText("Custom:"); add(label2); label2.setFont(new Font("Dialog", Font.BOLD, 12)); label2.setBounds(96,108,60,40); button1.setLabel("Say Hello"); add(button1); button1.setBackground(java.awt.Color.lightGray); button1.setFont(new Font("Dialog", Font.BOLD, 12)); button1.setBounds(132,184,84,40); add(label3); label3.setForeground(java.awt.Color.blue); label3.setFont(new Font("Dialog", Font.PLAIN, 20)); label3.setBounds(120,225,192,40); setTitle("AWT Application"); //}}

  14. Java Servlets • Execution controlled by Servlet Container (Tomcat) • Simple implementation: by writing responses to HTTP GET and POST requests • Servlet responses can be HTML, images, or any other data that would normally be returned by a web server • Includes use of unique 128-bit session keys created for each browser session. Session keys passed from browser via “cookies” for each request from the server • Servlet engine stores session data for each current session. When user logs in, determine which beam lines are available to that user and store data in session object. Each subsequent request is matched against that object. • Requests from browser contain no Axis-specific URLs or CGI with which user might try to directly access video servers.

  15. A Simple Servlet (code) import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class SimpleServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) { try { PrintWriter out = response.getWriter(); out.println("<HTML><HEAD><TITLE>A Simple Servlet</TITLE></HEAD>"); out.println("<BODY>"); out.println("<p><img src=/examples/ssrl.gif></p>"); out.println("Hello, World!"); out.println("</BODY>"); out.println("</HTML>"); } catch (IOException e) { System.err.println("Error writing to web browser."); } } public void doPost(HttpServletRequest request, HttpServletResponse response) { doGet(request, response); } }

  16. A Simple Servlet (result)

  17. Applets • Compiled Java Code • Execution controlled by containing web page • Generally, can only output to its graphic context within its web page, and can receive input only from its web page or from the user • Generally, can only establish communications socket with originating web server • Appropriate security certificates can be created to allow operations “outside the sandbox” with user permission • Efficiency of operation depends on JVM implementation of web browser

  18. A Simple Applet public class VidApplet extends Applet implements Runnable { public void start() { if (myThread == null && initOK) { myThread = new Thread(this); myThread.start(); } } public void stop() { if (myThread != null) { try { myThread.stop(); } catch (SecurityException e) {} myThread = null; } } public void run() { int imageLen = 0; while (true) { try { myThread.sleep(1000); } catch (InterruptedException e) { System.out.println("unable to sleep."); } imageOK = false; okToPaint = false; if (currImage != null) currImage.flush(); mt.removeImage(currImage); currImage = getImage(url); mt.addImage(currImage, 0); try { mt.waitForAll(5000); if (!mt.isErrorAny()) { imageOK = true; } } catch (InterruptedException e) {System.out.println("ERROR!");} repaint(); } } <HTML><HEAD><TITLE><APPLET TEST></TITLE></HEAD> <BODY> Hello World!<BR> <APPLET code="VidApplet.class" width="352" height="240"></APPLET> </BODY> </HTML>

  19. JavaScript • Java Source code included with an HTML file • Executed as page is loading or upon a programmed event (such as Mouse Click or Keyboard Press) • Syntax varies from standard Java to include web documents • JavaScript and Java Applets within a single page may cross-communicate with the appropriate programming

  20. A Simple JavaScript Example <HTML><HEAD><TITLE><JavaScript Example></TITLE> <SCRIPT Language=JavaScript> var userinput = prompt("To whom do you wish to say Hello?"); </SCRIPT> </HEAD> <BODY> Here is your message:<BR> <SCRIPT Language=JavaScript> document.write("Hello <B>" + userinput + "!</B>"); </SCRIPT> </BODY> </HTML>

  21. Beamline 1 Axis Server (Hutch) Axis Server (Control) Beamline n Axis Server (Hutch) Axis Server (Control) Video Stream Handling 1 1 1 Tomcat 1 n Separate threads handle each video stream, storing the latest image from each stream in a buffer. Requests from applets running in client web browsers return individual images from the buffers. A specific video stream (beamline, camera, size, resolution) is created on the first request and runs until no request has been made for it for 10 seconds. n n n . . . 1 1 1 1 n n n n

  22. Browser (HTML) Apache Authentication Browser (HTML) Tomcat User Name Tomcat UserName MySQL Configuration Database Avail. Beamlines Browser (HTML) Tomcat Avail. Beamlines Browser (HTML) Tomcat Beamline Request Browser (HTML) Tomcat Video Page Authentication Flow (1) This is the control flow between the user’s browser and the server for authentication and page selection

  23. Browser (Java) Tomcat Image Request Tomcat Axis Video Server Stream Request Browser (Java) Tomcat Axis Video Server Video Frame Video Stream Browser (Java) Image Request Tomcat Axis Video Server Video Stream Video Frame Browser (Java) Tomcat Axis Video Server No Request for 10 seconds Video Stream Axis Video Server Tomcat Terminate Video Stream Image Flow (2) This is the control flow from each Java applet. Multiple applets are running concurrently from any number of current users. Each applet displays a different video image.

  24. Browser (JavaScript) Tomcat Control Request Tomcat Axis Video Server Control Request (as root) Tomcat Axis Video Server Control Response Browser Tomcat Request Response Camera Control Flow (3) This is the control flow from the user’s browser for Preset changes, Camera enable/disable, and Date/Time enable disable. These requests are processed concurrently with the previous Image flow.

  25. Java and Bioinformatics The following articles from Sun’s Java website illustrate ways that Java is being used in the fields of Computational Biology and Bioinformatics. http://java.sun.com/features/2001/09/genome.html http://java.sun.com/features/2001/10/genome2.html

  26. Glossary Apache – Commonly used web server software developed by the Apache Software Foundation and distributed for free as “open source”. CGI – “Common Gateway Interface”. Specification for programs called by web servers to return dynamic data. CGI programs tend to be written in scripting languages such as Perl or TCL. Client Pull – Typical web browser operation where all data from the server must be explicitly requested by the web browser. Opposite of Server Push. Client-Server – Software/Network architecture that separates executable elements into two or more connected tiers which may run on different hardware resources. CLI – “Command Line Interface”. A software program’s user interface made up of commands typed into a console display. GUI – “Graphical User Interface”. A software program’s user interface made up of windows and control elements, as opposed to a CLI. IDE – “Integrated Development Environment”. Software development tool used to code, compile, and debug programs. Java – Software programming language developed by Sun Microsystems. JVM – “Java Virtual Machine”. System software needed to run Java programs. Java Servlets – Java-based alternative to CGI, used to return dynamically created html, images and data to web servers. Requires a “Servlet Container” such as Apache Tomcat. Java Applets – Java programs run within the context of a web browser. JavaScript – Java code included within an HTML file to be run by a web browser. Java Plug-Ins – Java Applets that are run by Sun’s Java Run Time JVM instead of a web browser’s built-in JVM. JPEG – “Joint Photographic Experts Group”. A digital image format commonly used in web pages. The format of images returned by Axis Video Servers. Middleware – A middle tier of a client-server architecture which retrieves data from a server and passes it on to a client. Typically handles business logic for a database server. MySQL – Open Source relational database software that supports Stuctured Query Language (SQL) queries. Server Push – Protocol in which a continuous data stream from a server can be processed by a web browser with no programming needed. Resource heavy and works only with Netscape. Opposite of Client Pull. Tomcat – An open source Java Servlet Container from the Apache Software Foundation. Integrates with the Apache web server. Thread – Execution of a portion of a software program that runs independently and that may run concurrently with other portions of the same program.

More Related