void eaps8000UsbUICharWindow::connectivityButtonPressed() { if( _ui->btn_connect->text() == CONNECT_PORT ) { connectPort(); } else if( _ui->btn_connect->text() == DISCONNECT_PORT ) { disconnectPort(); } }
KeytrackSerial::KeytrackSerial(QWidget *parent) : QWidget(parent), ui(new Ui::KeytrackSerial) { ui->setupUi(this); _serial_port = new QSerialPort(this); refreshPortList(); //Populate baudRate combo box with baud rate options ui->baudRate->addItem(QString::number(QSerialPort::Baud1200)); ui->baudRate->addItem(QString::number(QSerialPort::Baud2400)); ui->baudRate->addItem(QString::number(QSerialPort::Baud4800)); ui->baudRate->addItem(QString::number(QSerialPort::Baud9600)); ui->baudRate->addItem(QString::number(QSerialPort::Baud19200)); ui->baudRate->addItem(QString::number(QSerialPort::Baud38400)); ui->baudRate->addItem(QString::number(QSerialPort::Baud57600)); ui->baudRate->addItem(QString::number(QSerialPort::Baud115200)); //Preset baud rate selection to 9600 ui->baudRate->setCurrentText(QString::number(QSerialPort::Baud9600)); //Populate parity combo box with parity options ui->parity->addItem("No Parity"); ui->parity->addItem("Even Parity"); ui->parity->addItem("Odd Parity"); ui->parity->addItem("Space Parity"); ui->parity->addItem("Mark Parity"); updatePortSettings(); connect(ui->connectButton,SIGNAL(clicked()),SLOT(connectPort())); connect(ui->disconnectButton, SIGNAL(clicked()),SLOT(disconnectPort())); connect(ui->baudRate,SIGNAL(currentTextChanged(QString)),SLOT(updatePortSettings())); connect(ui->parity,SIGNAL(currentTextChanged(QString)), SLOT(updatePortSettings())); connect(ui->dataBits,SIGNAL(currentTextChanged(QString)),SLOT(updatePortSettings())); connect(ui->stopBits,SIGNAL(currentTextChanged(QString)),SLOT(updatePortSettings())); connect(_serial_port, SIGNAL(readyRead()),SLOT(handleReadyRead())); connect(ui->sendButton,SIGNAL(clicked()),SLOT(sendTextFromBox())); connect(ui->sendBox,SIGNAL(returnPressed()),SLOT(sendTextFromBox())); connect(this,SIGNAL(destroyed()),SLOT(disconnectPort())); }
void eaps8000UsbUICharWindow::mLabSignal( char signal, const QString& cmd ) { if( signal == SIGNAL_SHUTDOWN ) { emergencyStop(); } else if( signal == SIGNAL_STOP ) { if( _ui->chb_setZeroAtStopSignal->isChecked() ) { uiCharFinished(); _ui->lbl_info->setText( STOP_RECEIVED ); _ui->lbl_info->setStyleSheet( STYLE_ERROR ); } } else if( signal == 10 ) { if( _ui->btn_startStop->text() == STOP ) { startStop(); } } else if( signal == 11 ) { if( _ui->btn_startStop->text() == START ) { startStop(); } } else if( signal == 12 ) { if( _ui->btn_connect->text() == CONNECT_PORT ) { connectPort(); } } else if( signal == 13 ) { if( _ui->btn_connect->text() == DISCONNECT_PORT ) { disconnectPort(); } } else if( signal == 14 ) { if( cmd == "true" ) { _ui->chb_setZeroAtStopSignal->setChecked( true ); } else if( cmd == "false" ) { _ui->chb_setZeroAtStopSignal->setChecked( false ); } } else if( signal == 15 ) { if( cmd == "true" ) { _ui->chb_setZeroWhenFinished->setChecked( true ); } else if( cmd == "false" ) { _ui->chb_setZeroWhenFinished->setChecked( false ); } } else if( signal == 16 ) { if( cmd == "true" ) { _ui->chb_emitStopSignal->setChecked( true ); } else if( cmd == "false" ) { _ui->chb_emitStopSignal->setChecked( false ); } } else if( signal == 18 || signal == 19 ) { resetInfo(); } else if( signal == 41 ) { int indexType = _ui->cob_setValue->findText( cmd ); if( indexType == -1 ) { return; } _ui->cob_setValue->setCurrentIndex( indexType ); } else if( signal == 42 ) { bool conversionSuccessful = false; double stepSize = cmd.toDouble( &conversionSuccessful ); if( conversionSuccessful ) { _ui->dsb_stepSize->setValue( stepSize ); } } else if( signal == 43 ) { if( cmd == "true" ) { _ui->chb_calcValues->setChecked( true ); } else if( cmd == "false" ) { _ui->chb_calcValues->setChecked( false ); } } else if( signal == 45 ) { bool conversionSuccessful = false; double fromValue = cmd.toDouble( &conversionSuccessful ); if( conversionSuccessful ) { _ui->dsb_fromValue->setValue( fromValue ); } } else if( signal == 46 ) { bool conversionSuccessful = false; double toValue = cmd.toDouble( &conversionSuccessful ); if( conversionSuccessful ) { _ui->dsb_toValue->setValue( toValue ); } } else if( signal == 47 ) { int unitType = _ui->cob_unit->findText( cmd ); if( unitType == -1 ) { return; } _ui->cob_unit->setCurrentIndex( unitType ); } else if( signal == 51 ) { bool conversionSuccessful = false; int repeat = cmd.toInt( &conversionSuccessful ); if( conversionSuccessful ) { _ui->spb_repeat->setValue( repeat ); } } else if( signal == 52 ) { if( cmd == "true" ) { _ui->chb_loop->setChecked( true ); } else if( cmd == "false" ) { _ui->chb_loop->setChecked( false ); } } }
void eaps8000UsbWindow::mLabSignal( char signal, const QString& cmd ) { if( signal == SIGNAL_SHUTDOWN ) { emergencyStop(); } else if( signal == SIGNAL_STOP ) { if( _ui->chb_setZeroAtStopSignal->isChecked() && _port.isOpen() ) { _port.setValue( eaps8000UsbPort::setValueType::setTypeVoltage, 0.0, false ); _port.setValue( eaps8000UsbPort::setValueType::setTypeCurrent, 0.0, false ); _ui->lbl_info->setText( STOP_RECEIVED ); _ui->lbl_info->setStyleSheet( STYLE_ERROR ); emit changeWindowState( this->windowTitle(), false ); } } else if( signal == 12 ) { if( _ui->btn_connect->text() == CONNECT_PORT ) { connectPort(); } } else if( signal == 13 ) { if( _ui->btn_connect->text() == DISCONNECT_PORT ) { disconnectPort(); } } else if( signal == 18 || signal == 19 ) { resetInfo(); } else if( signal == 30 ) { if( _port.isRunning() ) { _ui->dsp_setValue->setValue( 0.0 ); _ui->chb_adjustSetValue->setChecked( false ); _port.setValue( eaps8000UsbPort::setValueType::setTypeVoltage, 0.0, false ); _port.setValue( eaps8000UsbPort::setValueType::setTypeCurrent, 0.0, false ); } } else if( signal >= 31 && signal <= 39 ) { if( !_port.isRunning() ) { return; } if( cmd.at( 0 ) != 'a' && cmd.at( 0 ) != 'n' ) { return; } bool adjustValue = false; if( cmd.at( 0 ) == 'a' ) { adjustValue = true; } bool convOk = false; double value = cmd.mid( 1 ).toDouble( &convOk ); if( !convOk ) { return; } QString type; QString unit; if( signal == 31 ) { type = VOLTAGE; unit = UNIT_VOLT; } else if( signal == 32 ) { type = CURRENT; unit = UNIT_AMPERE; } else if( signal == 33 ) { type = POWER; unit = UNIT_WATT; } else if( signal == 34 ) { type = POWER_BY_VOLTAGE; unit = UNIT_WATT; } else if( signal == 35 ) { type == POWER_BY_CURRENT; unit = UNIT_WATT; } else if( signal == 36 ) { type == RESISTANCE_BY_VOLTAGE; unit = UNIT_OHM; } else if( signal == 37 ) { type == RESISTANCE_BY_CURRENT; unit = UNIT_OHM; } else if( signal == 38 ) { type = _ui->cob_setValue->currentText(); unit = _ui->cob_setValueUnit->currentText(); value += _ui->dsp_setValue->value(); } else if( signal == 39 ) { type = _ui->cob_setValue->currentText(); unit = _ui->cob_setValueUnit->currentText(); value *= _ui->dsp_setValue->value(); } int indexType = _ui->cob_setValue->findText( type ); int indexUnit = _ui->cob_setValue->findText( unit ); if( indexType == -1 || indexUnit == -1 ) { return; } _ui->dsp_setValue->setValue( value ); _ui->cob_setValue->setCurrentIndex( indexType ); _ui->cob_setValueUnit->setCurrentIndex( indexUnit ); _ui->chb_adjustSetValue->setChecked( adjustValue ); setValue(); } }
PTUInterface::~PTUInterface(void) { disconnectPort(); }