Skip to content

Commit d5ba06a

Browse files
author
Ilia Platone
committed
Correct axes and device detection method
1 parent c8d0644 commit d5ba06a

18 files changed

Lines changed: 58 additions & 48 deletions

line.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,26 @@ Line::Line(QString ln, int n, QSettings *s, QWidget *pw, QList<Line*> *p) :
296296
MountMotorIndex = value;
297297
if(ahp_gt_is_connected()) {
298298
ahp_gt_select_device(MountMotorIndex);
299-
if(ahp_gt_is_detected(Ra)) {
299+
if(ahp_gt_is_detected()) {
300+
altaz = false;
300301
fork = false;
302+
if(ahp_gt_axis_is_detected(Ra)) {
303+
if((ahp_gt_get_features(Ra) & isAZEQ) != 0) {
304+
altaz |= true;
305+
}
306+
}
307+
if(ahp_gt_axis_is_detected(Dec)) {
308+
if((ahp_gt_get_features(Dec) & isAZEQ) != 0) {
309+
altaz |= true;
310+
}
311+
}
301312
if((ahp_gt_get_mount_flags() & isForkMount) != 0) {
302313
fork = true;
303314
}
304315
switch (ahp_gt_get_mount_type()) {
305-
case isMF:
306316
case isDOB:
317+
altaz = true;
318+
case isMF:
307319
fork = true;
308320
break;
309321
default:
@@ -414,7 +426,7 @@ void Line::runClicked(bool checked)
414426
void Line::updateLocation()
415427
{
416428
if(ahp_gt_is_connected()) {
417-
if(ahp_gt_is_detected(getRailIndex())) {
429+
if(ahp_gt_axis_is_detected(getRailIndex())) {
418430
ahp_gt_select_device(getRailIndex());
419431
if(ahp_gt_is_axis_moving(RailX)) {
420432
double x = ahp_gt_get_position(RailX, nullptr);
@@ -464,7 +476,7 @@ void Line::setLocation(int value)
464476
targetLocation()->xyz.z = xyz_locations[current_location].xyz.z;
465477
if(update_location) {
466478
if(ahp_gt_is_connected()) {
467-
if(ahp_gt_is_detected(getRailIndex())) {
479+
if(ahp_gt_axis_is_detected(getRailIndex())) {
468480
ahp_gt_select_device(getRailIndex());
469481
ahp_gt_goto_absolute(RailX, xyz_locations[current_location].xyz.x*2.0*M_PI/ahp_gt_get_totalsteps(RailX)/1000, M_PI * 2 * 800.0 / SIDEREAL_DAY);
470482
ahp_gt_goto_absolute(RailY, xyz_locations[current_location].xyz.y*2.0*M_PI/ahp_gt_get_totalsteps(RailY)/1000, M_PI * 2 * 800.0 / SIDEREAL_DAY);
@@ -483,7 +495,7 @@ void Line::updateRa()
483495
if(stream != nullptr)
484496
{
485497
if(ahp_gt_is_connected()) {
486-
if(ahp_gt_is_detected(getMountIndex())) {
498+
if(ahp_gt_axis_is_detected(getMountIndex())) {
487499
double v = ahp_gt_get_position(0, nullptr);
488500
v *= 12.0;
489501
v /= M_PI;
@@ -498,7 +510,7 @@ void Line::updateDec()
498510
if(stream != nullptr)
499511
{
500512
if(ahp_gt_is_connected()) {
501-
if(ahp_gt_is_detected(getMountIndex())) {
513+
if(ahp_gt_axis_is_detected(getMountIndex())) {
502514
double v = ahp_gt_get_position(1, nullptr);
503515
v *= 180.0;
504516
v /= M_PI;
@@ -562,7 +574,7 @@ bool Line::isRailBusy()
562574
if(stream != nullptr)
563575
{
564576
if(ahp_gt_is_connected()) {
565-
if(ahp_gt_is_detected(getRailIndex())) {
577+
if(ahp_gt_axis_is_detected(getRailIndex())) {
566578
bool busy = ahp_gt_is_axis_moving(RailX);
567579
busy |= ahp_gt_is_axis_moving(RailY);
568580
busy |= ahp_gt_is_axis_moving(RailZ);
@@ -578,7 +590,7 @@ bool Line::isMountBusy()
578590
if(stream != nullptr)
579591
{
580592
if(ahp_gt_is_connected()) {
581-
if(ahp_gt_is_detected(getMountIndex())) {
593+
if(ahp_gt_axis_is_detected(getMountIndex())) {
582594
bool busy = ahp_gt_is_axis_moving(Ra);
583595
busy |= ahp_gt_is_axis_moving(Dec);
584596
return busy;
@@ -590,7 +602,7 @@ bool Line::isMountBusy()
590602

591603
void Line::gotoRaDec(double ra, double dec) {
592604
if(ahp_gt_is_connected()) {
593-
if(ahp_gt_is_detected(getMountIndex())) {
605+
if(ahp_gt_axis_is_detected(getMountIndex())) {
594606
ahp_gt_select_device(getMountIndex());
595607
ahp_gt_set_location(Latitude, Longitude, Elevation);
596608
ahp_gt_goto_radec(ra, dec);
@@ -600,7 +612,7 @@ void Line::gotoRaDec(double ra, double dec) {
600612

601613
void Line::startTracking() {
602614
if(ahp_gt_is_connected()) {
603-
if(ahp_gt_is_detected(getMountIndex())) {
615+
if(ahp_gt_axis_is_detected(getMountIndex())) {
604616
Line::motor_lock();
605617
ahp_gt_select_device(getMountIndex());
606618
ahp_gt_stop_motion(Ra, 1);
@@ -612,7 +624,7 @@ void Line::startTracking() {
612624

613625
void Line::startSlewing(double ra_rate, double dec_rate) {
614626
if(ahp_gt_is_connected()) {
615-
if(ahp_gt_is_detected(getMountIndex())) {
627+
if(ahp_gt_axis_is_detected(getMountIndex())) {
616628
Line::motor_lock();
617629
ahp_gt_select_device(getMountIndex());
618630
if(ra_rate != 0.0) {
@@ -630,14 +642,14 @@ void Line::startSlewing(double ra_rate, double dec_rate) {
630642

631643
void Line::haltMotors() {
632644
if(ahp_gt_is_connected()) {
633-
if(ahp_gt_is_detected(getMountIndex())) {
645+
if(ahp_gt_axis_is_detected(getMountIndex())) {
634646
Line::motor_lock();
635647
ahp_gt_select_device(getMountIndex());
636648
ahp_gt_stop_motion(Ra, 1);
637649
ahp_gt_stop_motion(Dec, 1);
638650
Line::motor_unlock();
639651
}
640-
if(ahp_gt_is_detected(getRailIndex())) {
652+
if(ahp_gt_axis_is_detected(getRailIndex())) {
641653
Line::motor_lock();
642654
ahp_gt_select_device(getRailIndex());
643655
ahp_gt_stop_motion(RailX, 1);

line.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ class Line : public QWidget
452452
bool scanning { false };
453453
bool flipped { false };
454454
bool scalingDone { false };
455+
bool altaz { false };
455456
bool fork { false };
456457
void getMinMax();
457458
void plot(bool success, double o, double s);

mainwindow.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,15 @@ bool MainWindow::svf_from_resources(QString json, QString svf, QString bsdl)
117117
s.close();
118118
if(!QFile::exists(svf)) return false;
119119
if(!QFile::exists(bsdl)) return false;
120-
return false;
120+
return true;
121121
}
122122
return false;
123123
}
124124

125125
static void flash_svf(QStringList svf_list)
126126
{
127-
QString cmd = "echo 'cable FT2232\ndetect\nfrequency "+QString::number(12000000)+"\n";
128127
for(QString svf : svf_list)
129-
cmd+="svf "+svf+ "\n";
130-
cmd+="'|jtag";
131-
system(cmd.toStdString().c_str());
132-
sleep(1);
128+
program_jtag(svf.toUtf8(), "FT2232", NULL, 12000000);
133129
reset_by_vid_pid(0x0403, 0x6014);
134130
}
135131

@@ -280,8 +276,12 @@ MainWindow::MainWindow(QWidget *parent)
280276
settings->beginGroup("Connection");
281277
ui->XCPort->clear();
282278
ui->XCPort->addItem(settings->value("xc_connection", "no connection").toString());
279+
ui->XCPort->addItem("localhost:5760");
280+
ui->XCPort->setCurrentIndex(0);
283281
ui->MotorPort->clear();
284282
ui->MotorPort->addItem(settings->value("motor_connection", "no connection").toString());
283+
ui->MotorPort->addItem("localhost:9600");
284+
ui->MotorPort->setCurrentIndex(0);
285285
settings->endGroup();
286286
QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
287287
for (int i = 0; i < ports.length(); i++)
@@ -290,24 +290,21 @@ MainWindow::MainWindow(QWidget *parent)
290290
ports[i].portName();
291291
if(portname != ui->XCPort->itemText(0) && ports[i].vendorIdentifier() == 0x403 && ports[i].productIdentifier() == 0x6014)
292292
ui->XCPort->addItem(portname);
293-
if(portname != ui->MotorPort->itemText(0))
293+
if(portname != ui->MotorPort->itemText(0) && ports[i].vendorIdentifier() == 0x1a86 && ports[i].productIdentifier() == 0x7523)
294294
ui->MotorPort->addItem(portname);
295295
}
296+
settings->beginGroup("Firmware");
297+
ui->firmware->addItem(settings->value("firmware", "Current").toString());
298+
ui->firmware->addItem("Current");
296299
QStringList firmwares = CheckFirmware(url+"xc*");
297300
if(firmwares.count() > 0) {
298301
ui->firmware->clear();
299302
ui->firmware->addItem("Current");
300-
ui->firmware->addItem("Erase");
301303
for (QString fw : firmwares)
302304
ui->firmware->addItem(fw.replace("firmware/", "").replace("-firmware.bin", ""));
303305
}
304-
ui->firmware->setCurrentText(settings->value("firmware", "xc2").toString());
305-
if(ui->XCPort->itemText(0) != "no connection")
306-
ui->XCPort->addItem("no connection");
307-
if(ui->MotorPort->itemText(0) != "no connection")
308-
ui->MotorPort->addItem("no connection");
309-
ui->XCPort->setCurrentIndex(0);
310-
ui->MotorPort->setCurrentIndex(0);
306+
ui->firmware->setCurrentIndex(0);
307+
settings->endGroup();
311308
connect(ui->Run, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked), this, &MainWindow::runClicked);
312309
connect(ui->Mode, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated),
313310
[ = ](int index)
@@ -419,7 +416,7 @@ MainWindow::MainWindow(QWidget *parent)
419416
(void)checked;
420417
int port = 5760;
421418
QString address = "localhost";
422-
QString xcport, motorport, controlport;
419+
QString xcport, motorport;
423420
xcport = ui->XCPort->currentText();
424421
motorport = ui->MotorPort->currentText();
425422
settings->beginGroup("Connection");
@@ -429,18 +426,18 @@ MainWindow::MainWindow(QWidget *parent)
429426
ui->XCPort->setEnabled(false);
430427
if(ui->firmware->currentText() == "Current") goto skip_download;
431428
has_svf_firmware = false;
432-
if (DownloadFirmware(url+ui->firmware->currentText(), svf_filename, bsdl_filename, 3000)){
429+
if (DownloadFirmware(url+ui->firmware->currentText(), svf_filename, bsdl_filename, 10000)){
433430
has_svf_firmware = true;
434431
} else if(svf_from_resources(ui->firmware->currentText(), svf_filename, bsdl_filename)){
435432
has_svf_firmware = true;
436433
}
437434
if(has_svf_firmware) {
438-
//svf_from_resources("Erase", erase_svf_filename, erase_svf_filename);
439435
flash_svf(QStringList({svf_filename}));
436+
settings->setValue("firmware", ui->firmware->currentText());
440437
ui->firmware->setEnabled(true);
441438
ui->Connect->setEnabled(true);
442439
ui->XCPort->setEnabled(true);
443-
}
440+
} else goto err_exit;
444441
skip_download:
445442
xcFD = -1;
446443
xc_local_port = false;
@@ -762,7 +759,7 @@ MainWindow::MainWindow(QWidget *parent)
762759
}
763760
}
764761
ahp_xc_set_correlation_order(1);
765-
npackets = ahp_xc_scan_autocorrelations(requests.toVector().data(), requests.count(), &spectrum, &threadsStopped, &percent);
762+
npackets = ahp_xc_scan_correlations(requests.toVector().data(), requests.count(), &spectrum, &threadsStopped, &percent);
766763
if(npackets == 0)
767764
break;
768765
for(int x = 0; x < Lines.count(); x++)

polytope.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ void Polytope::stackCorrelations()
441441
line->resetStopPtr();
442442
line->setLocation();
443443
}
444-
npackets = ahp_xc_scan_crosscorrelations(requests.toVector().data(), requests.length(), &spectrum, stop, percent);
444+
npackets = ahp_xc_scan_correlations(requests.toVector().data(), requests.length(), &spectrum, stop, percent);
445445
if(spectrum != nullptr && npackets > 0)
446446
{
447447
setSpectrumSize(npackets);

xc1.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

xc10.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

xc12.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

xc14.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

xc16.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

xc18.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)