Skip to content

FOSSEE-Internship/RT-labs-Solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# fossee_sbhs EXPERIMENT ========== Architecture ------------

The previous architecture involved the dependence of network on client side . One of the main agendas here was to remove that dependence . Thus Scilab was introduced on the server .
All the computations on Scilab happen on the server independent of the client network connectivity .
Thus the app involves an architecture where the client when loads the experiment page , All he needs to do is provide the input values and scilab code he wants to run and stimulate .
On server, these input values are received along with the scilab code .
The Scilab Code is run through java using JAVASCI , and the inputs given by the user are passed to it . Now, the Scilab generated values/outputs are passed back to the server. The server redirects the output to the hardware (here sbhs) using Serial Port communication via RXTX library (gnu.io.*). The output generated by the hardware is the desired output which is sent back via the server to the Web Browser.
This whole cycle of running scilab and then communicating with the hardware happens at a iteration rate specified by the user .

PREREQUISITES

  1. Netbeans IDE (run this as root , as for serial port communication bring a root user is necessary)

  2. JAVASCI library
    Here , you need to have a latest scilab version downloaded on your system which includes two jar files and one .so file is required here.
    Shared library file - Path to the scilab version installed/lib/scilab
    jar files -

    1.Path to the scilab version installed/share/scilab/modules /javasci/jar (org.scilab.modules.javasci.jar)

    2.Path to the scilab version installed/share/scilab/modules/types/jar
    (org.scilab.modules.types.jar)
Download the2.2pre2 binary version.
Find the RxtxComm.jar file and libSerial.so (This version might have some issue of the shared library file and jar file not having the same
version , make sure when you choose your .so file , the version’s match).
ADD ALL THE JAR FILES IN THE JVM ITSELF
usr/lib/jvm/<–ur java version–>/jre/lib/–machinetype– / — this is where the .so file goes
-usr/lib/jvm/<–ur java version–>/jre/lib/ext —- this is where jar file goes

Now, for pasting into jvm directly , you need to own the permissions to edit the folder.Change the permissions of the folder by

sudo chown -R /usr/lib/jvm

Now after doing this make changes in ur bash.bashrc file in /etc

- sudo gedit /etc/bash.bashrc (this is bash file for root)
  • Add
  • export SCI=/home/anamika/scilab-5.5.2/share/scilab
  • export LD_LIBRARY_PATH= / home / anamika / scilab -5.5.2 / lib / scilab:/home/anamika/scilab-5.5.2/lib/thirdparty

Add these two exports at the end of the file.

Now ,
start netbeans , after going to the bin folder of netbeans as-
sudo -E ./netbeans
-E(is for preserving the enviornment u have just set).
  1. JDK (use openjdk)
  2. Apache Tomcat 8.0.15

WORKING-

The flow is -

The slot time is 55 min for every booking . So , the server connects all the ports at the start of a slot and all the connections are broken after 55 mins . This is done via ScheduledExecutorService class and ServletContextListeners. Here there are two other threads which are called at an interval of 5 mins from each other to start and break the connections .
Now after a connection is set up the first page that runs when a user enters the initres.jsp page which is responsible for intialising all the resources (like scilab instance , log file etc.) , then he is redirected to the page sbhs.jsp .
Here the user has to upload his code first and then save it by giving it a name.
extension .sci to the file is a compulsion , after uploading saving is also necessary
After that user needs to put his inputs and start the experiment .
The whole cycle of calling scilab and communicating with the device takes place here . It can be paused and stopped . Stopping will initiate a new experiment .
Here , a refresh will also generate new experiment .
Also, The user must allow popups as the closing of resources occur by certain popup windows of file like createnewlog.jsp ,finish.jsp etc.
Also there are certain files which are necessary like-
1 . a file which tells me which port is bonded to which machine
(currently a script makes this file , by pinging every machine )
the file is currently named mid1.txt.
Every time the program is not exited properly , the lock files for the usb port in /var/lock do not get destroyed and thus creates error -
RXTX fhs_lock() Error: creating lock file: /var/lock/LCK..ttyUSB3: File exists
Whenever that occurs run this - sudo -i rm -f /var/lock/LCK*. 2 . A script file which lists all the port currently connected to the machine (currently called test.sh - it has only one command ls /dev/ttyUSB* ).
Make the file excutable *
sudo chmod +x /pathname/test.sh

ISSUES

Javasci library used does not allow more than one instance to be created , thus it will not make a feasible solution.Creating multiple instances might work sometimes but it is unstable and can resultt in crashing of jvm.
Using cloud or calling scilab instances through the terminal is a workaround.
If the scilab part is changed , the other parts of the software can be used as it is .

BE CAREFUL

->Everytime the system is shutdown , the port no changes , use both the files again in such case.
->If the scilab instances aren’t closed properly,the jvm might crash. Restart the system in such a case.
->If all the ports aren’t closed properly , PortInUseException occurs .Start the server again in such a case.
->The session made initially when the user enters the webapp is used throughout .Make no new sessions.
->Make sure you place the required jar files and so files in the jvm or else classloader issues might occur.
--------- * --------- * ---------

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published