function perform_calculate_sensor_data() { //write_to_log(__FILE__,__LINE__,__FUNCTION__,'$_GET[countofcall]',$_GET['countofcall']); if ($_GET['countofcall'] == 0) { //write_to_log(__FILE__,__LINE__,__FUNCTION__,'$_GET[countofcall]',$_GET['countofcall']); // $data=read_sensor_data_old($_POST['consequent_id_1']); $data = read_sensor_data($_POST['consequent_id_1']); // print_r($_SESSION['$jt']); // $jt=$_SESSION['$jt']; $nodeId = $_GET['node']; $jt2 = gettree(); $jN = $jt2->getNode($nodeId); $jChildren = $jN->getChildren(); $row_count = 0; $child_data_row = array(); $t = 0; $child_data_ass = array(); foreach ($jChildren as $value) { // write_to_log(__FILE__,__LINE__,__FUNCTION__,'$value',$value); // write_to_log(__FILE__,__LINE__,__FUNCTION__,'$_SESSION['.$value.']["sensor_data_result_non_normalize_1"]',$_SESSION[$value]["sensor_data_result_non_normalize_1"]); if (isset($_SESSION[$value]["sensor_data_result_non_normalize_1"])) { $child_data_row[$t] = $_SESSION[$value]["sensor_data_result_non_normalize_1"]; $child_data_ass[$value] = $child_data_row[$t]; // echo'$child_data_ass<br>'; // print_r($child_data_ass); $t++; } } write_to_log(__FILE__, __LINE__, __FUNCTION__, '$child_data_ass', $child_data_ass); write_to_log(__FILE__, __LINE__, __FUNCTION__, '$child_data_row', $child_data_row); if (count($child_data_row) > 0) { $child_data = flip_array($child_data_row); write_to_log(__FILE__, __LINE__, __FUNCTION__, 'flipped $child_data_row', $child_data_row); if (!is_array($data)) { if ($data == 'FNF') { $data = $child_data; } } else { // $data = merge_array($data,$child_data); $data = merge_array_ass($data, $child_data_ass); $data = flip_array($data); } } else { $tmp = array(); foreach ($data as $x => $x_value) { $tmp[] = $x_value; } $data = $tmp; $data = flip_array($data); } write_to_log(__FILE__, __LINE__, __FUNCTION__, 'count($data)', count($data)); write_to_log(__FILE__, __LINE__, __FUNCTION__, '$data', $data); $rows = count($data); $cols = count($data[0]); // assumes non empty matrix // for($i=0;$i<$rows;$i++){ // for($j=0;$j<$cols;$j++){ // write_to_log(__FILE__,__LINE__,__FUNCTION__,'$data['.$i.']['.($j).']',$data[$i][($j)]); // } // } $_SESSION[$_GET['node']]['horizontalAxisLabel'] = array(); // write_to_log(__FILE__,__LINE__,__FUNCTION__,'$_SESSION['.$_GET['node'].'][horizontalAxisLabel]',$_SESSION[$_GET['node']]['horizontalAxisLabel']); for ($j = 1; $j <= $_POST['number_of_child']; $j++) { $_SESSION[$_GET['node']]['horizontalAxisLabel'][$j - 1] = $_POST['antecedent_id_' . $j]; $_SESSION[$_GET['node']]["sensor_data_result_" . $j] = array_fill(0, count($data), 0); $_SESSION[$_GET['node']]["sensor_graph_label_" . $j] = array_fill(0, count($data), 0); } write_to_log(__FILE__, __LINE__, __FUNCTION__, '$_SESSION[' . $_GET['node'] . '][horizontalAxisLabel]', $_SESSION[$_GET['node']]['horizontalAxisLabel']); for ($i = 0; $i < count($data); $i++) { for ($j = 1; $j <= $_POST['number_of_child']; $j++) { if (isset($_POST['antecedent_checked_input_' . $j]) && !empty($_POST['antecedent_checked_input_' . $j])) { write_to_log(__FILE__, __LINE__, __FUNCTION__, '$data[' . $i . '][' . ($j - 1) . ']', $data[$i][$j - 1]); $_POST['antecedent_input_' . $j] = $data[$i][$j - 1]; write_to_log(__FILE__, __LINE__, __FUNCTION__, '$_POST[antecedent_input_' . $j . ']', $_POST['antecedent_input_' . $j]); } } compute_rule_base($_POST['consequent_id_1'], $_POST['consequent_number_of_ref_val']); $input_Transformation = execute_Input_Transformation(); write_to_log(__FILE__, __LINE__, __FUNCTION__, '$input_Transformation', $input_Transformation); $resul1 = execute_Activation_Weight_Computation(); write_to_log(__FILE__, __LINE__, __FUNCTION__, 'execute_Activation_Weight_Computation : $resul1', $resul1); perform_update(); $resul1 = perform_aggregation(); write_to_log(__FILE__, __LINE__, __FUNCTION__, 'perform_aggregation $resul1', $resul1); for ($k = 1; $k <= $_POST['number_of_child']; $k++) { // write_to_log(__FILE__,__LINE__,__FUNCTION__,'after $_SESSION['.$_GET['node'].'][crisp_value]',$_SESSION[$_GET['node']]['crisp_value']); // $_SESSION[$_GET['node']]["sensor_data_result_".$k][$i]=convert_to_crisp(explode("-",$resul1)); $_SESSION[$_GET['node']]["sensor_data_result_" . $k][$i] = $_SESSION[$_GET['node']]['crisp_value']; $_SESSION[$_GET['node']]["sensor_data_result_non_normalize_" . $k][$i] = $_SESSION[$_GET['node']]['crisp_value']; if (isset($_POST['antecedent_checked_input_' . $k]) && !empty($_POST['antecedent_checked_input_' . $k])) { $_SESSION[$_GET['node']]["sensor_graph_label_" . $k][$i] = $data[$i][$k - 1]; } else { $_SESSION[$_GET['node']]["sensor_graph_label_" . $k][$i] = $_POST['antecedent_input_' . $k]; } // $_SESSION[$_GET['node']]['horizontalAxisLabel_'.$j]=$_POST['antecedent_id_'.$j]; } } // write_to_log(__FILE__,__LINE__,__FUNCTION__,'before normalize $_SESSION['.$_GET['node'].'][sensor_data_result_'.$k.']',$_SESSION[$_GET['node']]["sensor_data_result_".$k]); for ($k = 1; $k <= $_POST['number_of_child']; $k++) { write_to_log(__FILE__, __LINE__, __FUNCTION__, 'before normalize $_SESSION[' . $_GET['node'] . '][sensor_data_result_' . $k . ']', $_SESSION[$_GET['node']]["sensor_data_result_" . $k]); $_SESSION[$_GET['node']]["sensor_data_result_" . $k] = data_normalization($_SESSION[$_GET['node']]["sensor_data_result_" . $k]); $_SESSION[$_GET['node']]["sensor_data_result_" . $k][$i] = 'end'; // $_SESSION[$_GET['node']]["sensor_graph_label_".$k]=data_normalization($_SESSION[$_GET['node']]["sensor_graph_label_".$k]); $_SESSION[$_GET['node']]["sensor_graph_label_" . $k] = $_SESSION[$_GET['node']]["sensor_graph_label_" . $k]; write_to_log(__FILE__, __LINE__, __FUNCTION__, 'after normalize $_SESSION[' . $_GET['node'] . '][sensor_data_result_' . $k . ']', $_SESSION[$_GET['node']]["sensor_data_result_" . $k]); } } $dataTObeNormalize = array(); for ($k = 1; $k <= $_POST['number_of_child']; $k++) { write_to_log(__FILE__, __LINE__, __FUNCTION__, '$_SESSION[' . $_GET['node'] . '][sensor_data_result_' . $k . ']', $_SESSION[$_GET['node']]["sensor_data_result_" . $k]); write_to_log(__FILE__, __LINE__, __FUNCTION__, '$_SESSION[' . $_GET['node'] . '][sensor_graph_label_' . $k . ']', $_SESSION[$_GET['node']]["sensor_graph_label_" . $k]); $dataTObeNormalize[] = $_SESSION[$_GET['node']]["sensor_graph_label_" . $k]; } // print_r($dataTObeNormalize); // echo('max<br>'); // print_r(m_max($dataTObeNormalize)); // echo('min<br>'); // print_r(m_min($dataTObeNormalize)); return 'done'; }
function perform_calculate_sensor_data() { //write_to_log(__FILE__,__LINE__,__FUNCTION__,'$_GET[countofcall]',$_GET['countofcall']); if ($_GET['countofcall'] == 0) { //write_to_log(__FILE__,__LINE__,__FUNCTION__,'$_GET[countofcall]',$_GET['countofcall']); $data = read_sensor_data($_POST['consequent_id_1']); /* if(count($data)==0){ for($j=1;$j<=$_POST['number_of_child'];$j++){ } } */ write_to_log(__FILE__, __LINE__, __FUNCTION__, '$data', $data); $_SESSION["sensor_data_result"] = array_fill(0, count($data), 0); $_SESSION["sensor_graph_label"] = array_fill(0, count($data), 0); write_to_log(__FILE__, __LINE__, __FUNCTION__, 'count($data)', count($data)); for ($i = 0; $i < count($data); $i++) { for ($j = 1; $j <= $_POST['number_of_child']; $j++) { if (isset($_POST['antecedent_checked_input_' . $j]) && !empty($_POST['antecedent_checked_input_' . $j])) { $_POST['antecedent_input_' . $j] = $data[$i]; write_to_log(__FILE__, __LINE__, __FUNCTION__, '$_POST[antecedent_input_' . $j . ']', $_POST['antecedent_input_' . $j]); $_SESSION['horizontalAxisLabel'] = $_POST['antecedent_id_' . $j]; } } // $_POST['antecedent_input_1']=$data[$i]; // write_to_log(__FILE__,__LINE__,__FUNCTION__,'$_POST[antecedent_input_2]',$_POST['antecedent_input_2']); // echo '<br> $_POST[antecedent_input_2]<br>'; // print_r($_POST['antecedent_input_2']); // echo'<br>'; // $_SESSION["sensor_data_result"][$i]=$data[$i]; compute_rule_base($_POST['consequent_id_1'], $_POST['consequent_number_of_ref_val']); // CreateRuleBase(); $input_Transformation = execute_Input_Transformation(); write_to_log(__FILE__, __LINE__, __FUNCTION__, '$input_Transformation', $input_Transformation); $resul1 = execute_Activation_Weight_Computation(); write_to_log(__FILE__, __LINE__, __FUNCTION__, '$resul1', $resul1); perform_update(); $resul1 = perform_aggregation(); write_to_log(__FILE__, __LINE__, __FUNCTION__, '$resul1', $resul1); $_SESSION["sensor_data_result"][$i] = convert_to_crisp(explode("-", $resul1)); $_SESSION["sensor_graph_label"][$i] = $data[$i]; } $_SESSION["sensor_data_result"] = data_normalization($_SESSION["sensor_data_result"]); $_SESSION["sensor_data_result"][$i] = 'end'; write_to_log(__FILE__, __LINE__, __FUNCTION__, '$_SESSION["sensor_data_result"]', $_SESSION["sensor_data_result"]); } write_to_log(__FILE__, __LINE__, __FUNCTION__, '$_SESSION["sensor_data_result"]', $_SESSION["sensor_data_result"]); return implode(",", $_SESSION["sensor_data_result"]); }