summaryrefslogtreecommitdiffstats
path: root/Under-Testing/Website/mutexTry.php
diff options
context:
space:
mode:
authorTriatmoko2011-11-16 21:45:25 +0100
committerTriatmoko2011-11-16 21:45:25 +0100
commitda276e3f3627746db06b63e678d45740e833648e (patch)
treeba785ea5c13a05d3a8ef1d52d930c092037dfd53 /Under-Testing/Website/mutexTry.php
parentThe real time showing on the web site works fine (diff)
downloadgsm-selftest-da276e3f3627746db06b63e678d45740e833648e.tar.gz
gsm-selftest-da276e3f3627746db06b63e678d45740e833648e.tar.xz
gsm-selftest-da276e3f3627746db06b63e678d45740e833648e.zip
bug on smart test
Diffstat (limited to 'Under-Testing/Website/mutexTry.php')
-rwxr-xr-xUnder-Testing/Website/mutexTry.php198
1 files changed, 98 insertions, 100 deletions
diff --git a/Under-Testing/Website/mutexTry.php b/Under-Testing/Website/mutexTry.php
index 5579437..3bf32c8 100755
--- a/Under-Testing/Website/mutexTry.php
+++ b/Under-Testing/Website/mutexTry.php
@@ -10,7 +10,6 @@
<?php
//Connection stuff
-//DB
include 'dbconnection.php'
//Socket
@@ -20,113 +19,112 @@ $ip = 'localhost';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname);
-//End of connection stuff
-include 'mutexFunctions.php'; //mutex functions, isfree, lock and release
-include 'insertData.php'; //insert task functions
+
+//mutex functions, isfree, lock and release
+include 'mutexFunctions.php';
+//insert task functions
+include 'insertData.php';
$nameOfLock = 'Webpage';
$timeToKeepTheMutex = 360;
-$locking = isLocked($nameOfLock);//Check if the webpage is already open
+//Check if the webpage is already open
+$locking = isLocked($nameOfLock);
if ($locking == '1') //1 means nobody is on the website
{
- $lockMe = Lock($nameOfLock,$timeToKeepTheMutex); //Set a mutex for the webpage
- if ($lockMe == '1') //1 means a successful lock
- {
-
- include 'post.php'; // read posted data and add them to the database
- //check if the software is running!
- $softwareLock = 'SoftwareStarted';
+ //Set a mutex for the webpage
+ $lockMe = Lock($nameOfLock,$timeToKeepTheMutex);
+ if ($lockMe == '1') //1 means a successful lock
+ {
+ // read posted data and add them to the database
+ include 'post.php';
+ $softwareLock = 'SoftwareStarted';
- if($taskAmount != 0)
- {
- $softwareRunning = isLocked($softwareLock);
- if($softwareRunning == '1') //1 means software is not started yet, start it
- {
- $startApp = fsockopen($ip, 34600, $errno, $error, 5);
- if (!$startApp)
- {
- printf('THE SOFTWARE THAT SHOULD RUN IN BACKGROUND IS NOT RUNNING!');
- }
- else
- {
- socket_set_timeout( $startApp, 50); //one should set the number of the longest test, so we can define the timeout
- fwrite($startApp, "START APP");
- usleep(2500);
- fclose($startApp);
- }
-
- sleep(6); //sleep till the software starts
- //the software should be running already and set the lock, now we test it and then connect to it!
-
- $softwareRunning1 = isLocked($softwareLock);
- if($softwareRunning1 == '0') //Software running and waiting for connection!
- {
- //try to open the socket and connect to the software
- $fp = fsockopen($ip, $port, $errno, $error, 5);
-
- if (!$fp)
- {
- echo 'Could not open the socket or connect to the testing software! Check ports on both sides!';
+ if($taskAmount != 0)
+ {
+ #try to lock the startSoftware
+ $StartSoftware = isLocked($softwareLock);
+ if($StartSoftware == '1') //1 means software is not started yet, start it
+ {
+ $startApp = fsockopen($ip, 34600, $errno, $error, 5);
+ if (!$startApp)
+ {
+ printf('THE SOFTWARE THAT SHOULD RUN IN BACKGROUND IS NOT RUNNING!');
+ printf('Solution: - You need to start the script which always running background (startSoftware.py)');
+ printf(' - You can find this script on Code -> Server-Code -startSoftware.py');
+ printf(' - python startSoftware.py');
+ }
+ else
+ {
+ socket_set_timeout( $startApp, 50); //one should set the number of the longest test, so we can define the timeout
+ fwrite($startApp, "START APP");
+ usleep(2500);
+ fclose($startApp);
+ }
+ //sleep till the software starts
+ sleep(6);
+ $controller = isLocked($softwareLock);
+ if($controller == '0') //Software running and waiting for connection!
+ {
+ //try to open the socket and connect to the software
+ $fp = fsockopen($ip, $port, $errno, $error, 5);
+ if (!$fp)
+ {
+ echo 'Could not open the socket or connect to the testing software! Check ports on both sides!';
- }
- else
- {
- socket_set_timeout($fp,50); //one should set the number of the longest test, so we can define the timeout function (it is the number after "$fp,")
-
- fwrite($fp, "START TEST");
-
- if(!feof($fp))
- {
- while(!feof($fp))
- {
- $received = fgets($fp, 128); //receive data!
-
- if ($received == "CONFIRM\n") //we got the confirmation from the testing software
- {
- //test finished successfully
-
- $GSMRZ1 = 0;
- $GSMRZ2 = 0;
- $GSMRZ3 = 0;
-
- $SIP = 0;
- $UNISIP = 0;
- $LANDLINE = 0;
- $LSFKS = 0;
-
- $GSMEE = 0;
- $GSMEV = 0;
- $GSMET = 0;
- $GSMEO = 0;
-
- $SIPP = 2;
- $LANDLINEP = 2;
- $UNISIPP = 2;
- $NANOBTS1P = 2;
- $NANOBTS2P = 2;
- /////////// end of test!
- echo '<div id="main">
- <table summary = "Results">
- <thead>
- <tr>
- <th scope = "col"> From: </th>
- <th scope = "col" > To: </th>
- <th scope = "col"> Message: </th>
- <th scope = "col"> Status: </th>
- </tr>
- </thead>
- <!-- start of the table rows-->
- <tbody>';
- echo str_repeat("\n",7024);
- flush();
- sleep(6);
- $pings = mysql_query("select * from PingResultTable where taskNo=(select max(taskNo) from PingResultTable)");
+ }
+ else
+ {
+ socket_set_timeout($fp,50);
+ fwrite($fp, "START TEST");
+ if(!feof($fp))
+ {
+ while(!feof($fp))
+ {
+ $received = fgets($fp, 128); //receive data!
+ //we got the confirmation from the testing software
+ if ($received == "CONFIRM\n")
+ {
+ $GSMRZ1 = 0;
+ $GSMRZ2 = 0;
+ $GSMRZ3 = 0;
+
+ $SIP = 0;
+ $UNISIP = 0;
+ $LANDLINE = 0;
+ $LSFKS = 0;
- while($row = mysql_fetch_array($pings))
- {
- // echo $row['taskNo'];
+ $GSMEE = 0;
+ $GSMEV = 0;
+ $GSMET = 0;
+ $GSMEO = 0;
+
+ $SIPP = 2;
+ $LANDLINEP = 2;
+ $UNISIPP = 2;
+ $NANOBTS1P = 2;
+ $NANOBTS2P = 2;
+
+ echo '<div id="main">
+ <table summary = "Results">
+ <thead>
+ <tr>
+ <th scope = "col"> From: </th>
+ <th scope = "col" > To: </th>
+ <th scope = "col"> Message: </th>
+ <th scope = "col"> Status: </th>
+ </tr>
+ </thead>
+ <!-- start of the table rows-->
+ <tbody>';
+ echo str_repeat("\n",7024);
+ flush();
+ sleep(6);
+ $pings = mysql_query("select * from PingResultTable where taskNo=(select max(taskNo) from PingResultTable)");
+
+ while($row = mysql_fetch_array($pings))
+ {
$SIPP = $row['sipServer'];
$LANDLINEP = $row['sipGate'];
$UNISIPP = $row['unisip'];
@@ -917,7 +915,7 @@ if ($locking == '1') //1 means nobody is on the website
}
}
- elseif($softwareRunning1 == '1')
+ elseif($controller == '1')
{
echo 'Testing software was not started(didn\'t obtain the lock)! Check it!';
}
@@ -926,7 +924,7 @@ if ($locking == '1') //1 means nobody is on the website
echo 'Testing software didn\'t obtain the lock';
}
}
- elseif($softwareRunning == '0') //0 means the software is still running in the background
+ elseif($StartSoftware == '0') //0 means the software is still running in the background
{
echo 'Testing software is still running! Maybe you should kill it (if not started manually!)';
}