Rev 399 | Rev 441 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 399 | Rev 440 | ||
---|---|---|---|
Line 195... | Line 195... | ||
195 | LayOut_Speed->addWidget(SpeedMeter); |
195 | LayOut_Speed->addWidget(SpeedMeter); |
196 | } |
196 | } |
Line 197... | Line 197... | ||
197 | 197 | ||
198 | void MKTool::init_Objects() |
198 | void MKTool::init_Objects() |
- | 199 | { |
|
- | 200 | //new KopterData object that contains all data from MK |
|
- | 201 | data = new KopterData(); |
|
199 | { |
202 | |
200 | //new QT-Communication object |
203 | //new QT-Communication object |
Line 201... | Line 204... | ||
201 | com = new QTCommunication(); |
204 | com = new QTCommunication(); |
202 | 205 | ||
Line 203... | Line 206... | ||
203 | //create handler that handles incomming data |
206 | //create handler that handles incomming data |
204 | handler = new Handler(com); |
207 | handler = new Handler(com, data); |
Line 205... | Line 208... | ||
205 | 208 | ||
206 | // QTimer-Instanzen |
209 | // QTimer-Instanzen |
Line 207... | Line 210... | ||
207 | Ticker = new QTimer(this); |
210 | Ticker = new QTimer(this); |
208 | 211 | ||
Line 209... | Line 212... | ||
209 | // Verbindungsobject |
212 | // Verbindungsobject |
210 | //o_Connection = new cConnection(); |
213 | //o_Connection = new cConnection(); |
Line 211... | Line 214... | ||
211 | 214 | ||
Line 415... | Line 418... | ||
415 | 418 | ||
416 | // Waypoint zur NC Senden. |
419 | // Waypoint zur NC Senden. |
417 | //FIXME: put this in cpp/NaviCtrl.cpp? |
420 | //FIXME: put this in cpp/NaviCtrl.cpp? |
418 | void MKTool::slot_pb_SendTarget() |
421 | void MKTool::slot_pb_SendTarget() |
- | 422 | { |
|
419 | { |
423 | sNaviData navi = data->navi; |
420 | if ((Navi.Current.Longitude == 0) && (Navi.Current.Latitude == 0)) |
424 | if ((navi.Current.Longitude == 0) && (navi.Current.Latitude == 0)) |
421 | { |
425 | { |
422 | QMessageBox msgB; |
426 | QMessageBox msgB; |
423 | QString msg; |
427 | QString msg; |
424 | msgB.setText(tr("Fehler: Es konnten keine GPS-Daten vom Mikrokopter empfangen werden")); |
428 | msgB.setText(tr("Fehler: Es konnten keine GPS-Daten vom Mikrokopter empfangen werden")); |
Line 457... | Line 461... | ||
457 | desired_pos.reserve[3] = 0; // reserve |
461 | desired_pos.reserve[3] = 0; // reserve |
Line 458... | Line 462... | ||
458 | 462 | ||
459 | //...und sende ihn an die NaviCtrl |
463 | //...und sende ihn an die NaviCtrl |
460 | int max_radius = 10000; |
464 | int max_radius = 10000; |
461 | if (ok_lat && ok_lon && |
465 | if (ok_lat && ok_lon && |
462 | abs((double)(Navi.Current.Longitude - desired_pos.Position.Longitude)) < max_radius && |
466 | abs((double)(navi.Current.Longitude - desired_pos.Position.Longitude)) < max_radius && |
463 | abs((double)(Navi.Current.Latitude - desired_pos.Position.Latitude)) < max_radius) |
467 | abs((double)(navi.Current.Latitude - desired_pos.Position.Latitude)) < max_radius) |
464 | { |
468 | { |
465 | handler->send_waypoint(desired_pos); |
469 | handler->send_waypoint(desired_pos); |
466 | } |
470 | } |
467 | else |
471 | else |
468 | { |
472 | { |
469 | QMessageBox msgB; |
473 | QMessageBox msgB; |
470 | QString msg; |
474 | QString msg; |
471 | msg += tr("Bitte die Eingabe ueberpruefen!\n"); |
475 | msg += tr("Bitte die Eingabe ueberpruefen!\n"); |
472 | msg += tr("Die Werte muessen sich in der Naehe der aktuellen Koordinaten befinden\n"); |
476 | msg += tr("Die Werte muessen sich in der Naehe der aktuellen Koordinaten befinden\n"); |
473 | msg += "(Lon: "; |
477 | msg += "(Lon: "; |
474 | msg += QString::number(Navi.Current.Longitude); |
478 | msg += QString::number(navi.Current.Longitude); |
475 | msg += ", "; |
479 | msg += ", "; |
476 | msg += "Lat: "; |
480 | msg += "Lat: "; |
477 | msg += QString::number(Navi.Current.Latitude); |
481 | msg += QString::number(navi.Current.Latitude); |
478 | msg += ")"; |
482 | msg += ")"; |
479 | msgB.setText(msg); |
483 | msgB.setText(msg); |
480 | msgB.exec(); |
484 | msgB.exec(); |
481 | } |
485 | } |
Line 495... | Line 499... | ||
495 | } |
499 | } |
Line 496... | Line 500... | ||
496 | 500 | ||
497 | // Hardware Auswahl und umschalten |
501 | // Hardware Auswahl und umschalten |
498 | void MKTool::slot_rb_Hardware() |
502 | void MKTool::slot_rb_Hardware() |
499 | { |
503 | { |
500 | if ((rb_SelNC->isChecked() == false) && (Mode.ID != ADDRESS_NC)) |
504 | if ((rb_SelNC->isChecked() == false) && (data->mode.ID != ADDRESS_NC)) |
501 | { |
505 | { |
502 | lb_Status->setText(tr("Schalte um auf NaviCtrl.")); |
506 | lb_Status->setText(tr("Schalte um auf NaviCtrl.")); |
503 | handler->switch_navictrl(); |
507 | handler->switch_navictrl(); |
504 | //FIXME: remove wait? |
508 | //FIXME: remove wait? |
Line 530... | Line 534... | ||
530 | 534 | ||
531 | // Ticker-Event |
535 | // Ticker-Event |
532 | /////////////// |
536 | /////////////// |
533 | void MKTool::slot_Ticker() |
537 | void MKTool::slot_Ticker() |
534 | { |
538 | { |
535 | //FIXME: Put this somewhere in Handler.cpp |
539 | //FIXME: Put this somewhere in libMK/QTCommunication.cpp |
536 | /* |
540 | /* |
537 | if (TickerDiv) |
541 | if (TickerDiv) |
538 | TickerDiv = false; |
542 | TickerDiv = false; |
539 | else |
543 | else |
Line 681... | Line 685... | ||
681 | { |
685 | { |
682 | } |
686 | } |
Line 683... | Line 687... | ||
683 | 687 | ||
Line 684... | Line -... | ||
684 | disconnect(f_Motortest, 0,0,0); |
- | |
685 | - | ||
686 | for (int z = 0; z<12; z++) |
- | |
687 | { |
- | |
688 | Motor.Speed[z] = 0; |
- | |
689 | } |
688 | disconnect(f_Motortest, 0,0,0); |
Line 690... | Line 689... | ||
690 | 689 | ||
691 | slot_Motortest(Motor); |
690 | handler->reset_motor(); |
692 | 691 | ||
Line 701... | Line 700... | ||
701 | 700 | ||
702 | // Motormixer-Einstellungen anzeigen |
701 | // Motormixer-Einstellungen anzeigen |
703 | void MKTool::slot_ac_MotorMixer() |
702 | void MKTool::slot_ac_MotorMixer() |
704 | { |
703 | { |
705 | f_MotorMixer->set_Objects(handler, Settings); |
704 | f_MotorMixer->set_Objects(handler, Settings); |
Line 706... | Line 705... | ||
706 | handler->read_mixer(); |
705 | handler->read_motor_mixer(); |
707 | 706 | ||
708 | if (f_MotorMixer->exec()==QDialog::Accepted) |
707 | if (f_MotorMixer->exec()==QDialog::Accepted) |
709 | { |
708 | { |
Line 719... | Line 718... | ||
719 | f_LCD = new dlg_LCD(this); |
718 | f_LCD = new dlg_LCD(this); |
Line 720... | Line 719... | ||
720 | 719 | ||
721 | // LCD auf / ab |
720 | // LCD auf / ab |
722 | connect(f_LCD->pb_LCDup, SIGNAL(clicked()), this, SLOT(slot_LCD_UP())); |
721 | connect(f_LCD->pb_LCDup, SIGNAL(clicked()), this, SLOT(slot_LCD_UP())); |
723 | connect(f_LCD->pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN())); |
722 | connect(f_LCD->pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN())); |
724 | //FIXME: put this in com/Handler.cpp |
723 | //FIXME: put this in libMK/Handler.cpp |
725 | f_LCD->show(); |
724 | f_LCD->show(); |
726 | handler->show_lcd(); |
725 | handler->show_lcd(); |
727 | //FIXME: replace ticker with something else |
726 | //FIXME: replace ticker with something else??? |
728 | Ticker->setInterval(500); |
727 | Ticker->setInterval(500); |
729 | TickerEvent[2] = true; |
728 | TickerEvent[2] = true; |
730 | } |
729 | } |
Line 739... | Line 738... | ||
739 | } |
738 | } |
740 | } |
739 | } |
Line 741... | Line 740... | ||
741 | 740 | ||
742 | void MKTool::slot_MAP_SetWayPoints(QList<sWayPoint> l_WayPoints) |
741 | void MKTool::slot_MAP_SetWayPoints(QList<sWayPoint> l_WayPoints) |
743 | { |
742 | { |
Line 744... | Line 743... | ||
744 | //FIXME: Put this in com/Handler.cpp or com/NaviCtrl.cpp |
743 | //FIXME: Put this in libMK/Handler.cpp or libMK/NaviCtrl.cpp |
Line 745... | Line 744... | ||
745 | 744 | ||
746 | double Longitude, Latitude; |
745 | double Longitude, Latitude; |
Line 804... | Line 803... | ||
804 | set_Analog Old_Analog1; |
803 | set_Analog Old_Analog1; |
Line 805... | Line 804... | ||
805 | 804 | ||
Line 806... | Line 805... | ||
806 | Old_Analog1 = Settings->Analog1; |
805 | Old_Analog1 = Settings->Analog1; |
807 | 806 | ||
Line 808... | Line 807... | ||
808 | dlg_Config *f_Config = new dlg_Config(this); |
807 | dlg_Config *f_Config = new dlg_Config(this); |
809 | f_Config->set_Settings(Settings, Mode.ID); |
808 | f_Config->set_Settings(Settings, data->mode.ID); |
810 | 809 | ||
811 | if (f_Config->exec()==QDialog::Accepted) |
810 | if (f_Config->exec()==QDialog::Accepted) |
Line 812... | Line 811... | ||
812 | { |
811 | { |
813 | Settings = f_Config->get_Settings(); |
812 | Settings = f_Config->get_Settings(); |
814 | Settings->write_Settings_Analog(Mode.ID); |
813 | Settings->write_Settings_Analog(data->mode.ID); |
815 | 814 | ||
Line 992... | Line 991... | ||
992 | handler->stop_all_debug(); |
991 | handler->stop_all_debug(); |
993 | } |
992 | } |
994 | else |
993 | else |
995 | { |
994 | { |
996 | // Wenn MK3MAG dann andauernd Daten neu anfragen. |
995 | // Wenn MK3MAG dann andauernd Daten neu anfragen. |
- | 996 | //FIXME: TickerEvent in Communication oder so |
|
997 | if (Mode.ID == ADDRESS_MK3MAG) |
997 | /* if (Mode.ID == ADDRESS_MK3MAG) |
998 | TickerEvent[3] = true; |
998 | TickerEvent[3] = true;*/ |
Line 999... | Line 999... | ||
999 | 999 | ||
1000 | if (ac_FastDebug->isChecked()) |
1000 | if (ac_FastDebug->isChecked()) |
1001 | { |
1001 | { |
1002 | lb_Status->setText(tr("Fordere schnelle DebugDaten an.")); |
1002 | lb_Status->setText(tr("Fordere schnelle DebugDaten an.")); |
Line 1255... | Line 1255... | ||
1255 | Settings->TTY.Port = le_Port->text(); |
1255 | Settings->TTY.Port = le_Port->text(); |
1256 | } |
1256 | } |
Line 1257... | Line 1257... | ||
1257 | 1257 | ||
1258 | void MKTool::show_DebugData() |
1258 | void MKTool::show_DebugData() |
- | 1259 | { |
|
1259 | { |
1260 | //FIXME: log analogdata in Communication |
1260 | if (logger->is_active()) |
1261 | /* if (logger->is_active()) |
Line 1261... | Line 1262... | ||
1261 | logger->write(AnalogData); |
1262 | logger->write(AnalogData);*/ |
1262 | 1263 | ||
1263 | if (ac_StartPlotter->isChecked()) |
1264 | if (ac_StartPlotter->isChecked()) |
- | 1265 | { |
|
1264 | { |
1266 | aID[NextPlot] = NextPlot; |
1265 | aID[NextPlot] = NextPlot; |
1267 | //FIXME: get analogData from handler |
1266 | 1268 | /* |
|
1267 | for (int a = 0; a < MaxAnalog; a++) |
1269 | for (int a = 0; a < MaxAnalog; a++) |
1268 | { |
1270 | { |
1269 | aData[a][NextPlot] = AnalogData[a]; |
1271 | aData[a][NextPlot] = AnalogData[a]; |
Line 1270... | Line 1272... | ||
1270 | } |
1272 | }*/ |
1271 | NextPlot++; |
1273 | NextPlot++; |
1272 | 1274 | ||
Line -... | Line 1275... | ||
- | 1275 | if ((tab_Main->currentWidget()->objectName() == QString("Tab_1"))) |
|
- | 1276 | update_Plot(); |
|
1273 | if ((tab_Main->currentWidget()->objectName() == QString("Tab_1"))) |
1277 | } |
1274 | update_Plot(); |
1278 | |
1275 | } |
1279 | //FIXME: get analogdata from handler |
1276 | 1280 | /* |
|
1277 | le_A_0->setText(QString("%1").arg(AnalogData[0])); |
1281 | le_A_0->setText(QString("%1").arg(AnalogData[0])); |
Line 1324... | Line 1328... | ||
1324 | Nick = Nick - 255; |
1328 | Nick = Nick - 255; |
Line 1325... | Line 1329... | ||
1325 | 1329 | ||
1326 | Attitude->setAngle(Roll); |
1330 | Attitude->setAngle(Roll); |
1327 | Attitude->setGradient(double(double(Nick) / 100.0)); |
1331 | Attitude->setGradient(double(double(Nick) / 100.0)); |
- | 1332 | } |
|
1328 | } |
1333 | */ |
Line 1329... | Line 1334... | ||
1329 | } |
1334 | } |
1330 | 1335 | ||
1331 | void MKTool::new_NaviData(sRxData RX) |
1336 | void MKTool::new_NaviData(sRxData RX) |
1332 | { |
- | |
- | 1337 | { |
|
1333 | // qDebug("Navi-Data"); |
1338 | // qDebug("Navi-Data"); |
1334 | 1339 | sNaviData navi = data->navi; |
|
1335 | switch(RX.decode[N_NC_FLAGS]) |
1340 | switch(RX.decode[N_NC_FLAGS]) |
1336 | { |
1341 | { |
1337 | case 0x01 : lb_Mode->setText(tr("Free")); break; |
1342 | case 0x01 : lb_Mode->setText(tr("Free")); break; |
Line 1341... | Line 1346... | ||
1341 | case 0x10 : lb_Mode->setText(tr("Serial Error")); break; |
1346 | case 0x10 : lb_Mode->setText(tr("Serial Error")); break; |
1342 | case 0x20 : lb_Mode->setText(tr("Target reached")); break; |
1347 | case 0x20 : lb_Mode->setText(tr("Target reached")); break; |
1343 | case 0x40 : lb_Mode->setText(tr("Manual Control")); break; |
1348 | case 0x40 : lb_Mode->setText(tr("Manual Control")); break; |
1344 | } |
1349 | } |
Line 1345... | Line 1350... | ||
1345 | 1350 | ||
1346 | Navi.Current.Longitude = Parser::dataToLong(RX.decode, N_CUR_LONGITUDE, true); |
1351 | navi.Current.Longitude = Parser::dataToLong(RX.decode, N_CUR_LONGITUDE, true); |
1347 | Navi.Current.Latitude = Parser::dataToLong(RX.decode, N_CUR_LATITUDE, true); |
1352 | navi.Current.Latitude = Parser::dataToLong(RX.decode, N_CUR_LATITUDE, true); |
1348 | Navi.Current.Altitude = Parser::dataToLong(RX.decode, N_CUR_ALTITUDE, true); |
1353 | navi.Current.Altitude = Parser::dataToLong(RX.decode, N_CUR_ALTITUDE, true); |
1349 | Navi.Target.Longitude = Parser::dataToLong(RX.decode, N_TAR_LONGITUDE, true); |
1354 | navi.Target.Longitude = Parser::dataToLong(RX.decode, N_TAR_LONGITUDE, true); |
1350 | Navi.Target.Latitude = Parser::dataToLong(RX.decode, N_TAR_LATITUDE, true); |
1355 | navi.Target.Latitude = Parser::dataToLong(RX.decode, N_TAR_LATITUDE, true); |
Line 1351... | Line 1356... | ||
1351 | Navi.Target.Altitude = Parser::dataToLong(RX.decode, N_TAR_ALTITUDE, true); |
1356 | navi.Target.Altitude = Parser::dataToLong(RX.decode, N_TAR_ALTITUDE, true); |
1352 | 1357 | ||
1353 | le_CDistance->setText(QString("%1 cm").arg(Parser::dataToInt(RX.decode, N_HOME_DISTANCE))); |
1358 | le_CDistance->setText(QString("%1 cm").arg(Parser::dataToInt(RX.decode, N_HOME_DISTANCE))); |
1354 | le_CWPA->setText(QString("%1").arg(RX.decode[N_WP_INDEX])); |
1359 | le_CWPA->setText(QString("%1").arg(RX.decode[N_WP_INDEX])); |
Line 1393... | Line 1398... | ||
1393 | Nick = Nick - 255; |
1398 | Nick = Nick - 255; |
Line 1394... | Line 1399... | ||
1394 | 1399 | ||
1395 | Attitude->setAngle(Roll); |
1400 | Attitude->setAngle(Roll); |
Line 1396... | Line 1401... | ||
1396 | Attitude->setGradient(double(0.0 - (double(Nick) / 100.0))); |
1401 | Attitude->setGradient(double(0.0 - (double(Nick) / 100.0))); |
1397 | 1402 | ||
1398 | sNaviString NaviString; |
1403 | sNaviData naviData; |
1399 | 1404 | ||
1400 | NaviString.Longitude = Parser::getFloat(Navi.Current.Longitude,7); |
1405 | naviData.Longitude = Parser::getFloat(navi.Current.Longitude,7); |
Line 1401... | Line 1406... | ||
1401 | NaviString.Latitude = Parser::getFloat(Navi.Current.Latitude,7); |
1406 | naviData.Latitude = Parser::getFloat(navi.Current.Latitude,7); |
1402 | NaviString.Altitude = Parser::getFloat(Navi.Current.Altitude,3); |
1407 | naviData.Altitude = Parser::getFloat(navi.Current.Altitude,3); |
Line 1403... | Line 1408... | ||
1403 | 1408 | ||
Line 1404... | Line 1409... | ||
1404 | le_CurLong->setText(QString::number(NaviString.Longitude)); |
1409 | le_CurLong->setText(QString::number(naviData.Longitude)); |
Line 1405... | Line 1410... | ||
1405 | le_CurLat->setText(QString::number(NaviString.Latitude)); |
1410 | le_CurLat->setText(QString::number(naviData.Latitude)); |
1406 | 1411 | ||
1407 | KML_Server->store_NaviString(NaviString); |
1412 | KML_Server->store_NaviString(naviData); |
1408 | 1413 | ||
1409 | f_Map->add_Position(NaviString.Longitude, NaviString.Latitude); |
1414 | f_Map->add_Position(naviData.Longitude, naviData.Latitude); |
1410 | 1415 | ||
Line 1411... | Line 1416... | ||
1411 | if ((QMK_Server->property("Connect")) == true) |
1416 | if ((QMK_Server->property("Connect")) == true) |
1412 | { |
1417 | { |
Line 1470... | Line 1475... | ||
1470 | } |
1475 | } |
Line 1471... | Line 1476... | ||
1471 | 1476 | ||
1472 | // Verbindung zum Kopter herstellen / Trennen |
1477 | // Verbindung zum Kopter herstellen / Trennen |
1473 | void MKTool::slot_OpenPort() |
1478 | void MKTool::slot_OpenPort() |
1474 | { |
1479 | { |
1475 | //FIXME: Put this in com/QTCommunication.cpp |
1480 | //FIXME: Put this in libMK/QTCommunication.cpp |
1476 | /* |
1481 | /* |
1477 | if (o_Connection->isOpen()) |
1482 | if (o_Connection->isOpen()) |
1478 | { |
1483 | { |
1479 | TX_Data[0] = Settings->Data.Debug_Off / 10; |
1484 | TX_Data[0] = Settings->Data.Debug_Off / 10; |
Line 1532... | Line 1537... | ||
1532 | // Programm beenden |
1537 | // Programm beenden |
1533 | /////////////////// |
1538 | /////////////////// |
Line 1534... | Line 1539... | ||
1534 | 1539 | ||
1535 | MKTool::~MKTool() |
1540 | MKTool::~MKTool() |
1536 | { |
1541 | { |
1537 | //FIXME: Put this in com/QTCommunication.cpp |
1542 | //FIXME: Put this in libMK/QTCommunication.cpp |
1538 | /* |
1543 | /* |
1539 | if (o_Connection->isOpen()) |
1544 | if (o_Connection->isOpen()) |
1540 | { |
1545 | { |
1541 | o_Connection->Close(); |
1546 | o_Connection->Close(); |