From 6bd0b517d38272caf7e81ad01245b946c7798eb5 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Tue, 20 Sep 2011 01:55:09 +0200 Subject: [PATCH] Implement result viewer for experiments --- application/controllers/results.php | 15 +++++ application/libraries/Program_runner.php | 9 +++ application/libraries/programs/Scatt.php | 68 ++++++++++++++++++++++- application/libraries/programs/index.html | 10 ++++ application/views/results/experiment.php | 58 +++++++++++++++++++ application/views/results/index.html | 10 ++++ 6 files changed, 167 insertions(+), 3 deletions(-) create mode 100755 application/libraries/programs/index.html create mode 100644 application/views/results/experiment.php create mode 100755 application/views/results/index.html diff --git a/application/controllers/results.php b/application/controllers/results.php index 977c642..e25346a 100644 --- a/application/controllers/results.php +++ b/application/controllers/results.php @@ -25,6 +25,7 @@ * Result browser. * * @author Karsten Heiken + * @author Eike Foken */ class Results extends MY_Controller { @@ -36,6 +37,7 @@ class Results extends MY_Controller { $this->load->model('program'); $this->load->model('job'); $this->load->model('server'); + $this->load->model('experiment'); } /** @@ -58,6 +60,19 @@ class Results extends MY_Controller { * @param string $experimentId The experiment for which to get the results */ public function experiment($experimentId) { + $experiment = $this->experiment->getById($experimentId); + + // execute program runner + $program = $this->program->getById($experiment['program_id']); + $this->load->library('program_runner', array('program_driver' => $program['driver'])); + $results = $this->program_runner->getResults($experiment['id']); + + $data = array(); // empty data array + $data['experiment'] = $experiment; + $data['project'] = $this->project->getById($experiment['project_id']); + $data['results'] = $results; + + $this->load->view('results/experiment', $data); } /** diff --git a/application/libraries/Program_runner.php b/application/libraries/Program_runner.php index 383c1b9..edcedaf 100644 --- a/application/libraries/Program_runner.php +++ b/application/libraries/Program_runner.php @@ -24,6 +24,7 @@ /** * * @package ScattPort + * @subpackage Libraries * @author Eike Foken */ class Program_runner { @@ -74,6 +75,14 @@ class Program_runner { return true; } + /** + * + * @param string $experimentId + */ + public function getResults($experimentId) { + return $this->driver->_getResults($experimentId); + } + } /* End of file Program_runner.php */ diff --git a/application/libraries/programs/Scatt.php b/application/libraries/programs/Scatt.php index 2741bef..262f8c2 100644 --- a/application/libraries/programs/Scatt.php +++ b/application/libraries/programs/Scatt.php @@ -1,7 +1,30 @@ - */ class Scatt extends Program_runner { @@ -17,7 +40,7 @@ class Scatt extends Program_runner { $this->CI->load->model('program'); $this->program = $this->CI->program->getByDriver(strtolower(__CLASS__)); - log_message('debug', "Scatt Class Initialized"); + log_message('debug', "ScaTT Class Initialized"); } /** @@ -39,4 +62,43 @@ class Scatt extends Program_runner { return true; } -} \ No newline at end of file + + /** + * + * @param string $experimentId + */ + public function _getResults($experimentId) { + $this->CI->load->helper('array'); + + $experiment = $this->CI->experiment->getById($experimentId); + + $path = FCPATH . 'uploads/' . $experiment['project_id'] . '/' . $experiment['id'] . '/'; + + if (!file_exists($path . 'default.out')) { + return array(); + } + + $handler = fopen($path . 'default.out', "r"); + + $results = array(); + + while (($line = fgets($handler)) !== false) { + $values = array(); + $i = 0; + + foreach (preg_split("/\s+/", $line) as $value) { + if ($value != '') { + $values[] = trim($value); + } + $i++; + } + $results[] = $values; + } + + return $results; + } + +} + +/* End of file Scatt.php */ +/* Location: ./application/libraries/programs/Scatt.php */ diff --git a/application/libraries/programs/index.html b/application/libraries/programs/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/application/libraries/programs/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/application/views/results/experiment.php b/application/views/results/experiment.php new file mode 100644 index 0000000..e08a4ec --- /dev/null +++ b/application/views/results/experiment.php @@ -0,0 +1,58 @@ +load->view('header');?> + +
+
+

» » »

+
+ +
+

+ + + + + + + + + + + + + + + + + + + + +
+
+
+ +load->view('footer');?> diff --git a/application/views/results/index.html b/application/views/results/index.html new file mode 100755 index 0000000..c942a79 --- /dev/null +++ b/application/views/results/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file