summaryrefslogtreecommitdiffstats
path: root/Under-Testing/Website/mutexSmartTest.php
diff options
context:
space:
mode:
authorgsmselftest2011-11-17 19:12:47 +0100
committergsmselftest2011-11-17 19:12:47 +0100
commitfadf2551d69a15fdd5782b686b962d4e16e4dd92 (patch)
tree30fe337c0e3a1e86d9ced6772c54f83458c615ec /Under-Testing/Website/mutexSmartTest.php
parentupdate loging files for every handler and fic device configuration function (diff)
downloadgsm-selftest-fadf2551d69a15fdd5782b686b962d4e16e4dd92.tar.gz
gsm-selftest-fadf2551d69a15fdd5782b686b962d4e16e4dd92.tar.xz
gsm-selftest-fadf2551d69a15fdd5782b686b962d4e16e4dd92.zip
need more test for tonight. Will be final version by tomorrow noon.
Diffstat (limited to 'Under-Testing/Website/mutexSmartTest.php')
-rw-r--r--Under-Testing/Website/mutexSmartTest.php354
1 files changed, 177 insertions, 177 deletions
diff --git a/Under-Testing/Website/mutexSmartTest.php b/Under-Testing/Website/mutexSmartTest.php
index 0d535f9..663f2f0 100644
--- a/Under-Testing/Website/mutexSmartTest.php
+++ b/Under-Testing/Website/mutexSmartTest.php
@@ -1,23 +1,21 @@
<html>
-
<head>
<script src='delayedLoading.js' type="text/javascript"></script>
<!--ADD HERE ALL THE NEEDED META DATA -->
<title>Network test live results!</title>
<link rel="stylesheet" href="css/tableCSS.css" type="text/css" media="screen">
</head>
-
<body onscroll="scrollEvent();" onload="loaderInit();">
<div>
-
<?php
@apache_setenv('no-gzip',1);
@ini_set('zlib.output_compression',0);
@ini_set('implicit_flush',1);
-//Connection stuff
+# DB Connection
include 'dbconnection.php';
+# Socket configuration
$port = 34500;
$ip = 'localhost';
@@ -25,142 +23,138 @@ $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mys
mysql_select_db($dbname);
-
-//mutex functions, isfree, lock and release
+#mutex functions, isfree, lock and release
include 'mutexFunctions.php';
+
$nameOfLock = 'Webpage';
$timeToKeepTheMutex = 360;
-//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
+#1 means nobody is on the website
+if ($locking == '1')
{
- //Set a mutex for the webpage
- $lockMe = Lock($nameOfLock,$timeToKeepTheMutex);
-
- if ($lockMe == '1') //1 means a successful lock
- {
- $softwareLock = 'SoftwareStarted';
- $taskAmount= 1;
- $numberofTask =0;
+ $lockMe = Lock($nameOfLock,$timeToKeepTheMutex); //Set a mutex for the webpage
+ if ($lockMe == '1') #1 means a successful lock
+ {
+ #check if the software is running!
+ $softwareLock = 'SoftwareStarted';
+ $taskAmount= 1;
+ $numberofTask =0;
+ if($taskAmount != 0 or $taskAmount == 'ON')
+ {
+ $softwareRunning = isLocked($softwareLock);
+ #1 means software is not started yet, start it
+ if($softwareRunning == '1')
+ {
+ $startApp = fsockopen($ip, 34600, $errno, $error, 5);
+ if (!$startApp)
+ {
+ printf('THE SOFTWARE THAT SHOULD RUN IN BACKGROUND IS NOT RUNNING! -- try to start startSoftware.py script under Server-Code folder');
+ }
+ 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);
+ }
- if($taskAmount != 0 or $taskAmount == 'ON')
- {
- #try to lock the startSoftware
- $StartSoftware = isLocked($softwareLock);
- if($StartSoftware == '1') //1 means software is not started yet, start it
- {
- //trying connect to startsoftware
- $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);
- //send START APP Message to start software to start the task
- fwrite($startApp, "START APP");
- usleep(2500);
- fclose($startApp);
- }
+ #sleep till the software starts
+ sleep(5);
- //sleep till the controller starting
- sleep(6);
- #try to lock the controller
- $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);
+ #try to lock the controller
+ $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!';
+ }
+ else
+ {
+ socket_set_timeout($fp,50);
+ # send message to controller to start the smart test
+ fwrite($fp, "SMART TEST");
- 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);
- fwrite($fp, "SMART TEST");
- if(!feof($fp))
- {
- while(!feof($fp))
- {
- //receive data!
- $received = fgets($fp, 128);
+ if(!feof($fp))
+ {
+ while(!feof($fp))
+ {
+ #receive data!
+ $received = fgets($fp, 128);
- //we got the confirmation from the testing software
- if ($received == "CONFIRM\n")
- {
- $GSMRZ1 = 0;
- $GSMRZ2 = 0;
- $GSMRZ3 = 0;
+ if ($received == "CONFIRM\n")
+ #we got the confirmation from the controller
+ {
+ $GSMRZ1 = 0;
+ $GSMRZ2 = 0;
+ $GSMRZ3 = 0;
+
+ $SIP = 0;
+ $UNISIP = 0;
+ $LANDLINE = 0;
+ $LSFKS = 0;
- $SIP = 0;
- $UNISIP = 0;
- $LANDLINE = 0;
- $LSFKS = 0;
+ $GSMEE = 0;
+ $GSMEV = 0;
+ $GSMET = 0;
+ $GSMEO = 0;
- $GSMEE = 0;
- $GSMEV = 0;
- $GSMET = 0;
- $GSMEO = 0;
+ $SIPP = 0;
+ $LANDLINEP = 0;
+ $UNISIPP = 0;
+ $NANOBTS1P = 0;
+ $NANOBTS2P = 0;
+
+ echo str_pad(' ',4096).'<br>'."\n";
+ ob_implicit_flush(1);
- $SIPP = 0;
- $LANDLINEP = 0;
- $UNISIPP = 0;
- $NANOBTS1P = 0;
- $NANOBTS2P = 0;
- echo str_pad(' ',4096).'<br>'."\n";
- ob_implicit_flush(1);
- echo '<div id="main">
- <table summary = "Results">
+ 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>
+ <tr>
+ <th scope = "col"> From: </th>
+ <th scope = "col" > To: </th>
+ <th scope = "col"> Message: </th>
+ <th scope = "col"> Status: </th>
+ </tr>
</thead>
- <tbody>';
- ob_implicit_flush(1);
- }
- elseif ($received == "TEST DONE\n")
- {
- if ($taskAmount == "ON")
- {
- $taskAmount = "SMART TEST";
- }
+ <tbody>';
+ ob_implicit_flush(1);
+ }
+ elseif ($received == "TEST DONE\n")
+ {
+ if ($taskAmount == "ON")
+ {
+ $taskAmount = "SMART TEST";
+ }
- echo '</tbody>
- </table>';
- echo '</div>';
- echo '<div id="sidebar">';
- echo "<a class='pChart' href='networkResult.php?S=$SIP&RZ1=$GSMRZ1&RZ2=$GSMRZ2&RZ3=$GSMRZ3&US=$UNISIP&LL=$LANDLINE&LS=$LSFKS&EE=$GSMEE&EV=$GSMEV&ET=$GSMET&EO=$GSMEO&SP=$SIPP&SGP=$LANDLINEP&USP=$UNISIPP&NBP1=$NANOBTS1P&NBP2=$NANOBTS2P' data-pchart-alt='Picture3'>Picture 3</a></div>";
- echo '<div id="footer"><font size ="3" face="Century Gothic" color="black">Number of tasks: '.$numberofTask.'<br> TEST SUCCESSFULLY FINISHED!</font></div>';
- ob_implicit_flush(1);
- usleep(100);
- fwrite($fp, 'DISCONNECT'); //tell the testing software it may close
- break;
- }
- else
- {
- //parse the received data!
- $numberofTask++;
- $received = str_replace("\n",'',$received);
- $dataForTable = explode("|", $received);
- $callFrom = strtoupper($dataForTable[1]);
- $callTo = strtoupper($dataForTable[2]);
- $testStatus = strtoupper($dataForTable[3]);
-
- // start algorithm to define the result for the picture
+ echo '</tbody></table>';
+ echo '</div>';
+ echo '<div id="sidebar">';
+echo "<a class='pChart' href='networkResult.php?S=$SIP&RZ1=$GSMRZ1&RZ2=$GSMRZ2&RZ3=$GSMRZ3&US=$UNISIP&LL=$LANDLINE&LS=$LSFKS&EE=$GSMEE&EV=$GSMEV&ET=$GSMET&EO=$GSMEO&SP=$SIPP&SGP=$LANDLINEP&USP=$UNISIPP&NBP1=$NANOBTS1P&NBP2=$NANOBTS2P' data-pchart-alt='Picture3'>Picture 3</a></div>";
+echo '<div id="footer"><font size ="3" face="Century Gothic" color="black">SMART TEST<br>Number of tasks: '.$numberofTask.'<br> TEST SUCCESSFULLY FINISHED!</font></div>';
+ ob_implicit_flush(1);
+ usleep(100);
+ #tell the testing software it may close
+ fwrite($fp, 'DISCONNECT');
+ break;
+ }
+ else
+ {
+ //parse the received data!
+ $numberofTask++;
+ $received = str_replace("\n",'',$received);
+ $dataForTable = explode("|", $received);
+ $callFrom = strtoupper($dataForTable[1]);
+ $callTo = strtoupper($dataForTable[2]);
+ $testStatus = strtoupper($dataForTable[3]);
+
if($callFrom == 'SIP' || $callTo == 'SIP')
{
if($testStatus == '200' || $testStatus == '402')
@@ -280,6 +274,7 @@ if ($locking == '1') //1 means nobody is on the website
}
}
}
+
if($callFrom == 'GSMRZ2' || $callTo == 'GSMRZ2')
{
if($testStatus == '200' || $testStatus == '402')
@@ -359,9 +354,12 @@ if ($locking == '1') //1 means nobody is on the website
{
$NANOBTS1P= 2;
}
+
}
}
+
}
+
if($callFrom == 'GSMRZ3' || $callTo == 'GSMRZ3')
{
if($testStatus == '200' || $testStatus == '402')
@@ -442,8 +440,10 @@ if ($locking == '1') //1 means nobody is on the website
{
$NANOBTS2P= 2;
}
+
}
- }
+ }//
+
}
if($callFrom == 'GSMEXT.O2' || $callTo == 'GSMEXT.O2')
{
@@ -583,6 +583,7 @@ if ($locking == '1') //1 means nobody is on the website
}
}
}
+
if($callFrom == 'GSMEXT.EPLUS' || $callTo == 'GSMEXT.EPLUS')
{
if($testStatus == '200')
@@ -660,6 +661,7 @@ if ($locking == '1') //1 means nobody is on the website
}
}
}
+
if($callFrom == 'GSMEXT.TM' || $callTo == 'GSMEXT.TM')
{
if($testStatus == '200' || $testStatus == '402')
@@ -730,6 +732,7 @@ if ($locking == '1') //1 means nobody is on the website
}
}
+
if($callFrom == 'LANDLINE' || $callTo == 'LANDLINE')
{
@@ -742,6 +745,7 @@ if ($locking == '1') //1 means nobody is on the website
}
elseif($testStatus == '486')
{
+ $LANDLINEP = 1;
if ($LANDLINE != 1)
{
$LANDLINE = -1;
@@ -870,6 +874,7 @@ if ($locking == '1') //1 means nobody is on the website
{
$UNISIPP = 0;
}
+
}
elseif ($testStatus == '501')
{
@@ -889,71 +894,66 @@ if ($locking == '1') //1 means nobody is on the website
}
}
}
-
- echo '<tr>
- <th scope = "row" id = "r100">'. $dataForTable[1] . '</th>
- <th scope = "row" id = "r100">'. $dataForTable[2] . '</th>
- <td> ' . $dataForTable[4] . ' </td>
- <td>' . $dataForTable[3] . '</td>
- </tr>';
+ echo '<tr>
+ <th scope = "row" id = "r100">'. $dataForTable[1] . '</th>
+ <th scope = "row" id = "r100">'. $dataForTable[2] . '</th>
+ <td> ' . $dataForTable[4] . ' </td>
+ <td>' . $dataForTable[3] . '</td>
+ </tr>';
ob_implicit_flush(1);
- usleep(100);
- //tell the software to proceed with the test and confirm receiving data
- fwrite($fp, "CONTINUE");
- }
- }
- }
+ usleep(100);
+ # tesll controller to continue the test
+ fwrite($fp, "CONTINUE");
+ }
+ }
+ }
fclose($fp);//close the soccket and the connection
- }
- }
- elseif($controller == '1')
- {
- echo 'Testing software was not started(didn\'t obtain the lock)! Check it!';
- echo 'Soulution : Check login information (username, password, db name) in DBClass.py';
- echo ' Check manual start manually gsmselftest.py (./gsmselftest.py)';
- }
- else
- {
- echo 'Testing software didn\'t obtain the lock';
- echo 'Soulution : Check login information in DBClass.py';
- echo ' Check manual start manually gsmselftest.py (./gsmselftest.py)';
- }
- }
- 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!)';
- }
- else
- {
- echo 'We have an unknown error! Refresh te web page!';
- }
- }
- else
- {
- echo 'No single test was selected! Please go back and select at least one test';
- }
- }
- elseif($lockMe == '0') //0 means if the attempt timed out (for example, because another client has previously locked the name)
- {
- echo 'Someone was faster than you';
- }
- else
- {
- // # if an error occurred (such as running out of memory or the thread was killed with
- echo 'We have an error here';
- }
+ }
+
+ }
+ elseif($softwareRunning1 == '1')
+ {
+ echo 'Controller was not started(didn\'t obtain the lock)! Check it!';
+ }
+ else
+ {
+ echo 'Testing software didn\'t obtain the lock';
+ }
+ } }
+ elseif($softwareRunning == '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!)';
+ }
+ else
+ {
+ echo 'We have an unknown error! Refresh te web page!';
+ }
+ }
+ else
+ {
+ echo 'No single test was selected! Please go back and select at least one test';
+ }
+ }
+ elseif($lockMe == '0') //0 means if the attempt timed out (for example, because another client has previously locked the name)
+ {
+ echo 'Someone was faster than you';
+ }
+ else
+ {
+ // # if an error occurred (such as running out of memory or the thread was killed with
+ echo 'We have an error here';
+ }
}
elseif ($locking == '0') //0 means somebody is already on the web site
{
- echo 'Somebody is using the web site already!' . "<br>";
+ echo 'Somebody is using the web site already!' . "<br>";
}
else
{
- echo 'We have some serious error here';
+ echo 'We have some serious error here';
}
?>
-
</div>
</body>
</html>