13#include <QStandardPaths>
16#include "auxiliary/kspaths.h"
27QString directionString(GuideDirection direction)
45QString directionStringLong(GuideDirection direction)
63QString pierSideString(ISD::Mount::PierSide side)
67 case ISD::Mount::PierSide::PIER_WEST:
69 case ISD::Mount::PierSide::PIER_EAST:
71 case ISD::Mount::PierSide::PIER_UNKNOWN:
77double degreesToHours(
double degrees)
79 return 24.0 * degrees / 360.0;
93void GuideLog::appendToLog(
const QString &lines)
105void GuideLog::startLog()
114 appendToLog(
QString(
"KStars version %1. PHD2 log version 2.5. Log enabled at %2\n\n")
123void GuideLog::endLog()
125 if (!enabled || !initialized)
128 if (isGuiding && initialized)
131 appendToLog(
QString(
"Log closed at %1\n")
139void GuideLog::startGuiding(
const GuideInfo &info)
149 appendToLog(
QString(
"Guiding Begins at %1\n"
150 "Pixel scale = %2 arc-sec/px, Binning = %3, Focal length = %4 mm\n"
151 "RA = %5 hr, Dec = %6 deg, Hour angle = N/A hr, Pier side = %7, "
152 "Rotator pos = N/A, Alt = %8 deg, Az = %9 deg\n"
153 "Mount = mount, xAngle = %10, xRate = %11, yAngle = %12, yRate = %13\n"
154 "Frame,Time,mount,dx,dy,RARawDistance,DECRawDistance,RAGuideDistance,DECGuideDistance,"
155 "RADuration,RADirection,DECDuration,DECDirection,XStep,YStep,StarMass,SNR,ErrorCode\n")
159 .
arg(info.focalLength)
162 .
arg(pierSideString(info.pierSide))
179void GuideLog::addGuideData(
const GuideData &data)
181 QString mountString = data.type == GuideData::MOUNT ?
"\"Mount\"" :
"\"DROP\"";
184 appendToLog(
QString(
"%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11,%12,%13,%14,%15,%16,%17,%18\n")
194 .
arg(data.raDuration)
195 .
arg(directionString(data.raDirection))
196 .
arg(data.decDuration)
197 .
arg(directionString(data.decDirection))
202 .
arg(
static_cast<int>(data.code)));
208void GuideLog::endGuiding()
210 appendToLog(
QString(
"Guiding Ends at %1\n\n")
217void GuideLog::startCalibration(
const GuideInfo &info)
225 appendToLog(
QString(
"Calibration Begins at %1\n"
226 "Pixel scale = %2 arc-sec/px, Binning = %3, Focal length = %4 mm\n"
227 "RA = %5 hr, Dec = %6 deg, Hour angle = N/A hr, Pier side = %7, "
228 "Rotator pos = N/A, Alt = %8 deg, Az = %9 deg\n"
229 "Direction,Step,dx,dy,x,y,Dist\n")
233 .
arg(info.focalLength)
236 .
arg(pierSideString(info.pierSide))
240 calibrationIndex = 1;
242 lastCalibrationDirection = NO_DIR;
247void GuideLog::addCalibrationData(GuideDirection direction,
double x,
double y,
double xOrigin,
double yOrigin)
249 if (direction != lastCalibrationDirection)
250 calibrationIndex = 1;
251 lastCalibrationDirection = direction;
253 appendToLog(
QString(
"%1,%2,%3,%4,%5,%6,%7\n")
254 .arg(directionStringLong(direction))
255 .arg(calibrationIndex)
269void GuideLog::endCalibrationSection(GuideDirection direction,
double degrees)
271 appendToLog(
QString(
"%1 calibration complete. Angle = %2 deg\n")
272 .arg(directionStringLong(direction))
280void GuideLog::endCalibration(
double raSpeed,
double decSpeed)
282 if (raSpeed == 0 && decSpeed == 0)
283 appendToLog(
QString(
"Calibration complete (Failed)\n\n"));
285 appendToLog(
QString(
"Calibration guide speeds: RA = %1 a-s/s, Dec = %2 a-s/s\n"
286 "Calibration complete\n\n")
291void GuideLog::ditherInfo(
double dx,
double dy,
double x,
double y)
293 appendToLog(
QString(
"INFO: DITHER by %1, %2, new lock pos = %3, %4\n")
299 appendToLog(
"INFO: SETTLING STATE CHANGE, Settling started\n");
302void GuideLog::pauseInfo()
304 appendToLog(
"INFO: Server received PAUSE\n");
307void GuideLog::resumeInfo()
309 appendToLog(
"INFO: Server received RESUME\n");
312void GuideLog::settleStartedInfo()
318void GuideLog::settleCompletedInfo()
320 appendToLog(
"INFO: SETTLING STATE CHANGE, Settling complete\n");
char * toString(const EngineQuery &query)
KIOCORE_EXPORT QString dir(const QString &fileClass)
QDateTime currentDateTime()
QString filePath(const QString &fileName) const const
bool open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
void setFileName(const QString &name)
virtual void close() override
QString arg(Args &&... args) const const
QString number(double n, char format, int precision)