bool ItemsList::generateSchedule() { if (!m_actualTable.isEmpty() && mainOrderActive ) { setAnimationVisible(true); emit animationVisible(getAnimationVisible()); if( setPath().isEmpty() ) { runMsg("Nie wybrano lokalizacji."); setAnimationVisible(false); emit animationVisible(getAnimationVisible()); return false; } QAxObject* excel; QAxObject* wbooks; QAxObject* book; QFileInfo scheduleFile("schedule.xlsm"); QVariant excelPath; QVariant destPath; excelPath = QVariant(scheduleFile.absoluteFilePath().replace("/", "\\\\")); excel = new QAxObject("Excel.Application", this); excel->setProperty("Visible", false); excel->setProperty("DisplayAlerts",0); wbooks = excel->querySubObject("Workbooks"); book = wbooks->querySubObject("Open (const QString&)", excelPath); destPath = excel->dynamicCall("Run(QVariant)", QVariant("runMacro")); book->dynamicCall("Close()"); excel->dynamicCall("Quit()"); runMsg("Wygenerowano harmonogram",destPath.toString()); delete book; delete wbooks; delete excel; setAnimationVisible(false); emit animationVisible(getAnimationVisible()); csvFile->remove(); tableDialog->model->clear(); mainOrderActive = false; return true; } else if(m_actualTable.isEmpty() || !mainOrderActive ) { runMsg("Zamówienie jest puste."); return false; } return false; }
bool ItemsList::checkData() { if( m_order.isEmpty() || m_recipient.isEmpty()) { runMsg("Nie uzupełniono pól tekstowych"); return false; } else if( m_year.toInt() < 2015 || m_day.toInt() < 1 || m_month.toInt() < 1) { runMsg("Termin dostawy nieprawidłowy."); return false; } else return true; }
void ItemsList::showTable() { if (mainOrderActive) tableDialog->exec(); else { runMsg("Zamówienie jest puste."); } }
void CCommComponent::run_V4_FilterTest() { while(true) { if(true == mStandbyState) { std:: cout << "[*] Comm-Component: Server waiting for connection" << std::endl; mServer.waitForClient(); CMessage msg(EEvent::EV_REQUEST_RUN); if(mTxQueue.addMessage(msg, true)) { std::cout << "[*] Comm-Component: RUN-Request transmitted" << std::endl; } mStandbyState = false; //Switch to running mode } else //RUNNING-State { CMessage msg; if(mRxQueue.getMessage(msg, true)) { if(msg.mHeader.mEvent == EEvent::EV_REQUEST_TX_DATA) { if(false == mServer.transmitMessage(msg)) { //Connection was shutdown by Matlab, notify the Control-Component and terminate the process CMessage runMsg(EEvent::EV_REQUEST_STANDBY); if(mTxQueue.addMessage(runMsg, true)) { std::cout << "[*] Comm-Component: Sent STANDBY-Request to the Control-Component" << std::endl; } mStandbyState = true; std::cout << "[*] Comm-Component: Client disconnected, terminating" << std::endl; exit(0); } else { if(EDataType::SENSOR_DATA == msg.mHeader.mDataType) { std::cout << "[*] Comm-Component: Sensor-Data received" << std::endl; } else if(EDataType::UNFILTERED_DATA == msg.mHeader.mDataType) { std::cout << "[*] Comm-Component: Unfiltered-Data received" << std::endl; } else if(EDataType::COMPLEMENTARY_DATA == msg.mHeader.mDataType) { std::cout << "[*] Comm-Component: Complementary-Filter-Data received" << std::endl; } else if(EDataType::KALMAN_DATA == msg.mHeader.mDataType) { std::cout << "[*] Comm-Component: Kalman-Filter-Data received" << std::endl; } } } } } } }
void CCommComponent::run_V1_AusgleichsPolynomAccelerometer() { while(true) { if(mStandbyState == true) { std::cout << "[*] Comm-Component: Server waiting for connection" << std::endl; mServer.waitForClient(); //Send a RUN-Request to the Control-Component CMessage msg(EEvent::EV_REQUEST_RUN); if(mTxQueue.addMessage(msg, true)) { std::cout << "[*] Comm-Component: RUN-Request transmitted" << std::endl; } mStandbyState = false; //Switch to running mode } else { CMessage msg; if(mRxQueue.getMessage(msg, true)) { if(msg.mHeader.mEvent == EEvent::EV_REQUEST_TX_DATA) { if(msg.mHeader.mDataType == EDataType::SENSOR_DATA) { CSensorData* data = reinterpret_cast<CSensorData*>(msg.mData); std::cout << "[*] Comm-Component: Sensor-Data received" << std::endl; std::cout << std::setw(15) << ::std::left << " X1__dd: " << data->getX1_raw__dd() << std::endl; std::cout << std::setw(15) << ::std::left << " X2__dd: " << data->getX2_raw__dd() << std::endl; std::cout << std::setw(15) << ::std::left << " Y1__dd: " << data->getY1_raw__dd() << std::endl; std::cout << std::setw(15) << ::std::left << " Y2__dd: " << data->getY2_raw__dd() << std::endl; std::cout << std::setw(15) << ::std::left << " Phi1__dd: " << data->getPhi1_raw__d() << std::endl; std::cout << std::setw(15) << ::std::left << " Phi2__dd: " << data->getPhi2_raw__d() << std::endl << std::endl; } if(false == mServer.transmitMessage(msg)) { //Connection was shutdown by Matlab, notify the Control-Component and terminate the process CMessage runMsg(EEvent::EV_REQUEST_STANDBY); if(mTxQueue.addMessage(runMsg, true)) { std::cout << "[*] Comm-Component: Sent STANDBY-Request to the Control-Component" << std::endl; } mStandbyState = true; std::cout << "[*] Comm-Component: Client disconnected, terminating" << std::endl; exit(0); } } } } } }
void CCommComponent::run_V3_AusgleichsPolynomMotorADC() { while(true) { if(true == mStandbyState) { std::cout << "[*] Comm-Component: Server waiting for connection" << std::endl; mServer.waitForClient(); CMessage msg(EEvent::EV_REQUEST_RUN); if(mTxQueue.addMessage(msg, true)) { std::cout << "[*] Comm-Component: RUN-Request transmitted" << std::endl; } mStandbyState = false; } else { CMessage msg; if(mRxQueue.getMessage(msg, true)) { if(msg.mHeader.mDataType == EDataType::MOTOR_DATA) { CMotorData* data = reinterpret_cast<CMotorData*>(msg.mData); std::cout << "[*] Comm-Component: Motor-Data received" << std::endl; std::cout << std::setw(25) << ::std::left << " Time: " << data->getTime() << std::endl; std::cout << std::setw(25) << ::std::left << " Torque: " << data->getTorque() << std::endl; std::cout << std::setw(25) << ::std::left << " Psi__d: " << data->getPsi__d() << std::endl; std::cout << std::setw(25) << ::std::left << " Psi_raw__d: " << data->getPsi_raw__d() << std::endl; } } if(false == mServer.transmitMessage(msg)) { //Connection was shutdown by Matlab, notify the Control-Component and terminate the process CMessage runMsg(EEvent::EV_REQUEST_STANDBY); if(mTxQueue.addMessage(runMsg, true)) { std::cout << "[*] Comm-Component: Sent STANDBY-Request to the Control-Component" << std::endl; } mStandbyState = true; std::cout << "[*] Comm-Component: Client disconnected, terminating" << std::endl; exit(0); } if(mServer.receiveMessage(msg, false)) { //Route the message to the Control-Componenten mTxQueue.addMessage(msg, true); } } } }
QString ItemsList::setPath() { QString csvWritePath = ""; csvWritePath = QFileDialog::getExistingDirectory( 0 , tr("Wybierz folder"), QDir::homePath() ); QFile csvFile( QDir::homePath()+"/schedule.csv" ); if ( !csvFile.open(QIODevice::WriteOnly | QIODevice::Append) ) { runMsg("Nie można otworzyć pliku pomocniczego schedule.csv."); return QString(""); } QTextStream out( &csvFile ); out << csvWritePath; csvFile.close(); return csvWritePath; }
void CCommComponent::run_V7_RegelungTest() { while(true) { if(mStandbyState == true) { std::cout << "[*] Comm-Component: Server waiting for connection" << std::endl; mServer.waitForClient(); //Send a RUN-Request to the Control-Component CMessage msg(EEvent::EV_REQUEST_RUN); if(mTxQueue.addMessage(msg, true)) { std::cout << "[*] Comm-Component: RUN-Request transmitted" << std::endl; } mStandbyState = false; //Switch to running mode } else { CMessage msg; if(mRxQueue.getMessage(msg, true)) { if(msg.mHeader.mEvent == EEvent::EV_REQUEST_TX_DATA) { std::cout << "[*] Comm-Component: Data received" << std::endl; if(false == mServer.transmitMessage(msg)) { //Connection was shutdown by Matlab, notify the Control-Component and terminate the process CMessage runMsg(EEvent::EV_REQUEST_STANDBY); if(mTxQueue.addMessage(runMsg, true)) { std::cout << "[*] Comm-Component: Sent STANDBY-Request to the Control-Component" << std::endl; } mStandbyState = true; std::cout << "[*] Comm-Component: Client disconnected, terminating" << std::endl; exit(0); } } } } } }
void ItemsList::generateCSV() { QString separator = ";"; QList <QStandardItem*> itemsList; QTextStream out( csvFile ); if ( !csvFile->open(QIODevice::WriteOnly | QIODevice::Append) ) { runMsg("Nie można otworzyć pliku pomocniczego schedule.csv."); return; } QBrush brush; QFont checkedFont; checkedFont.setFamily("Arial"); checkedFont.setBold(true); checkedFont.setWeight(15); brush.setColor(Qt::green); if (!mainOrderActive) { out << m_order + separator << m_year + "-" + m_month + "-" + m_day + separator << m_recipient + separator << endl; out << "Rodzaj stołu" + separator << "Elektryczna regulacja wysokości" + separator << "Uchwyty do pasów" + separator << "Regulacja kąta odchylenia" + separator << "Elektrycznie łamane leżysko" + separator << "Układ jezdny z hamulcami"+ separator << "Zagłówek 3-elementowy"+ separator << "Pozycja fotela"+ separator << "Sterowanie nożne"+ separator << "Pilot podblatowy"+ separator << "Kołki do stabilizacji"+ separator << "Uchwyt na prześcieradło"+ separator << "Zatyczka"+ separator << "Stal nierdzewna"+ separator << "Ilość sztuk"+ separator << "Kolor blatu"+ separator << "Kolor ramy" + separator << "Uwagi" << endl; mainOrderActive = true; } out << m_actualTable + separator; QStandardItem * item = new QStandardItem(m_actualTable); item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); itemsList.push_back( item ); /* fill options */ for( uint row = 0 ; row < m_statesArray.size() ; ++row ) { out << QString::number(m_statesArray[row]) + separator; item = new QStandardItem(QString::number(m_statesArray[row])); item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); if(item->text() == "1") { item -> setForeground(brush); item -> setFont(checkedFont); } itemsList.push_back( item ); } out << m_quantity + separator; item = new QStandardItem(m_quantity); item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); itemsList.push_back( item ); out << m_topColor + separator; item = new QStandardItem(m_topColor); item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); itemsList.push_back( item ); out << m_bottomColor + separator ; item = new QStandardItem(m_bottomColor); item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); itemsList.push_back( item ); out << m_notes + separator << endl; item = new QStandardItem(m_notes); item -> setTextAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); itemsList.push_back( item ); csvFile->close(); tableDialog->model->appendColumn(itemsList); runMsg("Dodano do zamówienia."); }