EXPLANATORY NOTES ON PROJECT and

Sample Codes GUI for IDEA Project

The sample codes provided here are provided by Francis Ng (upon request from Leong Hon Wai) for UIT2201 Intelligent Door Project.

This document and the sample code has been revised recently (7-April-2003). You may want to get a new copy to replace the old one you had.)


Download Instructions:

To get the sample program (all in one place), download source3.zip. Then, follow the instructions of Hong Ee (found in the forum page). After unzipping the files there the permission modes of the files should be like this. Also, to compile your Java programs, please also use the correct Java CLASSPATH as described here.


This is a sample FrontEnd GUI designed by Francis Ng (upon request from Leong Hon Wai) for UIT2201 Intelligent Door Project. It serve to as sample programs as well as to illustrate that the various components of our Intelligent Door can be independently developed. This is given as a FrontEnd GUI that can be accessed at

http://www-cgi.comp.nus.edu.sg:8000/~nghoongk/frontend.html
(You need to be inside NUS or SoC's domain to be able to view.)

In this FrontEnd GUI, we want to illustrate the use of forms+cgi (in frontend.html) and how it communicates with a controller on the server.


The Sample Controller

The controller in the server can be written in one of serveral languages (perl, php, C++, Java). In this sample, we have provided three: perl, C/C++, Java one done in perl. The SDA1 team has decided to implement this controller in php.

At the moment, the sample Controller does the following simple task:

  1. get the input parameters (name and two numbers),
  2. Calls two programs in the backend engine, (in this case, checkname and calcnum)
  3. Depending on the results obtained (in this case, status1, status2), it calls different functions (in this case, do_result_1 - 5) to output the appropriate GUI (html page).
We have provided code for the Sample Controllers (written in perl) for your reference. They are given below: All the programs are similar. The difference is the part which calls/runs the other programs (which are written in other languages.


The FeatureEngine Programs

Like the Controller, the programs in the backend engine can be written in one of several languages. The teams in the Software Feature Implementation teams will be implementing different features and they are free to the choose the languages -- provided a correctly tested executable is provided.

Some of the Software Feature Implementation teams will need to access the database -- for that they will need to interface with the Oracle Database designed by SDA3:DBMS. Thus, the sample programs (in Java and Perl) have been revised to include a part that will interface with the Oracle database to do query, get the results and process them. More on this in DB section. (Note: The one for C/C++ has not been revised.)

  • Programs written in Java -- | CheckName.java (includes Oracle access) | CalcNum.java |

  • Programs written in Perl -- | checkname.pl (includes Oracle access) | calcnum.pl |

  • The Other Programs written in C/C++ -- | checkname.cpp | calcnum.cpp | With the current architecture, the feature implementation can be done as standalone programs that are compiled into executables. Make sure that your programs read in the correct input parameters and prints out the correct output parameters.

    Remarks on Integration:

    As discussed earlier, once we have the controller skeleton up (SDA1 Team), each one of you can download a copy and put into your own public_cgi sub-dir. Then, you can do your own independent testing of your executables on your copy of IDEA. Please do careful testing to make sure it is correct.

    After that, you should email a copy of the source and executables to the SDA1 group -- who will then "install" your executables into the IDEA project account --- uit2201p.


    IDEA Database (SDA3 Team)

    For this project, we use one oracle account to store the database for IDEA. The account will be "shared" by all the developers -- and will be "managed" by the SDA3:DB team. To login to the account from a unix terminal, do the following:
       % source /opt/oracle/bin/oraenv
       % sqlplus 
           then login with userid and password
    to get you into a very primitive Unix interface to Oracle. From here, you can type in various sql commands. Some of the useful ones I learnt from Francis are:
       > select table_name from user_tables;      
           {lists out all the tables in the account}
       > select * from names;
           {list all entries in table names}
       > insert into names (userid,username) values (3,'leonghw');
           {insert an entry into the table} 
    Of course, you can also use other SQL clients to access the database. For more information, please see
    https://www.comp.nus.edu.sg/cf/dbms/oracle.html

    The SDA3 Team will be responsible for designing the tables in the database and for publishing the schema for these tables, and also populating the tables with records. They may need help from some of the Feature Implementation people...

    At the moment, there is a sample table called "Names" with schema {userid,username} and very few records. When I did a query, I got the following:

    >select * from names
    
        USERID USERNAME
    ---------- --------------------
             1 Samantha
             2 Michael
             3 leonghw 

    A Note for the Feature Implementation People:

    Since most of the people doing Feature Implementation are familiar with Java, we have provided Java sample program (CheckName.java) to interface with Oracle and doing query. Each of you will need to first establish an Oracle connection via the dbManager (a custom class written for this project). Then, it does an sql query "select * from names", then "catches" the output, and checks the name is in it.

    (Of course, to list all entries in the table, you can just also just print out the output is caught. You can use this CheckName.java as a sample to play around with it using other sql queries.)


    IDEA GUI Generation

    The SDA2:GUI team will be developing the output screens for IDEA. They need to know the what kind of mesages to output and also what of buttons/forms that are available in the output screen (GUI).

    After receiving the output from the IDEAFeatureEngine programs, the controller parses the results and then calls the appropriate GUI-generation programs to generate the correct GUI (html page).

    In this sample, we provide two mechanisms to do this:

    There is a third mechanism to do this that combines both of these if we use frames in the output GUI page. The appropriate page can first be generated into an html file and then the correct output html file (with frames appropriately done) can be generated.


    UIT2201: CS & IT Revolution; (Spring 2003); A/P Leong HW