Isis 3 Programmer Reference
PushFrameCameraCcdLayout.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include <iostream>
8#include <sstream>
9
10#include <SpiceUsr.h>
11#include <SpiceZfc.h>
12#include <SpiceZmc.h>
13
14#include "FileName.h"
15#include "IString.h"
16#include "PushFrameCameraCcdLayout.h"
17#include "NaifStatus.h"
18
19namespace Isis {
27
28
37
38
44
45
56 bool PushFrameCameraCcdLayout::addKernel(const QString &kernel) {
57 FileName kern(kernel);
58 if ( kern.isVersioned()) {
59 kern = kern.highestVersion();
60 }
61 m_kernels.Add(kern.expanded());
62 int nloaded = m_kernels.Load();
63 return (nloaded > 0);
64 }
65
66
74 QString var = "INS" + toString(m_ccdId) + "_FILTER_SAMPLES";
75 return (getSpiceInt(var));
76 }
77
78
86 QString var = "INS" + toString(m_ccdId) + "_FILTER_LINES";
87 return (getSpiceInt(var));
88 }
89
90
101 const int &frameId,
102 const QString &name) const {
103 FrameletInfo finfo(frameId);
104 finfo.m_filterName = name;
105
106 QString base = "INS" + toString(frameId);
107 try {
108 finfo.m_samples = getSpiceInt(base + "_FILTER_SAMPLES");
109 finfo.m_lines = getSpiceInt(base + "_FILTER_LINES");
110 finfo.m_startLine = getSpiceInt(base + "_FILTER_OFFSET");
111 }
112 catch (IException &e) {
113 QString msg = "Could not find layout information for framelet ["
114 + toString(frameId) + "].";
115 throw IException(e, IException::Io, msg, _FILEINFO_);
116 }
117 finfo.m_startSample = 1;
118
119 if ( finfo.m_filterName.isEmpty()) {
120 try {
121 finfo.m_filterName = getSpiceString(base + "_FILTER_NAME");
122 } catch (IException &ie) {
123 // noop - leave name empty
124 }
125 }
126
127 return (finfo);
128 }
129
130
142 const int index) const {
143 SpiceBoolean found = false;
144 SpiceInt numValuesRead;
145 SpiceInt kernelValue;
146 gipool_c(var.toLatin1().data(), (SpiceInt) index, 1, &numValuesRead,
147 &kernelValue, &found);
148
149 // Gotta throw an error here if not found
150 if (!found) {
152 QString msg = "Can not find [" + var + "] in text kernels";
153 throw IException(IException::Io, msg, _FILEINFO_);
154 }
155
156 return ( (int) kernelValue );
157 }
158
159
171 const int index) const {
172 SpiceBoolean found = false;
173 SpiceInt numValuesRead;
174 SpiceDouble kernelValue;
175 gdpool_c(var.toLatin1().data(), (SpiceInt) index, 1, &numValuesRead,
176 &kernelValue, &found);
177
178 // Gotta throw an error here if not found
179 if (!found) {
181 QString msg = "Can not find [" + var + "] in text kernels";
182 throw IException(IException::Io, msg, _FILEINFO_);
183 }
184
185 return ( (double) kernelValue );
186 }
187
188
199 QString PushFrameCameraCcdLayout::getSpiceString(const QString &var,
200 const int index) const {
201 SpiceBoolean found = false;
202 SpiceInt numValuesRead;
203 char kernelValue[512];
204 gcpool_c(var.toLatin1().data(), (SpiceInt) index, 1, sizeof(kernelValue),
205 &numValuesRead, kernelValue, &found);
206
207 // Gotta throw an error here if not found
208 if (!found) {
210 QString msg = "Can not find [" + var + "] in text kernels";
211 throw IException(IException::Io, msg, _FILEINFO_);
212 }
213
214 return ( QString(kernelValue) );
215 }
216
217};
File name manipulation and expansion.
Definition FileName.h:100
Isis exception class.
Definition IException.h:91
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition IException.h:155
bool Add(const QString &kfile)
Add a new kernel to the list.
Definition Kernels.cpp:178
int Load(const QString &ktype)
Load all kernels with one more types.
Definition Kernels.cpp:364
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
FrameletInfo getFrameInfo(const int &frameId, const QString &name="") const
Get the layout information for a framelet.
PushFrameCameraCcdLayout()
Push frame full CCD layout class.
int getSpiceInt(const QString &var, const int index=0) const
Query the loaded kernels for an integer valued keyword.
Kernels m_kernels
NAIF kernel manager.
QString getSpiceString(const QString &var, const int index=0) const
Query the loaded kernels for a string valued keyword.
double getSpiceDouble(const QString &var, const int index=0) const
Query the loaded kernels for a double valued keyword.
int ccdSamples() const
Return the number of samples in the CCD.
int ccdLines() const
Return the number of lines in the CCD.
bool addKernel(const QString &kernel)
Add a NAIF kernel to the set of kernels that values will be pulled from.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
Container for the layout of a specific framelet on the detector.