Ejemplo n.º 1
0
// remount /
void Dialog::on_pushButton_remount_root_released()
{
    if(!check_if_can_run(false))
        return;
    int ret = backup::do_cmd_return_str("adb shell busybox mount -o remount,rw / 2>&1", ui->textEdit_result);
    if(ret != 0)
        update_result(msg_alert, "Remount root Error!\n");
    else
        update_result(msg_succeed, "Remount root ok!\n");
}
Ejemplo n.º 2
0
// update hardware
void Dialog::on_pushButton_update_hardware_released()
{
    if(!check_if_can_run(false))
        return;
    int ret = backup::do_cmd_return_str("adb push /home/kangear/ybk-hw/ybkMisc/out/target/product/rk30sdk/system/lib/hw/print.default.so /system/lib/hw/ 2>&1", ui->textEdit_result);
    if(ret != 0)
        update_result(msg_alert, "Update hardware Error!\n");
    else
        update_result(msg_succeed, "Update hardware ok!\n");
}
Ejemplo n.º 3
0
// update services.jar
void Dialog::on_pushButton_update_services_released()
{
    if(!check_if_can_run(false))
        return;
    int ret = backup::do_cmd_return_str(get_cmd_update_services_jar(), ui->textEdit_result);
    if(ret != 0)
        update_result(msg_alert, "Update services java Error!\n");
    else
        update_result(msg_succeed, "Update services java ok!\n");
}
Ejemplo n.º 4
0
// reboot device
void Dialog::on_pushButton_reboot_released()
{
    if(!check_if_can_run(false))
        return;

    int ret = backup::do_cmd_return_str("adb reboot 2>&1", ui->textEdit_result);
    if(ret != 0)
        update_result(msg_alert, "Reboot failed!");
    else
        update_result(msg_succeed, "Reboot succeed!");

    update_ui();
}
Ejemplo n.º 5
0
int		my_getnbr(const char *str)
{
  char		sign;
  unsigned int	i;
  int		length;
  int		result;
  unsigned char	overflow;

  sign = '+';
  i = 0;
  length = my_strlen(str);
  result = 0;
  overflow = 0;
  while (i < length && check_valid(str[i]) && !overflow)
    {
      if (str[i] == '+' || str[i] == '-')
	{
	  add_sign(&sign, str[i]);
	}
      else
	{
	  overflow = update_result(&result, str[i], sign);
	}
      i = i + 1;
    }
  return (result);
}
Ejemplo n.º 6
0
void ArcballHelper::update(Arcball const & arcball)
{
    update_drag(arcball);
    update_constraints(arcball);
    update_result(arcball);
    update_rim(arcball);

    helpers = gst::Scene(eye);

    if (show_drag) {
        helpers.add(drag_node);
    }

    if (show_rim) {
        helpers.add(rim_node);
    }

    if (show_result) {
        helpers.add(result_node);
    }

    if (show_constraints) {
        for (auto node : constraint_nodes) {
            helpers.add(node);
        }
    }

    helpers.update();
}
void Analyzer_Position_Estimate_Divergence::evaluate_estimate(
    const std::string name,
    AnalyzerVehicle::Position position,
    AnalyzerVehicle::Position estimate)
{
    if (estimate.lat_modtime() == 0) {
        // No estimate for this  yet
        return;
    }
    double delta = estimate.horizontal_distance_to(position);

    bool failing = (delta > delta_warn());
    // ::fprintf(stderr, "%s: delta=%f delta_warn=%f: %s\n", name.c_str(), delta, delta_warn(), failing ? "FAILING" : "");

    if (_result.count(name) == 0 ||
        _result[name] == NULL) {
        // no current problem
        if (failing) {
            open_result(name, delta);
        }
    } else {
        // problem currently underway
        if (failing) {
            update_result(name, delta);
        } else {
            close_result(name);
        }
    }
}
void Analyzer_Attitude_Estimate_Divergence::evaluate_estimate(
    std::string name,
    AnalyzerVehicle::Attitude attitude,
    AnalyzerVehicle::Attitude estimate)
{
    if (estimate.roll_modtime() == 0) {
        // No estimate for this  yet
        return;
    }

    double delta_roll = fabs(angle_delta(estimate.roll(), attitude.roll()));
    double delta_pitch = fabs(angle_delta(estimate.pitch(), attitude.pitch()));
    // double delta_yaw = estimate.yaw() - attitude.yaw();

    double delta = delta_roll > delta_pitch ? delta_roll : delta_pitch;

    bool failing = (delta >= delta_warn());
    if (_result[name] == NULL) {
        if (failing) {
            open_result(name, delta);
        }
    } else {
        if (failing) {
            update_result(name, delta);
        } else {
            close_result(name);
        }
    }
}
Ejemplo n.º 9
0
void Dialog::on_pushButton_sync_data_released()
{
    if(!check_if_can_run(false))
        return;

    QString android_product_out = target_product_path;
    if(QDir(android_product_out).exists())
    {
        int ret = backup::do_cmd_return_str("adb -p " + android_product_out + " sync data 2>&1", ui->textEdit_result);
        if(ret != 0)
            update_result(msg_alert, "Sync data Failed!\n");
        else
            update_result(msg_succeed, "Sync data Succeed!\n");
    }
    else
        update_result(msg_alert, "No such file or directory!\n");
}
void Analyzer_Position_Estimate_Divergence::open_result(const std::string name,
                                                        double delta)
{
    _result[name] = new Analyzer_Position_Estimate_Divergence_Result(name);
   _result[name]->set_reason("This position estimate differs from the canonical craft position");
    _result[name]->set_T_start(_vehicle->T());
    _result[name]->set_max_delta(0);
    _result[name]->add_source(_data_sources.get("POSITION"));
    _result[name]->add_source(_data_sources.get(std::string("POSITION_ESTIMATE_") + name));
    update_result(name, delta);
}
Ejemplo n.º 11
0
void SendWork() {
    while (isRunning) {
        auto item = SendQueue.GetFrontAndPop();
        pthread_t ptid = pthread_self();
        FM_LOG_TRACE("Send thread id: %d", ptid);
        if (item.first == EXIT_OK) {
            update_result(item.second);
        } else {
            update_system_error(item.first, item.second);
        }
    }
}
Ejemplo n.º 12
0
// update vold.bin
void Dialog::on_pushButton_update_vold_released()
{
    if(!check_if_can_run(true))
        return;

    if(QFile(framework_jar_absolute_path).exists())
    {
        int ret = backup::do_cmd_return_str(get_cmd_update_vold_bin(), ui->textEdit_result);
        if(ret != 0)
            update_result(msg_alert, "Update vold Failed!\n");
        else
        {
            // restart vold
            backup::do_cmd_return_str("adb shell setprop ctl.stop vold && adb shell setprop ctl.start vold 2>&1", ui->textEdit_result);
            update_result(msg_succeed, "Update vold Succeed!\n");
        }
    }
    else
    {
        update_result(msg_alert, "No such file or directory!\n");
    }
}
Ejemplo n.º 13
0
int my_cmd_next(db_res_t* res)
{
	int ret;
	struct my_cmd* mcmd;

	mcmd = DB_GET_PAYLOAD(res->cmd);
	if (mcmd->next_flag == 2 || mcmd->next_flag == -2) return 1;

	if (mcmd->st == NULL) {
		ERR("mysql: Prepared statement not found\n");
		return -1;
	}

	ret = mysql_stmt_fetch(mcmd->st);
	
	if (ret == MYSQL_NO_DATA) {
		mcmd->next_flag =  mcmd->next_flag<0?-2:2;
		return 1;
	}
	/* MYSQL_DATA_TRUNCATED is only defined in mysql >= 5.0 */
#if defined MYSQL_DATA_TRUNCATED
	if (ret == MYSQL_DATA_TRUNCATED) {
		int i;
		ERR("mysql: mysql_stmt_fetch, data truncated, fields: %d\n", res->cmd->result_count);
		for (i = 0; i < res->cmd->result_count; i++) {
			if (mcmd->st->bind[i].error /*&& mcmd->st->bind[i].buffer_length*/) {
				ERR("mysql: truncation, bind %d, length: %lu, buffer_length: %lu\n", 
					i, *(mcmd->st->bind[i].length), mcmd->st->bind[i].buffer_length);
			}
		}
		ret = 0;
	}
#endif
	if (mcmd->next_flag <= 0) {
		mcmd->next_flag++;
	}
	if (ret != 0) {
		ERR("mysql: Error in mysql_stmt_fetch (ret=%d): %s\n", ret, mysql_stmt_error(mcmd->st));
		return -1;
	}

	if (update_result(res->cmd->result, mcmd->st) < 0) {
		mysql_stmt_free_result(mcmd->st);
		return -1;
	}

	res->cur_rec->fld = res->cmd->result;
	return 0;
}
void Analyzer_Velocity_Estimate_Divergence::evaluate_estimate(
    const std::string name,
    AnalyzerVehicle::Velocity &velocity,
    AnalyzerVehicle::Velocity &estimate)
{
    if (estimate.velocity_modtime() == 0) {
        // No estimate for this  yet
        return;
    }

    // make sure we're comparing apples with apples:
    double velocity_size;
    if (estimate.is_2d()) {
        velocity_size = velocity.size_2d();
    } else {
        velocity_size = velocity.size();
    }
    double delta = estimate.size() - velocity_size;
    // ::fprintf(stderr, "delta: %f\n", delta);

    bool failing = (delta > delta_warn());
    // ::fprintf(stderr, "%s: delta=%f delta_warn=%f: %s\n", name.c_str(), delta, delta_warn(), failing ? "FAILING" : "");

    if (_result.count(name) == 0 ||
        _result[name] == NULL) {
        // no current problem
        if (failing) {
            open_result(name, delta);
        }
    } else {
        // problem currently underway
        if (failing) {
            update_result(name, delta);
        } else {
            close_result(name);
        }
    }
}
Ejemplo n.º 15
0
void E_scene_main_game::player_do_a_move(char promotion)
{
	// Inform FAILE of the move
	char piece_pos[6];

	piece_pos[0]=(char)('h'-SquareXSelected);	// from
	piece_pos[1]=(char)(SquareZSelected+'1');	// from
	piece_pos[2]=(char)('h'-FutureXSquare);	// target
	piece_pos[3]=(char)(FutureZSquare+'1');	// target
	piece_pos[4]=promotion; // promotion
	piece_pos[5]=0;

	Player_do_a_move(piece_pos);
	// Update the graphical interface
	chessboard->Move_piece(SquareXSelected+8*SquareZSelected,FutureXSquare+8*FutureZSquare);

	if (game_mode == PLAYER_VS_PLAYER)
	{
		update_result();
		
		if (result!=no_result)
		{
			game_is_over=true;
			pGlobalInfos->GUI_displayResult(result);
		}
	}
					
	
	SquareXSelected=-1;
	SquareZSelected=-1;
	FutureXSquare=-1;
	FutureZSquare=-1;
	
	if (current_color == WHITE)
		current_color = BLACK;
	else
		current_color = WHITE;
}
Ejemplo n.º 16
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->actionBackground, SIGNAL(triggered()), this, SLOT(background_file_open()));
    connect(ui->actionClosed_Aperature, SIGNAL(triggered()), this, SLOT(closedapp_file_open()));
    connect(ui->actionImage_Stack, SIGNAL(triggered()), this, SLOT(imagelist_file_open()));
    connect(ui->actionRun_Experiment, SIGNAL(triggered()), this, SLOT(run_experiment()));

    set_background = false;
    set_closed = false;
    set_image_list = false;

    ui->actionClosed_Aperature->setDisabled(true);
    ui->actionImage_Stack->setDisabled(true);
    ui->actionRun_Experiment->setDisabled(true);
    ui->actionShow_Graph->setDisabled(true);

    frapmodel = new FrapModel(0);

    connect(this,SIGNAL(primaset(QString)),frapmodel,SLOT(setPrima(QString)));
    connect(this,SIGNAL(closedset(QString)),frapmodel,SLOT(setClosed(QString)));
    connect(this,SIGNAL(doselection()),frapmodel,SLOT(doSelection()));
    connect(this,SIGNAL(imagelistset(QStringList)),frapmodel,SLOT(setImageList(QStringList)));

    connect(ui->actionShow_Graph, SIGNAL(triggered()),frapmodel, SLOT(prepareLinearFit()));

    //connect(frapmodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)), ui->tableView,SLOT(dataChanged(QModelIndex,QModelIndex)));
    connect(frapmodel,SIGNAL(update_result(QString)), this, SLOT(show_result(QString)));
    connect(frapmodel,SIGNAL(plotLinearFit(int,std::vector<double>&,std::vector<double>&,std::vector<double>&,double,double)), ui->pl_widget, SLOT(plotLinearFit(int,std::vector<double>&,std::vector<double>&,std::vector<double>&,double,double)));

    ui->tabWidget->setCurrentIndex(0);
    starting_dir = "/home/jon/Programming/C/frap-tool-old";
}
Ejemplo n.º 17
0
// -----------------------------------------------------------------------------
int QALSH::knn(						// k-nn search
	float* query,						// query point
	int top_k,							// top-k value
	ResultItem* rslt,					// k-nn results
	char* output_folder)				// output folder
{
	// -------------------------------------------------------------------------
	//  Space allocation and initialization
	// -------------------------------------------------------------------------
									// init k-nn results
	for (int i = 0; i < top_k; i++) {
		rslt[i].id_   = -1;
		rslt[i].dist_ = MAXREAL;
	}
									// objects frequency
	int* frequency  = new int[n_pts_];
	for (int i = 0; i < n_pts_; i++) {
		frequency[i]  = 0;
	}
									// whether an object is checked
	bool* is_checked = new bool[n_pts_];
	for (int i = 0; i < n_pts_; i++) {
		is_checked[i] = false;
	}

	float* data = new float[dim_];	// one object data
	for (int i = 0; i < dim_; i++) {
		data[i] = 0.0f;
	}
	g_memory += ((SIZEBOOL + SIZEINT) * n_pts_ + SIZEFLOAT * dim_);

	bool* flag = new bool[m_];		// whether a hash table is finished
	for (int i = 0; i < m_; i++) {
		flag[i] = true;
	}

	float* q_val = new float[m_];	// hash value of query
	for (int i = 0; i < m_; i++) {
		q_val[i] = -1.0f;
	}
	g_memory += (SIZEFLOAT + SIZEBOOL) * m_;
									// left and right page buffer
	PageBuffer* lptr = new PageBuffer[m_];
	PageBuffer* rptr = new PageBuffer[m_];
	g_memory += (SIZECHAR * B_ * m_ * 2 + SIZEINT * m_ * 6);

	for (int i = 0; i < m_; i++) {
		lptr[i].leaf_node_ = NULL;
		lptr[i].index_pos_ = -1;
		lptr[i].leaf_pos_  = -1;
		lptr[i].size_      = -1;

		rptr[i].leaf_node_ = NULL;
		rptr[i].index_pos_ = -1;
		rptr[i].leaf_pos_  = -1;
		rptr[i].size_      = -1;
	}

	// -------------------------------------------------------------------------
	//  Compute hash value <q_dist> of query and init the page buffers 
	//  <lptr> and <rptr>.
	// -------------------------------------------------------------------------
	page_io_ = 0;					// num of page i/os
	dist_io_ = 0;					// num of dist cmpt
	init_buffer(lptr, rptr, q_val, query);

	// -------------------------------------------------------------------------
	//  Determine the basic <radius> and <bucket_width> 
	// -------------------------------------------------------------------------
	float radius = find_radius(lptr, rptr, q_val);
	float bucket_width = (w_ * radius / 2.0f);

	// -------------------------------------------------------------------------
	//  K-nn search
	// -------------------------------------------------------------------------
	bool again      = true;			// stop flag
	int  candidates = 99 + top_k;	// threshold of candidates
	int  flag_num   = 0;			// used for bucket bound
	int  scanned_id = 0;			// num of scanned id
	int checked=0;

	int id    = -1;					// current object id
	int count = -1;					// count size in one page
	int start = -1;					// start position
	int end   = -1;					// end position

	float left_dist = -1.0f;		// left dist with query
	float right_dist = -1.0f;		// right dist with query
	float knn_dist = MAXREAL;		// kth nn dist
									// result entry for update
	ResultItem* item = new ResultItem();
	g_memory += (long) sizeof(ResultItem);

	while (again) {
		// ---------------------------------------------------------------------
		//  Step 1: initialize the stop condition for current round
		// ---------------------------------------------------------------------
		flag_num = 0;
		for (int i = 0; i < m_; i++) {
			flag[i] = true;
		}

		// ---------------------------------------------------------------------
		//  Step 2: find frequent objects
		// ---------------------------------------------------------------------
		while (true) {
			for (int i = 0; i < m_; i++) {
				if (!flag[i]) continue;

				// -------------------------------------------------------------
				//  Step 2.1: compute <left_dist> and <right_dist>
				// -------------------------------------------------------------
				left_dist = -1.0f;
				if (lptr[i].size_ != -1) {
					left_dist = calc_proj_dist(&lptr[i], q_val[i]);
				}

				right_dist = -1.0f;
				if (rptr[i].size_ != -1) {
					right_dist = calc_proj_dist(&rptr[i], q_val[i]);
				}

				// -------------------------------------------------------------
				//  Step 2.2: determine the closer direction (left or right)
				//  and do collision counting to find frequent objects.
				//
				//  For the frequent object, we calc the L2 distance with
				//  query, and update the k-nn result.
				// -------------------------------------------------------------
				if (left_dist >= 0 && left_dist < bucket_width && 
					((right_dist >= 0 && left_dist <= right_dist) ||
					right_dist < 0)) {

					count = lptr[i].size_;
					end = lptr[i].leaf_pos_;
					start = end - count;
					for (int j = end; j > start; j--) {
						id = lptr[i].leaf_node_->get_entry_id(j);
						frequency[id]++;
						scanned_id++;

						if (frequency[id] > l_ && !is_checked[id]) {
							is_checked[id] = true;
							read_data(id, dim_, B_, data, output_folder);

							item->dist_ = calc_l2_dist(data, query, dim_);
							item->id_ = id;
							knn_dist = update_result(rslt, item, top_k);
							checked++;
							// -------------------------------------------------
							//  Terminating condition 2
							// -------------------------------------------------
							dist_io_++;
							if (dist_io_ >= candidates) {
								again = false;
								flag_num += m_;
								break;
							}
						}
					}
					update_left_buffer(&lptr[i], &rptr[i]);
				}
				else if (right_dist >= 0 && right_dist < bucket_width && 
					((left_dist >= 0 && left_dist > right_dist) || 
					left_dist < 0)) {

					count = rptr[i].size_;
					start = rptr[i].leaf_pos_;
					end = start + count;
					for (int j = start; j < end; j++) {
						id = rptr[i].leaf_node_->get_entry_id(j);
						frequency[id]++;
						scanned_id++;
						if (frequency[id] > l_ && !is_checked[id]) {
							is_checked[id] = true;
							read_data(id, dim_, B_, data, output_folder);

							item->dist_ = calc_l2_dist(data, query, dim_);
							item->id_ = id;
							knn_dist = update_result(rslt, item, top_k);
   							checked++;
							// -------------------------------------------------
							//  Terminating condition 2
							// -------------------------------------------------
							dist_io_++;
							if (dist_io_ >= candidates) {
								again = false;
								flag_num += m_;
								break;
							}
						}
					}
					update_right_buffer(&lptr[i], &rptr[i]);
				}
				else {
					flag[i] = false;
					flag_num++;
				}
				if (flag_num >= m_) break;
			}
			if (flag_num >= m_) break;
		}
		// ---------------------------------------------------------------------
		//  Terminating condition 1
		// ---------------------------------------------------------------------
		if (knn_dist < appr_ratio_ * radius && dist_io_ >= top_k) {
			again = false;
			break;
		}

		// ---------------------------------------------------------------------
		//  Step 3: auto-update <radius>
		// ---------------------------------------------------------------------
		radius = update_radius(lptr, rptr, q_val, radius);
		bucket_width = radius * w_ / 2.0f;
	}

	// -------------------------------------------------------------------------
	//  Release space
	// -------------------------------------------------------------------------
	if (data != NULL || frequency != NULL || is_checked != NULL) {
		delete[] data; data = NULL;
		delete[] frequency;  frequency  = NULL;
		delete[] is_checked; is_checked = NULL;
		g_memory -= ((SIZEBOOL + SIZEINT) * n_pts_ + SIZEFLOAT * dim_);
	}
	if (q_val != NULL || flag != NULL || item != NULL) {
		delete[] q_val; q_val = NULL;
		delete[] flag; flag = NULL;
		delete   item; item = NULL;
		g_memory -= (SIZEFLOAT + SIZEBOOL) * m_;
		g_memory -= (long) sizeof(ResultItem);
	}

	for (int i = 0; i < m_; i++) {
		// ---------------------------------------------------------------------
		//  CANNOT remove the condition
		//              <lptrs[i].leaf_node != rptrs[i].leaf_node>
		//  Because <lptrs[i].leaf_node> and <rptrs[i].leaf_node> may point 
		//  to the same address, then we would delete it twice and receive 
		//  the runtime error or segmentation fault.
		// ---------------------------------------------------------------------
		if (lptr[i].leaf_node_ && lptr[i].leaf_node_ != rptr[i].leaf_node_) {
			delete lptr[i].leaf_node_; lptr[i].leaf_node_ = NULL;
		}
		if (rptr[i].leaf_node_) {
			delete rptr[i].leaf_node_; rptr[i].leaf_node_ = NULL;
		}
	}
	delete[] lptr; lptr = NULL;
	delete[] rptr; rptr = NULL;
	g_memory -= (SIZECHAR * B_ * m_ * 2 + SIZEINT * m_ * 6);
	return (page_io_ + dist_io_);
}
Ejemplo n.º 18
0
void Dialog::err_log(const QString info)
{
    update_result(msg_alert, info);
}