Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilities: minor fixes in DAGalvo #449

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions DeviceAdapters/Utilities/DAGalvo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@ int DAGalvo::PointAndFire(double x, double y, double timeUs)
return ERR_NO_SHUTTER_DEVICE_FOUND;

// Should we do this non-blocking instead?
bool open = false;
ret = s->GetOpen(open);
if (ret != DEVICE_OK)
return ret;
ret = s->SetOpen(true);
if (ret != DEVICE_OK)
return ret;
std::this_thread::sleep_for(std::chrono::microseconds((long long)timeUs));
return s->SetOpen(false);
return s->SetOpen(open);

}

Expand Down Expand Up @@ -240,28 +244,29 @@ double DAGalvo::GetYMinimum()

int DAGalvo::AddPolygonVertex(int index, double x, double y)
{
if (index > 0) {
if (index >= 0) {
size_t nrPolygons = polygons_->size();
if (index < nrPolygons) {
DAPolygon* polygon = polygons_->at(index);
polygon->addVertex(x, y);
return true;
return DEVICE_OK;
}
else if (index == nrPolygons) {
DAPolygon* polygon = new DAPolygon(x, y);
polygons_->push_back(polygon);
return true;
return DEVICE_OK;
}
}
return false; // the index is more than nrPolygons and our vector does not accomodate this
return DEVICE_UNKNOWN_POSITION; // the index is more than nrPolygons and our vector does not accomodate this
}

int DAGalvo::DeletePolygons()
{
for (int i = 0; i < polygons_->size(); i++) {
delete(polygons_->at(i));
}
return polygons_->empty();
polygons_->clear();
return DEVICE_OK;
}

int DAGalvo::RunSequence()
Expand Down