• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Developing the Beamline Video System Software Solutions using ...
 

Developing the Beamline Video System Software Solutions using ...

on

  • 792 views

 

Statistics

Views

Total Views
792
Views on SlideShare
792
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Developing the Beamline Video System Software Solutions using ... Developing the Beamline Video System Software Solutions using ... Presentation Transcript

    • Developing the Beamline Video System Software Solutions using Java Technology Kenneth R. Sharp Stanford Synchrotron Radiation Laboratory January 8, 2002
    • 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.
    • Component Architecture HTML Java Java Internet Applet Applet JavaScript JavaScript Java Java Applet Applet SMB Beamlines Axis Server Web Server (Hutch) Axis Server (Control) Java Servlets
    • 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
    • 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
    • Video System n-tiered Architecture Web Browser MySQL Beamline SMB Configuration Database HTML & JavaScript Tomcat (Servlet Container) Beamline 1 Axis Server Java Applets Video System (Hutch) Servlets Axis Server (Control) . . . Apache (User Authentication Beamline n and SSL) Axis Server Internet (Hutch) Axis Server (Control)
    • 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.
    • 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
    • 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
    • Visual Café IDE
    • 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)
    • 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) {} } }
    • 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"); //}}
    • 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.
    • 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); } }
    • A Simple Servlet (result)
    • 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
    • A Simple Applet public class VidApplet extends Applet implements Runnable { public void start() { if (myThread == null && initOK) public void run() { { int imageLen = 0; myThread = new Thread(this); while (true) { myThread.start(); try { } myThread.sleep(1000); } } catch (InterruptedException e) { System.out.println("unable to sleep."); public void stop() } { imageOK = false; if (myThread != null) okToPaint = false; { if (currImage != null) currImage.flush(); try { mt.removeImage(currImage); myThread.stop(); currImage = getImage(url); } catch (SecurityException e) {} mt.addImage(currImage, 0); myThread = null; try { } mt.waitForAll(5000); } if (!mt.isErrorAny()) { imageOK = true; <HTML><HEAD><TITLE><APPLET TEST></TITLE></HEAD> } <BODY> } catch (InterruptedException e) Hello World!<BR> {System.out.println("ERROR!");} <APPLET code="VidApplet.class" width="352" height="240"></APPLET> repaint(); </BODY> } </HTML> }
    • 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
    • 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>
    • Video Stream Handling 1 1 1 Tomcat Beamline 1 1 Axis Server (Hutch) n Separate threads n handle each video Axis Server n stream, storing the latest image from (Control) each stream in a n buffer. Requests from applets running in . 1 client web browsers return individual . 1 images from the . 1 buffers. A specific video 1 stream (beamline, camera, siz e, resolution) is created on the first Beamline n n request and runs until n no request has been Axis Server (Hutch) made for it for 10 seconds. Axis Server n (Control) n
    • Authentication Flow (1) This is the control flow between the user’s browser and the server for authentication and page selection Browser (HTML) Authentication Apache Browser (HTML) User Name Tomcat UserName MySQL Tomcat Configuration Avail. Database Beamlines Browser (HTML) Avail. Tomcat Beamlines Browser (HTML) Beamline Tomcat Request Browser (HTML) Video Page Tomcat
    • 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. Image Browser (Java) Request Tomcat Stream Axis Video Tomcat Request Server Browser (Java) Video Video Axis Video Frame Tomcat Stream Server Image Request Video Axis Video Browser (Java) Tomcat Stream Video Server Frame No Request for Video Axis Video Browser (Java) Tomcat Stream 10 seconds Server Terminate Axis Video Tomcat Video Server Stream
    • 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. Browser Control Request Tomcat (JavaScript) Control Axis Video Tomcat Request (as Server root) Control Axis Video Tomcat Response Server Browser Request Tomcat Response
    • 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
    • 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.