void ShuttleThread::jogshuttle(unsigned short code, unsigned int value) { switch (code) { case JOG : jog(value); break; case SHUTTLE : shuttle(value); break; } }
void ShuttleThread::handle_event(EV ev) { switch (ev.type) { case KEY : key(ev.code, ev.value); break; case JOGSHUTTLE : if (ev.code == JOG) jog(ev.value); if (ev.code == SHUTTLE) shuttle(ev.value); break; } }
void QApplicationCommand::jog(QApplicationCommand::JogType type, int axisIndex, double velocity) { jog(type, axisIndex, velocity, 0.0); }
void QApplicationCommand::jog(QApplicationCommand::JogType type, int axisIndex) { jog(type, axisIndex, 0.0, 0.0); }
void jogging_state_machine(struct jog_state_input* data){ static JOG_STATE state = INIT; static JOG_STATE next_state = INIT; static unsigned int delay = 0; float x = 0; float y = 0; float z = 0; /* sprintf(debug_str, "joy: %d , %d \t", data->x, data->y); printString(debug_str); sprintf(debug_str, "but: %d, %d\n", data->button_a, data->button_b); printString(debug_str);*/ switch(state){ case INIT: if(!data->button_a && !data->button_b){ next_state = JOG_XY; printString("Jogging XY\n"); delay = delay_debounce; state = WAIT; } break; case JOG_XY: if(data->x == 0){ x = -1; jog(X, x); } else if(data->x == 255){ x = 1; jog(X, x); } if(data->y == 0){ y = -1; jog(Y, y); } else if(data->y == 255){ y = 1; jog(Y, y); } if(!data->button_a){ next_state = JOG_Z; printString("Jogging Z\n"); delay = delay_debounce; state = WAIT; } else { next_state = JOG_XY; delay = delay_debounce; state = WAIT; } break; case JOG_Z: if(data->y == 0){ jog(Z, -1); } else if(data->y == 255){ jog(Z, 1); } if(!data->button_b){ next_state = JOG_XY; printString("Jogging XY\n"); delay = delay_debounce; state = WAIT; } else if(!data->button_a){ next_state = ZERO_X; printString("Reset zero X?\n"); delay = delay_debounce; state = WAIT; } else { next_state = JOG_Z; delay = delay_debounce; state = WAIT; } break; case ZERO_X: if(!data->button_a){ reset_axis(X); } if(!data->button_a || !data->button_b){ next_state = ZERO_Y; printString("Reset zero Y?\n"); delay = delay_debounce; state = WAIT; } break; case ZERO_Y: if(!data->button_a){ reset_axis(Y); } if(!data->button_a || !data->button_b){ next_state = ZERO_Z; printString("Reset zero Z?\n"); delay = delay_debounce; state = WAIT; } break; case ZERO_Z: if(!data->button_a){ reset_axis(Z); } if(!data->button_a || !data->button_b){ next_state = INIT; printString("Jogging back to init\n"); delay = delay_debounce; state = WAIT; } case WAIT: if (delay == 0) state = next_state; else delay--; break; } }
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); }