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
189 void setSeqFilename(const QFileInfo &newSeqFilename)
190 {
191 m_seqFilename = newSeqFilename;
192 }
193
194private:
195 // TODO use QVariantMap or QVariantList instead of passing this many args.
196 QString generateFilenameInternal(const QMap<PathProperty, QVariant> &pathPropertyMap, const bool local, const bool batch_mode, const int nextSequenceID, const QString &extension,
197 const QString &filename, const bool glob = false, const bool gettingSignature = false, const bool isVideo = false) const;
198
199 /**
200 * @brief setGenerateFilenameSettings Generate property map from job settings. In case that gettingSignature is set to true,
201 * only explicitly defined parameters from the job's core properties are filled. This is necessary for a proper cooperation with the
202 * scheduler, that generates signatures for captured files without proper knowledge of the involved camera and therefore has no ability
203 * to fill core properties from camera values. In all other cases, missing properties are filled from current camera values.
204 * @param job sequence job holding the attributes
205 * @param pathPropertyMap property map to be filled
206 * @param local set true if local file directory should be used
207 * @param is this parameter setting for generating a signature?
208 */
209 void setGenerateFilenameSettings(const SequenceJob &job, QMap<PathProperty, QVariant> &pathPropertyMap, const bool local, const bool gettingSignature = false);
210
211 /**
212 * @brief generateReplacement Generate the replacement for the given property. if usePattern
213 * is true, a pattern for the given type is used instead of a fixed value.
214 */
215 QString generateReplacement(const QMap<PathProperty, QVariant> &pathPropertyMap, PathProperty property, bool usePattern = false) const;
216
217 static QString getFrameType(CCDFrameType frameType)
218 {
219 if (m_frameTypes.contains(frameType))
220 return m_frameTypes[frameType];
221
222 qWarning() << frameType << " not in " << m_frameTypes.keys();
223 return "";
224 }
225
226 // properties that will be used for substitutions
227 QMap<PathProperty, QVariant> m_PathPropertyMap;
228 const QVariant getPathProperty(PathProperty prop) const
229 {
230 return m_PathPropertyMap[prop];
231 }
232 void setPathProperty(QMap<PathProperty, QVariant> &pathPropertyMap, PathProperty prop, QVariant value)
233 {
234 pathPropertyMap[prop] = value;
235 }
236
237 static QMap<CCDFrameType, QString> m_frameTypes;
238 QFileInfo m_seqFilename;
239};
240
241}
242
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:83
bool contains(const Key &key) const const
QList< Key > keys() const const
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 Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.