+
+ if (is_numeric($value))
+ return ((int) ($value * 10))/10;
+
+ return $value;
+
+}
+
+function getTopHatAgents() {
+
+ $tophat_auth = array( 'AuthMethod' => 'password', 'Username' => 'guest@top-hat.info', 'AuthString' => 'guest');
+ $tophat_api = new TopHatAPI($tophat_auth);
+
+ //print ("Requesting tophat agents...");
+ //print_r($r);
+
+ $values = $tophat_api->Get('agents', 'latest', array('colocated.platform_name' => array('SONoMA', 'DIMES', 'ETOMIC', 'TDMI'), 'platform_name'=> 'TDMI'), array('hostname', 'colocated.peer_name', 'colocated.platform_name'));
+
+ $result = array();
+
+ if ($values) foreach ($values as $t) {
+ //print_r($t);
+ //print("<hr>");
+ $result[$t['hostname']] = "";
+ foreach ($t['colocated'] as $ll) {
+
+ if (strpos($result[$t['hostname']]['all'],$ll['platform_name']) === false) {
+ if ($result[$t['hostname']]['all'] != "")
+ $result[$t['hostname']]['all'] .= ",";
+ $result[$t['hostname']]['all'] .= $ll['platform_name'];
+ }
+
+ if ($ll['platform_name'] == 'SONoMA') {
+ if (strpos($result[$t['hostname']]['sonoma'],$ll['peer_name']) === false) {
+ if ($result[$t['hostname']]['sonoma'] != "")
+ $result[$t['hostname']]['sonoma'] .= ",";
+ $result[$t['hostname']]['sonoma'] .= $ll['peer_name'];
+ }
+ }
+
+ if ($ll['platform_name'] == 'TDMI') {
+ if (strpos($result[$t['hostname']]['tdmi'],$ll['peer_name']) === false) {
+ if ($result[$t['hostname']]['tdmi'] != "")
+ $result[$t['hostname']]['tdmi'] .= ",";
+ $result[$t['hostname']]['tdmi'] .= $ll['peer_name'];
+ }
+ }
+ }
+ }
+
+ $this->TopHatAgents = $result;
+
+ //print_r($this->TopHatAgents);
+
+ return $result;
+}
+
+function getTopHatData($data, $planetlab_nodes) {
+
+ $tophat_auth = array( 'AuthMethod' => 'password', 'Username' => 'guest@top-hat.info', 'AuthString' => 'guest');
+ $tophat_api = new TopHatAPI($tophat_auth);
+
+ $requested_data = explode(",", $data);
+
+ $r = array ('hostname');