Beispiel #1
0
/** Maps waveform to the platform. The platform is obtained using the man_platform_get_context()
 * function.
 * The mapping result is saved to each module in the module_t.processor_idx and module_t.exec_position
 * fields. module_t.node is pointed to the platform node object of the allocated processor.
 * The number of nodes allocated to each node is saved in the mapping_t.modules_x_node array.
 * \returns 0 if the mapping was feasible, -1 otherwise. The error description is saved in the
 * oesr_man_error class.
 */
int mapping_map(mapping_t *m, waveform_t *waveform) {
	/**@TODO: Use the oesr_man_error class for error messages */

	mdebug("waveform_name=%s, nof_modules=%d\n",waveform->name, waveform->nof_modules);
	int i;
	int ret=-1;
	float total_mopts;
	man_platform_t *platform = man_platform_get_context();
	man_node_t *node;
	if (!platform) {
		aerror("oesr_man not initialized\n");
		return -1;
	}
	printf("Computing mapping for %d modules...\n",waveform->nof_modules);
	if (mapping_alloc(m,waveform->nof_modules,platform->nof_processors)) {
		return -1;
	}
	if (setup_algorithm(m)) {
		goto free;
	}
	if (generate_model(m, waveform, platform)) {
		goto free;
	}
	if (call_algorithm(m, waveform, platform)) {
		goto free;
	}
	total_mopts=0;
	memset(m->modules_x_node,0,sizeof(int)*MAX(nodes));
	for (i=0;i<waveform->nof_modules;i++) {
		if (m->p_res[joined_function_inv[i]] >= platform->nof_processors) {
			aerror_msg("Module %d mapped to processor %d, but platform has %d processors only\n",
					joined_function_inv[i],m->p_res[joined_function_inv[i]]+1,platform->nof_processors);
			goto free;
		}
		man_processor_t *p = (man_processor_t*) platform->processors[m->p_res[joined_function_inv[i]]];
		waveform->modules[i].node = p->node;
		waveform->modules[i].processor_idx = p->idx_in_node;
		waveform->modules[i].exec_position = i;/*waveform->nof_modules-i-1;*/
		node = p->node;
		m->modules_x_node[node->id]++;
		total_mopts+=waveform->modules[i].c_mopts[0];
	}
	printf("Done. %g GOPTS\n",total_mopts/1000);
	ret = 0;
free:
	mapping_free(m,waveform->nof_modules,platform->nof_processors);
	return ret;
}
WatchDiamondWidget::WatchDiamondWidget(int argc, char **argv, QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);
    setFocusPolicy(Qt::StrongFocus);
    markWidget = new MarkWidget(argc,argv,wg_mark);
    coordinate = new Coordinate(lb_x,lb_y,lb_z,lb_a,lb_b);
    setupDialog= new AlgorithmDialog(this);

    for(int i=0; i<5; i++)
        axisPos[i] = 0;

    doubleValidator = new QDoubleValidator(this);
    le_setDiamondT->setValidator(doubleValidator);
    le_getDiamondT->setValidator(doubleValidator);
    le_glueT->setValidator(doubleValidator);
    le_afterGlueT->setValidator(doubleValidator);

    slowVel = markWidget->get_slow_velocity();
    fastVel = markWidget->get_fast_velocity();
    currentVel = fastVel;
    //QString vel = double_to_qstring(currentVel);
    //le_setVelocity->setText(vel);
    autoRun = false;

    QAction* clear = new QAction(QString::fromUtf8("清除所有"),this);
    te_sysMessage->addAction(clear);
    te_sysMessage->setContextMenuPolicy(Qt::ActionsContextMenu);
    te_sysMessage->setTextColor(QColor(Qt::red));
    te_sysMessage->setReadOnly(true);
    te_sysMessage->setText(QString("system Message:\n"));

    jogButtons[0] = bt_xPlus; jogButtons[1] = bt_xReduce; jogButtons[2] = bt_yPlus; jogButtons[3] = bt_yReduce;
    jogButtons[4] = bt_zPlus; jogButtons[5] = bt_zReduce; jogButtons[6] = bt_aPlus; jogButtons[7] = bt_aReduce;
    jogButtons[8] = bt_bPlus; jogButtons[9] = bt_bReduce;

    ioButtons[0] = tb_1; ioButtons[1] = tb_2; ioButtons[2] = tb_3;
    ioButtons[3] = tb_4; ioButtons[4] = tb_5; ioButtons[5] = tb_6;

    connect(markWidget,SIGNAL(update_emc_status(MarkEmcStatus)),this,SLOT(update_emc_slot(MarkEmcStatus)));    
    connect(markWidget,SIGNAL(update_infor(Information&)),this,SLOT(update_infor_slot(Information&)));
    connect(bt_machineRun,SIGNAL(toggled(bool)),this,SLOT(machine_open_toggled(bool)));
    connect(bt_home,SIGNAL(clicked()),this,SLOT(home()));
    connect(bt_zero,SIGNAL(clicked()),this,SLOT(zero()));
    connect(bt_changeVelocity,SIGNAL(toggled(bool)),this,SLOT(change_vel_toggled(bool)));
    //connect(le_setVelocity,SIGNAL(editingFinished()),this,SLOT(finish_set_velocity()));
    connect(bt_scanDiamond,SIGNAL(clicked()),this,SLOT(scan_diamond()));
    connect(bt_scanWatch,SIGNAL(toggled(bool)),this,SLOT(scan_watch(bool)));
    connect(bt_setGlue,SIGNAL(toggled(bool)),this,SLOT(set_glue(bool)));
    connect(bt_setDiamond,SIGNAL(toggled(bool)),this,SLOT(set_diamond(bool)));
    connect(action_open,SIGNAL(triggered()),this,SLOT(open_project()));
    connect(action_new,SIGNAL(triggered()),this,SLOT(new_project()));
    connect(action_halConfig,SIGNAL(triggered()),this,SLOT(hal_config()));
    connect(action_halMeter,SIGNAL(triggered()),this,SLOT(hal_meter()));
    connect(action_halScope,SIGNAL(triggered()),this,SLOT(hal_scope()));
    connect(action_algorithm,SIGNAL(triggered()),this,SLOT(setup_algorithm()));
    connect(bt_autoRun,SIGNAL(toggled(bool)),this,SLOT(auto_run(bool)));
    connect(bt_pause,SIGNAL(toggled(bool)),this,SLOT(pause(bool)));
    connect(bt_stop,SIGNAL(clicked()),this,SLOT(stop()));
    connect(clear,SIGNAL(triggered()),this,SLOT(clear_error_message()));

    connect(bt_getDiamondZ,SIGNAL(clicked()),this,SLOT(set_height()));
    connect(bt_setGlueZ,SIGNAL(clicked()),this,SLOT(set_height()));
    connect(bt_setDiamondZ,SIGNAL(clicked()),this,SLOT(set_height()));
    connect(sp_getDiamondZ,SIGNAL(editingFinished()),this,SLOT(set_height()));
    connect(sp_setDiamondZ,SIGNAL(editingFinished()),this,SLOT(set_height()));
    connect(sp_setGlueZ,SIGNAL(editingFinished()),this,SLOT(set_height()));

    connect(le_setDiamondT,SIGNAL(editingFinished()),this,SLOT(set_time()));
    connect(le_getDiamondT,SIGNAL(editingFinished()),this,SLOT(set_time()));
    connect(le_glueT,SIGNAL(editingFinished()),this,SLOT(set_time()));
    connect(le_afterGlueT,SIGNAL(editingFinished()),this,SLOT(set_time()));

    connect(hs_slowVel,SIGNAL(valueChanged(int)),this,SLOT(set_velocity(int)));
    connect(hs_fastVel,SIGNAL(valueChanged(int)),this,SLOT(set_velocity(int)));

    connect(sp_pickupOffsetX,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double)));
    connect(sp_pickupOffsetY,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double)));
    connect(sp_glueOffsetX,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double)));
    connect(sp_glueOffsetY,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double)));

    for(int i=0; i<10; i++){
        connect(jogButtons[i],SIGNAL(pressed()),this,SLOT(jog()));
        connect(jogButtons[i],SIGNAL(released()),this,SLOT(end_jog()));
    }

    for(int i=0; i<6; i++){
        connect(ioButtons[i],SIGNAL(toggled(bool)),this,SLOT(io_button_toggled(bool)));
    }

    connect(sp_distance,SIGNAL(valueChanged(double)),this,SLOT(set_diamond_distance(double)));
    sp_distance->setValue(0.080);
    bt_machineRun->setChecked(true);
    timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(ask_home()));
    timer->start(500);

    //bt_home->setChecked(true);
}