Kstars

placeholderpath.h
1/*
2 SPDX-FileCopyrightText: 2021 Kwon-Young Choi <kwon-young.choi@hotmail.fr>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <lilxml.h>
10#include "indi/indistd.h"
11#include <QDebug>
12#include <QFileInfo>
13
14class QString;
15class SchedulerJob;
16
17namespace Ekos
18{
19
20class SequenceJob;
21
22class PlaceholderPath
23{
24 public:
25 typedef enum
26 {
27 PP_FORMAT, // QString
28 PP_SUFFIX, // uint
29 PP_DIRECTORY, // QString
30 PP_TARGETNAME, // QString
31 PP_FRAMETYPE, // CCDFrameType (uint)
32 PP_DARKFLAT, // bool
33 PP_EXPOSURE, // double
34 PP_FILTER, // QString
35 PP_BIN, // Point
36 PP_GAIN, // double
37 PP_ISO, // uint
38 PP_OFFSET, // double
39 PP_PIERSIDE, // ISD::Mount::PierSide (int)
40 PP_TEMPERATURE // double
41 } PathProperty;
42
43 typedef enum
44 {
45 PP_TYPE_NONE,
46 PP_TYPE_STRING,
47 PP_TYPE_BOOL,
48 PP_TYPE_UINT,
49 PP_TYPE_DOUBLE,
50 PP_TYPE_POINT
51 } PathPropertyType;
52
53 PlaceholderPath(const QString &seqFilename);
54 PlaceholderPath();
55 ~PlaceholderPath();
56
57 /**
58 * @brief processJobInfo loads the placeHolderPath with properties from the SequenceJob
59 * @param sequence job to be processed
60 */
61 void processJobInfo(SequenceJob *job);
62
63 /**
64 * @brief addjob creates the directory suffix for the SequenceJob
65 * @param sequence job to be processed
66 * @param targetname name of the celestial target
67 */
68 void updateFullPrefix(SequenceJob *job, const QString &targetName);
69
70 /**
71 * @brief constructPrefix creates the prefix for the SequenceJob
72 * @param sequence job to be processed
73 * @param imagePrefix sequence job prefix string
74 * @return QString containing the processed prefix string
75 */
76 QString constructPrefix(const SequenceJob *job, const QString &imagePrefix);
77
78 /**
79 * @brief generateFilename performs the data for tag substituion in the filename
80 * @param sequence job to be processed
81 * @param targetName name of the celestial target
82 * @param local Generate local filename, otherwise, generate remote filename
83 * @param batch_mode if true dateTime tag is returned with placeholders
84 * @param nextSequenceID file sequence number count
85 * @param extension filename extension
86 * @param filename passed in with tags
87 * @param glob used in batch mode
88 * @return QString containing formatted filename
89 *
90 * This overload of the function supports calls from the capture class
91 */
92 QString generateSequenceFilename(const SequenceJob &job, bool local, const bool batch_mode,
93 const int nextSequenceID, const QString &extension, const QString &filename,
94 const bool glob = false, const bool gettingSignature = false);
95
96 /**
97 * @brief generateFilename performs the data for tag substituion in the filename
98 * @param sequence job to be processed
99 * @param local Generate local filename, otherwise, generate remote filename
100 * @param batch_mode if true dateTime tag is returned with placeholders
101 * @param nextSequenceID file sequence number count
102 * @param extension filename extension
103 * @param filename passed in with tags
104 * @param glob used in batch mode
105 * @return QString containing formatted filename
106 *
107 * This overload of the function supports calls from the indicamera class
108 */
109 QString generateOutputFilename(const bool local, const bool batch_mode, const int nextSequenceID, const QString &extension, const QString &filename,
110 const bool glob = false, const bool gettingSignature = false) const;
111
112 /**
113 * @brief setGenerateFilenameSettings loads the placeHolderPath with settings from the passed job
114 * @param sequence job to be processed
115 */
116 void setGenerateFilenameSettings(const SequenceJob &job)
117 {
118 setGenerateFilenameSettings(job, m_PathPropertyMap, true, false);
119 }
120
121 /**
122 * @brief remainingPlaceholders finds placeholder tags in filename
123 * @param filename string to be processed
124 * @return a QStringList of the remaining placeholders
125 */
126 static QStringList remainingPlaceholders(const QString &filename);
127
128 /**
129 * @brief remainingPlaceholders provides a list of already existing fileIDs from passed sequence job
130 * @param sequence job to be processed
131 * @return a QStringList of the existing fileIDs
132 */
133 QList<int> getCompletedFileIds(const SequenceJob &job);
134
135 /**
136 * @brief getCompletedFiles provides the number of existing fileIDs
137 * @param sequence job to be processed
138 * @return number of existing fileIDs
139 */
140 int getCompletedFiles(const SequenceJob &job);
141
142 /**
143 * @brief getCompletedFiles determines the number of files matching the given path pattern
144 */
145 static int getCompletedFiles(const QString &path);
146
147 /**
148 * @brief checkSeqBoundary provides the ID to use for the next file
149 * @param sequence job to be processed
150 * @return number for the next fileIDs
151 */
152 int checkSeqBoundary(const SequenceJob &job);
153
154 /**
155 * @brief Property type definitions
156 */
157 static PathPropertyType propertyType(PathProperty property);
158
159 /**
160 * @brief defaultFormat provides a default format string
161 * @param useFilter whether to include the filter in the format string
162 * @param useExposure whether to include the exposure in the format string
163 * @param useTimestamp whether to include the timestamp in the format string
164 * @return the format string
165 */
166 static QString defaultFormat(bool useFilter, bool useExposure, bool useTimestamp);
167
168 /**
169 * @brief repairFilename is an emergency method used when an unexpected filename collision is detected.
170 * @param filename the filename which already exists on disk.
171 * @return Returns the repaired filename. If it was unable to repair, it returns the filename passed in.
172 */
173 static QString repairFilename(const QString &filename);
174
175 // shortcuts
176 static bool isFilterEnabled(const QString format)
177 {
178 return format.contains("%F");
179 }
180 static bool isExpEnabled(const QString format)
181 {
182 return format.contains("%e");
183 }
184 static bool isTsEnabled(const QString format)
185 {
186 return format.contains("%D");
187 }
188
189private:
190 // TODO use QVariantMap or QVariantList instead of passing this many args.
191 QString generateFilenameInternal(const QMap<PathProperty, QVariant> &pathPropertyMap, const bool local, const bool batch_mode, const int nextSequenceID, const QString &extension,
192 const QString &filename, const bool glob = false, const bool gettingSignature = false) const;
193
194 /**
195 * @brief setGenerateFilenameSettings Generate property map from job settings. In case that gettingSignature is set to true,
196 * only explicitly defined parameters from the job's core properties are filled. This is necessary for a proper cooperation with the
197 * scheduler, that generates signatures for captured files without proper knowledge of the involved camera and therefore has no ability
198 * to fill core properties from camera values. In all other cases, missing properties are filled from current camera values.
199 * @param job sequence job holding the attributes
200 * @param pathPropertyMap property map to be filled
201 * @param local set true if local file directory should be used
202 * @param is this parameter setting for generating a signature?
203 */
204 void setGenerateFilenameSettings(const SequenceJob &job, QMap<PathProperty, QVariant> &pathPropertyMap, const bool local, const bool gettingSignature = false);
205
206 /**
207 * @brief generateReplacement Generate the replacement for the given property. if usePattern
208 * is true, a pattern for the given type is used instead of a fixed value.
209 */
210 QString generateReplacement(const QMap<PathProperty, QVariant> &pathPropertyMap, PathProperty property, bool usePattern = false) const;
211
212 static QString getFrameType(CCDFrameType frameType)
213 {
214 if (m_frameTypes.contains(frameType))
215 return m_frameTypes[frameType];
216
217 qWarning() << frameType << " not in " << m_frameTypes.keys();
218 return "";
219 }
220
221 // properties that will be used for substitutions
222 QMap<PathProperty, QVariant> m_PathPropertyMap;
223 const QVariant getPathProperty(PathProperty prop) const
224 {
225 return m_PathPropertyMap[prop];
226 }
227 void setPathProperty(QMap<PathProperty, QVariant> &pathPropertyMap, PathProperty prop, QVariant value)
228 {
229 pathPropertyMap[prop] = value;
230 }
231
232 static QMap<CCDFrameType, QString> m_frameTypes;
233 QFileInfo m_seqFilename;
234};
235
236}
237
Sequence Job is a container for the details required to capture a series of images.
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:78
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:02 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.