BoardHardware::BoardHardware(QWidget *parent, SubteStatus * subte, EventHandler *eventHandler) : BaseBoard(parent,subte,eventHandler), ui(new Ui::BoardHardware) { ui->setupUi(this); connect(m_eventHandler,SIGNAL(controlReady()),this,SLOT(startBoard())); connect(m_eventHandler,SIGNAL(controlDisable()),this,SLOT(disableScreen())); connect(m_eventHandler,SIGNAL(controlEnable()),this,SLOT(enableScreen())); connect(m_eventHandler,SIGNAL(controlReset()),this,SLOT(resetControls())); connect(m_eventHandler,SIGNAL(cargarEstado(int)),this,SLOT(loadState(int))); connect(m_eventHandler,SIGNAL(bPressed()),this,SLOT(bocinaON())); connect(m_eventHandler,SIGNAL(bReleased()),this,SLOT(bocinaOFF())); // connect(m_eventHandler,SIGNAL(aPressed()),this,SLOT(ranaAD())); // connect(m_eventHandler,SIGNAL(ceroPressed()),this,SLOT(ranaCERO())); // connect(m_eventHandler,SIGNAL(rPressed()),this,SLOT(ranaAT())); connect(m_eventHandler,SIGNAL(fPressed()),this,SLOT(setaON())); connect(m_eventHandler,SIGNAL(tPressed()),this,SLOT(setaOFF())); m_horn = NULL; // m_tractionLever = NULL; // m_rana = NULL; // m_hombreMuerto = NULL; m_setaButton = NULL; m_tractionHardware = NULL; }
BoardRight::BoardRight(QWidget *parent, SubteStatus * subte, EventHandler *eventHandler) : BaseBoard(parent,subte,eventHandler), ui(new Ui::BoardRight) { ui->setupUi(this); QSize buttonSize; buttonSize.setWidth(78); buttonSize.setHeight(78); ui->CONDisy_widget->setSize(buttonSize); ui->DESDisy_widget->setSize(buttonSize); ui->calientapies->setSize(buttonSize); ui->frenoRetencion->setSize(buttonSize); ui->desacople->setSize(buttonSize); connect(m_eventHandler,SIGNAL(controlReady()),this,SLOT(startBoard())); connect(m_eventHandler,SIGNAL(controlDisable()),this,SLOT(disableScreen())); connect(m_eventHandler,SIGNAL(controlEnable()),this,SLOT(enableScreen())); connect(m_eventHandler,SIGNAL(controlReset()),this,SLOT(resetControls())); connect(m_eventHandler,SIGNAL(cargarEstado(int)),this,SLOT(loadState(int))); m_manometer = NULL; m_CON_Disyuntor = NULL; m_DES_Disyuntor = NULL; m_sicasmac = NULL; m_modoConduccion = NULL; m_frenoRetencion = NULL; }
BoardLeft::BoardLeft(QWidget *parent, SubteStatus * subte, EventHandler *eventHandler) : BaseBoard(parent,subte,eventHandler), ui(new Ui::BoardLeft) { ui->setupUi(this); connect(m_eventHandler,SIGNAL(controlReady()),this,SLOT(startBoard())); connect(m_eventHandler,SIGNAL(controlDisable()),this,SLOT(disableScreen())); connect(m_eventHandler,SIGNAL(controlEnable()),this,SLOT(enableScreen())); connect(m_eventHandler,SIGNAL(controlReset()),this,SLOT(resetControls())); connect(m_eventHandler,SIGNAL(cargarEstado(int)),this,SLOT(loadState(int))); }
void EventHandler::processValueChanged(std::string host, std::string key, std::string value){ qDebug() << "value - key:: host:" << host.c_str() << " key:"<< key.c_str() << " value:" << value.c_str() << "time: " << QTime::currentTime().toString() ; if(key.compare("i_iniciar_simulador") == 0){ if (value.compare("con") == 0){ qDebug() << "i_iniciar_simulador con recibido" ; m_eNetHelper->client()->CambiarValorClave("c_listo","0"); emit controlReady(); m_eNetHelper->client()->Suscribirse(m_eNetHelper->instructionsHostName(),"i_estado_simulador"); m_eNetHelper->client()->Suscribirse(m_eNetHelper->visualHostName(),"v_velocidad"); m_eNetHelper->client()->Suscribirse(m_eNetHelper->visualHostName(),"v_voltaje"); m_eNetHelper->client()->Suscribirse(m_eNetHelper->visualHostName(),"v_esfuerzo"); m_eNetHelper->client()->Suscribirse(m_eNetHelper->visualHostName(),"v_estado_puertas"); emit controlReset(); m_eNetHelper->client()->CambiarValorClave("c_rana","at"); m_eNetHelper->client()->CambiarValorClave("c_regulador_mando","0"); m_eNetHelper->client()->CambiarValorClave("c_traccion","0"); m_eNetHelper->client()->CambiarValorClave("c_freno_emergencia","des"); emit controlDisable(); m_eNetHelper->client()->CambiarValorClave("c_listo","1"); }else if (value.compare("des") == 0){ m_eNetHelper->client()->CambiarValorClave("c_listo","0"); m_eNetHelper->client()->CambiarValorClave("c_regulador_mando"," "); m_eNetHelper->client()->CambiarValorClave("c_llave_atp"," "); m_eNetHelper->client()->CambiarValorClave("c_modo_conduccion"," "); Sleep(1000); emit closeApp(); } } else if(key.compare("i_estado_simulador") == 0){ if (value.compare("0") == 0){ qDebug() << "i_estado_simulador 0 recibido" ; m_eNetHelper->client()->CambiarValorClave("c_listo","0"); emit controlReset(); m_eNetHelper->client()->CambiarValorClave("c_rana","at"); m_eNetHelper->client()->CambiarValorClave("c_regulador_de_mando","0"); m_eNetHelper->client()->CambiarValorClave("c_traccion","0"); emit controlDisable(); m_eNetHelper->client()->CambiarValorClave("c_listo","1"); } else if(value.compare("1") == 0){ emit controlEnable(); } else if(value.compare("2") == 0){ emit controlDisable(); } } else if(key.compare("v_velocidad") == 0){ m_subte->updateSpeed(std::stod(value)); qDebug() << "Velocidad ingresa velocidad correcta." ; } else if(key.compare("v_voltaje") == 0){ try{ m_subte->updateVolt(std::stod(value)); } catch (...) { qDebug() << "voltaje incorrecta." ; } } else if(key.compare("v_voltaje") == 0){ try{ m_subte->updateVolt(std::stod(value)); } catch (...) { qDebug() << "voltaje incorrecta." ; } } else if(key.compare("v_esfuerzo") == 0){ try{ m_subte->updateAmm(std::stod(value)); } catch (...) { qDebug() << "esfuerzo incorrecta." ; } } else if(key.compare("v_estado_puertas") == 0){ try{ qDebug() << "cambio de estado de puertas"; QString message = value.c_str(); QStringList parameters = message.split(";"); std::string side = parameters.at(0).toStdString(); std::string state = parameters.at(1).toStdString(); if(side.compare("derecha") == 0){ if(state.compare("abierto") == 0){ m_subte->openRightDoors(); qDebug() << "puertas derechas abiertas"; } else if(state.compare("cerrado") == 0){ m_subte->closeRightDoors(); qDebug() << "puertas derechas cerradas"; } } else { if(state.compare("abierto") == 0){ m_subte->openLeftDoors(); qDebug() << "puertas izquierdas abiertas"; } else if(state.compare("cerrado") == 0){ m_subte->closeLeftDoors(); qDebug() << "puertas izquierdas cerrado"; } } } catch (...) { qDebug() << "valor puertas incorrecto." ; } } }