Commit 1013ff59 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Update device list and status information in camogmgui

parent 75cce656
...@@ -7,7 +7,7 @@ CONFIGS = qt_source ...@@ -7,7 +7,7 @@ CONFIGS = qt_source
IMAGES = $(GUIDIR)/images/filebrowser-01.gif $(GUIDIR)/images/filebrowser-bottom-01.gif $(GUIDIR)/images/png_white_30.png \ IMAGES = $(GUIDIR)/images/filebrowser-01.gif $(GUIDIR)/images/filebrowser-bottom-01.gif $(GUIDIR)/images/png_white_30.png \
$(GUIDIR)/images/record.gif $(GUIDIR)/images/reload.png $(GUIDIR)/images/stop.gif $(GUIDIR)/images/create_folder.png \ $(GUIDIR)/images/record.gif $(GUIDIR)/images/reload.png $(GUIDIR)/images/stop.gif $(GUIDIR)/images/create_folder.png \
$(GUIDIR)/images/divider.png $(GUIDIR)/images/folder.gif $(GUIDIR)/images/help.png $(GUIDIR)/images/quicktime.png \ $(GUIDIR)/images/divider.png $(GUIDIR)/images/folder.gif $(GUIDIR)/images/help.png $(GUIDIR)/images/quicktime.png \
$(GUIDIR)/images/rec_folder.png $(GUIDIR)/images/up_folder.gif $(GUIDIR)/images/play_audio.png $(GUIDIR)/images/rec_folder.png $(GUIDIR)/images/up_folder.gif $(GUIDIR)/images/play_audio.png $(GUIDIR)/images/hdd.png
SRCS = camogm.c camogm_ogm.c camogm_jpeg.c camogm_mov.c camogm_kml.c camogm_read.c index_list.c SRCS = camogm.c camogm_ogm.c camogm_jpeg.c camogm_mov.c camogm_kml.c camogm_read.c index_list.c
......
...@@ -124,7 +124,7 @@ else if ($cmd == "status") ...@@ -124,7 +124,7 @@ else if ($cmd == "status")
header("Content-Type: text/xml"); header("Content-Type: text/xml");
header("Content-Length: ".strlen($status)."\n"); header("Content-Length: ".strlen($status)."\n");
header("Pragma: no-cache\n"); header("Pragma: no-cache\n");
printf($status); printf("%s", $status);
} }
else if ($cmd == "run_status") else if ($cmd == "run_status")
{ {
...@@ -151,7 +151,7 @@ else if ($cmd == "run_status") ...@@ -151,7 +151,7 @@ else if ($cmd == "run_status")
header("Content-Type: text/xml"); header("Content-Type: text/xml");
header("Content-Length: ".strlen($status)."\n"); header("Content-Length: ".strlen($status)."\n");
header("Pragma: no-cache\n"); header("Pragma: no-cache\n");
printf($status); printf("%s", $status);
} }
else if ($cmd=="get_hdd_space"){ else if ($cmd=="get_hdd_space"){
if (isset($_GET['mountpoint'])) if (isset($_GET['mountpoint']))
...@@ -188,7 +188,7 @@ else if ($cmd=="mount") { // mount media like HDD ...@@ -188,7 +188,7 @@ else if ($cmd=="mount") { // mount media like HDD
echo "</".$cmd.">"; echo "</".$cmd.">";
xml_footer(); xml_footer();
} }
else if ($cmd=="unmount") { // unmount media like HDD else if (($cmd=="umount") || ($cmd=="unmount")) { // unmount media like HDD
$message = ""; $message = "";
if (isset($_GET['mountpoint'])) { if (isset($_GET['mountpoint'])) {
$mountpoint = $_GET['mountpoint']; $mountpoint = $_GET['mountpoint'];
...@@ -348,29 +348,36 @@ else ...@@ -348,29 +348,36 @@ else
case "listdevices": case "listdevices":
exec ("cat /proc/partitions", $arr1); exec ("cat /proc/partitions", $arr1);
exec ("cat /proc/mounts", $arr2); exec ("cat /proc/mounts", $arr2);
$j = 0;
// first two lines are header and empty line separator, skip them
$i = 2; $i = 2;
while($i < count($arr1)) { while($i < count($arr1)) {
if(!strpos($arr1[$i], "mtdblock")) { // skip flash and RAM disk partitions
if(!strpos($arr1[$i], "mtdblock") && !strpos($arr1[$i], "ram")) {
$temp = $arr1[$i]; $temp = $arr1[$i];
while(strstr($temp, " ")) { while(strstr($temp, " ")) {
$temp = str_replace(chr(9), " ", $temp); $temp = str_replace(chr(9), " ", $temp);
$temp = str_replace(" ", " ", $temp); $temp = str_replace(" ", " ", $temp);
} }
//echo $temp; if (preg_match_all('/ +[a-z]{3,3}[0-9]{1,1}$/', $temp, $available_partitons) > 0) {
preg_match_all('/[a-z]{3,3}[0-9]{1,1}/', $temp, $available_partitons); // remove leading spaces
//preg_match_all('/[a-z]{3,3}/', $temp, $available_devices); $partitions[$j] = preg_replace("/^ +/", "", $available_partitons[0][0]);
$parts = explode(" ", $temp); $parts = explode(" ", $temp);
$size = $parts[3]; $size[$j] = $parts[3];
$j++;
}
} }
$i++; $i++;
} }
foreach ($available_partitons as $device) { $j = 0;
foreach ($partitions as $partition) {
echo "<item>"; echo "<item>";
echo "<partition>/dev/".$device[0]."</partition>"; echo "<partition>/dev/".$partition."</partition>";
echo "<size>".round($size/1024/1024, 2) ." GB</size>"; echo "<size>".round($size[$j]/1024/1024, 2) ." GB</size>";
$i = 2; $j++;
$i = 0;
while($i < count($arr2)) { while($i < count($arr2)) {
if(strpos($arr2[$i], $device[0])) if(strpos($arr2[$i], $partition))
{ {
$parts = explode(" ", $arr2[$i]); $parts = explode(" ", $arr2[$i]);
$mountpoint = $parts[1]; $mountpoint = $parts[1];
...@@ -378,17 +385,20 @@ else ...@@ -378,17 +385,20 @@ else
} }
$i++; $i++;
} }
if ($mountpoint != "") if ($mountpoint != "") {
echo "<mountpoint>".$mountpoint."</mountpoint>"; echo "<mountpoint>".$mountpoint."</mountpoint>";
else $mountpoint = "";
} else {
echo "<mountpoint>none</mountpoint>"; echo "<mountpoint>none</mountpoint>";
if ($filesystem != "") }
if ($filesystem != "") {
echo "<filesystem>".$filesystem."</filesystem>"; echo "<filesystem>".$filesystem."</filesystem>";
else $filesystem = "";
} else {
echo "<filesystem>none</filesystem>"; echo "<filesystem>none</filesystem>";
}
echo "</item>"; echo "</item>";
} }
break; break;
case "mkdir": case "mkdir":
......
...@@ -75,7 +75,7 @@ function scan_devices() { ...@@ -75,7 +75,7 @@ function scan_devices() {
function process_scan_devices(xmldoc) { function process_scan_devices(xmldoc) {
if (xmldoc.getElementsByTagName('listdevices').length > 0) { if (xmldoc.getElementsByTagName('listdevices').length > 0) {
var content = ""; var content = "";
content += "<table cellpadding='10' cellspacing='0' cellmargin='0'>"; content += "<table cellpadding='5' cellspacing='0' cellmargin='0'>";
content += "<tr><td></td><td><b>Partition</b></td><td><b>Mountpoint</b></td><td><b>Size</b></td><td><b>Filesystem</b></td><td></td></tr>"; content += "<tr><td></td><td><b>Partition</b></td><td><b>Mountpoint</b></td><td><b>Size</b></td><td><b>Filesystem</b></td><td></td></tr>";
for (var i=0; i < xmldoc.getElementsByTagName('item').length; i++) { for (var i=0; i < xmldoc.getElementsByTagName('item').length; i++) {
if (xmldoc.getElementsByTagName('item')[i].firstChild.firstChild.data != null) { if (xmldoc.getElementsByTagName('item')[i].firstChild.firstChild.data != null) {
...@@ -85,7 +85,7 @@ function process_scan_devices(xmldoc) { ...@@ -85,7 +85,7 @@ function process_scan_devices(xmldoc) {
content += " value='/var/hdd'"; content += " value='/var/hdd'";
content += "></td><td>" + xmldoc.getElementsByTagName('size')[i].firstChild.data + "</td><td>" + '</td><td><a href="#" onClick="mount_custom_partition(\'' + xmldoc.getElementsByTagName('partition')[i].firstChild.data + '\');">mount</a></td></tr>'; content += "></td><td>" + xmldoc.getElementsByTagName('size')[i].firstChild.data + "</td><td>" + '</td><td><a href="#" onClick="mount_custom_partition(\'' + xmldoc.getElementsByTagName('partition')[i].firstChild.data + '\');">mount</a></td></tr>';
} else { } else {
content += "<tr><td><img alt=\"HDD\" src=\"../camerasetup/images/hdd.png\"></td><td>" + xmldoc.getElementsByTagName('partition')[i].firstChild.data; content += "<tr><td><img alt=\"HDD\" src=\"images/hdd.png\"></td><td>" + xmldoc.getElementsByTagName('partition')[i].firstChild.data;
content += "</td><td>" + xmldoc.getElementsByTagName('mountpoint')[i].firstChild.data + "</td><td>"; content += "</td><td>" + xmldoc.getElementsByTagName('mountpoint')[i].firstChild.data + "</td><td>";
content += xmldoc.getElementsByTagName('size')[i].firstChild.data + "</td><td>" + xmldoc.getElementsByTagName('filesystem')[i].firstChild.data; content += xmldoc.getElementsByTagName('size')[i].firstChild.data + "</td><td>" + xmldoc.getElementsByTagName('filesystem')[i].firstChild.data;
content += '</td><td><a href="#" onClick="unmount_custom_partition(\' ' + xmldoc.getElementsByTagName('mountpoint')[i].firstChild.data + '\');">unmount</a></td></tr>'; content += '</td><td><a href="#" onClick="unmount_custom_partition(\' ' + xmldoc.getElementsByTagName('mountpoint')[i].firstChild.data + '\');">unmount</a></td></tr>';
...@@ -272,9 +272,11 @@ function makeRequest(url, parameters) { ...@@ -272,9 +272,11 @@ function makeRequest(url, parameters) {
function process_request() { function process_request() {
if (http_request.readyState == 4) { if (http_request.readyState == 4) {
if (http_request.status == 200) { if (http_request.status == 200) {
console.log("process_request");
if(http_request.responseXML != null) { if(http_request.responseXML != null) {
var xmldoc = http_request.responseXML; var xmldoc = http_request.responseXML;
if (xmldoc.getElementsByTagName('camogm_state').length > 0) { if (xmldoc.getElementsByTagName('camogm_state').length > 0) {
console.log(xmldoc.getElementsByTagName('state')[0].firstChild.data);
process_recording(xmldoc); process_recording(xmldoc);
} }
if (xmldoc.getElementsByTagName('command').length > 0) { if (xmldoc.getElementsByTagName('command').length > 0) {
...@@ -319,7 +321,10 @@ function process_recording(xmldoc) { ...@@ -319,7 +321,10 @@ function process_recording(xmldoc) {
var frame_number = xmldoc.getElementsByTagName('frame_number')[0].firstChild.data; var frame_number = xmldoc.getElementsByTagName('frame_number')[0].firstChild.data;
var file_length = xmldoc.getElementsByTagName('file_length')[0].firstChild.data; var file_length = xmldoc.getElementsByTagName('file_length')[0].firstChild.data;
var file_name = xmldoc.getElementsByTagName('file_name')[0].firstChild.data; var file_name = xmldoc.getElementsByTagName('file_name')[0].firstChild.data;
if (state=='"stopped"'){
clearInterval(update_intvl);
}
//Update HTML //Update HTML
document.getElementById('ajax_state').innerHTML = state.substring(1, state.length-1); document.getElementById('ajax_state').innerHTML = state.substring(1, state.length-1);
document.getElementById('ajax_file_duration').innerHTML = Math.round(file_duration*100)/100 + " seconds / " + frame_number + " frames"; document.getElementById('ajax_file_duration').innerHTML = Math.round(file_duration*100)/100 + " seconds / " + frame_number + " frames";
...@@ -345,11 +350,14 @@ function process_recording(xmldoc) { ...@@ -345,11 +350,14 @@ function process_recording(xmldoc) {
} }
recording = false; recording = false;
function update_state() { function update_state() {
if (recording) { //if (recording) {
makeRequest('camogm_interface.php', '?cmd=status'); makeRequest('camogm_interface.php', '?cmd=status');
setTimeout('update_state()', 200); //setTimeout('update_state()', 200);
} //}
} }
var update_intvl;
function toggle_recording() { function toggle_recording() {
if (recording) // Stop it if (recording) // Stop it
{ {
...@@ -376,7 +384,7 @@ function toggle_recording() { ...@@ -376,7 +384,7 @@ function toggle_recording() {
setTimeout('list_files(getCookie("current_dir"))', 300); setTimeout('list_files(getCookie("current_dir"))', 300);
setTimeout('get_hdd_space()', 600); setTimeout('get_hdd_space()', 600);
setTimeout("makeRequest('camogm_interface.php', '?cmd=status')", 900); //setTimeout(last_update, 900);
} }
else // Start it else // Start it
{ {
...@@ -390,8 +398,11 @@ function toggle_recording() { ...@@ -390,8 +398,11 @@ function toggle_recording() {
// show we are recording // show we are recording
document.getElementById('record_text').innerHTML = "<img src=\"images/stop.gif\" style=\"position:relative; bottom:-5px;\"> STOP"; document.getElementById('record_text').innerHTML = "<img src=\"images/stop.gif\" style=\"position:relative; bottom:-5px;\"> STOP";
document.getElementById('sitecoloumn').style.backgroundColor = "#AF2020"; document.getElementById('sitecoloumn').style.backgroundColor = "#AF2020";
clearInterval(update_intvl);
update_intvl = setInterval(update_state,1000);
} }
update_state(); //update_state();
} }
function rename_file(oldname, newname) { function rename_file(oldname, newname) {
makeRequest('camogm_interface.php', '?cmd=file_rename&file_old=' + oldname + '&file_new=' + newname); makeRequest('camogm_interface.php', '?cmd=file_rename&file_old=' + oldname + '&file_new=' + newname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment