diff --git a/src/Refine_DefMap.cpp b/src/Refine_DefMap.cpp
index 1b00acc21..6e5cb7284 100644
--- a/src/Refine_DefMap.cpp
+++ b/src/Refine_DefMap.cpp
@@ -36,7 +36,8 @@
#include "Refine_DefMap.h"
#include "darks_dialog.h"
-enum {
+enum
+{
ID_PREVIEW = 10001,
};
@@ -63,8 +64,9 @@ static void AddTableEntryPair(wxWindow *parent, wxFlexGridSizer *pTable, const w
pTable->Add(pControl, 1, wxALL, 5);
}
-RefineDefMap::RefineDefMap(wxWindow *parent) :
- wxDialog(parent, wxID_ANY, _("Refine Bad-pixel Map"), wxDefaultPosition, wxSize(900, 400), wxCAPTION | wxCLOSE_BOX), m_profileId(-1)
+RefineDefMap::RefineDefMap(wxWindow *parent)
+ : wxDialog(parent, wxID_ANY, _("Refine Bad-pixel Map"), wxDefaultPosition, wxSize(900, 400), wxCAPTION | wxCLOSE_BOX)
+ , m_profileId(-1)
{
SetSize(wxSize(900, 400));
@@ -162,11 +164,13 @@ RefineDefMap::RefineDefMap(wxWindow *parent) :
pHotSlider = new wxSlider(this, wxID_ANY, 0, 0, 100, wxPoint(-1, -1), wxSize(200, -1), wxSL_HORIZONTAL | wxSL_VALUE_LABEL);
pHotSlider->Bind(wxEVT_SCROLL_CHANGED, &RefineDefMap::OnHotChange, this);
pHotSlider->Bind(wxEVT_SCROLL_THUMBTRACK, &RefineDefMap::OnHotChange, this);
- pHotSlider->SetToolTip(_("Move this slider to increase or decrease the number of pixels that will be treated as 'hot', then click on 'generate' to build and load the new bad-pixel map"));
+ pHotSlider->SetToolTip(_("Move this slider to increase or decrease the number of pixels that will be treated as 'hot', "
+ "then click on 'generate' to build and load the new bad-pixel map"));
pColdSlider = new wxSlider(this, wxID_ANY, 0, 0, 100, wxPoint(-1, -1), wxSize(200, -1), wxSL_HORIZONTAL | wxSL_VALUE_LABEL);
pColdSlider->Bind(wxEVT_SCROLL_CHANGED, &RefineDefMap::OnColdChange, this);
pColdSlider->Bind(wxEVT_SCROLL_THUMBTRACK, &RefineDefMap::OnColdChange, this);
- pColdSlider->SetToolTip(_("Move this slider to increase or decrease the number of pixels that will be treated as 'cold', then click on 'generate' to build and load the new bad-pixel map"));
+ pColdSlider->SetToolTip(_("Move this slider to increase or decrease the number of pixels that will be treated as 'cold', "
+ "then click on 'generate' to build and load the new bad-pixel map"));
AddTableEntryPair(this, pAdjustmentGrid, _("Hot pixels"), pHotSlider);
AddTableEntryPair(this, pAdjustmentGrid, _("Cold pixels"), pColdSlider);
pAggressivenessGrp->Add(pAdjustmentGrid);
@@ -180,21 +184,17 @@ RefineDefMap::RefineDefMap(wxWindow *parent) :
pApplyBtn = new wxButton(this, wxID_ANY, _("Generate"));
pApplyBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &RefineDefMap::OnGenerate, this);
- pApplyBtn->SetToolTip(_("Use the current aggressiveness settings to build and load a new bad-pixel map; this will discard any manually added bad pixels"));
+ pApplyBtn->SetToolTip(_("Use the current aggressiveness settings to build and load a new bad-pixel map; this will discard "
+ "any manually added bad pixels"));
pAddDefectBtn = new wxButton(this, wxID_ANY, _("Add Bad Pixel"));
pAddDefectBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &RefineDefMap::OnAddDefect, this);
- pAddDefectBtn->SetToolTip(_("Click on a bad pixel in the image display; then click on this button to add it to the in-use bad-pixel map"));
-
- pButtonSizer->Add(
- pResetBtn,
- wxSizerFlags(0).Align(0).Border(wxALL, 10));
- pButtonSizer->Add(
- pApplyBtn,
- wxSizerFlags(0).Align(0).Border(wxALL, 10));
- pButtonSizer->Add(
- pAddDefectBtn,
- wxSizerFlags(0).Align(0).Border(wxALL, 10));
+ pAddDefectBtn->SetToolTip(
+ _("Click on a bad pixel in the image display; then click on this button to add it to the in-use bad-pixel map"));
+
+ pButtonSizer->Add(pResetBtn, wxSizerFlags(0).Align(0).Border(wxALL, 10));
+ pButtonSizer->Add(pApplyBtn, wxSizerFlags(0).Align(0).Border(wxALL, 10));
+ pButtonSizer->Add(pAddDefectBtn, wxSizerFlags(0).Align(0).Border(wxALL, 10));
pVSizer->Add(pButtonSizer, wxSizerFlags().Center().Border(wxALL, 10));
@@ -240,7 +240,7 @@ bool RefineDefMap::InitUI()
if (!DefectMap::DefectMapExists(pConfig->GetCurrentProfileId(), false))
{
if (RebuildMasterDarks())
- firstTime = true; // Need to get the UI built before finishing up
+ firstTime = true; // Need to get the UI built before finishing up
}
if (DefectMap::DefectMapExists(m_profileId, false) || firstTime)
{
@@ -253,7 +253,7 @@ bool RefineDefMap::InitUI()
else
{
RestoreCameraMode();
- return false; // No master dark files to work with, user didn't build them
+ return false; // No master dark files to work with, user didn't build them
}
}
@@ -297,7 +297,6 @@ void RefineDefMap::LoadFromProfile()
GetBadPxCounts();
ShowStatus(_("Statistics completed..."), false);
LoadPreview();
-
}
bool RefineDefMap::RebuildMasterDarks()
@@ -351,10 +350,10 @@ void RefineDefMap::ApplyNewMap()
pInfoGrid->SetCellValue(hotFactorLoc, wxString::Format("%d", pHotSlider->GetValue()));
pInfoGrid->SetCellValue(coldFactorLoc, wxString::Format("%d", pColdSlider->GetValue()));
pInfoGrid->SetCellValue(createTimeLoc, DefectMapTimeString());
- pStatsGrid->SetCellValue(manualPixelLoc, "0"); // Manual pixels will always be discarded
+ pStatsGrid->SetCellValue(manualPixelLoc, "0"); // Manual pixels will always be discarded
pHotSlider->Enable(true);
pColdSlider->Enable(true);
- pFrame->SetDarkMenuState(); // Get enabled states straightened out
+ pFrame->SetDarkMenuState(); // Get enabled states straightened out
}
void RefineDefMap::OnGenerate(wxCommandEvent& evt)
@@ -369,7 +368,7 @@ void RefineDefMap::OnGenerate(wxCommandEvent& evt)
else
{
ShowStatus(_("Master dark frames NOT rebuilt"), false);
- return; // Couldn't do what we were asked
+ return; // Couldn't do what we were asked
}
}
ApplyNewMap();
@@ -382,7 +381,7 @@ wxString RefineDefMap::DefectMapTimeString()
if (wxFileExists(dfFileName))
{
wxDateTime when = wxFileModificationTime(dfFileName);
- return(when.FormatDate() + " " + when.FormatTime());
+ return (when.FormatDate() + " " + when.FormatTime());
}
else
return "";
@@ -405,7 +404,7 @@ void RefineDefMap::Recalc()
if (manualPixelCount != 0)
{
manualPixelCount = 0;
- pStatsGrid->SetCellValue(manualPixelLoc, "0"); // Manual pixels will always be discarded
+ pStatsGrid->SetCellValue(manualPixelLoc, "0"); // Manual pixels will always be discarded
}
GetBadPxCounts();
m_builder.BuildDefectMap(m_defectMap, false);
@@ -432,7 +431,7 @@ void RefineDefMap::OnAddDefect(wxCommandEvent& evt)
if (pFrame->pGuider->IsLocked())
{
- wxPoint badspot((int)(pixelLoc.X + 0.5), (int)(pixelLoc.Y + 0.5));
+ wxPoint badspot((int) (pixelLoc.X + 0.5), (int) (pixelLoc.Y + 0.5));
Debug.AddLine(wxString::Format("Current position returned as %.1f,%.1f", pixelLoc.X, pixelLoc.Y));
Debug.AddLine(wxString::Format("User adding bad pixel at %d,%d", badspot.x, badspot.y));
@@ -445,7 +444,7 @@ void RefineDefMap::OnAddDefect(wxCommandEvent& evt)
{
if (!pCurrMap->FindDefect(badspot))
{
- pCurrMap->AddDefect(badspot); // Changes both in-memory instance and disk file
+ pCurrMap->AddDefect(badspot); // Changes both in-memory instance and disk file
manualPixelCount++;
pStatsGrid->SetCellValue(manualPixelLoc, wxString::Format("%d", manualPixelCount));
needLoadPreview = true;
diff --git a/src/about_dialog.cpp b/src/about_dialog.cpp
index 7c58e33c1..3f83fce3a 100644
--- a/src/about_dialog.cpp
+++ b/src/about_dialog.cpp
@@ -44,171 +44,173 @@ wxEND_EVENT_TABLE();
// clang-format on
AboutDialog::AboutDialog()
- : wxDialog(pFrame, wxID_ANY, wxString::Format(_("About %s"), APPNAME),
- wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
+ : wxDialog(
+ pFrame, wxID_ANY, wxString::Format(_("About %s"), APPNAME), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
SetBackgroundColour(*wxWHITE);
wxBoxSizer *pSizer = new wxBoxSizer(wxHORIZONTAL);
- #include "icons/phd2_64.png.h"
+#include "icons/phd2_64.png.h"
wxBitmap phd2(wxBITMAP_PNG_FROM_DATA(phd2_64));
wxStaticBitmap *pImage = new wxStaticBitmap(this, wxID_ANY, phd2);
wxFileSystem::AddHandler(new wxMemoryFSHandler);
- wxMemoryFSHandler::AddFile("about.html", wxString::Format(
- "
"
- ""
- "%s %s "
- ""
- ""
- "Project maintainers "
- ""
- ""
- "Andy Galasso "
- "Bruce Waddington "
- " "
- "
"
- " "
- "Past maintainers "
- ""
- ""
- "Craig Stark "
- "Bret McKee "
- " "
- "
"
- " "
- "Credits "
- ""
- ""
- "Bernhard Reutner-Fischer "
- "Stefan Elste "
- "Geoffrey Hausheer "
- "Jared Wellman "
- "John Wainwright "
- " "
- ""
- "Sylvain Girard "
- "Max Chen "
- "Carsten Przygoda "
- "Hans Lambermont "
- "David Ault "
- " "
- ""
- "Markus Wieczorek "
- "Linkage "
- "Robin Glover "
- "Patrick Chevalley "
- "Scott Edwards "
- " "
- ""
- "Eiji Kaneshige "
- "Konstantin Menshikoff "
- "Jakub Bartas "
- "Javier R "
- "Oleh Malyi "
- " "
- ""
- "Tsung-Chi Wu "
- "Raffi Enficiaud "
- "Sabin Fota "
- "Dylan O'Donnell "
- "Katsuhiro Kojima "
- " "
- ""
- "Simon Taylor "
- "Hallgeir Holien "
- "Laurent Schmitz "
- "Atushi Sakauchi "
- "Giorgio Mazzacurati "
- " "
- ""
- "Günter Scholz "
- "Ray Gralak "
- "Khalefa Algadi "
- "David C. Partridge "
- "Matteo Ghellere "
- " "
- ""
- "norma "
- "Edgar D. Klenske "
- "Bernhard Schölkopf "
- "Philipp Hennig "
- "Stephan Wenninger "
- " "
- ""
- "Wagner Trindade "
- "Cyril Richard "
- "Mattia Verga "
- "Iván Zabala "
- "Ken Self "
- " "
- ""
- "Alex Helms "
- "Randy Pufahl "
- "Jasem Mutlaq "
- "Thomas Stibor "
- "Ludovic Pollet "
- " "
- ""
- "Paweł Pleskaczyński "
- "nabePla "
- "Philip Peake "
- "Manuel Rosales "
- "Marcel Greter "
- " "
- ""
- "Miquel Recacha "
- "Mario Nicotra "
- "Gerry Roberts "
- "Anthony Hinsinger "
- "Radek Kaczorek "
- " "
- ""
- "Sebastian Godelet "
- "Stanislav Holub "
- "Valerio Faiuolo "
- "Peter Berbee "
- "Paolo Stivanin "
- " "
- ""
- "Paweł Soja "
- "ToupTek Photonics Co., Ltd "
- "Jarno Paananen "
- "Leo Shatz "
- "Niels Rackwitz "
- " "
- ""
- "Philipp Weber "
- "Kirill M. Skorobogatov "
- " "
- " "
- " "
- " "
- "
"
- " "
- " "
- "Copyright 2006-2013 Craig Stark "
- "Copyright 2009 Geoffrey Hausheer "
- "Copyright 2012-2013 Bret McKee "
- "Copyright 2013 Sylvain Girard "
- "Copyright 2013-2022 Andy Galasso "
- "Copyright 2013-2023 Bruce Waddington "
- "Copyright 2014 Hans Lambermont "
- "Copyright 2014 Robin Glover "
- "Copyright 2014-2017 Max Planck Society "
- "Copyright 2017 Ken Self "
- "Copyright 2019 Jasem Mutlaq "
- " "
- " "
- "The Predictive PEC guide algorithm is based on "
- "Gaussian Process Based Predictive Control for Periodic Error Correction "
- " "
- "", APPNAME, FULLVER));
+ wxMemoryFSHandler::AddFile("about.html",
+ wxString::Format(""
+ ""
+ "%s %s "
+ ""
+ ""
+ "Project maintainers "
+ ""
+ ""
+ "Andy Galasso "
+ "Bruce Waddington "
+ " "
+ "
"
+ " "
+ "Past maintainers "
+ ""
+ ""
+ "Craig Stark "
+ "Bret McKee "
+ " "
+ "
"
+ " "
+ "Credits "
+ ""
+ ""
+ "Bernhard Reutner-Fischer "
+ "Stefan Elste "
+ "Geoffrey Hausheer "
+ "Jared Wellman "
+ "John Wainwright "
+ " "
+ ""
+ "Sylvain Girard "
+ "Max Chen "
+ "Carsten Przygoda "
+ "Hans Lambermont "
+ "David Ault "
+ " "
+ ""
+ "Markus Wieczorek "
+ "Linkage "
+ "Robin Glover "
+ "Patrick Chevalley "
+ "Scott Edwards "
+ " "
+ ""
+ "Eiji Kaneshige "
+ "Konstantin Menshikoff "
+ "Jakub Bartas "
+ "Javier R "
+ "Oleh Malyi "
+ " "
+ ""
+ "Tsung-Chi Wu "
+ "Raffi Enficiaud "
+ "Sabin Fota "
+ "Dylan O'Donnell "
+ "Katsuhiro Kojima "
+ " "
+ ""
+ "Simon Taylor "
+ "Hallgeir Holien "
+ "Laurent Schmitz "
+ "Atushi Sakauchi "
+ "Giorgio Mazzacurati "
+ " "
+ ""
+ "Günter Scholz "
+ "Ray Gralak "
+ "Khalefa Algadi "
+ "David C. Partridge "
+ "Matteo Ghellere "
+ " "
+ ""
+ "norma "
+ "Edgar D. Klenske "
+ "Bernhard Schölkopf "
+ "Philipp Hennig "
+ "Stephan Wenninger "
+ " "
+ ""
+ "Wagner Trindade "
+ "Cyril Richard "
+ "Mattia Verga "
+ "Iván Zabala "
+ "Ken Self "
+ " "
+ ""
+ "Alex Helms "
+ "Randy Pufahl "
+ "Jasem Mutlaq "
+ "Thomas Stibor "
+ "Ludovic Pollet "
+ " "
+ ""
+ "Paweł Pleskaczyński "
+ "nabePla "
+ "Philip Peake "
+ "Manuel Rosales "
+ "Marcel Greter "
+ " "
+ ""
+ "Miquel Recacha "
+ "Mario Nicotra "
+ "Gerry Roberts "
+ "Anthony Hinsinger "
+ "Radek Kaczorek "
+ " "
+ ""
+ "Sebastian Godelet "
+ "Stanislav Holub "
+ "Valerio Faiuolo "
+ "Peter Berbee "
+ "Paolo Stivanin "
+ " "
+ ""
+ "Paweł Soja "
+ "ToupTek Photonics Co., Ltd "
+ "Jarno Paananen "
+ "Leo Shatz "
+ "Niels Rackwitz "
+ " "
+ ""
+ "Philipp Weber "
+ "Kirill M. Skorobogatov "
+ " "
+ " "
+ " "
+ " "
+ "
"
+ " "
+ " "
+ "Copyright 2006-2013 Craig Stark "
+ "Copyright 2009 Geoffrey Hausheer "
+ "Copyright 2012-2013 Bret McKee "
+ "Copyright 2013 Sylvain Girard "
+ "Copyright 2013-2022 Andy Galasso "
+ "Copyright 2013-2023 Bruce Waddington "
+ "Copyright 2014 Hans Lambermont "
+ "Copyright 2014 Robin Glover "
+ "Copyright 2014-2017 Max Planck Society "
+ "Copyright 2017 Ken Self "
+ "Copyright 2019 Jasem Mutlaq "
+ " "
+ " "
+ "The Predictive PEC guide algorithm is based on "
+ "Gaussian Process Based Predictive "
+ "Control for Periodic Error Correction "
+ " "
+ "",
+ APPNAME, FULLVER));
wxHtmlWindow *pHtml;
pHtml = new wxHtmlWindow(this, ABOUT_LINK, wxDefaultPosition, wxSize(640, 500), wxHW_SCROLLBAR_AUTO);
pHtml->SetBorders(0);
@@ -228,7 +230,7 @@ AboutDialog::~AboutDialog(void)
wxMemoryFSHandler::RemoveFile("about.html");
}
-void AboutDialog::OnLink(wxHtmlLinkEvent & event)
+void AboutDialog::OnLink(wxHtmlLinkEvent& event)
{
wxLaunchDefaultBrowser(event.GetLinkInfo().GetHref());
}
diff --git a/src/about_dialog.h b/src/about_dialog.h
index d6a7fed7e..27b88de02 100644
--- a/src/about_dialog.h
+++ b/src/about_dialog.h
@@ -35,15 +35,14 @@
#ifndef ABOUT_DIALOG_H_INCLUDED
#define ABOUT_DIALOG_H_INCLUDED
-class AboutDialog :
- public wxDialog
+class AboutDialog : public wxDialog
{
public:
AboutDialog(void);
~AboutDialog(void);
private:
- void OnLink(wxHtmlLinkEvent & event);
+ void OnLink(wxHtmlLinkEvent& event);
wxDECLARE_EVENT_TABLE();
};
diff --git a/src/advanced_dialog.cpp b/src/advanced_dialog.cpp
index d292227db..5aa48570d 100644
--- a/src/advanced_dialog.cpp
+++ b/src/advanced_dialog.cpp
@@ -116,10 +116,10 @@ static void EnableValidators(wxWindow *win)
EnableValidators(kid);
}
-AdvancedDialog::AdvancedDialog(MyFrame *pFrame) :
- wxDialog(pFrame, wxID_ANY, _("Advanced Settings"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX),
- m_tip(nullptr),
- m_tipTimer(nullptr)
+AdvancedDialog::AdvancedDialog(MyFrame *pFrame)
+ : wxDialog(pFrame, wxID_ANY, _("Advanced Settings"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
+ , m_tip(nullptr)
+ , m_tipTimer(nullptr)
{
/*
* The advanced dialog is made up of a number of "on the fly" generated panels that configure different things.
@@ -160,9 +160,9 @@ AdvancedDialog::AdvancedDialog(MyFrame *pFrame) :
#else
m_pNotebook = new wxNotebook(this, wxID_ANY);
#endif
- m_pFrame = pFrame; // We get called before global var is initialized
+ m_pFrame = pFrame; // We get called before global var is initialized
- wxSizerFlags sizer_flags = wxSizerFlags(0).Align(wxALIGN_TOP|wxALIGN_CENTER_HORIZONTAL).Border(wxALL,2).Expand();
+ wxSizerFlags sizer_flags = wxSizerFlags(0).Align(wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL).Border(wxALL, 2).Expand();
// Build all the panels first - these are needed to create the various ConfigCtrlSets
// Each panel gets a vertical sizer attached to it
@@ -191,7 +191,7 @@ AdvancedDialog::AdvancedDialog(MyFrame *pFrame) :
m_pDevicesSettingsPanel->SetSizer(pDevicesTabSizer);
m_pNotebook->AddPage(m_pDevicesSettingsPanel, _("Other Devices"));
- BuildCtrlSets(); // Populates the m_brainCtrls map with all UI controls
+ BuildCtrlSets(); // Populates the m_brainCtrls map with all UI controls
// Pane contruction now pulls controls from the map and places them where they make sense to a user
// Populate global pane
@@ -222,12 +222,11 @@ AdvancedDialog::AdvancedDialog(MyFrame *pFrame) :
wxSizer *bsz = CreateButtonSizer(wxOK | wxCANCEL);
bsz->PrependStretchSpacer();
wxButton *helpbtn = new wxButton(this, wxID_ANY, _("Help"));
-# include "icons/help22.png.h"
+#include "icons/help22.png.h"
wxBitmap help_bmp(wxBITMAP_PNG_FROM_DATA(help22));
helpbtn->SetBitmap(help_bmp, wxLEFT);
- helpbtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](wxCommandEvent& evt) {
- ::pFrame->help->Display(HelpLink(m_pNotebook));
- });
+ helpbtn->Bind(
+ wxEVT_COMMAND_BUTTON_CLICKED, [this](wxCommandEvent& evt) { ::pFrame->help->Display(HelpLink(m_pNotebook)); });
bsz->Prepend(helpbtn);
pTopLevelSizer->Add(bsz, wxSizerFlags(0).Expand().Border(wxALL, 5));
SetSizerAndFit(pTopLevelSizer);
@@ -243,7 +242,8 @@ AdvancedDialog::~AdvancedDialog()
delete m_tipTimer;
}
-// Let a client(GearDialog) ask to preload the UI elements - prevents any visible delay when the AdvancedDialog is shown for the first time
+// Let a client(GearDialog) ask to preload the UI elements - prevents any visible delay when the AdvancedDialog is shown for the
+// first time
void AdvancedDialog::Preload()
{
if (m_rebuildPanels)
@@ -303,15 +303,15 @@ void AdvancedDialog::RebuildPanels()
AddCameraPage();
- m_pGuiderPane->LayoutControls(m_pFrame->pGuider, m_brainCtrls); // Guider pane doesn't have specific device dependencies
+ m_pGuiderPane->LayoutControls(m_pFrame->pGuider, m_brainCtrls); // Guider pane doesn't have specific device dependencies
m_pGuiderPane->Layout();
AddMountPage();
- AddAoPage(); // Will handle no AO case
- AddRotatorPage(); // Will handle no Rotator case
+ AddAoPage(); // Will handle no AO case
+ AddRotatorPage(); // Will handle no Rotator case
- if (m_pAOPane == nullptr && m_pRotatorPane == nullptr) // Dump the Other Devices tab if not needed
+ if (m_pAOPane == nullptr && m_pRotatorPane == nullptr) // Dump the Other Devices tab if not needed
{
int idx = m_pNotebook->FindPage(m_pDevicesSettingsPanel);
if (idx != wxNOT_FOUND)
@@ -328,7 +328,7 @@ void AdvancedDialog::RebuildPanels()
GetSizer()->Fit(this);
m_rebuildPanels = false;
- ConfirmLayouts(); // maybe should be under compiletime option
+ ConfirmLayouts(); // maybe should be under compiletime option
}
// Needed by ConfigDialogCtrlSets to know what parent to use when creating a control
@@ -346,7 +346,7 @@ wxWindow *AdvancedDialog::GetTabLocation(BRAIN_CTRL_IDS id)
return m_pDevicesSettingsPanel;
else
{
- assert(false); // Fundamental problem
+ assert(false); // Fundamental problem
return nullptr;
}
}
@@ -511,8 +511,7 @@ void AdvancedDialog::UnloadValues()
// Any un-do ops need to be handled at the ConfigDialogPane level
void AdvancedDialog::Undo()
{
- ConfigDialogPane *const panes[] =
- { m_pGlobalPane, m_pGuiderPane, m_pCameraPane, m_pMountPane, m_pAOPane, m_pRotatorPane };
+ ConfigDialogPane *const panes[] = { m_pGlobalPane, m_pGuiderPane, m_pCameraPane, m_pMountPane, m_pAOPane, m_pRotatorPane };
for (unsigned int i = 0; i < WXSIZEOF(panes); i++)
{
@@ -577,7 +576,6 @@ double AdvancedDialog::DetermineGuideSpeed()
else
minSpd = raSpd;
sidRate = SiderealRateFromGuideSpeed(minSpd);
-
}
}
else
@@ -595,22 +593,23 @@ double AdvancedDialog::DetermineGuideSpeed()
}
return sidRate;
}
-// Reacts to param changes in the AD that change the image scale. Calibration step-size is recalculated, calibration is cleared, MinMoves are set to defaults based on new image scale
+// Reacts to param changes in the AD that change the image scale. Calibration step-size is recalculated, calibration is
+// cleared, MinMoves are set to defaults based on new image scale
void AdvancedDialog::MakeImageScaleAdjustments()
{
double guideSpeedX;
Debug.Write("Image scale has changed via AD UI - step-size and algo adjustments will be made\n");
- Debug.Write(wxString::Format("New image scale properties: fl= %d, px= %.3fu, bin= %d\n",
- pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(),
- pCamera->Binning));
+ Debug.Write(wxString::Format("New image scale properties: fl= %d, px= %.3fu, bin= %d\n", pFrame->GetFocalLength(),
+ pCamera->GetCameraPixelSize(), pCamera->Binning));
// Determine a calibration step-size based on recommended distance and best estimator of mount guide speeds
guideSpeedX = DetermineGuideSpeed();
int calibrationStep;
- int recDistance = CalstepDialog::GetCalibrationDistance(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning);
+ int recDistance =
+ CalstepDialog::GetCalibrationDistance(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning);
int oldStepSize = TheScope()->GetCalibrationDuration();
- CalstepDialog::GetCalibrationStepSize(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning, guideSpeedX,
- CalstepDialog::DEFAULT_STEPS, 0, recDistance, nullptr, &calibrationStep);
+ CalstepDialog::GetCalibrationStepSize(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning,
+ guideSpeedX, CalstepDialog::DEFAULT_STEPS, 0, recDistance, nullptr, &calibrationStep);
TheScope()->SetCalibrationDuration(calibrationStep);
Debug.Write(wxString::Format("Cal step-size changed from %d ms to %d ms\n", oldStepSize, calibrationStep));
// Clear the calibration to force a new one and reset the min-move values
@@ -621,7 +620,8 @@ void AdvancedDialog::MakeImageScaleAdjustments()
pSecondaryMount->ClearCalibration();
Debug.Write("Calibrations cleared because of image scale change\n");
- double defMinMove = GuideAlgorithm::SmartDefaultMinMove(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning);
+ double defMinMove =
+ GuideAlgorithm::SmartDefaultMinMove(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning);
Debug.Write(wxString::Format("Guide algo min moves reset to %.3fu\n", defMinMove));
pMount->GetXGuideAlgorithm()->SetMinMove(defMinMove);
pMount->GetYGuideAlgorithm()->SetMinMove(defMinMove);
@@ -660,7 +660,10 @@ size_t AdvancedDialog::FindPage(wxWindow *ctrl)
struct ClearTipTimer : public wxTimer
{
wxTipWindow **m_w;
- ClearTipTimer(wxTipWindow **w) : m_w(w) { }
+ ClearTipTimer(wxTipWindow **w)
+ : m_w(w)
+ {
+ }
void Notify() override
{
if (*m_w)
@@ -684,7 +687,10 @@ void AdvancedDialog::ShowInvalid(wxWindow *ctrl, const wxString& message)
if (!m_tipTimer)
m_tipTimer = new ClearTipTimer(&m_tip);
- enum { TIP_TIMER_MILLISECONDS = 9000 };
+ enum
+ {
+ TIP_TIMER_MILLISECONDS = 9000
+ };
m_tipTimer->StartOnce(TIP_TIMER_MILLISECONDS);
}
diff --git a/src/advanced_dialog.h b/src/advanced_dialog.h
index 9f75b1fa3..18fae66eb 100644
--- a/src/advanced_dialog.h
+++ b/src/advanced_dialog.h
@@ -43,7 +43,8 @@ class CameraConfigDialogPane;
class GuiderConfigDialogPane;
class wxTipWindow;
-enum TAB_PAGES {
+enum TAB_PAGES
+{
AD_GLOBAL_PAGE,
AD_GUIDER_PAGE,
AD_CAMERA_PAGE,
@@ -58,7 +59,7 @@ class AdvancedDialog : public wxDialog
MyFrame *m_pFrame;
wxBookCtrlBase *m_pNotebook;
MyFrameConfigDialogPane *m_pGlobalPane;
- Guider::GuiderConfigDialogPane* m_pGuiderPane;
+ Guider::GuiderConfigDialogPane *m_pGuiderPane;
CameraConfigDialogPane *m_pCameraPane;
Mount::MountConfigDialogPane *m_pMountPane;
AOConfigDialogPane *m_pAOPane;
@@ -82,7 +83,6 @@ class AdvancedDialog : public wxDialog
bool m_imageScaleChanged;
public:
-
static const double MIN_FOCAL_LENGTH;
static const double MAX_FOCAL_LENGTH;
@@ -103,7 +103,10 @@ class AdvancedDialog : public wxDialog
bool Validate() override;
void ShowInvalid(wxWindow *ctrl, const wxString& message);
- void FlagImageScaleChange() { m_imageScaleChanged = true; } // Allows image scale adjustment to be made only once when AD is closed
+ void FlagImageScaleChange()
+ {
+ m_imageScaleChanged = true;
+ } // Allows image scale adjustment to be made only once when AD is closed
int GetFocalLength();
void SetFocalLength(int val);
double GetPixelSize();
@@ -111,7 +114,7 @@ class AdvancedDialog : public wxDialog
int GetBinning();
void SetBinning(int binning);
void MakeImageScaleAdjustments();
- Mount::MountConfigDialogPane* GetCurrentMountPane() { return m_pMountPane; }
+ Mount::MountConfigDialogPane *GetCurrentMountPane() { return m_pMountPane; }
wxWindow *GetTabLocation(BRAIN_CTRL_IDS id);
diff --git a/src/aui_controls.cpp b/src/aui_controls.cpp
index eca856554..f14bb0472 100644
--- a/src/aui_controls.cpp
+++ b/src/aui_controls.cpp
@@ -1,37 +1,37 @@
/*
-* aui_controls.cpp
-* PHD Guiding
-*
-* Created by Bruce Waddington
-* Copyright (c) 2016 Bruce Waddington and Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development,
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * aui_controls.cpp
+ * PHD Guiding
+ *
+ * Created by Bruce Waddington
+ * Copyright (c) 2016 Bruce Waddington and Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development,
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
#include "aui_controls.h"
@@ -39,15 +39,15 @@
#include
#include
-//#define ICON_DEV
+// #define ICON_DEV
#ifndef ICON_DEV
-#include "icons/sb_led_green.png.h"
-#include "icons/sb_led_yellow.png.h"
-#include "icons/sb_led_red.png.h"
-#include "icons/sb_arrow_left_16.png.h"
-#include "icons/sb_arrow_right_16.png.h"
-#include "icons/sb_arrow_up_16.png.h"
-#include "icons/sb_arrow_down_16.png.h"
+# include "icons/sb_led_green.png.h"
+# include "icons/sb_led_yellow.png.h"
+# include "icons/sb_led_red.png.h"
+# include "icons/sb_arrow_left_16.png.h"
+# include "icons/sb_arrow_right_16.png.h"
+# include "icons/sb_arrow_up_16.png.h"
+# include "icons/sb_arrow_down_16.png.h"
#endif
// clang-format off
@@ -77,11 +77,15 @@ class SBPanel : public wxPanel
{
std::vector m_fieldOffsets;
wxString m_overlayText;
- std::unordered_set m_hidden; // controls that are hidden by the overlay text
+ std::unordered_set m_hidden; // controls that are hidden by the overlay text
- enum { OVERLAY_HPADDING = 10 };
+ enum
+ {
+ OVERLAY_HPADDING = 10
+ };
- int OverlayWidth() const {
+ int OverlayWidth() const
+ {
wxSize sz = GetTextExtent(m_overlayText);
return OVERLAY_HPADDING + sz.GetWidth() + OVERLAY_HPADDING;
}
@@ -121,7 +125,7 @@ class SBStateIndicatorItem;
class SBStateIndicators
{
- std::vector m_stateItems;
+ std::vector m_stateItems;
SBPanel *m_parentPanel;
public:
@@ -149,8 +153,8 @@ class SBStateIndicatorItem
wxString otherInfo;
public:
- SBStateIndicatorItem(SBPanel *panel, SBStateIndicators *container,
- int indField, const wxString& indLabel, SBFieldTypes indType, std::vector& fldWidths);
+ SBStateIndicatorItem(SBPanel *panel, SBStateIndicators *container, int indField, const wxString& indLabel,
+ SBFieldTypes indType, std::vector& fldWidths);
void PositionControl();
void UpdateState();
wxString GearToolTip(int quadState);
@@ -188,25 +192,24 @@ class SBStarIndicators
SBStarIndicators(SBPanel *panel, std::vector& fldWidths);
void PositionControls();
void UpdateState(double MassPct, double SNR, bool Saturated);
-
};
// How this works:
// PHDStatusBar is a child of wxStatusBar and is composed of various control groups - properties of the guide star, info about
-// current guide commands, and state information about the current app session. Each group is managed by its own class, and that class
-// is responsible for building, positioning, and updating its controls. The various controls are positioned (via the OnSize event) on top of the SBPanel that
-// is the single underlying field in the base-class statusbar. The SBPanel class handles its own Paint event in order to render
-// the borders and field separators the way we want.
+// current guide commands, and state information about the current app session. Each group is managed by its own class, and
+// that class is responsible for building, positioning, and updating its controls. The various controls are positioned (via the
+// OnSize event) on top of the SBPanel that is the single underlying field in the base-class statusbar. The SBPanel class
+// handles its own Paint event in order to render the borders and field separators the way we want.
// ----------------------------------------------------------------------------
// SBPanel - parent control is the parent for all the status bar items
//
SBPanel::SBPanel(wxStatusBar *parent, const wxSize& panelSize)
- : wxPanel(parent, wxID_ANY, wxDefaultPosition, panelSize)
+ : wxPanel(parent, wxID_ANY, wxDefaultPosition, panelSize)
{
m_fieldOffsets.reserve(12);
int txtHeight;
- parent->GetTextExtent("M", &emWidth, &txtHeight); // Horizontal spacer used by various controls
+ parent->GetTextExtent("M", &emWidth, &txtHeight); // Horizontal spacer used by various controls
SetBackgroundStyle(wxBG_STYLE_PAINT);
#ifdef __APPLE__
@@ -397,14 +400,15 @@ SBStarIndicators::SBStarIndicators(SBPanel *panel, std::vector& fldWidths)
txtSNRLabel->Show(false);
txtSNRValue->SetBackgroundColour(*wxBLACK);
txtSNRValue->SetForegroundColour(*wxGREEN);
- txtSNRValue->SetToolTip(_("Signal-to-noise ratio of guide star\nGreen means SNR >= 10\nYellow means 4 <= SNR < 10\nRed means SNR < 4"));
+ txtSNRValue->SetToolTip(
+ _("Signal-to-noise ratio of guide star\nGreen means SNR >= 10\nYellow means 4 <= SNR < 10\nRed means SNR < 4"));
m_parentPanel = panel;
}
void SBStarIndicators::PositionControls()
{
- int fieldNum = (int)Field_Sat;
+ int fieldNum = (int) Field_Sat;
wxPoint snrPos;
wxPoint satPos;
@@ -473,7 +477,7 @@ SBGuideIndicators::SBGuideIndicators(SBPanel *panel, std::vector& fldWidths
arrowUp = wxBitmap(wxBITMAP_PNG_FROM_DATA(sb_arrow_up_16));
arrowDown = wxBitmap(wxBITMAP_PNG_FROM_DATA(sb_arrow_down_16));
#endif
- wxColor fgColor(200, 200, 200); // reduced brightness
+ wxColor fgColor(200, 200, 200); // reduced brightness
int guideAmtWidth;
int txtHeight;
panel->GetTextExtent("5555 ms, 555 px", &guideAmtWidth, &txtHeight);
@@ -482,24 +486,26 @@ SBGuideIndicators::SBGuideIndicators(SBPanel *panel, std::vector& fldWidths
bitmapRA = new wxStaticBitmap(panel, wxID_ANY, arrowLeft);
wxSize bitmapSize = bitmapRA->GetSize();
bitmapRA->Show(false);
- txtRaAmounts = new wxStaticText(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(guideAmtWidth, bitmapSize.y), wxALIGN_CENTER);
+ txtRaAmounts = new wxStaticText(
+ panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(guideAmtWidth, bitmapSize.y), wxALIGN_CENTER);
txtRaAmounts->SetBackgroundColour(*wxBLACK);
txtRaAmounts->SetForegroundColour(fgColor);
- txtDecAmounts = new wxStaticText(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(guideAmtWidth, bitmapSize.y), wxALIGN_RIGHT);
+ txtDecAmounts =
+ new wxStaticText(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(guideAmtWidth, bitmapSize.y), wxALIGN_RIGHT);
txtDecAmounts->SetBackgroundColour(*wxBLACK);
txtDecAmounts->SetForegroundColour(fgColor);
bitmapDec = new wxStaticBitmap(panel, wxID_ANY, arrowUp);
bitmapDec->Show(false);
m_parentPanel = panel;
- // Since we don't want separators between the arrows and the text info, we lump the two together and treat them as one field for the purpose
- // of positioning
- fldWidths.push_back(bitmapSize.x + guideAmtWidth + 2 * panel->emWidth); // RA info
- fldWidths.push_back(bitmapSize.x + guideAmtWidth + 2 * panel->emWidth); // Dec info
+ // Since we don't want separators between the arrows and the text info, we lump the two together and treat them as one field
+ // for the purpose of positioning
+ fldWidths.push_back(bitmapSize.x + guideAmtWidth + 2 * panel->emWidth); // RA info
+ fldWidths.push_back(bitmapSize.x + guideAmtWidth + 2 * panel->emWidth); // Dec info
}
void SBGuideIndicators::PositionControls()
{
- int fieldNum = (int)Field_RAInfo;
+ int fieldNum = (int) Field_RAInfo;
int txtWidth;
int txtHeight;
wxPoint loc;
@@ -511,7 +517,7 @@ void SBGuideIndicators::PositionControls()
txtRaAmounts->SetPosition(raPosition);
fieldNum++;
- wxString txtSizer = wxString::Format(_("%d ms, %0.1f px"), 120, 4.38);
+ wxString txtSizer = wxString::Format(_("%d ms, %0.1f px"), 120, 4.38);
m_parentPanel->GetTextExtent(txtSizer, &txtWidth, &txtHeight);
wxPoint decPosition = m_parentPanel->FieldLoc(fieldNum);
txtDecAmounts->SetPosition(decPosition);
@@ -562,7 +568,8 @@ void SBGuideIndicators::UpdateState(int raDirection, int decDirection, double ra
//------------------------------------------------------------------------------------------
// ---SBStateIndicatorItem - individual state indicators
//
-SBStateIndicatorItem::SBStateIndicatorItem(SBPanel *panel, SBStateIndicators *host, int indField, const wxString& indLabel, SBFieldTypes indType, std::vector& fldWidths)
+SBStateIndicatorItem::SBStateIndicatorItem(SBPanel *panel, SBStateIndicators *host, int indField, const wxString& indLabel,
+ SBFieldTypes indType, std::vector& fldWidths)
{
m_type = indType;
lastState = -2;
@@ -575,7 +582,8 @@ SBStateIndicatorItem::SBStateIndicatorItem(SBPanel *panel, SBStateIndicators *ho
// Use default positions for control creation - positioning is handled explicitly in PositionControls()
if (indType != Field_Gear)
{
- ctrl = new wxStaticText(m_parentPanel, wxID_ANY, indLabel, wxDefaultPosition, wxSize(txtWidth + m_parentPanel->emWidth, -1), wxALIGN_CENTER);
+ ctrl = new wxStaticText(m_parentPanel, wxID_ANY, indLabel, wxDefaultPosition,
+ wxSize(txtWidth + m_parentPanel->emWidth, -1), wxALIGN_CENTER);
fldWidths.push_back(txtWidth + 2 * m_parentPanel->emWidth);
}
else
@@ -601,8 +609,8 @@ static int CalibrationQuadState(wxString *tip)
{
// For calib quad state: -1 => no cal, 0 => cal but no pointing compensation, 1 => golden
- bool calibrated = (pMount || pSecondaryMount) &&
- (!pMount || pMount->IsCalibrated()) && (!pSecondaryMount || pSecondaryMount->IsCalibrated());
+ bool calibrated = (pMount || pSecondaryMount) && (!pMount || pMount->IsCalibrated()) &&
+ (!pSecondaryMount || pSecondaryMount->IsCalibrated());
if (!calibrated)
{
@@ -649,11 +657,12 @@ static wxString Join(const wxString& delim, const std::vector& vec)
wxString buf;
buf.reserve(l + delim.length() * (vec.size() - 1));
std::for_each(vec.begin(), vec.end(),
- [&buf, &delim](const wxString& s) {
- if (!buf.empty())
- buf += delim;
- buf += s;
- });
+ [&buf, &delim](const wxString& s)
+ {
+ if (!buf.empty())
+ buf += delim;
+ buf += s;
+ });
return buf;
}
@@ -664,7 +673,8 @@ void SBStateIndicatorItem::UpdateState()
switch (m_type)
{
- case Field_Gear: {
+ case Field_Gear:
+ {
std::vector MIAs;
bool cameraOk = true;
bool problems = false;
@@ -732,7 +742,7 @@ void SBStateIndicatorItem::UpdateState()
if (cameraOk)
pic->SetIcon(container->icoYellowLed);
else
- pic->SetIcon(container->icoRedLed); // What good are we without a camera
+ pic->SetIcon(container->icoRedLed); // What good are we without a camera
quadState = 0;
otherInfo = Join(_(", "), MIAs);
pic->SetToolTip(GearToolTip(quadState));
@@ -765,11 +775,12 @@ void SBStateIndicatorItem::UpdateState()
break;
- case Field_Calib: {
+ case Field_Calib:
+ {
quadState = CalibrationQuadState(&cal_tooltip);
lastState = -2; // force tool-tip update even if state did not change
break;
- }
+ }
default:
break;
@@ -853,9 +864,10 @@ SBStateIndicators::SBStateIndicators(SBPanel *panel, std::vector& fldWidths
led = wxBitmap(wxBITMAP_PNG_FROM_DATA(sb_led_red));
icoRedLed.CopyFromBitmap(led);
#endif
- for (int inx = (int)Field_Darks; inx <= (int)Field_Gear; inx++)
+ for (int inx = (int) Field_Darks; inx <= (int) Field_Gear; inx++)
{
- SBStateIndicatorItem *item = new SBStateIndicatorItem(m_parentPanel, this, inx, labels[inx - Field_Darks], (SBFieldTypes)(inx), fldWidths);
+ SBStateIndicatorItem *item =
+ new SBStateIndicatorItem(m_parentPanel, this, inx, labels[inx - Field_Darks], (SBFieldTypes) (inx), fldWidths);
m_stateItems.push_back(item);
item->UpdateState();
}
@@ -883,7 +895,8 @@ void SBStateIndicators::UpdateState()
}
}
-enum {
+enum
+{
SB_HEIGHT = 16
};
@@ -895,7 +908,7 @@ PHDStatusBar::PHDStatusBar(wxWindow *parent, long style)
std::vector fieldWidths;
// Set up the only field the wxStatusBar base class will know about
- int widths[] = {-1};
+ int widths[] = { -1 };
SetFieldsCount(1);
SetStatusWidths(1, widths);
@@ -907,10 +920,10 @@ PHDStatusBar::PHDStatusBar(wxWindow *parent, long style)
// Build the leftmost text status field, the only field managed at this level
m_Msg1 = new wxStaticText(m_ctrlPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1));
int txtWidth, txtHeight;
- GetTextExtent(_("Selected star at (999.9, 999.9)"), &txtWidth, &txtHeight); // only care about the width
+ GetTextExtent(_("Selected star at (999.9, 999.9)"), &txtWidth, &txtHeight); // only care about the width
m_Msg1->SetBackgroundColour(*wxBLACK);
m_Msg1->SetForegroundColour(*wxWHITE);
- fieldWidths.push_back(txtWidth); // Doesn't matter but we need to occupy the position in fieldWidths
+ fieldWidths.push_back(txtWidth); // Doesn't matter but we need to occupy the position in fieldWidths
// Build the star status fields
m_StarIndicators = new SBStarIndicators(m_ctrlPanel, fieldWidths);
@@ -935,7 +948,7 @@ PHDStatusBar *PHDStatusBar::CreateInstance(wxWindow *parent, long style)
// Destructor
PHDStatusBar::~PHDStatusBar()
{
- this->DestroyChildren(); // any wxWidgets objects will be deleted
+ this->DestroyChildren(); // any wxWidgets objects will be deleted
delete m_StateIndicators;
delete m_GuideIndicators;
delete m_StarIndicators;
@@ -978,8 +991,8 @@ void PHDStatusBar::UpdateStarInfo(double SNR, bool Saturated)
void PHDStatusBar::UpdateGuiderInfo(const GuideStepInfo& info)
{
- m_GuideIndicators->UpdateState(info.directionRA, info.directionDec, fabs(info.mountOffset.X),
- info.durationRA, fabs(info.mountOffset.Y), info.durationDec);
+ m_GuideIndicators->UpdateState(info.directionRA, info.directionDec, fabs(info.mountOffset.X), info.durationRA,
+ fabs(info.mountOffset.Y), info.durationDec);
}
void PHDStatusBar::ClearGuiderInfo()
diff --git a/src/aui_controls.h b/src/aui_controls.h
index 6b0d2c709..43c1c46b2 100644
--- a/src/aui_controls.h
+++ b/src/aui_controls.h
@@ -1,37 +1,37 @@
/*
-* aui_controls.h
-* PHD Guiding
-*
-* Created by Bruce Waddington
-* Copyright (c) 2016-2017 Bruce Waddington and Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development,
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * aui_controls.h
+ * PHD Guiding
+ *
+ * Created by Bruce Waddington
+ * Copyright (c) 2016-2017 Bruce Waddington and Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development,
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#ifndef _AUI_CONTROLS_H_
#define _AUI_CONTROLS_H_
@@ -85,4 +85,4 @@ class PHDToolBarArt : public wxAuiDefaultToolBarArt
virtual wxAuiToolBarArt *Clone() { return new PHDToolBarArt(*this); }
};
-#endif // AUI_CONTROLS_H
+#endif // AUI_CONTROLS_H
diff --git a/src/backlash_comp.cpp b/src/backlash_comp.cpp
index bfb132a5b..94ca83b9c 100644
--- a/src/backlash_comp.cpp
+++ b/src/backlash_comp.cpp
@@ -1,45 +1,45 @@
/*
-* backlash_comp.cpp
-* PHD Guiding
-*
-* Created by Bruce Waddington
-* Copyright (c) 2015 Bruce Waddington and Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development,
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * backlash_comp.cpp
+ * PHD Guiding
+ *
+ * Created by Bruce Waddington
+ * Copyright (c) 2015 Bruce Waddington and Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development,
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
#include "backlash_comp.h"
#include
-static const unsigned int MIN_COMP_AMOUNT = 20; // min pulse in ms, must be small enough to effectively disable blc
-static const unsigned int MAX_COMP_AMOUNT = 8000; // max pulse in ms
+static const unsigned int MIN_COMP_AMOUNT = 20; // min pulse in ms, must be small enough to effectively disable blc
+static const unsigned int MAX_COMP_AMOUNT = 8000; // max pulse in ms
class CorrectionTuple
{
@@ -72,18 +72,15 @@ class BLCEvent
stictionSeen = false;
}
- size_t InfoCount() const
- {
- return corrections.size();
- }
+ size_t InfoCount() const { return corrections.size(); }
void AddEventInfo(long TimeSecs, double Amount, double minMove)
{
- // Correction[0] is the deflection that triggered the BLC in the first place. Correction[1] is the first delta after the pulse was issued,
- // Correction[2] is the (optional) subsequent delta, needed to detect stiction
+ // Correction[0] is the deflection that triggered the BLC in the first place. Correction[1] is the first delta after
+ // the pulse was issued, Correction[2] is the (optional) subsequent delta, needed to detect stiction
if (InfoCount() < 3)
{
- corrections.push_back(CorrectionTuple(TimeSecs, Amount)); // Regardless of size relative to min-move
+ corrections.push_back(CorrectionTuple(TimeSecs, Amount)); // Regardless of size relative to min-move
if (fabs(Amount) > minMove)
{
if (InfoCount() == 2)
@@ -92,19 +89,17 @@ class BLCEvent
initialUndershoot = true;
else
initialOvershoot = true;
-
}
else
{
if (InfoCount() == 3)
{
- stictionSeen = Amount < 0 && corrections[1].miss > 0; // 2nd follow-on miss was an over-shoot
+ stictionSeen = Amount < 0 && corrections[1].miss > 0; // 2nd follow-on miss was an over-shoot
}
}
}
}
}
-
};
// Basic operation
@@ -135,15 +130,17 @@ class BLCHistory
double avgInitialMiss;
double avgStictionAmount;
- RecentStats() : shortCount(0), longCount(0), stictionCount(0), avgInitialMiss(0), avgStictionAmount(0)
+ RecentStats()
+ : shortCount(0)
+ , longCount(0)
+ , stictionCount(0)
+ , avgInitialMiss(0)
+ , avgStictionAmount(0)
{
}
};
- bool WindowOpen() const
- {
- return windowOpen;
- }
+ bool WindowOpen() const { return windowOpen; }
BLCHistory()
{
@@ -152,10 +149,7 @@ class BLCHistory
timeBase = wxGetCurrentTime();
}
- static void LogStatus(const wxString& Msg)
- {
- Debug.Write(wxString::Format("BLC: %s\n", Msg));
- }
+ static void LogStatus(const wxString& Msg) { Debug.Write(wxString::Format("BLC: %s\n", Msg)); }
void CloseWindow()
{
@@ -180,9 +174,9 @@ class BLCHistory
bool added = false;
if (blcIndex >= 0 && blcEvents[blcIndex].InfoCount() < ENTRY_CAPACITY)
{
- blcEvents[blcIndex].AddEventInfo(When-timeBase, Amt, MinMove);
+ blcEvents[blcIndex].AddEventInfo(When - timeBase, Amt, MinMove);
added = true;
- //LogStatus("Deflection entry added for event " + std::to_string(blcIndex));
+ // LogStatus("Deflection entry added for event " + std::to_string(blcIndex));
}
else
{
@@ -231,7 +225,7 @@ class BLCHistory
}
// Stats over some number of recent events, returns the average initial miss
- double GetStats(int numEvents, RecentStats* Results) const
+ double GetStats(int numEvents, RecentStats *Results) const
{
int bottom = std::max(0, blcIndex - (numEvents - 1));
double sum = 0;
@@ -267,7 +261,7 @@ class BLCHistory
return Results->avgInitialMiss;
}
- bool AdjustmentNeeded(double miss, double minMove, double yRate, double* correction)
+ bool AdjustmentNeeded(double miss, double minMove, double yRate, double *correction)
{
bool adjust = false;
const BLCEvent *currEvent;
@@ -278,22 +272,23 @@ class BLCHistory
{
avgInitMiss = GetStats(HISTORY_DEPTH, &stats);
currEvent = &blcEvents[blcIndex];
- wxString deflections = " Deflections: 0=" + std::to_string(currEvent->corrections[0].miss) + ", 1:" +
- wxString(std::to_string(currEvent->corrections[1].miss));
+ wxString deflections = " Deflections: 0=" + std::to_string(currEvent->corrections[0].miss) +
+ ", 1:" + wxString(std::to_string(currEvent->corrections[1].miss));
if (currEvent->InfoCount() > 2)
deflections += ", 2:" + std::to_string(currEvent->corrections[2].miss);
- LogStatus(wxString::Format("History state: CurrMiss=%0.2f, AvgInitMiss=%0.2f, ShCount=%d, LgCount=%d, SticCount=%d, %s",
- miss, stats.avgInitialMiss, stats.shortCount, stats.longCount, stats.stictionCount, deflections));
+ LogStatus(
+ wxString::Format("History state: CurrMiss=%0.2f, AvgInitMiss=%0.2f, ShCount=%d, LgCount=%d, SticCount=%d, %s",
+ miss, stats.avgInitialMiss, stats.shortCount, stats.longCount, stats.stictionCount, deflections));
}
else
return false;
- if (fabs(miss) >= minMove) // Most recent miss was big enough to look at
+ if (fabs(miss) >= minMove) // Most recent miss was big enough to look at
{
int corr;
- corr = (int)(floor(abs(avgInitMiss) / yRate) + 0.5); // unsigned correction value
+ corr = (int) (floor(abs(avgInitMiss) / yRate) + 0.5); // unsigned correction value
if (miss > 0)
- // UNDER-SHOOT-------------------------------
+ // UNDER-SHOOT-------------------------------
{
if (avgInitMiss > 0)
{
@@ -307,7 +302,7 @@ class BLCHistory
else
{
// Check for over-shoot history
- if (stats.longCount >= 2) // 2 or more over-shoots in window
+ if (stats.longCount >= 2) // 2 or more over-shoots in window
LogStatus("Under-shoot; no adjustment because of over-shoot history");
else
{
@@ -328,15 +323,15 @@ class BLCHistory
}
}
else
- // OVER-SHOOT, miss < 0--------------------------------------
+ // OVER-SHOOT, miss < 0--------------------------------------
{
std::string msg = "";
if (currEvent->stictionSeen)
{
- if (stats.stictionCount > 1) // Seeing and low min-move can look like stiction, don't over-react
+ if (stats.stictionCount > 1) // Seeing and low min-move can look like stiction, don't over-react
{
msg = "Over-shoot, stiction seen, ";
- double stictionCorr = (int)(floor(abs(stats.avgStictionAmount) / yRate) + 0.5);
+ double stictionCorr = (int) (floor(abs(stats.avgStictionAmount) / yRate) + 0.5);
*correction = -stictionCorr;
RemoveOldestStictions(1);
adjust = true;
@@ -394,8 +389,8 @@ BacklashComp::BacklashComp(Scope *scope)
SetCompValues(lastAmt, lastFloor, lastCeiling);
m_lastDirection = NONE;
if (m_compActive)
- Debug.Write(wxString::Format("BLC: Enabled with correction = %d ms, Floor = %d, Ceiling = %d, %s\n",
- m_pulseWidth, m_adjustmentFloor, m_adjustmentCeiling, m_fixedSize ? "Fixed" : "Adjustable"));
+ Debug.Write(wxString::Format("BLC: Enabled with correction = %d ms, Floor = %d, Ceiling = %d, %s\n", m_pulseWidth,
+ m_adjustmentFloor, m_adjustmentCeiling, m_fixedSize ? "Fixed" : "Adjustable"));
else
Debug.Write("BLC: Backlash compensation is disabled\n");
}
@@ -415,7 +410,7 @@ int BacklashComp::GetBacklashPulseMinValue()
return MIN_COMP_AMOUNT;
}
-void BacklashComp::GetBacklashCompSettings(int* pulseWidth, int* floor, int* ceiling) const
+void BacklashComp::GetBacklashCompSettings(int *pulseWidth, int *floor, int *ceiling) const
{
*pulseWidth = m_pulseWidth;
*floor = m_adjustmentFloor;
@@ -427,7 +422,7 @@ void BacklashComp::GetBacklashCompSettings(int* pulseWidth, int* floor, int* cei
void BacklashComp::SetCompValues(int requestedSize, int floor, int ceiling)
{
m_pulseWidth = wxMax(0, wxMin(requestedSize, MAX_COMP_AMOUNT));
- if (floor > m_pulseWidth || floor < MIN_COMP_AMOUNT) // Coming from GA or user input makes no sense
+ if (floor > m_pulseWidth || floor < MIN_COMP_AMOUNT) // Coming from GA or user input makes no sense
m_adjustmentFloor = MIN_COMP_AMOUNT;
else
m_adjustmentFloor = floor;
@@ -448,8 +443,8 @@ void BacklashComp::SetBacklashPulseWidth(int ms, int floor, int ceiling)
int oldBLC = m_pulseWidth;
SetCompValues(ms, floor, ceiling);
pFrame->NotifyGuidingParam("Backlash comp amount", m_pulseWidth);
- Debug.Write(wxString::Format("BLC: Comp pulse set to %d ms, Floor = %d ms, Ceiling = %d ms, %s\n",
- m_pulseWidth, m_adjustmentFloor, m_adjustmentCeiling, m_fixedSize ? "Fixed" : "Adjustable"));
+ Debug.Write(wxString::Format("BLC: Comp pulse set to %d ms, Floor = %d ms, Ceiling = %d ms, %s\n", m_pulseWidth,
+ m_adjustmentFloor, m_adjustmentCeiling, m_fixedSize ? "Fixed" : "Adjustable"));
if (abs(m_pulseWidth - oldBLC) > 100)
{
m_pHistory->ClearHistory();
@@ -473,7 +468,8 @@ void BacklashComp::EnableBacklashComp(bool enable)
m_compActive = enable;
pConfig->Profile.SetBoolean("/" + m_pScope->GetMountClassName() + "/BacklashCompEnabled", m_compActive);
- Debug.Write(wxString::Format("BLC: Backlash comp %s, Comp pulse = %d ms\n", m_compActive ? "enabled" : "disabled", m_pulseWidth));
+ Debug.Write(
+ wxString::Format("BLC: Backlash comp %s, Comp pulse = %d ms\n", m_compActive ? "enabled" : "disabled", m_pulseWidth));
}
void BacklashComp::ResetBLCState()
@@ -514,15 +510,15 @@ void BacklashComp::TrackBLCResults(unsigned int moveOptions, double yRawOffset)
// An earlier BLC was applied and we're tracking follow-up results
- // Record the history even if residual error is zero. Sign convention has nothing to do with N or S direction - only whether we
- // needed more correction (+) or less (-)
+ // Record the history even if residual error is zero. Sign convention has nothing to do with N or S direction - only whether
+ // we needed more correction (+) or less (-)
GUIDE_DIRECTION dir = yRawOffset > 0.0 ? DOWN : UP;
double yDistance = fabs(yRawOffset);
double miss;
if (dir == m_lastDirection)
- miss = yDistance; // + => we needed more of the same, under-shoot
+ miss = yDistance; // + => we needed more of the same, under-shoot
else
- miss = -yDistance; // over-shoot
+ miss = -yDistance; // over-shoot
double minMove = fmax(m_pScope->GetYGuideAlgorithm()->GetMinMove(), 0.); // Algo w/ no min-move returns -1
@@ -597,11 +593,14 @@ void BacklashComp::ApplyBacklashComp(unsigned int moveOptions, double yGuideDist
class BacklashGraph : public wxDialog
{
public:
- BacklashGraph(wxDialog *parent, const std::vector &northSteps, const std::vector &southSteps, int PulseSize);
- wxBitmap CreateGraph(int graphicWidth, int graphicHeight, const std::vector &northSteps, const std::vector &southSteps, int PulseSize);
+ BacklashGraph(
+ wxDialog *parent, const std::vector& northSteps, const std::vector& southSteps, int PulseSize);
+ wxBitmap CreateGraph(int graphicWidth, int graphicHeight, const std::vector& northSteps,
+ const std::vector& southSteps, int PulseSize);
};
-BacklashGraph::BacklashGraph(wxDialog *parent, const std::vector &northSteps, const std::vector &southSteps, int PulseSize)
+BacklashGraph::BacklashGraph(
+ wxDialog *parent, const std::vector& northSteps, const std::vector& southSteps, int PulseSize)
: wxDialog(parent, wxID_ANY, wxGetTranslation(_("Backlash Results")), wxDefaultPosition, wxSize(500, 400))
{
// Just but a big button area for the graph with a button below it
@@ -612,14 +611,13 @@ BacklashGraph::BacklashGraph(wxDialog *parent, const std::vector &northS
vSizer->Add(graph, 0, wxALIGN_CENTER_HORIZONTAL | wxALL | wxFIXED_MINSIZE, 5);
// ok button because we're modal
- vSizer->Add(
- CreateButtonSizer(wxOK),
- wxSizerFlags(0).Expand().Border(wxALL, 10));
+ vSizer->Add(CreateButtonSizer(wxOK), wxSizerFlags(0).Expand().Border(wxALL, 10));
SetSizerAndFit(vSizer);
}
-wxBitmap BacklashGraph::CreateGraph(int bmpWidth, int bmpHeight, const std::vector &northSteps, const std::vector &southSteps, int PulseSize)
+wxBitmap BacklashGraph::CreateGraph(
+ int bmpWidth, int bmpHeight, const std::vector& northSteps, const std::vector& southSteps, int PulseSize)
{
wxMemoryDC dc;
wxBitmap bmp(bmpWidth, bmpHeight, -1);
@@ -665,7 +663,7 @@ wxBitmap BacklashGraph::CreateGraph(int bmpWidth, int bmpHeight, const std::vect
// Since we get mount coordinates, north steps will always be in ascending order
numNorth = northSteps.size();
northInc = (northSteps.at(numNorth - 1) - northSteps.at(0)) / numNorth;
- numSouth = southSteps.size(); // May not be the same as numNorth if some sort of problem occurred
+ numSouth = southSteps.size(); // May not be the same as numNorth if some sort of problem occurred
dc.SelectObject(bmp);
dc.SetBackground(*wxBLACK_BRUSH);
@@ -675,7 +673,7 @@ wxBitmap BacklashGraph::CreateGraph(int bmpWidth, int bmpHeight, const std::vect
// Bottom and top labels
xOrigin = graphWindowWidth / 2;
- yOrigin = graphWindowHeight + 40; // Leave room at the top for labels and such
+ yOrigin = graphWindowHeight + 40; // Leave room at the top for labels and such
dc.SetTextForeground(idealColor);
dc.DrawText(_("Ideal"), 0.7 * graphWindowWidth, bmpHeight - 25);
dc.SetTextForeground(decColor);
@@ -692,8 +690,8 @@ wxBitmap BacklashGraph::CreateGraph(int bmpWidth, int bmpHeight, const std::vect
}
// Draw the axes
dc.SetPen(axisPen);
- dc.DrawLine(0, yOrigin, graphWindowWidth, yOrigin); // x
- dc.DrawLine(xOrigin, yOrigin, xOrigin, 0); // y
+ dc.DrawLine(0, yOrigin, graphWindowWidth, yOrigin); // x
+ dc.DrawLine(xOrigin, yOrigin, xOrigin, 0); // y
// Draw the north steps
dc.SetPen(decPen);
@@ -708,7 +706,8 @@ wxBitmap BacklashGraph::CreateGraph(int bmpWidth, int bmpHeight, const std::vect
// Draw the south steps
for (int i = 0; i < numSouth; i++)
{
- dc.DrawCircle(wxPoint((i + numNorth) * xScaleFactor, round(yOrigin - (southSteps.at(i) - minDec) * yScaleFactor)), ptRadius);
+ dc.DrawCircle(
+ wxPoint((i + numNorth) * xScaleFactor, round(yOrigin - (southSteps.at(i) - minDec) * yScaleFactor)), ptRadius);
}
// Now show an ideal south recovery line
@@ -718,7 +717,8 @@ wxBitmap BacklashGraph::CreateGraph(int bmpWidth, int bmpHeight, const std::vect
double peakSouth = southSteps.at(0);
for (int i = 1; i <= numNorth; i++)
{
- wxPoint where = wxPoint((i + numNorth)* xScaleFactor, round(yOrigin - (peakSouth - i * northInc - minDec) * yScaleFactor));
+ wxPoint where =
+ wxPoint((i + numNorth) * xScaleFactor, round(yOrigin - (peakSouth - i * northInc - minDec) * yScaleFactor));
dc.DrawCircle(where, ptRadius);
}
@@ -732,7 +732,7 @@ BacklashTool::BacklashTool()
{
m_scope = TheScope();
- m_lastDecGuideRate = GetLastDecGuideRate(); // -1 if we aren't calibrated
+ m_lastDecGuideRate = GetLastDecGuideRate(); // -1 if we aren't calibrated
if (m_lastDecGuideRate > 0)
m_bltState = BLT_STATE_INITIALIZE;
else
@@ -747,10 +747,7 @@ BacklashTool::BacklashTool()
m_backlashExemption = false;
}
-BacklashTool::~BacklashTool()
-{
-
-}
+BacklashTool::~BacklashTool() { }
bool BacklashTool::IsGraphable()
{
@@ -792,15 +789,13 @@ void BacklashTool::StopMeasurement()
static bool OutOfRoom(const wxSize& frameSize, double camX, double camY, int margin)
{
- return camX < margin ||
- camY < margin ||
- camX >= frameSize.GetWidth() - margin ||
- camY >= frameSize.GetHeight() - margin;
+ return camX < margin || camY < margin || camX >= frameSize.GetWidth() - margin || camY >= frameSize.GetHeight() - margin;
}
-// Measure the apparent backlash by looking at the first south moves, looking to see when the mount moves consistently at the expected rate
-// Goal is to establish a good seed value for backlash compensation, not to accurately measure the hardware performance
-BacklashTool::MeasurementResults BacklashTool::ComputeBacklashPx(double* bltPx, int* bltMs, double* northRate)
+// Measure the apparent backlash by looking at the first south moves, looking to see when the mount moves consistently at the
+// expected rate Goal is to establish a good seed value for backlash compensation, not to accurately measure the hardware
+// performance
+BacklashTool::MeasurementResults BacklashTool::ComputeBacklashPx(double *bltPx, int *bltMs, double *northRate)
{
double expectedAmount;
double expectedMagnitude;
@@ -817,16 +812,20 @@ BacklashTool::MeasurementResults BacklashTool::ComputeBacklashPx(double* bltPx,
if (m_northBLSteps.size() > 3)
{
// figure out the drift-related corrections
- double driftAmtPx = m_driftPerSec * (m_msmtEndTime - m_msmtStartTime) / 1000; // amount of drift in px for entire north measurement period
+ double driftAmtPx = m_driftPerSec * (m_msmtEndTime - m_msmtStartTime) /
+ 1000; // amount of drift in px for entire north measurement period
int stepCount = m_northStats.GetCount();
northDelta = m_northStats.GetSum();
- nRate = fabs((northDelta - driftAmtPx) / (stepCount * m_pulseWidth)); // drift-corrected empirical measure of north rate
+ nRate = fabs((northDelta - driftAmtPx) / (stepCount * m_pulseWidth)); // drift-corrected empirical measure of north rate
driftPxPerFrame = driftAmtPx / stepCount;
- Debug.Write(wxString::Format("BLT: Drift correction of %0.2f px applied to total north moves of %0.2f px, %0.3f px/frame\n", driftAmtPx, northDelta, driftPxPerFrame));
+ Debug.Write(
+ wxString::Format("BLT: Drift correction of %0.2f px applied to total north moves of %0.2f px, %0.3f px/frame\n",
+ driftAmtPx, northDelta, driftPxPerFrame));
Debug.Write(wxString::Format("BLT: Empirical north rate = %.2f px/s \n", nRate * 1000));
- // Compute an expected movement of 90% of the median delta north moves (px). Use the 90% tolerance to accept situations where the south rate
- // never matches the north rate yet the mount is moving consistently. Allow smoothing for odd mounts that produce sequences of short-long-short-long...
+ // Compute an expected movement of 90% of the median delta north moves (px). Use the 90% tolerance to accept situations
+ // where the south rate never matches the north rate yet the mount is moving consistently. Allow smoothing for odd
+ // mounts that produce sequences of short-long-short-long...
expectedAmount = 0.9 * m_northStats.GetMedian();
expectedMagnitude = fabs(expectedAmount);
int goodSouthMoves = 0;
@@ -834,25 +833,29 @@ BacklashTool::MeasurementResults BacklashTool::ComputeBacklashPx(double* bltPx,
bool smoothing = false;
for (int step = 1; step < m_southBLSteps.size(); step++)
{
- double southMove = m_southBLSteps[step] - m_southBLSteps[step-1];
+ double southMove = m_southBLSteps[step] - m_southBLSteps[step - 1];
earlySouthMoves += southMove;
- if (southMove < 0 && (fabs(southMove) >= expectedMagnitude || fabs(southMove + lastSouthMove / 2.0) > expectedMagnitude)) // Big enough move and in the correct (south) direction
+ if (southMove < 0 &&
+ (fabs(southMove) >= expectedMagnitude ||
+ fabs(southMove + lastSouthMove / 2.0) >
+ expectedMagnitude)) // Big enough move and in the correct (south) direction
{
if (fabs(southMove) < expectedMagnitude)
smoothing = true;
goodSouthMoves++;
- // We want two consecutive south moves that meet or exceed the expected magnitude. This sidesteps situations where the mount shows a "false start" south
+ // We want two consecutive south moves that meet or exceed the expected magnitude. This sidesteps situations
+ // where the mount shows a "false start" south
if (goodSouthMoves == 2)
{
if (smoothing)
Debug.Write("BLT: Smoothing applied to south data points\n");
// bl = sum(expected moves) - sum(actual moves) - (drift correction for that period)
- blPx = step * expectedMagnitude - fabs(earlySouthMoves - step * driftPxPerFrame); // drift-corrected backlash amount
+ blPx = step * expectedMagnitude -
+ fabs(earlySouthMoves - step * driftPxPerFrame); // drift-corrected backlash amount
if (blPx * nRate < -200)
- rslt = MEASUREMENT_SANITY; // large negative number
- else
- if (blPx >= 0.7 * northDelta)
- rslt = MEASUREMENT_TOO_FEW_NORTH; // bl large compared to total north moves
+ rslt = MEASUREMENT_SANITY; // large negative number
+ else if (blPx >= 0.7 * northDelta)
+ rslt = MEASUREMENT_TOO_FEW_NORTH; // bl large compared to total north moves
else
rslt = MEASUREMENT_VALID;
if (blPx < 0)
@@ -877,7 +880,7 @@ BacklashTool::MeasurementResults BacklashTool::ComputeBacklashPx(double* bltPx,
rslt = MEASUREMENT_TOO_FEW_NORTH;
// Update the ref variables
*bltPx = blPx;
- *bltMs = (int)(blPx / nRate);
+ *bltMs = (int) (blPx / nRate);
*northRate = nRate;
return rslt;
}
@@ -896,9 +899,9 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
if (m_bltState != BLT_STATE_INITIALIZE)
{
decDelta = currMountLocation.Y - m_markerPoint.Y;
- m_cumClearingDistance += decDelta; // use signed value
- //if (m_bltState == BLT_STATE_CLEAR_NORTH) // DEBUG ONLY
- // decDelta = fakeDeltas[wxMin(m_stepCount, 7)];
+ m_cumClearingDistance += decDelta; // use signed value
+ // if (m_bltState == BLT_STATE_CLEAR_NORTH) // DEBUG ONLY
+ // decDelta = fakeDeltas[wxMin(m_stepCount, 7)];
}
Debug.Write("BLT: Entering DecMeasurementStep, state = " + std::to_string(m_bltState) + "\n");
switch (m_bltState)
@@ -909,19 +912,21 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
m_startingPoint = currMountLocation;
// Compute pulse size for clearing backlash - just use the last known guide rate
if (m_lastDecGuideRate <= 0)
- m_lastDecGuideRate = GetLastDecGuideRate(); // try it again, maybe the user has since calibrated
+ m_lastDecGuideRate = GetLastDecGuideRate(); // try it again, maybe the user has since calibrated
if (m_lastDecGuideRate > 0)
{
- m_pulseWidth = BACKLASH_EXPECTED_DISTANCE * 1.25 / m_lastDecGuideRate; // px/px_per_ms, bump it to sidestep near misses
+ m_pulseWidth =
+ BACKLASH_EXPECTED_DISTANCE * 1.25 / m_lastDecGuideRate; // px/px_per_ms, bump it to sidestep near misses
m_acceptedMoves = 0;
m_lastClearRslt = 0;
m_cumClearingDistance = 0;
m_backlashExemption = false;
m_Rslt = MEASUREMENT_VALID;
- // Get this state machine in synch with the guider state machine - let it drive us, starting with backlash clearing step
+ // Get this state machine in synch with the guider state machine - let it drive us, starting with backlash
+ // clearing step
m_bltState = BLT_STATE_CLEAR_NORTH;
m_scope->SetGuidingEnabled(true);
- pFrame->pGuider->EnableMeasurementMode(true); // Measurement results now come to us
+ pFrame->pGuider->EnableMeasurementMode(true); // Measurement results now come to us
}
else
{
@@ -937,7 +942,8 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
{
// Get things moving with the first clearing pulse
Debug.Write(wxString::Format("BLT starting North backlash clearing using pulse width of %d,"
- " looking for moves >= %d px\n", m_pulseWidth, BACKLASH_EXPECTED_DISTANCE));
+ " looking for moves >= %d px\n",
+ m_pulseWidth, BACKLASH_EXPECTED_DISTANCE));
pFrame->ScheduleAxisMove(m_scope, NORTH, m_pulseWidth, MOVEOPTS_CALIBRATION_MOVE);
m_stepCount = 1;
m_lastStatus = wxString::Format(_("Clearing North backlash, step %d"), m_stepCount);
@@ -946,40 +952,45 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
}
if (fabs(decDelta) >= BACKLASH_EXPECTED_DISTANCE)
{
- if (m_acceptedMoves == 0 || (m_lastClearRslt * decDelta) > 0) // Just starting or still moving in same direction
+ if (m_acceptedMoves == 0 || (m_lastClearRslt * decDelta) > 0) // Just starting or still moving in same direction
{
m_acceptedMoves++;
Debug.Write(wxString::Format("BLT accepted clearing move of %0.2f\n", decDelta));
}
else
{
- m_acceptedMoves = 0; // Reset on a direction reversal
+ m_acceptedMoves = 0; // Reset on a direction reversal
Debug.Write(wxString::Format("BLT rejected clearing move of %0.2f, direction reversal\n", decDelta));
}
}
else
Debug.Write(wxString::Format("BLT backlash clearing move of %0.2f px was not large enough\n", decDelta));
- if (m_acceptedMoves < BACKLASH_MIN_COUNT) // More work to do
+ if (m_acceptedMoves < BACKLASH_MIN_COUNT) // More work to do
{
if (m_stepCount < MAX_CLEARING_STEPS)
{
if (fabs(m_cumClearingDistance) > BACKLASH_EXEMPTION_DISTANCE)
{
- // We moved the mount a substantial distance north but the individual moves were too small - probably a bad calibration,
- // so let the user proceed with backlash measurement before we push the star too far
- Debug.Write(wxString::Format("BLT: Cum backlash of %0.2f px is at least half of expected, continue with backlash measurement\n", m_cumClearingDistance));
+ // We moved the mount a substantial distance north but the individual moves were too small - probably a
+ // bad calibration, so let the user proceed with backlash measurement before we push the star too far
+ Debug.Write(wxString::Format(
+ "BLT: Cum backlash of %0.2f px is at least half of expected, continue with backlash measurement\n",
+ m_cumClearingDistance));
m_backlashExemption = true;
}
else
{
- if (!OutOfRoom(pCamera->FullSize, currentCamLoc.X, currentCamLoc.Y, pFrame->pGuider->GetMaxMovePixels()))
+ if (!OutOfRoom(
+ pCamera->FullSize, currentCamLoc.X, currentCamLoc.Y, pFrame->pGuider->GetMaxMovePixels()))
{
pFrame->ScheduleAxisMove(m_scope, NORTH, m_pulseWidth, MOVEOPTS_CALIBRATION_MOVE);
m_stepCount++;
m_markerPoint = currMountLocation;
m_lastClearRslt = decDelta;
- m_lastStatus = wxString::Format(_("Clearing North backlash, step %d (up to limit of %d)"), m_stepCount, MAX_CLEARING_STEPS);
- m_lastStatusDebug = wxString::Format("Clearing North backlash, step %d (up to limit of %d)", m_stepCount, MAX_CLEARING_STEPS);
+ m_lastStatus = wxString::Format(
+ _("Clearing North backlash, step %d (up to limit of %d)"), m_stepCount, MAX_CLEARING_STEPS);
+ m_lastStatusDebug = wxString::Format(
+ "Clearing North backlash, step %d (up to limit of %d)", m_stepCount, MAX_CLEARING_STEPS);
Debug.Write(wxString::Format("BLT: %s, LastDecDelta = %0.2f px\n", m_lastStatusDebug, decDelta));
break;
}
@@ -989,22 +1000,25 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
{
m_lastStatus = _("Could not clear North backlash - test failed");
m_Rslt = MEASUREMENT_BL_NOT_CLEARED;
- throw (wxString("BLT: Could not clear north backlash"));
+ throw(wxString("BLT: Could not clear north backlash"));
}
}
- if (m_acceptedMoves >= BACKLASH_MIN_COUNT || m_backlashExemption || OutOfRoom(pCamera->FullSize, currentCamLoc.X, currentCamLoc.Y, pFrame->pGuider->GetMaxMovePixels())) // Ok to go ahead with actual backlash measurement
+ if (m_acceptedMoves >= BACKLASH_MIN_COUNT || m_backlashExemption ||
+ OutOfRoom(pCamera->FullSize, currentCamLoc.X, currentCamLoc.Y,
+ pFrame->pGuider->GetMaxMovePixels())) // Ok to go ahead with actual backlash measurement
{
m_bltState = BLT_STATE_STEP_NORTH;
double totalBacklashCleared = m_stepCount * m_pulseWidth;
- // Want to move the mount North at >=500 ms, regardless of image scale. But reduce pulse width if it would exceed 80% of the tracking rectangle -
- // need to leave some room for seeing deflections and dec drift
- m_pulseWidth = wxMax((int)NORTH_PULSE_SIZE, m_scope->GetCalibrationDuration());
- m_pulseWidth = wxMin(m_pulseWidth, (int)floor(0.7 * (double)pFrame->pGuider->GetMaxMovePixels() / m_lastDecGuideRate));
+ // Want to move the mount North at >=500 ms, regardless of image scale. But reduce pulse width if it would
+ // exceed 80% of the tracking rectangle - need to leave some room for seeing deflections and dec drift
+ m_pulseWidth = wxMax((int) NORTH_PULSE_SIZE, m_scope->GetCalibrationDuration());
+ m_pulseWidth =
+ wxMin(m_pulseWidth, (int) floor(0.7 * (double) pFrame->pGuider->GetMaxMovePixels() / m_lastDecGuideRate));
m_stepCount = 0;
- // Move 50% more than the backlash we cleared or >=8 secs, whichever is greater. We want to leave plenty of room
- // for giving South moves time to clear backlash and actually get moving
+ // Move 50% more than the backlash we cleared or >=8 secs, whichever is greater. We want to leave plenty of
+ // room for giving South moves time to clear backlash and actually get moving
m_northPulseCount = wxMax((MAX_NORTH_PULSES + m_pulseWidth - 1) / m_pulseWidth,
- totalBacklashCleared * 1.5 / m_pulseWidth); // Up to 8 secs
+ totalBacklashCleared * 1.5 / m_pulseWidth); // Up to 8 secs
Debug.Write(wxString::Format("BLT: Starting North moves at Dec=%0.2f\n", currMountLocation.Y));
m_msmtStartTime = ::wxGetUTCTimeMillis().GetValue();
@@ -1012,10 +1026,13 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
}
case BLT_STATE_STEP_NORTH:
- if (m_stepCount < m_northPulseCount && !OutOfRoom(pCamera->FullSize, currentCamLoc.X, currentCamLoc.Y, pFrame->pGuider->GetMaxMovePixels()))
+ if (m_stepCount < m_northPulseCount &&
+ !OutOfRoom(pCamera->FullSize, currentCamLoc.X, currentCamLoc.Y, pFrame->pGuider->GetMaxMovePixels()))
{
- m_lastStatus = wxString::Format(_("Moving North for %d ms, step %d / %d"), m_pulseWidth, m_stepCount + 1, m_northPulseCount);
- m_lastStatusDebug = wxString::Format("Moving North for %d ms, step %d / %d", m_pulseWidth, m_stepCount + 1, m_northPulseCount);
+ m_lastStatus = wxString::Format(
+ _("Moving North for %d ms, step %d / %d"), m_pulseWidth, m_stepCount + 1, m_northPulseCount);
+ m_lastStatusDebug =
+ wxString::Format("Moving North for %d ms, step %d / %d", m_pulseWidth, m_stepCount + 1, m_northPulseCount);
double deltaN;
if (m_stepCount >= 1)
{
@@ -1025,9 +1042,10 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
else
{
deltaN = 0;
- m_markerPoint = currMountLocation; // Marker point at start of Dec moves North
+ m_markerPoint = currMountLocation; // Marker point at start of Dec moves North
}
- Debug.Write(wxString::Format("BLT: %s, DecLoc = %0.2f, DeltaDec = %0.2f\n", m_lastStatusDebug, currMountLocation.Y, deltaN));
+ Debug.Write(wxString::Format(
+ "BLT: %s, DecLoc = %0.2f, DeltaDec = %0.2f\n", m_lastStatusDebug, currMountLocation.Y, deltaN));
m_northBLSteps.push_back(currMountLocation.Y);
pFrame->ScheduleAxisMove(m_scope, NORTH, m_pulseWidth, MOVEOPTS_CALIBRATION_MOVE);
m_stepCount++;
@@ -1043,15 +1061,18 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
deltaN = currMountLocation.Y - m_northBLSteps.back();
m_northStats.AddGuideInfo(m_stepCount, deltaN, 0);
}
- Debug.Write(wxString::Format("BLT: North pulses ended at Dec location %0.2f, TotalDecDelta=%0.2f px, LastDeltaDec = %0.2f\n", currMountLocation.Y, decDelta, deltaN));
+ Debug.Write(wxString::Format(
+ "BLT: North pulses ended at Dec location %0.2f, TotalDecDelta=%0.2f px, LastDeltaDec = %0.2f\n",
+ currMountLocation.Y, decDelta, deltaN));
m_northBLSteps.push_back(currMountLocation.Y);
if (m_stepCount < m_northPulseCount)
{
if (m_stepCount < 0.5 * m_northPulseCount)
{
- m_lastStatus = _("Star too close to edge for accurate measurement of backlash. Choose a star farther from the edge.");
+ m_lastStatus = _("Star too close to edge for accurate measurement of backlash. Choose a star farther "
+ "from the edge.");
m_Rslt = MEASUREMENT_TOO_FEW_NORTH;
- throw (wxString("BLT: Too few north moves"));
+ throw(wxString("BLT: Too few north moves"));
}
Debug.Write("BLT: North pulses truncated, too close to frame edge\n");
}
@@ -1064,8 +1085,10 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
case BLT_STATE_STEP_SOUTH:
if (m_stepCount < m_northPulseCount)
{
- m_lastStatus = wxString::Format(_("Moving South for %d ms, step %d / %d"), m_pulseWidth, m_stepCount + 1, m_northPulseCount);
- m_lastStatusDebug = wxString::Format("Moving South for %d ms, step %d / %d", m_pulseWidth, m_stepCount + 1, m_northPulseCount);
+ m_lastStatus = wxString::Format(
+ _("Moving South for %d ms, step %d / %d"), m_pulseWidth, m_stepCount + 1, m_northPulseCount);
+ m_lastStatusDebug =
+ wxString::Format("Moving South for %d ms, step %d / %d", m_pulseWidth, m_stepCount + 1, m_northPulseCount);
Debug.Write(wxString::Format("BLT: %s, DecLoc = %0.2f\n", m_lastStatusDebug, currMountLocation.Y));
m_southBLSteps.push_back(currMountLocation.Y);
pFrame->ScheduleAxisMove(m_scope, SOUTH, m_pulseWidth, MOVEOPTS_CALIBRATION_MOVE);
@@ -1092,25 +1115,26 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
{
case MEASUREMENT_SANITY:
m_lastStatus = _("Dec movements too erratic - test failed");
- throw (wxString("BLT: Calculation failed sanity check"));
+ throw(wxString("BLT: Calculation failed sanity check"));
break;
case MEASUREMENT_TOO_FEW_NORTH:
- // Don't throw an exception - the test was completed but the bl result is not accurate - handle it in the GA UI
+ // Don't throw an exception - the test was completed but the bl result is not accurate - handle it in
+ // the GA UI
break;
case MEASUREMENT_TOO_FEW_SOUTH:
m_lastStatus = _("Mount never established consistent south moves - test failed");
- throw (wxString("BLT: Too few acceptable south moves"));
+ throw(wxString("BLT: Too few acceptable south moves"));
break;
default:
- break;
+ break;
}
}
double sigmaPx;
double sigmaMs;
GetBacklashSigma(&sigmaPx, &sigmaMs);
- Debug.Write(wxString::Format("BLT: Trial backlash amount is %0.2f px, %d ms, sigma = %0.1f px\n", m_backlashResultPx, m_backlashResultMs,
- sigmaPx));
+ Debug.Write(wxString::Format("BLT: Trial backlash amount is %0.2f px, %d ms, sigma = %0.1f px\n",
+ m_backlashResultPx, m_backlashResultMs, sigmaPx));
if (m_backlashResultMs > 0)
{
// Don't push the guide star outside the tracking region
@@ -1118,16 +1142,19 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
{
m_lastStatus = wxString::Format(_("Issuing test backlash correction of %d ms"), m_backlashResultMs);
Debug.Write(m_lastStatus + "\n");
- // This should put us back roughly to where we issued the big North pulse unless the backlash is very large
+ // This should put us back roughly to where we issued the big North pulse unless the backlash is very
+ // large
pFrame->ScheduleAxisMove(m_scope, SOUTH, m_backlashResultMs, MOVEOPTS_CALIBRATION_MOVE);
m_stepCount++;
break;
}
else
{
- int maxFrameMove = (int)floor((double)0.8 * pFrame->pGuider->GetMaxMovePixels() / m_northRate);
- Debug.Write(wxString::Format("BLT: Clearing pulse is very large, issuing max S move of %d\n", maxFrameMove));
- pFrame->ScheduleAxisMove(m_scope, SOUTH, maxFrameMove, MOVEOPTS_CALIBRATION_MOVE); // One more pulse to cycle the state machine
+ int maxFrameMove = (int) floor((double) 0.8 * pFrame->pGuider->GetMaxMovePixels() / m_northRate);
+ Debug.Write(
+ wxString::Format("BLT: Clearing pulse is very large, issuing max S move of %d\n", maxFrameMove));
+ pFrame->ScheduleAxisMove(m_scope, SOUTH, maxFrameMove,
+ MOVEOPTS_CALIBRATION_MOVE); // One more pulse to cycle the state machine
m_stepCount = 0;
// Can't fine-tune the pulse size, just try to restore the star to < MaxMove of error
m_bltState = BLT_STATE_RESTORE;
@@ -1140,29 +1167,33 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
m_stepCount = 0;
// fall through, no need for test pulse
}
-
}
// See how close we came, maybe fine-tune a bit
if (m_bltState == BLT_STATE_TEST_CORRECTION)
{
- Debug.Write(wxString::Format("BLT: Trial backlash pulse resulted in net DecDelta = %0.2f px, Dec Location %0.2f\n", decDelta, currMountLocation.Y));
- tol = TRIAL_TOLERANCE_AS / pFrame->GetCameraPixelScale(); // tolerance in units of px
- if (fabs(decDelta) > tol) // decDelta = (current - markerPoint)
+ Debug.Write(
+ wxString::Format("BLT: Trial backlash pulse resulted in net DecDelta = %0.2f px, Dec Location %0.2f\n",
+ decDelta, currMountLocation.Y));
+ tol = TRIAL_TOLERANCE_AS / pFrame->GetCameraPixelScale(); // tolerance in units of px
+ if (fabs(decDelta) > tol) // decDelta = (current - markerPoint)
{
- double pulse_delta = fabs(currMountLocation.Y - m_endSouth.Y); // How far we moved with the test pulse
- double target_delta = fabs(m_markerPoint.Y - m_endSouth.Y); // How far we needed to go
- if ((m_endSouth.Y - m_markerPoint.Y) * decDelta < 0) // Sign change, went too far
+ double pulse_delta = fabs(currMountLocation.Y - m_endSouth.Y); // How far we moved with the test pulse
+ double target_delta = fabs(m_markerPoint.Y - m_endSouth.Y); // How far we needed to go
+ if ((m_endSouth.Y - m_markerPoint.Y) * decDelta < 0) // Sign change, went too far
{
- //m_backlashResultMs *= target_delta / pulse_delta;
- Debug.Write(wxString::Format("BLT: Nominal backlash value over-shot by %0.2f X\n", target_delta / pulse_delta));
+ // m_backlashResultMs *= target_delta / pulse_delta;
+ Debug.Write(
+ wxString::Format("BLT: Nominal backlash value over-shot by %0.2f X\n", target_delta / pulse_delta));
}
else
{
- Debug.Write(wxString::Format("BLT: Nominal backlash value under-shot by %0.2f X\n", target_delta / pulse_delta));
+ Debug.Write(wxString::Format(
+ "BLT: Nominal backlash value under-shot by %0.2f X\n", target_delta / pulse_delta));
}
}
else
- Debug.Write(wxString::Format("BLT: Nominal backlash pulse resulted in final delta of %0.1f a-s\n", fabs(decDelta) * pFrame->GetCameraPixelScale()));
+ Debug.Write(wxString::Format("BLT: Nominal backlash pulse resulted in final delta of %0.1f a-s\n",
+ fabs(decDelta) * pFrame->GetCameraPixelScale()));
}
m_bltState = BLT_STATE_RESTORE;
@@ -1171,16 +1202,19 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
// fall through
case BLT_STATE_RESTORE:
- // We could be a considerable distance from where we started, so get back close to the starting point without losing the star
+ // We could be a considerable distance from where we started, so get back close to the starting point without losing
+ // the star
if (m_stepCount == 0)
{
- Debug.Write(wxString::Format("BLT: Starting Dec position at %0.2f, Ending Dec position at %0.2f\n", m_markerPoint.Y, currMountLocation.Y));
+ Debug.Write(wxString::Format("BLT: Starting Dec position at %0.2f, Ending Dec position at %0.2f\n",
+ m_markerPoint.Y, currMountLocation.Y));
amt = fabs(currMountLocation.Y - m_startingPoint.Y);
- if (amt > pFrame->pGuider->GetMaxMovePixels()) // Too big, try to move guide star closer to starting position
+ if (amt > pFrame->pGuider->GetMaxMovePixels()) // Too big, try to move guide star closer to starting position
{
- m_restoreCount = (int)floor((amt / m_northRate) / m_pulseWidth);
- m_restoreCount = wxMin(m_restoreCount, 10); // Don't spend forever at it, something probably went wrong
- Debug.Write(wxString::Format("BLT: Final restore distance is %0.1f px, approx %d steps\n", amt, m_restoreCount));
+ m_restoreCount = (int) floor((amt / m_northRate) / m_pulseWidth);
+ m_restoreCount = wxMin(m_restoreCount, 10); // Don't spend forever at it, something probably went wrong
+ Debug.Write(
+ wxString::Format("BLT: Final restore distance is %0.1f px, approx %d steps\n", amt, m_restoreCount));
m_stepCount = 0;
}
else
@@ -1203,9 +1237,9 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
m_lastStatus = _("Measurement complete");
CleanUp();
m_bltState = BLT_STATE_COMPLETED;
- break; // This will cycle the guider state machine and get normal guiding going
+ break; // This will cycle the guider state machine and get normal guiding going
- case BLT_STATE_COMPLETED: // Shouldn't happen
+ case BLT_STATE_COMPLETED: // Shouldn't happen
break;
case BLT_STATE_ABORTED:
@@ -1213,12 +1247,12 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
Debug.Write("BLT: measurement process halted by user or by error\n");
CleanUp();
break;
- } // end of switch on state
+ } // end of switch on state
}
catch (const wxString& msg)
{
POSSIBLY_UNUSED(msg);
- Debug.Write(wxString::Format("BLT: Exception thrown in logical state %d\n", (int)m_bltState));
+ Debug.Write(wxString::Format("BLT: Exception thrown in logical state %d\n", (int) m_bltState));
m_bltState = BLT_STATE_ABORTED;
Debug.Write("BLT: " + m_lastStatus + "\n");
CleanUp();
@@ -1227,7 +1261,7 @@ void BacklashTool::DecMeasurementStep(const PHD_Point& currentCamLoc)
Debug.Write("BLT: Exiting DecMeasurementStep\n");
}
-void BacklashTool::GetBacklashSigma(double* SigmaPx, double* SigmaMs)
+void BacklashTool::GetBacklashSigma(double *SigmaPx, double *SigmaMs)
{
if ((m_Rslt == MEASUREMENT_VALID || m_Rslt == BacklashTool::MEASUREMENT_TOO_FEW_NORTH) && m_northStats.GetCount() > 1)
{
@@ -1245,7 +1279,8 @@ void BacklashTool::GetBacklashSigma(double* SigmaPx, double* SigmaMs)
}
// Launch modal dlg to show backlash test
-void BacklashTool::ShowGraph(wxDialog *pGA, const std::vector &northSteps, const std::vector &southSteps, int PulseSize)
+void BacklashTool::ShowGraph(
+ wxDialog *pGA, const std::vector& northSteps, const std::vector& southSteps, int PulseSize)
{
BacklashGraph dlg(pGA, northSteps, southSteps, PulseSize);
dlg.ShowModal();
@@ -1253,7 +1288,7 @@ void BacklashTool::ShowGraph(wxDialog *pGA, const std::vector &northStep
void BacklashTool::CleanUp()
{
- m_scope->GetBacklashComp()->ResetBLCState(); // Normal guiding will start, don't want old BC state applied
+ m_scope->GetBacklashComp()->ResetBLCState(); // Normal guiding will start, don't want old BC state applied
pFrame->pGuider->EnableMeasurementMode(false);
Debug.Write("BLT: Cleanup completed\n");
}
diff --git a/src/backlash_comp.h b/src/backlash_comp.h
index 2c79d68b1..3bf7747e2 100644
--- a/src/backlash_comp.h
+++ b/src/backlash_comp.h
@@ -44,7 +44,7 @@ class BLCHistory;
struct RunningStats
{
int count;
- double currentSS; // Sum of squares
+ double currentSS; // Sum of squares
double currentMean;
RunningStats();
@@ -62,7 +62,7 @@ class BacklashTool
int m_acceptedMoves;
double m_lastClearRslt;
double m_lastDecGuideRate;
- double m_backlashResultPx; // units of pixels
+ double m_backlashResultPx; // units of pixels
double m_cumClearingDistance;
bool m_backlashExemption;
int m_backlashResultMs;
@@ -71,8 +71,8 @@ class BacklashTool
PHD_Point m_startingPoint;
PHD_Point m_markerPoint;
PHD_Point m_endSouth;
- wxString m_lastStatus; // Translated for UI
- wxString m_lastStatusDebug; // Always English for debug log
+ wxString m_lastStatus; // Translated for UI
+ wxString m_lastStatusDebug; // Always English for debug log
Scope *m_scope;
std::vector m_northBLSteps;
std::vector m_southBLSteps;
@@ -96,7 +96,7 @@ class BacklashTool
BLT_STATE_COMPLETED
} m_bltState;
- enum MeasurementConstants // To control the behavior of the measurement process
+ enum MeasurementConstants // To control the behavior of the measurement process
{
BACKLASH_MIN_COUNT = 3,
BACKLASH_EXPECTED_DISTANCE = 4,
@@ -104,7 +104,7 @@ class BacklashTool
MAX_CLEARING_STEPS = 100,
NORTH_PULSE_SIZE = 500,
MAX_NORTH_PULSES = 8000,
- TRIAL_TOLERANCE_AS = 2 // arc-secs
+ TRIAL_TOLERANCE_AS = 2 // arc-secs
};
enum MeasurementResults
@@ -117,10 +117,9 @@ class BacklashTool
} m_Rslt;
private:
- MeasurementResults ComputeBacklashPx(double* bltPx, int* bltMs, double* northRate);
+ MeasurementResults ComputeBacklashPx(double *bltPx, int *bltMs, double *northRate);
public:
-
BacklashTool();
~BacklashTool();
void StartMeasurement(double DriftPerMin);
@@ -132,11 +131,11 @@ class BacklashTool
int GetBLTMsmtPulseSize() const { return m_pulseWidth; }
double GetBacklashResultPx() const { return m_backlashResultPx; }
int GetBacklashResultMs() const { return m_backlashResultMs; }
- void GetBacklashSigma(double* SigmaPx, double* SigmaMs);
+ void GetBacklashSigma(double *SigmaPx, double *SigmaMs);
bool GetBacklashExempted() const { return m_backlashExemption; }
wxString GetLastStatus() const { return m_lastStatus; }
void SetBacklashPulse(int amt);
- void ShowGraph(wxDialog *pGA, const std::vector &northSteps, const std::vector &southSteps, int PulseSize);
+ void ShowGraph(wxDialog *pGA, const std::vector& northSteps, const std::vector& southSteps, int PulseSize);
bool IsGraphable();
const std::vector& GetNorthSteps() const { return m_northBLSteps; }
const std::vector& GetSouthSteps() const { return m_southBLSteps; }
@@ -157,7 +156,6 @@ class BacklashComp
void SetCompValues(int requestSize, int floor, int ceiling);
public:
-
BacklashComp(Scope *scope);
~BacklashComp();
diff --git a/src/calibration_assistant.cpp b/src/calibration_assistant.cpp
index c77d4ff80..4f01d99ff 100644
--- a/src/calibration_assistant.cpp
+++ b/src/calibration_assistant.cpp
@@ -1,46 +1,52 @@
/*
-* calibration_assistant.cpp
-* PHD Guiding
-*
-* Created by Bruce Waddington
-* Copyright (c) 2023 Bruce Waddington
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development,
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * calibration_assistant.cpp
+ * PHD Guiding
+ *
+ * Created by Bruce Waddington
+ * Copyright (c) 2023 Bruce Waddington
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development,
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
#include "calibration_assistant.h"
#include "calstep_dialog.h"
#include
-enum {defBestDec = 0, defBestOffset = 5, textWrapPoint = 500, slewSettleTime = 2000};
+enum
+{
+ defBestDec = 0,
+ defBestOffset = 5,
+ textWrapPoint = 500,
+ slewSettleTime = 2000
+};
double const siderealSecsPerSec = 0.9973;
-#define RateX(spd) (spd * 3600.0 / (15.0 * siderealSecsPerSec))
+#define RateX(spd) (spd * 3600.0 / (15.0 * siderealSecsPerSec))
class CalibrationAssistant : public wxDialog
{
@@ -73,8 +79,8 @@ class CalibrationAssistant : public wxDialog
// Methods
void ShowExplanationMsg(double dec);
void ExplainResults(void);
- bool GetCalibPositionRecommendations(int* HA, int* Dec) const;
- void GetCustomLocation(int* PrefHA, int* PrefDec, bool* SingleSide, bool* UsingDefaults) const;
+ bool GetCalibPositionRecommendations(int *HA, int *Dec) const;
+ void GetCustomLocation(int *PrefHA, int *PrefDec, bool *SingleSide, bool *UsingDefaults) const;
void InitializeUI(bool forceDefaults);
void UpdateCurrentPosition(bool fromTimer);
void ShowError(const wxString& msg, bool fatal);
@@ -98,6 +104,7 @@ class CalibrationAssistant : public wxDialog
~CalibrationAssistant();
double GetCalibrationDec();
void LoadCustomPosition(int CustHA, int CustDec);
+
private:
void PerformSanityChecks(void);
GUIDER_STATE m_guiderState;
@@ -108,10 +115,10 @@ class CalibrationAssistant : public wxDialog
class CalAssistSanityDialog : public wxDialog
{
public:
- CalAssistSanityDialog(CalibrationAssistant* Parent, const wxString& msg);
+ CalAssistSanityDialog(CalibrationAssistant *Parent, const wxString& msg);
private:
- CalibrationAssistant* m_parent;
+ CalibrationAssistant *m_parent;
void OnRecal(wxCommandEvent& evt);
void OnCancel(wxCommandEvent& evt);
};
@@ -136,7 +143,7 @@ class CalCustomDialog : public wxDialog
void OnTargetEast(wxCommandEvent& evt);
public:
- CalCustomDialog(CalibrationAssistant* Parent, int DefaultHA, int DefaultDec);
+ CalCustomDialog(CalibrationAssistant *Parent, int DefaultHA, int DefaultDec);
};
// Utility function to add the pairs to a flexgrid
@@ -147,10 +154,11 @@ static void AddTableEntryPair(wxWindow *parent, wxFlexGridSizer *pTable, const w
pTable->Add(pControl, 1, wxALL, 5);
}
-static wxSpinCtrl *NewSpinnerInt(wxWindow *parent, const wxSize& size, int val, int minval, int maxval, int inc,
- const wxString& tooltip)
+static wxSpinCtrl *NewSpinnerInt(
+ wxWindow *parent, const wxSize& size, int val, int minval, int maxval, int inc, const wxString& tooltip)
{
- wxSpinCtrl *pNewCtrl = pFrame->MakeSpinCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, size, wxSP_ARROW_KEYS, minval, maxval, val, _("Exposure time"));
+ wxSpinCtrl *pNewCtrl = pFrame->MakeSpinCtrl(
+ parent, wxID_ANY, wxEmptyString, wxDefaultPosition, size, wxSP_ARROW_KEYS, minval, maxval, val, _("Exposure time"));
pNewCtrl->SetValue(val);
pNewCtrl->SetToolTip(tooltip);
return pNewCtrl;
@@ -164,26 +172,25 @@ static void MakeBold(wxControl *ctrl)
}
CalibrationAssistant::CalibrationAssistant()
- : wxDialog(pFrame, wxID_ANY, _("Calibration Assistant"),
- wxDefaultPosition, wxSize(700, -1), wxCAPTION | wxCLOSE_BOX),
- m_sanityCheckDone(0),
- m_justSlewed(0),
- m_isSlewing(0),
- m_monitoringCalibration(0),
- m_calibrationActive(0)
+ : wxDialog(pFrame, wxID_ANY, _("Calibration Assistant"), wxDefaultPosition, wxSize(700, -1), wxCAPTION | wxCLOSE_BOX)
+ , m_sanityCheckDone(0)
+ , m_justSlewed(0)
+ , m_isSlewing(0)
+ , m_monitoringCalibration(0)
+ , m_calibrationActive(0)
{
- wxStaticBoxSizer* currSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Current Pointing Location"));
- wxStaticBoxSizer* tgtSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Calibration Location"));
- wxFlexGridSizer* currPosSizer = new wxFlexGridSizer(1, 5, 5, 15);
- wxFlexGridSizer* targetPosSizer = new wxFlexGridSizer(1, 5, 5, 15);
+ wxStaticBoxSizer *currSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Current Pointing Location"));
+ wxStaticBoxSizer *tgtSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Calibration Location"));
+ wxFlexGridSizer *currPosSizer = new wxFlexGridSizer(1, 5, 5, 15);
+ wxFlexGridSizer *targetPosSizer = new wxFlexGridSizer(1, 5, 5, 15);
m_pExplanation = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(680, -1), wxALIGN_LEFT);
MakeBold(m_pExplanation);
int textWidth = StringWidth(this, "000000000");
m_pCurrOffset = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(textWidth, -1));
m_pCurrDec = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(textWidth, -1));
- wxStaticBoxSizer* sizerCurrSOP = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Pointing"));
+ wxStaticBoxSizer *sizerCurrSOP = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Pointing"));
m_pCurrWest = new wxRadioButton(this, wxID_ANY, _("West"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
m_pCurrEast = new wxRadioButton(this, wxID_ANY, _("East"));
sizerCurrSOP->Add(m_pCurrWest);
@@ -197,12 +204,15 @@ CalibrationAssistant::CalibrationAssistant()
MakeBold(m_pCurrOffset);
int spinnerWidth = StringWidth(this, "0000");
- m_pTargetDec = NewSpinnerInt(this, wxSize(spinnerWidth, -1), 0, -50, 50, 5, _("Target declination for slew, as close to Dec = 0 as possible for your location (>=-20 and <= 20) recommended"));
+ m_pTargetDec = NewSpinnerInt(this, wxSize(spinnerWidth, -1), 0, -50, 50, 5,
+ _("Target declination for slew, as close to Dec = 0 as possible for your location (>=-20 and <= 20) recommended"));
AddTableEntryPair(this, targetPosSizer, _("Declination"), m_pTargetDec);
- m_pTargetOffset = NewSpinnerInt(this, wxSize(spinnerWidth, -1), 10, 5, 50, 5, _("Target offset from central meridian, in degrees; east or west based on 'Pointing' buttons (less than 15 degrees recommended)"));
+ m_pTargetOffset = NewSpinnerInt(this, wxSize(spinnerWidth, -1), 10, 5, 50, 5,
+ _("Target offset from central meridian, in degrees; east or west based on 'Pointing' buttons (less than 15 degrees "
+ "recommended)"));
AddTableEntryPair(this, targetPosSizer, _("Meridian offset (degrees)"), m_pTargetOffset);
- wxStaticBoxSizer* sizerTargetSOP = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Pointing"));
+ wxStaticBoxSizer *sizerTargetSOP = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Pointing"));
m_pTargetWest = new wxRadioButton(this, wxID_ANY, _("West"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
m_pTargetWest->SetToolTip(_("Scope on the east side of pier, pointing west"));
m_pTargetWest->Bind(wxEVT_COMMAND_RADIOBUTTON_SELECTED, &CalibrationAssistant::OnTargetWest, this);
@@ -214,33 +224,37 @@ CalibrationAssistant::CalibrationAssistant()
targetPosSizer->Add(sizerTargetSOP);
tgtSizer->Add(targetPosSizer);
- wxBoxSizer* midBtnSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *midBtnSizer = new wxBoxSizer(wxHORIZONTAL);
wxButton *pCustomBtn = new wxButton(this, wxID_ANY, _("Save custom values..."));
- pCustomBtn->SetToolTip(_("Save a custom sky location if your site has restricted sky visibility and you can't calibrate at the recommended location"));
+ pCustomBtn->SetToolTip(_("Save a custom sky location if your site has restricted sky visibility and you can't calibrate at "
+ "the recommended location"));
pCustomBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalibrationAssistant::OnCustom, this);
wxButton *pLoadBtn = new wxButton(this, wxID_ANY, _("Load custom values"));
- pLoadBtn->SetToolTip(_("Reload a previously saved custom location and displays its values in the 'Calibration Location' fields"));
+ pLoadBtn->SetToolTip(
+ _("Reload a previously saved custom location and displays its values in the 'Calibration Location' fields"));
pLoadBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalibrationAssistant::OnLoadCustom, this);
- wxButton* pRestoreBtn = new wxButton(this, wxID_ANY, _("Restore defaults"));
+ wxButton *pRestoreBtn = new wxButton(this, wxID_ANY, _("Restore defaults"));
pRestoreBtn->SetToolTip(_("Restore the 'Calibration Location' fields to show the recommended pointing location"));
pRestoreBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalibrationAssistant::OnRestore, this);
midBtnSizer->Add(pLoadBtn, wxSizerFlags().Center().Border(wxALL, 20));
midBtnSizer->Add(pCustomBtn, wxSizerFlags().Center().Border(wxALL, 20));
midBtnSizer->Add(pRestoreBtn, wxSizerFlags().Center().Border(wxALL, 20));
- m_pMessage = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, 75), wxALIGN_CENTER_HORIZONTAL | wxST_NO_AUTORESIZE);
+ m_pMessage = new wxStaticText(
+ this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, 75), wxALIGN_CENTER_HORIZONTAL | wxST_NO_AUTORESIZE);
MakeBold(m_pMessage);
m_pWarning = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, -1), wxALIGN_CENTER_HORIZONTAL);
MakeBold(m_pWarning);
- wxBoxSizer* btnSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
m_pSlewBtn = new wxButton(this, wxID_ANY, _("Slew"));
m_pSlewBtn->SetToolTip(_("Start a slew to the calibration location. BE SURE the scope can be safely slewed"));
m_pSlewBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalibrationAssistant::OnSlew, this);
m_pCalibrateBtn = new wxButton(this, wxID_ANY, _("Calibrate"));
- m_pCalibrateBtn->SetToolTip(_("Start the PHD2 calibration. The Calibration Assistant window will remain open to monitor and assess results"));
+ m_pCalibrateBtn->SetToolTip(
+ _("Start the PHD2 calibration. The Calibration Assistant window will remain open to monitor and assess results"));
m_pCalibrateBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalibrationAssistant::OnCalibrate, this);
- wxButton* pCancelBtn = new wxButton(this, wxID_ANY, _("Cancel"));
+ wxButton *pCancelBtn = new wxButton(this, wxID_ANY, _("Cancel"));
pCancelBtn->SetToolTip(_("Close the Calibration Assistant window. Any calibration currently underway will continue."));
pCancelBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalibrationAssistant::OnCancel, this);
@@ -251,7 +265,7 @@ CalibrationAssistant::CalibrationAssistant()
m_pExplainBtn = new wxButton(this, wxID_ANY, _("Explain"));
m_pExplainBtn->SetToolTip(_("Show additional information about any calibration result that is less than 'good'"));
m_pExplainBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalibrationAssistant::OnExplain, this);
- wxBoxSizer* vSizer = new wxBoxSizer(wxVERTICAL);
+ wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL);
vSizer->Add(m_pExplanation, wxSizerFlags().Center().Border(wxTop, 5).Border(wxLEFT, 20));
vSizer->Add(currSizer, wxSizerFlags().Center().Border(wxALL, 20));
vSizer->Add(tgtSizer, wxSizerFlags().Center());
@@ -261,7 +275,7 @@ CalibrationAssistant::CalibrationAssistant()
vSizer->Add(m_pMessage, wxSizerFlags().Center().Border(wxTOP, 15));
vSizer->Add(btnSizer, wxSizerFlags().Center().Border(wxTOP, 5));
- m_pTimer = new wxTimer(this, wxID_ANY); // asynch updates to current position fields
+ m_pTimer = new wxTimer(this, wxID_ANY); // asynch updates to current position fields
m_pTimer->SetOwner(this);
this->Connect(wxEVT_TIMER, wxTimerEventHandler(CalibrationAssistant::OnTimer), NULL, this);
this->Bind(wxEVT_CLOSE_WINDOW, &CalibrationAssistant::OnClose, this);
@@ -282,7 +296,7 @@ CalibrationAssistant::~CalibrationAssistant()
pFrame->pCalibrationAssistant = NULL;
}
-void CalibrationAssistant::GetCustomLocation(int* PrefHA, int* PrefDec, bool* SingleSide, bool* UsingDefaults) const
+void CalibrationAssistant::GetCustomLocation(int *PrefHA, int *PrefDec, bool *SingleSide, bool *UsingDefaults) const
{
*PrefHA = pConfig->Profile.GetInt("/scope/CalSlew/TgtHA", defBestOffset);
*PrefDec = pConfig->Profile.GetInt("/scope/CalSlew/TgtDec", defBestDec);
@@ -305,7 +319,7 @@ void CalibrationAssistant::PerformSanityChecks(void)
if (!pPointingSource->ValidGuideRates(raSpd, decSpd))
return;
- CalAssistSanityDialog* sanityDlg;
+ CalAssistSanityDialog *sanityDlg;
double minSpd;
double sidRate;
if (decSpd != -1)
@@ -317,24 +331,25 @@ void CalibrationAssistant::PerformSanityChecks(void)
{
if (sidRate <= 0.2)
msg = _("Your mount guide speed is too slow for effective calibration and guiding."
- " Use the hand-controller or mount driver to increase the guide speed to at least 0.5x sidereal."
- " Then click the 'Recalc' button so PHD2 can compute a correct calibration step-size.");
+ " Use the hand-controller or mount driver to increase the guide speed to at least 0.5x sidereal."
+ " Then click the 'Recalc' button so PHD2 can compute a correct calibration step-size.");
else
msg = _("Your mount guide speed is below the minimum recommended value of 0.5x sidereal."
- " Use the hand-controller or mount driver to increase the guide speed to at least 0.5x sidereal."
- " Then click the 'Recalc' button so PHD2 can compute a correct calibration step-size.");
+ " Use the hand-controller or mount driver to increase the guide speed to at least 0.5x sidereal."
+ " Then click the 'Recalc' button so PHD2 can compute a correct calibration step-size.");
}
else
{
- int recDistance = CalstepDialog::GetCalibrationDistance(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning);
+ int recDistance =
+ CalstepDialog::GetCalibrationDistance(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning);
int currStepSize = TheScope()->GetCalibrationDuration();
int recStepSize;
- CalstepDialog::GetCalibrationStepSize(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning, sidRate,
- CalstepDialog::DEFAULT_STEPS, m_currentDec, recDistance, 0, &recStepSize);
- if (fabs(1.0 - (double)currStepSize / (double)recStepSize) > 0.3) // Within 30% is good enough
+ CalstepDialog::GetCalibrationStepSize(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning,
+ sidRate, CalstepDialog::DEFAULT_STEPS, m_currentDec, recDistance, 0, &recStepSize);
+ if (fabs(1.0 - (double) currStepSize / (double) recStepSize) > 0.3) // Within 30% is good enough
{
msg = _("Your current calibration parameters can be adjusted for more accurate results."
- " Click the 'Recalc' button to restore them to the default values.");
+ " Click the 'Recalc' button to restore them to the default values.");
}
}
if (!msg.empty())
@@ -397,7 +412,6 @@ void CalibrationAssistant::TrackCalibration(GUIDER_STATE state)
}
case STATE_STOP:
break;
-
}
}
@@ -460,7 +474,7 @@ void CalibrationAssistant::UpdateCurrentPosition(bool fromTimer)
}
// Return of 'true' means error occurred
-bool CalibrationAssistant::GetCalibPositionRecommendations(int* HA, int* Dec) const
+bool CalibrationAssistant::GetCalibPositionRecommendations(int *HA, int *Dec) const
{
double hourAngle;
int bestDec;
@@ -495,13 +509,13 @@ bool CalibrationAssistant::GetCalibPositionRecommendations(int* HA, int* Dec) co
else if (lat >= 0.)
{
eqAltitude = 90.0 - lat;
- if (eqAltitude < 30.) // far north location
+ if (eqAltitude < 30.) // far north location
bestDec += 30. - eqAltitude;
}
else
{
eqAltitude = 90. + lat;
- if (eqAltitude < 30.) // far south location
+ if (eqAltitude < 30.) // far south location
bestDec -= (30. - eqAltitude);
}
*HA = bestOffset;
@@ -523,7 +537,8 @@ void CalibrationAssistant::ShowExplanationMsg(double dec)
wxString slewCond;
wxString explanation = wxEmptyString;
if (pPointingSource->CanSlew())
- slewCond = _("Use the 'slew' button to move the scope to within 20 degrees of Dec = 0 or as close to that as your site will allow.");
+ slewCond = _("Use the 'slew' button to move the scope to within 20 degrees of Dec = 0 or as close to that as your site "
+ "will allow.");
else
slewCond = _("Slew the scope to within 20 degrees of Dec = 0 or as close to that as your site will allow.");
if (fabs(dec) > 80.)
@@ -532,11 +547,13 @@ void CalibrationAssistant::ShowExplanationMsg(double dec)
}
else if (fabs(dec) > degrees(Scope::DEC_COMP_LIMIT))
{
- explanation = _("If you calibrate within 30 degrees of the pole, you will need to recalibrate when you slew to a different target.")
- + " " + slewCond;
+ explanation = _("If you calibrate within 30 degrees of the pole, you will need to recalibrate when you slew to a "
+ "different target.") +
+ " " + slewCond;
}
else if (fabs(dec) > 20.)
- explanation = _("Calibration will be more accurate with the scope pointing closer to the celestial equator.") + " " + slewCond;
+ explanation =
+ _("Calibration will be more accurate with the scope pointing closer to the celestial equator.") + " " + slewCond;
m_pExplanation->SetLabelText(explanation);
m_pExplanation->Wrap(textWrapPoint);
}
@@ -575,7 +592,8 @@ void CalibrationAssistant::InitializeUI(bool forceDefaults)
}
else
{
- CalibrationAssistant::GetCustomLocation(&bestOffset, &bestDec, &singleSide, &usingDefaults); // Get any custom preferences if present
+ CalibrationAssistant::GetCustomLocation(
+ &bestOffset, &bestDec, &singleSide, &usingDefaults); // Get any custom preferences if present
}
ShowExplanationMsg(dec);
@@ -583,9 +601,9 @@ void CalibrationAssistant::InitializeUI(bool forceDefaults)
m_currentDec = dec;
hourAngle = norm(lst - ra, -12.0, 12.0);
- if (!usingDefaults) // Custom pointing position
+ if (!usingDefaults) // Custom pointing position
{
- if (singleSide) // Use specified E-W orientation
+ if (singleSide) // Use specified E-W orientation
{
if (bestOffset <= 0)
m_pTargetEast->SetValue(true);
@@ -594,7 +612,7 @@ void CalibrationAssistant::InitializeUI(bool forceDefaults)
}
else
{
- if (hourAngle <= 0) // Use same E-W orientation as current pointing position
+ if (hourAngle <= 0) // Use same E-W orientation as current pointing position
m_pTargetEast->SetValue(true);
else
m_pTargetWest->SetValue(true);
@@ -621,7 +639,7 @@ void CalibrationAssistant::InitializeUI(bool forceDefaults)
ShowError(_("Mount can't report its pointing position"), true);
return;
}
- } // end of default handling
+ } // end of default handling
// Current position
m_pCurrOffset->SetValue(wxString::Format("%.1f", abs(hourAngle * 15.0)));
@@ -671,11 +689,13 @@ bool CalibrationAssistant::PerformSlew(double ra, double dec)
{
double ra, dec;
SlewInBg(wxWindow *parent, double ra_, double dec_)
- : RunInBg(parent, _("Slew"), _("Slewing...")), ra(ra_), dec(dec_)
+ : RunInBg(parent, _("Slew"), _("Slewing..."))
+ , ra(ra_)
+ , dec(dec_)
{
SetPopupDelay(100);
}
- bool Entry() //wxWidgets background thread method
+ bool Entry() // wxWidgets background thread method
{
bool err = pPointingSource->SlewToCoordinatesAsync(ra, dec);
if (err)
@@ -698,8 +718,10 @@ bool CalibrationAssistant::PerformSlew(double ra, double dec)
};
SlewInBg bg(this, ra, dec);
m_isSlewing = true;
- // Additional 2-sec delays are used here because some mount controllers report slew-completions before the mount has completely stopped moving - for example with behind-the-scenes clearing of RA backlash
- // Starting a calibration before everything has settled will produce a bad result. The forced delays are simply an extra safety margin to reduce the likelihood of this happening.
+ // Additional 2-sec delays are used here because some mount controllers report slew-completions before the mount has
+ // completely stopped moving - for example with behind-the-scenes clearing of RA backlash Starting a calibration before
+ // everything has settled will produce a bad result. The forced delays are simply an extra safety margin to reduce the
+ // likelihood of this happening.
if (bg.Run())
{
m_isSlewing = false;
@@ -763,16 +785,17 @@ void CalibrationAssistant::OnSlew(wxCommandEvent& evt)
m_pSlewBtn->Enable(false);
m_pCalibrateBtn->Enable(false);
m_meridianFlipping = (m_pWarning->GetLabelText().Length() > 0);
- Debug.Write(wxString::Format("CalAsst: slew from ra %.2f, dec %.1f to ra %.2f, dec %.1f, M/F = %d\n",
- cur_ra, cur_dec, slew_ra, decSlew, m_meridianFlipping));
- if (decSlew <= cur_dec || m_meridianFlipping) // scope will slew sky-south regardless of north or south hemisphere
+ Debug.Write(wxString::Format("CalAsst: slew from ra %.2f, dec %.1f to ra %.2f, dec %.1f, M/F = %d\n", cur_ra, cur_dec,
+ slew_ra, decSlew, m_meridianFlipping));
+ if (decSlew <= cur_dec || m_meridianFlipping) // scope will slew sky-south regardless of north or south hemisphere
{
ShowStatus(_("Initial slew to approximate position"));
if (!PerformSlew(slew_ra, decSlew - 1.0))
{
ShowStatus(_("Final slew north to pre-clear Dec backlash"));
if (!PerformSlew(slew_ra, decSlew))
- ShowStatus(_("Wait for tracking to stabilize, then click 'Calibrate' to start calibration or 'Cancel' to exit"));
+ ShowStatus(
+ _("Wait for tracking to stabilize, then click 'Calibrate' to start calibration or 'Cancel' to exit"));
}
}
else
@@ -796,11 +819,12 @@ static wxString VectorToString(const wxString& separator, const std::vectorLoadCalibrationDetails(&newDetails);
// See if we already triggered a sanity check alert on this last calibration
- acceptableRslt = (newDetails.lastIssue == CalibrationIssueType::CI_None || newDetails.lastIssue == CalibrationIssueType::CI_Different);
+ acceptableRslt = (newDetails.lastIssue == CalibrationIssueType::CI_None ||
+ newDetails.lastIssue == CalibrationIssueType::CI_Different);
- // RA/Dec rates should be related by cos(dec) but don't check if Dec is too high or Dec guiding is disabled. Also don't check if DecComp
- // is disabled because a Sitech controller might be monkeying around with the apparent rates
+ // RA/Dec rates should be related by cos(dec) but don't check if Dec is too high or Dec guiding is disabled. Also don't
+ // check if DecComp is disabled because a Sitech controller might be monkeying around with the apparent rates
if (newCal.declination != UNKNOWN_DECLINATION && newCal.yRate != CALIBRATION_RATE_UNCALIBRATED &&
fabs(newCal.declination) <= Scope::DEC_COMP_LIMIT && TheScope()->DecCompensationEnabled())
{
double expectedRatio = cos(newCal.declination);
- if (newDetails.raGuideSpeed > 0.) // for mounts that may have different guide speeds on RA and Dec axes
+ if (newDetails.raGuideSpeed > 0.) // for mounts that may have different guide speeds on RA and Dec axes
speedRatio = newDetails.decGuideSpeed / newDetails.raGuideSpeed;
else
speedRatio = 1.0;
actualRatio = newCal.xRate * speedRatio / newCal.yRate;
ratesMeaningful = true;
- debugVals += wxString::Format("Spds: %.1fX,%.1fX, ", RateX(newDetails.raGuideSpeed), RateX(newDetails.decGuideSpeed)) +
- wxString::Format("Dec: %.1f, Rates: %.1f, %.1f, ", degrees(newCal.declination), RateX(newCal.xRate), RateX(newCal.yRate));
+ debugVals +=
+ wxString::Format("Spds: %.1fX,%.1fX, ", RateX(newDetails.raGuideSpeed), RateX(newDetails.decGuideSpeed)) +
+ wxString::Format(
+ "Dec: %.1f, Rates: %.1f, %.1f, ", degrees(newCal.declination), RateX(newCal.xRate), RateX(newCal.yRate));
}
else
debugVals += "Spds: N/A, ";
- goodRslt = (newDetails.raStepCount >= 2 * CAL_ALERT_MINSTEPS || (newDetails.decStepCount >= 2 * CAL_ALERT_MINSTEPS && newDetails.decStepCount > 0)) && // Dec guiding might be disabled
- (newDetails.raStepCount <= 30 || (newDetails.decStepCount <= 30 && newDetails.decStepCount > 0)); // Not too few, not too many
+ goodRslt = (newDetails.raStepCount >= 2 * CAL_ALERT_MINSTEPS ||
+ (newDetails.decStepCount >= 2 * CAL_ALERT_MINSTEPS &&
+ newDetails.decStepCount > 0)) && // Dec guiding might be disabled
+ (newDetails.raStepCount <= 30 ||
+ (newDetails.decStepCount <= 30 && newDetails.decStepCount > 0)); // Not too few, not too many
debugVals += wxString::Format("Steps: %d,%d, ", newDetails.raStepCount, newDetails.decStepCount);
if (!goodRslt)
reasons.push_back(_("Steps"));
// Non-orthogonal RA/Dec axes. Values in Calibration structures are in radians
- double nonOrtho = degrees(fabs(fabs(norm_angle(newCal.xAngle - newCal.yAngle)) - M_PI / 2.)); // Delta from the nearest multiple of 90 degrees
+ double nonOrtho = degrees(
+ fabs(fabs(norm_angle(newCal.xAngle - newCal.yAngle)) - M_PI / 2.)); // Delta from the nearest multiple of 90 degrees
debugVals += wxString::Format("Ortho: %.2f, ", nonOrtho);
if (nonOrtho > 5)
{
@@ -898,13 +929,15 @@ void CalibrationAssistant::EvaluateCalibration(void)
else if (acceptableRslt)
{
{
- ShowStatus(_("Calibration result was acceptable, guiding is active using the new calibration") + "\n" + evalWhy);
+ ShowStatus(
+ _("Calibration result was acceptable, guiding is active using the new calibration") + "\n" + evalWhy);
Debug.Write("CalAsst: acceptable result, " + evalWhy + "\n");
}
}
else
{
- ShowStatus(_("Calibration result was poor, consider re-doing it while following all recommendations") + "\n" + evalWhy);
+ ShowStatus(
+ _("Calibration result was poor, consider re-doing it while following all recommendations") + "\n" + evalWhy);
Debug.Write("CalAsst: poor result, " + evalWhy + "\n");
}
}
@@ -951,7 +984,7 @@ void CalibrationAssistant::OnCalibrate(wxCommandEvent& evt)
if (pFrame->CaptureActive)
pFrame->StopCapturing();
ShowStatus(_("Pre-clearing backlash"));
- if (PerformSlew(m_currentRA, m_currentDec + 2.0 / 60.)) // Status messages generated are handled by PerformSlew
+ if (PerformSlew(m_currentRA, m_currentDec + 2.0 / 60.)) // Status messages generated are handled by PerformSlew
return;
}
m_pSlewBtn->Enable(false);
@@ -973,7 +1006,7 @@ void CalibrationAssistant::OnCalibrate(wxCommandEvent& evt)
void CalibrationAssistant::ExplainResults()
{
- CalAssistExplanationDialog* dlg = new CalAssistExplanationDialog(m_lastResult);
+ CalAssistExplanationDialog *dlg = new CalAssistExplanationDialog(m_lastResult);
dlg->ShowModal();
}
@@ -1001,7 +1034,7 @@ void CalibrationAssistant::OnCancel(wxCommandEvent& evt)
void CalibrationAssistant::OnExplain(wxCommandEvent& evt)
{
- //m_lastResult = "Steps, Rates, Orthogonality, Sky location, Incomplete";
+ // m_lastResult = "Steps, Rates, Orthogonality, Sky location, Incomplete";
ExplainResults();
}
void CalibrationAssistant::OnClose(wxCloseEvent& evt)
@@ -1027,24 +1060,26 @@ void CalibrationAssistant::OnCustom(wxCommandEvent& evt)
if (sideEast)
ha = -ha;
CalCustomDialog custDlg(this, ha, dec);
- custDlg.ShowModal(); // Dialog handles the UI updates
+ custDlg.ShowModal(); // Dialog handles the UI updates
}
-CalCustomDialog::CalCustomDialog(CalibrationAssistant* Parent, int DefaultHA, int DefaultDec)
- : wxDialog(pFrame, wxID_ANY, _("Save Customized Calibration Position"),
- wxDefaultPosition, wxSize(474, -1), wxCAPTION | wxCLOSE_BOX)
+CalCustomDialog::CalCustomDialog(CalibrationAssistant *Parent, int DefaultHA, int DefaultDec)
+ : wxDialog(pFrame, wxID_ANY, _("Save Customized Calibration Position"), wxDefaultPosition, wxSize(474, -1),
+ wxCAPTION | wxCLOSE_BOX)
{
m_Parent = Parent;
- wxStaticBoxSizer* tgtSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Target Position"));
- wxFlexGridSizer* targetPosSizer = new wxFlexGridSizer(1, 5, 5, 15);
+ wxStaticBoxSizer *tgtSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Target Position"));
+ wxFlexGridSizer *targetPosSizer = new wxFlexGridSizer(1, 5, 5, 15);
int spinnerWidth = StringWidth(this, "0000");
- m_pTargetDec = NewSpinnerInt(this, wxSize(spinnerWidth, -1), DefaultDec, -50, 50, 5, _("Target declination for slew, as close to Dec = 0 as possible for your location"));
+ m_pTargetDec = NewSpinnerInt(this, wxSize(spinnerWidth, -1), DefaultDec, -50, 50, 5,
+ _("Target declination for slew, as close to Dec = 0 as possible for your location"));
AddTableEntryPair(this, targetPosSizer, _("Declination"), m_pTargetDec);
- m_pTargetOffset = NewSpinnerInt(this, wxSize(spinnerWidth, -1), abs(DefaultHA), 5, 50, 5, _("Target offset from central meridian, in degrees; east or west based on 'Pointing' buttons"));
+ m_pTargetOffset = NewSpinnerInt(this, wxSize(spinnerWidth, -1), abs(DefaultHA), 5, 50, 5,
+ _("Target offset from central meridian, in degrees; east or west based on 'Pointing' buttons"));
AddTableEntryPair(this, targetPosSizer, _("Meridian offset (degrees)"), m_pTargetOffset);
- wxStaticBoxSizer* sizerTargetSOP = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Pointing"));
+ wxStaticBoxSizer *sizerTargetSOP = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Pointing"));
m_pTargetWest = new wxRadioButton(this, wxID_ANY, _("West"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
m_pTargetWest->SetToolTip(_("Scope on the east side of pier, pointing west"));
m_pTargetWest->Bind(wxEVT_COMMAND_RADIOBUTTON_SELECTED, &CalCustomDialog::OnTargetWest, this);
@@ -1061,26 +1096,28 @@ CalCustomDialog::CalCustomDialog(CalibrationAssistant* Parent, int DefaultHA, in
tgtSizer->Add(targetPosSizer);
m_pEastWestOnly = new wxCheckBox(this, wxID_ANY, wxEmptyString);
- m_pEastWestOnly->SetToolTip(_("Check this if calibration can only be done on a particular side of the meridian because of nearby obstructions"));
+ m_pEastWestOnly->SetToolTip(
+ _("Check this if calibration can only be done on a particular side of the meridian because of nearby obstructions"));
if (m_pTargetWest->GetValue())
m_pEastWestOnly->SetLabelText(_("Western sky only"));
else
m_pEastWestOnly->SetLabelText(_("Eastern sky only"));
- wxStaticText* pMessage = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, -1), wxALIGN_CENTER_HORIZONTAL);
+ wxStaticText *pMessage =
+ new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, -1), wxALIGN_CENTER_HORIZONTAL);
pMessage->SetLabelText(_("If your site location requires a unique sky position for calibration, you can specify it here."));
pMessage->Wrap(textWrapPoint);
MakeBold(pMessage);
- wxBoxSizer* btnSizer = new wxBoxSizer(wxHORIZONTAL);
- wxButton* OkBtn = new wxButton(this, wxID_ANY, _("Ok"));
+ wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxButton *OkBtn = new wxButton(this, wxID_ANY, _("Ok"));
OkBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalCustomDialog::OnOk, this);
- wxButton* cancelBtn = new wxButton(this, wxID_ANY, _("Cancel"));
+ wxButton *cancelBtn = new wxButton(this, wxID_ANY, _("Cancel"));
cancelBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalCustomDialog::OnCancel, this);
btnSizer->Add(OkBtn, wxSizerFlags().Border(wxALL, 20));
btnSizer->Add(cancelBtn, wxSizerFlags().Border(wxALL, 20));
- wxBoxSizer* vSizer = new wxBoxSizer(wxVERTICAL);
+ wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL);
vSizer->Add(tgtSizer, wxSizerFlags().Center());
vSizer->Add(m_pEastWestOnly, wxSizerFlags().Center().Border(wxTOP, 15));
vSizer->Add(pMessage, wxSizerFlags().Center().Border(wxTOP, 15));
@@ -1117,24 +1154,23 @@ void CalCustomDialog::OnTargetEast(wxCommandEvent& evt)
m_pEastWestOnly->SetLabelText(_("Eastern sky only"));
}
-CalAssistSanityDialog::CalAssistSanityDialog(CalibrationAssistant* Parent, const wxString& msg)
- : wxDialog(pFrame, wxID_ANY, _("Calibration Parameters Check"),
- wxDefaultPosition, wxSize(600, -1), wxCAPTION | wxCLOSE_BOX)
+CalAssistSanityDialog::CalAssistSanityDialog(CalibrationAssistant *Parent, const wxString& msg)
+ : wxDialog(pFrame, wxID_ANY, _("Calibration Parameters Check"), wxDefaultPosition, wxSize(600, -1), wxCAPTION | wxCLOSE_BOX)
{
m_parent = Parent;
- wxStaticText* pMessage = new wxStaticText(this, wxID_ANY, msg, wxDefaultPosition, wxSize(600, -1), wxALIGN_LEFT);
+ wxStaticText *pMessage = new wxStaticText(this, wxID_ANY, msg, wxDefaultPosition, wxSize(600, -1), wxALIGN_LEFT);
pMessage->Wrap(textWrapPoint);
MakeBold(pMessage);
- wxBoxSizer* btnSizer = new wxBoxSizer(wxHORIZONTAL);
- wxButton* pRecalBtn = new wxButton(this, wxID_ANY, _("Recalc"));
+ wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxButton *pRecalBtn = new wxButton(this, wxID_ANY, _("Recalc"));
pRecalBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalAssistSanityDialog::OnRecal, this);
- wxButton* cancelBtn = new wxButton(this, wxID_ANY, _("Cancel"));
+ wxButton *cancelBtn = new wxButton(this, wxID_ANY, _("Cancel"));
cancelBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalAssistSanityDialog::OnCancel, this);
btnSizer->Add(pRecalBtn, wxSizerFlags().Border(wxALL, 20));
btnSizer->Add(cancelBtn, wxSizerFlags().Border(wxALL, 20));
- wxBoxSizer* vSizer = new wxBoxSizer(wxVERTICAL);
+ wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL);
vSizer->Add(pMessage, wxSizerFlags().Center().Border(wxTOP, 15).Border(wxLEFT, 20));
vSizer->Add(btnSizer, wxSizerFlags().Center().Border(wxTOP, 15));
@@ -1165,9 +1201,11 @@ void CalAssistSanityDialog::OnRecal(wxCommandEvent& evt)
minSpd = raSpd;
double sidrate = RateX(minSpd);
int calibrationStep;
- int recDistance = CalstepDialog::GetCalibrationDistance(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning);
- CalstepDialog::GetCalibrationStepSize(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning, sidrate,
- CalstepDialog::DEFAULT_STEPS, m_parent->GetCalibrationDec(), recDistance, nullptr, &calibrationStep);
+ int recDistance = CalstepDialog::GetCalibrationDistance(
+ pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning);
+ CalstepDialog::GetCalibrationStepSize(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning,
+ sidrate, CalstepDialog::DEFAULT_STEPS, m_parent->GetCalibrationDec(), recDistance, nullptr,
+ &calibrationStep);
TheScope()->SetCalibrationDuration(calibrationStep);
EndDialog(wxOK);
}
@@ -1176,26 +1214,25 @@ void CalAssistSanityDialog::OnRecal(wxCommandEvent& evt)
}
CalAssistExplanationDialog::CalAssistExplanationDialog(const wxString& Why)
- : wxDialog(pFrame, wxID_ANY, _("Explanation of Results"),
- wxDefaultPosition, wxSize(700, -1), wxCAPTION | wxCLOSE_BOX)
+ : wxDialog(pFrame, wxID_ANY, _("Explanation of Results"), wxDefaultPosition, wxSize(700, -1), wxCAPTION | wxCLOSE_BOX)
{
const int wrapPoint = 550;
const int textHeight = 80;
- wxBoxSizer* vSizer = new wxBoxSizer(wxVERTICAL);
- wxStaticText* pHeader = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(680, textHeight), wxALIGN_LEFT);
+ wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL);
+ wxStaticText *pHeader =
+ new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(680, textHeight), wxALIGN_LEFT);
pHeader->SetLabelText(_("Assuming you have followed all the recommendations of the Calibration Assistant, "
- "the information below can help you identify any remaining problems."
- ));
+ "the information below can help you identify any remaining problems."));
vSizer->Add(pHeader, wxSizerFlags().Center().Border(wxALL, 10));
if (Why.Contains("Steps"))
{
- wxStaticBoxSizer* stepsGrp = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Too Few Steps"));
- wxStaticText* pSteps = new wxStaticText(stepsGrp->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, textHeight), wxALIGN_LEFT);
- pSteps->SetLabelText(_(
- "Calibration was completed with fewer than the desired number of steps. This is usually caused by "
- "changes to binning, focal length, or mount guide speed without using the new-profile-wizard. "
- "Run the wizard to restore the correct calibration parameters."
- ));
+ wxStaticBoxSizer *stepsGrp = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Too Few Steps"));
+ wxStaticText *pSteps = new wxStaticText(
+ stepsGrp->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, textHeight), wxALIGN_LEFT);
+ pSteps->SetLabelText(
+ _("Calibration was completed with fewer than the desired number of steps. This is usually caused by "
+ "changes to binning, focal length, or mount guide speed without using the new-profile-wizard. "
+ "Run the wizard to restore the correct calibration parameters."));
pSteps->Wrap(wrapPoint);
stepsGrp->Add(pSteps, wxSizerFlags().Center().Border(wxALL, 5));
vSizer->Add(stepsGrp, wxSizerFlags().Center().Border(wxALL, 10));
@@ -1203,12 +1240,13 @@ CalAssistExplanationDialog::CalAssistExplanationDialog(const wxString& Why)
if (Why.Contains("Rates"))
{
- wxStaticBoxSizer* ratesGrp = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Unexpected Rates"));
- wxStaticText* pRates = new wxStaticText(ratesGrp->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, textHeight), wxALIGN_LEFT);
- pRates->SetLabelText(_(
- "Measured RA and Dec movements on the camera sensor aren't related by the expected ratio (cos(dec)). This can be caused "
- "by sustantial weight imbalance in Dec or physical resistance to movement because of cables or over-tight gear mesh."
- ));
+ wxStaticBoxSizer *ratesGrp = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Unexpected Rates"));
+ wxStaticText *pRates = new wxStaticText(
+ ratesGrp->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, textHeight), wxALIGN_LEFT);
+ pRates->SetLabelText(_("Measured RA and Dec movements on the camera sensor aren't related by the expected ratio "
+ "(cos(dec)). This can be caused "
+ "by sustantial weight imbalance in Dec or physical resistance to movement because of cables or "
+ "over-tight gear mesh."));
pRates->Wrap(wrapPoint);
ratesGrp->Add(pRates, wxSizerFlags().Center().Border(wxALL, 5));
vSizer->Add(ratesGrp, wxSizerFlags().Center().Border(wxALL, 10));
@@ -1216,13 +1254,13 @@ CalAssistExplanationDialog::CalAssistExplanationDialog(const wxString& Why)
if (Why.Contains("Orthogonality"))
{
- wxStaticBoxSizer* orthGrp = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Orthogonality"));
- wxStaticText* pOrtho = new wxStaticText(orthGrp->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, textHeight), wxALIGN_LEFT);
- pOrtho->SetLabelText(_(
- "The mount is wandering off-target on one axis while PHD2 is measuring movement on the other axis. "
- "This can be caused by large periodic error in RA or polar alignment > 10 arc-min. If the orthogonality "
- "error is very large, the mount is probably not guiding correctly."
- ));
+ wxStaticBoxSizer *orthGrp = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Orthogonality"));
+ wxStaticText *pOrtho = new wxStaticText(
+ orthGrp->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, textHeight), wxALIGN_LEFT);
+ pOrtho->SetLabelText(
+ _("The mount is wandering off-target on one axis while PHD2 is measuring movement on the other axis. "
+ "This can be caused by large periodic error in RA or polar alignment > 10 arc-min. If the orthogonality "
+ "error is very large, the mount is probably not guiding correctly."));
pOrtho->Wrap(wrapPoint);
orthGrp->Add(pOrtho, wxSizerFlags().Center().Border(wxALL, 5));
vSizer->Add(orthGrp, wxSizerFlags().Center().Border(wxALL, 10));
@@ -1230,12 +1268,13 @@ CalAssistExplanationDialog::CalAssistExplanationDialog(const wxString& Why)
if (Why.Contains("Sky location"))
{
- wxStaticBoxSizer* locationGrp = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Sky Location"));
- wxStaticText* pLocation = new wxStaticText(locationGrp->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, textHeight), wxALIGN_LEFT);
- pLocation->SetLabelText(_(
- "Calibration wasn't done with Dec in the range of -20 to +20. Outside that range, measurement errors may degrade the calibration accuracy. "
- "If Dec is outside the range of -60 to +60, declination compensation will not work correctly."
- ));
+ wxStaticBoxSizer *locationGrp = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Sky Location"));
+ wxStaticText *pLocation = new wxStaticText(
+ locationGrp->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, textHeight), wxALIGN_LEFT);
+ pLocation->SetLabelText(
+ _("Calibration wasn't done with Dec in the range of -20 to +20. Outside that range, measurement errors may "
+ "degrade the calibration accuracy. "
+ "If Dec is outside the range of -60 to +60, declination compensation will not work correctly."));
pLocation->Wrap(wrapPoint);
locationGrp->Add(pLocation, wxSizerFlags().Center().Border(wxALL, 5));
vSizer->Add(locationGrp, wxSizerFlags().Center().Border(wxALL, 10));
@@ -1243,19 +1282,20 @@ CalAssistExplanationDialog::CalAssistExplanationDialog(const wxString& Why)
if (Why.Contains("Incomplete"))
{
- wxStaticBoxSizer* failGrp = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Not Enough Movement"));
- wxStaticText* pFail = new wxStaticText(failGrp->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, textHeight), wxALIGN_LEFT);
- pFail->SetLabelText(_(
- "If you saw an alert saying the guide star did not move enough, the mount may not be receiving or handling guide commands. "
- "If you are using an ST-4 guide cable, try replacing it. Otherwise, use the Star-Cross and Manual Guide tools in PHD2 to help "
- "isolate the mechanical problem."
- ));
+ wxStaticBoxSizer *failGrp = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Not Enough Movement"));
+ wxStaticText *pFail = new wxStaticText(
+ failGrp->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(600, textHeight), wxALIGN_LEFT);
+ pFail->SetLabelText(_("If you saw an alert saying the guide star did not move enough, the mount may not be receiving "
+ "or handling guide commands. "
+ "If you are using an ST-4 guide cable, try replacing it. Otherwise, use the Star-Cross and "
+ "Manual Guide tools in PHD2 to help "
+ "isolate the mechanical problem."));
pFail->Wrap(wrapPoint);
failGrp->Add(pFail, wxSizerFlags().Center().Border(wxALL, 5));
vSizer->Add(failGrp, wxSizerFlags().Center().Border(wxALL, 5));
}
- wxButton* okBtn = new wxButton(this, wxID_OK, _("Ok"));
+ wxButton *okBtn = new wxButton(this, wxID_OK, _("Ok"));
vSizer->Add(okBtn, wxSizerFlags().Center().Border(wxALL, 20));
SetAutoLayout(true);
diff --git a/src/calibration_assistant.h b/src/calibration_assistant.h
index 98376c0aa..705278c74 100644
--- a/src/calibration_assistant.h
+++ b/src/calibration_assistant.h
@@ -1,37 +1,37 @@
/*
-* calibration_assistant.h
-* PHD Guiding
-*
-* Created by Bruce Waddington
-* Copyright (c) 2023 Bruce Waddington
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development,
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * calibration_assistant.h
+ * PHD Guiding
+ *
+ * Created by Bruce Waddington
+ * Copyright (c) 2023 Bruce Waddington
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development,
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#ifndef Calilbration_Assistant_h_included
#define Calilbration_Assistant_h_included
diff --git a/src/calreview_dialog.cpp b/src/calreview_dialog.cpp
index f65e02883..8d0336e95 100644
--- a/src/calreview_dialog.cpp
+++ b/src/calreview_dialog.cpp
@@ -1,37 +1,37 @@
/*
-* calreview_dialog.cpp
-* PHD Guiding
-*
-* Created by Bruce Waddington
-* Copyright (c) 2015 Bruce Waddington
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development,
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * calreview_dialog.cpp
+ * PHD Guiding
+ *
+ * Created by Bruce Waddington
+ * Copyright (c) 2015 Bruce Waddington
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development,
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
#include "calreview_dialog.h"
@@ -47,11 +47,9 @@ wxEND_EVENT_TABLE();
#define NA_STR _("N/A")
#define CALREVIEW_BITMAP_SIZE 250
-CalReviewDialog::CalReviewDialog( )
-{
-}
+CalReviewDialog::CalReviewDialog() { }
-CalReviewDialog::CalReviewDialog(wxFrame* parent, const wxString& caption)
+CalReviewDialog::CalReviewDialog(wxFrame *parent, const wxString& caption)
{
m_childDialog = false;
Create(parent, caption);
@@ -64,12 +62,12 @@ CalReviewDialog::~CalReviewDialog()
}
// Separated from constructor because derived classes may override functions used to populate the UI
-bool CalReviewDialog::Create(wxWindow* parent, const wxString& caption, const wxWindowID& id, const wxPoint& pos,
- const wxSize& size, long style)
+bool CalReviewDialog::Create(
+ wxWindow *parent, const wxString& caption, const wxWindowID& id, const wxPoint& pos, const wxSize& size, long style)
{
- SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
- wxDialog::Create( parent, id, caption, pos, size, style );
+ SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
+ wxDialog::Create(parent, id, caption, pos, size, style);
CreateControls();
GetSizer()->Fit(this);
@@ -80,13 +78,14 @@ bool CalReviewDialog::Create(wxWindow* parent, const wxString& caption, const wx
void CalReviewDialog::CreateControls()
{
- CalReviewDialog* parent = this;
- wxBoxSizer* topVSizer = new wxBoxSizer(wxVERTICAL);
+ CalReviewDialog *parent = this;
+ wxBoxSizer *topVSizer = new wxBoxSizer(wxVERTICAL);
parent->SetSizer(topVSizer);
- wxNotebook* calibNotebook = new wxNotebook(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);
+ wxNotebook *calibNotebook = new wxNotebook(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);
- wxPanel* panelMount = new wxPanel(calibNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTAB_TRAVERSAL);
+ wxPanel *panelMount =
+ new wxPanel(calibNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTAB_TRAVERSAL);
CreatePanel(panelMount, false);
panelMount->SetBackgroundColour("BLACK");
@@ -95,22 +94,20 @@ void CalReviewDialog::CreateControls()
// Build the AO panel only if an AO is configured
if (pSecondaryMount)
{
- wxPanel* panelAO = new wxPanel(calibNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTAB_TRAVERSAL);
+ wxPanel *panelAO =
+ new wxPanel(calibNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTAB_TRAVERSAL);
CreatePanel(panelAO, true);
panelAO->SetBackgroundColour("BLACK");
calibNotebook->AddPage(panelAO, _("AO"));
}
- topVSizer->Add(calibNotebook, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
- AddButtons(this, topVSizer); // virtual function
+ topVSizer->Add(calibNotebook, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+ AddButtons(this, topVSizer); // virtual function
}
-// Base class version of buttons - subclasses can put their own buttons if needed. No buttons for the base class because it is non-modal -
-// but the window close event is hooked in order to force a destroy() and null of the global pointer
-void CalReviewDialog::AddButtons(CalReviewDialog* parentDialog, wxBoxSizer* parentVSizer)
-{
-
-}
+// Base class version of buttons - subclasses can put their own buttons if needed. No buttons for the base class because it is
+// non-modal - but the window close event is hooked in order to force a destroy() and null of the global pointer
+void CalReviewDialog::AddButtons(CalReviewDialog *parentDialog, wxBoxSizer *parentVSizer) { }
// Populate one of the panels in the wxNotebook
void CalReviewDialog::CreatePanel(wxPanel *thisPanel, bool AO)
@@ -148,11 +145,11 @@ void CalReviewDialog::CreatePanel(wxPanel *thisPanel, bool AO)
// Done with left-hand side
// Now put the data grid(s) on the right side
thisPanel->SetForegroundColour("WHITE");
- CreateDataGrids(thisPanel, panelHSizer, AO); // Virtual function
+ CreateDataGrids(thisPanel, panelHSizer, AO); // Virtual function
}
// Base class version builds data grids showing last calibration details and calibration "context"
-void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSizer, bool AO)
+void CalReviewDialog::CreateDataGrids(wxPanel *parentPanel, wxSizer *parentHSizer, bool AO)
{
const double siderealSecondPerSec = 0.9973;
const double siderealRate = 15.0 * siderealSecondPerSec;
@@ -172,7 +169,7 @@ void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
Calibration calBaseline;
mount->GetLastCalibration(&calBaseline);
- wxBoxSizer* panelGridVSizer = new wxBoxSizer(wxVERTICAL);
+ wxBoxSizer *panelGridVSizer = new wxBoxSizer(wxVERTICAL);
parentHSizer->Add(panelGridVSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
int row = 0;
@@ -181,12 +178,13 @@ void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
bool validBaselineDeclination = calBaseline.declination != UNKNOWN_DECLINATION;
// Build the upper frame and grid for data from the last calibration
- wxStaticBox* staticBoxLastCal = new wxStaticBox(parentPanel, wxID_ANY, _("Last Mount Calibration"));
+ wxStaticBox *staticBoxLastCal = new wxStaticBox(parentPanel, wxID_ANY, _("Last Mount Calibration"));
if (AO)
staticBoxLastCal->SetLabelText(_("Last AO Calibration"));
- wxStaticBoxSizer* calibFrame = new wxStaticBoxSizer(staticBoxLastCal, wxVERTICAL | wxEXPAND);
+ wxStaticBoxSizer *calibFrame = new wxStaticBoxSizer(staticBoxLastCal, wxVERTICAL | wxEXPAND);
panelGridVSizer->Add(calibFrame, 0, wxALIGN_LEFT | wxALL, 5);
- wxGrid* calGrid = new wxGrid(parentPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL);
+ wxGrid *calGrid =
+ new wxGrid(parentPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL);
calGrid->SetColLabelSize(0);
calGrid->SetRowLabelSize(0);
if (!AO)
@@ -225,8 +223,10 @@ void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
if (validDetails && calDetails.raGuideSpeed > 0.0)
{
- guideRaSiderealX = calDetails.raGuideSpeed * 3600.0 / siderealRate; // Degrees/sec to Degrees/hour, 15 degrees/hour is roughly sidereal rate
- guideDecSiderealX = calDetails.decGuideSpeed * 3600.0 / siderealRate; // Degrees/sec to Degrees/hour, 15 degrees/hour is roughly sidereal rate
+ guideRaSiderealX = calDetails.raGuideSpeed * 3600.0 /
+ siderealRate; // Degrees/sec to Degrees/hour, 15 degrees/hour is roughly sidereal rate
+ guideDecSiderealX = calDetails.decGuideSpeed * 3600.0 /
+ siderealRate; // Degrees/sec to Degrees/hour, 15 degrees/hour is roughly sidereal rate
}
wxString ARCSECPERSEC(_("a-s/sec"));
@@ -240,10 +240,12 @@ void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
else
calGrid->SetCellValue(row, col++, _("X rate:"));
if (validDetails)
- calGrid->SetCellValue(row, col++, wxString::Format("%0.3f %s\n%0.3f %s", calBaseline.xRate * 1000 * calDetails.imageScale, ARCSECPERSEC,
- calBaseline.xRate * 1000, PXPERSEC));
+ calGrid->SetCellValue(row, col++,
+ wxString::Format("%0.3f %s\n%0.3f %s", calBaseline.xRate * 1000 * calDetails.imageScale, ARCSECPERSEC,
+ calBaseline.xRate * 1000, PXPERSEC));
else
- calGrid->SetCellValue(row, col++, wxString::Format("%0.3f %s", calBaseline.xRate * 1000, PXPERSEC)); // just px/sec with no image scale data
+ calGrid->SetCellValue(row, col++,
+ wxString::Format("%0.3f %s", calBaseline.xRate * 1000, PXPERSEC)); // just px/sec with no image scale data
if (!AO)
calGrid->SetCellValue(row, col++, _("Dec rate:"));
else
@@ -251,10 +253,12 @@ void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
if (calBaseline.yRate != CALIBRATION_RATE_UNCALIBRATED)
{
if (validDetails)
- calGrid->SetCellValue(row, col++, wxString::Format("%0.3f %s\n%0.3f %s", calBaseline.yRate * 1000 * calDetails.imageScale, ARCSECPERSEC,
- calBaseline.yRate * 1000, PXPERSEC));
+ calGrid->SetCellValue(row, col++,
+ wxString::Format("%0.3f %s\n%0.3f %s", calBaseline.yRate * 1000 * calDetails.imageScale, ARCSECPERSEC,
+ calBaseline.yRate * 1000, PXPERSEC));
else
- calGrid->SetCellValue(row, col++, wxString::Format("%0.3f %s", calBaseline.yRate * 1000, PXPERSEC)); // just px/sec with no image scale data
+ calGrid->SetCellValue(row, col++,
+ wxString::Format("%0.3f %s", calBaseline.yRate * 1000, PXPERSEC)); // just px/sec with no image scale data
}
else
calGrid->SetCellValue(row, col++, NA_STR);
@@ -286,7 +290,7 @@ void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
row++;
col = 0;
calGrid->SetCellValue(row, col++, _("Binning:"));
- calGrid->SetCellValue(row, col++, wxString::Format("%d", (int)calBaseline.binning));
+ calGrid->SetCellValue(row, col++, wxString::Format("%d", (int) calBaseline.binning));
calGrid->SetCellValue(row, col++, _("Created:"));
calGrid->SetCellValue(row, col++, validDetails ? calDetails.origTimestamp : _("Unknown"));
@@ -295,22 +299,24 @@ void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
row++;
col = 0;
calGrid->SetCellValue(row, col++, _("Side of pier:"));
- wxString side = calDetails.origPierSide == PIER_SIDE_EAST ? _("East") :
- calDetails.origPierSide == PIER_SIDE_WEST ? _("West") : NA_STR;
+ wxString side = calDetails.origPierSide == PIER_SIDE_EAST ? _("East")
+ : calDetails.origPierSide == PIER_SIDE_WEST ? _("West")
+ : NA_STR;
calGrid->SetCellValue(row, col++, side);
}
calGrid->AutoSize();
calibFrame->Add(calGrid, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
- if (!AO) // Don't put this mount-related data on the AO panel
+ if (!AO) // Don't put this mount-related data on the AO panel
{
// Build the upper frame and grid for configuration data
- wxStaticBox* staticBoxMount = new wxStaticBox(parentPanel, wxID_ANY, _("Mount Configuration"));
- wxStaticBoxSizer* configFrame = new wxStaticBoxSizer(staticBoxMount, wxVERTICAL);
+ wxStaticBox *staticBoxMount = new wxStaticBox(parentPanel, wxID_ANY, _("Mount Configuration"));
+ wxStaticBoxSizer *configFrame = new wxStaticBoxSizer(staticBoxMount, wxVERTICAL);
panelGridVSizer->Add(configFrame, 0, wxALIGN_LEFT | wxALL, 5);
- wxGrid* cfgGrid = new wxGrid(parentPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL);
+ wxGrid *cfgGrid =
+ new wxGrid(parentPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL);
row = 0;
col = 0;
cfgGrid->SetColLabelSize(0);
@@ -330,21 +336,23 @@ void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
cfgGrid->SetCellValue(row, col++, _("Image scale:"));
if (validDetails)
{
- wxString binning = wxString::Format(_("Binning: %d"), (int)calDetails.origBinning); // Always binning used in actual calibration
+ wxString binning =
+ wxString::Format(_("Binning: %d"), (int) calDetails.origBinning); // Always binning used in actual calibration
cfgGrid->SetCellValue(row, col++, wxString::Format("%0.2f %s\n%s", calDetails.imageScale, ARCSECPERPX, binning));
}
else
cfgGrid->SetCellValue(row, col++, NA_STR);
cfgGrid->SetCellValue(row, col++, _("Side-of-pier:"));
- wxString sPierSide = calBaseline.pierSide == PIER_SIDE_EAST ? _("East") :
- calBaseline.pierSide == PIER_SIDE_WEST ? _("West") : NA_STR;
+ wxString sPierSide = calBaseline.pierSide == PIER_SIDE_EAST ? _("East")
+ : calBaseline.pierSide == PIER_SIDE_WEST ? _("West")
+ : NA_STR;
cfgGrid->SetCellValue(row, col++, _(sPierSide));
row++;
col = 0;
cfgGrid->SetCellValue(row, col++, _("RA Guide speed:"));
- if (guideRaSiderealX != -1.0) // Do the RA guide setting
+ if (guideRaSiderealX != -1.0) // Do the RA guide setting
{
cfgGrid->SetCellValue(row, col++, wxString::Format(_("%0.2fx"), guideRaSiderealX));
}
@@ -352,7 +360,7 @@ void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
cfgGrid->SetCellValue(row, col++, NA_STR);
cfgGrid->SetCellValue(row, col++, _("Dec Guide speed:"));
- if (guideDecSiderealX != -1.0) // Do the Dec guide setting
+ if (guideDecSiderealX != -1.0) // Do the Dec guide setting
{
cfgGrid->SetCellValue(row, col++, wxString::Format(_("%0.2fx"), guideDecSiderealX));
}
@@ -370,15 +378,13 @@ void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
{
if (fabs(calBaseline.yRate) > 0.00001 && fabs(calBaseline.xRate / calBaseline.yRate) <= 1.0)
{
- dec = acos(calBaseline.xRate / calBaseline.yRate); // RA_Rate = Dec_Rate * cos(dec)
+ dec = acos(calBaseline.xRate / calBaseline.yRate); // RA_Rate = Dec_Rate * cos(dec)
decEstimated = true;
}
}
cfgGrid->SetCellValue(row, col++, _("Declination"));
- wxString decStr = decEstimated ?
- Mount::DeclinationStrTr(dec, "%0.1f (est)") :
- Mount::DeclinationStrTr(dec, "%0.1f");
+ wxString decStr = decEstimated ? Mount::DeclinationStrTr(dec, "%0.1f (est)") : Mount::DeclinationStrTr(dec, "%0.1f");
cfgGrid->SetCellValue(row, col++, decStr);
cfgGrid->SetCellValue(row, col++, _("Rotator position:"));
@@ -393,7 +399,7 @@ void CalReviewDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
}
}
-#define IntPoint(RealPoint, scaler) wxPoint(wxRound(RealPoint.x * scaler), wxRound(RealPoint.y * scaler))
+#define IntPoint(RealPoint, scaler) wxPoint(wxRound(RealPoint.x *scaler), wxRound(RealPoint.y *scaler))
// Build the calibration "step" graph which will appear on the lefthand side of the panels
wxBitmap CalReviewDialog::CreateGraph(bool AO)
@@ -405,7 +411,7 @@ wxBitmap CalReviewDialog::CreateGraph(bool AO)
if (!pSecondaryMount || AO)
mount = pMount;
else
- mount = pSecondaryMount; // Mount tab, use mount details
+ mount = pSecondaryMount; // Mount tab, use mount details
mount->LoadCalibrationDetails(&calDetails);
@@ -425,7 +431,7 @@ wxBitmap CalReviewDialog::CreateGraph(bool AO)
double scaleFactor;
if (biggestVal > 0.0)
- scaleFactor = ((CALREVIEW_BITMAP_SIZE - 5) / 2) / biggestVal; // Leave room for circular point
+ scaleFactor = ((CALREVIEW_BITMAP_SIZE - 5) / 2) / biggestVal; // Leave room for circular point
else
scaleFactor = 1.0;
@@ -438,8 +444,8 @@ wxBitmap CalReviewDialog::CreateGraph(bool AO)
memDC.SetPen(axisPen);
// Draw the axes
memDC.SetDeviceOrigin(wxCoord(CALREVIEW_BITMAP_SIZE / 2), wxCoord(CALREVIEW_BITMAP_SIZE / 2));
- memDC.DrawLine(-CALREVIEW_BITMAP_SIZE / 2, 0, CALREVIEW_BITMAP_SIZE / 2, 0); // x
- memDC.DrawLine(0, -CALREVIEW_BITMAP_SIZE / 2, 0, CALREVIEW_BITMAP_SIZE / 2); // y
+ memDC.DrawLine(-CALREVIEW_BITMAP_SIZE / 2, 0, CALREVIEW_BITMAP_SIZE / 2, 0); // x
+ memDC.DrawLine(0, -CALREVIEW_BITMAP_SIZE / 2, 0, CALREVIEW_BITMAP_SIZE / 2); // y
if (calDetails.raStepCount > 0)
{
@@ -455,20 +461,22 @@ wxBitmap CalReviewDialog::CreateGraph(bool AO)
// Scale the points, then plot them individually
for (int i = 0; i < (int) calDetails.raSteps.size(); i++)
{
- if (i == calDetails.raStepCount + 2) // Valid even for "single-step" calibration
+ if (i == calDetails.raStepCount + 2) // Valid even for "single-step" calibration
{
- memDC.SetPen(wxPen(raColor, 1)); // 1-pixel-thick outline
- memDC.SetBrush(wxNullBrush); // Outline only for "return" data points
+ memDC.SetPen(wxPen(raColor, 1)); // 1-pixel-thick outline
+ memDC.SetBrush(wxNullBrush); // Outline only for "return" data points
ptRadius = 3;
}
memDC.DrawCircle(IntPoint(calDetails.raSteps.at(i), scaleFactor), ptRadius);
}
// Show the line PHD2 will use for the rate
memDC.SetPen(raPen);
- if ((int)calDetails.raSteps.size() > calDetails.raStepCount) // New calib, includes return values
- memDC.DrawLine(IntPoint(calDetails.raSteps.at(0), scaleFactor), IntPoint(calDetails.raSteps.at(calDetails.raStepCount), scaleFactor));
+ if ((int) calDetails.raSteps.size() > calDetails.raStepCount) // New calib, includes return values
+ memDC.DrawLine(IntPoint(calDetails.raSteps.at(0), scaleFactor),
+ IntPoint(calDetails.raSteps.at(calDetails.raStepCount), scaleFactor));
else
- memDC.DrawLine(IntPoint(calDetails.raSteps.at(0), scaleFactor), IntPoint(calDetails.raSteps.at(calDetails.raStepCount - 1), scaleFactor));
+ memDC.DrawLine(IntPoint(calDetails.raSteps.at(0), scaleFactor),
+ IntPoint(calDetails.raSteps.at(calDetails.raStepCount - 1), scaleFactor));
}
// Handle the Dec data
@@ -478,24 +486,26 @@ wxBitmap CalReviewDialog::CreateGraph(bool AO)
memDC.SetPen(decPen);
memDC.SetBrush(decBrush);
int ptRadius = 2;
- if (calDetails.decStepCount > 0 && calDetails.decSteps.size() > 0) // redundant, protection against old bug
+ if (calDetails.decStepCount > 0 && calDetails.decSteps.size() > 0) // redundant, protection against old bug
{
for (int i = 0; i < (int) calDetails.decSteps.size(); i++)
{
if (i == calDetails.decStepCount + 2)
{
- memDC.SetPen(wxPen(decColor, 1)); // 1-pixel-thick outline
- memDC.SetBrush(wxNullBrush); // Outline only for "return" data points
+ memDC.SetPen(wxPen(decColor, 1)); // 1-pixel-thick outline
+ memDC.SetBrush(wxNullBrush); // Outline only for "return" data points
ptRadius = 3;
}
memDC.DrawCircle(IntPoint(calDetails.decSteps.at(i), scaleFactor), ptRadius);
}
// Show the line PHD2 will use for the rate
memDC.SetPen(decPen);
- if ((int)calDetails.decSteps.size() > calDetails.decStepCount) // New calib, includes return values
- memDC.DrawLine(IntPoint(calDetails.decSteps.at(0), scaleFactor), IntPoint(calDetails.decSteps.at(calDetails.decStepCount), scaleFactor));
+ if ((int) calDetails.decSteps.size() > calDetails.decStepCount) // New calib, includes return values
+ memDC.DrawLine(IntPoint(calDetails.decSteps.at(0), scaleFactor),
+ IntPoint(calDetails.decSteps.at(calDetails.decStepCount), scaleFactor));
else
- memDC.DrawLine(IntPoint(calDetails.decSteps.at(0), scaleFactor), IntPoint(calDetails.decSteps.at(calDetails.decStepCount - 1), scaleFactor));
+ memDC.DrawLine(IntPoint(calDetails.decSteps.at(0), scaleFactor),
+ IntPoint(calDetails.decSteps.at(calDetails.decStepCount - 1), scaleFactor));
}
return bmp;
@@ -519,24 +529,21 @@ void CalReviewDialog::OnCloseWindow(wxCloseEvent& event)
}
// Derived classes from CalibrationRestoreDialog
-// Restore dialog is basically the same as 'Review' except for option to actually restore the old calibration data - plus, it's modal
-CalRestoreDialog::CalRestoreDialog(wxFrame* parent, const wxString& caption)
+// Restore dialog is basically the same as 'Review' except for option to actually restore the old calibration data - plus, it's
+// modal
+CalRestoreDialog::CalRestoreDialog(wxFrame *parent, const wxString& caption)
{
m_childDialog = true;
Create(parent, caption);
}
-void CalRestoreDialog::AddButtons(CalReviewDialog* parentDialog, wxBoxSizer* parentVSizer)
+void CalRestoreDialog::AddButtons(CalReviewDialog *parentDialog, wxBoxSizer *parentVSizer)
{
wxBoxSizer *pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
wxButton *pRestore = new wxButton(parentDialog, wxID_OK, _("Restore"));
pRestore->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalRestoreDialog::OnRestore, this);
- pButtonSizer->Add(
- pRestore,
- wxSizerFlags(0).Align(0).Border(wxRIGHT | wxLEFT | wxBOTTOM, 10));
- pButtonSizer->Add(
- CreateButtonSizer(wxCANCEL),
- wxSizerFlags(0).Align(0).Border(wxRIGHT | wxLEFT | wxBOTTOM, 10));
+ pButtonSizer->Add(pRestore, wxSizerFlags(0).Align(0).Border(wxRIGHT | wxLEFT | wxBOTTOM, 10));
+ pButtonSizer->Add(CreateButtonSizer(wxCANCEL), wxSizerFlags(0).Align(0).Border(wxRIGHT | wxLEFT | wxBOTTOM, 10));
parentVSizer->Add(pButtonSizer, wxSizerFlags(0).Center());
}
@@ -549,8 +556,8 @@ void CalRestoreDialog::OnRestore(wxCommandEvent& event)
}
// CalSanity dialog may get launched as part of an 'alert' if the last calibration looked wonky - this one is non-modal
-CalSanityDialog::CalSanityDialog(wxFrame *parent, const Calibration& oldParams, const CalibrationDetails& oldDetails,
- CalibrationIssueType issue)
+CalSanityDialog::CalSanityDialog(
+ wxFrame *parent, const Calibration& oldParams, const CalibrationDetails& oldDetails, CalibrationIssueType issue)
{
m_pScope = TheScope();
m_pScope->GetLastCalibration(&m_newParams);
@@ -566,7 +573,7 @@ CalSanityDialog::CalSanityDialog(wxFrame *parent, const Calibration& oldParams,
CalSanityDialog::~CalSanityDialog()
{
- pFrame->pCalSanityCheckDlg = NULL; // Clear the global pointer used to launch us
+ pFrame->pCalSanityCheckDlg = NULL; // Clear the global pointer used to launch us
}
static const int MESSAGE_HEIGHT = 100;
@@ -585,24 +592,33 @@ void CalSanityDialog::BuildMessage(wxStaticText *pText, CalibrationIssueType ety
{
case CI_Steps:
msg = _("The calibration was done with a very small number of steps, which can produce inaccurate results. "
- "Consider reducing the size of the calibration step parameter until you see at least 8 steps in each direction. The 'calculator' "
- "feature in the 'Mount' configuration tab can help you with this.");
+ "Consider reducing the size of the calibration step parameter until you see at least 8 steps in each "
+ "direction. The 'calculator' "
+ "feature in the 'Mount' configuration tab can help you with this.");
break;
case CI_Angle:
- msg = wxString::Format(_("The RA and Declination angles computed in the calibration are questionable. Normally, "
- "these angles will be nearly perpendicular, having an 'orthogonality error' of less than 10 degrees. In this calibration, your error was %s degrees, which "
- "is often caused by poor polar alignment, large Dec backlash, or a large periodic error in RA."), m_newAngleDelta);
+ msg =
+ wxString::Format(_("The RA and Declination angles computed in the calibration are questionable. Normally, "
+ "these angles will be nearly perpendicular, having an 'orthogonality error' of less than 10 "
+ "degrees. In this calibration, your error was %s degrees, which "
+ "is often caused by poor polar alignment, large Dec backlash, or a large periodic error in RA."),
+ m_newAngleDelta);
break;
case CI_Different:
- msg = wxString::Format(_("The most recent calibration produced results that are %s%% different from the previous calibration. If this is because "
- "you changed equipment configurations, you may want to use different profiles. Doing so will allow you to switch back "
- "and forth between configurations and still retain earlier settings and calibration results."), m_oldNewDifference);
+ msg = wxString::Format(_("The most recent calibration produced results that are %s%% different from the previous "
+ "calibration. If this is because "
+ "you changed equipment configurations, you may want to use different profiles. Doing so will "
+ "allow you to switch back "
+ "and forth between configurations and still retain earlier settings and calibration results."),
+ m_oldNewDifference);
break;
case CI_Rates:
- msg = wxString::Format(_("The RA and Declination guiding rates differ by an unexpected amount. For your declination of %0.0f degrees, "
- "the RA rate should be about %0.0f%% of the Dec rate. But your RA rate is %0.0f%% of the Dec rate. "
- "This usually means one of the axis calibrations is incorrect and may result in poor guiding."),
- degrees(m_newParams.declination), cos(m_newParams.declination) * 100.0, m_newParams.xRate / m_newParams.yRate * 100.0);
+ msg = wxString::Format(
+ _("The RA and Declination guiding rates differ by an unexpected amount. For your declination of %0.0f degrees, "
+ "the RA rate should be about %0.0f%% of the Dec rate. But your RA rate is %0.0f%% of the Dec rate. "
+ "This usually means one of the axis calibrations is incorrect and may result in poor guiding."),
+ degrees(m_newParams.declination), cos(m_newParams.declination) * 100.0,
+ m_newParams.xRate / m_newParams.yRate * 100.0);
break;
default:
msg = wxString::Format("Just testing");
@@ -612,8 +628,9 @@ void CalSanityDialog::BuildMessage(wxStaticText *pText, CalibrationIssueType ety
pText->Wrap(420);
}
-// Overridden method for building the data grids - these are substantially different from the CalReview base but the overall appearance and graph presence are the same
-void CalSanityDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSizer, bool AO)
+// Overridden method for building the data grids - these are substantially different from the CalReview base but the overall
+// appearance and graph presence are the same
+void CalSanityDialog::CreateDataGrids(wxPanel *parentPanel, wxSizer *parentHSizer, bool AO)
{
wxString raSteps = wxString::Format("%d", m_calDetails.raStepCount);
wxString decSteps = wxString::Format("%d", m_calDetails.decStepCount);
@@ -623,7 +640,7 @@ void CalSanityDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
double imageScale = m_calDetails.imageScale;
bool oldValid = m_oldParams.isValid;
- if (!AO) // AO calibration never triggers sanity check alerts, so don't show that data
+ if (!AO) // AO calibration never triggers sanity check alerts, so don't show that data
{
// Compute the orthogonality stuff
m_newAngleDelta = wxString::Format("%0.1f", m_calDetails.orthoError);
@@ -644,7 +661,8 @@ void CalSanityDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
wxStaticBoxSizer *pMsgGrp = new wxStaticBoxSizer(wxVERTICAL, parentPanel, _("Explanation"));
// Explanation area
- wxStaticText *pMsgArea = new wxStaticText(parentPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(450, -1), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
+ wxStaticText *pMsgArea = new wxStaticText(
+ parentPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(450, -1), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
BuildMessage(pMsgArea, m_issue);
pMsgArea->SetSizeHints(wxSize(450, MESSAGE_HEIGHT));
wxFont font = pMsgArea->GetFont();
@@ -667,7 +685,8 @@ void CalSanityDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
pGrid->SetCellValue(row, col++, raSteps);
pGrid->SetCellValue(row, col++, _("Steps, Dec:"));
pGrid->SetCellValue(row, col++, decSteps);
- if (m_issue == CI_Steps){
+ if (m_issue == CI_Steps)
+ {
if (raSteps <= decSteps)
HighlightCell(pGrid, row, 1);
else
@@ -691,7 +710,8 @@ void CalSanityDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
{
pGrid->SetCellValue(row, col++, _("This declination rate:"));
if (newDecRate != CALIBRATION_RATE_UNCALIBRATED)
- pGrid->SetCellValue(row, col++, wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newDecRate * 1000 * imageScale, newDecRate * 1000));
+ pGrid->SetCellValue(row, col++,
+ wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newDecRate * 1000 * imageScale, newDecRate * 1000));
else
pGrid->SetCellValue(row, col++, NA_STR);
pGrid->SetCellValue(row, col++, _("Previous declination rate:"));
@@ -705,10 +725,12 @@ void CalSanityDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
else
{
pGrid->SetCellValue(row, col++, _("RA rate:"));
- pGrid->SetCellValue(row, col++, wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newRARate * 1000 * imageScale, newRARate * 1000));
+ pGrid->SetCellValue(row, col++,
+ wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newRARate * 1000 * imageScale, newRARate * 1000));
pGrid->SetCellValue(row, col++, _("Declination rate:"));
if (newDecRate != CALIBRATION_RATE_UNCALIBRATED)
- pGrid->SetCellValue(row, col++, wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newDecRate * 1000 * imageScale, newDecRate * 1000));
+ pGrid->SetCellValue(row, col++,
+ wxString::Format(_("%0.3f a-s/sec\n%0.3f px/sec"), newDecRate * 1000 * imageScale, newDecRate * 1000));
else
pGrid->SetCellValue(row, col++, NA_STR);
if (m_issue == CI_Rates)
@@ -728,10 +750,9 @@ void CalSanityDialog::CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSize
pVSizer->Add(m_pBlockThis, wxSizerFlags(0).Border(wxALL, 15));
parentHSizer->Add(pVSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
}
-
}
-void CalSanityDialog::AddButtons(CalReviewDialog* parentDialog, wxBoxSizer* parentVSizer)
+void CalSanityDialog::AddButtons(CalReviewDialog *parentDialog, wxBoxSizer *parentVSizer)
{
wxBoxSizer *pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
@@ -739,26 +760,19 @@ void CalSanityDialog::AddButtons(CalReviewDialog* parentDialog, wxBoxSizer* pare
pIgnore->SetToolTip(_("Accept the calibration as being valid and continue guiding"));
pIgnore->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalSanityDialog::OnIgnore, this);
wxButton *pRecal = new wxButton(this, wxID_ANY, _("Discard calibration"));
- pRecal->SetToolTip(_("Stop guiding and discard the most recent calibration. Calibration will be re-done the next time you start guiding"));
+ pRecal->SetToolTip(_(
+ "Stop guiding and discard the most recent calibration. Calibration will be re-done the next time you start guiding"));
pRecal->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalSanityDialog::OnRecal, this);
wxButton *pRestore = new wxButton(this, wxID_ANY, _("Restore old calibration"));
pRestore->SetToolTip(_("Stop guiding, discard the most recent calibration, then load the previous (good) calibration"));
pRestore->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalSanityDialog::OnRestore, this);
pRestore->Enable(m_oldValid);
- pButtonSizer->Add(
- pIgnore,
- wxSizerFlags(0).Align(0).Border(wxRIGHT | wxLEFT | wxBOTTOM, 10));
- pButtonSizer->Add(
- pRecal,
- wxSizerFlags(0).Align(0).Border(wxRIGHT | wxLEFT | wxBOTTOM, 10));
- pButtonSizer->Add(
- pRestore,
- wxSizerFlags(0).Align(0).Border(wxRIGHT | wxLEFT | wxBOTTOM, 10));
-
- parentVSizer->Add(
- pButtonSizer,
- wxSizerFlags(0).Center());
+ pButtonSizer->Add(pIgnore, wxSizerFlags(0).Align(0).Border(wxRIGHT | wxLEFT | wxBOTTOM, 10));
+ pButtonSizer->Add(pRecal, wxSizerFlags(0).Align(0).Border(wxRIGHT | wxLEFT | wxBOTTOM, 10));
+ pButtonSizer->Add(pRestore, wxSizerFlags(0).Align(0).Border(wxRIGHT | wxLEFT | wxBOTTOM, 10));
+
+ parentVSizer->Add(pButtonSizer, wxSizerFlags(0).Center());
}
void CalSanityDialog::OnIgnore(wxCommandEvent& evt)
diff --git a/src/calreview_dialog.h b/src/calreview_dialog.h
index 95f4c15ec..a501f6300 100644
--- a/src/calreview_dialog.h
+++ b/src/calreview_dialog.h
@@ -1,63 +1,64 @@
/*
-* calreview_dialog.h
-* PHD Guiding
-*
-* Created by Bruce Waddington
-* Copyright (c) 2015 Bruce Waddington
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development,
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * calreview_dialog.h
+ * PHD Guiding
+ *
+ * Created by Bruce Waddington
+ * Copyright (c) 2015 Bruce Waddington
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development,
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#ifndef _CALREVIEW_DIALOG_H_
-#define _CALREVIEW_DIALOG_H_
+# define _CALREVIEW_DIALOG_H_
-#include
+# include
-class CalReviewDialog: public wxDialog
+class CalReviewDialog : public wxDialog
{
wxDECLARE_EVENT_TABLE();
public:
/// Constructors
- CalReviewDialog( );
- CalReviewDialog(wxFrame* parent, const wxString& caption = _("Review Calibration"));
+ CalReviewDialog();
+ CalReviewDialog(wxFrame *parent, const wxString& caption = _("Review Calibration"));
~CalReviewDialog();
protected:
/// Creation
- bool Create(wxWindow* parent, const wxString& caption, const wxWindowID& id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxSize(400, 300), long style = wxCAPTION | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCLOSE_BOX);
+ bool Create(wxWindow *parent, const wxString& caption, const wxWindowID& id = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(400, 300),
+ long style = wxCAPTION | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCLOSE_BOX);
/// Builds the controls and sizers with virtual functions for derived dialogs
virtual void CreateControls();
- virtual void AddButtons(CalReviewDialog* parentDialog, wxBoxSizer* parentVSizer);
- void CreatePanel(wxPanel* thisPanel, bool AO);
- virtual void CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSizer, bool AO);
+ virtual void AddButtons(CalReviewDialog *parentDialog, wxBoxSizer *parentVSizer);
+ void CreatePanel(wxPanel *thisPanel, bool AO);
+ virtual void CreateDataGrids(wxPanel *parentPanel, wxSizer *parentHSizer, bool AO);
wxBitmap CreateGraph(bool AO);
void ShutDown();
void OnCloseWindow(wxCloseEvent& event);
@@ -72,9 +73,10 @@ class CalRestoreDialog : public CalReviewDialog
{
public:
- CalRestoreDialog(wxFrame* parent, const wxString& caption = _("Restore Calibration"));
+ CalRestoreDialog(wxFrame *parent, const wxString& caption = _("Restore Calibration"));
+
private:
- virtual void AddButtons(CalReviewDialog* parentDialog, wxBoxSizer* parentVSizer);
+ virtual void AddButtons(CalReviewDialog *parentDialog, wxBoxSizer *parentVSizer);
void OnRestore(wxCommandEvent& event);
};
@@ -82,13 +84,14 @@ class CalRestoreDialog : public CalReviewDialog
class CalSanityDialog : public CalReviewDialog
{
public:
- CalSanityDialog(wxFrame* parent, const Calibration& oldParams, const CalibrationDetails& oldDetails,
- CalibrationIssueType issue);
+ CalSanityDialog(
+ wxFrame *parent, const Calibration& oldParams, const CalibrationDetails& oldDetails, CalibrationIssueType issue);
~CalSanityDialog();
+
private:
- virtual void AddButtons(CalReviewDialog* parentDialog, wxBoxSizer* parentVSizer);
- virtual void CreateDataGrids(wxPanel* parentPanel, wxSizer* parentHSizer, bool AO);
+ virtual void AddButtons(CalReviewDialog *parentDialog, wxBoxSizer *parentVSizer);
+ virtual void CreateDataGrids(wxPanel *parentPanel, wxSizer *parentHSizer, bool AO);
void OnIgnore(wxCommandEvent& evt);
void OnRecal(wxCommandEvent& evt);
@@ -108,4 +111,4 @@ class CalSanityDialog : public CalReviewDialog
Scope *m_pScope;
};
#endif
- // _CALREVIEW_DIALOG_H_
+// _CALREVIEW_DIALOG_H_
diff --git a/src/calstep_dialog.cpp b/src/calstep_dialog.cpp
index b54cd6fe3..81ada27d3 100644
--- a/src/calstep_dialog.cpp
+++ b/src/calstep_dialog.cpp
@@ -51,14 +51,14 @@
static wxSpinCtrlDouble *NewSpinner(wxWindow *parent, int width, double val, double minval, double maxval, double inc)
{
- wxSpinCtrlDouble *pNewCtrl = pFrame->MakeSpinCtrlDouble(parent, wxID_ANY, _T("foo2"), wxPoint(-1, -1),
- wxSize(width, -1), wxSP_ARROW_KEYS, minval, maxval, val, inc);
+ wxSpinCtrlDouble *pNewCtrl = pFrame->MakeSpinCtrlDouble(
+ parent, wxID_ANY, _T("foo2"), wxPoint(-1, -1), wxSize(width, -1), wxSP_ARROW_KEYS, minval, maxval, val, inc);
pNewCtrl->SetDigits(2);
return pNewCtrl;
}
-CalstepDialog::CalstepDialog(wxWindow *parent, int focalLength, double pixelSize, int binning) :
- wxDialog(parent, wxID_ANY, _("Calibration Calculator"), wxDefaultPosition, wxSize(400, 500), wxCAPTION | wxCLOSE_BOX)
+CalstepDialog::CalstepDialog(wxWindow *parent, int focalLength, double pixelSize, int binning)
+ : wxDialog(parent, wxID_ANY, _("Calibration Calculator"), wxDefaultPosition, wxSize(400, 500), wxCAPTION | wxCLOSE_BOX)
{
double dGuideRateDec = 0.0; // initialize to suppress compiler warning
double dGuideRateRA = 0.0; // initialize to suppress compiler warning
@@ -68,11 +68,11 @@ CalstepDialog::CalstepDialog(wxWindow *parent, int focalLength, double pixelSize
// Get squared away with initial parameter values - start with values from the profile
m_iNumSteps = pConfig->Profile.GetInt("/CalStepCalc/NumSteps", DEFAULT_STEPS);
- m_dDeclination = pConfig->Profile.GetDouble ("/CalStepCalc/CalDeclination", 0.0);
+ m_dDeclination = pConfig->Profile.GetDouble("/CalStepCalc/CalDeclination", 0.0);
m_iFocalLength = focalLength;
m_fPixelSize = pixelSize;
m_binning = binning;
- m_fGuideSpeed = (float) pConfig->Profile.GetDouble ("/CalStepCalc/GuideSpeed", Scope::DEFAULT_MOUNT_GUIDE_SPEED);
+ m_fGuideSpeed = (float) pConfig->Profile.GetDouble("/CalStepCalc/GuideSpeed", Scope::DEFAULT_MOUNT_GUIDE_SPEED);
m_calibrationDistance = pConfig->Profile.GetInt("/scope/CalibrationDistance", DEFAULT_DISTANCE);
// Now improve on Dec and guide speed if mount/pointing info is available
@@ -81,7 +81,8 @@ CalstepDialog::CalstepDialog(wxWindow *parent, int focalLength, double pixelSize
if (!pPointingSource->GetGuideRates(&dGuideRateRA, &dGuideRateDec))
{
if (dGuideRateRA >= dGuideRateDec)
- m_fGuideSpeed = dGuideRateRA * 3600.0 / (15.0 * dSiderealSecondPerSec); // Degrees/sec to Degrees/hour, 15 degrees/hour is roughly sidereal rate
+ m_fGuideSpeed = dGuideRateRA * 3600.0 /
+ (15.0 * dSiderealSecondPerSec); // Degrees/sec to Degrees/hour, 15 degrees/hour is roughly sidereal rate
else
m_fGuideSpeed = dGuideRateDec * 3600.0 / (15.0 * dSiderealSecondPerSec);
@@ -104,21 +105,21 @@ CalstepDialog::CalstepDialog(wxWindow *parent, int focalLength, double pixelSize
m_pInputGroupBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Input Parameters"));
textWidth = StringWidth(this, "00000");
m_pPixelSize = NewSpinner(this, textWidth, m_fPixelSize, MIN_PIXELSIZE, MAX_PIXELSIZE, 0.1);
- m_pPixelSize->GetSize(&spinnerWidth, &spinnerHeight); // Get sizing info from spinner, which will be largest
+ m_pPixelSize->GetSize(&spinnerWidth, &spinnerHeight); // Get sizing info from spinner, which will be largest
// Focal length - any positive int
- wxIntegerValidator valFocalLength (&m_iFocalLength, 0);
+ wxIntegerValidator valFocalLength(&m_iFocalLength, 0);
valFocalLength.SetRange(0, wxINT32_MAX);
- m_pFocalLength = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(spinnerWidth,
- -1), 0, valFocalLength);
+ m_pFocalLength =
+ new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(spinnerWidth, -1), 0, valFocalLength);
m_pFocalLength->Enable(!pFrame->CaptureActive);
m_pFocalLength->Bind(wxEVT_TEXT, &CalstepDialog::OnText, this);
- AddTableEntry (m_pInputTableSizer, _("Focal length, mm"), m_pFocalLength, _("Guide scope focal length"));
+ AddTableEntry(m_pInputTableSizer, _("Focal length, mm"), m_pFocalLength, _("Guide scope focal length"));
// Pixel size
m_pPixelSize->Enable(!pFrame->CaptureActive);
m_pPixelSize->Bind(wxEVT_SPINCTRLDOUBLE, &CalstepDialog::OnSpinCtrlDouble, this);
- AddTableEntry (m_pInputTableSizer, _("Pixel size, microns"), m_pPixelSize, _("Guide camera pixel size"));
+ AddTableEntry(m_pInputTableSizer, _("Pixel size, microns"), m_pPixelSize, _("Guide camera pixel size"));
// binning
wxArrayString opts;
@@ -134,32 +135,37 @@ CalstepDialog::CalstepDialog(wxWindow *parent, int focalLength, double pixelSize
// Guide speed
m_pGuideSpeed = NewSpinner(this, textWidth, m_fGuideSpeed, MIN_GUIDESPEED, MAX_GUIDESPEED, 0.25);
m_pGuideSpeed->Bind(wxEVT_SPINCTRLDOUBLE, &CalstepDialog::OnSpinCtrlDouble, this);
- AddTableEntry (m_pInputTableSizer, _("Guide speed, n.nn x sidereal"), m_pGuideSpeed,
- /* xgettext:no-c-format */ _("Guide speed, multiple of sidereal rate; if your mount's guide speed is 50% sidereal rate, enter 0.5."
- " NOTE: Changing this setting has no effect on the guide speed used by the mount - that must be changed via driver UI or hand-controller."));
+ AddTableEntry(m_pInputTableSizer, _("Guide speed, n.nn x sidereal"), m_pGuideSpeed,
+ /* xgettext:no-c-format */
+ _("Guide speed, multiple of sidereal rate; if your mount's guide speed is 50% sidereal rate, enter 0.5."
+ " NOTE: Changing this setting has no effect on the guide speed used by the mount - that must be changed via driver "
+ "UI or hand-controller."));
// Number of steps
m_pNumSteps = NewSpinner(this, textWidth, m_iNumSteps, MIN_STEPS, MAX_STEPS, 1);
- m_pNumSteps->SetDigits (0);
+ m_pNumSteps->SetDigits(0);
m_pNumSteps->Bind(wxEVT_SPINCTRLDOUBLE, &CalstepDialog::OnSpinCtrlDouble, this);
- AddTableEntry (m_pInputTableSizer, _("Calibration steps"), m_pNumSteps,
- wxString::Format(_("Targeted number of steps in each direction. The default value (%d) works fine for most setups."), (int) DEFAULT_STEPS));
+ AddTableEntry(m_pInputTableSizer, _("Calibration steps"), m_pNumSteps,
+ wxString::Format(_("Targeted number of steps in each direction. The default value (%d) works fine for most setups."),
+ (int) DEFAULT_STEPS));
// Distance for calibration (arcsec)
m_pDistance = NewSpinner(this, textWidth, m_calibrationDistance, MIN_DISTANCE, MAX_DISTANCE, 1.0);
m_pDistance->SetDigits(0);
m_pDistance->Bind(wxEVT_SPINCTRLDOUBLE, &CalstepDialog::OnSpinCtrlDouble, this);
AddTableEntry(m_pInputTableSizer, _("Calibration distance, px"), m_pDistance,
- wxString::Format(_("Targeted distance in each direction. The default value (%d) works fine for most setups."), (int) DEFAULT_DISTANCE));
+ wxString::Format(_("Targeted distance in each direction. The default value (%d) works fine for most setups."),
+ (int) DEFAULT_DISTANCE));
// Calibration declination
m_pDeclination = NewSpinner(this, textWidth, m_dDeclination, MIN_DECLINATION, MAX_DECLINATION, 5.0);
m_pDeclination->SetDigits(0);
m_pDeclination->Bind(wxEVT_SPINCTRLDOUBLE, &CalstepDialog::OnSpinCtrlDouble, this);
- AddTableEntry (m_pInputTableSizer, _("Calibration declination, degrees"), m_pDeclination, _("Approximate declination where you will do calibration"));
+ AddTableEntry(m_pInputTableSizer, _("Calibration declination, degrees"), m_pDeclination,
+ _("Approximate declination where you will do calibration"));
// Button for doing a 'reset'
- wxButton* pResetButton = new wxButton(this, wxID_DEFAULT, _("Reset"));
+ wxButton *pResetButton = new wxButton(this, wxID_DEFAULT, _("Reset"));
pResetButton->SetToolTip(_("Reset the calibration parameters to defaults"));
pResetButton->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CalstepDialog::OnReset, this);
m_pInputTableSizer->Add(pResetButton, 1, wxALL, 5);
@@ -168,35 +174,32 @@ CalstepDialog::CalstepDialog(wxWindow *parent, int focalLength, double pixelSize
m_pOutputGroupBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Computed Values"));
m_status = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
- m_pImageScale = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(spinnerWidth,
- -1));
+ m_pImageScale = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(spinnerWidth, -1));
m_pImageScale->Enable(false);
- AddTableEntry (m_pOutputTableSizer, _("Image scale, arc-sec/px"), m_pImageScale, "");
+ AddTableEntry(m_pOutputTableSizer, _("Image scale, arc-sec/px"), m_pImageScale, "");
m_pRslt = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(spinnerWidth, -1));
- AddTableEntry (m_pOutputTableSizer, _("Calibration step, ms"), m_pRslt, "");
+ AddTableEntry(m_pOutputTableSizer, _("Calibration step, ms"), m_pRslt, "");
// Add the tables to the panel, centered
- m_pInputGroupBox->Add (m_pInputTableSizer, 0, wxALL, 10);
- m_pOutputGroupBox->Add (m_pOutputTableSizer, 0, wxALL, 10);
+ m_pInputGroupBox->Add(m_pInputTableSizer, 0, wxALL, 10);
+ m_pOutputGroupBox->Add(m_pOutputTableSizer, 0, wxALL, 10);
m_pVSizer->Add(m_status, 1, wxALL, 5);
- m_pVSizer->Add (m_pInputGroupBox, wxSizerFlags().Center().Border(wxALL, 10));
- m_pVSizer->Add (m_pOutputGroupBox, wxSizerFlags().Center().Border(wxRIGHT|wxLEFT|wxBOTTOM, 10));
+ m_pVSizer->Add(m_pInputGroupBox, wxSizerFlags().Center().Border(wxALL, 10));
+ m_pVSizer->Add(m_pOutputGroupBox, wxSizerFlags().Center().Border(wxRIGHT | wxLEFT | wxBOTTOM, 10));
// ok/cancel buttons
- m_pVSizer->Add(
- CreateButtonSizer(wxOK | wxCANCEL),
- wxSizerFlags(0).Expand().Border(wxALL, 10) );
+ m_pVSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags(0).Expand().Border(wxALL, 10));
- SetSizerAndFit (m_pVSizer);
+ SetSizerAndFit(m_pVSizer);
}
// Utility function to add the tuples to the grid including tool-tips
-void CalstepDialog::AddTableEntry (wxFlexGridSizer *pTable, const wxString& label, wxWindow *pControl, const wxString& toolTip)
+void CalstepDialog::AddTableEntry(wxFlexGridSizer *pTable, const wxString& label, wxWindow *pControl, const wxString& toolTip)
{
- wxStaticText *pLabel = new wxStaticText(this, wxID_ANY, label + _(": "),wxPoint(-1,-1),wxSize(-1,-1));
- pTable->Add (pLabel, 1, wxALL, 5);
- pTable->Add (pControl, 1, wxALL, 5);
- pControl->SetToolTip (toolTip);
+ wxStaticText *pLabel = new wxStaticText(this, wxID_ANY, label + _(": "), wxPoint(-1, -1), wxSize(-1, -1));
+ pTable->Add(pLabel, 1, wxALL, 5);
+ pTable->Add(pControl, 1, wxALL, 5);
+ pControl->SetToolTip(toolTip);
}
// the recommended calibration distance is 20 arc-seconds or 25 pixels, whichever is greater
@@ -227,13 +230,13 @@ void CalstepDialog::GetCalibrationStepSize(int FocalLength, double PixelSize, in
double Declination, int distance, double *pImageScale, int *pStepSize)
{
double ImageScale = MyFrame::GetPixelScale(PixelSize, FocalLength, binning); // arc-sec per pixel
- double totalDuration = (double) distance * ImageScale / (15.0 * GuideSpeed); // 15 arc-sec/sec is sidereal rate
- double Pulse = totalDuration / DesiredSteps * 1000.0; // milliseconds at DEC=0
- double MaxPulse = totalDuration / MIN_STEPS * 1000.0; // max pulse size to still get MIN steps
- Pulse = wxMin(MaxPulse, Pulse / cos(radians(Declination))); // UI forces abs(Dec) <= 60 degrees
+ double totalDuration = (double) distance * ImageScale / (15.0 * GuideSpeed); // 15 arc-sec/sec is sidereal rate
+ double Pulse = totalDuration / DesiredSteps * 1000.0; // milliseconds at DEC=0
+ double MaxPulse = totalDuration / MIN_STEPS * 1000.0; // max pulse size to still get MIN steps
+ Pulse = wxMin(MaxPulse, Pulse / cos(radians(Declination))); // UI forces abs(Dec) <= 60 degrees
if (pImageScale)
*pImageScale = ImageScale;
- *pStepSize = (int) ceil(Pulse / 50.0) * 50; // round up to nearest 50 ms, too-small pulses can lead to calibration problems
+ *pStepSize = (int) ceil(Pulse / 50.0) * 50; // round up to nearest 50 ms, too-small pulses can lead to calibration problems
}
void CalstepDialog::OnText(wxCommandEvent& evt)
@@ -263,7 +266,7 @@ void CalstepDialog::DoRecalc(void)
if (this->Validate() && this->TransferDataFromWindow())
{
m_fPixelSize = m_pPixelSize->GetValue();
- m_pPixelSize->SetValue(m_fPixelSize); // For European locales, '.' -> ',' on output
+ m_pPixelSize->SetValue(m_fPixelSize); // For European locales, '.' -> ',' on output
m_binning = m_binningChoice->GetSelection() + 1;
m_fGuideSpeed = m_pGuideSpeed->GetValue();
m_pGuideSpeed->SetValue(m_fGuideSpeed);
@@ -284,16 +287,16 @@ void CalstepDialog::DoRecalc(void)
m_status->SetLabel(wxEmptyString);
// Spin controls enforce numeric ranges
- GetCalibrationStepSize(m_iFocalLength, m_fPixelSize, m_binning, m_fGuideSpeed, m_iNumSteps,
- m_dDeclination, m_calibrationDistance, &m_fImageScale, &m_iStepSize);
+ GetCalibrationStepSize(m_iFocalLength, m_fPixelSize, m_binning, m_fGuideSpeed, m_iNumSteps, m_dDeclination,
+ m_calibrationDistance, &m_fImageScale, &m_iStepSize);
m_bValidResult = true;
}
if (m_bValidResult)
{
- m_pImageScale->SetValue (wxString::Format ("%.2f", m_fImageScale));
- m_pRslt->SetValue (wxString::Format ("%3d", m_iStepSize));
+ m_pImageScale->SetValue(wxString::Format("%.2f", m_fImageScale));
+ m_pRslt->SetValue(wxString::Format("%3d", m_iStepSize));
}
else
{
@@ -327,6 +330,4 @@ bool CalstepDialog::GetResults(int *focalLength, double *pixelSize, int *binning
return false;
}
-CalstepDialog::~CalstepDialog(void)
-{
-}
+CalstepDialog::~CalstepDialog(void) { }
diff --git a/src/calstep_dialog.h b/src/calstep_dialog.h
index f94b664b1..023a7fbc6 100644
--- a/src/calstep_dialog.h
+++ b/src/calstep_dialog.h
@@ -39,7 +39,6 @@
class CalstepDialog : public wxDialog
{
private:
-
// wx UI controls
wxBoxSizer *m_pVSizer;
wxFlexGridSizer *m_pInputTableSizer;
@@ -72,8 +71,11 @@ class CalstepDialog : public wxDialog
void OnReset(wxCommandEvent& evt);
public:
-
- enum { DEFAULT_STEPS = 12, DEFAULT_DISTANCE = 25 };
+ enum
+ {
+ DEFAULT_STEPS = 12,
+ DEFAULT_DISTANCE = 25
+ };
static const double DEFAULT_GUIDESPEED;
CalstepDialog(wxWindow *parent, int focalLength, double pixelSize, int binning);
@@ -81,8 +83,8 @@ class CalstepDialog : public wxDialog
bool GetResults(int *focalLength, double *pixelSize, int *binning, int *stepSize, int *distance);
static int GetCalibrationDistance(int focalLength, double pixelSize, int binning);
- static void GetCalibrationStepSize(int focalLength, double pixelSize, int binning, double guideSpeed,
- int desiredSteps, double declination, int distance, double *imageScale, int *stepSize);
+ static void GetCalibrationStepSize(int focalLength, double pixelSize, int binning, double guideSpeed, int desiredSteps,
+ double declination, int distance, double *imageScale, int *stepSize);
private:
void OnText(wxCommandEvent& evt);
diff --git a/src/cam_INovaPLC.cpp b/src/cam_INovaPLC.cpp
index cd29edaf5..44d010685 100644
--- a/src/cam_INovaPLC.cpp
+++ b/src/cam_INovaPLC.cpp
@@ -33,19 +33,19 @@
*/
#include "phd.h"
-#if defined (INOVA_PLC)
-#include "camera.h"
-#include "image_math.h"
-#include "cam_INovaPLC.h"
-#include "DSCAMAPI.h"
+#if defined(INOVA_PLC)
+# include "camera.h"
+# include "image_math.h"
+# include "cam_INovaPLC.h"
+# include "DSCAMAPI.h"
CameraINovaPLC::CameraINovaPLC()
{
Connected = FALSE;
- Name=_T("i-Nova PLC-M");
- FullSize = wxSize(1280,1024); // Current size of a full frame
- m_hasGuideOutput = true; // Do we have an ST4 port?
- HasGainControl = true; // Can we adjust gain?
+ Name = _T("i-Nova PLC-M");
+ FullSize = wxSize(1280, 1024); // Current size of a full frame
+ m_hasGuideOutput = true; // Do we have an ST4 port?
+ HasGainControl = true; // Can we adjust gain?
}
wxByte CameraINovaPLC::BitsPerPixel()
@@ -61,10 +61,10 @@ bool CameraINovaPLC::Connect(const wxString& camId)
DSCameraSetDataWide(true);
DSCameraSetAeState(false); // Turn off auto-exposure
- DSCameraGetRowTime(&RowTime); // Figure the row-time in microseconds -- this lets me figure the actual exp time
- RawData = new unsigned short[1280*1024];
+ DSCameraGetRowTime(&RowTime); // Figure the row-time in microseconds -- this lets me figure the actual exp time
+ RawData = new unsigned short[1280 * 1024];
- Connected = true; // Set global flag for being connected
+ Connected = true; // Set global flag for being connected
return false;
}
@@ -92,20 +92,22 @@ bool CameraINovaPLC::ST4PulseGuideScope(int direction, int duration)
bit1 - DEC+
bit2 - DEC-
bit3 - RA-*/
- switch (direction) {
- case WEST:
- dircode = 0x01;
- break;
- case NORTH:
- dircode = 0x02;
- break;
- case SOUTH:
- dircode = 0x04;
- break;
- case EAST:
- dircode = 0x08;
- break;
- default: return true; // bad direction passed in
+ switch (direction)
+ {
+ case WEST:
+ dircode = 0x01;
+ break;
+ case NORTH:
+ dircode = 0x02;
+ break;
+ case SOUTH:
+ dircode = 0x04;
+ break;
+ case EAST:
+ dircode = 0x08;
+ break;
+ default:
+ return true; // bad direction passed in
}
DSCameraSetGuidingPort(dircode);
WorkerThread::MilliSleep(duration);
@@ -117,7 +119,7 @@ bool CameraINovaPLC::Disconnect()
{
Connected = false;
DSCameraUnInit();
- delete [] RawData;
+ delete[] RawData;
return false;
}
@@ -127,33 +129,39 @@ bool CameraINovaPLC::Capture(int duration, usImage& img, int options, const wxRe
int ysize = FullSize.GetHeight();
DS_CAMERA_STATUS rval;
int ntries = 1;
- if (img.Init(FullSize)) {
+ if (img.Init(FullSize))
+ {
DisconnectWithAlert(CAPT_FAIL_MEMORY);
return true;
}
int ExpDur = pFrame->RequestedExposureDuration();
- if (duration != ExpDur) { // reset the exp time - and pause -- we have had a change here from the current value
+ if (duration != ExpDur)
+ { // reset the exp time - and pause -- we have had a change here from the current value
rval = DSCameraSetExposureTime(ExpDur * 1000 / RowTime);
wxMilliSleep(100);
}
rval = DSCameraGrabFrame((BYTE *) RawData);
- while (rval != STATUS_OK) {
+ while (rval != STATUS_OK)
+ {
ntries++;
rval = DSCameraGrabFrame((BYTE *) RawData);
- //pFrame->StatusMsg(wxString::Format("%d %d",ntries,rval));
- if (ntries > 30) {
+ // pFrame->StatusMsg(wxString::Format("%d %d",ntries,rval));
+ if (ntries > 30)
+ {
pFrame->Alert("Timeout capturing frames - >30 bad in a row");
return true;
}
}
- for (unsigned int i = 0; i > 8) | (RawData[i] << 8);
+ for (unsigned int i = 0; i < xsize * ysize; i++)
+ {
+ img.ImageData[i] = (RawData[i] >> 8) | (RawData[i] << 8);
}
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
return false;
}
diff --git a/src/cam_KWIQGuider.cpp b/src/cam_KWIQGuider.cpp
index 56c6e24b9..8e0902671 100644
--- a/src/cam_KWIQGuider.cpp
+++ b/src/cam_KWIQGuider.cpp
@@ -37,16 +37,17 @@
#ifdef KWIQGUIDER_CAMERA
-#include "cam_KWIQGuider.h"
-#include "camera.h"
+# include "cam_KWIQGuider.h"
+# include "camera.h"
-#include
+# include
using namespace KWIQ;
class CameraKWIQGuider : public GuideCamera
{
KWIQ::KWIQGuider *KWIQguider;
+
public:
CameraKWIQGuider();
bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
@@ -63,9 +64,9 @@ CameraKWIQGuider::CameraKWIQGuider()
{
Connected = false;
Name = _T("KWIQGuider (KWIQGuider)");
- FullSize = wxSize(1280, 1024); // Current size of a full frame
- m_hasGuideOutput = true; // Do we have an ST4 port?
- HasGainControl = true; // Can we adjust gain?
+ FullSize = wxSize(1280, 1024); // Current size of a full frame
+ m_hasGuideOutput = true; // Do we have an ST4 port?
+ HasGainControl = true; // Can we adjust gain?
KWIQguider = new KWIQGuider();
}
@@ -80,7 +81,7 @@ bool CameraKWIQGuider::Connect(const wxString& camId)
if (!KWIQguider->Connect())
return CamConnectFailed(_("Could not connect to KWIQGuider"));
- Connected = true; // Set global flag for being connected
+ Connected = true; // Set global flag for being connected
return false;
}
@@ -93,20 +94,22 @@ bool CameraKWIQGuider::Disconnect()
bool CameraKWIQGuider::ST4PulseGuideScope(int direction, int duration)
{
- switch (direction) {
- case WEST:
- KWIQguider->Guide(guide_west, duration);
- break;
- case NORTH:
- KWIQguider->Guide(guide_north, duration);
- break;
- case SOUTH:
- KWIQguider->Guide(guide_south, duration);
- break;
- case EAST:
- KWIQguider->Guide(guide_east, duration);
- break;
- default: return true; // bad direction passed in
+ switch (direction)
+ {
+ case WEST:
+ KWIQguider->Guide(guide_west, duration);
+ break;
+ case NORTH:
+ KWIQguider->Guide(guide_north, duration);
+ break;
+ case SOUTH:
+ KWIQguider->Guide(guide_south, duration);
+ break;
+ case EAST:
+ KWIQguider->Guide(guide_east, duration);
+ break;
+ default:
+ return true; // bad direction passed in
}
wxMilliSleep(duration + 10);
@@ -119,23 +122,26 @@ bool CameraKWIQGuider::Capture(int duration, usImage& img, int options, const wx
int xsize = FullSize.GetWidth();
int ysize = FullSize.GetHeight();
- if (img.Init(xsize,ysize)) {
+ if (img.Init(xsize, ysize))
+ {
DisconnectWithAlert(CAPT_FAIL_MEMORY);
return true;
}
- KWIQguider->SetGain((int)(GuideCameraGain / 24));
-// KWIQguider->SetGain((int)(GuideCameraGain / 7)); // Won't exceed 15, not < 1
+ KWIQguider->SetGain((int) (GuideCameraGain / 24));
+ // KWIQguider->SetGain((int)(GuideCameraGain / 7)); // Won't exceed 15, not < 1
struct raw_image *raw = KWIQguider->Expose(duration);
- for (unsigned int i = 0; i < raw->width * raw->height; i++) {
+ for (unsigned int i = 0; i < raw->width * raw->height; i++)
+ {
img.ImageData[i] = (unsigned short) raw->data[i];
}
KWIQguider->FreeRawImage(raw);
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
return false;
}
diff --git a/src/cam_LELXUSBWebcam.cpp b/src/cam_LELXUSBWebcam.cpp
index be9fdc735..757a4292a 100644
--- a/src/cam_LELXUSBWebcam.cpp
+++ b/src/cam_LELXUSBWebcam.cpp
@@ -38,19 +38,21 @@
#if defined(LE_LXUSB_CAMERA)
-#include "cam_LELXUSBWebcam.h"
-#include "cam_wdm_base.h"
-#include "cameras/ShoestringLXUSB_DLL.h"
+# include "cam_LELXUSBWebcam.h"
+# include "cam_wdm_base.h"
+# include "cameras/ShoestringLXUSB_DLL.h"
class CameraLELxUsbWebcam : public CameraLEWebcam
{
bool m_isOpen;
+
public:
CameraLELxUsbWebcam();
virtual ~CameraLELxUsbWebcam();
bool Connect(const wxString& camId) override;
bool Disconnect() override;
+
private:
virtual bool LEControl(int actions);
};
@@ -178,15 +180,15 @@ bool CameraLELxUsbWebcam::LEControl(int actions)
if (actions & LECAMERA_LED_OFF)
{
- ledState = LXUSB_LED_OFF_RED;
+ ledState = LXUSB_LED_OFF_RED;
}
else if (actions & LECAMERA_LED_RED)
{
- ledState = LXUSB_LED_ON_RED;
+ ledState = LXUSB_LED_ON_RED;
}
else if (actions & LECAMERA_LED_GREEN)
{
- ledState = LXUSB_LED_ON_GREEN;
+ ledState = LXUSB_LED_ON_GREEN;
}
LXUSB_SetAll(frame1State, frame2State, shutterState, ampState, ledState);
diff --git a/src/cam_LEParallelWebcam.cpp b/src/cam_LEParallelWebcam.cpp
index 6c4f5076d..b5a616901 100644
--- a/src/cam_LEParallelWebcam.cpp
+++ b/src/cam_LEParallelWebcam.cpp
@@ -38,14 +38,15 @@
#if defined(LE_PARALLEL_CAMERA)
-#include "cam_LEParallelWebcam.h"
-#include "cam_wdm_base.h"
+# include "cam_LEParallelWebcam.h"
+# include "cam_wdm_base.h"
class CameraLEParallelWebcam : public CameraLEWebcam
{
private:
virtual bool LEControl(int actions);
ParallelPort *m_pParallelPort;
+
public:
CameraLEParallelWebcam();
virtual ~CameraLEParallelWebcam();
@@ -61,7 +62,7 @@ void _stdcall Out32(short PortAddress, short data);
CameraLEParallelWebcam::CameraLEParallelWebcam(void)
: CameraLEWebcam()
{
- Name=_T("Parallel LE Webcam");
+ Name = _T("Parallel LE Webcam");
m_pParallelPort = NULL;
}
@@ -155,10 +156,10 @@ bool CameraLEParallelWebcam::LEControl(int actions)
enum
{
- PARALLEL_BIT_TRANSFER = 1,
- PARALLEL_BIT_UNUSED = 2,
+ PARALLEL_BIT_TRANSFER = 1,
+ PARALLEL_BIT_UNUSED = 2,
PARALLEL_BIT_AMPLIFIER = 4,
- PARALLEL_BIT_SHUTTER = 8
+ PARALLEL_BIT_SHUTTER = 8
};
BYTE bitsToClear = 0;
diff --git a/src/cam_LESerialWebcam.cpp b/src/cam_LESerialWebcam.cpp
index 839d882dd..812183e37 100644
--- a/src/cam_LESerialWebcam.cpp
+++ b/src/cam_LESerialWebcam.cpp
@@ -38,8 +38,8 @@
#if defined(LE_SERIAL_CAMERA)
-#include "cam_LESerialWebcam.h"
-#include "cam_wdm_base.h"
+# include "cam_LESerialWebcam.h"
+# include "cam_wdm_base.h"
class CameraLESerialWebcam : public CameraLEWebcam
{
@@ -55,24 +55,24 @@ class CameraLESerialWebcam : public CameraLEWebcam
CameraLESerialWebcam();
virtual ~CameraLESerialWebcam();
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- void ShowPropertyDialog() override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ void ShowPropertyDialog() override;
private:
bool LEControl(int actions);
};
-#define LE_MASK_DTR 1
-#define LE_MASK_RTS 2
-//#define LE_INIT_DTR 4
-//#define LE_INIT_RTS 8
-#define LE_EXPO_DTR 16
-#define LE_EXPO_RTS 32
-#define LE_AMP_DTR 64
-#define LE_AMP_RTS 128
+# define LE_MASK_DTR 1
+# define LE_MASK_RTS 2
+// #define LE_INIT_DTR 4
+// #define LE_INIT_RTS 8
+# define LE_EXPO_DTR 16
+# define LE_EXPO_RTS 32
+# define LE_AMP_DTR 64
+# define LE_AMP_RTS 128
-#define LE_DEFAULT (LE_MASK_DTR | LE_MASK_RTS | /*LE_INIT_DTR | LE_INIT_RTS |*/ LE_EXPO_RTS | LE_AMP_DTR)
+# define LE_DEFAULT (LE_MASK_DTR | LE_MASK_RTS | /*LE_INIT_DTR | LE_INIT_RTS |*/ LE_EXPO_RTS | LE_AMP_DTR)
CameraLESerialWebcam::CameraLESerialWebcam(void)
: CameraLEWebcam()
@@ -98,8 +98,9 @@ bool CameraLESerialWebcam::Connect(const wxString& camId)
m_UseAmp = pConfig->Profile.GetBoolean("/camera/serialLEWebcam/UseAmp", false);
m_signalConfig = pConfig->Profile.GetInt("/camera/serialLEWebcam/SignalConfig", LE_DEFAULT);
- m_Expo = (m_signalConfig & (LE_EXPO_DTR | LE_EXPO_RTS) ^ (LE_MASK_DTR | LE_MASK_RTS)) ? m_InvertedLogic : !m_InvertedLogic ;
- m_Amp = (m_signalConfig & (LE_AMP_DTR | LE_AMP_RTS) ^ (LE_MASK_DTR | LE_MASK_RTS)) ? m_InvertedLogic : !m_InvertedLogic ;
+ m_Expo =
+ (m_signalConfig & (LE_EXPO_DTR | LE_EXPO_RTS) ^ (LE_MASK_DTR | LE_MASK_RTS)) ? m_InvertedLogic : !m_InvertedLogic;
+ m_Amp = (m_signalConfig & (LE_AMP_DTR | LE_AMP_RTS) ^ (LE_MASK_DTR | LE_MASK_RTS)) ? m_InvertedLogic : !m_InvertedLogic;
m_pSerialPort = SerialPort::SerialPortFactory();
if (!m_pSerialPort)
@@ -113,7 +114,7 @@ bool CameraLESerialWebcam::Connect(const wxString& camId)
throw ERROR_INFO("LESerialWebcamClass::Connect: serial port connect failed");
}
- //pConfig->Profile.SetString("/camera/serialLEWebcam/serialport", serialPorts[resp]);
+ // pConfig->Profile.SetString("/camera/serialLEWebcam/serialport", serialPorts[resp]);
if (CameraLEWebcam::Connect(camId))
{
@@ -254,7 +255,7 @@ struct LEWebcamDialog : public wxDialog
wxCheckBox *m_pLEAmpRTS;
wxCheckBox *m_pInvertedLogic;
wxCheckBox *m_pUseAmp;
- CVVidCapture* m_pVidCap;
+ CVVidCapture *m_pVidCap;
void OnDefaults(wxCommandEvent& evt);
void OnVidCapClick(wxCommandEvent& evt);
@@ -274,8 +275,8 @@ void LEWebcamDialog::OnDefaults(wxCommandEvent& evt)
m_pLEMaskDTR->SetValue(def & LE_MASK_DTR ? true : false);
m_pLEMaskRTS->SetValue(def & LE_MASK_RTS ? true : false);
- //m_pLEInitDTR->SetValue(def & LE_INIT_DTR ? true : false);
- //m_pLEInitRTS->SetValue(def & LE_INIT_RTS ? true : false);
+ // m_pLEInitDTR->SetValue(def & LE_INIT_DTR ? true : false);
+ // m_pLEInitRTS->SetValue(def & LE_INIT_RTS ? true : false);
m_pLEExpoDTR->SetValue(def & LE_EXPO_DTR ? true : false);
m_pLEExpoRTS->SetValue(def & LE_EXPO_RTS ? true : false);
m_pLEAmpDTR->SetValue(def & LE_AMP_DTR ? true : false);
@@ -313,15 +314,14 @@ LEWebcamDialog::LEWebcamDialog(wxWindow *parent, CVVidCapture *vc)
if (serialPorts.IsEmpty())
{
- wxMessageBox(_("No serial ports found"),_("Error"), wxOK | wxICON_ERROR);
+ wxMessageBox(_("No serial ports found"), _("Error"), wxOK | wxICON_ERROR);
throw ERROR_INFO("No Serial port found");
}
wxString lastSerialPort = pConfig->Profile.GetString("/camera/serialLEWebcam/serialport", "");
int resp = serialPorts.Index(lastSerialPort);
- m_pPortNum = new wxChoice(this, wxID_ANY,wxDefaultPosition,
- wxDefaultSize, serialPorts );
+ m_pPortNum = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, serialPorts);
m_pPortNum->SetSelection(resp);
pHSizer->Add(m_pPortNum, wxSizerFlags().Border(wxRIGHT | wxLEFT, 10).Expand());
@@ -347,13 +347,13 @@ LEWebcamDialog::LEWebcamDialog(wxWindow *parent, CVVidCapture *vc)
m_pLEMaskRTS->SetValue(signal_config & LE_MASK_RTS ? true : false);
pSignalSizer->Add(m_pLEMaskRTS, wxSizerFlags().Center());
- //pSignalSizer->Add(new wxStaticText(this, wxID_ANY, _T("LE Init")));
- //m_pLEInitDTR = new wxCheckBox(this, wxID_ANY, _T(""));
- //m_pLEInitDTR->SetValue(signal_config & LE_INIT_DTR ? true : false);
- //pSignalSizer->Add(m_pLEInitDTR, wxSizerFlags().Center());
- //m_pLEInitRTS = new wxCheckBox(this, wxID_ANY, _T(""));
- //m_pLEInitRTS->SetValue(signal_config & LE_INIT_RTS ? true : false);
- //pSignalSizer->Add(m_pLEInitRTS, wxSizerFlags().Center());
+ // pSignalSizer->Add(new wxStaticText(this, wxID_ANY, _T("LE Init")));
+ // m_pLEInitDTR = new wxCheckBox(this, wxID_ANY, _T(""));
+ // m_pLEInitDTR->SetValue(signal_config & LE_INIT_DTR ? true : false);
+ // pSignalSizer->Add(m_pLEInitDTR, wxSizerFlags().Center());
+ // m_pLEInitRTS = new wxCheckBox(this, wxID_ANY, _T(""));
+ // m_pLEInitRTS->SetValue(signal_config & LE_INIT_RTS ? true : false);
+ // pSignalSizer->Add(m_pLEInitRTS, wxSizerFlags().Center());
pSignalSizer->Add(new wxStaticText(this, wxID_ANY, _T("LE Expo")));
m_pLEExpoDTR = new wxCheckBox(this, wxID_ANY, _T(""));
@@ -389,7 +389,7 @@ LEWebcamDialog::LEWebcamDialog(wxWindow *parent, CVVidCapture *vc)
if (m_pVidCap)
{
wxButton *pBtnVidCap = new wxButton(this, wxID_CONVERT, _("Webcam settings"));
- pHSizer ->Add(pBtnVidCap, wxSizerFlags().Border(wxLEFT, 10));
+ pHSizer->Add(pBtnVidCap, wxSizerFlags().Border(wxLEFT, 10));
}
pVSizer->Add(pHSizer, wxSizerFlags().Border(wxALL, 10));
pVSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Border(wxALL, 10));
@@ -408,21 +408,28 @@ void CameraLESerialWebcam::ShowPropertyDialog()
{
pConfig->Profile.SetString("/camera/serialLEWebcam/serialport", dlg.m_pPortNum->GetStringSelection());
- m_signalConfig = 0;
- if (dlg.m_pLEMaskDTR->GetValue()) m_signalConfig |= LE_MASK_DTR;
- if (dlg.m_pLEMaskRTS->GetValue()) m_signalConfig |= LE_MASK_RTS;
- //if (dlg.m_pLEInitDTR->GetValue()) m_signalConfig |= LE_INIT_DTR;
- //if (dlg.m_pLEInitRTS->GetValue()) m_signalConfig |= LE_INIT_RTS;
- if (dlg.m_pLEExpoDTR->GetValue()) m_signalConfig |= LE_EXPO_DTR;
- if (dlg.m_pLEExpoRTS->GetValue()) m_signalConfig |= LE_EXPO_RTS;
- if (dlg.m_pLEAmpDTR->GetValue()) m_signalConfig |= LE_AMP_DTR;
- if (dlg.m_pLEAmpRTS->GetValue()) m_signalConfig |= LE_AMP_RTS;
+ m_signalConfig = 0;
+ if (dlg.m_pLEMaskDTR->GetValue())
+ m_signalConfig |= LE_MASK_DTR;
+ if (dlg.m_pLEMaskRTS->GetValue())
+ m_signalConfig |= LE_MASK_RTS;
+ // if (dlg.m_pLEInitDTR->GetValue()) m_signalConfig |= LE_INIT_DTR;
+ // if (dlg.m_pLEInitRTS->GetValue()) m_signalConfig |= LE_INIT_RTS;
+ if (dlg.m_pLEExpoDTR->GetValue())
+ m_signalConfig |= LE_EXPO_DTR;
+ if (dlg.m_pLEExpoRTS->GetValue())
+ m_signalConfig |= LE_EXPO_RTS;
+ if (dlg.m_pLEAmpDTR->GetValue())
+ m_signalConfig |= LE_AMP_DTR;
+ if (dlg.m_pLEAmpRTS->GetValue())
+ m_signalConfig |= LE_AMP_RTS;
m_InvertedLogic = dlg.m_pInvertedLogic->GetValue();
m_UseAmp = dlg.m_pUseAmp->GetValue();
- m_Expo = (m_signalConfig & (LE_EXPO_DTR | LE_EXPO_RTS) ^ (LE_MASK_DTR | LE_MASK_RTS)) ? m_InvertedLogic : !m_InvertedLogic ;
- m_Amp = (m_signalConfig & (LE_AMP_DTR | LE_AMP_RTS) ^ (LE_MASK_DTR | LE_MASK_RTS)) ? m_InvertedLogic : !m_InvertedLogic ;
+ m_Expo =
+ (m_signalConfig & (LE_EXPO_DTR | LE_EXPO_RTS) ^ (LE_MASK_DTR | LE_MASK_RTS)) ? m_InvertedLogic : !m_InvertedLogic;
+ m_Amp = (m_signalConfig & (LE_AMP_DTR | LE_AMP_RTS) ^ (LE_MASK_DTR | LE_MASK_RTS)) ? m_InvertedLogic : !m_InvertedLogic;
- pConfig->Profile.SetInt("/camera/serialLEWebcam/SignalConfig", m_signalConfig );
+ pConfig->Profile.SetInt("/camera/serialLEWebcam/SignalConfig", m_signalConfig);
pConfig->Profile.SetBoolean("/camera/serialLEWebcam/InvertedLogic", m_InvertedLogic);
pConfig->Profile.SetBoolean("/camera/serialLEWebcam/UseAmp", m_UseAmp);
diff --git a/src/cam_LESerialWebcam.h b/src/cam_LESerialWebcam.h
index fd83f849e..8b1b378d7 100644
--- a/src/cam_LESerialWebcam.h
+++ b/src/cam_LESerialWebcam.h
@@ -45,4 +45,4 @@ class LESerialWebcamCameraFactory
static GuideCamera *MakeLESerialWebcamCamera();
};
-#endif //CAM_LESERIALWEBCAM_H_INCLUDED
+#endif // CAM_LESERIALWEBCAM_H_INCLUDED
diff --git a/src/cam_LEwebcam.cpp b/src/cam_LEwebcam.cpp
index 5b215f649..42b387c52 100644
--- a/src/cam_LEwebcam.cpp
+++ b/src/cam_LEwebcam.cpp
@@ -38,19 +38,17 @@
#if defined(LE_CAMERA)
-#include "cam_wdm_base.h"
+# include "cam_wdm_base.h"
CameraLEWebcam::CameraLEWebcam(void)
- : CameraWDM()
+ : CameraWDM()
{
Name = _T("Generic LE Webcam");
PropertyDialogType = PROPDLG_WHEN_CONNECTED;
HasDelayParam = true;
}
-CameraLEWebcam::~CameraLEWebcam(void)
-{
-}
+CameraLEWebcam::~CameraLEWebcam(void) { }
bool CameraLEWebcam::Connect(const wxString& camId)
{
@@ -99,12 +97,14 @@ bool CameraLEWebcam::Capture(int duration, usImage& img, int options, const wxRe
else
{
// do the "amp on" part of the exposure
- LEControl(LECAMERA_LED_GREEN | LECAMERA_SHUTTER_OPEN | LECAMERA_EXPOSURE_FIELD_A | LECAMERA_EXPOSURE_FIELD_B | LECAMERA_AMP_ON);
+ LEControl(LECAMERA_LED_GREEN | LECAMERA_SHUTTER_OPEN | LECAMERA_EXPOSURE_FIELD_A | LECAMERA_EXPOSURE_FIELD_B |
+ LECAMERA_AMP_ON);
wxMilliSleep(ampOnTime);
}
// do the "amp off" part of the exposure.
- LEControl(LECAMERA_LED_RED | LECAMERA_SHUTTER_OPEN | LECAMERA_EXPOSURE_FIELD_A | LECAMERA_EXPOSURE_FIELD_B | LECAMERA_AMP_OFF);
+ LEControl(LECAMERA_LED_RED | LECAMERA_SHUTTER_OPEN | LECAMERA_EXPOSURE_FIELD_A | LECAMERA_EXPOSURE_FIELD_B |
+ LECAMERA_AMP_OFF);
wxMilliSleep(ampOffTime);
// exposure complete - release the frame
@@ -140,15 +140,15 @@ bool CameraLEWebcam::Capture(int duration, usImage& img, int options, const wxRe
unsigned short *dptr2 = frame2.ImageData;
unsigned short *dptr3 = frame3.ImageData;
- UINT64 sum1=0;
- UINT64 sum2=0;
- UINT64 sum3=0;
+ UINT64 sum1 = 0;
+ UINT64 sum2 = 0;
+ UINT64 sum3 = 0;
// we only use the data from the frame with the largest sum.
// This is because we are not exactly sure when we will capture the "Long Exposure"
// frame
- for (unsigned int i = 0;i < frame1.NPixels; i++)
+ for (unsigned int i = 0; i < frame1.NPixels; i++)
{
sum1 += *dptr1++;
sum2 += *dptr2++;
diff --git a/src/cam_MeadeDSI.cpp b/src/cam_MeadeDSI.cpp
index 643e98e52..2af7c0413 100644
--- a/src/cam_MeadeDSI.cpp
+++ b/src/cam_MeadeDSI.cpp
@@ -36,16 +36,16 @@
#ifdef MEADE_DSI_CAMERA
-#include "camera.h"
-#include "time.h"
-#include "image_math.h"
-#include "cam_MeadeDSI.h"
+# include "camera.h"
+# include "time.h"
+# include "image_math.h"
+# include "cam_MeadeDSI.h"
-#if defined(__APPLE__)
-# include
-#endif
+# if defined(__APPLE__)
+# include
+# endif
-#include "DsiDevice.h"
+# include "DsiDevice.h"
class DsiDevice;
@@ -57,21 +57,21 @@ class CameraDSI : public GuideCamera
CameraDSI();
~CameraDSI();
- bool CanSelectCamera() const override { return true; }
- bool EnumCameras(wxArrayString& names, wxArrayString& ids) override;
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool HasNonGuiCapture() override;
+ bool CanSelectCamera() const override { return true; }
+ bool EnumCameras(wxArrayString& names, wxArrayString& ids) override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool HasNonGuiCapture() override;
wxByte BitsPerPixel() override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- bool GetDevicePixelSize(double *devPixelSize) override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ bool GetDevicePixelSize(double *devPixelSize) override;
};
CameraDSI::CameraDSI()
: MeadeCam(0)
{
Name = _T("Meade DSI");
- FullSize = wxSize(768,505); // CURRENTLY ULTRA-RAW
+ FullSize = wxSize(768, 505); // CURRENTLY ULTRA-RAW
HasGainControl = true;
}
@@ -130,18 +130,25 @@ bool CameraDSI::Connect(const wxString& camId)
}
retval = !(MeadeCam->Open(DevNum));
-// wxMessageBox(wxString::Format("Color: %d\n%u x %u",
-// MeadeCam->IsColor,MeadeCam->GetWidth(),MeadeCam->GetHeight()));
- if (!retval) {
- FullSize = wxSize(MeadeCam->GetWidth(),MeadeCam->GetHeight());
-// wxMessageBox(wxString::Format("%s\n%s (%d)\nColor: %d\n-II: %d\n%u x %u",MeadeCam->CcdName,MeadeCam->ModelName, MeadeCam->ModelNumber,
-// MeadeCam->IsColor,MeadeCam->IsDsiII, FullSize.GetWidth(), FullSize.GetHeight()) + "\n" + MeadeCam->ErrorMessage);
-// wxMessageBox(wxString::Format("%s\n%s (%d)\nColor: %d\n-USB2: %d\n%u x %u",MeadeCam->CcdName,MeadeCam->ModelName, MeadeCam->ModelNumber,
-// MeadeCam->IsColor,MeadeCam->IsUSB2, FullSize.GetWidth(), FullSize.GetHeight()) + "\n" + MeadeCam->ErrorMessage);
+ // wxMessageBox(wxString::Format("Color: %d\n%u x %u",
+ // MeadeCam->IsColor,MeadeCam->GetWidth(),MeadeCam->GetHeight()));
+ if (!retval)
+ {
+ FullSize = wxSize(MeadeCam->GetWidth(), MeadeCam->GetHeight());
+ // wxMessageBox(wxString::Format("%s\n%s (%d)\nColor: %d\n-II: %d\n%u x %u",MeadeCam->CcdName,MeadeCam->ModelName,
+ // MeadeCam->ModelNumber,
+ // MeadeCam->IsColor,MeadeCam->IsDsiII, FullSize.GetWidth(), FullSize.GetHeight()) + "\n" +
+ // MeadeCam->ErrorMessage);
+ // wxMessageBox(wxString::Format("%s\n%s (%d)\nColor: %d\n-USB2: %d\n%u x
+ // %u",MeadeCam->CcdName,MeadeCam->ModelName, MeadeCam->ModelNumber,
+ // MeadeCam->IsColor,MeadeCam->IsUSB2, FullSize.GetWidth(), FullSize.GetHeight()) +
+ // "\n" + MeadeCam->ErrorMessage);
MeadeCam->Initialize();
MeadeCam->SetHighGain(true);
- if (!MeadeCam->IsDsiIII) MeadeCam->SetDualExposureThreshold(501);
- else MeadeCam->SetBinMode(1);
+ if (!MeadeCam->IsDsiIII)
+ MeadeCam->SetDualExposureThreshold(501);
+ else
+ MeadeCam->SetBinMode(1);
MeadeCam->SetOffset(255);
MeadeCam->SetFastReadoutSpeed(true);
@@ -176,7 +183,7 @@ bool CameraDSI::GetDevicePixelSize(double *devPixelSize)
else
*devPixelSize = 7.5;
- return false; // Pixel sizes are hard-coded
+ return false; // Pixel sizes are hard-coded
}
bool CameraDSI::Capture(int duration, usImage& img, int options, const wxRect& subframe)
@@ -196,7 +203,7 @@ bool CameraDSI::Capture(int duration, usImage& img, int options, const wxRect& s
// The AbortImage method does not appear to work with the DSI camera. If abort is called and the thread is terminated, the
// pending image is still downloaded and PHD2 will crash
-#if AbortActuallyWorks
+# if AbortActuallyWorks
CameraWatchdog watchdog(duration, GetTimeoutMs());
// wait for image to finish and d/l
@@ -215,23 +222,26 @@ bool CameraDSI::Capture(int duration, usImage& img, int options, const wxRect& s
return true;
}
}
-#else // handle the pending image download, regardless
+# else // handle the pending image download, regardless
// We also need to prevent the thread from being killed when phd2 is closed
WorkerThreadKillGuard _guard;
- if (duration > 100) {
+ if (duration > 100)
+ {
wxMilliSleep(duration - 100); // wait until near end of exposure, nicely
}
bool still_going = true;
- while (still_going) { // wait for image to finish and d/l
+ while (still_going)
+ { // wait for image to finish and d/l
wxMilliSleep(20);
still_going = !(MeadeCam->ImageReady);
}
-#endif // end of waiting for the image
+# endif // end of waiting for the image
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
if (options & CAPTURE_RECON)
{
@@ -239,7 +249,7 @@ bool CameraDSI::Capture(int duration, usImage& img, int options, const wxRect& s
QuickLRecon(img);
if (MeadeCam->IsDsiII)
SquarePixels(img, 8.6, 8.3);
- else if (!MeadeCam->IsDsiIII) // Original DSI
+ else if (!MeadeCam->IsDsiIII) // Original DSI
SquarePixels(img, 9.6, 7.5);
}
diff --git a/src/cam_NebSBIG.cpp b/src/cam_NebSBIG.cpp
index 67909d4d6..358001f99 100644
--- a/src/cam_NebSBIG.cpp
+++ b/src/cam_NebSBIG.cpp
@@ -35,16 +35,16 @@
#include "phd.h"
#ifdef NEB_SBIG
-#include "camera.h"
-#include "time.h"
-#include "image_math.h"
-#include "cam_NebSBIG.h"
-#include "socket_server.h"
+# include "camera.h"
+# include "time.h"
+# include "image_math.h"
+# include "cam_NebSBIG.h"
+# include "socket_server.h"
CameraNebSBIG::CameraNebSBIG()
{
Connected = false;
- Name=_T("Nebulosity SBIG Guide chip");
+ Name = _T("Nebulosity SBIG Guide chip");
}
wxByte CameraNebSBIG::BitsPerPixel()
@@ -56,8 +56,9 @@ bool CameraNebSBIG::Connect(const wxString& camId)
{
int xsize, ysize;
bool retval = ServerSendCamConnect(xsize, ysize);
- if (retval) return true;
- FullSize = wxSize(xsize,ysize);
+ if (retval)
+ return true;
+ FullSize = wxSize(xsize, ysize);
Connected = true;
return false;
}
@@ -77,10 +78,10 @@ bool CameraNebSBIG::Capture(int duration, usImage& img, int options, const wxRec
return true;
}
bool retval = ServerReqFrame(duration, img);
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
return retval;
-
}
bool CameraNebSBIG::ST4PulseGuideScope(int direction, int duration)
diff --git a/src/cam_NebSBIG.h b/src/cam_NebSBIG.h
index 925a16210..3f9af4e8f 100644
--- a/src/cam_NebSBIG.h
+++ b/src/cam_NebSBIG.h
@@ -40,12 +40,12 @@ class CameraNebSBIG : public GuideCamera
{
public:
CameraNebSBIG();
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool HasNonGuiCapture() override;
- wxByte BitsPerPixel() override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- bool ST4PulseGuideScope(int direction, int duration) override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool HasNonGuiCapture() override;
+ wxByte BitsPerPixel() override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ bool ST4PulseGuideScope(int direction, int duration) override;
};
#endif
diff --git a/src/cam_OSPL130.cpp b/src/cam_OSPL130.cpp
index c450266f0..2c464cf3f 100644
--- a/src/cam_OSPL130.cpp
+++ b/src/cam_OSPL130.cpp
@@ -13,9 +13,9 @@
#include "image_math.h"
#include
-#if defined (OS_PL130)
-#include "cam_OSPL130.h"
-#include "cameras/OSPL130API.h"
+#if defined(OS_PL130)
+# include "cam_OSPL130.h"
+# include "cameras/OSPL130API.h"
static bool DLLExists(const wxString& DLLName)
{
@@ -34,8 +34,8 @@ static bool DLLExists(const wxString& DLLName)
CameraOpticstarPL130::CameraOpticstarPL130()
{
Connected = false;
- Name=_T("Opticstar PL-130M");
- FullSize = wxSize(1280,1024);
+ Name = _T("Opticstar PL-130M");
+ FullSize = wxSize(1280, 1024);
m_hasGuideOutput = false;
HasGainControl = false;
Color = false;
@@ -48,7 +48,7 @@ wxByte CameraOpticstarPL130::BitsPerPixel()
bool CameraOpticstarPL130::Connect(const wxString& camId)
{
-// returns true on error
+ // returns true on error
if (!DLLExists("OSPL130RT.dll"))
return CamConnectFailed(_("Cannot find OSPL130RT.dll"));
@@ -57,7 +57,7 @@ bool CameraOpticstarPL130::Connect(const wxString& camId)
if (retval)
return CamConnectFailed(_("Cannot init camera"));
- //OSPL130_SetGain(6);
+ // OSPL130_SetGain(6);
Connected = true;
return false;
}
@@ -79,28 +79,32 @@ bool CameraOpticstarPL130::Capture(int duration, usImage& img, int options, cons
DisconnectWithAlert(CAPT_FAIL_MEMORY);
return true;
}
- if (OSPL130_Capture(mode,duration)) {
+ if (OSPL130_Capture(mode, duration))
+ {
pFrame->Alert(_("Cannot start exposure"));
return true;
}
- if (duration > 100) {
+ if (duration > 100)
+ {
wxMilliSleep(duration - 100); // wait until near end of exposure, nicely
wxGetApp().Yield();
-// if (Abort) {
-// MeadeCam->AbortImage();
-// return true;
-// }
+ // if (Abort) {
+ // MeadeCam->AbortImage();
+ // return true;
+ // }
}
- while (still_going) { // wait for image to finish and d/l
+ while (still_going)
+ { // wait for image to finish and d/l
wxMilliSleep(20);
OSPL130_IsExposing(&still_going);
wxGetApp().Yield();
}
// Download
- OSPL130_GetRawImage(0,0,FullSize.GetWidth(),FullSize.GetHeight(), (void *) img.ImageData);
+ OSPL130_GetRawImage(0, 0, FullSize.GetWidth(), FullSize.GetHeight(), (void *) img.ImageData);
// byte swap
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
if (Color && (options & CAPTURE_RECON))
QuickLRecon(img);
diff --git a/src/cam_OSPL130.h b/src/cam_OSPL130.h
index 4b058c2f1..a25ffd3ad 100644
--- a/src/cam_OSPL130.h
+++ b/src/cam_OSPL130.h
@@ -36,15 +36,15 @@
class CameraOpticstarPL130 : public GuideCamera
{
- bool Color;
+ bool Color;
public:
CameraOpticstarPL130();
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- wxByte BitsPerPixel() override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ wxByte BitsPerPixel() override;
};
-#endif //OSPL130DEF
+#endif // OSPL130DEF
diff --git a/src/cam_StarShootDSCI.cpp b/src/cam_StarShootDSCI.cpp
index 374a2edc4..92307bd24 100644
--- a/src/cam_StarShootDSCI.cpp
+++ b/src/cam_StarShootDSCI.cpp
@@ -35,18 +35,18 @@
#include "phd.h"
#ifdef ORION_DSCI
-#include "camera.h"
-#include "image_math.h"
-#include "cam_StarShootDSCI.h"
+# include "camera.h"
+# include "image_math.h"
+# include "cam_StarShootDSCI.h"
CameraStarShootDSCI::CameraStarShootDSCI()
{
Connected = false;
Name = _T("StarShoot DSCI");
- FullSize = wxSize(782,582); // This is *after* squaring
+ FullSize = wxSize(782, 582); // This is *after* squaring
HasGainControl = true;
- RawX = 752; // Also re-set in connect routine
+ RawX = 752; // Also re-set in connect routine
RawY = 582;
XPixelSize = 6.5;
YPixelSize = 6.25;
@@ -69,7 +69,7 @@ bool CameraStarShootDSCI::Connect(const wxString& camId)
{
// returns true on error
- CameraDLL = LoadLibrary(TEXT("DSCI")); // load the DLL
+ CameraDLL = LoadLibrary(TEXT("DSCI")); // load the DLL
if (!CameraDLL)
return CamConnectFailed(wxT("Can't find DSCI.dll"));
@@ -77,59 +77,69 @@ bool CameraStarShootDSCI::Connect(const wxString& camId)
// assign functions
B_V_DLLFUNC OCP_openUSB = (B_V_DLLFUNC) GetProcAddress(CameraDLL, "openUSB");
- if (!OCP_openUSB) {
+ if (!OCP_openUSB)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(_("Didn't find openUSB in DLL"));
}
bool retval = OCP_openUSB();
- if (!retval) {
+ if (!retval)
+ {
FreeLibrary(CameraDLL);
return true;
}
// Good to go, now get other functions
B_V_DLLFUNC OCP_isUSB2 = (B_V_DLLFUNC) GetProcAddress(CameraDLL, "IsUSB20");
- if (!OCP_isUSB2) {
+ if (!OCP_isUSB2)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("Didn't find %s in DLL"), "IsUSB20"));
}
UI_V_DLLFUNC OCP_Width = (UI_V_DLLFUNC) GetProcAddress(CameraDLL, "CAM_Width");
- if (!OCP_Width) {
+ if (!OCP_Width)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("Didn't find %s in DLL"), "CAM_Width"));
}
UI_V_DLLFUNC OCP_Height = (UI_V_DLLFUNC) GetProcAddress(CameraDLL, "CAM_Height");
- if (!OCP_Height) {
+ if (!OCP_Height)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("Didn't find %s in DLL"), "CAM_Height"));
}
- OCP_sendEP1_1BYTE = (V_V_DLLFUNC)GetProcAddress(CameraDLL,"sendEP1_1BYTE");
- if (!OCP_sendEP1_1BYTE) {
+ OCP_sendEP1_1BYTE = (V_V_DLLFUNC) GetProcAddress(CameraDLL, "sendEP1_1BYTE");
+ if (!OCP_sendEP1_1BYTE)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("Didn't find %s in DLL"), "sendEP1_1BYTE"));
}
- OCP_sendRegister = (OCPREGFUNC)GetProcAddress(CameraDLL,"sendRegister");
- if (!OCP_sendRegister) {
+ OCP_sendRegister = (OCPREGFUNC) GetProcAddress(CameraDLL, "sendRegister");
+ if (!OCP_sendRegister)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("Didn't find %s in DLL"), "sendRegister"));
}
- OCP_Exposure = (B_I_DLLFUNC)GetProcAddress(CameraDLL,"CAM_Exposure");
- if (!OCP_Exposure) {
+ OCP_Exposure = (B_I_DLLFUNC) GetProcAddress(CameraDLL, "CAM_Exposure");
+ if (!OCP_Exposure)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("Didn't find %s in DLL"), "CAM_Exposure"));
}
- OCP_Exposing = (B_V_DLLFUNC)GetProcAddress(CameraDLL,"CAM_Exposing");
- if (!OCP_Exposing) {
+ OCP_Exposing = (B_V_DLLFUNC) GetProcAddress(CameraDLL, "CAM_Exposing");
+ if (!OCP_Exposing)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("Didn't find %s in DLL"), "CAM_Exposing"));
}
- OCP_ProcessedBuffer = (USP_V_DLLFUNC)GetProcAddress(CameraDLL,"CAM_ProcessedBuffer");
- if (!OCP_ProcessedBuffer) {
+ OCP_ProcessedBuffer = (USP_V_DLLFUNC) GetProcAddress(CameraDLL, "CAM_ProcessedBuffer");
+ if (!OCP_ProcessedBuffer)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("Didn't find %s in DLL"), "CAM_ProcessedBuffer"));
}
@@ -154,19 +164,21 @@ bool CameraStarShootDSCI::Capture(int duration, usImage& img, int options, const
unsigned char retval = 0;
if (duration != lastdur)
{
- retval = OCP_sendRegister(duration,0,(unsigned char) (GuideCameraGain * 63 / 100),120,true,0,false,false,false,false,false,ampoff,false,false);
+ retval = OCP_sendRegister(duration, 0, (unsigned char) (GuideCameraGain * 63 / 100), 120, true, 0, false, false, false,
+ false, false, ampoff, false, false);
lastdur = duration;
}
- if (retval) {
+ if (retval)
+ {
pFrame->Alert(_("Problem sending register to StarShoot"));
return true;
}
if (USB2)
- retval = OCP_Exposure(1); // Start USB2 exposure
+ retval = OCP_Exposure(1); // Start USB2 exposure
else
- retval = OCP_Exposure(0); // Start USB1.1 exposure
+ retval = OCP_Exposure(0); // Start USB1.1 exposure
if (!retval)
{
@@ -191,12 +203,12 @@ bool CameraStarShootDSCI::Capture(int duration, usImage& img, int options, const
return true;
}
- const unsigned short *rawptr = OCP_ProcessedBuffer(); // Copy raw data in
+ const unsigned short *rawptr = OCP_ProcessedBuffer(); // Copy raw data in
memcpy(img.ImageData, rawptr, img.NPixels * sizeof(unsigned short));
SubtractDark(img);
QuickLRecon(img);
- SquarePixels(img,XPixelSize,YPixelSize);
+ SquarePixels(img, XPixelSize, YPixelSize);
return false;
}
diff --git a/src/cam_StarShootDSCI.h b/src/cam_StarShootDSCI.h
index 545440810..159ff5e47 100644
--- a/src/cam_StarShootDSCI.h
+++ b/src/cam_StarShootDSCI.h
@@ -40,13 +40,13 @@
class CameraStarShootDSCI : public GuideCamera
{
- bool USB2; // Is it a USB2 connection?
- int RawX; // Raw size of array
+ bool USB2; // Is it a USB2 connection?
+ int RawX; // Raw size of array
int RawY;
int lastdur; // duration last asked for -- if same, don't need to resend registers
- float XPixelSize; // pixel dimensions - needed for squaring
+ float XPixelSize; // pixel dimensions - needed for squaring
float YPixelSize;
- HINSTANCE CameraDLL; // Handle to DLL
+ HINSTANCE CameraDLL; // Handle to DLL
V_V_DLLFUNC OCP_sendEP1_1BYTE;
OCPREGFUNC OCP_sendRegister;
B_I_DLLFUNC OCP_Exposure;
@@ -55,9 +55,9 @@ class CameraStarShootDSCI : public GuideCamera
public:
CameraStarShootDSCI();
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
bool HasNonGuiCapture() override { return true; }
wxByte BitsPerPixel() override;
};
diff --git a/src/cam_altair.cpp b/src/cam_altair.cpp
index 8a79b8daf..250443523 100644
--- a/src/cam_altair.cpp
+++ b/src/cam_altair.cpp
@@ -37,23 +37,25 @@
#ifdef ALTAIR
-#include "cam_altair.h"
-#include "altaircam.h"
+# include "cam_altair.h"
+# include "altaircam.h"
-#ifdef __WINDOWS__
+# ifdef __WINDOWS__
struct SDKLib
{
HMODULE m_module;
-#define SDK(f) \
- decltype(Altaircam_ ## f) *f;
-#define SDK_OPT(f) SDK(f)
-# include "cameras/altaircam_sdk.h"
-#undef SDK
-#undef SDK_OPT
+# define SDK(f) decltype(Altaircam_##f) *f;
+# define SDK_OPT(f) SDK(f)
+# include "cameras/altaircam_sdk.h"
+# undef SDK
+# undef SDK_OPT
- SDKLib() : m_module(nullptr) { }
+ SDKLib()
+ : m_module(nullptr)
+ {
+ }
~SDKLib() { Unload(); }
bool _Load(LPCTSTR filename, const char *prefix)
@@ -72,23 +74,27 @@ struct SDKLib
try
{
-#define _GPA(f) \
- std::ostringstream os; \
- os << prefix << #f; \
- std::string name = os.str(); \
- f = reinterpret_cast(GetProcAddress(m_module, name.c_str()))
-#define SDK(f) do { \
- _GPA(f); \
- if (!f) \
- throw name; \
- } while (false);
-#define SDK_OPT(f) do { \
- _GPA(f); \
- } while (false);
-# include "cameras/altaircam_sdk.h"
-#undef SDK
-#undef SDK_OPT
-#undef _GPA
+# define _GPA(f) \
+ std::ostringstream os; \
+ os << prefix << #f; \
+ std::string name = os.str(); \
+ f = reinterpret_cast(GetProcAddress(m_module, name.c_str()))
+# define SDK(f) \
+ do \
+ { \
+ _GPA(f); \
+ if (!f) \
+ throw name; \
+ } while (false);
+# define SDK_OPT(f) \
+ do \
+ { \
+ _GPA(f); \
+ } while (false);
+# include "cameras/altaircam_sdk.h"
+# undef SDK
+# undef SDK_OPT
+# undef _GPA
}
catch (const std::string& name)
{
@@ -102,15 +108,9 @@ struct SDKLib
return true;
}
- bool Load()
- {
- return _Load(_T("altaircam.dll"), "Altaircam_");
- }
+ bool Load() { return _Load(_T("altaircam.dll"), "Altaircam_"); }
- bool LoadLegacy()
- {
- return _Load(_T("AltairCam_legacy.dll"), "Toupcam_");
- }
+ bool LoadLegacy() { return _Load(_T("AltairCam_legacy.dll"), "Toupcam_"); }
void Unload()
{
@@ -122,11 +122,14 @@ struct SDKLib
}
};
-#endif // __WINDOWS__
+# endif // __WINDOWS__
struct AltairCamera : public GuideCamera
{
- enum { MAX_DISCARD_FRAMES = 5 };
+ enum
+ {
+ MAX_DISCARD_FRAMES = 5
+ };
AltairCamType m_type;
SDKLib m_sdk;
@@ -187,9 +190,8 @@ AltairCameraDlg::AltairCameraDlg(wxWindow *parent)
wxStaticBoxSizer *sbSizer3 = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Settings")), wxVERTICAL);
wxBoxSizer *sizer1 = new wxBoxSizer(wxHORIZONTAL);
- m_reduceRes = new wxCheckBox(this, wxID_ANY,
- wxString::Format(_("Reduced Resolution (by ~%d%%)"), 20),
- wxDefaultPosition, wxDefaultSize, 0);
+ m_reduceRes = new wxCheckBox(
+ this, wxID_ANY, wxString::Format(_("Reduced Resolution (by ~%d%%)"), 20), wxDefaultPosition, wxDefaultSize, 0);
sizer1->Add(m_reduceRes, 0, wxALL, 5);
sbSizer3->Add(sizer1);
@@ -199,8 +201,9 @@ AltairCameraDlg::AltairCameraDlg(wxWindow *parent)
int width = StringWidth(this, _T("00"));
m_framesToDiscard = pFrame->MakeSpinCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(width, -1),
wxSP_ARROW_KEYS, 0, AltairCamera::MAX_DISCARD_FRAMES, 0);
- m_framesToDiscard->SetToolTip(_("Discard this many frames whan capturing starts. "
- "Useful for preventing initial under-exposed frames interfering with automatic star selection."));
+ m_framesToDiscard->SetToolTip(
+ _("Discard this many frames whan capturing starts. "
+ "Useful for preventing initial under-exposed frames interfering with automatic star selection."));
sizer2->Add(m_framesToDiscard, 0, wxALL, 5);
sbSizer3->Add(sizer2);
@@ -229,16 +232,16 @@ static int GetConfigDiscardFrames()
}
AltairCamera::AltairCamera(AltairCamType type)
- :
- m_type(type),
- m_buffer(nullptr),
- m_capturing(false)
+ : m_type(type)
+ , m_buffer(nullptr)
+ , m_capturing(false)
{
Name = _T("Altair Camera");
Connected = false;
m_hasGuideOutput = true;
HasSubframes = false;
- HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to true later when the camera is connected
+ HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to
+ // true later when the camera is connected
PropertyDialogType = PROPDLG_WHEN_DISCONNECTED;
this->m_framesToDiscard = GetConfigDiscardFrames();
@@ -367,8 +370,7 @@ bool AltairCamera::Connect(const wxString& camIdArg)
bool hasSkip = (pai->model->flag & ALTAIRCAM_FLAG_BINSKIP_SUPPORTED) != 0;
m_isColor = (pai->model->flag & ALTAIRCAM_FLAG_MONO) == 0;
- Debug.Write(wxString::Format("ALTAIR: isColor = %d, hasROI = %d, hasSkip = %d\n",
- m_isColor, hasROI, hasSkip));
+ Debug.Write(wxString::Format("ALTAIR: isColor = %d, hasROI = %d, hasSkip = %d\n", m_isColor, hasROI, hasSkip));
int width, height;
if (FAILED(m_sdk.get_Resolution(m_handle, 0, &width, &height)))
@@ -378,7 +380,8 @@ bool AltairCamera::Connect(const wxString& camIdArg)
}
delete[] m_buffer;
- m_buffer = new unsigned char[width * height]; // new SDK has issues with some ROI functions needing full resolution buffer size
+ m_buffer =
+ new unsigned char[width * height]; // new SDK has issues with some ROI functions needing full resolution buffer size
m_reduceResolution = pConfig->Profile.GetBoolean("/camera/Altair/ReduceResolution", false);
if (hasROI && m_reduceResolution)
@@ -415,7 +418,7 @@ bool AltairCamera::Connect(const wxString& camIdArg)
m_sdk.put_Option(m_handle, ALTAIRCAM_OPTION_RAW, 1);
-#if 0
+# if 0
// TODO: this is the initiailization code copied from cam_touptek.cpp
// I was hoping this one of these might help with the problem of the first
// frame exposure being very low, but it had no effect. Leaving these
@@ -435,14 +438,13 @@ bool AltairCamera::Connect(const wxString& camIdArg)
m_sdk.put_Option(m_handle, ALTAIRCAM_OPTION_FFC, 0);
m_sdk.put_Option(m_handle, ALTAIRCAM_OPTION_DFC, 0);
m_sdk.put_Option(m_handle, ALTAIRCAM_OPTION_SHARPENING, 0);
-#endif
+# endif
m_sdk.put_AutoExpoEnable(m_handle, 0);
m_frame = wxRect(FullSize);
- Debug.Write(wxString::Format("Altair: frame (%d,%d)+(%d,%d)\n",
- m_frame.x, m_frame.y, m_frame.width, m_frame.height));
+ Debug.Write(wxString::Format("Altair: frame (%d,%d)+(%d,%d)\n", m_frame.x, m_frame.y, m_frame.width, m_frame.height));
if (hasROI && m_reduceResolution)
{
@@ -468,7 +470,7 @@ bool AltairCamera::GetDevicePixelSize(double *devPixelSize)
return true;
*devPixelSize = m_devicePixelSize;
- return false; // Pixel size is known in any case
+ return false; // Pixel size is known in any case
}
void AltairCamera::ShowPropertyDialog()
@@ -523,21 +525,21 @@ void __stdcall CameraCallback(unsigned int event, void *pCallbackCtx)
}
}
-//static void flush_buffered_image(int cameraId, usImage& img)
+// static void flush_buffered_image(int cameraId, usImage& img)
//{
-// enum { NUM_IMAGE_BUFFERS = 2 }; // camera has 2 internal frame buffers
+// enum { NUM_IMAGE_BUFFERS = 2 }; // camera has 2 internal frame buffers
//
-// // clear buffered frames if any
+// // clear buffered frames if any
//
-// for (unsigned int num_cleared = 0; num_cleared < NUM_IMAGE_BUFFERS; num_cleared++)
-// {
-// ASI_ERROR_CODE status = ASIGetVideoData(cameraId, (unsigned char *) img.ImageData, img.NPixels * sizeof(unsigned short), 0);
-// if (status != ASI_SUCCESS)
-// break; // no more buffered frames
+// for (unsigned int num_cleared = 0; num_cleared < NUM_IMAGE_BUFFERS; num_cleared++)
+// {
+// ASI_ERROR_CODE status = ASIGetVideoData(cameraId, (unsigned char *) img.ImageData, img.NPixels * sizeof(unsigned
+// short), 0); if (status != ASI_SUCCESS)
+// break; // no more buffered frames
//
-// Debug.Write(wxString::Format("Altair: getimagedata clearbuf %u ret %d\n", num_cleared + 1, status));
-// }
-//}
+// Debug.Write(wxString::Format("Altair: getimagedata clearbuf %u ret %d\n", num_cleared + 1, status));
+// }
+// }
bool AltairCamera::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
@@ -552,8 +554,7 @@ bool AltairCamera::Capture(int duration, usImage& img, int options, const wxRect
long exposureUS = duration * 1000;
unsigned int cur_exp;
- if (m_sdk.get_ExpoTime(m_handle, &cur_exp) == 0 &&
- cur_exp != exposureUS)
+ if (m_sdk.get_ExpoTime(m_handle, &cur_exp) == 0 && cur_exp != exposureUS)
{
Debug.Write(wxString::Format("Altair: set CONTROL_EXPOSURE %d\n", exposureUS));
m_sdk.put_ExpoTime(m_handle, exposureUS);
@@ -561,8 +562,7 @@ bool AltairCamera::Capture(int duration, usImage& img, int options, const wxRect
long new_gain = cam_gain(m_minGain, m_maxGain, GuideCameraGain);
unsigned short cur_gain;
- if (m_sdk.get_ExpoAGain(m_handle, &cur_gain) == 0 &&
- new_gain != cur_gain)
+ if (m_sdk.get_ExpoAGain(m_handle, &cur_gain) == 0 && new_gain != cur_gain)
{
Debug.Write(wxString::Format("Altair: set CONTROL_GAIN %d%% %d\n", GuideCameraGain, new_gain));
m_sdk.put_ExpoAGain(m_handle, new_gain);
@@ -601,11 +601,11 @@ bool AltairCamera::Capture(int duration, usImage& img, int options, const wxRect
CameraWatchdog watchdog(duration, duration + GetTimeoutMs() + 10000); // total timeout is 2 * duration + 15s (typically)
// do not wait here, as we will miss a frame most likely, leading to poor flow of frames.
-// if (WorkerThread::MilliSleep(duration, WorkerThread::INT_ANY) &&
-// (WorkerThread::TerminateRequested() || StopCapture()))
-// {
-// return true;
-// }
+ // if (WorkerThread::MilliSleep(duration, WorkerThread::INT_ANY) &&
+ // (WorkerThread::TerminateRequested() || StopCapture()))
+ // {
+ // return true;
+ // }
while (true) // PullImage retry loop
{
diff --git a/src/cam_ascom.cpp b/src/cam_ascom.cpp
index 3cd5e9a0a..a726083f9 100644
--- a/src/cam_ascom.cpp
+++ b/src/cam_ascom.cpp
@@ -37,19 +37,19 @@
#if defined(ASCOM_CAMERA)
-#include "camera.h"
-#include "comdispatch.h"
-#include "time.h"
-#include "image_math.h"
-#include
-#include
-#include
-#include
+# include "camera.h"
+# include "comdispatch.h"
+# include "time.h"
+# include "image_math.h"
+# include
+# include
+# include
+# include
-#include "cam_ascom.h"
+# include "cam_ascom.h"
-#include
-#include
+# include
+# include
class CameraASCOM : public GuideCamera
{
@@ -68,27 +68,25 @@ class CameraASCOM : public GuideCamera
double m_driverPixelSize;
public:
-
bool Color;
CameraASCOM(const wxString& choice);
~CameraASCOM();
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool HasNonGuiCapture() override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- void ShowPropertyDialog() override;
- bool ST4PulseGuideScope(int direction, int duration) override;
- wxByte BitsPerPixel() override;
- bool GetDevicePixelSize(double *devPixelSize) override;
- bool SetCoolerOn(bool on) override;
- bool SetCoolerSetpoint(double temperature) override;
- bool GetCoolerStatus(bool *on, double *setpoint, double *power, double *temperature) override;
- bool GetSensorTemperature(double *temperature) override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool HasNonGuiCapture() override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ void ShowPropertyDialog() override;
+ bool ST4PulseGuideScope(int direction, int duration) override;
+ wxByte BitsPerPixel() override;
+ bool GetDevicePixelSize(double *devPixelSize) override;
+ bool SetCoolerOn(bool on) override;
+ bool SetCoolerSetpoint(double temperature) override;
+ bool GetCoolerStatus(bool *on, double *setpoint, double *power, double *temperature) override;
+ bool GetSensorTemperature(double *temperature) override;
private:
-
bool Create(DispatchObj *obj, DispatchClass *cls);
bool AbortExposure();
@@ -97,11 +95,8 @@ class CameraASCOM : public GuideCamera
};
// Frequently used IDs
-static DISPID dispid_setxbin, dispid_setybin, dispid_startx, dispid_starty,
- dispid_numx, dispid_numy,
- dispid_startexposure, dispid_abortexposure, dispid_stopexposure,
- dispid_imageready, dispid_imagearray,
- dispid_ispulseguiding, dispid_pulseguide,
+static DISPID dispid_setxbin, dispid_setybin, dispid_startx, dispid_starty, dispid_numx, dispid_numy, dispid_startexposure,
+ dispid_abortexposure, dispid_stopexposure, dispid_imageready, dispid_imagearray, dispid_ispulseguiding, dispid_pulseguide,
dispid_cooleron, dispid_coolerpower, dispid_ccdtemperature, dispid_setccdtemperature;
inline static void LogExcep(HRESULT hr, const wxString& prefix, const EXCEPINFO& excep)
@@ -125,20 +120,20 @@ static bool ASCOM_SetBin(IDispatch *cam, int binning, EXCEPINFO *excep)
DISPPARAMS dispParms;
dispParms.cArgs = 1;
dispParms.rgvarg = rgvarg;
- dispParms.cNamedArgs = 1; // PropPut kludge
+ dispParms.cNamedArgs = 1; // PropPut kludge
dispParms.rgdispidNamedArgs = &dispidNamed;
Variant vRes;
HRESULT hr;
- if (FAILED(hr = cam->Invoke(dispid_setxbin, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
- &dispParms, &vRes, excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(
+ dispid_setxbin, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &dispParms, &vRes, excep, nullptr)))
{
LogExcep(hr, "invoke setxbin", *excep);
return true;
}
- if (FAILED(hr = cam->Invoke(dispid_setybin, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
- &dispParms, &vRes, excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(
+ dispid_setybin, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &dispParms, &vRes, excep, nullptr)))
{
LogExcep(hr, "invoke setybin", *excep);
return true;
@@ -158,39 +153,39 @@ static bool ASCOM_SetROI(IDispatch *cam, const wxRect& roi, EXCEPINFO *excep)
DISPPARAMS dispParms;
dispParms.cArgs = 1;
dispParms.rgvarg = rgvarg;
- dispParms.cNamedArgs = 1; // PropPut kludge
+ dispParms.cNamedArgs = 1; // PropPut kludge
dispParms.rgdispidNamedArgs = &dispidNamed;
Variant vRes;
HRESULT hr;
rgvarg[0].lVal = roi.GetLeft();
- if (FAILED(hr = cam->Invoke(dispid_startx, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
- &dispParms, &vRes, excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(
+ dispid_startx, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &dispParms, &vRes, excep, nullptr)))
{
LogExcep(hr, "set startx", *excep);
return true;
}
rgvarg[0].lVal = roi.GetTop();
- if (FAILED(hr = cam->Invoke(dispid_starty, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
- &dispParms, &vRes, excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(
+ dispid_starty, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &dispParms, &vRes, excep, nullptr)))
{
LogExcep(hr, "set starty", *excep);
return true;
}
rgvarg[0].lVal = roi.GetWidth();
- if (FAILED(hr = cam->Invoke(dispid_numx, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
- &dispParms, &vRes, excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(
+ dispid_numx, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &dispParms, &vRes, excep, nullptr)))
{
LogExcep(hr, "set numx", *excep);
return true;
}
rgvarg[0].lVal = roi.GetHeight();
- if (FAILED(hr = cam->Invoke(dispid_numy, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
- &dispParms, &vRes, excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(
+ dispid_numy, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &dispParms, &vRes, excep, nullptr)))
{
LogExcep(hr, "set numy", *excep);
return true;
@@ -212,8 +207,8 @@ static bool ASCOM_AbortExposure(IDispatch *cam, EXCEPINFO *excep)
Variant vRes;
HRESULT hr;
- if (FAILED(hr = cam->Invoke(dispid_abortexposure, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
- &dispParms, &vRes, excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(
+ dispid_abortexposure, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispParms, &vRes, excep, nullptr)))
{
LogExcep(hr, "invoke abortexposure", *excep);
return true;
@@ -235,8 +230,8 @@ static bool ASCOM_StopExposure(IDispatch *cam, EXCEPINFO *excep)
Variant vRes;
HRESULT hr;
- if (FAILED(hr = cam->Invoke(dispid_stopexposure, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
- &dispParms, &vRes, excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(
+ dispid_stopexposure, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispParms, &vRes, excep, nullptr)))
{
LogExcep(hr, "invoke stopexposure", *excep);
return true;
@@ -251,7 +246,7 @@ static bool ASCOM_StartExposure(IDispatch *cam, double duration, bool dark, EXCE
VARIANTARG rgvarg[2];
rgvarg[1].vt = VT_R8;
- rgvarg[1].dblVal = duration;
+ rgvarg[1].dblVal = duration;
rgvarg[0].vt = VT_BOOL;
rgvarg[0].boolVal = dark ? VARIANT_FALSE : VARIANT_TRUE;
@@ -264,8 +259,8 @@ static bool ASCOM_StartExposure(IDispatch *cam, double duration, bool dark, EXCE
Variant vRes;
HRESULT hr;
- if (FAILED(hr = cam->Invoke(dispid_startexposure, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
- &dispParms, &vRes, excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(
+ dispid_startexposure, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispParms, &vRes, excep, nullptr)))
{
LogExcep(hr, "invoke startexposure", *excep);
return true;
@@ -287,8 +282,8 @@ static bool ASCOM_ImageReady(IDispatch *cam, bool *ready, EXCEPINFO *excep)
Variant vRes;
HRESULT hr;
- if (FAILED(hr = cam->Invoke(dispid_imageready, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
- &dispParms, &vRes, excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(
+ dispid_imageready, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dispParms, &vRes, excep, nullptr)))
{
LogExcep(hr, "invoke imageready", *excep);
return true;
@@ -298,8 +293,8 @@ static bool ASCOM_ImageReady(IDispatch *cam, bool *ready, EXCEPINFO *excep)
return false;
}
-static bool ASCOM_Image(IDispatch *cam, usImage& img, bool is_subframe, const wxRect& roi,
- wxSize *size, const wxSize& max_size, bool *swap_axes, EXCEPINFO *excep)
+static bool ASCOM_Image(IDispatch *cam, usImage& img, bool is_subframe, const wxRect& roi, wxSize *size, const wxSize& max_size,
+ bool *swap_axes, EXCEPINFO *excep)
{
// returns true on error, false if OK
@@ -312,8 +307,8 @@ static bool ASCOM_Image(IDispatch *cam, usImage& img, bool is_subframe, const wx
Variant vRes;
HRESULT hr;
- if (FAILED(hr = cam->Invoke(dispid_imagearray, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
- &dispParms, &vRes, excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(
+ dispid_imagearray, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dispParms, &vRes, excep, nullptr)))
{
LogExcep(hr, "invoke imagearray", *excep);
return true;
@@ -328,7 +323,7 @@ static bool ASCOM_Image(IDispatch *cam, usImage& img, bool is_subframe, const wx
SafeArrayGetLBound(rawarray, 2, &lbound2);
long *rawdata;
- hr = SafeArrayAccessData(rawarray, (void**)&rawdata);
+ hr = SafeArrayAccessData(rawarray, (void **) &rawdata);
if (hr != S_OK)
{
hr = SafeArrayDestroyData(rawarray);
@@ -340,8 +335,8 @@ static bool ASCOM_Image(IDispatch *cam, usImage& img, bool is_subframe, const wx
if (!is_subframe && !*swap_axes && xsize < ysize && max_size.x > max_size.y)
{
- Debug.Write(wxString::Format("ASCOM camera: array axes are flipped (%dx%d) vs (%dx%d)\n",
- xsize, ysize, max_size.x, max_size.y));
+ Debug.Write(wxString::Format(
+ "ASCOM camera: array axes are flipped (%dx%d) vs (%dx%d)\n", xsize, ysize, max_size.x, max_size.y));
*swap_axes = true;
}
@@ -414,10 +409,12 @@ static bool ASCOM_IsMoving(IDispatch *cam)
ExcepInfo excep;
Variant vRes;
- if (FAILED(hr = cam->Invoke(dispid_ispulseguiding, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dispParms, &vRes, &excep, nullptr)))
+ if (FAILED(hr = cam->Invoke(dispid_ispulseguiding, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dispParms, &vRes,
+ &excep, nullptr)))
{
LogExcep(hr, "invoke ispulseguiding", excep);
- pFrame->Alert(ExcepMsg(_("ASCOM driver failed checking IsPulseGuiding. See the debug log for more information."), excep));
+ pFrame->Alert(
+ ExcepMsg(_("ASCOM driver failed checking IsPulseGuiding. See the debug log for more information."), excep));
return false;
}
@@ -439,9 +436,7 @@ CameraASCOM::CameraASCOM(const wxString& choice)
m_bitsPerPixel = 0;
}
-CameraASCOM::~CameraASCOM()
-{
-}
+CameraASCOM::~CameraASCOM() { }
wxByte CameraASCOM::BitsPerPixel()
{
@@ -555,7 +550,10 @@ bool CameraASCOM::Connect(const wxString& camId)
struct ConnectInBg : public ConnectCameraInBg
{
CameraASCOM *cam;
- ConnectInBg(CameraASCOM *cam_) : cam(cam_) { }
+ ConnectInBg(CameraASCOM *cam_)
+ : cam(cam_)
+ {
+ }
bool Entry()
{
GITObjRef dobj(cam->m_gitEntry);
@@ -587,21 +585,27 @@ bool CameraASCOM::Connect(const wxString& camId)
if (!driver.GetProp(&vRes, L"CanPulseGuide"))
{
Debug.AddLine(ExcepMsg("CanPulseGuide", driver.Excep()));
- return CamConnectFailed(wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "CanPulseGuide"));
+ return CamConnectFailed(
+ wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."),
+ "CanPulseGuide"));
}
m_hasGuideOutput = ((vRes.boolVal != VARIANT_FALSE) ? true : false);
if (!driver.GetProp(&vRes, L"CanAbortExposure"))
{
Debug.AddLine(ExcepMsg("CanAbortExposure", driver.Excep()));
- return CamConnectFailed(wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "CanAbortExposure"));
+ return CamConnectFailed(
+ wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."),
+ "CanAbortExposure"));
}
m_canAbortExposure = vRes.boolVal != VARIANT_FALSE ? true : false;
if (!driver.GetProp(&vRes, L"CanStopExposure"))
{
Debug.AddLine(ExcepMsg("CanStopExposure", driver.Excep()));
- return CamConnectFailed(wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "CanStopExposure"));
+ return CamConnectFailed(
+ wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."),
+ "CanStopExposure"));
}
m_canStopExposure = vRes.boolVal != VARIANT_FALSE ? true : false;
@@ -616,14 +620,16 @@ bool CameraASCOM::Connect(const wxString& camId)
if (!driver.GetProp(&vRes, L"CameraXSize"))
{
Debug.AddLine(ExcepMsg("CameraXSize", driver.Excep()));
- return CamConnectFailed(wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "CameraXSize"));
+ return CamConnectFailed(wxString::Format(
+ _("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "CameraXSize"));
}
m_maxSize.SetWidth((int) vRes.lVal);
if (!driver.GetProp(&vRes, L"CameraYSize"))
{
Debug.AddLine(ExcepMsg("CameraYSize", driver.Excep()));
- return CamConnectFailed(wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "CameraYSize"));
+ return CamConnectFailed(wxString::Format(
+ _("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "CameraYSize"));
}
m_maxSize.SetHeight((int) vRes.lVal);
@@ -632,7 +638,7 @@ bool CameraASCOM::Connect(const wxString& camId)
if (!driver.GetProp(&vRes, L"MaxADU"))
{
Debug.AddLine(ExcepMsg("MaxADU", driver.Excep()));
- m_bitsPerPixel = 16; // assume 16 BPP
+ m_bitsPerPixel = 16; // assume 16 BPP
}
else
{
@@ -647,9 +653,8 @@ bool CameraASCOM::Connect(const wxString& camId)
DriverVersion = vRes.iVal;
}
- if (DriverVersion > 1 && // We can check the color sensor status of the cam
- driver.GetProp(&vRes, L"SensorType") &&
- vRes.iVal > 1)
+ if (DriverVersion > 1 && // We can check the color sensor status of the cam
+ driver.GetProp(&vRes, L"SensorType") && vRes.iVal > 1)
{
Color = true;
}
@@ -659,14 +664,16 @@ bool CameraASCOM::Connect(const wxString& camId)
if (!driver.GetProp(&vRes, L"PixelSizeX"))
{
Debug.AddLine(ExcepMsg("PixelSizeX", driver.Excep()));
- return CamConnectFailed(wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "PixelSizeX"));
+ return CamConnectFailed(wxString::Format(
+ _("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "PixelSizeX"));
}
m_driverPixelSize = vRes.dblVal;
if (!driver.GetProp(&vRes, L"PixelSizeY"))
{
Debug.AddLine(ExcepMsg("PixelSizeY", driver.Excep()));
- return CamConnectFailed(wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "PixelSizeY"));
+ return CamConnectFailed(wxString::Format(
+ _("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "PixelSizeY"));
}
m_driverPixelSize = wxMax(m_driverPixelSize, vRes.dblVal);
@@ -690,14 +697,18 @@ bool CameraASCOM::Connect(const wxString& camId)
if (!driver.GetProp(&vRes, L"CanSetCCDTemperature"))
{
Debug.AddLine(ExcepMsg("CanSetCCDTemperature", driver.Excep()));
- return CamConnectFailed(wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "CanSetCCDTemperature"));
+ return CamConnectFailed(wxString::Format(
+ _("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."),
+ "CanSetCCDTemperature"));
}
m_canSetCoolerTemperature = vRes.boolVal != VARIANT_FALSE ? true : false;
if (!driver.GetProp(&vRes, L"CanGetCoolerPower"))
{
Debug.AddLine(ExcepMsg("CanGetCoolerPower", driver.Excep()));
- return CamConnectFailed(wxString::Format(_("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."), "CanGetCoolerPower"));
+ return CamConnectFailed(wxString::Format(
+ _("ASCOM driver missing the %s property. Please report this error to your ASCOM driver provider."),
+ "CanGetCoolerPower"));
}
m_canGetCoolerPower = vRes.boolVal != VARIANT_FALSE ? true : false;
}
@@ -836,7 +847,8 @@ bool CameraASCOM::SetCoolerOn(bool on)
if (!cam.PutProp(dispid_cooleron, on))
{
Debug.AddLine(ExcepMsg(wxString::Format("ASCOM error turning camera cooler %s", on ? "on" : "off"), cam.Excep()));
- pFrame->Alert(ExcepMsg(wxString::Format(_("ASCOM error turning camera cooler %s"), on ? _("on") : _("off")), cam.Excep()));
+ pFrame->Alert(
+ ExcepMsg(wxString::Format(_("ASCOM error turning camera cooler %s"), on ? _("on") : _("off")), cam.Excep()));
return true;
}
@@ -1039,7 +1051,7 @@ bool CameraASCOM::Capture(int duration, usImage& img, int options, const wxRect&
bool takeDark = HasShutter && ShutterClosed;
// Start the exposure
- if (ASCOM_StartExposure(cam.IDisp(), (double)duration / 1000.0, takeDark, &excep))
+ if (ASCOM_StartExposure(cam.IDisp(), (double) duration / 1000.0, takeDark, &excep))
{
Debug.AddLine(ExcepMsg("ASCOM_StartExposure failed", excep));
pFrame->Alert(ExcepMsg(_("ASCOM error -- Cannot start exposure with given parameters"), excep));
@@ -1058,7 +1070,7 @@ bool CameraASCOM::Capture(int duration, usImage& img, int options, const wxRect&
}
}
- while (true) // wait for image to finish and d/l
+ while (true) // wait for image to finish and d/l
{
wxMilliSleep(20);
bool ready;
@@ -1071,8 +1083,7 @@ bool CameraASCOM::Capture(int duration, usImage& img, int options, const wxRect&
}
if (ready)
break;
- if (WorkerThread::InterruptRequested() &&
- (WorkerThread::TerminateRequested() || AbortExposure()))
+ if (WorkerThread::InterruptRequested() && (WorkerThread::TerminateRequested() || AbortExposure()))
{
return true;
}
@@ -1104,14 +1115,15 @@ bool CameraASCOM::ST4PulseGuideScope(int direction, int duration)
if (!m_hasGuideOutput)
return true;
- if (!pMount || !pMount->IsConnected()) return false;
+ if (!pMount || !pMount->IsConnected())
+ return false;
GITObjRef cam(m_gitEntry);
// Start the motion (which may stop on its own)
VARIANTARG rgvarg[2];
rgvarg[1].vt = VT_I2;
- rgvarg[1].iVal = direction;
+ rgvarg[1].iVal = direction;
rgvarg[0].vt = VT_I4;
rgvarg[0].lVal = (long) duration;
@@ -1127,14 +1139,14 @@ bool CameraASCOM::ST4PulseGuideScope(int direction, int duration)
Variant vRes;
HRESULT hr;
- if (FAILED(hr = cam.IDisp()->Invoke(dispid_pulseguide, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
- &dispParms, &vRes, &excep, nullptr)))
+ if (FAILED(hr = cam.IDisp()->Invoke(
+ dispid_pulseguide, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispParms, &vRes, &excep, nullptr)))
{
LogExcep(hr, "invoke pulseguide", excep);
return true;
}
- if (watchdog.Time() < duration) // likely returned right away and not after move - enter poll loop
+ if (watchdog.Time() < duration) // likely returned right away and not after move - enter poll loop
{
while (ASCOM_IsMoving(cam.IDisp()))
{
diff --git a/src/cam_ascom.h b/src/cam_ascom.h
index 45eeb0180..75fb40830 100644
--- a/src/cam_ascom.h
+++ b/src/cam_ascom.h
@@ -1,35 +1,35 @@
/*
-* cam_ascom.h
-* Open PHD Guiding
-*
-* Copyright (c) 2020 Andy Galasso.
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of openphdguiding.org nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * cam_ascom.h
+ * Open PHD Guiding
+ *
+ * Copyright (c) 2020 Andy Galasso.
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of openphdguiding.org nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#ifndef CAM_ASCOM_INCLUDED
#define CAM_ASCOM_INCLUDED
diff --git a/src/cam_atik16.cpp b/src/cam_atik16.cpp
index 97c734d67..81379f8bb 100644
--- a/src/cam_atik16.cpp
+++ b/src/cam_atik16.cpp
@@ -35,13 +35,13 @@
#if defined(ATIK16)
-#include "cam_atik16.h"
-#include "camera.h"
-#include "image_math.h"
+# include "cam_atik16.h"
+# include "camera.h"
+# include "image_math.h"
-#include
+# include
-#include "ArtemisHSCAPI.h"
+# include "ArtemisHSCAPI.h"
class CameraAtik16 : public GuideCamera
{
@@ -55,18 +55,18 @@ class CameraAtik16 : public GuideCamera
~CameraAtik16();
bool CanSelectCamera() const override { return true; }
- bool EnumCameras(wxArrayString& names, wxArrayString& ids) override;
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool HasNonGuiCapture() override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
+ bool EnumCameras(wxArrayString& names, wxArrayString& ids) override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool HasNonGuiCapture() override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
- bool ST4PulseGuideScope(int direction, int duration) override;
- void ClearGuidePort();
- wxByte BitsPerPixel() override;
+ bool ST4PulseGuideScope(int direction, int duration) override;
+ void ClearGuidePort();
+ wxByte BitsPerPixel() override;
- bool Color;
- bool HSModel;
+ bool Color;
+ bool HSModel;
private:
bool ST4HasNonGuiMove();
@@ -78,7 +78,7 @@ CameraAtik16::CameraAtik16(bool hsmodel, bool color)
{
Connected = false;
Name = _T("Atik 16");
- FullSize = wxSize(1280,1024);
+ FullSize = wxSize(1280, 1024);
m_hasGuideOutput = true;
HasGainControl = true;
Color = color;
@@ -151,9 +151,10 @@ bool CameraAtik16::Connect(const wxString& camId)
{
// returns true on error
- if (Cam_Handle) {
+ if (Cam_Handle)
+ {
Debug.Write("Already connected\n");
- return false; // Already connected
+ return false; // Already connected
}
wxString err;
if (!LoadDLL(&err))
@@ -173,7 +174,7 @@ bool CameraAtik16::Connect(const wxString& camId)
Cam_Handle = ArtemisConnect(devnum); // Connect to first avail camera
- if (!Cam_Handle) // Connection failed
+ if (!Cam_Handle) // Connection failed
{
return CamConnectFailed(wxString::Format(_("Atik camera connection failed - Driver version %d"), ArtemisAPIVersion()));
}
@@ -206,15 +207,15 @@ bool CameraAtik16::Connect(const wxString& camId)
int NumTempSensors;
int TECMin;
int TECMax;
- int level,setpoint;
+ int level, setpoint;
TECFlags = TECMin = TECMax = level = setpoint = 0;
- ArtemisTemperatureSensorInfo(Cam_Handle,0,&NumTempSensors);
+ ArtemisTemperatureSensorInfo(Cam_Handle, 0, &NumTempSensors);
ArtemisCoolingInfo(Cam_Handle, &TECFlags, &level, &TECMin, &TECMax, &setpoint);
if ((TECFlags & 0x04) && !(TECFlags & 0x08)) // On/off only, no setpoints
- setpoint = 1; // Turn it on
+ setpoint = 1; // Turn it on
else
- setpoint = 10 * 100; // should be 10C
+ setpoint = 10 * 100; // should be 10C
if (TECFlags & 0x02) // can be controlled
ArtemisSetCooling(Cam_Handle, setpoint);
@@ -232,29 +233,39 @@ bool CameraAtik16::Connect(const wxString& camId)
bool CameraAtik16::ST4PulseGuideScope(int direction, int duration)
{
int axis;
- //wxStopWatch swatch;
+ // wxStopWatch swatch;
// Output pins are NC, Com, RA+(W), Dec+(N), Dec-(S), RA-(E) ?? http://www.starlight-xpress.co.uk/faq.htm
- switch (direction) {
-/* case WEST: axis = ARTEMIS_GUIDE_WEST; break; // 0111 0000
- case NORTH: axis = ARTEMIS_GUIDE_NORTH; break; // 1011 0000
- case SOUTH: axis = ARTEMIS_GUIDE_SOUTH; break; // 1101 0000
- case EAST: axis = ARTEMIS_GUIDE_EAST; break; // 1110 0000*/
- case WEST: axis = 2; break; // 0111 0000
- case NORTH: axis = 0; break; // 1011 0000
- case SOUTH: axis = 1; break; // 1101 0000
- case EAST: axis = 3; break; // 1110 0000
- default: return true; // bad direction passed in
+ switch (direction)
+ {
+ /* case WEST: axis = ARTEMIS_GUIDE_WEST; break; // 0111 0000
+ case NORTH: axis = ARTEMIS_GUIDE_NORTH; break; // 1011 0000
+ case SOUTH: axis = ARTEMIS_GUIDE_SOUTH; break; // 1101 0000
+ case EAST: axis = ARTEMIS_GUIDE_EAST; break; // 1110 0000*/
+ case WEST:
+ axis = 2;
+ break; // 0111 0000
+ case NORTH:
+ axis = 0;
+ break; // 1011 0000
+ case SOUTH:
+ axis = 1;
+ break; // 1101 0000
+ case EAST:
+ axis = 3;
+ break; // 1110 0000
+ default:
+ return true; // bad direction passed in
}
- //swatch.Start();
- ArtemisPulseGuide(Cam_Handle,axis,duration); // returns after pulse
- //long t1 = swatch.Time();
- //wxMessageBox(wxString::Format("%ld",t1));
-/* ArtemisGuide(Cam_Handle,axis);
- wxMilliSleep(duration);
- ArtemisStopGuiding(Cam_Handle);*/
- //if (duration > 50) wxMilliSleep(duration - 50); // wait until it's mostly done
- //wxMilliSleep(duration + 10);
+ // swatch.Start();
+ ArtemisPulseGuide(Cam_Handle, axis, duration); // returns after pulse
+ // long t1 = swatch.Time();
+ // wxMessageBox(wxString::Format("%ld",t1));
+ /* ArtemisGuide(Cam_Handle,axis);
+ wxMilliSleep(duration);
+ ArtemisStopGuiding(Cam_Handle);*/
+ // if (duration > 50) wxMilliSleep(duration - 50); // wait until it's mostly done
+ // wxMilliSleep(duration + 10);
return false;
}
@@ -307,12 +318,14 @@ bool CameraAtik16::Capture(int duration, usImage& img, int options, const wxRect
return true;
}
- wxRect frame; // raw subframe to meet camera subframe requirements, may be a superset of the requested subframe - unbinned coords
- wxPoint subframePos; // position of PHD2 subframe within frame - binned coords
+ wxRect frame; // raw subframe to meet camera subframe requirements, may be a superset of the requested subframe - unbinned
+ // coords
+ wxPoint subframePos; // position of PHD2 subframe within frame - binned coords
if (useSubframe)
{
- // Round height up to next multiple of 2 to workaround bug where the camera returns incorrect data when the subframe height is odd.
+ // Round height up to next multiple of 2 to workaround bug where the camera returns incorrect data when the subframe
+ // height is odd.
int w = subframe.width * Binning;
int x = subframe.x * Binning;
if (w & 1)
@@ -361,8 +374,7 @@ bool CameraAtik16::Capture(int duration, usImage& img, int options, const wxRect
wxMilliSleep(100);
else
wxMilliSleep(30);
- if (WorkerThread::InterruptRequested() &&
- (WorkerThread::TerminateRequested() || StopCapture(Cam_Handle)))
+ if (WorkerThread::InterruptRequested() && (WorkerThread::TerminateRequested() || StopCapture(Cam_Handle)))
{
return true;
}
diff --git a/src/cam_atik16.h b/src/cam_atik16.h
index 641f54ffa..0283d6718 100644
--- a/src/cam_atik16.h
+++ b/src/cam_atik16.h
@@ -40,4 +40,4 @@ class AtikCameraFactory
static GuideCamera *MakeAtikCamera(bool hsModel, bool color);
};
-#endif //ATIK16DEF
+#endif // ATIK16DEF
diff --git a/src/cam_firewire.h b/src/cam_firewire.h
index 9c9102b37..48099cd0f 100644
--- a/src/cam_firewire.h
+++ b/src/cam_firewire.h
@@ -35,37 +35,36 @@
#ifndef FIREWIREDEF
#define FIREWIREDEF
-#if defined (__APPLE__)
-#include
-#include
-#elif defined (CLOSED_SOURCE)
-#include "tisudshl.h"
+#if defined(__APPLE__)
+# include
+# include
+#elif defined(CLOSED_SOURCE)
+# include "tisudshl.h"
#endif
class CameraFirewire : public GuideCamera
{
-#if defined (__APPLE__)
+#if defined(__APPLE__)
dc1394_t *m_dcContext;
dc1394camera_t *camera;
-#elif defined (CLOSED_SOURCE)
- DShowLib::Grabber* m_pGrabber;
+#elif defined(CLOSED_SOURCE)
+ DShowLib::Grabber *m_pGrabber;
DShowLib::tFrameHandlerSinkPtr pSink;
- DShowLib::tIVCDAbsoluteValuePropertyPtr m_pExposureAbs;
- DShowLib::tIVCDRangePropertyPtr m_pGain;
+ DShowLib::tIVCDAbsoluteValuePropertyPtr m_pExposureAbs;
+ DShowLib::tIVCDRangePropertyPtr m_pGain;
long GainMax;
#endif
public:
-
CameraFirewire();
~CameraFirewire();
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool HasNonGuiCapture() override;
- wxByte BitsPerPixel() override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- void InitCapture() override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool HasNonGuiCapture() override;
+ wxByte BitsPerPixel() override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ void InitCapture() override;
};
#endif
diff --git a/src/cam_firewire_IC.cpp b/src/cam_firewire_IC.cpp
index f05cc3ae9..b984e448b 100644
--- a/src/cam_firewire_IC.cpp
+++ b/src/cam_firewire_IC.cpp
@@ -34,27 +34,27 @@
#include "phd.h"
-#if defined (__WINDOWS__) && defined (FIREWIRE_CAMERA)
-#include "camera.h"
-#include "time.h"
-#include "image_math.h"
-#include
-#include
-#include
+#if defined(__WINDOWS__) && defined(FIREWIRE_CAMERA)
+# include "camera.h"
+# include "time.h"
+# include "image_math.h"
+# include
+# include
+# include
// Deal with 8-bit vs. 16-bit??
// Take care of gain capability
// Start stream in InitCapture()?
-#include "cam_firewire.h"
+# include "cam_firewire.h"
using namespace _DSHOWLIB_NAMESPACE;
CameraFirewire::CameraFirewire()
{
Connected = false;
Name = _T("The Imaging Source");
- FullSize = wxSize(1280,1024);
+ FullSize = wxSize(1280, 1024);
HasGainControl = true;
m_hasGuideOutput = false;
}
@@ -64,9 +64,9 @@ wxByte CameraFirewire::BitsPerPixel()
return 8;
}
-//CameraFirewire::~CameraFirewire () {
-// ;
-//}
+// CameraFirewire::~CameraFirewire () {
+// ;
+// }
bool CameraFirewire::Connect(const wxString& camId)
{
int CamNum, ModeNum;
@@ -77,158 +77,273 @@ bool CameraFirewire::Connect(const wxString& camId)
wxTextFile *debugfile;
int debugstep = 0;
- if (debug) {
- debugfile = new wxTextFile(Debug.GetLogDir() + PATHSEPSTR + wxString::Format("PHD_debug_%ld.txt",wxGetLocalTime()));
- if (debugfile->Exists()) debugfile->Open();
- else debugfile->Create();
+ if (debug)
+ {
+ debugfile = new wxTextFile(Debug.GetLogDir() + PATHSEPSTR + wxString::Format("PHD_debug_%ld.txt", wxGetLocalTime()));
+ if (debugfile->Exists())
+ debugfile->Open();
+ else
+ debugfile->Create();
wxDateTime now = wxDateTime::Now();
debugfile->AddLine(wxString::Format("DEBUG %s %s -- ", APPNAME, FULLVER) + now.FormatDate() + now.FormatTime());
}
- try {
- if (debug) { debugfile->AddLine(wxString::Format("1: Init library")); debugfile->Write(); }
+ try
+ {
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("1: Init library"));
+ debugfile->Write();
+ }
// Init the TIS library
- if( ! DShowLib::InitLibrary( "ISB3200016679" ) ) { // license key check
+ if (!DShowLib::InitLibrary("ISB3200016679"))
+ { // license key check
return CamConnectFailed(_("Cannot initialize ImageCapture library"));
}
- if (debug) { debugfile->AddLine(wxString::Format("2: Create grabber")); debugfile->Write(); }
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("2: Create grabber"));
+ debugfile->Write();
+ }
m_pGrabber = new DShowLib::Grabber();
- if (debug) { debugfile->AddLine(wxString::Format("3: Find cameras")); debugfile->Write(); }
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("3: Find cameras"));
+ debugfile->Write();
+ }
Grabber::tVidCapDevListPtr pVidCapDevList = m_pGrabber->getAvailableVideoCaptureDevices();
- if( pVidCapDevList == 0 || pVidCapDevList->empty() )
+ if (pVidCapDevList == 0 || pVidCapDevList->empty())
return CamConnectFailed(_("No camera found"));
int NCams = (int) pVidCapDevList->size();
- if (debug) { debugfile->AddLine(wxString::Format("4: Found %d cams",NCams)); debugfile->Write(); }
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("4: Found %d cams", NCams));
+ debugfile->Write();
+ }
// deal with > 1 cam
CamNum = 0;
- if (NCams > 1) {
- for( Grabber::tVidCapDevList::iterator it = pVidCapDevList->begin();
- it != pVidCapDevList->end(); ++it ) {
+ if (NCams > 1)
+ {
+ for (Grabber::tVidCapDevList::iterator it = pVidCapDevList->begin(); it != pVidCapDevList->end(); ++it)
+ {
Names.Add(it->toString());
}
- CamNum = wxGetSingleChoiceIndex(_("Select Camera"),_("Camera"),Names);
+ CamNum = wxGetSingleChoiceIndex(_("Select Camera"), _("Camera"), Names);
if (CamNum == -1)
return true;
}
// Open camera
- if (debug) { debugfile->AddLine(wxString::Format("5: Open Camera")); debugfile->Write(); }
- retval = m_pGrabber->openDev( pVidCapDevList->at( CamNum ) );
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("5: Open Camera"));
+ debugfile->Write();
+ }
+ retval = m_pGrabber->openDev(pVidCapDevList->at(CamNum));
if (!retval)
return CamConnectFailed(_("Cannot open camera"));
- if (debug) { debugfile->AddLine(wxString(pVidCapDevList->at(CamNum).toString())); debugfile->Write(); }
+ if (debug)
+ {
+ debugfile->AddLine(wxString(pVidCapDevList->at(CamNum).toString()));
+ debugfile->Write();
+ }
- if (debug) { debugfile->AddLine(wxString::Format("6: Get Video formats")); debugfile->Write(); }
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("6: Get Video formats"));
+ debugfile->Write();
+ }
// Get video formats
Grabber::tVidFmtListPtr pVidFmtList = m_pGrabber->getAvailableVideoFormats();
- if ((pVidFmtList == 0) || pVidFmtList->empty()) {
+ if ((pVidFmtList == 0) || pVidFmtList->empty())
+ {
m_pGrabber->closeDev();
return CamConnectFailed(_("Cannot get list of video modes"));
}
int NModes = pVidFmtList->size();
- if (debug) { debugfile->AddLine(wxString::Format("7: Found %d formats",NModes)); debugfile->Write(); }
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("7: Found %d formats", NModes));
+ debugfile->Write();
+ }
- // Names.Clear();
- // ModeNum = 0;
+ // Names.Clear();
+ // ModeNum = 0;
wxString Name;
- // if (NModes > 1) {
- ModeNum = -1;
- int i = 0;
- for( Grabber::tVidFmtList::iterator it = pVidFmtList->begin();
- it != pVidFmtList->end(); ++it, i++ ) {
- // Names.Add(it->toString());
- Name = wxString(it->toString());
- if (debug) {debugfile->AddLine(wxString(it->toString())); debugfile->Write(); }
- if (Name.Find("Y800") != wxNOT_FOUND) {
- ModeNum = i;
- break;
- }
+ // if (NModes > 1) {
+ ModeNum = -1;
+ int i = 0;
+ for (Grabber::tVidFmtList::iterator it = pVidFmtList->begin(); it != pVidFmtList->end(); ++it, i++)
+ {
+ // Names.Add(it->toString());
+ Name = wxString(it->toString());
+ if (debug)
+ {
+ debugfile->AddLine(wxString(it->toString()));
+ debugfile->Write();
}
- //ModeNum = wxGetSingleChoiceIndex(_T("Select Mode"),_T("Mode"),Names);
- if (ModeNum == -1) {
- return CamConnectFailed(_("Cannot find a Y800 mode"));
+ if (Name.Find("Y800") != wxNOT_FOUND)
+ {
+ ModeNum = i;
+ break;
}
- // }
+ }
+ // ModeNum = wxGetSingleChoiceIndex(_T("Select Mode"),_T("Mode"),Names);
+ if (ModeNum == -1)
+ {
+ return CamConnectFailed(_("Cannot find a Y800 mode"));
+ }
+ // }
- if (debug) { debugfile->AddLine(wxString::Format("8: Set format %d",ModeNum)); debugfile->Write(); }
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("8: Set format %d", ModeNum));
+ debugfile->Write();
+ }
// Set the video format
m_pGrabber->setVideoFormat(pVidFmtList->at(ModeNum));
// Set some more format things
- if (debug) { debugfile->AddLine(wxString::Format("9: Set FPS")); debugfile->Write(); }
- // retval = m_pGrabber->setFPS(7.5); // No need to run higher than this
- // if (!retval) wxMessageBox (_T("Could not set to 7.5 FPS"));
- if (debug) { debugfile->AddLine(wxString::Format("10: Turn off auto-exposure")); debugfile->Write(); }
- retval = m_pGrabber->setProperty(CameraControl_Exposure,false);
- if (!retval) {
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("9: Set FPS"));
+ debugfile->Write();
+ }
+ // retval = m_pGrabber->setFPS(7.5); // No need to run higher than this
+ // if (!retval) wxMessageBox (_T("Could not set to 7.5 FPS"));
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("10: Turn off auto-exposure"));
+ debugfile->Write();
+ }
+ retval = m_pGrabber->setProperty(CameraControl_Exposure, false);
+ if (!retval)
+ {
return CamConnectFailed(_("Could not turn off auto-exposure"));
}
// Setup the frame handler
- if (debug) { debugfile->AddLine(wxString::Format("11: Setup frame handler")); debugfile->Write(); }
- pSink = FrameHandlerSink::create(eY800, 4 ); // not sure why I even need 4...
- if (!pSink) {
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("11: Setup frame handler"));
+ debugfile->Write();
+ }
+ pSink = FrameHandlerSink::create(eY800, 4); // not sure why I even need 4...
+ if (!pSink)
+ {
return CamConnectFailed(_("Cannot setup frame handler"));
}
- if (debug) { debugstep = 1; debugfile->AddLine(wxString::Format("12: Set snap mode")); debugfile->Write(); }
- pSink->setSnapMode( true );
+ if (debug)
+ {
+ debugstep = 1;
+ debugfile->AddLine(wxString::Format("12: Set snap mode"));
+ debugfile->Write();
+ }
+ pSink->setSnapMode(true);
- if (debug) { debugstep = 2; debugfile->AddLine(wxString::Format("12a: Setting SinkType")); debugfile->Write(); }
+ if (debug)
+ {
+ debugstep = 2;
+ debugfile->AddLine(wxString::Format("12a: Setting SinkType"));
+ debugfile->Write();
+ }
retval = m_pGrabber->setSinkType(pSink);
- if (!retval) {
+ if (!retval)
+ {
Debug.Write("cam_firewire_IC: Could not set sink type\n");
return CamConnectFailed(_("FireWire camera setup failed"));
}
// Get info I need
- if (debug) { debugstep = 3; debugfile->AddLine(wxString::Format("12b: Getting name for mode %d",ModeNum)); debugfile->Write(); }
+ if (debug)
+ {
+ debugstep = 3;
+ debugfile->AddLine(wxString::Format("12b: Getting name for mode %d", ModeNum));
+ debugfile->Write();
+ }
Name = wxString(pVidCapDevList->at(CamNum).toString());
- if (debug) { debugstep = 4; debugfile->AddLine(_T(" Name: " + Name)); debugfile->Write(); }
- if (debug) { debugstep = 5; debugfile->AddLine(wxString::Format("12c: Getting size for mode %d",ModeNum)); debugfile->Write(); }
+ if (debug)
+ {
+ debugstep = 4;
+ debugfile->AddLine(_T(" Name: " + Name));
+ debugfile->Write();
+ }
+ if (debug)
+ {
+ debugstep = 5;
+ debugfile->AddLine(wxString::Format("12c: Getting size for mode %d", ModeNum));
+ debugfile->Write();
+ }
SIZE sz = pVidFmtList->at(ModeNum).getSize();
- if (debug) {debugstep = 6; debugfile->AddLine(_T("Size found - setting FullSize")); debugfile->Write(); }
- FullSize = wxSize((int)sz.cx, (int)sz.cy);
+ if (debug)
+ {
+ debugstep = 6;
+ debugfile->AddLine(_T("Size found - setting FullSize"));
+ debugfile->Write();
+ }
+ FullSize = wxSize((int) sz.cx, (int) sz.cy);
- if (debug) { debugstep = 7; debugfile->AddLine(wxString::Format("Image: %d %d Camera: ",FullSize.GetWidth(),FullSize.GetHeight()) + Name); debugfile->Write(); }
+ if (debug)
+ {
+ debugstep = 7;
+ debugfile->AddLine(wxString::Format("Image: %d %d Camera: ", FullSize.GetWidth(), FullSize.GetHeight()) + Name);
+ debugfile->Write();
+ }
// Get the stream prepared, but don't start yet - going to start/stop on each frame grab
- if (debug) { debugstep = 8; debugfile->AddLine(wxString::Format("13: Prepare Live")); debugfile->Write(); }
+ if (debug)
+ {
+ debugstep = 8;
+ debugfile->AddLine(wxString::Format("13: Prepare Live"));
+ debugfile->Write();
+ }
retval = m_pGrabber->prepareLive(false); // not using their renderer
- if (!retval) {
+ if (!retval)
+ {
return CamConnectFailed(_("Could not start Live view"));
}
// Get pointer to the exposure duration functin needed
- if (debug) { debugfile->AddLine(wxString::Format("14: Get VCD properties")); debugfile->Write(); }
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("14: Get VCD properties"));
+ debugfile->Write();
+ }
tIVCDPropertyItemsPtr pItems = m_pGrabber->getAvailableVCDProperties();
- if( pItems != 0 ) {
- tIVCDPropertyItemPtr pExposureItem = pItems->findItem( VCDID_Exposure );
- tIVCDPropertyElementPtr pExposureValueElement = pExposureItem->findElement( VCDElement_Value );
- if (pExposureValueElement != 0) {
+ if (pItems != 0)
+ {
+ tIVCDPropertyItemPtr pExposureItem = pItems->findItem(VCDID_Exposure);
+ tIVCDPropertyElementPtr pExposureValueElement = pExposureItem->findElement(VCDElement_Value);
+ if (pExposureValueElement != 0)
+ {
pExposureValueElement->getInterfacePtr(m_pExposureAbs);
- if (m_pExposureAbs == 0) {
+ if (m_pExposureAbs == 0)
+ {
pFrame->Alert(_("Warning - cannot directly control exposure duration - running in auto-exposure"));
- m_pGrabber->setProperty(CameraControl_Exposure,true);
+ m_pGrabber->setProperty(CameraControl_Exposure, true);
}
else
m_pExposureAbs->setValue(0.2);
}
- tIVCDPropertyItemPtr pGainItem = pItems->findItem( VCDID_Gain );
- tIVCDPropertyElementPtr pGainValueElement = pGainItem->findElement( VCDElement_Value );
- if (pGainValueElement != 0) {
+ tIVCDPropertyItemPtr pGainItem = pItems->findItem(VCDID_Gain);
+ tIVCDPropertyElementPtr pGainValueElement = pGainItem->findElement(VCDElement_Value);
+ if (pGainValueElement != 0)
+ {
pGainValueElement->getInterfacePtr(m_pGain);
- if (m_pGain == 0) {
+ if (m_pGain == 0)
+ {
pFrame->Alert(_T("Warning - cannot directly control gain - running in auto-gain"));
- // m_pGrabber->setProperty(CameraControl_Exposure,true);
+ // m_pGrabber->setProperty(CameraControl_Exposure,true);
}
- else {
+ else
+ {
GainMax = m_pGain->getRangeMax();
long lval = (long) GuideCameraGain * GainMax / 100;
if (lval > m_pGain->getRangeMax())
@@ -241,11 +356,22 @@ bool CameraFirewire::Connect(const wxString& camId)
}
}
} // try
- catch (...) {
- if (debug) { debugfile->AddLine(wxString::Format("Failed at %d",debugstep)); debugfile->Write(); debugfile->Close(); }
- return CamConnectFailed(wxString::Format(_("Fatal error at step %d connecting to TIS camera"),debugstep));
+ catch (...)
+ {
+ if (debug)
+ {
+ debugfile->AddLine(wxString::Format("Failed at %d", debugstep));
+ debugfile->Write();
+ debugfile->Close();
+ }
+ return CamConnectFailed(wxString::Format(_("Fatal error at step %d connecting to TIS camera"), debugstep));
+ }
+ if (debug)
+ {
+ debugfile->Write();
+ debugfile->Close();
+ delete debugfile;
}
- if (debug) {debugfile->Write(); debugfile->Close(); delete debugfile; }
Connected = true;
return false;
}
@@ -262,7 +388,8 @@ bool CameraFirewire::Disconnect()
void CameraFirewire::InitCapture()
{
// Set gain
- if (m_pGain != 0) {
+ if (m_pGain != 0)
+ {
long lval = (long) GuideCameraGain * GainMax / 100;
if (lval > m_pGain->getRangeMax())
lval = m_pGain->getRangeMax();
@@ -287,13 +414,15 @@ bool CameraFirewire::Capture(int duration, usImage& img, int options, const wxRe
}
unsigned short *dataptr = img.ImageData;
- if ((duration != programmed_dur) && (m_pExposureAbs != 0)) {
+ if ((duration != programmed_dur) && (m_pExposureAbs != 0))
+ {
m_pExposureAbs->setValue(duration / 1000.0);
programmed_dur = duration;
}
bool retval = m_pGrabber->startLive(false);
- if (!retval) {
+ if (!retval)
+ {
pFrame->Alert(_("Could not start video stream"));
return true;
}
@@ -302,20 +431,23 @@ bool CameraFirewire::Capture(int duration, usImage& img, int options, const wxRe
// grab the next frame
- Error err = pSink->snapImages( 1,15000 );
- if (err.getVal() == eTIMEOUT_PREMATURLY_ELAPSED) {
+ Error err = pSink->snapImages(1, 15000);
+ if (err.getVal() == eTIMEOUT_PREMATURLY_ELAPSED)
+ {
wxMilliSleep(200);
- err = pSink->snapImages( 1,15000 );
+ err = pSink->snapImages(1, 15000);
}
- if (err.getVal() == eTIMEOUT_PREMATURLY_ELAPSED) {
+ if (err.getVal() == eTIMEOUT_PREMATURLY_ELAPSED)
+ {
wxMilliSleep(200);
- err = pSink->snapImages( 1,15000 );
+ err = pSink->snapImages(1, 15000);
}
if (err.isError())
{
- DisconnectWithAlert(wxString::Format(_("Error capturing image: %d (%d) %s"),
- (int) err.getVal(), (int) eTIMEOUT_PREMATURLY_ELAPSED, wxString(err.c_str())), NO_RECONNECT);
+ DisconnectWithAlert(wxString::Format(_("Error capturing image: %d (%d) %s"), (int) err.getVal(),
+ (int) eTIMEOUT_PREMATURLY_ELAPSED, wxString(err.c_str())),
+ NO_RECONNECT);
return true;
}
unsigned char *imgptr = (unsigned char *) pSink->getLastAcqMemBuffer()->getPtr();
@@ -323,19 +455,20 @@ bool CameraFirewire::Capture(int duration, usImage& img, int options, const wxRe
for (unsigned int i = 0; i < img.NPixels; i++, dataptr++, imgptr++)
*dataptr = (unsigned short) *imgptr;
-/* if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &vframe)!=DC1394_SUCCESS) {
- DisconnectWithAlert(_("Cannot get a frame from the queue"));
- return true;
- }
- imgptr = vpFrame->image;
- for (unsigned int i = 0; i < img.NPixels; i++, dataptr++, imgptr++)
- *dataptr = (unsigned short) *imgptr;
- dc1394_capture_enqueue(camera, vframe); // release this frame
- */
+ /* if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &vframe)!=DC1394_SUCCESS) {
+ DisconnectWithAlert(_("Cannot get a frame from the queue"));
+ return true;
+ }
+ imgptr = vpFrame->image;
+ for (unsigned int i = 0; i < img.NPixels; i++, dataptr++, imgptr++)
+ *dataptr = (unsigned short) *imgptr;
+ dc1394_capture_enqueue(camera, vframe); // release this frame
+ */
m_pGrabber->suspendLive();
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
return false;
}
diff --git a/src/cam_firewire_OSX.cpp b/src/cam_firewire_OSX.cpp
index 023d1f9fa..8f8c7f713 100644
--- a/src/cam_firewire_OSX.cpp
+++ b/src/cam_firewire_OSX.cpp
@@ -34,11 +34,11 @@
#if defined(__APPLE__) && defined(FIREWIRE_CAMERA)
-#include "phd.h"
-#include "camera.h"
-#include "time.h"
-#include "image_math.h"
-#include
+# include "phd.h"
+# include "camera.h"
+# include "time.h"
+# include "image_math.h"
+# include
// Deal with 8-bit vs. 16-bit??
// Take care of gain capability
@@ -46,26 +46,28 @@
bool DCAM_flush_mode = true;
bool DCAM_start_stop_mode = true;
-#include "cam_firewire.h"
+# include "cam_firewire.h"
-CameraFirewire::CameraFirewire() : m_dcContext(0), camera(0)
+CameraFirewire::CameraFirewire()
+ : m_dcContext(0)
+ , camera(0)
{
Connected = false;
-// HaveBPMap = false;
-// NBadPixels=-1;
- Name=_T("The Imaging Source Firewire");
- FullSize = wxSize(1280,1024);
+ // HaveBPMap = false;
+ // NBadPixels=-1;
+ Name = _T("The Imaging Source Firewire");
+ FullSize = wxSize(1280, 1024);
HasGainControl = true;
m_hasGuideOutput = false;
}
CameraFirewire::~CameraFirewire()
{
- if(m_dcContext)
- {
- dc1394_free(m_dcContext);
- m_dcContext = 0;
- }
+ if (m_dcContext)
+ {
+ dc1394_free(m_dcContext);
+ m_dcContext = 0;
+ }
}
wxByte CameraFirewire::BitsPerPixel()
@@ -79,36 +81,40 @@ bool CameraFirewire::Connect(const wxString& camId)
uint32_t i;
dc1394video_mode_t vidmode;
- if(m_dcContext == 0)
+ if (m_dcContext == 0)
{
m_dcContext = dc1394_new();
}
- if(m_dcContext == 0)
+ if (m_dcContext == 0)
{
return CamConnectFailed(_("Error looking for Firewire / IEEE1394 cameras (internal error)"));
}
dc1394camera_list_t *cameras;
err = dc1394_camera_enumerate(m_dcContext, &cameras);
- if (err != DC1394_SUCCESS) { // && (err != DC1394_NO_CAMERA)) {
+ if (err != DC1394_SUCCESS)
+ { // && (err != DC1394_NO_CAMERA)) {
return CamConnectFailed(_("Error looking for Firewire / IEEE1394 cameras"));
}
- if (cameras->num == 0) {
+ if (cameras->num == 0)
+ {
return CamConnectFailed(_("No Firewire / IEEE1394 camera found"));
}
// Choose camera
CamNum = 0;
- if (cameras->num > 1) {
+ if (cameras->num > 1)
+ {
wxArrayString CamNames;
- for (i=0; inum; i++)
+ for (i = 0; i < cameras->num; i++)
{
dc1394camera_t *current_camera = dc1394_camera_new(m_dcContext, cameras->ids[i].guid);
CamNames.Add(wxString(current_camera->model));
dc1394_camera_free(current_camera);
}
- CamNum = wxGetSingleChoiceIndex(_T("Select Firewire camera"),("Camera name"),CamNames);
- if (CamNum == -1) {
+ CamNum = wxGetSingleChoiceIndex(_T("Select Firewire camera"), ("Camera name"), CamNames);
+ if (CamNum == -1)
+ {
dc1394_camera_free_list(cameras);
return true;
}
@@ -124,28 +130,33 @@ bool CameraFirewire::Connect(const wxString& camId)
// Get the highest-res mono mode
uint32_t w, h, max;
dc1394video_modes_t video_modes;
- dc1394_video_get_supported_modes(camera,&video_modes);
+ dc1394_video_get_supported_modes(camera, &video_modes);
dc1394color_coding_t coding;
bool HaveValid = false;
- w=h=max=0;
- for (i=0; i max) {
- max = w*h;
+ w = h = max = 0;
+ for (i = 0; i < video_modes.num; i++)
+ {
+ dc1394_get_image_size_from_video_mode(camera, video_modes.modes[i], &w, &h);
+ dc1394_get_color_coding_from_video_mode(camera, video_modes.modes[i], &coding);
+ if (coding == DC1394_COLOR_CODING_MONO8)
+ {
+ if ((w * h) > max)
+ {
+ max = w * h;
HaveValid = true;
vidmode = video_modes.modes[i];
}
}
}
- if (!HaveValid) {
+ if (!HaveValid)
+ {
dc1394_camera_free(camera);
return CamConnectFailed(_("Cannot find a suitable monochrome video mode"));
}
- if (dc1394_video_set_framerate(camera,DC1394_FRAMERATE_7_5)) {
+ if (dc1394_video_set_framerate(camera, DC1394_FRAMERATE_7_5))
+ {
dc1394_camera_free(camera);
return CamConnectFailed(_("Cannot set frame rate to 7.5 FPS"));
}
@@ -154,10 +165,11 @@ bool CameraFirewire::Connect(const wxString& camId)
dc1394_video_set_iso_speed(camera, DC1394_ISO_SPEED_400);
// Engage video mode
- dc1394_video_set_mode(camera,vidmode);
+ dc1394_video_set_mode(camera, vidmode);
// Setup DMA buffers for capture
- if (dc1394_capture_setup(camera,4,DC1394_CAPTURE_FLAGS_DEFAULT)) {
+ if (dc1394_capture_setup(camera, 4, DC1394_CAPTURE_FLAGS_DEFAULT))
+ {
dc1394_camera_free(camera);
return CamConnectFailed(_("Cannot setup DMA buffers"));
}
@@ -166,66 +178,71 @@ bool CameraFirewire::Connect(const wxString& camId)
long t1;
// Startup transmission to make sure we can do so
swatch.Start();
- if (dc1394_video_set_transmission(camera, DC1394_ON) != DC1394_SUCCESS) {
+ if (dc1394_video_set_transmission(camera, DC1394_ON) != DC1394_SUCCESS)
+ {
dc1394_camera_free(camera);
return CamConnectFailed(_("Cannot start transmission"));
}
dc1394switch_t status = DC1394_OFF;
- for (i=0; i<5; i++) {
+ for (i = 0; i < 5; i++)
+ {
wxMilliSleep(50);
dc1394_video_get_transmission(camera, &status);
- if (status != DC1394_OFF) break;
+ if (status != DC1394_OFF)
+ break;
}
t1 = swatch.Time();
- if (i==5) {
+ if (i == 5)
+ {
dc1394_camera_free(camera);
return CamConnectFailed(_("Transmission failed to start"));
}
-// dc1394_video_set_transmission(camera, DC1394_OFF); // turn it back off for now
+ // dc1394_video_set_transmission(camera, DC1394_OFF); // turn it back off for now
-// dc1394_feature_set_value(camera,DC1394_FEATURE_EXPOSURE,0); // turn off auto-exposure
+ // dc1394_feature_set_value(camera,DC1394_FEATURE_EXPOSURE,0); // turn off auto-exposure
-/* wxMilliSleep(500);
- dc1394video_frame_t *vframe;
+ /* wxMilliSleep(500);
+ dc1394video_frame_t *vframe;
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
- dc1394_capture_enqueue(camera, vframe);
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
- dc1394_capture_enqueue(camera, vframe);
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
- dc1394_capture_enqueue(camera, vframe);
-*/
+ dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
+ dc1394_capture_enqueue(camera, vframe);
+ dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
+ dc1394_capture_enqueue(camera, vframe);
+ dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
+ dc1394_capture_enqueue(camera, vframe);
+ */
// Setup my params
- dc1394_get_image_size_from_video_mode(camera,vidmode,&w,&h);
- FullSize = wxSize((int)w, (int)h);
+ dc1394_get_image_size_from_video_mode(camera, vidmode, &w, &h);
+ FullSize = wxSize((int) w, (int) h);
Name = wxString(camera->model);
-// wxMessageBox(Name + wxString::Format(" - %d x %d - %ld ms",FullSize.GetWidth(),FullSize.GetHeight(),t1));
-// dc1394feature_info_t feature;
+ // wxMessageBox(Name + wxString::Format(" - %d x %d - %ld ms",FullSize.GetWidth(),FullSize.GetHeight(),t1));
+ // dc1394feature_info_t feature;
// set shutter speed mode
- dc1394bool_t Present;
- dc1394_feature_has_absolute_control(camera,DC1394_FEATURE_SHUTTER,&Present);
- if (Present != DC1394_TRUE) {
+ dc1394bool_t Present;
+ dc1394_feature_has_absolute_control(camera, DC1394_FEATURE_SHUTTER, &Present);
+ if (Present != DC1394_TRUE)
+ {
pFrame->Alert("Cannot use absolute values to set exposures. Exposure durations will not be controlled properly");
}
dc1394_feature_set_mode(camera, DC1394_FEATURE_SHUTTER, DC1394_FEATURE_MODE_MANUAL);
- dc1394_feature_set_absolute_control(camera,DC1394_FEATURE_SHUTTER,DC1394_ON);
- dc1394_feature_set_absolute_value(camera,DC1394_FEATURE_SHUTTER,1.0);
+ dc1394_feature_set_absolute_control(camera, DC1394_FEATURE_SHUTTER, DC1394_ON);
+ dc1394_feature_set_absolute_value(camera, DC1394_FEATURE_SHUTTER, 1.0);
// Set gain to manual control
- dc1394_feature_set_mode(camera,DC1394_FEATURE_GAIN,DC1394_FEATURE_MODE_MANUAL);
+ dc1394_feature_set_mode(camera, DC1394_FEATURE_GAIN, DC1394_FEATURE_MODE_MANUAL);
if (DCAM_start_stop_mode)
dc1394_video_set_transmission(camera, DC1394_OFF);
-/* int ans = wxMessageBox("Enable flushing of buffer on each capture?",_T("Flush mode?"),wxYES_NO);
- if (ans == wxYES)
- DCAM_flush_mode = true;
- else
- DCAM_flush_mode = false;
-*/
+ /* int ans = wxMessageBox("Enable flushing of buffer on each capture?",_T("Flush mode?"),wxYES_NO);
+ if (ans == wxYES)
+ DCAM_flush_mode = true;
+ else
+ DCAM_flush_mode = false;
+ */
Connected = true;
return false;
}
@@ -237,15 +254,16 @@ void CameraFirewire::InitCapture()
uint32_t Max;
uint32_t NewVal;
- dc1394_feature_get_boundaries(camera,DC1394_FEATURE_GAIN,&Min,&Max);
+ dc1394_feature_get_boundaries(camera, DC1394_FEATURE_GAIN, &Min, &Max);
NewVal = GuideCameraGain * (Max - Min) / 100 + Min;
- dc1394_feature_set_value(camera,DC1394_FEATURE_GAIN, NewVal);
+ dc1394_feature_set_value(camera, DC1394_FEATURE_GAIN, NewVal);
}
bool CameraFirewire::Disconnect()
{
- if (camera) {
- dc1394_video_set_transmission(camera,DC1394_OFF);
+ if (camera)
+ {
+ dc1394_video_set_transmission(camera, DC1394_OFF);
dc1394_camera_free(camera);
camera = 0;
}
@@ -261,8 +279,10 @@ bool CameraFirewire::Capture(int duration, usImage& img, int options, const wxRe
int xsize = FullSize.GetWidth();
int ysize = FullSize.GetHeight();
- if (img.NPixels != (unsigned int)(xsize * ysize)) {
- if (img.Init(xsize, ysize)) {
+ if (img.NPixels != (unsigned int) (xsize * ysize))
+ {
+ if (img.Init(xsize, ysize))
+ {
DisconnectWithAlert(CAPT_FAIL_MEMORY);
return true;
}
@@ -270,94 +290,106 @@ bool CameraFirewire::Capture(int duration, usImage& img, int options, const wxRe
swatch.Start();
unsigned short *dataptr = img.ImageData;
- if (DCAM_start_stop_mode) {
+ if (DCAM_start_stop_mode)
+ {
dc1394_video_set_transmission(camera, DC1394_ON);
dc1394switch_t status = DC1394_OFF;
- for (int i=0; i<5; i++) {
+ for (int i = 0; i < 5; i++)
+ {
wxMilliSleep(10);
dc1394_video_get_transmission(camera, &status);
- if (status != DC1394_OFF) break;
+ if (status != DC1394_OFF)
+ break;
}
}
// Dequeue any existing
-/* dc1394_video_set_transmission(camera,DC1394_OFF);
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &frame);
- if (pFrame->frames_behind) dc1394_capture_enqueue(camera, frame);
- while (pFrame->frames_behind) {
+ /* dc1394_video_set_transmission(camera,DC1394_OFF);
dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &frame);
- dc1394_capture_enqueue(camera, frame);
- }*/
- if (duration != programmed_dur) {
- dc1394_feature_set_absolute_value(camera,DC1394_FEATURE_SHUTTER,(float) (duration) / 1000.0);
+ if (pFrame->frames_behind) dc1394_capture_enqueue(camera, frame);
+ while (pFrame->frames_behind) {
+ dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &frame);
+ dc1394_capture_enqueue(camera, frame);
+ }*/
+ if (duration != programmed_dur)
+ {
+ dc1394_feature_set_absolute_value(camera, DC1394_FEATURE_SHUTTER, (float) (duration) / 1000.0);
programmed_dur = duration;
}
dc1394video_frame_t *vframe = nullptr;
// Flush
- if (DCAM_flush_mode) {
+ if (DCAM_flush_mode)
+ {
vframe = nullptr;
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &vframe);
- if (vframe) dc1394_capture_enqueue(camera, vframe);
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &vframe);
- if (vframe) dc1394_capture_enqueue(camera, vframe);
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &vframe);
- if (vframe) dc1394_capture_enqueue(camera, vframe);
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &vframe);
- if (vframe) dc1394_capture_enqueue(camera, vframe);
+ dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_POLL, &vframe);
+ if (vframe)
+ dc1394_capture_enqueue(camera, vframe);
+ dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_POLL, &vframe);
+ if (vframe)
+ dc1394_capture_enqueue(camera, vframe);
+ dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_POLL, &vframe);
+ if (vframe)
+ dc1394_capture_enqueue(camera, vframe);
+ dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_POLL, &vframe);
+ if (vframe)
+ dc1394_capture_enqueue(camera, vframe);
}
/*
while (vframe && vpFrame->frames_behind) {
- pFrame->StatusMsg(wxString::Format("%d %d %d", (int) vpFrame->size[0], (int) vpFrame->image_bytes, (int) vpFrame->frames_behind));
- dc1394_capture_enqueue(camera, vframe);
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &vframe);
+ pFrame->StatusMsg(wxString::Format("%d %d %d", (int) vpFrame->size[0], (int) vpFrame->image_bytes, (int)
+ vpFrame->frames_behind)); dc1394_capture_enqueue(camera, vframe); dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL,
+ &vframe);
}*/
-/* dc1394_video_set_transmission(camera, DC1394_ON);
- dc1394switch_t status = DC1394_OFF;
- for (i=0; i<5; i++) {
- wxMilliSleep(50);
- dc1394_video_get_transmission(camera, &status);
- if (status != DC1394_OFF) break;
- }*/
+ /* dc1394_video_set_transmission(camera, DC1394_ON);
+ dc1394switch_t status = DC1394_OFF;
+ for (i=0; i<5; i++) {
+ wxMilliSleep(50);
+ dc1394_video_get_transmission(camera, &status);
+ if (status != DC1394_OFF) break;
+ }*/
-/*
- // Grab a short frame
- err = dc1394_feature_set_absolute_value(camera,DC1394_FEATURE_SHUTTER,0.001);
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
- dc1394_capture_enqueue(camera, vframe);
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
- dc1394_capture_enqueue(camera, vframe);
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
- dc1394_capture_enqueue(camera, vframe);
-
-*/
-
-/* wxMilliSleep(duration - 20);
- // Flush
- vframe = NULL;
- dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &vframe);
- if (vframe) dc1394_capture_enqueue(camera, vframe);
- while (vframe) {
+ /*
+ // Grab a short frame
+ err = dc1394_feature_set_absolute_value(camera,DC1394_FEATURE_SHUTTER,0.001);
+ dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
+ dc1394_capture_enqueue(camera, vframe);
+ dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
+ dc1394_capture_enqueue(camera, vframe);
+ dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_WAIT, &vframe);
+ dc1394_capture_enqueue(camera, vframe);
+
+ */
+
+ /* wxMilliSleep(duration - 20);
+ // Flush
+ vframe = NULL;
dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &vframe);
if (vframe) dc1394_capture_enqueue(camera, vframe);
- }
-*/
+ while (vframe) {
+ dc1394_capture_dequeue(camera,DC1394_CAPTURE_POLICY_POLL, &vframe);
+ if (vframe) dc1394_capture_enqueue(camera, vframe);
+ }
+ */
// grab the next frame
- if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &vframe) != DC1394_SUCCESS) {
+ if (dc1394_capture_dequeue(camera, DC1394_CAPTURE_POLICY_WAIT, &vframe) != DC1394_SUCCESS)
+ {
DisconnectWithAlert(_("Cannot get a frame from the queue"), NO_RECONNECT);
return true;
}
unsigned char *imgptr = vframe->image;
-// pFrame->StatusMsg(wxString::Format("%d %d %d",(int) vpFrame->frames_behind, (int) vpFrame->size[0], (int) vpFrame->size[1]));
+ // pFrame->StatusMsg(wxString::Format("%d %d %d",(int) vpFrame->frames_behind, (int) vpFrame->size[0], (int)
+ // vpFrame->size[1]));
for (unsigned int i = 0; i < img.NPixels; i++, dataptr++, imgptr++)
*dataptr = (unsigned short) *imgptr;
- dc1394_capture_enqueue(camera, vframe); // release this frame
-// pFrame->StatusMsg(wxString::Format("Behind: %lu Pos: %lu",vpFrame->frames_behind,vpFrame->id));
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ dc1394_capture_enqueue(camera, vframe); // release this frame
+ // pFrame->StatusMsg(wxString::Format("Behind: %lu Pos: %lu",vpFrame->frames_behind,vpFrame->id));
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
if (DCAM_start_stop_mode)
dc1394_video_set_transmission(camera, DC1394_OFF);
diff --git a/src/cam_indi.cpp b/src/cam_indi.cpp
index 59ef5ff9a..698b4753d 100644
--- a/src/cam_indi.cpp
+++ b/src/cam_indi.cpp
@@ -38,160 +38,159 @@
#ifdef INDI_CAMERA
-#include "cam_indi.h"
-#include "camera.h"
-#include "config_indi.h"
-#include "image_math.h"
-#include "indi_gui.h"
-#include
+# include "cam_indi.h"
+# include "camera.h"
+# include "config_indi.h"
+# include "image_math.h"
+# include "indi_gui.h"
+# include
-#include
-#include
+# include
+# include
class CapturedFrame
{
- public:
- void *m_data;
- size_t m_size;
- char m_format[MAXINDIBLOBFMT];
+public:
+ void *m_data;
+ size_t m_size;
+ char m_format[MAXINDIBLOBFMT];
- CapturedFrame()
- {
- m_data = nullptr;
- m_size = 0;
- m_format[0] = 0;
- }
+ CapturedFrame()
+ {
+ m_data = nullptr;
+ m_size = 0;
+ m_format[0] = 0;
+ }
- ~CapturedFrame()
- {
-#ifdef INDI_SHARED_BLOB_SUPPORT
- IDSharedBlobFree(m_data);
-#else
- free(m_data);
-#endif
- }
+ ~CapturedFrame()
+ {
+# ifdef INDI_SHARED_BLOB_SUPPORT
+ IDSharedBlobFree(m_data);
+# else
+ free(m_data);
+# endif
+ }
- // Take ownership of this blob's data, so INDI won't overwrite/free the memory
- void steal(IBLOB *bp)
- {
- m_data = bp->blob;
- m_size = bp->size;
- strncpy(m_format, bp->format, MAXINDIBLOBFMT);
+ // Take ownership of this blob's data, so INDI won't overwrite/free the memory
+ void steal(IBLOB *bp)
+ {
+ m_data = bp->blob;
+ m_size = bp->size;
+ strncpy(m_format, bp->format, MAXINDIBLOBFMT);
- bp->blob = nullptr;
- bp->size = 0;
- }
+ bp->blob = nullptr;
+ bp->size = 0;
+ }
};
class CameraINDI : public GuideCamera, public INDI::BaseClient
{
- private:
- ISwitchVectorProperty *connection_prop;
- INumberVectorProperty *expose_prop;
- INumberVectorProperty *frame_prop;
- INumber *frame_x;
- INumber *frame_y;
- INumber *frame_width;
- INumber *frame_height;
- ISwitchVectorProperty *frame_type_prop;
- INumberVectorProperty *ccdinfo_prop;
- INumberVectorProperty *binning_prop;
- INumber *binning_x;
- INumber *binning_y;
- ISwitchVectorProperty *video_prop;
- ITextVectorProperty *camera_port;
- INDI::BaseDevice camera_device;
- INumberVectorProperty *pulseGuideNS_prop;
- INumber *pulseN_prop;
- INumber *pulseS_prop;
- INumberVectorProperty *pulseGuideEW_prop;
- INumber *pulseE_prop;
- INumber *pulseW_prop;
-
- wxMutex sync_lock;
- wxCondition sync_cond;
- bool guide_active;
- GuideAxis guide_active_axis;
-
- IndiGui *m_gui;
-
- wxMutex m_lastFrame_lock;
- wxCondition m_lastFrame_cond;
- CapturedFrame *m_lastFrame;
-
- usImage *StackImg;
- int StackFrames;
- volatile bool stacking; // TODO: use a wxCondition to signal completion
- bool has_blob;
- bool has_old_videoprop;
- bool first_frame;
- volatile bool modal;
- bool ready;
- wxByte m_bitsPerPixel;
- double PixSize;
- double PixSizeX;
- double PixSizeY;
- wxRect m_maxSize;
- wxByte m_curBinning;
- bool HasBayer;
- long INDIport;
- wxString INDIhost;
- wxString INDICameraName;
- long INDICameraCCD;
- wxString INDICameraCCDCmd;
- wxString INDICameraBlobName;
- bool INDICameraForceVideo;
- bool INDICameraForceExposure;
- wxRect m_roi;
-
- bool ConnectToDriver(RunInBg *ctx);
- void SetCCDdevice();
- void ClearStatus();
- void CheckState();
- void CameraDialog();
- void CameraSetup();
- bool ReadFITS(CapturedFrame *cf, usImage& img, bool takeSubframe, const wxRect& subframe);
- bool StackStream(CapturedFrame *cf);
- void SendBinning();
-
- // Update the last frame, discarding any missed frame
- void updateLastFrame(IBLOB *bp);
-
- // Wait until a frame was acquired, for limited amout of time.
- // If non null is returned, caller is responsible for deletion
- CapturedFrame *waitFrame(unsigned long waitTime);
-
- protected:
- void newDevice(INDI::BaseDevice dp) override;
- void removeDevice(INDI::BaseDevice dp) override;
- void newProperty(INDI::Property property) override;
- void updateProperty(INDI::Property property) override;
- void removeProperty(INDI::Property property) override {}
- void newMessage(INDI::BaseDevice dp, int messageID) override;
- void serverConnected() override;
- void serverDisconnected(int exit_code) override;
-
- public:
- CameraINDI();
- ~CameraINDI();
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- bool HasNonGuiCapture() override;
- wxByte BitsPerPixel() override;
- bool GetDevicePixelSize(double *pixSize) override;
- void ShowPropertyDialog() override;
-
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
-
- bool ST4PulseGuideScope(int direction, int duration) override;
- bool ST4HasNonGuiMove() override;
+private:
+ ISwitchVectorProperty *connection_prop;
+ INumberVectorProperty *expose_prop;
+ INumberVectorProperty *frame_prop;
+ INumber *frame_x;
+ INumber *frame_y;
+ INumber *frame_width;
+ INumber *frame_height;
+ ISwitchVectorProperty *frame_type_prop;
+ INumberVectorProperty *ccdinfo_prop;
+ INumberVectorProperty *binning_prop;
+ INumber *binning_x;
+ INumber *binning_y;
+ ISwitchVectorProperty *video_prop;
+ ITextVectorProperty *camera_port;
+ INDI::BaseDevice camera_device;
+ INumberVectorProperty *pulseGuideNS_prop;
+ INumber *pulseN_prop;
+ INumber *pulseS_prop;
+ INumberVectorProperty *pulseGuideEW_prop;
+ INumber *pulseE_prop;
+ INumber *pulseW_prop;
+
+ wxMutex sync_lock;
+ wxCondition sync_cond;
+ bool guide_active;
+ GuideAxis guide_active_axis;
+
+ IndiGui *m_gui;
+
+ wxMutex m_lastFrame_lock;
+ wxCondition m_lastFrame_cond;
+ CapturedFrame *m_lastFrame;
+
+ usImage *StackImg;
+ int StackFrames;
+ volatile bool stacking; // TODO: use a wxCondition to signal completion
+ bool has_blob;
+ bool has_old_videoprop;
+ bool first_frame;
+ volatile bool modal;
+ bool ready;
+ wxByte m_bitsPerPixel;
+ double PixSize;
+ double PixSizeX;
+ double PixSizeY;
+ wxRect m_maxSize;
+ wxByte m_curBinning;
+ bool HasBayer;
+ long INDIport;
+ wxString INDIhost;
+ wxString INDICameraName;
+ long INDICameraCCD;
+ wxString INDICameraCCDCmd;
+ wxString INDICameraBlobName;
+ bool INDICameraForceVideo;
+ bool INDICameraForceExposure;
+ wxRect m_roi;
+
+ bool ConnectToDriver(RunInBg *ctx);
+ void SetCCDdevice();
+ void ClearStatus();
+ void CheckState();
+ void CameraDialog();
+ void CameraSetup();
+ bool ReadFITS(CapturedFrame *cf, usImage& img, bool takeSubframe, const wxRect& subframe);
+ bool StackStream(CapturedFrame *cf);
+ void SendBinning();
+
+ // Update the last frame, discarding any missed frame
+ void updateLastFrame(IBLOB *bp);
+
+ // Wait until a frame was acquired, for limited amout of time.
+ // If non null is returned, caller is responsible for deletion
+ CapturedFrame *waitFrame(unsigned long waitTime);
+
+protected:
+ void newDevice(INDI::BaseDevice dp) override;
+ void removeDevice(INDI::BaseDevice dp) override;
+ void newProperty(INDI::Property property) override;
+ void updateProperty(INDI::Property property) override;
+ void removeProperty(INDI::Property property) override { }
+ void newMessage(INDI::BaseDevice dp, int messageID) override;
+ void serverConnected() override;
+ void serverDisconnected(int exit_code) override;
+
+public:
+ CameraINDI();
+ ~CameraINDI();
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ bool HasNonGuiCapture() override;
+ wxByte BitsPerPixel() override;
+ bool GetDevicePixelSize(double *pixSize) override;
+ void ShowPropertyDialog() override;
+
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+
+ bool ST4PulseGuideScope(int direction, int duration) override;
+ bool ST4HasNonGuiMove() override;
};
CameraINDI::CameraINDI()
- :
- sync_cond(sync_lock),
- m_lastFrame_cond(m_lastFrame_lock),
- m_gui(nullptr)
+ : sync_cond(sync_lock)
+ , m_lastFrame_cond(m_lastFrame_lock)
+ , m_gui(nullptr)
{
m_lastFrame = nullptr;
ClearStatus();
@@ -317,149 +316,144 @@ void CameraINDI::updateProperty(INDI::Property property)
switch (property.getType())
{
- case INDI_SWITCH:
- {
- auto svp = property.getSwitch();
+ case INDI_SWITCH:
+ {
+ auto svp = property.getSwitch();
- if (INDIConfig::Verbose())
- Debug.Write(wxString::Format("INDI Camera Received Switch: %s = %i\n", svp->name, svp->sp->s));
+ if (INDIConfig::Verbose())
+ Debug.Write(wxString::Format("INDI Camera Received Switch: %s = %i\n", svp->name, svp->sp->s));
- if (strcmp(svp->name, "CONNECTION") == 0)
+ if (strcmp(svp->name, "CONNECTION") == 0)
+ {
+ ISwitch *connectswitch = IUFindSwitch(svp, "CONNECT");
+ if (connectswitch->s == ISS_ON)
{
- ISwitch *connectswitch = IUFindSwitch(svp, "CONNECT");
- if (connectswitch->s == ISS_ON)
- {
- Connected = true;
- CheckState();
- }
- else
- {
- if (ready)
- {
- ClearStatus();
-
- // call Disconnect in the main thread since that will
- // want to join the INDI worker thread which is
- // probably the current thread
-
- PhdApp::ExecInMainThread(
- [this]()
- {
- DisconnectWithAlert(_("INDI camera disconnected"), NO_RECONNECT);
- });
- }
- }
+ Connected = true;
+ CheckState();
}
-
- }
- break;
- case INDI_NUMBER:
- {
- auto nvp = property.getNumber();
-
- if (INDIConfig::Verbose())
+ else
{
- if (strcmp(nvp->name, "CCD_EXPOSURE") == 0 )
- {
- // rate limit this one, it's too noisy
- static double s_lastval;
- if (nvp->np->value > 0.0 && fabs(nvp->np->value - s_lastval) < 0.5)
- return;
- s_lastval = nvp->np->value;
- }
- std::ostringstream os;
- for (int i = 0; i < nvp->nnp; i++)
+ if (ready)
{
- if (i) os << ',';
- os << nvp->np[i].name << ':' << nvp->np[i].value;
+ ClearStatus();
+
+ // call Disconnect in the main thread since that will
+ // want to join the INDI worker thread which is
+ // probably the current thread
+
+ PhdApp::ExecInMainThread([this]() { DisconnectWithAlert(_("INDI camera disconnected"), NO_RECONNECT); });
}
- Debug.Write(wxString::Format("INDI Camera Received Number: %s = %s state = %s\n", nvp->name, os.str().c_str(),
- property.getStateAsString()));
}
+ }
+ }
+ break;
+ case INDI_NUMBER:
+ {
+ auto nvp = property.getNumber();
- if (nvp == ccdinfo_prop)
+ if (INDIConfig::Verbose())
+ {
+ if (strcmp(nvp->name, "CCD_EXPOSURE") == 0)
{
- PixSize = IUFindNumber(ccdinfo_prop, "CCD_PIXEL_SIZE")->value;
- PixSizeX = IUFindNumber(ccdinfo_prop, "CCD_PIXEL_SIZE_X")->value;
- PixSizeY = IUFindNumber(ccdinfo_prop, "CCD_PIXEL_SIZE_Y")->value;
- m_maxSize.x = IUFindNumber(ccdinfo_prop, "CCD_MAX_X")->value;
- m_maxSize.y = IUFindNumber(ccdinfo_prop, "CCD_MAX_Y")->value;
- // defer defining FullSize since it is not simply derivable from max size and binning
- // no: FullSize = wxSize(m_maxSize.x / Binning, m_maxSize.y / Binning);
- m_bitsPerPixel = IUFindNumber(ccdinfo_prop, "CCD_BITSPERPIXEL")->value;
+ // rate limit this one, it's too noisy
+ static double s_lastval;
+ if (nvp->np->value > 0.0 && fabs(nvp->np->value - s_lastval) < 0.5)
+ return;
+ s_lastval = nvp->np->value;
}
- else if (nvp == binning_prop)
+ std::ostringstream os;
+ for (int i = 0; i < nvp->nnp; i++)
{
- MaxBinning = wxMin(binning_x->max, binning_y->max);
- m_curBinning = wxMin(binning_x->value, binning_y->value);
- if (Binning > MaxBinning)
- Binning = MaxBinning;
- // defer defining FullSize since it is not simply derivable from max size and binning
- // no: FullSize = wxSize(m_maxSize.x / Binning, m_maxSize.y / Binning);
+ if (i)
+ os << ',';
+ os << nvp->np[i].name << ':' << nvp->np[i].value;
}
- else if (nvp == pulseGuideEW_prop || nvp == pulseGuideNS_prop)
+ Debug.Write(wxString::Format(
+ "INDI Camera Received Number: %s = %s state = %s\n", nvp->name, os.str().c_str(), property.getStateAsString()));
+ }
+
+ if (nvp == ccdinfo_prop)
+ {
+ PixSize = IUFindNumber(ccdinfo_prop, "CCD_PIXEL_SIZE")->value;
+ PixSizeX = IUFindNumber(ccdinfo_prop, "CCD_PIXEL_SIZE_X")->value;
+ PixSizeY = IUFindNumber(ccdinfo_prop, "CCD_PIXEL_SIZE_Y")->value;
+ m_maxSize.x = IUFindNumber(ccdinfo_prop, "CCD_MAX_X")->value;
+ m_maxSize.y = IUFindNumber(ccdinfo_prop, "CCD_MAX_Y")->value;
+ // defer defining FullSize since it is not simply derivable from max size and binning
+ // no: FullSize = wxSize(m_maxSize.x / Binning, m_maxSize.y / Binning);
+ m_bitsPerPixel = IUFindNumber(ccdinfo_prop, "CCD_BITSPERPIXEL")->value;
+ }
+ else if (nvp == binning_prop)
+ {
+ MaxBinning = wxMin(binning_x->max, binning_y->max);
+ m_curBinning = wxMin(binning_x->value, binning_y->value);
+ if (Binning > MaxBinning)
+ Binning = MaxBinning;
+ // defer defining FullSize since it is not simply derivable from max size and binning
+ // no: FullSize = wxSize(m_maxSize.x / Binning, m_maxSize.y / Binning);
+ }
+ else if (nvp == pulseGuideEW_prop || nvp == pulseGuideNS_prop)
+ {
+ bool notify = false;
{
- bool notify = false;
+ wxMutexLocker lck(sync_lock);
+ if (guide_active && nvp->s != IPS_BUSY &&
+ ((guide_active_axis == GUIDE_RA && nvp == pulseGuideEW_prop) ||
+ (guide_active_axis == GUIDE_DEC && nvp == pulseGuideNS_prop)))
{
- wxMutexLocker lck(sync_lock);
- if (guide_active && nvp->s != IPS_BUSY &&
- ((guide_active_axis == GUIDE_RA && nvp == pulseGuideEW_prop) ||
- (guide_active_axis == GUIDE_DEC && nvp == pulseGuideNS_prop)))
- {
- guide_active = false;
- notify = true;
- }
- else if (!guide_active && nvp->s == IPS_BUSY)
- {
- guide_active = true;
- guide_active_axis = nvp == pulseGuideEW_prop ? GUIDE_RA : GUIDE_DEC;
- }
+ guide_active = false;
+ notify = true;
+ }
+ else if (!guide_active && nvp->s == IPS_BUSY)
+ {
+ guide_active = true;
+ guide_active_axis = nvp == pulseGuideEW_prop ? GUIDE_RA : GUIDE_DEC;
}
- if (notify)
- sync_cond.Broadcast();
}
+ if (notify)
+ sync_cond.Broadcast();
}
- break;
- case INDI_TEXT:
- {
- auto tvp = property.getText();
-
- if (INDIConfig::Verbose())
- Debug.Write(wxString::Format("INDI Camera Received Text: %s = %s\n", tvp->name, tvp->tp->text));
+ }
+ break;
+ case INDI_TEXT:
+ {
+ auto tvp = property.getText();
- }
- break;
- case INDI_BLOB:
- {
- // we go here every time a new blob is available
- // this is normally the image from the camera
+ if (INDIConfig::Verbose())
+ Debug.Write(wxString::Format("INDI Camera Received Text: %s = %s\n", tvp->name, tvp->tp->text));
+ }
+ break;
+ case INDI_BLOB:
+ {
+ // we go here every time a new blob is available
+ // this is normally the image from the camera
- auto bvp = property.getBLOB();
- auto bp = bvp->at(0);
+ auto bvp = property.getBLOB();
+ auto bp = bvp->at(0);
- if (INDIConfig::Verbose())
- Debug.Write(wxString::Format("INDI Camera Received BLOB %s len=%d size=%d\n", bp->name, bp->bloblen, bp->size));
+ if (INDIConfig::Verbose())
+ Debug.Write(wxString::Format("INDI Camera Received BLOB %s len=%d size=%d\n", bp->name, bp->bloblen, bp->size));
- if (expose_prop && !INDICameraForceVideo)
+ if (expose_prop && !INDICameraForceVideo)
+ {
+ if (bp->name == INDICameraBlobName)
{
- if (bp->name == INDICameraBlobName)
- {
- updateLastFrame(bp);
- }
+ updateLastFrame(bp);
}
- else if (video_prop)
+ }
+ else if (video_prop)
+ {
+ if (modal && !stacking)
{
- if (modal && !stacking)
- {
- CapturedFrame cf;
- cf.steal(bp);
- StackStream(&cf);
- }
+ CapturedFrame cf;
+ cf.steal(bp);
+ StackStream(&cf);
}
}
+ }
+ break;
+ default:
break;
- default:
- break;
}
}
@@ -494,10 +488,10 @@ void CameraINDI::newProperty(INDI::Property property)
// set option to receive blob and messages for the selected CCD
setBLOBMode(B_ALSO, INDICameraName.mb_str(wxConvUTF8), INDICameraBlobName.mb_str(wxConvUTF8));
-#ifdef INDI_SHARED_BLOB_SUPPORT
+# ifdef INDI_SHARED_BLOB_SUPPORT
// Allow faster mode provided we don't modify the blob content or free/realloc it
enableDirectBlobAccess(INDICameraName.mb_str(wxConvUTF8), INDICameraBlobName.mb_str(wxConvUTF8));
-#endif
+# endif
}
}
else if (PropName == INDICameraCCDCmd + "EXPOSURE" && Proptype == INDI_NUMBER)
@@ -637,7 +631,10 @@ bool CameraINDI::Connect(const wxString& camId)
struct ConnectInBg : public ConnectCameraInBg
{
CameraINDI *cam;
- ConnectInBg(CameraINDI *cam_) : cam(cam_) { }
+ ConnectInBg(CameraINDI *cam_)
+ : cam(cam_)
+ {
+ }
bool Entry()
{
// Wait for driver to establish a device connection
@@ -655,7 +652,6 @@ bool CameraINDI::Connect(const wxString& camId)
// We need to return FALSE if we are successful
return !cam->Connected;
-
}
};
@@ -847,18 +843,11 @@ void CameraINDI::SetCCDdevice()
bool CameraINDI::ReadFITS(CapturedFrame *frame, usImage& img, bool takeSubframe, const wxRect& subframe)
{
- fitsfile *fptr; // FITS file pointer
- int status = 0; // CFITSIO status value MUST be initialized to zero!
+ fitsfile *fptr; // FITS file pointer
+ int status = 0; // CFITSIO status value MUST be initialized to zero!
// load blob to CFITSIO
- if (fits_open_memfile(&fptr,
- "",
- READONLY,
- &frame->m_data,
- &frame->m_size,
- 0,
- nullptr,
- &status))
+ if (fits_open_memfile(&fptr, "", READONLY, &frame->m_data, &frame->m_size, 0, nullptr, &status))
{
pFrame->Alert(_("Unsupported type or read error loading FITS file"));
return true;
@@ -897,7 +886,7 @@ bool CameraINDI::ReadFITS(CapturedFrame *frame, usImage& img, bool takeSubframe,
return true;
}
- long fpixel[3] = {1, 1, 1};
+ long fpixel[3] = { 1, 1, 1 };
if (takeSubframe)
{
@@ -970,7 +959,8 @@ bool CameraINDI::StackStream(CapturedFrame *cf)
if (cf->m_size != StackImg->NPixels)
{
- Debug.Write(wxString::Format("INDI Camera: discarding blob with size %d, expected %u\n", cf->m_size, StackImg->NPixels));
+ Debug.Write(
+ wxString::Format("INDI Camera: discarding blob with size %d, expected %u\n", cf->m_size, StackImg->NPixels));
return true;
}
@@ -1113,11 +1103,11 @@ bool CameraINDI::Capture(int duration, usImage& img, int options, const wxRect&
// try to use video stream instead of exposure
// See: http://www.indilib.org/forum/ccds-dslrs/3078-v4l2-ccd-exposure-property.html
// TODO : check if an updated INDI v4l2 driver offer a better solution
- pFrame->Alert(wxString::Format(_("Camera %s, exposure error. Trying to use streaming instead."),
- INDICameraName));
+ pFrame->Alert(
+ wxString::Format(_("Camera %s, exposure error. Trying to use streaming instead."), INDICameraName));
INDICameraForceVideo = true;
first_frame = false;
- return Capture(duration, img, options, subframeArg);
+ return Capture(duration, img, options, subframeArg);
}
else
{
@@ -1230,7 +1220,7 @@ bool CameraINDI::Capture(int duration, usImage& img, int options, const wxRect&
modal = false;
}
- if (WorkerThread::StopRequested() || WorkerThread::TerminateRequested())
+ if (WorkerThread::StopRequested() || WorkerThread::TerminateRequested())
{
// Stop video streaming when Stop button is pressed or exiting the program
v_on->s = ISS_OFF;
@@ -1287,14 +1277,14 @@ bool CameraINDI::ST4PulseGuideScope(int direction, int duration)
{
switch (direction)
{
- case EAST:
- case WEST:
- case NORTH:
- case SOUTH:
- break;
- default:
- Debug.Write("INDI Camera error CameraINDI::Guide NONE\n");
- return true;
+ case EAST:
+ case WEST:
+ case NORTH:
+ case SOUTH:
+ break;
+ default:
+ Debug.Write("INDI Camera error CameraINDI::Guide NONE\n");
+ return true;
}
if (!pulseGuideNS_prop || !pulseGuideEW_prop)
@@ -1322,26 +1312,26 @@ bool CameraINDI::ST4PulseGuideScope(int direction, int duration)
switch (direction)
{
- case EAST:
- pulseE_prop->value = duration;
- pulseW_prop->value = 0;
- sendNewNumber(pulseGuideEW_prop);
- break;
- case WEST:
- pulseE_prop->value = 0;
- pulseW_prop->value = duration;
- sendNewNumber(pulseGuideEW_prop);
- break;
- case NORTH:
- pulseN_prop->value = duration;
- pulseS_prop->value = 0;
- sendNewNumber(pulseGuideNS_prop);
- break;
- case SOUTH:
- pulseN_prop->value = 0;
- pulseS_prop->value = duration;
- sendNewNumber(pulseGuideNS_prop);
- break;
+ case EAST:
+ pulseE_prop->value = duration;
+ pulseW_prop->value = 0;
+ sendNewNumber(pulseGuideEW_prop);
+ break;
+ case WEST:
+ pulseE_prop->value = 0;
+ pulseW_prop->value = duration;
+ sendNewNumber(pulseGuideEW_prop);
+ break;
+ case NORTH:
+ pulseN_prop->value = duration;
+ pulseS_prop->value = 0;
+ sendNewNumber(pulseGuideNS_prop);
+ break;
+ case SOUTH:
+ pulseN_prop->value = 0;
+ pulseS_prop->value = duration;
+ sendNewNumber(pulseGuideNS_prop);
+ break;
}
if (INDIConfig::Verbose())
diff --git a/src/cam_ioptron.cpp b/src/cam_ioptron.cpp
index 40ae79dc6..ffeb385d5 100644
--- a/src/cam_ioptron.cpp
+++ b/src/cam_ioptron.cpp
@@ -36,17 +36,14 @@
#if defined(IOPTRON_CAMERA)
-#include "cam_ioptron.h"
-#include "cam_wdm_base.h"
-#include "CVPlatform.h"
+# include "cam_ioptron.h"
+# include "cam_wdm_base.h"
+# include "CVPlatform.h"
class IoptronCamera : public CameraWDM
{
public:
- IoptronCamera()
- {
- m_rawYUY2 = true;
- }
+ IoptronCamera() { m_rawYUY2 = true; }
bool CanSelectCamera() const override
{
// TODO: we could probably hanlde multiple cameras, but would need 2 cameras to test
@@ -157,15 +154,13 @@ bool IoptronCamera::SelectDeviceAndMode(SelectionContext ctx)
CVVidCapture::VIDCAP_MODE modeInfo;
if (CVSUCCESS(vc.get()->GetModeInfo(i, modeInfo)))
{
- if (modeInfo.XRes == 640 && modeInfo.YRes == 960 &&
- modeInfo.InputFormat == VIDCAP_FORMAT_YUY2)
+ if (modeInfo.XRes == 640 && modeInfo.YRes == 960 && modeInfo.InputFormat == VIDCAP_FORMAT_YUY2)
{
if (m_deviceMode == -1)
m_deviceMode = i;
}
- Debug.Write(wxString::Format("IOPTRON: mode %d: %dx%d (%s) %d fps %s\n", i, modeInfo.XRes,
- modeInfo.YRes, vc.get()->GetFormatModeName(modeInfo.InputFormat),
- modeInfo.EstFrameRate, i == m_deviceMode ? "<<<<" : ""));
+ Debug.Write(wxString::Format("IOPTRON: mode %d: %dx%d (%s) %d fps %s\n", i, modeInfo.XRes, modeInfo.YRes,
+ vc.get()->GetFormatModeName(modeInfo.InputFormat), modeInfo.EstFrameRate, i == m_deviceMode ? "<<<<" : ""));
}
else
Debug.Write(wxString::Format("IOPTRON: mode %d: GetModeInfo failed, skipped\n", i));
diff --git a/src/cam_moravian.cpp b/src/cam_moravian.cpp
index b5a1eda6d..617a6faa1 100644
--- a/src/cam_moravian.cpp
+++ b/src/cam_moravian.cpp
@@ -1,42 +1,42 @@
/*
-* cam_moravian.cpp
-* PHD2 Guiding
-*
-* Copyright (c) 2020 Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of openphdguiding.org nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * cam_moravian.cpp
+ * PHD2 Guiding
+ *
+ * Copyright (c) 2020 Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of openphdguiding.org nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
#ifdef MORAVIAN_CAMERA
-#include "cam_moravian.h"
+# include "cam_moravian.h"
// #include "gxeth.h" TODO - ethernet camera support
-#include "gxusb.h"
+# include "gxusb.h"
static std::vector __ids;
@@ -50,7 +50,7 @@ static std::vector _get_ids()
Debug.Write("MVN: begin enumerate\n");
__ids.clear();
gXusb::Enumerate(_enum_cb);
- Debug.Write(wxString::Format("MVN: enumerate found %u\n", (unsigned int)__ids.size())); // MSVC barfs on %zu
+ Debug.Write(wxString::Format("MVN: enumerate found %u\n", (unsigned int) __ids.size())); // MSVC barfs on %zu
return __ids;
}
@@ -58,7 +58,10 @@ struct MCam
{
gXusb::CCamera *m_cam;
- MCam() : m_cam(nullptr) { }
+ MCam()
+ : m_cam(nullptr)
+ {
+ }
~MCam()
{
@@ -143,10 +146,7 @@ struct MCam
return dflt;
}
- wxString Serial()
- {
- return StrParam(gspCameraSerial, wxString::Format("ID%d", IntParam(gipCameraId, 1)));
- }
+ wxString Serial() { return StrParam(gspCameraSerial, wxString::Format("ID%d", IntParam(gipCameraId, 1))); }
float GetValue(gXusb::CARDINAL idx, float dflt = 0.f)
{
@@ -269,10 +269,7 @@ struct MCam
return ok;
}
- wxSize ChipSize()
- {
- return wxSize(IntParam(gipChipW), IntParam(gipChipD));
- }
+ wxSize ChipSize() { return wxSize(IntParam(gipChipW), IntParam(gipChipD)); }
bool CaptureSync(void *buf, unsigned int size, unsigned int duration, wxByte bpp, const wxRect& frame)
{
@@ -280,13 +277,13 @@ struct MCam
gXusb::BOOLEAN ok;
if (bpp == 8)
{
- ok = gXusb::GetImageExposure8b(m_cam, exp, false, frame.GetLeft(), frame.GetTop(), frame.GetWidth(), frame.GetHeight(),
- size, buf);
+ ok = gXusb::GetImageExposure8b(
+ m_cam, exp, false, frame.GetLeft(), frame.GetTop(), frame.GetWidth(), frame.GetHeight(), size, buf);
}
else
{
- ok = gXusb::GetImageExposure16b(m_cam, exp, false, frame.GetLeft(), frame.GetTop(), frame.GetWidth(), frame.GetHeight(),
- size, buf);
+ ok = gXusb::GetImageExposure16b(
+ m_cam, exp, false, frame.GetLeft(), frame.GetTop(), frame.GetWidth(), frame.GetHeight(), size, buf);
}
if (!ok)
Debug.Write(wxString::Format("MVN: CaptureSync: %s\n", LastError()));
@@ -336,7 +333,7 @@ class MoravianCamera : public GuideCamera
unsigned int m_curGain;
void *m_buffer;
size_t m_buffer_size;
- wxByte m_bpp; // bits per pixel: 8 or 16
+ wxByte m_bpp; // bits per pixel: 8 or 16
MCam m_cam;
bool m_canGuide;
int m_maxGain;
@@ -370,15 +367,15 @@ class MoravianCamera : public GuideCamera
};
MoravianCamera::MoravianCamera()
- :
- m_buffer(nullptr)
+ : m_buffer(nullptr)
{
Name = _T("Moravian Camera");
PropertyDialogType = PROPDLG_WHEN_DISCONNECTED;
Connected = false;
m_hasGuideOutput = false; // updated when connected
HasSubframes = true;
- HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to true later when the camera is connected
+ HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to
+ // true later when the camera is connected
m_defaultGainPct = 0; // TODO: what is a good default? GuideCamera::GetDefaultCameraGain();
int value = pConfig->Profile.GetInt("/camera/moravian/bpp", 16);
m_bpp = value == 8 ? 8 : 16;
@@ -432,8 +429,8 @@ MoravianCameraDlg::MoravianCameraDlg()
wxBoxSizer *sizer5 = new wxBoxSizer(wxHORIZONTAL);
- wxStaticText *staticText1 = new wxStaticText(sizer2->GetStaticBox(), wxID_ANY, _("Read Mode"),
- wxDefaultPosition, wxDefaultSize, 0);
+ wxStaticText *staticText1 =
+ new wxStaticText(sizer2->GetStaticBox(), wxID_ANY, _("Read Mode"), wxDefaultPosition, wxDefaultSize, 0);
staticText1->Wrap(-1);
sizer5->Add(staticText1, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxTOP, 5);
@@ -626,10 +623,8 @@ bool MoravianCamera::Connect(const wxString& camId)
int flash_minor = m_cam.IntParam(gipFlashMinor);
int flash_build = m_cam.IntParam(gipFlashBuild);
- Debug.Write(wxString::Format("MVN: Driver %d.%d.%d | Firmware %d.%d.%d | Flash %d.%d.%d\n",
- drv_major, drv_minor, drv_build,
- fw_major, fw_minor, fw_build,
- flash_major, flash_minor, flash_build));
+ Debug.Write(wxString::Format("MVN: Driver %d.%d.%d | Firmware %d.%d.%d | Flash %d.%d.%d\n", drv_major, drv_minor, drv_build,
+ fw_major, fw_minor, fw_build, flash_major, flash_minor, flash_build));
Name = m_cam.StrParam(gspCameraDescription, _T("Moravian Camera"));
@@ -663,8 +658,7 @@ bool MoravianCamera::Connect(const wxString& camId)
m_hasGuideOutput = m_cam.BoolParam(gbpGuide);
m_maxMoveMs = m_hasGuideOutput ? m_cam.IntParam(gipMaximalMoveTime) : 0;
- Debug.Write(wxString::Format("MVN: CanPulseGuide: %s MaxMove: %d\n",
- m_hasGuideOutput ? "yes" : "no", m_maxMoveMs));
+ Debug.Write(wxString::Format("MVN: CanPulseGuide: %s MaxMove: %d\n", m_hasGuideOutput ? "yes" : "no", m_maxMoveMs));
bool rgb = m_cam.BoolParam(gbpRGB);
bool cmy = m_cam.BoolParam(gbpCMY);
@@ -713,8 +707,8 @@ bool MoravianCamera::Connect(const wxString& camId)
m_maxGain = m_cam.IntParam(gipMaxGain);
int default_gain = 0; // TODO: ask moravian
m_defaultGainPct = gain_pct(0, m_maxGain, default_gain);
- Debug.Write(wxString::Format("MVN: gain range = %d .. %d default = %ld (%d%%)\n",
- 0, m_maxGain, default_gain, m_defaultGainPct));
+ Debug.Write(
+ wxString::Format("MVN: gain range = %d .. %d default = %ld (%d%%)\n", 0, m_maxGain, default_gain, m_defaultGainPct));
unsigned int new_gain = cam_gain(0, m_maxGain, GuideCameraGain);
Debug.Write(wxString::Format("MVN: set gain %d%% %d\n", GuideCameraGain, new_gain));
@@ -947,12 +941,26 @@ bool MoravianCamera::ST4PulseGuideScope(int direction, int duration)
gXusb::INT16 radur, decdur;
- switch (direction) {
- case NORTH: radur = 0; decdur = +dur; break;
- case SOUTH: radur = 0; decdur = -dur; break;
- case EAST: radur = +dur; decdur = 0; break;
- case WEST: radur = -dur; decdur = 0; break;
- default: return true;
+ switch (direction)
+ {
+ case NORTH:
+ radur = 0;
+ decdur = +dur;
+ break;
+ case SOUTH:
+ radur = 0;
+ decdur = -dur;
+ break;
+ case EAST:
+ radur = +dur;
+ decdur = 0;
+ break;
+ case WEST:
+ radur = -dur;
+ decdur = 0;
+ break;
+ default:
+ return true;
}
if (!gXusb::MoveTelescope(m_cam, radur, decdur))
diff --git a/src/cam_moravian.h b/src/cam_moravian.h
index 1731a3bef..b0f5e0678 100644
--- a/src/cam_moravian.h
+++ b/src/cam_moravian.h
@@ -1,35 +1,35 @@
/*
-* cam_moravian.h
-* PHD2 Guiding
-*
-* Copyright (c) 2020 Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of openphdguiding.org nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * cam_moravian.h
+ * PHD2 Guiding
+ *
+ * Copyright (c) 2020 Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of openphdguiding.org nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#ifndef CAM_MORAVIAN_INCLUDED
#define CAM_MORAVIAN_INCLUDED
diff --git a/src/cam_ogma.cpp b/src/cam_ogma.cpp
index 4aed3d455..320f1161f 100644
--- a/src/cam_ogma.cpp
+++ b/src/cam_ogma.cpp
@@ -36,21 +36,21 @@
#if defined(OGMA_CAMERA)
-#include "cam_ogma.h"
-#include "ogmacam.h"
+# include "cam_ogma.h"
+# include "ogmacam.h"
// Touptek API uses these Windows definitions even on non-Windows platforms
-#ifndef S_OK
-#define S_OK ((HRESULT)0L)
-#define S_FALSE ((HRESULT)1L)
-#endif
+# ifndef S_OK
+# define S_OK ((HRESULT) 0L)
+# define S_FALSE ((HRESULT) 1L)
+# endif
struct OgmaCam
{
HOgmacam m_h;
void *m_buffer;
void *m_tmpbuf;
- wxByte m_bpp; // bits per pixel: 8 or 16
+ wxByte m_bpp; // bits per pixel: 8 or 16
bool m_isColor;
bool m_hasGuideOutput;
double m_devicePixelSize;
@@ -65,13 +65,14 @@ struct OgmaCam
wxMutex m_lock;
wxCondition m_cond;
- OgmaCam() :
- m_h(nullptr),
- m_buffer(nullptr),
- m_tmpbuf(nullptr),
- m_started(false),
- m_cond(m_lock)
- { }
+ OgmaCam()
+ : m_h(nullptr)
+ , m_buffer(nullptr)
+ , m_tmpbuf(nullptr)
+ , m_started(false)
+ , m_cond(m_lock)
+ {
+ }
~OgmaCam()
{
@@ -79,21 +80,15 @@ struct OgmaCam
::free(m_tmpbuf);
}
- int gain_pct(int val) const
- {
- return (val - m_minGain) * 100 / (m_maxGain - m_minGain);
- }
+ int gain_pct(int val) const { return (val - m_minGain) * 100 / (m_maxGain - m_minGain); }
- int cam_gain(int pct) const
- {
- return m_minGain + pct * (m_maxGain - m_minGain) / 100;
- }
+ int cam_gain(int pct) const { return m_minGain + pct * (m_maxGain - m_minGain) / 100; }
void StopCapture()
{
if (m_started)
{
- //Debug.Write("OGMA: stopcapture\n");
+ // Debug.Write("OGMA: stopcapture\n");
HRESULT hr;
if (FAILED(hr = Ogmacam_Stop(m_h)))
Debug.Write(wxString::Format("OGMA: Ogmacam_Stop failed with status 0x%x\n", hr));
@@ -113,7 +108,7 @@ struct OgmaCam
case OGMACAM_EVENT_NOFRAMETIMEOUT:
case OGMACAM_EVENT_NOPACKETTIMEOUT:
case OGMACAM_EVENT_TRIGGERFAIL:
- //Debug.Write(wxString::Format("OGMA: cam event 0x%x\n", event));
+ // Debug.Write(wxString::Format("OGMA: cam event 0x%x\n", event));
{
wxMutexLocker lck(cam->m_lock);
cam->m_captureResult = event;
@@ -131,7 +126,7 @@ struct OgmaCam
if (m_started)
return;
- //Debug.Write("OGMA: startcapture\n");
+ // Debug.Write("OGMA: startcapture\n");
HRESULT hr;
if (FAILED(hr = Ogmacam_StartPullModeWithCallback(m_h, &CamEventCb, this)))
@@ -208,15 +203,9 @@ struct OgmaCam
}
}
- bool SoftwareBinning() const
- {
- return m_isColor;
- }
+ bool SoftwareBinning() const { return m_isColor; }
- bool SetHwBinning(unsigned int binning)
- {
- return SetOption(OGMACAM_OPTION_BINNING, OgmacamBinning(binning));
- }
+ bool SetHwBinning(unsigned int binning) { return SetOption(OGMACAM_OPTION_BINNING, OgmacamBinning(binning)); }
bool SetBinning(unsigned int binning)
{
@@ -261,7 +250,6 @@ class CameraOgma : public GuideCamera
OgmaCam m_cam;
public:
-
CameraOgma();
~CameraOgma();
@@ -293,16 +281,15 @@ CameraOgma::CameraOgma()
Connected = false;
m_cam.m_hasGuideOutput = true;
HasSubframes = true;
- HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to true later when the camera is connected
+ HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to
+ // true later when the camera is connected
m_cam.m_defaultGainPct = GuideCamera::GetDefaultCameraGain();
int value = pConfig->Profile.GetInt("/camera/ogma/bpp", 8);
m_cam.m_bpp = value == 8 ? 8 : 16;
MaxBinning = 4;
}
-CameraOgma::~CameraOgma()
-{
-}
+CameraOgma::~CameraOgma() { }
bool CameraOgma::EnumCameras(wxArrayString& names, wxArrayString& ids)
{
@@ -376,8 +363,8 @@ bool CameraOgma::Connect(const wxString& camIdArg)
HasCooler = (info->model->flag & OGMACAM_FLAG_TEC) != 0;
m_cam.m_hasGuideOutput = (info->model->flag & OGMACAM_FLAG_ST4) != 0;
- Debug.Write(wxString::Format("OGMA: isColor = %d, hasCooler = %d, hasST4 = %d\n",
- m_cam.m_isColor, HasCooler, m_cam.m_hasGuideOutput));
+ Debug.Write(wxString::Format(
+ "OGMA: isColor = %d, hasCooler = %d, hasST4 = %d\n", m_cam.m_isColor, HasCooler, m_cam.m_hasGuideOutput));
if (FAILED(Ogmacam_get_Resolution(m_cam.m_h, 0, &m_cam.m_maxSize.x, &m_cam.m_maxSize.y)))
{
@@ -444,7 +431,8 @@ bool CameraOgma::Connect(const wxString& camIdArg)
m_cam.m_maxGain = maxGain;
HasGainControl = maxGain > minGain;
m_cam.m_defaultGainPct = m_cam.gain_pct(defaultGain);
- Debug.Write(wxString::Format("OGMA: gain range %d .. %d, default = %d (%d%%)\n", minGain, maxGain, defaultGain, m_cam.m_defaultGainPct));
+ Debug.Write(wxString::Format(
+ "OGMA: gain range %d .. %d, default = %d (%d%%)\n", minGain, maxGain, defaultGain, m_cam.m_defaultGainPct));
}
else
{
@@ -469,14 +457,14 @@ bool CameraOgma::Connect(const wxString& camIdArg)
m_cam.SetOption(OGMACAM_OPTION_RAW, 1);
m_cam.SetOption(OGMACAM_OPTION_BITDEPTH, m_cam.m_bpp == 8 ? 0 : 1);
m_cam.SetOption(OGMACAM_OPTION_LINEAR, 0);
- //m_cam.SetOption(OGMACAM_OPTION_CURVE, 0); // resetting this one fails on all the cameras I have
+ // m_cam.SetOption(OGMACAM_OPTION_CURVE, 0); // resetting this one fails on all the cameras I have
m_cam.SetOption(OGMACAM_OPTION_COLORMATIX, 0);
m_cam.SetOption(OGMACAM_OPTION_WBGAIN, 0);
- m_cam.SetOption(OGMACAM_OPTION_TRIGGER, 1); // software trigger
+ m_cam.SetOption(OGMACAM_OPTION_TRIGGER, 1); // software trigger
m_cam.SetOption(OGMACAM_OPTION_AUTOEXP_POLICY, 0); // 0="Exposure Only" 1="Exposure Preferred"
m_cam.SetOption(OGMACAM_OPTION_ROTATE, 0);
m_cam.SetOption(OGMACAM_OPTION_UPSIDE_DOWN, 0);
- //m_cam.SetOption(OGMACAM_OPTION_CG, 0); // "Conversion Gain" 0=LCG 1=HCG 2=HDR // setting this fails
+ // m_cam.SetOption(OGMACAM_OPTION_CG, 0); // "Conversion Gain" 0=LCG 1=HCG 2=HDR // setting this fails
m_cam.SetOption(OGMACAM_OPTION_FFC, 0);
m_cam.SetOption(OGMACAM_OPTION_DFC, 0);
m_cam.SetOption(OGMACAM_OPTION_SHARPENING, 0);
@@ -501,12 +489,8 @@ bool CameraOgma::Connect(const wxString& camIdArg)
unsigned int fourcc, bpp;
if (SUCCEEDED(hr = Ogmacam_get_RawFormat(m_cam.m_h, &fourcc, &bpp)))
{
- Debug.Write(wxString::Format("OGMA: raw format = %c%c%c%c bit depth = %u\n",
- fourcc & 0xff,
- (fourcc >> 8) & 0xff,
- (fourcc >> 16) & 0xff,
- fourcc >> 24,
- bpp));
+ Debug.Write(wxString::Format("OGMA: raw format = %c%c%c%c bit depth = %u\n", fourcc & 0xff, (fourcc >> 8) & 0xff,
+ (fourcc >> 16) & 0xff, fourcc >> 24, bpp));
}
else
Debug.Write(wxString::Format("OGMA: Ogmacam_get_RawFormat failed with status 0x%x\n", hr));
@@ -560,7 +544,7 @@ bool CameraOgma::Capture(int duration, usImage& img, int options, const wxRect&
unsigned int const binning = m_cam.m_curBin;
- wxRect roi; // un-binned coordinates
+ wxRect roi; // un-binned coordinates
if (useSubframe)
{
@@ -605,7 +589,7 @@ bool CameraOgma::Capture(int duration, usImage& img, int options, const wxRect&
m_cam.StartCapture();
- //Debug.Write("OGMA: capture: trigger\n");
+ // Debug.Write("OGMA: capture: trigger\n");
if (FAILED(hr = Ogmacam_Trigger(m_cam.m_h, 1)))
Debug.Write(wxString::Format("OGMA: Ogmacam_Trigger(1) failed with status 0x%x\n", hr));
@@ -658,7 +642,7 @@ bool CameraOgma::Capture(int duration, usImage& img, int options, const wxRect&
return true;
}
- //Debug.Write("OGMA: capture: image ready\n");
+ // Debug.Write("OGMA: capture: image ready\n");
void *buf;
wxSize sz;
@@ -724,7 +708,7 @@ bool CameraOgma::Capture(int duration, usImage& img, int options, const wxRect&
}
}
- //Debug.Write("OGMA: capture: pull done\n");
+ // Debug.Write("OGMA: capture: pull done\n");
if (options & CAPTURE_SUBTRACT_DARK)
SubtractDark(img);
@@ -749,10 +733,14 @@ inline static int GetOgmacamDirection(int direction)
switch (direction)
{
default:
- case NORTH: return 0;
- case EAST: return 2;
- case WEST: return 3;
- case SOUTH: return 1;
+ case NORTH:
+ return 0;
+ case EAST:
+ return 2;
+ case WEST:
+ return 3;
+ case SOUTH:
+ return 1;
}
}
@@ -811,7 +799,7 @@ OgmaCameraDlg::OgmaCameraDlg()
wxStdDialogButtonSizer *sdbSizer2 = new wxStdDialogButtonSizer();
wxButton *sdbSizer2OK = new wxButton(this, wxID_OK);
- wxButton* sdbSizer2Cancel = new wxButton(this, wxID_CANCEL);
+ wxButton *sdbSizer2Cancel = new wxButton(this, wxID_CANCEL);
sdbSizer2->AddButton(sdbSizer2OK);
sdbSizer2->AddButton(sdbSizer2Cancel);
sdbSizer2->Realize();
@@ -867,13 +855,13 @@ bool CameraOgma::SetCoolerOn(bool on)
bool CameraOgma::SetCoolerSetpoint(double temperature)
{
- int val = (int)(temperature * 10.);
-#if defined(OGMACAM_TEC_TARGET_MIN)
+ int val = (int) (temperature * 10.);
+# if defined(OGMACAM_TEC_TARGET_MIN)
val = wxMax(val, OGMACAM_TEC_TARGET_MIN);
-#endif
-#if defined(OGMACAM_TEC_TARGET_MAX)
+# endif
+# if defined(OGMACAM_TEC_TARGET_MAX)
val = wxMin(val, OGMACAM_TEC_TARGET_MAX);
-#endif
+# endif
return m_cam.SetOption(OGMACAM_OPTION_TECTARGET, val) ? false : true;
}
@@ -893,8 +881,7 @@ bool CameraOgma::GetCoolerStatus(bool *on, double *setpoint, double *power, doub
else
err = true;
- if (m_cam.GetOption(OGMACAM_OPTION_TEC_VOLTAGE, &vcur) &&
- m_cam.GetOption(OGMACAM_OPTION_TEC_VOLTAGE_MAX, &vmax) &&
+ if (m_cam.GetOption(OGMACAM_OPTION_TEC_VOLTAGE, &vcur) && m_cam.GetOption(OGMACAM_OPTION_TEC_VOLTAGE_MAX, &vmax) &&
vmax > 0)
{
*power = vcur * 100.0 / vmax;
diff --git a/src/cam_opencv.cpp b/src/cam_opencv.cpp
index c0466d478..f8115e1eb 100644
--- a/src/cam_opencv.cpp
+++ b/src/cam_opencv.cpp
@@ -38,14 +38,14 @@
#ifdef OPENCV_CAMERA
-#include "cam_opencv.h"
+# include "cam_opencv.h"
-#include
+# include
CameraOpenCV::CameraOpenCV(int devNumber)
{
Connected = false;
- Name=_T("OpenCV");
+ Name = _T("OpenCV");
FullSize = wxSize(640, 480);
m_hasGuideOutput = false;
pCapDev = NULL;
@@ -98,7 +98,8 @@ bool CameraOpenCV::Connect(const wxString& camId)
bError = true;
}
- return bError;;
+ return bError;
+ ;
}
bool CameraOpenCV::Disconnect()
@@ -172,4 +173,4 @@ bool CameraOpenCV::Capture(int duration, usImage& img, int options, const wxRect
return bError;
}
-#endif // OPENCV_CAMERA
+#endif // OPENCV_CAMERA
diff --git a/src/cam_opencv.h b/src/cam_opencv.h
index fa843afd9..7505278a3 100644
--- a/src/cam_opencv.h
+++ b/src/cam_opencv.h
@@ -41,7 +41,7 @@
class CameraOpenCV : public GuideCamera
{
- int DeviceNum;
+ int DeviceNum;
protected:
cv::VideoCapture *pCapDev;
@@ -50,11 +50,11 @@ class CameraOpenCV : public GuideCamera
CameraOpenCV(int devNumber);
~CameraOpenCV();
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- bool HasNonGuiCapture() override { return true; }
- wxByte BitsPerPixel() override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ bool HasNonGuiCapture() override { return true; }
+ wxByte BitsPerPixel() override;
};
-#endif //CAM_OPENCV_H_INCLUDED
+#endif // CAM_OPENCV_H_INCLUDED
diff --git a/src/cam_openssag.cpp b/src/cam_openssag.cpp
index ca088870d..86c9e40be 100644
--- a/src/cam_openssag.cpp
+++ b/src/cam_openssag.cpp
@@ -36,12 +36,12 @@
#ifdef OPENSSAG_CAMERA
-#include "camera.h"
-#include "image_math.h"
-#include "cam_openssag.h"
+# include "camera.h"
+# include "image_math.h"
+# include "cam_openssag.h"
-#include
-#include
+# include
+# include
using namespace OpenSSAG;
@@ -71,9 +71,9 @@ CameraOpenSSAG::CameraOpenSSAG()
{
Connected = false;
Name = _T("StarShoot Autoguider (OpenSSAG)");
- FullSize = wxSize(1280,1024); // Current size of a full frame
- m_hasGuideOutput = true; // Do we have an ST4 port?
- HasGainControl = true; // Can we adjust gain?
+ FullSize = wxSize(1280, 1024); // Current size of a full frame
+ m_hasGuideOutput = true; // Do we have an ST4 port?
+ HasGainControl = true; // Can we adjust gain?
PropertyDialogType = PROPDLG_WHEN_DISCONNECTED;
ssag = new SSAG();
@@ -115,7 +115,12 @@ bool CameraOpenSSAG::Connect(const wxString& camId)
{
SSAG *ssag;
int vid, pid;
- ConnectInBg(SSAG *ssag_, int vid_, int pid_) : ssag(ssag_), vid(vid_), pid(pid_) { }
+ ConnectInBg(SSAG *ssag_, int vid_, int pid_)
+ : ssag(ssag_)
+ , vid(vid_)
+ , pid(pid_)
+ {
+ }
bool Entry()
{
bool err = !ssag->Connect(true, vid, pid);
@@ -131,27 +136,29 @@ bool CameraOpenSSAG::Connect(const wxString& camId)
return CamConnectFailed(_("Could not connect to StarShoot Autoguider"));
}
- Connected = true; // Set global flag for being connected
+ Connected = true; // Set global flag for being connected
return false;
}
bool CameraOpenSSAG::ST4PulseGuideScope(int direction, int duration)
{
- switch (direction) {
- case WEST:
- ssag->Guide(guide_west, duration);
- break;
- case NORTH:
- ssag->Guide(guide_north, duration);
- break;
- case SOUTH:
- ssag->Guide(guide_south, duration);
- break;
- case EAST:
- ssag->Guide(guide_east, duration);
- break;
- default: return true; // bad direction passed in
+ switch (direction)
+ {
+ case WEST:
+ ssag->Guide(guide_west, duration);
+ break;
+ case NORTH:
+ ssag->Guide(guide_north, duration);
+ break;
+ case SOUTH:
+ ssag->Guide(guide_south, duration);
+ break;
+ case EAST:
+ ssag->Guide(guide_east, duration);
+ break;
+ default:
+ return true; // bad direction passed in
}
wxMilliSleep(duration + 10);
@@ -174,7 +181,7 @@ bool CameraOpenSSAG::Capture(int duration, usImage& img, int options, const wxRe
return true;
}
- ssag->SetGain((int)(GuideCameraGain / 24));
+ ssag->SetGain((int) (GuideCameraGain / 24));
struct raw_image *raw = ssag->Expose(duration);
if (!raw)
@@ -183,13 +190,15 @@ bool CameraOpenSSAG::Capture(int duration, usImage& img, int options, const wxRe
return true;
}
- for (unsigned int i = 0; i < raw->width * raw->height; i++) {
+ for (unsigned int i = 0; i < raw->width * raw->height; i++)
+ {
img.ImageData[i] = (unsigned short) raw->data[i];
}
ssag->FreeRawImage(raw);
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
return false;
}
@@ -231,7 +240,8 @@ PropertiesDlg::PropertiesDlg(wxWindow *parent)
wxBoxSizer *sz0 = new wxBoxSizer(wxVERTICAL);
wxWindow *label = new wxStaticText(this, wxID_ANY, _("Loader VID:"));
- m_vid = new wxTextCtrl(this, wxID_ANY, wxString::Format("0x%04x", vid), wxDefaultPosition, wxSize(TextWidth(this, "0x88888"), -1));
+ m_vid = new wxTextCtrl(
+ this, wxID_ANY, wxString::Format("0x%04x", vid), wxDefaultPosition, wxSize(TextWidth(this, "0x88888"), -1));
m_vid->SetToolTip(wxString::Format(_("SSAG Loader USB Vendor ID. Default = 0x%04x"), default_loader_vid));
wxSizer *sz1 = new wxBoxSizer(wxHORIZONTAL);
@@ -241,7 +251,8 @@ PropertiesDlg::PropertiesDlg(wxWindow *parent)
sz0->Add(sz1, 1, wxEXPAND, 5);
label = new wxStaticText(this, wxID_ANY, _("Loader PID:"));
- m_pid = new wxTextCtrl(this, wxID_ANY, wxString::Format("0x%04x", pid), wxDefaultPosition, wxSize(TextWidth(this, "0x88888"), -1));
+ m_pid = new wxTextCtrl(
+ this, wxID_ANY, wxString::Format("0x%04x", pid), wxDefaultPosition, wxSize(TextWidth(this, "0x88888"), -1));
m_pid->SetToolTip(wxString::Format(_("SSAG Loader USB Product ID. Default = 0x%04x"), default_loader_pid));
sz1 = new wxBoxSizer(wxHORIZONTAL);
@@ -270,8 +281,7 @@ void CameraOpenSSAG::ShowPropertyDialog()
if (dlg.ShowModal() == wxID_OK)
{
long vid, pid;
- if (dlg.m_vid->GetValue().ToLong(&vid, 0) &&
- dlg.m_pid->GetValue().ToLong(&pid, 0))
+ if (dlg.m_vid->GetValue().ToLong(&vid, 0) && dlg.m_pid->GetValue().ToLong(&pid, 0))
{
SetLoaderVidPid(vid, pid);
}
diff --git a/src/cam_openssag.h b/src/cam_openssag.h
index 6bd929f88..50ddd64d6 100644
--- a/src/cam_openssag.h
+++ b/src/cam_openssag.h
@@ -35,13 +35,15 @@
#ifndef CAM_OPENSSAG_H_INCLUDED
#define CAM_OPENSSAG_H_INCLUDED
-namespace OpenSSAG {
- class SSAG;
+namespace OpenSSAG
+{
+class SSAG;
}
class CameraOpenSSAG : public GuideCamera
{
OpenSSAG::SSAG *ssag;
+
public:
CameraOpenSSAG();
~CameraOpenSSAG();
diff --git a/src/cam_qguide.cpp b/src/cam_qguide.cpp
index 550f6ed80..dd69bc692 100644
--- a/src/cam_qguide.cpp
+++ b/src/cam_qguide.cpp
@@ -34,24 +34,27 @@
#include "phd.h"
-#if defined (QGUIDE)
+#if defined(QGUIDE)
-#include "camera.h"
-#include "time.h"
-#include "image_math.h"
+# include "camera.h"
+# include "time.h"
+# include "image_math.h"
-#include
-#include
-//wxTextFile *qglogfile;
+# include
+# include
+// wxTextFile *qglogfile;
-int ushort_compare (const void * a, const void * b) {
- if ( *(unsigned short *)a > *(unsigned short *)b ) return 1;
- if ( *(unsigned short *)a < *(unsigned short *)b ) return -1;
- return 0;
+int ushort_compare(const void *a, const void *b)
+{
+ if (*(unsigned short *) a > *(unsigned short *) b)
+ return 1;
+ if (*(unsigned short *) a < *(unsigned short *) b)
+ return -1;
+ return 0;
}
-#define QGDEBUG 0
-#include "cam_qguide.h"
+# define QGDEBUG 0
+# include "cam_qguide.h"
// QHY CMOS guide camera version
// Tom's driver
@@ -59,7 +62,7 @@ CameraQGuider::CameraQGuider()
{
Connected = false;
Name = _T("Q-Guider");
- FullSize = wxSize(1280,1024);
+ FullSize = wxSize(1280, 1024);
m_hasGuideOutput = true;
HasGainControl = true;
}
@@ -71,18 +74,18 @@ wxByte CameraQGuider::BitsPerPixel()
bool CameraQGuider::Connect(const wxString& camId)
{
-// returns true on error
-// CameraReset();
+ // returns true on error
+ // CameraReset();
if (!openUSB(0))
return CamConnectFailed(_("No camera"));
-// ClearGuidePort();
-// GuideCommand(0x0F,10);
-// buffer = new unsigned char[1311744];
+ // ClearGuidePort();
+ // GuideCommand(0x0F,10);
+ // buffer = new unsigned char[1311744];
SETBUFFERMODE(0);
Connected = true;
-// qglogfile = new wxTextFile(Debug.GetLogDir() + PATHSEPSTR + _T("PHD_QGuide_log.txt"));
- //qglogfile->AddLine(wxNow() + ": QGuide connected"); //qglogfile->Write();
+ // qglogfile = new wxTextFile(Debug.GetLogDir() + PATHSEPSTR + _T("PHD_QGuide_log.txt"));
+ // qglogfile->AddLine(wxNow() + ": QGuide connected"); //qglogfile->Write();
return false;
}
@@ -91,41 +94,52 @@ bool CameraQGuider::ST4PulseGuideScope(int direction, int duration)
int reg = 0;
int dur = duration / 10;
- //qglogfile->AddLine(wxString::Format("Sending guide dur %d",dur)); //qglogfile->Write();
- if (dur >= 255) dur = 254; // Max guide pulse is 2.54s -- 255 keeps it on always
+ // qglogfile->AddLine(wxString::Format("Sending guide dur %d",dur)); //qglogfile->Write();
+ if (dur >= 255)
+ dur = 254; // Max guide pulse is 2.54s -- 255 keeps it on always
// Output pins are NC, Com, RA+(W), Dec+(N), Dec-(S), RA-(E) ?? http://www.starlight-xpress.co.uk/faq.htm
- switch (direction) {
- case WEST: reg = 0x80; break; // 0111 0000
- case NORTH: reg = 0x40; break; // 1011 0000
- case SOUTH: reg = 0x20; break; // 1101 0000
- case EAST: reg = 0x10; break; // 1110 0000
- default: return true; // bad direction passed in
+ switch (direction)
+ {
+ case WEST:
+ reg = 0x80;
+ break; // 0111 0000
+ case NORTH:
+ reg = 0x40;
+ break; // 1011 0000
+ case SOUTH:
+ reg = 0x20;
+ break; // 1101 0000
+ case EAST:
+ reg = 0x10;
+ break; // 1110 0000
+ default:
+ return true; // bad direction passed in
}
- GuideCommand(reg,dur);
- //if (duration > 50) wxMilliSleep(duration - 50); // wait until it's mostly done
+ GuideCommand(reg, dur);
+ // if (duration > 50) wxMilliSleep(duration - 50); // wait until it's mostly done
WorkerThread::MilliSleep(duration + 10);
- //qglogfile->AddLine("Done"); //qglogfile->Write();
+ // qglogfile->AddLine("Done"); //qglogfile->Write();
return false;
}
void CameraQGuider::ClearGuidePort()
{
-// SendGuideCommand(DevName,0,0);
+ // SendGuideCommand(DevName,0,0);
}
void CameraQGuider::InitCapture()
{
-// CameraReset();
- ProgramCamera(0,0,1280,1024, (GuideCameraGain * 63 / 100) );
-// SetNoiseReduction(0);
+ // CameraReset();
+ ProgramCamera(0, 0, 1280, 1024, (GuideCameraGain * 63 / 100));
+ // SetNoiseReduction(0);
}
bool CameraQGuider::Disconnect()
{
closeUSB();
-// delete [] buffer;
+ // delete [] buffer;
Connected = false;
- //qglogfile->AddLine(wxNow() + ": Disconnecting"); //qglogfile->Write(); //qglogfile->Close();
+ // qglogfile->AddLine(wxNow() + ": Disconnecting"); //qglogfile->Write(); //qglogfile->Close();
return false;
}
@@ -138,35 +152,35 @@ static bool StopExposure()
bool CameraQGuider::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
-// Only does full frames still
+ // Only does full frames still
unsigned short *dptr;
bool firstimg = true;
- //qglogfile->AddLine(wxString::Format("Capturing dur %d",duration)); //qglogfile->Write();
-// ThreadedExposure(10, buffer);
- ProgramCamera(0,0,1280,1024, (GuideCameraGain * 63 / 100) );
+ // qglogfile->AddLine(wxString::Format("Capturing dur %d",duration)); //qglogfile->Write();
+ // ThreadedExposure(10, buffer);
+ ProgramCamera(0, 0, 1280, 1024, (GuideCameraGain * 63 / 100));
-/* ThreadedExposure(10, NULL);
- while (isExposing())
- wxMilliSleep(10);
-*/
- if (img.Init(FullSize)) {
+ /* ThreadedExposure(10, NULL);
+ while (isExposing())
+ wxMilliSleep(10);
+ */
+ if (img.Init(FullSize))
+ {
DisconnectWithAlert(CAPT_FAIL_MEMORY);
return true;
}
// ThreadedExposure(duration, buffer);
ThreadedExposure(duration, NULL);
- //qglogfile->AddLine("Exposure programmed"); //qglogfile->Write();
+ // qglogfile->AddLine("Exposure programmed"); //qglogfile->Write();
CameraWatchdog watchdog(duration, GetTimeoutMs() + 1000); // typically 6 second timeout
if (duration > 100)
{
// Shift to > duration
- if (WorkerThread::MilliSleep(duration + 100) &&
- (WorkerThread::TerminateRequested() || StopExposure()))
+ if (WorkerThread::MilliSleep(duration + 100) && (WorkerThread::TerminateRequested() || StopExposure()))
{
return true;
}
@@ -175,8 +189,7 @@ bool CameraQGuider::Capture(int duration, usImage& img, int options, const wxRec
while (isExposing())
{
wxMilliSleep(200);
- if (WorkerThread::InterruptRequested() &&
- (WorkerThread::TerminateRequested() || StopExposure()))
+ if (WorkerThread::InterruptRequested() && (WorkerThread::TerminateRequested() || StopExposure()))
{
return true;
}
@@ -187,16 +200,17 @@ bool CameraQGuider::Capture(int duration, usImage& img, int options, const wxRec
}
}
- //qglogfile->AddLine("Exposure done"); //qglogfile->Write();
+ // qglogfile->AddLine("Exposure done"); //qglogfile->Write();
-/* dptr = img.ImageData;
- for (unsigned int i=0; i 65535) val = 65535;
+ if (val < 0)
+ val = 0;
+ else if (val > 65535)
+ val = 65535;
*ptr2 = (unsigned short) val;
}
-
}
}
#endif
diff --git a/src/cam_qguide.h b/src/cam_qguide.h
index 81bb74596..700e780ea 100644
--- a/src/cam_qguide.h
+++ b/src/cam_qguide.h
@@ -43,19 +43,19 @@ class CameraQGuider : public GuideCamera
public:
CameraQGuider();
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- void InitCapture() override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ void InitCapture() override;
- bool ST4PulseGuideScope(int direction, int duration) override;
- void ClearGuidePort();
- bool HasNonGuiCapture() override { return true; }
- bool ST4HasNonGuiMove() override { return true; }
- wxByte BitsPerPixel() override;
+ bool ST4PulseGuideScope(int direction, int duration) override;
+ void ClearGuidePort();
+ bool HasNonGuiCapture() override { return true; }
+ bool ST4HasNonGuiMove() override { return true; }
+ wxByte BitsPerPixel() override;
private:
void RemoveLines(usImage& img);
};
-#endif //QGUIDEDEF
+#endif // QGUIDEDEF
diff --git a/src/cam_qhy.cpp b/src/cam_qhy.cpp
index ced573ade..2e5c40b30 100644
--- a/src/cam_qhy.cpp
+++ b/src/cam_qhy.cpp
@@ -1,44 +1,44 @@
/*
-* cam_qhy.cpp
-* Open PHD Guiding
-*
-* Created by Andy Galasso.
-* Copyright (c) 2015-2019 Andy Galasso.
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of openphdguiding.org nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * cam_qhy.cpp
+ * Open PHD Guiding
+ *
+ * Created by Andy Galasso.
+ * Copyright (c) 2015-2019 Andy Galasso.
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of openphdguiding.org nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
#if defined(QHY_CAMERA)
-#include "camera.h"
-#include "cam_qhy.h"
-#include "qhyccd.h"
+# include "camera.h"
+# include "cam_qhy.h"
+# include "qhyccd.h"
class Camera_QHY : public GuideCamera
{
@@ -57,7 +57,6 @@ class Camera_QHY : public GuideCamera
wxByte m_bpp;
public:
-
Camera_QHY();
~Camera_QHY();
@@ -80,13 +79,13 @@ static bool s_qhySdkInitDone = false;
static wxString GetQHYSDKVersion()
{
-#if defined (__APPLE__)
+# if defined(__APPLE__)
return "V7.4.16.4"; // FIXME - remove this when we update to the newer SDK that implements GetQHYCCDSDKVersion
-#else
+# else
uint32_t YMDS[4] = {};
GetQHYCCDSDKVersion(&YMDS[0], &YMDS[1], &YMDS[2], &YMDS[3]);
return wxString::Format("V20%02d%02d%02d_%d", YMDS[0], YMDS[1], YMDS[2], YMDS[3]);
-#endif
+# endif
}
static bool QHYSDKInit()
@@ -103,20 +102,20 @@ static bool QHYSDKInit()
long ll;
if (wxGetEnv("QHY_LOG_LEVEL", &s) && s.ToLong(&ll))
lvl = static_cast(std::min(std::max(ll, 0L), 6L));
-#if !defined(__WINDOWS__)
+# if !defined(__WINDOWS__)
EnableQHYCCDLogFile(false);
-#endif
+# endif
SetQHYCCDLogLevel(lvl);
uint32_t ret;
if ((ret = InitQHYCCDResource()) != 0)
{
- Debug.Write(wxString::Format("InitQHYCCDResource failed: %d\n", (int)ret));
+ Debug.Write(wxString::Format("InitQHYCCDResource failed: %d\n", (int) ret));
return true;
}
-#if defined (__APPLE__)
+# if defined(__APPLE__)
Debug.Write("QHY: call OSXInitQHYCCDFirmwareArray()\n");
ret = OSXInitQHYCCDFirmwareArray();
Debug.Write(wxString::Format("QHY: OSXInitQHYCCDFirmwareArray() returns %d\n", ret));
@@ -134,7 +133,7 @@ static bool QHYSDKInit()
}
}
// non-zero result indicates camera already has firmware
-#endif
+# endif
s_qhySdkInitDone = true;
return false;
@@ -183,7 +182,10 @@ bool Camera_QHY::GetDevicePixelSize(double *devPixelSize)
int Camera_QHY::GetDefaultCameraGain()
{
- enum { DefaultQHYCameraGain = 40 };
+ enum
+ {
+ DefaultQHYCameraGain = 40
+ };
return DefaultQHYCameraGain;
}
@@ -207,8 +209,9 @@ bool Camera_QHY::EnumCameras(wxArrayString& names, wxArrayString& ids)
uint32_t ret = IsQHYCCDControlAvailable(h, CONTROL_ST4PORT);
if (ret == QHYCCD_SUCCESS)
st4 = true;
- //CloseQHYCCD(h); // CloseQHYCCD() would proform a reset, so the other software that use QHY camera would be impacted.
- // Do not call this,would not cause memory leak.The SDk has already process this.
+ // CloseQHYCCD(h); // CloseQHYCCD() would proform a reset, so the other software that use QHY camera would be
+ // impacted.
+ // Do not call this,would not cause memory leak.The SDk has already process this.
}
Debug.Write(wxString::Format("QHY cam [%d] %s avail %s st4 %s\n", i, camid, h ? "Yes" : "No", st4 ? "Yes" : "No"));
if (st4)
@@ -305,7 +308,8 @@ bool Camera_QHY::Connect(const wxString& camId)
Debug.Write(wxString::Format("QHY: cam reports bayer type %d\n", bayer));
Color = false;
- switch ((BAYER_ID)bayer) {
+ switch ((BAYER_ID) bayer)
+ {
case BAYER_GB:
case BAYER_GR:
case BAYER_BG:
@@ -314,13 +318,21 @@ bool Camera_QHY::Connect(const wxString& camId)
}
// check bin modes
- CONTROL_ID modes[] = { CAM_BIN2X2MODE, CAM_BIN3X3MODE, CAM_BIN4X4MODE, };
- int bin[] = { 2, 3, 4, };
+ CONTROL_ID modes[] = {
+ CAM_BIN2X2MODE,
+ CAM_BIN3X3MODE,
+ CAM_BIN4X4MODE,
+ };
+ int bin[] = {
+ 2,
+ 3,
+ 4,
+ };
int maxBin = 1;
for (int i = 0; i < WXSIZEOF(modes); i++)
{
ret = IsQHYCCDControlAvailable(m_camhandle, modes[i]);
-#if 0
+# if 0
// FIXME- IsQHYCCDControlAvailable is supposed to return QHYCCD_ERROR_NOTSUPPORT for a
// bin mode that is not supported, but in fact it returns QHYCCD_ERROR, so we cannot
// distinguish "not supported" from "error".
@@ -330,7 +342,7 @@ bool Camera_QHY::Connect(const wxString& camId)
m_camhandle = 0;
return CamConnectFailed(_("Failed to get camera bin info"));
}
-#endif
+# endif
if (ret == QHYCCD_SUCCESS)
maxBin = bin[i];
else
@@ -362,7 +374,7 @@ bool Camera_QHY::Connect(const wxString& camId)
m_curGain = -1;
m_curExposure = -1;
- m_roi = wxRect(0, 0, FullSize.GetWidth(), FullSize.GetHeight()); // binned coordinates
+ m_roi = wxRect(0, 0, FullSize.GetWidth(), FullSize.GetHeight()); // binned coordinates
Debug.Write(wxString::Format("QHY: call SetQHYCCDResolution roi = %d,%d\n", m_roi.width, m_roi.height));
ret = SetQHYCCDResolution(m_camhandle, 0, 0, m_roi.GetWidth(), m_roi.GetHeight());
@@ -388,10 +400,10 @@ static void StopCapture(qhyccd_handle *handle)
bool Camera_QHY::Disconnect()
{
StopCapture(m_camhandle);
-#if !defined(__APPLE__)
+# if !defined(__APPLE__)
// this crashes on macOS, but seems to work ok without it
CloseQHYCCD(m_camhandle);
-#endif
+# endif
m_camhandle = 0;
Connected = false;
delete[] RawBuffer;
@@ -405,11 +417,20 @@ bool Camera_QHY::ST4PulseGuideScope(int direction, int duration)
switch (direction)
{
- case NORTH: qdir = 1; break;
- case SOUTH: qdir = 2; break;
- case EAST: qdir = 0; break;
- case WEST: qdir = 3; break;
- default: return true; // bad direction passed in
+ case NORTH:
+ qdir = 1;
+ break;
+ case SOUTH:
+ qdir = 2;
+ break;
+ case EAST:
+ qdir = 0;
+ break;
+ case WEST:
+ qdir = 3;
+ break;
+ default:
+ return true; // bad direction passed in
}
if (duration > (uint16_t) (-1))
duration = (uint16_t) (-1);
@@ -429,7 +450,7 @@ inline static int round_up(int v, int m)
}
// stopping capture causes problems on some cameras on Windows, disable it for now until we can test with a newer SDK
-//#define CAN_STOP_CAPTURE
+// #define CAN_STOP_CAPTURE
bool Camera_QHY::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
@@ -459,7 +480,10 @@ bool Camera_QHY::Capture(int duration, usImage& img, int options, const wxRect&
// Use a larger ROI around the subframe to avoid changing the ROI as the centroid
// wobbles around. Changing the ROI introduces a lag of several seconds.
// This also satifies the constraint that ROI width and height must be multiples of 4.
- enum { PAD = 1 << 5 };
+ enum
+ {
+ PAD = 1 << 5
+ };
roi.SetLeft(round_down(subframe.GetLeft(), PAD));
roi.SetRight(round_up(subframe.GetRight() + 1, PAD) - 1);
roi.SetTop(round_down(subframe.GetTop(), PAD));
@@ -475,7 +499,7 @@ bool Camera_QHY::Capture(int duration, usImage& img, int options, const wxRect&
ret = SetQHYCCDBinMode(m_camhandle, Binning, Binning);
if (ret != QHYCCD_SUCCESS)
{
- Debug.Write(wxString::Format("SetQHYCCDBinMode failed! ret = %d\n", (int)ret));
+ Debug.Write(wxString::Format("SetQHYCCDBinMode failed! ret = %d\n", (int) ret));
}
if (m_roi != roi)
@@ -498,8 +522,8 @@ bool Camera_QHY::Capture(int duration, usImage& img, int options, const wxRect&
}
else
{
- Debug.Write(wxString::Format("SetQHYCCDResolution(%d,%d,%d,%d) failed! ret = %d\n",
- roi.GetLeft(), roi.GetTop(), roi.GetWidth(), roi.GetHeight(), (int)ret));
+ Debug.Write(wxString::Format("SetQHYCCDResolution(%d,%d,%d,%d) failed! ret = %d\n", roi.GetLeft(), roi.GetTop(),
+ roi.GetWidth(), roi.GetHeight(), (int) ret));
}
}
@@ -512,7 +536,7 @@ bool Camera_QHY::Capture(int duration, usImage& img, int options, const wxRect&
}
else
{
- Debug.Write(wxString::Format("QHY set exposure ret %d\n", (int)ret));
+ Debug.Write(wxString::Format("QHY set exposure ret %d\n", (int) ret));
pFrame->Alert(_("Failed to set camera exposure"));
}
}
@@ -529,7 +553,7 @@ bool Camera_QHY::Capture(int duration, usImage& img, int options, const wxRect&
}
else
{
- Debug.Write(wxString::Format("QHY set gain ret %d\n", (int)ret));
+ Debug.Write(wxString::Format("QHY set gain ret %d\n", (int) ret));
pFrame->Alert(_("Failed to set camera gain"));
}
}
@@ -537,17 +561,17 @@ bool Camera_QHY::Capture(int duration, usImage& img, int options, const wxRect&
ret = ExpQHYCCDSingleFrame(m_camhandle);
if (ret == QHYCCD_ERROR)
{
- Debug.Write(wxString::Format("QHY exp single frame ret %d\n", (int)ret));
+ Debug.Write(wxString::Format("QHY exp single frame ret %d\n", (int) ret));
DisconnectWithAlert(_("QHY exposure failed"), NO_RECONNECT);
return true;
}
-#ifdef CAN_STOP_CAPTURE
+# ifdef CAN_STOP_CAPTURE
if (WorkerThread::InterruptRequested())
{
StopCapture(m_camhandle);
return true;
}
-#endif
+# endif
if (ret == QHYCCD_SUCCESS)
{
Debug.Write(wxString::Format("QHY: 200ms delay needed\n"));
@@ -555,7 +579,7 @@ bool Camera_QHY::Capture(int duration, usImage& img, int options, const wxRect&
}
if (ret == QHYCCD_READ_DIRECTLY)
{
- //Debug.Write("QHYCCD_READ_DIRECTLY\n");
+ // Debug.Write("QHYCCD_READ_DIRECTLY\n");
}
uint32_t w, h, bpp, channels;
@@ -563,22 +587,22 @@ bool Camera_QHY::Capture(int duration, usImage& img, int options, const wxRect&
if (ret != QHYCCD_SUCCESS || (bpp != 8 && bpp != 16))
{
Debug.Write(wxString::Format("QHY get single frame ret %d bpp %u\n", ret, bpp));
-#ifdef CAN_STOP_CAPTURE
+# ifdef CAN_STOP_CAPTURE
StopCapture(m_camhandle);
-#endif
+# endif
// users report that reconnecting the camera after this failure allows
// them to resume guiding so we'll try to reconnect automatically
DisconnectWithAlert(_("QHY get frame failed"), RECONNECT);
return true;
}
-#ifdef CAN_STOP_CAPTURE
+# ifdef CAN_STOP_CAPTURE
if (WorkerThread::InterruptRequested())
{
StopCapture(m_camhandle);
return true;
}
-#endif
+# endif
if (useSubframe)
{
diff --git a/src/cam_qhy5.cpp b/src/cam_qhy5.cpp
index 8c7e04114..09279cbac 100644
--- a/src/cam_qhy5.cpp
+++ b/src/cam_qhy5.cpp
@@ -32,39 +32,35 @@
*
*/
-
#include "phd.h"
#if defined(CAM_QHY5)
-#include
-#include "camera.h"
-#include "image_math.h"
+# include
+# include "camera.h"
+# include "image_math.h"
-#include "cam_qhy5.h"
+# include "cam_qhy5.h"
-#define QHY5_MATRIX_WIDTH 1558
-#define QHY5_MATRIX_HEIGHT 1048
-#define QHY5_BUFFER_SIZE (QHY5_MATRIX_WIDTH * (QHY5_MATRIX_HEIGHT + 2))
+# define QHY5_MATRIX_WIDTH 1558
+# define QHY5_MATRIX_HEIGHT 1048
+# define QHY5_BUFFER_SIZE (QHY5_MATRIX_WIDTH * (QHY5_MATRIX_HEIGHT + 2))
-#define QHY5_IMAGE_WIDTH 1280
-#define QHY5_IMAGE_HEIGHT 1024
+# define QHY5_IMAGE_WIDTH 1280
+# define QHY5_IMAGE_HEIGHT 1024
-#define QHY5_VID 0x16c0
-#define QHY5_PID 0x296d
-#define STORE_WORD_BE(var, val) *(var) = ((val) >> 8) & 0xff; *((var) + 1) = (val) & 0xff
+# define QHY5_VID 0x16c0
+# define QHY5_PID 0x296d
+# define STORE_WORD_BE(var, val) \
+ *(var) = ((val) >> 8) & 0xff; \
+ *((var) + 1) = (val) & 0xff
static unsigned char reg[19];
-static int gain_lut[74] = {0x000, 0x004, 0x005, 0x006, 0x007, 0x008, 0x009, 0x00A, 0x00B,
- 0x00C, 0x00D, 0x00E, 0x00F, 0x010, 0x011, 0x012, 0x013, 0x014,
- 0x015, 0x016, 0x017, 0x018, 0x019, 0x01A, 0x01B, 0x01C, 0x01D,
- 0x01E, 0x01F, 0x051, 0x052, 0x053, 0x054, 0x055, 0x056, 0x057,
- 0x058, 0x059, 0x05A, 0x05B, 0x05C, 0x05D, 0x05E, 0x05F, 0x6CE,
- 0x6CF, 0x6D0, 0x6D1, 0x6D2, 0x6D3, 0x6D4, 0x6D5, 0x6D6, 0x6D7,
- 0x6D8, 0x6D9, 0x6DA, 0x6DB, 0x6DC, 0x6DD, 0x6DE, 0x6DF, 0x6E0,
- 0x6E1, 0x6E2, 0x6E3, 0x6E4, 0x6E5, 0x6E6, 0x6E7, 0x6FC, 0x6FD,
- 0x6FE, 0x6FF
- };
+static int gain_lut[74] = { 0x000, 0x004, 0x005, 0x006, 0x007, 0x008, 0x009, 0x00A, 0x00B, 0x00C, 0x00D, 0x00E, 0x00F, 0x010,
+ 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x017, 0x018, 0x019, 0x01A, 0x01B, 0x01C, 0x01D, 0x01E, 0x01F, 0x051, 0x052,
+ 0x053, 0x054, 0x055, 0x056, 0x057, 0x058, 0x059, 0x05A, 0x05B, 0x05C, 0x05D, 0x05E, 0x05F, 0x6CE, 0x6CF, 0x6D0, 0x6D1,
+ 0x6D2, 0x6D3, 0x6D4, 0x6D5, 0x6D6, 0x6D7, 0x6D8, 0x6D9, 0x6DA, 0x6DB, 0x6DC, 0x6DD, 0x6DE, 0x6DF, 0x6E0, 0x6E1, 0x6E2,
+ 0x6E3, 0x6E4, 0x6E5, 0x6E6, 0x6E7, 0x6FC, 0x6FD, 0x6FE, 0x6FF };
static libusb_device_handle *m_handle = NULL;
@@ -125,14 +121,14 @@ bool CameraQHY5::Connect(const wxString& camId)
return true;
}
- if ( libusb_kernel_driver_active( m_handle, 0 ) )
- libusb_detach_kernel_driver( m_handle, 0 );
+ if (libusb_kernel_driver_active(m_handle, 0))
+ libusb_detach_kernel_driver(m_handle, 0);
- libusb_set_configuration( m_handle, 1 );
- libusb_claim_interface( m_handle, 0 );
+ libusb_set_configuration(m_handle, 1);
+ libusb_claim_interface(m_handle, 0);
if (RawBuffer)
- delete [] RawBuffer;
+ delete[] RawBuffer;
RawBuffer = new unsigned char[QHY5_BUFFER_SIZE];
@@ -155,23 +151,23 @@ bool CameraQHY5::ST4PulseGuideScope(int direction, int duration)
case WEST:
reg = 0x80;
dur[0] = duration;
- break; // 0111 0000
+ break; // 0111 0000
case NORTH:
reg = 0x40;
dur[1] = duration;
- break; // 1011 0000
+ break; // 1011 0000
case SOUTH:
reg = 0x20;
dur[1] = duration;
- break; // 1101 0000
+ break; // 1101 0000
case EAST:
reg = 0x10;
dur[0] = duration;
- break; // 1110 0000
+ break; // 1110 0000
default:
return true; // bad direction passed in
}
- result = libusb_control_transfer(m_handle, 0x42, 0x10, 0, reg, (unsigned char *)dur, sizeof(dur), 5000);
+ result = libusb_control_transfer(m_handle, 0x42, 0x10, 0, reg, (unsigned char *) dur, sizeof(dur), 5000);
wxMilliSleep(duration + 10);
return result < 0 ? true : false;
}
@@ -179,22 +175,20 @@ bool CameraQHY5::ST4PulseGuideScope(int direction, int duration)
void CameraQHY5::ClearGuidePort()
{
int16_t res = 0;
- libusb_control_transfer(m_handle, 0xc2, 0x18, 0, 0, (unsigned char *)&res, sizeof(res), 5000);
+ libusb_control_transfer(m_handle, 0xc2, 0x18, 0, 0, (unsigned char *) &res, sizeof(res), 5000);
}
-void CameraQHY5::InitCapture()
-{
-}
+void CameraQHY5::InitCapture() { }
bool CameraQHY5::Disconnect()
{
- libusb_release_interface( m_handle, 0 );
- libusb_close( m_handle );
+ libusb_release_interface(m_handle, 0);
+ libusb_close(m_handle);
m_handle = NULL;
Connected = false;
if (RawBuffer)
- delete [] RawBuffer;
+ delete[] RawBuffer;
RawBuffer = NULL;
return false;
@@ -202,20 +196,20 @@ bool CameraQHY5::Disconnect()
bool CameraQHY5::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
-// Only does full frames still
- //static int last_dur = 0;
+ // Only does full frames still
+ // static int last_dur = 0;
static int last_gain = 60;
static int first_time = 1;
unsigned char *bptr;
unsigned short *dptr;
- int x, y;
+ int x, y;
int xsize = FullSize.GetWidth();
int ysize = FullSize.GetHeight();
int op_height = FullSize.GetHeight();
- //bool firstimg = true;
+ // bool firstimg = true;
unsigned char buffer[2]; // for debug purposes
int offset, value, index;
- int gain, gain_val, gain_lut_sz = (int)(sizeof(gain_lut) / sizeof(int));
+ int gain, gain_val, gain_lut_sz = (int) (sizeof(gain_lut) / sizeof(int));
int ret, result;
if (img.Init(xsize, ysize))
@@ -226,21 +220,21 @@ bool CameraQHY5::Capture(int duration, usImage& img, int options, const wxRect&
if (GuideCameraGain != last_gain)
{
- op_height -= (op_height % 4);
+ op_height -= (op_height % 4);
offset = (QHY5_MATRIX_HEIGHT - op_height) / 2;
index = (QHY5_MATRIX_WIDTH * (op_height + 26)) >> 16;
value = (QHY5_MATRIX_WIDTH * (op_height + 26)) & 0xffff;
- gain = (int)(73. * (GuideCameraGain / 100.));
- if ( gain >= gain_lut_sz )
+ gain = (int) (73. * (GuideCameraGain / 100.));
+ if (gain >= gain_lut_sz)
gain = gain_lut_sz - 1;
- if ( gain < 0 )
+ if (gain < 0)
gain = 0;
- gain_val = gain_lut[ gain ];
- STORE_WORD_BE(reg + 0, gain_val);
- STORE_WORD_BE(reg + 2, gain_val);
- STORE_WORD_BE(reg + 4, gain_val);
- STORE_WORD_BE(reg + 6, gain_val);
- STORE_WORD_BE(reg + 8, offset);
+ gain_val = gain_lut[gain];
+ STORE_WORD_BE(reg + 0, gain_val);
+ STORE_WORD_BE(reg + 2, gain_val);
+ STORE_WORD_BE(reg + 4, gain_val);
+ STORE_WORD_BE(reg + 6, gain_val);
+ STORE_WORD_BE(reg + 8, offset);
STORE_WORD_BE(reg + 10, 0);
STORE_WORD_BE(reg + 12, op_height - 1);
STORE_WORD_BE(reg + 14, 0x0521);
@@ -271,7 +265,7 @@ bool CameraQHY5::Capture(int duration, usImage& img, int options, const wxRect&
/* wait for exposure end */
wxMilliSleep(duration);
- ret = libusb_bulk_transfer( m_handle, 0x82, RawBuffer, QHY5_BUFFER_SIZE, &result, 20000);
+ ret = libusb_bulk_transfer(m_handle, 0x82, RawBuffer, QHY5_BUFFER_SIZE, &result, 20000);
if (ret < 0)
{
pFrame->Alert(_T("Failed to read image: libusb_bulk_transfer() failed."));
@@ -284,8 +278,8 @@ bool CameraQHY5::Capture(int duration, usImage& img, int options, const wxRect&
return true;
}
- //bptr = RawBuffer;
- // Load and crop from the 800 x 525 image that came in
+ // bptr = RawBuffer;
+ // Load and crop from the 800 x 525 image that came in
dptr = img.ImageData;
for (y = 0; y < ysize; y++)
{
@@ -296,7 +290,8 @@ bool CameraQHY5::Capture(int duration, usImage& img, int options, const wxRect&
}
}
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
return false;
}
diff --git a/src/cam_qhy5.h b/src/cam_qhy5.h
index 6f209e6a7..8090c8d7b 100644
--- a/src/cam_qhy5.h
+++ b/src/cam_qhy5.h
@@ -43,16 +43,16 @@ class CameraQHY5 : public GuideCamera
public:
CameraQHY5();
~CameraQHY5();
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- void InitCapture() override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ void InitCapture() override;
- bool ST4PulseGuideScope(int direction, int duration) override;
- bool ST4HasNonGuiMove() override { return true; }
- bool HasNonGuiCapture() override { return true; }
- void ClearGuidePort();
- wxByte BitsPerPixel() override;
+ bool ST4PulseGuideScope(int direction, int duration) override;
+ bool ST4HasNonGuiMove() override { return true; }
+ bool HasNonGuiCapture() override { return true; }
+ void ClearGuidePort();
+ wxByte BitsPerPixel() override;
};
#endif // QHY5IIIBASE_H_INCLUDED
diff --git a/src/cam_sbig.cpp b/src/cam_sbig.cpp
index d22b63838..38495debc 100644
--- a/src/cam_sbig.cpp
+++ b/src/cam_sbig.cpp
@@ -36,20 +36,20 @@
#if defined(SBIG)
-#include "cam_sbig.h"
-#include "camera.h"
-#include "image_math.h"
-
-#include
-#include
-
-#if defined (__APPLE__)
-#include
-#elif defined(__LINUX__)
-#include
-#else
-#include "cameras/Sbigudrv.h"
-#endif
+# include "cam_sbig.h"
+# include "camera.h"
+# include "image_math.h"
+
+# include
+# include
+
+# if defined(__APPLE__)
+# include
+# elif defined(__LINUX__)
+# include
+# else
+# include "cameras/Sbigudrv.h"
+# endif
class CameraSBIG : public GuideCamera
{
@@ -85,7 +85,8 @@ static unsigned long bcd2long(unsigned long bcd)
int digit;
unsigned long val = 0;
- do {
+ do
+ {
pos -= 4;
digit = (bcd >> pos) & 0xf;
val = val * 10 + digit;
@@ -99,8 +100,8 @@ CameraSBIG::CameraSBIG()
{
Connected = false;
Name = _T("SBIG");
- //FullSize = wxSize(1280,1024);
- //HasGainControl = true;
+ // FullSize = wxSize(1280,1024);
+ // HasGainControl = true;
m_hasGuideOutput = true;
m_useTrackingCCD = false;
HasShutter = true;
@@ -123,16 +124,18 @@ static bool _LoadDriver()
{
short err;
-#if defined (__WINDOWS__)
- __try {
+# if defined(__WINDOWS__)
+ __try
+ {
err = SBIGUnivDrvCommand(CC_OPEN_DRIVER, NULL, NULL);
}
- __except (EXCEPTION_EXECUTE_HANDLER) {
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {
err = CE_DRIVER_NOT_FOUND;
}
-#else
+# else
err = SBIGUnivDrvCommand(CC_OPEN_DRIVER, NULL, NULL);
-#endif
+# endif
return err == CE_NO_ERROR;
}
@@ -158,20 +161,19 @@ static bool SelectInterfaceAndDevice()
interf.Add("USB");
interf.Add("Ethernet");
-#if defined (__WINDOWS__)
+# if defined(__WINDOWS__)
interf.Add("LPT 0x378");
interf.Add("LPT 0x278");
interf.Add("LPT 0x3BC");
-#else
+# else
interf.Add("USB1 direct");
interf.Add("USB2 direct");
interf.Add("USB3 direct");
-#endif
+# endif
int resp = pConfig->Profile.GetInt("/camera/sbig/interface", 0);
- resp = wxGetSingleChoiceIndex(_("Select interface"), _("Interface"), interf,
- NULL, wxDefaultCoord, wxDefaultCoord, true, wxCHOICE_WIDTH, wxCHOICE_HEIGHT,
- resp);
+ resp = wxGetSingleChoiceIndex(_("Select interface"), _("Interface"), interf, NULL, wxDefaultCoord, wxDefaultCoord, true,
+ wxCHOICE_WIDTH, wxCHOICE_HEIGHT, resp);
if (resp == -1)
{
@@ -185,7 +187,8 @@ static bool SelectInterfaceAndDevice()
short err;
- switch (resp) {
+ switch (resp)
+ {
case 0:
odp.deviceType = DEV_USB;
QueryUSBResults2 usbp;
@@ -207,10 +210,11 @@ static bool SelectInterfaceAndDevice()
odp.deviceType = DEV_USB1 + i;
}
break;
- case 1: {
+ case 1:
+ {
odp.deviceType = DEV_ETH;
- wxString IPstr = wxGetTextFromUser(_("IP address"), _("Enter IP address"),
- pConfig->Profile.GetString("/camera/sbig/ipaddr", _T("")));
+ wxString IPstr = wxGetTextFromUser(
+ _("IP address"), _("Enter IP address"), pConfig->Profile.GetString("/camera/sbig/ipaddr", _T("")));
Debug.Write(wxString::Format("SBIG: selected ipaddr %s\n", IPstr));
if (IPstr.length() == 0)
return true;
@@ -234,7 +238,7 @@ static bool SelectInterfaceAndDevice()
odp.ipAddress = ip;
break;
}
-#ifdef __WINDOWS__
+# ifdef __WINDOWS__
case 2:
Debug.Write("SBIG: selected LPT1\n");
odp.deviceType = DEV_LPT1;
@@ -250,7 +254,7 @@ static bool SelectInterfaceAndDevice()
odp.deviceType = DEV_LPT3;
odp.lptBaseAddress = 0x3BC;
break;
-#else
+# else
case 2:
Debug.Write("SBIG: selected USB1\n");
odp.deviceType = DEV_USB1;
@@ -263,7 +267,7 @@ static bool SelectInterfaceAndDevice()
Debug.Write("SBIG: selected USB3\n");
odp.deviceType = DEV_USB3;
break;
-#endif
+# endif
}
pConfig->Profile.SetInt("/camera/sbig/deviceType", odp.deviceType);
@@ -406,7 +410,7 @@ bool CameraSBIG::Connect(const wxString& camId)
err = SBIGUnivDrvCommand(CC_GET_CCD_INFO, &gcip, &gcir6);
if (err == CE_NO_ERROR)
{
- IsColor = gcir6.ccdBits & 1; // b0 set indicates color CCD
+ IsColor = gcir6.ccdBits & 1; // b0 set indicates color CCD
}
}
@@ -416,9 +420,10 @@ bool CameraSBIG::Connect(const wxString& camId)
IsColor = true;
}
- Debug.Write(wxString::Format("SBIG: %s type=%u, UseTrackingCCD=%d, MaxBin = %hu, 1x1 size %d x %d, 2x2 size %d x %d IsColor %d\n",
- gcir0.name, gcir0.cameraType, m_useTrackingCCD, MaxBinning, m_imageSize[0].x, m_imageSize[0].y, m_imageSize[1].x, m_imageSize[1].y,
- IsColor));
+ Debug.Write(
+ wxString::Format("SBIG: %s type=%u, UseTrackingCCD=%d, MaxBin = %hu, 1x1 size %d x %d, 2x2 size %d x %d IsColor %d\n",
+ gcir0.name, gcir0.cameraType, m_useTrackingCCD, MaxBinning, m_imageSize[0].x, m_imageSize[0].y, m_imageSize[1].x,
+ m_imageSize[1].y, IsColor));
Connected = true;
return false;
@@ -459,7 +464,8 @@ bool CameraSBIG::Capture(int duration, usImage& img, int options, const wxRect&
FullSize = m_imageSize[Binning - 1];
- if (subframe.width <= 0 || subframe.height <= 0 || subframe.GetRight() >= FullSize.GetWidth() || subframe.GetBottom() >= FullSize.GetHeight())
+ if (subframe.width <= 0 || subframe.height <= 0 || subframe.GetRight() >= FullSize.GetWidth() ||
+ subframe.GetBottom() >= FullSize.GetHeight())
{
TakeSubframe = false;
}
@@ -473,7 +479,7 @@ bool CameraSBIG::Capture(int duration, usImage& img, int options, const wxRect&
if (m_useTrackingCCD)
{
- sep.ccd = CCD_TRACKING;
+ sep.ccd = CCD_TRACKING;
sep.abgState = ABG_CLK_LOW7;
eep.ccd = CCD_TRACKING;
rlp.ccd = CCD_TRACKING;
@@ -481,7 +487,7 @@ bool CameraSBIG::Capture(int duration, usImage& img, int options, const wxRect&
}
else
{
- sep.ccd = CCD_IMAGING;
+ sep.ccd = CCD_IMAGING;
sep.abgState = ABG_LOW7;
eep.ccd = CCD_IMAGING;
rlp.ccd = CCD_IMAGING;
@@ -490,8 +496,7 @@ bool CameraSBIG::Capture(int duration, usImage& img, int options, const wxRect&
sep.exposureTime = (unsigned long) duration / 10;
sep.openShutter = ShutterClosed ? SC_CLOSE_SHUTTER : SC_OPEN_SHUTTER;
- sep.readoutMode = rlp.readoutMode = dlp.readoutMode =
- Binning == 1 ? RM_1X1 : RM_2X2;
+ sep.readoutMode = rlp.readoutMode = dlp.readoutMode = Binning == 1 ? RM_1X1 : RM_2X2;
if (TakeSubframe)
{
@@ -582,7 +587,7 @@ bool CameraSBIG::Capture(int duration, usImage& img, int options, const wxRect&
SBIGUnivDrvCommand(CC_DUMP_LINES, &dlp, NULL);
// set up to read the part of the lines we do want
- rlp.pixelStart = subframe.x;
+ rlp.pixelStart = subframe.x;
rlp.pixelLength = subframe.width;
img.Clear();
@@ -600,7 +605,7 @@ bool CameraSBIG::Capture(int duration, usImage& img, int options, const wxRect&
}
else
{
- rlp.pixelStart = 0;
+ rlp.pixelStart = 0;
rlp.pixelLength = (unsigned short) FullSize.GetWidth();
unsigned short *dataptr = img.ImageData;
for (int y = 0; y < FullSize.GetHeight(); y++)
@@ -628,28 +633,41 @@ bool CameraSBIG::ST4PulseGuideScope(int direction, int duration)
ActivateRelayParams rp;
rp.tXMinus = rp.tXPlus = rp.tYMinus = rp.tYPlus = 0;
unsigned short dur = duration / 10;
- switch (direction) {
- case WEST: rp.tXMinus = dur; break;
- case EAST: rp.tXPlus = dur; break;
- case NORTH: rp.tYMinus = dur; break;
- case SOUTH: rp.tYPlus = dur; break;
+ switch (direction)
+ {
+ case WEST:
+ rp.tXMinus = dur;
+ break;
+ case EAST:
+ rp.tXPlus = dur;
+ break;
+ case NORTH:
+ rp.tYMinus = dur;
+ break;
+ case SOUTH:
+ rp.tYPlus = dur;
+ break;
}
short err = SBIGUnivDrvCommand(CC_ACTIVATE_RELAY, &rp, NULL);
- if (err != CE_NO_ERROR) return true;
+ if (err != CE_NO_ERROR)
+ return true;
- if (duration > 60) wxMilliSleep(duration - 50);
+ if (duration > 60)
+ wxMilliSleep(duration - 50);
QueryCommandStatusParams qcsp;
qcsp.command = CC_ACTIVATE_RELAY;
MountWatchdog watchdog(duration, 5000);
- while (true) { // wait for pulse to finish
+ while (true)
+ { // wait for pulse to finish
wxMilliSleep(10);
QueryCommandStatusResults qcsr;
err = SBIGUnivDrvCommand(CC_QUERY_COMMAND_STATUS, &qcsp, &qcsr);
- if (err != CE_NO_ERROR) {
+ if (err != CE_NO_ERROR)
+ {
pFrame->Alert(_("Cannot check SBIG relay status"));
return true;
}
diff --git a/src/cam_sbigrotator.cpp b/src/cam_sbigrotator.cpp
index 3e5f9d3d7..20b169001 100644
--- a/src/cam_sbigrotator.cpp
+++ b/src/cam_sbigrotator.cpp
@@ -36,8 +36,8 @@
#if defined(SBIG) && defined(SBIGROTATOR_CAMERA)
-#include "cam_sbigrotator.h"
-#include "cam_sbig.h"
+# include "cam_sbigrotator.h"
+# include "cam_sbig.h"
class CameraSBIGRotator : public GuideCamera
{
@@ -80,7 +80,7 @@ bool CameraSBIGRotator::Connect(const wxString& camId)
try
{
- wxString raAngle = wxGetTextFromUser(_("Enter RA Angle (in degrees)"),_("RA angle"), _T("0.0"));
+ wxString raAngle = wxGetTextFromUser(_("Enter RA Angle (in degrees)"), _("RA angle"), _T("0.0"));
double temp;
if (raAngle.length() == 0 || !raAngle.ToDouble(&temp))
@@ -95,8 +95,7 @@ bool CameraSBIGRotator::Connect(const wxString& camId)
choices.Add(wxString::Format("Unmirrored (%.2f)", temp - 90));
choices.Add(wxString::Format("Mirrored (%.2f)", temp + 90));
- int idx = wxGetSingleChoiceIndex(_("Choose Dec Angle"), _("Dec Angle"),
- choices);
+ int idx = wxGetSingleChoiceIndex(_("Choose Dec Angle"), _("Dec Angle"), choices);
if (idx == -1)
return true;
@@ -151,7 +150,7 @@ bool CameraSBIGRotator::Capture(int duration, usImage& img, int options, const w
return bError;
}
-bool CameraSBIGRotator::ST4PulseGuideScope (int direction, int duration)
+bool CameraSBIGRotator::ST4PulseGuideScope(int direction, int duration)
{
return m_pSubcamera->ST4PulseGuideScope(direction, duration);
}
diff --git a/src/cam_sbigrotator.h b/src/cam_sbigrotator.h
index 554dd6ed4..c021e40ff 100644
--- a/src/cam_sbigrotator.h
+++ b/src/cam_sbigrotator.h
@@ -33,7 +33,7 @@
*/
#if defined(SBIG) && defined(SBIGROTATOR_CAMERA) && !defined(SBIGROTATOR_CAMERA_H_INCLUDED)
-#define SBIGROTATOR_CAMERA_H_INCLUDED
+# define SBIGROTATOR_CAMERA_H_INCLUDED
class SBIGRotatorCameraFactory
{
@@ -41,4 +41,4 @@ class SBIGRotatorCameraFactory
static GuideCamera *MakeSBIGRotatorCamera();
};
-#endif //defined(SBIGROTATOR_CAMERA_H_INCLUDED) and defined(SBIG)
+#endif // defined(SBIGROTATOR_CAMERA_H_INCLUDED) and defined(SBIG)
diff --git a/src/cam_skyraider.cpp b/src/cam_skyraider.cpp
index 0ee8bc131..01a47b1a1 100644
--- a/src/cam_skyraider.cpp
+++ b/src/cam_skyraider.cpp
@@ -36,10 +36,10 @@
#if defined(SKYRAIDER_CAMERA)
-#include "cam_skyraider.h"
+# include "cam_skyraider.h"
-#include "MallincamGuider/MallincamGuider.h"
-#include "MallincamGuider/toupcam.h"
+# include "MallincamGuider/MallincamGuider.h"
+# include "MallincamGuider/toupcam.h"
static bool verbose = true;
@@ -74,22 +74,15 @@ struct SkyraiderCamera : public GuideCamera
void FrameReady();
bool StopCapture();
- int gain_pct(int val) const
- {
- return (val - m_minGain) * 100 / (m_maxGain - m_minGain);
- }
+ int gain_pct(int val) const { return (val - m_minGain) * 100 / (m_maxGain - m_minGain); }
- int cam_gain(int pct) const
- {
- return m_minGain + pct * (m_maxGain - m_minGain) / 100;
- }
+ int cam_gain(int pct) const { return m_minGain + pct * (m_maxGain - m_minGain) / 100; }
};
-//#define USE_PUSH_MODE
+// #define USE_PUSH_MODE
-#ifdef USE_PUSH_MODE
-static void __stdcall CameraPushDataCallback(const void *pData, const BITMAPINFOHEADER *pHeader,
- BOOL bSnap, void *pCallbackCtx)
+# ifdef USE_PUSH_MODE
+static void __stdcall CameraPushDataCallback(const void *pData, const BITMAPINFOHEADER *pHeader, BOOL bSnap, void *pCallbackCtx)
{
if (pData)
{
@@ -97,7 +90,7 @@ static void __stdcall CameraPushDataCallback(const void *pData, const BITMAPINFO
pCam->FrameReady();
}
}
-#else // USE_PUSH_MODE
+# else // USE_PUSH_MODE
static void __stdcall CameraCallback(unsigned nEvent, void *pCallbackCtx)
{
if (nEvent == MALLINCAM_EVENT_IMAGE)
@@ -106,11 +99,11 @@ static void __stdcall CameraCallback(unsigned nEvent, void *pCallbackCtx)
pCam->FrameReady();
}
}
-#endif // USE_PUSH_MODE
+# endif // USE_PUSH_MODE
SkyraiderCamera::SkyraiderCamera()
- : m_buffer(nullptr),
- m_capturing(false)
+ : m_buffer(nullptr)
+ , m_capturing(false)
{
Connected = false;
Name = _T("MallinCam SkyRaider");
@@ -174,8 +167,8 @@ bool SkyraiderCamera::Connect(const wxString& camId)
m_maxGain = max;
HasGainControl = max > min;
m_defaultGainPct = gain_pct(def);
- Debug.Write(wxString::Format("SKYRAIDER: gain range %d .. %d, default = %d (%d%%)\n",
- m_minGain, m_maxGain, def, m_defaultGainPct));
+ Debug.Write(wxString::Format(
+ "SKYRAIDER: gain range %d .. %d, default = %d (%d%%)\n", m_minGain, m_maxGain, def, m_defaultGainPct));
}
if (m_buffer)
@@ -185,8 +178,8 @@ bool SkyraiderCamera::Connect(const wxString& camId)
m_buffer = new unsigned char[FullSize.x * FullSize.y];
- //Mallincam_put_AutoExpoEnable(m_Guider.m_Hmallincam, 0);
- //Toupcam_put_AutoExpoEnable(reinterpret_cast(m_Guider.m_Hmallincam), 0);
+ // Mallincam_put_AutoExpoEnable(m_Guider.m_Hmallincam, 0);
+ // Toupcam_put_AutoExpoEnable(reinterpret_cast(m_Guider.m_Hmallincam), 0);
return false;
}
@@ -210,18 +203,16 @@ bool SkyraiderCamera::Capture(int duration, usImage& img, int options, const wxR
int res = m_Guider.Mallincam_get_ExpoTime(m_Guider.m_Hmallincam, &cur_exp);
if ((res == MC_SUCCESS) && (cur_exp != exposureUS))
{
- Debug.Write(wxString::Format("SKYRAIDER: exposure value is %u, updating to %ld\n",
- cur_exp, exposureUS));
+ Debug.Write(wxString::Format("SKYRAIDER: exposure value is %u, updating to %ld\n", cur_exp, exposureUS));
res = m_Guider.Mallincam_put_ExpoTime(m_Guider.m_Hmallincam, exposureUS);
}
unsigned short new_gain = cam_gain(GuideCameraGain);
unsigned short cur_gain;
- if (m_Guider.Mallincam_get_ExpoAGain(m_Guider.m_Hmallincam, &cur_gain) == MC_SUCCESS &&
- new_gain != cur_gain)
+ if (m_Guider.Mallincam_get_ExpoAGain(m_Guider.m_Hmallincam, &cur_gain) == MC_SUCCESS && new_gain != cur_gain)
{
- Debug.Write(wxString::Format("SKYRAIDER: gain value is %hu (%d%%), updating to %hu (%d%%)\n",
- cur_gain, gain_pct(cur_gain), new_gain, GuideCameraGain));
+ Debug.Write(wxString::Format("SKYRAIDER: gain value is %hu (%d%%), updating to %hu (%d%%)\n", cur_gain,
+ gain_pct(cur_gain), new_gain, GuideCameraGain));
m_Guider.Mallincam_put_ExpoAGain(m_Guider.m_Hmallincam, new_gain);
}
@@ -230,21 +221,21 @@ bool SkyraiderCamera::Capture(int duration, usImage& img, int options, const wxR
// get is current
unsigned int width, height;
-#if 0 // TODO: this is almost certainly required, but it was excluded for some reason and I have no way to test it
+# if 0 // TODO: this is almost certainly required, but it was excluded for some reason and I have no way to test it
while (SUCCEEDED(m_sdk.PullImage(m_handle, m_buffer, 8, &width, &height)))
{
}
-#endif
+# endif
if (!m_capturing)
{
Debug.Write("SKYRAIDER: startcapture\n");
m_frameReady = false;
-#ifdef USE_PUSH_MODE
+# ifdef USE_PUSH_MODE
m_Guider.Mallincam_StartPushMode(m_Guider.m_Hmallincam, CameraPushDataCallback, this);
-#else
+# else
m_Guider.Mallincam_StartPullModeWithCallback(m_Guider.m_Hmallincam, CameraCallback, this);
-#endif
+# endif
m_capturing = true;
}
@@ -252,28 +243,31 @@ bool SkyraiderCamera::Capture(int duration, usImage& img, int options, const wxR
CameraWatchdog watchdog(duration, duration + GetTimeoutMs() + 10000); // total timeout is 2 * duration + 15s (typically)
-// do not wait here, as we will miss a frame most likely, leading to poor flow of frames.
-// if (WorkerThread::MilliSleep(duration, WorkerThread::INT_ANY) &&
-// (WorkerThread::TerminateRequested() || StopCapture()))
-// {
-// return true;
-// }
+ // do not wait here, as we will miss a frame most likely, leading to poor flow of frames.
+ // if (WorkerThread::MilliSleep(duration, WorkerThread::INT_ANY) &&
+ // (WorkerThread::TerminateRequested() || StopCapture()))
+ // {
+ // return true;
+ // }
while (true)
{
if (m_frameReady)
{
- if (verbose) Debug.Write("SKYRAIDER: frame is ready, pull image\n");
+ if (verbose)
+ Debug.Write("SKYRAIDER: frame is ready, pull image\n");
m_frameReady = false;
int result = m_Guider.Mallincam_PullImage(m_Guider.m_Hmallincam, m_buffer, 8, &width, &height);
- if (verbose) Debug.Write(wxString::Format("SKYRAIDER: pull image ret %d\n", res));
+ if (verbose)
+ Debug.Write(wxString::Format("SKYRAIDER: pull image ret %d\n", res));
if (result == MC_SUCCESS)
break;
}
WorkerThread::MilliSleep(poll, WorkerThread::INT_ANY);
if (WorkerThread::InterruptRequested())
{
- if (verbose) Debug.Write("SKYRAIDER: interrupt requested\n");
+ if (verbose)
+ Debug.Write("SKYRAIDER: interrupt requested\n");
StopCapture();
return true;
}
@@ -289,7 +283,8 @@ bool SkyraiderCamera::Capture(int duration, usImage& img, int options, const wxR
for (int i = 0; i < img.NPixels; i++)
img.ImageData[i] = m_buffer[i];
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
return false;
}
@@ -307,7 +302,8 @@ bool SkyraiderCamera::StopCapture()
void SkyraiderCamera::FrameReady()
{
- if (verbose) Debug.Write("SKYRAIDER: frameready callback\n");
+ if (verbose)
+ Debug.Write("SKYRAIDER: frameready callback\n");
m_frameReady = true;
}
diff --git a/src/cam_sspiag.cpp b/src/cam_sspiag.cpp
index db2838bce..ca0e0d6b6 100644
--- a/src/cam_sspiag.cpp
+++ b/src/cam_sspiag.cpp
@@ -32,10 +32,10 @@
*
*/
#include "phd.h"
-#if defined (SSPIAG)
-#include "camera.h"
-#include "time.h"
-#include "image_math.h"
+#if defined(SSPIAG)
+# include "camera.h"
+# include "time.h"
+# include "image_math.h"
/* To-Do
- Updating gain on the fly, esp. if also changing exposure duration?
@@ -43,22 +43,22 @@
*/
-#include "cam_sspiag.h"
+# include "cam_sspiag.h"
// Orion SS PI AG camera (aka QHY5V)
-//extern "C" __declspec(dllexport) __stdcall void setDevName(PCHAR i);
-typedef void (CALLBACK* Q5V_PCHAR)(char*);
+// extern "C" __declspec(dllexport) __stdcall void setDevName(PCHAR i);
+typedef void(CALLBACK *Q5V_PCHAR)(char *);
Q5V_PCHAR Q5V_SetDevName;
-//extern "C" __declspec(dllexport) __stdcall void getFullSizeImage(unsigned char *img);
-//extern "C" __declspec(dllexport) __stdcall void RowNoiseReductionMethod(unsigned char i);
-//extern "C" __declspec(dllexport) __stdcall void BlackCalibration(unsigned char i); //0= not enable 1=enable
-//extern "C" __declspec(dllexport) __stdcall void RowNoiseConstant(unsigned char i);
-typedef void (CALLBACK* Q5V_UPCHAR)(unsigned char*);
+// extern "C" __declspec(dllexport) __stdcall void getFullSizeImage(unsigned char *img);
+// extern "C" __declspec(dllexport) __stdcall void RowNoiseReductionMethod(unsigned char i);
+// extern "C" __declspec(dllexport) __stdcall void BlackCalibration(unsigned char i); //0= not enable 1=enable
+// extern "C" __declspec(dllexport) __stdcall void RowNoiseConstant(unsigned char i);
+typedef void(CALLBACK *Q5V_UPCHAR)(unsigned char *);
Q5V_UPCHAR Q5V_GetFullSizeImage;
-//extern "C" __declspec(dllexport) __stdcall unsigned char openQHY5V(void);
-typedef unsigned char (CALLBACK* Q5V_UC_V)(void);
+// extern "C" __declspec(dllexport) __stdcall unsigned char openQHY5V(void);
+typedef unsigned char(CALLBACK *Q5V_UC_V)(void);
Q5V_UC_V Q5V_OpenQHY5V;
/*extern "C" __declspec(dllexport) __stdcall void AGC_enable(int i);
@@ -68,7 +68,7 @@ extern "C" __declspec(dllexport) __stdcall void LongExpMode(int i);
extern "C" __declspec(dllexport) __stdcall void HighDynamic(int i);
extern "C" __declspec(dllexport) __stdcall void BlackOffset(int i);
*/
-typedef void (CALLBACK* Q5V_INT)(int);
+typedef void(CALLBACK *Q5V_INT)(int);
Q5V_INT Q5V_AGC_Enable;
Q5V_INT Q5V_AEC_Enable;
Q5V_INT Q5V_BitCompanding;
@@ -76,44 +76,44 @@ Q5V_INT Q5V_LongExpMode;
Q5V_INT Q5V_HighDynamic;
Q5V_INT Q5V_BlackOffset;
-//extern "C" __declspec(dllexport) __stdcall void HighGainBoost(unsigned char i);
-typedef void (CALLBACK* Q5V_UC)(unsigned char);
+// extern "C" __declspec(dllexport) __stdcall void HighGainBoost(unsigned char i);
+typedef void(CALLBACK *Q5V_UC)(unsigned char);
Q5V_UC Q5V_HighGainBoost;
Q5V_UC Q5V_RowNoiseReductionMethod;
Q5V_UC Q5V_BlackCalibration;
Q5V_UC Q5V_RowNoiseConstant;
-//extern "C" __declspec(dllexport) __stdcall void setQHY5VGlobalGain(unsigned short i);
-//extern "C" __declspec(dllexport) __stdcall void setTotalShutterWidth(unsigned short width);
-typedef void (CALLBACK* Q5V_US)(unsigned short);
+// extern "C" __declspec(dllexport) __stdcall void setQHY5VGlobalGain(unsigned short i);
+// extern "C" __declspec(dllexport) __stdcall void setTotalShutterWidth(unsigned short width);
+typedef void(CALLBACK *Q5V_US)(unsigned short);
Q5V_US Q5V_SetQHY5VGlobalGain;
Q5V_US Q5V_SetTotalShutterWidth;
-//extern "C" __declspec(dllexport) __stdcall void RowNoiseReduction(int en,int useblacklevel,unsigned char darkpixels,unsigned char RowNoiseConstant);
-//typedef void (CALLBACK* Q5V_ROWNR)(int, int, unsigned char, unsigned char);
-//Q5V_ROWNR Q5V_RowNoiseReduction;
+// extern "C" __declspec(dllexport) __stdcall void RowNoiseReduction(int en,int useblacklevel,unsigned char darkpixels,unsigned
+// char RowNoiseConstant); typedef void (CALLBACK* Q5V_ROWNR)(int, int, unsigned char, unsigned char); Q5V_ROWNR
+// Q5V_RowNoiseReduction;
-//extern "C" __declspec(dllexport) __stdcall void ReadMode(int RowFlip,int ColumnFlip,int ShowDarkRows,int ShowDarkColumns);
-typedef void (CALLBACK* Q5V_RMODE)(int, int, int, int);
+// extern "C" __declspec(dllexport) __stdcall void ReadMode(int RowFlip,int ColumnFlip,int ShowDarkRows,int ShowDarkColumns);
+typedef void(CALLBACK *Q5V_RMODE)(int, int, int, int);
Q5V_RMODE Q5V_ReadMode;
-//extern "C" __declspec(dllexport) __stdcall void setLongExpTime(unsigned long i);
-typedef void (CALLBACK* Q5V_UL)(unsigned long);
+// extern "C" __declspec(dllexport) __stdcall void setLongExpTime(unsigned long i);
+typedef void(CALLBACK *Q5V_UL)(unsigned long);
Q5V_UL Q5V_SetLongExpTime;
-//extern "C" __declspec(dllexport) __stdcall void QHY5VInit(void);
-typedef void (CALLBACK* Q5V_V)(void);
+// extern "C" __declspec(dllexport) __stdcall void QHY5VInit(void);
+typedef void(CALLBACK *Q5V_V)(void);
Q5V_V Q5V_QHY5VInit;
-//sendGuideCommand(PCHAR devname,unsigned char GuideCommand,unsigned char PulseTime);//for QHY5,QHY5V
-typedef void (CALLBACK* Q5V_GUIDE) (char*, unsigned char, unsigned char);
+// sendGuideCommand(PCHAR devname,unsigned char GuideCommand,unsigned char PulseTime);//for QHY5,QHY5V
+typedef void(CALLBACK *Q5V_GUIDE)(char *, unsigned char, unsigned char);
Q5V_GUIDE Q5V_SendGuideCommand;
CameraSSPIAG::CameraSSPIAG()
{
Connected = false;
Name = _T("StarShoot PIAG");
- FullSize = wxSize(752,480);
+ FullSize = wxSize(752, 480);
m_hasGuideOutput = true;
HasGainControl = true;
RawBuffer = NULL;
@@ -128,133 +128,155 @@ bool CameraSSPIAG::Connect(const wxString& camId)
{
// returns true on error
CameraDLL = LoadLibrary(TEXT("astroDLLsspiag"));
- if (CameraDLL == NULL) {
+ if (CameraDLL == NULL)
+ {
return CamConnectFailed(_("Cannot load astroDLLsspiag.dll"));
}
- Q5V_SetDevName = (Q5V_PCHAR)GetProcAddress(CameraDLL,"setDevName");
- if (!Q5V_SetDevName) {
+ Q5V_SetDevName = (Q5V_PCHAR) GetProcAddress(CameraDLL, "setDevName");
+ if (!Q5V_SetDevName)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "setDevName"));
}
- Q5V_GetFullSizeImage = (Q5V_UPCHAR)GetProcAddress(CameraDLL,"getFullSizeImage");
- if (!Q5V_GetFullSizeImage) {
+ Q5V_GetFullSizeImage = (Q5V_UPCHAR) GetProcAddress(CameraDLL, "getFullSizeImage");
+ if (!Q5V_GetFullSizeImage)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "getFullSizeImage"));
}
- Q5V_RowNoiseReductionMethod = (Q5V_UC)GetProcAddress(CameraDLL,"RowNoiseReductionMethod");
- if (!Q5V_RowNoiseReductionMethod) {
+ Q5V_RowNoiseReductionMethod = (Q5V_UC) GetProcAddress(CameraDLL, "RowNoiseReductionMethod");
+ if (!Q5V_RowNoiseReductionMethod)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "RowNoiseReductionMethod"));
}
- Q5V_BlackCalibration = (Q5V_UC)GetProcAddress(CameraDLL,"BlackCalibration");
- if (!Q5V_BlackCalibration) {
+ Q5V_BlackCalibration = (Q5V_UC) GetProcAddress(CameraDLL, "BlackCalibration");
+ if (!Q5V_BlackCalibration)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "BlackCalibration"));
}
- Q5V_RowNoiseConstant = (Q5V_UC)GetProcAddress(CameraDLL,"RowNoiseConstant");
- if (!Q5V_RowNoiseConstant) {
+ Q5V_RowNoiseConstant = (Q5V_UC) GetProcAddress(CameraDLL, "RowNoiseConstant");
+ if (!Q5V_RowNoiseConstant)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "RowNoiseConstant"));
}
- Q5V_OpenQHY5V = (Q5V_UC_V)GetProcAddress(CameraDLL,"openQHY5V");
- if (!Q5V_OpenQHY5V) {
+ Q5V_OpenQHY5V = (Q5V_UC_V) GetProcAddress(CameraDLL, "openQHY5V");
+ if (!Q5V_OpenQHY5V)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "openQHY5V"));
}
- Q5V_AGC_Enable = (Q5V_INT)GetProcAddress(CameraDLL,"AGC_enable");
- if (!Q5V_AGC_Enable) {
+ Q5V_AGC_Enable = (Q5V_INT) GetProcAddress(CameraDLL, "AGC_enable");
+ if (!Q5V_AGC_Enable)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "AGC_enable"));
}
- Q5V_AEC_Enable = (Q5V_INT)GetProcAddress(CameraDLL,"AEC_enable");
- if (!Q5V_AEC_Enable) {
+ Q5V_AEC_Enable = (Q5V_INT) GetProcAddress(CameraDLL, "AEC_enable");
+ if (!Q5V_AEC_Enable)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "AEC_enable"));
}
- Q5V_BitCompanding = (Q5V_INT)GetProcAddress(CameraDLL,"bitCompanding");
- if (!Q5V_BitCompanding) {
+ Q5V_BitCompanding = (Q5V_INT) GetProcAddress(CameraDLL, "bitCompanding");
+ if (!Q5V_BitCompanding)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "bitCompanding"));
}
- Q5V_LongExpMode = (Q5V_INT)GetProcAddress(CameraDLL,"LongExpMode");
- if (!Q5V_LongExpMode) {
+ Q5V_LongExpMode = (Q5V_INT) GetProcAddress(CameraDLL, "LongExpMode");
+ if (!Q5V_LongExpMode)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "LongExpMode"));
}
- Q5V_HighDynamic = (Q5V_INT)GetProcAddress(CameraDLL,"HighDynamic");
- if (!Q5V_HighDynamic) {
+ Q5V_HighDynamic = (Q5V_INT) GetProcAddress(CameraDLL, "HighDynamic");
+ if (!Q5V_HighDynamic)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "HighDynamic"));
}
- Q5V_BlackOffset = (Q5V_INT)GetProcAddress(CameraDLL,"BlackOffset");
- if (!Q5V_BlackOffset) {
+ Q5V_BlackOffset = (Q5V_INT) GetProcAddress(CameraDLL, "BlackOffset");
+ if (!Q5V_BlackOffset)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "BlackOffset"));
}
- Q5V_HighGainBoost = (Q5V_UC)GetProcAddress(CameraDLL,"HighGainBoost");
- if (!Q5V_HighGainBoost) {
+ Q5V_HighGainBoost = (Q5V_UC) GetProcAddress(CameraDLL, "HighGainBoost");
+ if (!Q5V_HighGainBoost)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "HighGainBoost"));
}
- Q5V_SetQHY5VGlobalGain = (Q5V_US)GetProcAddress(CameraDLL,"setQHY5VGlobalGain");
- if (!Q5V_SetQHY5VGlobalGain) {
+ Q5V_SetQHY5VGlobalGain = (Q5V_US) GetProcAddress(CameraDLL, "setQHY5VGlobalGain");
+ if (!Q5V_SetQHY5VGlobalGain)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "setQHY5VGlobalGain"));
}
- Q5V_SetTotalShutterWidth = (Q5V_US)GetProcAddress(CameraDLL,"setTotalShutterWidth");
- if (!Q5V_SetTotalShutterWidth) {
+ Q5V_SetTotalShutterWidth = (Q5V_US) GetProcAddress(CameraDLL, "setTotalShutterWidth");
+ if (!Q5V_SetTotalShutterWidth)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "setTotalShutterWidth"));
}
-/* Q5V_RowNoiseReduction = (Q5V_ROWNR)GetProcAddress(CameraDLL,"RowNoiseReduction");
- if (!Q5V_RowNoiseReduction) {
- FreeLibrary(CameraDLL);
- return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "RowNoiseReduction"));
- }*/
- Q5V_ReadMode = (Q5V_RMODE)GetProcAddress(CameraDLL,"ReadMode");
- if (!Q5V_ReadMode) {
+ /* Q5V_RowNoiseReduction = (Q5V_ROWNR)GetProcAddress(CameraDLL,"RowNoiseReduction");
+ if (!Q5V_RowNoiseReduction) {
+ FreeLibrary(CameraDLL);
+ return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "RowNoiseReduction"));
+ }*/
+ Q5V_ReadMode = (Q5V_RMODE) GetProcAddress(CameraDLL, "ReadMode");
+ if (!Q5V_ReadMode)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "ReadMode"));
}
- Q5V_SetLongExpTime = (Q5V_UL)GetProcAddress(CameraDLL,"setLongExpTime");
- if (!Q5V_SetLongExpTime) {
+ Q5V_SetLongExpTime = (Q5V_UL) GetProcAddress(CameraDLL, "setLongExpTime");
+ if (!Q5V_SetLongExpTime)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "setLongExpTime"));
}
- Q5V_QHY5VInit = (Q5V_V)GetProcAddress(CameraDLL,"QHY5VInit");
- if (!Q5V_QHY5VInit) {
+ Q5V_QHY5VInit = (Q5V_V) GetProcAddress(CameraDLL, "QHY5VInit");
+ if (!Q5V_QHY5VInit)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("astroDLLsspiag.dll does not have %s"), "QHY5VInit"));
}
GenericDLL = LoadLibrary(TEXT("SSPIAGCAM.dll"));
- if (GenericDLL == NULL) {
+ if (GenericDLL == NULL)
+ {
FreeLibrary(CameraDLL);
return CamConnectFailed(_("Cannot load SSPIAGCAM.dll"));
}
- Q5V_SendGuideCommand = (Q5V_GUIDE)GetProcAddress(GenericDLL,"sendGuideCommand");
- if (!Q5V_SendGuideCommand) {
+ Q5V_SendGuideCommand = (Q5V_GUIDE) GetProcAddress(GenericDLL, "sendGuideCommand");
+ if (!Q5V_SendGuideCommand)
+ {
FreeLibrary(GenericDLL);
FreeLibrary(CameraDLL);
return CamConnectFailed(wxString::Format(_("SSPIAGCAM.dll does not have %s"), "sendGuideCommand"));
}
Q5V_SetDevName("SSPIA-0");
- if (!Q5V_OpenQHY5V()) {
+ if (!Q5V_OpenQHY5V())
+ {
FreeLibrary(GenericDLL);
FreeLibrary(CameraDLL);
return CamConnectFailed(_("Failed to open the camera"));
}
if (RawBuffer)
- delete [] RawBuffer;
- RawBuffer = new unsigned char[856*500];
+ delete[] RawBuffer;
+ RawBuffer = new unsigned char[856 * 500];
Q5V_QHY5VInit();
Q5V_GetFullSizeImage(RawBuffer);
wxMilliSleep(100);
Q5V_QHY5VInit();
Q5V_GetFullSizeImage(RawBuffer);
- Q5V_ReadMode(0,0,1,1);
+ Q5V_ReadMode(0, 0, 1, 1);
Q5V_GetFullSizeImage(RawBuffer);
Q5V_BlackOffset(5);
Q5V_GetFullSizeImage(RawBuffer);
@@ -264,8 +286,8 @@ bool CameraSSPIAG::Connect(const wxString& camId)
Q5V_GetFullSizeImage(RawBuffer);
Q5V_RowNoiseReductionMethod(1);
Q5V_GetFullSizeImage(RawBuffer);
-// Q5V_HighGainBoost(255);
-// Q5V_GetFullSizeImage(RawBuffer);
+ // Q5V_HighGainBoost(255);
+ // Q5V_GetFullSizeImage(RawBuffer);
Q5V_AEC_Enable(0);
Q5V_GetFullSizeImage(RawBuffer);
Q5V_AGC_Enable(0);
@@ -281,40 +303,51 @@ bool CameraSSPIAG::Connect(const wxString& camId)
bool CameraSSPIAG::ST4PulseGuideScope(int direction, int duration)
{
-// Vend req 0xb5 (vendTXD)
-// Buffer[0] = GuideCommand, Buffer[1]=PulseTime.
+ // Vend req 0xb5 (vendTXD)
+ // Buffer[0] = GuideCommand, Buffer[1]=PulseTime.
int reg = 0;
int dur = duration / 10;
- if (dur >= 255) dur = 254; // Max guide pulse is 2.54s -- 255 keeps it on always
+ if (dur >= 255)
+ dur = 254; // Max guide pulse is 2.54s -- 255 keeps it on always
// Output pins are NC, Com, RA+(W), Dec+(N), Dec-(S), RA-(E) ?? http://www.starlight-xpress.co.uk/faq.htm
- switch (direction) {
- case WEST: reg = 0x80; break; // 0111 0000
- case NORTH: reg = 0x40; break; // 1011 0000
- case SOUTH: reg = 0x20; break; // 1101 0000
- case EAST: reg = 0x10; break; // 1110 0000
- default: return true; // bad direction passed in
+ switch (direction)
+ {
+ case WEST:
+ reg = 0x80;
+ break; // 0111 0000
+ case NORTH:
+ reg = 0x40;
+ break; // 1011 0000
+ case SOUTH:
+ reg = 0x20;
+ break; // 1101 0000
+ case EAST:
+ reg = 0x10;
+ break; // 1110 0000
+ default:
+ return true; // bad direction passed in
}
- Q5V_SendGuideCommand("QHY5V-0", reg,dur);
+ Q5V_SendGuideCommand("QHY5V-0", reg, dur);
WorkerThread::MilliSleep(duration + 10);
return false;
}
void CameraSSPIAG::ClearGuidePort()
{
- Q5V_SendGuideCommand("QHY5V-0",0,0);
+ Q5V_SendGuideCommand("QHY5V-0", 0, 0);
}
void CameraSSPIAG::InitCapture()
{
- //Q5V_SetQHY5VGlobalGain(GuideCameraGain * 63 / 100);
+ // Q5V_SetQHY5VGlobalGain(GuideCameraGain * 63 / 100);
}
bool CameraSSPIAG::Disconnect()
{
- //closeUSB();
+ // closeUSB();
if (RawBuffer)
- delete [] RawBuffer;
+ delete[] RawBuffer;
RawBuffer = NULL;
FreeLibrary(CameraDLL);
FreeLibrary(GenericDLL);
@@ -324,29 +357,32 @@ bool CameraSSPIAG::Disconnect()
bool CameraSSPIAG::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
-// Only does full frames still
+ // Only does full frames still
static int last_dur = 0;
static int last_gain = 60;
unsigned char *bptr;
unsigned short *dptr;
- int x,y;
+ int x, y;
int xsize = FullSize.GetWidth();
int ysize = FullSize.GetHeight();
-// bool firstimg = true;
+ // bool firstimg = true;
- if (img.Init(FullSize)) {
+ if (img.Init(FullSize))
+ {
DisconnectWithAlert(CAPT_FAIL_MEMORY);
return true;
}
- if (duration != last_dur) {
+ if (duration != last_dur)
+ {
Q5V_SetLongExpTime(duration);
last_dur = duration;
}
- else if (GuideCameraGain != last_gain) {
+ else if (GuideCameraGain != last_gain)
+ {
Q5V_SetQHY5VGlobalGain(GuideCameraGain * 63 / 100);
last_gain = GuideCameraGain;
-// Q5V_GetFullSizeImage(RawBuffer);
+ // Q5V_GetFullSizeImage(RawBuffer);
}
bptr = RawBuffer;
@@ -354,17 +390,21 @@ bool CameraSSPIAG::Capture(int duration, usImage& img, int options, const wxRect
// Load and crop from the 800 x 525 image that came in
dptr = img.ImageData;
- for (y=0; y
+# include
class CameraStarfish : public GuideCamera
{
@@ -54,48 +54,105 @@ class CameraStarfish : public GuideCamera
public:
CameraStarfish();
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- void InitCapture() override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ void InitCapture() override;
- bool ST4PulseGuideScope(int direction, int duration) override;
+ bool ST4PulseGuideScope(int direction, int duration) override;
- bool HasNonGuiCapture() override { return true; }
- bool ST4HasNonGuiMove() override { return true; }
- wxByte BitsPerPixel() override;
+ bool HasNonGuiCapture() override { return true; }
+ bool ST4HasNonGuiMove() override { return true; }
+ wxByte BitsPerPixel() override;
};
-#if defined (__WINDOWS__)
-#define kIOReturnSuccess 0
+# if defined(__WINDOWS__)
+# define kIOReturnSuccess 0
typedef int IOReturn;
using namespace FcCamSpace;
-void fcUsb_init(void) { FcCamFuncs::fcUsb_init(); }
-void fcUsb_close(void) { FcCamFuncs::fcUsb_close(); }
-void fcUsb_CloseCameraDriver(void) { FcCamFuncs::fcUsb_close(); }
-int fcUsb_FindCameras(void) { return FcCamFuncs::fcUsb_FindCameras(); }
-int fcUsb_cmd_setRegister(int camNum, UInt16 regAddress, UInt16 dataValue) { return FcCamFuncs::fcUsb_cmd_setRegister(camNum, regAddress, dataValue); }
-UInt16 fcUsb_cmd_getRegister(int camNum, UInt16 regAddress) { return FcCamFuncs::fcUsb_cmd_getRegister(camNum, regAddress); }
-int fcUsb_cmd_setIntegrationTime(int camNum, UInt32 theTime) { return FcCamFuncs::fcUsb_cmd_setIntegrationTime(camNum, theTime); }
-int fcUsb_cmd_startExposure(int camNum) { return FcCamFuncs::fcUsb_cmd_startExposure(camNum); }
-int fcUsb_cmd_abortExposure(int camNum) { return FcCamFuncs::fcUsb_cmd_abortExposure(camNum); }
-UInt16 fcUsb_cmd_getState(int camNum) { return FcCamFuncs::fcUsb_cmd_getState(camNum); }
-int fcUsb_cmd_setRoi(int camNum, UInt16 left, UInt16 top, UInt16 right, UInt16 bottom) { return FcCamFuncs::fcUsb_cmd_setRoi(camNum,left,top,right,bottom); }
-int fcUsb_cmd_setRelay(int camNum, int whichRelay) { return FcCamFuncs::fcUsb_cmd_setRelay(camNum,whichRelay); }
-int fcUsb_cmd_clearRelay(int camNum, int whichRelay) { return FcCamFuncs::fcUsb_cmd_clearRelay(camNum,whichRelay); }
-int fcUsb_cmd_pulseRelay(int camNum, int whichRelay, int onMs, int offMs, bool repeats) { return FcCamFuncs::fcUsb_cmd_pulseRelay(camNum,whichRelay, onMs, offMs, repeats); }
-int fcUsb_cmd_setTemperature(int camNum, SInt16 theTemp) { return FcCamFuncs::fcUsb_cmd_setTemperature(camNum,theTemp); }
-bool fcUsb_cmd_getTECInPowerOK(int camNum) { return FcCamFuncs::fcUsb_cmd_getTECInPowerOK(camNum); }
-int fcUsb_cmd_getRawFrame(int camNum, UInt16 numRows, UInt16 numCols, UInt16 *frameBuffer) { return FcCamFuncs::fcUsb_cmd_getRawFrame(camNum,numRows,numCols, frameBuffer); }
-int fcUsb_cmd_setReadMode(int camNum, int DataXfrReadMode, int DataFormat) { return FcCamFuncs::fcUsb_cmd_setReadMode(camNum,DataXfrReadMode,DataFormat); }
-bool fcUsb_haveCamera(void) { return FcCamFuncs::fcUsb_haveCamera(); }
-#endif
+void fcUsb_init(void)
+{
+ FcCamFuncs::fcUsb_init();
+}
+void fcUsb_close(void)
+{
+ FcCamFuncs::fcUsb_close();
+}
+void fcUsb_CloseCameraDriver(void)
+{
+ FcCamFuncs::fcUsb_close();
+}
+int fcUsb_FindCameras(void)
+{
+ return FcCamFuncs::fcUsb_FindCameras();
+}
+int fcUsb_cmd_setRegister(int camNum, UInt16 regAddress, UInt16 dataValue)
+{
+ return FcCamFuncs::fcUsb_cmd_setRegister(camNum, regAddress, dataValue);
+}
+UInt16 fcUsb_cmd_getRegister(int camNum, UInt16 regAddress)
+{
+ return FcCamFuncs::fcUsb_cmd_getRegister(camNum, regAddress);
+}
+int fcUsb_cmd_setIntegrationTime(int camNum, UInt32 theTime)
+{
+ return FcCamFuncs::fcUsb_cmd_setIntegrationTime(camNum, theTime);
+}
+int fcUsb_cmd_startExposure(int camNum)
+{
+ return FcCamFuncs::fcUsb_cmd_startExposure(camNum);
+}
+int fcUsb_cmd_abortExposure(int camNum)
+{
+ return FcCamFuncs::fcUsb_cmd_abortExposure(camNum);
+}
+UInt16 fcUsb_cmd_getState(int camNum)
+{
+ return FcCamFuncs::fcUsb_cmd_getState(camNum);
+}
+int fcUsb_cmd_setRoi(int camNum, UInt16 left, UInt16 top, UInt16 right, UInt16 bottom)
+{
+ return FcCamFuncs::fcUsb_cmd_setRoi(camNum, left, top, right, bottom);
+}
+int fcUsb_cmd_setRelay(int camNum, int whichRelay)
+{
+ return FcCamFuncs::fcUsb_cmd_setRelay(camNum, whichRelay);
+}
+int fcUsb_cmd_clearRelay(int camNum, int whichRelay)
+{
+ return FcCamFuncs::fcUsb_cmd_clearRelay(camNum, whichRelay);
+}
+int fcUsb_cmd_pulseRelay(int camNum, int whichRelay, int onMs, int offMs, bool repeats)
+{
+ return FcCamFuncs::fcUsb_cmd_pulseRelay(camNum, whichRelay, onMs, offMs, repeats);
+}
+int fcUsb_cmd_setTemperature(int camNum, SInt16 theTemp)
+{
+ return FcCamFuncs::fcUsb_cmd_setTemperature(camNum, theTemp);
+}
+bool fcUsb_cmd_getTECInPowerOK(int camNum)
+{
+ return FcCamFuncs::fcUsb_cmd_getTECInPowerOK(camNum);
+}
+int fcUsb_cmd_getRawFrame(int camNum, UInt16 numRows, UInt16 numCols, UInt16 *frameBuffer)
+{
+ return FcCamFuncs::fcUsb_cmd_getRawFrame(camNum, numRows, numCols, frameBuffer);
+}
+int fcUsb_cmd_setReadMode(int camNum, int DataXfrReadMode, int DataFormat)
+{
+ return FcCamFuncs::fcUsb_cmd_setReadMode(camNum, DataXfrReadMode, DataFormat);
+}
+bool fcUsb_haveCamera(void)
+{
+ return FcCamFuncs::fcUsb_haveCamera();
+}
+# endif
CameraStarfish::CameraStarfish()
{
Connected = false;
Name = _T("Fishcamp Starfish");
- FullSize = wxSize(1280,1024);
+ FullSize = wxSize(1280, 1024);
HasSubframes = true;
HasGainControl = true;
m_hasGuideOutput = true;
@@ -109,26 +166,29 @@ wxByte CameraStarfish::BitsPerPixel()
bool CameraStarfish::Connect(const wxString& camId)
{
-// returns true on error
+ // returns true on error
wxBeginBusyCursor();
- if (!DriverLoaded) {
- fcUsb_init(); // Init the driver
+ if (!DriverLoaded)
+ {
+ fcUsb_init(); // Init the driver
DriverLoaded = true;
}
NCams = fcUsb_FindCameras();
wxEndBusyCursor();
if (NCams == 0)
return true;
- else {
- CamNum = 1; // Assume just the one cam for now
+ else
+ {
+ CamNum = 1; // Assume just the one cam for now
// set to polling mode and turn off black adjustment but turn on auto balancing of the offsets in the 2x2 matrix
IOReturn rval = fcUsb_cmd_setReadMode(CamNum, fc_classicDataXfr, fc_16b_data);
- if (rval != kIOReturnSuccess) return true;
+ if (rval != kIOReturnSuccess)
+ return true;
if (fcUsb_cmd_getTECInPowerOK(CamNum))
- fcUsb_cmd_setTemperature(CamNum,10);
+ fcUsb_cmd_setTemperature(CamNum, 10);
}
- lastSubFrame = wxRect(wxSize(1, 1)); // To differentiate between full-frame "null" subframe
+ lastSubFrame = wxRect(wxSize(1, 1)); // To differentiate between full-frame "null" subframe
Connected = true;
return false;
}
@@ -145,18 +205,21 @@ void CameraStarfish::InitCapture()
{
// Set gain
unsigned short Gain = (unsigned short) GuideCameraGain;
- if (Gain < 25 ) { // Low noise 1x-4x in .125x mode maps on 0-24
- Gain = 8 + Gain; //103
+ if (Gain < 25)
+ { // Low noise 1x-4x in .125x mode maps on 0-24
+ Gain = 8 + Gain; // 103
}
- else if (Gain < 57) { // 4.25x-8x in .25x steps maps onto 25-56
- Gain = 0x51 + (Gain - 25)/2; // 81-96 aka 0x51-0x60
+ else if (Gain < 57)
+ { // 4.25x-8x in .25x steps maps onto 25-56
+ Gain = 0x51 + (Gain - 25) / 2; // 81-96 aka 0x51-0x60
}
- else { // 9x-15x in 1x steps maps onto 57-95
- Gain = 0x61 + (Gain - 57)/6;
+ else
+ { // 9x-15x in 1x steps maps onto 57-95
+ Gain = 0x61 + (Gain - 57) / 6;
}
- if (Gain > 0x67) Gain = 0x67;
- fcUsb_cmd_setRegister(CamNum,0x35,Gain);
-
+ if (Gain > 0x67)
+ Gain = 0x67;
+ fcUsb_cmd_setRegister(CamNum, 0x35, Gain);
}
static bool StopExposure(int camNum)
@@ -174,7 +237,8 @@ bool CameraStarfish::Capture(int duration, usImage& img, int options, const wxRe
IOReturn rval;
// init memory
- if (img.Init(FullSize)) {
+ if (img.Init(FullSize))
+ {
DisconnectWithAlert(CAPT_FAIL_MEMORY);
return true;
}
@@ -200,17 +264,29 @@ bool CameraStarfish::Capture(int duration, usImage& img, int options, const wxRe
// set ROI if something has changed
if (lastSubFrame != subframe)
{
- rval = fcUsb_cmd_setRoi(CamNum, (unsigned short)xpos, (unsigned short)ypos, (unsigned short)(xpos + xsize - 1), (unsigned short)(ypos + ysize - 1));
- //Debug.AddLine(wxString::Format("Starfish: using %s", usingSubFrames ? " sub-frames" : " full frames"));
- //Debug.AddLine(wxString::Format("Starfish: ROI set from {%d,%d} to {%d,%d)", xpos, ypos, xpos + xsize - 1, ypos + ysize - 1));
- if (rval != kIOReturnSuccess) { if (debug) pFrame->Alert(_T("Starfish Err 1")); return true; }
+ rval = fcUsb_cmd_setRoi(CamNum, (unsigned short) xpos, (unsigned short) ypos, (unsigned short) (xpos + xsize - 1),
+ (unsigned short) (ypos + ysize - 1));
+ // Debug.AddLine(wxString::Format("Starfish: using %s", usingSubFrames ? " sub-frames" : " full frames"));
+ // Debug.AddLine(wxString::Format("Starfish: ROI set from {%d,%d} to {%d,%d)", xpos, ypos, xpos + xsize - 1, ypos +
+ // ysize - 1));
+ if (rval != kIOReturnSuccess)
+ {
+ if (debug)
+ pFrame->Alert(_T("Starfish Err 1"));
+ return true;
+ }
lastSubFrame = subframe;
}
// set duration
fcUsb_cmd_setIntegrationTime(CamNum, (unsigned int) duration);
rval = fcUsb_cmd_startExposure(CamNum);
- if (rval != kIOReturnSuccess) { if (debug) pFrame->Alert(_T("Starfish Err 2")); return true; }
+ if (rval != kIOReturnSuccess)
+ {
+ if (debug)
+ pFrame->Alert(_T("Starfish Err 2"));
+ return true;
+ }
CameraWatchdog watchdog(duration, GetTimeoutMs());
@@ -228,8 +304,7 @@ bool CameraStarfish::Capture(int duration, usImage& img, int options, const wxRe
while (fcUsb_cmd_getState(CamNum) != 0)
{
wxMilliSleep(50);
- if (WorkerThread::InterruptRequested() &&
- (WorkerThread::TerminateRequested() || StopExposure(CamNum)))
+ if (WorkerThread::InterruptRequested() && (WorkerThread::TerminateRequested() || StopExposure(CamNum)))
{
return true;
}
@@ -242,7 +317,7 @@ bool CameraStarfish::Capture(int duration, usImage& img, int options, const wxRe
if (usingSubFrames)
{
- rval = fcUsb_cmd_getRawFrame(CamNum, (unsigned short)ysize, (unsigned short)xsize, subImage.ImageData);
+ rval = fcUsb_cmd_getRawFrame(CamNum, (unsigned short) ysize, (unsigned short) xsize, subImage.ImageData);
// Transfer the subframe to the corresponding location in the full-size frame
for (int y = 0; y < ysize; y++)
{
@@ -254,7 +329,7 @@ bool CameraStarfish::Capture(int duration, usImage& img, int options, const wxRe
}
else
{
- rval = fcUsb_cmd_getRawFrame(CamNum, (unsigned short)ysize, (unsigned short)xsize, img.ImageData);
+ rval = fcUsb_cmd_getRawFrame(CamNum, (unsigned short) ysize, (unsigned short) xsize, img.ImageData);
}
/* if (rval != kIOReturnSuccess) {
@@ -262,15 +337,19 @@ bool CameraStarfish::Capture(int duration, usImage& img, int options, const wxRe
//return true;
}*/
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
return false;
}
-bool CameraStarfish::ST4PulseGuideScope(int direction, int duration) {
+bool CameraStarfish::ST4PulseGuideScope(int direction, int duration)
+{
- if (direction == WEST) direction = EAST; // my ENUM and theirs are flipped
- else if (direction == EAST) direction = WEST;
+ if (direction == WEST)
+ direction = EAST; // my ENUM and theirs are flipped
+ else if (direction == EAST)
+ direction = WEST;
if (fcUsb_cmd_pulseRelay(CamNum, direction, duration, 0, false) != kIOReturnSuccess)
return true;
diff --git a/src/cam_starfish.h b/src/cam_starfish.h
index 6c8900fa2..cbfb011bf 100644
--- a/src/cam_starfish.h
+++ b/src/cam_starfish.h
@@ -40,4 +40,4 @@ class StarfishCameraFactory
static GuideCamera *MakeStarfishCamera();
};
-#endif // CAM_STARFISH_INCLUDED
+#endif // CAM_STARFISH_INCLUDED
diff --git a/src/cam_svb.cpp b/src/cam_svb.cpp
index 019b45b9b..89ae1ca77 100644
--- a/src/cam_svb.cpp
+++ b/src/cam_svb.cpp
@@ -1,46 +1,46 @@
/*
-* cam_svb.cpp
-* PHD2 Guiding
-*
-* Copyright (c) 2020 Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of openphdguiding.org nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * cam_svb.cpp
+ * PHD2 Guiding
+ *
+ * Copyright (c) 2020 Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of openphdguiding.org nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
#ifdef SVB_CAMERA
-#include "cam_svb.h"
-#include "cameras/SVBCameraSDK.h"
+# include "cam_svb.h"
+# include "cameras/SVBCameraSDK.h"
-#ifdef __WINDOWS__
-# include
-# include
-#endif
+# ifdef __WINDOWS__
+# include
+# include
+# endif
enum CaptureMode
{
@@ -55,7 +55,7 @@ class SVBCamera : public GuideCamera
unsigned short m_prevBinning;
void *m_buffer;
size_t m_buffer_size;
- wxByte m_bpp; // bits per pixel: 8 or 16
+ wxByte m_bpp; // bits per pixel: 8 or 16
CaptureMode m_mode;
bool m_capturing;
int m_cameraId;
@@ -90,15 +90,15 @@ class SVBCamera : public GuideCamera
};
SVBCamera::SVBCamera()
- :
- m_buffer(nullptr)
+ : m_buffer(nullptr)
{
Name = _T("Svbony Camera");
PropertyDialogType = PROPDLG_WHEN_DISCONNECTED;
Connected = false;
m_hasGuideOutput = false; // updated when connected
HasSubframes = true;
- HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to true later when the camera is connected
+ HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to
+ // true later when the camera is connected
m_defaultGainPct = GuideCamera::GetDefaultCameraGain();
int value = pConfig->Profile.GetInt("/camera/svb/bpp", 16);
m_bpp = value == 8 ? 8 : 16;
@@ -137,7 +137,7 @@ SVBCameraDlg::SVBCameraDlg()
wxStdDialogButtonSizer *sdbSizer2 = new wxStdDialogButtonSizer();
wxButton *sdbSizer2OK = new wxButton(this, wxID_OK);
- wxButton* sdbSizer2Cancel = new wxButton(this, wxID_CANCEL);
+ wxButton *sdbSizer2Cancel = new wxButton(this, wxID_CANCEL);
sdbSizer2->AddButton(sdbSizer2OK);
sdbSizer2->AddButton(sdbSizer2Cancel);
sdbSizer2->Realize();
@@ -241,7 +241,8 @@ static int FindCamera(const wxString& camId, wxString *err)
SVB_CAMERA_INFO info;
if (SVBGetCameraInfo(&info, i) == SVB_SUCCESS)
{
- Debug.Write(wxString::Format("SVB: cam [%d] id %d %s S/N %s\n", i, info.CameraID, info.FriendlyName, info.CameraSN));
+ Debug.Write(
+ wxString::Format("SVB: cam [%d] id %d %s S/N %s\n", i, info.CameraID, info.FriendlyName, info.CameraSN));
if (info.CameraSN == camId)
{
Debug.Write(wxString::Format("SVB: found matching camera at idx %d, id=%d\n", i, info.CameraID));
@@ -257,7 +258,8 @@ static int FindCamera(const wxString& camId, wxString *err)
inline static int ImgTypeBits(SVB_IMG_TYPE t)
{
- switch (t) {
+ switch (t)
+ {
case SVB_IMG_RAW8:
case SVB_IMG_Y8:
return 8;
@@ -345,14 +347,13 @@ bool SVBCamera::Connect(const wxString& camId)
}
}
- Debug.Write(wxString::Format("SVB: using mode BPP = %u, image type %d\n", (unsigned int)m_bpp, img_type));
+ Debug.Write(wxString::Format("SVB: using mode BPP = %u, image type %d\n", (unsigned int) m_bpp, img_type));
if (img_type == SVB_IMG_END)
{
Disconnect();
return CamConnectFailed(wxString::Format(_("The camera does not support %s mode, try selecting %s mode"),
- m_bpp == 8 ? _("8-bit") : _("16-bit"),
- m_bpp == 8 ? _("16-bit") : _("8-bit")));
+ m_bpp == 8 ? _("8-bit") : _("16-bit"), m_bpp == 8 ? _("16-bit") : _("8-bit")));
}
m_mode = CM_VIDEO;
@@ -471,8 +472,8 @@ bool SVBCamera::Connect(const wxString& camId)
m_minGain = caps.MinValue;
m_maxGain = caps.MaxValue;
m_defaultGainPct = gain_pct(m_minGain, m_maxGain, caps.DefaultValue);
- Debug.Write(wxString::Format("SVB: gain range = %d .. %d default = %ld (%d%%)\n",
- m_minGain, m_maxGain, caps.DefaultValue, m_defaultGainPct));
+ Debug.Write(wxString::Format("SVB: gain range = %d .. %d default = %ld (%d%%)\n", m_minGain, m_maxGain,
+ caps.DefaultValue, m_defaultGainPct));
}
// fall through
@@ -497,7 +498,6 @@ bool SVBCamera::Connect(const wxString& camId)
break;
}
}
-
}
m_frame = wxRect(FullSize);
@@ -505,8 +505,7 @@ bool SVBCamera::Connect(const wxString& camId)
SVBSetOutputImageType(m_cameraId, img_type);
- SVBSetROIFormat(m_cameraId, m_frame.GetLeft(), m_frame.GetTop(),
- m_frame.GetWidth(), m_frame.GetHeight(), Binning);
+ SVBSetROIFormat(m_cameraId, m_frame.GetLeft(), m_frame.GetTop(), m_frame.GetWidth(), m_frame.GetHeight(), Binning);
return false;
}
@@ -569,7 +568,10 @@ inline static int round_up(int v, int m)
static void flush_buffered_image(int cameraId, void *buf, size_t size)
{
- enum { NUM_IMAGE_BUFFERS = 2 }; // camera has 2 internal frame buffers
+ enum
+ {
+ NUM_IMAGE_BUFFERS = 2
+ }; // camera has 2 internal frame buffers
// clear buffered frames if any
@@ -629,8 +631,7 @@ bool SVBCamera::Capture(int duration, usImage& img, int options, const wxRect& s
long cur_exp;
// The returned exposure value may differ from the requested exposure by several usecs,
// so round the returned exposure to the nearest millisecond.
- if (SVBGetControlValue(m_cameraId, SVB_EXPOSURE, &cur_exp, &tmp) == SVB_SUCCESS &&
- (cur_exp + 500) / 1000 != duration)
+ if (SVBGetControlValue(m_cameraId, SVB_EXPOSURE, &cur_exp, &tmp) == SVB_SUCCESS && (cur_exp + 500) / 1000 != duration)
{
Debug.Write(wxString::Format("SVB: set CONTROL_EXPOSURE %d\n", duration * 1000));
SVBSetControlValue(m_cameraId, SVB_EXPOSURE, duration * 1000, SVB_FALSE);
@@ -638,8 +639,7 @@ bool SVBCamera::Capture(int duration, usImage& img, int options, const wxRect& s
long new_gain = cam_gain(m_minGain, m_maxGain, GuideCameraGain);
long cur_gain;
- if (SVBGetControlValue(m_cameraId, SVB_GAIN, &cur_gain, &tmp) == SVB_SUCCESS &&
- new_gain != cur_gain)
+ if (SVBGetControlValue(m_cameraId, SVB_GAIN, &cur_gain, &tmp) == SVB_SUCCESS && new_gain != cur_gain)
{
Debug.Write(wxString::Format("SVB: set CONTROL_GAIN %d%% %d\n", GuideCameraGain, new_gain));
SVBSetControlValue(m_cameraId, SVB_GAIN, new_gain, SVB_FALSE);
@@ -658,18 +658,17 @@ bool SVBCamera::Capture(int duration, usImage& img, int options, const wxRect& s
{
StopCapture();
- SVB_ERROR_CODE status = SVBSetROIFormat(m_cameraId, frame.GetLeft(), frame.GetTop(),
- frame.GetWidth(), frame.GetHeight(), Binning);
+ SVB_ERROR_CODE status =
+ SVBSetROIFormat(m_cameraId, frame.GetLeft(), frame.GetTop(), frame.GetWidth(), frame.GetHeight(), Binning);
if (status != SVB_SUCCESS)
- Debug.Write(wxString::Format("SVB: setImageFormat(%d,%d,%d,%d,%hu) => %d\n",
- frame.GetLeft(), frame.GetTop(), frame.GetWidth(), frame.GetHeight(), Binning, status));
+ Debug.Write(wxString::Format("SVB: setImageFormat(%d,%d,%d,%d,%hu) => %d\n", frame.GetLeft(), frame.GetTop(),
+ frame.GetWidth(), frame.GetHeight(), Binning, status));
}
int poll = wxMin(duration, 100);
- unsigned char *const buffer =
- m_bpp == 16 && !useSubframe ? (unsigned char *) img.ImageData : (unsigned char *) m_buffer;
+ unsigned char *const buffer = m_bpp == 16 && !useSubframe ? (unsigned char *) img.ImageData : (unsigned char *) m_buffer;
if (m_mode == CM_VIDEO)
{
@@ -727,7 +726,10 @@ bool SVBCamera::Capture(int duration, usImage& img, int options, const wxRect& s
SVBSendSoftTrigger(m_cameraId);
- enum { GRACE_PERIOD_MS = 500 }; // recommended by Svbony
+ enum
+ {
+ GRACE_PERIOD_MS = 500
+ }; // recommended by Svbony
CameraWatchdog watchdog(duration, duration + GRACE_PERIOD_MS);
if (duration > 100)
@@ -815,7 +817,7 @@ bool SVBCamera::Capture(int duration, usImage& img, int options, const wxRect& s
if (options & CAPTURE_SUBTRACT_DARK)
SubtractDark(img);
if (m_isColor && Binning == 1 && (options & CAPTURE_RECON))
- QuickLRecon(img);
+ QuickLRecon(img);
return false;
}
diff --git a/src/cam_svb.h b/src/cam_svb.h
index 0f89a22c5..46d16dbcc 100644
--- a/src/cam_svb.h
+++ b/src/cam_svb.h
@@ -1,35 +1,35 @@
/*
-* cam_svb.h
-* PHD2 Guiding
-*
-* Copyright (c) 2020 Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of openphdguiding.org nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * cam_svb.h
+ * PHD2 Guiding
+ *
+ * Copyright (c) 2020 Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of openphdguiding.org nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#ifndef CAM_SVB_INCLUDED
#define CAM_SVB_INCLUDED
diff --git a/src/cam_sxv.cpp b/src/cam_sxv.cpp
index 8e40b8881..c9659014d 100644
--- a/src/cam_sxv.cpp
+++ b/src/cam_sxv.cpp
@@ -35,24 +35,24 @@
#include "phd.h"
-#if defined (SXV)
+#if defined(SXV)
-#include "cam_sxv.h"
-#include "image_math.h"
+# include "cam_sxv.h"
+# include "image_math.h"
-#include
+# include
-#if defined (__WINDOWS__)
-# include "cameras/SXUSB.h"
+# if defined(__WINDOWS__)
+# include "cameras/SXUSB.h"
typedef struct t_sxccd_params sxccd_params_t;
typedef HANDLE sxccd_handle_t;
-# define SXCCD_EXP_FLAGS_NOWIPE_FRAME CCD_EXP_FLAGS_NOWIPE_FRAME
-# define SXCCD_EXP_FLAGS_FIELD_ODD CCD_EXP_FLAGS_FIELD_ODD
-# define SXCCD_EXP_FLAGS_FIELD_BOTH CCD_EXP_FLAGS_FIELD_BOTH
-#else
-# include "cameras/SXMacLib.h"
+# define SXCCD_EXP_FLAGS_NOWIPE_FRAME CCD_EXP_FLAGS_NOWIPE_FRAME
+# define SXCCD_EXP_FLAGS_FIELD_ODD CCD_EXP_FLAGS_FIELD_ODD
+# define SXCCD_EXP_FLAGS_FIELD_BOTH CCD_EXP_FLAGS_FIELD_BOTH
+# else
+# include "cameras/SXMacLib.h"
typedef void *sxccd_handle_t;
-#endif
+# endif
class CameraSXV : public GuideCamera
{
@@ -70,7 +70,6 @@ class CameraSXV : public GuideCamera
double m_devicePixelSize;
public:
-
CameraSXV();
~CameraSXV();
@@ -92,7 +91,8 @@ class CameraSXV : public GuideCamera
void InitFrameSizes();
};
-enum {
+enum
+{
SX_CMOS_GUIDER = 39,
};
@@ -107,53 +107,141 @@ static wxString NameFromModel(int model)
switch (model)
{
- case 0x05: m = "SX-H5"; break;
- case 0x85: m = "SX-H5C"; break;
- case 0x09: m = "SX-H9"; break; // this is almost certainly a Superstar
- case 0x89: m = "SX-H9C"; break;
- case 0x39: m = "SX-LS9"; break;
- case 0x19: m = "SX-SX9"; break;
- case 0x99: m = "SX-SX9C"; break;
- case 0x10: m = "SX-H16"; break;
- case 0x90: m = "SX-H16C"; break;
- case 0x11: m = "SX-H17"; break;
- case 0x91: m = "SX-H17C"; break;
- case 0x12: m = "SX-H18"; break;
- case 0x92: m = "SX-H18C"; break;
- case 0x23: m = "SX-H35"; break;
- case 0xB3: m = "SX-H35C"; break;
- case 0x24: m = "SX-H36"; break;
- case 0xB4: m = "SX-H36C"; break;
- case 0x56: m = "SX-H674"; break;
- case 0xB6: m = "SX-H674C"; break;
- case 0x57: m = "SX-H694"; break;
- case 0xB7: m = "SX-H694C"; break;
- case 0x28: m = "SX-H814"; break;
- case 0xA8: m = "SX-H814C"; break;
- case 0x29: m = "SX-H834"; break;
- case 0xA9: m = "SX-H834C"; break;
- case 0x3B: m = "SX-H825"; break;
- case 0xBB: m = "SX-H825C"; break;
- case 0x3C: m = "SX-US825"; break;
- case 0xBC: m = "SX-US825C"; break;
- // interlaced models
- case 0x45: m = "SX-MX5"; break;
- case 0x84: m = "SX-MX5C"; break;
- case 0x46: m = "SX-LX1"; break;
- case 0x47: m = "SX-MX7"; break;
- case 0xC7: m = "SX-MX7C"; break;
- case 0x48: m = "SX-MX8"; break;
- case 0xC8: m = "SX-MX8C"; break;
- case 0x49: m = "SX-MX9"; break;
- case 0x59: m = "SX-M25"; break;
- case 0x5A: m = "SX-M26"; break;
- // development models
- case 0x0C: m = "SX-DEV1"; break;
- case 0x0D: m = "SX-DEV2"; break;
- case 0x0E: m = "SX-DEV3"; break;
- case 0x0F: m = "SX-DEV4"; break;
-
- default: m = wxString::Format("SX Camera Model %d", model); break;
+ case 0x05:
+ m = "SX-H5";
+ break;
+ case 0x85:
+ m = "SX-H5C";
+ break;
+ case 0x09:
+ m = "SX-H9";
+ break; // this is almost certainly a Superstar
+ case 0x89:
+ m = "SX-H9C";
+ break;
+ case 0x39:
+ m = "SX-LS9";
+ break;
+ case 0x19:
+ m = "SX-SX9";
+ break;
+ case 0x99:
+ m = "SX-SX9C";
+ break;
+ case 0x10:
+ m = "SX-H16";
+ break;
+ case 0x90:
+ m = "SX-H16C";
+ break;
+ case 0x11:
+ m = "SX-H17";
+ break;
+ case 0x91:
+ m = "SX-H17C";
+ break;
+ case 0x12:
+ m = "SX-H18";
+ break;
+ case 0x92:
+ m = "SX-H18C";
+ break;
+ case 0x23:
+ m = "SX-H35";
+ break;
+ case 0xB3:
+ m = "SX-H35C";
+ break;
+ case 0x24:
+ m = "SX-H36";
+ break;
+ case 0xB4:
+ m = "SX-H36C";
+ break;
+ case 0x56:
+ m = "SX-H674";
+ break;
+ case 0xB6:
+ m = "SX-H674C";
+ break;
+ case 0x57:
+ m = "SX-H694";
+ break;
+ case 0xB7:
+ m = "SX-H694C";
+ break;
+ case 0x28:
+ m = "SX-H814";
+ break;
+ case 0xA8:
+ m = "SX-H814C";
+ break;
+ case 0x29:
+ m = "SX-H834";
+ break;
+ case 0xA9:
+ m = "SX-H834C";
+ break;
+ case 0x3B:
+ m = "SX-H825";
+ break;
+ case 0xBB:
+ m = "SX-H825C";
+ break;
+ case 0x3C:
+ m = "SX-US825";
+ break;
+ case 0xBC:
+ m = "SX-US825C";
+ break;
+ // interlaced models
+ case 0x45:
+ m = "SX-MX5";
+ break;
+ case 0x84:
+ m = "SX-MX5C";
+ break;
+ case 0x46:
+ m = "SX-LX1";
+ break;
+ case 0x47:
+ m = "SX-MX7";
+ break;
+ case 0xC7:
+ m = "SX-MX7C";
+ break;
+ case 0x48:
+ m = "SX-MX8";
+ break;
+ case 0xC8:
+ m = "SX-MX8C";
+ break;
+ case 0x49:
+ m = "SX-MX9";
+ break;
+ case 0x59:
+ m = "SX-M25";
+ break;
+ case 0x5A:
+ m = "SX-M26";
+ break;
+ // development models
+ case 0x0C:
+ m = "SX-DEV1";
+ break;
+ case 0x0D:
+ m = "SX-DEV2";
+ break;
+ case 0x0E:
+ m = "SX-DEV3";
+ break;
+ case 0x0F:
+ m = "SX-DEV4";
+ break;
+
+ default:
+ m = wxString::Format("SX Camera Model %d", model);
+ break;
}
if (model == 0x46)
@@ -195,14 +283,15 @@ wxByte CameraSXV::BitsPerPixel()
class SXCameraDlg : public wxDialog
{
public:
- wxCheckBox* m_squarePixels;
+ wxCheckBox *m_squarePixels;
SXCameraDlg(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& title = _("SX Camera Settings"),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(268, 133), long style = wxDEFAULT_DIALOG_STYLE);
~SXCameraDlg() { }
};
-SXCameraDlg::SXCameraDlg(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style)
+SXCameraDlg::SXCameraDlg(
+ wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxDialog(parent, id, title, pos, size, style)
{
SetSizeHints(wxDefaultSize, wxDefaultSize);
@@ -214,9 +303,9 @@ SXCameraDlg::SXCameraDlg(wxWindow *parent, wxWindowID id, const wxString& title,
sbSizer3->Add(m_squarePixels, 0, wxALL, 5);
bSizer12->Add(sbSizer3, 1, wxEXPAND, 5);
- wxStdDialogButtonSizer* sdbSizer2 = new wxStdDialogButtonSizer();
+ wxStdDialogButtonSizer *sdbSizer2 = new wxStdDialogButtonSizer();
wxButton *sdbSizer2OK = new wxButton(this, wxID_OK);
- wxButton* sdbSizer2Cancel = new wxButton(this, wxID_CANCEL);
+ wxButton *sdbSizer2Cancel = new wxButton(this, wxID_CANCEL);
sdbSizer2->AddButton(sdbSizer2OK);
sdbSizer2->AddButton(sdbSizer2Cancel);
sdbSizer2->Realize();
@@ -269,7 +358,7 @@ void CameraSXV::InitFrameSizes()
{
FullSize.SetWidth(CCDParams.width / Binning);
// This is the height after squaring pixels.
- FullSize.SetHeight((int)floor((float)(CCDParams.height / Binning) * CCDParams.pix_height / CCDParams.pix_width));
+ FullSize.SetHeight((int) floor((float) (CCDParams.height / Binning) * CCDParams.pix_height / CCDParams.pix_width));
}
else
{
@@ -282,17 +371,17 @@ void CameraSXV::InitFrameSizes()
m_darkFrameSize = FullSize;
}
- Debug.Write(wxString::Format("SXV: Bin = %hu, dark size = %dx%d, frame size = %dx%d\n",
- Binning, m_darkFrameSize.x, m_darkFrameSize.y, FullSize.x, FullSize.y));
+ Debug.Write(wxString::Format("SXV: Bin = %hu, dark size = %dx%d, frame size = %dx%d\n", Binning, m_darkFrameSize.x,
+ m_darkFrameSize.y, FullSize.x, FullSize.y));
}
bool CameraSXV::Connect(const wxString& camId)
{
// returns true on error
-#if defined (__APPLE__) || defined (__linux__) || defined (__FreeBSD__)
+# if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__)
sxSetTimeoutMS(m_timeoutMs);
-#endif
+# endif
long idx = -1;
if (camId == DEFAULT_CAMERA_ID)
@@ -338,7 +427,7 @@ bool CameraSXV::Connect(const wxString& camId)
Name = NameFromModel(CameraModel);
- if (CameraModel & 0x80) // color
+ if (CameraModel & 0x80) // color
ColorSensor = true;
else
ColorSensor = false;
@@ -396,12 +485,12 @@ bool CameraSXV::Connect(const wxString& camId)
}
Debug.AddLine("SX Camera: " + Name);
- Debug.AddLine(wxString::Format("SX Camera Params: %u x %u (reported as %u x %u) PixSz: %.2f x %.2f; #Pix: %u Array color type: %u,%u Interlaced: %d Model: %u, Subype: %u, Porch: %u,%u %u,%u Extras: %u",
- FullSize.GetWidth(), FullSize.GetHeight(), CCDParams.width, CCDParams.height,
- CCDParams.pix_width, CCDParams.pix_height, FullSize.GetHeight() * FullSize.GetWidth(),
- CCDParams.color_matrix, (int) ColorSensor, (int) Interlaced,
- CameraModel, SubType, CCDParams.hfront_porch, CCDParams.hback_porch, CCDParams.vfront_porch, CCDParams.vback_porch,
- CCDParams.extra_caps));
+ Debug.AddLine(wxString::Format("SX Camera Params: %u x %u (reported as %u x %u) PixSz: %.2f x %.2f; #Pix: %u Array color "
+ "type: %u,%u Interlaced: %d Model: %u, Subype: %u, Porch: %u,%u %u,%u Extras: %u",
+ FullSize.GetWidth(), FullSize.GetHeight(), CCDParams.width, CCDParams.height, CCDParams.pix_width, CCDParams.pix_height,
+ FullSize.GetHeight() * FullSize.GetWidth(), CCDParams.color_matrix, (int) ColorSensor, (int) Interlaced, CameraModel,
+ SubType, CCDParams.hfront_porch, CCDParams.hback_porch, CCDParams.vfront_porch, CCDParams.vback_porch,
+ CCDParams.extra_caps));
if (!err)
Connected = true;
@@ -450,28 +539,35 @@ static bool InitImgCMOSGuider(usImage& img, const wxSize& FullSize, const unsign
{
int oddbias, evenbias;
oddbias = evenbias = 0;
- for (int x = 0; x < 16; x += 2) { // Figure the offsets for this line
- oddbias += (int)*rawptr++;
- evenbias += (int)*rawptr++;
+ for (int x = 0; x < 16; x += 2)
+ { // Figure the offsets for this line
+ oddbias += (int) *rawptr++;
+ evenbias += (int) *rawptr++;
}
- oddbias = oddbias / 8 - 1000; // Create avg and pre-build in the offset to keep off of the floor
+ oddbias = oddbias / 8 - 1000; // Create avg and pre-build in the offset to keep off of the floor
evenbias = evenbias / 8 - 1000;
- for (int x = 0; x < output_xsize; x += 2) { // Load value into new image array pulling out right bias
- int val = (int)*rawptr++ - oddbias;
- if (val < 0) val = 0; // Bounds check
- else if (val > 65535) val = 65535;
- *dataptr++ = (unsigned short)val;
- val = (int)*rawptr++ - evenbias;
- if (val < 0) val = 0; // Bounds check
- else if (val > 65535) val = 65535;
- *dataptr++ = (unsigned short)val;
+ for (int x = 0; x < output_xsize; x += 2)
+ { // Load value into new image array pulling out right bias
+ int val = (int) *rawptr++ - oddbias;
+ if (val < 0)
+ val = 0; // Bounds check
+ else if (val > 65535)
+ val = 65535;
+ *dataptr++ = (unsigned short) val;
+ val = (int) *rawptr++ - evenbias;
+ if (val < 0)
+ val = 0; // Bounds check
+ else if (val > 65535)
+ val = 65535;
+ *dataptr++ = (unsigned short) val;
}
}
return false;
}
-static bool InitImgInterlacedInterp(usImage& img, const wxSize& FullSize, bool subframe, const wxRect& frame, const usImage& tmp)
+static bool InitImgInterlacedInterp(
+ usImage& img, const wxSize& FullSize, bool subframe, const wxRect& frame, const usImage& tmp)
{
if (img.Init(FullSize))
return true;
@@ -528,8 +624,8 @@ static bool InitImgInterlacedSquare(usImage& img, const wxSize& FullSize, bool s
// xsize = number of columns (752)
// ysize = number of rows read from camera (290)
- float const pw = ccdparams.pix_width * binning; // bin1: 8.6, bin2: 17.2
- float const ph = ccdparams.pix_height; // reported value is for the binned pixel (16.6)
+ float const pw = ccdparams.pix_width * binning; // bin1: 8.6, bin2: 17.2
+ float const ph = ccdparams.pix_height; // reported value is for the binned pixel (16.6)
float const r0 = pw / ph;
if (img.Init(FullSize))
@@ -561,7 +657,7 @@ static bool InitImgInterlacedSquare(usImage& img, const wxSize& FullSize, bool s
{
const unsigned short *src = raw + p0 * fullw + xofs;
for (int x = 0; x < framew; x++)
- *dst++ = (unsigned short)(r0 * (float) *src++);
+ *dst++ = (unsigned short) (r0 * (float) *src++);
}
else
{
@@ -570,7 +666,7 @@ static bool InitImgInterlacedSquare(usImage& img, const wxSize& FullSize, bool s
const unsigned short *src0 = raw + p0 * fullw + xofs;
const unsigned short *src1 = raw + p1 * fullw + xofs;
for (int x = 0; x < framew; x++)
- *dst++ = (unsigned short)(r0 * (float)*src0++ + r1 * (float)*src1++);
+ *dst++ = (unsigned short) (r0 * (float) *src0++ + r1 * (float) *src1++);
}
y0 = y1;
@@ -581,8 +677,8 @@ static bool InitImgInterlacedSquare(usImage& img, const wxSize& FullSize, bool s
return false;
}
-static bool InitImgProgressive(usImage& img, unsigned int xofs, unsigned int yofs, unsigned int xsize,
- unsigned int ysize, bool subframe, const wxSize& FullSize, const unsigned short *raw)
+static bool InitImgProgressive(usImage& img, unsigned int xofs, unsigned int yofs, unsigned int xsize, unsigned int ysize,
+ bool subframe, const wxSize& FullSize, const unsigned short *raw)
{
if (img.Init(FullSize))
return true;
@@ -607,7 +703,7 @@ static bool InitImgProgressive(usImage& img, unsigned int xofs, unsigned int yof
return false;
}
-inline static void swap(unsigned short *&a, unsigned short *&b)
+inline static void swap(unsigned short *& a, unsigned short *& b)
{
unsigned short *tmp = a;
a = b;
@@ -625,9 +721,8 @@ static bool ClearPixels(sxccd_handle_t sxHandle, unsigned short flags)
return true;
}
-static bool LatchPixels(sxccd_handle_t sxHandle, unsigned short flags, unsigned short xoffset,
- unsigned short yoffset, unsigned short width, unsigned short height, unsigned short xbin,
- unsigned short ybin)
+static bool LatchPixels(sxccd_handle_t sxHandle, unsigned short flags, unsigned short xoffset, unsigned short yoffset,
+ unsigned short width, unsigned short height, unsigned short xbin, unsigned short ybin)
{
int ret = sxLatchPixels(sxHandle, flags, 0, xoffset, yoffset, width, height, xbin, ybin);
if (ret == 0)
@@ -638,9 +733,8 @@ static bool LatchPixels(sxccd_handle_t sxHandle, unsigned short flags, unsigned
return true;
}
-static bool ExposePixels(sxccd_handle_t sxHandle, unsigned short flags, unsigned short xoffset,
- unsigned short yoffset, unsigned short width, unsigned short height, unsigned short xbin,
- unsigned short ybin, unsigned int msec)
+static bool ExposePixels(sxccd_handle_t sxHandle, unsigned short flags, unsigned short xoffset, unsigned short yoffset,
+ unsigned short width, unsigned short height, unsigned short xbin, unsigned short ybin, unsigned int msec)
{
int ret = sxExposePixels(sxHandle, flags, 0, xoffset, yoffset, width, height, xbin, ybin, msec);
if (ret == 0)
@@ -677,7 +771,7 @@ bool CameraSXV::Capture(int duration, usImage& img, int options, const wxRect& s
if (HasShutter && ShutterClosed)
{
- sxSetShutter(hCam, 1); // Close the shutter if needed
+ sxSetShutter(hCam, 1); // Close the shutter if needed
wxMilliSleep(200);
}
@@ -721,7 +815,8 @@ bool CameraSXV::Capture(int duration, usImage& img, int options, const wxRect& s
{
if (SquarePixels)
{
- // incoming subframe coordinates are in squared pixel coordinate system, convert to camera pixel coordinates
+ // incoming subframe coordinates are in squared pixel coordinate system, convert to camera pixel
+ // coordinates
float r = CCDParams.pix_width * (float) xbin / CCDParams.pix_height;
unsigned int y0 = (unsigned int) floor(subframe.GetTop() * r);
unsigned int y1 = (unsigned int) floor(subframe.GetBottom() * r);
@@ -734,7 +829,7 @@ bool CameraSXV::Capture(int duration, usImage& img, int options, const wxRect& s
{
unsigned int y0 = (unsigned int) subframe.GetTop() / 2;
// interpolation may require the next row
- unsigned int y1 = (unsigned int)(subframe.GetBottom() + 1) / 2;
+ unsigned int y1 = (unsigned int) (subframe.GetBottom() + 1) / 2;
if (y1 >= CCDParams.height)
y1 = CCDParams.height - 1;
yofs = y0;
@@ -817,7 +912,7 @@ bool CameraSXV::Capture(int duration, usImage& img, int options, const wxRect& s
// if (WorkerThread::InterruptRequested())
// return true;
- if (!ReadPixels(hCam, RawData, nPixelsToRead)) // stop exposure and read but only the one frame
+ if (!ReadPixels(hCam, RawData, nPixelsToRead)) // stop exposure and read but only the one frame
{
DisconnectWithAlert(_("Lost connection to camera"), RECONNECT);
return true;
@@ -825,7 +920,7 @@ bool CameraSXV::Capture(int duration, usImage& img, int options, const wxRect& s
if (HasShutter && ShutterClosed)
{
- sxSetShutter(hCam, 0); // Open it back up
+ sxSetShutter(hCam, 0); // Open it back up
wxMilliSleep(200);
}
@@ -838,7 +933,8 @@ bool CameraSXV::Capture(int duration, usImage& img, int options, const wxRect& s
if (IsCMOSGuider(CameraModel))
error = InitImgCMOSGuider(img, FullSize, RawData);
else
- error = InitImgProgressive(img, xofs / xbin, yofs / ybin, xsize / xbin, ysize / ybin, takeSubframe, FullSize, RawData);
+ error =
+ InitImgProgressive(img, xofs / xbin, yofs / ybin, xsize / xbin, ysize / ybin, takeSubframe, FullSize, RawData);
if (error)
{
@@ -918,24 +1014,25 @@ bool CameraSXV::ST4PulseGuideScope(int direction, int duration)
// North = 2
// South = 4
unsigned char dircmd = 0;
- switch (direction) {
- case WEST:
- dircmd = (unsigned char) 1;
- break;
- case EAST:
- dircmd = (unsigned char) 8;
- break;
- case NORTH:
- dircmd = (unsigned char) 2;
- break;
- case SOUTH:
- dircmd = (unsigned char) 4;
- break;
- }
- sxSetSTAR2000(hCam,dircmd);
+ switch (direction)
+ {
+ case WEST:
+ dircmd = (unsigned char) 1;
+ break;
+ case EAST:
+ dircmd = (unsigned char) 8;
+ break;
+ case NORTH:
+ dircmd = (unsigned char) 2;
+ break;
+ case SOUTH:
+ dircmd = (unsigned char) 4;
+ break;
+ }
+ sxSetSTAR2000(hCam, dircmd);
WorkerThread::MilliSleep(duration);
dircmd = 0;
- sxSetSTAR2000(hCam,dircmd);
+ sxSetSTAR2000(hCam, dircmd);
return false;
}
diff --git a/src/cam_touptek.cpp b/src/cam_touptek.cpp
index a5a746791..5d9e459ef 100644
--- a/src/cam_touptek.cpp
+++ b/src/cam_touptek.cpp
@@ -36,22 +36,22 @@
#if defined(TOUPTEK_CAMERA)
-#include "cam_touptek.h"
-#include "cameras/toupcam.h"
-#include "image_math.h"
+# include "cam_touptek.h"
+# include "cameras/toupcam.h"
+# include "image_math.h"
// Touptek API uses these Windows definitions even on non-Windows platforms
-#ifndef S_OK
-#define S_OK ((HRESULT)0L)
-#define S_FALSE ((HRESULT)1L)
-#endif
+# ifndef S_OK
+# define S_OK ((HRESULT) 0L)
+# define S_FALSE ((HRESULT) 1L)
+# endif
struct ToupCam
{
HToupCam m_h;
void *m_buffer;
void *m_tmpbuf;
- wxByte m_bpp; // bits per pixel: 8 or 16
+ wxByte m_bpp; // bits per pixel: 8 or 16
bool m_isColor;
bool m_hasGuideOutput;
double m_devicePixelSize;
@@ -66,13 +66,14 @@ struct ToupCam
wxMutex m_lock;
wxCondition m_cond;
- ToupCam() :
- m_h(nullptr),
- m_buffer(nullptr),
- m_tmpbuf(nullptr),
- m_started(false),
- m_cond(m_lock)
- { }
+ ToupCam()
+ : m_h(nullptr)
+ , m_buffer(nullptr)
+ , m_tmpbuf(nullptr)
+ , m_started(false)
+ , m_cond(m_lock)
+ {
+ }
~ToupCam()
{
@@ -80,21 +81,15 @@ struct ToupCam
::free(m_tmpbuf);
}
- int gain_pct(int val) const
- {
- return (val - m_minGain) * 100 / (m_maxGain - m_minGain);
- }
+ int gain_pct(int val) const { return (val - m_minGain) * 100 / (m_maxGain - m_minGain); }
- int cam_gain(int pct) const
- {
- return m_minGain + pct * (m_maxGain - m_minGain) / 100;
- }
+ int cam_gain(int pct) const { return m_minGain + pct * (m_maxGain - m_minGain) / 100; }
void StopCapture()
{
if (m_started)
{
- //Debug.Write("TOUPTEK: stopcapture\n");
+ // Debug.Write("TOUPTEK: stopcapture\n");
HRESULT hr;
if (FAILED(hr = Toupcam_Stop(m_h)))
Debug.Write(wxString::Format("TOUPTEK: Toupcam_Stop failed with status 0x%x\n", hr));
@@ -114,7 +109,7 @@ struct ToupCam
case TOUPCAM_EVENT_NOFRAMETIMEOUT:
case TOUPCAM_EVENT_NOPACKETTIMEOUT:
case TOUPCAM_EVENT_TRIGGERFAIL:
- //Debug.Write(wxString::Format("TOUPTEK: cam event 0x%x\n", event));
+ // Debug.Write(wxString::Format("TOUPTEK: cam event 0x%x\n", event));
{
wxMutexLocker lck(cam->m_lock);
cam->m_captureResult = event;
@@ -132,7 +127,7 @@ struct ToupCam
if (m_started)
return;
- //Debug.Write("TOUPTEK: startcapture\n");
+ // Debug.Write("TOUPTEK: startcapture\n");
HRESULT hr;
if (FAILED(hr = Toupcam_StartPullModeWithCallback(m_h, &CamEventCb, this)))
@@ -209,15 +204,9 @@ struct ToupCam
}
}
- bool SoftwareBinning() const
- {
- return m_isColor;
- }
+ bool SoftwareBinning() const { return m_isColor; }
- bool SetHwBinning(unsigned int binning)
- {
- return SetOption(TOUPCAM_OPTION_BINNING, ToupcamBinning(binning));
- }
+ bool SetHwBinning(unsigned int binning) { return SetOption(TOUPCAM_OPTION_BINNING, ToupcamBinning(binning)); }
bool SetBinning(unsigned int binning)
{
@@ -262,7 +251,6 @@ class CameraToupTek : public GuideCamera
ToupCam m_cam;
public:
-
CameraToupTek();
~CameraToupTek();
@@ -294,16 +282,15 @@ CameraToupTek::CameraToupTek()
Connected = false;
m_cam.m_hasGuideOutput = true;
HasSubframes = true;
- HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to true later when the camera is connected
+ HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to
+ // true later when the camera is connected
m_cam.m_defaultGainPct = GuideCamera::GetDefaultCameraGain();
int value = pConfig->Profile.GetInt("/camera/ToupTek/bpp", 8);
m_cam.m_bpp = value == 8 ? 8 : 16;
MaxBinning = 4;
}
-CameraToupTek::~CameraToupTek()
-{
-}
+CameraToupTek::~CameraToupTek() { }
bool CameraToupTek::EnumCameras(wxArrayString& names, wxArrayString& ids)
{
@@ -377,8 +364,8 @@ bool CameraToupTek::Connect(const wxString& camIdArg)
HasCooler = (info->model->flag & TOUPCAM_FLAG_TEC) != 0;
m_cam.m_hasGuideOutput = (info->model->flag & TOUPCAM_FLAG_ST4) != 0;
- Debug.Write(wxString::Format("TOUPTEK: isColor = %d, hasCooler = %d, hasST4 = %d\n",
- m_cam.m_isColor, HasCooler, m_cam.m_hasGuideOutput));
+ Debug.Write(wxString::Format(
+ "TOUPTEK: isColor = %d, hasCooler = %d, hasST4 = %d\n", m_cam.m_isColor, HasCooler, m_cam.m_hasGuideOutput));
if (FAILED(Toupcam_get_Resolution(m_cam.m_h, 0, &m_cam.m_maxSize.x, &m_cam.m_maxSize.y)))
{
@@ -445,7 +432,8 @@ bool CameraToupTek::Connect(const wxString& camIdArg)
m_cam.m_maxGain = maxGain;
HasGainControl = maxGain > minGain;
m_cam.m_defaultGainPct = m_cam.gain_pct(defaultGain);
- Debug.Write(wxString::Format("TOUPTEK: gain range %d .. %d, default = %d (%d%%)\n", minGain, maxGain, defaultGain, m_cam.m_defaultGainPct));
+ Debug.Write(wxString::Format(
+ "TOUPTEK: gain range %d .. %d, default = %d (%d%%)\n", minGain, maxGain, defaultGain, m_cam.m_defaultGainPct));
}
else
{
@@ -470,14 +458,14 @@ bool CameraToupTek::Connect(const wxString& camIdArg)
m_cam.SetOption(TOUPCAM_OPTION_RAW, 1);
m_cam.SetOption(TOUPCAM_OPTION_BITDEPTH, m_cam.m_bpp == 8 ? 0 : 1);
m_cam.SetOption(TOUPCAM_OPTION_LINEAR, 0);
- //m_cam.SetOption(TOUPCAM_OPTION_CURVE, 0); // resetting this one fails on all the cameras I have
+ // m_cam.SetOption(TOUPCAM_OPTION_CURVE, 0); // resetting this one fails on all the cameras I have
m_cam.SetOption(TOUPCAM_OPTION_COLORMATIX, 0);
m_cam.SetOption(TOUPCAM_OPTION_WBGAIN, 0);
- m_cam.SetOption(TOUPCAM_OPTION_TRIGGER, 1); // software trigger
+ m_cam.SetOption(TOUPCAM_OPTION_TRIGGER, 1); // software trigger
m_cam.SetOption(TOUPCAM_OPTION_AUTOEXP_POLICY, 0); // 0="Exposure Only" 1="Exposure Preferred"
m_cam.SetOption(TOUPCAM_OPTION_ROTATE, 0);
m_cam.SetOption(TOUPCAM_OPTION_UPSIDE_DOWN, 0);
- //m_cam.SetOption(TOUPCAM_OPTION_CG, 0); // "Conversion Gain" 0=LCG 1=HCG 2=HDR // setting this fails
+ // m_cam.SetOption(TOUPCAM_OPTION_CG, 0); // "Conversion Gain" 0=LCG 1=HCG 2=HDR // setting this fails
m_cam.SetOption(TOUPCAM_OPTION_FFC, 0);
m_cam.SetOption(TOUPCAM_OPTION_DFC, 0);
m_cam.SetOption(TOUPCAM_OPTION_SHARPENING, 0);
@@ -502,12 +490,8 @@ bool CameraToupTek::Connect(const wxString& camIdArg)
unsigned int fourcc, bpp;
if (SUCCEEDED(hr = Toupcam_get_RawFormat(m_cam.m_h, &fourcc, &bpp)))
{
- Debug.Write(wxString::Format("TOUPTEK: raw format = %c%c%c%c bit depth = %u\n",
- fourcc & 0xff,
- (fourcc >> 8) & 0xff,
- (fourcc >> 16) & 0xff,
- fourcc >> 24,
- bpp));
+ Debug.Write(wxString::Format("TOUPTEK: raw format = %c%c%c%c bit depth = %u\n", fourcc & 0xff, (fourcc >> 8) & 0xff,
+ (fourcc >> 16) & 0xff, fourcc >> 24, bpp));
}
else
Debug.Write(wxString::Format("TOUPTEK: Toupcam_get_RawFormat failed with status 0x%x\n", hr));
@@ -561,7 +545,7 @@ bool CameraToupTek::Capture(int duration, usImage& img, int options, const wxRec
unsigned int const binning = m_cam.m_curBin;
- wxRect roi; // un-binned coordinates
+ wxRect roi; // un-binned coordinates
if (useSubframe)
{
@@ -606,7 +590,7 @@ bool CameraToupTek::Capture(int duration, usImage& img, int options, const wxRec
m_cam.StartCapture();
- //Debug.Write("TOUPTEK: capture: trigger\n");
+ // Debug.Write("TOUPTEK: capture: trigger\n");
if (FAILED(hr = Toupcam_Trigger(m_cam.m_h, 1)))
Debug.Write(wxString::Format("TOUPTEK: Toupcam_Trigger(1) failed with status 0x%x\n", hr));
@@ -659,7 +643,7 @@ bool CameraToupTek::Capture(int duration, usImage& img, int options, const wxRec
return true;
}
- //Debug.Write("TOUPTEK: capture: image ready\n");
+ // Debug.Write("TOUPTEK: capture: image ready\n");
void *buf;
wxSize sz;
@@ -725,7 +709,7 @@ bool CameraToupTek::Capture(int duration, usImage& img, int options, const wxRec
}
}
- //Debug.Write("TOUPTEK: capture: pull done\n");
+ // Debug.Write("TOUPTEK: capture: pull done\n");
if (options & CAPTURE_SUBTRACT_DARK)
SubtractDark(img);
@@ -750,10 +734,14 @@ inline static int GetToupcamDirection(int direction)
switch (direction)
{
default:
- case NORTH: return 0;
- case EAST: return 2;
- case WEST: return 3;
- case SOUTH: return 1;
+ case NORTH:
+ return 0;
+ case EAST:
+ return 2;
+ case WEST:
+ return 3;
+ case SOUTH:
+ return 1;
}
}
@@ -812,7 +800,7 @@ ToupTekCameraDlg::ToupTekCameraDlg()
wxStdDialogButtonSizer *sdbSizer2 = new wxStdDialogButtonSizer();
wxButton *sdbSizer2OK = new wxButton(this, wxID_OK);
- wxButton* sdbSizer2Cancel = new wxButton(this, wxID_CANCEL);
+ wxButton *sdbSizer2Cancel = new wxButton(this, wxID_CANCEL);
sdbSizer2->AddButton(sdbSizer2OK);
sdbSizer2->AddButton(sdbSizer2Cancel);
sdbSizer2->Realize();
@@ -868,7 +856,7 @@ bool CameraToupTek::SetCoolerOn(bool on)
bool CameraToupTek::SetCoolerSetpoint(double temperature)
{
- int val = (int)(temperature * 10.);
+ int val = (int) (temperature * 10.);
val = wxMax(val, TOUPCAM_TEC_TARGET_MIN);
val = wxMin(val, TOUPCAM_TEC_TARGET_MAX);
@@ -890,8 +878,7 @@ bool CameraToupTek::GetCoolerStatus(bool *on, double *setpoint, double *power, d
else
err = true;
- if (m_cam.GetOption(TOUPCAM_OPTION_TEC_VOLTAGE, &vcur) &&
- m_cam.GetOption(TOUPCAM_OPTION_TEC_VOLTAGE_MAX, &vmax) &&
+ if (m_cam.GetOption(TOUPCAM_OPTION_TEC_VOLTAGE, &vcur) && m_cam.GetOption(TOUPCAM_OPTION_TEC_VOLTAGE_MAX, &vmax) &&
vmax > 0)
{
*power = vcur * 100.0 / vmax;
diff --git a/src/cam_vfw.cpp b/src/cam_vfw.cpp
index f7eb5cedc..c29a124b7 100644
--- a/src/cam_vfw.cpp
+++ b/src/cam_vfw.cpp
@@ -36,19 +36,20 @@
#ifdef VFW_CAMERA
-#include "camera.h"
-#include "time.h"
-#include "image_math.h"
-#include
-//#include "vcapwin.h"
-#include "cam_vfw.h"
+# include "camera.h"
+# include "time.h"
+# include "image_math.h"
+# include
+// #include "vcapwin.h"
+# include "cam_vfw.h"
CameraVFW::CameraVFW()
{
Connected = false;
Name = _T("Windows VFW");
- FullSize = wxSize(640,480); // should be overwritten
- VFW_Window = NULL; Extra_Window=NULL;
+ FullSize = wxSize(640, 480); // should be overwritten
+ VFW_Window = NULL;
+ Extra_Window = NULL;
PropertyDialogType = PROPDLG_WHEN_CONNECTED;
HasDelayParam = false;
HasPortNum = false;
@@ -61,66 +62,76 @@ wxByte CameraVFW::BitsPerPixel()
bool CameraVFW::Connect(const wxString& camId)
{
-// returns true on error
-// bool retval;
+ // returns true on error
+ // bool retval;
int ndevices, i, devicenum;
wxSplitterWindow *dispwin;
- wxVideoCaptureWindow* capwin;
+ wxVideoCaptureWindow *capwin;
- if (!Extra_Window) {
- dispwin = new wxSplitterWindow(pFrame->guider,-1);
+ if (!Extra_Window)
+ {
+ dispwin = new wxSplitterWindow(pFrame->guider, -1);
Extra_Window = dispwin;
}
- else dispwin = Extra_Window;
+ else
+ dispwin = Extra_Window;
- if (!VFW_Window) {
- capwin = new wxVideoCaptureWindow(dispwin,WIN_VFW,wxPoint(0,0),wxSize(640,480));
+ if (!VFW_Window)
+ {
+ capwin = new wxVideoCaptureWindow(dispwin, WIN_VFW, wxPoint(0, 0), wxSize(640, 480));
VFW_Window = capwin;
}
- else capwin = VFW_Window;
+ else
+ capwin = VFW_Window;
dispwin->Show(false);
- //capwin->Create(frame);
+ // capwin->Create(frame);
ndevices = capwin->GetDeviceCount();
- if (ndevices == 0) return true;
+ if (ndevices == 0)
+ return true;
devicenum = 1;
- if (ndevices > 1) { // multiple found -- get one from user
+ if (ndevices > 1)
+ { // multiple found -- get one from user
wxArrayString devnames;
- for (i=0; iGetDeviceName(i));
- devicenum = wxGetSingleChoiceIndex(_("Select capture device"),_("Camera choice"),devnames);
+ devicenum = wxGetSingleChoiceIndex(_("Select capture device"), _("Camera choice"), devnames);
if (devicenum == -1)
return true;
- else devicenum = devicenum + 1;
+ else
+ devicenum = devicenum + 1;
}
- if (capwin->DeviceConnect(devicenum-1) == false) // try to connect
+ if (capwin->DeviceConnect(devicenum - 1) == false) // try to connect
return true;
- if (VFW_Window->HasVideoFormatDialog()) {
+ if (VFW_Window->HasVideoFormatDialog())
+ {
VFW_Window->VideoFormatDialog();
-// int w,h,bpp;
-// FOURCC fourcc;
-// VFW_Window->GetVideoFormat( &w,&h, &bpp, &fourcc );
-// FullSize = wxSize(w,h);
+ // int w,h,bpp;
+ // FOURCC fourcc;
+ // VFW_Window->GetVideoFormat( &w,&h, &bpp, &fourcc );
+ // FullSize = wxSize(w,h);
}
- int w,h,bpp;
+ int w, h, bpp;
FOURCC fourcc;
- capwin->GetVideoFormat( &w,&h, &bpp, &fourcc );
-// capwin->SetVideoFormat(640,480,-1,-1);
- FullSize=wxSize(w,h);
- pFrame->StatusMsg(wxString::Format("%d x %d mode activated",w,h));
+ capwin->GetVideoFormat(&w, &h, &bpp, &fourcc);
+ // capwin->SetVideoFormat(640,480,-1,-1);
+ FullSize = wxSize(w, h);
+ pFrame->StatusMsg(wxString::Format("%d x %d mode activated", w, h));
Connected = true;
return false;
}
-bool CameraVFW::Disconnect() {
- if (VFW_Window->IsDeviceConnected()) {
+bool CameraVFW::Disconnect()
+{
+ if (VFW_Window->IsDeviceConnected())
+ {
VFW_Window->DeviceDisconnect();
}
Connected = false;
VFW_Window = NULL;
-// Extra_Window = NULL;
+ // Extra_Window = NULL;
return false;
}
@@ -137,45 +148,50 @@ bool CameraVFW::Capture(int duration, usImage& img, int options, const wxRect& s
wxStopWatch swatch;
- //gNumFrames = 0;
- if (img.Init(FullSize)) {
+ // gNumFrames = 0;
+ if (img.Init(FullSize))
+ {
DisconnectWithAlert(CAPT_FAIL_MEMORY);
return true;
}
img.Clear();
- swatch.Start(); //wxStartTimer();
- while (still_going) {
+ swatch.Start(); // wxStartTimer();
+ while (still_going)
+ {
VFW_Window->SnapshotTowxImage();
cap_img = VFW_Window->GetwxImage();
imgdata = cap_img.GetData();
dptr = img.ImageData;
- for (unsigned int i = 0; i < img.NPixels; i++, dptr++, imgdata += 3) {
- *dptr = *dptr + (unsigned short) (*imgdata + *(imgdata+1) + *(imgdata+2));
+ for (unsigned int i = 0; i < img.NPixels; i++, dptr++, imgdata += 3)
+ {
+ *dptr = *dptr + (unsigned short) (*imgdata + *(imgdata + 1) + *(imgdata + 2));
}
NFrames++;
if ((swatch.Time() >= duration) && (NFrames > 2))
still_going = false;
}
- pFrame->StatusMsg(wxString::Format("%d frames",NFrames));
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ pFrame->StatusMsg(wxString::Format("%d frames", NFrames));
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
return false;
}
-void CameraVFW::ShowPropertyDialog() {
-// if (event.GetId() == ADV_BUTTON1) {
-/* if (VFW_Window->HasVideoFormatDialog()) {
- VFW_Window->VideoFormatDialog();
- int w,h,bpp;
- FOURCC fourcc;
- VFW_Window->GetVideoFormat( &w,&h, &bpp, &fourcc );
- FullSize = wxSize(w,h);
- }*/
-// else {
- if (VFW_Window->HasVideoSourceDialog()) VFW_Window->VideoSourceDialog();
-// }
-
+void CameraVFW::ShowPropertyDialog()
+{
+ // if (event.GetId() == ADV_BUTTON1) {
+ /* if (VFW_Window->HasVideoFormatDialog()) {
+ VFW_Window->VideoFormatDialog();
+ int w,h,bpp;
+ FOURCC fourcc;
+ VFW_Window->GetVideoFormat( &w,&h, &bpp, &fourcc );
+ FullSize = wxSize(w,h);
+ }*/
+ // else {
+ if (VFW_Window->HasVideoSourceDialog())
+ VFW_Window->VideoSourceDialog();
+ // }
}
#endif
diff --git a/src/cam_vfw.h b/src/cam_vfw.h
index 92811efcd..703ef788c 100644
--- a/src/cam_vfw.h
+++ b/src/cam_vfw.h
@@ -40,15 +40,15 @@
class CameraVFW : public GuideCamera
{
wxVideoCaptureWindow *VFW_Window;
- wxSplitterWindow *Extra_Window;
+ wxSplitterWindow *Extra_Window;
public:
CameraVFW();
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- void ShowPropertyDialog() override;
- wxByte BitsPerPixel() override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ void ShowPropertyDialog() override;
+ wxByte BitsPerPixel() override;
};
#endif
diff --git a/src/cam_wdm.cpp b/src/cam_wdm.cpp
index 42ba42658..0087a6a96 100644
--- a/src/cam_wdm.cpp
+++ b/src/cam_wdm.cpp
@@ -39,16 +39,16 @@
#ifdef WDM_CAMERA
-#include "cam_wdm_base.h"
-#include "cam_wdm.h"
-#include "CVPlatform.h"
+# include "cam_wdm_base.h"
+# include "cam_wdm.h"
+# include "CVPlatform.h"
CameraWDM::CameraWDM()
{
Connected = false;
- Name = _T("Windows Camera"); // should get overwritten on connect
- FullSize = wxSize(640, 480); // should get overwritten on connect
- m_deviceNumber = -1; // Which WDM device connected
+ Name = _T("Windows Camera"); // should get overwritten on connect
+ FullSize = wxSize(640, 480); // should get overwritten on connect
+ m_deviceNumber = -1; // Which WDM device connected
m_deviceMode = -1;
PropertyDialogType = PROPDLG_WHEN_CONNECTED;
HasDelayParam = false;
@@ -174,7 +174,7 @@ bool CameraWDM::SelectDeviceAndMode(SelectionContext ctx)
// Init the library
if (CVFAILED(vidCap->Init()))
{
- wxMessageBox(_T("Error initializing WDM services"),_("Error"), wxOK | wxICON_ERROR);
+ wxMessageBox(_T("Error initializing WDM services"), _("Error"), wxOK | wxICON_ERROR);
throw ERROR_INFO("CVFAILED(VidCap->Init())");
}
inited = true;
@@ -300,7 +300,7 @@ bool CameraWDM::Connect(const wxString& camId)
// Init the library
if (CVFAILED(m_pVidCap->Init()))
{
- wxMessageBox(_T("Error initializing WDM services"), _("Error"),wxOK | wxICON_ERROR);
+ wxMessageBox(_T("Error initializing WDM services"), _("Error"), wxOK | wxICON_ERROR);
throw ERROR_INFO("CVFAILED(VidCap->Init())");
}
@@ -323,7 +323,8 @@ bool CameraWDM::Connect(const wxString& camId)
}
else
{
- wxMessageBox(wxString::Format("Error connecting to WDM device #%d", m_deviceNumber), _("Error"), wxOK | wxICON_ERROR);
+ wxMessageBox(
+ wxString::Format("Error connecting to WDM device #%d", m_deviceNumber), _("Error"), wxOK | wxICON_ERROR);
throw ERROR_INFO("Error connecting to WDM device");
}
@@ -337,15 +338,13 @@ bool CameraWDM::Connect(const wxString& camId)
CVVidCapture::VIDCAP_MODE modeInfo;
if (CVFAILED(m_pVidCap->GetCurrentMode(modeInfo)))
{
- wxMessageBox(wxString::Format("Error probing video mode %d", m_deviceMode),_("Error"),wxOK | wxICON_ERROR);
+ wxMessageBox(wxString::Format("Error probing video mode %d", m_deviceMode), _("Error"), wxOK | wxICON_ERROR);
throw ERROR_INFO("GetCurrentMode() failed");
}
// RAW YUY2 format encodes two 8-bit greyscale pixels per pseudo-YUY2 value
// so the width is twice the video mode's advertised width
- FullSize = m_rawYUY2 ?
- wxSize(modeInfo.XRes * 2, modeInfo.YRes) :
- wxSize(modeInfo.XRes, modeInfo.YRes);
+ FullSize = m_rawYUY2 ? wxSize(modeInfo.XRes * 2, modeInfo.YRes) : wxSize(modeInfo.XRes, modeInfo.YRes);
// Start the stream
m_captureMode = NOT_CAPTURING; // Make sure we don't start saving yet
diff --git a/src/cam_wdm_base.h b/src/cam_wdm_base.h
index 7fd03dffb..476dcd904 100644
--- a/src/cam_wdm_base.h
+++ b/src/cam_wdm_base.h
@@ -64,8 +64,7 @@ class CameraWDM : public GuideCamera
volatile int m_nFrames;
volatile int m_nAttempts;
usImage *m_stack;
- volatile enum E_CAPTURE_MODE
- {
+ volatile enum E_CAPTURE_MODE {
NOT_CAPTURING = 0,
STOP_CAPTURING,
CAPTURE_ONE_FRAME,
@@ -95,8 +94,9 @@ class CameraWDM : public GuideCamera
bool OnCapture(const cbdata& p);
protected:
- enum SelectionContext {
- CTX_SELECT, // selecting device and mode in response to camera selection button
+ enum SelectionContext
+ {
+ CTX_SELECT, // selecting device and mode in response to camera selection button
CTX_CONNECT, // selecting device and mode in response to camera connect button
};
virtual bool SelectDeviceAndMode(SelectionContext ctx);
@@ -122,7 +122,6 @@ class CameraLEWebcam : public CameraWDM
};
public:
-
CameraLEWebcam();
~CameraLEWebcam();
diff --git a/src/cam_zwo.cpp b/src/cam_zwo.cpp
index be2eb0af1..5bc76b4f7 100644
--- a/src/cam_zwo.cpp
+++ b/src/cam_zwo.cpp
@@ -1,54 +1,54 @@
/*
-* cam_zwo.cpp
-* PHD Guiding
-*
-* Created by Robin Glover.
-* Copyright (c) 2014 Robin Glover.
-* Copyright (c) 2017-2018 Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * cam_zwo.cpp
+ * PHD Guiding
+ *
+ * Created by Robin Glover.
+ * Copyright (c) 2014 Robin Glover.
+ * Copyright (c) 2017-2018 Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
#ifdef ZWO_ASI
-#include "cam_zwo.h"
-#include "cameras/ASICamera2.h"
+# include "cam_zwo.h"
+# include "cameras/ASICamera2.h"
-#ifdef __WINDOWS__
+# ifdef __WINDOWS__
-#ifdef OS_WINDOWS
+# ifdef OS_WINDOWS
// troubleshooting with the libusb definitions
-# undef OS_WINDOWS
-#endif
+# undef OS_WINDOWS
+# endif
-# include
-# include
-#endif
+# include
+# include
+# endif
enum CaptureMode
{
@@ -63,7 +63,7 @@ class Camera_ZWO : public GuideCamera
unsigned short m_prevBinning;
void *m_buffer;
size_t m_buffer_size;
- wxByte m_bpp; // bits per pixel: 8 or 16
+ wxByte m_bpp; // bits per pixel: 8 or 16
CaptureMode m_mode;
bool m_capturing;
int m_cameraId;
@@ -105,15 +105,15 @@ class Camera_ZWO : public GuideCamera
};
Camera_ZWO::Camera_ZWO()
- :
- m_buffer(nullptr)
+ : m_buffer(nullptr)
{
Name = _T("ZWO ASI Camera");
PropertyDialogType = PROPDLG_WHEN_DISCONNECTED;
Connected = false;
m_hasGuideOutput = true;
HasSubframes = true;
- HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to true later when the camera is connected
+ HasGainControl = true; // workaround: ok to set to false later, but brain dialog will crash if we start false then change to
+ // true later when the camera is connected
m_defaultGainPct = GuideCamera::GetDefaultCameraGain();
int value = pConfig->Profile.GetInt("/camera/ZWO/bpp", 8);
m_bpp = value == 8 ? 8 : 16;
@@ -132,9 +132,7 @@ wxByte Camera_ZWO::BitsPerPixel()
inline wxSize Camera_ZWO::BinnedFrameSize(unsigned int binning)
{
// ASI cameras require width % 8 == 0 and height % 2 == 0
- return wxSize(
- (m_maxSize.x / binning) & ~(8U - 1),
- (m_maxSize.y / binning) & ~(2U - 1));
+ return wxSize((m_maxSize.x / binning) & ~(8U - 1), (m_maxSize.y / binning) & ~(2U - 1));
}
struct ZWOCameraDlg : public wxDialog
@@ -160,7 +158,7 @@ ZWOCameraDlg::ZWOCameraDlg()
wxStdDialogButtonSizer *sdbSizer2 = new wxStdDialogButtonSizer();
wxButton *sdbSizer2OK = new wxButton(this, wxID_OK);
- wxButton* sdbSizer2Cancel = new wxButton(this, wxID_CANCEL);
+ wxButton *sdbSizer2Cancel = new wxButton(this, wxID_CANCEL);
sdbSizer2->AddButton(sdbSizer2OK);
sdbSizer2->AddButton(sdbSizer2Cancel);
sdbSizer2->Realize();
@@ -198,14 +196,14 @@ inline static int gain_pct(int minval, int maxval, int val)
return (val - minval) * 100 / (maxval - minval);
}
-#ifdef __WINDOWS__
+# ifdef __WINDOWS__
-#if !defined(FACILITY_VISUALCPP)
-# define FACILITY_VISUALCPP ((LONG)0x6d)
-#endif
-#ifndef VcppException
-# define VcppException(sev,err) ((sev) | ((FACILITY_VISUALCPP)<<16) | (err))
-#endif
+# if !defined(FACILITY_VISUALCPP)
+# define FACILITY_VISUALCPP ((LONG) 0x6d)
+# endif
+# ifndef VcppException
+# define VcppException(sev, err) ((sev) | ((FACILITY_VISUALCPP) << 16) | (err))
+# endif
static LONG WINAPI DelayLoadDllExceptionFilter(PEXCEPTION_POINTERS pExcPointers, wxString *err)
{
@@ -214,7 +212,8 @@ static LONG WINAPI DelayLoadDllExceptionFilter(PEXCEPTION_POINTERS pExcPointers,
switch (pExcPointers->ExceptionRecord->ExceptionCode)
{
- case VcppException(ERROR_SEVERITY_ERROR, ERROR_MOD_NOT_FOUND): {
+ case VcppException(ERROR_SEVERITY_ERROR, ERROR_MOD_NOT_FOUND):
+ {
// ASICamera2.dll depends on the VC++ 2008 runtime, check for that
HMODULE hm = LoadLibraryEx(_T("MSVCR90.DLL"), NULL, LOAD_LIBRARY_AS_DATAFILE);
if (hm)
@@ -223,7 +222,8 @@ static LONG WINAPI DelayLoadDllExceptionFilter(PEXCEPTION_POINTERS pExcPointers,
*err = wxString::Format(_("Could not load DLL %s"), pdli->szDll);
}
else
- *err = _("The ASI camera library requires the Microsoft Visual C++ 2008 Redistributable Package (x86), available at http://www.microsoft.com/en-us/download/details.aspx?id=29");
+ *err = _("The ASI camera library requires the Microsoft Visual C++ 2008 Redistributable Package (x86), available "
+ "at http://www.microsoft.com/en-us/download/details.aspx?id=29");
break;
}
@@ -245,23 +245,25 @@ static LONG WINAPI DelayLoadDllExceptionFilter(PEXCEPTION_POINTERS pExcPointers,
static bool DoTryLoadDll(wxString *err)
{
- __try {
+ __try
+ {
ASIGetNumOfConnectedCameras();
return true;
}
- __except (DelayLoadDllExceptionFilter(GetExceptionInformation(), err)) {
+ __except (DelayLoadDllExceptionFilter(GetExceptionInformation(), err))
+ {
return false;
}
}
-#else // __WINDOWS__
+# else // __WINDOWS__
static bool DoTryLoadDll(wxString *err)
{
return true;
}
-#endif // __WINDOWS__
+# endif // __WINDOWS__
static bool TryLoadDll(wxString *err)
{
@@ -536,7 +538,6 @@ bool Camera_ZWO::Connect(const wxString& camId)
break;
}
}
-
}
if (HasGainControl)
@@ -693,7 +694,10 @@ inline static int round_up(int v, int m)
static void flush_buffered_image(int cameraId, void *buf, size_t size)
{
- enum { NUM_IMAGE_BUFFERS = 2 }; // camera has 2 internal frame buffers
+ enum
+ {
+ NUM_IMAGE_BUFFERS = 2
+ }; // camera has 2 internal frame buffers
// clear buffered frames if any
@@ -751,8 +755,7 @@ bool Camera_ZWO::Capture(int duration, usImage& img, int options, const wxRect&
long exposureUS = duration * 1000;
ASI_BOOL tmp;
long cur_exp;
- if (ASIGetControlValue(m_cameraId, ASI_EXPOSURE, &cur_exp, &tmp) == ASI_SUCCESS &&
- cur_exp != exposureUS)
+ if (ASIGetControlValue(m_cameraId, ASI_EXPOSURE, &cur_exp, &tmp) == ASI_SUCCESS && cur_exp != exposureUS)
{
Debug.Write(wxString::Format("ZWO: set CONTROL_EXPOSURE %d\n", exposureUS));
ASISetControlValue(m_cameraId, ASI_EXPOSURE, exposureUS, ASI_FALSE);
@@ -760,8 +763,7 @@ bool Camera_ZWO::Capture(int duration, usImage& img, int options, const wxRect&
long new_gain = cam_gain(m_minGain, m_maxGain, GuideCameraGain);
long cur_gain;
- if (ASIGetControlValue(m_cameraId, ASI_GAIN, &cur_gain, &tmp) == ASI_SUCCESS &&
- new_gain != cur_gain)
+ if (ASIGetControlValue(m_cameraId, ASI_GAIN, &cur_gain, &tmp) == ASI_SUCCESS && new_gain != cur_gain)
{
Debug.Write(wxString::Format("ZWO: set CONTROL_GAIN %d%% %d\n", GuideCameraGain, new_gain));
ASISetControlValue(m_cameraId, ASI_GAIN, new_gain, ASI_FALSE);
@@ -780,9 +782,11 @@ bool Camera_ZWO::Capture(int duration, usImage& img, int options, const wxRect&
{
StopCapture();
- ASI_ERROR_CODE status = ASISetROIFormat(m_cameraId, frame.GetWidth(), frame.GetHeight(), Binning, m_bpp == 8 ? ASI_IMG_RAW8 : ASI_IMG_RAW16);
+ ASI_ERROR_CODE status = ASISetROIFormat(
+ m_cameraId, frame.GetWidth(), frame.GetHeight(), Binning, m_bpp == 8 ? ASI_IMG_RAW8 : ASI_IMG_RAW16);
if (status != ASI_SUCCESS)
- Debug.Write(wxString::Format("ZWO: setImageFormat(%d,%d,%hu) => %d\n", frame.GetWidth(), frame.GetHeight(), Binning, status));
+ Debug.Write(wxString::Format(
+ "ZWO: setImageFormat(%d,%d,%hu) => %d\n", frame.GetWidth(), frame.GetHeight(), Binning, status));
}
if (pos_change)
@@ -794,8 +798,7 @@ bool Camera_ZWO::Capture(int duration, usImage& img, int options, const wxRect&
int poll = wxMin(duration, 100);
- unsigned char *const buffer =
- m_bpp == 16 && !useSubframe ? (unsigned char *) img.ImageData : (unsigned char *) m_buffer;
+ unsigned char *const buffer = m_bpp == 16 && !useSubframe ? (unsigned char *) img.ImageData : (unsigned char *) m_buffer;
if (m_mode == CM_VIDEO)
{
@@ -848,7 +851,8 @@ bool Camera_ZWO::Capture(int duration, usImage& img, int options, const wxRect&
ASIStartExposure(m_cameraId, is_dark);
- CameraWatchdog watchdog(duration, duration + GetTimeoutMs() + 10000); // total timeout is 2 * duration + 15s (typically)
+ CameraWatchdog watchdog(
+ duration, duration + GetTimeoutMs() + 10000); // total timeout is 2 * duration + 15s (typically)
if (duration > 100)
{
@@ -987,7 +991,7 @@ bool Camera_ZWO::ST4PulseGuideScope(int direction, int duration)
return false;
}
-void Camera_ZWO::ClearGuidePort()
+void Camera_ZWO::ClearGuidePort()
{
ASIPulseGuideOff(m_cameraId, ASI_GUIDE_NORTH);
ASIPulseGuideOff(m_cameraId, ASI_GUIDE_SOUTH);
@@ -1000,10 +1004,13 @@ GuideCamera *ZWOCameraFactory::MakeZWOCamera()
return new Camera_ZWO();
}
-#if defined(__APPLE__)
+# if defined(__APPLE__)
// workaround link error for missing symbol ___exp10 from libASICamera2.a
-#include
-extern "C" double __exp10(double x) { return pow(10.0, x); }
-#endif
+# include
+extern "C" double __exp10(double x)
+{
+ return pow(10.0, x);
+}
+# endif
#endif // ZWO_ASI
diff --git a/src/cam_zwo.h b/src/cam_zwo.h
index e2abb5526..293709bae 100644
--- a/src/cam_zwo.h
+++ b/src/cam_zwo.h
@@ -1,37 +1,37 @@
/*
-* cam_zwo.h
-* PHD Guiding
-*
-* Created by Robin Glover.
-* Copyright (c) 2014 Robin Glover
-* Copyright (c) 2018 Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * cam_zwo.h
+ * PHD Guiding
+ *
+ * Created by Robin Glover.
+ * Copyright (c) 2014 Robin Glover
+ * Copyright (c) 2018 Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#ifndef CAM_ZWO_H_INCLUDED
#define CAM_ZWO_H_INCLUDED
diff --git a/src/camcal_import_dialog.cpp b/src/camcal_import_dialog.cpp
index c0312a0e9..02bbf55c3 100644
--- a/src/camcal_import_dialog.cpp
+++ b/src/camcal_import_dialog.cpp
@@ -33,8 +33,8 @@
*
*/
-// Handles import of camera calibration files (dark library, bad-pix map files) from user-selected profile to the current profile
-// Source profile choices are limited to camera data with compatible geometry
+// Handles import of camera calibration files (dark library, bad-pix map files) from user-selected profile to the current
+// profile Source profile choices are limited to camera data with compatible geometry
#include "phd.h"
#include "camcal_import_dialog.h"
@@ -48,10 +48,10 @@ static void AddTableEntryPair(wxWindow *parent, wxFlexGridSizer *pTable, const w
pTable->Add(pControl, 1, wxALL, 5);
}
-CamCalImportDialog::CamCalImportDialog(wxWindow *parent) :
- wxDialog(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
+CamCalImportDialog::CamCalImportDialog(wxWindow *parent)
+ : wxDialog(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
- wxBoxSizer* vSizer = new wxBoxSizer(wxVERTICAL);
+ wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL);
SetTitle(wxString::Format(_("Import Darks to Profile %s"), pConfig->GetCurrentProfile()));
@@ -59,11 +59,12 @@ CamCalImportDialog::CamCalImportDialog(wxWindow *parent) :
m_profileNames = pConfig->ProfileNames();
// Start with the dark library
- wxStaticBoxSizer* darksGroup = new wxStaticBoxSizer(wxVERTICAL, this, _("Dark Library"));
+ wxStaticBoxSizer *darksGroup = new wxStaticBoxSizer(wxVERTICAL, this, _("Dark Library"));
- wxStaticText* darksLabel = new wxStaticText(this, wxID_STATIC, _("Choose the profile with the dark library you want to use:"), wxDefaultPosition, wxDefaultSize, 0);
+ wxStaticText *darksLabel = new wxStaticText(
+ this, wxID_STATIC, _("Choose the profile with the dark library you want to use:"), wxDefaultPosition, wxDefaultSize, 0);
darksGroup->Add(darksLabel, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
- wxFlexGridSizer* drkGrid = new wxFlexGridSizer(2, 2, 0, 0);
+ wxFlexGridSizer *drkGrid = new wxFlexGridSizer(2, 2, 0, 0);
wxArrayString drkChoices;
drkChoices.Add(_("None"));
@@ -72,7 +73,8 @@ CamCalImportDialog::CamCalImportDialog(wxWindow *parent) :
if (drkChoices.Count() > 1)
{
- m_darksChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, drkChoices, 0, wxDefaultValidator, _("Darks Profiles"));
+ m_darksChoice = new wxChoice(
+ this, wxID_ANY, wxDefaultPosition, wxDefaultSize, drkChoices, 0, wxDefaultValidator, _("Darks Profiles"));
m_darksChoice->SetSelection(0);
m_darksChoice->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &CamCalImportDialog::OnDarkProfileChoice, this);
AddTableEntryPair(this, drkGrid, _("Import from profile"), m_darksChoice);
@@ -85,9 +87,10 @@ CamCalImportDialog::CamCalImportDialog(wxWindow *parent) :
vSizer->Add(darksGroup, 0, wxALIGN_LEFT | wxALL, 10);
// Now add the bad-pix map controls
- wxStaticBoxSizer* bpmGroup = new wxStaticBoxSizer(wxVERTICAL, this, _("Bad-pixel Map"));
+ wxStaticBoxSizer *bpmGroup = new wxStaticBoxSizer(wxVERTICAL, this, _("Bad-pixel Map"));
- wxStaticText* bpmLabel = new wxStaticText(this, wxID_STATIC, _("Choose the profile with the bad-pixel map you want to use:"), wxDefaultPosition, wxDefaultSize, 0);
+ wxStaticText *bpmLabel = new wxStaticText(this, wxID_STATIC,
+ _("Choose the profile with the bad-pixel map you want to use:"), wxDefaultPosition, wxDefaultSize, 0);
bpmGroup->Add(bpmLabel, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 10);
wxArrayString bpmChoices;
@@ -97,7 +100,8 @@ CamCalImportDialog::CamCalImportDialog(wxWindow *parent) :
if (bpmChoices.Count() > 1)
{
- m_bpmChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, bpmChoices, 0, wxDefaultValidator, _("Bad-pix Map Profiles"));
+ m_bpmChoice = new wxChoice(
+ this, wxID_ANY, wxDefaultPosition, wxDefaultSize, bpmChoices, 0, wxDefaultValidator, _("Bad-pix Map Profiles"));
m_bpmChoice->SetSelection(0);
m_bpmChoice->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &CamCalImportDialog::OnBPMProfileChoice, this);
wxFlexGridSizer *bpmGrid = new wxFlexGridSizer(2, 2, 0, 0);
@@ -112,29 +116,27 @@ CamCalImportDialog::CamCalImportDialog(wxWindow *parent) :
vSizer->Add(bpmGroup, 0, wxALIGN_LEFT | wxALL, 10);
// Add the buttons
- wxBoxSizer* btnHSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *btnHSizer = new wxBoxSizer(wxHORIZONTAL);
vSizer->Add(btnHSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 10);
- wxButton* btnOk = new wxButton(this, wxID_ANY, _("OK"), wxDefaultPosition, wxDefaultSize, 0);
+ wxButton *btnOk = new wxButton(this, wxID_ANY, _("OK"), wxDefaultPosition, wxDefaultSize, 0);
btnOk->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &CamCalImportDialog::OnOk, this);
btnOk->SetDefault();
btnHSizer->Add(btnOk, 0, wxALIGN_CENTER_VERTICAL | wxALL, 10);
- wxButton* btnCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0);
+ wxButton *btnCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0);
btnHSizer->Add(btnCancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 10);
- //PopulateLBs(darksLB, bpmLB);
+ // PopulateLBs(darksLB, bpmLB);
SetSizerAndFit(vSizer);
m_activeProfileName = pConfig->GetCurrentProfile();
m_sourceDarksProfileId = -1;
m_sourceBpmProfileId = -1;
}
-CamCalImportDialog::~CamCalImportDialog(void)
-{
-}
+CamCalImportDialog::~CamCalImportDialog(void) { }
-void CamCalImportDialog::FindCompatibleDarks(wxArrayString* pResults)
+void CamCalImportDialog::FindCompatibleDarks(wxArrayString *pResults)
{
for (unsigned int i = 0; i < m_profileNames.GetCount(); i++)
@@ -144,10 +146,9 @@ void CamCalImportDialog::FindCompatibleDarks(wxArrayString* pResults)
if (pFrame->DarkLibExists(profileId, false))
pResults->Add(m_profileNames[i]);
}
-
}
-void CamCalImportDialog::FindCompatibleBPMs(wxArrayString* pResults)
+void CamCalImportDialog::FindCompatibleBPMs(wxArrayString *pResults)
{
for (unsigned int i = 0; i < m_profileNames.GetCount(); i++)
{
@@ -174,7 +175,6 @@ void CamCalImportDialog::OnDarkProfileChoice(wxCommandEvent& evt)
m_darkCameraChoice->SetLabelText(wxEmptyString);
m_sourceDarksProfileId = -1;
}
-
}
void CamCalImportDialog::OnBPMProfileChoice(wxCommandEvent& evt)
@@ -205,7 +205,8 @@ void CamCalImportDialog::OnOk(wxCommandEvent& evt)
{
if (DefectMap::ImportFromProfile(m_sourceBpmProfileId, m_thisProfileId))
{
- Debug.Write(wxString::Format("Defect map files imported and loaded from profile %d to profile %d\n", m_sourceBpmProfileId, m_thisProfileId));
+ Debug.Write(wxString::Format(
+ "Defect map files imported and loaded from profile %d to profile %d\n", m_sourceBpmProfileId, m_thisProfileId));
pFrame->LoadDefectMapHandler(true);
bpmLoaded = true;
}
@@ -222,7 +223,8 @@ void CamCalImportDialog::OnOk(wxCommandEvent& evt)
destName = MyFrame::DarkLibFileName(m_thisProfileId);
if (wxCopyFile(sourceName, destName, true))
{
- Debug.Write(wxString::Format("Dark library imported from profile %d to profile %d\n", m_sourceDarksProfileId, m_thisProfileId));
+ Debug.Write(wxString::Format(
+ "Dark library imported from profile %d to profile %d\n", m_sourceDarksProfileId, m_thisProfileId));
if (!bpmLoaded)
{
pFrame->LoadDarkHandler(true);
@@ -234,6 +236,6 @@ void CamCalImportDialog::OnOk(wxCommandEvent& evt)
wxMessageBox(_("Dark library could not be imported because of errors in file/copy"));
}
}
- pFrame->SetDarkMenuState(); // Get enabled states straightened out
+ pFrame->SetDarkMenuState(); // Get enabled states straightened out
EndModal(wxID_OK);
}
diff --git a/src/camcal_import_dialog.h b/src/camcal_import_dialog.h
index 740e09a3e..6ffef8aee 100644
--- a/src/camcal_import_dialog.h
+++ b/src/camcal_import_dialog.h
@@ -39,17 +39,16 @@
class CamCalImportDialog : public wxDialog
{
public:
-
CamCalImportDialog(wxWindow *parent);
~CamCalImportDialog(void);
private:
- wxChoice* m_darksChoice;
- wxStaticText* m_darkCameraChoice;
- wxChoice* m_bpmChoice;
- wxStaticText* m_bpmCameraChoice;
- void FindCompatibleDarks(wxArrayString* pResults);
- void FindCompatibleBPMs(wxArrayString* pResults);
+ wxChoice *m_darksChoice;
+ wxStaticText *m_darkCameraChoice;
+ wxChoice *m_bpmChoice;
+ wxStaticText *m_bpmCameraChoice;
+ void FindCompatibleDarks(wxArrayString *pResults);
+ void FindCompatibleBPMs(wxArrayString *pResults);
void OnDarkProfileChoice(wxCommandEvent& evt);
void OnBPMProfileChoice(wxCommandEvent& evt);
void OnOk(wxCommandEvent& evt);
diff --git a/src/camera.cpp b/src/camera.cpp
index 325e5e4db..549621433 100644
--- a/src/camera.cpp
+++ b/src/camera.cpp
@@ -50,135 +50,135 @@ const double GuideCamera::UnknownPixelSize = 0.0;
wxSize UNDEFINED_FRAME_SIZE = wxSize(0, 0);
-#if defined (ATIK16)
+#if defined(ATIK16)
# include "cam_atik16.h"
#endif
-#if defined (IOPTRON_CAMERA)
+#if defined(IOPTRON_CAMERA)
# include "cam_ioptron.h"
#endif
-#if defined (LE_SERIAL_CAMERA)
+#if defined(LE_SERIAL_CAMERA)
# include "cam_LESerialWebcam.h"
#endif
-#if defined (LE_PARALLEL_CAMERA)
+#if defined(LE_PARALLEL_CAMERA)
# include "cam_LEParallelwebcam.h"
#endif
-#if defined (LE_LXUSB_CAMERA)
+#if defined(LE_LXUSB_CAMERA)
# include "cam_LELXUSBwebcam.h"
#endif
-#if defined (QGUIDE)
+#if defined(QGUIDE)
# include "cam_qguide.h"
#endif
-#if defined (CAM_QHY5)
+#if defined(CAM_QHY5)
# include "cam_qhy5.h"
#endif
-#if defined (QHY_CAMERA)
+#if defined(QHY_CAMERA)
# include "cam_qhy.h"
#endif
-#if defined (SVB_CAMERA)
+#if defined(SVB_CAMERA)
# include "cam_svb.h"
#endif
-#if defined (ZWO_ASI)
+#if defined(ZWO_ASI)
# include "cam_zwo.h"
#endif
-#if defined (TOUPTEK_CAMERA)
+#if defined(TOUPTEK_CAMERA)
# include "cam_touptek.h"
#endif
-#if defined (SKYRAIDER_CAMERA)
+#if defined(SKYRAIDER_CAMERA)
# include "cam_skyraider.h"
#endif
-#if defined (ALTAIR)
+#if defined(ALTAIR)
# include "cam_altair.h"
#endif
-#if defined (ORION_DSCI)
+#if defined(ORION_DSCI)
# include "cam_StarShootDSCI.h"
#endif
-#if defined (OS_PL130)
+#if defined(OS_PL130)
# include "cam_OSPL130.h"
#endif
-#if defined (VFW_CAMERA)
+#if defined(VFW_CAMERA)
# include "cam_vfw.h"
#endif
-#if defined (OGMA_CAMERA)
+#if defined(OGMA_CAMERA)
# include "cam_ogma.h"
#endif
-#if defined (OPENCV_CAMERA)
+#if defined(OPENCV_CAMERA)
# include "cam_opencv.h"
#endif
-#if defined (WDM_CAMERA)
+#if defined(WDM_CAMERA)
# include "cam_wdm.h"
#endif
-#if defined (STARFISH_CAMERA)
+#if defined(STARFISH_CAMERA)
# include "cam_starfish.h"
#endif
-#if defined (SXV)
+#if defined(SXV)
# include "cam_sxv.h"
#endif
-#if defined (SBIG)
+#if defined(SBIG)
# include "cam_sbig.h"
#endif
-#if defined (NEB_SBIG)
+#if defined(NEB_SBIG)
# include "cam_NebSBIG.h"
#endif
-#if defined (FIREWIRE_CAMERA)
+#if defined(FIREWIRE_CAMERA)
# include "cam_firewire.h"
#endif
-#if defined (MEADE_DSI_CAMERA)
+#if defined(MEADE_DSI_CAMERA)
# include "cam_MeadeDSI.h"
#endif
-#if defined (MORAVIAN_CAMERA)
+#if defined(MORAVIAN_CAMERA)
# include "cam_moravian.h"
#endif
-#if defined (SSAG)
+#if defined(SSAG)
# include "cam_ssag.h"
#endif
-#if defined (OPENSSAG_CAMERA)
+#if defined(OPENSSAG_CAMERA)
# include "cam_openssag.h"
#endif
-#if defined (KWIQGUIDER_CAMERA)
+#if defined(KWIQGUIDER_CAMERA)
# include "cam_KWIQGuider.h"
#endif
-#if defined (SSPIAG)
+#if defined(SSPIAG)
# include "cam_sspiag.h"
#endif
-#if defined (INOVA_PLC)
+#if defined(INOVA_PLC)
# include "cam_INovaPLC.h"
#endif
-#if defined (ASCOM_CAMERA)
+#if defined(ASCOM_CAMERA)
# include "cam_ascom.h"
#endif
-#if defined (INDI_CAMERA)
+#if defined(INDI_CAMERA)
# include "cam_indi.h"
#endif
@@ -186,10 +186,11 @@ wxSize UNDEFINED_FRAME_SIZE = wxSize(0, 0);
# include "cam_sbigrotator.h"
#endif
-#if defined (V4L_CAMERA)
+#if defined(V4L_CAMERA)
# include "cam_VIDEODEVICE.h"
-extern "C" {
-#include
+extern "C"
+{
+# include
}
#endif
@@ -248,129 +249,130 @@ wxArrayString GuideCamera::GuideCameraList()
wxArrayString CameraList;
CameraList.Add(_("None"));
-#if defined (ASCOM_CAMERA)
+#if defined(ASCOM_CAMERA)
wxArrayString ascomCameras = ASCOMCameraFactory::EnumAscomCameras();
for (unsigned int i = 0; i < ascomCameras.Count(); i++)
CameraList.Add(ascomCameras[i]);
#endif
-#if defined (ATIK16)
+#if defined(ATIK16)
CameraList.Add(_T("Atik 16 series, mono"));
CameraList.Add(_T("Atik 16 series, color"));
#endif
-#if defined (ATIK_GEN3)
+#if defined(ATIK_GEN3)
CameraList.Add(_T("Atik Gen3, mono"));
CameraList.Add(_T("Atik Gen3, color"));
#endif
-#if defined (QGUIDE)
+#if defined(QGUIDE)
CameraList.Add(_T("CCD Labs Q-Guider"));
#endif
-#if defined (STARFISH_CAMERA)
+#if defined(STARFISH_CAMERA)
CameraList.Add(_T("Fishcamp Starfish"));
#endif
-#if defined (INOVA_PLC)
+#if defined(INOVA_PLC)
CameraList.Add(_T("i-Nova PLC-M"));
#endif
-#if defined (IOPTRON_CAMERA)
+#if defined(IOPTRON_CAMERA)
CameraList.Add(_T("iOptron iGuider"));
#endif
-#if defined (SSAG)
+#if defined(SSAG)
CameraList.Add(_T("StarShoot Autoguider"));
#endif
-#if defined (SSPIAG)
+#if defined(SSPIAG)
CameraList.Add(_T("StarShoot Planetary Imager & Autoguider"));
#endif
-#if defined (OS_PL130)
+#if defined(OS_PL130)
CameraList.Add(_T("Opticstar PL-130M"));
CameraList.Add(_T("Opticstar PL-130C"));
#endif
-#if defined (ORION_DSCI)
+#if defined(ORION_DSCI)
CameraList.Add(_T("Orion StarShoot DSCI"));
#endif
-#if defined (OPENSSAG_CAMERA)
+#if defined(OPENSSAG_CAMERA)
CameraList.Add(_T("Orion StarShoot Autoguider"));
#endif
-#if defined (KWIQGUIDER_CAMERA)
+#if defined(KWIQGUIDER_CAMERA)
CameraList.Add(_T("KWIQGuider"));
#endif
-#if defined (QGUIDE)
+#if defined(QGUIDE)
CameraList.Add(_T("MagZero MZ-5"));
#endif
-#if defined (MEADE_DSI_CAMERA)
+#if defined(MEADE_DSI_CAMERA)
CameraList.Add(_T("Meade DSI I, II, or III"));
#endif
-#if defined (MORAVIAN_CAMERA)
+#if defined(MORAVIAN_CAMERA)
CameraList.Add(_T("Moravian Camera"));
#endif
-#if defined (CAM_QHY5)
+#if defined(CAM_QHY5)
CameraList.Add(_T("QHY 5"));
#endif
-#if defined (QHY_CAMERA)
+#if defined(QHY_CAMERA)
CameraList.Add(_T("QHY Camera"));
#endif
-#if defined (ALTAIR)
- CameraList.Add(_T("Altair Camera"));
+#if defined(ALTAIR)
+ CameraList.Add(_T("Altair Camera"));
CameraList.Add(_T("Altair Camera (2015/2016)"));
#endif
-#if defined (ZWO_ASI)
+#if defined(ZWO_ASI)
CameraList.Add(_T("ZWO ASI Camera"));
#endif
-#if defined (TOUPTEK_CAMERA)
+#if defined(TOUPTEK_CAMERA)
CameraList.Add(_T("ToupTek Camera"));
CameraList.Add(_T("Omegon Pro Camera"));
#endif
-#if defined (SKYRAIDER_CAMERA)
+#if defined(SKYRAIDER_CAMERA)
CameraList.Add(_T("MallinCam SkyRaider"));
#endif
-#if defined (SBIG)
+#if defined(SBIG)
CameraList.Add(_T("SBIG"));
#endif
-#if defined (SBIGROTATOR_CAMERA)
+#if defined(SBIGROTATOR_CAMERA)
CameraList.Add(_T("SBIG Rotator"));
#endif
-#if defined (SVB_CAMERA)
+#if defined(SVB_CAMERA)
CameraList.Add(_T("Svbony Camera"));
#endif
-#if defined (SXV)
+#if defined(SXV)
CameraList.Add(_T("Starlight Xpress SXV"));
#endif
-#if defined (FIREWIRE_CAMERA)
+#if defined(FIREWIRE_CAMERA)
CameraList.Add(_T("The Imaging Source (DCAM Firewire)"));
#endif
-#if defined (OGMA_CAMERA)
+#if defined(OGMA_CAMERA)
CameraList.Add(_T("OGMA Camera"));
#endif
-#if defined (OPENCV_CAMERA)
+#if defined(OPENCV_CAMERA)
CameraList.Add(_T("OpenCV webcam 1"));
CameraList.Add(_T("OpenCV webcam 2"));
#endif
-#if defined (WDM_CAMERA)
+#if defined(WDM_CAMERA)
CameraList.Add(_T("Windows WDM-style webcam camera"));
#endif
-#if defined (VFW_CAMERA)
+#if defined(VFW_CAMERA)
CameraList.Add(_T("Windows VFW-style webcam camera (older & SAC8)"));
#endif
-#if defined (LE_LXUSB_CAMERA)
+#if defined(LE_LXUSB_CAMERA)
CameraList.Add(_T("Long exposure LXUSB webcam"));
#endif
-#if defined (LE_PARALLEL_CAMERA)
+#if defined(LE_PARALLEL_CAMERA)
CameraList.Add(_T("Long exposure Parallel webcam"));
#endif
-#if defined (LE_SERIAL_CAMERA)
+#if defined(LE_SERIAL_CAMERA)
CameraList.Add(_T("Long exposure Serial webcam"));
#endif
-#if defined (INDI_CAMERA)
+#if defined(INDI_CAMERA)
CameraList.Add(INDICamName());
#endif
-#if defined (V4L_CAMERA)
- if (true == Camera_VIDEODEVICE.ProbeDevices()) {
+#if defined(V4L_CAMERA)
+ if (true == Camera_VIDEODEVICE.ProbeDevices())
+ {
CameraList.Add(_T("V4L(2) Camera"));
}
#endif
-#if defined (SIMULATOR)
+#if defined(SIMULATOR)
CameraList.Add(_T("Simulator"));
#endif
-#if defined (NEB_SBIG)
+#if defined(NEB_SBIG)
CameraList.Add(_T("Guide chip on SBIG cam in Nebulosity"));
#endif
@@ -397,17 +399,19 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
}
// Chack ASCOM and INDI first since those choices may match match other choices below (like Simulator)
-#if defined (ASCOM_CAMERA)
- else if (choice.Contains(_T("ASCOM"))) {
+#if defined(ASCOM_CAMERA)
+ else if (choice.Contains(_T("ASCOM")))
+ {
pReturn = ASCOMCameraFactory::MakeASCOMCamera(choice);
}
#endif
-#if defined (INDI_CAMERA)
- else if (choice.Contains(_T("INDI"))) {
+#if defined(INDI_CAMERA)
+ else if (choice.Contains(_T("INDI")))
+ {
pReturn = INDICameraFactory::MakeINDICamera();
}
#endif
-#if defined (IOPTRON_CAMERA)
+#if defined(IOPTRON_CAMERA)
else if (choice == _T("iOptron iGuider"))
pReturn = IoptronCameraFactory::MakeIoptronCamera();
#endif
@@ -415,7 +419,7 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
pReturn = nullptr;
else if (choice == _T("Simulator"))
pReturn = GearSimulator::MakeCamSimulator();
-#if defined (ATIK16)
+#if defined(ATIK16)
else if (choice.StartsWith("Atik 16 series"))
{
bool hsmodel = false;
@@ -423,7 +427,7 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
pReturn = AtikCameraFactory::MakeAtikCamera(hsmodel, color);
}
#endif
-#if defined (ATIK_GEN3)
+#if defined(ATIK_GEN3)
else if (choice.StartsWith(_T("Atik Gen3")))
{
bool hsmodel = true;
@@ -431,7 +435,7 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
pReturn = AtikCameraFactory::MakeAtikCamera(hsmodel, color);
}
#endif
-#if defined (QGUIDE)
+#if defined(QGUIDE)
else if (choice.Contains(_T("CCD Labs Q-Guider")))
{
pReturn = new CameraQGuider();
@@ -443,7 +447,7 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
pReturn->Name = _T("MagZero MZ-5");
}
#endif
-#if defined (QHY_CAMERA)
+#if defined(QHY_CAMERA)
else if (choice == _T("QHY Camera"))
pReturn = QHYCameraFactory::MakeQHYCamera();
#endif
@@ -458,8 +462,7 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
pReturn = ZWOCameraFactory::MakeZWOCamera();
#endif
#if defined(TOUPTEK_CAMERA)
- else if (choice == _T("ToupTek Camera") ||
- choice == _T("Omegon Pro Camera"))
+ else if (choice == _T("ToupTek Camera") || choice == _T("Omegon Pro Camera"))
{
pReturn = ToupTekCameraFactory::MakeToupTekCamera();
}
@@ -468,27 +471,27 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
else if (choice == _T("MallinCam SkyRaider"))
pReturn = SkyraiderCameraFactory::MakeSkyraiderCamera();
#endif
-#if defined (CAM_QHY5) // must come afer other QHY 5's since this pattern would match them
+#if defined(CAM_QHY5) // must come afer other QHY 5's since this pattern would match them
else if (choice.Contains(_T("QHY 5")))
pReturn = new CameraQHY5();
#endif
-#if defined (OPENSSAG_CAMERA)
+#if defined(OPENSSAG_CAMERA)
else if (choice.Contains(_T("Orion StarShoot Autoguider")))
pReturn = new CameraOpenSSAG();
#endif
-#if defined (KWIQGUIDER_CAMERA)
+#if defined(KWIQGUIDER_CAMERA)
else if (choice.Contains(_T("KWIQGuider")))
pReturn = KWIQGuiderCameraFactory::MakeKWIQGuiderCamera();
#endif
-#if defined (SSAG)
+#if defined(SSAG)
else if (choice.Contains(_T("StarShoot Autoguider")))
pReturn = SSAGCameraFactory::MakeSSAGCamera();
#endif
-#if defined (SSPIAG)
+#if defined(SSPIAG)
else if (choice.Contains(_T("StarShoot Planetary Imager & Autoguider")))
pReturn = new CameraSSPIAG();
#endif
-#if defined (ORION_DSCI)
+#if defined(ORION_DSCI)
else if (choice.Contains(_T("Orion StarShoot DSCI")))
pReturn = new CameraStarShootDSCI();
#endif
@@ -500,7 +503,7 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
else if (choice == _T("OGMA Camera"))
pReturn = OGMACameraFactory::MakeOGMACamera();
#endif
-#if defined (OPENCV_CAMERA)
+#if defined(OPENCV_CAMERA)
else if (choice.Contains(_T("OpenCV webcam")))
{
int dev = 0;
@@ -511,27 +514,27 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
pReturn = new CameraOpenCV(dev);
}
#endif
-#if defined (WDM_CAMERA)
+#if defined(WDM_CAMERA)
else if (choice.Contains(_T("Windows WDM")))
pReturn = WDMCameraFactory::MakeWDMCamera();
#endif
-#if defined (VFW_CAMERA)
+#if defined(VFW_CAMERA)
else if (choice.Contains(_T("Windows VFW")))
pReturn = new CameraVFW();
#endif
-#if defined (LE_SERIAL_CAMERA)
+#if defined(LE_SERIAL_CAMERA)
else if (choice.Contains(_T("Long exposure Serial webcam")))
pReturn = LESerialWebcamCameraFactory::MakeLESerialWebcamCamera();
#endif
-#if defined (LE_PARALLEL_CAMERA)
- else if (choice.Contains( _T("Long exposure Parallel webcam")))
+#if defined(LE_PARALLEL_CAMERA)
+ else if (choice.Contains(_T("Long exposure Parallel webcam")))
pReturn = LEParallelWebcamCameraFactory::MakeLEParallelWebcamCamera();
#endif
-#if defined (LE_LXUSB_CAMERA)
+#if defined(LE_LXUSB_CAMERA)
else if (choice.Contains(_T("Long exposure LXUSB webcam")))
pReturn = LELxUsbWebcamCameraFactory::MakeLELxUsbWebcamCamera();
#endif
-#if defined (MEADE_DSI_CAMERA)
+#if defined(MEADE_DSI_CAMERA)
else if (choice.Contains(_T("Meade DSI I, II, or III")))
pReturn = DSICameraFactory::MakeDSICamera();
#endif
@@ -539,15 +542,15 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
else if (choice == _T("Moravian Camera"))
pReturn = MoravianCameraFactory::MakeMoravianCamera();
#endif
-#if defined (STARFISH_CAMERA)
+#if defined(STARFISH_CAMERA)
else if (choice.Contains(_T("Fishcamp Starfish")))
pReturn = StarfishCameraFactory::MakeStarfishCamera();
#endif
-#if defined (SXV)
+#if defined(SXV)
else if (choice.Contains(_T("Starlight Xpress SXV")))
pReturn = SXVCameraFactory::MakeSXVCamera();
#endif
-#if defined (OS_PL130)
+#if defined(OS_PL130)
else if (choice.Contains(_T("Opticstar PL-130M")))
{
Camera_OSPL130.Color = false;
@@ -561,28 +564,28 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
pReturn = new Camera_OSPL130Class();
}
#endif
-#if defined (NEB_SBIG)
+#if defined(NEB_SBIG)
else if (choice.Contains(_T("Nebulosity")))
pReturn = new CameraNebSBIG();
#endif
-#if defined (SBIGROTATOR_CAMERA)
+#if defined(SBIGROTATOR_CAMERA)
// must go above SBIG
else if (choice.Contains(_T("SBIG Rotator")))
pReturn = SBIGRotatorCameraFactory::MakeSBIGRotatorCamera();
#endif
-#if defined (SBIG)
+#if defined(SBIG)
else if (choice.Contains(_T("SBIG")))
pReturn = SBIGCameraFactory::MakeSBIGCamera();
#endif
-#if defined (FIREWIRE_CAMERA)
+#if defined(FIREWIRE_CAMERA)
else if (choice.Contains(_T("The Imaging Source (DCAM Firewire)")))
pReturn = new CameraFirewire();
#endif
-#if defined (INOVA_PLC)
+#if defined(INOVA_PLC)
else if (choice.Contains(_T("i-Nova PLC-M")))
pReturn = new CameraINovaPLC();
#endif
-#if defined (V4L_CAMERA)
+#if defined(V4L_CAMERA)
else if (choice.Contains(_T("V4L(2) Camera")))
{
// There is at least ONE V4L(2) device ... let's find out exactly
@@ -603,7 +606,8 @@ GuideCamera *GuideCamera::Factory(const wxString& choice)
wxArrayString choices;
int choice = 0;
- if ((choice = wxGetSinglechoiceIndex(_("Select your camera"), _T("V4L(2) devices"), Camera_VIDEODEVICE.GetProductArray(choices))) != -1)
+ if ((choice = wxGetSinglechoiceIndex(
+ _("Select your camera"), _T("V4L(2) devices"), Camera_VIDEODEVICE.GetProductArray(choices))) != -1)
{
deviceInfo = Camera_VIDEODEVICE.GetDeviceAtIndex(choice);
@@ -782,17 +786,17 @@ CameraConfigDialogPane *GuideCamera::GetConfigDialogPane(wxWindow *pParent)
static wxSpinCtrl *NewSpinnerInt(wxWindow *parent, int width, int val, int minval, int maxval, int inc)
{
- wxSpinCtrl *pNewCtrl = pFrame->MakeSpinCtrl(parent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, minval, maxval, val);
+ wxSpinCtrl *pNewCtrl = pFrame->MakeSpinCtrl(
+ parent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, minval, maxval, val);
pNewCtrl->SetValue(val);
return pNewCtrl;
}
-static wxSpinCtrlDouble *NewSpinnerDouble(wxWindow *parent, int width, double val, double minval, double maxval, double inc,
- const wxString& tooltip)
+static wxSpinCtrlDouble *NewSpinnerDouble(
+ wxWindow *parent, int width, double val, double minval, double maxval, double inc, const wxString& tooltip)
{
- wxSpinCtrlDouble *pNewCtrl = pFrame->MakeSpinCtrlDouble(parent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, minval, maxval, val, inc);
+ wxSpinCtrlDouble *pNewCtrl = pFrame->MakeSpinCtrlDouble(
+ parent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, minval, maxval, val, inc);
pNewCtrl->SetDigits(2);
pNewCtrl->SetToolTip(tooltip);
return pNewCtrl;
@@ -829,9 +833,10 @@ void CameraConfigDialogPane::LayoutControls(GuideCamera *pCamera, BrainCtrlIdMap
wxStaticBoxSizer *pSpecGroup = new wxStaticBoxSizer(wxVERTICAL, m_pParent, _("Camera-Specific Properties"));
if (pCamera)
{
- wxFlexGridSizer *pDetailsSizer = new wxFlexGridSizer(6, 3, 15, 15); // Will auto-shrink to fit
- // Create all possible property controls then disable individual controls later if camera doesn't support them. This is safer for "omnibus" style drivers that
- // handle many cameras with different capabilities. Exceptions are 'port' and 'LE-delay' which will be created conditionally
+ wxFlexGridSizer *pDetailsSizer = new wxFlexGridSizer(6, 3, 15, 15); // Will auto-shrink to fit
+ // Create all possible property controls then disable individual controls later if camera doesn't support them. This is
+ // safer for "omnibus" style drivers that handle many cameras with different capabilities. Exceptions are 'port' and
+ // 'LE-delay' which will be created conditionally
wxSizerFlags spec_flags = wxSizerFlags(0).Border(wxALL, 10).Align(wxVERTICAL).Expand();
pDetailsSizer->Add(GetSizerCtrl(CtrlMap, AD_szPixelSize));
pDetailsSizer->Add(GetSizerCtrl(CtrlMap, AD_szGain));
@@ -851,15 +856,14 @@ void CameraConfigDialogPane::LayoutControls(GuideCamera *pCamera, BrainCtrlIdMap
wxStaticText *pNoCam = new wxStaticText(m_pParent, wxID_ANY, _("No camera specified"));
pSpecGroup->Add(pNoCam, wxSizerFlags().Align(wxALIGN_CENTER_HORIZONTAL));
pSpecGroup->Layout();
-
}
if (pCamera)
pGenGroup->Add(GetSizerCtrl(CtrlMap, AD_szSaturationOptions), wxSizerFlags(0).Border(wxALL, 2).Expand());
this->Add(pGenGroup, def_flags);
if (pCamera && !pCamera->Connected)
{
- wxStaticText *pNotConnected = new wxStaticText(m_pParent, wxID_ANY,
- _("Camera is not connected. Property controls may change if you connect to it first."));
+ wxStaticText *pNotConnected = new wxStaticText(
+ m_pParent, wxID_ANY, _("Camera is not connected. Property controls may change if you connect to it first."));
MakeBold(pNotConnected);
this->Add(pNotConnected, wxSizerFlags().Align(wxALIGN_CENTER_HORIZONTAL).Border(wxALL, 10));
}
@@ -869,14 +873,16 @@ void CameraConfigDialogPane::LayoutControls(GuideCamera *pCamera, BrainCtrlIdMap
Fit(m_pParent);
}
-CameraConfigDialogCtrlSet* GuideCamera::GetConfigDlgCtrlSet(wxWindow *pParent, GuideCamera *pCamera, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
+CameraConfigDialogCtrlSet *GuideCamera::GetConfigDlgCtrlSet(
+ wxWindow *pParent, GuideCamera *pCamera, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
{
return new CameraConfigDialogCtrlSet(pParent, pCamera, pAdvancedDialog, CtrlMap);
}
-CameraConfigDialogCtrlSet::CameraConfigDialogCtrlSet(wxWindow *pParent, GuideCamera *pCamera, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
- : ConfigDialogCtrlSet(pParent, pAdvancedDialog, CtrlMap),
- m_pUseSubframes(nullptr)
+CameraConfigDialogCtrlSet::CameraConfigDialogCtrlSet(
+ wxWindow *pParent, GuideCamera *pCamera, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
+ : ConfigDialogCtrlSet(pParent, pAdvancedDialog, CtrlMap)
+ , m_pUseSubframes(nullptr)
{
int textWidth = StringWidth(_T("0000"));
assert(pCamera);
@@ -884,11 +890,13 @@ CameraConfigDialogCtrlSet::CameraConfigDialogCtrlSet(wxWindow *pParent, GuideCam
m_pCamera = pCamera;
// Sub-frames
m_pUseSubframes = new wxCheckBox(GetParentWindow(AD_cbUseSubFrames), wxID_ANY, _("Use Subframes"));
- AddCtrl(CtrlMap, AD_cbUseSubFrames, m_pUseSubframes, _("Check to only download subframes (ROIs). Sub-frame size is equal to search region size."));
+ AddCtrl(CtrlMap, AD_cbUseSubFrames, m_pUseSubframes,
+ _("Check to only download subframes (ROIs). Sub-frame size is equal to search region size."));
// Pixel size
m_pPixelSize = NewSpinnerDouble(GetParentWindow(AD_szPixelSize), textWidth, m_pCamera->GetCameraPixelSize(), 0.0, 99.9, 0.1,
- _("Guide camera un-binned pixel size in microns. Used with the guide telescope focal length to display guiding error in arc-seconds."));
+ _("Guide camera un-binned pixel size in microns. Used with the guide telescope focal length to display guiding error "
+ "in arc-seconds."));
AddLabeledCtrl(CtrlMap, AD_szPixelSize, _("Pixel size"), m_pPixelSize, "");
// Gain control
@@ -896,13 +904,13 @@ CameraConfigDialogCtrlSet::CameraConfigDialogCtrlSet(wxWindow *pParent, GuideCam
wxStaticText *label = new wxStaticText(parent, wxID_ANY, _("Camera gain") + _(": "));
m_pCameraGain = NewSpinnerInt(parent, textWidth, 100, 0, 100, 1);
m_pCameraGain->SetToolTip(
- /* xgettext:no-c-format */ _("Camera gain, default = 95%, lower if you experience noise or wish to guide on a very bright star. Not available on all cameras."));
- m_resetGain = new wxButton(GetParentWindow(AD_szGain), wxID_ANY, _("Reset"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ /* xgettext:no-c-format */ _("Camera gain, default = 95%, lower if you experience noise or wish to guide on a very "
+ "bright star. Not available on all cameras."));
+ m_resetGain =
+ new wxButton(GetParentWindow(AD_szGain), wxID_ANY, _("Reset"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
m_resetGain->SetToolTip(_("Reset gain to camera's default value (disabled when camera is not connected)"));
- m_resetGain->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](wxCommandEvent& evt) {
- m_pCameraGain->SetValue(::pCamera->GetDefaultCameraGain());
- }
- );
+ m_resetGain->Bind(wxEVT_COMMAND_BUTTON_CLICKED,
+ [this](wxCommandEvent& evt) { m_pCameraGain->SetValue(::pCamera->GetDefaultCameraGain()); });
wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(label, wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL));
sizer->Add(m_pCameraGain, wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL));
@@ -914,8 +922,7 @@ CameraConfigDialogCtrlSet::CameraConfigDialogCtrlSet(wxWindow *pParent, GuideCam
wxArrayString opts;
m_pCamera->GetBinningOpts(&opts);
int width = StringArrayWidth(opts);
- m_binning = new wxChoice(GetParentWindow(AD_szBinning), wxID_ANY, wxDefaultPosition,
- wxSize(width + 35, -1), opts);
+ m_binning = new wxChoice(GetParentWindow(AD_szBinning), wxID_ANY, wxDefaultPosition, wxSize(width + 35, -1), opts);
AddLabeledCtrl(CtrlMap, AD_szBinning, _("Binning"), m_binning, _("Camera pixel binning"));
// Delay parameter
@@ -929,14 +936,30 @@ CameraConfigDialogCtrlSet::CameraConfigDialogCtrlSet(wxWindow *pParent, GuideCam
if (m_pCamera->HasPortNum)
{
wxString port_choices[] = {
- _T("Port 378"), _T("Port 3BC"), _T("Port 278"), _T("COM1"), _T("COM2"), _T("COM3"), _T("COM4"),
- _T("COM5"), _T("COM6"), _T("COM7"), _T("COM8"), _T("COM9"), _T("COM10"), _T("COM11"), _T("COM12"),
- _T("COM13"), _T("COM14"), _T("COM15"), _T("COM16"),
+ _T("Port 378"),
+ _T("Port 3BC"),
+ _T("Port 278"),
+ _T("COM1"),
+ _T("COM2"),
+ _T("COM3"),
+ _T("COM4"),
+ _T("COM5"),
+ _T("COM6"),
+ _T("COM7"),
+ _T("COM8"),
+ _T("COM9"),
+ _T("COM10"),
+ _T("COM11"),
+ _T("COM12"),
+ _T("COM13"),
+ _T("COM14"),
+ _T("COM15"),
+ _T("COM16"),
};
width = StringArrayWidth(port_choices, WXSIZEOF(port_choices));
- m_pPortNum = new wxChoice(GetParentWindow(AD_szPort), wxID_ANY, wxDefaultPosition,
- wxSize(width + 35, -1), WXSIZEOF(port_choices), port_choices);
+ m_pPortNum = new wxChoice(GetParentWindow(AD_szPort), wxID_ANY, wxDefaultPosition, wxSize(width + 35, -1),
+ WXSIZEOF(port_choices), port_choices);
AddLabeledCtrl(CtrlMap, AD_szPort, _("LE Port"), m_pPortNum, _("Port number for long-exposure control"));
}
@@ -954,19 +977,20 @@ CameraConfigDialogCtrlSet::CameraConfigDialogCtrlSet(wxWindow *pParent, GuideCam
width = StringWidth(_T("65535"));
parent = GetParentWindow(AD_szSaturationOptions);
m_camSaturationADU = new wxTextCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(1.5 * width, -1));
- m_camSaturationADU->SetToolTip(_("ADU level to determine saturation - 65535 for most 16-bit cameras, or 255 for 8-bit cameras."));
+ m_camSaturationADU->SetToolTip(
+ _("ADU level to determine saturation - 65535 for most 16-bit cameras, or 255 for 8-bit cameras."));
m_SaturationByADU = new wxRadioButton(parent, wxID_ANY, _("Saturation by Max-ADU value:"));
m_SaturationByADU->SetToolTip(_("Identify star saturation based on camera maximum-ADU value (recommended)"));
m_SaturationByADU->Bind(wxEVT_COMMAND_RADIOBUTTON_SELECTED, &CameraConfigDialogCtrlSet::OnSaturationChoiceChanged, this);
- wxStaticBoxSizer* szADUGroup = new wxStaticBoxSizer(wxHORIZONTAL, parent,
- wxEmptyString);
+ wxStaticBoxSizer *szADUGroup = new wxStaticBoxSizer(wxHORIZONTAL, parent, wxEmptyString);
szADUGroup->Add(m_SaturationByADU, wxSizerFlags().Border(wxTOP, 2));
szADUGroup->Add(m_camSaturationADU, wxSizerFlags().Border(wxLEFT, 6));
m_SaturationByProfile = new wxRadioButton(parent, wxID_ANY, _("Saturation via star-profile"));
m_SaturationByProfile->SetToolTip(_("Identify star saturation based on flat-topped profile, regardless of brightness"));
- m_SaturationByProfile->Bind(wxEVT_COMMAND_RADIOBUTTON_SELECTED, &CameraConfigDialogCtrlSet::OnSaturationChoiceChanged, this);
- wxFlexGridSizer* szSaturationGroup = new wxFlexGridSizer(1, 2, 5, 15);
+ m_SaturationByProfile->Bind(
+ wxEVT_COMMAND_RADIOBUTTON_SELECTED, &CameraConfigDialogCtrlSet::OnSaturationChoiceChanged, this);
+ wxFlexGridSizer *szSaturationGroup = new wxFlexGridSizer(1, 2, 5, 15);
szSaturationGroup->Add(szADUGroup, wxSizerFlags().Border(wxALL, 3).Align(wxALIGN_CENTER_VERTICAL));
szSaturationGroup->Add(m_SaturationByProfile, wxSizerFlags(0).Border(wxLEFT, 70).Expand().Align(wxALIGN_CENTER_VERTICAL));
@@ -976,7 +1000,8 @@ CameraConfigDialogCtrlSet::CameraConfigDialogCtrlSet(wxWindow *pParent, GuideCam
m_timeoutVal = NewSpinnerInt(GetParentWindow(AD_szCameraTimeout), textWidth, 5, 5, 9999, 1);
AddLabeledCtrl(CtrlMap, AD_szCameraTimeout, _("Disconnect nonresponsive \ncamera after (seconds)"), m_timeoutVal,
wxString::Format(_("The camera will be disconnected if it fails to respond for this long. "
- "The default value, %d seconds, should be appropriate for most cameras."), DefaultGuideCameraTimeoutMs / 1000));
+ "The default value, %d seconds, should be appropriate for most cameras."),
+ DefaultGuideCameraTimeoutMs / 1000));
}
void CameraConfigDialogCtrlSet::OnSaturationChoiceChanged(wxCommandEvent& event)
@@ -1070,52 +1095,52 @@ void CameraConfigDialogCtrlSet::LoadValues()
case 0x278:
m_pPortNum->SetSelection(2);
break;
- case 1: // COM1
+ case 1: // COM1
m_pPortNum->SetSelection(3);
break;
- case 2: // COM2
+ case 2: // COM2
m_pPortNum->SetSelection(4);
break;
- case 3: // COM3
+ case 3: // COM3
m_pPortNum->SetSelection(5);
break;
- case 4: // COM4
+ case 4: // COM4
m_pPortNum->SetSelection(6);
break;
- case 5: // COM5
+ case 5: // COM5
m_pPortNum->SetSelection(7);
break;
- case 6: // COM6
+ case 6: // COM6
m_pPortNum->SetSelection(8);
break;
- case 7: // COM7
+ case 7: // COM7
m_pPortNum->SetSelection(9);
break;
- case 8: // COM8
+ case 8: // COM8
m_pPortNum->SetSelection(10);
break;
- case 9: // COM9
+ case 9: // COM9
m_pPortNum->SetSelection(11);
break;
- case 10: // COM10
+ case 10: // COM10
m_pPortNum->SetSelection(12);
break;
- case 11: // COM11
+ case 11: // COM11
m_pPortNum->SetSelection(13);
break;
- case 12: // COM12
+ case 12: // COM12
m_pPortNum->SetSelection(14);
break;
- case 13: // COM13
+ case 13: // COM13
m_pPortNum->SetSelection(15);
break;
- case 14: // COM14
+ case 14: // COM14
m_pPortNum->SetSelection(16);
break;
- case 15: // COM15
+ case 15: // COM15
m_pPortNum->SetSelection(17);
break;
- case 16: // COM16
+ case 16: // COM16
m_pPortNum->SetSelection(18);
break;
default:
@@ -1127,13 +1152,13 @@ void CameraConfigDialogCtrlSet::LoadValues()
}
double pxSize;
- if (m_pCamera->GetDevicePixelSize(&pxSize)) // true=>error
+ if (m_pCamera->GetDevicePixelSize(&pxSize)) // true=>error
{
pxSize = m_pCamera->GetCameraPixelSize();
m_pPixelSize->Enable(!pFrame->CaptureActive);
}
else
- m_pPixelSize->Enable(false); // Got a device-level pixel size, disable the control
+ m_pPixelSize->Enable(false); // Got a device-level pixel size, disable the control
m_pPixelSize->SetValue(pxSize);
@@ -1158,7 +1183,7 @@ void CameraConfigDialogCtrlSet::LoadValues()
{
setpt = pConfig->Profile.GetDouble("/camera/CoolerSetpt", 10.0);
}
- m_coolerSetpt->SetValue((int)floor(setpt));
+ m_coolerSetpt->SetValue((int) floor(setpt));
}
m_coolerOn->Enable(ok);
@@ -1312,15 +1337,12 @@ wxString GuideCamera::GetSettingsSummary()
else
pixelSizeStr = wxString::Format(_("%0.1f um"), m_pixelSize);
- return wxString::Format("Camera = %s%s%s%s, full size = %d x %d, %s, %s, pixel size = %s\n",
- Name,
- HasGainControl ? wxString::Format(", gain = %d", GuideCameraGain) : "",
- HasDelayParam ? wxString::Format(", delay = %d", ReadDelay) : "",
- HasPortNum ? wxString::Format(", port = 0x%hx", Port) : "",
- FullSize.GetWidth(), FullSize.GetHeight(),
- darkDur ? wxString::Format("have dark, dark dur = %d", darkDur) : "no dark",
- CurrentDefectMap ? "defect map in use" : "no defect map",
- pixelSizeStr);
+ return wxString::Format("Camera = %s%s%s%s, full size = %d x %d, %s, %s, pixel size = %s\n", Name,
+ HasGainControl ? wxString::Format(", gain = %d", GuideCameraGain) : "",
+ HasDelayParam ? wxString::Format(", delay = %d", ReadDelay) : "",
+ HasPortNum ? wxString::Format(", port = 0x%hx", Port) : "", FullSize.GetWidth(), FullSize.GetHeight(),
+ darkDur ? wxString::Format("have dark, dark dur = %d", darkDur) : "no dark",
+ CurrentDefectMap ? "defect map in use" : "no defect map", pixelSizeStr);
}
void GuideCamera::AddDark(usImage *dark)
@@ -1455,21 +1477,21 @@ void GuideCamera::DisconnectWithAlert(CaptureFailType type)
break;
case CAPT_FAIL_TIMEOUT:
- {
- wxString msg;
- // Dark library exposure times won't match the selected exposure time in the pull-down menu of the main window
- if (!ShutterClosed)
- msg = (wxString::Format(_("After %.1f sec the camera has not completed a %.1f sec exposure, so "
- "it has been disconnected to prevent other problems. Refer to Trouble-shooting section of Help."),
- (pFrame->RequestedExposureDuration() + m_timeoutMs) / 1000.,
- pFrame->RequestedExposureDuration() / 1000.));
- else
- msg = _("The camera has not completed an exposure in at least 15 seconds, so "
- "it has been disconnected to prevent other problems. Refer to Trouble-shooting section of Help.");
+ {
+ wxString msg;
+ // Dark library exposure times won't match the selected exposure time in the pull-down menu of the main window
+ if (!ShutterClosed)
+ msg = (wxString::Format(
+ _("After %.1f sec the camera has not completed a %.1f sec exposure, so "
+ "it has been disconnected to prevent other problems. Refer to Trouble-shooting section of Help."),
+ (pFrame->RequestedExposureDuration() + m_timeoutMs) / 1000., pFrame->RequestedExposureDuration() / 1000.));
+ else
+ msg = _("The camera has not completed an exposure in at least 15 seconds, so "
+ "it has been disconnected to prevent other problems. Refer to Trouble-shooting section of Help.");
- DisconnectWithAlert(msg, RECONNECT);
- }
- break;
+ DisconnectWithAlert(msg, RECONNECT);
+ }
+ break;
}
}
@@ -1490,13 +1512,12 @@ void GuideCamera::DisconnectWithAlert(const wxString& msg, ReconnectType reconne
}
else
{
- pFrame->Alert(msg + "\n" + _("The camera has been disconnected. Please resolve the problem and re-connect the camera."));
+ pFrame->Alert(
+ msg + "\n" + _("The camera has been disconnected. Please resolve the problem and re-connect the camera."));
}
}
-void GuideCamera::InitCapture()
-{
-}
+void GuideCamera::InitCapture() { }
bool GuideCamera::Capture(GuideCamera *camera, int duration, usImage& img, int captureOptions, const wxRect& subframe)
{
diff --git a/src/camera.h b/src/camera.h
index d980c5fe0..3aadf7173 100644
--- a/src/camera.h
+++ b/src/camera.h
@@ -41,7 +41,7 @@ class DefectMap;
enum PropDlgType
{
PROPDLG_NONE = 0,
- PROPDLG_WHEN_CONNECTED = (1 << 0), // property dialog available when connected
+ PROPDLG_WHEN_CONNECTED = (1 << 0), // property dialog available when connected
PROPDLG_WHEN_DISCONNECTED = (1 << 1), // property dialog available when disconnected
PROPDLG_ANY = (PROPDLG_WHEN_CONNECTED | PROPDLG_WHEN_DISCONNECTED),
};
@@ -68,7 +68,7 @@ class CameraConfigDialogCtrlSet : public ConfigDialogCtrlSet
wxSpinCtrl *m_pCameraGain;
wxButton *m_resetGain;
wxSpinCtrl *m_timeoutVal;
- wxChoice *m_pPortNum;
+ wxChoice *m_pPortNum;
wxSpinCtrl *m_pDelay;
wxSpinCtrlDouble *m_pPixelSize;
wxChoice *m_binning;
@@ -81,7 +81,8 @@ class CameraConfigDialogCtrlSet : public ConfigDialogCtrlSet
int m_prevBinning;
public:
- CameraConfigDialogCtrlSet(wxWindow *pParent, GuideCamera *pCamera, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
+ CameraConfigDialogCtrlSet(
+ wxWindow *pParent, GuideCamera *pCamera, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
virtual ~CameraConfigDialogCtrlSet() {};
virtual void LoadValues();
virtual void UnloadValues();
@@ -96,7 +97,7 @@ class CameraConfigDialogCtrlSet : public ConfigDialogCtrlSet
enum CaptureOptionBits
{
CAPTURE_SUBTRACT_DARK = 1 << 0,
- CAPTURE_RECON = 1 << 1, // debayer and/or deinterlace as required
+ CAPTURE_RECON = 1 << 1, // debayer and/or deinterlace as required
CAPTURE_LIGHT = CAPTURE_SUBTRACT_DARK | CAPTURE_RECON,
CAPTURE_DARK = 0,
@@ -108,40 +109,39 @@ class GuideCamera : public wxMessageBoxProxy, public OnboardST4
friend class CameraConfigDialogPane;
friend class CameraConfigDialogCtrlSet;
- double m_pixelSize;
+ double m_pixelSize;
protected:
- bool m_hasGuideOutput;
- int m_timeoutMs;
- bool m_saturationByADU;
- unsigned short m_saturationADU;
+ bool m_hasGuideOutput;
+ int m_timeoutMs;
+ bool m_saturationByADU;
+ unsigned short m_saturationADU;
public:
-
static const double UnknownPixelSize;
- int GuideCameraGain;
- wxString Name; // User-friendly name
- wxSize FullSize; // Size of current image
- bool Connected;
- PropDlgType PropertyDialogType;
- bool HasPortNum;
- bool HasDelayParam;
- bool HasGainControl;
- bool HasShutter;
- bool HasSubframes;
- wxByte MaxBinning;
- wxByte Binning;
- short Port;
- int ReadDelay;
- bool ShutterClosed; // false=light, true=dark
- bool UseSubframes;
- bool HasCooler;
+ int GuideCameraGain;
+ wxString Name; // User-friendly name
+ wxSize FullSize; // Size of current image
+ bool Connected;
+ PropDlgType PropertyDialogType;
+ bool HasPortNum;
+ bool HasDelayParam;
+ bool HasGainControl;
+ bool HasShutter;
+ bool HasSubframes;
+ wxByte MaxBinning;
+ wxByte Binning;
+ short Port;
+ int ReadDelay;
+ bool ShutterClosed; // false=light, true=dark
+ bool UseSubframes;
+ bool HasCooler;
wxCriticalSection DarkFrameLock; // dark frames can be accessed in the main thread or the camera worker thread
- usImage *CurrentDarkFrame;
- ExposureImgMap Darks; // map exposure => dark frame
- DefectMap *CurrentDefectMap;
+ usImage *CurrentDarkFrame;
+ ExposureImgMap Darks; // map exposure => dark frame
+ DefectMap *CurrentDefectMap;
static wxArrayString GuideCameraList();
static GuideCamera *Factory(const wxString& choice);
@@ -153,7 +153,10 @@ class GuideCamera : public wxMessageBoxProxy, public OnboardST4
virtual wxByte BitsPerPixel() = 0;
static bool Capture(GuideCamera *camera, int duration, usImage& img, int captureOptions, const wxRect& subframe);
- static bool Capture(GuideCamera *camera, int duration, usImage& img, int captureOptions) { return Capture(camera, duration, img, captureOptions, wxRect(0, 0, 0, 0)); }
+ static bool Capture(GuideCamera *camera, int duration, usImage& img, int captureOptions)
+ {
+ return Capture(camera, duration, img, captureOptions, wxRect(0, 0, 0, 0));
+ }
virtual bool CanSelectCamera() const { return false; }
virtual bool HandleSelectCameraButtonClick(wxCommandEvent& evt);
@@ -162,41 +165,42 @@ class GuideCamera : public wxMessageBoxProxy, public OnboardST4
// Opens up and connects to camera. cameraId identifies which camera to connect to if
// there is more than one camera present
- virtual bool Connect(const wxString& cameraId) = 0;
- virtual bool Disconnect() = 0; // Disconnects, unloading any DLLs loaded by Connect
- virtual void InitCapture(); // Gets run at the start of any loop (e.g., reset stream, set gain, etc).
+ virtual bool Connect(const wxString& cameraId) = 0;
+ virtual bool Disconnect() = 0; // Disconnects, unloading any DLLs loaded by Connect
+ virtual void InitCapture(); // Gets run at the start of any loop (e.g., reset stream, set gain, etc).
- virtual bool ST4HasGuideOutput();
- virtual bool ST4HostConnected();
- virtual bool ST4HasNonGuiMove();
- virtual bool ST4PulseGuideScope(int direction, int duration);
+ virtual bool ST4HasGuideOutput();
+ virtual bool ST4HostConnected();
+ virtual bool ST4HasNonGuiMove();
+ virtual bool ST4PulseGuideScope(int direction, int duration);
CameraConfigDialogPane *GetConfigDialogPane(wxWindow *pParent);
- CameraConfigDialogCtrlSet *GetConfigDlgCtrlSet(wxWindow *pParent, GuideCamera *pCamera, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
+ CameraConfigDialogCtrlSet *GetConfigDlgCtrlSet(
+ wxWindow *pParent, GuideCamera *pCamera, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
static void GetBinningOpts(int maxBin, wxArrayString *opts);
void GetBinningOpts(wxArrayString *opts);
bool SetBinning(int binning);
- virtual void ShowPropertyDialog() { return; }
- bool SetCameraPixelSize(double pixel_size);
- double GetCameraPixelSize() const;
- virtual bool GetDevicePixelSize(double *devPixelSize); // Value from device/driver or error return
+ virtual void ShowPropertyDialog() { return; }
+ bool SetCameraPixelSize(double pixel_size);
+ double GetCameraPixelSize() const;
+ virtual bool GetDevicePixelSize(double *devPixelSize); // Value from device/driver or error return
- virtual bool SetCoolerOn(bool on);
- virtual bool SetCoolerSetpoint(double temperature);
- virtual bool GetCoolerStatus(bool *on, double *setpoint, double *power, double *temperature);
- virtual bool GetSensorTemperature(double *temperature);
+ virtual bool SetCoolerOn(bool on);
+ virtual bool SetCoolerSetpoint(double temperature);
+ virtual bool GetCoolerStatus(bool *on, double *setpoint, double *power, double *temperature);
+ virtual bool GetSensorTemperature(double *temperature);
virtual wxString GetSettingsSummary();
- void AddDark(usImage *dark);
- void SelectDark(int exposureDuration);
- void SetDefectMap(DefectMap *newMap);
- void ClearDefectMap();
- void ClearDarks();
+ void AddDark(usImage *dark);
+ void SelectDark(int exposureDuration);
+ void SetDefectMap(DefectMap *newMap);
+ void ClearDefectMap();
+ void ClearDarks();
- void SubtractDark(usImage& img);
- void GetDarklibProperties(int *pNumDarks, double *pMinExp, double *pMaxExp);
+ void SubtractDark(usImage& img);
+ void GetDarklibProperties(int *pNumDarks, double *pMinExp, double *pMaxExp);
virtual const wxSize& DarkFrameSize() { return FullSize; }
@@ -213,17 +217,18 @@ class GuideCamera : public wxMessageBoxProxy, public OnboardST4
virtual bool Capture(int duration, usImage& img, int captureOptions, const wxRect& subframe) = 0;
protected:
-
int GetTimeoutMs() const;
void SetTimeoutMs(int timeoutMs);
static bool CamConnectFailed(const wxString& errorMessage);
- enum CaptureFailType {
+ enum CaptureFailType
+ {
CAPT_FAIL_MEMORY,
CAPT_FAIL_TIMEOUT,
};
- enum ReconnectType {
+ enum ReconnectType
+ {
NO_RECONNECT,
RECONNECT,
};
@@ -248,7 +253,7 @@ inline double GuideCamera::GetCameraPixelSize() const
inline bool GuideCamera::GetDevicePixelSize(double *devPixelSize)
{
- return true; // Return an error, the device/driver can't report pixel size
+ return true; // Return an error, the device/driver can't report pixel size
}
inline bool GuideCamera::IsSaturationByADU() const
diff --git a/src/cameras.h b/src/cameras.h
index 2bc48b16c..e3ee6ec4b 100644
--- a/src/cameras.h
+++ b/src/cameras.h
@@ -39,108 +39,108 @@
to detect or package this
*/
-#if defined(__WINDOWS__)
+# if defined(__WINDOWS__)
// Windows cameras
-# define ALTAIR
-# define ASCOM_CAMERA
-# define ATIK16
-# define ATIK_GEN3
-# define INDI_CAMERA
-# define INOVA_PLC
-# define IOPTRON_CAMERA
-# define LE_CAMERA
-# define LE_LXUSB_CAMERA
-# define LE_PARALLEL_CAMERA
-# define LE_SERIAL_CAMERA
-# define MORAVIAN_CAMERA
-# define OGMA_CAMERA
-# define OPENCV_CAMERA
-# define ORION_DSCI
-# define QGUIDE
-# define QHY_CAMERA
-# define SBIG
-# define SBIGROTATOR_CAMERA
-# define SIMULATOR
-# define SSPIAG
-# define SVB_CAMERA
-# define SXV
-# define TOUPTEK_CAMERA
-# define WDM_CAMERA
-# define ZWO_ASI
-
-//# define OS_PL130 // the Opticstar library is not yet included
-//# define FIREWIRE_CAMERA // the The Imaging Source library is not yet included
-
-# ifdef HAVE_WXVIDCAP // These need wxVidCapLib, which needs to be built-up separately. The LE-webcams could go to WDM
-# define VFW_CAMERA
-# endif
-
-#elif defined(__APPLE__)
-// Mac cameras
-# ifdef HAVE_FIREWIRE_CAMERA
-# define FIREWIRE_CAMERA
-# endif
-# define INDI_CAMERA
-# ifdef HAVE_KWIQGUIDER_CAMERA
-# define KWIQGUIDER_CAMERA
-# endif
-# ifdef HAVE_OGMA_CAMERA
+# define ALTAIR
+# define ASCOM_CAMERA
+# define ATIK16
+# define ATIK_GEN3
+# define INDI_CAMERA
+# define INOVA_PLC
+# define IOPTRON_CAMERA
+# define LE_CAMERA
+# define LE_LXUSB_CAMERA
+# define LE_PARALLEL_CAMERA
+# define LE_SERIAL_CAMERA
+# define MORAVIAN_CAMERA
# define OGMA_CAMERA
-# endif
-# ifdef HAVE_OPENSSAG_CAMERA
-# define OPENSSAG_CAMERA
-# endif
-# ifdef HAVE_QHY_CAMERA
+# define OPENCV_CAMERA
+# define ORION_DSCI
+# define QGUIDE
# define QHY_CAMERA
-# endif
-# ifdef HAVE_SBIG_CAMERA
# define SBIG
-# endif
-# define SIMULATOR
-# ifdef HAVE_SXV_CAMERA
+# define SBIGROTATOR_CAMERA
+# define SIMULATOR
+# define SSPIAG
+# define SVB_CAMERA
# define SXV
-# endif
-# ifdef HAVE_TOUPTEK_CAMERA
# define TOUPTEK_CAMERA
-# endif
-#ifdef HAVE_ZWO_CAMERA
-# define ZWO_ASI
-#endif
-#ifdef HAVE_SVB_CAMERA
-# define SVB_CAMERA
-#endif
+# define WDM_CAMERA
+# define ZWO_ASI
-#elif defined (__linux__) || defined (__FreeBSD__)
+// # define OS_PL130 // the Opticstar library is not yet included
+// # define FIREWIRE_CAMERA // the The Imaging Source library is not yet included
-# define SIMULATOR
-# define OPENCV_CAMERA
-# define CAM_QHY5
-# ifdef HAVE_OGMA_CAMERA
-# define OGMA_CAMERA
-# endif
-# ifdef HAVE_QHY_CAMERA
-# define QHY_CAMERA
-# endif
-# define INDI_CAMERA
-# ifdef HAVE_ZWO_CAMERA
-# define ZWO_ASI
-# endif
-# ifdef HAVE_TOUPTEK_CAMERA
-# define TOUPTEK_CAMERA
-# endif
-# ifdef HAVE_SXV_CAMERA
-# define SXV
-# endif
-# ifdef HAVE_SBIG_CAMERA
+# ifdef HAVE_WXVIDCAP // These need wxVidCapLib, which needs to be built-up separately. The LE-webcams could go to WDM
+# define VFW_CAMERA
+# endif
+
+# elif defined(__APPLE__)
+// Mac cameras
+# ifdef HAVE_FIREWIRE_CAMERA
+# define FIREWIRE_CAMERA
+# endif
+# define INDI_CAMERA
+# ifdef HAVE_KWIQGUIDER_CAMERA
+# define KWIQGUIDER_CAMERA
+# endif
+# ifdef HAVE_OGMA_CAMERA
+# define OGMA_CAMERA
+# endif
+# ifdef HAVE_OPENSSAG_CAMERA
+# define OPENSSAG_CAMERA
+# endif
+# ifdef HAVE_QHY_CAMERA
+# define QHY_CAMERA
+# endif
+# ifdef HAVE_SBIG_CAMERA
# define SBIG
-# endif
-# ifdef HAVE_SVB_CAMERA
+# endif
+# define SIMULATOR
+# ifdef HAVE_SXV_CAMERA
+# define SXV
+# endif
+# ifdef HAVE_TOUPTEK_CAMERA
+# define TOUPTEK_CAMERA
+# endif
+# ifdef HAVE_ZWO_CAMERA
+# define ZWO_ASI
+# endif
+# ifdef HAVE_SVB_CAMERA
# define SVB_CAMERA
-# endif
+# endif
+
+# elif defined(__linux__) || defined(__FreeBSD__)
+
+# define SIMULATOR
+# define OPENCV_CAMERA
+# define CAM_QHY5
+# ifdef HAVE_OGMA_CAMERA
+# define OGMA_CAMERA
+# endif
+# ifdef HAVE_QHY_CAMERA
+# define QHY_CAMERA
+# endif
+# define INDI_CAMERA
+# ifdef HAVE_ZWO_CAMERA
+# define ZWO_ASI
+# endif
+# ifdef HAVE_TOUPTEK_CAMERA
+# define TOUPTEK_CAMERA
+# endif
+# ifdef HAVE_SXV_CAMERA
+# define SXV
+# endif
+# ifdef HAVE_SBIG_CAMERA
+# define SBIG
+# endif
+# ifdef HAVE_SVB_CAMERA
+# define SVB_CAMERA
+# endif
// this should work ... needs testing
-//# define OPENSSAG
+// # define OPENSSAG
-#endif
+# endif
// Currently unused
// #define NEB_SBIG // This is for an on-hold project that would get the guide chip data from an SBIG connected in Neb
diff --git a/src/circbuf.h b/src/circbuf.h
index 167abb39b..440bb77dd 100644
--- a/src/circbuf.h
+++ b/src/circbuf.h
@@ -46,20 +46,43 @@ class circular_buffer
unsigned int m_tail;
unsigned int m_size;
unsigned int m_capacity;
+
public:
class iterator
{
friend class circular_buffer;
circular_buffer& m_cb;
unsigned int m_pos;
- iterator(circular_buffer& cb, unsigned int pos) : m_cb(cb), m_pos(pos) { }
+ iterator(circular_buffer& cb, unsigned int pos)
+ : m_cb(cb)
+ , m_pos(pos)
+ {
+ }
+
public:
- iterator& operator++() { ++m_pos; return *this; }
- iterator operator++(int) { iterator it(*this); m_pos++; return it; }
- bool operator==(const iterator& rhs) const { assert(&m_cb == &rhs.m_cb); return m_pos == rhs.m_pos; }
- bool operator!=(const iterator& rhs) const { assert(&m_cb == &rhs.m_cb); return m_pos != rhs.m_pos; }
+ iterator& operator++()
+ {
+ ++m_pos;
+ return *this;
+ }
+ iterator operator++(int)
+ {
+ iterator it(*this);
+ m_pos++;
+ return it;
+ }
+ bool operator==(const iterator& rhs) const
+ {
+ assert(&m_cb == &rhs.m_cb);
+ return m_pos == rhs.m_pos;
+ }
+ bool operator!=(const iterator& rhs) const
+ {
+ assert(&m_cb == &rhs.m_cb);
+ return m_pos != rhs.m_pos;
+ }
T& operator*() const { return m_cb.m_ary[m_pos % m_cb.m_capacity]; }
- T* operator->() const { return &m_cb.m_ary[m_pos % m_cb.m_capacity]; }
+ T *operator->() const { return &m_cb.m_ary[m_pos % m_cb.m_capacity]; }
};
friend class circular_buffer::iterator;
circular_buffer();
@@ -78,21 +101,21 @@ class circular_buffer
template
circular_buffer::circular_buffer()
- : m_ary(0),
- m_head(0),
- m_tail(0),
- m_size(0),
- m_capacity(0)
+ : m_ary(0)
+ , m_head(0)
+ , m_tail(0)
+ , m_size(0)
+ , m_capacity(0)
{
}
template
circular_buffer::circular_buffer(unsigned int capacity)
- : m_ary(new T[capacity]),
- m_head(0),
- m_tail(0),
- m_size(0),
- m_capacity(capacity)
+ : m_ary(new T[capacity])
+ , m_head(0)
+ , m_tail(0)
+ , m_size(0)
+ , m_capacity(capacity)
{
assert(capacity > 0);
}
@@ -100,7 +123,7 @@ circular_buffer::circular_buffer(unsigned int capacity)
template
circular_buffer::~circular_buffer()
{
- delete [] m_ary;
+ delete[] m_ary;
}
template
diff --git a/src/comdispatch.cpp b/src/comdispatch.cpp
index 773268b20..32cf54398 100644
--- a/src/comdispatch.cpp
+++ b/src/comdispatch.cpp
@@ -37,8 +37,8 @@
// windows only ASCOM helper code
#if defined(__WINDOWS__)
-#include "comdispatch.h"
-#include
+# include "comdispatch.h"
+# include
wxString ExcepMsg(const EXCEPINFO& excep)
{
@@ -124,20 +124,20 @@ bool DispatchClass::dispid_cached(DISPID *ret, IDispatch *idisp, OLECHAR *wname,
}
DispatchObj::DispatchObj()
- : m_class(0),
- m_idisp(0)
+ : m_class(0)
+ , m_idisp(0)
{
}
DispatchObj::DispatchObj(DispatchClass *cls)
- : m_class(cls),
- m_idisp(0)
+ : m_class(cls)
+ , m_idisp(0)
{
}
DispatchObj::DispatchObj(IDispatch *idisp, DispatchClass *cls)
- : m_class(cls),
- m_idisp(idisp)
+ : m_class(cls)
+ , m_idisp(idisp)
{
if (m_idisp)
m_idisp->AddRef();
@@ -164,7 +164,7 @@ bool DispatchObj::Create(OLECHAR *progid)
return false;
IDispatch *idisp;
HRESULT hr;
- if (FAILED(hr = CoCreateInstance(clsid, NULL, CLSCTX_SERVER, IID_IDispatch, (LPVOID *)&idisp)))
+ if (FAILED(hr = CoCreateInstance(clsid, NULL, CLSCTX_SERVER, IID_IDispatch, (LPVOID *) &idisp)))
{
Debug.AddLine(wxString::Format("CoCreateInstance: [%x] %s", hr, _com_error(hr).ErrorMessage()));
return false;
@@ -365,7 +365,8 @@ bool DispatchObj::InvokeMethod(Variant *res, OLECHAR *name)
}
GITEntry::GITEntry()
- : m_pIGlobalInterfaceTable(0), m_dwCookie(0)
+ : m_pIGlobalInterfaceTable(0)
+ , m_dwCookie(0)
{
}
@@ -381,7 +382,7 @@ void GITEntry::Register(IDispatch *idisp)
// first find the global table
HRESULT hr;
if (FAILED(hr = ::CoCreateInstance(CLSID_StdGlobalInterfaceTable, NULL, CLSCTX_INPROC_SERVER, IID_IGlobalInterfaceTable,
- (void **)&m_pIGlobalInterfaceTable)))
+ (void **) &m_pIGlobalInterfaceTable)))
{
Debug.AddLine(wxString::Format("create global interface table: [%x] %s", hr, _com_error(hr).ErrorMessage()));
throw ERROR_INFO("Cannot CoCreateInstance of Global Interface Table");
diff --git a/src/comdispatch.h b/src/comdispatch.h
index 8bc8c23e7..d378fc598 100644
--- a/src/comdispatch.h
+++ b/src/comdispatch.h
@@ -49,6 +49,7 @@ struct Variant : public VARIANT
class ExcepInfo : public EXCEPINFO
{
ExcepInfo& operator=(const ExcepInfo& rhs) = delete;
+
public:
ExcepInfo();
~ExcepInfo();
@@ -62,6 +63,7 @@ class DispatchClass
{
typedef std::map idmap_t;
idmap_t m_idmap;
+
public:
DispatchClass() { }
~DispatchClass() { }
@@ -74,6 +76,7 @@ class DispatchObj
DispatchClass *m_class;
IDispatch *m_idisp;
ExcepInfo m_excep;
+
public:
DispatchObj();
DispatchObj(DispatchClass *cls);
@@ -103,6 +106,7 @@ class GITEntry
{
IGlobalInterfaceTable *m_pIGlobalInterfaceTable;
DWORD m_dwCookie;
+
public:
GITEntry();
~GITEntry();
@@ -114,17 +118,14 @@ class GITEntry
{
IDispatch *idisp = 0;
if (m_dwCookie)
- m_pIGlobalInterfaceTable->GetInterfaceFromGlobal(m_dwCookie, IID_IDispatch, (LPVOID *)&idisp);
+ m_pIGlobalInterfaceTable->GetInterfaceFromGlobal(m_dwCookie, IID_IDispatch, (LPVOID *) &idisp);
return idisp;
}
};
struct GITObjRef : public DispatchObj
{
- GITObjRef(const GITEntry& gitentry)
- {
- Attach(gitentry.Get(), 0);
- }
+ GITObjRef(const GITEntry& gitentry) { Attach(gitentry.Get(), 0); }
};
#endif
diff --git a/src/comet_tool.cpp b/src/comet_tool.cpp
index f3c135335..231bb2d9a 100644
--- a/src/comet_tool.cpp
+++ b/src/comet_tool.cpp
@@ -81,34 +81,38 @@ static wxString TITLE_TRAINING = wxTRANSLATE("Comet Tracking - Training Active")
static wxString TITLE_ACTIVE = wxTRANSLATE("Comet Tracking - Active");
CometToolWin::CometToolWin()
- : wxDialog(pFrame, wxID_ANY, wxGetTranslation(TITLE), wxPoint(-1,-1), wxSize(300,300)),
- m_training(false),
- m_timer(this)
+ : wxDialog(pFrame, wxID_ANY, wxGetTranslation(TITLE), wxPoint(-1, -1), wxSize(300, 300))
+ , m_training(false)
+ , m_timer(this)
{
- SetSizeHints( wxDefaultSize, wxDefaultSize );
+ SetSizeHints(wxDefaultSize, wxDefaultSize);
m_enable = new wxToggleButton(this, wxID_ANY, _("Enable"), wxDefaultPosition, wxDefaultSize, 0);
m_enable->SetToolTip(_("Toggle comet tracking on or off."));
- m_xLabel = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(20,-1), wxALIGN_RIGHT);
+ m_xLabel = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(20, -1), wxALIGN_RIGHT);
m_xLabel->Wrap(-1);
m_yLabel = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(20, -1), wxALIGN_RIGHT);
m_yLabel->Wrap(-1);
- m_xRate = new wxSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -5000., +5000., 0., 1.);
+ m_xRate = new wxSpinCtrlDouble(
+ this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -5000., +5000., 0., 1.);
m_xRate->SetToolTip(_("Comet tracking rate"));
- m_yRate = new wxSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -5000., +5000., 0., 1.);
+ m_yRate = new wxSpinCtrlDouble(
+ this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, -5000., +5000., 0., 1.);
m_yRate->SetToolTip(_("Comet tracking rate"));
wxString m_unitsChoices[] = { _("Pixels/hr"), _("Arcsec/hr") };
int m_unitsNChoices = sizeof(m_unitsChoices) / sizeof(wxString);
- m_units = new wxRadioBox(this, wxID_ANY, _("Units"), wxDefaultPosition, wxDefaultSize, m_unitsNChoices, m_unitsChoices, 1, wxRA_SPECIFY_ROWS);
+ m_units = new wxRadioBox(
+ this, wxID_ANY, _("Units"), wxDefaultPosition, wxDefaultSize, m_unitsNChoices, m_unitsChoices, 1, wxRA_SPECIFY_ROWS);
m_units->SetSelection(1);
m_units->SetToolTip(_("Tracking rate units"));
wxString m_axesChoices[] = { _("Camera (X/Y)"), _("Mount (RA/Dec)") };
int m_axesNChoices = sizeof(m_axesChoices) / sizeof(wxString);
- m_axes = new wxRadioBox(this, wxID_ANY, _("Axes"), wxDefaultPosition, wxDefaultSize, m_axesNChoices, m_axesChoices, 1, wxRA_SPECIFY_ROWS);
+ m_axes = new wxRadioBox(
+ this, wxID_ANY, _("Axes"), wxDefaultPosition, wxDefaultSize, m_axesNChoices, m_axesChoices, 1, wxRA_SPECIFY_ROWS);
m_axes->SetSelection(1);
m_axes->SetToolTip(_("Tracking rate axes"));
@@ -118,20 +122,21 @@ CometToolWin::CometToolWin()
m_stop->SetToolTip(_("Stop training"));
m_stop->Enable(false);
- // Use a text ctrl for status, wxStaticText flickers. Adding the wxTE_NO_VSCROLL style also causes the control to flicker on Windows 7.
+ // Use a text ctrl for status, wxStaticText flickers. Adding the wxTE_NO_VSCROLL style also causes the control to flicker on
+ // Windows 7.
long style = wxSTATIC_BORDER | wxTE_MULTILINE /*| wxTE_NO_VSCROLL*/;
m_status = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(400, 60), style);
m_status->Enable(false);
wxBoxSizer *xSizer = new wxBoxSizer(wxHORIZONTAL);
xSizer->Add(0, 0, 1, wxEXPAND, 5);
- xSizer->Add(m_xLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
- xSizer->Add(m_xRate, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+ xSizer->Add(m_xLabel, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
+ xSizer->Add(m_xRate, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
xSizer->Add(0, 0, 1, wxEXPAND, 5);
wxBoxSizer *ySizer = new wxBoxSizer(wxHORIZONTAL);
ySizer->Add(0, 0, 1, wxEXPAND, 5);
- ySizer->Add(m_yLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+ ySizer->Add(m_yLabel, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
ySizer->Add(m_yRate, 0, wxALL, 5);
ySizer->Add(0, 0, 1, wxEXPAND, 5);
@@ -152,7 +157,7 @@ CometToolWin::CometToolWin()
trainingSizer->Add(m_status, 0, wxALL, 5);
wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
- topSizer->Add(m_enable, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5);
+ topSizer->Add(m_enable, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 5);
topSizer->Add(ratesSizer, 1, wxEXPAND, 5);
topSizer->Add(trainingSizer, 0, wxEXPAND, 5);
@@ -188,7 +193,7 @@ CometToolWin::~CometToolWin(void)
pFrame->pCometTool = 0;
}
-static void SetEnabledState(CometToolWin* win, bool active)
+static void SetEnabledState(CometToolWin *win, bool active)
{
if (active)
{
@@ -294,14 +299,14 @@ void CometToolWin::UpdateStatus()
if (m_training)
{
m_status->SetValue(wxString::Format(_("Training, elapsed time %lus.\nUse the "
- "\"Adjust Lock Position\" controls to center the comet\nin the imaging "
- "camera and click Stop to complete training."),
- (long)((::wxGetUTCTimeMillis().GetValue() - m_startTime) / 1000)));
+ "\"Adjust Lock Position\" controls to center the comet\nin the imaging "
+ "camera and click Stop to complete training."),
+ (long) ((::wxGetUTCTimeMillis().GetValue() - m_startTime) / 1000)));
}
else
{
m_status->SetValue(_("Center the comet in the imaging camera.\nSelect a guide "
- "star and start Guiding.\nThen, click Start to begin training."));
+ "star and start Guiding.\nThen, click Start to begin training."));
}
}
diff --git a/src/config_indi.cpp b/src/config_indi.cpp
index 0d3a9e790..f14f0b7ad 100644
--- a/src/config_indi.cpp
+++ b/src/config_indi.cpp
@@ -40,16 +40,16 @@
#include "camera.h"
#include "scope.h"
-#if defined (INDI_CAMERA) || defined (GUIDE_INDI)
+#if defined(INDI_CAMERA) || defined(GUIDE_INDI)
-#include "config_indi.h"
+# include "config_indi.h"
-#include
-#include
-#include
-#include
-#include
-#include
+# include
+# include
+# include
+# include
+# include
+# include
enum
{
@@ -60,18 +60,17 @@ enum
FORCEVIDEO = 105,
};
-#define POS(r, c) wxGBPosition(r,c)
-#define SPAN(r, c) wxGBSpan(r,c)
+# define POS(r, c) wxGBPosition(r, c)
+# define SPAN(r, c) wxGBSpan(r, c)
bool INDIConfig::s_verbose;
INDIConfig::INDIConfig(wxWindow *parent, const wxString& title, IndiDevType devtype)
- :
- wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
- m_gui(nullptr),
- dev_type(devtype)
+ : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+ , m_gui(nullptr)
+ , dev_type(devtype)
{
- auto sizerLabelFlags = wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL;
+ auto sizerLabelFlags = wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL;
auto sizerButtonFlags = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL;
auto sizerSectionFlags = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL;
auto sizerTextFlags = wxALIGN_LEFT | wxALL | wxEXPAND;
@@ -82,18 +81,15 @@ INDIConfig::INDIConfig(wxWindow *parent, const wxString& title, IndiDevType devt
wxBoxSizer *sizer;
pos = 0;
- gbs->Add(new wxStaticText(this, wxID_ANY, _("INDI Server")),
- POS(pos, 0), SPAN(1, 1), sizerSectionFlags, border);
+ gbs->Add(new wxStaticText(this, wxID_ANY, _("INDI Server")), POS(pos, 0), SPAN(1, 1), sizerSectionFlags, border);
++pos;
- gbs->Add(new wxStaticText(this, wxID_ANY, _("Hostname")),
- POS(pos, 0), SPAN(1, 1), sizerLabelFlags, border);
+ gbs->Add(new wxStaticText(this, wxID_ANY, _("Hostname")), POS(pos, 0), SPAN(1, 1), sizerLabelFlags, border);
host = new wxTextCtrl(this, wxID_ANY);
gbs->Add(host, POS(pos, 1), SPAN(1, 1), sizerTextFlags, border);
++pos;
- gbs->Add(new wxStaticText(this, wxID_ANY, _("Port")),
- POS(pos, 0), SPAN(1, 1), sizerLabelFlags, border);
+ gbs->Add(new wxStaticText(this, wxID_ANY, _("Port")), POS(pos, 0), SPAN(1, 1), sizerLabelFlags, border);
port = new wxTextCtrl(this, wxID_ANY);
gbs->Add(port, POS(pos, 1), SPAN(1, 1), sizerTextFlags, border);
@@ -104,8 +100,7 @@ INDIConfig::INDIConfig(wxWindow *parent, const wxString& title, IndiDevType devt
gbs->Add(connect, POS(pos, 1), SPAN(1, 1), sizerButtonFlags, border);
++pos;
- gbs->Add(new wxStaticText(this, wxID_ANY, _T("========")),
- POS(pos, 0), SPAN(1, 1), wxALIGN_LEFT | wxALL, border);
+ gbs->Add(new wxStaticText(this, wxID_ANY, _T("========")), POS(pos, 0), SPAN(1, 1), wxALIGN_LEFT | wxALL, border);
devlabel = new wxStaticText(this, wxID_ANY, _("Device"));
if (dev_type == INDI_TYPE_CAMERA)
@@ -122,8 +117,7 @@ INDIConfig::INDIConfig(wxWindow *parent, const wxString& title, IndiDevType devt
gbs->Add(devlabel, POS(pos, 1), SPAN(1, 1), wxALIGN_LEFT | wxALL, border);
++pos;
- gbs->Add(new wxStaticText(this, wxID_ANY, _("Driver")),
- POS(pos, 0), SPAN(1, 1), sizerLabelFlags, border);
+ gbs->Add(new wxStaticText(this, wxID_ANY, _("Driver")), POS(pos, 0), SPAN(1, 1), sizerLabelFlags, border);
dev = new wxComboBox(this, MDEV, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY);
gbs->Add(dev, POS(pos, 1), SPAN(1, 1), sizerTextFlags, border);
@@ -131,8 +125,7 @@ INDIConfig::INDIConfig(wxWindow *parent, const wxString& title, IndiDevType devt
if (dev_type == INDI_TYPE_CAMERA)
{
++pos;
- gbs->Add(new wxStaticText(this, wxID_ANY, _("Dual CCD")),
- POS(pos, 0), SPAN(1, 1), sizerLabelFlags, border);
+ gbs->Add(new wxStaticText(this, wxID_ANY, _("Dual CCD")), POS(pos, 0), SPAN(1, 1), sizerLabelFlags, border);
ccd = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY);
gbs->Add(ccd, POS(pos, 1), SPAN(1, 1), sizerTextFlags, border);
}
@@ -143,19 +136,18 @@ INDIConfig::INDIConfig(wxWindow *parent, const wxString& title, IndiDevType devt
{
++pos;
forcevideo = new wxCheckBox(this, FORCEVIDEO, _("Camera does not support exposure time"));
- forcevideo->SetToolTip(
- _("Force the use of streaming and frame stacking for cameras that do not support setting an absolute exposure time."));
- gbs->Add(forcevideo, POS(pos, 0), SPAN(1, 2), sizerTextFlags, border);
+ forcevideo->SetToolTip(_("Force the use of streaming and frame stacking for cameras that do not support setting an "
+ "absolute exposure time."));
+ gbs->Add(forcevideo, POS(pos, 0), SPAN(1, 2), sizerTextFlags, border);
++pos;
forceexposure = new wxCheckBox(this, wxID_ANY, _("Camera does not support streaming"));
forceexposure->SetToolTip(_("Force the use of exposure time for cameras that do not support streaming."));
- gbs->Add(forceexposure, POS(pos, 0), SPAN(1, 2), sizerTextFlags, border);
+ gbs->Add(forceexposure, POS(pos, 0), SPAN(1, 2), sizerTextFlags, border);
}
++pos;
- gbs->Add(new wxStaticText(this, wxID_ANY, _("Other options")),
- POS(pos, 0), SPAN(1, 1), sizerLabelFlags, border);
+ gbs->Add(new wxStaticText(this, wxID_ANY, _("Other options")), POS(pos, 0), SPAN(1, 1), sizerLabelFlags, border);
guiBtn = new wxButton(this, MINDIGUI, _("INDI"));
gbs->Add(guiBtn, POS(pos, 1), SPAN(1, 1), sizerButtonFlags, border);
@@ -377,9 +369,9 @@ static wxString formatInterface(unsigned int ifs)
wxString s;
-#define F(t) \
- if (ifs & INDI::BaseDevice:: t ## _INTERFACE) \
- _append(s, #t)
+# define F(t) \
+ if (ifs & INDI::BaseDevice::t##_INTERFACE) \
+ _append(s, #t)
F(TELESCOPE);
F(CCD);
@@ -394,7 +386,7 @@ static wxString formatInterface(unsigned int ifs)
F(LIGHTBOX);
F(AUX);
-#undef F
+# undef F
return s;
}
@@ -424,11 +416,11 @@ void INDIConfig::newProperty(INDI::Property property)
if (!include)
{
Debug.Write(wxString::Format("exclude device %s not a valid %s\n", devname,
- dev_type == INDI_TYPE_CAMERA ? "camera" :
- dev_type == INDI_TYPE_MOUNT ? "mount" :
- dev_type == INDI_TYPE_AUX_MOUNT ? "aux mount" :
- dev_type == INDI_TYPE_AO ? "AO" :
- "rotator"));
+ dev_type == INDI_TYPE_CAMERA ? "camera"
+ : dev_type == INDI_TYPE_MOUNT ? "mount"
+ : dev_type == INDI_TYPE_AUX_MOUNT ? "aux mount"
+ : dev_type == INDI_TYPE_AO ? "AO"
+ : "rotator"));
int n = dev->FindString(devname, true);
if (n != wxNOT_FOUND)
diff --git a/src/config_indi.h b/src/config_indi.h
index 99eff7309..0b2f96875 100644
--- a/src/config_indi.h
+++ b/src/config_indi.h
@@ -57,65 +57,62 @@ enum IndiDevType
class INDIConfig : public wxDialog, public INDI::BaseClient
{
- static bool s_verbose;
-
- wxTextCtrl *host;
- wxTextCtrl *port;
- wxButton *connect;
- wxStaticText *connect_status;
- wxStaticText *devlabel;
- wxComboBox *dev;
- wxComboBox *ccd;
- wxCheckBox *forcevideo;
- wxCheckBox *forceexposure;
- wxButton *guiBtn;
- wxButton *okBtn;
-
- IndiGui *m_gui;
- IndiDevType dev_type;
-
- public:
-
- INDIConfig(wxWindow *parent, const wxString& title, IndiDevType devtype);
- ~INDIConfig();
-
- long INDIport;
- wxString INDIhost;
- wxString INDIDevName;
- long INDIDevCCD;
- bool INDIForceVideo;
- bool INDIForceExposure;
-
- void Connect();
- void Disconnect();
- void SetSettings();
- void SaveSettings();
-
- static void LoadProfileSettings();
- static bool Verbose();
- static void SetVerbose(bool val);
-
- void OnUpdateFromThread(wxThreadEvent& event);
-
- protected:
-
- void newDevice(INDI::BaseDevice dp) override;
- void removeDevice(INDI::BaseDevice dp) override {};
- void newProperty(INDI::Property property) override;
- void removeProperty(INDI::Property property) override {}
- void serverConnected() override;
- void serverDisconnected(int exit_code) override;
-
- private:
-
- void OnConnectButton(wxCommandEvent& evt);
- void OnIndiGui(wxCommandEvent& evt);
- void OnDevSelected(wxCommandEvent& evt);
- void OnVerboseChecked(wxCommandEvent& evt);
- void OnForceVideoChecked(wxCommandEvent& evt);
- void UpdateControlStates();
-
- wxDECLARE_EVENT_TABLE();
+ static bool s_verbose;
+
+ wxTextCtrl *host;
+ wxTextCtrl *port;
+ wxButton *connect;
+ wxStaticText *connect_status;
+ wxStaticText *devlabel;
+ wxComboBox *dev;
+ wxComboBox *ccd;
+ wxCheckBox *forcevideo;
+ wxCheckBox *forceexposure;
+ wxButton *guiBtn;
+ wxButton *okBtn;
+
+ IndiGui *m_gui;
+ IndiDevType dev_type;
+
+public:
+ INDIConfig(wxWindow *parent, const wxString& title, IndiDevType devtype);
+ ~INDIConfig();
+
+ long INDIport;
+ wxString INDIhost;
+ wxString INDIDevName;
+ long INDIDevCCD;
+ bool INDIForceVideo;
+ bool INDIForceExposure;
+
+ void Connect();
+ void Disconnect();
+ void SetSettings();
+ void SaveSettings();
+
+ static void LoadProfileSettings();
+ static bool Verbose();
+ static void SetVerbose(bool val);
+
+ void OnUpdateFromThread(wxThreadEvent& event);
+
+protected:
+ void newDevice(INDI::BaseDevice dp) override;
+ void removeDevice(INDI::BaseDevice dp) override {};
+ void newProperty(INDI::Property property) override;
+ void removeProperty(INDI::Property property) override { }
+ void serverConnected() override;
+ void serverDisconnected(int exit_code) override;
+
+private:
+ void OnConnectButton(wxCommandEvent& evt);
+ void OnIndiGui(wxCommandEvent& evt);
+ void OnDevSelected(wxCommandEvent& evt);
+ void OnVerboseChecked(wxCommandEvent& evt);
+ void OnForceVideoChecked(wxCommandEvent& evt);
+ void UpdateControlStates();
+
+ wxDECLARE_EVENT_TABLE();
};
inline bool INDIConfig::Verbose()
diff --git a/src/configdialog.cpp b/src/configdialog.cpp
index 54a68a363..d36e2926c 100644
--- a/src/configdialog.cpp
+++ b/src/configdialog.cpp
@@ -42,12 +42,12 @@ ConfigDialogPane::ConfigDialogPane(const wxString& heading, wxWindow *pParent)
void ConfigDialogPane::DoAdd(wxSizer *pSizer)
{
- this->Add(pSizer, wxSizerFlags().Expand().Border(wxALL,3));
+ this->Add(pSizer, wxSizerFlags().Expand().Border(wxALL, 3));
}
void ConfigDialogPane::DoAdd(wxWindow *pWindow)
{
- this->Add(pWindow, wxSizerFlags().Expand().Border(wxALL,3));
+ this->Add(pWindow, wxSizerFlags().Expand().Border(wxALL, 3));
}
void ConfigDialogPane::DoAdd(wxWindow *pWindow, const wxString& toolTip)
@@ -56,7 +56,8 @@ void ConfigDialogPane::DoAdd(wxWindow *pWindow, const wxString& toolTip)
DoAdd(pWindow);
}
-wxSizer *ConfigDialogPane::MakeLabeledControl(const wxString& label, wxWindow *pControl, const wxString& toolTip, wxWindow *pControl2)
+wxSizer *ConfigDialogPane::MakeLabeledControl(
+ const wxString& label, wxWindow *pControl, const wxString& toolTip, wxWindow *pControl2)
{
wxStaticText *pLabel = new wxStaticText(m_pParent, wxID_ANY, label + _(": "));
pControl->SetToolTip(toolTip);
@@ -88,7 +89,7 @@ int ConfigDialogPane::StringArrayWidth(wxString string[], int nElements)
{
int width = 0;
- for(int i=0;isecond.isPositioned = true;
}
- return ctrl; // May return null but client can use CondAddCtrl
+ return ctrl; // May return null but client can use CondAddCtrl
}
-// Handle the case where a control is not created because of state. wxWidgets handles a null window correctly in 'Add' but the behavior
-// is technically undocumented.
+// Handle the case where a control is not created because of state. wxWidgets handles a null window correctly in 'Add' but the
+// behavior is technically undocumented.
void ConfigDialogPane::CondAddCtrl(wxSizer *szr, BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, const wxSizerFlags& flags)
{
wxWindow *ctrl = GetSingleCtrl(CtrlMap, id);
@@ -139,7 +139,7 @@ wxSizer *ConfigDialogPane::GetSizerCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS
if (ctrl)
it->second.isPositioned = true;
}
- return ctrl; // May return null, won't add entry in CtrlMap
+ return ctrl; // May return null, won't add entry in CtrlMap
}
void ConfigDialogPane::OnImageScaleChange()
@@ -152,7 +152,7 @@ void ConfigDialogPane::EnableDecControls(bool enable)
// Do nothing by default - subclasses will override if needed
}
-ConfigDialogCtrlSet::ConfigDialogCtrlSet(wxWindow *pParent, AdvancedDialog* pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
+ConfigDialogCtrlSet::ConfigDialogCtrlSet(wxWindow *pParent, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
{
m_pParent = pParent;
m_pAdvDlg = pAdvancedDialog;
@@ -231,7 +231,8 @@ void ConfigDialogCtrlSet::AddGroup(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, w
AddMapElement(CtrlMap, id, pSizer);
}
-wxSizer *ConfigDialogCtrlSet::MakeLabeledControl(BRAIN_CTRL_IDS id, const wxString& label, wxWindow *pControl, const wxString& toolTip)
+wxSizer *ConfigDialogCtrlSet::MakeLabeledControl(
+ BRAIN_CTRL_IDS id, const wxString& label, wxWindow *pControl, const wxString& toolTip)
{
wxStaticText *pLabel = new wxStaticText(GetParentWindow(id), wxID_ANY, label + _(": "));
pControl->SetToolTip(toolTip);
@@ -243,7 +244,8 @@ wxSizer *ConfigDialogCtrlSet::MakeLabeledControl(BRAIN_CTRL_IDS id, const wxStri
return pSizer;
}
-void ConfigDialogCtrlSet::AddLabeledCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, const wxString& Label, wxControl *pCtrl, const wxString& toolTip)
+void ConfigDialogCtrlSet::AddLabeledCtrl(
+ BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, const wxString& Label, wxControl *pCtrl, const wxString& toolTip)
{
AddGroup(CtrlMap, id, MakeLabeledControl(id, Label, pCtrl, toolTip));
}
diff --git a/src/configdialog.h b/src/configdialog.h
index 59f9610b8..c1239530d 100644
--- a/src/configdialog.h
+++ b/src/configdialog.h
@@ -35,12 +35,14 @@
#ifndef CONFIG_DIALOG_H_INCLUDED
#define CONFIG_DIALOG_H_INCLUDED
-// Design Notes: The goal here is to separate the ownership of various controls from where they are displayed in the AD. A class that "owns" a control
-// will create it and handle all its behavior - loading, unloading, all the semantics. This part is handled by the ConfigDlgControlSet. Where those controls
-// are displayed is determined by the BrainIDControlMap, a dictionary that maps the control ids to the AD panel where they will be displayed. The owner of the
-// AD panel - the "host" - is responsible for creating the panel UI and rendering all the controls that belong on that panel. This will be handled in the
-// LayoutControls() method of the hosting class. Beyond that, the host class has no involvement with controls that are owned by a different class.
-// Example: the focal length control (AD_szFocalLength) is owned by MyFrame but is displayed on the guiding tab
+// Design Notes: The goal here is to separate the ownership of various controls from where they are displayed in the AD. A
+// class that "owns" a control will create it and handle all its behavior - loading, unloading, all the semantics. This part is
+// handled by the ConfigDlgControlSet. Where those controls are displayed is determined by the BrainIDControlMap, a dictionary
+// that maps the control ids to the AD panel where they will be displayed. The owner of the AD panel - the "host" - is
+// responsible for creating the panel UI and rendering all the controls that belong on that panel. This will be handled in the
+// LayoutControls() method of the hosting class. Beyond that, the host class has no involvement with controls that are owned by
+// a different class. Example: the focal length control (AD_szFocalLength) is owned by MyFrame but is displayed on the guiding
+// tab
// Segmented by the tab page location seen in the UI
// "sz" => element is a sizer
@@ -56,7 +58,7 @@ enum BRAIN_CTRL_IDS
AD_cbEnableImageLogging,
AD_szImageLoggingOptions,
AD_szDither,
- AD_GLOBAL_TAB_BOUNDARY, //-----end of global tab controls
+ AD_GLOBAL_TAB_BOUNDARY, //-----end of global tab controls
AD_cbUseSubFrames,
AD_szNoiseReduction,
@@ -71,7 +73,7 @@ enum BRAIN_CTRL_IDS
AD_szPort,
AD_szBinning,
AD_szCooler,
- AD_CAMERA_TAB_BOUNDARY, // ------ end of camera tab controls
+ AD_CAMERA_TAB_BOUNDARY, // ------ end of camera tab controls
AD_cbScaleImages,
AD_szFocalLength,
@@ -86,13 +88,13 @@ enum BRAIN_CTRL_IDS
AD_cbSlewDetection,
AD_cbUseDecComp,
AD_cbBeepForLostStar,
- AD_GUIDER_TAB_BOUNDARY, // --------------- end of guiding tab controls
+ AD_GUIDER_TAB_BOUNDARY, // --------------- end of guiding tab controls
AD_szBLCompCtrls,
AD_szMaxRAAmt,
AD_szMaxDecAmt,
AD_szDecGuideMode,
- AD_MOUNT_TAB_BOUNDARY, // ----------- end of mount tab controls
+ AD_MOUNT_TAB_BOUNDARY, // ----------- end of mount tab controls
AD_AOTravel,
AD_szCalStepsPerIteration,
@@ -104,25 +106,23 @@ enum BRAIN_CTRL_IDS
AD_cbClearAOCalibration,
AD_cbEnableAOGuiding,
AD_cbRotatorReverse,
- AD_DEVICES_TAB_BOUNDARY // ----------- end of devices tab controls
+ AD_DEVICES_TAB_BOUNDARY // ----------- end of devices tab controls
};
struct BrainCtrlInfo
{
wxObject *panelCtrl;
- bool isPositioned; // debug only
+ bool isPositioned; // debug only
BrainCtrlInfo()
- :
- panelCtrl(0),
- isPositioned(false)
+ : panelCtrl(0)
+ , isPositioned(false)
{
}
BrainCtrlInfo(BRAIN_CTRL_IDS id, wxObject *ctrl)
- :
- panelCtrl(ctrl),
- isPositioned(false)
+ : panelCtrl(ctrl)
+ , isPositioned(false)
{
}
};
@@ -133,6 +133,7 @@ class ConfigDialogPane : public wxStaticBoxSizer
{
protected:
wxWindow *m_pParent;
+
public:
ConfigDialogPane(const wxString& heading, wxWindow *pParent);
virtual ~ConfigDialogPane(void) {};
@@ -144,11 +145,13 @@ class ConfigDialogPane : public wxStaticBoxSizer
wxWindow *GetSingleCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id);
wxSizer *GetSizerCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id);
void CondAddCtrl(wxSizer *szr, BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, const wxSizerFlags& flags = 0);
- virtual void OnImageScaleChange(); // Only for adjustments made within the AD panels
- virtual void EnableDecControls(bool enable); // Needed for guide algo ConfigDialogPanes which inherit directly from this class
+ virtual void OnImageScaleChange(); // Only for adjustments made within the AD panels
+ virtual void EnableDecControls(
+ bool enable); // Needed for guide algo ConfigDialogPanes which inherit directly from this class
protected:
- wxSizer *MakeLabeledControl(const wxString& label, wxWindow *pControl, const wxString& toolTip, wxWindow *pControl2 = nullptr);
+ wxSizer *MakeLabeledControl(
+ const wxString& label, wxWindow *pControl, const wxString& toolTip, wxWindow *pControl2 = nullptr);
void DoAdd(wxSizer *pSizer);
void DoAdd(wxWindow *pWindow);
void DoAdd(wxWindow *pWindow, const wxString& toolTip);
@@ -177,10 +180,11 @@ class ConfigDialogCtrlSet
public:
wxSizer *MakeLabeledControl(BRAIN_CTRL_IDS id, const wxString& label, wxWindow *pControl, const wxString& toolTip);
void AddMapElement(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS, wxObject *pElem);
- void AddGroup(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, wxSizer *pSizer); // Sizer
- void AddCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, wxControl *pCtrl); // Bare control
- void AddLabeledCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, const wxString& Label, wxControl *pCtrl, const wxString& toolTip);
- void AddCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, wxControl *pCtrl, const wxString& toolTip); // Control with tooltip
+ void AddGroup(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, wxSizer *pSizer); // Sizer
+ void AddCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, wxControl *pCtrl); // Bare control
+ void AddLabeledCtrl(
+ BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, const wxString& Label, wxControl *pCtrl, const wxString& toolTip);
+ void AddCtrl(BrainCtrlIdMap& CtrlMap, BRAIN_CTRL_IDS id, wxControl *pCtrl, const wxString& toolTip); // Control with tooltip
wxWindow *GetParentWindow(BRAIN_CTRL_IDS id);
diff --git a/src/confirm_dialog.cpp b/src/confirm_dialog.cpp
index 88237a7cd..8ba67d98f 100644
--- a/src/confirm_dialog.cpp
+++ b/src/confirm_dialog.cpp
@@ -34,7 +34,8 @@
#include "phd.h"
-ConfirmDialog::ConfirmDialog(const wxString& prompt, const wxString& title, const wxString& affirmLabel, const wxString& negativeLabel)
+ConfirmDialog::ConfirmDialog(
+ const wxString& prompt, const wxString& title, const wxString& affirmLabel, const wxString& negativeLabel)
: wxDialog(pFrame, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
dont_ask_again = new wxCheckBox(this, wxID_ANY, _("Don't ask again"));
@@ -60,16 +61,15 @@ ConfirmDialog::ConfirmDialog(const wxString& prompt, const wxString& title, cons
SetSizerAndFit(topLevelSizer);
}
-ConfirmDialog::~ConfirmDialog(void)
-{
-}
+ConfirmDialog::~ConfirmDialog(void) { }
static wxString ConfigKey(const wxString& name)
{
return "/Confirm" + name;
}
-bool ConfirmDialog::Confirm(const wxString& prompt, const wxString& config_key, const wxString& affirmLabel, const wxString& negativeLabel, const wxString& title_arg)
+bool ConfirmDialog::Confirm(const wxString& prompt, const wxString& config_key, const wxString& affirmLabel,
+ const wxString& negativeLabel, const wxString& title_arg)
{
wxString key(ConfigKey(config_key));
diff --git a/src/confirm_dialog.h b/src/confirm_dialog.h
index e538e7335..9356477fa 100644
--- a/src/confirm_dialog.h
+++ b/src/confirm_dialog.h
@@ -35,15 +35,16 @@
#ifndef CONFIRM_DIALOG_H_INCLUDED
#define CONFIRM_DIALOG_H_INCLUDED
-class ConfirmDialog :
- public wxDialog
+class ConfirmDialog : public wxDialog
{
public:
- ConfirmDialog(const wxString& prompt, const wxString& title, const wxString& affirmativeLabel, const wxString& negativeLabel);
+ ConfirmDialog(
+ const wxString& prompt, const wxString& title, const wxString& affirmativeLabel, const wxString& negativeLabel);
~ConfirmDialog(void);
static bool Confirm(const wxString& prompt, const wxString& config_key, const wxString& title = "");
- static bool Confirm(const wxString& prompt, const wxString& config_key, const wxString& affirmativeLabel, const wxString& negativeLabel, const wxString& title = "");
+ static bool Confirm(const wxString& prompt, const wxString& config_key, const wxString& affirmativeLabel,
+ const wxString& negativeLabel, const wxString& title = "");
static void ResetAllDontAskAgain(void);
private:
diff --git a/src/darks_dialog.cpp b/src/darks_dialog.cpp
index 0e5859c8f..a6f95d8c0 100644
--- a/src/darks_dialog.cpp
+++ b/src/darks_dialog.cpp
@@ -44,7 +44,7 @@ static const int DefDarkCount = 5;
static const int DefDMExpTime = 15;
static const int DefDMCount = 25;
-static const int MaxNoteLength = 65; // For now
+static const int MaxNoteLength = 65; // For now
// Utility function to add the pairs to a flexgrid
static void AddTableEntryPair(wxWindow *parent, wxFlexGridSizer *pTable, const wxString& label, wxWindow *pControl)
@@ -54,10 +54,11 @@ static void AddTableEntryPair(wxWindow *parent, wxFlexGridSizer *pTable, const w
pTable->Add(pControl, 1, wxALL, 5);
}
-static wxSpinCtrl *NewSpinnerInt(wxWindow *parent, const wxSize& size, int val, int minval, int maxval, int inc,
- const wxString& tooltip)
+static wxSpinCtrl *NewSpinnerInt(
+ wxWindow *parent, const wxSize& size, int val, int minval, int maxval, int inc, const wxString& tooltip)
{
- wxSpinCtrl *pNewCtrl = pFrame->MakeSpinCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, size, wxSP_ARROW_KEYS, minval, maxval, val, _("Exposure time"));
+ wxSpinCtrl *pNewCtrl = pFrame->MakeSpinCtrl(
+ parent, wxID_ANY, wxEmptyString, wxDefaultPosition, size, wxSP_ARROW_KEYS, minval, maxval, val, _("Exposure time"));
pNewCtrl->SetValue(val);
pNewCtrl->SetToolTip(tooltip);
return pNewCtrl;
@@ -89,8 +90,8 @@ static wxString MaxExposureDefault()
// Dialog operates in one of two modes: 1) To create a user-requested dark library or 2) To create a master dark frame
// and associated data files needed to construct a new defect map
-DarksDialog::DarksDialog(wxWindow *parent, bool darkLib) :
- wxDialog(parent, wxID_ANY, _("Build Dark Library"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
+DarksDialog::DarksDialog(wxWindow *parent, bool darkLib)
+ : wxDialog(parent, wxID_ANY, _("Build Dark Library"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
buildDarkLib = darkLib;
if (!buildDarkLib)
@@ -105,22 +106,25 @@ DarksDialog::DarksDialog(wxWindow *parent, bool darkLib) :
wxStaticBoxSizer *pDarkGroup = new wxStaticBoxSizer(wxVERTICAL, this, _("Dark Library"));
wxFlexGridSizer *pDarkParams = new wxFlexGridSizer(2, 4, 5, 15);
- m_pDarkMinExpTime = new wxComboBox(this, BUTTON_DURATION, wxEmptyString, wxDefaultPosition, wxDefaultSize,
- m_expStrings, wxCB_READONLY);
+ m_pDarkMinExpTime =
+ new wxComboBox(this, BUTTON_DURATION, wxEmptyString, wxDefaultPosition, wxDefaultSize, m_expStrings, wxCB_READONLY);
AddTableEntryPair(this, pDarkParams, _("Min Exposure Time"), m_pDarkMinExpTime);
m_pDarkMinExpTime->SetValue(pConfig->Profile.GetString("/camera/darks_min_exptime", MinExposureDefault()));
- m_pDarkMinExpTime->SetToolTip(_("Minimum exposure time for darks. Choose a value corresponding to the shortest camera exposure you will use for guiding."));
+ m_pDarkMinExpTime->SetToolTip(_("Minimum exposure time for darks. Choose a value corresponding to the shortest camera "
+ "exposure you will use for guiding."));
- m_pDarkMaxExpTime = new wxComboBox(this, BUTTON_DURATION, wxEmptyString, wxDefaultPosition, wxDefaultSize,
- m_expStrings, wxCB_READONLY);
+ m_pDarkMaxExpTime =
+ new wxComboBox(this, BUTTON_DURATION, wxEmptyString, wxDefaultPosition, wxDefaultSize, m_expStrings, wxCB_READONLY);
AddTableEntryPair(this, pDarkParams, _("Max Exposure Time"), m_pDarkMaxExpTime);
m_pDarkMaxExpTime->SetValue(pConfig->Profile.GetString("/camera/darks_max_exptime", MaxExposureDefault()));
- m_pDarkMaxExpTime->SetToolTip(_("Maximum exposure time for darks. Choose a value corresponding to the longest camera exposure you will use for guiding."));
+ m_pDarkMaxExpTime->SetToolTip(_("Maximum exposure time for darks. Choose a value corresponding to the longest camera "
+ "exposure you will use for guiding."));
- m_pDarkCount = NewSpinnerInt(this, pFrame->GetTextExtent("9999"), pConfig->Profile.GetInt("/camera/darks_num_frames", DefDarkCount),
- 1, 20, 1, _("Number of dark frames for each exposure time"));
+ m_pDarkCount = NewSpinnerInt(this, pFrame->GetTextExtent("9999"),
+ pConfig->Profile.GetInt("/camera/darks_num_frames", DefDarkCount), 1, 20, 1,
+ _("Number of dark frames for each exposure time"));
AddTableEntryPair(this, pDarkParams, _("Frames to take for each \n exposure time"), m_pDarkCount);
pDarkGroup->Add(pDarkParams, wxSizerFlags().Border(wxALL, 10));
pvSizer->Add(pDarkGroup, wxSizerFlags().Border(wxALL, 10).Expand());
@@ -129,11 +133,14 @@ DarksDialog::DarksDialog(wxWindow *parent, bool darkLib) :
wxBoxSizer *hSizer = new wxBoxSizer(wxHORIZONTAL);
wxStaticText *pInfo = new wxStaticText(this, wxID_ANY, wxEmptyString, wxPoint(-1, -1), wxSize(-1, -1));
m_rbModifyDarkLib = new wxRadioButton(this, wxID_ANY, _("Modify/extend existing dark library"));
- m_rbModifyDarkLib->SetToolTip(_("Darks created now will replace older darks having matching exposure times. If different exposure times are used, "
+ m_rbModifyDarkLib->SetToolTip(_(
+ "Darks created now will replace older darks having matching exposure times. If different exposure times are used, "
"those darks will be added to the library."));
m_rbNewDarkLib = new wxRadioButton(this, wxID_ANY, _("Create entirely new dark library"));
- m_rbNewDarkLib->SetToolTip(_("Darks created now will be used to build a completely new dark library - old dark frames will be discarded. You "
- " MUST use this option if you've seen alert messages about incompatible frame sizes or mismatches with the current camera."));
+ m_rbNewDarkLib->SetToolTip(
+ _("Darks created now will be used to build a completely new dark library - old dark frames will be discarded. You "
+ " MUST use this option if you've seen alert messages about incompatible frame sizes or mismatches with the "
+ "current camera."));
if (pFrame->DarkLibExists(pConfig->GetCurrentProfileId(), false))
{
if (pFrame->LoadDarkHandler(true))
@@ -141,8 +148,9 @@ DarksDialog::DarksDialog(wxWindow *parent, bool darkLib) :
double min_v, max_v;
int num;
pCamera->GetDarklibProperties(&num, &min_v, &max_v);
- pInfo->SetLabel(wxString::Format(_("Existing dark library covers %d exposure times in the range of %g s to %g s"),
- num, min_v / 1000., max_v / 1000.));
+ pInfo->SetLabel(
+ wxString::Format(_("Existing dark library covers %d exposure times in the range of %g s to %g s"), num,
+ min_v / 1000., max_v / 1000.));
m_rbModifyDarkLib->SetValue(true);
}
else
@@ -170,11 +178,13 @@ DarksDialog::DarksDialog(wxWindow *parent, bool darkLib) :
// Defect map controls
wxStaticBoxSizer *pDMapGroup = new wxStaticBoxSizer(wxVERTICAL, this, _("Dark Frame Settings"));
wxFlexGridSizer *pDMapParams = new wxFlexGridSizer(2, 4, 5, 15);
- m_pDefectExpTime = NewSpinnerInt(this, pFrame->GetTextExtent("9999"), pConfig->Profile.GetInt("/camera/dmap_exptime", DefDMExpTime),
- 5, 15, 1, _("Exposure time for building defect map"));
+ m_pDefectExpTime =
+ NewSpinnerInt(this, pFrame->GetTextExtent("9999"), pConfig->Profile.GetInt("/camera/dmap_exptime", DefDMExpTime), 5,
+ 15, 1, _("Exposure time for building defect map"));
AddTableEntryPair(this, pDMapParams, _("Exposure Time"), m_pDefectExpTime);
- m_pNumDefExposures = NewSpinnerInt(this, pFrame->GetTextExtent("9999"), pConfig->Profile.GetInt("/camera/dmap_num_frames", DefDMCount),
- 5, 25, 1, _("Number of exposures for building defect map"));
+ m_pNumDefExposures =
+ NewSpinnerInt(this, pFrame->GetTextExtent("9999"), pConfig->Profile.GetInt("/camera/dmap_num_frames", DefDMCount),
+ 5, 25, 1, _("Number of exposures for building defect map"));
AddTableEntryPair(this, pDMapParams, _("Number of Exposures"), m_pNumDefExposures);
pDMapGroup->Add(pDMapParams, wxSizerFlags().Border(wxALL, 10));
pvSizer->Add(pDMapGroup, wxSizerFlags().Border(wxALL, 10));
@@ -182,7 +192,7 @@ DarksDialog::DarksDialog(wxWindow *parent, bool darkLib) :
// Controls for notes and status
wxBoxSizer *phSizer = new wxBoxSizer(wxHORIZONTAL);
- wxStaticText *pNoteLabel = new wxStaticText(this, wxID_ANY, _("Notes: "), wxPoint(-1, -1), wxSize(-1, -1));
+ wxStaticText *pNoteLabel = new wxStaticText(this, wxID_ANY, _("Notes: "), wxPoint(-1, -1), wxSize(-1, -1));
wxSize sz(38 * StringWidth(this, "M"), -1);
m_pNotes = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, sz);
m_pNotes->SetToolTip(_("Free-form note, included in FITs header for each dark frame; max length=65"));
@@ -198,7 +208,7 @@ DarksDialog::DarksDialog(wxWindow *parent, bool darkLib) :
pvSizer->Add(m_pProgress, wxSizerFlags().Border(wxLEFT, 60));
// Buttons
- wxBoxSizer *pButtonSizer = new wxBoxSizer( wxHORIZONTAL );
+ wxBoxSizer *pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
m_pResetBtn = new wxButton(this, wxID_ANY, _("Reset"));
m_pResetBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DarksDialog::OnReset, this);
m_pResetBtn->SetToolTip(_("Reset all parameters to application defaults"));
@@ -211,15 +221,9 @@ DarksDialog::DarksDialog(wxWindow *parent, bool darkLib) :
m_pStopBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DarksDialog::OnStop, this);
m_pStopBtn->SetToolTip("");
- pButtonSizer->Add(
- m_pResetBtn,
- wxSizerFlags(0).Align(0).Border(wxALL, 10));
- pButtonSizer->Add(
- m_pStartBtn,
- wxSizerFlags(0).Align(0).Border(wxALL, 10));
- pButtonSizer->Add(
- m_pStopBtn,
- wxSizerFlags(0).Align(0).Border(wxALL, 10));
+ pButtonSizer->Add(m_pResetBtn, wxSizerFlags(0).Align(0).Border(wxALL, 10));
+ pButtonSizer->Add(m_pStartBtn, wxSizerFlags(0).Align(0).Border(wxALL, 10));
+ pButtonSizer->Add(m_pStopBtn, wxSizerFlags(0).Align(0).Border(wxALL, 10));
pvSizer->Add(pButtonSizer, wxSizerFlags().Center().Border(wxALL, 10));
// status bar
@@ -229,7 +233,7 @@ DarksDialog::DarksDialog(wxWindow *parent, bool darkLib) :
pvSizer->Add(m_pStatusBar, 0, wxGROW);
SetAutoLayout(true);
- SetSizerAndFit (pvSizer);
+ SetSizerAndFit(pvSizer);
m_cancelling = false;
m_started = false;
@@ -270,16 +274,16 @@ void DarksDialog::OnStart(wxCommandEvent& evt)
tot_dur += exposureDurations[i] * darkFrameCount;
m_pProgress->SetRange(tot_dur);
- if (m_rbNewDarkLib->GetValue()) // User rebuilding from scratch
+ if (m_rbNewDarkLib->GetValue()) // User rebuilding from scratch
pCamera->ClearDarks();
for (int inx = minExpInx; inx <= maxExpInx; inx++)
{
int darkExpTime = exposureDurations[inx];
if (darkExpTime >= 1000)
- ShowStatus (wxString::Format(_("Building master dark at %.1f sec:"), (double)darkExpTime / 1000.0), false);
+ ShowStatus(wxString::Format(_("Building master dark at %.1f sec:"), (double) darkExpTime / 1000.0), false);
else
- ShowStatus (wxString::Format(_("Building master dark at %d mSec:"), darkExpTime), false);
+ ShowStatus(wxString::Format(_("Building master dark at %d mSec:"), darkExpTime), false);
usImage *newDark = new usImage();
err = CreateMasterDarkFrame(*newDark, exposureDurations[inx], darkFrameCount);
wxYield();
@@ -296,7 +300,9 @@ void DarksDialog::OnStart(wxCommandEvent& evt)
if (m_cancelling || err)
{
- ShowStatus(m_cancelling ? _("Operation cancelled - no changes have been made") : _("Operation failed - no changes have been made"), false);
+ ShowStatus(m_cancelling ? _("Operation cancelled - no changes have been made")
+ : _("Operation failed - no changes have been made"),
+ false);
if (pFrame->DarkLibExists(pConfig->GetCurrentProfileId(), false))
{
if (pFrame->LoadDarkHandler(true))
@@ -308,7 +314,7 @@ void DarksDialog::OnStart(wxCommandEvent& evt)
else
{
pFrame->SaveDarkLibrary(m_pNotes->GetValue());
- pFrame->LoadDarkHandler(true); // Put it to use, including selection of matching dark frame
+ pFrame->LoadDarkHandler(true); // Put it to use, including selection of matching dark frame
wrapupMsg = _("dark library built");
if (m_rbNewDarkLib)
Debug.AddLine("Dark library - new dark lib created from scratch.");
@@ -320,7 +326,7 @@ void DarksDialog::OnStart(wxCommandEvent& evt)
else
{
// Start by computing master dark frame with longish exposure times
- ShowStatus(_("Taking darks to compute defect map: "), false);
+ ShowStatus(_("Taking darks to compute defect map: "), false);
int defectFrameCount = m_pNumDefExposures->GetValue();
int defectExpTime = m_pDefectExpTime->GetValue() * 1000;
@@ -356,7 +362,7 @@ void DarksDialog::OnStart(wxCommandEvent& evt)
m_pStartBtn->Enable(true);
m_pResetBtn->Enable(true);
- pFrame->SetDarkMenuState(); // Hard to know where we are at this point
+ pFrame->SetDarkMenuState(); // Hard to know where we are at this point
if (m_cancelling || err)
{
@@ -370,7 +376,7 @@ void DarksDialog::OnStart(wxCommandEvent& evt)
// Put up a message showing results and maybe notice to uncover the scope; then close the dialog
pCamera->ShutterClosed = false; // Lights
if (!pCamera->HasShutter)
- wrapupMsg = _("Uncover guide scope") + wxT("\n\n") + wrapupMsg; // Results will appear in smaller font
+ wrapupMsg = _("Uncover guide scope") + wxT("\n\n") + wrapupMsg; // Results will appear in smaller font
wxMessageBox(wxString::Format(_("Operation complete: %s"), wrapupMsg));
EndDialog(wxOK);
}
@@ -449,7 +455,7 @@ struct Histogram
mean += v;
v >>= (img.BitsPerPixel - 8);
if (v > 255)
- v = 255; // should never happen if BitsPerPixel is valid
+ v = 255; // should never happen if BitsPerPixel is valid
++val[v];
}
mean /= img.NPixels;
@@ -502,7 +508,7 @@ bool DarksDialog::CreateMasterDarkFrame(usImage& darkFrame, int expTime, int fra
err = GuideCamera::Capture(pCamera, expTime, darkFrame, CAPTURE_DARK);
if (err)
{
- ShowStatus(wxString::Format(_("%.1f s dark FAILED"), (double)expTime / 1000.0), true);
+ ShowStatus(wxString::Format(_("%.1f s dark FAILED"), (double) expTime / 1000.0), true);
pCamera->ShutterClosed = false;
break;
}
@@ -512,9 +518,9 @@ bool DarksDialog::CreateMasterDarkFrame(usImage& darkFrame, int expTime, int fra
darkFrame.CalcStats();
- Debug.Write(wxString::Format("dark frame stats: bpp %u min %u max %u med %u filtmin %u filtmax %u\n",
- darkFrame.BitsPerPixel, darkFrame.MinADU, darkFrame.MaxADU,
- darkFrame.MedianADU, darkFrame.FiltMin, darkFrame.FiltMax));
+ Debug.Write(
+ wxString::Format("dark frame stats: bpp %u min %u max %u med %u filtmin %u filtmax %u\n", darkFrame.BitsPerPixel,
+ darkFrame.MinADU, darkFrame.MaxADU, darkFrame.MedianADU, darkFrame.FiltMin, darkFrame.FiltMax));
Histogram h(darkFrame);
h.Dump();
@@ -538,7 +544,7 @@ bool DarksDialog::CreateMasterDarkFrame(usImage& darkFrame, int expTime, int fra
const unsigned int *iptr = avgimg;
unsigned short *usptr = darkFrame.ImageData;
for (unsigned int i = 0; i < darkFrame.NPixels; i++)
- *usptr++ = (unsigned short)(*iptr++ / frameCount);
+ *usptr++ = (unsigned short) (*iptr++ / frameCount);
}
m_pProgress->SetValue(m_pProgress->GetValue() + expTime);
@@ -549,6 +555,4 @@ bool DarksDialog::CreateMasterDarkFrame(usImage& darkFrame, int expTime, int fra
return err;
}
-DarksDialog::~DarksDialog(void)
-{
-}
+DarksDialog::~DarksDialog(void) { }
diff --git a/src/darks_dialog.h b/src/darks_dialog.h
index eae9adb93..e1503e0f9 100644
--- a/src/darks_dialog.h
+++ b/src/darks_dialog.h
@@ -69,7 +69,6 @@ class DarksDialog : public wxDialog
private:
bool buildDarkLib;
-
};
#endif
diff --git a/src/debuglog.cpp b/src/debuglog.cpp
index ac00b6b48..5d3532b3f 100644
--- a/src/debuglog.cpp
+++ b/src/debuglog.cpp
@@ -41,9 +41,8 @@
const int RetentionPeriod = 30;
DebugLog::DebugLog()
- :
- m_enabled(false),
- m_lastWriteTime(wxDateTime::UNow())
+ : m_enabled(false)
+ , m_lastWriteTime(wxDateTime::UNow())
{
}
@@ -57,8 +56,7 @@ static bool ParseLogTimestamp(wxDateTime *p, const wxString& s)
{
wxDateTime dt;
wxString::const_iterator iter;
- if (dt.ParseFormat(s, "%Y-%m-%d_%H%M%S", wxDateTime(), &iter) &&
- iter == s.end())
+ if (dt.ParseFormat(s, "%Y-%m-%d_%H%M%S", wxDateTime(), &iter) && iter == s.end())
{
*p = dt;
return true;
@@ -77,9 +75,8 @@ wxDateTime DebugLog::GetLogFileTime()
while (cont)
{
wxDateTime dt;
- if (filename.length() == 35 &&
- ParseLogTimestamp(&dt, filename.substr(14, 17))
- && (!latest.IsValid() || dt.IsLaterThan(latest)))
+ if (filename.length() == 35 && ParseLogTimestamp(&dt, filename.substr(14, 17)) &&
+ (!latest.IsValid() || dt.IsLaterThan(latest)))
{
latest = dt;
}
@@ -161,7 +158,7 @@ wxString DebugLog::AddBytes(const wxString& str, const unsigned char *pBytes, un
{
wxString Line = str + " - ";
- for (unsigned int i=0; i < count; i++)
+ for (unsigned int i = 0; i < count; i++)
{
unsigned char ch = pBytes[i];
Line += wxString::Format("%2.2X (%c) ", ch, isprint(ch) ? ch : '?');
@@ -193,10 +190,8 @@ wxString DebugLog::Write(const wxString& str)
wxDateTime now = wxDateTime::UNow();
wxTimeSpan deltaTime = now - m_lastWriteTime;
m_lastWriteTime = now;
- wxString outputLine = wxString::Format("%s %s %lu %s", now.Format("%H:%M:%S.%l"),
- deltaTime.Format("%S.%l"),
- (unsigned long) wxThread::GetCurrentId(),
- str);
+ wxString outputLine = wxString::Format("%s %s %lu %s", now.Format("%H:%M:%S.%l"), deltaTime.Format("%S.%l"),
+ (unsigned long) wxThread::GetCurrentId(), str);
wxFFile::Write(outputLine);
#if defined(ALWAYS_FLUSH_DEBUGLOG)
@@ -210,25 +205,25 @@ wxString DebugLog::Write(const wxString& str)
return str;
}
-DebugLog& operator<< (DebugLog& out, const wxString &str)
+DebugLog& operator<<(DebugLog& out, const wxString& str)
{
out.Write(str);
return out;
}
-DebugLog& operator<< (DebugLog& out, const char *str)
+DebugLog& operator<<(DebugLog& out, const char *str)
{
out.Write(str);
return out;
}
-DebugLog& operator<< (DebugLog& out, const int i)
+DebugLog& operator<<(DebugLog& out, const int i)
{
out.Write(wxString::Format(_T("%d"), i));
return out;
}
-DebugLog& operator<< (DebugLog& out, const double d)
+DebugLog& operator<<(DebugLog& out, const double d)
{
out.Write(wxString::Format(_T("%f"), d));
return out;
diff --git a/src/debuglog.h b/src/debuglog.h
index 21fc34377..547f85989 100644
--- a/src/debuglog.h
+++ b/src/debuglog.h
@@ -63,10 +63,10 @@ class DebugLog : public wxFFile, public Logger
void RemoveOldFiles();
};
-extern DebugLog& operator<< (DebugLog& out, const wxString& str);
-extern DebugLog& operator<< (DebugLog& out, const char *str);
-extern DebugLog& operator<< (DebugLog& out, const int i);
-extern DebugLog& operator<< (DebugLog& out, const double d);
+extern DebugLog& operator<<(DebugLog& out, const wxString& str);
+extern DebugLog& operator<<(DebugLog& out, const char *str);
+extern DebugLog& operator<<(DebugLog& out, const int i);
+extern DebugLog& operator<<(DebugLog& out, const double d);
inline bool DebugLog::IsEnabled() const
{
diff --git a/src/drift_tool.cpp b/src/drift_tool.cpp
index 729a29516..ba790d59b 100644
--- a/src/drift_tool.cpp
+++ b/src/drift_tool.cpp
@@ -116,7 +116,7 @@ struct DriftToolWin : public wxFrame
void UpdateScopeCoordinates(void);
- void SetStatusText(const wxString &text, int number = 0) override;
+ void SetStatusText(const wxString& text, int number = 0) override;
wxDECLARE_EVENT_TABLE();
};
@@ -136,9 +136,10 @@ wxEND_EVENT_TABLE();
DriftToolWin::DriftToolWin()
: wxFrame(pFrame, wxID_ANY, _("Drift Align"), wxDefaultPosition, wxDefaultSize,
- wxCAPTION|wxCLOSE_BOX|wxMINIMIZE_BOX|wxSYSTEM_MENU|wxTAB_TRAVERSAL|wxFRAME_FLOAT_ON_PARENT|wxFRAME_NO_TASKBAR),
- m_need_end_dec_drift(false),
- m_slewing(false)
+ wxCAPTION | wxCLOSE_BOX | wxMINIMIZE_BOX | wxSYSTEM_MENU | wxTAB_TRAVERSAL | wxFRAME_FLOAT_ON_PARENT |
+ wxFRAME_NO_TASKBAR)
+ , m_need_end_dec_drift(false)
+ , m_slewing(false)
{
SetSizeHints(wxDefaultSize, wxDefaultSize);
@@ -148,20 +149,21 @@ DriftToolWin::DriftToolWin()
// a horizontal box sizer for the bitmap and the instructions
wxBoxSizer *instrSizer = new wxBoxSizer(wxHORIZONTAL);
-# include "icons/AzArrow.xpm"
+#include "icons/AzArrow.xpm"
m_azArrowBmp = new wxBitmap(AzArrow);
-# include "icons/AltArrow.xpm"
+#include "icons/AltArrow.xpm"
m_altArrowBmp = new wxBitmap(AltArrow);
m_bmp = new wxStaticBitmap(this, wxID_ANY, *m_azArrowBmp, wxDefaultPosition, wxSize(80, 100));
- instrSizer->Add(m_bmp, 0, wxALIGN_CENTER_VERTICAL|wxFIXED_MINSIZE, 5);
+ instrSizer->Add(m_bmp, 0, wxALIGN_CENTER_VERTICAL | wxFIXED_MINSIZE, 5);
- m_instructions = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(400,120), wxALIGN_LEFT|wxST_NO_AUTORESIZE);
+ m_instructions =
+ new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(400, 120), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
#ifdef __WXOSX__
m_instructions->SetFont(*wxSMALL_FONT);
#endif
m_instructions->Wrap(-1);
- instrSizer->Add(m_instructions, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+ instrSizer->Add(m_instructions, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
topSizer->Add(instrSizer);
@@ -219,14 +221,14 @@ DriftToolWin::DriftToolWin()
sbSizer->Add(gbSizer, 1, wxALIGN_CENTER, 5);
// add static sizer to top-level sizer
- topSizer->Add(sbSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+ topSizer->Add(sbSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
// add some padding below the static sizer
topSizer->Add(0, 3, 0, wxEXPAND, 3);
m_notesLabel = new wxStaticText(this, wxID_ANY, _("Altitude adjustment notes"));
m_notesLabel->Wrap(-1);
- topSizer->Add(m_notesLabel, 0, wxEXPAND|wxTOP|wxLEFT, 8);
+ topSizer->Add(m_notesLabel, 0, wxEXPAND | wxTOP | wxLEFT, 8);
m_notes = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1, 54), wxTE_MULTILINE);
pFrame->RegisterTextCtrl(m_notes);
@@ -240,22 +242,22 @@ DriftToolWin::DriftToolWin()
hSizer->Add(0, 0, 2, wxEXPAND, 5);
m_drift = new wxButton(this, ID_DRIFT, _("Drift"));
- hSizer->Add(m_drift, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ hSizer->Add(m_drift, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
// proportional pad on right of Drift button
hSizer->Add(0, 0, 1, wxEXPAND, 5);
m_adjust = new wxButton(this, ID_ADJUST, _("Adjust"));
- hSizer->Add(m_adjust, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ hSizer->Add(m_adjust, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
// proportional pad on right of Align button
hSizer->Add(0, 0, 2, wxEXPAND, 5);
m_phaseBtn = new wxButton(this, ID_PHASE, wxT("???"));
- hSizer->Add(m_phaseBtn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
+ hSizer->Add(m_phaseBtn, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
// add button sizer to top level sizer
- topSizer->Add(hSizer, 1, wxEXPAND|wxALL, 5);
+ topSizer->Add(hSizer, 1, wxEXPAND | wxALL, 5);
SetSizer(topSizer);
@@ -282,7 +284,10 @@ DriftToolWin::DriftToolWin()
m_timer = NULL;
if (m_can_slew || (pPointingSource && pPointingSource->CanReportPosition()))
{
- enum { SCOPE_POS_POLL_MS = 1500 };
+ enum
+ {
+ SCOPE_POS_POLL_MS = 1500
+ };
m_timer = new wxTimer(this, ID_TIMER);
m_timer->Start(SCOPE_POS_POLL_MS, false /* continuous */);
}
@@ -374,12 +379,11 @@ void DriftToolWin::UpdatePhaseState()
{
SetTitle(_("Drift Align - Azimuth Adjustment"));
m_bmp->SetBitmap(*m_azArrowBmp);
- m_instructions->SetLabel(
- _("Slew to near the Meridian and the Equator.\n"
- "Press Drift to measure drift, watch the Dec trend line.\n"
- "Press Adjust and adjust your mount's azimuth.\n"
- "Repeat Drift/Adjust until alignment is complete.\n"
- "Then, click Altitude to begin Altitude adjustment."));
+ m_instructions->SetLabel(_("Slew to near the Meridian and the Equator.\n"
+ "Press Drift to measure drift, watch the Dec trend line.\n"
+ "Press Adjust and adjust your mount's azimuth.\n"
+ "Repeat Drift/Adjust until alignment is complete.\n"
+ "Then, click Altitude to begin Altitude adjustment."));
m_notesLabel->SetLabel(_("Azimuth adjustment notes"));
m_notes->SetValue(pConfig->Profile.GetString("/DriftTool/Az/Notes", wxEmptyString));
m_phaseBtn->SetLabel(_("> Altitude"));
@@ -388,12 +392,11 @@ void DriftToolWin::UpdatePhaseState()
{
SetTitle(_("Drift Align - Altitude Adjustment"));
m_bmp->SetBitmap(*m_altArrowBmp);
- m_instructions->SetLabel(
- _("Slew to a location near the Equator and the Eastern or Western horizon.\n"
- "Press Drift to measure drift, watch the Dec trend line.\n"
- "Press Adjust and adjust your mount's altitude.\n"
- "Repeat Drift/Adjust until alignment is complete.\n"
- "Click Azimuth to repeat Azimuth adjustment."));
+ m_instructions->SetLabel(_("Slew to a location near the Equator and the Eastern or Western horizon.\n"
+ "Press Drift to measure drift, watch the Dec trend line.\n"
+ "Press Adjust and adjust your mount's altitude.\n"
+ "Repeat Drift/Adjust until alignment is complete.\n"
+ "Click Azimuth to repeat Azimuth adjustment."));
m_notesLabel->SetLabel(_("Altitude adjustment notes"));
m_notes->SetValue(pConfig->Profile.GetString("/DriftTool/Alt/Notes", wxEmptyString));
m_phaseBtn->SetLabel(_("< Azimuth"));
@@ -420,8 +423,7 @@ void DriftToolWin::UpdateModeState()
if (!m_drifting)
{
- if (!pCamera->Connected ||
- !pMount || !pMount->IsConnected())
+ if (!pCamera->Connected || !pMount || !pMount->IsConnected())
{
idleStatus = _("Please connect a camera and a mount");
m_mode = MODE_IDLE;
@@ -465,7 +467,8 @@ void DriftToolWin::UpdateModeState()
SetStatusText(_("Start guiding..."));
pFrame->GuideButtonClick(false, _T("DriftTool:drift"));
return;
- case STATE_GUIDING: {
+ case STATE_GUIDING:
+ {
// turn of dec guiding
if (!m_need_end_dec_drift)
{
@@ -491,8 +494,8 @@ void DriftToolWin::UpdateModeState()
m_adjust->Enable(false);
m_drifting = false;
EnableSlew(m_can_slew);
- SetStatusText(m_phase == PHASE_ADJUST_AZ ? _("Adjust azimuth, click Drift when done") :
- _("Adjust altitude, click Drift when done"));
+ SetStatusText(m_phase == PHASE_ADJUST_AZ ? _("Adjust azimuth, click Drift when done")
+ : _("Adjust altitude, click Drift when done"));
// use full frames for adjust phase
pCamera->UseSubframes = false;
@@ -504,9 +507,10 @@ void DriftToolWin::UpdateModeState()
// Set the lock position to the where the star has drifted to. This will be the center of the polar align circle.
pFrame->pGuider->SetLockPosition(pFrame->pGuider->CurrentPosition());
- // Make sure guider does not react to star lost (like by invalidating the lock position) while adjustment is in progress
+ // Make sure guider does not react to star lost (like by invalidating the lock position) while adjustment is in
+ // progress
pFrame->pGuider->SetIgnoreLostStarLooping(true);
- pFrame->pGraphLog->Refresh(); // polar align circle is updated in graph window's OnPaint handler
+ pFrame->pGraphLog->Refresh(); // polar align circle is updated in graph window's OnPaint handler
}
}
else // MODE_IDLE
@@ -545,8 +549,8 @@ void DriftToolWin::OnSlew(wxCommandEvent& evt)
double slew_ra = norm_ra(cur_st + (raSlew * 24.0 / 360.0));
- Debug.Write(wxString::Format("Drift tool: slew from ra %.2f, dec %.1f to ra %.2f, dec %.1f\n",
- cur_ra, cur_dec, slew_ra, decSlew));
+ Debug.Write(
+ wxString::Format("Drift tool: slew from ra %.2f, dec %.1f to ra %.2f, dec %.1f\n", cur_ra, cur_dec, slew_ra, decSlew));
if (pPointingSource->CanSlewAsync())
{
@@ -554,7 +558,9 @@ void DriftToolWin::OnSlew(wxCommandEvent& evt)
{
double ra, dec;
SlewInBg(wxWindow *parent, double ra_, double dec_)
- : RunInBg(parent, _("Slew"), _("Slewing...")), ra(ra_), dec(dec_)
+ : RunInBg(parent, _("Slew"), _("Slewing..."))
+ , ra(ra_)
+ , dec(dec_)
{
SetPopupDelay(100);
}
@@ -808,7 +814,7 @@ void DriftToolWin::OnTimer(wxTimerEvent& evt)
}
}
-void DriftToolWin::SetStatusText(const wxString &text, int number)
+void DriftToolWin::SetStatusText(const wxString& text, int number)
{
Debug.Write(wxString::Format("Drift tool: status: %s\n", text));
wxFrame::SetStatusText(text, number);
@@ -826,15 +832,14 @@ wxWindow *DriftTool::CreateDriftToolWindow()
if (pFrame->GetCameraPixelScale() == 1.0)
{
- bool confirmed = ConfirmDialog::Confirm(_(
- "The Drift Align tool is most effective when PHD2 knows your guide\n"
- "scope focal length and camera pixel size.\n"
- "\n"
- "Enter your guide scope focal length on the Global tab in the Brain.\n"
- "Enter your camera pixel size on the Camera tab in the Brain.\n"
- "\n"
- "Would you like to run the drift tool anyway?"),
- "/drift_tool_without_pixscale");
+ bool confirmed = ConfirmDialog::Confirm(_("The Drift Align tool is most effective when PHD2 knows your guide\n"
+ "scope focal length and camera pixel size.\n"
+ "\n"
+ "Enter your guide scope focal length on the Global tab in the Brain.\n"
+ "Enter your camera pixel size on the Camera tab in the Brain.\n"
+ "\n"
+ "Would you like to run the drift tool anyway?"),
+ "/drift_tool_without_pixscale");
if (!confirmed)
{
diff --git a/src/eegg.cpp b/src/eegg.cpp
index 2a379fea3..6b055be38 100644
--- a/src/eegg.cpp
+++ b/src/eegg.cpp
@@ -45,7 +45,8 @@
static wxString FlipCalEnabledKey()
{
- // we want the key to be under "/Confirm" so ConfirmDialog::ResetAllDontAskAgain() resets it, but we also want the setting to be per-profile
+ // we want the key to be under "/Confirm" so ConfirmDialog::ResetAllDontAskAgain() resets it, but we also want the setting
+ // to be per-profile
return wxString::Format("/Confirm/%d/FlipCalWarningEnabled", pConfig->GetCurrentProfileId());
}
@@ -77,7 +78,7 @@ void MyFrame::OnEEGG(wxCommandEvent& evt)
}
else
{
- if (pCalReviewDlg) // Review dialog is non-modal
+ if (pCalReviewDlg) // Review dialog is non-modal
pCalReviewDlg->Destroy();
pCalReviewDlg = new CalReviewDialog(this);
pCalReviewDlg->Show();
@@ -88,8 +89,8 @@ void MyFrame::OnEEGG(wxCommandEvent& evt)
if (pMount)
{
Calibration cal;
- cal.xRate = pMount->xRate();
- cal.yRate = pMount->yRate();
+ cal.xRate = pMount->xRate();
+ cal.yRate = pMount->yRate();
cal.xAngle = pMount->xAngle();
cal.yAngle = pMount->yAngle();
cal.declination = pPointingSource->GetDeclinationRadians();
@@ -101,15 +102,15 @@ void MyFrame::OnEEGG(wxCommandEvent& evt)
if (!pMount->IsCalibrated())
{
- cal.xRate = 1.0;
- cal.yRate = 1.0;
- cal.xAngle = 0.0;
- cal.yAngle = M_PI / 2.;
+ cal.xRate = 1.0;
+ cal.yRate = 1.0;
+ cal.xAngle = 0.0;
+ cal.yAngle = M_PI / 2.;
cal.declination = UNKNOWN_DECLINATION;
}
ManualCalDialog manualcal(cal);
- if (manualcal.ShowModal () == wxID_OK)
+ if (manualcal.ShowModal() == wxID_OK)
{
manualcal.GetValues(&cal);
pMount->SetCalibration(cal);
@@ -134,8 +135,10 @@ void MyFrame::OnEEGG(wxCommandEvent& evt)
}
if (devicestr.Length() > 0)
{
- if (wxMessageBox(wxString::Format(_("%s calibration will be cleared - calibration will be re-done when guiding is started."), devicestr),
- _("Clear Calibration"), wxOK | wxCANCEL) == wxOK)
+ if (wxMessageBox(wxString::Format(
+ _("%s calibration will be cleared - calibration will be re-done when guiding is started."),
+ devicestr),
+ _("Clear Calibration"), wxOK | wxCANCEL) == wxOK)
{
if (pMount)
pMount->ClearCalibration();
@@ -168,22 +171,24 @@ void MyFrame::OnEEGG(wxCommandEvent& evt)
lastCal.pierSide != PIER_SIDE_UNKNOWN)
{
pFrame->SuppressableAlert(FlipCalEnabledKey(),
- _("This is unnecessary because PHD2 has pointing info from the mount. If you are seeing run-away Dec guiding "
- "after a meridian flip, use Help and look in the index for 'Reverse Dec output'."),
+ _("This is unnecessary because PHD2 has pointing info from the mount. If you are seeing run-away Dec "
+ "guiding "
+ "after a meridian flip, use Help and look in the index for 'Reverse Dec output'."),
SuppressFlipCalAlert, 0, true);
}
else
{
if (FlipCalibrationData())
{
- wxMessageBox(_("Failed to flip calibration - please upload debug log file to PHD2 forum for assistance."));
+ wxMessageBox(
+ _("Failed to flip calibration - please upload debug log file to PHD2 forum for assistance."));
}
else
{
double xnew = degrees(scope->xAngle());
double ynew = degrees(scope->yAngle());
- wxMessageBox(wxString::Format(_("Calibration angles flipped: (%.2f, %.2f) to (%.2f, %.2f)"),
- xorig, yorig, xnew, ynew));
+ wxMessageBox(wxString::Format(
+ _("Calibration angles flipped: (%.2f, %.2f) to (%.2f, %.2f)"), xorig, yorig, xnew, ynew));
}
}
}
@@ -287,12 +292,10 @@ void MyFrame::OnGuidingAssistant(wxCommandEvent& WXUNUSED(evt))
if (pFrame->pGuider->IsGuiding())
{
- ok = ConfirmDialog::Confirm(_(
- "The Guiding Assitant will disable guide output and\n"
- "allow the guide star to drift.\n"
- "\n"
- "Ok to disable guide output?"
- ),
+ ok = ConfirmDialog::Confirm(_("The Guiding Assitant will disable guide output and\n"
+ "allow the guide star to drift.\n"
+ "\n"
+ "Ok to disable guide output?"),
"/guiding_assistant_while_guiding", _("Confirm Disable Guiding"));
}
diff --git a/src/event_server.cpp b/src/event_server.cpp
index 889ce966d..bb3a05b6b 100644
--- a/src/event_server.cpp
+++ b/src/event_server.cpp
@@ -61,14 +61,22 @@ static wxString state_name(EXPOSED_STATE st)
{
switch (st)
{
- case EXPOSED_STATE_NONE: return "Stopped";
- case EXPOSED_STATE_SELECTED: return "Selected";
- case EXPOSED_STATE_CALIBRATING: return "Calibrating";
- case EXPOSED_STATE_GUIDING_LOCKED: return "Guiding";
- case EXPOSED_STATE_GUIDING_LOST: return "LostLock";
- case EXPOSED_STATE_PAUSED: return "Paused";
- case EXPOSED_STATE_LOOPING: return "Looping";
- default: return "Unknown";
+ case EXPOSED_STATE_NONE:
+ return "Stopped";
+ case EXPOSED_STATE_SELECTED:
+ return "Selected";
+ case EXPOSED_STATE_CALIBRATING:
+ return "Calibrating";
+ case EXPOSED_STATE_GUIDING_LOCKED:
+ return "Guiding";
+ case EXPOSED_STATE_GUIDING_LOST:
+ return "LostLock";
+ case EXPOSED_STATE_PAUSED:
+ return "Paused";
+ case EXPOSED_STATE_LOOPING:
+ return "Looping";
+ default:
+ return "Unknown";
}
}
@@ -96,9 +104,23 @@ struct JSeq
wxString m_s;
bool m_first;
bool m_closed;
- JSeq() : m_first(true), m_closed(false) { m_s << LDELIM; }
- void close() { m_s << RDELIM; m_closed = true; }
- wxString str() { if (!m_closed) close(); return m_s; }
+ JSeq()
+ : m_first(true)
+ , m_closed(false)
+ {
+ m_s << LDELIM;
+ }
+ void close()
+ {
+ m_s << RDELIM;
+ m_closed = true;
+ }
+ wxString str()
+ {
+ if (!m_closed)
+ close();
+ return m_s;
+ }
};
typedef JSeq<'[', ']'> JAry;
@@ -129,13 +151,16 @@ static wxString json_format(const json_value *j)
if (!j)
return literal_null;
- switch (j->type) {
+ switch (j->type)
+ {
default:
- case JSON_NULL: return literal_null;
- case JSON_OBJECT: {
+ case JSON_NULL:
+ return literal_null;
+ case JSON_OBJECT:
+ {
wxString ret("{");
bool first = true;
- json_for_each (jj, j)
+ json_for_each(jj, j)
{
if (first)
first = false;
@@ -146,10 +171,11 @@ static wxString json_format(const json_value *j)
ret << "}";
return ret;
}
- case JSON_ARRAY: {
+ case JSON_ARRAY:
+ {
wxString ret("[");
bool first = true;
- json_for_each (jj, j)
+ json_for_each(jj, j)
{
if (first)
first = false;
@@ -160,37 +186,109 @@ static wxString json_format(const json_value *j)
ret << "]";
return ret;
}
- case JSON_STRING: return '"' + json_escape(j->string_value) + '"';
- case JSON_INT: return wxString::Format("%d", j->int_value);
- case JSON_FLOAT: return wxString::Format("%g", (double) j->float_value);
- case JSON_BOOL: return j->int_value ? literal_true : literal_false;
+ case JSON_STRING:
+ return '"' + json_escape(j->string_value) + '"';
+ case JSON_INT:
+ return wxString::Format("%d", j->int_value);
+ case JSON_FLOAT:
+ return wxString::Format("%g", (double) j->float_value);
+ case JSON_BOOL:
+ return j->int_value ? literal_true : literal_false;
}
}
-struct NULL_TYPE { } NULL_VALUE;
+struct NULL_TYPE
+{
+} NULL_VALUE;
// name-value pair
struct NV
{
wxString n;
wxString v;
- NV(const wxString& n_, const wxString& v_) : n(n_), v('"' + json_escape(v_) + '"') { }
- NV(const wxString& n_, const char *v_) : n(n_), v('"' + json_escape(v_) + '"') { }
- NV(const wxString& n_, const wchar_t *v_) : n(n_), v('"' + json_escape(v_) + '"') { }
- NV(const wxString& n_, int v_) : n(n_), v(wxString::Format("%d", v_)) { }
- NV(const wxString& n_, unsigned int v_) : n(n_), v(wxString::Format("%u", v_)) { }
- NV(const wxString& n_, double v_) : n(n_), v(wxString::Format("%g", v_)) { }
- NV(const wxString& n_, double v_, int prec) : n(n_), v(wxString::Format("%.*f", prec, v_)) { }
- NV(const wxString& n_, bool v_) : n(n_), v(v_ ? literal_true : literal_false) { }
+ NV(const wxString& n_, const wxString& v_)
+ : n(n_)
+ , v('"' + json_escape(v_) + '"')
+ {
+ }
+ NV(const wxString& n_, const char *v_)
+ : n(n_)
+ , v('"' + json_escape(v_) + '"')
+ {
+ }
+ NV(const wxString& n_, const wchar_t *v_)
+ : n(n_)
+ , v('"' + json_escape(v_) + '"')
+ {
+ }
+ NV(const wxString& n_, int v_)
+ : n(n_)
+ , v(wxString::Format("%d", v_))
+ {
+ }
+ NV(const wxString& n_, unsigned int v_)
+ : n(n_)
+ , v(wxString::Format("%u", v_))
+ {
+ }
+ NV(const wxString& n_, double v_)
+ : n(n_)
+ , v(wxString::Format("%g", v_))
+ {
+ }
+ NV(const wxString& n_, double v_, int prec)
+ : n(n_)
+ , v(wxString::Format("%.*f", prec, v_))
+ {
+ }
+ NV(const wxString& n_, bool v_)
+ : n(n_)
+ , v(v_ ? literal_true : literal_false)
+ {
+ }
template
NV(const wxString& n_, const std::vector& vec);
- NV(const wxString& n_, JAry& ary) : n(n_), v(ary.str()) { }
- NV(const wxString& n_, JObj& obj) : n(n_), v(obj.str()) { }
- NV(const wxString& n_, const json_value *v_) : n(n_), v(json_format(v_)) { }
- NV(const wxString& n_, const PHD_Point& p) : n(n_) { JAry ary; ary << p.X << p.Y; v = ary.str(); }
- NV(const wxString& n_, const wxPoint& p) : n(n_) { JAry ary; ary << p.x << p.y; v = ary.str(); }
- NV(const wxString& n_, const wxSize& s) : n(n_) { JAry ary; ary << s.x << s.y; v = ary.str(); }
- NV(const wxString& n_, const NULL_TYPE& nul) : n(n_), v(literal_null) { }
+ NV(const wxString& n_, JAry& ary)
+ : n(n_)
+ , v(ary.str())
+ {
+ }
+ NV(const wxString& n_, JObj& obj)
+ : n(n_)
+ , v(obj.str())
+ {
+ }
+ NV(const wxString& n_, const json_value *v_)
+ : n(n_)
+ , v(json_format(v_))
+ {
+ }
+ NV(const wxString& n_, const PHD_Point& p)
+ : n(n_)
+ {
+ JAry ary;
+ ary << p.X << p.Y;
+ v = ary.str();
+ }
+ NV(const wxString& n_, const wxPoint& p)
+ : n(n_)
+ {
+ JAry ary;
+ ary << p.x << p.y;
+ v = ary.str();
+ }
+ NV(const wxString& n_, const wxSize& s)
+ : n(n_)
+ {
+ JAry ary;
+ ary << s.x << s.y;
+ v = ary.str();
+ }
+ NV(const wxString& n_, const NULL_TYPE& nul)
+ : n(n_)
+ , v(literal_null)
+ {
+ }
};
template
@@ -239,20 +337,16 @@ struct Ev : public JObj
Ev(const wxString& event)
{
double const now = ::wxGetUTCTimeMillis().ToDouble() / 1000.0;
- *this << NV("Event", event)
- << NV("Timestamp", now, 3)
- << NV("Host", wxGetHostName())
- << NV("Inst", wxGetApp().GetInstanceNumber());
+ *this << NV("Event", event) << NV("Timestamp", now, 3) << NV("Host", wxGetHostName())
+ << NV("Inst", wxGetApp().GetInstanceNumber());
}
};
static Ev ev_message_version()
{
Ev ev("Version");
- ev << NV("PHDVersion", PHDVERSION)
- << NV("PHDSubver", PHDSUBVER)
- << NV("OverlapSupport", true)
- << NV("MsgVersion", MSG_PROTOCOL_VERSION);
+ ev << NV("PHDVersion", PHDVERSION) << NV("PHDSubver", PHDSUBVER) << NV("OverlapSupport", true)
+ << NV("MsgVersion", MSG_PROTOCOL_VERSION);
return ev;
}
@@ -311,10 +405,7 @@ static Ev ev_settling(double distance, double time, double settleTime, bool star
{
Ev ev("Settling");
- ev << NV("Distance", distance, 2)
- << NV("Time", time, 1)
- << NV("SettleTime", settleTime, 1)
- << NV("StarLocked", starLocked);
+ ev << NV("Distance", distance, 2) << NV("Time", time, 1) << NV("SettleTime", settleTime, 1) << NV("StarLocked", starLocked);
return ev;
}
@@ -332,15 +423,17 @@ static Ev ev_settle_done(const wxString& errorMsg, int settleFrames, int dropped
ev << NV("Error", errorMsg);
}
- ev << NV("TotalFrames", settleFrames)
- << NV("DroppedFrames", droppedFrames);
+ ev << NV("TotalFrames", settleFrames) << NV("DroppedFrames", droppedFrames);
return ev;
}
struct ClientReadBuf
{
- enum { SIZE = 1024 };
+ enum
+ {
+ SIZE = 1024
+ };
char m_buf[SIZE];
char *dest;
@@ -358,7 +451,11 @@ struct ClientData
ClientReadBuf rdbuf;
wxMutex wrlock;
- ClientData(wxSocketClient *cli_) : cli(cli_), refcnt(1) { }
+ ClientData(wxSocketClient *cli_)
+ : cli(cli_)
+ , refcnt(1)
+ {
+ }
void AddRef() { ++refcnt; }
void RemoveRef()
{
@@ -373,7 +470,11 @@ struct ClientData
struct ClientDataGuard
{
ClientData *cd;
- ClientDataGuard(wxSocketClient *cli) : cd((ClientData *) cli->GetClientData()) { cd->AddRef(); }
+ ClientDataGuard(wxSocketClient *cli)
+ : cd((ClientData *) cli->GetClientData())
+ {
+ cd->AddRef();
+ }
~ClientDataGuard() { cd->RemoveRef(); }
ClientData *operator->() const { return cd; }
};
@@ -385,18 +486,30 @@ inline static wxMutex *client_wrlock(wxSocketClient *cli)
static wxString SockErrStr(wxSocketError e)
{
- switch (e) {
- case wxSOCKET_NOERROR: return "";
- case wxSOCKET_INVOP: return "Invalid operation";
- case wxSOCKET_IOERR: return "Input / Output error";
- case wxSOCKET_INVADDR: return "Invalid address";
- case wxSOCKET_INVSOCK: return "Invalid socket(uninitialized)";
- case wxSOCKET_NOHOST: return "No corresponding host";
- case wxSOCKET_INVPORT: return "Invalid port";
- case wxSOCKET_WOULDBLOCK: return "operation would block";
- case wxSOCKET_TIMEDOUT: return "timeout expired";
- case wxSOCKET_MEMERR: return "Memory exhausted";
- default: return wxString::Format("unknown socket error %d", e);
+ switch (e)
+ {
+ case wxSOCKET_NOERROR:
+ return "";
+ case wxSOCKET_INVOP:
+ return "Invalid operation";
+ case wxSOCKET_IOERR:
+ return "Input / Output error";
+ case wxSOCKET_INVADDR:
+ return "Invalid address";
+ case wxSOCKET_INVSOCK:
+ return "Invalid socket(uninitialized)";
+ case wxSOCKET_NOHOST:
+ return "No corresponding host";
+ case wxSOCKET_INVPORT:
+ return "Invalid port";
+ case wxSOCKET_WOULDBLOCK:
+ return "operation would block";
+ case wxSOCKET_TIMEDOUT:
+ return "timeout expired";
+ case wxSOCKET_MEMERR:
+ return "Memory exhausted";
+ default:
+ return wxString::Format("unknown socket error %d", e);
}
}
@@ -406,9 +519,8 @@ static void send_buf(wxSocketClient *client, const wxCharBuffer& buf)
client->Write(buf.data(), buf.length());
if (client->LastWriteCount() != buf.length())
{
- Debug.Write(wxString::Format("evsrv: cli %p short write %u/%u %s\n",
- client, client->LastWriteCount(), (unsigned int) buf.length(),
- SockErrStr(client->Error() ? client->LastError() : wxSOCKET_NOERROR)));
+ Debug.Write(wxString::Format("evsrv: cli %p short write %u/%u %s\n", client, client->LastWriteCount(),
+ (unsigned int) buf.length(), SockErrStr(client->Error() ? client->LastError() : wxSOCKET_NOERROR)));
}
}
@@ -426,8 +538,7 @@ static void do_notify(const EventServer::CliSockSet& cli, const JObj& jj)
{
wxCharBuffer buf = (JObj(jj).str() + "\r\n").ToUTF8();
- for (EventServer::CliSockSet::const_iterator it = cli.begin();
- it != cli.end(); ++it)
+ for (EventServer::CliSockSet::const_iterator it = cli.begin(); it != cli.end(); ++it)
{
send_buf(*it, buf);
}
@@ -480,7 +591,8 @@ static void send_catchup_events(wxSocketClient *cli)
mount = pSecondaryMount;
do_notify1(cli, ev_start_calibration(mount));
}
- else if (st == EXPOSED_STATE_PAUSED) {
+ else if (st == EXPOSED_STATE_PAUSED)
+ {
do_notify1(cli, ev_paused());
}
@@ -503,7 +615,8 @@ static void drain_input(wxSocketInputStream& sis)
}
}
-enum {
+enum
+{
JSONRPC_PARSE_ERROR = -32700,
JSONRPC_INVALID_REQUEST = -32600,
JSONRPC_METHOD_NOT_FOUND = -32601,
@@ -542,19 +655,17 @@ struct JRpcResponse : public JObj
static wxString parser_error(const JsonParser& parser)
{
- return wxString::Format("invalid JSON request: %s on line %d at \"%.12s...\"",
- parser.ErrorDesc(), parser.ErrorLine(), parser.ErrorPos());
+ return wxString::Format(
+ "invalid JSON request: %s on line %d at \"%.12s...\"", parser.ErrorDesc(), parser.ErrorLine(), parser.ErrorPos());
}
-static void
-parse_request(const json_value *req, const json_value **pmethod, const json_value **pparams,
- const json_value **pid)
+static void parse_request(const json_value *req, const json_value **pmethod, const json_value **pparams, const json_value **pid)
{
*pmethod = *pparams = *pid = 0;
if (req)
{
- json_for_each (t, req)
+ json_for_each(t, req)
{
if (t->name)
{
@@ -570,13 +681,15 @@ parse_request(const json_value *req, const json_value **pmethod, const json_valu
}
// paranoia
-#define VERIFY_GUIDER(response) do { \
- if (!pFrame || !pFrame->pGuider) \
- { \
- response << jrpc_error(1, "internal error"); \
- return; \
- } \
-} while (0)
+#define VERIFY_GUIDER(response) \
+ do \
+ { \
+ if (!pFrame || !pFrame->pGuider) \
+ { \
+ response << jrpc_error(1, "internal error"); \
+ return; \
+ } \
+ } while (0)
static void deselect_star(JObj& response, const json_value *params)
{
@@ -710,7 +823,7 @@ static void get_current_equipment(JObj& response, const json_value *params)
JObj t;
if (pCamera)
- devstat(t, "camera", pCamera->Name, pCamera->Connected);
+ devstat(t, "camera", pCamera->Name, pCamera->Connected);
Mount *mount = TheScope();
if (mount)
@@ -733,8 +846,7 @@ static void get_current_equipment(JObj& response, const json_value *params)
static bool all_equipment_connected()
{
- return pCamera && pCamera->Connected &&
- (!pMount || pMount->IsConnected()) &&
+ return pCamera && pCamera->Connected && (!pMount || pMount->IsConnected()) &&
(!pSecondaryMount || pSecondaryMount->IsConnected());
}
@@ -781,8 +893,7 @@ static void set_connected(JObj& response, const json_value *params)
VERIFY_GUIDER(response);
wxString errMsg;
- bool error = val->int_value ? pFrame->pGearDialog->ConnectAll(&errMsg) :
- pFrame->pGearDialog->DisconnectAll(&errMsg);
+ bool error = val->int_value ? pFrame->pGearDialog->ConnectAll(&errMsg) : pFrame->pGearDialog->DisconnectAll(&errMsg);
if (error)
{
@@ -1028,7 +1139,10 @@ inline static const char *string_val(const json_value *j)
enum WHICH_MOUNT
{
- MOUNT, AO, WHICH_MOUNT_BOTH, WHICH_MOUNT_ERR
+ MOUNT,
+ AO,
+ WHICH_MOUNT_BOTH,
+ WHICH_MOUNT_ERR
};
static WHICH_MOUNT which_mount(const json_value *p)
@@ -1068,9 +1182,15 @@ static void clear_calibration(JObj& response, const json_value *params)
WHICH_MOUNT which = which_mount(p.param("which"));
switch (which)
{
- case MOUNT: clear_mount = true; break;
- case AO: clear_ao = true; break;
- case WHICH_MOUNT_BOTH: clear_mount = clear_ao = true; break;
+ case MOUNT:
+ clear_mount = true;
+ break;
+ case AO:
+ clear_ao = true;
+ break;
+ case WHICH_MOUNT_BOTH:
+ clear_mount = clear_ao = true;
+ break;
case WHICH_MOUNT_ERR:
response << jrpc_error(JSONRPC_INVALID_PARAMS, "expected param \"mount\", \"ao\", or \"both\"");
return;
@@ -1131,8 +1251,7 @@ static bool is_camera_shift_req(const json_value *params)
if (j)
{
const char *axes = string_val(j);
- if (wxStricmp(axes, "x/y") == 0 ||
- wxStricmp(axes, "camera") == 0)
+ if (wxStricmp(axes, "x/y") == 0 || wxStricmp(axes, "camera") == 0)
{
return true;
}
@@ -1145,8 +1264,7 @@ static JObj& operator<<(JObj& j, const LockPosShiftParams& l)
j << NV("enabled", l.shiftEnabled);
if (l.shiftRate.IsValid())
{
- j << NV("rate", l.shiftRate)
- << NV("units", l.shiftUnits == UNIT_ARCSEC ? "arcsec/hr" : "pixels/hr")
+ j << NV("rate", l.shiftRate) << NV("units", l.shiftUnits == UNIT_ARCSEC ? "arcsec/hr" : "pixels/hr")
<< NV("axes", l.shiftIsMountCoords ? "RA/Dec" : "X/Y");
}
return j;
@@ -1233,8 +1351,7 @@ static bool parse_lock_shift_params(LockPosShiftParams *shift, const json_value
j = p.param("units");
const char *units = j ? string_val(j) : "";
- if (wxStricmp(units, "arcsec/hr") == 0 ||
- wxStricmp(units, "arc-sec/hr") == 0)
+ if (wxStricmp(units, "arcsec/hr") == 0 || wxStricmp(units, "arc-sec/hr") == 0)
{
shift->shiftUnits = UNIT_ARCSEC;
}
@@ -1372,7 +1489,8 @@ struct B64Encode
size_t nread;
B64Encode()
- : t(0), nread(0)
+ : t(0)
+ , nread(0)
{
}
void append1(unsigned char ch)
@@ -1381,10 +1499,7 @@ struct B64Encode
t |= ch;
if (++nread % 3 == 0)
{
- os << E[t >> 18]
- << E[(t >> 12) & 0x3F]
- << E[(t >> 6) & 0x3F]
- << E[t & 0x3F];
+ os << E[t >> 18] << E[(t >> 12) & 0x3F] << E[(t >> 6) & 0x3F] << E[t & 0x3F];
t = 0;
}
}
@@ -1397,17 +1512,13 @@ struct B64Encode
}
std::string finish()
{
- switch (nread % 3) {
+ switch (nread % 3)
+ {
case 1:
- os << E[t >> 2]
- << E[(t & 0x3) << 4]
- << "==";
+ os << E[t >> 2] << E[(t & 0x3) << 4] << "==";
break;
case 2:
- os << E[t >> 10]
- << E[(t >> 4) & 0x3F]
- << E[(t & 0xf) << 2]
- << '=';
+ os << E[t >> 10] << E[(t >> 4) & 0x3F] << E[(t & 0xf) << 2] << '=';
break;
}
return os.str();
@@ -1463,11 +1574,8 @@ static void get_star_image(JObj& response, const json_value *params)
pos.Y -= rect.GetTop();
JObj rslt;
- rslt << NV("frame", img->FrameNum)
- << NV("width", rect.GetWidth())
- << NV("height", rect.GetHeight())
- << NV("star_pos", pos)
- << NV("pixels", enc.finish());
+ rslt << NV("frame", img->FrameNum) << NV("width", rect.GetWidth()) << NV("height", rect.GetHeight()) << NV("star_pos", pos)
+ << NV("pixels", enc.finish());
response << jrpc_result(rslt);
}
@@ -1476,7 +1584,7 @@ static bool parse_settle(SettleParams *settle, const json_value *j, wxString *er
{
bool found_pixels = false, found_time = false, found_timeout = false;
- json_for_each (t, j)
+ json_for_each(t, j)
{
if (float_param("pixels", t, &settle->tolerancePx))
{
@@ -1593,7 +1701,8 @@ static void dither(JObj& response, const json_value *params)
//
// {"method": "dither", "params": [10, false, {"pixels": 1.5, "time": 8, "timeout": 30}], "id": 42}
// or
- // {"method": "dither", "params": {"amount": 10, "raOnly": false, "settle": {"pixels": 1.5, "time": 8, "timeout": 30}}, "id": 42}
+ // {"method": "dither", "params": {"amount": 10, "raOnly": false, "settle": {"pixels": 1.5, "time": 8, "timeout": 30}},
+ // "id": 42}
Params p("amount", "raOnly", "settle", params);
const json_value *jv;
@@ -1863,24 +1972,23 @@ static void get_settling(JObj& response, const json_value *params)
response << jrpc_result(settling);
}
-static void get_variable_delay_settings(JObj& response, const json_value* params)
+static void get_variable_delay_settings(JObj& response, const json_value *params)
{
JObj rslt;
VarDelayCfg delayParams = pFrame->GetVariableDelayConfig();
- rslt << NV("Enabled", delayParams.enabled)
- << NV("ShortDelaySeconds", delayParams.shortDelay / 1000)
- << NV("LongDelaySeconds", delayParams.longDelay / 1000);
+ rslt << NV("Enabled", delayParams.enabled) << NV("ShortDelaySeconds", delayParams.shortDelay / 1000)
+ << NV("LongDelaySeconds", delayParams.longDelay / 1000);
response << jrpc_result(rslt);
}
// set_variable_delay values are in units of seconds to match the UI convention in the Advanced Settings dialog
-static void set_variable_delay_settings(JObj& response, const json_value* params)
+static void set_variable_delay_settings(JObj& response, const json_value *params)
{
Params p("Enabled", "ShortDelaySeconds", "LongDelaySeconds", params);
- const json_value* p0 = p.param("Enabled");
- const json_value* p1 = p.param("ShortDelaySeconds");
- const json_value* p2 = p.param("LongDelaySeconds");
+ const json_value *p0 = p.param("Enabled");
+ const json_value *p1 = p.param("ShortDelaySeconds");
+ const json_value *p2 = p.param("LongDelaySeconds");
bool enabled;
double shortDelaySec;
double longDelaySec;
@@ -1890,7 +1998,7 @@ static void set_variable_delay_settings(JObj& response, const json_value* params
return;
}
VarDelayCfg currParams;
- pFrame->SetVariableDelayConfig(enabled, (int)shortDelaySec * 1000, (int)longDelaySec * 1000);
+ pFrame->SetVariableDelayConfig(enabled, (int) shortDelaySec * 1000, (int) longDelaySec * 1000);
response << jrpc_result(0);
}
@@ -1899,8 +2007,10 @@ static GUIDE_DIRECTION dir_param(const json_value *p)
if (!p || p->type != JSON_STRING)
return GUIDE_DIRECTION::NONE;
- struct {
- const char *s; GUIDE_DIRECTION d;
+ struct
+ {
+ const char *s;
+ GUIDE_DIRECTION d;
} dirs[] = {
{ "n", GUIDE_DIRECTION::NORTH },
{ "s", GUIDE_DIRECTION::SOUTH },
@@ -1925,12 +2035,18 @@ static GUIDE_DIRECTION dir_param(const json_value *p)
static GUIDE_DIRECTION opposite(GUIDE_DIRECTION d)
{
- switch (d) {
- case UP: return DOWN;
- case DOWN: return UP;
- case LEFT: return RIGHT;
- case RIGHT: return LEFT;
- default: return d;
+ switch (d)
+ {
+ case UP:
+ return DOWN;
+ case DOWN:
+ return UP;
+ case LEFT:
+ return RIGHT;
+ case RIGHT:
+ return LEFT;
+ default:
+ return d;
}
}
@@ -1956,8 +2072,12 @@ static void guide_pulse(JObj& response, const json_value *params)
Mount *m = nullptr;
switch (which)
{
- case MOUNT: m = TheScope(); break;
- case AO: m = TheAO(); break;
+ case MOUNT:
+ m = TheScope();
+ break;
+ case AO:
+ m = TheAO();
+ break;
case WHICH_MOUNT_BOTH:
case WHICH_MOUNT_ERR:
response << jrpc_error(1, "invalid 'which' param");
@@ -1990,10 +2110,14 @@ static void guide_pulse(JObj& response, const json_value *params)
static const char *parity_str(GuideParity p)
{
- switch (p) {
- case GUIDE_PARITY_EVEN: return "+";
- case GUIDE_PARITY_ODD: return "-";
- default: return "?";
+ switch (p)
+ {
+ case GUIDE_PARITY_EVEN:
+ return "+";
+ case GUIDE_PARITY_ODD:
+ return "-";
+ default:
+ return "?";
}
}
@@ -2005,14 +2129,18 @@ static void get_calibration_data(JObj& response, const json_value *params)
Mount *m = nullptr;
switch (which)
{
- case MOUNT: m = TheScope(); break;
- case AO: m = TheAO(); break;
+ case MOUNT:
+ m = TheScope();
+ break;
+ case AO:
+ m = TheAO();
+ break;
case WHICH_MOUNT_BOTH:
case WHICH_MOUNT_ERR:
- {
- response << jrpc_error(1, "invalid 'which' param");
- return;
- }
+ {
+ response << jrpc_error(1, "invalid 'which' param");
+ return;
+ }
}
if (!m || !m->IsConnected())
@@ -2026,13 +2154,10 @@ static void get_calibration_data(JObj& response, const json_value *params)
if (m->IsCalibrated())
{
- rslt << NV("xAngle", degrees(m->xAngle()), 1)
- << NV("xRate", m->xRate() * 1000.0, 3)
- << NV("xParity", parity_str(m->RAParity()))
- << NV("yAngle", degrees(m->yAngle()), 1)
- << NV("yRate", m->yRate() * 1000.0, 3)
- << NV("yParity", parity_str(m->DecParity()))
- << NV("declination", degrees(m->GetCalibrationDeclination()));
+ rslt << NV("xAngle", degrees(m->xAngle()), 1) << NV("xRate", m->xRate() * 1000.0, 3)
+ << NV("xParity", parity_str(m->RAParity())) << NV("yAngle", degrees(m->yAngle()), 1)
+ << NV("yRate", m->yRate() * 1000.0, 3) << NV("yParity", parity_str(m->DecParity()))
+ << NV("declination", degrees(m->GetCalibrationDeclination()));
}
response << jrpc_result(rslt);
@@ -2058,13 +2183,11 @@ static void get_cooler_status(JObj& response, const json_value *params)
JObj rslt;
- rslt << NV("coolerOn", on)
- << NV("temperature", temperature, 1);
+ rslt << NV("coolerOn", on) << NV("temperature", temperature, 1);
if (on)
{
- rslt << NV("setpoint", setpoint, 1)
- << NV("power", power, 1);
+ rslt << NV("setpoint", setpoint, 1) << NV("power", power, 1);
}
response << jrpc_result(rslt);
@@ -2116,7 +2239,12 @@ struct JRpcCall
const json_value *method;
JRpcResponse response;
- JRpcCall(wxSocketClient *cli_, const json_value *req_) : cli(cli_), req(req_), method(nullptr) { }
+ JRpcCall(wxSocketClient *cli_, const json_value *req_)
+ : cli(cli_)
+ , req(req_)
+ , method(nullptr)
+ {
+ }
};
static void dump_request(const JRpcCall& call)
@@ -2164,62 +2292,208 @@ static bool handle_request(JRpcCall& call)
return true;
}
- static struct {
+ static struct
+ {
const char *name;
void (*fn)(JObj& response, const json_value *params);
- } methods[] = {
- { "clear_calibration", &clear_calibration, },
- { "deselect_star", &deselect_star, },
- { "get_exposure", &get_exposure, },
- { "set_exposure", &set_exposure, },
- { "get_exposure_durations", &get_exposure_durations, },
- { "get_profiles", &get_profiles, },
- { "get_profile", &get_profile, },
- { "set_profile", &set_profile, },
- { "get_connected", &get_connected, },
- { "set_connected", &set_connected, },
- { "get_calibrated", &get_calibrated, },
- { "get_paused", &get_paused, },
- { "set_paused", &set_paused, },
- { "get_lock_position", &get_lock_position, },
- { "set_lock_position", &set_lock_position, },
- { "loop", &loop, },
- { "stop_capture", &stop_capture, },
- { "guide", &guide, },
- { "dither", &dither, },
- { "find_star", &find_star, },
- { "get_pixel_scale", &get_pixel_scale, },
- { "get_app_state", &get_app_state, },
- { "flip_calibration", &flip_calibration, },
- { "get_lock_shift_enabled", &get_lock_shift_enabled, },
- { "set_lock_shift_enabled", &set_lock_shift_enabled, },
- { "get_lock_shift_params", &get_lock_shift_params, },
- { "set_lock_shift_params", &set_lock_shift_params, },
- { "save_image", &save_image, },
- { "get_star_image", &get_star_image, },
- { "get_use_subframes", &get_use_subframes, },
- { "get_search_region", &get_search_region, },
- { "shutdown", &shutdown, },
- { "get_camera_binning", &get_camera_binning, },
- { "get_camera_frame_size", &get_camera_frame_size, },
- { "get_current_equipment", &get_current_equipment, },
- { "get_guide_output_enabled", &get_guide_output_enabled, },
- { "set_guide_output_enabled", &set_guide_output_enabled, },
- { "get_algo_param_names", &get_algo_param_names, },
- { "get_algo_param", &get_algo_param, },
- { "set_algo_param", &set_algo_param, },
- { "get_dec_guide_mode", &get_dec_guide_mode, },
- { "set_dec_guide_mode", &set_dec_guide_mode, },
- { "get_settling", &get_settling, },
- { "guide_pulse", &guide_pulse, },
- { "get_calibration_data", &get_calibration_data, },
- { "capture_single_frame", &capture_single_frame, },
- { "get_cooler_status", &get_cooler_status, },
- { "get_ccd_temperature", &get_sensor_temperature, },
- { "export_config_settings", &export_config_settings, },
- { "get_variable_delay_settings", &get_variable_delay_settings},
- { "set_variable_delay_settings", &set_variable_delay_settings}
- };
+ } methods[] = { {
+ "clear_calibration",
+ &clear_calibration,
+ },
+ {
+ "deselect_star",
+ &deselect_star,
+ },
+ {
+ "get_exposure",
+ &get_exposure,
+ },
+ {
+ "set_exposure",
+ &set_exposure,
+ },
+ {
+ "get_exposure_durations",
+ &get_exposure_durations,
+ },
+ {
+ "get_profiles",
+ &get_profiles,
+ },
+ {
+ "get_profile",
+ &get_profile,
+ },
+ {
+ "set_profile",
+ &set_profile,
+ },
+ {
+ "get_connected",
+ &get_connected,
+ },
+ {
+ "set_connected",
+ &set_connected,
+ },
+ {
+ "get_calibrated",
+ &get_calibrated,
+ },
+ {
+ "get_paused",
+ &get_paused,
+ },
+ {
+ "set_paused",
+ &set_paused,
+ },
+ {
+ "get_lock_position",
+ &get_lock_position,
+ },
+ {
+ "set_lock_position",
+ &set_lock_position,
+ },
+ {
+ "loop",
+ &loop,
+ },
+ {
+ "stop_capture",
+ &stop_capture,
+ },
+ {
+ "guide",
+ &guide,
+ },
+ {
+ "dither",
+ &dither,
+ },
+ {
+ "find_star",
+ &find_star,
+ },
+ {
+ "get_pixel_scale",
+ &get_pixel_scale,
+ },
+ {
+ "get_app_state",
+ &get_app_state,
+ },
+ {
+ "flip_calibration",
+ &flip_calibration,
+ },
+ {
+ "get_lock_shift_enabled",
+ &get_lock_shift_enabled,
+ },
+ {
+ "set_lock_shift_enabled",
+ &set_lock_shift_enabled,
+ },
+ {
+ "get_lock_shift_params",
+ &get_lock_shift_params,
+ },
+ {
+ "set_lock_shift_params",
+ &set_lock_shift_params,
+ },
+ {
+ "save_image",
+ &save_image,
+ },
+ {
+ "get_star_image",
+ &get_star_image,
+ },
+ {
+ "get_use_subframes",
+ &get_use_subframes,
+ },
+ {
+ "get_search_region",
+ &get_search_region,
+ },
+ {
+ "shutdown",
+ &shutdown,
+ },
+ {
+ "get_camera_binning",
+ &get_camera_binning,
+ },
+ {
+ "get_camera_frame_size",
+ &get_camera_frame_size,
+ },
+ {
+ "get_current_equipment",
+ &get_current_equipment,
+ },
+ {
+ "get_guide_output_enabled",
+ &get_guide_output_enabled,
+ },
+ {
+ "set_guide_output_enabled",
+ &set_guide_output_enabled,
+ },
+ {
+ "get_algo_param_names",
+ &get_algo_param_names,
+ },
+ {
+ "get_algo_param",
+ &get_algo_param,
+ },
+ {
+ "set_algo_param",
+ &set_algo_param,
+ },
+ {
+ "get_dec_guide_mode",
+ &get_dec_guide_mode,
+ },
+ {
+ "set_dec_guide_mode",
+ &set_dec_guide_mode,
+ },
+ {
+ "get_settling",
+ &get_settling,
+ },
+ {
+ "guide_pulse",
+ &guide_pulse,
+ },
+ {
+ "get_calibration_data",
+ &get_calibration_data,
+ },
+ {
+ "capture_single_frame",
+ &capture_single_frame,
+ },
+ {
+ "get_cooler_status",
+ &get_cooler_status,
+ },
+ {
+ "get_ccd_temperature",
+ &get_sensor_temperature,
+ },
+ {
+ "export_config_settings",
+ &export_config_settings,
+ },
+ { "get_variable_delay_settings", &get_variable_delay_settings },
+ { "set_variable_delay_settings", &set_variable_delay_settings } };
for (unsigned int i = 0; i < WXSIZEOF(methods); i++)
{
@@ -2269,7 +2543,7 @@ static void handle_cli_input_complete(wxSocketClient *cli, char *input, JsonPars
JAry ary;
bool found = false;
- json_for_each (req, root)
+ json_for_each(req, root)
{
JRpcCall call(cli, req);
if (handle_request(call))
@@ -2354,9 +2628,7 @@ EventServer::EventServer()
{
}
-EventServer::~EventServer()
-{
-}
+EventServer::~EventServer() { }
bool EventServer::EventServerStart(unsigned int instanceId)
{
@@ -2395,8 +2667,7 @@ void EventServer::EventServerStop()
if (!m_serverSocket)
return;
- for (CliSockSet::const_iterator it = m_eventServerClients.begin();
- it != m_eventServerClients.end(); ++it)
+ for (CliSockSet::const_iterator it = m_eventServerClients.begin(); it != m_eventServerClients.end(); ++it)
{
destroy_client(*it);
}
@@ -2472,13 +2743,8 @@ void EventServer::NotifyCalibrationStep(const CalibrationStepInfo& info)
Ev ev("Calibrating");
- ev << NVMount(info.mount)
- << NV("dir", info.direction)
- << NV("dist", info.dist)
- << NV("dx", info.dx)
- << NV("dy", info.dy)
- << NV("pos", info.pos)
- << NV("step", info.stepNumber);
+ ev << NVMount(info.mount) << NV("dir", info.direction) << NV("dist", info.dist) << NV("dx", info.dx) << NV("dy", info.dy)
+ << NV("pos", info.pos) << NV("step", info.stepNumber);
if (!info.msg.empty())
ev << NV("State", info.msg);
@@ -2549,9 +2815,7 @@ void EventServer::NotifyLooping(unsigned int exposure, const Star *star, const F
if (mass)
{
- ev << NV("StarMass", mass, 0)
- << NV("SNR", snr, 2)
- << NV("HFD", hfd, 2);
+ ev << NV("StarMass", mass, 0) << NV("SNR", snr, 2) << NV("HFD", hfd, 2);
}
if (err)
@@ -2580,12 +2844,8 @@ void EventServer::NotifyStarLost(const FrameDroppedInfo& info)
Ev ev("StarLost");
- ev << NV("Frame", info.frameNumber)
- << NV("Time", info.time, 3)
- << NV("StarMass", info.starMass, 0)
- << NV("SNR", info.starSNR, 2)
- << NV("HFD", info.starHFD, 2)
- << NV("AvgDist", info.avgDist, 2);
+ ev << NV("Frame", info.frameNumber) << NV("Time", info.time, 3) << NV("StarMass", info.starMass, 0)
+ << NV("SNR", info.starSNR, 2) << NV("HFD", info.starHFD, 2) << NV("AvgDist", info.avgDist, 2);
if (info.starError)
ev << NV("ErrorCode", info.starError);
@@ -2623,26 +2883,21 @@ void EventServer::NotifyGuideStep(const GuideStepInfo& step)
Ev ev("GuideStep");
- ev << NV("Frame", step.frameNumber)
- << NV("Time", step.time, 3)
- << NVMount(step.mount)
- << NV("dx", step.cameraOffset.X, 3)
- << NV("dy", step.cameraOffset.Y, 3)
- << NV("RADistanceRaw", step.mountOffset.X, 3)
- << NV("DECDistanceRaw", step.mountOffset.Y, 3)
- << NV("RADistanceGuide", step.guideDistanceRA, 3)
+ ev << NV("Frame", step.frameNumber) << NV("Time", step.time, 3) << NVMount(step.mount) << NV("dx", step.cameraOffset.X, 3)
+ << NV("dy", step.cameraOffset.Y, 3) << NV("RADistanceRaw", step.mountOffset.X, 3)
+ << NV("DECDistanceRaw", step.mountOffset.Y, 3) << NV("RADistanceGuide", step.guideDistanceRA, 3)
<< NV("DECDistanceGuide", step.guideDistanceDec, 3);
if (step.durationRA > 0)
{
- ev << NV("RADuration", step.durationRA)
- << NV("RADirection", step.mount->DirectionStr((GUIDE_DIRECTION)step.directionRA));
+ ev << NV("RADuration", step.durationRA)
+ << NV("RADirection", step.mount->DirectionStr((GUIDE_DIRECTION) step.directionRA));
}
if (step.durationDec > 0)
{
ev << NV("DECDuration", step.durationDec)
- << NV("DECDirection", step.mount->DirectionStr((GUIDE_DIRECTION)step.directionDec));
+ << NV("DECDirection", step.mount->DirectionStr((GUIDE_DIRECTION) step.directionDec));
}
if (step.mount->IsStepGuider())
@@ -2650,13 +2905,11 @@ void EventServer::NotifyGuideStep(const GuideStepInfo& step)
ev << NV("Pos", step.aoPos);
}
- ev << NV("StarMass", step.starMass, 0)
- << NV("SNR", step.starSNR, 2)
- << NV("HFD", step.starHFD, 2)
+ ev << NV("StarMass", step.starMass, 0) << NV("SNR", step.starSNR, 2) << NV("HFD", step.starHFD, 2)
<< NV("AvgDist", step.avgDist, 2);
if (step.starError)
- ev << NV("ErrorCode", step.starError);
+ ev << NV("ErrorCode", step.starError);
if (step.raLimited)
ev << NV("RALimited", true);
diff --git a/src/fitsiowrap.cpp b/src/fitsiowrap.cpp
index 1ad2aba61..5ff5168d4 100644
--- a/src/fitsiowrap.cpp
+++ b/src/fitsiowrap.cpp
@@ -1,37 +1,37 @@
/*
-* fitsiowrap.cpp
-* PHD Guiding
-*
-* Created by Andy Galasso
-* Copyright (c) 2014 Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Craig Stark, Stark Labs,
-* Bret McKee, Dad Dog Development, Ltd, nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * fitsiowrap.cpp
+ * PHD Guiding
+ *
+ * Created by Andy Galasso
+ * Copyright (c) 2014 Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Craig Stark, Stark Labs,
+ * Bret McKee, Dad Dog Development, Ltd, nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
@@ -46,7 +46,8 @@ class FitsFname
public:
FitsFname(const wxString& str, bool create, bool clobber);
- ~FitsFname() {
+ ~FitsFname()
+ {
#ifdef __WINDOWS__
delete[] m_str;
#endif
diff --git a/src/fitsiowrap.h b/src/fitsiowrap.h
index b4794bc65..415775a3f 100644
--- a/src/fitsiowrap.h
+++ b/src/fitsiowrap.h
@@ -1,37 +1,37 @@
/*
-* fitsiowrap.h
-* PHD Guiding
-*
-* Created by Andy Galasso
-* Copyright (c) 2014 Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Craig Stark, Stark Labs,
-* Bret McKee, Dad Dog Development, Ltd, nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * fitsiowrap.h
+ * PHD Guiding
+ *
+ * Created by Andy Galasso
+ * Copyright (c) 2014 Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Craig Stark, Stark Labs,
+ * Bret McKee, Dad Dog Development, Ltd, nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#ifndef FITSIOWRAP_INCLUDED
#define FITSIOWRAP_INCLUDED
@@ -48,26 +48,34 @@ class FITSHdrWriter
int *status;
public:
+ FITSHdrWriter(fitsfile *fptr_, int *status_)
+ : fptr(fptr_)
+ , status(status_)
+ {
+ }
- FITSHdrWriter(fitsfile *fptr_, int *status_) : fptr(fptr_), status(status_) { }
-
- void write(const char *key, float val, const char *comment) {
+ void write(const char *key, float val, const char *comment)
+ {
fits_write_key(fptr, TFLOAT, const_cast(key), &val, const_cast(comment), status);
}
- void write(const char *key, unsigned int val, const char *comment) {
+ void write(const char *key, unsigned int val, const char *comment)
+ {
fits_write_key(fptr, TUINT, const_cast(key), &val, const_cast(comment), status);
}
- void write(const char *key, int val, const char *comment) {
+ void write(const char *key, int val, const char *comment)
+ {
fits_write_key(fptr, TINT, const_cast(key), &val, const_cast(comment), status);
}
- void write(const char *key, const char *val, const char *comment) {
+ void write(const char *key, const char *val, const char *comment)
+ {
fits_write_key(fptr, TSTRING, const_cast(key), const_cast(val), const_cast(comment), status);
}
- void write(const char *key, const wxDateTime& t, const wxDateTime::TimeZone& z, const char *comment) {
+ void write(const char *key, const wxDateTime& t, const wxDateTime::TimeZone& z, const char *comment)
+ {
wxString s = t.Format("%Y-%m-%dT%H:%M:%S", z) + wxString::Format(".%03d", t.GetMillisecond(z));
write(key, (const char *) s.c_str(), comment);
}
diff --git a/src/gear_dialog.cpp b/src/gear_dialog.cpp
index 77691ad3b..fb7df84ff 100644
--- a/src/gear_dialog.cpp
+++ b/src/gear_dialog.cpp
@@ -118,33 +118,33 @@ wxEND_EVENT_TABLE();
* | +-------------------+ +-------------------+ |
* +--------------------------------------------------------------------------+
*/
-GearDialog::GearDialog(wxWindow *pParent) :
- wxDialog(pParent, wxID_ANY, _("Connect Equipment"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX),
- m_cameraUpdated(false),
- m_mountUpdated(false),
- m_stepGuiderUpdated(false),
- m_rotatorUpdated(false),
- m_showDarksDialog(false),
- m_camWarningIssued(false),
- m_camChanged(false),
- m_imageScaleRatio(1.0),
- m_flushConfig(false)
-{
- m_pCamera = nullptr;
- m_pScope = nullptr;
+GearDialog::GearDialog(wxWindow *pParent)
+ : wxDialog(pParent, wxID_ANY, _("Connect Equipment"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
+ , m_cameraUpdated(false)
+ , m_mountUpdated(false)
+ , m_stepGuiderUpdated(false)
+ , m_rotatorUpdated(false)
+ , m_showDarksDialog(false)
+ , m_camWarningIssued(false)
+ , m_camChanged(false)
+ , m_imageScaleRatio(1.0)
+ , m_flushConfig(false)
+{
+ m_pCamera = nullptr;
+ m_pScope = nullptr;
m_pAuxScope = nullptr;
m_pStepGuider = nullptr;
m_pRotator = nullptr;
- m_pCameras = nullptr;
- m_pScopes = nullptr;
- m_pAuxScopes = nullptr;
- m_pStepGuiders = nullptr;
+ m_pCameras = nullptr;
+ m_pScopes = nullptr;
+ m_pAuxScopes = nullptr;
+ m_pStepGuiders = nullptr;
m_pRotators = nullptr;
- m_pConnectCameraButton = nullptr;
- m_pConnectScopeButton = nullptr;
- m_pConnectAuxScopeButton = nullptr;
+ m_pConnectCameraButton = nullptr;
+ m_pConnectScopeButton = nullptr;
+ m_pConnectAuxScopeButton = nullptr;
m_pConnectStepGuiderButton = nullptr;
m_pConnectRotatorButton = nullptr;
@@ -171,8 +171,8 @@ GearDialog::~GearDialog()
delete m_pRotator;
// prevent double frees
- pCamera = nullptr;
- pMount = nullptr;
+ pCamera = nullptr;
+ pMount = nullptr;
pSecondaryMount = nullptr;
pPointingSource = nullptr;
pRotator = nullptr;
@@ -182,9 +182,9 @@ GearDialog::~GearDialog()
static wxToggleButton *MakeConnectBtn(wxWindow *parent, wxWindowID id)
{
-# include "icons/connected.png.h"
+#include "icons/connected.png.h"
wxBitmap connected_bmp(wxBITMAP_PNG_FROM_DATA(connected));
-# include "icons/disconnected.png.h"
+#include "icons/disconnected.png.h"
wxBitmap disconnected_bmp(wxBITMAP_PNG_FROM_DATA(disconnected));
wxToggleButton *btn = new wxToggleButton(parent, id, _("Disconnect"), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
@@ -206,9 +206,9 @@ static wxToggleButton *MakeConnectBtn(wxWindow *parent, wxWindowID id)
void GearDialog::Initialize()
{
- wxSizerFlags sizerFlags = wxSizerFlags().Align(wxALIGN_CENTER).Border(wxALL,2).Expand();
- wxSizerFlags sizerTextFlags = wxSizerFlags().Align(wxALIGN_CENTER).Border(wxALL,2).Expand();
- wxSizerFlags sizerLabelFlags = wxSizerFlags().Align(wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL).Border(wxALL, 2);
+ wxSizerFlags sizerFlags = wxSizerFlags().Align(wxALIGN_CENTER).Border(wxALL, 2).Expand();
+ wxSizerFlags sizerTextFlags = wxSizerFlags().Align(wxALIGN_CENTER).Border(wxALL, 2).Expand();
+ wxSizerFlags sizerLabelFlags = wxSizerFlags().Align(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL).Border(wxALL, 2);
wxSizerFlags sizerButtonFlags = wxSizerFlags().Align(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL).Border(wxALL, 2).Expand();
wxBoxSizer *pTopLevelSizer = new wxBoxSizer(wxVERTICAL);
@@ -216,13 +216,15 @@ void GearDialog::Initialize()
wxBoxSizer *profilesSizer = new wxBoxSizer(wxHORIZONTAL);
profilesSizer->Add(new wxStaticText(this, wxID_ANY, _("Equipment profile")), sizerLabelFlags);
m_profiles = new wxChoice(this, GEAR_PROFILES, wxDefaultPosition, wxDefaultSize, pConfig->ProfileNames());
- m_profiles->SetToolTip(_("Select the Equipment Profile you would like to use. PHD stores all of your settings and equipment selections in an Equipment Profile. "
+ m_profiles->SetToolTip(_("Select the Equipment Profile you would like to use. PHD stores all of your settings and "
+ "equipment selections in an Equipment Profile. "
"You can create multiple profiles and switch back and forth between them."));
m_profiles->SetStringSelection(pConfig->GetCurrentProfile());
profilesSizer->Add(m_profiles, sizerButtonFlags);
m_menuProfileManage = new wxMenu();
- m_menuProfileManage->Append(GEAR_PROFILE_WIZARD, _("New using Wizard..."), _("Run the first-light wizard to create a new profile"));
+ m_menuProfileManage->Append(
+ GEAR_PROFILE_WIZARD, _("New using Wizard..."), _("Run the first-light wizard to create a new profile"));
m_menuProfileManage->Append(GEAR_PROFILE_NEW, _("New"), _("Create a new profile, optionally copying from another profile"));
m_menuProfileManage->Append(GEAR_PROFILE_DELETE, _("Delete"), _("Delete the selected profile"));
m_menuProfileManage->Append(GEAR_PROFILE_RENAME, _("Rename"), _("Rename the selected profile"));
@@ -234,17 +236,20 @@ void GearDialog::Initialize()
m_btnProfileManage->SetToolTip(_("Create a new Equipment Profile, or delete or rename the selected Equipment Profile"));
profilesSizer->Add(m_btnProfileManage, sizerButtonFlags);
- pTopLevelSizer->Add(profilesSizer, wxSizerFlags().Align(wxALIGN_CENTER).Border(wxALL,2));
+ pTopLevelSizer->Add(profilesSizer, wxSizerFlags().Align(wxALIGN_CENTER).Border(wxALL, 2));
pTopLevelSizer->AddSpacer(10);
// text at the top. I tried (really really hard) to get it to resize/Wrap()
// with the rest of the sizer, but it just didn't want to work, and I needed
// to get the rest of the dialog working.
- wxStaticText *pText = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
+ wxStaticText *pText = new wxStaticText(
+ this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
int width, height;
- pText->SetLabel(_("Select your equipment below and click Connect All to connect, or click Disconnect All to disconnect. You can also connect or disconnect individual equipment items by clicking the button next to the item."));
+ pText->SetLabel(
+ _("Select your equipment below and click Connect All to connect, or click Disconnect All to disconnect. You can also "
+ "connect or disconnect individual equipment items by clicking the button next to the item."));
pText->GetTextExtent(_T("MMMMMMMMMM"), &width, &height);
- pText->Wrap(4*width);
+ pText->Wrap(4 * width);
pTopLevelSizer->Add(pText, sizerTextFlags.Align(wxALIGN_CENTER));
// The Gear grid in the middle of the screen
@@ -252,14 +257,15 @@ void GearDialog::Initialize()
pTopLevelSizer->Add(m_gearSizer, wxSizerFlags().Align(wxALIGN_CENTER).Border(wxALL, 2));
// Camera
- m_gearSizer->Add(new wxStaticText(this, wxID_ANY, _("Camera"), wxDefaultPosition, wxDefaultSize), wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
- m_pCameras = new wxChoice(this, GEAR_CHOICE_CAMERA, wxDefaultPosition, wxDefaultSize,
- 0, nullptr, 0, wxDefaultValidator, _("Camera"));
+ m_gearSizer->Add(new wxStaticText(this, wxID_ANY, _("Camera"), wxDefaultPosition, wxDefaultSize), wxGBPosition(0, 0),
+ wxGBSpan(1, 1), wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
+ m_pCameras = new wxChoice(
+ this, GEAR_CHOICE_CAMERA, wxDefaultPosition, wxDefaultSize, 0, nullptr, 0, wxDefaultValidator, _("Camera"));
m_gearSizer->Add(m_pCameras, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
-# include "icons/select.png.h"
+#include "icons/select.png.h"
wxBitmap select_bmp(wxBITMAP_PNG_FROM_DATA(select));
-# include "icons/setup.png.h"
+#include "icons/setup.png.h"
wxBitmap setup_bmp(wxBITMAP_PNG_FROM_DATA(setup));
m_selectCameraButton = new wxBitmapButton(this, GEAR_BUTTON_SELECT_CAMERA, select_bmp);
@@ -270,35 +276,44 @@ void GearDialog::Initialize()
m_pSetupCameraButton->SetToolTip(_("Camera Setup"));
m_gearSizer->Add(m_pSetupCameraButton, wxGBPosition(0, 3), wxGBSpan(1, 1), wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
m_pConnectCameraButton = MakeConnectBtn(this, GEAR_BUTTON_CONNECT_CAMERA);
- m_gearSizer->Add(m_pConnectCameraButton, wxGBPosition(0, 4), wxGBSpan(1, 1), wxBOTTOM | wxTOP | wxRIGHT | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
+ m_gearSizer->Add(m_pConnectCameraButton, wxGBPosition(0, 4), wxGBSpan(1, 1),
+ wxBOTTOM | wxTOP | wxRIGHT | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
// mount
- m_gearSizer->Add(new wxStaticText(this, wxID_ANY, _("Mount"), wxDefaultPosition, wxDefaultSize), wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
- m_pScopes = new wxChoice(this, GEAR_CHOICE_SCOPE, wxDefaultPosition, wxDefaultSize,
- 0, nullptr, 0, wxDefaultValidator, _("Mount"));
- m_pScopes->SetToolTip(_("Specify how guide commands will be sent to the mount - via an ASCOM or INDI driver, directly from the camera or AO, "
- "or via one of the GPxxx devices. An ASCOM connection is recommended."));
+ m_gearSizer->Add(new wxStaticText(this, wxID_ANY, _("Mount"), wxDefaultPosition, wxDefaultSize), wxGBPosition(1, 0),
+ wxGBSpan(1, 1), wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
+ m_pScopes =
+ new wxChoice(this, GEAR_CHOICE_SCOPE, wxDefaultPosition, wxDefaultSize, 0, nullptr, 0, wxDefaultValidator, _("Mount"));
+ m_pScopes->SetToolTip(
+ _("Specify how guide commands will be sent to the mount - via an ASCOM or INDI driver, directly from the camera or AO, "
+ "or via one of the GPxxx devices. An ASCOM connection is recommended."));
m_gearSizer->Add(m_pScopes, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
m_pSetupScopeButton = new wxBitmapButton(this, GEAR_BUTTON_SETUP_SCOPE, setup_bmp);
m_pSetupScopeButton->SetToolTip(_("Mount Setup"));
m_gearSizer->Add(m_pSetupScopeButton, wxGBPosition(1, 3), wxGBSpan(1, 1), wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
m_pConnectScopeButton = MakeConnectBtn(this, GEAR_BUTTON_CONNECT_SCOPE);
- m_gearSizer->Add(m_pConnectScopeButton, wxGBPosition(1, 4), wxGBSpan(1, 1), wxBOTTOM | wxTOP | wxRIGHT | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
+ m_gearSizer->Add(m_pConnectScopeButton, wxGBPosition(1, 4), wxGBSpan(1, 1),
+ wxBOTTOM | wxTOP | wxRIGHT | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
// aux mount - used for position/state information when not guiding through ASCOM interface
- m_gearSizer->Add(new wxStaticText(this, wxID_ANY, _("Aux Mount"), wxDefaultPosition, wxDefaultSize), wxGBPosition(2, 0), wxGBSpan(1, 1), wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
- m_pAuxScopes = new wxChoice(this, GEAR_CHOICE_AUXSCOPE, wxDefaultPosition, wxDefaultSize,
- 0, nullptr, 0, wxDefaultValidator, _("Aux Mount"));
+ m_gearSizer->Add(new wxStaticText(this, wxID_ANY, _("Aux Mount"), wxDefaultPosition, wxDefaultSize), wxGBPosition(2, 0),
+ wxGBSpan(1, 1), wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
+ m_pAuxScopes = new wxChoice(
+ this, GEAR_CHOICE_AUXSCOPE, wxDefaultPosition, wxDefaultSize, 0, nullptr, 0, wxDefaultValidator, _("Aux Mount"));
#if defined(GUIDE_ASCOM) || defined(GUIDE_INDI)
-#ifdef GUIDE_ASCOM
+# ifdef GUIDE_ASCOM
wxString driverName = _T("ASCOM");
# else
wxString driverName = _T("INDI");
-#endif
- m_pAuxScopes->SetToolTip(wxString::Format(_("If you are using a guide port (On-camera or GPXXX) interface for guiding, you can also use an 'aux' connection to your %s-compatible mount. This will "
- "be used to make automatic calibration adjustments based on declination and side-of-pier. If you have already selected an %s driver for your 'mount', the 'aux' mount "
- "parameter will not be used."), driverName, driverName));
+# endif
+ m_pAuxScopes->SetToolTip(
+ wxString::Format(_("If you are using a guide port (On-camera or GPXXX) interface for guiding, you can also use an "
+ "'aux' connection to your %s-compatible mount. This will "
+ "be used to make automatic calibration adjustments based on declination and side-of-pier. If you "
+ "have already selected an %s driver for your 'mount', the 'aux' mount "
+ "parameter will not be used."),
+ driverName, driverName));
#endif // ASCOM or INDI
m_gearSizer->Add(m_pAuxScopes, wxGBPosition(2, 1), wxGBSpan(1, 1), wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
@@ -306,47 +321,54 @@ void GearDialog::Initialize()
m_pSetupAuxScopeButton->SetToolTip(_("Aux Mount Setup"));
m_gearSizer->Add(m_pSetupAuxScopeButton, wxGBPosition(2, 3), wxGBSpan(1, 1), wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
m_pConnectAuxScopeButton = MakeConnectBtn(this, GEAR_BUTTON_CONNECT_AUXSCOPE);
- m_gearSizer->Add(m_pConnectAuxScopeButton, wxGBPosition(2, 4), wxGBSpan(1, 1), wxBOTTOM | wxTOP | wxRIGHT | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
+ m_gearSizer->Add(m_pConnectAuxScopeButton, wxGBPosition(2, 4), wxGBSpan(1, 1),
+ wxBOTTOM | wxTOP | wxRIGHT | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
m_moreButton = new wxButton(this, GEAR_BUTTON_MORE, wxEmptyString);
m_gearSizer->Add(m_moreButton, wxGBPosition(3, 0), wxGBSpan(1, 4), wxALL | /*wxALIGN_CENTER*/ wxALIGN_LEFT, 5);
// ao
- m_gearSizer->Add(new wxStaticText(this, wxID_ANY, _("AO"), wxDefaultPosition, wxDefaultSize), wxGBPosition(4, 0), wxGBSpan(1, 1), wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
- m_pStepGuiders = new wxChoice(this, GEAR_CHOICE_STEPGUIDER, wxDefaultPosition, wxDefaultSize,
- 0, nullptr, 0, wxDefaultValidator, _("AO"));
+ m_gearSizer->Add(new wxStaticText(this, wxID_ANY, _("AO"), wxDefaultPosition, wxDefaultSize), wxGBPosition(4, 0),
+ wxGBSpan(1, 1), wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
+ m_pStepGuiders = new wxChoice(
+ this, GEAR_CHOICE_STEPGUIDER, wxDefaultPosition, wxDefaultSize, 0, nullptr, 0, wxDefaultValidator, _("AO"));
m_gearSizer->Add(m_pStepGuiders, wxGBPosition(4, 1), wxGBSpan(1, 1), wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
m_pSetupStepGuiderButton = new wxBitmapButton(this, GEAR_BUTTON_SETUP_STEPGUIDER, setup_bmp);
m_pSetupStepGuiderButton->SetToolTip(_("AO Setup"));
- m_gearSizer->Add(m_pSetupStepGuiderButton, wxGBPosition(4, 3), wxGBSpan(1, 1), wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
+ m_gearSizer->Add(
+ m_pSetupStepGuiderButton, wxGBPosition(4, 3), wxGBSpan(1, 1), wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
m_pConnectStepGuiderButton = MakeConnectBtn(this, GEAR_BUTTON_CONNECT_STEPGUIDER);
- m_gearSizer->Add(m_pConnectStepGuiderButton, wxGBPosition(4, 4), wxGBSpan(1, 1), wxBOTTOM | wxTOP | wxRIGHT | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
+ m_gearSizer->Add(m_pConnectStepGuiderButton, wxGBPosition(4, 4), wxGBSpan(1, 1),
+ wxBOTTOM | wxTOP | wxRIGHT | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
// rotator
- m_gearSizer->Add(new wxStaticText(this, wxID_ANY, _("Rotator"), wxDefaultPosition, wxDefaultSize), wxGBPosition(5, 0), wxGBSpan(1, 1), wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
- m_pRotators = new wxChoice(this, GEAR_CHOICE_ROTATOR, wxDefaultPosition, wxDefaultSize, 0, nullptr, 0, wxDefaultValidator, _("Rotator"));
+ m_gearSizer->Add(new wxStaticText(this, wxID_ANY, _("Rotator"), wxDefaultPosition, wxDefaultSize), wxGBPosition(5, 0),
+ wxGBSpan(1, 1), wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
+ m_pRotators = new wxChoice(
+ this, GEAR_CHOICE_ROTATOR, wxDefaultPosition, wxDefaultSize, 0, nullptr, 0, wxDefaultValidator, _("Rotator"));
m_gearSizer->Add(m_pRotators, wxGBPosition(5, 1), wxGBSpan(1, 1), wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
m_pSetupRotatorButton = new wxBitmapButton(this, GEAR_BUTTON_SETUP_ROTATOR, setup_bmp);
m_pSetupRotatorButton->SetToolTip(_("Rotator Setup"));
m_gearSizer->Add(m_pSetupRotatorButton, wxGBPosition(5, 3), wxGBSpan(1, 1), wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
m_pConnectRotatorButton = MakeConnectBtn(this, GEAR_BUTTON_CONNECT_ROTATOR);
- m_gearSizer->Add(m_pConnectRotatorButton, wxGBPosition(5, 4), wxGBSpan(1, 1), wxBOTTOM | wxTOP | wxRIGHT | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
+ m_gearSizer->Add(m_pConnectRotatorButton, wxGBPosition(5, 4), wxGBSpan(1, 1),
+ wxBOTTOM | wxTOP | wxRIGHT | wxEXPAND | wxALIGN_CENTER_VERTICAL, 5);
// Setup the bottom row of buttons
wxBoxSizer *pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
- m_pConnectAllButton = new wxButton( this, GEAR_BUTTON_CONNECT_ALL, _("Connect All"));
+ m_pConnectAllButton = new wxButton(this, GEAR_BUTTON_CONNECT_ALL, _("Connect All"));
m_pConnectAllButton->SetToolTip(_("Connect all equipment and close the equipment selection window"));
pButtonSizer->Add(m_pConnectAllButton, sizerFlags);
- m_pDisconnectAllButton = new wxButton( this, GEAR_BUTTON_DISCONNECT_ALL, _("Disconnect All"));
+ m_pDisconnectAllButton = new wxButton(this, GEAR_BUTTON_DISCONNECT_ALL, _("Disconnect All"));
m_pDisconnectAllButton->SetToolTip(_("Disconnect all equipment"));
pButtonSizer->Add(m_pDisconnectAllButton, sizerFlags);
- wxButton* closeBtn = new wxButton(this, wxID_CANCEL, _("Close"));
+ wxButton *closeBtn = new wxButton(this, wxID_CANCEL, _("Close"));
pButtonSizer->Add(closeBtn, sizerFlags);
- pTopLevelSizer->Add(pButtonSizer, wxSizerFlags().Align(wxALIGN_TOP|wxALIGN_CENTER_HORIZONTAL).Border(wxALL,2));
+ pTopLevelSizer->Add(pButtonSizer, wxSizerFlags().Align(wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL).Border(wxALL, 2));
// preselect the choices
LoadGearChoices();
@@ -424,8 +446,10 @@ static wxString NewAoName(const wxString& oldname)
// we renamed the AOs when we added the INDI SBIG AO
// temporary code to convert the old names to the new
// this should be removed after a release or two
- if (oldname == _T("sxAO")) return _T("SX AO");
- if (oldname == _T("INDI sxAO")) return _T("SX AO (INDI)");
+ if (oldname == _T("sxAO"))
+ return _T("SX AO");
+ if (oldname == _T("INDI sxAO"))
+ return _T("SX AO (INDI)");
return oldname;
}
#endif
@@ -488,10 +512,8 @@ int GearDialog::ShowGearDialog(bool autoConnect)
wxCommandEvent dummyEvent;
OnButtonConnectAll(dummyEvent);
- if (m_pCamera && m_pCamera->Connected &&
- (!m_pScope || m_pScope->IsConnected()) &&
- (!m_pAuxScope || m_pAuxScope->IsConnected()) &&
- (!m_pStepGuider || m_pStepGuider->IsConnected()) &&
+ if (m_pCamera && m_pCamera->Connected && (!m_pScope || m_pScope->IsConnected()) &&
+ (!m_pAuxScope || m_pAuxScope->IsConnected()) && (!m_pStepGuider || m_pStepGuider->IsConnected()) &&
(!m_pRotator || m_pRotator->IsConnected()))
{
callSuper = false;
@@ -544,10 +566,9 @@ void GearDialog::EndModal(int retCode)
pFrame->pGraphLog->UpdateControls();
pFrame->pTarget->UpdateControls();
- if (pFrame->GetAutoLoadCalibration() && !m_camChanged) // ok to reload calibration
+ if (pFrame->GetAutoLoadCalibration() && !m_camChanged) // ok to reload calibration
{
- if (pMount && pMount->IsConnected() &&
- (!pSecondaryMount || pSecondaryMount->IsConnected()))
+ if (pMount && pMount->IsConnected() && (!pSecondaryMount || pSecondaryMount->IsConnected()))
{
Debug.Write("Auto-loading calibration data\n");
pFrame->LoadCalibration();
@@ -677,7 +698,8 @@ void GearDialog::UpdateScopeButtonState()
{
m_pConnectScopeButton->Enable(false);
}
- else if (m_pScope->RequiresStepGuider() && (!m_pStepGuider || !m_pStepGuider->ST4HasGuideOutput() || !m_pStepGuider->IsConnected()))
+ else if (m_pScope->RequiresStepGuider() &&
+ (!m_pStepGuider || !m_pStepGuider->ST4HasGuideOutput() || !m_pStepGuider->IsConnected()))
{
m_pConnectScopeButton->Enable(false);
}
@@ -694,7 +716,7 @@ void GearDialog::UpdateAuxScopeButtonState()
// Now set up the buttons to match our current state
if (m_pScope && m_pScope->CanReportPosition())
{
- int noneInx = m_pAuxScopes->FindString(_("None")); // Should always be first in list
+ int noneInx = m_pAuxScopes->FindString(_("None")); // Should always be first in list
m_pAuxScopes->SetSelection(noneInx);
m_pAuxScopes->Enable(false);
m_pSetupAuxScopeButton->Enable(false);
@@ -820,11 +842,9 @@ void GearDialog::UpdateRotatorButtonState()
void GearDialog::UpdateConnectAllButtonState()
{
- if ((m_pCamera && !m_pCamera->Connected) ||
- (m_pScope && !m_pScope->IsConnected()) ||
- (m_pAuxScope && !m_pAuxScope->IsConnected()) ||
- (m_pStepGuider && !m_pStepGuider->IsConnected()) ||
- (m_pRotator && !m_pRotator->IsConnected()))
+ if ((m_pCamera && !m_pCamera->Connected) || (m_pScope && !m_pScope->IsConnected()) ||
+ (m_pAuxScope && !m_pAuxScope->IsConnected()) || (m_pStepGuider && !m_pStepGuider->IsConnected()) ||
+ (m_pRotator && !m_pRotator->IsConnected()))
{
m_pConnectAllButton->Enable(true);
}
@@ -836,11 +856,9 @@ void GearDialog::UpdateConnectAllButtonState()
void GearDialog::UpdateDisconnectAllButtonState()
{
- if ((m_pCamera && m_pCamera->Connected) ||
- (m_pScope && m_pScope->IsConnected()) ||
- (m_pAuxScope && m_pAuxScope->IsConnected()) ||
- (m_pStepGuider && m_pStepGuider->IsConnected()) ||
- (m_pRotator && m_pRotator->IsConnected()))
+ if ((m_pCamera && m_pCamera->Connected) || (m_pScope && m_pScope->IsConnected()) ||
+ (m_pAuxScope && m_pAuxScope->IsConnected()) || (m_pStepGuider && m_pStepGuider->IsConnected()) ||
+ (m_pRotator && m_pRotator->IsConnected()))
{
m_pDisconnectAllButton->Enable(true);
m_profiles->Enable(false);
@@ -1109,9 +1127,9 @@ bool GearDialog::DoConnectCamera(bool autoReconnecting)
Debug.Write(wxString::Format("DoConnectCamera: reconnecting=%d warningIssued=%d lastCam=[%s] scaleRatio=%.3f\n",
autoReconnecting, m_camWarningIssued, m_lastCamera, m_imageScaleRatio));
- // No very reliable way to know if cam selection has changed - id's and name strings may be the same for different cams from same mfr
- // so do what we can here including consideration of image scale change
- // Purpose is to warn user of potential loss of dark/bpm files and later, to adjust guide params as best we can
+ // No very reliable way to know if cam selection has changed - id's and name strings may be the same for different cams
+ // from same mfr so do what we can here including consideration of image scale change Purpose is to warn user of
+ // potential loss of dark/bpm files and later, to adjust guide params as best we can
if (!m_camWarningIssued && !autoReconnecting)
{
if ((m_lastCamera != _("None") && newCam != _("None") && !DeviceSelectionMatches(m_lastCamera, newCam)) ||
@@ -1128,12 +1146,13 @@ bool GearDialog::DoConnectCamera(bool autoReconnecting)
{
Debug.Write("DoConnectCamera: displaying camera-change warning\n");
- wxString msg = _("By changing cameras in this profile, you won't be able to use the existing dark library or bad-pixel maps. You should consider"
- " creating a new profile for this set-up. Do you want to connect to this camera anyway?");
+ wxString msg = _("By changing cameras in this profile, you won't be able to use the existing dark library "
+ "or bad-pixel maps. You should consider"
+ " creating a new profile for this set-up. Do you want to connect to this camera anyway?");
if (wxMessageBox(msg, _("Camera Change Warning"), wxYES_NO, this) == wxYES)
{
m_camWarningIssued = true;
- m_lastCamera = newCam; // make consistent with what's in the UI
+ m_lastCamera = newCam; // make consistent with what's in the UI
}
else
{
@@ -1159,8 +1178,8 @@ bool GearDialog::DoConnectCamera(bool autoReconnecting)
m_pCamera->SetCameraGain(defaultGain);
}
- // See if the profile was created with a binning level that isn't supported by the camera (user mistake) - if so, reset binning to 1
- // Must be done here because orig binning level is not saved
+ // See if the profile was created with a binning level that isn't supported by the camera (user mistake) - if so, reset
+ // binning to 1 Must be done here because orig binning level is not saved
if (profileBinning > m_pCamera->MaxBinning)
{
int rslt;
@@ -1193,7 +1212,7 @@ bool GearDialog::DoConnectCamera(bool autoReconnecting)
Debug.Write(wxString::Format("HasSubFrames=%d\n", m_pCamera->HasSubframes));
Debug.Write(wxString::Format("ST4HasGuideOutput=%d\n", m_pCamera->ST4HasGuideOutput()));
- if (!autoReconnecting) // On a reconnect, this stuff is already established
+ if (!autoReconnecting) // On a reconnect, this stuff is already established
{
AutoLoadDefectMap();
if (!pCamera->CurrentDefectMap)
@@ -1286,8 +1305,7 @@ void GearDialog::UpdateGearPointers()
pSecondaryMount = nullptr;
}
- pPointingSource = m_pScope && (!m_pAuxScope || m_pScope->CanReportPosition()) ?
- m_pScope : m_pAuxScope;
+ pPointingSource = m_pScope && (!m_pAuxScope || m_pScope->CanReportPosition()) ? m_pScope : m_pAuxScope;
pRotator = m_pRotator;
}
@@ -1816,7 +1834,7 @@ void GearDialog::OnButtonDisconnectRotator(wxCommandEvent& event)
void GearDialog::OnButtonProfileManage(wxCommandEvent& event)
{
PopupMenu(m_menuProfileManage, m_btnProfileManage->GetPosition().x,
- m_btnProfileManage->GetPosition().y + m_btnProfileManage->GetSize().GetHeight());
+ m_btnProfileManage->GetPosition().y + m_btnProfileManage->GetSize().GetHeight());
}
void GearDialog::OnButtonWizard(wxCommandEvent& event)
@@ -1826,7 +1844,8 @@ void GearDialog::OnButtonWizard(wxCommandEvent& event)
bool firstLight = IsEmptyProfile();
wxString current = m_profiles->GetStringSelection();
- bool showGreeting = event.GetId() == 0; // Event id of 0 comes from "first light" launch; show first light UI panel only then
+ bool showGreeting =
+ event.GetId() == 0; // Event id of 0 comes from "first light" launch; show first light UI panel only then
bool darks_requested;
if (EquipmentProfileWizard::ShowModal(this, showGreeting, &darks_requested))
{
@@ -1834,7 +1853,7 @@ void GearDialog::OnButtonWizard(wxCommandEvent& event)
// if this was a first-light run, we may have left an empty "My Equipment" profile behind - if so, delete it
if (firstLight)
{
- pConfig->DeleteProfile(current); // Can't be any dark/bpm files associated with it
+ pConfig->DeleteProfile(current); // Can't be any dark/bpm files associated with it
}
wxArrayString profiles = pConfig->ProfileNames();
@@ -1872,9 +1891,9 @@ void GearDialog::ShowProfileWizard()
void GearDialog::ShowProfileWizard(wxCommandEvent& evt)
{
OnButtonWizard(evt);
- if (!IsEmptyProfile()) // User didn't just cancel out
+ if (!IsEmptyProfile()) // User didn't just cancel out
{
- ShowGearDialog(m_showDarksDialog); // Maybe auto-connect, close, launch darks; or just display dialog
+ ShowGearDialog(m_showDarksDialog); // Maybe auto-connect, close, launch darks; or just display dialog
}
}
@@ -1911,10 +1930,8 @@ bool GearDialog::SetProfile(int profileId, wxString *error)
return true;
}
- if ((m_pCamera && m_pCamera->Connected) ||
- (m_pScope && m_pScope->IsConnected()) ||
- (m_pAuxScope && m_pAuxScope->IsConnected()) ||
- (m_pStepGuider && m_pStepGuider->IsConnected()) ||
+ if ((m_pCamera && m_pCamera->Connected) || (m_pScope && m_pScope->IsConnected()) ||
+ (m_pAuxScope && m_pAuxScope->IsConnected()) || (m_pStepGuider && m_pStepGuider->IsConnected()) ||
(m_pRotator && m_pRotator->IsConnected()))
{
*error = "cannot set profile when equipment is connected";
@@ -1947,10 +1964,8 @@ bool GearDialog::SetProfile(int profileId, wxString *error)
bool GearDialog::ConnectAll(wxString *error)
{
- if (m_pCamera && m_pCamera->Connected &&
- (!m_pScope || m_pScope->IsConnected()) &&
- (!m_pAuxScope || m_pAuxScope->IsConnected()) &&
- (!m_pStepGuider || m_pStepGuider->IsConnected()) &&
+ if (m_pCamera && m_pCamera->Connected && (!m_pScope || m_pScope->IsConnected()) &&
+ (!m_pAuxScope || m_pAuxScope->IsConnected()) && (!m_pStepGuider || m_pStepGuider->IsConnected()) &&
(!m_pRotator || m_pRotator->IsConnected()))
{
// everything already connected
@@ -2003,10 +2018,8 @@ bool GearDialog::ConnectAll(wxString *error)
bool GearDialog::DisconnectAll(wxString *error)
{
- if ((!m_pCamera || !m_pCamera->Connected) &&
- (!m_pScope || !m_pScope->IsConnected()) &&
- (!m_pAuxScope || !m_pAuxScope->IsConnected()) &&
- (!m_pStepGuider || !m_pStepGuider->IsConnected()) &&
+ if ((!m_pCamera || !m_pCamera->Connected) && (!m_pScope || !m_pScope->IsConnected()) &&
+ (!m_pAuxScope || !m_pAuxScope->IsConnected()) && (!m_pStepGuider || !m_pStepGuider->IsConnected()) &&
(!m_pRotator || !m_pRotator->IsConnected()))
{
// nothing connected
@@ -2084,12 +2097,14 @@ struct NewProfileDialog : public wxDialog
NewProfileDialog::NewProfileDialog(wxWindow *parent)
: wxDialog(parent, wxID_ANY, _("New Equipment Profile"))
{
- wxSizerFlags sizerLabelFlags = wxSizerFlags().Align(wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL).Border(wxALL,2).Expand();
- wxSizerFlags sizerTextFlags = wxSizerFlags().Align(wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL).Border(wxALL,2).Expand();
- wxSizerFlags sizerButtonFlags = wxSizerFlags().Align(wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL).Border(wxALL,2).Expand();
+ wxSizerFlags sizerLabelFlags = wxSizerFlags().Align(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL).Border(wxALL, 2).Expand();
+ wxSizerFlags sizerTextFlags = wxSizerFlags().Align(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL).Border(wxALL, 2).Expand();
+ wxSizerFlags sizerButtonFlags = wxSizerFlags().Align(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL).Border(wxALL, 2).Expand();
wxSizer *sizer1 = new wxBoxSizer(wxHORIZONTAL);
- sizer1->Add(new wxStaticText(this, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL), sizerLabelFlags);
+ sizer1->Add(
+ new wxStaticText(this, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL),
+ sizerLabelFlags);
wxSize size = GetTextExtent("MMMMMMMMMMMMMMMMMMMMMMMMMMMM");
size.SetHeight(-1);
m_name = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, size);
@@ -2100,10 +2115,13 @@ NewProfileDialog::NewProfileDialog(wxWindow *parent)
choices.Insert(_("PHD Defaults"), 0);
wxSizer *sizer2 = new wxBoxSizer(wxHORIZONTAL);
- sizer2->Add(new wxStaticText(this, wxID_ANY, _("Profile initial settings"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL), sizerLabelFlags);
+ sizer2->Add(new wxStaticText(this, wxID_ANY, _("Profile initial settings"), wxDefaultPosition, wxDefaultSize,
+ wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL),
+ sizerLabelFlags);
m_copyFrom = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices);
m_copyFrom->SetSelection(0);
- m_copyFrom->SetToolTip(_("Select PHD Defaults to create a profile with default PHD settings, or select an existing Equipment Profile to copy its settings into your new profile."));
+ m_copyFrom->SetToolTip(_("Select PHD Defaults to create a profile with default PHD settings, or select an existing "
+ "Equipment Profile to copy its settings into your new profile."));
sizer2->Add(m_copyFrom, sizerTextFlags);
wxSizer *sizer3 = new wxBoxSizer(wxVERTICAL);
@@ -2127,7 +2145,8 @@ void GearDialog::OnProfileNew(wxCommandEvent& event)
if (pConfig->GetProfileId(newname) > 0)
{
- wxMessageBox(wxString::Format(_("Cannot create profile %s, there is already a profile with that name"), newname), _("Error"));
+ wxMessageBox(
+ wxString::Format(_("Cannot create profile %s, there is already a profile with that name"), newname), _("Error"));
return;
}
@@ -2159,7 +2178,8 @@ void GearDialog::OnProfileNew(wxCommandEvent& event)
void GearDialog::OnProfileDelete(wxCommandEvent& event)
{
wxString current = m_profiles->GetStringSelection();
- int result = wxMessageBox(wxString::Format(_("Delete profile %s?"), current), _("Delete Equipment Profile"), wxOK | wxCANCEL | wxCENTRE);
+ int result = wxMessageBox(
+ wxString::Format(_("Delete profile %s?"), current), _("Delete Equipment Profile"), wxOK | wxCANCEL | wxCENTRE);
if (result != wxOK)
return;
int id = pConfig->GetProfileId(current);
@@ -2188,7 +2208,8 @@ void GearDialog::OnProfileRename(wxCommandEvent& event)
if (pConfig->GetProfileId(newname) > 0)
{
- wxMessageBox(_(wxString::Format("Cannot not rename profile to %s, there is already a profile with that name", newname)), _("Error"));
+ wxMessageBox(_(wxString::Format("Cannot not rename profile to %s, there is already a profile with that name", newname)),
+ _("Error"));
return;
}
@@ -2209,7 +2230,7 @@ void GearDialog::OnProfileLoad(wxCommandEvent& event)
wxString default_path = pConfig->Global.GetString("/profileFilePath", wxEmptyString);
wxFileDialog dlg(this, _("Import PHD Equipment Profiles"), default_path, wxEmptyString,
- wxT("PHD profile files (*.phd)|*.phd"), wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE);
+ wxT("PHD profile files (*.phd)|*.phd"), wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE);
if (dlg.ShowModal() == wxID_CANCEL)
{
@@ -2241,9 +2262,8 @@ void GearDialog::OnProfileLoad(wxCommandEvent& event)
void GearDialog::OnProfileSave(wxCommandEvent& event)
{
wxString default_path = pConfig->Global.GetString("/profileFilePath", wxEmptyString);
- wxString fname = wxFileSelector(_("Export PHD Equipment Profile"), default_path,
- pConfig->GetCurrentProfile() + wxT(".phd"), wxT("phd"),
- wxT("PHD profile files (*.phd)|*.phd"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this);
+ wxString fname = wxFileSelector(_("Export PHD Equipment Profile"), default_path, pConfig->GetCurrentProfile() + wxT(".phd"),
+ wxT("phd"), wxT("PHD profile files (*.phd)|*.phd"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this);
if (fname.IsEmpty())
{
diff --git a/src/gear_dialog.h b/src/gear_dialog.h
index 3d727ed00..c6daa9128 100644
--- a/src/gear_dialog.h
+++ b/src/gear_dialog.h
@@ -40,10 +40,10 @@ class wxGridBagSizer;
class GearDialog : public wxDialog
{
GuideCamera *m_pCamera;
- Scope *m_pScope;
- Scope *m_pAuxScope;
- StepGuider *m_pStepGuider;
- Rotator *m_pRotator;
+ Scope *m_pScope;
+ Scope *m_pAuxScope;
+ StepGuider *m_pStepGuider;
+ Rotator *m_pRotator;
bool m_cameraUpdated;
bool m_mountUpdated;
diff --git a/src/gear_simulator.cpp b/src/gear_simulator.cpp
index 1c5d588ae..4f6effd76 100644
--- a/src/gear_simulator.cpp
+++ b/src/gear_simulator.cpp
@@ -38,20 +38,20 @@
#ifdef SIMULATOR
-#include "camera.h"
-#include "gear_simulator.h"
-#include "image_math.h"
+# include "camera.h"
+# include "gear_simulator.h"
+# include "image_math.h"
-#include
-#include
-#include
-#include
+# include
+# include
+# include
+# include
-#include
-#include
-#include
+# include
+# include
+# include
-#define SIMMODE 3 // 1=FITS, 2=BMP, 3=Generate
+# define SIMMODE 3 // 1=FITS, 2=BMP, 3=Generate
// #define SIMDEBUG
/* simulation parameters for SIMMODE = 3*/
@@ -74,7 +74,7 @@ struct SimCamParams
static PierSide pier_side;
static bool reverse_dec_pulse_on_west_side;
static unsigned int clouds_inten;
- static double clouds_opacity; // UI has percentage, internally 0-1.0
+ static double clouds_opacity; // UI has percentage, internally 0-1.0
static double image_scale; // arc-sec per pixel
static bool use_pe;
static bool use_stiction;
@@ -88,23 +88,24 @@ struct SimCamParams
static unsigned int frame_download_ms;
};
-unsigned int SimCamParams::width = 752; // simulated camera image width
-unsigned int SimCamParams::height = 580; // simulated camera image height
-unsigned int SimCamParams::border = 12; // do not place any stars within this size border
-unsigned int SimCamParams::nr_stars; // number of stars to generate
-unsigned int SimCamParams::nr_hot_pixels; // number of hot pixels to generate
-double SimCamParams::noise_multiplier; // noise factor, increase to increase noise
-double SimCamParams::dec_backlash; // dec backlash amount (pixels)
-double SimCamParams::pe_scale; // scale factor controlling magnitude of simulated periodic error
-double SimCamParams::dec_drift_rate; // dec drift rate (pixels per second)
-double SimCamParams::seeing_scale; // simulated seeing scale factor
-double SimCamParams::cam_angle; // simulated camera angle (degrees)
-double SimCamParams::guide_rate; // guide rate, pixels per second
-PierSide SimCamParams::pier_side; // side of pier
-bool SimCamParams::reverse_dec_pulse_on_west_side; // reverse dec pulse on west side of pier, like ASCOM pulse guided equatorial mounts
-unsigned int SimCamParams::clouds_inten = 50; // seed brightness for cloud contribution
+unsigned int SimCamParams::width = 752; // simulated camera image width
+unsigned int SimCamParams::height = 580; // simulated camera image height
+unsigned int SimCamParams::border = 12; // do not place any stars within this size border
+unsigned int SimCamParams::nr_stars; // number of stars to generate
+unsigned int SimCamParams::nr_hot_pixels; // number of hot pixels to generate
+double SimCamParams::noise_multiplier; // noise factor, increase to increase noise
+double SimCamParams::dec_backlash; // dec backlash amount (pixels)
+double SimCamParams::pe_scale; // scale factor controlling magnitude of simulated periodic error
+double SimCamParams::dec_drift_rate; // dec drift rate (pixels per second)
+double SimCamParams::seeing_scale; // simulated seeing scale factor
+double SimCamParams::cam_angle; // simulated camera angle (degrees)
+double SimCamParams::guide_rate; // guide rate, pixels per second
+PierSide SimCamParams::pier_side; // side of pier
+bool SimCamParams::reverse_dec_pulse_on_west_side; // reverse dec pulse on west side of pier, like ASCOM pulse guided equatorial
+ // mounts
+unsigned int SimCamParams::clouds_inten = 50; // seed brightness for cloud contribution
double SimCamParams::clouds_opacity;
-double SimCamParams::image_scale; // arc-sec per pixel
+double SimCamParams::image_scale; // arc-sec per pixel
bool SimCamParams::use_pe;
bool SimCamParams::use_stiction;
bool SimCamParams::use_default_pe_params;
@@ -114,37 +115,37 @@ bool SimCamParams::show_comet;
double SimCamParams::comet_rate_x;
double SimCamParams::comet_rate_y;
bool SimCamParams::allow_async_st4 = true;
-unsigned int SimCamParams::frame_download_ms; // frame download time, ms
+unsigned int SimCamParams::frame_download_ms; // frame download time, ms
// Note: these are all in units appropriate for the UI
-#define NR_STARS_DEFAULT 20
-#define NR_HOT_PIXELS_DEFAULT 8
-#define NOISE_DEFAULT 2.0
-#define NOISE_MAX 5.0
-#define DEC_BACKLASH_DEFAULT 5.0 // arc-sec
-#define DEC_BACKLASH_MAX 100.0
-#define DEC_DRIFT_DEFAULT 5.0 // arc-sec per minute
-#define DEC_DRIFT_MAX 30.0
-#define SEEING_DEFAULT 2.0 // arc-sec FWHM
-#define SEEING_MAX 5.0
-#define CAM_ANGLE_DEFAULT 15.0
-#define CAM_ANGLE_MAX 360.0
-#define GUIDE_RATE_DEFAULT (1.0 * 15.0) // multiples of sidereal rate, a-s/sec
-#define GUIDE_RATE_MAX (1.0 * 15.0)
-#define PIER_SIDE_DEFAULT PIER_SIDE_EAST
-#define REVERSE_DEC_PULSE_ON_WEST_SIDE_DEFAULT true
-#define CLOUDS_OPACITY_DEFAULT 0
-#define USE_PE_DEFAULT true
-#define USE_STICTION_DEFAULT false
-#define PE_SCALE_DEFAULT 5.0 // amplitude arc-sec
-#define PE_SCALE_MAX 30.0
-#define USE_PE_DEFAULT_PARAMS true
-#define PE_CUSTOM_AMP_DEFAULT 2.0 // Give them a trivial 2 a-s 4 min smooth curve
-#define PE_CUSTOM_PERIOD_DEFAULT 240.0
-#define SHOW_COMET_DEFAULT false
-#define COMET_RATE_X_DEFAULT 555.0 // pixels per hour
-#define COMET_RATE_Y_DEFAULT -123.4 // pixels per hour
-#define SIM_FILE_DISPLACEMENTS_DEFAULT "star_displacements.csv"
+# define NR_STARS_DEFAULT 20
+# define NR_HOT_PIXELS_DEFAULT 8
+# define NOISE_DEFAULT 2.0
+# define NOISE_MAX 5.0
+# define DEC_BACKLASH_DEFAULT 5.0 // arc-sec
+# define DEC_BACKLASH_MAX 100.0
+# define DEC_DRIFT_DEFAULT 5.0 // arc-sec per minute
+# define DEC_DRIFT_MAX 30.0
+# define SEEING_DEFAULT 2.0 // arc-sec FWHM
+# define SEEING_MAX 5.0
+# define CAM_ANGLE_DEFAULT 15.0
+# define CAM_ANGLE_MAX 360.0
+# define GUIDE_RATE_DEFAULT (1.0 * 15.0) // multiples of sidereal rate, a-s/sec
+# define GUIDE_RATE_MAX (1.0 * 15.0)
+# define PIER_SIDE_DEFAULT PIER_SIDE_EAST
+# define REVERSE_DEC_PULSE_ON_WEST_SIDE_DEFAULT true
+# define CLOUDS_OPACITY_DEFAULT 0
+# define USE_PE_DEFAULT true
+# define USE_STICTION_DEFAULT false
+# define PE_SCALE_DEFAULT 5.0 // amplitude arc-sec
+# define PE_SCALE_MAX 30.0
+# define USE_PE_DEFAULT_PARAMS true
+# define PE_CUSTOM_AMP_DEFAULT 2.0 // Give them a trivial 2 a-s 4 min smooth curve
+# define PE_CUSTOM_PERIOD_DEFAULT 240.0
+# define SHOW_COMET_DEFAULT false
+# define COMET_RATE_X_DEFAULT 555.0 // pixels per hour
+# define COMET_RATE_Y_DEFAULT -123.4 // pixels per hour
+# define SIM_FILE_DISPLACEMENTS_DEFAULT "star_displacements.csv"
// Needed to handle legacy registry values that may no longer be in correct units or range
static double range_check(double thisval, double minval, double maxval)
@@ -166,18 +167,22 @@ static void load_sim_params()
SimCamParams::custom_pe_period = pConfig->Profile.GetDouble("/SimCam/pe_cust_period", PE_CUSTOM_PERIOD_DEFAULT);
double dval = pConfig->Profile.GetDouble("/SimCam/dec_drift", DEC_DRIFT_DEFAULT);
- SimCamParams::dec_drift_rate = range_check(dval, -DEC_DRIFT_MAX, DEC_DRIFT_MAX) / (SimCamParams::image_scale * 60.0); //a-s per min is saved
+ SimCamParams::dec_drift_rate =
+ range_check(dval, -DEC_DRIFT_MAX, DEC_DRIFT_MAX) / (SimCamParams::image_scale * 60.0); // a-s per min is saved
// backlash is in arc-secs in UI - map to px for internal use
dval = pConfig->Profile.GetDouble("/SimCam/dec_backlash", DEC_BACKLASH_DEFAULT);
SimCamParams::dec_backlash = range_check(dval, 0, DEC_BACKLASH_MAX) / SimCamParams::image_scale;
SimCamParams::pe_scale = range_check(pConfig->Profile.GetDouble("/SimCam/pe_scale", PE_SCALE_DEFAULT), 0, PE_SCALE_MAX);
- SimCamParams::seeing_scale = range_check(pConfig->Profile.GetDouble("/SimCam/seeing_scale", SEEING_DEFAULT), 0, SEEING_MAX); // FWHM a-s
+ SimCamParams::seeing_scale =
+ range_check(pConfig->Profile.GetDouble("/SimCam/seeing_scale", SEEING_DEFAULT), 0, SEEING_MAX); // FWHM a-s
SimCamParams::cam_angle = pConfig->Profile.GetDouble("/SimCam/cam_angle", CAM_ANGLE_DEFAULT);
SimCamParams::clouds_opacity = pConfig->Profile.GetDouble("/SimCam/clouds_opacity", CLOUDS_OPACITY_DEFAULT);
- SimCamParams::guide_rate = range_check(pConfig->Profile.GetDouble("/SimCam/guide_rate", GUIDE_RATE_DEFAULT), 0, GUIDE_RATE_MAX);
+ SimCamParams::guide_rate =
+ range_check(pConfig->Profile.GetDouble("/SimCam/guide_rate", GUIDE_RATE_DEFAULT), 0, GUIDE_RATE_MAX);
SimCamParams::pier_side = (PierSide) pConfig->Profile.GetInt("/SimCam/pier_side", PIER_SIDE_DEFAULT);
- SimCamParams::reverse_dec_pulse_on_west_side = pConfig->Profile.GetBoolean("/SimCam/reverse_dec_pulse_on_west_side", REVERSE_DEC_PULSE_ON_WEST_SIDE_DEFAULT);
+ SimCamParams::reverse_dec_pulse_on_west_side =
+ pConfig->Profile.GetBoolean("/SimCam/reverse_dec_pulse_on_west_side", REVERSE_DEC_PULSE_ON_WEST_SIDE_DEFAULT);
SimCamParams::show_comet = pConfig->Profile.GetBoolean("/SimCam/show_comet", SHOW_COMET_DEFAULT);
SimCamParams::comet_rate_x = pConfig->Profile.GetDouble("/SimCam/comet_rate_x", COMET_RATE_X_DEFAULT);
@@ -211,13 +216,13 @@ static void save_sim_params()
pConfig->Profile.SetInt("/SimCam/frame_download_ms", SimCamParams::frame_download_ms);
}
-#ifdef STEPGUIDER_SIMULATOR
+# ifdef STEPGUIDER_SIMULATOR
struct SimAoParams
{
static unsigned int max_position; // max position in steps
- static double scale; // arcsec per step
- static double angle; // angle relative to camera (degrees)
+ static double scale; // arcsec per step
+ static double angle; // angle relative to camera (degrees)
};
unsigned int SimAoParams::max_position = 45;
@@ -249,9 +254,7 @@ StepGuiderSimulator::StepGuiderSimulator()
SimAoParams::max_position = pConfig->Profile.GetInt("/SimAo/max_steps", 45);
}
-StepGuiderSimulator::~StepGuiderSimulator()
-{
-}
+StepGuiderSimulator::~StepGuiderSimulator() { }
bool StepGuiderSimulator::Connect()
{
@@ -266,7 +269,8 @@ bool StepGuiderSimulator::Connect()
if (!pCamera || pCamera->Name != _T("Simulator"))
{
- pFrame->Alert(_("The AO Simulator only works with the Camera Simulator. You should either disconnect the AO Simulator or connect the Camera Simulator."));
+ pFrame->Alert(_("The AO Simulator only works with the Camera Simulator. You should either disconnect the AO Simulator "
+ "or connect the Camera Simulator."));
}
return false;
@@ -277,7 +281,8 @@ bool StepGuiderSimulator::Disconnect()
if (StepGuider::Disconnect())
return true;
- if (s_sim_ao == this) {
+ if (s_sim_ao == this)
+ {
Debug.AddLine("AO Simulator Disconnected");
s_sim_ao = 0;
}
@@ -293,17 +298,20 @@ bool StepGuiderSimulator::Center()
StepGuider::STEP_RESULT StepGuiderSimulator::Step(GUIDE_DIRECTION direction, int steps)
{
-#if 0 // enable to test step failure
+# if 0 // enable to test step failure
wxPoint pos = GetAoPos();
if (direction == LEFT && pos.x - steps < -35)
{
Debug.Write("simulate step failure\n");
return STEP_LIMIT_REACHED;
}
-#endif
+# endif
// parent class maintains x/y offsets, so nothing to do here. Just simulate a delay.
- enum { LATENCY_MS_PER_STEP = 5 };
+ enum
+ {
+ LATENCY_MS_PER_STEP = 5
+ };
wxMilliSleep(steps * LATENCY_MS_PER_STEP);
return STEP_OK;
}
@@ -325,9 +333,9 @@ bool StepGuiderSimulator::HasNonGuiMove()
return true;
}
-#endif // STEPGUIDER_SIMULATOR
+# endif // STEPGUIDER_SIMULATOR
-#ifdef ROTATOR_SIMULATOR
+# ifdef ROTATOR_SIMULATOR
class RotatorSimulator : public Rotator
{
@@ -345,19 +353,16 @@ class RotatorSimulator : public Rotator
float Position() const override;
};
-RotatorSimulator::RotatorSimulator()
-{
-}
+RotatorSimulator::RotatorSimulator() { }
-RotatorSimulator::~RotatorSimulator()
-{
-}
+RotatorSimulator::~RotatorSimulator() { }
bool RotatorSimulator::Connect()
{
if (!pCamera || pCamera->Name != _T("Simulator"))
{
- pFrame->Alert(_("The Rotator Simulator only works with the Camera Simulator. You must either disconnect the Rotator Simulator or connect the Camera Simulator."));
+ pFrame->Alert(_("The Rotator Simulator only works with the Camera Simulator. You must either disconnect the Rotator "
+ "Simulator or connect the Camera Simulator."));
return true;
}
@@ -382,7 +387,7 @@ float RotatorSimulator::Position() const
return SimCamParams::cam_angle;
}
-#endif // ROTATOR_SIMULATOR
+# endif // ROTATOR_SIMULATOR
// value with backlash
// There is an index value, and a lower and upper limit separated by the
@@ -391,24 +396,31 @@ float RotatorSimulator::Position() const
// the value of the upper limit.
struct BacklashVal
{
- double cur; // current index value
- double upper; // upper limit
+ double cur; // current index value
+ double upper; // upper limit
double amount; // backlash amount (lower limit is upper - amount)
BacklashVal() { }
BacklashVal(double backlash_amount)
- : cur(0), upper(backlash_amount), amount(backlash_amount) { }
+ : cur(0)
+ , upper(backlash_amount)
+ , amount(backlash_amount)
+ {
+ }
double val() const { return upper; }
- void incr(double d) {
+ void incr(double d)
+ {
cur += d;
- if (d > 0.) {
+ if (d > 0.)
+ {
if (cur > upper)
upper = cur;
}
- else if (d < 0.) {
+ else if (d < 0.)
+ {
if (cur < upper - amount)
upper = cur + amount;
}
@@ -478,7 +490,16 @@ struct Cooler
double rate; // degrees per second
double direction; // -1 = cooling, +1 = warming
- Cooler() : on(false), startTemp(AMBIENT_TEMP), endTemp(AMBIENT_TEMP), setTemp(AMBIENT_TEMP), endTime(0), rate(1. / 8.), direction(0.) { }
+ Cooler()
+ : on(false)
+ , startTemp(AMBIENT_TEMP)
+ , endTemp(AMBIENT_TEMP)
+ , setTemp(AMBIENT_TEMP)
+ , endTime(0)
+ , rate(1. / 8.)
+ , direction(0.)
+ {
+ }
double CurrentTemp() const
{
@@ -487,7 +508,7 @@ struct Cooler
if (now >= endTime)
return endTemp;
- return endTemp - rate * direction * (double)(endTime - now);
+ return endTemp - rate * direction * (double) (endTime - now);
}
void TurnOn()
@@ -531,32 +552,32 @@ struct SimCamState
unsigned int height;
wxVector stars; // star positions and intensities (ra, dec)
wxVector hotpx; // hot pixels
- double ra_ofs; // assume no backlash in RA
- BacklashVal dec_ofs; // simulate backlash in DEC
- double cum_dec_drift; // cumulative dec drift
- wxStopWatch timer; // platform-independent timer
+ double ra_ofs; // assume no backlash in RA
+ BacklashVal dec_ofs; // simulate backlash in DEC
+ double cum_dec_drift; // cumulative dec drift
+ wxStopWatch timer; // platform-independent timer
long last_exposure_time; // last exposure time, milliseconds
- Cooler cooler; // simulated cooler
+ Cooler cooler; // simulated cooler
StictionSim stictionSim;
-#ifdef SIMDEBUG
+# ifdef SIMDEBUG
wxFFile DebugFile;
double last_ra_move;
double last_dec_move;
-#endif
+# endif
-#ifdef SIM_FILE_DISPLACEMENTS
- wxFileInputStream* pIStream;
- wxTextInputStream* pText;
+# ifdef SIM_FILE_DISPLACEMENTS
+ wxFileInputStream *pIStream;
+ wxTextInputStream *pText;
double scaleConversion;
void ReadDisplacements(double& cumX, double& cumY);
-#endif
+# endif
-#if SIMMODE == 1
+# if SIMMODE == 1
wxDir dir;
bool dirStarted;
bool ReadNextImage(usImage& img, const wxRect& subframe);
-#endif
+# endif
void Initialize();
void FillImage(usImage& img, const wxRect& subframe, int exptime, int gain, int offset);
@@ -575,11 +596,11 @@ void SimCamState::Initialize()
for (unsigned int i = 0; i < nr_stars; i++)
{
// generate stars in ra/dec coordinates
- stars[i].pos.x = (double)(rand() % (width - 2 * border)) - 0.5 * width;
- stars[i].pos.y = (double)(rand() % (height - 2 * border)) - 0.5 * height;
+ stars[i].pos.x = (double) (rand() % (width - 2 * border)) - 0.5 * width;
+ stars[i].pos.y = (double) (rand() % (height - 2 * border)) - 0.5 * height;
double r = (double) (rand() % 90) / 3.0; // 0..30
if (i == 10)
- stars[i].inten = 30.1; // Always have one saturated star
+ stars[i].inten = 30.1; // Always have one saturated star
else
stars[i].inten = 0.1 + (double) (r * r * r) / 9000.0;
@@ -595,7 +616,8 @@ void SimCamState::Initialize()
// generate hot pixels
unsigned int const nr_hot = SimCamParams::nr_hot_pixels;
hotpx.resize(nr_hot);
- for (unsigned int i = 0; i < nr_hot; i++) {
+ for (unsigned int i = 0; i < nr_hot; i++)
+ {
hotpx[i].x = rand() % width;
hotpx[i].y = rand() % height;
}
@@ -605,11 +627,11 @@ void SimCamState::Initialize()
cum_dec_drift = 0.;
last_exposure_time = 0;
-#if SIMMODE == 1
+# if SIMMODE == 1
dirStarted = false;
-#endif
+# endif
-#ifdef SIM_FILE_DISPLACEMENTS
+# ifdef SIM_FILE_DISPLACEMENTS
pIStream = nullptr;
wxString csvName = Debug.GetLogDir() + PATHSEPSTR + SIM_FILE_DISPLACEMENTS_DEFAULT;
if (wxFile::Exists(csvName))
@@ -633,21 +655,21 @@ void SimCamState::Initialize()
if (pIStream && pIStream->IsOk())
pText = new wxTextInputStream(*pIStream);
else
- pText = nullptr; // User cancelled open dialog or file is useless
- scaleConversion = 1.0; // safe default
-#endif
-
-#ifdef SIMDEBUG
- DebugFile.Open ("Sim_Debug.txt", "w");
-#ifdef SIM_FILE_DISPLACEMENTS
- DebugFile.Write ("Total_X, Total_Y, RA_Ofs, Dec_Ofs \n");
-#else
- DebugFile.Write ("PE, Drift, RA_Seeing, Dec_Seeing, Total_X, Total_Y, RA_Ofs, Dec_Ofs, \n");
-#endif
-#endif
+ pText = nullptr; // User cancelled open dialog or file is useless
+ scaleConversion = 1.0; // safe default
+# endif
+
+# ifdef SIMDEBUG
+ DebugFile.Open("Sim_Debug.txt", "w");
+# ifdef SIM_FILE_DISPLACEMENTS
+ DebugFile.Write("Total_X, Total_Y, RA_Ofs, Dec_Ofs \n");
+# else
+ DebugFile.Write("PE, Drift, RA_Seeing, Dec_Seeing, Total_X, Total_Y, RA_Ofs, Dec_Ofs, \n");
+# endif
+# endif
}
-#if SIMMODE == 1
+# if SIMMODE == 1
bool SimCamState::ReadNextImage(usImage& img, const wxRect& subframe)
{
wxString filename;
@@ -675,8 +697,8 @@ bool SimCamState::ReadNextImage(usImage& img, const wxRect& subframe)
}
Debug.Write("Sim file opened: " + filename + "\n");
- fitsfile *fptr; // FITS file pointer
- int status = 0; // CFITSIO status value MUST be initialized to zero!
+ fitsfile *fptr; // FITS file pointer
+ int status = 0; // CFITSIO status value MUST be initialized to zero!
if (PHD_fits_open_diskfile(&fptr, wxFileName(dir.GetName(), filename).GetFullPath(), READONLY, &status))
return true;
@@ -694,7 +716,8 @@ bool SimCamState::ReadNextImage(usImage& img, const wxRect& subframe)
int nhdus;
fits_get_num_hdus(fptr, &nhdus, &status);
- if ((nhdus != 1) || (naxis != 2)) {
+ if ((nhdus != 1) || (naxis != 2))
+ {
pFrame->Alert(_("Unsupported type or read error loading FITS file"));
PHD_fits_close_file(fptr);
return true;
@@ -706,7 +729,8 @@ bool SimCamState::ReadNextImage(usImage& img, const wxRect& subframe)
int xsize = (int) fits_size[0];
int ysize = (int) fits_size[1];
- if (img.Init(xsize, ysize)) {
+ if (img.Init(xsize, ysize))
+ {
pFrame->Alert(_("Memory allocation error"));
PHD_fits_close_file(fptr);
return true;
@@ -757,7 +781,7 @@ bool SimCamState::ReadNextImage(usImage& img, const wxRect& subframe)
return false;
}
-#endif // SIMMODE == 1
+# endif // SIMMODE == 1
// get a pair of normally-distributed independent random values - Box-Muller algorithm, sigma=1
static void rand_normal(double r[2])
@@ -789,25 +813,60 @@ inline static void set_pixel(usImage& img, int x, int y, unsigned short val)
inline static void incr_pixel(usImage& img, int x, int y, unsigned int val)
{
unsigned short *const addr = pixel_addr(img, x, y);
- if (addr) {
+ if (addr)
+ {
unsigned int t = *addr;
t += val;
- if (t > (unsigned int)(unsigned short)-1)
- *addr = (unsigned short)-1;
+ if (t > (unsigned int) (unsigned short) -1)
+ *addr = (unsigned short) -1;
else
- *addr = (unsigned short)t;
+ *addr = (unsigned short) t;
}
}
static void render_comet(usImage& img, int binning, const wxRect& subframe, const wxRealPoint& p, double inten)
{
- enum { WIDTH = 5 };
- double STAR[][WIDTH] = { { 0.0, 0.8, 2.2, 0.8, 0.0, },
- { 0.8, 16.6, 46.1, 16.6, 0.8, },
- { 2.2, 46.1, 128.0, 46.1, 2.2, },
- { 0.8, 16.6, 46.1, 16.6, 0.8, },
- { 0.0, 0.8, 2.2, 0.8, 0.0, },
- };
+ enum
+ {
+ WIDTH = 5
+ };
+ double STAR[][WIDTH] = {
+ {
+ 0.0,
+ 0.8,
+ 2.2,
+ 0.8,
+ 0.0,
+ },
+ {
+ 0.8,
+ 16.6,
+ 46.1,
+ 16.6,
+ 0.8,
+ },
+ {
+ 2.2,
+ 46.1,
+ 128.0,
+ 46.1,
+ 2.2,
+ },
+ {
+ 0.8,
+ 16.6,
+ 46.1,
+ 16.6,
+ 0.8,
+ },
+ {
+ 0.0,
+ 0.8,
+ 2.2,
+ 0.8,
+ 0.0,
+ },
+ };
wxRealPoint intpart;
double fx = modf(p.x / (double) binning, &intpart.x);
@@ -819,21 +878,20 @@ static void render_comet(usImage& img, int binning, const wxRect& subframe, cons
double d[WIDTH + 1][WIDTH + 1] = { { 0.0 } };
for (unsigned int i = 0; i < WIDTH; i++)
- for (unsigned int j = 0; j < WIDTH; j++)
- {
- double s = STAR[i][j];
- if (s > 0.0)
+ for (unsigned int j = 0; j < WIDTH; j++)
{
- s *= inten / 256.0;
- d[i][j] += f00 * s;
- d[i + 1][j] += f10 * s;
- d[i][j + 1] += f01 * s;
- d[i + 1][j + 1] += f11 * s;
+ double s = STAR[i][j];
+ if (s > 0.0)
+ {
+ s *= inten / 256.0;
+ d[i][j] += f00 * s;
+ d[i + 1][j] += f10 * s;
+ d[i][j + 1] += f01 * s;
+ d[i + 1][j + 1] += f11 * s;
+ }
}
- }
- wxPoint c((int)intpart.x - (WIDTH - 1) / 2,
- (int)intpart.y - (WIDTH - 1) / 2);
+ wxPoint c((int) intpart.x - (WIDTH - 1) / 2, (int) intpart.y - (WIDTH - 1) / 2);
for (unsigned int x_inc = 0; x_inc < 10; x_inc++)
{
@@ -842,22 +900,54 @@ static void render_comet(usImage& img, int binning, const wxRect& subframe, cons
int const cx = c.x + x_inc;
int const cy = c.y + y * x_inc;
if (cx < subframe.GetRight() && cy < subframe.GetBottom() && cy > subframe.GetTop())
- incr_pixel(img, cx, cy, (int)d[2][2]);
+ incr_pixel(img, cx, cy, (int) d[2][2]);
}
-
}
-
}
static void render_star(usImage& img, int binning, const wxRect& subframe, const wxRealPoint& p, double inten)
{
- enum { WIDTH = 5 };
- double STAR[][WIDTH] = {{ 0.0, 0.8, 2.2, 0.8, 0.0, },
- { 0.8, 16.6, 46.1, 16.6, 0.8, },
- { 2.2, 46.1, 128.0, 46.1, 2.2, },
- { 0.8, 16.6, 46.1, 16.6, 0.8, },
- { 0.0, 0.8, 2.2, 0.8, 0.0, },
- };
+ enum
+ {
+ WIDTH = 5
+ };
+ double STAR[][WIDTH] = {
+ {
+ 0.0,
+ 0.8,
+ 2.2,
+ 0.8,
+ 0.0,
+ },
+ {
+ 0.8,
+ 16.6,
+ 46.1,
+ 16.6,
+ 0.8,
+ },
+ {
+ 2.2,
+ 46.1,
+ 128.0,
+ 46.1,
+ 2.2,
+ },
+ {
+ 0.8,
+ 16.6,
+ 46.1,
+ 16.6,
+ 0.8,
+ },
+ {
+ 0.0,
+ 0.8,
+ 2.2,
+ 0.8,
+ 0.0,
+ },
+ };
wxRealPoint intpart;
double fx = modf(p.x / (double) binning, &intpart.x);
@@ -876,14 +966,13 @@ static void render_star(usImage& img, int binning, const wxRect& subframe, const
{
s *= inten / 256.0;
d[i][j] += f00 * s;
- d[i+1][j] += f10 * s;
- d[i][j+1] += f01 * s;
- d[i+1][j+1] += f11 * s;
+ d[i + 1][j] += f10 * s;
+ d[i][j + 1] += f01 * s;
+ d[i + 1][j + 1] += f11 * s;
}
}
- wxPoint c((int) intpart.x - (WIDTH - 1) / 2,
- (int) intpart.y - (WIDTH - 1) / 2);
+ wxPoint c((int) intpart.x - (WIDTH - 1) / 2, (int) intpart.y - (WIDTH - 1) / 2);
for (unsigned int i = 0; i < WIDTH + 1; i++)
{
@@ -896,8 +985,8 @@ static void render_star(usImage& img, int binning, const wxRect& subframe, const
if (cy < subframe.GetTop() || cy > subframe.GetBottom())
continue;
int incr = (int) d[i][j];
- if (incr > (unsigned short)-1)
- incr = (unsigned short)-1;
+ if (incr > (unsigned short) -1)
+ incr = (unsigned short) -1;
incr_pixel(img, cx, cy, incr);
}
}
@@ -913,13 +1002,14 @@ static void render_clouds(usImage& img, const wxRect& subframe, int exptime, int
for (unsigned short *p = p0; p < end; p++)
{
// Compute a randomized brightness contribution from clouds, then overlay that on the guide frame
- cloud_amt = (unsigned short)(SimCamParams::clouds_inten * ((double)gain / 10.0 * offset * exptime / 100.0 + ((rand() % (gain * 100)) / 30.0)));
- *p = (unsigned short) (SimCamParams::clouds_opacity * cloud_amt + (1 - SimCamParams::clouds_opacity) * *p);
+ cloud_amt = (unsigned short) (SimCamParams::clouds_inten *
+ ((double) gain / 10.0 * offset * exptime / 100.0 + ((rand() % (gain * 100)) / 30.0)));
+ *p = (unsigned short) (SimCamParams::clouds_opacity * cloud_amt + (1 - SimCamParams::clouds_opacity) * *p);
}
}
}
-#ifdef SIM_FILE_DISPLACEMENTS
+# ifdef SIM_FILE_DISPLACEMENTS
// Get raw star displacements from a file generated by using the CAPTURE_DEFLECTIONS
// compile-time option in guider.cpp to record them
void SimCamState::ReadDisplacements(double& incX, double& incY)
@@ -943,7 +1033,7 @@ void SimCamState::ReadDisplacements(double& incX, double& incY)
wxString tk = tok.GetNextToken();
while (tk != "Scale")
tk = tok.GetNextToken();
- tk = tok.GetNextToken(); // numeric image scale a-s/p
+ tk = tok.GetNextToken(); // numeric image scale a-s/p
double realImageScale;
if (tk.ToDouble(&realImageScale))
{
@@ -969,21 +1059,22 @@ void SimCamState::ReadDisplacements(double& incX, double& incY)
}
}
}
-#endif
+# endif
void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, int gain, int offset)
{
unsigned int const nr_stars = stars.size();
-#ifdef SIMDEBUG
- static int CountUp (0);
+# ifdef SIMDEBUG
+ static int CountUp(0);
if (CountUp == 0)
{
// Changes in the setup dialog are hard to track - just make sure we are using the params we think we are
- Debug.AddLine (wxString::Format("SimDebug: img_scale: %.3f, seeing_scale: %.3f", SimCamParams::image_scale, SimCamParams::seeing_scale));
+ Debug.AddLine(wxString::Format(
+ "SimDebug: img_scale: %.3f, seeing_scale: %.3f", SimCamParams::image_scale, SimCamParams::seeing_scale));
}
CountUp++;
-#endif
+# endif
// start with original star positions
wxVector pos(nr_stars);
@@ -993,7 +1084,7 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
double total_shift_x = 0;
double total_shift_y = 0;
-#ifdef SIM_FILE_DISPLACEMENTS
+# ifdef SIM_FILE_DISPLACEMENTS
double inc_x;
double inc_y;
@@ -1011,7 +1102,7 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
}
}
-#else // SIM_FILE_DISPLACEMENTS
+# else // SIM_FILE_DISPLACEMENTS
long const cur_time = timer.Time();
long const delta_time_ms = last_exposure_time - cur_time;
@@ -1037,32 +1128,46 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
double const now = cur_time / 1000. - s_ra_offset;
// Compute PE - canned PE terms create some "steep" sections of the curve
- static double const max_amp = 4.85; // max amplitude of canned PE
+ static double const max_amp = 4.85; // max amplitude of canned PE
double pe = 0.;
if (SimCamParams::use_pe)
{
if (SimCamParams::use_default_pe_params)
{
- static double const period[] = { 230.5, 122.0, 49.4, 9.56, 76.84, };
- static double const amp[] = {2.02, 0.69, 0.22, 0.137, 0.14}; // in a-s
- static double const phase[] = { 0.0, 1.4, 98.8, 35.9, 150.4, };
+ static double const period[] = {
+ 230.5,
+ 122.0,
+ 49.4,
+ 9.56,
+ 76.84,
+ };
+ static double const amp[] = { 2.02, 0.69, 0.22, 0.137, 0.14 }; // in a-s
+ static double const phase[] = {
+ 0.0,
+ 1.4,
+ 98.8,
+ 35.9,
+ 150.4,
+ };
for (unsigned int i = 0; i < WXSIZEOF(period); i++)
pe += amp[i] * cos((now - phase[i]) / period[i] * 2. * M_PI);
- pe *= (SimCamParams::pe_scale / (max_amp * SimCamParams::image_scale)); // modulated PE in px
+ pe *= (SimCamParams::pe_scale / (max_amp * SimCamParams::image_scale)); // modulated PE in px
}
else
{
- pe = SimCamParams::custom_pe_amp * cos(now / SimCamParams::custom_pe_period * 2.0 * M_PI) / SimCamParams::image_scale;
+ pe = SimCamParams::custom_pe_amp * cos(now / SimCamParams::custom_pe_period * 2.0 * M_PI) /
+ SimCamParams::image_scale;
}
}
// simulate drift in DEC
cum_dec_drift += (double) delta_time_ms * SimCamParams::dec_drift_rate / 1000.;
- // Compute total movements from all sources - ra_ofs and dec_ofs are cumulative sums of all guider movements relative to zero-point
+ // Compute total movements from all sources - ra_ofs and dec_ofs are cumulative sums of all guider movements relative to
+ // zero-point
total_shift_x = pe + ra_ofs;
total_shift_y = cum_dec_drift + dec_ofs.val();
@@ -1072,7 +1177,7 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
if (SimCamParams::seeing_scale > 0.0)
{
rand_normal(seeing);
- static const double seeing_adjustment = (2.345 * 1.4 * 2.4); //FWHM, geometry, empirical
+ static const double seeing_adjustment = (2.345 * 1.4 * 2.4); // FWHM, geometry, empirical
double sigma = SimCamParams::seeing_scale / (seeing_adjustment * SimCamParams::image_scale);
seeing[0] *= sigma;
seeing[1] *= sigma;
@@ -1080,7 +1185,7 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
total_shift_y += seeing[1];
}
-#endif // SIM_FILE_DISPLACEMENTS
+# endif // SIM_FILE_DISPLACEMENTS
for (unsigned int i = 0; i < nr_stars; i++)
{
@@ -1088,16 +1193,14 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
pos[i].y += total_shift_y;
}
-#ifdef SIMDEBUG
-#ifdef SIM_FILE_DISPLACEMENTS
- DebugFile.Write(wxString::Format("%.3f, %.3f, %.3f, %.3f\n", total_shift_x, total_shift_y,
- ra_ofs, dec_ofs.val()));
-#else
- DebugFile.Write(wxString::Format( "%.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f\n",
- pe, drift, seeing[0], seeing[1], total_shift_x, total_shift_y,
- ra_ofs, dec_ofs.val()));
-#endif
-#endif
+# ifdef SIMDEBUG
+# ifdef SIM_FILE_DISPLACEMENTS
+ DebugFile.Write(wxString::Format("%.3f, %.3f, %.3f, %.3f\n", total_shift_x, total_shift_y, ra_ofs, dec_ofs.val()));
+# else
+ DebugFile.Write(wxString::Format("%.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f\n", pe, drift, seeing[0], seeing[1],
+ total_shift_x, total_shift_y, ra_ofs, dec_ofs.val()));
+# endif
+# endif
// check for pier-flip
if (pPointingSource)
@@ -1105,7 +1208,8 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
PierSide new_side = pPointingSource->SideOfPier();
if (new_side != SimCamParams::pier_side)
{
- Debug.Write(wxString::Format("Cam simulator: pointing source pier side changed from %d to %d\n", SimCamParams::pier_side, new_side));
+ Debug.Write(wxString::Format(
+ "Cam simulator: pointing source pier side changed from %d to %d\n", SimCamParams::pier_side, new_side));
SimCamParams::pier_side = new_side;
}
}
@@ -1118,14 +1222,16 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
angle += M_PI;
double const cos_t = cos(angle);
double const sin_t = sin(angle);
- for (unsigned int i = 0; i < nr_stars; i++) {
+ for (unsigned int i = 0; i < nr_stars; i++)
+ {
cc[i].x = pos[i].x * cos_t - pos[i].y * sin_t + width / 2.0;
cc[i].y = pos[i].x * sin_t + pos[i].y * cos_t + height / 2.0;
}
-#ifdef STEPGUIDER_SIMULATOR
+# ifdef STEPGUIDER_SIMULATOR
// add-in AO offset
- if (s_sim_ao) {
+ if (s_sim_ao)
+ {
double const ao_angle = radians(SimAoParams::angle);
double const cos_a = cos(ao_angle);
double const sin_a = sin(ao_angle);
@@ -1133,12 +1239,13 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
double const ao_y = (double) s_sim_ao->CurrentPosition(UP) * SimAoParams::scale;
double const dx = ao_x * cos_a - ao_y * sin_a;
double const dy = ao_x * sin_a + ao_y * cos_a;
- for (unsigned int i = 0; i < nr_stars; i++) {
+ for (unsigned int i = 0; i < nr_stars; i++)
+ {
cc[i].x += dx;
cc[i].y += dy;
}
}
-#endif // STEPGUIDER_SIMULATOR
+# endif // STEPGUIDER_SIMULATOR
// render each star
if (!pCamera->ShutterClosed)
@@ -1147,13 +1254,13 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
{
double star = stars[i].inten * exptime * gain;
double dark = (double) gain / 10.0 * offset * exptime / 100.0;
- double noise = (double)(rand() % (gain * 100));
+ double noise = (double) (rand() % (gain * 100));
double inten = star + dark + noise;
render_star(img, pCamera->Binning, subframe, cc[i], inten);
}
-#ifndef SIM_FILE_DISPLACEMENTS
+# ifndef SIM_FILE_DISPLACEMENTS
if (SimCamParams::show_comet)
{
double x = total_shift_x + now * SimCamParams::comet_rate_x / 3600.;
@@ -1164,12 +1271,12 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
double inten = 3.0;
double star = inten * exptime * gain;
double dark = (double) gain / 10.0 * offset * exptime / 100.0;
- double noise = (double)(rand() % (gain * 100));
+ double noise = (double) (rand() % (gain * 100));
inten = star + dark + noise;
render_comet(img, pCamera->Binning, subframe, wxRealPoint(cx, cy), inten);
}
-#endif
+# endif
}
if (SimCamParams::clouds_opacity > 0)
@@ -1182,31 +1289,32 @@ void SimCamState::FillImage(usImage& img, const wxRect& subframe, int exptime, i
p.x /= pCamera->Binning;
p.y /= pCamera->Binning;
if (subframe.Contains(p))
- set_pixel(img, p.x, p.y, (unsigned short)-1);
+ set_pixel(img, p.x, p.y, (unsigned short) -1);
}
}
class CameraSimulator : public GuideCamera
{
SimCamState sim;
+
public:
CameraSimulator();
~CameraSimulator();
- bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
- bool Connect(const wxString& camId) override;
- bool Disconnect() override;
- void ShowPropertyDialog() override;
- bool HasNonGuiCapture() override { return true; }
- wxByte BitsPerPixel() override;
- bool SetCoolerOn(bool on) override;
- bool SetCoolerSetpoint(double temperature) override;
- bool GetCoolerStatus(bool *on, double *setpoint, double *power, double *temperature) override;
- bool GetSensorTemperature(double *temperature) override;
- bool ST4HasNonGuiMove() override { return true; }
- bool ST4SynchronousOnly() override;
- bool ST4PulseGuideScope(int direction, int duration) override;
+ bool Capture(int duration, usImage& img, int options, const wxRect& subframe) override;
+ bool Connect(const wxString& camId) override;
+ bool Disconnect() override;
+ void ShowPropertyDialog() override;
+ bool HasNonGuiCapture() override { return true; }
+ wxByte BitsPerPixel() override;
+ bool SetCoolerOn(bool on) override;
+ bool SetCoolerSetpoint(double temperature) override;
+ bool GetCoolerStatus(bool *on, double *setpoint, double *power, double *temperature) override;
+ bool GetSensorTemperature(double *temperature) override;
+ bool ST4HasNonGuiMove() override { return true; }
+ bool ST4SynchronousOnly() override;
+ bool ST4PulseGuideScope(int direction, int duration) override;
PierSide SideOfPier() const;
- void FlipPierSide();
+ void FlipPierSide();
};
CameraSimulator::CameraSimulator()
@@ -1224,11 +1332,11 @@ CameraSimulator::CameraSimulator()
wxByte CameraSimulator::BitsPerPixel()
{
-#if 1
+# if 1
return 16;
-#else
+# else
return 8;
-#endif
+# endif
}
bool CameraSimulator::Connect(const wxString& camId)
@@ -1239,18 +1347,21 @@ bool CameraSimulator::Connect(const wxString& camId)
struct ConnectInBg : public ConnectCameraInBg
{
CameraSimulator *cam;
- ConnectInBg(CameraSimulator *cam_) : cam(cam_) { }
+ ConnectInBg(CameraSimulator *cam_)
+ : cam(cam_)
+ {
+ }
bool Entry()
{
-//#define TEST_SLOW_CONNECT
-#ifdef TEST_SLOW_CONNECT
+// #define TEST_SLOW_CONNECT
+# ifdef TEST_SLOW_CONNECT
for (int i = 0; i < 100; i++)
{
wxMilliSleep(100);
if (IsCanceled())
return true;
}
-#endif
+# endif
return false;
}
};
@@ -1270,18 +1381,18 @@ bool CameraSimulator::Disconnect()
CameraSimulator::~CameraSimulator()
{
-#ifdef SIMDEBUG
+# ifdef SIMDEBUG
sim.DebugFile.Close();
-#endif
-#ifdef SIM_FILE_DISPLACEMENTS
+# endif
+# ifdef SIM_FILE_DISPLACEMENTS
if (sim.pText)
delete sim.pText;
if (sim.pIStream)
delete sim.pIStream;
-#endif
+# endif
}
-#if SIMMODE==2
+# if SIMMODE == 2
bool CameraSimulator::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
int xsize, ysize;
@@ -1290,30 +1401,33 @@ bool CameraSimulator::Capture(int duration, usImage& img, int options, const wxR
unsigned char *imgptr;
bool retval = disk_image.LoadFile("/Users/stark/dev/PHD/simimage.bmp");
- if (!retval) {
+ if (!retval)
+ {
pFrame->Alert(_("Cannot load simulated image"));
return true;
}
xsize = disk_image.GetWidth();
ysize = disk_image.GetHeight();
- if (img.Init(xsize,ysize)) {
+ if (img.Init(xsize, ysize))
+ {
pFrame->Alert(_("Memory allocation error"));
return true;
}
dataptr = img.ImageData;
imgptr = disk_image.GetData();
- for (unsigned int i = 0; i < img.NPixels; i++, dataptr++, imgptr++) {
+ for (unsigned int i = 0; i < img.NPixels; i++, dataptr++, imgptr++)
+ {
*dataptr = (unsigned short) *imgptr;
- imgptr++; imgptr++;
+ imgptr++;
+ imgptr++;
}
QuickLRecon(img);
return false;
-
}
-#endif
+# endif
-#if SIMMODE == 3
+# if SIMMODE == 3
static void fill_noise(usImage& img, const wxRect& subframe, int exptime, int gain, int offset)
{
unsigned short *p0 = &img.Pixel(subframe.GetLeft(), subframe.GetTop());
@@ -1321,17 +1435,19 @@ static void fill_noise(usImage& img, const wxRect& subframe, int exptime, int ga
{
unsigned short *const end = p0 + subframe.GetWidth();
for (unsigned short *p = p0; p < end; p++)
- *p = (unsigned short) (SimCamParams::noise_multiplier * ((double) gain / 10.0 * offset * exptime / 100.0 + (rand() % (gain * 100))));
+ *p = (unsigned short) (SimCamParams::noise_multiplier *
+ ((double) gain / 10.0 * offset * exptime / 100.0 + (rand() % (gain * 100))));
}
}
-#endif // SIMMODE == 3
+# endif // SIMMODE == 3
bool CameraSimulator::Capture(int duration, usImage& img, int options, const wxRect& subframeArg)
{
wxRect subframe(subframeArg);
CameraWatchdog watchdog(duration, GetTimeoutMs());
- // sleep before rendering the image so that any changes made in the middle of a long exposure (e.g. manual guide pulse) shows up in the image
+ // sleep before rendering the image so that any changes made in the middle of a long exposure (e.g. manual guide pulse)
+ // shows up in the image
if (duration > 5)
{
@@ -1344,7 +1460,7 @@ bool CameraSimulator::Capture(int duration, usImage& img, int options, const wxR
}
}
-#if SIMMODE == 1
+# if SIMMODE == 1
if (!UseSubframes)
subframe = wxRect();
@@ -1354,7 +1470,7 @@ bool CameraSimulator::Capture(int duration, usImage& img, int options, const wxR
FullSize = img.Size;
-#else
+# else
int width = sim.width / Binning;
int height = sim.height / Binning;
@@ -1386,9 +1502,10 @@ bool CameraSimulator::Capture(int duration, usImage& img, int options, const wxR
if (usingSubframe)
img.Subframe = subframe;
- if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
+ if (options & CAPTURE_SUBTRACT_DARK)
+ SubtractDark(img);
-#endif // SIMMODE == 1
+# endif // SIMMODE == 1
unsigned int tot_dur = duration + SimCamParams::frame_download_ms;
long elapsed = watchdog.Time();
@@ -1428,18 +1545,33 @@ bool CameraSimulator::ST4PulseGuideScope(int direction, int duration)
if (SimCamParams::pier_side == PIER_SIDE_WEST && SimCamParams::reverse_dec_pulse_on_west_side)
{
// after pier flip, North/South have opposite affect on declination
- switch (direction) {
- case NORTH: direction = SOUTH; break;
- case SOUTH: direction = NORTH; break;
+ switch (direction)
+ {
+ case NORTH:
+ direction = SOUTH;
+ break;
+ case SOUTH:
+ direction = NORTH;
+ break;
}
}
- switch (direction) {
- case WEST: sim.ra_ofs += d; break;
- case EAST: sim.ra_ofs -= d; break;
- case NORTH: sim.dec_ofs.incr(d); break;
- case SOUTH: sim.dec_ofs.incr(-d); break;
- default: return true;
+ switch (direction)
+ {
+ case WEST:
+ sim.ra_ofs += d;
+ break;
+ case EAST:
+ sim.ra_ofs -= d;
+ break;
+ case NORTH:
+ sim.dec_ofs.incr(d);
+ break;
+ case SOUTH:
+ sim.dec_ofs.incr(-d);
+ break;
+ default:
+ return true;
}
WorkerThread::MilliSleep(duration, WorkerThread::INT_ANY);
return false;
@@ -1474,7 +1606,9 @@ bool CameraSimulator::GetCoolerStatus(bool *onp, double *setpoint, double *power
if (on)
{
*setpoint = sim.cooler.setTemp;
- *power = cur < MIN_COOLER_TEMP ? 100. : cur >= AMBIENT_TEMP ? 0. : (AMBIENT_TEMP - cur) * 100. / (AMBIENT_TEMP - MIN_COOLER_TEMP);
+ *power = cur < MIN_COOLER_TEMP ? 100.
+ : cur >= AMBIENT_TEMP ? 0.
+ : (AMBIENT_TEMP - cur) * 100. / (AMBIENT_TEMP - MIN_COOLER_TEMP);
*temperature = cur;
}
else
@@ -1510,21 +1644,22 @@ static PierSide OtherSide(PierSide side)
void CameraSimulator::FlipPierSide()
{
SimCamParams::pier_side = OtherSide(SimCamParams::pier_side);
- Debug.Write(wxString::Format("CamSimulator FlipPierSide: side = %d cam_angle = %.1f\n", SimCamParams::pier_side, SimCamParams::cam_angle));
+ Debug.Write(wxString::Format(
+ "CamSimulator FlipPierSide: side = %d cam_angle = %.1f\n", SimCamParams::pier_side, SimCamParams::cam_angle));
}
-#if SIMMODE == 4
+# if SIMMODE == 4
bool CameraSimulator::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
int xsize, ysize;
// unsigned short *dataptr;
// int i;
- fitsfile *fptr; // FITS file pointer
- int status = 0; // CFITSIO status value MUST be initialized to zero!
+ fitsfile *fptr; // FITS file pointer
+ int status = 0; // CFITSIO status value MUST be initialized to zero!
int hdutype, naxis;
- int nhdus=0;
+ int nhdus = 0;
long fits_size[2];
- long fpixel[3] = {1,1,1};
+ long fpixel[3] = { 1, 1, 1 };
// char keyname[15];
// char keystrval[80];
static int frame = 0;
@@ -1533,7 +1668,8 @@ bool CameraSimulator::Capture(int duration, usImage& img, int options, const wxR
snprintf(fname, sizeof(fname), "/Users/stark/dev/PHD/simimg/DriftSim_%d.fit", frame);
if (!PHD_fits_open_diskfile(&fptr, fname, READONLY, &status))
{
- if (fits_get_hdu_type(fptr, &hdutype, &status) || hdutype != IMAGE_HDU) {
+ if (fits_get_hdu_type(fptr, &hdutype, &status) || hdutype != IMAGE_HDU)
+ {
pFrame->Alert(_("FITS file is not of an image"));
PHD_fits_close_file(fptr);
return true;
@@ -1544,38 +1680,41 @@ bool CameraSimulator::Capture(int duration, usImage& img, int options, const wxR
fits_get_img_size(fptr, 2, fits_size, &status);
xsize = (int) fits_size[0];
ysize = (int) fits_size[1];
- fits_get_num_hdus(fptr,&nhdus,&status);
- if ((nhdus != 1) || (naxis != 2)) {
- pFrame->Alert(wxString::Format(_("Unsupported type or read error loading FITS file %d %d"),nhdus,naxis));
+ fits_get_num_hdus(fptr, &nhdus, &status);
+ if ((nhdus != 1) || (naxis != 2))
+ {
+ pFrame->Alert(wxString::Format(_("Unsupported type or read error loading FITS file %d %d"), nhdus, naxis));
PHD_fits_close_file(fptr);
return true;
}
- if (img.Init(xsize,ysize)) {
+ if (img.Init(xsize, ysize))
+ {
pFrame->Alert(_("Memory allocation error"));
PHD_fits_close_file(fptr);
return true;
}
- if (fits_read_pix(fptr, TUSHORT, fpixel, xsize*ysize, nullptr, img.ImageData, nullptr, &status) ) { // Read image
+ if (fits_read_pix(fptr, TUSHORT, fpixel, xsize * ysize, nullptr, img.ImageData, nullptr, &status))
+ { // Read image
pFrame->Alert(_("Error reading data"));
PHD_fits_close_file(fptr);
return true;
}
PHD_fits_close_file(fptr);
frame = frame + step;
- if (frame > 440) {
+ if (frame > 440)
+ {
step = -1;
frame = 439;
}
- else if (frame < 0) {
+ else if (frame < 0)
+ {
step = 1;
frame = 1;
}
-
}
return false;
-
}
-#endif // SIMMODE == 4
+# endif // SIMMODE == 4
struct SimCamDialog : public wxDialog
{
@@ -1588,7 +1727,7 @@ struct SimCamDialog : public wxDialog
wxSpinCtrlDouble *pGuideRateSpin;
wxSpinCtrlDouble *pCameraAngleSpin;
wxSpinCtrlDouble *pSeeingSpin;
- wxCheckBox* showComet;
+ wxCheckBox *showComet;
wxCheckBox *pUsePECbx;
wxCheckBox *pUseStiction;
wxCheckBox *pReverseDecPulseCbx;
@@ -1624,17 +1763,18 @@ wxEND_EVENT_TABLE();
// Utility functions for adding controls with specified properties
static wxSlider *NewSlider(wxWindow *parent, int val, int minval, int maxval, const wxString& tooltip)
{
- wxSlider *pNewCtrl = new wxSlider(parent, wxID_ANY, val, minval, maxval, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_VALUE_LABEL);
+ wxSlider *pNewCtrl = new wxSlider(
+ parent, wxID_ANY, val, minval, maxval, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_VALUE_LABEL);
pNewCtrl->SetToolTip(tooltip);
return pNewCtrl;
}
-static wxSpinCtrlDouble *NewSpinner(wxWindow *parent, double val, double minval, double maxval, double inc,
- const wxString& tooltip)
+static wxSpinCtrlDouble *NewSpinner(
+ wxWindow *parent, double val, double minval, double maxval, double inc, const wxString& tooltip)
{
wxSize sz = pFrame->GetTextExtent(wxString::Format("%.2f", maxval * 10.));
- wxSpinCtrlDouble *pNewCtrl = pFrame->MakeSpinCtrlDouble(parent, wxID_ANY, wxEmptyString, wxDefaultPosition,
- sz, wxSP_ARROW_KEYS, minval, maxval, val, inc);
+ wxSpinCtrlDouble *pNewCtrl = pFrame->MakeSpinCtrlDouble(
+ parent, wxID_ANY, wxEmptyString, wxDefaultPosition, sz, wxSP_ARROW_KEYS, minval, maxval, val, inc);
pNewCtrl->SetDigits(2);
pNewCtrl->SetToolTip(tooltip);
return pNewCtrl;
@@ -1651,18 +1791,19 @@ static wxCheckBox *NewCheckBox(wxWindow *parent, bool val, const wxString& label
// Utility function to add the pairs to a grid including tool-tips
static void AddTableEntryPair(wxWindow *parent, wxFlexGridSizer *pTable, const wxString& label, wxWindow *pControl)
{
- wxStaticText *pLabel = new wxStaticText(parent, wxID_ANY, label + _(": "), wxPoint(-1,-1), wxSize(-1,-1));
+ wxStaticText *pLabel = new wxStaticText(parent, wxID_ANY, label + _(": "), wxPoint(-1, -1), wxSize(-1, -1));
pTable->Add(pLabel, 1, wxALL, 5);
pTable->Add(pControl, 1, wxALL, 5);
}
-static wxTextCtrl *AddCustomPEField(wxWindow *parent, wxFlexGridSizer *pTable, const wxString& label, const wxString& tip, double val)
+static wxTextCtrl *AddCustomPEField(
+ wxWindow *parent, wxFlexGridSizer *pTable, const wxString& label, const wxString& tip, double val)
{
int width;
int height;
parent->GetTextExtent(_T("999.9"), &width, &height);
- wxTextCtrl *pCtrl = new wxTextCtrl(parent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width+30, -1));
+ wxTextCtrl *pCtrl = new wxTextCtrl(parent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width + 30, -1));
pCtrl->SetValue(wxString::Format("%.1f", val));
pCtrl->SetToolTip(tip);
AddTableEntryPair(parent, pTable, label, pCtrl);
@@ -1689,7 +1830,7 @@ static void SetControlStates(SimCamDialog *dlg, bool captureActive)
dlg->pPECustomPeriod->Enable(enable);
dlg->pPECustomRb->Enable(enable);
dlg->pUsePECbx->Enable(enable);
- dlg->pUseStiction->Show(false); // no good for end-users
+ dlg->pUseStiction->Show(false); // no good for end-users
dlg->pPierFlip->Enable(enable);
dlg->pReverseDecPulseCbx->Enable(enable);
dlg->pResetBtn->Enable(enable);
@@ -1751,7 +1892,7 @@ SimCamDialog::SimCamDialog(wxWindow *parent)
AddTableEntryPair(this, pCamTable, _("Stars"), pStarsSlider);
pHotpxSlider = NewSlider(this, SimCamParams::nr_hot_pixels, 0, 50, _("Number of hot pixels"));
AddTableEntryPair(this, pCamTable, _("Hot pixels"), pHotpxSlider);
- pNoiseSlider = NewSlider(this, (int)floor(SimCamParams::noise_multiplier * 100 / NOISE_MAX), 0, 100,
+ pNoiseSlider = NewSlider(this, (int) floor(SimCamParams::noise_multiplier * 100 / NOISE_MAX), 0, 100,
/* xgettext:no-c-format */ _("% Simulated noise"));
AddTableEntryPair(this, pCamTable, _("Noise"), pNoiseSlider);
pCamGroup->Add(pCamTable);
@@ -1759,14 +1900,16 @@ SimCamDialog::SimCamDialog(wxWindow *parent)
// Mount group controls
wxStaticBoxSizer *pMountGroup = new wxStaticBoxSizer(wxVERTICAL, this, _("Mount"));
wxFlexGridSizer *pMountTable = new wxFlexGridSizer(2, 6, 5, 15);
- pBacklashSpin = NewSpinner(this, SimCamParams::dec_backlash * imageScale, 0, DEC_BACKLASH_MAX, 0.1, _("Dec backlash, arc-secs"));
+ pBacklashSpin =
+ NewSpinner(this, SimCamParams::dec_backlash * imageScale, 0, DEC_BACKLASH_MAX, 0.1, _("Dec backlash, arc-secs"));
AddTableEntryPair(this, pMountTable, _("Dec backlash"), pBacklashSpin);
- pDriftSpin = NewSpinner(this, SimCamParams::dec_drift_rate * 60.0 * imageScale, -DEC_DRIFT_MAX, DEC_DRIFT_MAX, 0.5, _("Dec drift, arc-sec/min"));
+ pDriftSpin = NewSpinner(this, SimCamParams::dec_drift_rate * 60.0 * imageScale, -DEC_DRIFT_MAX, DEC_DRIFT_MAX, 0.5,
+ _("Dec drift, arc-sec/min"));
AddTableEntryPair(this, pMountTable, _("Dec drift"), pDriftSpin);
pGuideRateSpin = NewSpinner(this, SimCamParams::guide_rate / 15.0, 0.25, GUIDE_RATE_MAX, 0.25, _("Guide rate, x sidereal"));
AddTableEntryPair(this, pMountTable, _("Guide rate"), pGuideRateSpin);
pUseStiction = NewCheckBox(this, SimCamParams::use_stiction, _("Apply stiction"), _("Simulate dec axis stiction"));
- pUseStiction->Enable(false); // too crude to put in hands of users
+ pUseStiction->Enable(false); // too crude to put in hands of users
pMountTable->Add(pUseStiction, 1, wxBOTTOM, 15);
pMountGroup->Add(pMountTable);
@@ -1779,8 +1922,8 @@ SimCamDialog::SimCamDialog(wxWindow *parent)
pPEDefaultRb = new wxRadioButton(this, wxID_ANY, _("Default curve"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
pPEDefaultRb->SetValue(SimCamParams::use_default_pe_params);
pPEDefaultRb->SetToolTip(_("Use a built-in PE curve that has some steep and smooth sections."));
- pPEDefaultRb->Bind(wxEVT_COMMAND_RADIOBUTTON_SELECTED, &SimCamDialog::OnRbDefaultPE, this); // Event handler binding
- wxStaticText *pSliderLabel = new wxStaticText(this, wxID_ANY, _("Amplitude: "),wxPoint(-1,-1),wxSize(-1,-1));
+ pPEDefaultRb->Bind(wxEVT_COMMAND_RADIOBUTTON_SELECTED, &SimCamDialog::OnRbDefaultPE, this); // Event handler binding
+ wxStaticText *pSliderLabel = new wxStaticText(this, wxID_ANY, _("Amplitude: "), wxPoint(-1, -1), wxSize(-1, -1));
pPEDefScale = NewSpinner(this, SimCamParams::pe_scale, 0, PE_SCALE_MAX, 0.5, _("PE Amplitude, arc-secs"));
int hor_spacing = StringWidth(this, "9");
@@ -1792,7 +1935,7 @@ SimCamDialog::SimCamDialog(wxWindow *parent)
pPECustomRb = new wxRadioButton(this, wxID_ANY, _("Custom curve"), wxDefaultPosition, wxDefaultSize);
pPECustomRb->SetValue(!SimCamParams::use_default_pe_params);
pPECustomRb->SetToolTip(_("Use a simple sinusoidal curve. You can specify the amplitude and period."));
- pPECustomRb->Bind(wxEVT_COMMAND_RADIOBUTTON_SELECTED, &SimCamDialog::OnRbCustomPE, this); // Event handler binding
+ pPECustomRb->Bind(wxEVT_COMMAND_RADIOBUTTON_SELECTED, &SimCamDialog::OnRbCustomPE, this); // Event handler binding
pPECustom->Add(pPECustomRb, wxSizerFlags().Border(wxTOP, 4));
pPECustomAmp = AddCustomPEField(this, pPECustom, _("Amplitude"), _("Amplitude, arc-secs"), SimCamParams::custom_pe_amp);
pPECustomPeriod = AddCustomPEField(this, pPECustom, _("Period"), _("Period, seconds"), SimCamParams::custom_pe_period);
@@ -1807,14 +1950,15 @@ SimCamDialog::SimCamDialog(wxWindow *parent)
// Now add some miscellaneous mount-related stuff (still within mount group)
wxBoxSizer *pMiscSizer = new wxBoxSizer(wxHORIZONTAL);
- pReverseDecPulseCbx = NewCheckBox(this, SimCamParams::reverse_dec_pulse_on_west_side, _("Reverse Dec pulse on West side of pier"),
- _("Simulate a mount that reverses guide pulse direction after a meridian flip, like an ASCOM pulse-guided mount."));
+ pReverseDecPulseCbx =
+ NewCheckBox(this, SimCamParams::reverse_dec_pulse_on_west_side, _("Reverse Dec pulse on West side of pier"),
+ _("Simulate a mount that reverses guide pulse direction after a meridian flip, like an ASCOM pulse-guided mount."));
pPierSide = SimCamParams::pier_side;
pPiersideLabel = new wxStaticText(this, wxID_ANY, _("Side of Pier: MMMMM"));
pMiscSizer->Add(pReverseDecPulseCbx, wxSizerFlags().Border(10).Expand());
pPierFlip = new wxButton(this, wxID_CONVERT, _("Pier Flip"));
pMiscSizer->Add(pPierFlip, wxSizerFlags().Border(wxLEFT, 30).Expand());
- pMiscSizer->Add(pPiersideLabel , wxSizerFlags().Border(wxLEFT, 30).Expand());
+ pMiscSizer->Add(pPiersideLabel, wxSizerFlags().Border(wxLEFT, 30).Expand());
pMountGroup->Add(pPEGroup, wxSizerFlags().Center().Border(10).Expand());
pMountGroup->Add(pMiscSizer, wxSizerFlags().Border(wxTOP, 10).Expand());
@@ -1825,7 +1969,7 @@ SimCamDialog::SimCamDialog(wxWindow *parent)
AddTableEntryPair(this, pSessionTable, _("Camera angle"), pCameraAngleSpin);
pSeeingSpin = NewSpinner(this, SimCamParams::seeing_scale, 0, SEEING_MAX, 0.5, _("Seeing, FWHM arc-sec"));
AddTableEntryPair(this, pSessionTable, _("Seeing"), pSeeingSpin);
- pCloudSlider = NewSlider(this, (int)(100 * SimCamParams::clouds_opacity), 0, 100, _("% cloud opacity"));
+ pCloudSlider = NewSlider(this, (int) (100 * SimCamParams::clouds_opacity), 0, 100, _("% cloud opacity"));
AddTableEntryPair(this, pSessionTable, _("Cloud %"), pCloudSlider);
showComet = new wxCheckBox(this, wxID_ANY, _("Comet"));
showComet->SetValue(SimCamParams::show_comet);
@@ -1837,31 +1981,23 @@ SimCamDialog::SimCamDialog(wxWindow *parent)
pVSizer->Add(pSessionGroup, wxSizerFlags().Border(wxRIGHT | wxLEFT, 10).Expand());
// Now deal with the buttons
- wxBoxSizer *pButtonSizer = new wxBoxSizer( wxHORIZONTAL );
+ wxBoxSizer *pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
pResetBtn = new wxButton(this, wxID_RESET, _("Reset"));
pResetBtn->SetToolTip(_("Reset all values to application defaults"));
- pButtonSizer->Add(
- pResetBtn,
- wxSizerFlags(0).Align(0).Border(wxALL, 10));
+ pButtonSizer->Add(pResetBtn, wxSizerFlags(0).Align(0).Border(wxALL, 10));
// Need to handle the OK event ourselves to validate text input fields
wxButton *pBtn = new wxButton(this, wxID_OK, _("OK"));
pBtn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &SimCamDialog::OnOkClick, this);
- pButtonSizer->Add(
- pBtn,
- wxSizerFlags(0).Align(0).Border(wxALL, 10));
- pButtonSizer->Add(
- new wxButton( this, wxID_CANCEL, _("Cancel") ),
- wxSizerFlags(0).Align(0).Border(wxALL, 10));
+ pButtonSizer->Add(pBtn, wxSizerFlags(0).Align(0).Border(wxALL, 10));
+ pButtonSizer->Add(new wxButton(this, wxID_CANCEL, _("Cancel")), wxSizerFlags(0).Align(0).Border(wxALL, 10));
// position the buttons centered with no border
- pVSizer->Add(
- pButtonSizer,
- wxSizerFlags(0).Center() );
+ pVSizer->Add(pButtonSizer, wxSizerFlags(0).Center());
SetSizerAndFit(pVSizer);
SetControlStates(this, pFrame->CaptureActive);
if (!pFrame->CaptureActive)
- SetRBState(this, pPEDefaultRb->GetValue()); // Enable matching PE-related controls
+ SetRBState(this, pPEDefaultRb->GetValue()); // Enable matching PE-related controls
UpdatePierSideLabel();
}
@@ -1869,7 +2005,7 @@ void SimCamDialog::OnReset(wxCommandEvent& event)
{
pStarsSlider->SetValue(NR_STARS_DEFAULT);
pHotpxSlider->SetValue(NR_HOT_PIXELS_DEFAULT);
- pNoiseSlider->SetValue((int)floor(NOISE_DEFAULT * 100.0 / NOISE_MAX));
+ pNoiseSlider->SetValue((int) floor(NOISE_DEFAULT * 100.0 / NOISE_MAX));
pBacklashSpin->SetValue(DEC_BACKLASH_DEFAULT);
pCloudSlider->SetValue(0);
@@ -1883,10 +2019,10 @@ void SimCamDialog::OnReset(wxCommandEvent& event)
pPEDefaultRb->SetValue(USE_PE_DEFAULT_PARAMS);
pPECustomRb->SetValue(!USE_PE_DEFAULT_PARAMS);
pPEDefScale->SetValue(PE_SCALE_DEFAULT);
- pPECustomAmp->SetValue(wxString::Format("%0.1f",PE_CUSTOM_AMP_DEFAULT));
+ pPECustomAmp->SetValue(wxString::Format("%0.1f", PE_CUSTOM_AMP_DEFAULT));
pPECustomPeriod->SetValue(wxString::Format("%0.1f", PE_CUSTOM_PERIOD_DEFAULT));
pPierSide = PIER_SIDE_DEFAULT;
- SetRBState( this, USE_PE_DEFAULT_PARAMS);
+ SetRBState(this, USE_PE_DEFAULT_PARAMS);
UpdatePierSideLabel();
showComet->SetValue(SHOW_COMET_DEFAULT);
}
@@ -1898,7 +2034,7 @@ void SimCamDialog::OnPierFlip(wxCommandEvent& event)
if (angle >= 360)
angle -= 360;
pCameraAngleSpin->SetValue(angle);
- pPierSide= OtherSide(pPierSide);
+ pPierSide = OtherSide(pPierSide);
UpdatePierSideLabel();
}
@@ -1910,9 +2046,13 @@ void SimCamDialog::UpdatePierSideLabel()
struct UpdateChecker
{
bool updated;
- UpdateChecker() : updated(false) { }
+ UpdateChecker()
+ : updated(false)
+ {
+ }
template
- void Update(T& val, const U& newval) {
+ void Update(T& val, const U& newval)
+ {
if (val != newval)
{
val = newval;
@@ -1925,15 +2065,15 @@ struct UpdateChecker
void CameraSimulator::ShowPropertyDialog()
{
SimCamDialog dlg(pFrame);
- double imageScale = pFrame->GetCameraPixelScale(); // arc-sec/pixel, defaults to 1.0 if no user specs
- SimCamParams::image_scale = imageScale; // keep current - might have gotten changed in brain dialog
+ double imageScale = pFrame->GetCameraPixelScale(); // arc-sec/pixel, defaults to 1.0 if no user specs
+ SimCamParams::image_scale = imageScale; // keep current - might have gotten changed in brain dialog
if (dlg.ShowModal() == wxID_OK)
{
UpdateChecker upd; // keep track of whether any values changed
upd.Update(SimCamParams::nr_stars, dlg.pStarsSlider->GetValue());
upd.Update(SimCamParams::nr_hot_pixels, dlg.pHotpxSlider->GetValue());
SimCamParams::noise_multiplier = (double) dlg.pNoiseSlider->GetValue() * NOISE_MAX / 100.0;
- upd.Update(SimCamParams::dec_backlash, dlg.pBacklashSpin->GetValue() / imageScale); // a-s -> px
+ upd.Update(SimCamParams::dec_backlash, dlg.pBacklashSpin->GetValue() / imageScale); // a-s -> px
bool use_pe = dlg.pUsePECbx->GetValue();
SimCamParams::use_pe = use_pe;
@@ -1949,10 +2089,10 @@ void CameraSimulator::ShowPropertyDialog()
dlg.pPECustomAmp->GetValue().ToDouble(&SimCamParams::custom_pe_amp);
dlg.pPECustomPeriod->GetValue().ToDouble(&SimCamParams::custom_pe_period);
}
- SimCamParams::dec_drift_rate = dlg.pDriftSpin->GetValue() / (imageScale * 60.0); // a-s per min to px per second
- SimCamParams::seeing_scale = dlg.pSeeingSpin->GetValue(); // already in a-s
+ SimCamParams::dec_drift_rate = dlg.pDriftSpin->GetValue() / (imageScale * 60.0); // a-s per min to px per second
+ SimCamParams::seeing_scale = dlg.pSeeingSpin->GetValue(); // already in a-s
upd.Update(SimCamParams::cam_angle, dlg.pCameraAngleSpin->GetValue());
- SimCamParams::guide_rate = dlg.pGuideRateSpin->GetValue() * 15.0;
+ SimCamParams::guide_rate = dlg.pGuideRateSpin->GetValue() * 15.0;
SimCamParams::pier_side = dlg.pPierSide;
SimCamParams::reverse_dec_pulse_on_west_side = dlg.pReverseDecPulseCbx->GetValue();
SimCamParams::show_comet = dlg.showComet->GetValue();
diff --git a/src/graph-stepguider.cpp b/src/graph-stepguider.cpp
index 735e4e3b1..3b62684c4 100644
--- a/src/graph-stepguider.cpp
+++ b/src/graph-stepguider.cpp
@@ -41,7 +41,6 @@
class GraphStepguiderClient : public wxWindow
{
public:
-
static const unsigned int m_maxHistorySize = 64;
struct
@@ -53,11 +52,11 @@ class GraphStepguiderClient : public wxWindow
PHD_Point m_avgPos;
PHD_Point m_curBump;
- wxPen *m_pPens[m_maxHistorySize];
+ wxPen *m_pPens[m_maxHistorySize];
wxBrush *m_pBrushes[m_maxHistorySize];
- unsigned int m_nItems; // # of items in the history
- unsigned int m_length; // # of items to display
+ unsigned int m_nItems; // # of items in the history
+ unsigned int m_length; // # of items to display
int m_xMax;
int m_yMax;
@@ -84,8 +83,8 @@ wxBEGIN_EVENT_TABLE(GraphStepguiderWindow, wxWindow)
wxEND_EVENT_TABLE();
// clang-format on
-GraphStepguiderWindow::GraphStepguiderWindow(wxWindow *parent) :
- wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _("AO Position"))
+GraphStepguiderWindow::GraphStepguiderWindow(wxWindow *parent)
+ : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _("AO Position"))
{
SetBackgroundColour(*wxBLACK);
@@ -98,23 +97,25 @@ GraphStepguiderWindow::GraphStepguiderWindow(wxWindow *parent) :
pMainSizer->Add(pLeftSizer, wxSizerFlags().Expand());
m_pClient->m_length = pConfig->Global.GetInt("/graph_stepguider/length", 1);
- wxString label = wxString::Format(_T("%3d"),m_pClient->m_length);
- LengthButton = new OptionsButton(this,BUTTON_GRAPH_LENGTH,label,wxPoint(10,10),wxSize(80,-1),wxALIGN_CENTER_HORIZONTAL);
+ wxString label = wxString::Format(_T("%3d"), m_pClient->m_length);
+ LengthButton =
+ new OptionsButton(this, BUTTON_GRAPH_LENGTH, label, wxPoint(10, 10), wxSize(80, -1), wxALIGN_CENTER_HORIZONTAL);
LengthButton->SetToolTip(_("Select the number of frames of history to display"));
pLeftSizer->Add(LengthButton, wxSizerFlags().Border(wxALL, 3).Expand());
- ClearButton = new wxButton(this,BUTTON_GRAPH_CLEAR,_("Clear"),wxPoint(10,100),wxSize(80,-1));
+ ClearButton = new wxButton(this, BUTTON_GRAPH_CLEAR, _("Clear"), wxPoint(10, 100), wxSize(80, -1));
ClearButton->SetToolTip(_("Clear graph data"));
pLeftSizer->Add(ClearButton, wxSizerFlags().Center().Border(wxALL, 3));
pLeftSizer->AddStretchSpacer();
- m_hzText = new wxStaticText(this, wxID_ANY, wxEmptyString/*wxString::Format(_("%.1f Hz"), 999.9)*/, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER | wxST_NO_AUTORESIZE);
+ m_hzText = new wxStaticText(this, wxID_ANY, wxEmptyString /*wxString::Format(_("%.1f Hz"), 999.9)*/, wxDefaultPosition,
+ wxDefaultSize, wxALIGN_CENTER | wxST_NO_AUTORESIZE);
m_hzText->SetForegroundColour(*wxLIGHT_GREY);
m_hzText->SetBackgroundColour(*wxBLACK);
pLeftSizer->Add(m_hzText, wxSizerFlags().Border(wxALL, 3).Expand());
- pMainSizer->Add(m_pClient, wxSizerFlags().Border(wxALL,3).Expand().Proportion(1));
+ pMainSizer->Add(m_pClient, wxSizerFlags().Border(wxALL, 3).Expand().Proportion(1));
SetSizer(pMainSizer);
pMainSizer->SetSizeHints(this);
@@ -142,8 +143,7 @@ void GraphStepguiderWindow::OnButtonLength(wxCommandEvent& WXUNUSED(evt))
break;
}
- PopupMenu(menu, LengthButton->GetPosition().x,
- LengthButton->GetPosition().y + LengthButton->GetSize().GetHeight());
+ PopupMenu(menu, LengthButton->GetPosition().x, LengthButton->GetPosition().y + LengthButton->GetSize().GetHeight());
delete menu;
}
@@ -175,8 +175,7 @@ bool GraphStepguiderWindow::SetState(bool is_active)
return m_visible;
}
-void GraphStepguiderWindow::SetLimits(unsigned int xMax, unsigned int yMax,
- unsigned int xBump, unsigned int yBump)
+void GraphStepguiderWindow::SetLimits(unsigned int xMax, unsigned int yMax, unsigned int xBump, unsigned int yBump)
{
assert(wxThread::IsMain());
@@ -240,8 +239,8 @@ wxBEGIN_EVENT_TABLE(GraphStepguiderClient, wxWindow)
wxEND_EVENT_TABLE();
// clang-format on
-GraphStepguiderClient::GraphStepguiderClient(wxWindow *parent) :
- wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(201,201), wxFULL_REPAINT_ON_RESIZE)
+GraphStepguiderClient::GraphStepguiderClient(wxWindow *parent)
+ : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(201, 201), wxFULL_REPAINT_ON_RESIZE)
{
SetBackgroundStyle(wxBG_STYLE_PAINT);
@@ -250,9 +249,9 @@ GraphStepguiderClient::GraphStepguiderClient(wxWindow *parent) :
for (unsigned int i = 0; i < m_maxHistorySize; i++)
{
- int color = (int)(i * 255 / m_maxHistorySize);
- m_pPens[i] = new wxPen(wxColor(color,color,color));
- m_pBrushes[i] = new wxBrush(wxColor(color,color,color), wxBRUSHSTYLE_SOLID);
+ int color = (int) (i * 255 / m_maxHistorySize);
+ m_pPens[i] = new wxPen(wxColor(color, color, color));
+ m_pBrushes[i] = new wxBrush(wxColor(color, color, color), wxBRUSHSTYLE_SOLID);
}
SetLimits(0, 0, 0, 0);
@@ -267,8 +266,7 @@ GraphStepguiderClient::~GraphStepguiderClient(void)
}
}
-void GraphStepguiderClient::SetLimits(unsigned int xMax, unsigned int yMax,
- unsigned int xBump, unsigned int yBump)
+void GraphStepguiderClient::SetLimits(unsigned int xMax, unsigned int yMax, unsigned int xBump, unsigned int yBump)
{
m_xMax = xMax;
m_yMax = yMax;
@@ -297,7 +295,7 @@ void GraphStepguiderClient::OnPaint(wxPaintEvent& WXUNUSED(evt))
wxAutoBufferedPaintDC dc(this);
dc.SetBackground(*wxBLACK_BRUSH);
- //dc.SetBackground(wxColour(10,0,0));
+ // dc.SetBackground(wxColour(10,0,0));
dc.Clear();
wxSize size = GetClientSize();
@@ -311,8 +309,8 @@ void GraphStepguiderClient::OnPaint(wxPaintEvent& WXUNUSED(evt))
return;
}
- wxPen GreySolidPen = wxPen(wxColour(200,200,200),2, wxPENSTYLE_SOLID);
- wxPen GreyDashPen = wxPen(wxColour(200,200,200),1, wxPENSTYLE_DOT);
+ wxPen GreySolidPen = wxPen(wxColour(200, 200, 200), 2, wxPENSTYLE_SOLID);
+ wxPen GreyDashPen = wxPen(wxColour(200, 200, 200), 1, wxPENSTYLE_DOT);
const int stepsPerDivision = 10;
@@ -326,16 +324,16 @@ void GraphStepguiderClient::OnPaint(wxPaintEvent& WXUNUSED(evt))
int yDivisions = ySteps / stepsPerDivision;
int yPixelsPerStep = (size.y - 1) / (2 * ySteps);
- int leftEdge = center.x - xDivisions * stepsPerDivision * xPixelsPerStep;
- int rightEdge = center.x + xDivisions * stepsPerDivision * xPixelsPerStep;
+ int leftEdge = center.x - xDivisions * stepsPerDivision * xPixelsPerStep;
+ int rightEdge = center.x + xDivisions * stepsPerDivision * xPixelsPerStep;
- int topEdge = center.y - yDivisions * stepsPerDivision * yPixelsPerStep;
- int bottomEdge = center.y + yDivisions * stepsPerDivision * yPixelsPerStep;
+ int topEdge = center.y - yDivisions * stepsPerDivision * yPixelsPerStep;
+ int bottomEdge = center.y + yDivisions * stepsPerDivision * yPixelsPerStep;
// Draw axes
dc.SetPen(GreySolidPen);
- dc.DrawLine(leftEdge, center.y , rightEdge, center.y);
+ dc.DrawLine(leftEdge, center.y, rightEdge, center.y);
dc.DrawLine(center.x, topEdge, center.x, bottomEdge);
// Draw divisions
@@ -418,7 +416,7 @@ void GraphStepguiderClient::OnPaint(wxPaintEvent& WXUNUSED(evt))
for (unsigned int i = startPoint; i < m_maxHistorySize; i++)
{
- if (i == m_maxHistorySize-1)
+ if (i == m_maxHistorySize - 1)
{
dotSize *= 2;
}
@@ -435,16 +433,14 @@ void GraphStepguiderClient::OnPaint(wxPaintEvent& WXUNUSED(evt))
dc.SetPen(*wxGREEN_PEN);
dc.SetBrush(*wxTRANSPARENT_BRUSH);
- dc.DrawCircle(center.x + (int)(m_avgPos.X * xPixelsPerStep),
- center.y + (int)(m_avgPos.Y * yPixelsPerStep), dotSize);
+ dc.DrawCircle(center.x + (int) (m_avgPos.X * xPixelsPerStep), center.y + (int) (m_avgPos.Y * yPixelsPerStep), dotSize);
if (m_curBump.IsValid())
{
dc.SetPen(*wxGREEN_PEN);
- dc.DrawLine(center.x + (int)(m_avgPos.X * xPixelsPerStep),
- center.y + (int)(m_avgPos.Y * yPixelsPerStep),
- center.x + (int)((m_avgPos.X + m_curBump.X * 2.0) * xPixelsPerStep),
- center.y + (int)((m_avgPos.Y + m_curBump.Y * 2.0) * yPixelsPerStep));
+ dc.DrawLine(center.x + (int) (m_avgPos.X * xPixelsPerStep), center.y + (int) (m_avgPos.Y * yPixelsPerStep),
+ center.x + (int) ((m_avgPos.X + m_curBump.X * 2.0) * xPixelsPerStep),
+ center.y + (int) ((m_avgPos.Y + m_curBump.Y * 2.0) * yPixelsPerStep));
}
}
}
diff --git a/src/graph.cpp b/src/graph.cpp
index 82a556e01..255d52084 100644
--- a/src/graph.cpp
+++ b/src/graph.cpp
@@ -64,17 +64,21 @@ wxEND_EVENT_TABLE();
// clang-format on
#ifdef __WXOSX__
-# define OSX_SMALL_FONT(lbl) do { (lbl)->SetFont(*wxSMALL_FONT); } while (0)
+# define OSX_SMALL_FONT(lbl) \
+ do \
+ { \
+ (lbl)->SetFont(*wxSMALL_FONT); \
+ } while (0)
#else
# define OSX_SMALL_FONT(lbl)
#endif
-GraphLogWindow::GraphLogWindow(wxWindow *parent) :
- wxWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize, wxFULL_REPAINT_ON_RESIZE,_T("Graph"))
+GraphLogWindow::GraphLogWindow(wxWindow *parent)
+ : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE, _T("Graph"))
{
SetBackgroundStyle(wxBG_STYLE_PAINT);
- wxBoxSizer *pMainSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *pMainSizer = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *pButtonSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *pClientSizer = new wxBoxSizer(wxVERTICAL);
@@ -87,13 +91,13 @@ GraphLogWindow::GraphLogWindow(wxWindow *parent) :
{
m_pXControlPane = pMount->GetXGuideAlgorithmControlPane(this);
m_pYControlPane = pMount->GetYGuideAlgorithmControlPane(this);
- m_pScopePane = pMount->GetGraphControlPane(this, _("Scope:"));
+ m_pScopePane = pMount->GetGraphControlPane(this, _("Scope:"));
}
else
{
m_pXControlPane = nullptr;
m_pYControlPane = nullptr;
- m_pScopePane = nullptr;
+ m_pScopePane = nullptr;
}
if (m_pXControlPane)
@@ -115,26 +119,30 @@ GraphLogWindow::GraphLogWindow(wxWindow *parent) :
SetBackgroundColour(*wxBLACK);
- m_pLengthButton = new OptionsButton(this,BUTTON_GRAPH_LENGTH, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
+ m_pLengthButton = new OptionsButton(
+ this, BUTTON_GRAPH_LENGTH, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
m_pLengthButton->SetToolTip(_("Select the number of frames of history to display on the X-axis"));
m_pLengthButton->SetLabel(wxString::Format(_T("x: %3d"), m_pClient->m_length));
pButtonSizer->Add(m_pLengthButton, wxSizerFlags().Border(wxTOP, 5).Expand());
- m_pHeightButton = new OptionsButton(this,BUTTON_GRAPH_HEIGHT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
+ m_pHeightButton = new OptionsButton(
+ this, BUTTON_GRAPH_HEIGHT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
m_heightButtonLabelVal = 0;
UpdateHeightButtonLabel();
pButtonSizer->Add(m_pHeightButton, wxSizerFlags().Expand());
- m_pSettingsButton = new OptionsButton(this, BUTTON_GRAPH_SETTINGS, _("Settings"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
+ m_pSettingsButton = new OptionsButton(
+ this, BUTTON_GRAPH_SETTINGS, _("Settings"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
m_pSettingsButton->SetToolTip(_("Graph settings"));
pButtonSizer->Add(m_pSettingsButton, wxSizerFlags().Expand());
wxButton *clearButton = new wxButton(this, BUTTON_GRAPH_CLEAR, _("Clear"));
- clearButton->SetToolTip(_("Clear graph data. You can also partially clear the graph by holding down the Ctrl key and clicking on the graph where you want the data to start."));
+ clearButton->SetToolTip(_("Clear graph data. You can also partially clear the graph by holding down the Ctrl key and "
+ "clicking on the graph where you want the data to start."));
clearButton->SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
pButtonSizer->Add(clearButton, wxSizerFlags().Expand());
- m_pCheckboxTrendlines = new wxCheckBox(this,CHECKBOX_GRAPH_TRENDLINES,_("Trendlines"));
+ m_pCheckboxTrendlines = new wxCheckBox(this, CHECKBOX_GRAPH_TRENDLINES, _("Trendlines"));
#if defined(__WXOSX__)
// workaround inability to set checkbox foreground color
m_pCheckboxTrendlines->SetBackgroundColour(wxColor(200, 200, 200));
@@ -144,7 +152,7 @@ GraphLogWindow::GraphLogWindow(wxWindow *parent) :
m_pCheckboxTrendlines->SetToolTip(_("Plot trend lines"));
pButtonSizer->Add(m_pCheckboxTrendlines, wxSizerFlags().Expand().Border(wxTOP, 1));
- m_pCheckboxCorrections = new wxCheckBox(this,CHECKBOX_GRAPH_CORRECTIONS,_("Corrections"));
+ m_pCheckboxCorrections = new wxCheckBox(this, CHECKBOX_GRAPH_CORRECTIONS, _("Corrections"));
#if defined(__WXOSX__)
// workaround inability to set checkbox foreground color
m_pCheckboxCorrections->SetBackgroundColour(wxColor(200, 200, 200));
@@ -188,7 +196,7 @@ GraphLogWindow::GraphLogWindow(wxWindow *parent) :
OSX_SMALL_FONT(lbl);
lbl->SetForegroundColour(*wxLIGHT_GREY);
lbl->SetBackgroundColour(*wxBLACK);
- m_pClient->m_pRaRMS = new wxStaticText(this, wxID_ANY, _T("0.00"), wxDefaultPosition, wxSize(80,-1));
+ m_pClient->m_pRaRMS = new wxStaticText(this, wxID_ANY, _T("0.00"), wxDefaultPosition, wxSize(80, -1));
OSX_SMALL_FONT(m_pClient->m_pRaRMS);
m_pClient->m_pRaRMS->SetForegroundColour(*wxLIGHT_GREY);
m_pClient->m_pRaRMS->SetBackgroundColour(*wxBLACK);
@@ -201,7 +209,7 @@ GraphLogWindow::GraphLogWindow(wxWindow *parent) :
OSX_SMALL_FONT(lbl);
lbl->SetForegroundColour(*wxLIGHT_GREY);
lbl->SetBackgroundColour(*wxBLACK);
- m_pClient->m_pDecRMS = new wxStaticText(this, wxID_ANY, _T("0.00"), wxDefaultPosition, wxSize(80,-1));
+ m_pClient->m_pDecRMS = new wxStaticText(this, wxID_ANY, _T("0.00"), wxDefaultPosition, wxSize(80, -1));
OSX_SMALL_FONT(m_pClient->m_pDecRMS);
m_pClient->m_pDecRMS->SetForegroundColour(*wxLIGHT_GREY);
m_pClient->m_pDecRMS->SetBackgroundColour(*wxBLACK);
@@ -214,7 +222,7 @@ GraphLogWindow::GraphLogWindow(wxWindow *parent) :
OSX_SMALL_FONT(lbl);
lbl->SetForegroundColour(*wxLIGHT_GREY);
lbl->SetBackgroundColour(*wxBLACK);
- m_pClient->m_pTotRMS = new wxStaticText(this, wxID_ANY, _T("0.00"), wxDefaultPosition, wxSize(80,-1));
+ m_pClient->m_pTotRMS = new wxStaticText(this, wxID_ANY, _T("0.00"), wxDefaultPosition, wxSize(80, -1));
OSX_SMALL_FONT(m_pClient->m_pTotRMS);
m_pClient->m_pTotRMS->SetForegroundColour(*wxLIGHT_GREY);
m_pClient->m_pTotRMS->SetBackgroundColour(*wxBLACK);
@@ -325,14 +333,14 @@ void GraphLogWindow::UpdateRADecDxDyLabels()
{
switch (m_pClient->m_mode)
{
- case GraphLogClientWindow::MODE_RADEC:
- m_pLabel1->SetLabel(_("RA"));
- m_pLabel2->SetLabel(_("Dec"));
- break;
- case GraphLogClientWindow::MODE_DXDY:
- m_pLabel1->SetLabel(_("dx"));
- m_pLabel2->SetLabel(_("dy"));
- break;
+ case GraphLogClientWindow::MODE_RADEC:
+ m_pLabel1->SetLabel(_("RA"));
+ m_pLabel2->SetLabel(_("Dec"));
+ break;
+ case GraphLogClientWindow::MODE_DXDY:
+ m_pLabel1->SetLabel(_("dx"));
+ m_pLabel2->SetLabel(_("dy"));
+ break;
}
}
@@ -373,7 +381,7 @@ void GraphLogWindow::OnArcsecsPixels(wxCommandEvent& evt)
m_pClient->m_heightUnits = UNIT_PIXELS;
break;
}
- pConfig->Global.SetInt("/graph/HeightUnits", (int)m_pClient->m_heightUnits);
+ pConfig->Global.SetInt("/graph/HeightUnits", (int) m_pClient->m_heightUnits);
Refresh();
}
@@ -450,8 +458,8 @@ void GraphLogWindow::OnButtonLength(wxCommandEvent& WXUNUSED(evt))
{
wxMenu *menu = GetLengthMenu();
- PopupMenu(menu, m_pLengthButton->GetPosition().x,
- m_pLengthButton->GetPosition().y + m_pLengthButton->GetSize().GetHeight());
+ PopupMenu(
+ menu, m_pLengthButton->GetPosition().x, m_pLengthButton->GetPosition().y + m_pLengthButton->GetSize().GetHeight());
delete menu;
}
@@ -506,8 +514,8 @@ void GraphLogWindow::OnButtonHeight(wxCommandEvent& WXUNUSED(evt))
break;
}
- PopupMenu(menu, m_pHeightButton->GetPosition().x,
- m_pHeightButton->GetPosition().y + m_pHeightButton->GetSize().GetHeight());
+ PopupMenu(
+ menu, m_pHeightButton->GetPosition().x, m_pHeightButton->GetPosition().y + m_pHeightButton->GetSize().GetHeight());
delete menu;
}
@@ -604,13 +612,13 @@ void GraphLogWindow::UpdateControls()
{
m_pXControlPane = pMount->GetXGuideAlgorithmControlPane(this);
m_pYControlPane = pMount->GetYGuideAlgorithmControlPane(this);
- m_pScopePane = pMount->GetGraphControlPane(this, _("Scope:"));
+ m_pScopePane = pMount->GetGraphControlPane(this, _("Scope:"));
}
else
{
m_pXControlPane = nullptr;
m_pYControlPane = nullptr;
- m_pScopePane = nullptr;
+ m_pScopePane = nullptr;
}
if (m_pXControlPane)
@@ -676,7 +684,7 @@ void GraphLogWindow::OnPaint(wxPaintEvent& WXUNUSED(evt))
wxAutoBufferedPaintDC dc(this);
dc.SetBackground(*wxBLACK_BRUSH);
- //dc.SetBackground(wxColour(10,0,0));
+ // dc.SetBackground(wxColour(10,0,0));
dc.Clear();
UpdateHeightButtonLabel();
@@ -756,10 +764,10 @@ wxBEGIN_EVENT_TABLE(GraphLogClientWindow, wxWindow)
wxEND_EVENT_TABLE();
// clang-format on
-GraphLogClientWindow::GraphLogClientWindow(wxWindow *parent) :
- wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(401,200), wxFULL_REPAINT_ON_RESIZE),
- m_line1(0),
- m_line2(0)
+GraphLogClientWindow::GraphLogClientWindow(wxWindow *parent)
+ : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(401, 200), wxFULL_REPAINT_ON_RESIZE)
+ , m_line1(0)
+ , m_line2(0)
{
SetBackgroundStyle(wxBG_STYLE_PAINT);
@@ -768,12 +776,12 @@ GraphLogClientWindow::GraphLogClientWindow(wxWindow *parent) :
if (!m_raOrDxColor.Set(pConfig->Global.GetString("/graph/RAColor", wxEmptyString)))
{
- m_raOrDxColor = wxColour(100,100,255);
+ m_raOrDxColor = wxColour(100, 100, 255);
pConfig->Global.SetString("/graph/RAColor", m_raOrDxColor.GetAsString(wxC2S_HTML_SYNTAX));
}
if (!m_decOrDyColor.Set(pConfig->Global.GetString("/graph/DecColor", wxEmptyString)))
{
- m_decOrDyColor = wxColour(255,0,0);
+ m_decOrDyColor = wxColour(255, 0, 0);
pConfig->Global.SetString("/graph/DecColor", m_decOrDyColor.GetAsString(wxC2S_HTML_SYNTAX));
}
@@ -792,9 +800,10 @@ GraphLogClientWindow::GraphLogClientWindow(wxWindow *parent) :
m_length = pConfig->Global.GetInt("/graph/length", m_minLength * 2);
m_noDitherDec.ChangeWindowSize(m_length);
m_noDitherRA.ChangeWindowSize(m_length);
- Debug.Write(wxString::Format("GraphStats window size = %d\n", (int)m_length));
+ Debug.Write(wxString::Format("GraphStats window size = %d\n", (int) m_length));
m_height = pConfig->Global.GetInt("/graph/height", m_minHeight * 2 * 2); // match PHD1 4-pixel scale for new users
- m_heightUnits = (GRAPH_UNITS) pConfig->Global.GetInt("graph/HeightUnits", (int) UNIT_ARCSEC); // preferred units, will still display pixels if camera pixel scale not available
+ m_heightUnits = (GRAPH_UNITS) pConfig->Global.GetInt("graph/HeightUnits",
+ (int) UNIT_ARCSEC); // preferred units, will still display pixels if camera pixel scale not available
m_showTrendlines = false;
m_showCorrections = pConfig->Global.GetBoolean("/graph/showCorrections", true);
@@ -805,8 +814,8 @@ GraphLogClientWindow::GraphLogClientWindow(wxWindow *parent) :
GraphLogClientWindow::~GraphLogClientWindow()
{
- delete [] m_line1;
- delete [] m_line2;
+ delete[] m_line1;
+ delete[] m_line2;
}
static void reset_trend_accums(TrendLineAccum accums[4])
@@ -879,10 +888,10 @@ bool GraphLogClientWindow::SetMaxLength(unsigned int maxLength)
m_history.resize(maxLength);
- delete [] m_line1;
+ delete[] m_line1;
m_line1 = new wxPoint[maxLength];
- delete [] m_line2;
+ delete[] m_line2;
m_line2 = new wxPoint[maxLength];
pConfig->Global.SetInt("/graph/maxLength", m_history.capacity());
@@ -966,7 +975,7 @@ static double rms(unsigned int nr, const TrendLineAccum *accum)
{
if (nr == 0)
return 0.0;
- double const n = (double)nr;
+ double const n = (double) nr;
double const s1 = accum->sum_y;
double const s2 = accum->sum_y2;
return sqrt(n * s2 - s1 * s1) / n;
@@ -983,7 +992,7 @@ void GraphLogClientWindow::UpdateStats(unsigned int nr, const S_HISTORY *cur)
if (nr >= 2)
{
- m_stats.osc_index = 1.0 - (double) m_raSameSides / (double)(nr - 1);
+ m_stats.osc_index = 1.0 - (double) m_raSameSides / (double) (nr - 1);
m_stats.osc_alert = m_stats.osc_index > 0.6 || m_stats.osc_index < 0.15;
}
else
@@ -1001,12 +1010,13 @@ void GraphLogClientWindow::UpdateStats(unsigned int nr, const S_HISTORY *cur)
}
}
-static double peak_ra(const circular_buffer &history, unsigned int nr)
+static double peak_ra(const circular_buffer& history, unsigned int nr)
{
double peak = 0.0;
const int end = history.size();
const int begin = end - nr;
- for (int i = begin; i < end; i++) {
+ for (int i = begin; i < end; i++)
+ {
double val = fabs(history[i].ra);
if (val > peak)
peak = val;
@@ -1014,12 +1024,13 @@ static double peak_ra(const circular_buffer &history, unsigned int nr
return peak;
}
-static double peak_dec(const circular_buffer &history, unsigned int nr)
+static double peak_dec(const circular_buffer& history, unsigned int nr)
{
double peak = 0.0;
const int end = history.size();
const int begin = end - nr;
- for (int i = begin; i < end; i++) {
+ for (int i = begin; i < end; i++)
+ {
double val = fabs(history[i].dec);
if (val > peak)
peak = val;
@@ -1101,7 +1112,8 @@ void GraphLogClientWindow::RecalculateTrendLines()
reset_trend_accums(m_trendLineAccum);
unsigned int trend_items = GetItemCount();
const int begin = m_history.size() - trend_items;
- for (unsigned int x = 0, i = begin; x < trend_items; i++, x++) {
+ for (unsigned int x = 0, i = begin; x < trend_items; i++, x++)
+ {
const S_HISTORY& h = m_history[i];
update_trend(x, trend_items, h.dx, 0.0, &m_trendLineAccum[0]);
update_trend(x, trend_items, h.dy, 0.0, &m_trendLineAccum[1]);
@@ -1175,10 +1187,14 @@ struct ScaleAndTranslate
{
int m_xorig, m_yorig;
double m_xmag, m_ymag;
- ScaleAndTranslate(int xorig, int yorig, double xmag, double ymag) : m_xorig(xorig), m_yorig(yorig), m_xmag(xmag), m_ymag(ymag) { }
- wxPoint pt(double x, double y) const {
- return wxPoint(m_xorig + (int)(x * m_xmag), m_yorig + (int)(y * m_ymag));
+ ScaleAndTranslate(int xorig, int yorig, double xmag, double ymag)
+ : m_xorig(xorig)
+ , m_yorig(yorig)
+ , m_xmag(xmag)
+ , m_ymag(ymag)
+ {
}
+ wxPoint pt(double x, double y) const { return wxPoint(m_xorig + (int) (x * m_xmag), m_yorig + (int) (y * m_ymag)); }
};
static wxString rms_label(double rms, double sampling)
@@ -1229,7 +1245,10 @@ static double GetMaxStarSNR(const circular_buffer& history, int start
return maxSNR;
}
-enum { GRAPH_BORDER = 5 };
+enum
+{
+ GRAPH_BORDER = 5
+};
void GraphLogClientWindow::OnPaint(wxPaintEvent& WXUNUSED(evt))
{
@@ -1262,12 +1281,12 @@ void GraphLogClientWindow::OnPaint(wxPaintEvent& WXUNUSED(evt))
dc.SetBackground(*wxBLACK_BRUSH);
dc.Clear();
- wxPen GreyDashPen(wxColour(200,200,200),1, wxPENSTYLE_DOT);
+ wxPen GreyDashPen(wxColour(200, 200, 200), 1, wxPENSTYLE_DOT);
// Draw axes
dc.SetPen(*wxGREY_PEN);
- dc.DrawLine(center.x,topEdge,center.x,bottomEdge);
- dc.DrawLine(leftEdge,center.y,rightEdge,center.y);
+ dc.DrawLine(center.x, topEdge, center.x, bottomEdge);
+ dc.DrawLine(leftEdge, center.y, rightEdge, center.y);
// draw a box around the client area
dc.DrawLine(leftEdge, topEdge, rightEdge, topEdge);
@@ -1289,12 +1308,15 @@ void GraphLogClientWindow::OnPaint(wxPaintEvent& WXUNUSED(evt))
for (int i = 1; i <= m_yDivisions; i++)
{
double div_y = center.y - i * yPixelsPerDivision;
- dc.DrawLine(leftEdge,div_y, rightEdge, div_y);
- dc.DrawText(wxString::Format("%g%s", i * (double)m_height / (m_yDivisions + 1), units == UNIT_ARCSEC ? "''" : (i == 3 ? " px" : "")), leftEdge + 3, div_y - 13);
+ dc.DrawLine(leftEdge, div_y, rightEdge, div_y);
+ dc.DrawText(wxString::Format("%g%s", i * (double) m_height / (m_yDivisions + 1),
+ units == UNIT_ARCSEC ? "''" : (i == 3 ? " px" : "")),
+ leftEdge + 3, div_y - 13);
div_y = center.y + i * yPixelsPerDivision;
dc.DrawLine(leftEdge, div_y, rightEdge, div_y);
- dc.DrawText(wxString::Format("%g%s", -i * (double)m_height / (m_yDivisions + 1), units == UNIT_ARCSEC ? "''" : ""), leftEdge + 3, div_y - 13);
+ dc.DrawText(wxString::Format("%g%s", -i * (double) m_height / (m_yDivisions + 1), units == UNIT_ARCSEC ? "''" : ""),
+ leftEdge + 3, div_y - 13);
}
for (int i = 1; i <= xDivisions; i++)
@@ -1304,7 +1326,8 @@ void GraphLogClientWindow::OnPaint(wxPaintEvent& WXUNUSED(evt))
}
const double xmag = size.x / (double) m_length;
- const double ymag = yPixelsPerDivision * (double)(m_yDivisions + 1) / (double)m_height * (units == UNIT_ARCSEC ? sampling : 1.0);
+ const double ymag =
+ yPixelsPerDivision * (double) (m_yDivisions + 1) / (double) m_height * (units == UNIT_ARCSEC ? sampling : 1.0);
ScaleAndTranslate sctr(xorig, yorig, xmag, ymag);
@@ -1387,7 +1410,7 @@ void GraphLogClientWindow::OnPaint(wxPaintEvent& WXUNUSED(evt))
wxPoint pt(sctr.pt(j, decDur));
pt.x += 5;
if (decDur < 0)
- dc.DrawRectangle(pt,wxSize(4, yorig - pt.y));
+ dc.DrawRectangle(pt, wxSize(4, yorig - pt.y));
else
dc.DrawRectangle(wxPoint(pt.x, yorig), wxSize(4, pt.y - yorig));
}
@@ -1515,9 +1538,9 @@ void GraphLogClientWindow::OnPaint(wxPaintEvent& WXUNUSED(evt))
{
const S_HISTORY& h0 = m_history[start_item];
const S_HISTORY& h1 = m_history[m_history.size() - 1];
- double dt = (double)(h1.timestamp - h0.timestamp) / (1000.0 * 60.0); // time span in minutes
- double ddec = (double) (plot_length - 1) * trendDecOrDy.first; // dec drift (pixels)
- ddec *= sampling; // convert pixels to arc-seconds
+ double dt = (double) (h1.timestamp - h0.timestamp) / (1000.0 * 60.0); // time span in minutes
+ double ddec = (double) (plot_length - 1) * trendDecOrDy.first; // dec drift (pixels)
+ ddec *= sampling; // convert pixels to arc-seconds
// From Frank Barrett, "Determining Polar Axis Alignment Accuracy"
// http://celestialwonders.com/articles/polaralignment/PolarAlignmentAccuracy.pdf
double err_arcmin = (3.82 * ddec) / (dt * cos(declination));
@@ -1525,15 +1548,15 @@ void GraphLogClientWindow::OnPaint(wxPaintEvent& WXUNUSED(evt))
double correction = pFrame->pGuider->GetPolarAlignCircleCorrection();
double err_px = polarAlignCircleRadius * correction;
dc.DrawText(wxString::Format("Polar alignment error: %.2f' (%s%.f px)", err_arcmin,
- correction < 1.0 ? "" : "< ", err_px),
+ correction < 1.0 ? "" : "< ", err_px),
leftEdge + 30, bottomEdge - 18);
}
}
}
// when drifting, center the polar align circle on the star; when adjusting, center the polar
// align circle at the lock position
- const PHD_Point& center = pFrame->pGuider->IsCalibratingOrGuiding() ?
- pFrame->pGuider->CurrentPosition() : pFrame->pGuider->LockPosition();
+ const PHD_Point& center =
+ pFrame->pGuider->IsCalibratingOrGuiding() ? pFrame->pGuider->CurrentPosition() : pFrame->pGuider->LockPosition();
pFrame->pGuider->SetPolarAlignCircle(center, polarAlignCircleRadius);
m_pRaRMS->SetLabel(rms_label(m_stats.rms_ra, sampling));
@@ -1542,7 +1565,7 @@ void GraphLogClientWindow::OnPaint(wxPaintEvent& WXUNUSED(evt))
if (m_stats.osc_alert)
{
- m_pOscIndex->SetForegroundColour(wxColour(185,20,0));
+ m_pOscIndex->SetForegroundColour(wxColour(185, 20, 0));
}
else
{
@@ -1571,7 +1594,7 @@ void GraphLogClientWindow::OnLeftBtnDown(wxMouseEvent& evt)
unsigned int plot_length = GetItemCount();
unsigned int start_item = m_history.size() - plot_length;
- unsigned int i = start_item + (unsigned int) floor((double)(evt.GetX() - xorig) / xmag + 0.5);
+ unsigned int i = start_item + (unsigned int) floor((double) (evt.GetX() - xorig) / xmag + 0.5);
if (i < m_history.size())
{
wxLongLong_t deltaT = m_history[m_history.size() - 1].timestamp - m_history[i].timestamp;
@@ -1580,7 +1603,8 @@ void GraphLogClientWindow::OnLeftBtnDown(wxMouseEvent& evt)
// Some items removed from m_history may not be resident in the "noDither" collections
int numDeletes = wxMin(m_noDitherDec.GetCount(), i);
- long newStart = m_noDitherDec.GetLastEntry().DeltaTime - deltaT; // mSec for new starting point in noDither collections
+ long newStart =
+ m_noDitherDec.GetLastEntry().DeltaTime - deltaT; // mSec for new starting point in noDither collections
while (numDeletes > 0)
{
@@ -1623,8 +1647,8 @@ GraphControlPane::GraphControlPane(wxWindow *pParent, const wxString& label)
SetBackgroundColour(*wxBLACK);
- int width = StringWidth(label);
- wxStaticText *pLabel = new wxStaticText(this,wxID_ANY,label, wxDefaultPosition, wxSize(width + 5, -1));
+ int width = StringWidth(label);
+ wxStaticText *pLabel = new wxStaticText(this, wxID_ANY, label, wxDefaultPosition, wxSize(width + 5, -1));
wxFont f = pLabel->GetFont();
f.SetWeight(wxFONTWEIGHT_BOLD);
pLabel->SetFont(f);
@@ -1635,18 +1659,11 @@ GraphControlPane::GraphControlPane(wxWindow *pParent, const wxString& label)
SetSizer(m_pControlSizer);
}
-GraphControlPane::~GraphControlPane()
-{
-}
+GraphControlPane::~GraphControlPane() { }
-void GraphControlPane::UpdateControls()
-{
-}
-
-void GraphControlPane::EnableDecControls(bool enable)
-{
+void GraphControlPane::UpdateControls() { }
-}
+void GraphControlPane::EnableDecControls(bool enable) { }
int GraphControlPane::StringWidth(const wxString& string)
{
diff --git a/src/graph.h b/src/graph.h
index 7f4368010..c1b2b1eee 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -71,12 +71,21 @@ struct S_HISTORY
bool decLimited;
S_HISTORY() { }
S_HISTORY(const GuideStepInfo& step)
- : timestamp(::wxGetUTCTimeMillis().GetValue()),
- dx(step.cameraOffset.X), dy(step.cameraOffset.Y), ra(step.mountOffset.X), dec(step.mountOffset.Y),
- starSNR(step.starSNR), starMass(step.starMass),
- raDur(step.durationRA), decDur(step.durationDec),
- raDir(step.directionRA), decDir(step.directionDec),
- raLimited(step.raLimited), decLimited(step.decLimited) { }
+ : timestamp(::wxGetUTCTimeMillis().GetValue())
+ , dx(step.cameraOffset.X)
+ , dy(step.cameraOffset.Y)
+ , ra(step.mountOffset.X)
+ , dec(step.mountOffset.Y)
+ , starSNR(step.starSNR)
+ , starMass(step.starMass)
+ , raDur(step.durationRA)
+ , decDur(step.durationDec)
+ , raDir(step.directionRA)
+ , decDir(step.directionDec)
+ , raLimited(step.raLimited)
+ , decLimited(step.decLimited)
+ {
+ }
};
struct DitherInfo
@@ -209,8 +218,8 @@ class GraphLogWindow : public wxWindow
void UpdateRADecDxDyLabels();
public:
-
- enum {
+ enum
+ {
DefaultMinLength = 50,
DefaultMaxLength = 400,
DefaultMinHeight = 1,
@@ -234,7 +243,7 @@ class GraphLogWindow : public wxWindow
void SetHeight(int height);
wxMenu *GetLengthMenu();
unsigned int GetHistoryItemCount() const;
- void EnableDecControls(bool enable); // For changes to Dec mode made outside of graph pane (e.g. AD)
+ void EnableDecControls(bool enable); // For changes to Dec mode made outside of graph pane (e.g. AD)
void OnPaint(wxPaintEvent& evt);
void OnButtonSettings(wxCommandEvent& evt);
@@ -273,6 +282,7 @@ class GraphControlPane : public wxWindow
~GraphControlPane();
virtual void UpdateControls();
virtual void EnableDecControls(bool enable);
+
protected:
wxBoxSizer *m_pControlSizer;
diff --git a/src/guide_algorithm.cpp b/src/guide_algorithm.cpp
index 59a2e84eb..d6133d031 100644
--- a/src/guide_algorithm.cpp
+++ b/src/guide_algorithm.cpp
@@ -41,8 +41,8 @@
wxString GuideAlgorithm::GetConfigPath() const
{
- return "/" + m_pMount->GetMountClassName() + "/GuideAlgorithm/" +
- (m_guideAxis == GUIDE_X ? "X/" : "Y/") + GetGuideAlgorithmClassName();
+ return "/" + m_pMount->GetMountClassName() + "/GuideAlgorithm/" + (m_guideAxis == GUIDE_X ? "X/" : "Y/") +
+ GetGuideAlgorithmClassName();
}
wxString GuideAlgorithm::GetAxis() const
@@ -50,9 +50,9 @@ wxString GuideAlgorithm::GetAxis() const
return m_guideAxis == GUIDE_RA ? _("RA") : _("DEC");
}
-// Default technique to force a reset on algo parameters is simply to remove the keys from the Registry - a subsequent creation of the algo
-// class will then use default values for everything. If this is too brute-force for a particular algo, the function can be overridden.
-// For algos that use a min-move parameter, a smart value will be applied based on image scale
+// Default technique to force a reset on algo parameters is simply to remove the keys from the Registry - a subsequent creation
+// of the algo class will then use default values for everything. If this is too brute-force for a particular algo, the
+// function can be overridden. For algos that use a min-move parameter, a smart value will be applied based on image scale
void GuideAlgorithm::ResetParams()
{
wxString configPath = GetConfigPath();
@@ -87,25 +87,22 @@ double GuideAlgorithm::SmartDefaultMinMove()
}
}
-void GuideAlgorithm::AdjustMinMoveSpinCtrl(wxSpinCtrlDouble* minMoveCtrl)
+void GuideAlgorithm::AdjustMinMoveSpinCtrl(wxSpinCtrlDouble *minMoveCtrl)
{
// Always use current AD values for all params affecting image scale
- double smartMove = GuideAlgorithm::SmartDefaultMinMove(pFrame->pAdvancedDialog->GetFocalLength(), pFrame->pAdvancedDialog->GetPixelSize(), pFrame->pAdvancedDialog->GetBinning());
+ double smartMove = GuideAlgorithm::SmartDefaultMinMove(pFrame->pAdvancedDialog->GetFocalLength(),
+ pFrame->pAdvancedDialog->GetPixelSize(), pFrame->pAdvancedDialog->GetBinning());
minMoveCtrl->SetValue(smartMove);
}
-void GuideAlgorithm::GuidingStarted()
-{
-}
+void GuideAlgorithm::GuidingStarted() { }
void GuideAlgorithm::GuidingStopped()
{
reset();
}
-void GuideAlgorithm::GuidingPaused()
-{
-}
+void GuideAlgorithm::GuidingPaused() { }
void GuideAlgorithm::GuidingResumed()
{
@@ -117,17 +114,14 @@ void GuideAlgorithm::GuidingDithered(double amt)
reset();
}
-void GuideAlgorithm::GuidingDitherSettleDone(bool success)
-{
-}
+void GuideAlgorithm::GuidingDitherSettleDone(bool success) { }
-void GuideAlgorithm::DirectMoveApplied(double amt)
-{
-}
+void GuideAlgorithm::DirectMoveApplied(double amt) { }
void GuideAlgorithm::GuidingDisabled()
{
- // By default, guide star deflections will be accumulated even with guiding disabled - algo can override if this is a problem
+ // By default, guide star deflections will be accumulated even with guiding disabled - algo can override if this is a
+ // problem
}
void GuideAlgorithm::GuidingEnabled()
@@ -136,9 +130,7 @@ void GuideAlgorithm::GuidingEnabled()
reset();
}
-void GuideAlgorithm::GetParamNames(wxArrayString& names) const
-{
-}
+void GuideAlgorithm::GetParamNames(wxArrayString& names) const { }
bool GuideAlgorithm::GetParam(const wxString& name, double *val) const
{
diff --git a/src/guide_algorithm.h b/src/guide_algorithm.h
index 2426d7d36..880bf2e01 100644
--- a/src/guide_algorithm.h
+++ b/src/guide_algorithm.h
@@ -76,7 +76,9 @@ class GuideAlgorithm
GuideAxis m_guideAxis;
public:
- GuideAlgorithm(Mount *pMount, GuideAxis axis) : m_pMount(pMount), m_guideAxis(axis) {};
+ GuideAlgorithm(Mount *pMount, GuideAxis axis)
+ : m_pMount(pMount)
+ , m_guideAxis(axis) {};
virtual ~GuideAlgorithm() {};
virtual GUIDE_ALGORITHM Algorithm() const = 0;
@@ -102,11 +104,11 @@ class GuideAlgorithm
virtual bool GetParam(const wxString& name, double *val) const;
virtual bool SetParam(const wxString& name, double val);
virtual double GetMinMove() const { return -1.0; };
- virtual bool SetMinMove(double minMove) { return true; }; // true indicates error
+ virtual bool SetMinMove(double minMove) { return true; }; // true indicates error
wxString GetConfigPath() const;
wxString GetAxis() const;
- virtual void ResetParams(); // Override if fine-tuned logic is needed by a particular algo
- static void AdjustMinMoveSpinCtrl(wxSpinCtrlDouble* minMoveCtrl);
+ virtual void ResetParams(); // Override if fine-tuned logic is needed by a particular algo
+ static void AdjustMinMoveSpinCtrl(wxSpinCtrlDouble *minMoveCtrl);
static double SmartDefaultMinMove();
static double SmartDefaultMinMove(int focalLength, double pixelSize, int binning);
};
diff --git a/src/guide_algorithm_gaussian_process.cpp b/src/guide_algorithm_gaussian_process.cpp
index a50251be6..ae08ad6e7 100644
--- a/src/guide_algorithm_gaussian_process.cpp
+++ b/src/guide_algorithm_gaussian_process.cpp
@@ -13,31 +13,31 @@
*/
/*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development, nor the names of its
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development, nor the names of its
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
#include "phd.h"
@@ -52,25 +52,26 @@
/** Default values for the parameters of this algorithm */
-static const double DefaultControlGain = 0.6; // control gain
-static const double DefaultPeriodLengthsForInference = 2.0; // minimal number of period lengths for full prediction
-static const double DefaultMinMove = 0.2;
+static const double DefaultControlGain = 0.6; // control gain
+static const double DefaultPeriodLengthsForInference = 2.0; // minimal number of period lengths for full prediction
+static const double DefaultMinMove = 0.2;
-static const double DefaultLengthScaleSE0Ker = 700.0; // length-scale of the long-range SE-kernel
-static const double DefaultSignalVarianceSE0Ker = 20.0; // signal variance of the long-range SE-kernel
-static const double DefaultLengthScalePerKer = 10.0; // length-scale of the periodic kernel
-static const double DefaultPeriodLengthPerKer = 200.0; // P_p, period-length of the periodic kernel
-static const double DefaultSignalVariancePerKer = 20.0; // signal variance of the periodic kernel
-static const double DefaultLengthScaleSE1Ker = 25.0; // length-scale of the short-range SE-kernel
-static const double DefaultSignalVarianceSE1Ker = 10.0; // signal variance of the short range SE-kernel
+static const double DefaultLengthScaleSE0Ker = 700.0; // length-scale of the long-range SE-kernel
+static const double DefaultSignalVarianceSE0Ker = 20.0; // signal variance of the long-range SE-kernel
+static const double DefaultLengthScalePerKer = 10.0; // length-scale of the periodic kernel
+static const double DefaultPeriodLengthPerKer = 200.0; // P_p, period-length of the periodic kernel
+static const double DefaultSignalVariancePerKer = 20.0; // signal variance of the periodic kernel
+static const double DefaultLengthScaleSE1Ker = 25.0; // length-scale of the short-range SE-kernel
+static const double DefaultSignalVarianceSE1Ker = 10.0; // signal variance of the short range SE-kernel
static const double DefaultPeriodLengthsForPeriodEstimation = 2.0; // minimal number of period lengts for PL estimation
-static const int DefaultNumPointsForApproximation = 100; // number of points used in the GP approximation
-static const double DefaultPredictionGain = 0.5; // amount of GP prediction to blend in
+static const int DefaultNumPointsForApproximation = 100; // number of points used in the GP approximation
+static const double DefaultPredictionGain = 0.5; // amount of GP prediction to blend in
-static const double DefaultNoresetMaxPctPeriod = 40.; // max percent of worm period elapsed to skip resetting the model when guiding is stopped and resumed
+static const double DefaultNoresetMaxPctPeriod =
+ 40.; // max percent of worm period elapsed to skip resetting the model when guiding is stopped and resumed
-static const bool DefaultComputePeriod = true;
+static const bool DefaultComputePeriod = true;
static void MakeBold(wxControl *ctrl)
{
@@ -79,15 +80,22 @@ static void MakeBold(wxControl *ctrl)
ctrl->SetFont(font);
}
-GuideAlgorithmGaussianProcess::
-GPExpertDialog::GPExpertDialog(wxWindow *Parent) :
- wxDialog(Parent, wxID_ANY, _("Expert Settings"), wxDefaultPosition, wxDefaultSize),
- m_pPeriodLengthsInference(0), m_pPeriodLengthsPeriodEstimation(0), m_pNumPointsApproximation(0), m_pSE0KLengthScale(0), m_pSE0KSignalVariance(0), m_pPKLengthScale(0),
- m_pPKSignalVariance(0), m_pSE1KLengthScale(0), m_pSE1KSignalVariance(0)
+GuideAlgorithmGaussianProcess::GPExpertDialog::GPExpertDialog(wxWindow *Parent)
+ : wxDialog(Parent, wxID_ANY, _("Expert Settings"), wxDefaultPosition, wxDefaultSize)
+ , m_pPeriodLengthsInference(0)
+ , m_pPeriodLengthsPeriodEstimation(0)
+ , m_pNumPointsApproximation(0)
+ , m_pSE0KLengthScale(0)
+ , m_pSE0KSignalVariance(0)
+ , m_pPKLengthScale(0)
+ , m_pPKSignalVariance(0)
+ , m_pSE1KLengthScale(0)
+ , m_pSE1KSignalVariance(0)
{
// create the expert options UI
wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL);
- wxStaticText *warning = new wxStaticText(this, wxID_ANY, _("Warning! Intended for use by experts"), wxPoint(-1, -1), wxSize(-1, -1));
+ wxStaticText *warning =
+ new wxStaticText(this, wxID_ANY, _("Warning! Intended for use by experts"), wxPoint(-1, -1), wxSize(-1, -1));
MakeBold(warning);
vSizer->Add(warning, wxSizerFlags().Center().Border(wxBOTTOM, 10));
@@ -95,85 +103,93 @@ GPExpertDialog::GPExpertDialog(wxWindow *Parent) :
int width;
width = StringWidth(this, _T("0000"));
- m_pNumPointsApproximation = pFrame->MakeSpinCtrl(this, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0, 2000, DefaultNumPointsForApproximation);
+ m_pNumPointsApproximation = pFrame->MakeSpinCtrl(this, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0, 2000, DefaultNumPointsForApproximation);
AddTableEntry(flexGrid, _("Approximation Data Points"), m_pNumPointsApproximation,
wxString::Format(_("Number of data points used in the approximation. Both prediction accuracy "
- "as well as runtime rise with the number of datapoints. Default = %d"), DefaultNumPointsForApproximation));
+ "as well as runtime rise with the number of datapoints. Default = %d"),
+ DefaultNumPointsForApproximation));
width = StringWidth(this, _T("0.00"));
- m_pPeriodLengthsInference = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 10.0, DefaultPeriodLengthsForInference, 0.1);
+ m_pPeriodLengthsInference = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 10.0, DefaultPeriodLengthsForInference, 0.1);
m_pPeriodLengthsInference->SetDigits(2);
AddTableEntry(flexGrid, _("Minimum Worm Cycles (Prediction)"), m_pPeriodLengthsInference,
wxString::Format(_("Minimal number of worm cycles needed to use the prediction. "
- "If there are too little data points, the prediction might be poor. "
- "Default = %.2f"), DefaultPeriodLengthsForInference));
+ "If there are too little data points, the prediction might be poor. "
+ "Default = %.2f"),
+ DefaultPeriodLengthsForInference));
width = StringWidth(this, _T("0000"));
- m_pPeriodLengthsPeriodEstimation = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 10.0, DefaultPeriodLengthsForPeriodEstimation, 0.1);
+ m_pPeriodLengthsPeriodEstimation = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 10.0, DefaultPeriodLengthsForPeriodEstimation, 0.1);
m_pPeriodLengthsPeriodEstimation->SetDigits(2);
AddTableEntry(flexGrid, _("Minimum Worm Cycles (Period Estimation)"), m_pPeriodLengthsPeriodEstimation,
wxString::Format(_("Minimal number of worm cycles for estimating the period length. "
- "If there are too little data points, the estimation might not work. Default = %d"),
- (int)DefaultPeriodLengthsForPeriodEstimation));
+ "If there are too little data points, the estimation might not work. Default = %d"),
+ (int) DefaultPeriodLengthsForPeriodEstimation));
width = StringWidth(this, _T("0000.0"));
- m_pSE0KLengthScale = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 100.0, 5000.0, DefaultLengthScaleSE0Ker, 10.0);
+ m_pSE0KLengthScale = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 100.0, 5000.0, DefaultLengthScaleSE0Ker, 10.0);
m_pSE0KLengthScale->SetDigits(2);
AddTableEntry(flexGrid, _("Length Scale (Long Range)"), m_pSE0KLengthScale,
wxString::Format(_("The length scale (in seconds) of the large non-periodic structure. "
- "This is essentially a high-pass filter for the periodic error and the length scale "
- "defines the corner frequency. Default = %.2f"),
- DefaultLengthScaleSE0Ker));
+ "This is essentially a high-pass filter for the periodic error and the length scale "
+ "defines the corner frequency. Default = %.2f"),
+ DefaultLengthScaleSE0Ker));
width = StringWidth(this, _T("000.0"));
- m_pSE0KSignalVariance = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 100.0, DefaultSignalVarianceSE0Ker, 1.0);
+ m_pSE0KSignalVariance = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 100.0, DefaultSignalVarianceSE0Ker, 1.0);
m_pSE0KSignalVariance->SetDigits(2);
AddTableEntry(flexGrid, _("Signal Variance (Long Range)"), m_pSE0KSignalVariance,
- wxString::Format(_("Signal variance (in pixels) of the long-term variations. Default = %.2f"), DefaultSignalVarianceSE0Ker));
+ wxString::Format(
+ _("Signal variance (in pixels) of the long-term variations. Default = %.2f"), DefaultSignalVarianceSE0Ker));
width = StringWidth(this, _T("000.0"));
- m_pPKLengthScale = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 1.0, 50.0, DefaultLengthScalePerKer, 5.0);
+ m_pPKLengthScale = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 1.0, 50.0, DefaultLengthScalePerKer, 5.0);
m_pPKLengthScale->SetDigits(2);
AddTableEntry(flexGrid, _("Length Scale (Periodic)"), m_pPKLengthScale,
wxString::Format(_("The length scale (in seconds) defines the \"wigglyness\" of the periodic structure. "
- "The smaller the length scale, the more structure can be learned. If chosen too "
- "small, some non-periodic structure might be picked up as well. Default = %.2f"), DefaultLengthScalePerKer));
+ "The smaller the length scale, the more structure can be learned. If chosen too "
+ "small, some non-periodic structure might be picked up as well. Default = %.2f"),
+ DefaultLengthScalePerKer));
width = StringWidth(this, _T("000.0"));
- m_pPKSignalVariance = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 100.0, DefaultSignalVariancePerKer, 0.1);
+ m_pPKSignalVariance = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 100.0, DefaultSignalVariancePerKer, 0.1);
m_pPKSignalVariance->SetDigits(2);
AddTableEntry(flexGrid, _("Signal Variance (Periodic)"), m_pPKSignalVariance,
wxString::Format(_("The signal variance (in pixels) of the periodic error. "
- "Default = %.2f"), DefaultSignalVariancePerKer));
+ "Default = %.2f"),
+ DefaultSignalVariancePerKer));
width = StringWidth(this, _T("000.0"));
- m_pSE1KLengthScale = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 1.0, 100.0, DefaultLengthScaleSE1Ker, 1.0);
+ m_pSE1KLengthScale = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 1.0, 100.0, DefaultLengthScaleSE1Ker, 1.0);
m_pSE1KLengthScale->SetDigits(2);
AddTableEntry(flexGrid, _("Length Scale (Short Range)"), m_pSE1KLengthScale,
wxString::Format(_("Length scale (in seconds) of the short range non-periodic parts "
- "of the gear error. This is essentially a low-pass filter for the periodic error and the length "
- "scale defines the corner frequency. Default = %.2f"), DefaultLengthScaleSE1Ker));
+ "of the gear error. This is essentially a low-pass filter for the periodic error and the length "
+ "scale defines the corner frequency. Default = %.2f"),
+ DefaultLengthScaleSE1Ker));
width = StringWidth(this, _T("000.0"));
- m_pSE1KSignalVariance = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 100.0, DefaultSignalVarianceSE1Ker, 0.1);
+ m_pSE1KSignalVariance = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 100.0, DefaultSignalVarianceSE1Ker, 0.1);
m_pSE1KSignalVariance->SetDigits(2);
AddTableEntry(flexGrid, _("Signal Variance (Short Range)"), m_pSE1KSignalVariance,
- wxString::Format(_("Signal variance (in pixels) of the short-term variations. Default = %.2f"), DefaultSignalVarianceSE1Ker));
+ wxString::Format(
+ _("Signal variance (in pixels) of the short-term variations. Default = %.2f"), DefaultSignalVarianceSE1Ker));
vSizer->Add(flexGrid);
SetSizerAndFit(vSizer);
}
-void GuideAlgorithmGaussianProcess::GPExpertDialog::AddTableEntry(wxFlexGridSizer *Grid, const wxString& Label, wxWindow *Ctrl, const wxString& ToolTip)
+void GuideAlgorithmGaussianProcess::GPExpertDialog::AddTableEntry(
+ wxFlexGridSizer *Grid, const wxString& Label, wxWindow *Ctrl, const wxString& ToolTip)
{
wxStaticText *pLabel = new wxStaticText(this, wxID_ANY, Label + _(": "), wxPoint(-1, -1), wxSize(-1, -1));
Grid->Add(pLabel, 1, wxALL, 5);
@@ -181,7 +197,8 @@ void GuideAlgorithmGaussianProcess::GPExpertDialog::AddTableEntry(wxFlexGridSize
Ctrl->SetToolTip(ToolTip);
}
-void GuideAlgorithmGaussianProcess::GPExpertDialog::LoadExpertValues(GuideAlgorithmGaussianProcess *m_pGuideAlgorithm, const std::vector& hyperParams)
+void GuideAlgorithmGaussianProcess::GPExpertDialog::LoadExpertValues(
+ GuideAlgorithmGaussianProcess *m_pGuideAlgorithm, const std::vector& hyperParams)
{
m_pPeriodLengthsInference->SetValue(m_pGuideAlgorithm->GetPeriodLengthsInference());
m_pPeriodLengthsPeriodEstimation->SetValue(m_pGuideAlgorithm->GetPeriodLengthsPeriodEstimation());
@@ -195,7 +212,8 @@ void GuideAlgorithmGaussianProcess::GPExpertDialog::LoadExpertValues(GuideAlgori
m_pSE1KSignalVariance->SetValue(hyperParams[SE1KSignalVariance]);
}
-void GuideAlgorithmGaussianProcess::GPExpertDialog::UnloadExpertValues(GuideAlgorithmGaussianProcess *m_pGuideAlgorithm, std::vector& hyperParams)
+void GuideAlgorithmGaussianProcess::GPExpertDialog::UnloadExpertValues(
+ GuideAlgorithmGaussianProcess *m_pGuideAlgorithm, std::vector& hyperParams)
{
m_pGuideAlgorithm->SetPeriodLengthsInference(m_pPeriodLengthsInference->GetValue());
m_pGuideAlgorithm->SetPeriodLengthsPeriodEstimation(m_pPeriodLengthsPeriodEstimation->GetValue());
@@ -209,8 +227,8 @@ void GuideAlgorithmGaussianProcess::GPExpertDialog::UnloadExpertValues(GuideAlgo
hyperParams[SE1KSignalVariance] = m_pSE1KSignalVariance->GetValue();
}
-GuideAlgorithmGaussianProcess::
-GuideAlgorithmGPGraphControlPane::GuideAlgorithmGPGraphControlPane(wxWindow *pParent, GuideAlgorithmGaussianProcess *pAlgorithm, const wxString& label)
+GuideAlgorithmGaussianProcess::GuideAlgorithmGPGraphControlPane::GuideAlgorithmGPGraphControlPane(
+ wxWindow *pParent, GuideAlgorithmGaussianProcess *pAlgorithm, const wxString& label)
: GraphControlPane(pParent, label)
{
int width;
@@ -219,31 +237,38 @@ GuideAlgorithmGPGraphControlPane::GuideAlgorithmGPGraphControlPane(wxWindow *pPa
// Prediction Weight
width = StringWidth(_T("000"));
- m_pWeight = pFrame->MakeSpinCtrl(this, wxID_ANY, _T(""), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS | wxALIGN_RIGHT, 0, 100, 0, _T("Prediction Weight"));
+ m_pWeight = pFrame->MakeSpinCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS | wxALIGN_RIGHT, 0, 100, 0, _T("Prediction Weight"));
m_pWeight->SetToolTip(wxString::Format(_("What percent of the predictive guide correction should be applied? "
- "Default = %.f%%, increase to rely more on the predictions"), 100 * DefaultPredictionGain));
- m_pWeight->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GuideAlgorithmGaussianProcess::GuideAlgorithmGPGraphControlPane::OnWeightSpinCtrl, this);
+ "Default = %.f%%, increase to rely more on the predictions"),
+ 100 * DefaultPredictionGain));
+ m_pWeight->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED,
+ &GuideAlgorithmGaussianProcess::GuideAlgorithmGPGraphControlPane::OnWeightSpinCtrl, this);
DoAdd(m_pWeight, _("PredWt"));
// Reactive Weight
width = StringWidth(_T("000"));
- m_pAggressiveness = pFrame->MakeSpinCtrl(this, wxID_ANY, _T(""), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS | wxALIGN_RIGHT, 0, 100, 0, _T("Reactive Weight"));
+ m_pAggressiveness = pFrame->MakeSpinCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS | wxALIGN_RIGHT, 0, 100, 0, _T("Reactive Weight"));
m_pAggressiveness->SetToolTip(wxString::Format(_("What percent of the reactive guide correction should be applied? "
- "Default = %.f%%, adjust if responding too much or too slowly"), 100 * DefaultControlGain));
- m_pAggressiveness->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GuideAlgorithmGaussianProcess::GuideAlgorithmGPGraphControlPane::OnAggressivenessSpinCtrl, this);
+ "Default = %.f%%, adjust if responding too much or too slowly"),
+ 100 * DefaultControlGain));
+ m_pAggressiveness->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED,
+ &GuideAlgorithmGaussianProcess::GuideAlgorithmGPGraphControlPane::OnAggressivenessSpinCtrl, this);
DoAdd(m_pAggressiveness, _("ReactWt"));
// Min move
width = StringWidth(_T("00.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(""), wxPoint(-1, -1),
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(
+ this, wxID_ANY, _T(""), wxPoint(-1, -1), wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
m_pMinMove->SetDigits(2);
- m_pMinMove->SetToolTip(wxString::Format(_("How many (fractional) pixels must the star move to trigger a reactive guide correction? "
- "If camera is binned, this is a fraction of the binned pixel size. Note this has no effect "
- "on the predictive guide correction. Default = %.2f"), DefaultMinMove));
- m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, &GuideAlgorithmGaussianProcess::GuideAlgorithmGPGraphControlPane::OnMinMoveSpinCtrlDouble, this);
+ m_pMinMove->SetToolTip(
+ wxString::Format(_("How many (fractional) pixels must the star move to trigger a reactive guide correction? "
+ "If camera is binned, this is a fraction of the binned pixel size. Note this has no effect "
+ "on the predictive guide correction. Default = %.2f"),
+ DefaultMinMove));
+ m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED,
+ &GuideAlgorithmGaussianProcess::GuideAlgorithmGPGraphControlPane::OnMinMoveSpinCtrlDouble, this);
DoAdd(m_pMinMove, _("MnMo"));
m_pWeight->SetValue(100.0 * m_pGuideAlgorithm->GetPredictionGain());
@@ -251,11 +276,7 @@ GuideAlgorithmGPGraphControlPane::GuideAlgorithmGPGraphControlPane(wxWindow *pPa
m_pMinMove->SetValue(m_pGuideAlgorithm->GetMinMove());
}
-GuideAlgorithmGaussianProcess::
-GuideAlgorithmGPGraphControlPane::~GuideAlgorithmGPGraphControlPane()
-{
-
-}
+GuideAlgorithmGaussianProcess::GuideAlgorithmGPGraphControlPane::~GuideAlgorithmGPGraphControlPane() { }
void GuideAlgorithmGaussianProcess::GuideAlgorithmGPGraphControlPane::OnWeightSpinCtrl(wxSpinEvent& WXUNUSED(evt))
{
@@ -292,60 +313,65 @@ class GuideAlgorithmGaussianProcess::GuideAlgorithmGaussianProcessDialogPane : p
wxSpinCtrlDouble *m_pMinMove;
wxSpinCtrlDouble *m_pPKPeriodLength;
wxSpinCtrl *m_pPredictionGain;
- wxCheckBox *m_checkboxComputePeriod;
+ wxCheckBox *m_checkboxComputePeriod;
wxSpinCtrlDouble *m_retainModelPct;
- wxButton *m_btnExpertOptions;
+ wxButton *m_btnExpertOptions;
public:
GuideAlgorithmGaussianProcessDialogPane(wxWindow *pParent, GuideAlgorithmGaussianProcess *pGuideAlgorithm)
- :
- ConfigDialogPane(_("Predictive PEC Guide Algorithm"),pParent), m_pGuideAlgorithm(pGuideAlgorithm)
+ : ConfigDialogPane(_("Predictive PEC Guide Algorithm"), pParent)
+ , m_pGuideAlgorithm(pGuideAlgorithm)
{
int width;
width = StringWidth(_T("0.00"));
- m_pPredictionGain = pFrame->MakeSpinCtrl(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0, 100, 100 * DefaultPredictionGain);
+ m_pPredictionGain = pFrame->MakeSpinCtrl(pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0, 100, 100 * DefaultPredictionGain);
DoAdd(_("Predictive Weight"), m_pPredictionGain,
wxString::Format(_("What percent of the predictive guide correction should be applied? "
- "Default = %.f%%, increase to rely more on the predictions"), 100 * DefaultPredictionGain));
+ "Default = %.f%%, increase to rely more on the predictions"),
+ 100 * DefaultPredictionGain));
width = StringWidth(_T("0.00"));
- m_pControlGain = pFrame->MakeSpinCtrl(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0, 100, 100 * DefaultControlGain);
+ m_pControlGain = pFrame->MakeSpinCtrl(pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS,
+ 0, 100, 100 * DefaultControlGain);
DoAdd(_("Reactive Weight"), m_pControlGain,
wxString::Format(_("What percent of the reactive guide correction should be applied? "
- "Default = %.f%%, adjust if responding too much or too slowly"), 100 * DefaultControlGain));
+ "Default = %.f%%, adjust if responding too much or too slowly"),
+ 100 * DefaultControlGain));
width = StringWidth(_T("0.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 5.0, DefaultMinMove, 0.01);
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(
+ pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 5.0, DefaultMinMove, 0.01);
m_pMinMove->SetDigits(2);
DoAdd(_("Minimum Move (pixels)"), m_pMinMove,
wxString::Format(_("How many (fractional) pixels must the star move to trigger a reactive guide correction? "
- "If camera is binned, this is a fraction of the binned pixel size. Note this has no effect "
- "on the predictive guide correction. Default = %.2f"), DefaultMinMove));
+ "If camera is binned, this is a fraction of the binned pixel size. Note this has no effect "
+ "on the predictive guide correction. Default = %.2f"),
+ DefaultMinMove));
width = StringWidth(_T("0000.0"));
- m_pPKPeriodLength = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 10.0, 2000.0, DefaultPeriodLengthPerKer, 1);
+ m_pPKPeriodLength = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 10.0, 2000.0, DefaultPeriodLengthPerKer, 1);
m_pPKPeriodLength->SetDigits(2);
m_checkboxComputePeriod = new wxCheckBox(pParent, wxID_ANY, _("Auto-adjust period"));
- m_checkboxComputePeriod->SetToolTip(wxString::Format(_("Auto-adjust the period length based on identified repetitive errors. Default = %s"),
- DefaultComputePeriod ? _("On") : _("Off")));
+ m_checkboxComputePeriod->SetToolTip(
+ wxString::Format(_("Auto-adjust the period length based on identified repetitive errors. Default = %s"),
+ DefaultComputePeriod ? _("On") : _("Off")));
DoAdd(_("Period Length"), m_pPKPeriodLength,
wxString::Format(_("The period length (in seconds) of the strongest periodic error component. Default = %.2f"),
- DefaultPeriodLengthPerKer));
+ DefaultPeriodLengthPerKer));
DoAdd(m_checkboxComputePeriod);
width = StringWidth(_T("888"));
- m_retainModelPct = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, wxEmptyString, wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 80.0, DefaultNoresetMaxPctPeriod, 1.0);
+ m_retainModelPct = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 80.0, DefaultNoresetMaxPctPeriod, 1.0);
m_retainModelPct->SetDigits(0);
DoAdd(wxString::Format(_("Retain model (%% period)")), m_retainModelPct,
wxString::Format(_("Enter a percentage greater than 0 to retain the PPEC model after guiding stops. "
- "Default = %.f%% of the period length."), DefaultNoresetMaxPctPeriod));
+ "Default = %.f%% of the period length."),
+ DefaultNoresetMaxPctPeriod));
m_btnExpertOptions = new wxButton(pParent, wxID_ANY, _("Expert..."));
m_btnExpertOptions->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GuideAlgorithmGaussianProcessDialogPane::OnExpertButton, this);
@@ -353,12 +379,13 @@ class GuideAlgorithmGaussianProcess::GuideAlgorithmGaussianProcessDialogPane : p
this->Add(m_btnExpertOptions, wxSizerFlags().Center().Border(wxALL, 3));
if (!m_pGuideAlgorithm->m_expertDialog)
- m_pGuideAlgorithm->m_expertDialog = new GPExpertDialog(m_pParent); // Do this here so the parent window has been built
+ m_pGuideAlgorithm->m_expertDialog =
+ new GPExpertDialog(m_pParent); // Do this here so the parent window has been built
}
virtual ~GuideAlgorithmGaussianProcessDialogPane()
{
- // no need to destroy the widgets, this is done by the parent...
+ // no need to destroy the widgets, this is done by the parent...
}
/* Fill the GUI with the parameters that are currently configured in the
@@ -397,29 +424,28 @@ class GuideAlgorithmGaussianProcess::GuideAlgorithmGaussianProcessDialogPane : p
m_pGuideAlgorithm->SetGPHyperparameters(hyperparameters);
if (pFrame->pGuider->IsGuiding() && m_pGuideAlgorithm->GetBoolComputePeriod() != m_checkboxComputePeriod->GetValue())
- pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " PPEC Adjust Period Length", m_checkboxComputePeriod->GetValue());
+ pFrame->NotifyGuidingParam(
+ m_pGuideAlgorithm->GetAxis() + " PPEC Adjust Period Length", m_checkboxComputePeriod->GetValue());
m_pGuideAlgorithm->SetBoolComputePeriod(m_checkboxComputePeriod->GetValue());
SetRetainModelPct(m_pGuideAlgorithm, m_retainModelPct->GetValue());
}
- virtual void OnImageScaleChange()
- {
- GuideAlgorithm::AdjustMinMoveSpinCtrl(m_pMinMove);
- }
+ virtual void OnImageScaleChange() { GuideAlgorithm::AdjustMinMoveSpinCtrl(m_pMinMove); }
- virtual void OnExpertButton(wxCommandEvent& evt)
- {
- m_pGuideAlgorithm->m_expertDialog->ShowModal();
- }
+ virtual void OnExpertButton(wxCommandEvent& evt) { m_pGuideAlgorithm->m_expertDialog->ShowModal(); }
// make the class non-copyable (if we ever need this, we must implement a deep copy)
- GuideAlgorithmGaussianProcessDialogPane(const GuideAlgorithmGaussianProcess::GuideAlgorithmGaussianProcessDialogPane&) = delete;
- GuideAlgorithmGaussianProcessDialogPane& operator=(const GuideAlgorithmGaussianProcess::GuideAlgorithmGaussianProcessDialogPane&) = delete;
+ GuideAlgorithmGaussianProcessDialogPane(
+ const GuideAlgorithmGaussianProcess::GuideAlgorithmGaussianProcessDialogPane&) = delete;
+ GuideAlgorithmGaussianProcessDialogPane& operator=(
+ const GuideAlgorithmGaussianProcess::GuideAlgorithmGaussianProcessDialogPane&) = delete;
};
GuideAlgorithmGaussianProcess::GuideAlgorithmGaussianProcess(Mount *pMount, GuideAxis axis)
- : GuideAlgorithm(pMount, axis), GPG(0), dark_tracking_mode_(false)
+ : GuideAlgorithm(pMount, axis)
+ , GPG(0)
+ , dark_tracking_mode_(false)
{
// create guide parameters, load default values at first
GaussianProcessGuider::guide_parameters parameters;
@@ -449,26 +475,36 @@ GuideAlgorithmGaussianProcess::GuideAlgorithmGaussianProcess(Mount *pMount, Guid
double min_move = pConfig->Profile.GetDouble(configPath + "/gp_min_move", DefaultMinMove);
SetMinMove(min_move);
- double period_lengths_for_inference = pConfig->Profile.GetDouble(configPath + "/gp_period_lengths_inference", DefaultPeriodLengthsForInference);
+ double period_lengths_for_inference =
+ pConfig->Profile.GetDouble(configPath + "/gp_period_lengths_inference", DefaultPeriodLengthsForInference);
SetPeriodLengthsInference(period_lengths_for_inference);
- double period_lengths_for_period_estimation = pConfig->Profile.GetDouble(configPath + "/gp_period_lengths_period_estimation", DefaultPeriodLengthsForPeriodEstimation);
+ double period_lengths_for_period_estimation = pConfig->Profile.GetDouble(
+ configPath + "/gp_period_lengths_period_estimation", DefaultPeriodLengthsForPeriodEstimation);
SetPeriodLengthsPeriodEstimation(period_lengths_for_period_estimation);
- int num_points_approximation = pConfig->Profile.GetInt(configPath + "/gp_points_for_approximation", DefaultNumPointsForApproximation);
+ int num_points_approximation =
+ pConfig->Profile.GetInt(configPath + "/gp_points_for_approximation", DefaultNumPointsForApproximation);
SetNumPointsForApproximation(num_points_approximation);
double prediction_gain = pConfig->Profile.GetDouble(configPath + "/gp_prediction_gain", DefaultPredictionGain);
SetPredictionGain(prediction_gain);
std::vector v_hyperparameters(NumParameters);
- v_hyperparameters[SE0KLengthScale] = pConfig->Profile.GetDouble(configPath + "/gp_length_scale_se0_kern", DefaultLengthScaleSE0Ker);
- v_hyperparameters[SE0KSignalVariance] = pConfig->Profile.GetDouble(configPath + "/gp_sigvar_se0_kern", DefaultSignalVarianceSE0Ker);
- v_hyperparameters[PKLengthScale] = pConfig->Profile.GetDouble(configPath + "/gp_length_scale_per_kern", DefaultLengthScalePerKer);
- v_hyperparameters[PKSignalVariance] = pConfig->Profile.GetDouble(configPath + "/gp_sigvar_per_kern", DefaultSignalVariancePerKer);
- v_hyperparameters[SE1KLengthScale] = pConfig->Profile.GetDouble(configPath + "/gp_length_scale_se1_kern", DefaultLengthScaleSE1Ker);
- v_hyperparameters[SE1KSignalVariance] = pConfig->Profile.GetDouble(configPath + "/gp_sigvar_se1_kern", DefaultSignalVarianceSE1Ker);
- v_hyperparameters[PKPeriodLength] = pConfig->Profile.GetDouble(configPath + "/gp_period_per_kern", DefaultPeriodLengthPerKer);
+ v_hyperparameters[SE0KLengthScale] =
+ pConfig->Profile.GetDouble(configPath + "/gp_length_scale_se0_kern", DefaultLengthScaleSE0Ker);
+ v_hyperparameters[SE0KSignalVariance] =
+ pConfig->Profile.GetDouble(configPath + "/gp_sigvar_se0_kern", DefaultSignalVarianceSE0Ker);
+ v_hyperparameters[PKLengthScale] =
+ pConfig->Profile.GetDouble(configPath + "/gp_length_scale_per_kern", DefaultLengthScalePerKer);
+ v_hyperparameters[PKSignalVariance] =
+ pConfig->Profile.GetDouble(configPath + "/gp_sigvar_per_kern", DefaultSignalVariancePerKer);
+ v_hyperparameters[SE1KLengthScale] =
+ pConfig->Profile.GetDouble(configPath + "/gp_length_scale_se1_kern", DefaultLengthScaleSE1Ker);
+ v_hyperparameters[SE1KSignalVariance] =
+ pConfig->Profile.GetDouble(configPath + "/gp_sigvar_se1_kern", DefaultSignalVarianceSE1Ker);
+ v_hyperparameters[PKPeriodLength] =
+ pConfig->Profile.GetDouble(configPath + "/gp_period_per_kern", DefaultPeriodLengthPerKer);
SetGPHyperparameters(v_hyperparameters);
@@ -519,8 +555,7 @@ bool GuideAlgorithmGaussianProcess::GetParam(const wxString& name, double *val)
*val = GetPredictionGain();
else if (name == "reactiveWeight")
*val = GetControlGain();
- else
- if (name == "periodLength")
+ else if (name == "periodLength")
{
std::vector hyperparameters = GetGPHyperparameters();
assert(hyperparameters.size() == NumParameters);
@@ -542,8 +577,7 @@ bool GuideAlgorithmGaussianProcess::SetParam(const wxString& name, double val)
err = SetPredictionGain(val);
else if (name == "reactiveWeight")
err = SetControlGain(val);
- else
- if (name == "periodLength")
+ else if (name == "periodLength")
{
std::vector hyperparameters(NumParameters);
hyperparameters[PKPeriodLength] = val;
@@ -899,38 +933,26 @@ bool GuideAlgorithmGaussianProcess::SetDarkTracking(bool value)
wxString GuideAlgorithmGaussianProcess::GetSettingsSummary() const
{
- static const char* format =
- "Control gain = %.3f\n"
- "Prediction gain = %.3f\n"
- "Minimum move = %.3f\n"
- "Hyperparameters\n"
- "\tLength scale long range SE kernel = %.3f\n"
- "\tSignal variance long range SE kernel = %.3f\n"
- "\tLength scale periodic kernel = %.3f\n"
- "\tSignal variance periodic kernel = %.3f\n"
- "\tLength scale short range SE kernel = %.3f\n"
- "\tSignal variance short range SE kernel = %.3f\n"
- "\tPeriod length periodic kernel = %.3f\n"
- "\tFFT called after = %.3f worm cycles\n"
- "\tAuto-adjust period length = %s\n"
- ;
+ static const char *format = "Control gain = %.3f\n"
+ "Prediction gain = %.3f\n"
+ "Minimum move = %.3f\n"
+ "Hyperparameters\n"
+ "\tLength scale long range SE kernel = %.3f\n"
+ "\tSignal variance long range SE kernel = %.3f\n"
+ "\tLength scale periodic kernel = %.3f\n"
+ "\tSignal variance periodic kernel = %.3f\n"
+ "\tLength scale short range SE kernel = %.3f\n"
+ "\tSignal variance short range SE kernel = %.3f\n"
+ "\tPeriod length periodic kernel = %.3f\n"
+ "\tFFT called after = %.3f worm cycles\n"
+ "\tAuto-adjust period length = %s\n";
std::vector hyperparameters = GetGPHyperparameters();
- return wxString::Format(
- format,
- GetControlGain(),
- GetPredictionGain(),
- GetMinMove(),
- hyperparameters[SE0KLengthScale],
- hyperparameters[SE0KSignalVariance],
- hyperparameters[PKLengthScale],
- hyperparameters[PKSignalVariance],
- hyperparameters[SE1KLengthScale],
- hyperparameters[SE1KSignalVariance],
- hyperparameters[PKPeriodLength],
- GetPeriodLengthsPeriodEstimation(),
- GetBoolComputePeriod() ? "On" : "Off");
+ return wxString::Format(format, GetControlGain(), GetPredictionGain(), GetMinMove(), hyperparameters[SE0KLengthScale],
+ hyperparameters[SE0KSignalVariance], hyperparameters[PKLengthScale], hyperparameters[PKSignalVariance],
+ hyperparameters[SE1KLengthScale], hyperparameters[SE1KSignalVariance], hyperparameters[PKPeriodLength],
+ GetPeriodLengthsPeriodEstimation(), GetBoolComputePeriod() ? "On" : "Off");
}
GUIDE_ALGORITHM GuideAlgorithmGaussianProcess::Algorithm() const
@@ -941,7 +963,7 @@ GUIDE_ALGORITHM GuideAlgorithmGaussianProcess::Algorithm() const
double GuideAlgorithmGaussianProcess::result(double input)
{
if (block_updates_)
- return(0);
+ return (0);
if (dark_tracking_mode_ == true)
{
@@ -952,8 +974,8 @@ double GuideAlgorithmGaussianProcess::result(double input)
const Star& star = pFrame->pGuider->PrimaryStar();
double control_signal = GPG->result(input, star.SNR, (double) pFrame->RequestedExposureDuration() / 1000.0);
- Debug.Write(wxString::Format("PPEC: input: %.2f, control: %.2f, exposure: %d\n",
- input, control_signal, pFrame->RequestedExposureDuration()));
+ Debug.Write(wxString::Format(
+ "PPEC: input: %.2f, control: %.2f, exposure: %d\n", input, control_signal, pFrame->RequestedExposureDuration()));
return control_signal;
}
@@ -962,8 +984,8 @@ double GuideAlgorithmGaussianProcess::deduceResult()
{
double control_signal = GPG->deduceResult((double) pFrame->RequestedExposureDuration() / 1000.0);
- Debug.Write(wxString::Format("PPEC (deduced): control: %.2f, exposure: %d\n", control_signal,
- pFrame->RequestedExposureDuration()));
+ Debug.Write(
+ wxString::Format("PPEC (deduced): control: %.2f, exposure: %d\n", control_signal, pFrame->RequestedExposureDuration()));
return control_signal;
}
@@ -1002,7 +1024,7 @@ inline static wxString FormatRA(double ra)
void GuideAlgorithmGaussianProcess::GuidingStarted()
{
bool need_reset = true;
- double ra_offset; // RA delta in SI seconds
+ double ra_offset; // RA delta in SI seconds
auto now = std::chrono::system_clock::now();
@@ -1012,16 +1034,15 @@ void GuideAlgorithmGaussianProcess::GuidingStarted()
PierSide prev_side = guiding_pier_side_;
guiding_pier_side_ = CurrentPierSide();
- Debug.Write(wxString::Format("PPEC: guiding starts RA = %s, pier %s, prev RA = %s, pier %s\n",
- FormatRA(guiding_ra_), Mount::PierSideStr(guiding_pier_side_),
- FormatRA(prev_ra), Mount::PierSideStr(prev_side)));
+ Debug.Write(wxString::Format("PPEC: guiding starts RA = %s, pier %s, prev RA = %s, pier %s\n", FormatRA(guiding_ra_),
+ Mount::PierSideStr(guiding_pier_side_), FormatRA(prev_ra), Mount::PierSideStr(prev_side)));
// retain the model (do not reset) if:
// - guiding on the same side of pier, and
// - worm rotation is less than 40% of the worm period
- if (!math_tools::isNaN(guiding_ra_) && !math_tools::isNaN(prev_ra) &&
- prev_side != PIER_SIDE_UNKNOWN && prev_side == guiding_pier_side_)
+ if (!math_tools::isNaN(guiding_ra_) && !math_tools::isNaN(prev_ra) && prev_side != PIER_SIDE_UNKNOWN &&
+ prev_side == guiding_pier_side_)
{
const double SECONDS_PER_HOUR = 60. * 60.;
const double SIDEREAL_SECONDS_PER_SEC = 0.9973;
@@ -1039,11 +1060,11 @@ void GuideAlgorithmGaussianProcess::GuidingStarted()
double period_length = GPG->GetGPHyperparameters()[PKPeriodLength];
double max_pct_period = GetRetainModelPct(this);
- Debug.Write(wxString::Format("PPEC: guiding was stopped for %.1f seconds, deltaRA %+.1fs, worm delta %+.1fs, %.1f%% of period "
- "(%.1fs), limit %.1f%% (%.1fs)\n",
- elapsed_time, -ra_offset, worm_offset,
- fabs(worm_offset) / period_length * 100., period_length,
- max_pct_period, max_pct_period / 100. * period_length));
+ Debug.Write(
+ wxString::Format("PPEC: guiding was stopped for %.1f seconds, deltaRA %+.1fs, worm delta %+.1fs, %.1f%% of period "
+ "(%.1fs), limit %.1f%% (%.1fs)\n",
+ elapsed_time, -ra_offset, worm_offset, fabs(worm_offset) / period_length * 100., period_length, max_pct_period,
+ max_pct_period / 100. * period_length));
if (fabs(worm_offset) < max_pct_period / 100. * period_length)
{
@@ -1081,20 +1102,16 @@ void GuideAlgorithmGaussianProcess::GuidingStopped()
guiding_stopped_time_ = std::chrono::system_clock::now();
}
-void GuideAlgorithmGaussianProcess::GuidingPaused()
-{
-}
+void GuideAlgorithmGaussianProcess::GuidingPaused() { }
-void GuideAlgorithmGaussianProcess::GuidingResumed()
-{
-}
+void GuideAlgorithmGaussianProcess::GuidingResumed() { }
void GuideAlgorithmGaussianProcess::GuidingDisabled()
{
// Don't submit guide star movements to the GP while guiding is disabled
Debug.Write("PPEC model updates disabled\n");
block_updates_ = true;
- GuidingStopped(); // Keep our last state and reset
+ GuidingStopped(); // Keep our last state and reset
}
void GuideAlgorithmGaussianProcess::GuidingEnabled()
diff --git a/src/guide_algorithm_gaussian_process.h b/src/guide_algorithm_gaussian_process.h
index 7d3439841..5b102b56b 100644
--- a/src/guide_algorithm_gaussian_process.h
+++ b/src/guide_algorithm_gaussian_process.h
@@ -64,7 +64,7 @@ class GuideAlgorithmGaussianProcess : public GuideAlgorithm
{
wxSpinCtrlDouble *m_pPeriodLengthsInference;
wxSpinCtrlDouble *m_pPeriodLengthsPeriodEstimation;
- wxSpinCtrl *m_pNumPointsApproximation;
+ wxSpinCtrl *m_pNumPointsApproximation;
wxSpinCtrlDouble *m_pSE0KLengthScale;
wxSpinCtrlDouble *m_pSE0KSignalVariance;
wxSpinCtrlDouble *m_pPKLengthScale;
@@ -97,10 +97,9 @@ class GuideAlgorithmGaussianProcess : public GuideAlgorithm
void OnMinMoveSpinCtrlDouble(wxSpinDoubleEvent& evt);
};
- GPExpertDialog *m_expertDialog; // Exactly one per GP instance independent from ConfigDialogPane lifetimes
+ GPExpertDialog *m_expertDialog; // Exactly one per GP instance independent from ConfigDialogPane lifetimes
private:
-
/**
* Holds all data that is needed for the GP guiding.
*/
@@ -120,8 +119,8 @@ class GuideAlgorithmGaussianProcess : public GuideAlgorithm
* Dark tracking mode is for debugging: only deduceResult is called if enabled.
*/
bool dark_tracking_mode_;
- bool block_updates_; // Don't update GP if guiding is disabled
- double guiding_ra_; // allow resuming guiding after guiding stopped if there is no change in RA
+ bool block_updates_; // Don't update GP if guiding is disabled
+ double guiding_ra_; // allow resuming guiding after guiding stopped if there is no change in RA
PierSide guiding_pier_side_;
std::chrono::system_clock::time_point guiding_stopped_time_; // time guiding stopped
@@ -235,7 +234,6 @@ class GuideAlgorithmGaussianProcess : public GuideAlgorithm
void GetParamNames(wxArrayString& names) const override;
bool GetParam(const wxString& name, double *val) const override;
bool SetParam(const wxString& name, double val) override;
-
};
-#endif // GUIDE_GAUSSIAN_PROCESS
+#endif // GUIDE_GAUSSIAN_PROCESS
diff --git a/src/guide_algorithm_hysteresis.cpp b/src/guide_algorithm_hysteresis.cpp
index a7e4ca96f..99e5396bd 100644
--- a/src/guide_algorithm_hysteresis.cpp
+++ b/src/guide_algorithm_hysteresis.cpp
@@ -39,7 +39,7 @@
#include "phd.h"
-static const double DefaultMinMove = 0.2;
+static const double DefaultMinMove = 0.2;
static const double DefaultHysteresis = 0.1;
static const double DefaultAggression = 0.7;
static const double MaxAggression = 2.0;
@@ -50,7 +50,7 @@ GuideAlgorithmHysteresis::GuideAlgorithmHysteresis(Mount *pMount, GuideAxis axis
{
wxString configPath = GetConfigPath();
- double minMove = pConfig->Profile.GetDouble(configPath + "/minMove", DefaultMinMove);
+ double minMove = pConfig->Profile.GetDouble(configPath + "/minMove", DefaultMinMove);
SetMinMove(minMove);
double hysteresis = pConfig->Profile.GetDouble(configPath + "/hysteresis", DefaultHysteresis);
@@ -62,9 +62,7 @@ GuideAlgorithmHysteresis::GuideAlgorithmHysteresis(Mount *pMount, GuideAxis axis
reset();
}
-GuideAlgorithmHysteresis::~GuideAlgorithmHysteresis(void)
-{
-}
+GuideAlgorithmHysteresis::~GuideAlgorithmHysteresis(void) { }
GUIDE_ALGORITHM GuideAlgorithmHysteresis::Algorithm() const
{
@@ -105,7 +103,6 @@ bool GuideAlgorithmHysteresis::SetMinMove(double minMove)
}
m_minMove = minMove;
-
}
catch (const wxString& Msg)
{
@@ -131,7 +128,6 @@ bool GuideAlgorithmHysteresis::SetHysteresis(double hysteresis)
}
m_hysteresis = hysteresis;
-
}
catch (const wxString& Msg)
{
@@ -174,11 +170,8 @@ bool GuideAlgorithmHysteresis::SetAggression(double aggression)
wxString GuideAlgorithmHysteresis::GetSettingsSummary() const
{
// return a loggable summary of current mount settings
- return wxString::Format("Hysteresis = %.3f, Aggression = %.3f, Minimum move = %.3f\n",
- GetHysteresis(),
- GetAggression(),
- GetMinMove()
- );
+ return wxString::Format(
+ "Hysteresis = %.3f, Aggression = %.3f, Minimum move = %.3f\n", GetHysteresis(), GetAggression(), GetMinMove());
}
void GuideAlgorithmHysteresis::GetParamNames(wxArrayString& names) const
@@ -225,9 +218,8 @@ ConfigDialogPane *GuideAlgorithmHysteresis::GetConfigDialogPane(wxWindow *pParen
return new GuideAlgorithmHysteresisConfigDialogPane(pParent, this);
}
-GuideAlgorithmHysteresis::
-GuideAlgorithmHysteresisConfigDialogPane::
-GuideAlgorithmHysteresisConfigDialogPane(wxWindow *pParent, GuideAlgorithmHysteresis *pGuideAlgorithm)
+GuideAlgorithmHysteresis::GuideAlgorithmHysteresisConfigDialogPane::GuideAlgorithmHysteresisConfigDialogPane(
+ wxWindow *pParent, GuideAlgorithmHysteresis *pGuideAlgorithm)
: ConfigDialogPane(_("Hysteresis Guide Algorithm"), pParent)
{
int width;
@@ -235,61 +227,56 @@ GuideAlgorithmHysteresisConfigDialogPane(wxWindow *pParent, GuideAlgorithmHyster
m_pGuideAlgorithm = pGuideAlgorithm;
width = StringWidth(_T("000"));
- m_pHysteresis = pFrame->MakeSpinCtrl(pParent, wxID_ANY,_T(""), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, MaxHysteresis * 100.0, 0.0, _T("Hysteresis"));
+ m_pHysteresis = pFrame->MakeSpinCtrl(pParent, wxID_ANY, _T(""), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 0.0,
+ MaxHysteresis * 100.0, 0.0, _T("Hysteresis"));
DoAdd(_("Hysteresis"), m_pHysteresis,
- wxString::Format(_("How much history of previous guide pulses should be applied\nDefault = %.f%%, increase to smooth out guiding commands"), DefaultHysteresis * 100.0));
+ wxString::Format(_("How much history of previous guide pulses should be applied\nDefault = %.f%%, increase to smooth "
+ "out guiding commands"),
+ DefaultHysteresis * 100.0));
width = StringWidth(_T("000"));
- m_pAggression = pFrame->MakeSpinCtrl(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, MaxAggression * 100.0, 0.0, _T("Aggressiveness"));
+ m_pAggression = pFrame->MakeSpinCtrl(pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 0.0,
+ MaxAggression * 100.0, 0.0, _T("Aggressiveness"));
DoAdd(_("Aggressiveness"), m_pAggression,
- wxString::Format(_("What percentage of the computed correction should be applied? Default = %.f%%, adjust if responding too much or too slowly"), DefaultAggression * 100.0));
+ wxString::Format(_("What percentage of the computed correction should be applied? Default = %.f%%, adjust if "
+ "responding too much or too slowly"),
+ DefaultAggression * 100.0));
width = StringWidth(_T("00.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(
+ pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
m_pMinMove->SetDigits(2);
DoAdd(_("Minimum Move (pixels)"), m_pMinMove,
- wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
- "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"), DefaultMinMove));
+ wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
+ "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"),
+ DefaultMinMove));
}
-GuideAlgorithmHysteresis::
-GuideAlgorithmHysteresisConfigDialogPane::
-~GuideAlgorithmHysteresisConfigDialogPane(void)
-{
-}
+GuideAlgorithmHysteresis::GuideAlgorithmHysteresisConfigDialogPane::~GuideAlgorithmHysteresisConfigDialogPane(void) { }
-void GuideAlgorithmHysteresis::
-GuideAlgorithmHysteresisConfigDialogPane::
-LoadValues(void)
+void GuideAlgorithmHysteresis::GuideAlgorithmHysteresisConfigDialogPane::LoadValues(void)
{
m_pHysteresis->SetValue(100.0 * m_pGuideAlgorithm->GetHysteresis());
m_pAggression->SetValue(100.0 * m_pGuideAlgorithm->GetAggression());
m_pMinMove->SetValue(m_pGuideAlgorithm->GetMinMove());
}
-void GuideAlgorithmHysteresis::
-GuideAlgorithmHysteresisConfigDialogPane::
-UnloadValues(void)
+void GuideAlgorithmHysteresis::GuideAlgorithmHysteresisConfigDialogPane::UnloadValues(void)
{
m_pGuideAlgorithm->SetHysteresis(m_pHysteresis->GetValue() / 100.0);
m_pGuideAlgorithm->SetAggression(m_pAggression->GetValue() / 100.0);
m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
}
-void GuideAlgorithmHysteresis::
-GuideAlgorithmHysteresisConfigDialogPane::OnImageScaleChange()
+void GuideAlgorithmHysteresis::GuideAlgorithmHysteresisConfigDialogPane::OnImageScaleChange()
{
GuideAlgorithm::AdjustMinMoveSpinCtrl(m_pMinMove);
}
-void GuideAlgorithmHysteresis::
-GuideAlgorithmHysteresisConfigDialogPane::EnableDecControls(bool enable)
+void GuideAlgorithmHysteresis::GuideAlgorithmHysteresisConfigDialogPane::EnableDecControls(bool enable)
{
m_pAggression->Enable(enable);
m_pMinMove->Enable(enable);
@@ -301,9 +288,8 @@ GraphControlPane *GuideAlgorithmHysteresis::GetGraphControlPane(wxWindow *pParen
return new GuideAlgorithmHysteresisGraphControlPane(pParent, this, label);
}
-GuideAlgorithmHysteresis::
-GuideAlgorithmHysteresisGraphControlPane::
-GuideAlgorithmHysteresisGraphControlPane(wxWindow *pParent, GuideAlgorithmHysteresis *pGuideAlgorithm, const wxString& label)
+GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::GuideAlgorithmHysteresisGraphControlPane(
+ wxWindow *pParent, GuideAlgorithmHysteresis *pGuideAlgorithm, const wxString& label)
: GraphControlPane(pParent, label)
{
int width;
@@ -312,29 +298,38 @@ GuideAlgorithmHysteresisGraphControlPane(wxWindow *pParent, GuideAlgorithmHyster
// Aggression
width = StringWidth(_T("000"));
- m_pAggression = pFrame->MakeSpinCtrl(this, wxID_ANY, _T(""), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS | wxALIGN_RIGHT, 0.0, MaxAggression * 100.0, 0.0, _T("Aggressiveness"));
- m_pAggression->SetToolTip(wxString::Format(_("What percentage of the computed correction should be applied?? Default = %.f%%, adjust if responding too much or too slowly"), DefaultAggression * 100.0));
- m_pAggression->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::OnAggressionSpinCtrl, this);
+ m_pAggression = pFrame->MakeSpinCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS | wxALIGN_RIGHT, 0.0, MaxAggression * 100.0, 0.0, _T("Aggressiveness"));
+ m_pAggression->SetToolTip(wxString::Format(_("What percentage of the computed correction should be applied?? Default = "
+ "%.f%%, adjust if responding too much or too slowly"),
+ DefaultAggression * 100.0));
+ m_pAggression->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED,
+ &GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::OnAggressionSpinCtrl, this);
DoAdd(m_pAggression, _("Agr"));
// Hysteresis
width = StringWidth(_T("000"));
- m_pHysteresis = pFrame->MakeSpinCtrl(this, wxID_ANY, _T(""), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS | wxALIGN_RIGHT, 0.0, MaxHysteresis * 100.0, 0.0, _T("Hysteresis"));
- m_pHysteresis->SetToolTip(wxString::Format(_("How much history of previous guide pulses should be applied\nDefault = %.f%%, increase to smooth out guiding commands"), DefaultHysteresis * 100.0));
- m_pHysteresis->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::OnHysteresisSpinCtrl, this);
- DoAdd(m_pHysteresis,_("Hys"));
+ m_pHysteresis = pFrame->MakeSpinCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS | wxALIGN_RIGHT, 0.0, MaxHysteresis * 100.0, 0.0, _T("Hysteresis"));
+ m_pHysteresis->SetToolTip(wxString::Format(_("How much history of previous guide pulses should be applied\nDefault = "
+ "%.f%%, increase to smooth out guiding commands"),
+ DefaultHysteresis * 100.0));
+ m_pHysteresis->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED,
+ &GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::OnHysteresisSpinCtrl, this);
+ DoAdd(m_pHysteresis, _("Hys"));
// Min move
width = StringWidth(_T("00.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(""), wxPoint(-1, -1),
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(
+ this, wxID_ANY, _T(""), wxPoint(-1, -1), wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
m_pMinMove->SetDigits(2);
- m_pMinMove->SetToolTip(wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
- "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"), DefaultMinMove));
- m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, &GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::OnMinMoveSpinCtrlDouble, this);
- DoAdd(m_pMinMove,_("MnMo"));
+ m_pMinMove->SetToolTip(
+ wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
+ "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"),
+ DefaultMinMove));
+ m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED,
+ &GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::OnMinMoveSpinCtrlDouble, this);
+ DoAdd(m_pMinMove, _("MnMo"));
m_pHysteresis->SetValue(100.0 * m_pGuideAlgorithm->GetHysteresis());
m_pAggression->SetValue(100.0 * m_pGuideAlgorithm->GetAggression());
@@ -349,39 +344,29 @@ GuideAlgorithmHysteresisGraphControlPane(wxWindow *pParent, GuideAlgorithmHyster
}
}
-GuideAlgorithmHysteresis::
-GuideAlgorithmHysteresisGraphControlPane::
-~GuideAlgorithmHysteresisGraphControlPane(void)
-{
-}
+GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::~GuideAlgorithmHysteresisGraphControlPane(void) { }
-void GuideAlgorithmHysteresis::
-GuideAlgorithmHysteresisGraphControlPane::EnableDecControls(bool enable)
+void GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::EnableDecControls(bool enable)
{
m_pAggression->Enable(enable);
m_pHysteresis->Enable(enable);
m_pMinMove->Enable(enable);
}
-void GuideAlgorithmHysteresis::
- GuideAlgorithmHysteresisGraphControlPane::
- OnAggressionSpinCtrl(wxSpinEvent& WXUNUSED(evt))
+void GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::OnAggressionSpinCtrl(wxSpinEvent& WXUNUSED(evt))
{
m_pGuideAlgorithm->SetAggression(m_pAggression->GetValue() / 100.0);
pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " Hysteresis aggression", m_pAggression->GetValue());
}
-void GuideAlgorithmHysteresis::
- GuideAlgorithmHysteresisGraphControlPane::
- OnHysteresisSpinCtrl(wxSpinEvent& WXUNUSED(evt))
+void GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::OnHysteresisSpinCtrl(wxSpinEvent& WXUNUSED(evt))
{
m_pGuideAlgorithm->SetHysteresis(this->m_pHysteresis->GetValue() / 100.0);
pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " Hysteresis hysteresis", m_pHysteresis->GetValue());
}
-void GuideAlgorithmHysteresis::
- GuideAlgorithmHysteresisGraphControlPane::
- OnMinMoveSpinCtrlDouble(wxSpinDoubleEvent& WXUNUSED(evt))
+void GuideAlgorithmHysteresis::GuideAlgorithmHysteresisGraphControlPane::OnMinMoveSpinCtrlDouble(
+ wxSpinDoubleEvent& WXUNUSED(evt))
{
m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " Hysteresis minimum move", m_pMinMove->GetValue());
diff --git a/src/guide_algorithm_hysteresis.h b/src/guide_algorithm_hysteresis.h
index 694f76326..0d04a0367 100644
--- a/src/guide_algorithm_hysteresis.h
+++ b/src/guide_algorithm_hysteresis.h
@@ -48,7 +48,6 @@ class GuideAlgorithmHysteresis : public GuideAlgorithm
double m_lastMove;
protected:
-
class GuideAlgorithmHysteresisConfigDialogPane : public ConfigDialogPane
{
GuideAlgorithmHysteresis *m_pGuideAlgorithm;
@@ -69,7 +68,8 @@ class GuideAlgorithmHysteresis : public GuideAlgorithm
class GuideAlgorithmHysteresisGraphControlPane : public GraphControlPane
{
public:
- GuideAlgorithmHysteresisGraphControlPane(wxWindow *pParent, GuideAlgorithmHysteresis *pGuideAlgorithm, const wxString& label);
+ GuideAlgorithmHysteresisGraphControlPane(
+ wxWindow *pParent, GuideAlgorithmHysteresis *pGuideAlgorithm, const wxString& label);
~GuideAlgorithmHysteresisGraphControlPane();
void EnableDecControls(bool enable) override;
@@ -95,7 +95,6 @@ class GuideAlgorithmHysteresis : public GuideAlgorithm
friend class GraphLogWindow;
public:
-
GuideAlgorithmHysteresis(Mount *pMount, GuideAxis axis);
~GuideAlgorithmHysteresis();
diff --git a/src/guide_algorithm_identity.cpp b/src/guide_algorithm_identity.cpp
index 25f07ec70..948772755 100644
--- a/src/guide_algorithm_identity.cpp
+++ b/src/guide_algorithm_identity.cpp
@@ -45,18 +45,14 @@ GuideAlgorithmIdentity::GuideAlgorithmIdentity(Mount *pMount, GuideAxis axis)
reset();
}
-GuideAlgorithmIdentity::~GuideAlgorithmIdentity(void)
-{
-}
+GuideAlgorithmIdentity::~GuideAlgorithmIdentity(void) { }
GUIDE_ALGORITHM GuideAlgorithmIdentity::Algorithm() const
{
return GUIDE_ALGORITHM_IDENTITY;
}
-void GuideAlgorithmIdentity::reset(void)
-{
-}
+void GuideAlgorithmIdentity::reset(void) { }
// the default algorithm simply returns its input
double GuideAlgorithmIdentity::result(double input)
@@ -71,29 +67,16 @@ ConfigDialogPane *GuideAlgorithmIdentity::GetConfigDialogPane(wxWindow *pParent)
return new GuideAlgorithmIdentityConfigDialogPane(pParent, this);
}
-GuideAlgorithmIdentity::
-GuideAlgorithmIdentityConfigDialogPane::
-GuideAlgorithmIdentityConfigDialogPane(wxWindow *pParent, GuideAlgorithmIdentity *pGuideAlgorithm)
+GuideAlgorithmIdentity::GuideAlgorithmIdentityConfigDialogPane::GuideAlgorithmIdentityConfigDialogPane(
+ wxWindow *pParent, GuideAlgorithmIdentity *pGuideAlgorithm)
: ConfigDialogPane(_("Guide Algorithm"), pParent)
{
m_pGuideAlgorithm = pGuideAlgorithm;
- DoAdd(new wxStaticText(pParent, wxID_ANY, _("Nothing to Configure"),wxPoint(-1,-1),wxSize(-1,-1)));
+ DoAdd(new wxStaticText(pParent, wxID_ANY, _("Nothing to Configure"), wxPoint(-1, -1), wxSize(-1, -1)));
}
-GuideAlgorithmIdentity::
-GuideAlgorithmIdentityConfigDialogPane::
-~GuideAlgorithmIdentityConfigDialogPane(void)
-{
-}
+GuideAlgorithmIdentity::GuideAlgorithmIdentityConfigDialogPane::~GuideAlgorithmIdentityConfigDialogPane(void) { }
-void GuideAlgorithmIdentity::
-GuideAlgorithmIdentityConfigDialogPane::
-LoadValues(void)
-{
-}
+void GuideAlgorithmIdentity::GuideAlgorithmIdentityConfigDialogPane::LoadValues(void) { }
-void GuideAlgorithmIdentity::
-GuideAlgorithmIdentityConfigDialogPane::
-UnloadValues(void)
-{
-}
+void GuideAlgorithmIdentity::GuideAlgorithmIdentityConfigDialogPane::UnloadValues(void) { }
diff --git a/src/guide_algorithm_identity.h b/src/guide_algorithm_identity.h
index 06d71f1ae..6050894d2 100644
--- a/src/guide_algorithm_identity.h
+++ b/src/guide_algorithm_identity.h
@@ -46,6 +46,7 @@ class GuideAlgorithmIdentity : public GuideAlgorithm
class GuideAlgorithmIdentityConfigDialogPane : public ConfigDialogPane
{
GuideAlgorithmIdentity *m_pGuideAlgorithm;
+
public:
GuideAlgorithmIdentityConfigDialogPane(wxWindow *pParent, GuideAlgorithmIdentity *pGuideAlgorithm);
~GuideAlgorithmIdentityConfigDialogPane();
diff --git a/src/guide_algorithm_lowpass.cpp b/src/guide_algorithm_lowpass.cpp
index e8f7a8716..b9812207b 100644
--- a/src/guide_algorithm_lowpass.cpp
+++ b/src/guide_algorithm_lowpass.cpp
@@ -1,66 +1,63 @@
/*
-* guide_algorithm_lowpass.cpp
-* PHD Guiding
-*
-* Created by Bret McKee
-* Copyright (c) 2012 Bret McKee
-* All rights reserved.
-*
-* Based upon work by Craig Stark.
-* Copyright (c) 2006-2010 Craig Stark.
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development,
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * guide_algorithm_lowpass.cpp
+ * PHD Guiding
+ *
+ * Created by Bret McKee
+ * Copyright (c) 2012 Bret McKee
+ * All rights reserved.
+ *
+ * Based upon work by Craig Stark.
+ * Copyright (c) 2006-2010 Craig Stark.
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development,
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
-static const double DefaultMinMove = 0.2;
+static const double DefaultMinMove = 0.2;
static const double DefaultSlopeWeight = 5.0;
GuideAlgorithmLowpass::GuideAlgorithmLowpass(Mount *pMount, GuideAxis axis)
: GuideAlgorithm(pMount, axis)
{
- double minMove = pConfig->Profile.GetDouble(GetConfigPath() + "/minMove", DefaultMinMove);
+ double minMove = pConfig->Profile.GetDouble(GetConfigPath() + "/minMove", DefaultMinMove);
SetMinMove(minMove);
double slopeWeight = pConfig->Profile.GetDouble(GetConfigPath() + "/SlopeWeight", DefaultSlopeWeight);
SetSlopeWeight(slopeWeight);
- m_axisStats = WindowedAxisStats(0); // self-managed window
+ m_axisStats = WindowedAxisStats(0); // self-managed window
m_timeBase = 0;
reset();
}
-GuideAlgorithmLowpass::~GuideAlgorithmLowpass(void)
-{
-
-}
+GuideAlgorithmLowpass::~GuideAlgorithmLowpass(void) { }
GUIDE_ALGORITHM GuideAlgorithmLowpass::Algorithm() const
{
@@ -76,7 +73,6 @@ void GuideAlgorithmLowpass::reset(void)
{
m_axisStats.AddGuideInfo(m_timeBase++, 0, 0);
}
-
}
double GuideAlgorithmLowpass::result(double input)
@@ -92,7 +88,8 @@ double GuideAlgorithmLowpass::result(double input)
if (fabs(dReturn) > fabs(input))
{
- Debug.Write(wxString::Format("GuideAlgorithmLowpass::Result() input %.2f is < calculated value %.2f, using input\n", input, dReturn));
+ Debug.Write(wxString::Format(
+ "GuideAlgorithmLowpass::Result() input %.2f is < calculated value %.2f, using input\n", input, dReturn));
dReturn = input;
}
@@ -118,7 +115,6 @@ bool GuideAlgorithmLowpass::SetMinMove(double minMove)
}
m_minMove = minMove;
-
}
catch (const wxString& Msg)
{
@@ -194,10 +190,7 @@ bool GuideAlgorithmLowpass::SetParam(const wxString& name, double val)
wxString GuideAlgorithmLowpass::GetSettingsSummary() const
{
// return a loggable summary of current mount settings
- return wxString::Format("Slope weight = %.3f, Minimum move = %.3f\n",
- GetSlopeWeight(),
- GetMinMove()
- );
+ return wxString::Format("Slope weight = %.3f, Minimum move = %.3f\n", GetSlopeWeight(), GetMinMove());
}
ConfigDialogPane *GuideAlgorithmLowpass::GetConfigDialogPane(wxWindow *pParent)
@@ -205,9 +198,8 @@ ConfigDialogPane *GuideAlgorithmLowpass::GetConfigDialogPane(wxWindow *pParent)
return new GuideAlgorithmLowpassConfigDialogPane(pParent, this);
}
-GuideAlgorithmLowpass::
- GuideAlgorithmLowpassConfigDialogPane::
- GuideAlgorithmLowpassConfigDialogPane(wxWindow *pParent, GuideAlgorithmLowpass *pGuideAlgorithm)
+GuideAlgorithmLowpass::GuideAlgorithmLowpassConfigDialogPane::GuideAlgorithmLowpassConfigDialogPane(
+ wxWindow *pParent, GuideAlgorithmLowpass *pGuideAlgorithm)
: ConfigDialogPane(_("Lowpass Guide Algorithm"), pParent)
{
int width;
@@ -215,54 +207,44 @@ GuideAlgorithmLowpass::
m_pGuideAlgorithm = pGuideAlgorithm;
width = StringWidth(_T("000.00"));
- m_pSlopeWeight = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.5, _T("SlopeWeight"));
+ m_pSlopeWeight = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.5, _T("SlopeWeight"));
m_pSlopeWeight->SetDigits(2);
DoAdd(_("Slope Weight"), m_pSlopeWeight,
wxString::Format(_("Weighting of slope parameter in lowpass auto-dec. Default = %.1f"), DefaultSlopeWeight));
width = StringWidth(_T("000.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(
+ pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
m_pMinMove->SetDigits(2);
DoAdd(_("Minimum Move (pixels)"), m_pMinMove,
wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
- "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"), DefaultMinMove));
-
+ "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"),
+ DefaultMinMove));
}
-GuideAlgorithmLowpass::
- GuideAlgorithmLowpassConfigDialogPane::
- ~GuideAlgorithmLowpassConfigDialogPane(void)
-{
-}
+GuideAlgorithmLowpass::GuideAlgorithmLowpassConfigDialogPane::~GuideAlgorithmLowpassConfigDialogPane(void) { }
-void GuideAlgorithmLowpass::
- GuideAlgorithmLowpassConfigDialogPane::
- LoadValues(void)
+void GuideAlgorithmLowpass::GuideAlgorithmLowpassConfigDialogPane::LoadValues(void)
{
m_pSlopeWeight->SetValue(m_pGuideAlgorithm->GetSlopeWeight());
m_pMinMove->SetValue(m_pGuideAlgorithm->GetMinMove());
}
-void GuideAlgorithmLowpass::
- GuideAlgorithmLowpassConfigDialogPane::
- UnloadValues(void)
+void GuideAlgorithmLowpass::GuideAlgorithmLowpassConfigDialogPane::UnloadValues(void)
{
m_pGuideAlgorithm->SetSlopeWeight(m_pSlopeWeight->GetValue());
m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
}
-void GuideAlgorithmLowpass::
-GuideAlgorithmLowpassConfigDialogPane::OnImageScaleChange()
+void GuideAlgorithmLowpass::GuideAlgorithmLowpassConfigDialogPane::OnImageScaleChange()
{
GuideAlgorithm::AdjustMinMoveSpinCtrl(m_pMinMove);
}
-void GuideAlgorithmLowpass::
-GuideAlgorithmLowpassConfigDialogPane::EnableDecControls(bool enable)
+void GuideAlgorithmLowpass::GuideAlgorithmLowpassConfigDialogPane::EnableDecControls(bool enable)
{
m_pMinMove->Enable(enable);
m_pSlopeWeight->Enable(enable);
@@ -273,9 +255,8 @@ GraphControlPane *GuideAlgorithmLowpass::GetGraphControlPane(wxWindow *pParent,
return new GuideAlgorithmLowpassGraphControlPane(pParent, this, label);
}
-GuideAlgorithmLowpass::
- GuideAlgorithmLowpassGraphControlPane::
- GuideAlgorithmLowpassGraphControlPane(wxWindow *pParent, GuideAlgorithmLowpass *pGuideAlgorithm, const wxString& label)
+GuideAlgorithmLowpass::GuideAlgorithmLowpassGraphControlPane::GuideAlgorithmLowpassGraphControlPane(
+ wxWindow *pParent, GuideAlgorithmLowpass *pGuideAlgorithm, const wxString& label)
: GraphControlPane(pParent, label)
{
int width;
@@ -283,20 +264,25 @@ GuideAlgorithmLowpass::
m_pGuideAlgorithm = pGuideAlgorithm;
width = StringWidth(_T("000.00"));
- m_pSlopeWeight = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.5, _T("SlopeWeight"));
+ m_pSlopeWeight = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.5, _T("SlopeWeight"));
m_pSlopeWeight->SetDigits(2);
- m_pSlopeWeight->SetToolTip(wxString::Format(_("Weighting of slope parameter in lowpass auto-dec. Default = %.1f"), DefaultSlopeWeight));
- m_pSlopeWeight->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, &GuideAlgorithmLowpass::GuideAlgorithmLowpassGraphControlPane::OnSlopeWeightSpinCtrlDouble, this);
+ m_pSlopeWeight->SetToolTip(
+ wxString::Format(_("Weighting of slope parameter in lowpass auto-dec. Default = %.1f"), DefaultSlopeWeight));
+ m_pSlopeWeight->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED,
+ &GuideAlgorithmLowpass::GuideAlgorithmLowpassGraphControlPane::OnSlopeWeightSpinCtrlDouble, this);
DoAdd(m_pSlopeWeight, _("Sl W"));
width = StringWidth(_T("000.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
m_pMinMove->SetDigits(2);
- m_pMinMove->SetToolTip(wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
- "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"), DefaultMinMove));
- m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, &GuideAlgorithmLowpass::GuideAlgorithmLowpassGraphControlPane::OnMinMoveSpinCtrlDouble, this);
+ m_pMinMove->SetToolTip(
+ wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
+ "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"),
+ DefaultMinMove));
+ m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED,
+ &GuideAlgorithmLowpass::GuideAlgorithmLowpassGraphControlPane::OnMinMoveSpinCtrlDouble, this);
DoAdd(m_pMinMove, _("MnMo"));
m_pSlopeWeight->SetValue(m_pGuideAlgorithm->GetSlopeWeight());
@@ -310,30 +296,21 @@ GuideAlgorithmLowpass::
}
}
-GuideAlgorithmLowpass::
- GuideAlgorithmLowpassGraphControlPane::
- ~GuideAlgorithmLowpassGraphControlPane(void)
-{
-}
+GuideAlgorithmLowpass::GuideAlgorithmLowpassGraphControlPane::~GuideAlgorithmLowpassGraphControlPane(void) { }
-void GuideAlgorithmLowpass::
-GuideAlgorithmLowpassGraphControlPane::EnableDecControls(bool enable)
+void GuideAlgorithmLowpass::GuideAlgorithmLowpassGraphControlPane::EnableDecControls(bool enable)
{
m_pSlopeWeight->Enable(enable);
m_pMinMove->Enable(enable);
}
-void GuideAlgorithmLowpass::
- GuideAlgorithmLowpassGraphControlPane::
- OnSlopeWeightSpinCtrlDouble(wxSpinDoubleEvent& evt)
+void GuideAlgorithmLowpass::GuideAlgorithmLowpassGraphControlPane::OnSlopeWeightSpinCtrlDouble(wxSpinDoubleEvent& evt)
{
m_pGuideAlgorithm->SetSlopeWeight(m_pSlopeWeight->GetValue());
pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " Low-pass slope weight", m_pSlopeWeight->GetValue());
}
-void GuideAlgorithmLowpass::
- GuideAlgorithmLowpassGraphControlPane::
- OnMinMoveSpinCtrlDouble(wxSpinDoubleEvent& evt)
+void GuideAlgorithmLowpass::GuideAlgorithmLowpassGraphControlPane::OnMinMoveSpinCtrlDouble(wxSpinDoubleEvent& evt)
{
m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " Low-pass minimum move", m_pMinMove->GetValue());
diff --git a/src/guide_algorithm_lowpass.h b/src/guide_algorithm_lowpass.h
index 57a6e5f6a..9bbb79fbd 100644
--- a/src/guide_algorithm_lowpass.h
+++ b/src/guide_algorithm_lowpass.h
@@ -117,4 +117,3 @@ inline double GuideAlgorithmLowpass::GetSlopeWeight() const
}
#endif /* GUIDE_ALGORITHM_LOWPASS_H_INCLUDED */
-
diff --git a/src/guide_algorithm_lowpass2.cpp b/src/guide_algorithm_lowpass2.cpp
index 0074bce79..9bfe93bc3 100644
--- a/src/guide_algorithm_lowpass2.cpp
+++ b/src/guide_algorithm_lowpass2.cpp
@@ -50,16 +50,13 @@ GuideAlgorithmLowpass2::GuideAlgorithmLowpass2(Mount *pMount, GuideAxis axis)
double aggr = pConfig->Profile.GetDouble(GetConfigPath() + "/Aggressiveness", DefaultAggressiveness);
SetAggressiveness(aggr);
- m_axisStats = WindowedAxisStats(HISTORY_SIZE); // Auto-windowed
+ m_axisStats = WindowedAxisStats(HISTORY_SIZE); // Auto-windowed
m_timeBase = 0;
reset();
}
-GuideAlgorithmLowpass2::~GuideAlgorithmLowpass2(void)
-{
-
-}
+GuideAlgorithmLowpass2::~GuideAlgorithmLowpass2(void) { }
GUIDE_ALGORITHM GuideAlgorithmLowpass2::Algorithm() const
{
@@ -75,17 +72,17 @@ void GuideAlgorithmLowpass2::reset(void)
double GuideAlgorithmLowpass2::result(double input)
{
- m_axisStats.AddGuideInfo(m_timeBase++, input, 0); // AxisStats instance is auto-windowed
+ m_axisStats.AddGuideInfo(m_timeBase++, input, 0); // AxisStats instance is auto-windowed
unsigned int numpts = m_axisStats.GetCount();
double dReturn;
double attenuation = m_aggressiveness / 100.;
double newSlope = 0;
if (numpts < 4)
- dReturn = input * attenuation; // Don't fall behind while we're figuring things out
+ dReturn = input * attenuation; // Don't fall behind while we're figuring things out
else
{
- if (fabs(input) > 4.0 * m_minMove) // Outlier deflection - dump the history
+ if (fabs(input) > 4.0 * m_minMove) // Outlier deflection - dump the history
{
dReturn = input * attenuation;
reset();
@@ -96,19 +93,20 @@ double GuideAlgorithmLowpass2::result(double input)
{
double intcpt;
m_axisStats.GetLinearFitResults(&newSlope, &intcpt);
- dReturn = newSlope * (double)numpts * attenuation;
+ dReturn = newSlope * (double) numpts * attenuation;
// Don't return a result that will push the star further in the wrong direction
if (input * dReturn < 0)
dReturn = 0;
}
}
- if (fabs(dReturn) > fabs(input)) // Keep guide pulses below magnitude of last deflection
+ if (fabs(dReturn) > fabs(input)) // Keep guide pulses below magnitude of last deflection
{
- Debug.Write(wxString::Format("GuideAlgorithmLowpass2::Result() input %.2f is < calculated value %.2f, using input\n", input, dReturn));
+ Debug.Write(wxString::Format(
+ "GuideAlgorithmLowpass2::Result() input %.2f is < calculated value %.2f, using input\n", input, dReturn));
dReturn = input * attenuation;
m_rejects++;
- if (m_rejects > 3) // 3-in-a-row, our slope is not useful
+ if (m_rejects > 3) // 3-in-a-row, our slope is not useful
{
reset();
Debug.Write("Lowpass2 history cleared, 3 successive rejected correction values\n");
@@ -120,7 +118,8 @@ double GuideAlgorithmLowpass2::result(double input)
if (fabs(input) < m_minMove)
dReturn = 0.0;
- Debug.Write(wxString::Format("GuideAlgorithmLowpass2::Result() returns %.2f from input %.2f, slope = %.2f\n", dReturn, input, newSlope));
+ Debug.Write(wxString::Format(
+ "GuideAlgorithmLowpass2::Result() returns %.2f from input %.2f, slope = %.2f\n", dReturn, input, newSlope));
return dReturn;
}
@@ -136,7 +135,6 @@ bool GuideAlgorithmLowpass2::SetMinMove(double minMove)
}
m_minMove = minMove;
-
}
catch (const wxString& Msg)
{
@@ -217,15 +215,11 @@ ConfigDialogPane *GuideAlgorithmLowpass2::GetConfigDialogPane(wxWindow *pParent)
wxString GuideAlgorithmLowpass2::GetSettingsSummary() const
{
// return a loggable summary of current mount settings
- return wxString::Format("Aggressiveness = %.3f, Minimum move = %.3f\n",
- GetAggressiveness(),
- GetMinMove()
- );
+ return wxString::Format("Aggressiveness = %.3f, Minimum move = %.3f\n", GetAggressiveness(), GetMinMove());
}
-GuideAlgorithmLowpass2::
-GuideAlgorithmLowpass2ConfigDialogPane::
-GuideAlgorithmLowpass2ConfigDialogPane(wxWindow *pParent, GuideAlgorithmLowpass2 *pGuideAlgorithm)
+GuideAlgorithmLowpass2::GuideAlgorithmLowpass2ConfigDialogPane::GuideAlgorithmLowpass2ConfigDialogPane(
+ wxWindow *pParent, GuideAlgorithmLowpass2 *pGuideAlgorithm)
: ConfigDialogPane(_("Lowpass2 Guide Algorithm"), pParent)
{
int width;
@@ -235,52 +229,44 @@ GuideAlgorithmLowpass2ConfigDialogPane(wxWindow *pParent, GuideAlgorithmLowpass2
m_pGuideAlgorithm = pGuideAlgorithm;
width = StringWidth(_T("000.00"));
- m_pAggressiveness = pFrame->MakeSpinCtrl(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 100.0, 0.0, _T("Aggressiveness"));
+ m_pAggressiveness = pFrame->MakeSpinCtrl(pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS,
+ 0.0, 100.0, 0.0, _T("Aggressiveness"));
DoAdd(_("Aggressiveness"), m_pAggressiveness,
- wxString::Format(_("What percentage of the computed correction should be applied? Default = %.f%%"), DefaultAggressiveness));
+ wxString::Format(
+ _("What percentage of the computed correction should be applied? Default = %.f%%"), DefaultAggressiveness));
width = StringWidth(_T("000.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(
+ pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
m_pMinMove->SetDigits(2);
DoAdd(_("Minimum Move (pixels)"), m_pMinMove,
wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
- "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"), DefaultMinMove));
+ "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"),
+ DefaultMinMove));
}
-GuideAlgorithmLowpass2::
-GuideAlgorithmLowpass2ConfigDialogPane::
-~GuideAlgorithmLowpass2ConfigDialogPane(void)
-{
-}
+GuideAlgorithmLowpass2::GuideAlgorithmLowpass2ConfigDialogPane::~GuideAlgorithmLowpass2ConfigDialogPane(void) { }
-void GuideAlgorithmLowpass2::
-GuideAlgorithmLowpass2ConfigDialogPane::
-LoadValues(void)
+void GuideAlgorithmLowpass2::GuideAlgorithmLowpass2ConfigDialogPane::LoadValues(void)
{
m_pAggressiveness->SetValue(m_pGuideAlgorithm->GetAggressiveness());
m_pMinMove->SetValue(m_pGuideAlgorithm->GetMinMove());
}
-void GuideAlgorithmLowpass2::
-GuideAlgorithmLowpass2ConfigDialogPane::
-UnloadValues(void)
+void GuideAlgorithmLowpass2::GuideAlgorithmLowpass2ConfigDialogPane::UnloadValues(void)
{
m_pGuideAlgorithm->SetAggressiveness(m_pAggressiveness->GetValue());
m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
}
-void GuideAlgorithmLowpass2::
-GuideAlgorithmLowpass2ConfigDialogPane::OnImageScaleChange()
+void GuideAlgorithmLowpass2::GuideAlgorithmLowpass2ConfigDialogPane::OnImageScaleChange()
{
GuideAlgorithm::AdjustMinMoveSpinCtrl(m_pMinMove);
}
-void GuideAlgorithmLowpass2::
-GuideAlgorithmLowpass2ConfigDialogPane::EnableDecControls(bool enable)
+void GuideAlgorithmLowpass2::GuideAlgorithmLowpass2ConfigDialogPane::EnableDecControls(bool enable)
{
m_pAggressiveness->Enable(enable);
m_pMinMove->Enable(enable);
@@ -291,29 +277,33 @@ GraphControlPane *GuideAlgorithmLowpass2::GetGraphControlPane(wxWindow *pParent,
return new GuideAlgorithmLowpass2GraphControlPane(pParent, this, label);
}
-GuideAlgorithmLowpass2::
-GuideAlgorithmLowpass2GraphControlPane::
-GuideAlgorithmLowpass2GraphControlPane(wxWindow *pParent, GuideAlgorithmLowpass2 *pGuideAlgorithm, const wxString& label)
-: GraphControlPane(pParent, label)
+GuideAlgorithmLowpass2::GuideAlgorithmLowpass2GraphControlPane::GuideAlgorithmLowpass2GraphControlPane(
+ wxWindow *pParent, GuideAlgorithmLowpass2 *pGuideAlgorithm, const wxString& label)
+ : GraphControlPane(pParent, label)
{
int width;
m_pGuideAlgorithm = pGuideAlgorithm;
width = StringWidth(_T("000.00"));
- m_pAggressiveness = pFrame->MakeSpinCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 100.0, 0.0, _T("Aggressiveness"));
- m_pAggressiveness->SetToolTip(wxString::Format(_("What percentage of the computed correction should be applied? Default = %.f%%"), DefaultAggressiveness));
- m_pAggressiveness->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GuideAlgorithmLowpass2::GuideAlgorithmLowpass2GraphControlPane::OnAggrSpinCtrl, this);
+ m_pAggressiveness = pFrame->MakeSpinCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 100.0, 0.0, _T("Aggressiveness"));
+ m_pAggressiveness->SetToolTip(wxString::Format(
+ _("What percentage of the computed correction should be applied? Default = %.f%%"), DefaultAggressiveness));
+ m_pAggressiveness->Bind(
+ wxEVT_COMMAND_SPINCTRL_UPDATED, &GuideAlgorithmLowpass2::GuideAlgorithmLowpass2GraphControlPane::OnAggrSpinCtrl, this);
DoAdd(m_pAggressiveness, _("Agg"));
width = StringWidth(_T("000.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
m_pMinMove->SetDigits(2);
- m_pMinMove->SetToolTip(wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
- "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"), DefaultMinMove));
- m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, &GuideAlgorithmLowpass2::GuideAlgorithmLowpass2GraphControlPane::OnMinMoveSpinCtrlDouble, this);
+ m_pMinMove->SetToolTip(
+ wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
+ "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"),
+ DefaultMinMove));
+ m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED,
+ &GuideAlgorithmLowpass2::GuideAlgorithmLowpass2GraphControlPane::OnMinMoveSpinCtrlDouble, this);
DoAdd(m_pMinMove, _("MnMo"));
m_pAggressiveness->SetValue(m_pGuideAlgorithm->GetAggressiveness());
@@ -327,30 +317,21 @@ GuideAlgorithmLowpass2GraphControlPane(wxWindow *pParent, GuideAlgorithmLowpass2
}
}
-GuideAlgorithmLowpass2::
-GuideAlgorithmLowpass2GraphControlPane::
-~GuideAlgorithmLowpass2GraphControlPane(void)
-{
-}
+GuideAlgorithmLowpass2::GuideAlgorithmLowpass2GraphControlPane::~GuideAlgorithmLowpass2GraphControlPane(void) { }
-void GuideAlgorithmLowpass2::
-GuideAlgorithmLowpass2GraphControlPane::EnableDecControls(bool enable)
+void GuideAlgorithmLowpass2::GuideAlgorithmLowpass2GraphControlPane::EnableDecControls(bool enable)
{
m_pAggressiveness->Enable(enable);
m_pMinMove->Enable(enable);
}
-void GuideAlgorithmLowpass2::
-GuideAlgorithmLowpass2GraphControlPane::
-OnAggrSpinCtrl(wxSpinEvent& evt)
+void GuideAlgorithmLowpass2::GuideAlgorithmLowpass2GraphControlPane::OnAggrSpinCtrl(wxSpinEvent& evt)
{
m_pGuideAlgorithm->SetAggressiveness(m_pAggressiveness->GetValue());
pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " Low-pass2 aggressiveness", m_pAggressiveness->GetValue());
}
-void GuideAlgorithmLowpass2::
-GuideAlgorithmLowpass2GraphControlPane::
-OnMinMoveSpinCtrlDouble(wxSpinDoubleEvent& evt)
+void GuideAlgorithmLowpass2::GuideAlgorithmLowpass2GraphControlPane::OnMinMoveSpinCtrlDouble(wxSpinDoubleEvent& evt)
{
m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " Low-pass2 minimum move", m_pMinMove->GetValue());
diff --git a/src/guide_algorithm_lowpass2.h b/src/guide_algorithm_lowpass2.h
index 4417d5f12..30811c564 100644
--- a/src/guide_algorithm_lowpass2.h
+++ b/src/guide_algorithm_lowpass2.h
@@ -57,6 +57,7 @@ class GuideAlgorithmLowpass2 : public GuideAlgorithm
GuideAlgorithmLowpass2 *m_pGuideAlgorithm;
wxSpinCtrl *m_pAggressiveness;
wxSpinCtrlDouble *m_pMinMove;
+
public:
GuideAlgorithmLowpass2ConfigDialogPane(wxWindow *pParent, GuideAlgorithmLowpass2 *pGuideAlgorithm);
~GuideAlgorithmLowpass2ConfigDialogPane();
@@ -70,7 +71,8 @@ class GuideAlgorithmLowpass2 : public GuideAlgorithm
class GuideAlgorithmLowpass2GraphControlPane : public GraphControlPane
{
public:
- GuideAlgorithmLowpass2GraphControlPane(wxWindow *pParent, GuideAlgorithmLowpass2 *pGuideAlgorithm, const wxString& label);
+ GuideAlgorithmLowpass2GraphControlPane(
+ wxWindow *pParent, GuideAlgorithmLowpass2 *pGuideAlgorithm, const wxString& label);
~GuideAlgorithmLowpass2GraphControlPane();
void EnableDecControls(bool enable) override;
diff --git a/src/guide_algorithm_resistswitch.cpp b/src/guide_algorithm_resistswitch.cpp
index cc1404378..351a45346 100644
--- a/src/guide_algorithm_resistswitch.cpp
+++ b/src/guide_algorithm_resistswitch.cpp
@@ -1,41 +1,41 @@
/*
-* guide_algorithm_resistswitch.cpp
-* PHD Guiding
-*
-* Created by Bret McKee
-* Copyright (c) 2012 Bret McKee
-* All rights reserved.
-*
-* Based upon work by Craig Stark.
-* Copyright (c) 2006-2010 Craig Stark.
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development,
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * guide_algorithm_resistswitch.cpp
+ * PHD Guiding
+ *
+ * Created by Bret McKee
+ * Copyright (c) 2012 Bret McKee
+ * All rights reserved.
+ *
+ * Based upon work by Craig Stark.
+ * Copyright (c) 2006-2010 Craig Stark.
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development,
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
@@ -45,7 +45,7 @@ static const double DefaultAggression = 1.0;
GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitch(Mount *pMount, GuideAxis axis)
: GuideAlgorithm(pMount, axis)
{
- double minMove = pConfig->Profile.GetDouble(GetConfigPath() + "/minMove", DefaultMinMove);
+ double minMove = pConfig->Profile.GetDouble(GetConfigPath() + "/minMove", DefaultMinMove);
SetMinMove(minMove);
double aggr = pConfig->Profile.GetDouble(GetConfigPath() + "/aggression", DefaultAggression);
@@ -57,9 +57,7 @@ GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitch(Mount *pMount, GuideAxis
reset();
}
-GuideAlgorithmResistSwitch::~GuideAlgorithmResistSwitch(void)
-{
-}
+GuideAlgorithmResistSwitch::~GuideAlgorithmResistSwitch(void) { }
GUIDE_ALGORITHM GuideAlgorithmResistSwitch::Algorithm() const
{
@@ -112,7 +110,8 @@ double GuideAlgorithmResistSwitch::result(double input)
double thresh = 3.0 * m_minMove;
if (sign(input) != m_currentSide && fabs(input) > thresh)
{
- Debug.Write(wxString::Format("resist switch: large excursion: input %.2f thresh %.2f direction from %d to %d\n", input, thresh, m_currentSide, sign(input)));
+ Debug.Write(wxString::Format("resist switch: large excursion: input %.2f thresh %.2f direction from %d to %d\n",
+ input, thresh, m_currentSide, sign(input)));
// force switch
m_currentSide = 0;
unsigned int i;
@@ -154,7 +153,8 @@ double GuideAlgorithmResistSwitch::result(double input)
throw THROW_INFO("Not getting worse");
}
- Debug.Write(wxString::Format("switching direction from %d to %d - decHistory=%d oldest=%.2f newest=%.2f\n", m_currentSide, sign(decHistory), decHistory, oldest, newest));
+ Debug.Write(wxString::Format("switching direction from %d to %d - decHistory=%d oldest=%.2f newest=%.2f\n",
+ m_currentSide, sign(decHistory), decHistory, oldest, newest));
m_currentSide = sign(decHistory);
}
@@ -227,7 +227,8 @@ bool GuideAlgorithmResistSwitch::SetAggression(double aggr)
pConfig->Profile.SetDouble(GetConfigPath() + "/aggression", m_aggression);
- Debug.Write(wxString::Format("GuideAlgorithmResistSwitch::SetAggression() returns %d, m_aggression=%.2f\n", bError, m_aggression));
+ Debug.Write(
+ wxString::Format("GuideAlgorithmResistSwitch::SetAggression() returns %d, m_aggression=%.2f\n", bError, m_aggression));
return bError;
}
@@ -268,7 +269,8 @@ bool GuideAlgorithmResistSwitch::SetParam(const wxString& name, double val)
if (name == "minMove")
err = SetMinMove(val);
- else if (name == "fastSwitch") {
+ else if (name == "fastSwitch")
+ {
SetFastSwitchEnabled(val != 0.0);
err = false;
}
@@ -283,8 +285,8 @@ bool GuideAlgorithmResistSwitch::SetParam(const wxString& name, double val)
wxString GuideAlgorithmResistSwitch::GetSettingsSummary() const
{
// return a loggable summary of current mount settings
- return wxString::Format("Minimum move = %.3f Aggression = %.f%% FastSwitch = %s\n",
- GetMinMove(), GetAggression() * 100.0, GetFastSwitchEnabled() ? "enabled" : "disabled");
+ return wxString::Format("Minimum move = %.3f Aggression = %.f%% FastSwitch = %s\n", GetMinMove(), GetAggression() * 100.0,
+ GetFastSwitchEnabled() ? "enabled" : "disabled");
}
ConfigDialogPane *GuideAlgorithmResistSwitch::GetConfigDialogPane(wxWindow *pParent)
@@ -292,9 +294,8 @@ ConfigDialogPane *GuideAlgorithmResistSwitch::GetConfigDialogPane(wxWindow *pPar
return new GuideAlgorithmResistSwitchConfigDialogPane(pParent, this);
}
-GuideAlgorithmResistSwitch::
- GuideAlgorithmResistSwitchConfigDialogPane::
- GuideAlgorithmResistSwitchConfigDialogPane(wxWindow *pParent, GuideAlgorithmResistSwitch *pGuideAlgorithm)
+GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchConfigDialogPane::GuideAlgorithmResistSwitchConfigDialogPane(
+ wxWindow *pParent, GuideAlgorithmResistSwitch *pGuideAlgorithm)
: ConfigDialogPane(_("ResistSwitch Guide Algorithm"), pParent)
{
int width;
@@ -302,56 +303,51 @@ GuideAlgorithmResistSwitch::
m_pGuideAlgorithm = pGuideAlgorithm;
width = StringWidth(_T("000"));
- m_pAggression = pFrame->MakeSpinCtrl(pParent, wxID_ANY, _T(""), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 1.0, 100.0, 100.0, _T("Aggressiveness"));
+ m_pAggression = pFrame->MakeSpinCtrl(pParent, wxID_ANY, _T(""), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 1.0,
+ 100.0, 100.0, _T("Aggressiveness"));
DoAdd(_("Aggressiveness"), m_pAggression,
- wxString::Format(_("What percentage of the computed correction should be applied? Default = %.f%%"), DefaultAggression * 100.0));
+ wxString::Format(
+ _("What percentage of the computed correction should be applied? Default = %.f%%"), DefaultAggression * 100.0));
width = StringWidth(_T("00.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(""), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(
+ pParent, wxID_ANY, _T(""), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
m_pMinMove->SetDigits(2);
DoAdd(_("Minimum Move (pixels)"), m_pMinMove,
wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
- "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"), DefaultMinMove));
+ "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"),
+ DefaultMinMove));
m_pFastSwitch = new wxCheckBox(pParent, wxID_ANY, _("Fast switch for large deflections"));
- DoAdd(m_pFastSwitch, _("Ordinarily the Resist Switch algortithm waits several frames before switching direction. With Fast Switch enabled PHD2 will switch direction immediately if it sees a very large deflection. Enable this option if your mount has a substantial amount of backlash and PHD2 sometimes overcorrects."));
+ DoAdd(m_pFastSwitch,
+ _("Ordinarily the Resist Switch algortithm waits several frames before switching direction. With Fast Switch enabled "
+ "PHD2 will switch direction immediately if it sees a very large deflection. Enable this option if your mount has a "
+ "substantial amount of backlash and PHD2 sometimes overcorrects."));
}
-GuideAlgorithmResistSwitch::
- GuideAlgorithmResistSwitchConfigDialogPane::
- ~GuideAlgorithmResistSwitchConfigDialogPane(void)
-{
-}
+GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchConfigDialogPane::~GuideAlgorithmResistSwitchConfigDialogPane(void) { }
-void GuideAlgorithmResistSwitch::
- GuideAlgorithmResistSwitchConfigDialogPane::
- LoadValues(void)
+void GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchConfigDialogPane::LoadValues(void)
{
m_pMinMove->SetValue(m_pGuideAlgorithm->GetMinMove());
m_pAggression->SetValue(m_pGuideAlgorithm->GetAggression() * 100.0);
m_pFastSwitch->SetValue(m_pGuideAlgorithm->GetFastSwitchEnabled());
}
-void GuideAlgorithmResistSwitch::
- GuideAlgorithmResistSwitchConfigDialogPane::
- UnloadValues(void)
+void GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchConfigDialogPane::UnloadValues(void)
{
m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
m_pGuideAlgorithm->SetAggression(m_pAggression->GetValue() / 100.0);
m_pGuideAlgorithm->SetFastSwitchEnabled(m_pFastSwitch->GetValue());
}
-void GuideAlgorithmResistSwitch::
-GuideAlgorithmResistSwitchConfigDialogPane::OnImageScaleChange()
+void GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchConfigDialogPane::OnImageScaleChange()
{
GuideAlgorithm::AdjustMinMoveSpinCtrl(m_pMinMove);
}
-void GuideAlgorithmResistSwitch::
-GuideAlgorithmResistSwitchConfigDialogPane::EnableDecControls(bool enable)
+void GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchConfigDialogPane::EnableDecControls(bool enable)
{
m_pAggression->Enable(enable);
m_pMinMove->Enable(enable);
@@ -363,9 +359,8 @@ GraphControlPane *GuideAlgorithmResistSwitch::GetGraphControlPane(wxWindow *pPar
return new GuideAlgorithmResistSwitchGraphControlPane(pParent, this, label);
}
-GuideAlgorithmResistSwitch::
- GuideAlgorithmResistSwitchGraphControlPane::
- GuideAlgorithmResistSwitchGraphControlPane(wxWindow *pParent, GuideAlgorithmResistSwitch *pGuideAlgorithm, const wxString& label)
+GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchGraphControlPane::GuideAlgorithmResistSwitchGraphControlPane(
+ wxWindow *pParent, GuideAlgorithmResistSwitch *pGuideAlgorithm, const wxString& label)
: GraphControlPane(pParent, label)
{
int width;
@@ -374,21 +369,26 @@ GuideAlgorithmResistSwitch::
// Aggression
width = StringWidth(_T("000"));
- m_pAggression = pFrame->MakeSpinCtrl(this, wxID_ANY, _T(""), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 1.0, 100.0, 100.0, _T("Aggressiveness"));
- m_pAggression->SetToolTip(wxString::Format(_("What percentage of the computed correction should be applied? Default = %.f%%"), DefaultAggression * 100.0));
- m_pAggression->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchGraphControlPane::OnAggressionSpinCtrl, this);
+ m_pAggression = pFrame->MakeSpinCtrl(
+ this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 1.0, 100.0, 100.0, _T("Aggressiveness"));
+ m_pAggression->SetToolTip(wxString::Format(
+ _("What percentage of the computed correction should be applied? Default = %.f%%"), DefaultAggression * 100.0));
+ m_pAggression->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED,
+ &GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchGraphControlPane::OnAggressionSpinCtrl, this);
DoAdd(m_pAggression, _T("Agr"));
m_pAggression->SetValue(m_pGuideAlgorithm->GetAggression() * 100.0);
// Min move
width = StringWidth(_T("00.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, _T(""), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(
+ this, wxID_ANY, _T(""), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.01, _T("MinMove"));
m_pMinMove->SetDigits(2);
- m_pMinMove->SetToolTip(wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
- "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"), DefaultMinMove));
- m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, &GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchGraphControlPane::OnMinMoveSpinCtrlDouble, this);
+ m_pMinMove->SetToolTip(
+ wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
+ "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"),
+ DefaultMinMove));
+ m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED,
+ &GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchGraphControlPane::OnMinMoveSpinCtrlDouble, this);
DoAdd(m_pMinMove, _("MnMo"));
m_pMinMove->SetValue(m_pGuideAlgorithm->GetMinMove());
@@ -400,30 +400,22 @@ GuideAlgorithmResistSwitch::
}
}
-GuideAlgorithmResistSwitch::
- GuideAlgorithmResistSwitchGraphControlPane::
- ~GuideAlgorithmResistSwitchGraphControlPane(void)
-{
-}
+GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchGraphControlPane::~GuideAlgorithmResistSwitchGraphControlPane(void) { }
-void GuideAlgorithmResistSwitch::
-GuideAlgorithmResistSwitchGraphControlPane::EnableDecControls(bool enable)
+void GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchGraphControlPane::EnableDecControls(bool enable)
{
m_pAggression->Enable(enable);
m_pMinMove->Enable(enable);
}
-void GuideAlgorithmResistSwitch::
- GuideAlgorithmResistSwitchGraphControlPane::
- OnMinMoveSpinCtrlDouble(wxSpinDoubleEvent& WXUNUSED(evt))
+void GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchGraphControlPane::OnMinMoveSpinCtrlDouble(
+ wxSpinDoubleEvent& WXUNUSED(evt))
{
m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " Resist switch minimum move", m_pMinMove->GetValue());
}
-void GuideAlgorithmResistSwitch::
- GuideAlgorithmResistSwitchGraphControlPane::
- OnAggressionSpinCtrl(wxSpinEvent& WXUNUSED(evt))
+void GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitchGraphControlPane::OnAggressionSpinCtrl(wxSpinEvent& WXUNUSED(evt))
{
m_pGuideAlgorithm->SetAggression(m_pAggression->GetValue() / 100.0);
pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " Resist switch aggression", m_pAggression->GetValue());
diff --git a/src/guide_algorithm_resistswitch.h b/src/guide_algorithm_resistswitch.h
index 9eb06772c..3296aa6a2 100644
--- a/src/guide_algorithm_resistswitch.h
+++ b/src/guide_algorithm_resistswitch.h
@@ -48,7 +48,7 @@ class GuideAlgorithmResistSwitch : public GuideAlgorithm
double m_minMove;
double m_aggression;
bool m_fastSwitchEnabled;
- int m_currentSide;
+ int m_currentSide;
protected:
class GuideAlgorithmResistSwitchConfigDialogPane : public ConfigDialogPane
@@ -71,7 +71,8 @@ class GuideAlgorithmResistSwitch : public GuideAlgorithm
class GuideAlgorithmResistSwitchGraphControlPane : public GraphControlPane
{
public:
- GuideAlgorithmResistSwitchGraphControlPane(wxWindow *pParent, GuideAlgorithmResistSwitch *pGuideAlgorithm, const wxString& label);
+ GuideAlgorithmResistSwitchGraphControlPane(
+ wxWindow *pParent, GuideAlgorithmResistSwitch *pGuideAlgorithm, const wxString& label);
~GuideAlgorithmResistSwitchGraphControlPane();
void EnableDecControls(bool enable) override;
diff --git a/src/guide_algorithm_zfilter.cpp b/src/guide_algorithm_zfilter.cpp
index e0fd501cb..afdac07a3 100644
--- a/src/guide_algorithm_zfilter.cpp
+++ b/src/guide_algorithm_zfilter.cpp
@@ -1,44 +1,44 @@
/*
-* guide_algorithm_zfilter.cpp
-* PHD Guiding
-*
-* Created by Ken Self
-* Copyright (c) 2018 Ken Self
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of openphdguiding.org nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * guide_algorithm_zfilter.cpp
+ * PHD Guiding
+ *
+ * Created by Ken Self
+ * Copyright (c) 2018 Ken Self
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of openphdguiding.org nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
static const double DefaultMinMove = 0.1;
static const double DefaultExpFactor = 2.0;
GuideAlgorithmZFilter::GuideAlgorithmZFilter(Mount *pMount, GuideAxis axis)
- : GuideAlgorithm(pMount, axis),
- m_pFactory(nullptr)
+ : GuideAlgorithm(pMount, axis)
+ , m_pFactory(nullptr)
{
m_expFactor = DefaultExpFactor;
m_design = BESSEL;
@@ -72,18 +72,18 @@ void GuideAlgorithmZFilter::reset()
double GuideAlgorithmZFilter::result(double input)
{
- double dReturn=0;
+ double dReturn = 0;
-// Digital filter designed by mkfilter/mkshape/gencode A.J. Fisher
+ // Digital filter designed by mkfilter/mkshape/gencode A.J. Fisher
double gain = m_gain;
-// Shift readings and results
+ // Shift readings and results
m_xv.insert(m_xv.begin(), (input + m_sumCorr) / gain); // Add total guide output to input to get uncorrected waveform
m_xv.pop_back();
m_yv.insert(m_yv.begin(), 0.0);
m_yv.pop_back();
-// Calculate filtered value
+ // Calculate filtered value
for (int i = 0; i < m_xcoeff.size(); i++)
{
m_yv.at(0) += m_xv.at(i) * m_xcoeff.at(i);
@@ -92,7 +92,7 @@ double GuideAlgorithmZFilter::result(double input)
{
m_yv.at(0) += m_yv.at(i) * m_ycoeff.at(i);
}
- dReturn = m_yv.at(0) - m_sumCorr; // Return the difference from the uncorrected waveform
+ dReturn = m_yv.at(0) - m_sumCorr; // Return the difference from the uncorrected waveform
if (fabs(dReturn) < m_minMove)
{
@@ -100,16 +100,17 @@ double GuideAlgorithmZFilter::result(double input)
}
m_sumCorr += dReturn;
-/* wxString msg = "GuideAlgorithmZFilter::m_xv ";
- for (int i = 0; ixcoeffs;
m_ycoeff = m_pFactory->ycoeffs;
- Debug.Write(wxString::Format("GuideAlgorithmZFilter::type=%s order=%d, corner=%lf, gain=%lg\n",
- m_pFactory->getname(), m_order, m_pFactory->corner(), m_gain));
+ Debug.Write(wxString::Format("GuideAlgorithmZFilter::type=%s order=%d, corner=%lf, gain=%lg\n", m_pFactory->getname(),
+ m_order, m_pFactory->corner(), m_gain));
wxString msg = wxString::Format("GuideAlgorithmZFilter::m_xcoeffs:");
for (int it = 0; it < m_xcoeff.size(); it++)
{
@@ -179,7 +179,6 @@ bool GuideAlgorithmZFilter::SetMinMove(double minMove)
}
m_minMove = minMove;
-
}
catch (const wxString& Msg)
{
@@ -206,7 +205,6 @@ bool GuideAlgorithmZFilter::SetExpFactor(double expFactor)
}
m_expFactor = expFactor;
-
}
catch (const wxString& Msg)
{
@@ -258,8 +256,8 @@ bool GuideAlgorithmZFilter::SetParam(const wxString& name, double val)
wxString GuideAlgorithmZFilter::GetSettingsSummary() const
{
// return a loggable summary of current mount settings
- return wxString::Format("Type=%s-%d, Exp-factor=%.1f, Minimum move = %.3f\n",
- m_pFactory->getname(), m_order, m_pFactory->corner() / 4.0, GetMinMove());
+ return wxString::Format("Type=%s-%d, Exp-factor=%.1f, Minimum move = %.3f\n", m_pFactory->getname(), m_order,
+ m_pFactory->corner() / 4.0, GetMinMove());
}
ConfigDialogPane *GuideAlgorithmZFilter::GetConfigDialogPane(wxWindow *pParent)
@@ -267,63 +265,53 @@ ConfigDialogPane *GuideAlgorithmZFilter::GetConfigDialogPane(wxWindow *pParent)
return new GuideAlgorithmZFilterConfigDialogPane(pParent, this);
}
-GuideAlgorithmZFilter::
- GuideAlgorithmZFilterConfigDialogPane::
- GuideAlgorithmZFilterConfigDialogPane(wxWindow *pParent, GuideAlgorithmZFilter *pGuideAlgorithm)
+GuideAlgorithmZFilter::GuideAlgorithmZFilterConfigDialogPane::GuideAlgorithmZFilterConfigDialogPane(
+ wxWindow *pParent, GuideAlgorithmZFilter *pGuideAlgorithm)
: ConfigDialogPane(_("ZFilter Guide Algorithm"), pParent)
{
m_pGuideAlgorithm = pGuideAlgorithm;
int width;
width = StringWidth(_T("00.0"));
- m_pExpFactor = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 1.0, 20.0, 2.0, 1.0, _T("ExpFactor"));
+ m_pExpFactor = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS,
+ 1.0, 20.0, 2.0, 1.0, _T("ExpFactor"));
m_pExpFactor->SetDigits(1);
DoAdd(_("Exposure Factor"), m_pExpFactor,
wxString::Format(_("Multiplied by exposure time gives the equivalent exposure time after filtering. "
- "Default = %.1f"), DefaultExpFactor));
+ "Default = %.1f"),
+ DefaultExpFactor));
width = StringWidth(_T("000.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(pParent, wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.05, _T("MinMove"));
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(
+ pParent, wxID_ANY, _T(" "), wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.05, _T("MinMove"));
m_pMinMove->SetDigits(2);
DoAdd(_("Minimum Move (pixels)"), m_pMinMove,
wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
- "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"), DefaultMinMove));
-
+ "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"),
+ DefaultMinMove));
}
-GuideAlgorithmZFilter::
- GuideAlgorithmZFilterConfigDialogPane::
- ~GuideAlgorithmZFilterConfigDialogPane()
-{
-}
+GuideAlgorithmZFilter::GuideAlgorithmZFilterConfigDialogPane::~GuideAlgorithmZFilterConfigDialogPane() { }
-void GuideAlgorithmZFilter::
- GuideAlgorithmZFilterConfigDialogPane::
- LoadValues()
+void GuideAlgorithmZFilter::GuideAlgorithmZFilterConfigDialogPane::LoadValues()
{
m_pMinMove->SetValue(m_pGuideAlgorithm->GetMinMove());
m_pExpFactor->SetValue(m_pGuideAlgorithm->GetExpFactor());
}
-void GuideAlgorithmZFilter::
- GuideAlgorithmZFilterConfigDialogPane::
- UnloadValues()
+void GuideAlgorithmZFilter::GuideAlgorithmZFilterConfigDialogPane::UnloadValues()
{
m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
m_pGuideAlgorithm->SetExpFactor(m_pExpFactor->GetValue());
}
-void GuideAlgorithmZFilter::
-GuideAlgorithmZFilterConfigDialogPane::OnImageScaleChange()
+void GuideAlgorithmZFilter::GuideAlgorithmZFilterConfigDialogPane::OnImageScaleChange()
{
GuideAlgorithm::AdjustMinMoveSpinCtrl(m_pMinMove);
}
-void GuideAlgorithmZFilter::
-GuideAlgorithmZFilterConfigDialogPane::EnableDecControls(bool enable)
+void GuideAlgorithmZFilter::GuideAlgorithmZFilterConfigDialogPane::EnableDecControls(bool enable)
{
m_pExpFactor->Enable(enable);
m_pMinMove->Enable(enable);
@@ -334,9 +322,8 @@ GraphControlPane *GuideAlgorithmZFilter::GetGraphControlPane(wxWindow *pParent,
return new GuideAlgorithmZFilterGraphControlPane(pParent, this, label);
}
-GuideAlgorithmZFilter::
- GuideAlgorithmZFilterGraphControlPane::
- GuideAlgorithmZFilterGraphControlPane(wxWindow *pParent, GuideAlgorithmZFilter *pGuideAlgorithm, const wxString& label)
+GuideAlgorithmZFilter::GuideAlgorithmZFilterGraphControlPane::GuideAlgorithmZFilterGraphControlPane(
+ wxWindow *pParent, GuideAlgorithmZFilter *pGuideAlgorithm, const wxString& label)
: GraphControlPane(pParent, label)
{
int width;
@@ -344,24 +331,29 @@ GuideAlgorithmZFilter::
m_pGuideAlgorithm = pGuideAlgorithm;
width = StringWidth(_T("00.0"));
- m_pExpFactor = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 1.0, 20.0, 2.0, 1.0, _T("ExpFactor"));
+ m_pExpFactor = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 1.0, 20.0, 2.0, 1.0, _T("ExpFactor"));
m_pExpFactor->SetDigits(1);
m_pExpFactor->SetToolTip(
wxString::Format(_("Multiplied by exposure time gives the equivalent expsoure time after filtering. "
- "Default = %.1f"), DefaultExpFactor));
- m_pExpFactor->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, &GuideAlgorithmZFilter::GuideAlgorithmZFilterGraphControlPane::OnExpFactorSpinCtrlDouble, this);
+ "Default = %.1f"),
+ DefaultExpFactor));
+ m_pExpFactor->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED,
+ &GuideAlgorithmZFilter::GuideAlgorithmZFilterGraphControlPane::OnExpFactorSpinCtrlDouble, this);
DoAdd(m_pExpFactor, _("XFac"));
m_pExpFactor->SetValue(m_pGuideAlgorithm->GetExpFactor());
width = StringWidth(_T("000.00"));
- m_pMinMove = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.05, _T("MinMove"));
+ m_pMinMove = pFrame->MakeSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(width, -1),
+ wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.05, _T("MinMove"));
m_pMinMove->SetDigits(2);
- m_pMinMove->SetToolTip(wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
- "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"), DefaultMinMove));
- m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, &GuideAlgorithmZFilter::GuideAlgorithmZFilterGraphControlPane::OnMinMoveSpinCtrlDouble, this);
+ m_pMinMove->SetToolTip(
+ wxString::Format(_("How many (fractional) pixels must the star move to trigger a guide pulse? \n"
+ "If camera is binned, this is a fraction of the binned pixel size. Default = %.2f"),
+ DefaultMinMove));
+ m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED,
+ &GuideAlgorithmZFilter::GuideAlgorithmZFilterGraphControlPane::OnMinMoveSpinCtrlDouble, this);
DoAdd(m_pMinMove, _("MnMo"));
m_pMinMove->SetValue(m_pGuideAlgorithm->GetMinMove());
@@ -371,33 +363,23 @@ GuideAlgorithmZFilter::
m_pExpFactor->Enable(currDecGuideMode != DEC_NONE);
m_pMinMove->Enable(currDecGuideMode != DEC_NONE);
}
-
}
-GuideAlgorithmZFilter::
- GuideAlgorithmZFilterGraphControlPane::
- ~GuideAlgorithmZFilterGraphControlPane()
-{
-}
+GuideAlgorithmZFilter::GuideAlgorithmZFilterGraphControlPane::~GuideAlgorithmZFilterGraphControlPane() { }
-void GuideAlgorithmZFilter::
-GuideAlgorithmZFilterGraphControlPane::EnableDecControls(bool enable)
+void GuideAlgorithmZFilter::GuideAlgorithmZFilterGraphControlPane::EnableDecControls(bool enable)
{
m_pMinMove->Enable(enable);
m_pExpFactor->Enable(enable);
}
-void GuideAlgorithmZFilter::
-GuideAlgorithmZFilterGraphControlPane::
-OnMinMoveSpinCtrlDouble(wxSpinDoubleEvent& evt)
+void GuideAlgorithmZFilter::GuideAlgorithmZFilterGraphControlPane::OnMinMoveSpinCtrlDouble(wxSpinDoubleEvent& evt)
{
m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " ZFilter minimum move", m_pMinMove->GetValue());
}
-void GuideAlgorithmZFilter::
-GuideAlgorithmZFilterGraphControlPane::
-OnExpFactorSpinCtrlDouble(wxSpinDoubleEvent& evt)
+void GuideAlgorithmZFilter::GuideAlgorithmZFilterGraphControlPane::OnExpFactorSpinCtrlDouble(wxSpinDoubleEvent& evt)
{
m_pGuideAlgorithm->SetExpFactor(m_pExpFactor->GetValue());
pFrame->NotifyGuidingParam(m_pGuideAlgorithm->GetAxis() + " ZFilter exposure factor", m_pExpFactor->GetValue());
diff --git a/src/guide_algorithm_zfilter.h b/src/guide_algorithm_zfilter.h
index bd1444a02..5b050376f 100644
--- a/src/guide_algorithm_zfilter.h
+++ b/src/guide_algorithm_zfilter.h
@@ -40,7 +40,7 @@
class GuideAlgorithmZFilter : public GuideAlgorithm
{
FILTER_DESIGN m_design;
- std::vector m_xv, m_yv; // Historical values up to m_order
+ std::vector m_xv, m_yv; // Historical values up to m_order
std::vector m_xcoeff, m_ycoeff;
int m_order;
double m_gain;
@@ -49,6 +49,7 @@ class GuideAlgorithmZFilter : public GuideAlgorithm
double m_expFactor;
ZFilterFactory *m_pFactory;
+
protected:
class GuideAlgorithmZFilterConfigDialogPane : public ConfigDialogPane
{
diff --git a/src/guide_algorithms.h b/src/guide_algorithms.h
index 15a52aa91..92e3c5557 100644
--- a/src/guide_algorithms.h
+++ b/src/guide_algorithms.h
@@ -42,7 +42,7 @@
enum GUIDE_ALGORITHM
{
- GUIDE_ALGORITHM_NONE=-1,
+ GUIDE_ALGORITHM_NONE = -1,
GUIDE_ALGORITHM_IDENTITY,
GUIDE_ALGORITHM_HYSTERESIS,
GUIDE_ALGORITHM_LOWPASS,
diff --git a/src/guider.cpp b/src/guider.cpp
index 10bb6c5df..7a65b1dba 100644
--- a/src/guider.cpp
+++ b/src/guider.cpp
@@ -39,7 +39,7 @@
#include "guiding_assistant.h"
// un-comment to log star deflections to a file
-//#define CAPTURE_DEFLECTIONS
+// #define CAPTURE_DEFLECTIONS
struct DeflectionLogger
{
@@ -97,8 +97,8 @@ inline void DeflectionLogger::Log(const PHD_Point&) { }
#endif // CAPTURE_DEFLECTIONS
-static const int DefaultOverlayMode = OVERLAY_NONE;
-static const bool DefaultScaleImage = true;
+static const int DefaultOverlayMode = OVERLAY_NONE;
+static const bool DefaultScaleImage = true;
// clang-format off
wxBEGIN_EVENT_TABLE(Guider, wxWindow)
@@ -137,27 +137,37 @@ static void LoadBookmarks(std::vector *vec)
static const wxStringCharType *StateStr(GUIDER_STATE st)
{
- switch (st) {
- case STATE_UNINITIALIZED: return wxS("UNINITIALIZED");
- case STATE_SELECTING: return wxS("SELECTING");
- case STATE_SELECTED: return wxS("SELECTED");
- case STATE_CALIBRATING_PRIMARY: return wxS("CALIBRATING_PRIMARY");
- case STATE_CALIBRATING_SECONDARY: return wxS("CALIBRATING_SECONDARY");
- case STATE_CALIBRATED: return wxS("CALIBRATED");
- case STATE_GUIDING: return wxS("GUIDING");
- case STATE_STOP: return wxS("STOP");
- default: return wxS("??");
+ switch (st)
+ {
+ case STATE_UNINITIALIZED:
+ return wxS("UNINITIALIZED");
+ case STATE_SELECTING:
+ return wxS("SELECTING");
+ case STATE_SELECTED:
+ return wxS("SELECTED");
+ case STATE_CALIBRATING_PRIMARY:
+ return wxS("CALIBRATING_PRIMARY");
+ case STATE_CALIBRATING_SECONDARY:
+ return wxS("CALIBRATING_SECONDARY");
+ case STATE_CALIBRATED:
+ return wxS("CALIBRATED");
+ case STATE_GUIDING:
+ return wxS("GUIDING");
+ case STATE_STOP:
+ return wxS("STOP");
+ default:
+ return wxS("??");
}
}
-Guider::Guider(wxWindow *parent, int xSize, int ySize) :
- wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
+Guider::Guider(wxWindow *parent, int xSize, int ySize)
+ : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
{
m_state = STATE_UNINITIALIZED;
Debug.Write(wxString::Format("guider state => %s\n", StateStr(m_state)));
m_scaleFactor = 1.0;
m_showBookmarks = true;
- m_displayedImage = new wxImage(XWinSize,YWinSize,true);
+ m_displayedImage = new wxImage(XWinSize, YWinSize, true);
m_paused = PAUSE_NONE;
m_starFoundTimestamp = 0;
m_avgDistanceNeedReset = false;
@@ -190,7 +200,7 @@ Guider::Guider(wxWindow *parent, int xSize, int ySize) :
m_polarAlignCircleCorrection = 1.0;
SetBackgroundStyle(wxBG_STYLE_CUSTOM);
- SetBackgroundColour(wxColour((unsigned char) 30, (unsigned char) 30,(unsigned char) 30));
+ SetBackgroundColour(wxColour((unsigned char) 30, (unsigned char) 30, (unsigned char) 30));
s_deflectionLogger.Init();
}
@@ -288,15 +298,15 @@ bool Guider::SetOverlayMode(int overlayMode)
{
switch (overlayMode)
{
- case OVERLAY_NONE:
- case OVERLAY_BULLSEYE:
- case OVERLAY_GRID_FINE:
- case OVERLAY_GRID_COARSE:
- case OVERLAY_RADEC:
- case OVERLAY_SLIT:
- break;
- default:
- throw ERROR_INFO("invalid overlayMode");
+ case OVERLAY_NONE:
+ case OVERLAY_BULLSEYE:
+ case OVERLAY_GRID_FINE:
+ case OVERLAY_GRID_COARSE:
+ case OVERLAY_RADEC:
+ case OVERLAY_SLIT:
+ break;
+ default:
+ throw ERROR_INFO("invalid overlayMode");
}
m_overlayMode = (OVERLAY_MODE) overlayMode;
@@ -348,32 +358,32 @@ void Guider::SetOverlaySlitCoords(const wxPoint& center, const wxSize& size, int
{
if (angle != 0)
{
- double a = -radians((double)angle);
+ double a = -radians((double) angle);
double s = sin(a);
double c = cos(a);
- double cx = (double)center.x;
- double cy = (double)center.y;
+ double cx = (double) center.x;
+ double cy = (double) center.y;
double x, y;
- x = +(double)size.GetWidth() / 2.0;
- y = +(double)size.GetHeight() / 2.0;
- m_overlaySlitCoords.corners[0].x = cx + (int)floor(x * c - y * s);
- m_overlaySlitCoords.corners[0].y = cy + (int)floor(x * s + y * c);
-
- x = -(double)size.GetWidth() / 2.0;
- y = +(double)size.GetHeight() / 2.0;
- m_overlaySlitCoords.corners[1].x = cx + (int)floor(x * c - y * s);
- m_overlaySlitCoords.corners[1].y = cy + (int)floor(x * s + y * c);
-
- x = -(double)size.GetWidth() / 2.0;
- y = -(double)size.GetHeight() / 2.0;
- m_overlaySlitCoords.corners[2].x = cx + (int)floor(x * c - y * s);
- m_overlaySlitCoords.corners[2].y = cy + (int)floor(x * s + y * c);
-
- x = +(double)size.GetWidth() / 2.0;
- y = -(double)size.GetHeight() / 2.0;
- m_overlaySlitCoords.corners[3].x = cx + (int)floor(x * c - y * s);
- m_overlaySlitCoords.corners[3].y = cy + (int)floor(x * s + y * c);
+ x = +(double) size.GetWidth() / 2.0;
+ y = +(double) size.GetHeight() / 2.0;
+ m_overlaySlitCoords.corners[0].x = cx + (int) floor(x * c - y * s);
+ m_overlaySlitCoords.corners[0].y = cy + (int) floor(x * s + y * c);
+
+ x = -(double) size.GetWidth() / 2.0;
+ y = +(double) size.GetHeight() / 2.0;
+ m_overlaySlitCoords.corners[1].x = cx + (int) floor(x * c - y * s);
+ m_overlaySlitCoords.corners[1].y = cy + (int) floor(x * s + y * c);
+
+ x = -(double) size.GetWidth() / 2.0;
+ y = -(double) size.GetHeight() / 2.0;
+ m_overlaySlitCoords.corners[2].x = cx + (int) floor(x * c - y * s);
+ m_overlaySlitCoords.corners[2].y = cy + (int) floor(x * s + y * c);
+
+ x = +(double) size.GetWidth() / 2.0;
+ y = -(double) size.GetHeight() / 2.0;
+ m_overlaySlitCoords.corners[3].x = cx + (int) floor(x * c - y * s);
+ m_overlaySlitCoords.corners[3].y = cy + (int) floor(x * s + y * c);
}
else
{
@@ -446,25 +456,24 @@ bool Guider::PaintHelper(wxAutoBufferedPaintDCBase& dc, wxMemoryDC& memDC)
m_pCurrentImage->CopyToImage(&m_displayedImage, blevel, wlevel, pFrame->Stretch_gamma);
}
- int imageWidth = m_displayedImage->GetWidth();
- int imageHeight = m_displayedImage->GetHeight();
+ int imageWidth = m_displayedImage->GetWidth();
+ int imageHeight = m_displayedImage->GetHeight();
// scale the image if necessary
if (imageWidth != XWinSize || imageHeight != YWinSize)
{
// The image is not the exact right size -- figure out what to do.
- double xScaleFactor = imageWidth / (double)XWinSize;
- double yScaleFactor = imageHeight / (double)YWinSize;
+ double xScaleFactor = imageWidth / (double) XWinSize;
+ double yScaleFactor = imageHeight / (double) YWinSize;
int newWidth = imageWidth;
int newHeight = imageHeight;
- double newScaleFactor = (xScaleFactor > yScaleFactor) ?
- xScaleFactor :
- yScaleFactor;
+ double newScaleFactor = (xScaleFactor > yScaleFactor) ? xScaleFactor : yScaleFactor;
-// Debug.Write(wxString::Format("xScaleFactor=%.2f, yScaleFactor=%.2f, newScaleFactor=%.2f\n", xScaleFactor,
-// yScaleFactor, newScaleFactor));
+ // Debug.Write(wxString::Format("xScaleFactor=%.2f, yScaleFactor=%.2f, newScaleFactor=%.2f\n",
+ // xScaleFactor,
+ // yScaleFactor, newScaleFactor));
// we rescale the image if:
// - The image is either too big
@@ -472,8 +481,7 @@ bool Guider::PaintHelper(wxAutoBufferedPaintDCBase& dc, wxMemoryDC& memDC)
// than half the width of the window or
// - The user has requested rescaling
- if (xScaleFactor > 1.0 || yScaleFactor > 1.0 ||
- xScaleFactor < 0.45 || yScaleFactor < 0.45 || m_scaleImage)
+ if (xScaleFactor > 1.0 || yScaleFactor > 1.0 || xScaleFactor < 0.45 || yScaleFactor < 0.45 || m_scaleImage)
{
newWidth /= newScaleFactor;
@@ -485,7 +493,7 @@ bool Guider::PaintHelper(wxAutoBufferedPaintDCBase& dc, wxMemoryDC& memDC)
if (imageWidth != newWidth || imageHeight != newHeight)
{
-// Debug.Write(wxString::Format("Resizing image to %d,%d\n", newWidth, newHeight));
+ // Debug.Write(wxString::Format("Resizing image to %d,%d\n", newWidth, newHeight));
if (newWidth > 0 && newHeight > 0)
{
@@ -512,144 +520,144 @@ bool Guider::PaintHelper(wxAutoBufferedPaintDCBase& dc, wxMemoryDC& memDC)
if (m_overlayMode)
{
- dc.SetPen(wxPen(wxColor(200,50,50)));
+ dc.SetPen(wxPen(wxColor(200, 50, 50)));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
switch (m_overlayMode)
{
- case OVERLAY_BULLSEYE:
- {
- int cx = XImgSize / 2;
- int cy = YImgSize / 2;
- dc.DrawCircle(cx,cy,25);
- dc.DrawCircle(cx,cy,50);
- dc.DrawCircle(cx,cy,100);
- dc.DrawLine(0, cy, XImgSize, cy);
- dc.DrawLine(cx, 0, cx, YImgSize);
- break;
- }
- case OVERLAY_GRID_FINE:
- case OVERLAY_GRID_COARSE:
- {
- int i;
- int size = (m_overlayMode - 1) * 20;
- for (i=size; iIsCalibrated() ? mount->xAngle() : 0.0;
- double eAngle = wAngle + M_PI;
- GuideParity raParity = mount->RAParity();
- if (raParity == GUIDE_PARITY_ODD)
- {
- // odd parity => West calibration pulses move scope East
- // => star moves West
- // => East vector is opposite direction from X calibration vector (West calibration direction)
- eAngle += M_PI;
- }
- double cos_eangle = cos(eAngle);
- double sin_eangle = sin(eAngle);
- dc.SetPen(wxPen(pFrame->pGraphLog->GetRaOrDxColor(), 2, wxPENSTYLE_DOT));
- dc.DrawLine(ROUND(StarX * m_scaleFactor + r * cos_eangle), ROUND(StarY * m_scaleFactor + r * sin_eangle),
- ROUND(StarX * m_scaleFactor - r * cos_eangle), ROUND(StarY * m_scaleFactor - r * sin_eangle));
- if (raParity != GUIDE_PARITY_UNKNOWN)
- {
- dc.SetTextForeground(pFrame->pGraphLog->GetRaOrDxColor());
- dc.DrawText(_("E"),
- ROUND(StarX * m_scaleFactor + rlabel * cos_eangle) - 4, ROUND(StarY * m_scaleFactor + rlabel * sin_eangle) - 6);
- }
+ double wAngle = mount->IsCalibrated() ? mount->xAngle() : 0.0;
+ double eAngle = wAngle + M_PI;
+ GuideParity raParity = mount->RAParity();
+ if (raParity == GUIDE_PARITY_ODD)
+ {
+ // odd parity => West calibration pulses move scope East
+ // => star moves West
+ // => East vector is opposite direction from X calibration vector (West calibration direction)
+ eAngle += M_PI;
+ }
+ double cos_eangle = cos(eAngle);
+ double sin_eangle = sin(eAngle);
+ dc.SetPen(wxPen(pFrame->pGraphLog->GetRaOrDxColor(), 2, wxPENSTYLE_DOT));
+ dc.DrawLine(ROUND(StarX * m_scaleFactor + r * cos_eangle), ROUND(StarY * m_scaleFactor + r * sin_eangle),
+ ROUND(StarX * m_scaleFactor - r * cos_eangle), ROUND(StarY * m_scaleFactor - r * sin_eangle));
+ if (raParity != GUIDE_PARITY_UNKNOWN)
+ {
+ dc.SetTextForeground(pFrame->pGraphLog->GetRaOrDxColor());
+ dc.DrawText(_("E"), ROUND(StarX * m_scaleFactor + rlabel * cos_eangle) - 4,
+ ROUND(StarY * m_scaleFactor + rlabel * sin_eangle) - 6);
+ }
- double nAngle = mount->IsCalibrated() ? mount->yAngle() : M_PI / 2.0;
- GuideParity decParity = mount->DecParity();
- if (decParity == GUIDE_PARITY_EVEN)
- {
- // even parity => North calibration pulses move scope North
- // => star moves South
- // => North vector is opposite direction from Y calibration vector (North calibration direction)
- nAngle += M_PI;
- }
- double cos_nangle = cos(nAngle);
- double sin_nangle = sin(nAngle);
- dc.SetPen(wxPen(pFrame->pGraphLog->GetDecOrDyColor(), 2, wxPENSTYLE_DOT));
- dc.DrawLine(ROUND(StarX * m_scaleFactor + r * cos_nangle), ROUND(StarY * m_scaleFactor + r * sin_nangle),
- ROUND(StarX * m_scaleFactor - r * cos_nangle), ROUND(StarY * m_scaleFactor - r * sin_nangle));
- if (decParity != GUIDE_PARITY_UNKNOWN)
- {
- dc.SetTextForeground(pFrame->pGraphLog->GetDecOrDyColor());
- dc.DrawText(_("N"),
- ROUND(StarX * m_scaleFactor + rlabel * cos_nangle) - 4, ROUND(StarY * m_scaleFactor + rlabel * sin_nangle) - 6);
- }
+ double nAngle = mount->IsCalibrated() ? mount->yAngle() : M_PI / 2.0;
+ GuideParity decParity = mount->DecParity();
+ if (decParity == GUIDE_PARITY_EVEN)
+ {
+ // even parity => North calibration pulses move scope North
+ // => star moves South
+ // => North vector is opposite direction from Y calibration vector (North calibration direction)
+ nAngle += M_PI;
+ }
+ double cos_nangle = cos(nAngle);
+ double sin_nangle = sin(nAngle);
+ dc.SetPen(wxPen(pFrame->pGraphLog->GetDecOrDyColor(), 2, wxPENSTYLE_DOT));
+ dc.DrawLine(ROUND(StarX * m_scaleFactor + r * cos_nangle), ROUND(StarY * m_scaleFactor + r * sin_nangle),
+ ROUND(StarX * m_scaleFactor - r * cos_nangle), ROUND(StarY * m_scaleFactor - r * sin_nangle));
+ if (decParity != GUIDE_PARITY_UNKNOWN)
+ {
+ dc.SetTextForeground(pFrame->pGraphLog->GetDecOrDyColor());
+ dc.DrawText(_("N"), ROUND(StarX * m_scaleFactor + rlabel * cos_nangle) - 4,
+ ROUND(StarY * m_scaleFactor + rlabel * sin_nangle) - 6);
+ }
- wxGraphicsContext *gc = wxGraphicsContext::Create(dc);
- gc->SetPen(wxPen(pFrame->pGraphLog->GetRaOrDxColor(), 1, wxPENSTYLE_DOT));
- double step = (double) YImgSize / 10.0;
-
- double MidX = (double) XImgSize / 2.0;
- double MidY = (double) YImgSize / 2.0;
- gc->Rotate(eAngle);
- gc->GetTransform().TransformPoint(&MidX, &MidY);
- gc->Rotate(-eAngle);
- gc->Translate((double) XImgSize / 2.0 - MidX, (double) YImgSize / 2.0 - MidY);
- gc->Rotate(eAngle);
- for (int i = -2; i < 12; i++) {
- gc->StrokeLine(0.0,step * (double) i,
- (double) XImgSize, step * (double) i);
- }
+ wxGraphicsContext *gc = wxGraphicsContext::Create(dc);
+ gc->SetPen(wxPen(pFrame->pGraphLog->GetRaOrDxColor(), 1, wxPENSTYLE_DOT));
+ double step = (double) YImgSize / 10.0;
+
+ double MidX = (double) XImgSize / 2.0;
+ double MidY = (double) YImgSize / 2.0;
+ gc->Rotate(eAngle);
+ gc->GetTransform().TransformPoint(&MidX, &MidY);
+ gc->Rotate(-eAngle);
+ gc->Translate((double) XImgSize / 2.0 - MidX, (double) YImgSize / 2.0 - MidY);
+ gc->Rotate(eAngle);
+ for (int i = -2; i < 12; i++)
+ {
+ gc->StrokeLine(0.0, step * (double) i, (double) XImgSize, step * (double) i);
+ }
- MidX = (double) XImgSize / 2.0;
- MidY = (double) YImgSize / 2.0;
- gc->Rotate(-eAngle);
- gc->Rotate(nAngle);
- gc->GetTransform().TransformPoint(&MidX, &MidY);
- gc->Rotate(-nAngle);
- gc->Translate((double) XImgSize / 2.0 - MidX, (double) YImgSize / 2.0 - MidY);
- gc->Rotate(nAngle);
- gc->SetPen(wxPen(pFrame->pGraphLog->GetDecOrDyColor(),1,wxPENSTYLE_DOT));
- for (int i = -2; i < 12; i++) {
- gc->StrokeLine(0.0,step * (double) i,
- (double) XImgSize, step * (double) i);
- }
- delete gc;
+ MidX = (double) XImgSize / 2.0;
+ MidY = (double) YImgSize / 2.0;
+ gc->Rotate(-eAngle);
+ gc->Rotate(nAngle);
+ gc->GetTransform().TransformPoint(&MidX, &MidY);
+ gc->Rotate(-nAngle);
+ gc->Translate((double) XImgSize / 2.0 - MidX, (double) YImgSize / 2.0 - MidY);
+ gc->Rotate(nAngle);
+ gc->SetPen(wxPen(pFrame->pGraphLog->GetDecOrDyColor(), 1, wxPENSTYLE_DOT));
+ for (int i = -2; i < 12; i++)
+ {
+ gc->StrokeLine(0.0, step * (double) i, (double) XImgSize, step * (double) i);
}
- break;
+ delete gc;
}
+ break;
+ }
- case OVERLAY_SLIT:
- if (m_overlaySlitCoords.size.GetWidth() > 0 && m_overlaySlitCoords.size.GetHeight() > 0)
+ case OVERLAY_SLIT:
+ if (m_overlaySlitCoords.size.GetWidth() > 0 && m_overlaySlitCoords.size.GetHeight() > 0)
+ {
+ if (m_scaleFactor == 1.0)
{
- if (m_scaleFactor == 1.0)
- {
- dc.DrawLines(5, m_overlaySlitCoords.corners);
- }
- else
+ dc.DrawLines(5, m_overlaySlitCoords.corners);
+ }
+ else
+ {
+ wxPoint pt[5];
+ for (int i = 0; i < 5; i++)
{
- wxPoint pt[5];
- for (int i = 0; i < 5; i++)
- {
- pt[i].x = (int) floor(m_overlaySlitCoords.corners[i].x * m_scaleFactor);
- pt[i].y = (int) floor(m_overlaySlitCoords.corners[i].y * m_scaleFactor);
- }
- dc.DrawLines(5, pt);
+ pt[i].x = (int) floor(m_overlaySlitCoords.corners[i].x * m_scaleFactor);
+ pt[i].y = (int) floor(m_overlaySlitCoords.corners[i].y * m_scaleFactor);
}
+ dc.DrawLines(5, pt);
}
- break;
+ }
+ break;
- case OVERLAY_NONE:
- break;
+ case OVERLAY_NONE:
+ break;
}
}
@@ -659,7 +667,7 @@ bool Guider::PaintHelper(wxAutoBufferedPaintDCBase& dc, wxMemoryDC& memDC)
for (DefectMap::const_iterator it = m_defectMapPreview->begin(); it != m_defectMapPreview->end(); ++it)
{
const wxPoint& pt = *it;
- dc.DrawPoint((int)(pt.x * m_scaleFactor), (int)(pt.y * m_scaleFactor));
+ dc.DrawPoint((int) (pt.x * m_scaleFactor), (int) (pt.y * m_scaleFactor));
}
}
@@ -671,19 +679,19 @@ bool Guider::PaintHelper(wxAutoBufferedPaintDCBase& dc, wxMemoryDC& memDC)
switch (state)
{
- case STATE_UNINITIALIZED:
- case STATE_SELECTING:
- case STATE_SELECTED:
- case STATE_STOP:
- break;
- case STATE_CALIBRATING_PRIMARY:
- case STATE_CALIBRATING_SECONDARY:
- dc.SetPen(wxPen(wxColor(255,255,0),1, wxPENSTYLE_DOT));
- break;
- case STATE_CALIBRATED:
- case STATE_GUIDING:
- dc.SetPen(wxPen(wxColor(0,255,0)));
- break;
+ case STATE_UNINITIALIZED:
+ case STATE_SELECTING:
+ case STATE_SELECTED:
+ case STATE_STOP:
+ break;
+ case STATE_CALIBRATING_PRIMARY:
+ case STATE_CALIBRATING_SECONDARY:
+ dc.SetPen(wxPen(wxColor(255, 255, 0), 1, wxPENSTYLE_DOT));
+ break;
+ case STATE_CALIBRATED:
+ case STATE_GUIDING:
+ dc.SetPen(wxPen(wxColor(0, 255, 0)));
+ break;
}
dc.DrawLine(0, int(LockY * m_scaleFactor), XImgSize, int(LockY * m_scaleFactor));
@@ -695,10 +703,9 @@ bool Guider::PaintHelper(wxAutoBufferedPaintDCBase& dc, wxMemoryDC& memDC)
{
dc.SetBrush(*wxTRANSPARENT_BRUSH);
wxPenStyle penStyle = m_polarAlignCircleCorrection == 1.0 ? wxPENSTYLE_DOT : wxPENSTYLE_SOLID;
- dc.SetPen(wxPen(wxColor(255,0,255), 1, penStyle));
+ dc.SetPen(wxPen(wxColor(255, 0, 255), 1, penStyle));
int radius = ROUND(m_polarAlignCircleRadius * m_polarAlignCircleCorrection * m_scaleFactor);
- dc.DrawCircle(m_polarAlignCircleCenter.X * m_scaleFactor,
- m_polarAlignCircleCenter.Y * m_scaleFactor, radius);
+ dc.DrawCircle(m_polarAlignCircleCenter.X * m_scaleFactor, m_polarAlignCircleCenter.Y * m_scaleFactor, radius);
}
// draw static polar align stuff
@@ -732,9 +739,10 @@ void Guider::UpdateImageDisplay(usImage *pImage)
pImage = m_pCurrentImage;
}
- Debug.Write(wxString::Format("UpdateImageDisplay: Size=(%d,%d) min=%u, max=%u, med=%u, FiltMin=%u, FiltMax=%u, Gamma=%.3f\n",
- pImage->Size.x, pImage->Size.y, pImage->MinADU, pImage->MaxADU, pImage->MedianADU,
- pImage->FiltMin, pImage->FiltMax, pFrame->Stretch_gamma));
+ Debug.Write(
+ wxString::Format("UpdateImageDisplay: Size=(%d,%d) min=%u, max=%u, med=%u, FiltMin=%u, FiltMax=%u, Gamma=%.3f\n",
+ pImage->Size.x, pImage->Size.y, pImage->MinADU, pImage->MaxADU, pImage->MedianADU, pImage->FiltMin, pImage->FiltMax,
+ pFrame->Stretch_gamma));
Refresh();
Update();
@@ -935,23 +943,23 @@ void Guider::SetState(GUIDER_STATE newState)
// ourselves into a good state to restart looping later
switch (m_state)
{
- case STATE_UNINITIALIZED:
- case STATE_SELECTING:
- case STATE_SELECTED:
- newState = m_state;
- break;
- case STATE_CALIBRATING_PRIMARY:
- case STATE_CALIBRATING_SECONDARY:
- // because we have done some moving here, we need to just
- // start over...
- newState = STATE_UNINITIALIZED;
- break;
- case STATE_CALIBRATED:
- case STATE_GUIDING:
- newState = STATE_SELECTED;
- break;
- case STATE_STOP:
- break;
+ case STATE_UNINITIALIZED:
+ case STATE_SELECTING:
+ case STATE_SELECTED:
+ newState = m_state;
+ break;
+ case STATE_CALIBRATING_PRIMARY:
+ case STATE_CALIBRATING_SECONDARY:
+ // because we have done some moving here, we need to just
+ // start over...
+ newState = STATE_UNINITIALIZED;
+ break;
+ case STATE_CALIBRATED:
+ case STATE_GUIDING:
+ newState = STATE_SELECTED;
+ break;
+ case STATE_STOP:
+ break;
}
}
@@ -967,77 +975,77 @@ void Guider::SetState(GUIDER_STATE newState)
switch (requestedState)
{
- case STATE_UNINITIALIZED:
- InvalidateLockPosition();
- InvalidateCurrentPosition();
- newState = STATE_SELECTING;
- break;
- case STATE_SELECTED:
- break;
- case STATE_CALIBRATING_PRIMARY:
- if (!pMount->IsCalibrated())
- {
- pMount->ResetErrorCount();
- if (pMount->BeginCalibration(CurrentPosition()))
- {
- newState = STATE_UNINITIALIZED;
- Debug.Write(ERROR_INFO("pMount->BeginCalibration failed"));
- }
- else
- {
- GuideLog.StartCalibration(pMount);
- EvtServer.NotifyStartCalibration(pMount);
- }
- break;
- }
- // fall through
- case STATE_CALIBRATING_SECONDARY:
- if (!pSecondaryMount || !pSecondaryMount->IsConnected())
+ case STATE_UNINITIALIZED:
+ InvalidateLockPosition();
+ InvalidateCurrentPosition();
+ newState = STATE_SELECTING;
+ break;
+ case STATE_SELECTED:
+ break;
+ case STATE_CALIBRATING_PRIMARY:
+ if (!pMount->IsCalibrated())
+ {
+ pMount->ResetErrorCount();
+ if (pMount->BeginCalibration(CurrentPosition()))
{
- newState = STATE_CALIBRATED;
+ newState = STATE_UNINITIALIZED;
+ Debug.Write(ERROR_INFO("pMount->BeginCalibration failed"));
}
- else if (!pSecondaryMount->IsCalibrated())
+ else
{
- pSecondaryMount->ResetErrorCount();
- if (pSecondaryMount->BeginCalibration(CurrentPosition()))
- {
- newState = STATE_UNINITIALIZED;
- Debug.Write(ERROR_INFO("pSecondaryMount->BeginCalibration failed"));
- }
- else
- {
- GuideLog.StartCalibration(pSecondaryMount);
- EvtServer.NotifyStartCalibration(pSecondaryMount);
- }
+ GuideLog.StartCalibration(pMount);
+ EvtServer.NotifyStartCalibration(pMount);
}
break;
- case STATE_GUIDING:
- assert(pMount);
-
- m_ditherRecenterRemaining.Invalidate(); // reset dither fast recenter state
-
- pMount->AdjustCalibrationForScopePointing();
- if (pSecondaryMount)
- {
- pSecondaryMount->AdjustCalibrationForScopePointing();
- }
-
- pFrame->UpdateStatusBarCalibrationStatus();
-
- if (m_lockPosition.IsValid() && m_lockPosIsSticky)
+ }
+ // fall through
+ case STATE_CALIBRATING_SECONDARY:
+ if (!pSecondaryMount || !pSecondaryMount->IsConnected())
+ {
+ newState = STATE_CALIBRATED;
+ }
+ else if (!pSecondaryMount->IsCalibrated())
+ {
+ pSecondaryMount->ResetErrorCount();
+ if (pSecondaryMount->BeginCalibration(CurrentPosition()))
{
- Debug.Write("keeping sticky lock position\n");
+ newState = STATE_UNINITIALIZED;
+ Debug.Write(ERROR_INFO("pSecondaryMount->BeginCalibration failed"));
}
else
{
- SetLockPosition(CurrentPosition());
+ GuideLog.StartCalibration(pSecondaryMount);
+ EvtServer.NotifyStartCalibration(pSecondaryMount);
}
- break;
+ }
+ break;
+ case STATE_GUIDING:
+ assert(pMount);
- case STATE_SELECTING:
- case STATE_CALIBRATED:
- case STATE_STOP:
- break;
+ m_ditherRecenterRemaining.Invalidate(); // reset dither fast recenter state
+
+ pMount->AdjustCalibrationForScopePointing();
+ if (pSecondaryMount)
+ {
+ pSecondaryMount->AdjustCalibrationForScopePointing();
+ }
+
+ pFrame->UpdateStatusBarCalibrationStatus();
+
+ if (m_lockPosition.IsValid() && m_lockPosIsSticky)
+ {
+ Debug.Write("keeping sticky lock position\n");
+ }
+ else
+ {
+ SetLockPosition(CurrentPosition());
+ }
+ break;
+
+ case STATE_SELECTING:
+ case STATE_CALIBRATED:
+ case STATE_STOP:
+ break;
}
if (newState >= requestedState)
@@ -1078,7 +1086,8 @@ void Guider::UpdateCurrentDistance(double distance, double distanceRA)
}
else
{
- static double const alpha_long = .045; // heavy smoothing, low weighting for latest sample .045 => 15 frame half-life
+ static double const alpha_long =
+ .045; // heavy smoothing, low weighting for latest sample .045 => 15 frame half-life
m_avgDistanceLong += alpha_long * (distance - m_avgDistanceLong);
m_avgDistanceLongRA += alpha_long * (distanceRA - m_avgDistanceLongRA);
}
@@ -1103,7 +1112,10 @@ void Guider::UpdateCurrentDistance(double distance, double distanceRA)
inline static double CurrentError(time_t starFoundTimestamp, double avgDist)
{
- enum { THRESHOLD_SECONDS = 20 };
+ enum
+ {
+ THRESHOLD_SECONDS = 20
+ };
static double const LARGE_DISTANCE = 100.0;
if (!starFoundTimestamp)
@@ -1142,29 +1154,29 @@ void Guider::StopGuiding()
// first, send a notification that we stopped
switch (m_state)
{
- case STATE_UNINITIALIZED:
- case STATE_SELECTING:
- case STATE_SELECTED:
- break;
- case STATE_CALIBRATING_PRIMARY:
- case STATE_CALIBRATING_SECONDARY:
- case STATE_CALIBRATED:
- EvtServer.NotifyCalibrationFailed(m_state == STATE_CALIBRATING_SECONDARY ? pSecondaryMount : pMount,
- _("Calibration manually stopped"));
- // fall through to notify guiding stopped
- case STATE_GUIDING:
- if ((!pMount || !pMount->IsBusy()) && (!pSecondaryMount || !pSecondaryMount->IsBusy()))
- {
- // Notify guiding stopped if there are no outstanding guide steps. The Guiding
- // Stopped notification must come after the final GuideStep notification otherwise
- // event server clients and the guide log will show the guide step happening after
- // guiding stopped.
+ case STATE_UNINITIALIZED:
+ case STATE_SELECTING:
+ case STATE_SELECTED:
+ break;
+ case STATE_CALIBRATING_PRIMARY:
+ case STATE_CALIBRATING_SECONDARY:
+ case STATE_CALIBRATED:
+ EvtServer.NotifyCalibrationFailed(
+ m_state == STATE_CALIBRATING_SECONDARY ? pSecondaryMount : pMount, _("Calibration manually stopped"));
+ // fall through to notify guiding stopped
+ case STATE_GUIDING:
+ if ((!pMount || !pMount->IsBusy()) && (!pSecondaryMount || !pSecondaryMount->IsBusy()))
+ {
+ // Notify guiding stopped if there are no outstanding guide steps. The Guiding
+ // Stopped notification must come after the final GuideStep notification otherwise
+ // event server clients and the guide log will show the guide step happening after
+ // guiding stopped.
- pFrame->NotifyGuidingStopped();
- }
- break;
- case STATE_STOP:
- break;
+ pFrame->NotifyGuidingStopped();
+ }
+ break;
+ case STATE_STOP:
+ break;
}
SetState(STATE_STOP);
@@ -1204,7 +1216,8 @@ static void CheckCalibrationAutoLoad()
if (!alreadyAsked)
{
- wxString msg = wxString::Format(_("Do you want to automatically restore this calibration whenever the profile is used?"));
+ wxString msg =
+ wxString::Format(_("Do you want to automatically restore this calibration whenever the profile is used?"));
pFrame->Alert(msg, 0, "Auto-restore", &SetAutoLoad, 0, false, 0);
pConfig->Profile.SetBoolean("/AlreadyAskedCalibAutoload", true);
}
@@ -1225,8 +1238,7 @@ void Guider::DisplayImage(usImage *img)
UpdateImageDisplay();
}
-inline static bool
-IsLoopingState(GUIDER_STATE state)
+inline static bool IsLoopingState(GUIDER_STATE state)
{
// returns true for looping, but non-guiding states
switch (state)
@@ -1299,7 +1311,7 @@ void Guider::UpdateGuideState(usImage *pImage, bool bStopping)
GuiderOffset ofs;
FrameDroppedInfo info;
- if (UpdateCurrentPosition(pImage, &ofs, &info)) // true means error
+ if (UpdateCurrentPosition(pImage, &ofs, &info)) // true means error
{
info.frameNumber = pImage->FrameNum;
info.time = pFrame->TimeSinceGuidingStarted();
@@ -1307,51 +1319,51 @@ void Guider::UpdateGuideState(usImage *pImage, bool bStopping)
switch (m_state)
{
- case STATE_UNINITIALIZED:
- case STATE_SELECTING:
- EvtServer.NotifyLooping(pImage->FrameNum, nullptr, &info);
- break;
- case STATE_SELECTED:
- // we had a current position and lost it
- EvtServer.NotifyLooping(pImage->FrameNum, nullptr, &info);
- if (!m_ignoreLostStarLooping)
- {
- SetState(STATE_UNINITIALIZED);
- EvtServer.NotifyStarLost(info);
- }
- StaticPaTool::NotifyStarLost();
- break;
- case STATE_CALIBRATING_PRIMARY:
- case STATE_CALIBRATING_SECONDARY:
- GuideLog.CalibrationFrameDropped(info);
- Debug.Write("Star lost during calibration... blundering on\n");
- EvtServer.NotifyStarLost(info);
- pFrame->StatusMsg(_("star lost"));
- break;
- case STATE_GUIDING:
+ case STATE_UNINITIALIZED:
+ case STATE_SELECTING:
+ EvtServer.NotifyLooping(pImage->FrameNum, nullptr, &info);
+ break;
+ case STATE_SELECTED:
+ // we had a current position and lost it
+ EvtServer.NotifyLooping(pImage->FrameNum, nullptr, &info);
+ if (!m_ignoreLostStarLooping)
{
- GuideLog.FrameDropped(info);
+ SetState(STATE_UNINITIALIZED);
EvtServer.NotifyStarLost(info);
- GuidingAssistant::NotifyFrameDropped(info);
- pFrame->pGraphLog->AppendData(info);
-
- // allow guide algorithms to attempt dead reckoning
- static GuiderOffset ZERO_OFS;
- pFrame->SchedulePrimaryMove(pMount, ZERO_OFS, MOVEOPTS_DEDUCED_MOVE);
-
- wxColor prevColor = GetBackgroundColour();
- SetBackgroundColour(wxColour(64,0,0));
- ClearBackground();
- if (pFrame->GetBeepForLostStar())
- wxBell();
- wxMilliSleep(100);
- SetBackgroundColour(prevColor);
- break;
}
+ StaticPaTool::NotifyStarLost();
+ break;
+ case STATE_CALIBRATING_PRIMARY:
+ case STATE_CALIBRATING_SECONDARY:
+ GuideLog.CalibrationFrameDropped(info);
+ Debug.Write("Star lost during calibration... blundering on\n");
+ EvtServer.NotifyStarLost(info);
+ pFrame->StatusMsg(_("star lost"));
+ break;
+ case STATE_GUIDING:
+ {
+ GuideLog.FrameDropped(info);
+ EvtServer.NotifyStarLost(info);
+ GuidingAssistant::NotifyFrameDropped(info);
+ pFrame->pGraphLog->AppendData(info);
- case STATE_CALIBRATED:
- case STATE_STOP:
- break;
+ // allow guide algorithms to attempt dead reckoning
+ static GuiderOffset ZERO_OFS;
+ pFrame->SchedulePrimaryMove(pMount, ZERO_OFS, MOVEOPTS_DEDUCED_MOVE);
+
+ wxColor prevColor = GetBackgroundColour();
+ SetBackgroundColour(wxColour(64, 0, 0));
+ ClearBackground();
+ if (pFrame->GetBeepForLostStar())
+ wxBell();
+ wxMilliSleep(100);
+ SetBackgroundColour(prevColor);
+ break;
+ }
+
+ case STATE_CALIBRATED:
+ case STATE_STOP:
+ break;
}
statusMessage = info.status;
@@ -1385,137 +1397,136 @@ void Guider::UpdateGuideState(usImage *pImage, bool bStopping)
switch (m_state)
{
- case STATE_SELECTING:
- assert(CurrentPosition().IsValid());
- SetLockPosition(CurrentPosition());
- Debug.Write("CurrentPosition() valid, moving to STATE_SELECTED\n");
- EvtServer.NotifyStarSelected(CurrentPosition());
- SetState(STATE_SELECTED);
- break;
- case STATE_SELECTED:
- if (!StaticPaTool::UpdateState())
+ case STATE_SELECTING:
+ assert(CurrentPosition().IsValid());
+ SetLockPosition(CurrentPosition());
+ Debug.Write("CurrentPosition() valid, moving to STATE_SELECTED\n");
+ EvtServer.NotifyStarSelected(CurrentPosition());
+ SetState(STATE_SELECTED);
+ break;
+ case STATE_SELECTED:
+ if (!StaticPaTool::UpdateState())
+ {
+ SetState(STATE_UNINITIALIZED);
+ statusMessage = _("Static PA rotation failed");
+ throw ERROR_INFO("Static PA rotation failed");
+ }
+ if (!PolarDriftTool::UpdateState())
+ {
+ SetState(STATE_UNINITIALIZED);
+ statusMessage = _("Polar Drift PA drift failed");
+ throw ERROR_INFO("Polar Drift PA drift failed");
+ }
+ break;
+ case STATE_CALIBRATING_PRIMARY:
+ if (!pMount->IsCalibrated())
+ {
+ if (pMount->UpdateCalibrationState(CurrentPosition()))
{
SetState(STATE_UNINITIALIZED);
- statusMessage = _("Static PA rotation failed");
- throw ERROR_INFO("Static PA rotation failed");
+ statusMessage = pMount->IsStepGuider() ? _("AO calibration failed") : _("calibration failed");
+ throw ERROR_INFO("Calibration failed");
}
- if (!PolarDriftTool::UpdateState())
+
+ if (!pMount->IsCalibrated())
{
- SetState(STATE_UNINITIALIZED);
- statusMessage = _("Polar Drift PA drift failed");
- throw ERROR_INFO("Polar Drift PA drift failed");
+ break;
}
+ }
+
+ SetState(STATE_CALIBRATING_SECONDARY);
+
+ if (m_state == STATE_CALIBRATING_SECONDARY)
+ {
+ // if we really have a secondary mount, and it isn't calibrated,
+ // we need to take another exposure before falling into the code
+ // below. If we don't have one, or it is calibrated, we can fall
+ // through. If we don't fall through, we end up displaying a frame
+ // which has the lockpoint in the wrong place, and while I thought I
+ // could live with it when I originally wrote the code, it bothered
+ // me so I did this. Ick.
break;
- case STATE_CALIBRATING_PRIMARY:
- if (!pMount->IsCalibrated())
+ }
+
+ // Fall through
+ case STATE_CALIBRATING_SECONDARY:
+ if (pSecondaryMount && pSecondaryMount->IsConnected())
+ {
+ if (!pSecondaryMount->IsCalibrated())
{
- if (pMount->UpdateCalibrationState(CurrentPosition()))
+ if (pSecondaryMount->UpdateCalibrationState(CurrentPosition()))
{
SetState(STATE_UNINITIALIZED);
- statusMessage = pMount->IsStepGuider() ? _("AO calibration failed") : _("calibration failed");
+ statusMessage = _("calibration failed");
throw ERROR_INFO("Calibration failed");
}
-
- if (!pMount->IsCalibrated())
- {
- break;
- }
}
- SetState(STATE_CALIBRATING_SECONDARY);
-
- if (m_state == STATE_CALIBRATING_SECONDARY)
+ if (!pSecondaryMount->IsCalibrated())
{
- // if we really have a secondary mount, and it isn't calibrated,
- // we need to take another exposure before falling into the code
- // below. If we don't have one, or it is calibrated, we can fall
- // through. If we don't fall through, we end up displaying a frame
- // which has the lockpoint in the wrong place, and while I thought I
- // could live with it when I originally wrote the code, it bothered
- // me so I did this. Ick.
break;
}
+ }
+ assert(!pSecondaryMount || !pSecondaryMount->IsConnected() || pSecondaryMount->IsCalibrated());
- // Fall through
- case STATE_CALIBRATING_SECONDARY:
- if (pSecondaryMount && pSecondaryMount->IsConnected())
- {
- if (!pSecondaryMount->IsCalibrated())
- {
- if (pSecondaryMount->UpdateCalibrationState(CurrentPosition()))
- {
- SetState(STATE_UNINITIALIZED);
- statusMessage = _("calibration failed");
- throw ERROR_INFO("Calibration failed");
- }
- }
-
- if (!pSecondaryMount->IsCalibrated())
- {
- break;
- }
- }
- assert(!pSecondaryMount || !pSecondaryMount->IsConnected() || pSecondaryMount->IsCalibrated());
-
- SetState(STATE_CALIBRATED);
- // fall through
- case STATE_CALIBRATED:
- assert(m_state == STATE_CALIBRATED);
- SetState(STATE_GUIDING);
-
- pFrame->NotifyGuidingStarted();
+ SetState(STATE_CALIBRATED);
+ // fall through
+ case STATE_CALIBRATED:
+ assert(m_state == STATE_CALIBRATED);
+ SetState(STATE_GUIDING);
- // camera angle is known, so ok to calculate shift rate camera coords
- UpdateLockPosShiftCameraCoords();
- if (LockPosShiftEnabled())
- GuideLog.NotifyLockShiftParams(m_lockPosShift, m_lockPosition.ShiftRate());
+ pFrame->NotifyGuidingStarted();
- CheckCalibrationAutoLoad();
- break;
- case STATE_GUIDING:
- if (m_ditherRecenterRemaining.IsValid())
- {
- // fast recenter after dither taking large steps and bypassing
- // guide algorithms
+ // camera angle is known, so ok to calculate shift rate camera coords
+ UpdateLockPosShiftCameraCoords();
+ if (LockPosShiftEnabled())
+ GuideLog.NotifyLockShiftParams(m_lockPosShift, m_lockPosition.ShiftRate());
- PHD_Point step(wxMin(m_ditherRecenterRemaining.X, m_ditherRecenterStep.X),
- wxMin(m_ditherRecenterRemaining.Y, m_ditherRecenterStep.Y));
+ CheckCalibrationAutoLoad();
+ break;
+ case STATE_GUIDING:
+ if (m_ditherRecenterRemaining.IsValid())
+ {
+ // fast recenter after dither taking large steps and bypassing
+ // guide algorithms
- Debug.Write(wxString::Format("dither recenter: remaining=(%.1f,%.1f) step=(%.1f,%.1f)\n",
- m_ditherRecenterRemaining.X * m_ditherRecenterDir.x,
- m_ditherRecenterRemaining.Y * m_ditherRecenterDir.y,
- step.X * m_ditherRecenterDir.x, step.Y * m_ditherRecenterDir.y));
+ PHD_Point step(wxMin(m_ditherRecenterRemaining.X, m_ditherRecenterStep.X),
+ wxMin(m_ditherRecenterRemaining.Y, m_ditherRecenterStep.Y));
- m_ditherRecenterRemaining -= step;
- if (m_ditherRecenterRemaining.X < 0.5 && m_ditherRecenterRemaining.Y < 0.5)
- {
- // fast recenter is done
- m_ditherRecenterRemaining.Invalidate();
- // reset distance tracker
- m_avgDistanceNeedReset = true;
- }
+ Debug.Write(wxString::Format("dither recenter: remaining=(%.1f,%.1f) step=(%.1f,%.1f)\n",
+ m_ditherRecenterRemaining.X * m_ditherRecenterDir.x, m_ditherRecenterRemaining.Y * m_ditherRecenterDir.y,
+ step.X * m_ditherRecenterDir.x, step.Y * m_ditherRecenterDir.y));
- ofs.mountOfs.SetXY(step.X * m_ditherRecenterDir.x, step.Y * m_ditherRecenterDir.y);
- pMount->TransformMountCoordinatesToCameraCoordinates(ofs.mountOfs, ofs.cameraOfs);
- pFrame->SchedulePrimaryMove(pMount, ofs, MOVEOPTS_RECOVERY_MOVE);
- // let guide algorithms know about the direct move
- pMount->NotifyDirectMove(ofs.mountOfs);
- }
- else if (m_measurementMode)
- {
- GuidingAssistant::NotifyBacklashStep(CurrentPosition());
- }
- else
+ m_ditherRecenterRemaining -= step;
+ if (m_ditherRecenterRemaining.X < 0.5 && m_ditherRecenterRemaining.Y < 0.5)
{
- // ordinary guide step
- s_deflectionLogger.Log(CurrentPosition());
- pFrame->SchedulePrimaryMove(pMount, ofs, MOVEOPTS_GUIDE_STEP);
+ // fast recenter is done
+ m_ditherRecenterRemaining.Invalidate();
+ // reset distance tracker
+ m_avgDistanceNeedReset = true;
}
- break;
- case STATE_UNINITIALIZED:
- case STATE_STOP:
- break;
+ ofs.mountOfs.SetXY(step.X * m_ditherRecenterDir.x, step.Y * m_ditherRecenterDir.y);
+ pMount->TransformMountCoordinatesToCameraCoordinates(ofs.mountOfs, ofs.cameraOfs);
+ pFrame->SchedulePrimaryMove(pMount, ofs, MOVEOPTS_RECOVERY_MOVE);
+ // let guide algorithms know about the direct move
+ pMount->NotifyDirectMove(ofs.mountOfs);
+ }
+ else if (m_measurementMode)
+ {
+ GuidingAssistant::NotifyBacklashStep(CurrentPosition());
+ }
+ else
+ {
+ // ordinary guide step
+ s_deflectionLogger.Log(CurrentPosition());
+ pFrame->SchedulePrimaryMove(pMount, ofs, MOVEOPTS_GUIDE_STEP);
+ }
+ break;
+
+ case STATE_UNINITIALIZED:
+ case STATE_STOP:
+ break;
}
}
catch (const wxString& Msg)
@@ -1547,15 +1558,14 @@ bool Guider::ShiftLockPosition()
{
m_lockPosition.UpdateShift();
bool isValid = IsValidLockPosition(m_lockPosition);
- Debug.Write(wxString::Format("ShiftLockPos: new pos = %.2f, %.2f valid=%d\n",
- m_lockPosition.X, m_lockPosition.Y, isValid));
+ Debug.Write(wxString::Format("ShiftLockPos: new pos = %.2f, %.2f valid=%d\n", m_lockPosition.X, m_lockPosition.Y, isValid));
return !isValid;
}
void Guider::SetLockPosShiftRate(const PHD_Point& rate, GRAPH_UNITS units, bool isMountCoords, bool updateToolWin)
{
- Debug.Write(wxString::Format("SetLockPosShiftRate: rate = %.2f,%.2f units = %d isMountCoords = %d\n",
- rate.X, rate.Y, units, isMountCoords));
+ Debug.Write(wxString::Format(
+ "SetLockPosShiftRate: rate = %.2f,%.2f units = %d isMountCoords = %d\n", rate.X, rate.Y, units, isMountCoords));
m_lockPosShift.shiftRate = rate;
m_lockPosShift.shiftUnits = units;
@@ -1608,8 +1618,8 @@ void Guider::UpdateLockPosShiftCameraCoords()
{
PHD_Point radec_rates = m_lockPosShift.shiftRate;
- Debug.Write(wxString::Format("UpdateLockPosShiftCameraCoords: shift rate mount coords = %.2f,%.2f\n",
- radec_rates.X, radec_rates.Y));
+ Debug.Write(wxString::Format(
+ "UpdateLockPosShiftCameraCoords: shift rate mount coords = %.2f,%.2f\n", radec_rates.X, radec_rates.Y));
Mount *scope = TheScope();
if (scope)
@@ -1628,7 +1638,8 @@ void Guider::UpdateLockPosShiftCameraCoords()
if (decParity == GUIDE_PARITY_ODD)
radec_rates.Y = -radec_rates.Y;
- Debug.Write(wxString::Format("UpdateLockPosShiftCameraCoords: after parity adjustment: %.2f,%.2f\n", radec_rates.X, radec_rates.Y));
+ Debug.Write(wxString::Format(
+ "UpdateLockPosShiftCameraCoords: after parity adjustment: %.2f,%.2f\n", radec_rates.X, radec_rates.Y));
}
// account for scope declination
@@ -1638,7 +1649,8 @@ void Guider::UpdateLockPosShiftCameraCoords()
if (dec != UNKNOWN_DECLINATION)
{
radec_rates.X *= cos(dec);
- Debug.Write(wxString::Format("UpdateLockPosShiftCameraCoords: RA shift rate adjusted for declination %.1f\n", degrees(dec)));
+ Debug.Write(wxString::Format(
+ "UpdateLockPosShiftCameraCoords: RA shift rate adjusted for declination %.1f\n", degrees(dec)));
}
}
}
@@ -1651,18 +1663,17 @@ void Guider::UpdateLockPosShiftCameraCoords()
rate = m_lockPosShift.shiftRate;
}
- Debug.Write(wxString::Format("UpdateLockPosShiftCameraCoords: shift rate camera coords = %.2f,%.2f %s/hr\n",
- rate.X, rate.Y, m_lockPosShift.shiftUnits == UNIT_ARCSEC ? "arcsec" : "pixels"));
+ Debug.Write(wxString::Format("UpdateLockPosShiftCameraCoords: shift rate camera coords = %.2f,%.2f %s/hr\n", rate.X, rate.Y,
+ m_lockPosShift.shiftUnits == UNIT_ARCSEC ? "arcsec" : "pixels"));
// convert arc-seconds to pixels
if (m_lockPosShift.shiftUnits == UNIT_ARCSEC)
{
rate /= pFrame->GetCameraPixelScale();
}
- rate /= 3600.0; // per hour => per second
+ rate /= 3600.0; // per hour => per second
- Debug.Write(wxString::Format("UpdateLockPosShiftCameraCoords: shift rate %.2g,%.2g px/sec\n",
- rate.X, rate.Y));
+ Debug.Write(wxString::Format("UpdateLockPosShiftCameraCoords: shift rate %.2g,%.2g px/sec\n", rate.X, rate.Y));
m_lockPosition.SetShiftRate(rate.X, rate.Y);
}
@@ -1679,7 +1690,7 @@ Guider::GuiderConfigDialogPane *Guider::GetConfigDialogPane(wxWindow *pParent)
}
Guider::GuiderConfigDialogPane::GuiderConfigDialogPane(wxWindow *pParent, Guider *pGuider)
-: ConfigDialogPane(_("Guider Settings"), pParent)
+ : ConfigDialogPane(_("Guider Settings"), pParent)
{
m_pGuider = pGuider;
}
@@ -1719,16 +1730,17 @@ void Guider::GuiderConfigDialogPane::LayoutControls(Guider *pGuider, BrainCtrlId
this->Add(pCalib, def_flags);
this->Add(pShared, def_flags);
Fit(m_pParent);
-
}
-GuiderConfigDialogCtrlSet *Guider::GetConfigDialogCtrlSet(wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
+GuiderConfigDialogCtrlSet *Guider::GetConfigDialogCtrlSet(
+ wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
{
return new GuiderConfigDialogCtrlSet(pParent, pGuider, pAdvancedDialog, CtrlMap);
}
-GuiderConfigDialogCtrlSet::GuiderConfigDialogCtrlSet(wxWindow *pParent, Guider *pGuider, AdvancedDialog* pAdvancedDialog, BrainCtrlIdMap& CtrlMap) :
-ConfigDialogCtrlSet(pParent, pAdvancedDialog, CtrlMap)
+GuiderConfigDialogCtrlSet::GuiderConfigDialogCtrlSet(
+ wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
+ : ConfigDialogCtrlSet(pParent, pAdvancedDialog, CtrlMap)
{
assert(pGuider);
@@ -1737,8 +1749,11 @@ ConfigDialogCtrlSet(pParent, pAdvancedDialog, CtrlMap)
m_pScaleImage = new wxCheckBox(GetParentWindow(AD_cbScaleImages), wxID_ANY, _("Always scale images"));
AddCtrl(CtrlMap, AD_cbScaleImages, m_pScaleImage, _("Always scale images to fill window"));
- m_pEnableFastRecenter = new wxCheckBox(GetParentWindow(AD_cbFastRecenter), wxID_ANY, _("Fast recenter after calibration or dither"));
- AddCtrl(CtrlMap, AD_cbFastRecenter, m_pEnableFastRecenter, _("Speed up calibration and dithering by using larger guide pulses to return the star to the center position. Un-check to use the old, slower method of recentering after calibration or dither."));
+ m_pEnableFastRecenter =
+ new wxCheckBox(GetParentWindow(AD_cbFastRecenter), wxID_ANY, _("Fast recenter after calibration or dither"));
+ AddCtrl(CtrlMap, AD_cbFastRecenter, m_pEnableFastRecenter,
+ _("Speed up calibration and dithering by using larger guide pulses to return the star to the center position. Un-check "
+ "to use the old, slower method of recentering after calibration or dither."));
}
void GuiderConfigDialogCtrlSet::LoadValues()
@@ -1773,35 +1788,35 @@ EXPOSED_STATE Guider::GetExposedState()
switch (guider->GetState())
{
- case STATE_UNINITIALIZED:
- case STATE_STOP:
- default:
- rval = EXPOSED_STATE_NONE;
- break;
-
- case STATE_SELECTING:
- // only report "looping" if no star is selected
- if (guider->CurrentPosition().IsValid())
- rval = EXPOSED_STATE_SELECTED;
- else
- rval = EXPOSED_STATE_LOOPING;
- break;
+ case STATE_UNINITIALIZED:
+ case STATE_STOP:
+ default:
+ rval = EXPOSED_STATE_NONE;
+ break;
- case STATE_SELECTED:
- case STATE_CALIBRATED:
+ case STATE_SELECTING:
+ // only report "looping" if no star is selected
+ if (guider->CurrentPosition().IsValid())
rval = EXPOSED_STATE_SELECTED;
- break;
+ else
+ rval = EXPOSED_STATE_LOOPING;
+ break;
- case STATE_CALIBRATING_PRIMARY:
- case STATE_CALIBRATING_SECONDARY:
- rval = EXPOSED_STATE_CALIBRATING;
- break;
+ case STATE_SELECTED:
+ case STATE_CALIBRATED:
+ rval = EXPOSED_STATE_SELECTED;
+ break;
- case STATE_GUIDING:
- if (guider->IsLocked())
- rval = EXPOSED_STATE_GUIDING_LOCKED;
- else
- rval = EXPOSED_STATE_GUIDING_LOST;
+ case STATE_CALIBRATING_PRIMARY:
+ case STATE_CALIBRATING_SECONDARY:
+ rval = EXPOSED_STATE_CALIBRATING;
+ break;
+
+ case STATE_GUIDING:
+ if (guider->IsLocked())
+ rval = EXPOSED_STATE_GUIDING_LOCKED;
+ else
+ rval = EXPOSED_STATE_GUIDING_LOST;
}
Debug.Write(wxString::Format("case statement mapped state %d to %d\n", guider->GetState(), rval));
@@ -1860,8 +1875,8 @@ void Guider::DeleteAllBookmarks()
{
if (m_bookmarks.size())
{
- bool confirmed = ConfirmDialog::Confirm(_("Are you sure you want to delete all Bookmarks?"),
- "/delete_all_bookmarks_ok");
+ bool confirmed =
+ ConfirmDialog::Confirm(_("Are you sure you want to delete all Bookmarks?"), "/delete_all_bookmarks_ok");
if (confirmed)
{
m_bookmarks.clear();
@@ -1877,8 +1892,7 @@ void Guider::DeleteAllBookmarks()
static bool IsClose(const wxRealPoint& p1, const wxRealPoint& p2, double tolerance)
{
- return fabs(p1.x - p2.x) <= tolerance &&
- fabs(p1.y - p2.y) <= tolerance;
+ return fabs(p1.x - p2.x) <= tolerance && fabs(p1.y - p2.y) <= tolerance;
}
static std::vector::iterator FindBookmark(const wxRealPoint& pos, std::vector& vec)
diff --git a/src/guider.h b/src/guider.h
index d234ab7bb..ae6bd5951 100644
--- a/src/guider.h
+++ b/src/guider.h
@@ -91,9 +91,9 @@ struct OverlaySlitCoords
enum PauseType
{
- PAUSE_NONE, // not paused
- PAUSE_GUIDING, // pause guide corrections but continue looping exposures
- PAUSE_FULL, // pause guide corrections and pause looping exposures
+ PAUSE_NONE, // not paused
+ PAUSE_GUIDING, // pause guide corrections but continue looping exposures
+ PAUSE_FULL, // pause guide corrections and pause looping exposures
};
struct LockPosShiftParams
@@ -122,11 +122,10 @@ class GuiderConfigDialogCtrlSet : public ConfigDialogCtrlSet
wxCheckBox *m_pScaleImage;
public:
- GuiderConfigDialogCtrlSet(wxWindow *pParent, Guider *pGuider, AdvancedDialog* pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
+ GuiderConfigDialogCtrlSet(wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
virtual ~GuiderConfigDialogCtrlSet() {};
virtual void LoadValues();
virtual void UnloadValues();
-
};
struct GuiderOffset
@@ -149,11 +148,11 @@ class Guider : public wxWindow
PHD_Point m_ditherRecenterStep;
wxPoint m_ditherRecenterDir;
PHD_Point m_ditherRecenterRemaining;
- time_t m_starFoundTimestamp; // timestamp when star was last found
- double m_avgDistance; // averaged distance for distance reporting
- double m_avgDistanceRA; // averaged distance, RA only
- double m_avgDistanceLong; // averaged distance, more smoothed
- double m_avgDistanceLongRA; // averaged distance, more smoothed, RA only
+ time_t m_starFoundTimestamp; // timestamp when star was last found
+ double m_avgDistance; // averaged distance for distance reporting
+ double m_avgDistanceRA; // averaged distance, RA only
+ double m_avgDistanceLong; // averaged distance, more smoothed
+ double m_avgDistanceLongRA; // averaged distance, more smoothed, RA only
unsigned int m_avgDistanceCnt;
bool m_avgDistanceNeedReset;
GUIDER_STATE m_state;
@@ -167,7 +166,7 @@ class Guider : public wxWindow
double m_minStarHFD;
double m_minAFStarSNR;
double m_maxStarHFD;
- unsigned int m_autoSelDownsample; // downsample factor for star auto-selection, 0=Auto
+ unsigned int m_autoSelDownsample; // downsample factor for star auto-selection, 0=Auto
protected:
int m_searchRegion; // how far u/d/l/r do we do the initial search for a star
@@ -194,8 +193,9 @@ class Guider : public wxWindow
OVERLAY_MODE GetOverlayMode() const;
public:
- virtual GuiderConfigDialogPane *GetConfigDialogPane(wxWindow *pParent)= 0;
- virtual GuiderConfigDialogCtrlSet *GetConfigDialogCtrlSet(wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
+ virtual GuiderConfigDialogPane *GetConfigDialogPane(wxWindow *pParent) = 0;
+ virtual GuiderConfigDialogCtrlSet *GetConfigDialogCtrlSet(
+ wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
protected:
Guider(wxWindow *parent, int xSize, int ySize);
@@ -246,7 +246,7 @@ class Guider : public wxWindow
void StartGuiding();
void StopGuiding();
- void UpdateGuideState(usImage *pImage, bool bStopping=false);
+ void UpdateGuideState(usImage *pImage, bool bStopping = false);
void DisplayImage(usImage *img);
bool SetScaleImage(bool newScaleValue);
@@ -272,7 +272,8 @@ class Guider : public wxWindow
void SetMinStarHFD(double val);
double GetMaxStarHFD() const;
void SetMaxStarHFD(double val);
- // 'AF' methods deal with SNR threshold used only during Auto-Find - lets user specify a higher than default SNR floor for populating a multi-star list. Normal 'find' methods do not use this property
+ // 'AF' methods deal with SNR threshold used only during Auto-Find - lets user specify a higher than default SNR floor for
+ // populating a multi-star list. Normal 'find' methods do not use this property
void SetAFMinStarSNR(double val);
double GetAFMinStarSNR() const;
@@ -284,6 +285,7 @@ class Guider : public wxWindow
// their operation
private:
virtual void InvalidateLockPosition();
+
public:
virtual void LoadProfileSettings();
@@ -292,6 +294,7 @@ class Guider : public wxWindow
virtual bool IsValidLockPosition(const PHD_Point& pt) = 0;
virtual bool IsValidSecondaryStarPosition(const PHD_Point& pt) = 0;
virtual void InvalidateCurrentPosition(bool fullReset = false) = 0;
+
private:
virtual bool UpdateCurrentPosition(const usImage *pImage, GuiderOffset *ofs, FrameDroppedInfo *errorInfo) = 0;
virtual bool SetCurrentPosition(const usImage *pImage, const PHD_Point& position) = 0;
diff --git a/src/guider_multistar.cpp b/src/guider_multistar.cpp
index 40a1732de..1359a12d3 100644
--- a/src/guider_multistar.cpp
+++ b/src/guider_multistar.cpp
@@ -46,12 +46,15 @@
#include
#if ((wxMAJOR_VERSION < 3) && (wxMINOR_VERSION < 9))
-#define wxPENSTYLE_DOT wxDOT
+# define wxPENSTYLE_DOT wxDOT
#endif
class MassChecker
{
- enum { DefaultTimeWindowMs = 22500 };
+ enum
+ {
+ DefaultTimeWindowMs = 22500
+ };
struct Entry
{
@@ -60,8 +63,8 @@ class MassChecker
};
std::deque m_data;
- double m_highMass; // high-water mark
- double m_lowMass; // low-water mark
+ double m_highMass; // high-water mark
+ double m_lowMass; // low-water mark
unsigned long m_timeWindow;
double *m_tmp;
size_t m_tmpSize;
@@ -69,22 +72,18 @@ class MassChecker
bool m_isAutoExposure;
public:
-
MassChecker()
- : m_highMass(0.),
- m_lowMass(9e99),
- m_tmp(0),
- m_tmpSize(0),
- m_exposure(0),
- m_isAutoExposure(false)
+ : m_highMass(0.)
+ , m_lowMass(9e99)
+ , m_tmp(0)
+ , m_tmpSize(0)
+ , m_exposure(0)
+ , m_isAutoExposure(false)
{
SetTimeWindow(DefaultTimeWindowMs);
}
- ~MassChecker()
- {
- delete[] m_tmp;
- }
+ ~MassChecker() { delete[] m_tmp; }
void SetTimeWindow(unsigned int milliseconds)
{
@@ -110,10 +109,7 @@ class MassChecker
}
}
- double AdjustedMass(double mass) const
- {
- return m_isAutoExposure ? mass / (double) m_exposure : mass;
- }
+ double AdjustedMass(double mass) const { return m_isAutoExposure ? mass / (double) m_exposure : mass; }
void AppendData(double mass)
{
@@ -191,7 +187,8 @@ class MassChecker
static const double DefaultMassChangeThreshold = 0.5;
-enum {
+enum
+{
MIN_SEARCH_REGION = 7,
DEFAULT_SEARCH_REGION = 15,
MAX_SEARCH_REGION = 50,
@@ -209,13 +206,15 @@ wxEND_EVENT_TABLE();
// Define a constructor for the guide canvas
GuiderMultiStar::GuiderMultiStar(wxWindow *parent)
- : Guider(parent, XWinSize, YWinSize),
- m_massChecker(new MassChecker()),
- m_stabilizing(false), m_multiStarMode(true), m_lastPrimaryDistance(0),
- m_lockPositionMoved(false),
- m_maxStars(DEFAULT_MAX_STAR_COUNT),
- m_stabilitySigmaX(DEFAULT_STABILITY_SIGMAX),
- m_lastStarsUsed(0)
+ : Guider(parent, XWinSize, YWinSize)
+ , m_massChecker(new MassChecker())
+ , m_stabilizing(false)
+ , m_multiStarMode(true)
+ , m_lastPrimaryDistance(0)
+ , m_lockPositionMoved(false)
+ , m_maxStars(DEFAULT_MAX_STAR_COUNT)
+ , m_stabilitySigmaX(DEFAULT_STABILITY_SIGMAX)
+ , m_lastStarsUsed(0)
{
SetState(STATE_UNINITIALIZED);
m_primaryDistStats = new DescriptiveStats();
@@ -235,7 +234,8 @@ void GuiderMultiStar::SetMultiStarMode(bool val)
if (val && !oldVal)
{
m_primaryDistStats->ClearAll();
- if (GetState() >= STATE_SELECTED) // If we have a single star, need to force an auto-find to be sure we have the right secondary stars
+ if (GetState() >=
+ STATE_SELECTED) // If we have a single star, need to force an auto-find to be sure we have the right secondary stars
{
StopGuiding();
InvalidateCurrentPosition(true);
@@ -270,11 +270,11 @@ void GuiderMultiStar::LoadProfileSettings()
{
Guider::LoadProfileSettings();
- double massChangeThreshold = pConfig->Profile.GetDouble("/guider/onestar/MassChangeThreshold",
- DefaultMassChangeThreshold);
+ double massChangeThreshold = pConfig->Profile.GetDouble("/guider/onestar/MassChangeThreshold", DefaultMassChangeThreshold);
SetMassChangeThreshold(massChangeThreshold);
- bool massChangeThreshEnabled = pConfig->Profile.GetBoolean("/guider/onestar/MassChangeThresholdEnabled", massChangeThreshold != 1.0);
+ bool massChangeThreshEnabled =
+ pConfig->Profile.GetBoolean("/guider/onestar/MassChangeThresholdEnabled", massChangeThreshold != 1.0);
SetMassChangeThresholdEnabled(massChangeThreshEnabled);
bool tolerateJumps = pConfig->Profile.GetBoolean("/guider/onestar/TolerateJumpsEnabled", false);
@@ -383,7 +383,7 @@ bool GuiderMultiStar::SetCurrentPosition(const usImage *pImage, const PHD_Point&
double x = position.X;
double y = position.Y;
- Debug.Write(wxString::Format("SetCurrentPosition(%.2f,%.2f)\n", x, y ));
+ Debug.Write(wxString::Format("SetCurrentPosition(%.2f,%.2f)\n", x, y));
if ((x <= 0) || (x >= pImage->Size.x))
{
@@ -396,8 +396,8 @@ bool GuiderMultiStar::SetCurrentPosition(const usImage *pImage, const PHD_Point&
}
m_massChecker->Reset();
- bError = !m_primaryStar.Find(pImage, m_searchRegion, x, y, pFrame->GetStarFindMode(),
- GetMinStarHFD(), GetMaxStarHFD(), pCamera->GetSaturationADU(), Star::FIND_LOGGING_VERBOSE);
+ bError = !m_primaryStar.Find(pImage, m_searchRegion, x, y, pFrame->GetStarFindMode(), GetMinStarHFD(), GetMaxStarHFD(),
+ pCamera->GetSaturationADU(), Star::FIND_LOGGING_VERBOSE);
}
catch (const wxString& Msg)
{
@@ -414,12 +414,18 @@ static wxString StarStatusStr(const Star& star)
switch (star.GetError())
{
- case Star::STAR_LOWSNR: return _("Star lost - low SNR");
- case Star::STAR_LOWMASS: return _("Star lost - low mass");
- case Star::STAR_LOWHFD: return _("Star lost - low HFD");
- case Star::STAR_TOO_NEAR_EDGE: return _("Star too near edge");
- case Star::STAR_MASSCHANGE: return _("Star lost - mass changed");
- default: return _("No star found");
+ case Star::STAR_LOWSNR:
+ return _("Star lost - low SNR");
+ case Star::STAR_LOWMASS:
+ return _("Star lost - low mass");
+ case Star::STAR_LOWHFD:
+ return _("Star lost - low HFD");
+ case Star::STAR_TOO_NEAR_EDGE:
+ return _("Star too near edge");
+ case Star::STAR_MASSCHANGE:
+ return _("Star lost - mass changed");
+ default:
+ return _("No star found");
}
}
@@ -479,8 +485,8 @@ bool GuiderMultiStar::AutoSelect(const wxRect& roi)
m_massChecker->Reset();
- if (!m_primaryStar.Find(image, m_searchRegion, newStar.X, newStar.Y, Star::FIND_CENTROID, GetMinStarHFD(), GetMaxStarHFD(),
- pCamera->GetSaturationADU(), Star::FIND_LOGGING_VERBOSE))
+ if (!m_primaryStar.Find(image, m_searchRegion, newStar.X, newStar.Y, Star::FIND_CENTROID, GetMinStarHFD(),
+ GetMaxStarHFD(), pCamera->GetSaturationADU(), Star::FIND_LOGGING_VERBOSE))
{
throw ERROR_INFO("Unable to find");
}
@@ -535,30 +541,32 @@ bool GuiderMultiStar::AutoSelect(const wxRect& roi)
inline static wxRect SubframeRect(const PHD_Point& pos, int halfwidth)
{
- return wxRect(ROUND(pos.X) - halfwidth,
- ROUND(pos.Y) - halfwidth,
- 2 * halfwidth + 1,
- 2 * halfwidth + 1);
+ return wxRect(ROUND(pos.X) - halfwidth, ROUND(pos.Y) - halfwidth, 2 * halfwidth + 1, 2 * halfwidth + 1);
}
wxRect GuiderMultiStar::GetBoundingBox() const
{
- enum { SUBFRAME_BOUNDARY_PX = 0 };
+ enum
+ {
+ SUBFRAME_BOUNDARY_PX = 0
+ };
GUIDER_STATE state = GetState();
bool subframe;
PHD_Point pos;
- switch (state) {
+ switch (state)
+ {
case STATE_SELECTED:
case STATE_CALIBRATING_PRIMARY:
case STATE_CALIBRATING_SECONDARY:
subframe = m_primaryStar.WasFound();
pos = CurrentPosition();
break;
- case STATE_GUIDING: {
- subframe = m_primaryStar.WasFound(); // true;
+ case STATE_GUIDING:
+ {
+ subframe = m_primaryStar.WasFound(); // true;
// As long as the star is close to the lock position, keep the subframe
// at the lock position. Otherwise, follow the star.
double dist = CurrentPosition().Distance(LockPosition());
@@ -611,9 +619,15 @@ struct DistanceChecker
wxLongLong_t m_expires;
double m_forceTolerance;
- enum { WAIT_INTERVAL_MS = 5000 };
+ enum
+ {
+ WAIT_INTERVAL_MS = 5000
+ };
- DistanceChecker() : m_state(ST_GUIDING) { }
+ DistanceChecker()
+ : m_state(ST_GUIDING)
+ {
+ }
void Activate()
{
@@ -628,7 +642,10 @@ struct DistanceChecker
static bool _CheckDistance(double distance, bool raOnly, double tolerance)
{
- enum { MIN_FRAMES_FOR_STATS = 10 };
+ enum
+ {
+ MIN_FRAMES_FOR_STATS = 10
+ };
Guider *guider = pFrame->pGuider;
if (!guider->IsGuiding() || guider->IsPaused() || PhdController::IsSettling() ||
guider->CurrentErrorFrameCount() < MIN_FRAMES_FOR_STATS)
@@ -640,7 +657,7 @@ struct DistanceChecker
if (distance > threshold)
{
Debug.Write(wxString::Format("DistanceChecker: reject for large offset (%.2f > %.2f) avgDist = %.2f count = %u\n",
- distance, threshold, avgDist, guider->CurrentErrorFrameCount()));
+ distance, threshold, avgDist, guider->CurrentErrorFrameCount()));
return false;
}
return true;
@@ -702,7 +719,7 @@ wxString GuiderMultiStar::GetStarCount() const
{
// no weird displays if stars are being removed from list
return wxString::Format("%u/%u", wxMin(m_starsUsed, static_cast(m_guideStars.size())),
- static_cast(m_guideStars.size()));
+ static_cast(m_guideStars.size()));
}
// Private method to build compact logging string for how secondary stars were used
@@ -760,12 +777,14 @@ bool GuiderMultiStar::RefineOffset(const usImage *pImage, GuiderOffset *pOffset)
{
PHD_Point expectedLoc = m_primaryStar + pGS->offsetFromPrimary;
bool found;
- if (IsValidSecondaryStarPosition (expectedLoc))
- found = pGS->Find(pImage, m_searchRegion, expectedLoc.X, expectedLoc.Y, pFrame->GetStarFindMode(),
- GetMinStarHFD(), GetMaxStarHFD(), pCamera->GetSaturationADU(), Star::FIND_LOGGING_VERBOSE);
+ if (IsValidSecondaryStarPosition(expectedLoc))
+ found = pGS->Find(pImage, m_searchRegion, expectedLoc.X, expectedLoc.Y,
+ pFrame->GetStarFindMode(), GetMinStarHFD(), GetMaxStarHFD(),
+ pCamera->GetSaturationADU(), Star::FIND_LOGGING_VERBOSE);
else
found = pGS->Find(pImage, m_searchRegion, pGS->X, pGS->Y, pFrame->GetStarFindMode(),
- GetMinStarHFD(), GetMaxStarHFD(), pCamera->GetSaturationADU(), Star::FIND_LOGGING_VERBOSE);
+ GetMinStarHFD(), GetMaxStarHFD(), pCamera->GetSaturationADU(),
+ Star::FIND_LOGGING_VERBOSE);
if (found)
{
pGS->referencePoint.X = pGS->X;
@@ -775,18 +794,19 @@ bool GuiderMultiStar::RefineOffset(const usImage *pImage, GuiderOffset *pOffset)
}
else
{
- // Don't need to update reference point, lost star will continue to use the offsetFromPrimary location for possible recovery
+ // Don't need to update reference point, lost star will continue to use the
+ // offsetFromPrimary location for possible recovery
pGS->wasLost = true;
++pGS;
}
}
- return false; // All the secondary stars reference points reflect current positions
+ return false; // All the secondary stars reference points reflect current positions
}
}
}
}
else
- m_stabilizing = true; // get some data for primary star movement
+ m_stabilizing = true; // get some data for primary star movement
if (!m_stabilizing && m_guideStars.size() > 1 && (sumX != 0 || sumY != 0))
{
@@ -805,8 +825,8 @@ bool GuiderMultiStar::RefineOffset(const usImage *pImage, GuiderOffset *pOffset)
}
else
// Look for it where we last found it
- found = pGS->Find(pImage, m_searchRegion, pGS->X, pGS->Y, pFrame->GetStarFindMode(),
- GetMinStarHFD(), GetMaxStarHFD(), pCamera->GetSaturationADU(), Star::FIND_LOGGING_MINIMAL);
+ found = pGS->Find(pImage, m_searchRegion, pGS->X, pGS->Y, pFrame->GetStarFindMode(), GetMinStarHFD(),
+ GetMaxStarHFD(), pCamera->GetSaturationADU(), Star::FIND_LOGGING_MINIMAL);
if (found)
{
double dX = pGS->X - pGS->referencePoint.X;
@@ -844,7 +864,8 @@ bool GuiderMultiStar::RefineOffset(const usImage *pImage, GuiderOffset *pOffset)
AppendStarUse(secondaryInfo, Iter_Inx(pGS), dX, dY, 0, "R");
}
else
- AppendStarUse(secondaryInfo, Iter_Inx(pGS), dX, dY, 0, "M" + std::to_string(pGS->missCount));
+ AppendStarUse(
+ secondaryInfo, Iter_Inx(pGS), dX, dY, 0, "M" + std::to_string(pGS->missCount));
++pGS;
continue;
}
@@ -863,7 +884,7 @@ bool GuiderMultiStar::RefineOffset(const usImage *pImage, GuiderOffset *pOffset)
AppendStarUse(secondaryInfo, Iter_Inx(pGS), dX, dY, wt, "U");
}
- else // exactly zero on both axes, probably a hot pixel, drop it
+ else // exactly zero on both axes, probably a hot pixel, drop it
{
AppendStarUse(secondaryInfo, Iter_Inx(pGS), 0, 0, 0, "DZ");
pGS = m_guideStars.erase(pGS);
@@ -880,22 +901,22 @@ bool GuiderMultiStar::RefineOffset(const usImage *pImage, GuiderOffset *pOffset)
++pGS;
else
erasures = false;
- } // End of looping through secondary stars
+ } // End of looping through secondary stars
Debug.Write(secondaryInfo + "\n");
if (averaged)
{
sumX = sumX / sumWeights;
sumY = sumY / sumWeights;
- if (hypot(sumX, sumY) < primaryDistance) // Apply average only if its smaller than single-star delta
+ if (hypot(sumX, sumY) < primaryDistance) // Apply average only if its smaller than single-star delta
{
pOffset->cameraOfs.X = sumX;
pOffset->cameraOfs.Y = sumY;
refined = true;
}
- Debug.Write(wxString::Format("%s, %d included, MultiStar: {%0.2f, %0.2f}, one-star: {%0.2f, %0.2f}\n", (refined ? "refined" : "single-star"),
- validStars, sumX, sumY,
- origOffset.cameraOfs.X, origOffset.cameraOfs.Y));
+ Debug.Write(wxString::Format("%s, %d included, MultiStar: {%0.2f, %0.2f}, one-star: {%0.2f, %0.2f}\n",
+ (refined ? "refined" : "single-star"), validStars, sumX, sumY, origOffset.cameraOfs.X,
+ origOffset.cameraOfs.Y));
}
}
}
@@ -932,8 +953,8 @@ bool GuiderMultiStar::UpdateCurrentPosition(const usImage *pImage, GuiderOffset
{
Star newStar(m_primaryStar);
- if (!newStar.Find(pImage, m_searchRegion, pFrame->GetStarFindMode(), GetMinStarHFD(),
- GetMaxStarHFD(), pCamera->GetSaturationADU(), Star::FIND_LOGGING_VERBOSE))
+ if (!newStar.Find(pImage, m_searchRegion, pFrame->GetStarFindMode(), GetMinStarHFD(), GetMaxStarHFD(),
+ pCamera->GetSaturationADU(), Star::FIND_LOGGING_VERBOSE))
{
errorInfo->starError = newStar.GetError();
errorInfo->starMass = 0.0;
@@ -967,7 +988,8 @@ bool GuiderMultiStar::UpdateCurrentPosition(const usImage *pImage, GuiderOffset
errorInfo->status = StarStatusStr(m_primaryStar);
pFrame->StatusMsg(wxString::Format(_("Mass: %.f vs %.f"), newStar.Mass, limits[1]));
- Debug.Write(wxString::Format("UpdateCurrentPosition: star mass new=%.1f exp=%.1f thresh=%.0f%% limits=(%.1f, %.1f, %.1f)\n",
+ Debug.Write(wxString::Format(
+ "UpdateCurrentPosition: star mass new=%.1f exp=%.1f thresh=%.0f%% limits=(%.1f, %.1f, %.1f)\n",
newStar.Mass, limits[1], m_massChangeThreshold * 100., limits[0], limits[2], limits[3]));
m_massChecker->AppendData(newStar.Mass);
@@ -1021,7 +1043,7 @@ bool GuiderMultiStar::UpdateCurrentPosition(const usImage *pImage, GuiderOffset
if (m_multiStarMode && m_guideStars.size() > 1)
{
if (RefineOffset(pImage, ofs))
- distance = hypot(ofs->cameraOfs.X, ofs->cameraOfs.Y); // Distance is reported to server clients
+ distance = hypot(ofs->cameraOfs.X, ofs->cameraOfs.Y); // Distance is reported to server clients
}
else
m_starsUsed = 1;
@@ -1070,9 +1092,7 @@ bool GuiderMultiStar::IsValidLockPosition(const PHD_Point& pt)
if (!pImage)
return false;
// this is a bit ugly as it is tightly coupled to Star::Find
- return pt.X >= 1 + m_searchRegion &&
- pt.X + 1 + m_searchRegion < pImage->Size.GetX() &&
- pt.Y >= 1 + m_searchRegion &&
+ return pt.X >= 1 + m_searchRegion && pt.X + 1 + m_searchRegion < pImage->Size.GetX() && pt.Y >= 1 + m_searchRegion &&
pt.Y + 1 + m_searchRegion < pImage->Size.GetY();
}
@@ -1081,22 +1101,19 @@ bool GuiderMultiStar::IsValidSecondaryStarPosition(const PHD_Point& pt)
const usImage *pImage = CurrentImage();
if (!pImage)
return false;
- // As above, tightly coupled to Star::Find but with somewhat relaxed constraints. Find handles cases where search region is only partly within image
- return pt.X >= 5 &&
- pt.X + 5 < pImage->Size.GetX() &&
- pt.Y >= 5 &&
- pt.Y + 5 < pImage->Size.GetY();
+ // As above, tightly coupled to Star::Find but with somewhat relaxed constraints. Find handles cases where search region is
+ // only partly within image
+ return pt.X >= 5 && pt.X + 5 < pImage->Size.GetX() && pt.Y >= 5 && pt.Y + 5 < pImage->Size.GetY();
}
-void GuiderMultiStar::OnLClick(wxMouseEvent &mevent)
+void GuiderMultiStar::OnLClick(wxMouseEvent& mevent)
{
try
{
if (mevent.GetModifiers() == wxMOD_CONTROL)
{
double const scaleFactor = ScaleFactor();
- wxRealPoint pt((double) mevent.m_x / scaleFactor,
- (double) mevent.m_y / scaleFactor);
+ wxRealPoint pt((double) mevent.m_x / scaleFactor, (double) mevent.m_y / scaleFactor);
ToggleBookmark(pt);
m_showBookmarks = true;
pFrame->bookmarks_menu->Check(MENU_BOOKMARKS_SHOW, GetBookmarksShown());
@@ -1119,7 +1136,8 @@ void GuiderMultiStar::OnLClick(wxMouseEvent &mevent)
}
else
{
- if ((mevent.m_x <= m_searchRegion) || (mevent.m_x + m_searchRegion >= XWinSize) || (mevent.m_y <= m_searchRegion) || (mevent.m_y + m_searchRegion >= YWinSize))
+ if ((mevent.m_x <= m_searchRegion) || (mevent.m_x + m_searchRegion >= XWinSize) || (mevent.m_y <= m_searchRegion) ||
+ (mevent.m_y + m_searchRegion >= YWinSize))
{
mevent.Skip();
throw THROW_INFO("Skipping event because click outside of search region");
@@ -1199,10 +1217,9 @@ void GuiderMultiStar::OnPaint(wxPaintEvent& event)
dc.SetPen(wxPen(wxColour(0, 255, 255), 1, wxPENSTYLE_SOLID));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
- for (std::vector::const_iterator it = m_bookmarks.begin();
- it != m_bookmarks.end(); ++it)
+ for (std::vector::const_iterator it = m_bookmarks.begin(); it != m_bookmarks.end(); ++it)
{
- wxPoint p((int)(it->x * m_scaleFactor), (int)(it->y * m_scaleFactor));
+ wxPoint p((int) (it->x * m_scaleFactor), (int) (it->y * m_scaleFactor));
dc.DrawCircle(p, 3);
dc.DrawCircle(p, 6);
dc.DrawCircle(p, 12);
@@ -1224,10 +1241,9 @@ void GuiderMultiStar::OnPaint(wxPaintEvent& event)
m_lastStarsUsed = wxMin(m_guideStars.size(), (size_t) DEFAULT_MAX_STAR_COUNT);
}
- for (std::vector::const_iterator it = m_guideStars.begin() + 1;
- it != m_guideStars.end(); ++it)
+ for (std::vector::const_iterator it = m_guideStars.begin() + 1; it != m_guideStars.end(); ++it)
{
- wxPoint pt((int)(it->referencePoint.X * m_scaleFactor), (int)(it->referencePoint.Y * m_scaleFactor));
+ wxPoint pt((int) (it->referencePoint.X * m_scaleFactor), (int) (it->referencePoint.Y * m_scaleFactor));
dc.DrawCircle(pt, 6);
starsPlotted++;
if (starsPlotted == m_maxStars)
@@ -1243,24 +1259,24 @@ void GuiderMultiStar::OnPaint(wxPaintEvent& event)
if (state == STATE_SELECTED)
{
if (FoundStar)
- dc.SetPen(wxPen(wxColour(100,255,90), 1, wxPENSTYLE_SOLID)); // Draw the box around the star
+ dc.SetPen(wxPen(wxColour(100, 255, 90), 1, wxPENSTYLE_SOLID)); // Draw the box around the star
else
- dc.SetPen(wxPen(wxColour(230,130,30), 1, wxPENSTYLE_DOT));
+ dc.SetPen(wxPen(wxColour(230, 130, 30), 1, wxPENSTYLE_DOT));
DrawBox(dc, m_primaryStar, m_searchRegion, m_scaleFactor);
}
else if (state == STATE_CALIBRATING_PRIMARY || state == STATE_CALIBRATING_SECONDARY)
{
// in the calibration process
- dc.SetPen(wxPen(wxColour(32,196,32), 1, wxPENSTYLE_SOLID)); // Draw the box around the star
+ dc.SetPen(wxPen(wxColour(32, 196, 32), 1, wxPENSTYLE_SOLID)); // Draw the box around the star
DrawBox(dc, m_primaryStar, m_searchRegion, m_scaleFactor);
}
else if (state == STATE_CALIBRATED || state == STATE_GUIDING)
{
// locked and guiding
if (FoundStar)
- dc.SetPen(wxPen(wxColour(32,196,32), 1, wxPENSTYLE_SOLID)); // Draw the box around the star
+ dc.SetPen(wxPen(wxColour(32, 196, 32), 1, wxPENSTYLE_SOLID)); // Draw the box around the star
else
- dc.SetPen(wxPen(wxColour(230,130,30), 1, wxPENSTYLE_DOT));
+ dc.SetPen(wxPen(wxColour(230, 130, 30), 1, wxPENSTYLE_DOT));
DrawBox(dc, m_primaryStar, m_searchRegion, m_scaleFactor);
}
}
@@ -1278,20 +1294,20 @@ void GuiderMultiStar::SaveStarFITS()
usImage tmpimg;
wxString imgLogDirectory;
- tmpimg.Init(60,60);
- int start_x = ROUND(StarX)-30;
- int start_y = ROUND(StarY)-30;
+ tmpimg.Init(60, 60);
+ int start_x = ROUND(StarX) - 30;
+ int start_y = ROUND(StarY) - 30;
if ((start_x + 60) > pImage->Size.GetWidth())
start_x = pImage->Size.GetWidth() - 60;
if ((start_y + 60) > pImage->Size.GetHeight())
start_y = pImage->Size.GetHeight() - 60;
- int x,y, width;
+ int x, y, width;
width = pImage->Size.GetWidth();
unsigned short *usptr = tmpimg.ImageData;
for (y = 0; y < 60; y++)
{
for (x = 0; x < 60; x++, usptr++)
- *usptr = *(pImage->ImageData + (y + start_y)*width + (x + start_x));
+ *usptr = *(pImage->ImageData + (y + start_y) * width + (x + start_x));
}
imgLogDirectory = Debug.GetLogDir() + PATHSEPSTR + "PHD2_Stars";
@@ -1299,8 +1315,8 @@ void GuiderMultiStar::SaveStarFITS()
wxFileName::Mkdir(imgLogDirectory, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
wxString fname = imgLogDirectory + PATHSEPSTR + "PHD_GuideStar" + wxDateTime::Now().Format(_T("_%j_%H%M%S")) + ".fit";
- fitsfile *fptr; // FITS file pointer
- int status = 0; // CFITSIO status value MUST be initialized to zero!
+ fitsfile *fptr; // FITS file pointer
+ int status = 0; // CFITSIO status value MUST be initialized to zero!
PHD_fits_create_file(&fptr, fname, false, &status);
@@ -1354,7 +1370,6 @@ Guider::GuiderConfigDialogPane *GuiderMultiStar::GetConfigDialogPane(wxWindow *p
GuiderMultiStar::GuiderMultiStarConfigDialogPane::GuiderMultiStarConfigDialogPane(wxWindow *pParent, GuiderMultiStar *pGuider)
: GuiderConfigDialogPane(pParent, pGuider)
{
-
}
void GuiderMultiStar::GuiderMultiStarConfigDialogPane::LayoutControls(Guider *pGuider, BrainCtrlIdMap& CtrlMap)
@@ -1362,103 +1377,110 @@ void GuiderMultiStar::GuiderMultiStarConfigDialogPane::LayoutControls(Guider *pG
GuiderConfigDialogPane::LayoutControls(pGuider, CtrlMap);
}
-GuiderConfigDialogCtrlSet* GuiderMultiStar::GetConfigDialogCtrlSet(wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
+GuiderConfigDialogCtrlSet *GuiderMultiStar::GetConfigDialogCtrlSet(
+ wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
{
return new GuiderMultiStarConfigDialogCtrlSet(pParent, pGuider, pAdvancedDialog, CtrlMap);
}
-GuiderMultiStarConfigDialogCtrlSet::GuiderMultiStarConfigDialogCtrlSet(wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
+GuiderMultiStarConfigDialogCtrlSet::GuiderMultiStarConfigDialogCtrlSet(
+ wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap)
: GuiderConfigDialogCtrlSet(pParent, pGuider, pAdvancedDialog, CtrlMap)
{
- assert(pGuider);
- m_pGuiderMultiStar = static_cast(pGuider);
-
- int width;
-
- width = StringWidth(_T("0000"));
- m_pSearchRegion = pFrame->MakeSpinCtrl(GetParentWindow(AD_szStarTracking), wxID_ANY, _T(" "), wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, MIN_SEARCH_REGION, MAX_SEARCH_REGION, DEFAULT_SEARCH_REGION, _T("Search"));
- wxSizer *pSearchRegion = MakeLabeledControl(AD_szStarTracking, _("Search region (pixels)"), m_pSearchRegion,
- _("How many pixels (up/down/left/right) do we examine to find the star? Default = 15"));
-
- wxStaticBoxSizer *pStarMass = new wxStaticBoxSizer(wxHORIZONTAL, GetParentWindow(AD_szStarTracking), _("Star Mass Detection"));
- m_pEnableStarMassChangeThresh = new wxCheckBox(GetParentWindow(AD_szStarTracking), STAR_MASS_ENABLE, _("Enable"));
- m_pEnableStarMassChangeThresh->SetToolTip(_("Check to enable star mass change detection. When enabled, "
- "PHD skips frames when the guide star mass changes by an amount greater than the setting for 'tolerance'."));
-
- GetParentWindow(AD_szStarTracking)->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &GuiderMultiStarConfigDialogCtrlSet::OnStarMassEnableChecked, this, STAR_MASS_ENABLE);
-
- width = StringWidth(_T("100.0"));
- m_pMassChangeThreshold = pFrame->MakeSpinCtrlDouble(GetParentWindow(AD_szStarTracking), wxID_ANY, wxEmptyString, wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 10.0, 100.0, 0.0, 1.0, _T("MassChangeThreshold"));
- m_pMassChangeThreshold->SetDigits(1);
- wxSizer *pTolerance = MakeLabeledControl(AD_szStarTracking, _("Tolerance"), m_pMassChangeThreshold,
- _("When star mass change detection is enabled, this is the tolerance for star mass changes between frames, in percent. "
- "Larger values are more tolerant (less sensitive) to star mass changes. Valid range is 10-100, default is 50. "
- "If star mass change detection is not enabled then this setting is ignored."));
- pStarMass->Add(m_pEnableStarMassChangeThresh, wxSizerFlags(0).Border(wxTOP, 3));
- pStarMass->Add(pTolerance, wxSizerFlags(0).Border(wxLEFT, 40));
-
- width = StringWidth(_("65535"));
-
- double minHFD = pGuider->GetMinStarHFDFloor();
- m_MinHFD = pFrame->MakeSpinCtrlDouble(GetParentWindow(AD_szStarTracking), wxID_ANY, wxEmptyString, wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, minHFD, 10.0, pGuider->GetMinStarHFDFloor(), 0.5);
- m_MinHFD->SetDigits(1);
- wxSizer *pHFD = MakeLabeledControl(AD_szStarTracking, _("Minimum star HFD (pixels)"), m_MinHFD,
- _("The minimum star HFD (size) that will be used for identifying a guide star. "
- "This setting can be used to prevent PHD2 from guiding on a hot pixel. "
- "Use the Star Profile Tool to measure the HFD of a hot pixel and set the min HFD threshold "
- "a bit higher. When the HFD falls below this level, the hot pixel will be ignored."));
-
- m_MaxHFD = pFrame->MakeSpinCtrlDouble(GetParentWindow(AD_szStarTracking), wxID_ANY, wxEmptyString, wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, minHFD + 2.0, 10.0, 5.0, 0.5);
- m_MaxHFD->SetDigits(1);
- wxSizer *pMaxHFD = MakeLabeledControl(AD_szStarTracking, _("Maximum star HFD (pixels)"), m_MaxHFD,
- _("The maximum star HFD that will be used for identifying a guide star. "
- "This setting can be used to prevent PHD2 from choosing a large clump of sensor noise, adjacent faint stars, "
- "internal reflections, or comet heads as guide stars."));
-
- wxString ary[] = { _("Auto"), _T("1"), _T("2"), _T("3") };
- m_autoSelDownsample = new wxChoice(GetParentWindow(AD_szStarTracking), wxID_ANY, wxDefaultPosition, wxDefaultSize, WXSIZEOF(ary), ary);
- wxSizer *dsamp = MakeLabeledControl(AD_szStarTracking, _("Auto-selection frame downsample"), m_autoSelDownsample,
- _("Downsampling factor for star auto-selection camera frames. Choose a value greater than 1 if star "
- "auto-selection is failing to recognize misshapen guide stars."));
-
- m_pBeepForLostStarCtrl = new wxCheckBox(GetParentWindow(AD_cbBeepForLostStar), wxID_ANY, _("Beep on lost star"));
- m_pBeepForLostStarCtrl->SetToolTip(_("Issue an audible alarm any time the guide star is lost"));
-
- m_pUseMultiStars = new wxCheckBox(GetParentWindow(AD_szStarTracking), MULTI_STAR_ENABLE, _("Use multiple stars"));
- m_pUseMultiStars->SetToolTip(_("Use multiple guide stars if they are available"));
- GetParentWindow(AD_szStarTracking)->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &GuiderMultiStarConfigDialogCtrlSet::OnMultiStarChecked, this, MULTI_STAR_ENABLE);
- width = StringWidth(_T("100.0"));
-
- m_MinSNR = pFrame->MakeSpinCtrlDouble(GetParentWindow(AD_szStarTracking), wxID_ANY, wxEmptyString, wxDefaultPosition,
- wxSize(width, -1), wxSP_ARROW_KEYS, 6.0, 200.0, 6.0, 2.0);
- m_MinSNR->SetDigits(0);
- wxSizer *pSNR = MakeLabeledControl(AD_szStarTracking, _("Minimum star SNR for AutoFind"), m_MinSNR,
- _("The minimum star SNR that will be used for auto-selecting guide stars. "
- "This setting can be used to discourage PHD2 from choosing a guide star you know will be too faint for sustained guiding. "
- "This setting applies to both the primary guide star and candidate secondary stars in multi-star guiding. "
- "If this constraint cannot be met, a saturated or near-saturated star may be selected."));
-
- wxFlexGridSizer *pTrackingParams = new wxFlexGridSizer(3, 2, 8, 15);
- pTrackingParams->Add(pSearchRegion, wxSizerFlags(0).Border(wxTOP, 12));
- pTrackingParams->Add(pStarMass, wxSizerFlags(0).Border(wxLEFT, 75));
- pTrackingParams->Add(pHFD, wxSizerFlags().Border(wxTOP, 3));
- pTrackingParams->Add(pSNR, wxSizerFlags().Border(wxLEFT, 75));
- pTrackingParams->Add(pMaxHFD, wxSizerFlags().Border(wxTOP, 4));
- pTrackingParams->Add(m_pUseMultiStars, wxSizerFlags(0).Border(wxLEFT, 75));
- pTrackingParams->Add(m_pBeepForLostStarCtrl, wxSizerFlags().Border(wxTOP, 3));
- pTrackingParams->Add(dsamp, wxSizerFlags().Border(wxTOP, 3).Right());
-
- AddGroup(CtrlMap, AD_szStarTracking, pTrackingParams);
+ assert(pGuider);
+ m_pGuiderMultiStar = static_cast(pGuider);
+
+ int width;
+
+ width = StringWidth(_T("0000"));
+ m_pSearchRegion = pFrame->MakeSpinCtrl(GetParentWindow(AD_szStarTracking), wxID_ANY, _T(" "), wxDefaultPosition,
+ wxSize(width, -1), wxSP_ARROW_KEYS, MIN_SEARCH_REGION, MAX_SEARCH_REGION, DEFAULT_SEARCH_REGION, _T("Search"));
+ wxSizer *pSearchRegion = MakeLabeledControl(AD_szStarTracking, _("Search region (pixels)"), m_pSearchRegion,
+ _("How many pixels (up/down/left/right) do we examine to find the star? Default = 15"));
+
+ wxStaticBoxSizer *pStarMass =
+ new wxStaticBoxSizer(wxHORIZONTAL, GetParentWindow(AD_szStarTracking), _("Star Mass Detection"));
+ m_pEnableStarMassChangeThresh = new wxCheckBox(GetParentWindow(AD_szStarTracking), STAR_MASS_ENABLE, _("Enable"));
+ m_pEnableStarMassChangeThresh->SetToolTip(
+ _("Check to enable star mass change detection. When enabled, "
+ "PHD skips frames when the guide star mass changes by an amount greater than the setting for 'tolerance'."));
+
+ GetParentWindow(AD_szStarTracking)
+ ->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &GuiderMultiStarConfigDialogCtrlSet::OnStarMassEnableChecked, this,
+ STAR_MASS_ENABLE);
+
+ width = StringWidth(_T("100.0"));
+ m_pMassChangeThreshold = pFrame->MakeSpinCtrlDouble(GetParentWindow(AD_szStarTracking), wxID_ANY, wxEmptyString,
+ wxDefaultPosition, wxSize(width, -1), wxSP_ARROW_KEYS, 10.0, 100.0, 0.0, 1.0, _T("MassChangeThreshold"));
+ m_pMassChangeThreshold->SetDigits(1);
+ wxSizer *pTolerance = MakeLabeledControl(AD_szStarTracking, _("Tolerance"), m_pMassChangeThreshold,
+ _("When star mass change detection is enabled, this is the tolerance for star mass changes between frames, in percent. "
+ "Larger values are more tolerant (less sensitive) to star mass changes. Valid range is 10-100, default is 50. "
+ "If star mass change detection is not enabled then this setting is ignored."));
+ pStarMass->Add(m_pEnableStarMassChangeThresh, wxSizerFlags(0).Border(wxTOP, 3));
+ pStarMass->Add(pTolerance, wxSizerFlags(0).Border(wxLEFT, 40));
+
+ width = StringWidth(_("65535"));
+
+ double minHFD = pGuider->GetMinStarHFDFloor();
+ m_MinHFD = pFrame->MakeSpinCtrlDouble(GetParentWindow(AD_szStarTracking), wxID_ANY, wxEmptyString, wxDefaultPosition,
+ wxSize(width, -1), wxSP_ARROW_KEYS, minHFD, 10.0, pGuider->GetMinStarHFDFloor(), 0.5);
+ m_MinHFD->SetDigits(1);
+ wxSizer *pHFD = MakeLabeledControl(AD_szStarTracking, _("Minimum star HFD (pixels)"), m_MinHFD,
+ _("The minimum star HFD (size) that will be used for identifying a guide star. "
+ "This setting can be used to prevent PHD2 from guiding on a hot pixel. "
+ "Use the Star Profile Tool to measure the HFD of a hot pixel and set the min HFD threshold "
+ "a bit higher. When the HFD falls below this level, the hot pixel will be ignored."));
+
+ m_MaxHFD = pFrame->MakeSpinCtrlDouble(GetParentWindow(AD_szStarTracking), wxID_ANY, wxEmptyString, wxDefaultPosition,
+ wxSize(width, -1), wxSP_ARROW_KEYS, minHFD + 2.0, 10.0, 5.0, 0.5);
+ m_MaxHFD->SetDigits(1);
+ wxSizer *pMaxHFD = MakeLabeledControl(AD_szStarTracking, _("Maximum star HFD (pixels)"), m_MaxHFD,
+ _("The maximum star HFD that will be used for identifying a guide star. "
+ "This setting can be used to prevent PHD2 from choosing a large clump of sensor noise, adjacent faint stars, "
+ "internal reflections, or comet heads as guide stars."));
+
+ wxString ary[] = { _("Auto"), _T("1"), _T("2"), _T("3") };
+ m_autoSelDownsample =
+ new wxChoice(GetParentWindow(AD_szStarTracking), wxID_ANY, wxDefaultPosition, wxDefaultSize, WXSIZEOF(ary), ary);
+ wxSizer *dsamp = MakeLabeledControl(AD_szStarTracking, _("Auto-selection frame downsample"), m_autoSelDownsample,
+ _("Downsampling factor for star auto-selection camera frames. Choose a value greater than 1 if star "
+ "auto-selection is failing to recognize misshapen guide stars."));
+
+ m_pBeepForLostStarCtrl = new wxCheckBox(GetParentWindow(AD_cbBeepForLostStar), wxID_ANY, _("Beep on lost star"));
+ m_pBeepForLostStarCtrl->SetToolTip(_("Issue an audible alarm any time the guide star is lost"));
+
+ m_pUseMultiStars = new wxCheckBox(GetParentWindow(AD_szStarTracking), MULTI_STAR_ENABLE, _("Use multiple stars"));
+ m_pUseMultiStars->SetToolTip(_("Use multiple guide stars if they are available"));
+ GetParentWindow(AD_szStarTracking)
+ ->Bind(
+ wxEVT_COMMAND_CHECKBOX_CLICKED, &GuiderMultiStarConfigDialogCtrlSet::OnMultiStarChecked, this, MULTI_STAR_ENABLE);
+ width = StringWidth(_T("100.0"));
+
+ m_MinSNR = pFrame->MakeSpinCtrlDouble(GetParentWindow(AD_szStarTracking), wxID_ANY, wxEmptyString, wxDefaultPosition,
+ wxSize(width, -1), wxSP_ARROW_KEYS, 6.0, 200.0, 6.0, 2.0);
+ m_MinSNR->SetDigits(0);
+ wxSizer *pSNR = MakeLabeledControl(AD_szStarTracking, _("Minimum star SNR for AutoFind"), m_MinSNR,
+ _("The minimum star SNR that will be used for auto-selecting guide stars. "
+ "This setting can be used to discourage PHD2 from choosing a guide star you know will be too faint for sustained "
+ "guiding. "
+ "This setting applies to both the primary guide star and candidate secondary stars in multi-star guiding. "
+ "If this constraint cannot be met, a saturated or near-saturated star may be selected."));
+
+ wxFlexGridSizer *pTrackingParams = new wxFlexGridSizer(3, 2, 8, 15);
+ pTrackingParams->Add(pSearchRegion, wxSizerFlags(0).Border(wxTOP, 12));
+ pTrackingParams->Add(pStarMass, wxSizerFlags(0).Border(wxLEFT, 75));
+ pTrackingParams->Add(pHFD, wxSizerFlags().Border(wxTOP, 3));
+ pTrackingParams->Add(pSNR, wxSizerFlags().Border(wxLEFT, 75));
+ pTrackingParams->Add(pMaxHFD, wxSizerFlags().Border(wxTOP, 4));
+ pTrackingParams->Add(m_pUseMultiStars, wxSizerFlags(0).Border(wxLEFT, 75));
+ pTrackingParams->Add(m_pBeepForLostStarCtrl, wxSizerFlags().Border(wxTOP, 3));
+ pTrackingParams->Add(dsamp, wxSizerFlags().Border(wxTOP, 3).Right());
+
+ AddGroup(CtrlMap, AD_szStarTracking, pTrackingParams);
}
-GuiderMultiStarConfigDialogCtrlSet::~GuiderMultiStarConfigDialogCtrlSet()
-{
-
-}
+GuiderMultiStarConfigDialogCtrlSet::~GuiderMultiStarConfigDialogCtrlSet() { }
void GuiderMultiStarConfigDialogCtrlSet::LoadValues()
{
@@ -1492,10 +1514,7 @@ void GuiderMultiStarConfigDialogCtrlSet::UnloadValues()
GuiderConfigDialogCtrlSet::UnloadValues();
}
-void GuiderMultiStarConfigDialogCtrlSet::OnMultiStarChecked(wxCommandEvent& evt)
-{
-
-}
+void GuiderMultiStarConfigDialogCtrlSet::OnMultiStarChecked(wxCommandEvent& evt) { }
void GuiderMultiStarConfigDialogCtrlSet::OnStarMassEnableChecked(wxCommandEvent& event)
{
m_pMassChangeThreshold->Enable(event.IsChecked());
diff --git a/src/guider_multistar.h b/src/guider_multistar.h
index 63594ebfa..a0b22d8fc 100644
--- a/src/guider_multistar.h
+++ b/src/guider_multistar.h
@@ -51,7 +51,8 @@ class GuiderConfigDialogCtrlSet;
class GuiderMultiStarConfigDialogCtrlSet : public GuiderConfigDialogCtrlSet
{
public:
- GuiderMultiStarConfigDialogCtrlSet(wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
+ GuiderMultiStarConfigDialogCtrlSet(
+ wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
virtual ~GuiderMultiStarConfigDialogCtrlSet();
GuiderMultiStar *m_pGuiderMultiStar;
@@ -96,8 +97,7 @@ class GuiderMultiStar : public Guider
class GuiderMultiStarConfigDialogPane : public GuiderConfigDialogPane
{
protected:
-
- public:
+ public:
GuiderMultiStarConfigDialogPane(wxWindow *pParent, GuiderMultiStar *pGuider);
~GuiderMultiStarConfigDialogPane() {};
@@ -112,7 +112,7 @@ class GuiderMultiStar : public Guider
bool SetMassChangeThreshold(double starMassChangeThreshold);
bool SetTolerateJumps(bool enable, double threshold);
bool SetSearchRegion(int searchRegion);
- bool RefineOffset(const usImage *pImage, GuiderOffset* pOffset);
+ bool RefineOffset(const usImage *pImage, GuiderOffset *pOffset);
friend class GuiderMultiStarConfigDialogPane;
friend class GuiderMultiStarConfigDialogCtrlSet;
@@ -137,7 +137,8 @@ class GuiderMultiStar : public Guider
wxString GetSettingsSummary() const override;
Guider::GuiderConfigDialogPane *GetConfigDialogPane(wxWindow *pParent) override;
- GuiderConfigDialogCtrlSet *GetConfigDialogCtrlSet(wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap) override;
+ GuiderConfigDialogCtrlSet *GetConfigDialogCtrlSet(
+ wxWindow *pParent, Guider *pGuider, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap) override;
void LoadProfileSettings() override;
@@ -155,32 +156,27 @@ class GuiderMultiStar : public Guider
wxDECLARE_EVENT_TABLE();
};
-inline int
-GuiderMultiStar::GetMaxMovePixels() const
+inline int GuiderMultiStar::GetMaxMovePixels() const
{
return m_searchRegion;
}
-inline const Star&
-GuiderMultiStar::PrimaryStar() const
+inline const Star& GuiderMultiStar::PrimaryStar() const
{
return m_primaryStar;
}
-inline bool
-GuiderMultiStar::GetMultiStarMode() const
+inline bool GuiderMultiStar::GetMultiStarMode() const
{
return m_multiStarMode;
}
-inline bool
-GuiderMultiStar::IsLocked() const
+inline bool GuiderMultiStar::IsLocked() const
{
return m_primaryStar.WasFound();
}
-inline const PHD_Point&
-GuiderMultiStar::CurrentPosition() const
+inline const PHD_Point& GuiderMultiStar::CurrentPosition() const
{
return m_primaryStar;
}
diff --git a/src/guiding_assistant.cpp b/src/guiding_assistant.cpp
index 36306037b..58b28455b 100644
--- a/src/guiding_assistant.cpp
+++ b/src/guiding_assistant.cpp
@@ -1,36 +1,36 @@
/*
-* guiding_assistant.cpp
-* PHD Guiding
-*
-* Created by Andy Galasso and Bruce Waddington
-* Copyright (c) 2015 Andy Galasso and Bruce Waddington
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * guiding_assistant.cpp
+ * PHD Guiding
+ *
+ * Created by Andy Galasso and Bruce Waddington
+ * Copyright (c) 2015 Andy Galasso and Bruce Waddington
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
#include "guiding_assistant.h"
@@ -97,26 +97,30 @@ struct SampleWait : public wxDialog
void OnCancel(wxCommandEvent& event);
};
-SampleWait::SampleWait(int SecondsLeft, bool BltNeeded) : wxDialog(pFrame, wxID_ANY, _("Extended Sampling"))
+SampleWait::SampleWait(int SecondsLeft, bool BltNeeded)
+ : wxDialog(pFrame, wxID_ANY, _("Extended Sampling"))
{
- wxBoxSizer* vSizer = new wxBoxSizer(wxVERTICAL);
- wxBoxSizer* amtSizer = new wxBoxSizer(wxHORIZONTAL);
- wxStaticText* explanation = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
+ wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL);
+ wxBoxSizer *amtSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxStaticText *explanation = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
wxString msg;
if (BltNeeded)
- msg = _("Additional data sampling is being done to better meaure Dec drift. Backlash testing \nwill start automatically when sampling is completed.");
+ msg = _("Additional data sampling is being done to better meaure Dec drift. Backlash testing \nwill start "
+ "automatically when sampling is completed.");
else
- msg = _("Additional sampling is being done for accurate measurements. Results will be shown when sampling is complete.");
+ msg =
+ _("Additional sampling is being done for accurate measurements. Results will be shown when sampling is complete.");
explanation->SetLabelText(msg);
MakeBold(explanation);
- wxStaticText* countDownLabel = new wxStaticText(this, wxID_ANY, _("Seconds remaining: "), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
+ wxStaticText *countDownLabel =
+ new wxStaticText(this, wxID_ANY, _("Seconds remaining: "), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
m_SecondsLeft = SecondsLeft;
m_CountdownAmount = new wxStaticText(this, wxID_ANY, std::to_string(wxMax(0, m_SecondsLeft)));
amtSizer->Add(countDownLabel, wxSizerFlags(0).Border(wxALL, 8));
amtSizer->Add(m_CountdownAmount, wxSizerFlags(0).Border(wxALL, 8));
- wxButton* cancelBtn = new wxButton(this, wxID_ANY, _("Cancel"));
+ wxButton *cancelBtn = new wxButton(this, wxID_ANY, _("Cancel"));
cancelBtn->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(SampleWait::OnCancel), nullptr, this);
- wxBoxSizer* btnSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
btnSizer->Add(cancelBtn, wxSizerFlags(0).Border(wxALL, 8).Center());
vSizer->Add(explanation, wxSizerFlags(0).Border(wxALL, 8).Center());
@@ -164,11 +168,15 @@ struct GuidingAsstWin : public wxDialog
STATE_MEASURING = 2,
STATE_STOPPED = 3
};
- enum DlgConstants {MAX_BACKLASH_COMP = 3000, GA_MIN_SAMPLING_PERIOD = 120};
+ enum DlgConstants
+ {
+ MAX_BACKLASH_COMP = 3000,
+ GA_MIN_SAMPLING_PERIOD = 120
+ };
wxButton *m_start;
wxButton *m_stop;
- OptionsButton* btnReviewPrev;
+ OptionsButton *btnReviewPrev;
wxTextCtrl *m_report;
wxStaticText *m_instructions;
wxGrid *m_statusgrid;
@@ -214,7 +222,7 @@ struct GuidingAsstWin : public wxDialog
wxStaticText *m_calibration_msg;
wxStaticText *m_binning_msg;
wxStaticText *m_decAlgo_msg;
- double m_ra_minmove_rec; // recommended value
+ double m_ra_minmove_rec; // recommended value
double m_dec_minmove_rec; // recommended value
double m_min_exp_rec;
double m_max_exp_rec;
@@ -237,10 +245,10 @@ struct GuidingAsstWin : public wxDialog
double sumSNR;
double sumMass;
double m_lastTime;
- double maxRateRA; // arc-sec per second
- double decDriftPerMin; // px per minute
- double decCorrectedRMS; // RMS of drift-corrected Dec dataset
- double alignmentError; // arc-minutes
+ double maxRateRA; // arc-sec per second
+ double decDriftPerMin; // px per minute
+ double decCorrectedRMS; // RMS of drift-corrected Dec dataset
+ double alignmentError; // arc-minutes
double m_backlashPx;
int m_backlashMs;
double m_backlashSigmaMs;
@@ -250,7 +258,7 @@ struct GuidingAsstWin : public wxDialog
bool m_savePrimaryMountEnabled;
bool m_saveSecondaryMountEnabled;
bool m_measurementsTaken;
- int m_origSubFrames;
+ int m_origSubFrames;
bool m_suspectCalibration;
bool inBLTWrapUp = false;
bool origMultistarMode;
@@ -280,13 +288,11 @@ struct GuidingAsstWin : public wxDialog
void OnReviewPrevious(wxCommandEvent& event);
void OnGAReviewSelection(wxCommandEvent& evt);
- wxStaticText *AddRecommendationBtn(const wxString& msg,
- void (GuidingAsstWin::* handler)(wxCommandEvent&),
- wxButton **ppButton);
+ wxStaticText *AddRecommendationBtn(
+ const wxString& msg, void (GuidingAsstWin::*handler)(wxCommandEvent&), wxButton **ppButton);
wxStaticText *AddRecommendationMsg(const wxString& msg);
- void FillResultCell(wxGrid *pGrid, const wxGridCellCoords& loc, double pxVal,
- double asVal, const wxString& units1, const wxString& units2,
- const wxString& extraInfo = wxEmptyString);
+ void FillResultCell(wxGrid *pGrid, const wxGridCellCoords& loc, double pxVal, double asVal, const wxString& units1,
+ const wxString& units2, const wxString& extraInfo = wxEmptyString);
void UpdateInfo(const GuideStepInfo& info);
void DisplayStaticResults(const GADetails& details);
void FillInstructions(DialogState eState);
@@ -297,8 +303,8 @@ struct GuidingAsstWin : public wxDialog
void EndBacklashTest(bool completed);
void BacklashError();
void StatsReset();
- void LoadGAResults(const wxString& TimeStamp, GADetails* Details);
- void SaveGAResults(const wxString* AllRecommendations);
+ void LoadGAResults(const wxString& TimeStamp, GADetails *Details);
+ void SaveGAResults(const wxString *AllRecommendations);
int GetGAHistoryCount();
void GetMinMoveRecs(double& RecRA, double& RecDec);
bool LikelyBacklash(const CalibrationDetails& calDetails);
@@ -316,14 +322,22 @@ struct GridTooltipInfo : public wxObject
wxGrid *grid;
int gridNum;
wxGridCellCoords prevCoords;
- GridTooltipInfo(wxGrid *g, int i) : grid(g), gridNum(i) { }
+ GridTooltipInfo(wxGrid *g, int i)
+ : grid(g)
+ , gridNum(i)
+ {
+ }
};
struct TextWrapper
{
wxWindow *win;
int width;
- TextWrapper(wxWindow *win_, int width_) : win(win_), width(width_) { }
+ TextWrapper(wxWindow *win_, int width_)
+ : win(win_)
+ , width(width_)
+ {
+ }
wxString Wrap(const wxString& text) const
{
struct Wrapper : public wxTextWrapper
@@ -339,13 +353,13 @@ struct TextWrapper
// Constructor
GuidingAsstWin::GuidingAsstWin()
- : wxDialog(pFrame, wxID_ANY, wxGetTranslation(_("Guiding Assistant"))),
- m_measuring(false),
- m_guideOutputDisabled(false),
- m_measurementsTaken(false),
- m_origSubFrames(-1),
- m_backlashTool(nullptr),
- m_flushConfig(false)
+ : wxDialog(pFrame, wxID_ANY, wxGetTranslation(_("Guiding Assistant")))
+ , m_measuring(false)
+ , m_guideOutputDisabled(false)
+ , m_measurementsTaken(false)
+ , m_origSubFrames(-1)
+ , m_backlashTool(nullptr)
+ , m_flushConfig(false)
{
// Sizer hierarchy:
// m_vSizer has {instructions, vResultsSizer, m_gaStatus, btnSizer}
@@ -353,24 +367,24 @@ GuidingAsstWin::GuidingAsstWin()
// hTopSizer has {status_group, displacement_group}
// hBottomSizer has {other_group, m_recommendation_group}
m_vSizer = new wxBoxSizer(wxVERTICAL);
- wxBoxSizer* vResultsSizer = new wxBoxSizer(wxVERTICAL);
- wxBoxSizer* hTopSizer = new wxBoxSizer(wxHORIZONTAL); // Measurement status and high-frequency results
- wxBoxSizer* hBottomSizer = new wxBoxSizer(wxHORIZONTAL); // Low-frequency results and recommendations
+ wxBoxSizer *vResultsSizer = new wxBoxSizer(wxVERTICAL);
+ wxBoxSizer *hTopSizer = new wxBoxSizer(wxHORIZONTAL); // Measurement status and high-frequency results
+ wxBoxSizer *hBottomSizer = new wxBoxSizer(wxHORIZONTAL); // Low-frequency results and recommendations
- m_instructions = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(700, 50), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
+ m_instructions =
+ new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(700, 50), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
MakeBold(m_instructions);
m_vSizer->Add(m_instructions, wxSizerFlags(0).Border(wxALL, 8));
// Grids have either 3 or 4 columns, so compute width of largest label as scaling term for column widths
- double minLeftCol = StringWidth(this,
- _(" -999.99 px/min (-999.99 arc-sec/min )")) + 6;
- double minRightCol = 1.25 * (StringWidth(this,
- _(" 9.99 px ( 9.99 arc-sec)")) + 6);
+ double minLeftCol = StringWidth(this, _(" -999.99 px/min (-999.99 arc-sec/min )")) + 6;
+ double minRightCol = 1.25 * (StringWidth(this, _(" 9.99 px ( 9.99 arc-sec)")) + 6);
// Start of status group
wxStaticBoxSizer *status_group = new wxStaticBoxSizer(wxVERTICAL, this, _("Measurement Status"));
m_statusgrid = new wxGrid(this, wxID_ANY);
m_statusgrid->CreateGrid(3, 4);
- m_statusgrid->GetGridWindow()->Bind(wxEVT_MOTION, &GuidingAsstWin::OnMouseMove, this, wxID_ANY, wxID_ANY, new GridTooltipInfo(m_statusgrid, 1));
+ m_statusgrid->GetGridWindow()->Bind(
+ wxEVT_MOTION, &GuidingAsstWin::OnMouseMove, this, wxID_ANY, wxID_ANY, new GridTooltipInfo(m_statusgrid, 1));
m_statusgrid->SetRowLabelSize(1);
m_statusgrid->SetColLabelSize(1);
m_statusgrid->EnableEditing(false);
@@ -395,9 +409,9 @@ GuidingAsstWin::GuidingAsstWin()
m_statusgrid->SetCellValue(row, col++, _("Sample count"));
m_samplecount_loc.Set(row, col++);
- //StartRow(row, col);
- //m_statusgrid->SetCellValue(_("Frequency cut-off:"), row, col++); // Leave out for now, probably not useful to users
- //m_hfcutoff_loc.Set(row, col++);
+ // StartRow(row, col);
+ // m_statusgrid->SetCellValue(_("Frequency cut-off:"), row, col++); // Leave out for now, probably not useful to users
+ // m_hfcutoff_loc.Set(row, col++);
status_group->Add(m_statusgrid);
hTopSizer->Add(status_group, wxSizerFlags(0).Border(wxALL, 8));
@@ -407,7 +421,8 @@ GuidingAsstWin::GuidingAsstWin()
wxStaticBoxSizer *displacement_group = new wxStaticBoxSizer(wxVERTICAL, this, _("High-frequency Star Motion"));
m_displacementgrid = new wxGrid(this, wxID_ANY);
m_displacementgrid->CreateGrid(3, 2);
- m_displacementgrid->GetGridWindow()->Bind(wxEVT_MOTION, &GuidingAsstWin::OnMouseMove, this, wxID_ANY, wxID_ANY, new GridTooltipInfo(m_displacementgrid, 2));
+ m_displacementgrid->GetGridWindow()->Bind(
+ wxEVT_MOTION, &GuidingAsstWin::OnMouseMove, this, wxID_ANY, wxID_ANY, new GridTooltipInfo(m_displacementgrid, 2));
m_displacementgrid->SetRowLabelSize(1);
m_displacementgrid->SetColLabelSize(1);
m_displacementgrid->EnableEditing(false);
@@ -435,7 +450,8 @@ GuidingAsstWin::GuidingAsstWin()
wxStaticBoxSizer *other_group = new wxStaticBoxSizer(wxVERTICAL, this, _("Other Star Motion"));
m_othergrid = new wxGrid(this, wxID_ANY);
m_othergrid->CreateGrid(9, 2);
- m_othergrid->GetGridWindow()->Bind(wxEVT_MOTION, &GuidingAsstWin::OnMouseMove, this, wxID_ANY, wxID_ANY, new GridTooltipInfo(m_othergrid, 3));
+ m_othergrid->GetGridWindow()->Bind(
+ wxEVT_MOTION, &GuidingAsstWin::OnMouseMove, this, wxID_ANY, wxID_ANY, new GridTooltipInfo(m_othergrid, 3));
m_othergrid->SetRowLabelSize(1);
m_othergrid->SetColLabelSize(1);
m_othergrid->EnableEditing(false);
@@ -503,13 +519,13 @@ GuidingAsstWin::GuidingAsstWin()
m_recommend_group->Add(m_recommendgrid, wxSizerFlags(1).Expand());
// Add buttons for viewing the Dec backlash graph or getting help
- wxBoxSizer* hBtnSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *hBtnSizer = new wxBoxSizer(wxHORIZONTAL);
m_graphBtn = new wxButton(this, wxID_ANY, _("Show Backlash Graph"));
m_graphBtn->SetToolTip(_("Show graph of backlash measurement points"));
m_graphBtn->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(GuidingAsstWin::OnGraph), nullptr, this);
m_graphBtn->Enable(false);
hBtnSizer->Add(m_graphBtn, wxSizerFlags(0).Border(wxALL, 5));
- wxButton* helpBtn = new wxButton(this, wxID_ANY, _("Help"));
+ wxButton *helpBtn = new wxButton(this, wxID_ANY, _("Help"));
helpBtn->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(GuidingAsstWin::OnHelp), nullptr, this);
hBtnSizer->Add(50, 0);
hBtnSizer->Add(helpBtn, wxSizerFlags(0).Border(wxALL, 5));
@@ -523,8 +539,10 @@ GuidingAsstWin::GuidingAsstWin()
// End of recommendations
m_backlashCB = new wxCheckBox(this, wxID_ANY, _("Measure Declination Backlash"));
- m_backlashCB->SetToolTip(_("PHD2 will move the guide star a considerable distance north, then south to measure backlash. Be sure the selected star has "
- "plenty of room to move in the north direction. If the guide star is lost, increase the size of the search region to at least 20 px"));
+ m_backlashCB->SetToolTip(_("PHD2 will move the guide star a considerable distance north, then south to measure backlash. "
+ "Be sure the selected star has "
+ "plenty of room to move in the north direction. If the guide star is lost, increase the size "
+ "of the search region to at least 20 px"));
if (TheScope())
{
m_backlashCB->SetValue(!pMount->HasHPEncoders());
@@ -541,9 +559,9 @@ GuidingAsstWin::GuidingAsstWin()
m_vSizer->Add(m_gaStatus, wxSizerFlags(0).Border(wxALL, 8).Center());
wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
- btnSizer->Add(10, 0); // a little spacing left of Start button
+ btnSizer->Add(10, 0); // a little spacing left of Start button
btnSizer->Add(m_backlashCB, wxSizerFlags(0).Border(wxALL, 8));
- btnSizer->Add(40, 0); // Put a spacer between the button and checkbox
+ btnSizer->Add(40, 0); // Put a spacer between the button and checkbox
m_start = new wxButton(this, wxID_ANY, _("Start"), wxDefaultPosition, wxDefaultSize, 0);
m_start->SetToolTip(_("Start measuring (disables guiding)"));
@@ -590,7 +608,7 @@ GuidingAsstWin::GuidingAsstWin()
reviewMode = false;
if (pFrame->pGuider->IsGuiding())
{
- OnStart(dummy); // Auto-start if we're already guiding
+ OnStart(dummy); // Auto-start if we're already guiding
}
}
@@ -615,38 +633,64 @@ static bool GetGridToolTip(int gridNum, const wxGridCellCoords& coords, wxString
if (gridNum > 1 && col != 0)
return false;
- else
- if (col != 0 && col != 2)
+ else if (col != 0 && col != 2)
return false;
switch (gridNum * 100 + coords.GetRow())
{
- // status grid
- case 101:
- {
- if (col == 0)
- *s = _("Signal-to-noise ratio; a measure of how well PHD2 can isolate the star from the sky/noise background");
- else
- *s = _("Measure of overall star brightness. Consider using 'Auto-select Star' (Alt-S) to choose the star.");
- break;
- }
+ // status grid
+ case 101:
+ {
+ if (col == 0)
+ *s = _("Signal-to-noise ratio; a measure of how well PHD2 can isolate the star from the sky/noise background");
+ else
+ *s = _("Measure of overall star brightness. Consider using 'Auto-select Star' (Alt-S) to choose the star.");
+ break;
+ }
- // displacement grid
- case 200: *s = _("Measure of typical high-frequency right ascension star movements; guiding usually cannot correct for fluctuations this small."); break;
- case 201: *s = _("Measure of typical high-frequency declination star movements; guiding usually cannot correct for fluctuations this small."); break;
-
- // other grid
- case 300: *s = _("Maximum sample-sample deflection seen in right ascension."); break;
- case 301: *s = _("Maximum sample-sample deflection seen in declination."); break;
- case 302: *s = _("Maximum peak-peak deflection seen in right ascension during sampling period."); break;
- case 303: *s = _("Estimated overall drift rate in right ascension."); break;
- case 304: *s = _("Maximum drift rate in right ascension during sampling period."); break;
- case 305: *s = _("Exposure time to keep maximum RA drift below the recommended min-move level."); break;
- case 306: *s = _("Estimated overall drift rate in declination."); break;
- case 307: *s = _("Estimated declination backlash if test was completed. Results are time to clear backlash (ms) and corresponding gear angle (arc-sec). Uncertainty estimate is one unit of standard deviation"); break;
- case 308: *s = _("Estimate of polar alignment error. If the scope declination is unknown, the value displayed is a lower bound and the actual error may be larger."); break;
-
- default: return false;
+ // displacement grid
+ case 200:
+ *s = _("Measure of typical high-frequency right ascension star movements; guiding usually cannot correct for "
+ "fluctuations this small.");
+ break;
+ case 201:
+ *s = _("Measure of typical high-frequency declination star movements; guiding usually cannot correct for fluctuations "
+ "this small.");
+ break;
+
+ // other grid
+ case 300:
+ *s = _("Maximum sample-sample deflection seen in right ascension.");
+ break;
+ case 301:
+ *s = _("Maximum sample-sample deflection seen in declination.");
+ break;
+ case 302:
+ *s = _("Maximum peak-peak deflection seen in right ascension during sampling period.");
+ break;
+ case 303:
+ *s = _("Estimated overall drift rate in right ascension.");
+ break;
+ case 304:
+ *s = _("Maximum drift rate in right ascension during sampling period.");
+ break;
+ case 305:
+ *s = _("Exposure time to keep maximum RA drift below the recommended min-move level.");
+ break;
+ case 306:
+ *s = _("Estimated overall drift rate in declination.");
+ break;
+ case 307:
+ *s = _("Estimated declination backlash if test was completed. Results are time to clear backlash (ms) and "
+ "corresponding gear angle (arc-sec). Uncertainty estimate is one unit of standard deviation");
+ break;
+ case 308:
+ *s = _("Estimate of polar alignment error. If the scope declination is unknown, the value displayed is a lower bound "
+ "and the actual error may be larger.");
+ break;
+
+ default:
+ return false;
}
return true;
@@ -679,15 +723,18 @@ void GuidingAsstWin::FillInstructions(DialogState eState)
break;
case STATE_START_READY:
if (!m_measurementsTaken)
- instr = _("Click Start to begin measurements. Guiding will be disabled during this time so the star will move around.");
+ instr = _(
+ "Click Start to begin measurements. Guiding will be disabled during this time so the star will move around.");
else
instr = m_instructions->GetLabel();
break;
case STATE_MEASURING:
- instr = _("Guiding output is disabled and star movement is being measured. Click Stop after 2 minutes (longer if you're measuring RA tracking accuracy of the mount).");
+ instr = _("Guiding output is disabled and star movement is being measured. Click Stop after 2 minutes (longer if "
+ "you're measuring RA tracking accuracy of the mount).");
break;
case STATE_STOPPED:
- instr = _("Guiding has been resumed. Look at the recommendations and make any desired changes. Click Start to repeat the measurements, or close the window to continue guiding.");
+ instr = _("Guiding has been resumed. Look at the recommendations and make any desired changes. Click Start to repeat "
+ "the measurements, or close the window to continue guiding.");
break;
}
m_instructions->SetLabel(instr);
@@ -729,22 +776,20 @@ void GuidingAsstWin::BacklashStep(const PHD_Point& camLoc)
double bltGearAngle = (m_backlashPx * pFrame->GetCameraPixelScale());
double bltGearAngleSigma = (bltSigmaPx * pFrame->GetCameraPixelScale());
wxString preamble = ((m_backlashMs >= 5000 || qual == BacklashTool::MEASUREMENT_TOO_FEW_NORTH) ? ">=" : "");
- wxString outStr, outStrTr; // untranslated and translated
+ wxString outStr, outStrTr; // untranslated and translated
if (qual == BacklashTool::MEASUREMENT_VALID)
{
- outStr = wxString::Format("%s %d +/- %0.0f ms (%0.1f +/- %0.1f arc-sec)",
- preamble, wxMax(0, m_backlashMs), m_backlashSigmaMs,
- wxMax(0, bltGearAngle), bltGearAngleSigma);
- outStrTr = wxString::Format("%s %d +/- %0.0f %s (%0.1f +/- %0.1f %s)",
- preamble, wxMax(0, m_backlashMs), m_backlashSigmaMs, _("ms"),
- wxMax(0, bltGearAngle), bltGearAngleSigma, _("arc-sec"));
+ outStr = wxString::Format("%s %d +/- %0.0f ms (%0.1f +/- %0.1f arc-sec)", preamble,
+ wxMax(0, m_backlashMs), m_backlashSigmaMs, wxMax(0, bltGearAngle), bltGearAngleSigma);
+ outStrTr =
+ wxString::Format("%s %d +/- %0.0f %s (%0.1f +/- %0.1f %s)", preamble, wxMax(0, m_backlashMs),
+ m_backlashSigmaMs, _("ms"), wxMax(0, bltGearAngle), bltGearAngleSigma, _("arc-sec"));
}
else
{
- outStr = wxString::Format("%s %d +/- ms (test impaired)",
- preamble, wxMax(0, m_backlashMs));
- outStrTr = wxString::Format("%s %d +/- %s",
- preamble, wxMax(0, m_backlashMs), _("ms (test impaired)"));
+ outStr = wxString::Format("%s %d +/- ms (test impaired)", preamble, wxMax(0, m_backlashMs));
+ outStrTr =
+ wxString::Format("%s %d +/- %s", preamble, wxMax(0, m_backlashMs), _("ms (test impaired)"));
}
m_othergrid->SetCellValue(m_backlash_loc, outStrTr);
HighlightCell(m_othergrid, m_backlash_loc);
@@ -829,10 +874,10 @@ void GuidingAsstWin::OnDecMinMove(wxCommandEvent& event)
void GuidingAsstWin::OnDecAlgoChange(wxCommandEvent& event)
{
if (pMount->IsStepGuider())
- return; // should never happen
+ return; // should never happen
pMount->SetGuidingEnabled(false);
// Need to make algo change through AD UI controls to keep everything in-synch
- Mount::MountConfigDialogPane* currMountPane = pFrame->pAdvancedDialog->GetCurrentMountPane();
+ Mount::MountConfigDialogPane *currMountPane = pFrame->pAdvancedDialog->GetCurrentMountPane();
currMountPane->ChangeYAlgorithm("Lowpass2");
Debug.Write("GuideAssistant changed Dec algo to Lowpass2\n");
GuideAlgorithm *decAlgo = pMount->GetYGuideAlgorithm();
@@ -845,7 +890,8 @@ void GuidingAsstWin::OnDecAlgoChange(wxCommandEvent& event)
double newAggr = 80.0;
decAlgo->SetParam("aggressiveness", newAggr);
decAlgo->SetParam("minMove", m_dec_minmove_rec);
- Debug.Write(wxString::Format("GuideAssistant set Lowpass2 aggressiveness = %0.2f, min-move = %0.2f\n", newAggr, m_dec_minmove_rec));
+ Debug.Write(
+ wxString::Format("GuideAssistant set Lowpass2 aggressiveness = %0.2f, min-move = %0.2f\n", newAggr, m_dec_minmove_rec));
pFrame->pGraphLog->UpdateControls();
pMount->SetGuidingEnabled(true);
pFrame->NotifyGuidingParam("Declination algorithm", wxString("Lowpass2"));
@@ -872,12 +918,13 @@ void GuidingAsstWin::OnGraph(wxCommandEvent& event)
if (reviewMode)
m_backlashTool->ShowGraph(this, gaDetails.BLTNorthMoves, gaDetails.BLTSouthMoves, gaDetails.BLTMsmtPulse);
else
- m_backlashTool->ShowGraph(this, m_backlashTool->GetNorthSteps(), m_backlashTool->GetSouthSteps(), m_backlashTool->GetBLTMsmtPulseSize());
+ m_backlashTool->ShowGraph(
+ this, m_backlashTool->GetNorthSteps(), m_backlashTool->GetSouthSteps(), m_backlashTool->GetBLTMsmtPulseSize());
}
void GuidingAsstWin::OnHelp(wxCommandEvent& event)
{
- pFrame->help->Display("Tools.htm#Guiding_Assistant"); // named anchors in help file are not subject to translation
+ pFrame->help->Display("Tools.htm#Guiding_Assistant"); // named anchors in help file are not subject to translation
}
static wxString SizedMsg(const wxString& msg)
@@ -889,9 +936,8 @@ static wxString SizedMsg(const wxString& msg)
}
// Adds a recommendation string and a button bound to the passed event handler
-wxStaticText *GuidingAsstWin::AddRecommendationBtn(const wxString& msg,
- void (GuidingAsstWin::* handler)(wxCommandEvent&),
- wxButton **ppButton)
+wxStaticText *GuidingAsstWin::AddRecommendationBtn(
+ const wxString& msg, void (GuidingAsstWin::*handler)(wxCommandEvent&), wxButton **ppButton)
{
wxStaticText *rec_label;
@@ -926,29 +972,26 @@ void GuidingAsstWin::LogResults()
wxString str;
Debug.Write("Guiding Assistant results follow:\n");
str = wxString::Format("SNR=%s, Samples=%s, Elapsed Time=%s, RA HPF-RMS=%s, Dec HPF-RMS=%s, Total HPF-RMS=%s\n",
- m_statusgrid->GetCellValue(m_snr_loc), m_statusgrid->GetCellValue(m_samplecount_loc), m_statusgrid->GetCellValue(m_elapsedtime_loc),
- m_displacementgrid->GetCellValue(m_ra_rms_loc),
+ m_statusgrid->GetCellValue(m_snr_loc), m_statusgrid->GetCellValue(m_samplecount_loc),
+ m_statusgrid->GetCellValue(m_elapsedtime_loc), m_displacementgrid->GetCellValue(m_ra_rms_loc),
m_displacementgrid->GetCellValue(m_dec_rms_loc), m_displacementgrid->GetCellValue(m_total_rms_loc));
GuideLog.NotifyGAResult(str);
Debug.Write(str);
str = wxString::Format("RA Peak=%s, RA Peak-Peak %s, RA Drift Rate=%s, Max RA Drift Rate=%s, Drift-Limiting Exp=%s\n",
- m_othergrid->GetCellValue(m_ra_peak_loc),
- m_othergrid->GetCellValue(m_ra_peakpeak_loc), m_othergrid->GetCellValue(m_ra_drift_loc),
- m_othergrid->GetCellValue(m_ra_peak_drift_loc),
- m_othergrid->GetCellValue(m_ra_drift_exp_loc)
- );
+ m_othergrid->GetCellValue(m_ra_peak_loc), m_othergrid->GetCellValue(m_ra_peakpeak_loc),
+ m_othergrid->GetCellValue(m_ra_drift_loc), m_othergrid->GetCellValue(m_ra_peak_drift_loc),
+ m_othergrid->GetCellValue(m_ra_drift_exp_loc));
GuideLog.NotifyGAResult(str);
Debug.Write(str);
- str = wxString::Format("Dec Drift Rate=%s, Dec Peak=%s, PA Error=%s\n",
- m_othergrid->GetCellValue(m_dec_drift_loc), m_othergrid->GetCellValue(m_dec_peak_loc),
- m_othergrid->GetCellValue(m_pae_loc));
+ str = wxString::Format("Dec Drift Rate=%s, Dec Peak=%s, PA Error=%s\n", m_othergrid->GetCellValue(m_dec_drift_loc),
+ m_othergrid->GetCellValue(m_dec_peak_loc), m_othergrid->GetCellValue(m_pae_loc));
GuideLog.NotifyGAResult(str);
Debug.Write(str);
}
// Get info regarding any saved GA sessions that include a BLT
-static void GetBLTHistory(const std::vector&Timestamps, int* oldestBLTInx, int* BLTCount)
+static void GetBLTHistory(const std::vector& Timestamps, int *oldestBLTInx, int *BLTCount)
{
int oldestInx = -1;
int bltCount = 0;
@@ -996,7 +1039,7 @@ static void TrimGAHistory(bool FreshBLT, int HistoryDepth)
}
// Save the results from the most recent GA run in the profile
-void GuidingAsstWin::SaveGAResults(const wxString* AllRecommendations)
+void GuidingAsstWin::SaveGAResults(const wxString *AllRecommendations)
{
wxString prefix = "/GA/" + startStr;
@@ -1025,7 +1068,7 @@ void GuidingAsstWin::SaveGAResults(const wxString* AllRecommendations)
if (m_backlashRecommendedMs > 0)
pConfig->Profile.SetString(prefix + "/BLT_pulse", std::to_string(m_backlashMs));
pConfig->Profile.SetString(prefix + "/recommendations", *AllRecommendations);
- bool freshBLT = m_backlashTool && m_backlashTool->IsGraphable(); // Just did a BLT that is viewable
+ bool freshBLT = m_backlashTool && m_backlashTool->IsGraphable(); // Just did a BLT that is viewable
if (freshBLT)
{
pConfig->Profile.SetInt(prefix + "/BLT_MsmtPulse", m_backlashTool->GetBLTMsmtPulseSize());
@@ -1053,10 +1096,10 @@ void GuidingAsstWin::SaveGAResults(const wxString* AllRecommendations)
}
// Reload GA results for the passed timestamp
-void GuidingAsstWin::LoadGAResults(const wxString& TimeStamp, GADetails* Details)
+void GuidingAsstWin::LoadGAResults(const wxString& TimeStamp, GADetails *Details)
{
wxString prefix = "/GA/" + TimeStamp;
- *Details = {}; // Reset all vars
+ *Details = {}; // Reset all vars
Details->TimeStamp = pConfig->Profile.GetString(prefix + "/timestamp", wxEmptyString);
Details->SNR = pConfig->Profile.GetString(prefix + "/snr", wxEmptyString);
Details->StarMass = pConfig->Profile.GetString(prefix + "/star_mass", wxEmptyString);
@@ -1107,10 +1150,10 @@ void GuidingAsstWin::LoadGAResults(const wxString& TimeStamp, GADetails* Details
}
}
-// Compute a drift-corrected value for Dec RMS and use that as a seeing estimate. For long GA runs, compute values for overlapping
-// 2-minute intervals and use the smallest result
-// Perform suitable sanity checks, revert to default "smart" recommendations if things look wonky
-void GuidingAsstWin::GetMinMoveRecs(double& RecRA, double&RecDec)
+// Compute a drift-corrected value for Dec RMS and use that as a seeing estimate. For long GA runs, compute values for
+// overlapping 2-minute intervals and use the smallest result Perform suitable sanity checks, revert to default "smart"
+// recommendations if things look wonky
+void GuidingAsstWin::GetMinMoveRecs(double& RecRA, double& RecDec)
{
AxisStats decVals;
double bestEstimate = 1000;
@@ -1120,20 +1163,21 @@ void GuidingAsstWin::GetMinMoveRecs(double& RecRA, double&RecDec)
double selRSquared = 0;
double selSlope = 0;
double correctedRMS;
- const int MEASUREMENT_WINDOW_SIZE = 120; // seconds
+ const int MEASUREMENT_WINDOW_SIZE = 120; // seconds
const int WINDOW_ADJUSTMENT = MEASUREMENT_WINDOW_SIZE / 2;
int lastInx = m_decAxisStats.GetCount() - 1;
double pxscale = pFrame->GetCameraPixelScale();
StarDisplacement val = m_decAxisStats.GetEntry(0);
double tStart = val.DeltaTime;
- double multiplier_ra; // 65% of Dec recommendation, but 100% for encoder mounts
- double multiplier_dec = (pxscale < 1.5) ? 1.28 : 1.65; // 20% or 10% activity target based on normal distribution
+ double multiplier_ra; // 65% of Dec recommendation, but 100% for encoder mounts
+ double multiplier_dec = (pxscale < 1.5) ? 1.28 : 1.65; // 20% or 10% activity target based on normal distribution
double minMoveFloor = 0.1;
try
{
- if (m_decAxisStats.GetLastEntry().DeltaTime - tStart > 1.2 * MEASUREMENT_WINDOW_SIZE) //Long GA run, more than 2.4 minutes
+ if (m_decAxisStats.GetLastEntry().DeltaTime - tStart >
+ 1.2 * MEASUREMENT_WINDOW_SIZE) // Long GA run, more than 2.4 minutes
{
bool done = false;
int inx = 0;
@@ -1141,18 +1185,21 @@ void GuidingAsstWin::GetMinMoveRecs(double& RecRA, double&RecDec)
{
val = m_decAxisStats.GetEntry(inx);
decVals.AddGuideInfo(val.DeltaTime, val.StarPos, 0);
- // Compute the minimum sigma for sliding, overlapping 2-min elapsed time intervals. Include the final interval if it's >= 1.6 minutes
- if (val.DeltaTime - tStart >= MEASUREMENT_WINDOW_SIZE || (inx == lastInx && val.DeltaTime - tStart >= 0.8 * MEASUREMENT_WINDOW_SIZE))
+ // Compute the minimum sigma for sliding, overlapping 2-min elapsed time intervals. Include the final interval
+ // if it's >= 1.6 minutes
+ if (val.DeltaTime - tStart >= MEASUREMENT_WINDOW_SIZE ||
+ (inx == lastInx && val.DeltaTime - tStart >= 0.8 * MEASUREMENT_WINDOW_SIZE))
{
if (decVals.GetCount() > 1)
{
double simpleSigma = decVals.GetSigma();
rSquared = decVals.GetLinearFitResults(&slope, &intcpt, &correctedRMS);
- // If there is little drift relative to the random movements, the drift-correction is irrelevant and can actually degrade the result. So don't use the drift-corrected
- // RMS unless it's smaller than the simple sigma
+ // If there is little drift relative to the random movements, the drift-correction is irrelevant and can
+ // actually degrade the result. So don't use the drift-corrected RMS unless it's smaller than the
+ // simple sigma
if (correctedRMS < simpleSigma)
{
- if (correctedRMS < bestEstimate) // Keep track of the smallest value seen
+ if (correctedRMS < bestEstimate) // Keep track of the smallest value seen
{
bestEstimate = correctedRMS;
selRSquared = rSquared;
@@ -1161,7 +1208,8 @@ void GuidingAsstWin::GetMinMoveRecs(double& RecRA, double&RecDec)
}
else
bestEstimate = wxMin(bestEstimate, simpleSigma);
- Debug.Write(wxString::Format("GA long series, window start=%0.0f, window end=%0.0f, Uncorrected RMS=%0.3f, Drift=%0.3f, Corrected RMS=%0.3f, R-sq=%0.3f\n",
+ Debug.Write(wxString::Format("GA long series, window start=%0.0f, window end=%0.0f, Uncorrected "
+ "RMS=%0.3f, Drift=%0.3f, Corrected RMS=%0.3f, R-sq=%0.3f\n",
tStart, val.DeltaTime, simpleSigma, slope * 60, correctedRMS, rSquared));
}
// Move the start of the next window earlier by 1 minute
@@ -1178,22 +1226,24 @@ void GuidingAsstWin::GetMinMoveRecs(double& RecRA, double&RecDec)
}
done = (inx > lastInx);
}
- Debug.Write(wxString::Format("Full uncorrected RMS=%0.3fpx, Selected Dec drift=%0.3f px/min, Best seeing estimate=%0.3fpx, R-sq=%0.3f\n",
+ Debug.Write(wxString::Format(
+ "Full uncorrected RMS=%0.3fpx, Selected Dec drift=%0.3f px/min, Best seeing estimate=%0.3fpx, R-sq=%0.3f\n",
m_decAxisStats.GetSigma(), selSlope * 60, bestEstimate, selRSquared));
}
- else // Normal GA run of <= 2.4 minutes, just use the entire interval for stats
+ else // Normal GA run of <= 2.4 minutes, just use the entire interval for stats
{
if (m_decAxisStats.GetCount() > 1)
{
double simpleSigma = m_decAxisStats.GetSigma();
rSquared = m_decAxisStats.GetLinearFitResults(&slope, &intcpt, &correctedRMS);
- // If there is little drift relative to the random movements, the drift-correction is irrelevant and can actually degrade the result. So don't use the drift-corrected
- // RMS unless it's smaller than the simple sigma
+ // If there is little drift relative to the random movements, the drift-correction is irrelevant and can
+ // actually degrade the result. So don't use the drift-corrected RMS unless it's smaller than the simple sigma
if (correctedRMS < simpleSigma)
bestEstimate = correctedRMS;
else
bestEstimate = simpleSigma;
- Debug.Write(wxString::Format("Uncorrected Dec RMS=%0.3fpx, Dec drift=%0.3f px/min, Best seeing estimate=%0.3fpx, R-sq=%0.3f\n",
+ Debug.Write(wxString::Format(
+ "Uncorrected Dec RMS=%0.3fpx, Dec drift=%0.3f px/min, Best seeing estimate=%0.3fpx, R-sq=%0.3f\n",
simpleSigma, slope * 60, bestEstimate, rSquared));
}
}
@@ -1210,7 +1260,7 @@ void GuidingAsstWin::GetMinMoveRecs(double& RecRA, double&RecDec)
double const unit = 0.05;
double roundUpEst = std::max(round(bestEstimate * multiplier_dec / unit + 0.5) * unit, 0.05);
// Now apply a sanity check - there are still numerous things that could have gone wrong during the GA
- if (pxscale * roundUpEst <= 1.25) // Min-move below 1.25 arc-sec is credible
+ if (pxscale * roundUpEst <= 1.25) // Min-move below 1.25 arc-sec is credible
{
RecDec = roundUpEst;
RecRA = wxMax(minMoveFloor, RecDec * multiplier_ra);
@@ -1219,9 +1269,11 @@ void GuidingAsstWin::GetMinMoveRecs(double& RecRA, double&RecDec)
else
{
// Just reiterate the estimates made in the new-profile-wiz
- RecDec = GuideAlgorithm::SmartDefaultMinMove(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning);
+ RecDec =
+ GuideAlgorithm::SmartDefaultMinMove(pFrame->GetFocalLength(), pCamera->GetCameraPixelSize(), pCamera->Binning);
RecRA = wxMax(minMoveFloor, RecDec * multiplier_ra);
- Debug.Write(wxString::Format("GA Min-Move calcs failed sanity-check, DecEst=%0.3f, Dec-HPF-Sigma=%0.3f\n", roundUpEst, m_hpfDecStats.GetSigma()));
+ Debug.Write(wxString::Format("GA Min-Move calcs failed sanity-check, DecEst=%0.3f, Dec-HPF-Sigma=%0.3f\n",
+ roundUpEst, m_hpfDecStats.GetSigma()));
Debug.Write(wxString::Format("GA Min-Move recs reverting to smart defaults, RA=%0.3f, Dec=%0.3f\n", RecRA, RecDec));
}
}
@@ -1235,12 +1287,12 @@ void GuidingAsstWin::GetMinMoveRecs(double& RecRA, double&RecDec)
}
}
-// See if the mount probably has large Dec backlash, using either blt results or from inference. If so, we should relax the recommendations regarding
-// polar alignment error
+// See if the mount probably has large Dec backlash, using either blt results or from inference. If so, we should relax the
+// recommendations regarding polar alignment error
bool GuidingAsstWin::LikelyBacklash(const CalibrationDetails& calDetails)
{
bool likely = false;
- BacklashComp* blc = TheScope()->GetBacklashComp(); // Always valid
+ BacklashComp *blc = TheScope()->GetBacklashComp(); // Always valid
try
{
@@ -1293,28 +1345,28 @@ void GuidingAsstWin::MakeRecommendations()
GetMinMoveRecs(m_ra_minmove_rec, m_dec_minmove_rec);
// Refine the drift-limiting exposure value based on the ra_min_move recommendation
- m_othergrid->SetCellValue(m_ra_drift_exp_loc, maxRateRA <= 0.0 ? _(" ") :
- wxString::Format("%6.1f %s ", m_ra_minmove_rec / maxRateRA, (_("s"))));
+ m_othergrid->SetCellValue(
+ m_ra_drift_exp_loc, maxRateRA <= 0.0 ? _(" ") : wxString::Format("%6.1f %s ", m_ra_minmove_rec / maxRateRA, (_("s"))));
- LogResults(); // Dump the raw statistics
+ LogResults(); // Dump the raw statistics
// REMINDER: Any new recommendations must also be done in 'DisplayStaticRecommendations'
// Clump the no-button messages at the top
// ideal exposure ranges in general
double rarms = m_hpfRAStats.GetSigma();
- double multiplier_ra = 1.0; // 66% prediction interval
+ double multiplier_ra = 1.0; // 66% prediction interval
double ideal_min_exposure = 2.0;
double ideal_max_exposure = 4.0;
// adjust the min-exposure downward if drift limiting exposure is lower; then adjust range accordingly
double drift_exp;
if (maxRateRA > 0)
- drift_exp = ceil((multiplier_ra * rarms / maxRateRA) / 0.5) * 0.5; // Rounded up to nearest 0.5 sec
+ drift_exp = ceil((multiplier_ra * rarms / maxRateRA) / 0.5) * 0.5; // Rounded up to nearest 0.5 sec
else
drift_exp = ideal_min_exposure;
double min_rec_range = 2.0;
double pxscale = pFrame->GetCameraPixelScale();
- m_min_exp_rec = std::max(1.0, std::min(drift_exp, ideal_min_exposure)); // smaller of drift and ideal, never less than 1.0
+ m_min_exp_rec = std::max(1.0, std::min(drift_exp, ideal_min_exposure)); // smaller of drift and ideal, never less than 1.0
if (drift_exp > m_min_exp_rec)
{
@@ -1332,7 +1384,8 @@ void GuidingAsstWin::MakeRecommendations()
wxString allRecommendations;
// Always make a recommendation on exposure times
- wxString msg = wxString::Format(_("Try to keep your exposure times in the range of %.1fs to %.1fs"), m_min_exp_rec, m_max_exp_rec);
+ wxString msg =
+ wxString::Format(_("Try to keep your exposure times in the range of %.1fs to %.1fs"), m_min_exp_rec, m_max_exp_rec);
allRecommendations += "Exp:" + msg + "\n";
m_exposure_msg = AddRecommendationMsg(msg);
Debug.Write(wxString::Format("Recommendation: %s\n", msg));
@@ -1359,7 +1412,7 @@ void GuidingAsstWin::MakeRecommendations()
GuideLog.NotifyGAResult(logStr);
}
// SNR
- if ((sumSNR / (double)m_lpfRAStats.GetCount()) < 10.0)
+ if ((sumSNR / (double) m_lpfRAStats.GetCount()) < 10.0)
{
wxString msg(_("Consider using a brighter star for the test or increasing the exposure time"));
allRecommendations += "Star:" + msg + "\n";
@@ -1381,9 +1434,9 @@ void GuidingAsstWin::MakeRecommendations()
}
else
{
- msg = alignmentError < 10.0 ?
- _("Polar alignment error > 5 arc-min; that could probably be improved.") :
- _("Polar alignment error > 10 arc-min; try using the Drift Align tool to improve alignment.");
+ msg = alignmentError < 10.0
+ ? _("Polar alignment error > 5 arc-min; that could probably be improved.")
+ : _("Polar alignment error > 10 arc-min; try using the Drift Align tool to improve alignment.");
}
if (msg != "")
{
@@ -1437,7 +1490,7 @@ void GuidingAsstWin::MakeRecommendations()
if (m_backlashMs > 0)
{
- m_backlashRecommendedMs = (int)(floor(m_backlashMs / 10) * 10); // round down to nearest 10ms
+ m_backlashRecommendedMs = (int) (floor(m_backlashMs / 10) * 10); // round down to nearest 10ms
m_backlashRecommendedMs = wxMax(m_backlashRecommendedMs, 10);
}
else
@@ -1448,15 +1501,15 @@ void GuidingAsstWin::MakeRecommendations()
if (pMount->HasHPEncoders())
msg = _("Mount has absolute encoders, no compensation needed");
else
- msg = _("Backlash is small, no compensation needed"); // assume it was a small measurement error
+ msg = _("Backlash is small, no compensation needed"); // assume it was a small measurement error
smallBacklash = true;
}
else if (m_backlashMs <= MAX_BACKLASH_COMP)
msg = wxString::Format(_("Try starting with a Dec backlash compensation of %d ms"), m_backlashRecommendedMs);
else
{
- msg = wxString::Format(_("Backlash is >= %d ms; you may need to guide in only one Dec direction (currently %s)"), m_backlashMs,
- decDriftPerMin >= 0 ? _("South") : _("North"));
+ msg = wxString::Format(_("Backlash is >= %d ms; you may need to guide in only one Dec direction (currently %s)"),
+ m_backlashMs, decDriftPerMin >= 0 ? _("South") : _("North"));
}
allRecommendations += "BLT:" + msg + "\n";
m_backlash_msg = AddRecommendationBtn(msg, &GuidingAsstWin::OnDecBacklash, &m_decBacklashButton);
@@ -1467,11 +1520,11 @@ void GuidingAsstWin::MakeRecommendations()
}
bool hasEncoders = pMount->HasHPEncoders();
- if (hasEncoders || smallBacklash) // Uses encoders or has zero backlash
+ if (hasEncoders || smallBacklash) // Uses encoders or has zero backlash
{
GuideAlgorithm *decAlgo = pMount->GetYGuideAlgorithm();
wxString algoChoice = decAlgo->GetGuideAlgorithmClassName();
- if (algoChoice == "ResistSwitch") // automatically rules out AO's
+ if (algoChoice == "ResistSwitch") // automatically rules out AO's
{
wxString msgText = _("Try using Lowpass2 for Dec guiding");
allRecommendations += "DecAlgo:" + msgText + "\n";
@@ -1500,7 +1553,7 @@ void GuidingAsstWin::DisplayStaticRecommendations(const GADetails& details)
bool done = false;
size_t end;
- m_recommendgrid->Clear(true); // Always start fresh, delete any child buttons
+ m_recommendgrid->Clear(true); // Always start fresh, delete any child buttons
while (!done)
{
end = allRecs.find_first_of("\n");
@@ -1622,13 +1675,13 @@ void GuidingAsstWin::OnReviewPrevious(wxCommandEvent& event)
std::vector entryNames;
entryNames = pConfig->Profile.GetGroupNames("/GA");
- wxMenu* reviewList = new wxMenu();
+ wxMenu *reviewList = new wxMenu();
for (int inx = 0; inx < entryNames.size(); inx++)
{
reviewList->Append(GA_REVIEW_ITEMS_BASE + inx, entryNames[inx]);
}
- PopupMenu(reviewList, btnReviewPrev->GetPosition().x,
- btnReviewPrev->GetPosition().y + btnReviewPrev->GetSize().GetHeight());
+ PopupMenu(
+ reviewList, btnReviewPrev->GetPosition().x, btnReviewPrev->GetPosition().y + btnReviewPrev->GetSize().GetHeight());
wxDELETE(reviewList);
}
@@ -1657,7 +1710,8 @@ void GuidingAsstWin::DoStop(const wxString& status)
if (m_guideOutputDisabled)
{
- Debug.Write(wxString::Format("GuidingAssistant: Re-enabling guide output (%d, %d)\n", m_savePrimaryMountEnabled, m_saveSecondaryMountEnabled));
+ Debug.Write(wxString::Format(
+ "GuidingAssistant: Re-enabling guide output (%d, %d)\n", m_savePrimaryMountEnabled, m_saveSecondaryMountEnabled));
if (pMount)
pMount->SetGuidingEnabled(m_savePrimaryMountEnabled);
@@ -1665,7 +1719,7 @@ void GuidingAsstWin::DoStop(const wxString& status)
pSecondaryMount->SetGuidingEnabled(m_saveSecondaryMountEnabled);
m_guideOutputDisabled = false;
- pFrame->pGuider->SetMultiStarMode(origMultistarMode); // may force an auto-find to refresh secondary star data
+ pFrame->pGuider->SetMultiStarMode(origMultistarMode); // may force an auto-find to refresh secondary star data
pFrame->SetVariableDelayConfig(origVarDelayConfig.enabled, origVarDelayConfig.shortDelay, origVarDelayConfig.longDelay);
}
@@ -1700,7 +1754,7 @@ void GuidingAsstWin::EndBacklashTest(bool completed)
if (!completed)
{
wxCommandEvent dummy;
- OnAppStateNotify(dummy); // Make sure UI is in synch
+ OnAppStateNotify(dummy); // Make sure UI is in synch
}
DoStop();
}
@@ -1720,7 +1774,7 @@ void GuidingAsstWin::OnStop(wxCommandEvent& event)
m_gaStatus->SetLabel(wxEmptyString);
if (longEnough && performBLT)
{
- if (!m_measuringBacklash) // Run the backlash test after the sampling was completed
+ if (!m_measuringBacklash) // Run the backlash test after the sampling was completed
{
m_measuringBacklash = true;
if (m_origSubFrames == -1)
@@ -1730,7 +1784,7 @@ void GuidingAsstWin::OnStop(wxCommandEvent& event)
m_gaStatus->SetLabelText(_("Measuring backlash... ") + m_backlashTool->GetLastStatus());
Layout();
GetSizer()->Fit(this);
- m_backlashCB->Enable(false); // Don't let user turn it off once we've started
+ m_backlashCB->Enable(false); // Don't let user turn it off once we've started
m_measuring = false;
m_backlashTool->StartMeasurement(decDriftPerMin);
m_instructions->SetLabel(_("Measuring backlash... "));
@@ -1791,8 +1845,8 @@ void GuidingAsstWin::OnClose(wxCloseEvent& evt)
Destroy();
}
-void GuidingAsstWin::FillResultCell(wxGrid *pGrid, const wxGridCellCoords& loc, double pxVal, double asVal, const wxString& units1, const wxString& units2,
- const wxString& extraInfo)
+void GuidingAsstWin::FillResultCell(wxGrid *pGrid, const wxGridCellCoords& loc, double pxVal, double asVal,
+ const wxString& units1, const wxString& units2, const wxString& extraInfo)
{
pGrid->SetCellValue(loc, wxString::Format("%6.2f %s (%6.2f %s %s)", pxVal, units1, asVal, units2, extraInfo));
}
@@ -1848,7 +1902,7 @@ void GuidingAsstWin::UpdateInfo(const GuideStepInfo& info)
}
// Update the time measures
wxLongLong_t elapsedms = ::wxGetUTCTimeMillis().GetValue() - m_startTime;
- m_elapsedSecs = (double)elapsedms / 1000.0;
+ m_elapsedSecs = (double) elapsedms / 1000.0;
// add offset info to various stats accumulations
m_hpfRAStats.AddValue(m_raHPF.AddValue(ra));
double prevRAlpf = m_raLPF.GetCurrentLPF();
@@ -1882,7 +1936,7 @@ void GuidingAsstWin::UpdateInfo(const GuideStepInfo& info)
m_lastTime = info.time;
sumSNR += info.starSNR;
sumMass += info.starMass;
- double n = (double)m_lpfRAStats.GetCount();
+ double n = (double) m_lpfRAStats.GetCount();
wxString SEC(_("s"));
wxString MSEC(_("ms"));
@@ -1895,10 +1949,11 @@ void GuidingAsstWin::UpdateInfo(const GuideStepInfo& info)
wxString ARCSECPERSEC(_("arc-sec/sec"));
m_statusgrid->SetCellValue(m_timestamp_loc, startStr);
- m_statusgrid->SetCellValue(m_exposuretime_loc, wxString::Format("%g%s", (double)pFrame->RequestedExposureDuration() / 1000.0, SEC));
+ m_statusgrid->SetCellValue(
+ m_exposuretime_loc, wxString::Format("%g%s", (double) pFrame->RequestedExposureDuration() / 1000.0, SEC));
m_statusgrid->SetCellValue(m_snr_loc, wxString::Format("%.1f", sumSNR / n));
m_statusgrid->SetCellValue(m_starmass_loc, wxString::Format("%.1f", sumMass / n));
- m_statusgrid->SetCellValue(m_elapsedtime_loc, wxString::Format("%u%s", (unsigned int)(elapsedms / 1000), SEC));
+ m_statusgrid->SetCellValue(m_elapsedtime_loc, wxString::Format("%u%s", (unsigned int) (elapsedms / 1000), SEC));
m_statusgrid->SetCellValue(m_samplecount_loc, wxString::Format("%.0f", n));
if (n > 1)
@@ -1927,19 +1982,22 @@ void GuidingAsstWin::UpdateInfo(const GuideStepInfo& info)
FillResultCell(m_displacementgrid, m_ra_rms_loc, rarms, rarms * pxscale, PX, ARCSEC);
FillResultCell(m_displacementgrid, m_dec_rms_loc, decrms, decrms * pxscale, PX, ARCSEC);
FillResultCell(m_displacementgrid, m_total_rms_loc, combined, combined * pxscale, PX, ARCSEC);
- FillResultCell(m_othergrid, m_ra_peak_loc,
- m_raAxisStats.GetMaxDelta(), m_raAxisStats.GetMaxDelta() * pxscale, PX, ARCSEC);
- FillResultCell(m_othergrid, m_dec_peak_loc,
- m_decAxisStats.GetMaxDelta(), m_decAxisStats.GetMaxDelta() * pxscale, PX, ARCSEC);
+ FillResultCell(
+ m_othergrid, m_ra_peak_loc, m_raAxisStats.GetMaxDelta(), m_raAxisStats.GetMaxDelta() * pxscale, PX, ARCSEC);
+ FillResultCell(
+ m_othergrid, m_dec_peak_loc, m_decAxisStats.GetMaxDelta(), m_decAxisStats.GetMaxDelta() * pxscale, PX, ARCSEC);
double raPkPk = m_lpfRAStats.GetMaximum() - m_lpfRAStats.GetMinimum();
FillResultCell(m_othergrid, m_ra_peakpeak_loc, raPkPk, raPkPk * pxscale, PX, ARCSEC);
- double raDriftRate = (ra - m_startPos.X) / m_elapsedSecs * 60.0; // Raw max-min, can't smooth this one reliably
+ double raDriftRate = (ra - m_startPos.X) / m_elapsedSecs * 60.0; // Raw max-min, can't smooth this one reliably
FillResultCell(m_othergrid, m_ra_drift_loc, raDriftRate, raDriftRate * pxscale, PXPERMIN, ARCSECPERMIN);
FillResultCell(m_othergrid, m_ra_peak_drift_loc, maxRateRA, maxRateRA * pxscale, PXPERSEC, ARCSECPERSEC);
- m_othergrid->SetCellValue(m_ra_drift_exp_loc, maxRateRA <= 0.0 ? _(" ") :
- wxString::Format("%6.1f %s ", 1.3 * rarms / maxRateRA, SEC)); // Will get revised when min-move is computed
+ m_othergrid->SetCellValue(m_ra_drift_exp_loc,
+ maxRateRA <= 0.0
+ ? _(" ")
+ : wxString::Format("%6.1f %s ", 1.3 * rarms / maxRateRA, SEC)); // Will get revised when min-move is computed
FillResultCell(m_othergrid, m_dec_drift_loc, decDriftPerMin, decDriftPerMin * pxscale, PXPERMIN, ARCSECPERMIN);
- m_othergrid->SetCellValue(m_pae_loc, wxString::Format("%s %.1f %s", declination == UNKNOWN_DECLINATION ? "> " : "", alignmentError, ARCMIN));
+ m_othergrid->SetCellValue(
+ m_pae_loc, wxString::Format("%s %.1f %s", declination == UNKNOWN_DECLINATION ? "> " : "", alignmentError, ARCMIN));
}
}
diff --git a/src/guiding_assistant.h b/src/guiding_assistant.h
index 320fd44e8..b29c24ce4 100644
--- a/src/guiding_assistant.h
+++ b/src/guiding_assistant.h
@@ -1,36 +1,36 @@
/*
-* guiding_assistant.h
-* PHD Guiding
-*
-* Created by Andy Galasso
-* Copyright (c) 2015 Andy Galasso
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * guiding_assistant.h
+ * PHD Guiding
+ *
+ * Created by Andy Galasso
+ * Copyright (c) 2015 Andy Galasso
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#ifndef GUIDING_ASSISTANT_INCLUDED
#define GUIDING_ASSISTANT_INCLUDED
diff --git a/src/guiding_stats.cpp b/src/guiding_stats.cpp
index fd114b525..748c7b3da 100644
--- a/src/guiding_stats.cpp
+++ b/src/guiding_stats.cpp
@@ -1,37 +1,37 @@
/*
-* guiding_stats.cpp
-* PHD2 Guiding
-*
-* Created by Bruce Waddington
-* Copyright (c) 2018 Bruce Waddington
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development,
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * guiding_stats.cpp
+ * PHD2 Guiding
+ *
+ * Created by Bruce Waddington
+ * Copyright (c) 2018 Bruce Waddington
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development,
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include "phd.h"
#include
@@ -45,17 +45,14 @@
// differences, which can lead to things like negative variances
// See: http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
-// DescriptiveStats is used for non-windowed datasets. Max, min, sigma and variance are computed on-the-fly as values are added to dataset
-// Applicable to any double values, no semantic assumptions made. Does not retain a list of values
+// DescriptiveStats is used for non-windowed datasets. Max, min, sigma and variance are computed on-the-fly as values are added
+// to dataset Applicable to any double values, no semantic assumptions made. Does not retain a list of values
DescriptiveStats::DescriptiveStats()
{
ClearAll();
}
-DescriptiveStats::~DescriptiveStats()
-{
-
-}
+DescriptiveStats::~DescriptiveStats() { }
// Add a new double value, update stats
void DescriptiveStats::AddValue(double Val)
@@ -183,8 +180,8 @@ double DescriptiveStats::GetMaxDelta()
return 0.;
}
-// Applies a high-pass filter to a stream of data, one sample point at a time. Samples are not retained, client can use DescriptiveStats or AxisStats
-// on the filtered data values
+// Applies a high-pass filter to a stream of data, one sample point at a time. Samples are not retained, client can use
+// DescriptiveStats or AxisStats on the filtered data values
HighPassFilter::HighPassFilter(double CutoffPeriod, double SamplePeriod)
{
alphaCutoff = CutoffPeriod / (CutoffPeriod + std::max(1.0, SamplePeriod));
@@ -276,9 +273,7 @@ AxisStats::AxisStats()
InitializeScalars();
}
-AxisStats::~AxisStats()
-{
-}
+AxisStats::~AxisStats() { }
void AxisStats::ClearAll()
{
@@ -355,7 +350,7 @@ void AxisStats::AddGuideInfo(double DeltaT, double StarPos, double GuideAmt)
if (newDelta >= maxDelta)
{
maxDelta = newDelta;
- maxDeltaInx = guidingEntries.size(); // where the entry is going to go - furthest down in list among equals
+ maxDeltaInx = guidingEntries.size(); // where the entry is going to go - furthest down in list among equals
}
}
@@ -475,7 +470,7 @@ double AxisStats::GetMedian() const
double rslt = 0.;
// Need a copy of guidingEntries to do a sort
- std::vector sortedEntries;
+ std::vector sortedEntries;
for (auto pGS = guidingEntries.begin(); pGS != guidingEntries.end(); ++pGS)
{
@@ -543,7 +538,8 @@ double AxisStats::GetLinearFitResults(double *Slope, double *Intercept, double *
double currentMean = 0.;
double slope = ((numVals * sumXY) - (sumX * sumY)) / ((numVals * sumXSq) - (sumX * sumX));
- //double constrainedSlope = sumXY / sumXSq; // Possible future use, slope value if intercept is constrained to be zero
+ // double constrainedSlope = sumXY / sumXSq; // Possible future use, slope value if intercept is constrained to be
+ // zero
double intcpt = (sumY - (slope * sumX)) / numVals;
if (Sigma)
@@ -578,18 +574,17 @@ double AxisStats::GetLinearFitResults(double *Slope, double *Intercept, double *
return rSquared;
}
-WindowedAxisStats::WindowedAxisStats(int AutoWindowSize) : AxisStats()
+WindowedAxisStats::WindowedAxisStats(int AutoWindowSize)
+ : AxisStats()
{
autoWindowing = AutoWindowSize > 0;
windowSize = AutoWindowSize;
}
-WindowedAxisStats::~WindowedAxisStats()
-{
-
-}
+WindowedAxisStats::~WindowedAxisStats() { }
-// Change the auto-window size - trim older entries if necessary. Setting size to zero disables auto-windowing but does not discard data
+// Change the auto-window size - trim older entries if necessary. Setting size to zero disables auto-windowing but does not
+// discard data
bool WindowedAxisStats::ChangeWindowSize(unsigned int NewSize)
{
bool success = false;
@@ -625,7 +620,7 @@ bool WindowedAxisStats::ChangeWindowSize(unsigned int NewSize)
// entry[0] (the oldest) is actually removed.
void WindowedAxisStats::AdjustMinMaxValues()
{
- StarDisplacement target = guidingEntries.front(); // Entry that's about to be removed
+ StarDisplacement target = guidingEntries.front(); // Entry that's about to be removed
bool recalNeeded = false;
double prev = target.StarPos;
@@ -643,7 +638,8 @@ void WindowedAxisStats::AdjustMinMaxValues()
if (recalNeeded)
{
- for (auto pGS = guidingEntries.begin() + 1; pGS != guidingEntries.end(); ++pGS) // Dont start at zero, that will be removed
+ for (auto pGS = guidingEntries.begin() + 1; pGS != guidingEntries.end();
+ ++pGS) // Dont start at zero, that will be removed
{
StarDisplacement entry = *pGS;
minDisplacement = std::min(minDisplacement, entry.StarPos);
@@ -680,7 +676,7 @@ void WindowedAxisStats::RemoveOldestEntry()
axisReversals--;
if (target.Guided)
axisMoves--;
- AdjustMinMaxValues(); // Will process list only if required
+ AdjustMinMaxValues(); // Will process list only if required
guidingEntries.pop_front();
maxDeltaInx--;
}
diff --git a/src/guiding_stats.h b/src/guiding_stats.h
index e9a144d10..29412c231 100644
--- a/src/guiding_stats.h
+++ b/src/guiding_stats.h
@@ -1,76 +1,76 @@
/*
-* guiding_stats.h
-* PHD2 Guiding
-*
-* Created by Bruce Waddington
-* Copyright (c) 2018 Bruce Waddington
-* All rights reserved.
-*
-* This source code is distributed under the following "BSD" license
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
-* this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* Neither the name of Bret McKee, Dad Dog Development,
-* Craig Stark, Stark Labs nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*
-*/
+ * guiding_stats.h
+ * PHD2 Guiding
+ *
+ * Created by Bruce Waddington
+ * Copyright (c) 2018 Bruce Waddington
+ * All rights reserved.
+ *
+ * This source code is distributed under the following "BSD" license
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of Bret McKee, Dad Dog Development,
+ * Craig Stark, Stark Labs nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#ifndef _GUIDING_STATS_H
#define _GUIDING_STATS_H
#include
-// DescriptiveStats is used for basic statistics. Max, min, sigma and variance are computed on-the-fly as values are added to a dataset
-// Applicable to any double values, no semantic assumptions made. Does not retain a list of values
+// DescriptiveStats is used for basic statistics. Max, min, sigma and variance are computed on-the-fly as values are added to a
+// dataset Applicable to any double values, no semantic assumptions made. Does not retain a list of values
class DescriptiveStats
{
private:
int count;
- double runningS; // S denotes square of deltas from mean (variance)
+ double runningS; // S denotes square of deltas from mean (variance)
double newS;
- double runningMean; // current mean of dataset
+ double runningMean; // current mean of dataset
double newMean;
- double minValue; // current min value of dataset
- double maxValue; // current max value of dataset
- double lastValue; // for clients to easily compute deltas
- double maxDelta; // max absolute (delta(value))
+ double minValue; // current min value of dataset
+ double maxValue; // current max value of dataset
+ double lastValue; // for clients to easily compute deltas
+ double maxDelta; // max absolute (delta(value))
public:
DescriptiveStats();
~DescriptiveStats();
- void AddValue(double Val); // Add a double value to the dataset
- void ClearAll(); // Start over, reset all variables
- unsigned int GetCount(); // Returns the count of the dataset
- double GetLastValue(); // Returns the immediately previous value added to the dataset
- double GetMean(); // Returns the mean value of the dataset
- double GetSum(); // Sum of all added vars
- double GetMinimum(); // Returns the min value
- double GetMaximum(); // Returns the max value
- double GetVariance(); // Variance for those who need it
- double GetSigma(); // Returns the standard deviation
- double GetPopulationSigma(); // Population sigma ('n' vs 'n-1')
- double GetMaxDelta(); // Returns max of absolute delta(new - previous) values
+ void AddValue(double Val); // Add a double value to the dataset
+ void ClearAll(); // Start over, reset all variables
+ unsigned int GetCount(); // Returns the count of the dataset
+ double GetLastValue(); // Returns the immediately previous value added to the dataset
+ double GetMean(); // Returns the mean value of the dataset
+ double GetSum(); // Sum of all added vars
+ double GetMinimum(); // Returns the min value
+ double GetMaximum(); // Returns the max value
+ double GetVariance(); // Variance for those who need it
+ double GetSigma(); // Returns the standard deviation
+ double GetPopulationSigma(); // Population sigma ('n' vs 'n-1')
+ double GetMaxDelta(); // Returns max of absolute delta(new - previous) values
};
-// High and Low pass filters can be used to filter a stream of data elements that can then be added to DescriptiveStats or AxisStats
-// A low-pass filter will attenuate (dampen) high-frequency elements, a high-pass filter will do the opposite
+// High and Low pass filters can be used to filter a stream of data elements that can then be added to DescriptiveStats or
+// AxisStats A low-pass filter will attenuate (dampen) high-frequency elements, a high-pass filter will do the opposite
// Examples: use a low-pass filter to emphasize low-frequency data fluctuations such as a slow linear drift
// use a high-pass filter to ignore linear drift but emphasize more rapid fluctuations
// Neither class retains any history of the data, the client is responsble for using the HPF/LPF values as needed
@@ -117,32 +117,33 @@ struct StarDisplacement
StarDisplacement(double When, double Where);
};
-// AxisStats and the StarDisplacement class can be used to collect and evaluate typical guiding data. Datasets can be windowed or not.
-// Windowing means the data collection is limited to the most recent entries.
-// Windowed datasets will be automatically trimmed if AutoWindowSize > 0 or can be manually trimmed by client using RemoveOldestEntry()
+// AxisStats and the StarDisplacement class can be used to collect and evaluate typical guiding data. Datasets can be windowed
+// or not. Windowing means the data collection is limited to the most recent entries. Windowed datasets will be
+// automatically trimmed if AutoWindowSize > 0 or can be manually trimmed by client using RemoveOldestEntry()
class AxisStats
{
protected:
- std::deque guidingEntries; // queue of elements in dataset
- unsigned int axisMoves; // number of times in window when guide pulse was non-zero
- unsigned int axisReversals; // number of times in window when guide pulse caused a direction reversal
- double prevMove; // value of guide pulse in next-to-last entry
- double prevPosition; // value of guide star location in next-to-last entry
+ std::deque guidingEntries; // queue of elements in dataset
+ unsigned int axisMoves; // number of times in window when guide pulse was non-zero
+ unsigned int axisReversals; // number of times in window when guide pulse caused a direction reversal
+ double prevMove; // value of guide pulse in next-to-last entry
+ double prevPosition; // value of guide star location in next-to-last entry
// Variables used to compute stats in windowed AxisStats
- double sumX; // Sum of the x values (deltaT values)
- double sumY; // Sum of the y values (star position)
- double sumXY; // Sum of (x * y)
- double sumXSq; // Sum of (x squared)
- double sumYSq; // Sum of (y squared)
+ double sumX; // Sum of the x values (deltaT values)
+ double sumY; // Sum of the y values (star position)
+ double sumXY; // Sum of (x * y)
+ double sumXSq; // Sum of (x squared)
+ double sumYSq; // Sum of (y squared)
// Variables needed for windowed or non-windowed versions
- double maxDisplacement; // maximum star position value in current dataset
- double minDisplacement; // minimum star position value in current dataset
- double maxDelta; // maximum absolute delta of incremental star deltas
+ double maxDisplacement; // maximum star position value in current dataset
+ double minDisplacement; // minimum star position value in current dataset
+ double maxDelta; // maximum absolute delta of incremental star deltas
int maxDeltaInx;
void InitializeScalars();
public:
- // Constructor for 3 types of instance: non-windowed, windowed with automatic trimming of size, windowed but with client controlling actual window size
+ // Constructor for 3 types of instance: non-windowed, windowed with automatic trimming of size, windowed but with client
+ // controlling actual window size
AxisStats();
~AxisStats();
@@ -157,7 +158,8 @@ class AxisStats
// Return the count of elements in the dataset
unsigned int GetCount() const;
- // Get the last entry added to the dataset - useful if client needs to do difference operations for time, star position, or guide amount
+ // Get the last entry added to the dataset - useful if client needs to do difference operations for time, star position, or
+ // guide amount
StarDisplacement GetLastEntry() const;
// Get the maximum y value in the dataset
@@ -178,14 +180,14 @@ class AxisStats
unsigned int GetMoveCount() const;
unsigned int GetReversalCount() const;
- // Perform a linear fit on the star position values in the dataset. Return usual slope and y-intercept values along with "constrained slope" -
- // the slope when the y-intercept is forced to zero. Optionally, apply the fit to the original data values and computed the
- // standard deviation (Sigma) of the resulting drift-removed dataset. Drift-removed data values are discarded, original data elements are unmodified
- // Example 1: do a linear fit during calibration to compute an angle - "Sigma" is not needed
- // Example 2: do a linear fit on Dec values during a GA run - use the slope to compute a polar alignment error, use Sigma to estimate seeing of drift-corrected Dec values
- // Returns a coefficient of determination, R-Squared, a form of correlation assessment
- double GetLinearFitResults(double* Slope, double* Intercept, double* Sigma = NULL) const;
-
+ // Perform a linear fit on the star position values in the dataset. Return usual slope and y-intercept values along with
+ // "constrained slope" - the slope when the y-intercept is forced to zero. Optionally, apply the fit to the original data
+ // values and computed the standard deviation (Sigma) of the resulting drift-removed dataset. Drift-removed data values are
+ // discarded, original data elements are unmodified Example 1: do a linear fit during calibration to compute an angle -
+ // "Sigma" is not needed Example 2: do a linear fit on Dec values during a GA run - use the slope to compute a polar
+ // alignment error, use Sigma to estimate seeing of drift-corrected Dec values Returns a coefficient of determination,
+ // R-Squared, a form of correlation assessment
+ double GetLinearFitResults(double *Slope, double *Intercept, double *Sigma = NULL) const;
};
class WindowedAxisStats : public AxisStats
@@ -199,7 +201,8 @@ class WindowedAxisStats : public AxisStats
WindowedAxisStats(int AutoWindowSize);
~WindowedAxisStats();
- // Change the window size of an active dataset - all stats will be adjusted accordingly to reflect the most recent elements
+ // Change the window size of an active dataset - all stats will be adjusted accordingly to reflect the most recent
+ // elements
bool ChangeWindowSize(unsigned int NewWSize);
void RemoveOldestEntry();
void AddGuideInfo(double DeltaT, double StarPos, double GuideAmt);
diff --git a/src/guidinglog.cpp b/src/guidinglog.cpp
index ffb9dda61..3a580a6df 100644
--- a/src/guidinglog.cpp
+++ b/src/guidinglog.cpp
@@ -43,24 +43,24 @@
const int RetentionPeriod = 60;
GuidingLog::GuidingLog()
- :
- m_enabled(false),
- m_keepFile(false),
- m_isGuiding(false)
+ : m_enabled(false)
+ , m_keepFile(false)
+ , m_isGuiding(false)
{
}
-GuidingLog::~GuidingLog()
-{
-}
+GuidingLog::~GuidingLog() { }
static wxString PierSideStr(PierSide p)
{
switch (p)
{
- case PIER_SIDE_EAST: return "East";
- case PIER_SIDE_WEST: return "West";
- default: return "Unknown";
+ case PIER_SIDE_EAST:
+ return "East";
+ case PIER_SIDE_WEST:
+ return "West";
+ default:
+ return "Unknown";
}
}
@@ -68,9 +68,12 @@ static wxString ParityStr(int p)
{
switch (p)
{
- case GUIDE_PARITY_EVEN: return "Even";
- case GUIDE_PARITY_ODD: return "Odd";
- default: return "N/A";
+ case GUIDE_PARITY_EVEN:
+ return "Even";
+ case GUIDE_PARITY_ODD:
+ return "Odd";
+ default:
+ return "N/A";
}
}
@@ -119,8 +122,7 @@ static void GetAltAz(double Latitude, double HA, double Dec, double& Altitude, d
// Now get azimuth - alternative formula using zSin avoids div-by-zero conditions
double As = cos(decRadians) * sin(haRadians) / zSin;
- double Ac = (sin(latRadians) * cos(decRadians) * cos(haRadians) - cos(latRadians) *
- sin(decRadians)) / zSin;
+ double Ac = (sin(latRadians) * cos(decRadians) * cos(haRadians) - cos(latRadians) * sin(decRadians)) / zSin;
// atan2 doesn't want both params = 0
if (Ac == 0.0 && As == 0.0)
{
@@ -152,7 +154,8 @@ static wxString PointingInfo()
}
else
{
- rslt = wxString::Format("RA/Dec = Unknown, Hour angle = Unknown, Pier side = Unknown, Rotator pos = %s, ", RotatorPosStr());
+ rslt = wxString::Format(
+ "RA/Dec = Unknown, Hour angle = Unknown, Pier side = Unknown, Rotator pos = %s, ", RotatorPosStr());
pointingError = true;
}
if (pPointingSource && !pointingError && !pPointingSource->GetSiteLatLong(&latitude, &longitude))
@@ -193,11 +196,8 @@ static void GuidingHeader(wxFFile& file)
const Star& star = pFrame->pGuider->PrimaryStar();
file.Write(wxString::Format("Lock position = %.3f, %.3f, Star position = %.3f, %.3f, HFD = %.2f px\n",
- pFrame->pGuider->LockPosition().X,
- pFrame->pGuider->LockPosition().Y,
- pFrame->pGuider->CurrentPosition().X,
- pFrame->pGuider->CurrentPosition().Y,
- star.HFD));
+ pFrame->pGuider->LockPosition().X, pFrame->pGuider->LockPosition().Y, pFrame->pGuider->CurrentPosition().X,
+ pFrame->pGuider->CurrentPosition().Y, star.HFD));
file.Write("Frame,Time,mount,dx,dy,RARawDistance,DECRawDistance,RAGuideDistance,DECGuideDistance,"
"RADuration,RADirection,DECDuration,DECDirection,XStep,YStep,StarMass,SNR,ErrorCode\n");
@@ -208,9 +208,8 @@ static void WriteSummaryInfo(wxFFile& file, const GuideLogSummaryInfo& summary)
if (!summary.valid)
return;
- file.Write(wxString::Format("Log Summary: calcnt:%u gcnt:%u gdur:%.f gacnt:%u\n",
- summary.cal_cnt, summary.guide_cnt, summary.guide_dur,
- summary.ga_cnt));
+ file.Write(wxString::Format("Log Summary: calcnt:%u gcnt:%u gdur:%.f gacnt:%u\n", summary.cal_cnt, summary.guide_cnt,
+ summary.guide_dur, summary.ga_cnt));
}
void GuideLogSummaryInfo::LoadSummaryInfo(wxFFile& file)
@@ -220,11 +219,25 @@ void GuideLogSummaryInfo::LoadSummaryInfo(wxFFile& file)
wxFFileInputStream is(file);
if (is.IsOk())
{
- struct RestorePos {
+ struct RestorePos
+ {
wxFFile& f;
wxFileOffset o;
- RestorePos(wxFFile& f_) : f(f_) { o = f.Tell(); }
- ~RestorePos() { try { f.Seek(o); } catch (...) {} }
+ RestorePos(wxFFile& f_)
+ : f(f_)
+ {
+ o = f.Tell();
+ }
+ ~RestorePos()
+ {
+ try
+ {
+ f.Seek(o);
+ }
+ catch (...)
+ {
+ }
+ }
} restore(file);
wxFileOffset ofs = wxMax(file.Length() - 128, 0LL);
is.SeekI(ofs);
@@ -282,7 +295,8 @@ void GuidingLog::EnableLogging()
assert(m_file.IsOpened());
- m_file.Write(_T("PHD2 version ") FULLVER _T(" [") PHD_OSNAME _T("]") _T(", Log version ") GUIDELOG_VERSION _T(". Log enabled at ") +
+ m_file.Write(_T("PHD2 version ") FULLVER _T(" [") PHD_OSNAME _T("]")
+ _T(", Log version ") GUIDELOG_VERSION _T(". Log enabled at ") +
logFileTime.Format(_T("%Y-%m-%d %H:%M:%S")) + "\n");
m_enabled = true;
@@ -343,9 +357,9 @@ bool GuidingLog::ChangeDirLog(const wxString& newdir)
ok = false;
}
- if (enabled) // if SetLogDir failed, no harm no foul, stay with original. Otherwise
+ if (enabled) // if SetLogDir failed, no harm no foul, stay with original. Otherwise
{
- EnableLogging(); // start fresh...
+ EnableLogging(); // start fresh...
}
return ok;
@@ -400,7 +414,7 @@ void GuidingLog::CloseGuideLog()
m_enabled = false;
- if (!m_keepFile) // Delete the file if nothing useful was logged
+ if (!m_keepFile) // Delete the file if nothing useful was logged
{
wxRemove(m_fileName);
}
@@ -443,11 +457,8 @@ void GuidingLog::StartCalibration(const Mount *pCalibrationMount)
const Star& star = pFrame->pGuider->PrimaryStar();
m_file.Write(wxString::Format("Lock position = %.3f, %.3f, Star position = %.3f, %.3f, HFD = %.2f px\n",
- pFrame->pGuider->LockPosition().X,
- pFrame->pGuider->LockPosition().Y,
- pFrame->pGuider->CurrentPosition().X,
- pFrame->pGuider->CurrentPosition().Y,
- star.HFD));
+ pFrame->pGuider->LockPosition().X, pFrame->pGuider->LockPosition().Y, pFrame->pGuider->CurrentPosition().X,
+ pFrame->pGuider->CurrentPosition().Y, star.HFD));
m_file.Write("Direction,Step,dx,dy,x,y,Dist\n");
@@ -465,7 +476,8 @@ void GuidingLog::CalibrationFailed(const Mount *pCalibrationMount, const wxStrin
assert(m_file.IsOpened());
- m_file.Write(msg); m_file.Write("\n");
+ m_file.Write(msg);
+ m_file.Write("\n");
Flush();
}
@@ -477,25 +489,22 @@ void GuidingLog::CalibrationStep(const CalibrationStepInfo& info)
assert(m_file.IsOpened());
// Direction,Step,dx,dy,x,y,Dist
- m_file.Write(wxString::Format("%s,%d,%.3f,%.3f,%.3f,%.3f,%.3f\n",
- info.direction,
- info.stepNumber,
- info.dx, info.dy,
- info.pos.X, info.pos.Y,
- info.dist));
+ m_file.Write(wxString::Format("%s,%d,%.3f,%.3f,%.3f,%.3f,%.3f\n", info.direction, info.stepNumber, info.dx, info.dy,
+ info.pos.X, info.pos.Y, info.dist));
Flush();
}
-void GuidingLog::CalibrationDirectComplete(const Mount *pCalibrationMount, const wxString& direction, double angle, double rate, int parity)
+void GuidingLog::CalibrationDirectComplete(
+ const Mount *pCalibrationMount, const wxString& direction, double angle, double rate, int parity)
{
if (!m_enabled)
return;
assert(m_file.IsOpened());
- m_file.Write(wxString::Format("%s calibration complete. Angle = %.1f deg, Rate = %.3f px/sec, Parity = %s\n",
- direction, degrees(angle), rate * 1000.0, ParityStr(parity)));
+ m_file.Write(wxString::Format("%s calibration complete. Angle = %.1f deg, Rate = %.3f px/sec, Parity = %s\n", direction,
+ degrees(angle), rate * 1000.0, ParityStr(parity)));
Flush();
}
@@ -559,12 +568,9 @@ void GuidingLog::GuideStep(const GuideStepInfo& step)
assert(m_file.IsOpened());
- m_file.Write(wxString::Format("%d,%.3f,\"%s\",%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,",
- step.frameNumber, step.time,
- step.mount->IsStepGuider() ? "AO" : "Mount",
- step.cameraOffset.X, step.cameraOffset.Y,
- step.mountOffset.X, step.mountOffset.Y,
- step.guideDistanceRA, step.guideDistanceDec));
+ m_file.Write(wxString::Format("%d,%.3f,\"%s\",%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,", step.frameNumber, step.time,
+ step.mount->IsStepGuider() ? "AO" : "Mount", step.cameraOffset.X, step.cameraOffset.Y, step.mountOffset.X,
+ step.mountOffset.Y, step.guideDistanceRA, step.guideDistanceDec));
if (step.mount->IsStepGuider())
{
@@ -574,13 +580,12 @@ void GuidingLog::GuideStep(const GuideStepInfo& step)
}
else
{
- m_file.Write(wxString::Format("%d,%s,%d,%s,,,",
- step.durationRA, step.durationRA > 0 ? step.mount->DirectionChar((GUIDE_DIRECTION)step.directionRA) : "",
- step.durationDec, step.durationDec > 0 ? step.mount->DirectionChar((GUIDE_DIRECTION)step.directionDec): ""));
+ m_file.Write(wxString::Format("%d,%s,%d,%s,,,", step.durationRA,
+ step.durationRA > 0 ? step.mount->DirectionChar((GUIDE_DIRECTION) step.directionRA) : "", step.durationDec,
+ step.durationDec > 0 ? step.mount->DirectionChar((GUIDE_DIRECTION) step.directionDec) : ""));
}
- m_file.Write(wxString::Format("%.f,%.2f,%d\n",
- step.starMass, step.starSNR, step.starError));
+ m_file.Write(wxString::Format("%.f,%.2f,%d\n", step.starMass, step.starSNR, step.starError));
Flush();
}
@@ -592,8 +597,8 @@ void GuidingLog::FrameDropped(const FrameDroppedInfo& info)
assert(m_file.IsOpened());
- m_file.Write(wxString::Format("%d,%.3f,\"DROP\",,,,,,,,,,,,,%.f,%.2f,%d,\"%s\"\n",
- info.frameNumber, info.time, info.starMass, info.starSNR, info.starError, info.status));
+ m_file.Write(wxString::Format("%d,%.3f,\"DROP\",,,,,,,,,,,,,%.f,%.2f,%d,\"%s\"\n", info.frameNumber, info.time,
+ info.starMass, info.starSNR, info.starError, info.status));
Flush();
}
@@ -616,8 +621,8 @@ void GuidingLog::NotifyGuidingDithered(Guider *guider, double dx, double dy)
if (!m_enabled || !m_isGuiding)
return;
- m_file.Write(wxString::Format("INFO: DITHER by %.3f, %.3f, new lock pos = %.3f, %.3f\n",
- dx, dy, guider->LockPosition().X, guider->LockPosition().Y));
+ m_file.Write(wxString::Format(
+ "INFO: DITHER by %.3f, %.3f, new lock pos = %.3f, %.3f\n", dx, dy, guider->LockPosition().X, guider->LockPosition().Y));
Flush();
}
@@ -653,8 +658,8 @@ void GuidingLog::NotifySetLockPosition(Guider *guider)
if (!m_enabled || !m_isGuiding)
return;
- m_file.Write(wxString::Format("INFO: SET LOCK POSITION, new lock pos = %.3f, %.3f\n",
- guider->LockPosition().X, guider->LockPosition().Y));
+ m_file.Write(wxString::Format(
+ "INFO: SET LOCK POSITION, new lock pos = %.3f, %.3f\n", guider->LockPosition().X, guider->LockPosition().Y));
Flush();
@@ -670,12 +675,10 @@ void GuidingLog::NotifyLockShiftParams(const LockPosShiftParams& shiftParams, co
if (shiftParams.shiftEnabled)
{
details = wxString::Format("%s rate (%.2f,%.2f) %s/hr (%.2f,%.2f) px/hr",
- shiftParams.shiftIsMountCoords ? "RA,Dec" : "X,Y",
- shiftParams.shiftRate.IsValid() ? shiftParams.shiftRate.X : 0.0,
- shiftParams.shiftRate.IsValid() ? shiftParams.shiftRate.Y : 0.0,
- shiftParams.shiftUnits == UNIT_ARCSEC ? "arc-sec" : "pixels",
- cameraRate.IsValid() ? cameraRate.X * 3600.0 : 0.0,
- cameraRate.IsValid() ? cameraRate.Y * 3600.0 : 0.0);
+ shiftParams.shiftIsMountCoords ? "RA,Dec" : "X,Y", shiftParams.shiftRate.IsValid() ? shiftParams.shiftRate.X : 0.0,
+ shiftParams.shiftRate.IsValid() ? shiftParams.shiftRate.Y : 0.0,
+ shiftParams.shiftUnits == UNIT_ARCSEC ? "arc-sec" : "pixels", cameraRate.IsValid() ? cameraRate.X * 3600.0 : 0.0,
+ cameraRate.IsValid() ? cameraRate.Y * 3600.0 : 0.0);
}
m_file.Write(wxString::Format("INFO: LOCK SHIFT, enabled = %d %s\n", shiftParams.shiftEnabled, details));
@@ -700,10 +703,9 @@ void GuidingLog::NotifyManualGuide(const Mount *mount, int direction, int durati
if (!m_enabled || !m_isGuiding)
return;
- m_file.Write(wxString::Format("INFO: Manual guide (%s) %s %d %s\n",
- mount->IsStepGuider() ? "AO" : "Mount",
- mount->DirectionStr(static_cast(direction)), duration,
- mount->IsStepGuider() ? (duration != 1 ? "steps" : "step") : "ms"));
+ m_file.Write(wxString::Format("INFO: Manual guide (%s) %s %d %s\n", mount->IsStepGuider() ? "AO" : "Mount",
+ mount->DirectionStr(static_cast