Compare commits
129 Commits
b871b9dd46
...
alpha0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| b51c7c2aad | |||
| 33e79075fc | |||
| 2916bd4541 | |||
| 42f43cc1a1 | |||
| cd97ed875f | |||
| b3c7584205 | |||
| 5984bc5204 | |||
| d865e51ffb | |||
| 6e6f230f4d | |||
| a1f17f0d76 | |||
| e1a136a839 | |||
| 3497850e1f | |||
| e9c329d88f | |||
| 445a029a2f | |||
| 8e5e3631ba | |||
| 304464dbda | |||
| 4b5a390987 | |||
| 47ba7342e7 | |||
| c5f17b7403 | |||
| 8d36444c51 | |||
| d40ecb5df7 | |||
| d8130cede2 | |||
| 056c152d49 | |||
|
|
9630751a4d | ||
| 3dbe4c12b7 | |||
| 537207cd16 | |||
| f314c6a2c5 | |||
| af0268218a | |||
| fb70e9099b | |||
| b5d73e54d3 | |||
| 4fbe456892 | |||
| bfe5b4f286 | |||
|
|
be8397a0b4 | ||
| 3373bedb39 | |||
| a8a1d9a763 | |||
| c21b4c4771 | |||
| 59560704b0 | |||
| 6dc684bb4a | |||
| 2bc797b9ae | |||
| 9fbd628493 | |||
| 4bd4d156b5 | |||
| dc77f98db0 | |||
| f6482edd3f | |||
|
|
a4b3a32d94 | ||
| 8116658e0d | |||
| d4721d7b67 | |||
|
|
d3bab396a2 | ||
| a8275f3786 | |||
| 4b0569bfea | |||
| 2c561f7259 | |||
| 0182844af6 | |||
| 7d327a3276 | |||
| 9959f45b46 | |||
| 48d1bf37f7 | |||
|
|
9ad5bfb09b | ||
| 40d36545f3 | |||
| 3dbd68b21c | |||
|
|
617bcec1a1 | ||
|
|
28352f6c64 | ||
|
|
0ee87ccbf9 | ||
| f2aad0807d | |||
|
|
de097d6db2 | ||
| be69df5068 | |||
| 5d498d47f8 | |||
|
|
5e9e8897f0 | ||
|
|
f72d0bc3f0 | ||
| d42fa37a04 | |||
| ba03832ce6 | |||
| 3bd12bcf6d | |||
|
|
6199af6392 | ||
| 4401616d44 | |||
| 2f10fa2796 | |||
| 8aa58b727b | |||
| d9cb52f755 | |||
| 09a234ddc9 | |||
| 76cebec136 | |||
| e0b3ef225d | |||
| 32ed709222 | |||
| f8162779d6 | |||
| e6004a6c8a | |||
| 099c6056d7 | |||
| 18e6a99267 | |||
| 889d4ff3b2 | |||
| 53245002c5 | |||
| d11222a07f | |||
| 0ffee8eceb | |||
| de98ead539 | |||
|
|
2f80bcc78b | ||
|
|
408d23c376 | ||
|
|
b98063b229 | ||
|
|
00c7641d50 | ||
|
|
af5d852db9 | ||
| 1a8e1bbed0 | |||
| 578339fd8b | |||
| 775dedd835 | |||
| 1841664b63 | |||
| 5cfa67d6a1 | |||
| 8dd5e4751c | |||
| b1c5b64879 | |||
| c5299d06bb | |||
| 5202f8dc84 | |||
| ec7b7d8506 | |||
| cc57643315 | |||
| dce1c62419 | |||
| d1a31fc52c | |||
| 7049317539 | |||
|
|
c174021c40 | ||
|
|
7b110fb7ff | ||
|
|
dff70225ef | ||
|
|
452bd1c3e4 | ||
| 26011e7630 | |||
|
|
82f1477edd | ||
|
|
66e5f37c74 | ||
| 6ffc8e3582 | |||
| accbeff765 | |||
|
|
affaf176e5 | ||
| 700ed63169 | |||
|
|
9fbfb0d0b3 | ||
|
|
7cc2c5e2a3 | ||
| 4e08d985c9 | |||
| 652fbd0890 | |||
| b1df84a87f | |||
|
|
5df3dcf596 | ||
|
|
07cf211b3d | ||
| 86bb53d358 | |||
|
|
97b908838c | ||
| 6352865610 | |||
| 593a914d8d | |||
| 5b4456d6ef |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
CMakeLists.txt.user
|
CMakeLists.txt.user
|
||||||
build
|
build
|
||||||
|
.qtcreator
|
||||||
|
|||||||
746
.qtcreator/CMakeLists.txt.user.25c9513
Normal file
746
.qtcreator/CMakeLists.txt.user.25c9513
Normal file
@@ -0,0 +1,746 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE QtCreatorProject>
|
||||||
|
<!-- Written by QtCreator 18.0.1, 2026-02-10T08:36:52. -->
|
||||||
|
<qtcreator>
|
||||||
|
<data>
|
||||||
|
<variable>EnvironmentId</variable>
|
||||||
|
<value type="QByteArray">{25c95133-c398-49ba-8aa0-e9daf4073ad0}</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
<value type="qlonglong">0</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoDetect">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||||
|
<value type="QString" key="language">Cpp</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||||
|
<value type="QString" key="language">QmlJS</value>
|
||||||
|
<valuemap type="QVariantMap" key="value">
|
||||||
|
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||||
|
</valuemap>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||||
|
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.LineEndingBehavior">0</value>
|
||||||
|
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||||
|
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||||
|
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||||
|
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||||
|
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||||
|
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||||
|
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="bool" key="AutoTest.ApplyFilter">false</value>
|
||||||
|
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||||
|
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
|
||||||
|
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||||
|
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||||
|
<valuemap type="QVariantMap" key="ClangTools">
|
||||||
|
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||||
|
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||||
|
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||||
|
<value type="int" key="ClangTools.ParallelJobs">4</value>
|
||||||
|
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||||
|
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||||
|
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ClangdSettings">
|
||||||
|
<value type="bool" key="blockIndexing">true</value>
|
||||||
|
<value type="bool" key="useGlobalSettings">true</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="RcSync">0</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="QString" key="DeviceType">Desktop</value>
|
||||||
|
<value type="bool" key="HasPerBcDcs">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{0a48682c-1ff4-4142-9b6d-ae2f5a4dfc82}</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
|
<value type="QString" key="CMake.Build.Type">Debug</value>
|
||||||
|
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||||
|
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON
|
||||||
|
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
|
||||||
|
-DCMAKE_GENERATOR:STRING=Unix Makefiles
|
||||||
|
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
|
||||||
|
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}
|
||||||
|
-DCMAKE_BUILD_TYPE:STRING=Debug</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/timur/PROGRAMS/C++/mcc/build/Desktop-Debug</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||||
|
<value type="QString">all</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Собрать</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||||
|
<value type="QString">clean</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Собрать</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Очистка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Отладка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||||
|
<value type="QString"></value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Собрать</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.CMakePackageStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="QString" key="ApplicationManagerPlugin.Deploy.InstallPackageStep.Arguments">install-package --acknowledge</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Install Application Manager package</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.InstallPackageStep</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedFiles"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedHosts"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedRemotePaths"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedSysroots"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedLocalTimes"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedRemoteTimes"/>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.Configuration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">2</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings">
|
||||||
|
<value type="bool" key="AndroidBuildTargetDirSupport">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ApplicationmanagerPackageTargets"/>
|
||||||
|
<value type="bool" key="UseAndroidBuildTargetDir">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_telemetry_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_coord_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.2">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_pzone_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">3</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||||
|
<value type="QString"></value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Собрать</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.CMakePackageStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="QString" key="ApplicationManagerPlugin.Deploy.InstallPackageStep.Arguments">install-package --acknowledge</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Install Application Manager package</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.InstallPackageStep</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedFiles"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedHosts"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedRemotePaths"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedSysroots"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedLocalTimes"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedRemoteTimes"/>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.Configuration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">2</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_telemetry_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_coord_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.2">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_pzone_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">3</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Target.1</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="QString" key="DeviceType">Desktop</value>
|
||||||
|
<value type="bool" key="HasPerBcDcs">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clang</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clang</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{609869bc-d303-4485-8b34-3f43a08cec9e}</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">3</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||||
|
<value type="QString" key="CMake.Build.Type">Debug</value>
|
||||||
|
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||||
|
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON
|
||||||
|
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
|
||||||
|
-DCMAKE_GENERATOR:STRING=Ninja
|
||||||
|
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
|
||||||
|
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
|
||||||
|
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
|
||||||
|
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}
|
||||||
|
-DCMAKE_BUILD_TYPE:STRING=Debug</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/timur/PROGRAMS/C++/mcc/build/Clang-Debug</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||||
|
<value type="QString">all</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Собрать</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Сборка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||||
|
<value type="QString">clean</value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Собрать</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Очистка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Отладка</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">3</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||||
|
<value type="QString"></value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Собрать</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.CMakePackageStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="QString" key="ApplicationManagerPlugin.Deploy.InstallPackageStep.Arguments">install-package --acknowledge</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Install Application Manager package</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.InstallPackageStep</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedFiles"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedHosts"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedRemotePaths"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedSysroots"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedLocalTimes"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedRemoteTimes"/>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.Configuration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">2</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings">
|
||||||
|
<value type="bool" key="AndroidBuildTargetDirSupport">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ApplicationmanagerPackageTargets"/>
|
||||||
|
<value type="bool" key="UseAndroidBuildTargetDir">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">exe</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_telemetry_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.2">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_coord_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.3">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_pzone_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">4</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.1">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||||
|
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||||
|
<value type="QString"></value>
|
||||||
|
</valuelist>
|
||||||
|
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||||
|
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Собрать</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.CMakePackageStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="QString" key="ApplicationManagerPlugin.Deploy.InstallPackageStep.Arguments">install-package --acknowledge</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Install Application Manager package</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.InstallPackageStep</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedFiles"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedHosts"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedRemotePaths"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedSysroots"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedLocalTimes"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedRemoteTimes"/>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Развёртывание</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||||
|
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.Configuration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">2</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">exe</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_telemetry_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.2">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_coord_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.3">
|
||||||
|
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||||
|
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||||
|
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/bin/valgrind</value>
|
||||||
|
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||||
|
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||||
|
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||||
|
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||||
|
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph dwarf,4096 -F 250</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">mcc_pzone_test</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">4</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||||
|
<value type="qlonglong">2</value>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>Version</variable>
|
||||||
|
<value type="int">22</value>
|
||||||
|
</data>
|
||||||
|
</qtcreator>
|
||||||
478
CMakeLists.txt
478
CMakeLists.txt
@@ -1,11 +1,11 @@
|
|||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
|
|
||||||
|
set(QT_CREATOR_SKIP_MAINTENANCE_TOOL_PROVIDER ON)
|
||||||
|
|
||||||
# ******* MOUNT CONTROL COMPONENTS *******
|
# ******* MOUNT CONTROL COMPONENTS *******
|
||||||
|
|
||||||
project(mcc LANGUAGES C CXX Fortran VERSION 0.1)
|
project(mcc LANGUAGES C CXX Fortran VERSION 0.1)
|
||||||
|
|
||||||
|
|
||||||
# set(CMAKE_BUILD_TYPE Release)
|
# set(CMAKE_BUILD_TYPE Release)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
@@ -13,13 +13,33 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
|
|
||||||
# ******* LIBRARY OPTIONS *******
|
# ******* LIBRARY OPTIONS *******
|
||||||
|
|
||||||
option(USE_SPDLOG "Use of SPDLOG library (add implementation of logger class based on this library)" ON)
|
option(
|
||||||
option(USE_ERFA "Use of ERFA library (add implementation of CCTE based on this library)" ON)
|
USE_SPDLOG
|
||||||
|
"Use of SPDLOG library (add implementation of logger class based on this library)"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
|
option(
|
||||||
|
USE_ERFA
|
||||||
|
"Use of ERFA library (add implementation of CCTE based on this library)"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
|
option(
|
||||||
|
USE_EIGEN3
|
||||||
|
"Use of Eigen3 library as dependency for implemetation of PCM construction"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
option(USE_BSPLINE_PCM "Use of FITPACK bivariate splines for PCM" ON)
|
option(USE_BSPLINE_PCM "Use of FITPACK bivariate splines for PCM" ON)
|
||||||
|
|
||||||
|
option(
|
||||||
|
USE_ASIO
|
||||||
|
"Use of ASIO-library (add generic implementation of network capabilities)"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
option(BUILD_TESTS "Build tests" ON)
|
option(BUILD_TESTS "Build tests" ON)
|
||||||
|
|
||||||
@@ -28,155 +48,293 @@ find_package(Threads REQUIRED)
|
|||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
|
|
||||||
|
# ******** Eigen3 LIBRARY *******
|
||||||
|
|
||||||
|
if(USE_EIGEN3)
|
||||||
|
find_package(Eigen3 CONFIG)
|
||||||
|
if(TARGET Eigen3::Eigen)
|
||||||
|
message(STATUS "Eigen3 library was found!")
|
||||||
|
else()
|
||||||
|
message(STATUS \tfetch Eigen3 ...)
|
||||||
|
FetchContent_Declare(
|
||||||
|
eigen
|
||||||
|
GIT_REPOSITORY "https://gitlab.com/libeigen/eigen.git"
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
GIT_PROGRESS TRUE
|
||||||
|
OVERRIDE_FIND_PACKAGE
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(eigen)
|
||||||
|
|
||||||
|
find_package(Eigen3 REQUIRED CONFIG)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# ******* SPDLOG LIBRARY *******
|
# ******* SPDLOG LIBRARY *******
|
||||||
|
|
||||||
if (USE_SPDLOG)
|
if(USE_SPDLOG)
|
||||||
|
set(USE_SPDLOG_SYSTEM ON)
|
||||||
|
|
||||||
|
# find_package(spdlog CONFIG NO_MODULE)
|
||||||
|
# if(NOT ${spdlog_FOUND})
|
||||||
|
message(STATUS "\tfetch spdlog-lib ...")
|
||||||
|
FetchContent_Declare(
|
||||||
|
spdlog
|
||||||
|
GIT_REPOSITORY "https://github.com/gabime/spdlog.git"
|
||||||
|
GIT_TAG "v1.15.1"
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
GIT_SUBMODULES ""
|
||||||
|
GIT_PROGRESS TRUE
|
||||||
|
# CMAKE_ARGS
|
||||||
|
# -DSPDLOG_USE_STD_FORMAT=ON
|
||||||
|
# -DSPDLOG_FMT_EXTERNAL=OFF
|
||||||
|
OVERRIDE_FIND_PACKAGE
|
||||||
|
)
|
||||||
|
|
||||||
set(SPDLOG_USE_STD_FORMAT ON CACHE INTERNAL "Use of C++20 std::format")
|
set(SPDLOG_USE_STD_FORMAT ON CACHE INTERNAL "Use of C++20 std::format")
|
||||||
set(SPDLOG_FMT_EXTERNAL OFF CACHE INTERNAL "Turn off external fmt library")
|
set(SPDLOG_FMT_EXTERNAL OFF CACHE INTERNAL "Turn off external fmt library")
|
||||||
|
set(SPDLOG_INSTALL ON CACHE BOOL "Enable spdlog installation" FORCE)
|
||||||
|
FetchContent_MakeAvailable(spdlog)
|
||||||
|
|
||||||
find_package(spdlog CONFIG)
|
# find_package(spdlog REQUIRED CONFIG)
|
||||||
if (NOT ${spdlog_FOUND})
|
|
||||||
FetchContent_Declare(spdlog
|
set(USE_SPDLOG_SYSTEM OFF)
|
||||||
GIT_REPOSITORY "https://github.com/gabime/spdlog.git"
|
# else()
|
||||||
GIT_TAG "v1.15.1"
|
# set(SPDLOG_USE_STD_FORMAT ON CACHE INTERNAL "Use of C++20 std::format")
|
||||||
GIT_SHALLOW TRUE
|
# set(SPDLOG_FMT_EXTERNAL
|
||||||
GIT_SUBMODULES ""
|
# OFF
|
||||||
GIT_PROGRESS TRUE
|
# CACHE INTERNAL
|
||||||
CMAKE_ARGS "-DSPDLOG_USE_STD_FORMAT=ON -DSPDLOG_FMT_EXTERNAL=OFF"
|
# "Turn off external fmt library"
|
||||||
OVERRIDE_FIND_PACKAGE
|
# )
|
||||||
)
|
# endif()
|
||||||
find_package(spdlog CONFIG)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ******* ERFA LIBRARY *******
|
# ******* ERFA LIBRARY *******
|
||||||
|
|
||||||
find_program(MESON_PROG NAMES meson HINTS ENV PATHS)
|
|
||||||
|
|
||||||
if (NOT MESON_PROG)
|
|
||||||
message(FATAL "meson executable can not be found!!!")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_program(NINJA_PROG NAMES ninja ninja-build)
|
|
||||||
|
|
||||||
if (NOT NINJA_PROG)
|
|
||||||
message(FATAL "ninja executable can not be found!!!")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
|
||||||
pkg_check_modules(ERFALIB IMPORTED_TARGET GLOBAL erfa)
|
if(USE_ERFA)
|
||||||
|
|
||||||
if (NOT ERFALIB_FOUND)
|
|
||||||
message(STATUS "\tfetch erfa-lib ...")
|
|
||||||
# ExternalProject_Add(erfalib
|
|
||||||
# PREFIX ${CMAKE_BINARY_DIR}/erfa_lib
|
|
||||||
# GIT_REPOSITORY "https://github.com/liberfa/erfa.git"
|
|
||||||
# GIT_TAG "v2.0.1"
|
|
||||||
# UPDATE_COMMAND ""
|
|
||||||
# PATCH_COMMAND ""
|
|
||||||
# LOG_CONFIGURE 1
|
|
||||||
# CONFIGURE_COMMAND meson setup --reconfigure -Ddefault_library=static -Dbuildtype=release
|
|
||||||
# -Dprefix=${CMAKE_BINARY_DIR}/erfa_lib -Dlibdir= -Dincludedir= -Ddatadir= <SOURCE_DIR>
|
|
||||||
# BUILD_COMMAND ninja -C <BINARY_DIR>
|
|
||||||
# INSTALL_COMMAND meson install -C <BINARY_DIR>
|
|
||||||
# BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/erfa_lib/liberfa.a
|
|
||||||
# )
|
|
||||||
|
|
||||||
# add_library(PkgConfig::ERFALIB STATIC IMPORTED GLOBAL)
|
|
||||||
# set_target_properties(PkgConfig::ERFALIB PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/erfa_lib/liberfa.a)
|
|
||||||
# set_target_properties(PkgConfig::ERFALIB PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/erfa_lib)
|
|
||||||
# add_dependencies(PkgConfig::ERFALIB erfalib)
|
|
||||||
|
|
||||||
# set(CACHE{ERFALIB_INCLUDE_DIRS} TYPE PATH VALUE "${CMAKE_BINARY_DIR}/erfa_lib")
|
|
||||||
# set(CACHE{ERFALIB_LIBRARY_DIRS} TYPE PATH VALUE "${CMAKE_BINARY_DIR}/erfa_lib")
|
|
||||||
# set(CACHE{ERFALIB_LIBRARIES} TYPE STRING VALUE "erfa;m")
|
|
||||||
|
|
||||||
|
|
||||||
FetchContent_Declare(erfalib_project
|
|
||||||
GIT_REPOSITORY "https://github.com/liberfa/erfa.git"
|
|
||||||
GIT_TAG "v2.0.1"
|
|
||||||
GIT_SHALLOW TRUE
|
|
||||||
GIT_PROGRESS TRUE
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_MakeAvailable(erfalib_project)
|
|
||||||
# message(STATUS "ERFA: ${erfalib_project_SOURCE_DIR}")
|
|
||||||
|
|
||||||
message(STATUS "\tbuild erfa-lib ...")
|
|
||||||
execute_process(
|
|
||||||
COMMAND meson setup --reconfigure -Ddefault_library=static -Dbuildtype=release
|
|
||||||
-Dprefix=${CMAKE_BINARY_DIR}/erfa_lib -Dlibdir= -Dincludedir= -Ddatadir= ${CMAKE_BINARY_DIR}/erfa_lib ${erfalib_project_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
execute_process(
|
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/erfa_lib
|
|
||||||
COMMAND ninja -C ${CMAKE_BINARY_DIR}/erfa_lib
|
|
||||||
)
|
|
||||||
|
|
||||||
execute_process(
|
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/erfa_lib
|
|
||||||
COMMAND meson install -C ${CMAKE_BINARY_DIR}/erfa_lib
|
|
||||||
)
|
|
||||||
|
|
||||||
set(ENV{PKG_CONFIG_PATH} "${CMAKE_BINARY_DIR}/erfa_lib/pkgconfig")
|
|
||||||
pkg_check_modules(ERFALIB IMPORTED_TARGET GLOBAL erfa)
|
pkg_check_modules(ERFALIB IMPORTED_TARGET GLOBAL erfa)
|
||||||
|
|
||||||
|
if(NOT ERFALIB_FOUND)
|
||||||
|
message(STATUS "\tfetch erfa-lib ...")
|
||||||
|
# ExternalProject_Add(erfalib
|
||||||
|
# PREFIX ${CMAKE_BINARY_DIR}/erfa_lib
|
||||||
|
# GIT_REPOSITORY "https://github.com/liberfa/erfa.git"
|
||||||
|
# GIT_TAG "v2.0.1"
|
||||||
|
# UPDATE_COMMAND ""
|
||||||
|
# PATCH_COMMAND ""
|
||||||
|
# LOG_CONFIGURE 1
|
||||||
|
# CONFIGURE_COMMAND meson setup --reconfigure -Ddefault_library=static -Dbuildtype=release
|
||||||
|
# -Dprefix=${CMAKE_BINARY_DIR}/erfa_lib -Dlibdir= -Dincludedir= -Ddatadir= <SOURCE_DIR>
|
||||||
|
# BUILD_COMMAND ninja -C <BINARY_DIR>
|
||||||
|
# INSTALL_COMMAND meson install -C <BINARY_DIR>
|
||||||
|
# BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/erfa_lib/liberfa.a
|
||||||
|
# )
|
||||||
|
|
||||||
|
# add_library(PkgConfig::ERFALIB STATIC IMPORTED GLOBAL)
|
||||||
|
# set_target_properties(PkgConfig::ERFALIB PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/erfa_lib/liberfa.a)
|
||||||
|
# set_target_properties(PkgConfig::ERFALIB PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/erfa_lib)
|
||||||
|
# add_dependencies(PkgConfig::ERFALIB erfalib)
|
||||||
|
|
||||||
|
# set(CACHE{ERFALIB_INCLUDE_DIRS} TYPE PATH VALUE "${CMAKE_BINARY_DIR}/erfa_lib")
|
||||||
|
# set(CACHE{ERFALIB_LIBRARY_DIRS} TYPE PATH VALUE "${CMAKE_BINARY_DIR}/erfa_lib")
|
||||||
|
# set(CACHE{ERFALIB_LIBRARIES} TYPE STRING VALUE "erfa;m")
|
||||||
|
|
||||||
|
find_program(MESON_PROG NAMES meson HINTS ENV PATHS)
|
||||||
|
|
||||||
|
if(NOT MESON_PROG)
|
||||||
|
message(FATAL "meson executable can not be found!!!")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_program(NINJA_PROG NAMES ninja ninja-build)
|
||||||
|
|
||||||
|
if(NOT NINJA_PROG)
|
||||||
|
message(FATAL "ninja executable can not be found!!!")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
erfalib_project
|
||||||
|
GIT_REPOSITORY "https://github.com/liberfa/erfa.git"
|
||||||
|
GIT_TAG "v2.0.1"
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
GIT_PROGRESS TRUE
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(erfalib_project)
|
||||||
|
# message(STATUS "ERFA: ${erfalib_project_SOURCE_DIR}")
|
||||||
|
|
||||||
|
message(STATUS "\tbuild erfa-lib ...")
|
||||||
|
execute_process(
|
||||||
|
COMMAND
|
||||||
|
meson setup --reconfigure -Ddefault_library=static
|
||||||
|
-Dbuildtype=release -Dprefix=${CMAKE_BINARY_DIR}/erfa_lib
|
||||||
|
-Dlibdir= -Dincludedir= -Ddatadir= ${CMAKE_BINARY_DIR}/erfa_lib
|
||||||
|
${erfalib_project_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/erfa_lib
|
||||||
|
COMMAND ninja -C ${CMAKE_BINARY_DIR}/erfa_lib
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/erfa_lib
|
||||||
|
COMMAND meson install -C ${CMAKE_BINARY_DIR}/erfa_lib
|
||||||
|
)
|
||||||
|
|
||||||
|
set(ENV{PKG_CONFIG_PATH} "${CMAKE_BINARY_DIR}/erfa_lib/pkgconfig")
|
||||||
|
pkg_check_modules(ERFALIB IMPORTED_TARGET GLOBAL erfa)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "ERFA LIBS: ${ERFALIB_LIBRARIES}")
|
||||||
|
message(STATUS "ERFA LIB PATHS: ${ERFALIB_LIBRARY_DIRS}")
|
||||||
|
message(STATUS "ERFA INC PATHS: ${ERFALIB_INCLUDE_DIRS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(USE_ASIO)
|
||||||
|
pkg_check_modules(ASIOLIB IMPORTED_TARGET GLOBAL asio)
|
||||||
|
|
||||||
message(STATUS "ERFA LIBS: ${ERFALIB_LIBRARIES}")
|
set(USE_ASIO_SYSTEM ON)
|
||||||
message(STATUS "ERFA LIB PATHS: ${ERFALIB_LIBRARY_DIRS}")
|
|
||||||
message(STATUS "ERFA INC PATHS: ${ERFALIB_INCLUDE_DIRS}")
|
|
||||||
|
|
||||||
|
if(NOT ASIOLIB_FOUND)
|
||||||
|
message(STATUS "\tfetch asio-lib ...")
|
||||||
|
|
||||||
if (USE_BSPLINE_PCM)
|
FetchContent_Declare(
|
||||||
|
asiolib_project
|
||||||
|
PREFIX
|
||||||
|
${CMAKE_BINARY_DIR}/asio
|
||||||
|
GIT_REPOSITORY "https://github.com/chriskohlhoff/asio.git"
|
||||||
|
GIT_TAG "asio-1-36-0"
|
||||||
|
GIT_SHALLOW 1
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(asiolib_project)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
WORKING_DIRECTORY ${asiolib_project_SOURCE_DIR}/asio
|
||||||
|
COMMAND ./autogen.sh
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
WORKING_DIRECTORY ${asiolib_project_SOURCE_DIR}/asio
|
||||||
|
COMMAND ./configure --prefix=${asiolib_project_SOURCE_DIR}/asio
|
||||||
|
)
|
||||||
|
|
||||||
|
set(ENV{PKG_CONFIG_PATH} "${asiolib_project_SOURCE_DIR}/asio")
|
||||||
|
pkg_check_modules(ASIOLIB IMPORTED_TARGET GLOBAL asio)
|
||||||
|
|
||||||
|
message(STATUS "ASIO INC PATHS: ${ASIOLIB_INCLUDE_DIRS}")
|
||||||
|
|
||||||
|
set(USE_ASIO_SYSTEM OFF)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# if(USE_BSPLINE_PCM)
|
||||||
|
# # fitpack by P. Dierckx
|
||||||
|
# add_subdirectory(fitpack)
|
||||||
|
# endif()
|
||||||
|
|
||||||
|
set(MCC_SRC
|
||||||
|
include/mcc/mcc_concepts.h
|
||||||
|
include/mcc/mcc_constants.h
|
||||||
|
include/mcc/mcc_epoch.h
|
||||||
|
include/mcc/mcc_angle.h
|
||||||
|
include/mcc/mcc_coordinate.h
|
||||||
|
include/mcc/mcc_error.h
|
||||||
|
include/mcc/mcc_traits.h
|
||||||
|
include/mcc/mcc_utils.h
|
||||||
|
include/mcc/mcc_pzone.h
|
||||||
|
include/mcc/mcc_pzone_container.h
|
||||||
|
include/mcc/mcc_pcm.h
|
||||||
|
include/mcc/mcc_telemetry.h
|
||||||
|
include/mcc/mcc_movement_controls.h
|
||||||
|
include/mcc/mcc_generic_movecontrols.h
|
||||||
|
include/mcc/mcc_serialization_common.h
|
||||||
|
include/mcc/mcc_deserializer.h
|
||||||
|
include/mcc/mcc_serializer.h
|
||||||
|
include/mcc/mcc_generic_mount.h
|
||||||
|
include/mcc/mcc_keyvalue.h
|
||||||
|
)
|
||||||
|
|
||||||
|
if(USE_SPDLOG)
|
||||||
|
list(APPEND MCC_SRC include/mcc/mcc_spdlog.h)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_ERFA)
|
||||||
|
list(
|
||||||
|
APPEND MCC_SRC
|
||||||
|
include/mcc/mcc_ccte_iers.h
|
||||||
|
include/mcc/mcc_ccte_iers_default.h
|
||||||
|
include/mcc/mcc_ccte_erfa.h
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_ASIO)
|
||||||
|
list(
|
||||||
|
APPEND MCC_SRC
|
||||||
|
include/mcc/mcc_netserver_endpoint.h
|
||||||
|
include/mcc/mcc_netserver_proto.h
|
||||||
|
include/mcc/mcc_netserver.h
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_BSPLINE_PCM)
|
||||||
# fitpack by P. Dierckx
|
# fitpack by P. Dierckx
|
||||||
|
list(APPEND MCC_SRC include/mcc/mcc_bsplines.h)
|
||||||
add_subdirectory(fitpack)
|
add_subdirectory(fitpack)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(MCC_SRC mcc_concepts.h mcc_constants.h mcc_epoch.h mcc_angle.h mcc_coordinate.h mcc_error.h
|
if(USE_EIGEN3)
|
||||||
mcc_traits.h mcc_utils.h mcc_ccte_iers.h mcc_ccte_iers_default.h mcc_ccte_erfa.h mcc_pzone.h
|
list(
|
||||||
mcc_pzone_container.h mcc_pcm.h mcc_telemetry.h mcc_serializer.h)
|
APPEND MCC_SRC
|
||||||
|
include/mcc/mcc_pcm_construct.h
|
||||||
if (USE_SPDLOG)
|
include/mcc/mcc_pcm_fit.h
|
||||||
list(APPEND MCC_SRC mcc_spdlog.h)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} INTERFACE ${MCC_SRC})
|
add_library(${PROJECT_NAME} INTERFACE ${MCC_SRC})
|
||||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_23)
|
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_23)
|
||||||
target_link_libraries(${PROJECT_NAME} INTERFACE PkgConfig::ERFALIB)
|
|
||||||
# target_link_libraries(${PROJECT_NAME} INTERFACE PkgConfig::ERFALIB fitpack)
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
INTERFACE
|
INTERFACE
|
||||||
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR};${ERFALIB_INCLUDE_DIRS};${FITPACK_INCLUDE_DIR};>
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR};${ERFALIB_INCLUDE_DIRS};>
|
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
|
||||||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
|
|
||||||
)
|
)
|
||||||
if (USE_BSPLINE_PCM)
|
|
||||||
target_compile_definitions(${PROJECT_NAME} INTERFACE USE_BSPLINE_PCM)
|
if(USE_ERFA)
|
||||||
target_link_libraries(${PROJECT_NAME} INTERFACE fitpack)
|
target_link_libraries(${PROJECT_NAME} INTERFACE PkgConfig::ERFALIB)
|
||||||
# target_include_directories(
|
|
||||||
# ${PROJECT_NAME}
|
|
||||||
# INTERFACE
|
|
||||||
# $<BUILD_INTERFACE:${FITPACK_INCLUDE_DIR};>)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# get_target_property(ZZ ${PROJECT_NAME} INTERFACE_INCLUDE_DIRECTORIES)
|
if(USE_BSPLINE_PCM)
|
||||||
|
target_compile_definitions(${PROJECT_NAME} INTERFACE USE_BSPLINE_PCM)
|
||||||
|
target_link_libraries(${PROJECT_NAME} INTERFACE fitpack)
|
||||||
|
target_link_directories(
|
||||||
|
${PROJECT_NAME}
|
||||||
|
INTERFACE "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/fitpack>"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# message(STATUS "INT: ${ZZ}")
|
if(USE_EIGEN3)
|
||||||
|
target_link_libraries(${PROJECT_NAME} INTERFACE Eigen3::Eigen)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_ASIO)
|
||||||
|
target_link_libraries(${PROJECT_NAME} INTERFACE PkgConfig::ASIOLIB)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_SPDLOG)
|
||||||
|
target_compile_definitions(
|
||||||
|
${PROJECT_NAME}
|
||||||
|
INTERFACE SPDLOG_USE_STD_FORMAT=1 SPDLOG_FMT_EXTERNAL=0
|
||||||
|
)
|
||||||
|
target_link_libraries(${PROJECT_NAME} INTERFACE spdlog::spdlog_header_only)
|
||||||
|
# target_compile_definitions(
|
||||||
|
# ${PROJECT_NAME}
|
||||||
|
# INTERFACE SPDLOG_USE_STD_FORMAT=1
|
||||||
|
# )
|
||||||
|
endif()
|
||||||
|
|
||||||
# add_executable(exe EXCLUDE_FROM_ALL main.cpp)
|
if(BUILD_TESTS)
|
||||||
# target_link_libraries(exe PUBLIC ${PROJECT_NAME})
|
|
||||||
|
|
||||||
# get_target_property(ZZ exe INCLUDE_DIRECTORIES)
|
|
||||||
|
|
||||||
# message(STATUS "INT: ${ZZ_STRING}")
|
|
||||||
|
|
||||||
|
|
||||||
if (BUILD_TESTS)
|
|
||||||
add_executable(mcc_telemetry_test tests/mcc_telemetry_test.cpp)
|
add_executable(mcc_telemetry_test tests/mcc_telemetry_test.cpp)
|
||||||
target_link_libraries(mcc_telemetry_test PRIVATE ${PROJECT_NAME})
|
target_link_libraries(mcc_telemetry_test PRIVATE ${PROJECT_NAME})
|
||||||
|
|
||||||
@@ -185,40 +343,88 @@ if (BUILD_TESTS)
|
|||||||
|
|
||||||
add_executable(mcc_pzone_test tests/mcc_pzone_test.cpp)
|
add_executable(mcc_pzone_test tests/mcc_pzone_test.cpp)
|
||||||
target_link_libraries(mcc_pzone_test PRIVATE ${PROJECT_NAME})
|
target_link_libraries(mcc_pzone_test PRIVATE ${PROJECT_NAME})
|
||||||
|
|
||||||
|
add_executable(mcc_netmsg_test tests/mcc_netmsg_test.cpp)
|
||||||
|
target_link_libraries(mcc_netmsg_test PRIVATE ${PROJECT_NAME})
|
||||||
|
|
||||||
|
add_executable(mcc_fitpack_test tests/mcc_fitpack_test.cpp)
|
||||||
|
target_link_libraries(mcc_fitpack_test PRIVATE ${PROJECT_NAME})
|
||||||
|
|
||||||
|
add_executable(mcc_pcm_test tests/mcc_pcm_test.cpp)
|
||||||
|
target_link_libraries(mcc_pcm_test PRIVATE ${PROJECT_NAME})
|
||||||
|
|
||||||
|
add_executable(mcc_pcm_z1000_test tests/mcc_pcm_z1000_test.cpp)
|
||||||
|
target_link_libraries(mcc_pcm_z1000_test PRIVATE ${PROJECT_NAME})
|
||||||
|
|
||||||
|
add_executable(mcc_keyvalue_test tests/mcc_keyvalue_test.cpp)
|
||||||
|
target_link_libraries(mcc_keyvalue_test PRIVATE ${PROJECT_NAME})
|
||||||
else()
|
else()
|
||||||
# This is just a stub to allow access to the path and library settings for the ${PROJECT_NAME} target during development
|
# This is just a stub to allow access to the path and library settings for the ${PROJECT_NAME} target during development
|
||||||
add_executable(just_stub EXCLUDE_FROM_ALL main.cpp)
|
add_executable(just_stub EXCLUDE_FROM_ALL main.cpp)
|
||||||
target_link_libraries(just_stub PUBLIC ${PROJECT_NAME})
|
target_link_libraries(just_stub PUBLIC ${PROJECT_NAME})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}_Targets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
|
write_basic_package_version_file(
|
||||||
VERSION ${PROJECT_VERSION}
|
"${PROJECT_NAME}ConfigVersion.cmake"
|
||||||
COMPATIBILITY SameMajorVersion)
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
set(MCC_CONFIG_INSTALLDIR
|
||||||
|
${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
||||||
|
# CACHE PATH
|
||||||
|
# "install path for generated library config files"
|
||||||
|
)
|
||||||
|
set(MCC_HEADERS_INSTALLDIR
|
||||||
|
${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||||
|
# CACHE PATH
|
||||||
|
# "install path for headers"
|
||||||
|
)
|
||||||
|
|
||||||
set(MCC_CONFIG_INSTALLDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} CACHE PATH "install path for generated library config files")
|
configure_package_config_file(
|
||||||
set(MCC_HEADERS_INSTALLDIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "install path for headers")
|
"${PROJECT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||||
configure_package_config_file("${PROJECT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in"
|
INSTALL_DESTINATION ${MCC_CONFIG_INSTALLDIR}
|
||||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
PATH_VARS MCC_HEADERS_INSTALLDIR
|
||||||
INSTALL_DESTINATION
|
)
|
||||||
${MCC_CONFIG_INSTALLDIR}
|
|
||||||
PATH_VARS MCC_HEADERS_INSTALLDIR)
|
|
||||||
|
|
||||||
#install(EXPORT ${PROJECT_NAME}_Targets FILE ${PROJECT_NAME}Targets.cmake NAMESPACE ${PROJECT_NAME_NAMESPACE}:: DESTINATION ${MCC_CONFIG_INSTALLDIR})
|
|
||||||
#install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION ${MCC_CONFIG_INSTALLDIR})
|
|
||||||
#install(FILES ${MCC_SRC} DESTINATION include/${PROJECT_NAME})
|
|
||||||
|
|
||||||
|
install(
|
||||||
|
EXPORT ${PROJECT_NAME}_Targets
|
||||||
|
FILE ${PROJECT_NAME}Targets.cmake
|
||||||
|
NAMESPACE ${PROJECT_NAME_NAMESPACE}::
|
||||||
|
DESTINATION ${MCC_CONFIG_INSTALLDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||||
|
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||||
|
DESTINATION ${MCC_CONFIG_INSTALLDIR}
|
||||||
|
)
|
||||||
|
install(FILES ${MCC_SRC} DESTINATION include/${PROJECT_NAME})
|
||||||
|
|
||||||
# uninstall target
|
# uninstall target
|
||||||
if(NOT TARGET uninstall)
|
if(NOT TARGET uninstall)
|
||||||
configure_file(
|
configure_file(
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||||
IMMEDIATE @ONLY)
|
IMMEDIATE
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
add_custom_target(uninstall
|
add_custom_target(
|
||||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
uninstall
|
||||||
|
COMMAND
|
||||||
|
${CMAKE_COMMAND} -P
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ set(func_name "")
|
|||||||
file(GLOB src_files "*.f")
|
file(GLOB src_files "*.f")
|
||||||
|
|
||||||
foreach(ff IN LISTS src_files)
|
foreach(ff IN LISTS src_files)
|
||||||
get_filename_component(sn ${ff} NAME_WE)
|
get_filename_component(sn ${ff} NAME_WE)
|
||||||
list(APPEND func_name ${sn})
|
list(APPEND func_name ${sn})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# message(STATUS "${func_name}")
|
# message(STATUS "${func_name}")
|
||||||
@@ -18,21 +18,36 @@ string(REPLACE ";" " " func_str "${func_name}")
|
|||||||
enable_language(Fortran CXX)
|
enable_language(Fortran CXX)
|
||||||
|
|
||||||
include(FortranCInterface)
|
include(FortranCInterface)
|
||||||
FortranCInterface_HEADER(FortranCInterface.h
|
FortranCInterface_HEADER(
|
||||||
MACRO_NAMESPACE "FC_"
|
FortranCInterface.h
|
||||||
# SYMBOL_NAMESPACE "fp_"
|
MACRO_NAMESPACE "FC_"
|
||||||
SYMBOL_NAMESPACE ""
|
SYMBOL_NAMESPACE "fitpack_"
|
||||||
# SYMBOLS ${func_str}
|
#SYMBOL_NAMESPACE ""
|
||||||
SYMBOLS ${func_name}
|
# SYMBOLS ${func_str}
|
||||||
|
SYMBOLS ${func_name}
|
||||||
)
|
)
|
||||||
FortranCInterface_VERIFY(CXX)
|
FortranCInterface_VERIFY(CXX)
|
||||||
|
|
||||||
# set(FITPACK_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
|
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
# include_directories(${BSPLINES_INCLUDE_DIR})
|
|
||||||
|
|
||||||
add_library(fitpack_project STATIC EXCLUDE_FROM_ALL ${src_files} mcc_bsplines.h)
|
# add_library(fitpack_project STATIC EXCLUDE_FROM_ALL ${src_files} mcc_bsplines.h)
|
||||||
|
# add_library(fitpack_project STATIC EXCLUDE_FROM_ALL ${src_files})
|
||||||
|
add_library(fitpack_project STATIC ${src_files})
|
||||||
|
|
||||||
|
# get_target_property(FP_LIBDIR fitpack_project LIBRARY_OUTPUT_DIRECTORY)
|
||||||
|
# message(STATUS "FP_LIBDIR: ${FP_LIBDIR}")
|
||||||
|
|
||||||
add_library(fitpack STATIC IMPORTED GLOBAL)
|
add_library(fitpack STATIC IMPORTED GLOBAL)
|
||||||
set_target_properties(fitpack PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/fitpack/libfitpack_project.a)
|
set_target_properties(
|
||||||
set_target_properties(fitpack PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_BINARY_DIR}")
|
fitpack
|
||||||
|
PROPERTIES
|
||||||
|
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/libfitpack_project.a
|
||||||
|
# PROPERTIES IMPORTED_LOCATION ${FP_LIBDIR}/libfitpack_project.a
|
||||||
|
# IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/fitpack/libfitpack_project.a
|
||||||
|
)
|
||||||
|
set_target_properties(
|
||||||
|
fitpack
|
||||||
|
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
# "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
)
|
||||||
add_dependencies(fitpack fitpack_project)
|
add_dependencies(fitpack fitpack_project)
|
||||||
|
|||||||
@@ -1,369 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <ranges>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <FortranCInterface.h>
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
void surfit(int* iopt,
|
|
||||||
int* m,
|
|
||||||
double* x,
|
|
||||||
double* y,
|
|
||||||
double* z,
|
|
||||||
double* w,
|
|
||||||
double* xb,
|
|
||||||
double* xe,
|
|
||||||
double* yb,
|
|
||||||
double* ye,
|
|
||||||
int* kx,
|
|
||||||
int* ky,
|
|
||||||
double* s,
|
|
||||||
int* nxest,
|
|
||||||
int* nyest,
|
|
||||||
int* nmax,
|
|
||||||
double* eps,
|
|
||||||
int* nx,
|
|
||||||
double* tx,
|
|
||||||
int* ny,
|
|
||||||
double* ty,
|
|
||||||
double* c,
|
|
||||||
double* fp,
|
|
||||||
double* wrk1,
|
|
||||||
int* lwrk1,
|
|
||||||
double* wrk2,
|
|
||||||
int* lwrk2,
|
|
||||||
int* iwrk,
|
|
||||||
int* kwrk,
|
|
||||||
int* ier);
|
|
||||||
|
|
||||||
void bispev(double* tx,
|
|
||||||
int* nx,
|
|
||||||
double* ty,
|
|
||||||
int* ny,
|
|
||||||
double* c,
|
|
||||||
int* kx,
|
|
||||||
int* ky,
|
|
||||||
double* x,
|
|
||||||
int* mx,
|
|
||||||
double* y,
|
|
||||||
int* my,
|
|
||||||
double* z,
|
|
||||||
double* wrk,
|
|
||||||
int* lwrk,
|
|
||||||
int* iwrk,
|
|
||||||
int* kwrk,
|
|
||||||
int* ier);
|
|
||||||
|
|
||||||
void parder(double* tx,
|
|
||||||
int* nx,
|
|
||||||
double* ty,
|
|
||||||
int* ny,
|
|
||||||
double* c,
|
|
||||||
int* kx,
|
|
||||||
int* ky,
|
|
||||||
int* nux,
|
|
||||||
int* nuy,
|
|
||||||
double* x,
|
|
||||||
int* mx,
|
|
||||||
double* y,
|
|
||||||
int* my,
|
|
||||||
double* z,
|
|
||||||
double* wrk,
|
|
||||||
int* lwrk,
|
|
||||||
int* iwrk,
|
|
||||||
int* kwrk,
|
|
||||||
int* ier);
|
|
||||||
|
|
||||||
|
|
||||||
void sphere(int* iopt,
|
|
||||||
int* m,
|
|
||||||
double* teta,
|
|
||||||
double* phi,
|
|
||||||
double* r,
|
|
||||||
double* w,
|
|
||||||
double* s,
|
|
||||||
int* ntest,
|
|
||||||
int* npest,
|
|
||||||
double* eps,
|
|
||||||
int* nt,
|
|
||||||
double* tt,
|
|
||||||
int* np,
|
|
||||||
double* tp,
|
|
||||||
double* c,
|
|
||||||
double* fp,
|
|
||||||
double* wrk1,
|
|
||||||
int* lwrk1,
|
|
||||||
double* wrk2,
|
|
||||||
int* lwrk2,
|
|
||||||
int* iwrk,
|
|
||||||
int* kwrk,
|
|
||||||
int* ier);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace mcc::bsplines
|
|
||||||
{
|
|
||||||
|
|
||||||
template <int IOPT = 0,
|
|
||||||
std::ranges::contiguous_range TethaT,
|
|
||||||
std::ranges::contiguous_range PhiT,
|
|
||||||
std::ranges::contiguous_range FuncT,
|
|
||||||
typename WeightT,
|
|
||||||
std::ranges::contiguous_range TKnotT,
|
|
||||||
std::ranges::contiguous_range PKnotT,
|
|
||||||
std::ranges::contiguous_range CoeffT>
|
|
||||||
int fitpack_sphere_smooth(const TethaT& tetha,
|
|
||||||
const PhiT& phi,
|
|
||||||
const FuncT& func,
|
|
||||||
const WeightT& weight,
|
|
||||||
double s_par,
|
|
||||||
int& ntest,
|
|
||||||
int& npest,
|
|
||||||
TKnotT& tetha_knots,
|
|
||||||
PKnotT& phi_knots,
|
|
||||||
CoeffT& coeffs,
|
|
||||||
double& resi2_sum,
|
|
||||||
double eps = std::numeric_limits<double>::epsilon())
|
|
||||||
requires((std::ranges::contiguous_range<WeightT> || std::convertible_to<WeightT, double>) &&
|
|
||||||
std::ranges::output_range<CoeffT, double>)
|
|
||||||
{
|
|
||||||
static_assert(std::same_as<std::ranges::range_value_t<TethaT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<PhiT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<FuncT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<TKnotT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<PKnotT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<CoeffT>, double>,
|
|
||||||
"Input ranges elements type must be double!");
|
|
||||||
|
|
||||||
if constexpr (std::ranges::contiguous_range<WeightT>) {
|
|
||||||
static_assert(std::same_as<std::ranges::range_value_t<WeightT>, double>,
|
|
||||||
"Input ranges elements type must be double!");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static_assert(IOPT != -1 || IOPT != 0 || IOPT != 1, "Invalid IOPT template parameter value!");
|
|
||||||
|
|
||||||
|
|
||||||
int m = std::min(std::min(std::ranges::size(tetha), std::ranges::size(phi)), std::ranges::size(func));
|
|
||||||
if (m < 2) {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
int res = 0;
|
|
||||||
|
|
||||||
/* do checking here to avoid possibly unnecessary memory allocations */
|
|
||||||
|
|
||||||
// number of knots must be >= 8 for the qubic b-splines
|
|
||||||
if (ntest < 8 || npest < 8) {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
if constexpr (std::ranges::contiguous_range<WeightT>) {
|
|
||||||
m = std::min(m, std::ranges::size(weight));
|
|
||||||
if (m < 2) {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s_par <= 0.0) {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eps <= 0.0 || eps >= 1.0) {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
int nt = std::ranges::size(tetha_knots);
|
|
||||||
int np = std::ranges::size(phi_knots);
|
|
||||||
|
|
||||||
if (nt < ntest) {
|
|
||||||
std::ranges::fill_n(std::back_inserter(tetha_knots), ntest - nt, 0.0);
|
|
||||||
}
|
|
||||||
if (np < npest) {
|
|
||||||
std::ranges::fill_n(std::back_inserter(phi_knots), npest - np, 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// compute working arrays sizes according to sphere.f
|
|
||||||
const int u = ntest - 7;
|
|
||||||
const int v = npest - 7;
|
|
||||||
const int uv = u * v;
|
|
||||||
const int v2 = v * v;
|
|
||||||
|
|
||||||
int lwrk1 = 185 + 52 * v + 10 * u + 14 * uv + 8 * (u - 1) * v2 + 8 * m;
|
|
||||||
int lwrk2 = 48 + 21 * v + 7 * uv + 4 * (u - 1) * v2;
|
|
||||||
int kwrk = m + uv;
|
|
||||||
|
|
||||||
std::vector<double> wrk1(lwrk1);
|
|
||||||
std::vector<double> wrk2(lwrk2);
|
|
||||||
std::vector<int> iwrk(kwrk);
|
|
||||||
|
|
||||||
const int n_coeffs = (ntest - 4) * (npest - 4);
|
|
||||||
if (std::ranges::size(coeffs) < n_coeffs) { // resize
|
|
||||||
std::ranges::fill_n(std::back_inserter(coeffs), n_coeffs - std::ranges::size(coeffs), 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int iopt = IOPT;
|
|
||||||
|
|
||||||
auto tetha_ptr = const_cast<double*>(std::ranges::data(tetha));
|
|
||||||
auto phi_ptr = const_cast<double*>(std::ranges::data(phi));
|
|
||||||
auto func_ptr = const_cast<double*>(std::ranges::data(func));
|
|
||||||
auto tetha_knots_ptr = const_cast<double*>(std::ranges::data(tetha_knots));
|
|
||||||
auto phi_knots_ptr = const_cast<double*>(std::ranges::data(phi_knots));
|
|
||||||
|
|
||||||
if constexpr (std::ranges::contiguous_range<WeightT>) {
|
|
||||||
auto weight_ptr = const_cast<double*>(std::ranges::data(weight));
|
|
||||||
|
|
||||||
sphere(&iopt, &m, tetha_ptr, phi_ptr, func_ptr, weight_ptr, &s_par, &nt, &np, &eps, &ntest, tetha_knots_ptr,
|
|
||||||
&npest, phi_knots_ptr, std::ranges::data(coeffs), &resi2_sum, wrk1.data(), &lwrk1, wrk2.data(), &lwrk2,
|
|
||||||
iwrk.data(), &kwrk, &res);
|
|
||||||
// sphere(&iopt, &m, std::ranges::data(tetha), std::ranges::data(phi), std::ranges::data(func),
|
|
||||||
// std::ranges::data(weight), &s_par, &ntest, &npest, &eps, &ntest, std::ranges::data(tetha_knots),
|
|
||||||
// &npest, std::ranges::data(phi_knots), std::ranges::data(coeffs), &resi2_sum, wrk1.data(), &lwrk1,
|
|
||||||
// wrk2.data(), &lwrk2, iwrk.data(), &kwrk, &res);
|
|
||||||
} else {
|
|
||||||
std::vector<double> weight_vec(m, weight);
|
|
||||||
|
|
||||||
sphere(&iopt, &m, tetha_ptr, phi_ptr, func_ptr, weight_vec.data(), &s_par, &nt, &np, &eps, &ntest,
|
|
||||||
tetha_knots_ptr, &npest, phi_knots_ptr, std::ranges::data(coeffs), &resi2_sum, wrk1.data(), &lwrk1,
|
|
||||||
wrk2.data(), &lwrk2, iwrk.data(), &kwrk, &res);
|
|
||||||
// res = sphere(&iopt, &m, std::ranges::data(tetha), std::ranges::data(phi), std::ranges::data(func),
|
|
||||||
// weight_vec.data(), &s_par, &ntest, &npest, &eps, &ntest, std::ranges::data(tetha_knots), &npest,
|
|
||||||
// std::ranges::data(phi_knots), std::ranges::data(coeffs), &resi2_sum, wrk1.get(), &lwrk1,
|
|
||||||
// wrk2.get(), &lwrk2, iwrk.get(), &kwrk, &res);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
least-squares fitting (iopt=-1)
|
|
||||||
*/
|
|
||||||
template <std::ranges::contiguous_range TethaT,
|
|
||||||
std::ranges::contiguous_range PhiT,
|
|
||||||
std::ranges::contiguous_range FuncT,
|
|
||||||
typename WeightT,
|
|
||||||
std::ranges::contiguous_range TKnotT,
|
|
||||||
std::ranges::contiguous_range PKnotT,
|
|
||||||
std::ranges::contiguous_range CoeffT>
|
|
||||||
int fitpack_sphere_fit(const TethaT& tetha,
|
|
||||||
const PhiT& phi,
|
|
||||||
const FuncT& func,
|
|
||||||
const WeightT& weight,
|
|
||||||
TKnotT& tetha_knots,
|
|
||||||
PKnotT& phi_knots,
|
|
||||||
CoeffT& coeffs,
|
|
||||||
double& resi2_sum,
|
|
||||||
double eps = std::numeric_limits<double>::epsilon())
|
|
||||||
{
|
|
||||||
const double s = 100.0;
|
|
||||||
int nt = std::ranges::size(tetha_knots);
|
|
||||||
int np = std::ranges::size(phi_knots);
|
|
||||||
|
|
||||||
return fitpack_sphere_smooth<-1>(tetha, phi, func, weight, s, nt, np, tetha_knots, phi_knots, coeffs, resi2_sum,
|
|
||||||
eps);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <std::ranges::contiguous_range TXT,
|
|
||||||
std::ranges::contiguous_range TYT,
|
|
||||||
std::ranges::contiguous_range XT,
|
|
||||||
std::ranges::contiguous_range YT,
|
|
||||||
std::ranges::contiguous_range CoeffT,
|
|
||||||
std::ranges::contiguous_range FuncT>
|
|
||||||
int fitpack_eval_spl2d(const TXT& tx,
|
|
||||||
const TYT& ty,
|
|
||||||
const CoeffT& coeffs,
|
|
||||||
const XT& x,
|
|
||||||
const YT& y,
|
|
||||||
FuncT& func,
|
|
||||||
int kx = 3,
|
|
||||||
int ky = 3)
|
|
||||||
{
|
|
||||||
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<TYT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<XT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<YT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<CoeffT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<FuncT>, double>,
|
|
||||||
"Input ranges elements type must be double!");
|
|
||||||
|
|
||||||
if (kx < 0 || ky < 0) {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int ier = 0;
|
|
||||||
|
|
||||||
int ntx = std::ranges::size(tx);
|
|
||||||
int nty = std::ranges::size(ty);
|
|
||||||
|
|
||||||
auto n_coeffs = (ntx - kx - 1) * (nty - ky - 1);
|
|
||||||
if (std::ranges::size(coeffs) < n_coeffs) {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
int mx = std::ranges::size(x), my = std::ranges::size(y);
|
|
||||||
int N = mx * my;
|
|
||||||
|
|
||||||
if (std::ranges::size(func) < N) {
|
|
||||||
std::ranges::fill_n(std::back_inserter(func), N - std::ranges::size(func), 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute sizes of working arrays according to bispev.f
|
|
||||||
int lwrk = mx * (kx + 1) + my * (ky + 1);
|
|
||||||
std::vector<double> wrk(lwrk);
|
|
||||||
|
|
||||||
int kwrk = mx + my;
|
|
||||||
std::vector<int> iwrk(kwrk);
|
|
||||||
|
|
||||||
auto tx_ptr = const_cast<double*>(std::ranges::data(tx));
|
|
||||||
auto ty_ptr = const_cast<double*>(std::ranges::data(ty));
|
|
||||||
auto coeffs_ptr = const_cast<double*>(std::ranges::data(coeffs));
|
|
||||||
auto x_ptr = const_cast<double*>(std::ranges::data(x));
|
|
||||||
auto y_ptr = const_cast<double*>(std::ranges::data(y));
|
|
||||||
|
|
||||||
bispev(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, x_ptr, &mx, y_ptr, &my, std::ranges::data(func),
|
|
||||||
wrk.data(), &lwrk, iwrk.data(), &kwrk, &ier);
|
|
||||||
|
|
||||||
return ier;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// scalar x,y version
|
|
||||||
template <std::ranges::contiguous_range TXT,
|
|
||||||
std::ranges::contiguous_range TYT,
|
|
||||||
typename XT,
|
|
||||||
typename YT,
|
|
||||||
std::ranges::contiguous_range CoeffT,
|
|
||||||
typename FuncT>
|
|
||||||
int fitpack_eval_spl2d(const TXT& tx,
|
|
||||||
const TYT& ty,
|
|
||||||
const CoeffT& coeffs,
|
|
||||||
const XT& x,
|
|
||||||
const YT& y,
|
|
||||||
FuncT& func,
|
|
||||||
int kx = 3,
|
|
||||||
int ky = 3)
|
|
||||||
{
|
|
||||||
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<TYT>, double> &&
|
|
||||||
std::same_as<std::ranges::range_value_t<CoeffT>, double>,
|
|
||||||
"Input ranges elements type must be double!");
|
|
||||||
|
|
||||||
static_assert(
|
|
||||||
std::convertible_to<XT, double> && std::convertible_to<YT, double> && std::convertible_to<FuncT, double>,
|
|
||||||
"XT, YT and FuncT types must be a scalar convertible to double!");
|
|
||||||
|
|
||||||
auto xv = std::vector<double>(1, x);
|
|
||||||
auto yv = std::vector<double>(1, y);
|
|
||||||
auto fv = std::vector<double>(1, func);
|
|
||||||
|
|
||||||
return fitpack_eval_spl2d(tx, ty, coeffs, xv, yv, fv, kx, ky);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace mcc::fitpack
|
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
#include "mcc_traits.h"
|
#include "mcc_traits.h"
|
||||||
#include "mcc_utils.h"
|
#include "mcc_utils.h"
|
||||||
|
|
||||||
|
|
||||||
/* HELPERS TO REPRESENT ANGLE VALUE */
|
/* HELPERS TO REPRESENT ANGLE VALUE */
|
||||||
|
|
||||||
constexpr double operator""_rads(long double val) // angle in radians (no conversion)
|
constexpr double operator""_rads(long double val) // angle in radians (no conversion)
|
||||||
@@ -105,6 +104,48 @@ public:
|
|||||||
NORM_KIND_90_90, // [-90,90]
|
NORM_KIND_90_90, // [-90,90]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// varous angle normalization
|
||||||
|
template <norm_kind_t KIND>
|
||||||
|
static double normalizeAngle(double ang)
|
||||||
|
{
|
||||||
|
ang = std::fmod(ang, MCC_TWO_PI); // to the range of [0, 2*PI]
|
||||||
|
|
||||||
|
if constexpr (KIND == NORM_KIND_0_360) {
|
||||||
|
if (ang < 0.0) {
|
||||||
|
ang += MCC_TWO_PI;
|
||||||
|
}
|
||||||
|
} else if constexpr (KIND == NORM_KIND_0_180) {
|
||||||
|
if (ang < -std::numbers::pi) {
|
||||||
|
ang += MCC_TWO_PI;
|
||||||
|
} else if (ang < 0.0) {
|
||||||
|
ang = -ang;
|
||||||
|
} else if (ang > std::numbers::pi) {
|
||||||
|
ang = MCC_TWO_PI - ang;
|
||||||
|
}
|
||||||
|
} else if constexpr (KIND == NORM_KIND_180_180) {
|
||||||
|
if (ang > std::numbers::pi) {
|
||||||
|
ang -= MCC_TWO_PI;
|
||||||
|
} else if (ang < -std::numbers::pi) {
|
||||||
|
ang += MCC_TWO_PI;
|
||||||
|
}
|
||||||
|
} else if constexpr (KIND == NORM_KIND_90_90) {
|
||||||
|
if (ang >= 1.5 * std::numbers::pi) {
|
||||||
|
ang -= MCC_TWO_PI;
|
||||||
|
} else if (ang >= MCC_HALF_PI) {
|
||||||
|
ang = std::numbers::pi - ang;
|
||||||
|
} else if (ang <= -1.5 * std::numbers::pi) {
|
||||||
|
ang += MCC_TWO_PI;
|
||||||
|
} else if (ang <= -MCC_HALF_PI) {
|
||||||
|
ang = -(std::numbers::pi + ang);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNKNOWN ANGLE NORMALIZATION TYPE!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ang;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MccAngle() = default;
|
MccAngle() = default;
|
||||||
|
|
||||||
// by default 'val' is in radians
|
// by default 'val' is in radians
|
||||||
@@ -180,41 +221,42 @@ public:
|
|||||||
template <norm_kind_t KIND>
|
template <norm_kind_t KIND>
|
||||||
MccAngle& normalize()
|
MccAngle& normalize()
|
||||||
{
|
{
|
||||||
_angleInRads = std::fmod(_angleInRads, std::numbers::pi * 2.0);
|
_angleInRads = MccAngle::normalizeAngle<KIND>(_angleInRads);
|
||||||
|
|
||||||
if constexpr (KIND == NORM_KIND_0_360) {
|
|
||||||
if (_angleInRads < 0.0) {
|
|
||||||
_angleInRads += 2.0 * std::numbers::pi;
|
|
||||||
}
|
|
||||||
} else if constexpr (KIND == NORM_KIND_0_180) {
|
|
||||||
if (_angleInRads < -std::numbers::pi) {
|
|
||||||
// _angleInRads = 2.0 * std::numbers::pi + _angleInRads;
|
|
||||||
_angleInRads = MCC_TWO_PI + _angleInRads;
|
|
||||||
} else if (_angleInRads < 0.0) {
|
|
||||||
_angleInRads = -_angleInRads;
|
|
||||||
}
|
|
||||||
} else if constexpr (KIND == NORM_KIND_180_180) {
|
|
||||||
if (_angleInRads > std::numbers::pi) {
|
|
||||||
// _angleInRads = 2.0 * std::numbers::pi - _angleInRads;
|
|
||||||
_angleInRads = MCC_TWO_PI - _angleInRads;
|
|
||||||
} else if (_angleInRads < -std::numbers::pi) {
|
|
||||||
// _angleInRads += 2.0 * std::numbers::pi;
|
|
||||||
_angleInRads += MCC_TWO_PI;
|
|
||||||
}
|
|
||||||
} else if constexpr (KIND == NORM_KIND_90_90) {
|
|
||||||
if (_angleInRads >= 1.5 * std::numbers::pi) {
|
|
||||||
_angleInRads = _angleInRads - 2.0 * std::numbers::pi;
|
|
||||||
} else if (_angleInRads >= std::numbers::pi / 2.0) {
|
|
||||||
_angleInRads = std::numbers::pi - _angleInRads;
|
|
||||||
} else if (_angleInRads <= -1.5 * std::numbers::pi) {
|
|
||||||
// _angleInRads += 2.0 * std::numbers::pi;
|
|
||||||
_angleInRads += MCC_TWO_PI;
|
|
||||||
} else if (_angleInRads <= -std::numbers::pi / 2.0) {
|
|
||||||
_angleInRads = -(std::numbers::pi + _angleInRads);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
|
// _angleInRads = std::fmod(_angleInRads, MCC_TWO_PI);
|
||||||
|
|
||||||
|
// if constexpr (KIND == NORM_KIND_0_360) {
|
||||||
|
// if (_angleInRads < 0.0) {
|
||||||
|
// _angleInRads += 2.0 * std::numbers::pi;
|
||||||
|
// }
|
||||||
|
// } else if constexpr (KIND == NORM_KIND_0_180) {
|
||||||
|
// if (_angleInRads < -std::numbers::pi) {
|
||||||
|
// _angleInRads = MCC_TWO_PI + _angleInRads;
|
||||||
|
// } else if (_angleInRads < 0.0) {
|
||||||
|
// _angleInRads = -_angleInRads;
|
||||||
|
// }
|
||||||
|
// } else if constexpr (KIND == NORM_KIND_180_180) {
|
||||||
|
// if (_angleInRads > std::numbers::pi) {
|
||||||
|
// _angleInRads -= MCC_TWO_PI;
|
||||||
|
// } else if (_angleInRads < -std::numbers::pi) {
|
||||||
|
// _angleInRads += MCC_TWO_PI;
|
||||||
|
// }
|
||||||
|
// } else if constexpr (KIND == NORM_KIND_90_90) {
|
||||||
|
// if (_angleInRads >= 1.5 * std::numbers::pi) {
|
||||||
|
// // _angleInRads = _angleInRads - 2.0 * std::numbers::pi;
|
||||||
|
// _angleInRads -= MCC_TWO_PI;
|
||||||
|
// } else if (_angleInRads >= std::numbers::pi / 2.0) {
|
||||||
|
// _angleInRads = std::numbers::pi - _angleInRads;
|
||||||
|
// } else if (_angleInRads <= -1.5 * std::numbers::pi) {
|
||||||
|
// _angleInRads += MCC_TWO_PI;
|
||||||
|
// } else if (_angleInRads <= -std::numbers::pi / 2.0) {
|
||||||
|
// _angleInRads = -(std::numbers::pi + _angleInRads);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MccAngle& normalize()
|
MccAngle& normalize()
|
||||||
@@ -434,25 +476,38 @@ static T1 operator/(const T1& v1, const T2& v2)
|
|||||||
|
|
||||||
|
|
||||||
std::string MccAngleFancyString(std::convertible_to<MccAngle> auto const& ang,
|
std::string MccAngleFancyString(std::convertible_to<MccAngle> auto const& ang,
|
||||||
std::format_string<double> val_fmt = "{}")
|
std::format_string<double> val_fmt = "{:.2f}")
|
||||||
{
|
{
|
||||||
|
using ang_t = std::decay_t<decltype(ang)>;
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|
||||||
double abs_ang;
|
double abs_ang;
|
||||||
if constexpr (std::is_arithmetic_v<std::decay_t<decltype(ang)>>) {
|
if constexpr (std::is_arithmetic_v<ang_t>) {
|
||||||
abs_ang = std::abs(ang);
|
abs_ang = std::abs(ang);
|
||||||
} else {
|
} else {
|
||||||
abs_ang = std::abs(MccAngle{ang});
|
abs_ang = std::abs(MccAngle{ang});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abs_ang < 1.0_arcmins) {
|
if (abs_ang < 1.0_arcmins) {
|
||||||
std::format_to(std::back_inserter(s), val_fmt, MccAngle{ang}.arcsecs());
|
if constexpr (std::derived_from<ang_t, MccAngle>) {
|
||||||
|
std::format_to(std::back_inserter(s), val_fmt, ang.arcsecs());
|
||||||
|
} else {
|
||||||
|
std::format_to(std::back_inserter(s), val_fmt, MccAngle{ang}.arcsecs());
|
||||||
|
}
|
||||||
s += " arcsecs";
|
s += " arcsecs";
|
||||||
} else if (abs_ang < 1.0_degs) {
|
} else if (abs_ang < 1.0_degs) {
|
||||||
std::format_to(std::back_inserter(s), val_fmt, MccAngle{ang}.arcmins());
|
if constexpr (std::derived_from<ang_t, MccAngle>) {
|
||||||
|
std::format_to(std::back_inserter(s), val_fmt, ang.arcmins());
|
||||||
|
} else {
|
||||||
|
std::format_to(std::back_inserter(s), val_fmt, MccAngle{ang}.arcmins());
|
||||||
|
}
|
||||||
s += " arcmins";
|
s += " arcmins";
|
||||||
} else {
|
} else {
|
||||||
std::format_to(std::back_inserter(s), val_fmt, MccAngle{ang}.degrees());
|
if constexpr (std::derived_from<ang_t, MccAngle>) {
|
||||||
|
std::format_to(std::back_inserter(s), val_fmt, ang.degrees());
|
||||||
|
} else {
|
||||||
|
std::format_to(std::back_inserter(s), val_fmt, MccAngle{ang}.degrees());
|
||||||
|
}
|
||||||
s += " degs";
|
s += " degs";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,6 +517,115 @@ std::string MccAngleFancyString(std::convertible_to<MccAngle> auto const& ang,
|
|||||||
|
|
||||||
/* HELPER TYPES TO REPERESENT ANGLES ON THE CELESTIAL SPHERE */
|
/* HELPER TYPES TO REPERESENT ANGLES ON THE CELESTIAL SPHERE */
|
||||||
|
|
||||||
|
template <MccAngle::norm_kind_t NORM_KIND>
|
||||||
|
class MccNormalizedAngle : public MccAngle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
template <typename... CtorArgTs>
|
||||||
|
MccNormalizedAngle(CtorArgTs&&... args) : MccAngle(std::forward<CtorArgTs>(args)...)
|
||||||
|
{
|
||||||
|
normalize<NORM_KIND>();
|
||||||
|
}
|
||||||
|
|
||||||
|
MccNormalizedAngle(MccNormalizedAngle const&) = default;
|
||||||
|
MccNormalizedAngle(MccNormalizedAngle&&) = default;
|
||||||
|
|
||||||
|
MccNormalizedAngle& operator=(MccNormalizedAngle const&) = default;
|
||||||
|
MccNormalizedAngle& operator=(MccNormalizedAngle&&) = default;
|
||||||
|
|
||||||
|
template <typename VT>
|
||||||
|
MccNormalizedAngle& operator=(VT&& value)
|
||||||
|
requires std::is_arithmetic_v<VT>
|
||||||
|
{
|
||||||
|
_angleInRads = value;
|
||||||
|
normalize<NORM_KIND>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class MccAngleRA_ICRS : public MccNormalizedAngle<MccAngle::NORM_KIND_0_360>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_0_360>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MccAngleDEC_ICRS : public MccNormalizedAngle<MccAngle::NORM_KIND_90_90>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_90_90>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MccAngleRA_APP : public MccNormalizedAngle<MccAngle::NORM_KIND_0_360>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_0_360>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MccAngleDEC_APP : public MccNormalizedAngle<MccAngle::NORM_KIND_90_90>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_90_90>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MccAngleRA_OBS : public MccNormalizedAngle<MccAngle::NORM_KIND_0_360>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_0_360>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MccAngleDEC_OBS : public MccNormalizedAngle<MccAngle::NORM_KIND_90_90>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_90_90>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class MccAngleHA_APP : public MccNormalizedAngle<MccAngle::NORM_KIND_180_180>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_180_180>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MccAngleHA_OBS : public MccNormalizedAngle<MccAngle::NORM_KIND_180_180>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_180_180>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class MccAngleAZ : public MccNormalizedAngle<MccAngle::NORM_KIND_0_360>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_0_360>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MccAngleZD : public MccNormalizedAngle<MccAngle::NORM_KIND_0_180>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_0_180>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MccAngleALT : public MccNormalizedAngle<MccAngle::NORM_KIND_90_90>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_90_90>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class MccAngleLON : public MccNormalizedAngle<MccAngle::NORM_KIND_0_360>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_0_360>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class MccAngleLAT : public MccNormalizedAngle<MccAngle::NORM_KIND_90_90>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using MccNormalizedAngle<MccAngle::NORM_KIND_90_90>::MccNormalizedAngle;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
class MccNamedAngle : public MccAngle
|
class MccNamedAngle : public MccAngle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -559,7 +723,7 @@ public:
|
|||||||
using MccNamedAngle::MccNamedAngle;
|
using MccNamedAngle::MccNamedAngle;
|
||||||
// using MccAngle::MccAngle;
|
// using MccAngle::MccAngle;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
class MccAngleX : public MccAngle // some co-longitude coordinate
|
class MccAngleX : public MccAngle // some co-longitude coordinate
|
||||||
{
|
{
|
||||||
@@ -575,17 +739,17 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MccAngleLAT : public MccAngle
|
// class MccAngleLAT : public MccAngle
|
||||||
{
|
// {
|
||||||
public:
|
// public:
|
||||||
using MccAngle::MccAngle;
|
// using MccAngle::MccAngle;
|
||||||
};
|
// };
|
||||||
|
|
||||||
class MccAngleLON : public MccAngle
|
// class MccAngleLON : public MccAngle
|
||||||
{
|
// {
|
||||||
public:
|
// public:
|
||||||
using MccAngle::MccAngle;
|
// using MccAngle::MccAngle;
|
||||||
};
|
// };
|
||||||
|
|
||||||
class MccAngleUnknown : public MccAngle
|
class MccAngleUnknown : public MccAngle
|
||||||
{
|
{
|
||||||
@@ -649,7 +813,7 @@ static constexpr bool mcc_is_app_coordpair(MccCoordPairKind kind)
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_ICRS_STR = "RADEC-IRCS";
|
static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_ICRS_STR = "RADEC-ICRS";
|
||||||
static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_APP_STR = "RADEC-APP";
|
static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_APP_STR = "RADEC-APP";
|
||||||
static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_OBS_STR = "RADEC-OBS";
|
static constexpr std::string_view MCC_COORDPAIR_KIND_RADEC_OBS_STR = "RADEC-OBS";
|
||||||
static constexpr std::string_view MCC_COORDPAIR_KIND_HADEC_APP_STR = "HADEC-APP";
|
static constexpr std::string_view MCC_COORDPAIR_KIND_HADEC_APP_STR = "HADEC-APP";
|
||||||
@@ -715,21 +879,21 @@ static constexpr MccCoordPairKind MccCoordStrToPairKind(R&& spair)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum class MccCoordinatePairRep : int {
|
// enum class MccCoordinatePairRep : int {
|
||||||
MCC_COORDPAIR_REP_DEGREES, // both angles are in decimal degrees
|
// MCC_COORDPAIR_REP_DEGREES, // both angles are in decimal degrees
|
||||||
MCC_COORDPAIR_REP_SXGM_HOURDEG, // X is in hour and Y is in degree sexagesimal representation
|
// MCC_COORDPAIR_REP_SXGM_HOURDEG, // X is in hour and Y is in degree sexagesimal representation
|
||||||
MCC_COORDPAIR_REP_SXGM_DEGDEG // both angles are in sexagesimal degrees
|
// MCC_COORDPAIR_REP_SXGM_DEGDEG // both angles are in sexagesimal degrees
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
|
||||||
// default wide-acceptable sexagesimal representation
|
// // default wide-acceptable sexagesimal representation
|
||||||
static constexpr MccCoordinatePairRep MccCoordinatePairToSxgmRep(MccCoordPairKind kind)
|
// static constexpr MccCoordinatePairRep MccCoordinatePairToSxgmRep(MccCoordPairKind kind)
|
||||||
{
|
// {
|
||||||
return kind == MccCoordPairKind::COORDS_KIND_AZALT || kind == MccCoordPairKind::COORDS_KIND_AZZD ||
|
// return kind == MccCoordPairKind::COORDS_KIND_AZALT || kind == MccCoordPairKind::COORDS_KIND_AZZD ||
|
||||||
kind == MccCoordPairKind::COORDS_KIND_XY || kind == MccCoordPairKind::COORDS_KIND_LONLAT ||
|
// kind == MccCoordPairKind::COORDS_KIND_XY || kind == MccCoordPairKind::COORDS_KIND_LONLAT ||
|
||||||
kind == MccCoordPairKind::COORDS_KIND_GENERIC
|
// kind == MccCoordPairKind::COORDS_KIND_GENERIC
|
||||||
? MccCoordinatePairRep::MCC_COORDPAIR_REP_SXGM_DEGDEG
|
// ? MccCoordinatePairRep::MCC_COORDPAIR_REP_SXGM_DEGDEG
|
||||||
: MccCoordinatePairRep::MCC_COORDPAIR_REP_SXGM_HOURDEG; // RA-DEC or HA-DEC
|
// : MccCoordinatePairRep::MCC_COORDPAIR_REP_SXGM_HOURDEG; // RA-DEC or HA-DEC
|
||||||
}
|
// }
|
||||||
|
|
||||||
} // namespace mcc::impl
|
} // namespace mcc::impl
|
||||||
650
include/mcc/mcc_bsplines.h
Normal file
650
include/mcc/mcc_bsplines.h
Normal file
@@ -0,0 +1,650 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
#include <ranges>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <FortranCInterface.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* fitting on XY-grid */
|
||||||
|
void fitpack_surfit(int* iopt,
|
||||||
|
// void surfit(int* iopt,
|
||||||
|
int* m,
|
||||||
|
double* x,
|
||||||
|
double* y,
|
||||||
|
double* z,
|
||||||
|
double* w,
|
||||||
|
double* xb,
|
||||||
|
double* xe,
|
||||||
|
double* yb,
|
||||||
|
double* ye,
|
||||||
|
int* kx,
|
||||||
|
int* ky,
|
||||||
|
double* s,
|
||||||
|
int* nxest,
|
||||||
|
int* nyest,
|
||||||
|
int* nmax,
|
||||||
|
double* eps,
|
||||||
|
int* nx,
|
||||||
|
double* tx,
|
||||||
|
int* ny,
|
||||||
|
double* ty,
|
||||||
|
double* c,
|
||||||
|
double* fp,
|
||||||
|
double* wrk1,
|
||||||
|
int* lwrk1,
|
||||||
|
double* wrk2,
|
||||||
|
int* lwrk2,
|
||||||
|
int* iwrk,
|
||||||
|
int* kwrk,
|
||||||
|
int* ier);
|
||||||
|
|
||||||
|
/* XY-grid */
|
||||||
|
void fitpack_bispev(double* tx,
|
||||||
|
// void bispev(double* tx,
|
||||||
|
int* nx,
|
||||||
|
double* ty,
|
||||||
|
int* ny,
|
||||||
|
double* c,
|
||||||
|
int* kx,
|
||||||
|
int* ky,
|
||||||
|
double* x,
|
||||||
|
int* mx,
|
||||||
|
double* y,
|
||||||
|
int* my,
|
||||||
|
double* z,
|
||||||
|
double* wrk,
|
||||||
|
int* lwrk,
|
||||||
|
int* iwrk,
|
||||||
|
int* kwrk,
|
||||||
|
int* ier);
|
||||||
|
|
||||||
|
/* XY-grid */
|
||||||
|
void fitpack_parder(double* tx,
|
||||||
|
// void parder(double* tx,
|
||||||
|
int* nx,
|
||||||
|
double* ty,
|
||||||
|
int* ny,
|
||||||
|
double* c,
|
||||||
|
int* kx,
|
||||||
|
int* ky,
|
||||||
|
int* nux,
|
||||||
|
int* nuy,
|
||||||
|
double* x,
|
||||||
|
int* mx,
|
||||||
|
double* y,
|
||||||
|
int* my,
|
||||||
|
double* z,
|
||||||
|
double* wrk,
|
||||||
|
int* lwrk,
|
||||||
|
int* iwrk,
|
||||||
|
int* kwrk,
|
||||||
|
int* ier);
|
||||||
|
|
||||||
|
/* fitting on sphere */
|
||||||
|
void fitpack_sphere(int* iopt,
|
||||||
|
// void sphere(int* iopt,
|
||||||
|
int* m,
|
||||||
|
double* teta,
|
||||||
|
double* phi,
|
||||||
|
double* r,
|
||||||
|
double* w,
|
||||||
|
double* s,
|
||||||
|
int* ntest,
|
||||||
|
int* npest,
|
||||||
|
double* eps,
|
||||||
|
int* nt,
|
||||||
|
double* tt,
|
||||||
|
int* np,
|
||||||
|
double* tp,
|
||||||
|
double* c,
|
||||||
|
double* fp,
|
||||||
|
double* wrk1,
|
||||||
|
int* lwrk1,
|
||||||
|
double* wrk2,
|
||||||
|
int* lwrk2,
|
||||||
|
int* iwrk,
|
||||||
|
int* kwrk,
|
||||||
|
int* ier);
|
||||||
|
|
||||||
|
/* calculation for set of points (not grid) */
|
||||||
|
void fitpack_bispeu(double* tx,
|
||||||
|
// void bispeu(double* tx,
|
||||||
|
int* nx,
|
||||||
|
double* ty,
|
||||||
|
int* ny,
|
||||||
|
double* c,
|
||||||
|
int* kx,
|
||||||
|
int* ky,
|
||||||
|
double* x,
|
||||||
|
double* y,
|
||||||
|
double* z,
|
||||||
|
int* m,
|
||||||
|
double* wrk,
|
||||||
|
int* lwrk,
|
||||||
|
int* ier);
|
||||||
|
|
||||||
|
|
||||||
|
/* calculation for set of points (not grid) */
|
||||||
|
void fitpack_pardeu(double* tx,
|
||||||
|
// void pardeu(double* tx,
|
||||||
|
int* nx,
|
||||||
|
double* ty,
|
||||||
|
int* ny,
|
||||||
|
double* c,
|
||||||
|
int* kx,
|
||||||
|
int* ky,
|
||||||
|
int* nux,
|
||||||
|
int* nuy,
|
||||||
|
double* x,
|
||||||
|
double* y,
|
||||||
|
double* z,
|
||||||
|
int* m,
|
||||||
|
double* wrk,
|
||||||
|
int* lwrk,
|
||||||
|
int* iwrk,
|
||||||
|
int* kwrk,
|
||||||
|
int* ier);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace mcc::bsplines
|
||||||
|
{
|
||||||
|
|
||||||
|
template <int IOPT = 0,
|
||||||
|
std::ranges::contiguous_range TethaT,
|
||||||
|
std::ranges::contiguous_range PhiT,
|
||||||
|
std::ranges::contiguous_range FuncT,
|
||||||
|
typename WeightT,
|
||||||
|
std::ranges::contiguous_range TKnotT,
|
||||||
|
std::ranges::contiguous_range PKnotT,
|
||||||
|
std::ranges::contiguous_range CoeffT>
|
||||||
|
int fitpack_sphere_smooth(const TethaT& tetha,
|
||||||
|
const PhiT& phi,
|
||||||
|
const FuncT& func,
|
||||||
|
const WeightT& weight,
|
||||||
|
double s_par,
|
||||||
|
int& ntest,
|
||||||
|
int& npest,
|
||||||
|
TKnotT& tetha_knots,
|
||||||
|
PKnotT& phi_knots,
|
||||||
|
CoeffT& coeffs,
|
||||||
|
double& resi2_sum,
|
||||||
|
double eps = std::numeric_limits<double>::epsilon())
|
||||||
|
requires((std::ranges::contiguous_range<WeightT> || std::convertible_to<WeightT, double>) &&
|
||||||
|
std::ranges::output_range<CoeffT, double>)
|
||||||
|
{
|
||||||
|
static_assert(std::same_as<std::ranges::range_value_t<TethaT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<PhiT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<FuncT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<TKnotT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<PKnotT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<CoeffT>, double>,
|
||||||
|
"Input ranges elements type must be double!");
|
||||||
|
|
||||||
|
if constexpr (std::ranges::contiguous_range<WeightT>) {
|
||||||
|
static_assert(std::same_as<std::ranges::range_value_t<WeightT>, double>,
|
||||||
|
"Input ranges elements type must be double!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static_assert(IOPT != -1 || IOPT != 0 || IOPT != 1, "Invalid IOPT template parameter value!");
|
||||||
|
|
||||||
|
|
||||||
|
int m = std::min(std::min(std::ranges::size(tetha), std::ranges::size(phi)), std::ranges::size(func));
|
||||||
|
if (m < 2) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
/* do checking here to avoid possibly unnecessary memory allocations */
|
||||||
|
|
||||||
|
// number of knots must be >= 8 for the qubic b-splines
|
||||||
|
if (ntest < 8 || npest < 8) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (std::ranges::contiguous_range<WeightT>) {
|
||||||
|
m = std::min(m, std::ranges::size(weight));
|
||||||
|
if (m < 2) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_par <= 0.0) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eps <= 0.0 || eps >= 1.0) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
int nt = std::ranges::size(tetha_knots);
|
||||||
|
int np = std::ranges::size(phi_knots);
|
||||||
|
|
||||||
|
if (nt < ntest) {
|
||||||
|
std::ranges::fill_n(std::back_inserter(tetha_knots), ntest - nt, 0.0);
|
||||||
|
}
|
||||||
|
if (np < npest) {
|
||||||
|
std::ranges::fill_n(std::back_inserter(phi_knots), npest - np, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// compute working arrays sizes according to sphere.f
|
||||||
|
const int u = ntest - 7;
|
||||||
|
const int v = npest - 7;
|
||||||
|
const int uv = u * v;
|
||||||
|
const int v2 = v * v;
|
||||||
|
|
||||||
|
int lwrk1 = 185 + 52 * v + 10 * u + 14 * uv + 8 * (u - 1) * v2 + 8 * m;
|
||||||
|
int lwrk2 = 48 + 21 * v + 7 * uv + 4 * (u - 1) * v2;
|
||||||
|
int kwrk = m + uv;
|
||||||
|
|
||||||
|
std::vector<double> wrk1(lwrk1);
|
||||||
|
std::vector<double> wrk2(lwrk2);
|
||||||
|
std::vector<int> iwrk(kwrk);
|
||||||
|
|
||||||
|
const int n_coeffs = (ntest - 4) * (npest - 4);
|
||||||
|
if (std::ranges::size(coeffs) < n_coeffs) { // resize
|
||||||
|
std::ranges::fill_n(std::back_inserter(coeffs), n_coeffs - std::ranges::size(coeffs), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int iopt = IOPT;
|
||||||
|
|
||||||
|
auto tetha_ptr = const_cast<double*>(std::ranges::data(tetha));
|
||||||
|
auto phi_ptr = const_cast<double*>(std::ranges::data(phi));
|
||||||
|
auto func_ptr = const_cast<double*>(std::ranges::data(func));
|
||||||
|
auto tetha_knots_ptr = const_cast<double*>(std::ranges::data(tetha_knots));
|
||||||
|
auto phi_knots_ptr = const_cast<double*>(std::ranges::data(phi_knots));
|
||||||
|
|
||||||
|
if constexpr (std::ranges::contiguous_range<WeightT>) {
|
||||||
|
auto weight_ptr = const_cast<double*>(std::ranges::data(weight));
|
||||||
|
|
||||||
|
fitpack_sphere(&iopt, &m, tetha_ptr, phi_ptr, func_ptr, weight_ptr, &s_par, &nt, &np, &eps, &ntest,
|
||||||
|
tetha_knots_ptr, &npest, phi_knots_ptr, std::ranges::data(coeffs), &resi2_sum, wrk1.data(),
|
||||||
|
&lwrk1, wrk2.data(), &lwrk2, iwrk.data(), &kwrk, &res);
|
||||||
|
} else {
|
||||||
|
std::vector<double> weight_vec(m, weight);
|
||||||
|
|
||||||
|
fitpack_sphere(&iopt, &m, tetha_ptr, phi_ptr, func_ptr, weight_vec.data(), &s_par, &nt, &np, &eps, &ntest,
|
||||||
|
tetha_knots_ptr, &npest, phi_knots_ptr, std::ranges::data(coeffs), &resi2_sum, wrk1.data(),
|
||||||
|
&lwrk1, wrk2.data(), &lwrk2, iwrk.data(), &kwrk, &res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
least-squares fitting (iopt=-1)
|
||||||
|
*/
|
||||||
|
template <std::ranges::contiguous_range TethaT,
|
||||||
|
std::ranges::contiguous_range PhiT,
|
||||||
|
std::ranges::contiguous_range FuncT,
|
||||||
|
typename WeightT,
|
||||||
|
std::ranges::contiguous_range TKnotT,
|
||||||
|
std::ranges::contiguous_range PKnotT,
|
||||||
|
std::ranges::contiguous_range CoeffT>
|
||||||
|
int fitpack_sphere_fit(const TethaT& tetha,
|
||||||
|
const PhiT& phi,
|
||||||
|
const FuncT& func,
|
||||||
|
const WeightT& weight,
|
||||||
|
TKnotT& tetha_knots,
|
||||||
|
PKnotT& phi_knots,
|
||||||
|
CoeffT& coeffs,
|
||||||
|
double& resi2_sum,
|
||||||
|
double eps = std::numeric_limits<double>::epsilon())
|
||||||
|
{
|
||||||
|
const double s = 100.0;
|
||||||
|
int nt = std::ranges::size(tetha_knots);
|
||||||
|
int np = std::ranges::size(phi_knots);
|
||||||
|
|
||||||
|
return fitpack_sphere_smooth<-1>(tetha, phi, func, weight, s, nt, np, tetha_knots, phi_knots, coeffs, resi2_sum,
|
||||||
|
eps);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <std::ranges::contiguous_range TXT,
|
||||||
|
std::ranges::contiguous_range TYT,
|
||||||
|
std::ranges::contiguous_range XT,
|
||||||
|
std::ranges::contiguous_range YT,
|
||||||
|
std::ranges::contiguous_range CoeffT,
|
||||||
|
std::ranges::contiguous_range FuncT>
|
||||||
|
int fitpack_eval_spl2d_grid(const TXT& tx,
|
||||||
|
const TYT& ty,
|
||||||
|
const CoeffT& coeffs,
|
||||||
|
const XT& x,
|
||||||
|
const YT& y,
|
||||||
|
FuncT& func,
|
||||||
|
int kx = 3,
|
||||||
|
int ky = 3)
|
||||||
|
{
|
||||||
|
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<TYT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<XT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<YT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<CoeffT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<FuncT>, double>,
|
||||||
|
"Input ranges elements type must be double!");
|
||||||
|
|
||||||
|
if (kx < 0 || ky < 0) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ier = 0;
|
||||||
|
|
||||||
|
int ntx = std::ranges::size(tx);
|
||||||
|
int nty = std::ranges::size(ty);
|
||||||
|
|
||||||
|
auto n_coeffs = (ntx - kx - 1) * (nty - ky - 1);
|
||||||
|
if (std::ranges::size(coeffs) < n_coeffs) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mx = std::ranges::size(x), my = std::ranges::size(y);
|
||||||
|
int N = mx * my;
|
||||||
|
|
||||||
|
if (std::ranges::size(func) < N) {
|
||||||
|
std::ranges::fill_n(std::back_inserter(func), N - std::ranges::size(func), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute sizes of working arrays according to bispev.f
|
||||||
|
int lwrk = mx * (kx + 1) + my * (ky + 1);
|
||||||
|
std::vector<double> wrk(lwrk);
|
||||||
|
|
||||||
|
int kwrk = mx + my;
|
||||||
|
std::vector<int> iwrk(kwrk);
|
||||||
|
|
||||||
|
auto tx_ptr = const_cast<double*>(std::ranges::data(tx));
|
||||||
|
auto ty_ptr = const_cast<double*>(std::ranges::data(ty));
|
||||||
|
auto coeffs_ptr = const_cast<double*>(std::ranges::data(coeffs));
|
||||||
|
auto x_ptr = const_cast<double*>(std::ranges::data(x));
|
||||||
|
auto y_ptr = const_cast<double*>(std::ranges::data(y));
|
||||||
|
|
||||||
|
fitpack_bispev(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, x_ptr, &mx, y_ptr, &my, std::ranges::data(func),
|
||||||
|
wrk.data(), &lwrk, iwrk.data(), &kwrk, &ier);
|
||||||
|
|
||||||
|
return ier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* for set of points */
|
||||||
|
template <std::ranges::contiguous_range TXT,
|
||||||
|
std::ranges::contiguous_range TYT,
|
||||||
|
std::ranges::contiguous_range XT,
|
||||||
|
std::ranges::contiguous_range YT,
|
||||||
|
std::ranges::contiguous_range CoeffT,
|
||||||
|
std::ranges::contiguous_range FuncT>
|
||||||
|
int fitpack_eval_spl2d(const TXT& tx,
|
||||||
|
const TYT& ty,
|
||||||
|
const CoeffT& coeffs,
|
||||||
|
const XT& x,
|
||||||
|
const YT& y,
|
||||||
|
FuncT& func,
|
||||||
|
int kx = 3,
|
||||||
|
int ky = 3)
|
||||||
|
{
|
||||||
|
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<TYT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<XT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<YT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<CoeffT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<FuncT>, double>,
|
||||||
|
"Input ranges elements type must be double!");
|
||||||
|
|
||||||
|
if (kx < 0 || ky < 0) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::ranges::size(x) != std::ranges::size(y)) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
int m = std::ranges::size(x);
|
||||||
|
|
||||||
|
int ier = 0;
|
||||||
|
|
||||||
|
int ntx = std::ranges::size(tx);
|
||||||
|
int nty = std::ranges::size(ty);
|
||||||
|
|
||||||
|
auto n_coeffs = (ntx - kx - 1) * (nty - ky - 1);
|
||||||
|
if (std::ranges::size(coeffs) < n_coeffs) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::ranges::size(func) < m) {
|
||||||
|
std::ranges::fill_n(std::back_inserter(func), m - std::ranges::size(func), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto tx_ptr = const_cast<double*>(std::ranges::data(tx));
|
||||||
|
auto ty_ptr = const_cast<double*>(std::ranges::data(ty));
|
||||||
|
auto coeffs_ptr = const_cast<double*>(std::ranges::data(coeffs));
|
||||||
|
auto x_ptr = const_cast<double*>(std::ranges::data(x));
|
||||||
|
auto y_ptr = const_cast<double*>(std::ranges::data(y));
|
||||||
|
|
||||||
|
int lwrk = kx + ky + 2;
|
||||||
|
std::vector<double> wrk(lwrk);
|
||||||
|
|
||||||
|
fitpack_bispeu(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, x_ptr, y_ptr, std::ranges::data(func), &m,
|
||||||
|
wrk.data(), &lwrk, &ier);
|
||||||
|
// bispeu(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, x_ptr, y_ptr, std::ranges::data(func), &m, wrk.data(),
|
||||||
|
// &lwrk, &ier);
|
||||||
|
|
||||||
|
return ier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// scalar x,y version
|
||||||
|
template <std::ranges::contiguous_range TXT,
|
||||||
|
std::ranges::contiguous_range TYT,
|
||||||
|
typename XT,
|
||||||
|
typename YT,
|
||||||
|
std::ranges::contiguous_range CoeffT,
|
||||||
|
typename FuncT>
|
||||||
|
int fitpack_eval_spl2d(const TXT& tx,
|
||||||
|
const TYT& ty,
|
||||||
|
const CoeffT& coeffs,
|
||||||
|
const XT& x,
|
||||||
|
const YT& y,
|
||||||
|
FuncT& func,
|
||||||
|
int kx = 3,
|
||||||
|
int ky = 3)
|
||||||
|
{
|
||||||
|
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<TYT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<CoeffT>, double>,
|
||||||
|
"Input ranges elements type must be double!");
|
||||||
|
|
||||||
|
static_assert(
|
||||||
|
std::convertible_to<XT, double> && std::convertible_to<YT, double> && std::convertible_to<FuncT, double>,
|
||||||
|
"XT, YT and FuncT types must be a scalar convertible to double!");
|
||||||
|
|
||||||
|
auto xv = std::vector<double>(1, x);
|
||||||
|
auto yv = std::vector<double>(1, y);
|
||||||
|
auto fv = std::vector<double>(1, func);
|
||||||
|
|
||||||
|
return fitpack_eval_spl2d(tx, ty, coeffs, xv, yv, fv, kx, ky);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* partial derivatives */
|
||||||
|
|
||||||
|
template <std::ranges::contiguous_range TXT,
|
||||||
|
std::ranges::contiguous_range TYT,
|
||||||
|
std::ranges::contiguous_range XT,
|
||||||
|
std::ranges::contiguous_range YT,
|
||||||
|
std::ranges::contiguous_range CoeffT,
|
||||||
|
std::ranges::contiguous_range PderT>
|
||||||
|
int fitpack_parder_spl2d_grid(const TXT& tx,
|
||||||
|
const TYT& ty,
|
||||||
|
const CoeffT& coeffs,
|
||||||
|
const XT& x,
|
||||||
|
const YT& y,
|
||||||
|
PderT& pder,
|
||||||
|
int dx, // partial derivatives order along X
|
||||||
|
int dy, // partial derivatives order along Y
|
||||||
|
int kx = 3,
|
||||||
|
int ky = 3)
|
||||||
|
{
|
||||||
|
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<TYT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<XT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<YT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<CoeffT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<PderT>, double>,
|
||||||
|
"Input ranges elements type must be double!");
|
||||||
|
|
||||||
|
if (kx < 0 || ky < 0 || dx < 0 || dy < 0) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ntx = std::ranges::size(tx);
|
||||||
|
int nty = std::ranges::size(ty);
|
||||||
|
|
||||||
|
auto n_coeffs = (ntx - kx - 1) * (nty - ky - 1);
|
||||||
|
if (std::ranges::size(coeffs) < n_coeffs) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mx = std::ranges::size(x), my = std::ranges::size(y);
|
||||||
|
int N = mx * my;
|
||||||
|
|
||||||
|
if (std::ranges::size(pder) < N) {
|
||||||
|
std::ranges::fill_n(std::back_inserter(pder), N - std::ranges::size(pder), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// mx >=1, my >=1, 0 <= nux < kx, 0 <= nuy < ky, kwrk>=mx+my
|
||||||
|
// lwrk>=mx*(kx+1-nux)+my*(ky+1-nuy)+(nx-kx-1)*(ny-ky-1),
|
||||||
|
|
||||||
|
// compute sizes of working arrays according parder.f
|
||||||
|
int lwrk = mx * (kx + 1 - dx) + my * (ky + 1 - dy) + (ntx - kx - 1) * (nty - ky - 1);
|
||||||
|
std::vector<double> wrk(lwrk);
|
||||||
|
|
||||||
|
int kwrk = mx + my;
|
||||||
|
std::vector<int> iwrk(kwrk);
|
||||||
|
|
||||||
|
|
||||||
|
auto tx_ptr = const_cast<double*>(std::ranges::data(tx));
|
||||||
|
auto ty_ptr = const_cast<double*>(std::ranges::data(ty));
|
||||||
|
auto coeffs_ptr = const_cast<double*>(std::ranges::data(coeffs));
|
||||||
|
auto x_ptr = const_cast<double*>(std::ranges::data(x));
|
||||||
|
auto y_ptr = const_cast<double*>(std::ranges::data(y));
|
||||||
|
|
||||||
|
int ier = 0;
|
||||||
|
|
||||||
|
fitpack_parder(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, &dx, &dy, x_ptr, &mx, y_ptr, &my,
|
||||||
|
std::ranges::data(pder), wrk.data(), &lwrk, iwrk.data(), &kwrk, &ier);
|
||||||
|
|
||||||
|
return ier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <std::ranges::contiguous_range TXT,
|
||||||
|
std::ranges::contiguous_range TYT,
|
||||||
|
std::ranges::contiguous_range XT,
|
||||||
|
std::ranges::contiguous_range YT,
|
||||||
|
std::ranges::contiguous_range CoeffT,
|
||||||
|
std::ranges::contiguous_range PderT>
|
||||||
|
int fitpack_parder_spl2d(const TXT& tx,
|
||||||
|
const TYT& ty,
|
||||||
|
const CoeffT& coeffs,
|
||||||
|
const XT& x,
|
||||||
|
const YT& y,
|
||||||
|
PderT& pder,
|
||||||
|
int dx, // partial derivatives order along X
|
||||||
|
int dy, // partial derivatives order along Y
|
||||||
|
int kx = 3,
|
||||||
|
int ky = 3)
|
||||||
|
{
|
||||||
|
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<TYT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<XT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<YT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<CoeffT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<PderT>, double>,
|
||||||
|
"Input ranges elements type must be double!");
|
||||||
|
|
||||||
|
if (kx < 0 || ky < 0 || dx < 0 || dy < 0) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ntx = std::ranges::size(tx);
|
||||||
|
int nty = std::ranges::size(ty);
|
||||||
|
|
||||||
|
auto n_coeffs = (ntx - kx - 1) * (nty - ky - 1);
|
||||||
|
if (std::ranges::size(coeffs) < n_coeffs) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
int m = std::ranges::size(x);
|
||||||
|
if (std::ranges::size(x) != std::ranges::size(y)) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::ranges::size(pder) < m) {
|
||||||
|
std::ranges::fill_n(std::back_inserter(pder), m - std::ranges::size(pder), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
auto tx_ptr = const_cast<double*>(std::ranges::data(tx));
|
||||||
|
auto ty_ptr = const_cast<double*>(std::ranges::data(ty));
|
||||||
|
auto coeffs_ptr = const_cast<double*>(std::ranges::data(coeffs));
|
||||||
|
auto x_ptr = const_cast<double*>(std::ranges::data(x));
|
||||||
|
auto y_ptr = const_cast<double*>(std::ranges::data(y));
|
||||||
|
|
||||||
|
int ier = 0;
|
||||||
|
|
||||||
|
int lwrk = m * (kx + 1 - dx) + m * (ky + 1 - dy) + (ntx - kx - 1) * (nty - ky - 1);
|
||||||
|
std::vector<double> wrk(lwrk);
|
||||||
|
|
||||||
|
int kwrk = 2 * m;
|
||||||
|
std::vector<int> iwrk(kwrk);
|
||||||
|
|
||||||
|
fitpack_pardeu(tx_ptr, &ntx, ty_ptr, &nty, coeffs_ptr, &kx, &ky, &dx, &dy, x_ptr, y_ptr, std::ranges::data(pder),
|
||||||
|
&m, wrk.data(), &lwrk, iwrk.data(), &kwrk, &ier);
|
||||||
|
|
||||||
|
return ier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// scalar version
|
||||||
|
template <std::ranges::contiguous_range TXT,
|
||||||
|
std::ranges::contiguous_range TYT,
|
||||||
|
typename XT,
|
||||||
|
typename YT,
|
||||||
|
std::ranges::contiguous_range CoeffT,
|
||||||
|
typename PderT>
|
||||||
|
int fitpack_parder_spl2d(const TXT& tx,
|
||||||
|
const TYT& ty,
|
||||||
|
const CoeffT& coeffs,
|
||||||
|
const XT& x,
|
||||||
|
const YT& y,
|
||||||
|
PderT& pder,
|
||||||
|
int dx, // partial derivatives order along X
|
||||||
|
int dy, // partial derivatives order along Y
|
||||||
|
int kx = 3,
|
||||||
|
int ky = 3)
|
||||||
|
{
|
||||||
|
static_assert(std::same_as<std::ranges::range_value_t<TXT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<TYT>, double> &&
|
||||||
|
std::same_as<std::ranges::range_value_t<CoeffT>, double>,
|
||||||
|
"Input ranges elements type must be double!");
|
||||||
|
|
||||||
|
static_assert(
|
||||||
|
std::convertible_to<XT, double> && std::convertible_to<YT, double> && std::convertible_to<PderT, double>,
|
||||||
|
"XT, YT and FuncT types must be a scalar convertible to double!");
|
||||||
|
|
||||||
|
auto xv = std::vector<double>(1, x);
|
||||||
|
auto yv = std::vector<double>(1, y);
|
||||||
|
auto pv = std::vector<double>(1, pder);
|
||||||
|
|
||||||
|
return fitpack_parder_spl2d(tx, ty, coeffs, xv, yv, pv, dx, dy, kx, ky);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace mcc::bsplines
|
||||||
@@ -280,15 +280,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// latitude and longitude
|
// longitude and latitude
|
||||||
template <mcc_angle_c LAT_T, mcc_angle_c LON_T>
|
template <mcc_angle_c LON_T, mcc_angle_c LAT_T>
|
||||||
void geoPosition(std::pair<LAT_T, LON_T>* coords) const
|
void geoPosition(std::pair<LON_T, LAT_T>* coords) const
|
||||||
{
|
{
|
||||||
std::lock_guard lock{*_stateMutex};
|
std::lock_guard lock{*_stateMutex};
|
||||||
|
|
||||||
if (coords) {
|
if (coords) {
|
||||||
coords->first = _currentState.lat;
|
coords->first = _currentState.lon;
|
||||||
coords->second = _currentState.lon;
|
coords->second = _currentState.lat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,8 +479,12 @@ private:
|
|||||||
|
|
||||||
inline static const std::regex bull_tab_title_rx{"^ *MJD +x\\(arcsec\\) +y\\(arcsec\\) +UT1-UTC\\(sec\\) *$"};
|
inline static const std::regex bull_tab_title_rx{"^ *MJD +x\\(arcsec\\) +y\\(arcsec\\) +UT1-UTC\\(sec\\) *$"};
|
||||||
|
|
||||||
|
// inline static const std::regex bull_tab_vals_rx{
|
||||||
|
// "^ *[0-9]{4,} +[0-9]{1,2} +[0-9]{1,2} +[0-9]{5,} +[0-9]+\\.[0-9]+
|
||||||
|
// +[0-9]+\\.[0-9]+ +[0-9]+\\.[0-9]+ *$"};
|
||||||
inline static const std::regex bull_tab_vals_rx{
|
inline static const std::regex bull_tab_vals_rx{
|
||||||
"^ *[0-9]{4,} +[0-9]{1,2} +[0-9]{1,2} +[0-9]{5,} +[0-9]+\\.[0-9]+ +[0-9]+\\.[0-9]+ +[0-9]+\\.[0-9]+ *$"};
|
"^ *[0-9]{4,} +[0-9]{1,2} +[0-9]{1,2} +[0-9]{5,} +(\\+|\\-)?[0-9]+\\.[0-9]+ +(\\+|\\-)?[0-9]+\\.[0-9]+ "
|
||||||
|
"+(\\+|\\-)?[0-9]+\\.[0-9]+ *$"};
|
||||||
|
|
||||||
|
|
||||||
time_point_t _date;
|
time_point_t _date;
|
||||||
556
include/mcc/mcc_ccte_iers_default.h
Normal file
556
include/mcc/mcc_ccte_iers_default.h
Normal file
@@ -0,0 +1,556 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
namespace mcc::ccte::iers::defaults
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
// https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat
|
||||||
|
|
||||||
|
static std::string MCC_DEFAULT_LEAP_SECONDS_FILE = R"--(
|
||||||
|
|
||||||
|
# Value of TAI-UTC in second valid beetween the initial value until
|
||||||
|
# the epoch given on the next line. The last line reads that NO
|
||||||
|
# leap second was introduced since the corresponding date
|
||||||
|
# Updated through IERS Bulletin 72 issued in July 2026
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# File expires on 28 June 2027
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# MJD Date TAI-UTC (s)
|
||||||
|
# day month year
|
||||||
|
# --- -------------- ------
|
||||||
|
#
|
||||||
|
41317.0 1 1 1972 10
|
||||||
|
41499.0 1 7 1972 11
|
||||||
|
41683.0 1 1 1973 12
|
||||||
|
42048.0 1 1 1974 13
|
||||||
|
42413.0 1 1 1975 14
|
||||||
|
42778.0 1 1 1976 15
|
||||||
|
43144.0 1 1 1977 16
|
||||||
|
43509.0 1 1 1978 17
|
||||||
|
43874.0 1 1 1979 18
|
||||||
|
44239.0 1 1 1980 19
|
||||||
|
44786.0 1 7 1981 20
|
||||||
|
45151.0 1 7 1982 21
|
||||||
|
45516.0 1 7 1983 22
|
||||||
|
46247.0 1 7 1985 23
|
||||||
|
47161.0 1 1 1988 24
|
||||||
|
47892.0 1 1 1990 25
|
||||||
|
48257.0 1 1 1991 26
|
||||||
|
48804.0 1 7 1992 27
|
||||||
|
49169.0 1 7 1993 28
|
||||||
|
49534.0 1 7 1994 29
|
||||||
|
50083.0 1 1 1996 30
|
||||||
|
50630.0 1 7 1997 31
|
||||||
|
51179.0 1 1 1999 32
|
||||||
|
53736.0 1 1 2006 33
|
||||||
|
54832.0 1 1 2009 34
|
||||||
|
56109.0 1 7 2012 35
|
||||||
|
57204.0 1 7 2015 36
|
||||||
|
57754.0 1 1 2017 37
|
||||||
|
)--";
|
||||||
|
|
||||||
|
|
||||||
|
// https://datacenter.iers.org/data/latestVersion/bulletinA.txt
|
||||||
|
|
||||||
|
static std::string MCC_DEFAULT_IERS_BULLETIN_A_FILE = R"--(
|
||||||
|
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* *
|
||||||
|
* I E R S B U L L E T I N - A *
|
||||||
|
* *
|
||||||
|
* Rapid Service/Prediction of Earth Orientation *
|
||||||
|
**********************************************************************
|
||||||
|
8 October 2026 Vol. XXXIX No. 041
|
||||||
|
______________________________________________________________________
|
||||||
|
GENERAL INFORMATION:
|
||||||
|
MJD = Julian Date - 2 400 000.5 days
|
||||||
|
UT2-UT1 = 0.022 sin(2*pi*T) - 0.012 cos(2*pi*T)
|
||||||
|
- 0.006 sin(4*pi*T) + 0.007 cos(4*pi*T)
|
||||||
|
where pi = 3.14159265... and T is the date in Besselian years.
|
||||||
|
TT = TAI + 32.184 seconds
|
||||||
|
DUT1= (UT1-UTC) transmitted with time signals
|
||||||
|
= 0.0 seconds beginning 09 April 2026 at 0000 UTC
|
||||||
|
Beginning 1 January 2017:
|
||||||
|
TAI-UTC = 37.000 000 seconds
|
||||||
|
***********************************************************************
|
||||||
|
* ANNOUNCEMENTS: *
|
||||||
|
* *
|
||||||
|
* There will NOT be a leap second introduced in UTC *
|
||||||
|
* at the end of December 2026. *
|
||||||
|
* *
|
||||||
|
* The primary source for IERS Rapid Service/Prediction Center (RS/PC) *
|
||||||
|
* data products is the official IERS RS/PC website: *
|
||||||
|
* https://maia.usno.navy.mil *
|
||||||
|
* *
|
||||||
|
* IERS RS/PC products are also available from: *
|
||||||
|
* NASA CDDIS: https://cddis.nasa.gov/archive/products/iers/ *
|
||||||
|
* NASA CDDIS: ftps://gdc.cddis.eosdis.nasa.gov/products/iers/ *
|
||||||
|
* IERS Central Bureau: https://datacenter.iers.org/eop.php *
|
||||||
|
* *
|
||||||
|
* Questions about IERS RS/PC products can be emailed to: *
|
||||||
|
* eopcp@us.navy.mil *
|
||||||
|
* *
|
||||||
|
* Distribution statement A: *
|
||||||
|
* Approved for public release: distribution unlimited. *
|
||||||
|
* *
|
||||||
|
***********************************************************************
|
||||||
|
________________________________________________________________________
|
||||||
|
The contributed observations used in the preparation of this Bulletin
|
||||||
|
are available at <http://www.usno.navy.mil/USNO/earth-orientation/
|
||||||
|
eo-info/general/input-data>. The contributed analysis results are based
|
||||||
|
on data from Very Long Baseline Interferometry (VLBI), Satellite Laser
|
||||||
|
Ranging (SLR), the Global Positioning System (GPS) satellites, Lunar
|
||||||
|
Laser Ranging (LLR), and meteorological predictions of variations in
|
||||||
|
Atmospheric Angular Momentum (AAM).
|
||||||
|
________________________________________________________________________
|
||||||
|
|
||||||
|
COMBINED EARTH ORIENTATION PARAMETERS:
|
||||||
|
|
||||||
|
IERS Rapid Service
|
||||||
|
MJD x error y error UT1-UTC error
|
||||||
|
" " " " s s
|
||||||
|
26 10 2 61315 0.17334 .00009 0.32459 .00009 -0.023137 0.000021
|
||||||
|
26 10 3 61316 0.17258 .00009 0.32394 .00009 -0.023648 0.000022
|
||||||
|
26 10 4 61317 0.17187 .00009 0.32345 .00009 -0.024220 0.000021
|
||||||
|
26 10 5 61318 0.17095 .00009 0.32294 .00009 -0.025006 0.000022
|
||||||
|
26 10 6 61319 0.16982 .00009 0.32250 .00009 -0.026011 0.000022
|
||||||
|
26 10 7 61320 0.16879 .00009 0.32217 .00009 -0.027264 0.000023
|
||||||
|
26 10 8 61321 0.16813 .00009 0.32221 .00009 -0.028742 0.000022
|
||||||
|
|
||||||
|
_______________________________________________________________________
|
||||||
|
|
||||||
|
PREDICTIONS:
|
||||||
|
The following formulas will not reproduce the predictions given below,
|
||||||
|
but may be used to extend the predictions beyond the end of this table.
|
||||||
|
|
||||||
|
x = 0.1598 + 0.0465 cos A - 0.1071 sin A - 0.0426 cos C + 0.0358 sin C
|
||||||
|
y = 0.3762 - 0.0906 cos A - 0.0441 sin A + 0.0358 cos C + 0.0426 sin C
|
||||||
|
UT1-UTC = -0.1023 - 0.00035 (MJD - 61329) - (UT2-UT1)
|
||||||
|
|
||||||
|
where A = 2*pi*(MJD-61321)/365.25 and C = 2*pi*(MJD-61321)/435.
|
||||||
|
|
||||||
|
TAI-UTC(MJD 61322) = 37.0
|
||||||
|
The accuracy may be estimated from the expressions:
|
||||||
|
S x,y = 0.00068 (MJD-61321)**0.80 S t = 0.00025 (MJD-61321)**0.75
|
||||||
|
Estimated accuracies are: Predictions 10 d 20 d 30 d 40 d
|
||||||
|
Polar coord's 0.004 0.007 0.010 0.013
|
||||||
|
UT1-UTC 0.0014 0.0024 0.0032 0.0040
|
||||||
|
|
||||||
|
MJD x(arcsec) y(arcsec) UT1-UTC(sec)
|
||||||
|
2026 10 9 61322 0.1672 0.3223 -0.03029
|
||||||
|
2026 10 10 61323 0.1664 0.3225 -0.03180
|
||||||
|
2026 10 11 61324 0.1656 0.3226 -0.03321
|
||||||
|
2026 10 12 61325 0.1646 0.3227 -0.03444
|
||||||
|
2026 10 13 61326 0.1636 0.3227 -0.03546
|
||||||
|
2026 10 14 61327 0.1624 0.3225 -0.03625
|
||||||
|
2026 10 15 61328 0.1614 0.3223 -0.03684
|
||||||
|
2026 10 16 61329 0.1603 0.3222 -0.03732
|
||||||
|
2026 10 17 61330 0.1593 0.3221 -0.03778
|
||||||
|
2026 10 18 61331 0.1583 0.3220 -0.03834
|
||||||
|
2026 10 19 61332 0.1573 0.3220 -0.03904
|
||||||
|
2026 10 20 61333 0.1563 0.3220 -0.03991
|
||||||
|
2026 10 21 61334 0.1553 0.3220 -0.04102
|
||||||
|
2026 10 22 61335 0.1542 0.3220 -0.04236
|
||||||
|
2026 10 23 61336 0.1532 0.3221 -0.04389
|
||||||
|
2026 10 24 61337 0.1521 0.3221 -0.04556
|
||||||
|
2026 10 25 61338 0.1511 0.3222 -0.04727
|
||||||
|
2026 10 26 61339 0.1500 0.3222 -0.04888
|
||||||
|
2026 10 27 61340 0.1489 0.3223 -0.05031
|
||||||
|
2026 10 28 61341 0.1478 0.3224 -0.05150
|
||||||
|
2026 10 29 61342 0.1467 0.3225 -0.05251
|
||||||
|
2026 10 30 61343 0.1456 0.3226 -0.05343
|
||||||
|
2026 10 31 61344 0.1445 0.3227 -0.05437
|
||||||
|
2026 11 1 61345 0.1434 0.3228 -0.05546
|
||||||
|
2026 11 2 61346 0.1423 0.3230 -0.05677
|
||||||
|
2026 11 3 61347 0.1412 0.3231 -0.05830
|
||||||
|
2026 11 4 61348 0.1401 0.3233 -0.05999
|
||||||
|
2026 11 5 61349 0.1390 0.3235 -0.06177
|
||||||
|
2026 11 6 61350 0.1379 0.3237 -0.06353
|
||||||
|
2026 11 7 61351 0.1368 0.3239 -0.06518
|
||||||
|
2026 11 8 61352 0.1357 0.3242 -0.06664
|
||||||
|
2026 11 9 61353 0.1346 0.3244 -0.06789
|
||||||
|
2026 11 10 61354 0.1334 0.3247 -0.06892
|
||||||
|
2026 11 11 61355 0.1323 0.3250 -0.06976
|
||||||
|
2026 11 12 61356 0.1312 0.3253 -0.07049
|
||||||
|
2026 11 13 61357 0.1301 0.3256 -0.07117
|
||||||
|
2026 11 14 61358 0.1290 0.3259 -0.07187
|
||||||
|
2026 11 15 61359 0.1279 0.3263 -0.07267
|
||||||
|
2026 11 16 61360 0.1268 0.3266 -0.07362
|
||||||
|
2026 11 17 61361 0.1257 0.3270 -0.07477
|
||||||
|
2026 11 18 61362 0.1246 0.3274 -0.07612
|
||||||
|
2026 11 19 61363 0.1235 0.3278 -0.07765
|
||||||
|
2026 11 20 61364 0.1224 0.3283 -0.07931
|
||||||
|
2026 11 21 61365 0.1213 0.3287 -0.08103
|
||||||
|
2026 11 22 61366 0.1203 0.3292 -0.08270
|
||||||
|
2026 11 23 61367 0.1192 0.3296 -0.08420
|
||||||
|
2026 11 24 61368 0.1181 0.3301 -0.08546
|
||||||
|
2026 11 25 61369 0.1171 0.3306 -0.08647
|
||||||
|
2026 11 26 61370 0.1160 0.3311 -0.08729
|
||||||
|
2026 11 27 61371 0.1149 0.3317 -0.08807
|
||||||
|
2026 11 28 61372 0.1139 0.3322 -0.08895
|
||||||
|
2026 11 29 61373 0.1129 0.3328 -0.09003
|
||||||
|
2026 11 30 61374 0.1118 0.3334 -0.09134
|
||||||
|
2026 12 1 61375 0.1108 0.3340 -0.09284
|
||||||
|
2026 12 2 61376 0.1098 0.3346 -0.09444
|
||||||
|
2026 12 3 61377 0.1088 0.3352 -0.09603
|
||||||
|
2026 12 4 61378 0.1078 0.3359 -0.09752
|
||||||
|
2026 12 5 61379 0.1068 0.3365 -0.09884
|
||||||
|
2026 12 6 61380 0.1058 0.3372 -0.09995
|
||||||
|
2026 12 7 61381 0.1048 0.3379 -0.10085
|
||||||
|
2026 12 8 61382 0.1038 0.3386 -0.10156
|
||||||
|
2026 12 9 61383 0.1029 0.3393 -0.10213
|
||||||
|
2026 12 10 61384 0.1019 0.3400 -0.10261
|
||||||
|
2026 12 11 61385 0.1010 0.3408 -0.10308
|
||||||
|
2026 12 12 61386 0.1001 0.3416 -0.10361
|
||||||
|
2026 12 13 61387 0.0992 0.3423 -0.10426
|
||||||
|
2026 12 14 61388 0.0983 0.3431 -0.10506
|
||||||
|
2026 12 15 61389 0.0974 0.3439 -0.10604
|
||||||
|
2026 12 16 61390 0.0965 0.3447 -0.10718
|
||||||
|
2026 12 17 61391 0.0956 0.3456 -0.10847
|
||||||
|
2026 12 18 61392 0.0948 0.3464 -0.10983
|
||||||
|
2026 12 19 61393 0.0939 0.3473 -0.11117
|
||||||
|
2026 12 20 61394 0.0931 0.3481 -0.11241
|
||||||
|
2026 12 21 61395 0.0923 0.3490 -0.11346
|
||||||
|
2026 12 22 61396 0.0915 0.3499 -0.11427
|
||||||
|
2026 12 23 61397 0.0907 0.3508 -0.11490
|
||||||
|
2026 12 24 61398 0.0900 0.3517 -0.11543
|
||||||
|
2026 12 25 61399 0.0892 0.3527 -0.11604
|
||||||
|
2026 12 26 61400 0.0885 0.3536 -0.11683
|
||||||
|
2026 12 27 61401 0.0877 0.3546 -0.11789
|
||||||
|
2026 12 28 61402 0.0870 0.3555 -0.11917
|
||||||
|
2026 12 29 61403 0.0863 0.3565 -0.12060
|
||||||
|
2026 12 30 61404 0.0857 0.3575 -0.12202
|
||||||
|
2026 12 31 61405 0.0850 0.3585 -0.12334
|
||||||
|
2027 1 1 61406 0.0844 0.3595 -0.12446
|
||||||
|
2027 1 2 61407 0.0837 0.3606 -0.12535
|
||||||
|
2027 1 3 61408 0.0831 0.3616 -0.12600
|
||||||
|
2027 1 4 61409 0.0825 0.3626 -0.12645
|
||||||
|
2027 1 5 61410 0.0820 0.3637 -0.12674
|
||||||
|
2027 1 6 61411 0.0814 0.3647 -0.12694
|
||||||
|
2027 1 7 61412 0.0809 0.3658 -0.12711
|
||||||
|
2027 1 8 61413 0.0804 0.3669 -0.12733
|
||||||
|
2027 1 9 61414 0.0799 0.3680 -0.12767
|
||||||
|
2027 1 10 61415 0.0794 0.3691 -0.12816
|
||||||
|
2027 1 11 61416 0.0789 0.3702 -0.12883
|
||||||
|
2027 1 12 61417 0.0785 0.3713 -0.12967
|
||||||
|
2027 1 13 61418 0.0781 0.3724 -0.13064
|
||||||
|
2027 1 14 61419 0.0777 0.3735 -0.13169
|
||||||
|
2027 1 15 61420 0.0773 0.3747 -0.13273
|
||||||
|
2027 1 16 61421 0.0769 0.3758 -0.13369
|
||||||
|
2027 1 17 61422 0.0766 0.3769 -0.13448
|
||||||
|
2027 1 18 61423 0.0762 0.3781 -0.13506
|
||||||
|
2027 1 19 61424 0.0759 0.3793 -0.13544
|
||||||
|
2027 1 20 61425 0.0757 0.3804 -0.13570
|
||||||
|
2027 1 21 61426 0.0754 0.3816 -0.13596
|
||||||
|
2027 1 22 61427 0.0752 0.3827 -0.13639
|
||||||
|
2027 1 23 61428 0.0749 0.3839 -0.13707
|
||||||
|
2027 1 24 61429 0.0747 0.3851 -0.13803
|
||||||
|
2027 1 25 61430 0.0746 0.3863 -0.13935
|
||||||
|
2027 1 26 61431 0.0744 0.3875 -0.14075
|
||||||
|
2027 1 27 61432 0.0743 0.3887 -0.14210
|
||||||
|
2027 1 28 61433 0.0742 0.3899 -0.14327
|
||||||
|
2027 1 29 61434 0.0741 0.3911 -0.14422
|
||||||
|
2027 1 30 61435 0.0740 0.3923 -0.14491
|
||||||
|
2027 1 31 61436 0.0740 0.3935 -0.14540
|
||||||
|
2027 2 1 61437 0.0739 0.3947 -0.14572
|
||||||
|
2027 2 2 61438 0.0739 0.3959 -0.14595
|
||||||
|
2027 2 3 61439 0.0740 0.3971 -0.14614
|
||||||
|
2027 2 4 61440 0.0740 0.3983 -0.14638
|
||||||
|
2027 2 5 61441 0.0741 0.3995 -0.14674
|
||||||
|
2027 2 6 61442 0.0742 0.4007 -0.14726
|
||||||
|
2027 2 7 61443 0.0743 0.4019 -0.14799
|
||||||
|
2027 2 8 61444 0.0744 0.4031 -0.14890
|
||||||
|
2027 2 9 61445 0.0746 0.4043 -0.14998
|
||||||
|
2027 2 10 61446 0.0748 0.4055 -0.15115
|
||||||
|
2027 2 11 61447 0.0750 0.4067 -0.15235
|
||||||
|
2027 2 12 61448 0.0752 0.4079 -0.15347
|
||||||
|
2027 2 13 61449 0.0754 0.4091 -0.15446
|
||||||
|
2027 2 14 61450 0.0757 0.4103 -0.15526
|
||||||
|
2027 2 15 61451 0.0760 0.4115 -0.15586
|
||||||
|
2027 2 16 61452 0.0763 0.4127 -0.15632
|
||||||
|
2027 2 17 61453 0.0767 0.4139 -0.15676
|
||||||
|
2027 2 18 61454 0.0770 0.4151 -0.15731
|
||||||
|
2027 2 19 61455 0.0774 0.4162 -0.15809
|
||||||
|
2027 2 20 61456 0.0778 0.4174 -0.15917
|
||||||
|
2027 2 21 61457 0.0783 0.4186 -0.16054
|
||||||
|
2027 2 22 61458 0.0787 0.4197 -0.16207
|
||||||
|
2027 2 23 61459 0.0792 0.4209 -0.16363
|
||||||
|
2027 2 24 61460 0.0797 0.4221 -0.16506
|
||||||
|
2027 2 25 61461 0.0802 0.4232 -0.16628
|
||||||
|
2027 2 26 61462 0.0808 0.4243 -0.16724
|
||||||
|
2027 2 27 61463 0.0814 0.4255 -0.16796
|
||||||
|
2027 2 28 61464 0.0820 0.4266 -0.16848
|
||||||
|
2027 3 1 61465 0.0826 0.4277 -0.16888
|
||||||
|
2027 3 2 61466 0.0832 0.4288 -0.16923
|
||||||
|
2027 3 3 61467 0.0839 0.4299 -0.16960
|
||||||
|
2027 3 4 61468 0.0845 0.4310 -0.17006
|
||||||
|
2027 3 5 61469 0.0853 0.4321 -0.17068
|
||||||
|
2027 3 6 61470 0.0860 0.4332 -0.17149
|
||||||
|
2027 3 7 61471 0.0867 0.4342 -0.17250
|
||||||
|
2027 3 8 61472 0.0875 0.4353 -0.17368
|
||||||
|
2027 3 9 61473 0.0883 0.4363 -0.17499
|
||||||
|
2027 3 10 61474 0.0891 0.4373 -0.17634
|
||||||
|
2027 3 11 61475 0.0899 0.4384 -0.17764
|
||||||
|
2027 3 12 61476 0.0908 0.4394 -0.17880
|
||||||
|
2027 3 13 61477 0.0917 0.4404 -0.17976
|
||||||
|
2027 3 14 61478 0.0925 0.4414 -0.18051
|
||||||
|
2027 3 15 61479 0.0935 0.4423 -0.18111
|
||||||
|
2027 3 16 61480 0.0944 0.4433 -0.18163
|
||||||
|
2027 3 17 61481 0.0954 0.4442 -0.18221
|
||||||
|
2027 3 18 61482 0.0963 0.4452 -0.18298
|
||||||
|
2027 3 19 61483 0.0973 0.4461 -0.18401
|
||||||
|
2027 3 20 61484 0.0983 0.4470 -0.18533
|
||||||
|
2027 3 21 61485 0.0994 0.4479 -0.18686
|
||||||
|
2027 3 22 61486 0.1004 0.4488 -0.18850
|
||||||
|
2027 3 23 61487 0.1015 0.4496 -0.19010
|
||||||
|
2027 3 24 61488 0.1026 0.4505 -0.19153
|
||||||
|
2027 3 25 61489 0.1037 0.4513 -0.19271
|
||||||
|
2027 3 26 61490 0.1048 0.4521 -0.19364
|
||||||
|
2027 3 27 61491 0.1060 0.4529 -0.19435
|
||||||
|
2027 3 28 61492 0.1071 0.4537 -0.19490
|
||||||
|
2027 3 29 61493 0.1083 0.4545 -0.19538
|
||||||
|
2027 3 30 61494 0.1095 0.4552 -0.19585
|
||||||
|
2027 3 31 61495 0.1107 0.4560 -0.19639
|
||||||
|
2027 4 1 61496 0.1119 0.4567 -0.19707
|
||||||
|
2027 4 2 61497 0.1132 0.4574 -0.19794
|
||||||
|
2027 4 3 61498 0.1144 0.4581 -0.19902
|
||||||
|
2027 4 4 61499 0.1157 0.4587 -0.20031
|
||||||
|
2027 4 5 61500 0.1170 0.4594 -0.20177
|
||||||
|
2027 4 6 61501 0.1183 0.4600 -0.20334
|
||||||
|
2027 4 7 61502 0.1196 0.4606 -0.20493
|
||||||
|
2027 4 8 61503 0.1209 0.4612 -0.20645
|
||||||
|
2027 4 9 61504 0.1223 0.4618 -0.20783
|
||||||
|
2027 4 10 61505 0.1237 0.4623 -0.20906
|
||||||
|
2027 4 11 61506 0.1250 0.4629 -0.21016
|
||||||
|
2027 4 12 61507 0.1264 0.4634 -0.21122
|
||||||
|
2027 4 13 61508 0.1278 0.4639 -0.21237
|
||||||
|
2027 4 14 61509 0.1292 0.4644 -0.21370
|
||||||
|
2027 4 15 61510 0.1306 0.4648 -0.21529
|
||||||
|
2027 4 16 61511 0.1321 0.4652 -0.21712
|
||||||
|
2027 4 17 61512 0.1335 0.4657 -0.21911
|
||||||
|
2027 4 18 61513 0.1350 0.4661 -0.22114
|
||||||
|
2027 4 19 61514 0.1364 0.4664 -0.22304
|
||||||
|
2027 4 20 61515 0.1379 0.4668 -0.22469
|
||||||
|
2027 4 21 61516 0.1394 0.4671 -0.22598
|
||||||
|
2027 4 22 61517 0.1409 0.4674 -0.22690
|
||||||
|
2027 4 23 61518 0.1424 0.4677 -0.22747
|
||||||
|
2027 4 24 61519 0.1439 0.4680 -0.22778
|
||||||
|
2027 4 25 61520 0.1454 0.4682 -0.22790
|
||||||
|
2027 4 26 61521 0.1469 0.4684 -0.22795
|
||||||
|
2027 4 27 61522 0.1485 0.4686 -0.22799
|
||||||
|
2027 4 28 61523 0.1500 0.4688 -0.22810
|
||||||
|
2027 4 29 61524 0.1515 0.4689 -0.22834
|
||||||
|
2027 4 30 61525 0.1531 0.4691 -0.22872
|
||||||
|
2027 5 1 61526 0.1547 0.4692 -0.22926
|
||||||
|
2027 5 2 61527 0.1562 0.4693 -0.22992
|
||||||
|
2027 5 3 61528 0.1578 0.4693 -0.23065
|
||||||
|
2027 5 4 61529 0.1594 0.4694 -0.23137
|
||||||
|
2027 5 5 61530 0.1609 0.4694 -0.23200
|
||||||
|
2027 5 6 61531 0.1625 0.4694 -0.23246
|
||||||
|
2027 5 7 61532 0.1641 0.4693 -0.23268
|
||||||
|
2027 5 8 61533 0.1657 0.4693 -0.23267
|
||||||
|
2027 5 9 61534 0.1672 0.4692 -0.23249
|
||||||
|
2027 5 10 61535 0.1688 0.4691 -0.23225
|
||||||
|
2027 5 11 61536 0.1704 0.4690 -0.23209
|
||||||
|
2027 5 12 61537 0.1720 0.4688 -0.23211
|
||||||
|
2027 5 13 61538 0.1736 0.4687 -0.23238
|
||||||
|
2027 5 14 61539 0.1752 0.4685 -0.23287
|
||||||
|
2027 5 15 61540 0.1768 0.4683 -0.23350
|
||||||
|
2027 5 16 61541 0.1783 0.4680 -0.23417
|
||||||
|
2027 5 17 61542 0.1799 0.4678 -0.23477
|
||||||
|
2027 5 18 61543 0.1815 0.4675 -0.23522
|
||||||
|
2027 5 19 61544 0.1831 0.4672 -0.23549
|
||||||
|
2027 5 20 61545 0.1847 0.4668 -0.23553
|
||||||
|
2027 5 21 61546 0.1862 0.4665 -0.23532
|
||||||
|
2027 5 22 61547 0.1878 0.4661 -0.23490
|
||||||
|
2027 5 23 61548 0.1894 0.4657 -0.23447
|
||||||
|
2027 5 24 61549 0.1909 0.4653 -0.23402
|
||||||
|
2027 5 25 61550 0.1925 0.4648 -0.23356
|
||||||
|
2027 5 26 61551 0.1940 0.4643 -0.23305
|
||||||
|
2027 5 27 61552 0.1956 0.4638 -0.23271
|
||||||
|
2027 5 28 61553 0.1971 0.4633 -0.23256
|
||||||
|
2027 5 29 61554 0.1986 0.4628 -0.23252
|
||||||
|
2027 5 30 61555 0.2002 0.4622 -0.23259
|
||||||
|
2027 5 31 61556 0.2017 0.4616 -0.23260
|
||||||
|
2027 6 1 61557 0.2032 0.4610 -0.23253
|
||||||
|
2027 6 2 61558 0.2047 0.4604 -0.23231
|
||||||
|
2027 6 3 61559 0.2062 0.4597 -0.23185
|
||||||
|
2027 6 4 61560 0.2076 0.4591 -0.23119
|
||||||
|
2027 6 5 61561 0.2091 0.4584 -0.23032
|
||||||
|
2027 6 6 61562 0.2106 0.4576 -0.22943
|
||||||
|
2027 6 7 61563 0.2120 0.4569 -0.22870
|
||||||
|
2027 6 8 61564 0.2135 0.4561 -0.22819
|
||||||
|
2027 6 9 61565 0.2149 0.4553 -0.22786
|
||||||
|
2027 6 10 61566 0.2163 0.4545 -0.22767
|
||||||
|
2027 6 11 61567 0.2177 0.4537 -0.22763
|
||||||
|
2027 6 12 61568 0.2191 0.4529 -0.22757
|
||||||
|
2027 6 13 61569 0.2205 0.4520 -0.22745
|
||||||
|
2027 6 14 61570 0.2218 0.4511 -0.22711
|
||||||
|
2027 6 15 61571 0.2232 0.4502 -0.22646
|
||||||
|
2027 6 16 61572 0.2245 0.4493 -0.22558
|
||||||
|
2027 6 17 61573 0.2258 0.4483 -0.22449
|
||||||
|
2027 6 18 61574 0.2271 0.4473 -0.22329
|
||||||
|
2027 6 19 61575 0.2284 0.4464 -0.22201
|
||||||
|
2027 6 20 61576 0.2297 0.4453 -0.22078
|
||||||
|
2027 6 21 61577 0.2309 0.4443 -0.21958
|
||||||
|
2027 6 22 61578 0.2321 0.4433 -0.21855
|
||||||
|
2027 6 23 61579 0.2334 0.4422 -0.21767
|
||||||
|
2027 6 24 61580 0.2346 0.4411 -0.21699
|
||||||
|
2027 6 25 61581 0.2357 0.4400 -0.21648
|
||||||
|
2027 6 26 61582 0.2369 0.4389 -0.21610
|
||||||
|
2027 6 27 61583 0.2380 0.4378 -0.21582
|
||||||
|
2027 6 28 61584 0.2392 0.4366 -0.21555
|
||||||
|
2027 6 29 61585 0.2403 0.4354 -0.21520
|
||||||
|
2027 6 30 61586 0.2413 0.4342 -0.21476
|
||||||
|
2027 7 1 61587 0.2424 0.4330 -0.21407
|
||||||
|
2027 7 2 61588 0.2435 0.4318 -0.21326
|
||||||
|
2027 7 3 61589 0.2445 0.4306 -0.21229
|
||||||
|
2027 7 4 61590 0.2455 0.4293 -0.21142
|
||||||
|
2027 7 5 61591 0.2465 0.4281 -0.21066
|
||||||
|
2027 7 6 61592 0.2474 0.4268 -0.21015
|
||||||
|
2027 7 7 61593 0.2483 0.4255 -0.20989
|
||||||
|
2027 7 8 61594 0.2493 0.4242 -0.20984
|
||||||
|
2027 7 9 61595 0.2501 0.4228 -0.20994
|
||||||
|
2027 7 10 61596 0.2510 0.4215 -0.20988
|
||||||
|
2027 7 11 61597 0.2519 0.4202 -0.20959
|
||||||
|
2027 7 12 61598 0.2527 0.4188 -0.20900
|
||||||
|
2027 7 13 61599 0.2535 0.4174 -0.20815
|
||||||
|
2027 7 14 61600 0.2542 0.4160 -0.20703
|
||||||
|
2027 7 15 61601 0.2550 0.4146 -0.20571
|
||||||
|
2027 7 16 61602 0.2557 0.4132 -0.20432
|
||||||
|
2027 7 17 61603 0.2564 0.4118 -0.20294
|
||||||
|
2027 7 18 61604 0.2571 0.4103 -0.20162
|
||||||
|
2027 7 19 61605 0.2577 0.4089 -0.20047
|
||||||
|
2027 7 20 61606 0.2583 0.4074 -0.19943
|
||||||
|
2027 7 21 61607 0.2589 0.4060 -0.19858
|
||||||
|
2027 7 22 61608 0.2595 0.4045 -0.19794
|
||||||
|
2027 7 23 61609 0.2600 0.4030 -0.19744
|
||||||
|
2027 7 24 61610 0.2605 0.4015 -0.19706
|
||||||
|
2027 7 25 61611 0.2610 0.4000 -0.19671
|
||||||
|
2027 7 26 61612 0.2615 0.3985 -0.19636
|
||||||
|
2027 7 27 61613 0.2619 0.3970 -0.19587
|
||||||
|
2027 7 28 61614 0.2623 0.3955 -0.19523
|
||||||
|
2027 7 29 61615 0.2627 0.3940 -0.19436
|
||||||
|
2027 7 30 61616 0.2631 0.3924 -0.19338
|
||||||
|
2027 7 31 61617 0.2634 0.3909 -0.19242
|
||||||
|
2027 8 1 61618 0.2637 0.3893 -0.19156
|
||||||
|
2027 8 2 61619 0.2639 0.3878 -0.19089
|
||||||
|
2027 8 3 61620 0.2642 0.3862 -0.19047
|
||||||
|
2027 8 4 61621 0.2644 0.3847 -0.19032
|
||||||
|
2027 8 5 61622 0.2646 0.3831 -0.19038
|
||||||
|
2027 8 6 61623 0.2647 0.3816 -0.19045
|
||||||
|
2027 8 7 61624 0.2648 0.3800 -0.19036
|
||||||
|
2027 8 8 61625 0.2649 0.3784 -0.19005
|
||||||
|
2027 8 9 61626 0.2650 0.3768 -0.18939
|
||||||
|
2027 8 10 61627 0.2650 0.3753 -0.18850
|
||||||
|
2027 8 11 61628 0.2650 0.3737 -0.18736
|
||||||
|
2027 8 12 61629 0.2650 0.3721 -0.18613
|
||||||
|
2027 8 13 61630 0.2649 0.3706 -0.18490
|
||||||
|
2027 8 14 61631 0.2649 0.3690 -0.18367
|
||||||
|
2027 8 15 61632 0.2647 0.3674 -0.18263
|
||||||
|
2027 8 16 61633 0.2646 0.3658 -0.18175
|
||||||
|
2027 8 17 61634 0.2644 0.3643 -0.18101
|
||||||
|
2027 8 18 61635 0.2642 0.3627 -0.18047
|
||||||
|
2027 8 19 61636 0.2640 0.3611 -0.18006
|
||||||
|
2027 8 20 61637 0.2638 0.3596 -0.17971
|
||||||
|
2027 8 21 61638 0.2635 0.3580 -0.17944
|
||||||
|
2027 8 22 61639 0.2631 0.3565 -0.17920
|
||||||
|
2027 8 23 61640 0.2628 0.3549 -0.17893
|
||||||
|
2027 8 24 61641 0.2624 0.3534 -0.17850
|
||||||
|
2027 8 25 61642 0.2620 0.3518 -0.17787
|
||||||
|
2027 8 26 61643 0.2616 0.3503 -0.17711
|
||||||
|
2027 8 27 61644 0.2611 0.3488 -0.17636
|
||||||
|
2027 8 28 61645 0.2606 0.3472 -0.17574
|
||||||
|
2027 8 29 61646 0.2601 0.3457 -0.17539
|
||||||
|
2027 8 30 61647 0.2596 0.3442 -0.17532
|
||||||
|
2027 8 31 61648 0.2590 0.3427 -0.17563
|
||||||
|
2027 9 1 61649 0.2584 0.3412 -0.17620
|
||||||
|
2027 9 2 61650 0.2577 0.3398 -0.17690
|
||||||
|
2027 9 3 61651 0.2571 0.3383 -0.17757
|
||||||
|
2027 9 4 61652 0.2564 0.3368 -0.17804
|
||||||
|
2027 9 5 61653 0.2557 0.3354 -0.17821
|
||||||
|
2027 9 6 61654 0.2549 0.3339 -0.17804
|
||||||
|
2027 9 7 61655 0.2541 0.3325 -0.17762
|
||||||
|
2027 9 8 61656 0.2533 0.3311 -0.17702
|
||||||
|
2027 9 9 61657 0.2525 0.3297 -0.17639
|
||||||
|
2027 9 10 61658 0.2516 0.3283 -0.17578
|
||||||
|
2027 9 11 61659 0.2508 0.3269 -0.17523
|
||||||
|
2027 9 12 61660 0.2498 0.3255 -0.17482
|
||||||
|
2027 9 13 61661 0.2489 0.3242 -0.17451
|
||||||
|
2027 9 14 61662 0.2479 0.3228 -0.17443
|
||||||
|
2027 9 15 61663 0.2470 0.3215 -0.17454
|
||||||
|
2027 9 16 61664 0.2459 0.3202 -0.17483
|
||||||
|
2027 9 17 61665 0.2449 0.3189 -0.17520
|
||||||
|
2027 9 18 61666 0.2438 0.3176 -0.17547
|
||||||
|
2027 9 19 61667 0.2427 0.3163 -0.17563
|
||||||
|
2027 9 20 61668 0.2416 0.3151 -0.17573
|
||||||
|
2027 9 21 61669 0.2405 0.3138 -0.17562
|
||||||
|
2027 9 22 61670 0.2393 0.3126 -0.17534
|
||||||
|
2027 9 23 61671 0.2381 0.3114 -0.17497
|
||||||
|
2027 9 24 61672 0.2369 0.3102 -0.17466
|
||||||
|
2027 9 25 61673 0.2356 0.3091 -0.17446
|
||||||
|
2027 9 26 61674 0.2344 0.3079 -0.17452
|
||||||
|
2027 9 27 61675 0.2331 0.3068 -0.17491
|
||||||
|
2027 9 28 61676 0.2318 0.3057 -0.17557
|
||||||
|
2027 9 29 61677 0.2305 0.3046 -0.17637
|
||||||
|
2027 9 30 61678 0.2291 0.3035 -0.17727
|
||||||
|
2027 10 1 61679 0.2277 0.3025 -0.17809
|
||||||
|
2027 10 2 61680 0.2263 0.3015 -0.17865
|
||||||
|
2027 10 3 61681 0.2249 0.3005 -0.17894
|
||||||
|
2027 10 4 61682 0.2235 0.2995 -0.17892
|
||||||
|
2027 10 5 61683 0.2220 0.2985 -0.17866
|
||||||
|
2027 10 6 61684 0.2205 0.2976 -0.17834
|
||||||
|
2027 10 7 61685 0.2190 0.2966 -0.17806
|
||||||
|
2027 10 8 61686 0.2175 0.2957 -0.17778
|
||||||
|
These predictions are based on all announced leap seconds.
|
||||||
|
|
||||||
|
CELESTIAL POLE OFFSET SERIES:
|
||||||
|
NEOS Celestial Pole Offset Series
|
||||||
|
MJD dpsi error deps error
|
||||||
|
(msec. of arc)
|
||||||
|
61292 -123.28 1.24 -11.48 0.12
|
||||||
|
61293 -123.30 1.24 -11.30 0.12
|
||||||
|
61294 -123.26 1.24 -11.15 0.12
|
||||||
|
61295 -123.29 0.32 -11.07 0.16
|
||||||
|
61296 -123.59 0.32 -11.08 0.16
|
||||||
|
61297 -124.16 0.32 -11.18 0.16
|
||||||
|
61298 -124.72 0.32 -11.31 0.16
|
||||||
|
61299 -124.96 0.32 -11.38 0.16
|
||||||
|
61300 -124.76 0.32 -11.31 0.16
|
||||||
|
61301 -124.26 0.32 -11.17 0.16
|
||||||
|
61302 -123.69 0.32 -11.09 0.16
|
||||||
|
61303 -123.26 1.03 -11.12 0.11
|
||||||
|
61304 -123.06 1.03 -11.23 0.11
|
||||||
|
61305 -123.09 1.03 -11.27 0.11
|
||||||
|
|
||||||
|
IAU2000A Celestial Pole Offset Series
|
||||||
|
MJD dX error dY error
|
||||||
|
(msec. of arc)
|
||||||
|
61292 0.457 0.492 -0.206 0.116
|
||||||
|
61293 0.457 0.492 -0.198 0.116
|
||||||
|
61294 0.456 0.492 -0.190 0.116
|
||||||
|
61295 0.455 0.128 -0.182 0.160
|
||||||
|
61296 0.453 0.128 -0.175 0.160
|
||||||
|
61297 0.450 0.128 -0.167 0.160
|
||||||
|
61298 0.447 0.128 -0.160 0.160
|
||||||
|
61299 0.443 0.128 -0.152 0.160
|
||||||
|
61300 0.438 0.128 -0.145 0.160
|
||||||
|
61301 0.434 0.128 -0.138 0.160
|
||||||
|
61302 0.429 0.128 -0.131 0.160
|
||||||
|
61303 0.424 0.409 -0.124 0.113
|
||||||
|
61304 0.419 0.409 -0.117 0.113
|
||||||
|
61305 0.414 0.409 -0.109 0.113
|
||||||
|
|
||||||
|
)--";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace mcc::ccte::iers::defaults
|
||||||
|
|
||||||
@@ -58,10 +58,23 @@ concept mcc_error_c = std::default_initializable<T> && (std::convertible_to<T, b
|
|||||||
|
|
||||||
|
|
||||||
template <mcc_error_c ErrT, mcc_error_c DefErrT>
|
template <mcc_error_c ErrT, mcc_error_c DefErrT>
|
||||||
DefErrT mcc_deduced_err(ErrT const& err, DefErrT const& default_err)
|
auto mcc_deduced_err(ErrT const& err, DefErrT const& default_err)
|
||||||
|
// DefErrT mcc_deduced_err(ErrT const& err, DefErrT const& default_err)
|
||||||
{
|
{
|
||||||
if constexpr (std::same_as<ErrT, DefErrT>) {
|
if constexpr (std::same_as<ErrT, DefErrT>) {
|
||||||
return err;
|
return err;
|
||||||
|
} else if constexpr (std::is_error_code_enum_v<DefErrT>) {
|
||||||
|
if constexpr (std::same_as<ErrT, std::error_code>) {
|
||||||
|
return err;
|
||||||
|
} else {
|
||||||
|
return default_err;
|
||||||
|
}
|
||||||
|
} else if constexpr (std::is_error_condition_enum_v<DefErrT>) {
|
||||||
|
if constexpr (std::same_as<ErrT, std::error_condition>) {
|
||||||
|
return err;
|
||||||
|
} else {
|
||||||
|
return default_err;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return default_err;
|
return default_err;
|
||||||
}
|
}
|
||||||
@@ -147,6 +160,11 @@ concept mcc_fp_type_like_c =
|
|||||||
|
|
||||||
/* GEOMETRICAL ANGLE REPRESENTATION CLASS CONCEPT */
|
/* GEOMETRICAL ANGLE REPRESENTATION CLASS CONCEPT */
|
||||||
|
|
||||||
|
/* REQUIREMENT: in the MCC-library it is assumed that an arithmetic representation of angles are measured in the
|
||||||
|
radians!!! This means that possible conversion operator 'SOME_USER_ANGLE_CLASS::operator double()'
|
||||||
|
must return an angle in radians!
|
||||||
|
*/
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_angle_c = mcc_fp_type_like_c<T> && requires(T v, double vd) {
|
concept mcc_angle_c = mcc_fp_type_like_c<T> && requires(T v, double vd) {
|
||||||
// mandatory arithmetic operations
|
// mandatory arithmetic operations
|
||||||
@@ -468,11 +486,11 @@ struct mcc_skypoint_interface_t {
|
|||||||
return std::forward<SelfT>(self).refractInverseCorrection(dZ);
|
return std::forward<SelfT>(self).refractInverseCorrection(dZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns apparent sideral time (Greenwich) for the epoch of the celestial point
|
// returns apparent sideral time (Greenwich or local) for the epoch of the celestial point
|
||||||
template <std::derived_from<mcc_skypoint_interface_t> SelfT>
|
template <std::derived_from<mcc_skypoint_interface_t> SelfT>
|
||||||
auto appSideralTime(this SelfT&& self, mcc_angle_c auto* st)
|
auto appSideralTime(this SelfT&& self, mcc_angle_c auto* st, bool is_local)
|
||||||
{
|
{
|
||||||
return std::forward<SelfT>(self).appSideralTime(st);
|
return std::forward<SelfT>(self).appSideralTime(st, is_local);
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns equation of origins for the epoch of the celestial point
|
// returns equation of origins for the epoch of the celestial point
|
||||||
@@ -481,15 +499,55 @@ struct mcc_skypoint_interface_t {
|
|||||||
{
|
{
|
||||||
return std::forward<SelfT>(self).EO(eo);
|
return std::forward<SelfT>(self).EO(eo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <std::derived_from<mcc_skypoint_interface_t> SelfT>
|
||||||
|
// typename std::remove_cvref_t<SelfT>::dist_result_t distance(this SelfT&& self, auto const& sp)
|
||||||
|
// {
|
||||||
|
// return std::forward<SelfT>(self).distance(sp);
|
||||||
|
// }
|
||||||
|
// template <std::derived_from<mcc_skypoint_interface_t> SelfT>
|
||||||
|
// SelfT& operator+=(this SelfT& self, mcc_coord_pair_c auto const& dxy)
|
||||||
|
// {
|
||||||
|
// return self.operator+=(dxy);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// template <std::derived_from<mcc_skypoint_interface_t> SelfT>
|
||||||
|
// SelfT& operator-=(this SelfT& self, mcc_coord_pair_c auto const& dxy)
|
||||||
|
// {
|
||||||
|
// return self.operator-=(dxy);
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_skypoint_c = std::derived_from<T, mcc_skypoint_interface_t> && requires(const T t_const) {
|
concept mcc_skypoint_c =
|
||||||
{ t_const.epoch() } -> mcc_coord_epoch_c;
|
std::derived_from<T, mcc_skypoint_interface_t> && requires(const T t_const, const T t_other_const, T t) {
|
||||||
|
{ t_const.epoch() } -> mcc_coord_epoch_c;
|
||||||
|
|
||||||
// currently stored coordinates pair
|
// currently stored coordinates pair kind
|
||||||
{ t_const.pairKind() } -> std::same_as<impl::MccCoordPairKind>;
|
{ t_const.pairKind() } -> std::same_as<impl::MccCoordPairKind>;
|
||||||
};
|
|
||||||
|
// currently stored co-longitude coordinate
|
||||||
|
{ t_const.co_lon() } -> std::convertible_to<double>;
|
||||||
|
|
||||||
|
// currently stored co-latitude coordinate
|
||||||
|
{ t_const.co_lat() } -> std::convertible_to<double>;
|
||||||
|
|
||||||
|
requires requires(typename T::dist_result_t res) {
|
||||||
|
requires mcc_angle_c<decltype(res.dist)>; // distance on sphere
|
||||||
|
requires mcc_angle_c<decltype(res.dx)>; // difference along co-longitude coordinate
|
||||||
|
requires mcc_angle_c<decltype(res.dy)>; // difference along co-latitude coordinate
|
||||||
|
requires mcc_angle_c<decltype(res.x2)>; // co-longitude coordinates of target sky point (in the same
|
||||||
|
// coordinate system as 'this')
|
||||||
|
requires mcc_angle_c<decltype(res.y2)>; // co-latitude coordinates of target sky point (in the same
|
||||||
|
// coordinate system as 'this')
|
||||||
|
};
|
||||||
|
|
||||||
|
// distance on sphere between two sky points
|
||||||
|
{ t_const.distance(std::declval<const T&>()) } -> std::same_as<typename T::dist_result_t>;
|
||||||
|
|
||||||
|
// { t_const - t_other_const } -> mcc_coord_pair_c;
|
||||||
|
// { t_const + t_other_const } -> mcc_coord_pair_c;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -536,9 +594,11 @@ concept mcc_pcm_c = std::derived_from<T, mcc_pcm_interface_t<typename T::error_t
|
|||||||
requires mcc_error_c<typename T::error_t>;
|
requires mcc_error_c<typename T::error_t>;
|
||||||
|
|
||||||
// the 'T' class must contain static constexpr member of 'MccMountType' type
|
// the 'T' class must contain static constexpr member of 'MccMountType' type
|
||||||
requires std::same_as<decltype(T::mountType), const MccMountType>;
|
requires std::same_as<decltype(T::pcmMountType), const MccMountType>;
|
||||||
|
// requires std::same_as<decltype(T::mountType), const MccMountType>;
|
||||||
[]() {
|
[]() {
|
||||||
[[maybe_unused]] static constexpr MccMountType val = T::mountType;
|
// [[maybe_unused]] static constexpr MccMountType val = T::mountType;
|
||||||
|
[[maybe_unused]] static constexpr MccMountType val = T::pcmMountType;
|
||||||
}(); // to ensure 'mountType' can be used in compile-time context
|
}(); // to ensure 'mountType' can be used in compile-time context
|
||||||
|
|
||||||
// static const variable with name of PCM
|
// static const variable with name of PCM
|
||||||
@@ -566,7 +626,7 @@ concept mcc_pcm_c = std::derived_from<T, mcc_pcm_interface_t<typename T::error_t
|
|||||||
// static constexpr uint16_t HW_MOVE_ERROR = 555;
|
// static constexpr uint16_t HW_MOVE_ERROR = 555;
|
||||||
// }
|
// }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_hardware_movement_state_c = requires {
|
concept mcc_hardware_movement_state_c = std::formattable<T, char> && requires {
|
||||||
[]() {
|
[]() {
|
||||||
// // mount axes were stopped
|
// // mount axes were stopped
|
||||||
// [[maybe_unused]] static constexpr auto v0 = T::HW_MOVE_STOPPED;
|
// [[maybe_unused]] static constexpr auto v0 = T::HW_MOVE_STOPPED;
|
||||||
@@ -616,7 +676,6 @@ concept mcc_hardware_movement_state_c = requires {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_hardware_state_c = requires(T state) {
|
concept mcc_hardware_state_c = requires(T state) {
|
||||||
// encoder co-longitude and co-latiitude positions, as well as its measurement time point
|
// encoder co-longitude and co-latiitude positions, as well as its measurement time point
|
||||||
// the given constrains on coordinate pair kind can be used to deduce mount type
|
|
||||||
requires mcc_coord_pair_c<decltype(state.XY)> &&
|
requires mcc_coord_pair_c<decltype(state.XY)> &&
|
||||||
(decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_GENERIC ||
|
(decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_GENERIC ||
|
||||||
decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_XY);
|
decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_XY);
|
||||||
@@ -639,75 +698,20 @@ concept mcc_hardware_c = requires(T t) {
|
|||||||
// static const variable with name of hardware
|
// static const variable with name of hardware
|
||||||
requires std::formattable<decltype(T::hardwareName), char> && std::is_const_v<decltype(T::hardwareName)>;
|
requires std::formattable<decltype(T::hardwareName), char> && std::is_const_v<decltype(T::hardwareName)>;
|
||||||
|
|
||||||
// a type that defines at least HW_MOVE_ERROR, HW_MOVE_STOPPING, HW_MOVE_STOPPED, HW_MOVE_SLEWING,
|
|
||||||
// HW_MOVE_ADJUSTING, HW_MOVE_TRACKING and HW_MOVE_GUIDING compile-time constants. The main purpose of this type is
|
// the 'T' class must contain static constexpr member of 'MccMountType' type
|
||||||
// a possible tunning of hardware hardwareSetState-related commands and detect the stop and error states from
|
requires std::same_as<decltype(T::hwMountType), const MccMountType>;
|
||||||
// hardware
|
[]() {
|
||||||
//
|
[[maybe_unused]] static constexpr MccMountType val = T::hwMountType;
|
||||||
// e.g. an implementations can be as follows:
|
}(); // to ensure 'mountType' can be used in compile-time context
|
||||||
// enum class hardware_movement_state_t: int {HW_MOVE_ERROR = -1, HW_MOVE_STOPPED = 0, HW_MOVE_STOPPING,
|
|
||||||
// HW_MOVE_SLEWING, HW_MOVE_ADJUSTING, HW_MOVE_TRACKING, HW_MOVE_GUIDING}
|
|
||||||
//
|
|
||||||
// struct hardware_movement_state_t {
|
|
||||||
// static constexpr uint16_t HW_MOVE_STOPPED = 0;
|
|
||||||
// static constexpr uint16_t HW_MOVE_SLEWING = 111;
|
|
||||||
// static constexpr uint16_t HW_MOVE_ADJUSTING = 222;
|
|
||||||
// static constexpr uint16_t HW_MOVE_TRACKING = 333;
|
|
||||||
// static constexpr uint16_t HW_MOVE_GUIDING = 444;
|
|
||||||
// static constexpr uint16_t HW_MOVE_ERROR = 555;
|
|
||||||
// static constexpr uint16_t HW_MOVE_STOPPING = 666;
|
|
||||||
// }
|
|
||||||
|
|
||||||
requires mcc_hardware_movement_state_c<typename T::hardware_movement_state_t>;
|
requires mcc_hardware_movement_state_c<typename T::hardware_movement_state_t>;
|
||||||
|
|
||||||
// requires requires(typename T::hardware_movement_state_t type) {
|
|
||||||
// []() {
|
|
||||||
// // mount axes were stopped
|
|
||||||
// static constexpr auto v0 = T::hardware_movement_state_t::HW_MOVE_STOPPED;
|
|
||||||
|
|
||||||
// // hardware was asked for slewing (move to given celestial point)
|
|
||||||
// static constexpr auto v1 = T::hardware_movement_state_t::HW_MOVE_SLEWING;
|
|
||||||
|
|
||||||
// // hardware was asked for adjusting after slewing
|
|
||||||
// // (adjusting actual mount position to align with target celestial point at the end of slewing process)
|
|
||||||
// static constexpr auto v2 = T::hardware_movement_state_t::HW_MOVE_ADJUSTING;
|
|
||||||
|
|
||||||
// // hardware was asked for tracking (track target celestial point)
|
|
||||||
// static constexpr auto v3 = T::hardware_movement_state_t::HW_MOVE_TRACKING;
|
|
||||||
|
|
||||||
// // hardware was asked for guiding
|
|
||||||
// // (small corrections to align actual mount position with target celestial point)
|
|
||||||
// static constexpr auto v4 = T::hardware_movement_state_t::HW_MOVE_GUIDING;
|
|
||||||
|
|
||||||
// // to detect possible hardware error
|
|
||||||
// static constexpr auto v5 = T::hardware_movement_state_t::HW_MOVE_ERROR;
|
|
||||||
// }();
|
|
||||||
// };
|
|
||||||
|
|
||||||
requires mcc_hardware_state_c<typename T::hardware_state_t> && requires(typename T::hardware_state_t state) {
|
requires mcc_hardware_state_c<typename T::hardware_state_t> && requires(typename T::hardware_state_t state) {
|
||||||
requires std::same_as<decltype(state.movementState), typename T::hardware_movement_state_t>;
|
requires std::same_as<decltype(state.movementState), typename T::hardware_movement_state_t>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// requires requires(typename T::hardware_state_t state) {
|
|
||||||
// // encoder co-longitude and co-latiitude positions, as well as its measurement time point
|
|
||||||
// // the given constrains on coordinate pair kind can be used to deduce mount type
|
|
||||||
// requires mcc_coord_pair_c<decltype(state.XY)> &&
|
|
||||||
// ( // for equathorial mount:
|
|
||||||
// decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_HADEC_OBS ||
|
|
||||||
// // for alt-azimuthal mount:
|
|
||||||
// decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_AZALT ||
|
|
||||||
// decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_AZZD);
|
|
||||||
|
|
||||||
// // co-longitude and co-latiitude axis angular speeds, as well as its measurement/computation time point
|
|
||||||
// requires mcc_coord_pair_c<decltype(state.speedXY)> &&
|
|
||||||
// (decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_GENERIC ||
|
|
||||||
// decltype(state.XY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_XY);
|
|
||||||
|
|
||||||
|
|
||||||
// requires std::same_as<typename T::hardware_movement_state_t, decltype(state.movementState)>;
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
// set hardware state:
|
// set hardware state:
|
||||||
{ t.hardwareSetState(std::declval<typename T::hardware_state_t const&>()) } -> std::same_as<typename T::error_t>;
|
{ t.hardwareSetState(std::declval<typename T::hardware_state_t const&>()) } -> std::same_as<typename T::error_t>;
|
||||||
|
|
||||||
@@ -716,6 +720,8 @@ concept mcc_hardware_c = requires(T t) {
|
|||||||
|
|
||||||
// { t.hardwareStop() } -> std::same_as<typename T::error_t>; // stop any moving
|
// { t.hardwareStop() } -> std::same_as<typename T::error_t>; // stop any moving
|
||||||
{ t.hardwareInit() } -> std::same_as<typename T::error_t>; // initialize hardware
|
{ t.hardwareInit() } -> std::same_as<typename T::error_t>; // initialize hardware
|
||||||
|
|
||||||
|
{ t.hardwareShutdown() } -> std::same_as<typename T::error_t>; // shutdown hardware
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -726,6 +732,14 @@ concept mcc_telemetry_data_c = requires(T t) {
|
|||||||
// target celestial point (position on sky where mount must be slewed)
|
// target celestial point (position on sky where mount must be slewed)
|
||||||
requires mcc_skypoint_c<decltype(t.targetPos)>;
|
requires mcc_skypoint_c<decltype(t.targetPos)>;
|
||||||
|
|
||||||
|
// computed target encoder coordinates
|
||||||
|
requires(mcc_coord_pair_c<decltype(t.targetXY)> &&
|
||||||
|
(decltype(t.targetXY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_GENERIC ||
|
||||||
|
decltype(t.targetXY)::pairKind == impl::MccCoordPairKind::COORDS_KIND_XY));
|
||||||
|
|
||||||
|
// corrections to transform observed celestial coordinates of target to hardware encoder ones
|
||||||
|
requires mcc_pcm_result_c<decltype(t.pcmReverseCorrection)>;
|
||||||
|
|
||||||
// mount current celestial position
|
// mount current celestial position
|
||||||
requires mcc_skypoint_c<decltype(t.mountPos)>;
|
requires mcc_skypoint_c<decltype(t.mountPos)>;
|
||||||
|
|
||||||
@@ -779,23 +793,33 @@ struct mcc_telemetry_interface_t {
|
|||||||
|
|
||||||
// set target position
|
// set target position
|
||||||
template <std::derived_from<mcc_telemetry_interface_t> SelfT>
|
template <std::derived_from<mcc_telemetry_interface_t> SelfT>
|
||||||
RetT setTarget(this SelfT&& self, mcc_skypoint_c auto const& pt)
|
RetT setPointingTarget(this SelfT&& self, mcc_skypoint_c auto const& pt)
|
||||||
{
|
{
|
||||||
return std::forward<SelfT>(self).setTarget(pt);
|
return std::forward<SelfT>(self).setTarget(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get entered target position
|
||||||
|
template <std::derived_from<mcc_telemetry_interface_t> SelfT>
|
||||||
|
RetT getPointingTarget(this SelfT&& self, mcc_skypoint_c auto* pt)
|
||||||
|
{
|
||||||
|
return std::forward<SelfT>(self).getTarget(pt);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_telemetry_c = std::derived_from<T, mcc_telemetry_interface_t<typename T::error_t>> && requires(T t) {
|
concept mcc_telemetry_c =
|
||||||
// error type
|
std::derived_from<T, mcc_telemetry_interface_t<typename T::error_t>> && requires(T t, const T t_const) {
|
||||||
requires mcc_error_c<typename T::error_t>;
|
// error type
|
||||||
|
requires mcc_error_c<typename T::error_t>;
|
||||||
|
|
||||||
// telemetry data type definition
|
// telemetry data type definition
|
||||||
requires mcc_telemetry_data_c<typename T::telemetry_data_t>;
|
requires mcc_telemetry_data_c<typename T::telemetry_data_t>;
|
||||||
|
|
||||||
// get telemetry data
|
// get telemetry data
|
||||||
{ t.telemetryData(std::declval<typename T::telemetry_data_t*>()) } -> std::same_as<typename T::error_t>;
|
{ t.telemetryData(std::declval<typename T::telemetry_data_t*>()) } -> std::same_as<typename T::error_t>;
|
||||||
};
|
|
||||||
|
{ t_const.getPointingTarget() } -> mcc_skypoint_c;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -903,10 +927,15 @@ struct mcc_pzone_container_interface_t {
|
|||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_pzone_container_c = std::derived_from<T, mcc_pzone_container_interface_t<typename T::error_t>> && requires {
|
concept mcc_pzone_container_c =
|
||||||
// error type
|
std::derived_from<T, mcc_pzone_container_interface_t<typename T::error_t>> && requires(const T t_const) {
|
||||||
requires mcc_error_c<typename T::error_t>;
|
// error type
|
||||||
};
|
requires mcc_error_c<typename T::error_t>;
|
||||||
|
|
||||||
|
[]<std::ranges::range R>(R const&) {
|
||||||
|
return requires { requires std::formattable<std::ranges::range_value_t<R>, char>; };
|
||||||
|
}(t_const.pzoneNames());
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -944,27 +973,28 @@ concept mcc_movement_controls_c = requires(T t) {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_mount_status_c = requires {
|
concept mcc_mount_status_c = requires {
|
||||||
[]() {
|
[]() {
|
||||||
[[maybe_unused]] static constexpr std::array arr = {
|
[[maybe_unused]]
|
||||||
T::MOUNT_STATUS_ERROR, T::MOUNT_STATUS_IDLE, T::MOUNT_STATUS_INITIALIZATION,
|
static constexpr std::array arr = {T::MOUNT_STATUS_ERROR, T::MOUNT_STATUS_IDLE,
|
||||||
T::MOUNT_STATUS_ERROR, T::MOUNT_STATUS_STOPPED, T::MOUNT_STATUS_SLEWING,
|
T::MOUNT_STATUS_INITIALIZATION, T::MOUNT_STATUS_STOPPED,
|
||||||
T::MOUNT_STATUS_ADJUSTING, T::MOUNT_STATUS_GUIDING, T::MOUNT_STATUS_TRACKING};
|
T::MOUNT_STATUS_SLEWING, T::MOUNT_STATUS_ADJUSTING,
|
||||||
|
T::MOUNT_STATUS_GUIDING, T::MOUNT_STATUS_TRACKING};
|
||||||
}; // to ensure mount status is compile-time constants
|
}; // to ensure mount status is compile-time constants
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept mcc_generic_mount_c =
|
concept mcc_generic_mount_c = mcc_logger_c<T> && mcc_pzone_container_c<T> && mcc_telemetry_c<T> &&
|
||||||
mcc_logger_c<T> && mcc_pzone_container_c<T> && mcc_telemetry_c<T> && mcc_movement_controls_c<T> && requires(T t) {
|
mcc_movement_controls_c<T> && requires(T t, const T t_const) {
|
||||||
// error type
|
// error type
|
||||||
requires mcc_error_c<typename T::error_t>;
|
requires mcc_error_c<typename T::error_t>;
|
||||||
|
|
||||||
requires mcc_mount_status_c<typename T::mount_status_t>;
|
requires mcc_mount_status_c<typename T::mount_status_t>;
|
||||||
|
|
||||||
{ t.initMount() } -> std::same_as<typename T::error_t>;
|
{ t.initMount() } -> std::same_as<typename T::error_t>;
|
||||||
|
|
||||||
{ t.mountStatus() } -> std::same_as<typename T::mount_status_t>;
|
{ t_const.mountStatus() } -> std::same_as<typename T::mount_status_t>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace mcc
|
} // namespace mcc
|
||||||
@@ -18,11 +18,20 @@
|
|||||||
namespace mcc
|
namespace mcc
|
||||||
{
|
{
|
||||||
|
|
||||||
constexpr double MCC_HALF_PI = std::numbers::pi / 2.0;
|
static constexpr double MCC_DEGRESS_TO_RADS = std::numbers::pi / 180.0;
|
||||||
constexpr double MCC_TWO_PI = std::numbers::pi * 2.0;
|
static constexpr double MCC_ARCMINS_TO_RADS = MCC_DEGRESS_TO_RADS / 60.0;
|
||||||
|
static constexpr double MCC_ARCSECS_TO_RADS = MCC_DEGRESS_TO_RADS / 3600.0;
|
||||||
|
|
||||||
|
static constexpr double MCC_RADS_TO_DEGRESS = 1.0 / MCC_DEGRESS_TO_RADS;
|
||||||
|
|
||||||
|
static constexpr double MCC_HALF_PI = std::numbers::pi / 2.0;
|
||||||
|
static constexpr double MCC_TWO_PI = std::numbers::pi * 2.0;
|
||||||
|
|
||||||
static constexpr double MCC_SIDERAL_TO_UT1_RATIO = 1.002737909350795; // sideral/UT1
|
static constexpr double MCC_SIDERAL_TO_UT1_RATIO = 1.002737909350795; // sideral/UT1
|
||||||
|
|
||||||
|
static constexpr double MCC_J2000_MJD = 51544.5;
|
||||||
|
static constexpr double MCC_MJD_ZERO = 2400000.5;
|
||||||
|
|
||||||
|
|
||||||
// a value to represent of infinite time duration according to type of duration representation
|
// a value to represent of infinite time duration according to type of duration representation
|
||||||
template <traits::mcc_time_duration_c DT>
|
template <traits::mcc_time_duration_c DT>
|
||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
template <mcc_coord_epoch_c EpT = MccCelestialCoordEpoch>
|
template <mcc_coord_epoch_c EpT = MccCelestialCoordEpoch>
|
||||||
MccCoordPair(CO_LON_T const& x, CO_LAT_T const& y, EpT const& epoch = EpT::now()) : _x(x), _y(y), _epoch(epoch)
|
MccCoordPair(CO_LON_T const& x, CO_LAT_T const& y, EpT const& epoch = EpT::now()) : _x(x), _y(y), _epoch(epoch)
|
||||||
{
|
{
|
||||||
normalize();
|
// normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
MccCoordPair(const MccCoordPair&) = default;
|
MccCoordPair(const MccCoordPair&) = default;
|
||||||
@@ -87,7 +87,9 @@ public:
|
|||||||
setY((double)other.y());
|
setY((double)other.y());
|
||||||
setEpoch(other.epoch());
|
setEpoch(other.epoch());
|
||||||
|
|
||||||
normalize();
|
if constexpr (T::pairKind != pairKind) {
|
||||||
|
normalize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -100,7 +102,9 @@ public:
|
|||||||
setY((double)other.y());
|
setY((double)other.y());
|
||||||
setEpoch(other.epoch());
|
setEpoch(other.epoch());
|
||||||
|
|
||||||
normalize();
|
if constexpr (T::pairKind != pairKind) {
|
||||||
|
normalize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -113,7 +117,9 @@ public:
|
|||||||
setY((double)other.y());
|
setY((double)other.y());
|
||||||
setEpoch(other.epoch());
|
setEpoch(other.epoch());
|
||||||
|
|
||||||
normalize();
|
if constexpr (T::pairKind != pairKind) {
|
||||||
|
normalize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -126,7 +132,9 @@ public:
|
|||||||
setY((double)other.y());
|
setY((double)other.y());
|
||||||
setEpoch(other.epoch());
|
setEpoch(other.epoch());
|
||||||
|
|
||||||
normalize();
|
if constexpr (T::pairKind != pairKind) {
|
||||||
|
normalize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -171,14 +179,14 @@ public:
|
|||||||
{
|
{
|
||||||
_x = x;
|
_x = x;
|
||||||
|
|
||||||
normalize();
|
// normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setY(const CO_LAT_T& y)
|
void setY(const CO_LAT_T& y)
|
||||||
{
|
{
|
||||||
_y = y;
|
_y = y;
|
||||||
|
|
||||||
normalize();
|
// normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEpoch(mcc_coord_epoch_c auto const& ep)
|
void setEpoch(mcc_coord_epoch_c auto const& ep)
|
||||||
@@ -194,14 +202,23 @@ protected:
|
|||||||
|
|
||||||
void normalize()
|
void normalize()
|
||||||
{
|
{
|
||||||
|
_x = CO_LON_T{_x};
|
||||||
|
_y = CO_LAT_T{_y};
|
||||||
|
/*
|
||||||
if constexpr (pairKind != MccCoordPairKind::COORDS_KIND_GENERIC &&
|
if constexpr (pairKind != MccCoordPairKind::COORDS_KIND_GENERIC &&
|
||||||
pairKind != MccCoordPairKind::COORDS_KIND_XY) {
|
pairKind != MccCoordPairKind::COORDS_KIND_XY) {
|
||||||
if constexpr (pairKind == MccCoordPairKind::COORDS_KIND_HADEC_APP ||
|
// if constexpr (pairKind == MccCoordPairKind::COORDS_KIND_HADEC_APP ||
|
||||||
pairKind == MccCoordPairKind::COORDS_KIND_HADEC_OBS) {
|
// pairKind == MccCoordPairKind::COORDS_KIND_HADEC_OBS) {
|
||||||
_x = (double)MccAngle(_x).normalize<MccAngle::NORM_KIND_180_180>();
|
// _x = (double)MccAngle(_x).normalize<MccAngle::NORM_KIND_180_180>();
|
||||||
} else { // RA, AZ
|
// } else { // RA, AZ
|
||||||
_x = (double)MccAngle(_x).normalize<MccAngle::NORM_KIND_0_360>();
|
// _x = (double)MccAngle(_x).normalize<MccAngle::NORM_KIND_0_360>();
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
_x = (double)MccAngle(_x).normalize<MccAngle::NORM_KIND_0_360>();
|
||||||
|
|
||||||
|
// if (utils::isEqual((double)_x, MCC_TWO_PI)) {
|
||||||
|
// _x = 0.0;
|
||||||
|
// }
|
||||||
|
|
||||||
// DEC and ALT is [-90,90] degrees
|
// DEC and ALT is [-90,90] degrees
|
||||||
if constexpr (pairKind != MccCoordPairKind::COORDS_KIND_AZZD) {
|
if constexpr (pairKind != MccCoordPairKind::COORDS_KIND_AZZD) {
|
||||||
@@ -210,6 +227,7 @@ protected:
|
|||||||
_y = (double)MccAngle(_y).normalize<MccAngle::NORM_KIND_0_180>();
|
_y = (double)MccAngle(_y).normalize<MccAngle::NORM_KIND_0_180>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -234,7 +252,7 @@ struct MccSkyRADEC_ICRS : MccCoordPair<MccAngleRA_ICRS, MccAngleDEC_ICRS> {
|
|||||||
// ignore epoch setting (it is always J2000.0)
|
// ignore epoch setting (it is always J2000.0)
|
||||||
void setEpoch(mcc_coord_epoch_c auto const&)
|
void setEpoch(mcc_coord_epoch_c auto const&)
|
||||||
{
|
{
|
||||||
static_assert(false, "CANNOT SET EPOCH FOR ICRS-KIND COORDINATE PAIR!!!");
|
// static_assert(false, "CANNOT SET EPOCH FOR ICRS-KIND COORDINATE PAIR!!!");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -344,14 +362,24 @@ struct MccSkyAZALT : MccCoordPair<MccAngleAZ, MccAngleALT> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
using MccGenXY = MccCoordPair<MccAngleX, MccAngleY>;
|
using MccGenXY = MccCoordPair<MccAngleX, MccAngleY>;
|
||||||
|
|
||||||
using MccGeoLONLAT = MccCoordPair<MccAngleLON, MccAngleLAT>;
|
using MccGeoLONLAT = MccCoordPair<MccAngleLON, MccAngleLAT>;
|
||||||
|
|
||||||
|
// utility type definition: deduce a coordinate pair kind according to mount type
|
||||||
|
// mcc_deduced_coord_pair_t = MccSkyHADEC_OBS for equathorial mounts,
|
||||||
|
// mcc_deduced_coord_pair_t = MccSkyAZZD for altazimuthal ones and
|
||||||
|
// mcc_deduced_coord_pair_t = std::nullptr_t otherwise
|
||||||
|
template <MccMountType MOUNT_TYPE>
|
||||||
|
using mcc_deduced_coord_pair_t =
|
||||||
|
std::conditional_t<mccIsEquatorialMount(MOUNT_TYPE),
|
||||||
|
MccSkyHADEC_OBS,
|
||||||
|
std::conditional_t<mccIsAltAzMount(MOUNT_TYPE), MccSkyAZZD, std::nullptr_t>>;
|
||||||
|
|
||||||
static MccSkyHADEC_APP hadec = MccGenXY{};
|
|
||||||
static MccSkyAZALT azalt{MccSkyAZZD{1.0, 1.1}};
|
|
||||||
|
// static MccSkyHADEC_APP hadec = MccGenXY{};
|
||||||
|
// static MccSkyAZALT azalt{MccSkyAZZD{1.0, 1.1}};
|
||||||
|
|
||||||
|
|
||||||
/* MCC-LIBRARY DEFAULT GENERIC SKY POINT CLASS IMPLEMENTATION */
|
/* MCC-LIBRARY DEFAULT GENERIC SKY POINT CLASS IMPLEMENTATION */
|
||||||
@@ -370,6 +398,14 @@ public:
|
|||||||
|
|
||||||
using error_t = typename CCTE_T::error_t;
|
using error_t = typename CCTE_T::error_t;
|
||||||
|
|
||||||
|
struct dist_result_t {
|
||||||
|
MccAngle dist{};
|
||||||
|
MccAngle dx{};
|
||||||
|
MccAngle dy{};
|
||||||
|
MccAngle x2{};
|
||||||
|
MccAngle y2{};
|
||||||
|
};
|
||||||
|
|
||||||
MccGenericSkyPoint() {}
|
MccGenericSkyPoint() {}
|
||||||
|
|
||||||
template <mcc_coord_pair_c PT>
|
template <mcc_coord_pair_c PT>
|
||||||
@@ -423,6 +459,17 @@ public:
|
|||||||
return _epoch;
|
return _epoch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double co_lon() const
|
||||||
|
{
|
||||||
|
return _x;
|
||||||
|
}
|
||||||
|
|
||||||
|
double co_lat() const
|
||||||
|
{
|
||||||
|
return _y;
|
||||||
|
}
|
||||||
|
|
||||||
template <mcc_coord_pair_c PT>
|
template <mcc_coord_pair_c PT>
|
||||||
MccGenericSkyPoint& from(const PT& coord_pair)
|
MccGenericSkyPoint& from(const PT& coord_pair)
|
||||||
{
|
{
|
||||||
@@ -475,7 +522,7 @@ public:
|
|||||||
std::pair<double, double> pos;
|
std::pair<double, double> pos;
|
||||||
cctEngine.geoPosition(&pos);
|
cctEngine.geoPosition(&pos);
|
||||||
|
|
||||||
return MccGeoLONLAT(pos.second, pos.first);
|
return MccGeoLONLAT(pos.first, pos.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -516,6 +563,78 @@ public:
|
|||||||
return error_t{};
|
return error_t{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'inner' transformation
|
||||||
|
error_t to(MccCoordPairKind pair_kind)
|
||||||
|
{
|
||||||
|
return to(pair_kind, _epoch);
|
||||||
|
}
|
||||||
|
|
||||||
|
error_t to(MccCoordPairKind pair_kind, mcc_coord_epoch_c auto const& epoch)
|
||||||
|
{
|
||||||
|
// do not use here "mcc_coord_epoch_c::operator==" to avoid
|
||||||
|
// unnecessary computations (astrometrical algorithms mainly use Julian date as input)
|
||||||
|
if (pair_kind == _pairKind && utils::isEqual(epoch.MJD(), _epoch.MJD())) {
|
||||||
|
_epoch = epoch;
|
||||||
|
|
||||||
|
return error_t{};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto tr_func = [&, this]<mcc_coord_pair_c T>(T& cp) {
|
||||||
|
if constexpr (T::pairKind != MccCoordPairKind::COORDS_KIND_RADEC_ICRS) {
|
||||||
|
cp.setEpoch(epoch);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto err = to(cp);
|
||||||
|
|
||||||
|
if (!err) {
|
||||||
|
from(cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (pair_kind) {
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_ICRS: {
|
||||||
|
MccSkyRADEC_ICRS cp;
|
||||||
|
return tr_func(cp);
|
||||||
|
} break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_OBS: {
|
||||||
|
MccSkyRADEC_OBS cp;
|
||||||
|
return tr_func(cp);
|
||||||
|
} break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_APP: {
|
||||||
|
MccSkyRADEC_APP cp;
|
||||||
|
return tr_func(cp);
|
||||||
|
} break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_HADEC_OBS: {
|
||||||
|
MccSkyHADEC_OBS cp;
|
||||||
|
return tr_func(cp);
|
||||||
|
} break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_HADEC_APP: {
|
||||||
|
MccSkyHADEC_APP cp;
|
||||||
|
return tr_func(cp);
|
||||||
|
} break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_AZZD: {
|
||||||
|
MccSkyAZZD cp;
|
||||||
|
return tr_func(cp);
|
||||||
|
} break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_AZALT: {
|
||||||
|
MccSkyAZALT cp;
|
||||||
|
return tr_func(cp);
|
||||||
|
} break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_GENERIC:
|
||||||
|
case MccCoordPairKind::COORDS_KIND_UNKNOWN:
|
||||||
|
case MccCoordPairKind::COORDS_KIND_LONLAT:
|
||||||
|
case MccCoordPairKind::COORDS_KIND_XY: {
|
||||||
|
MccGenXY cp;
|
||||||
|
return tr_func(cp);
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
return error_t{};
|
||||||
|
}
|
||||||
|
|
||||||
|
return error_t{};
|
||||||
|
}
|
||||||
|
|
||||||
error_t refractCorrection(mcc_angle_c auto* dZ) const
|
error_t refractCorrection(mcc_angle_c auto* dZ) const
|
||||||
{
|
{
|
||||||
@@ -581,23 +700,45 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
error_t appSideralTime(mcc_angle_c auto* st) const
|
error_t appSideralTime(mcc_angle_c auto* st, bool is_local = false) const
|
||||||
{
|
{
|
||||||
// return Greenwich apparent sideral time since epoch is UTC
|
return cctEngine.apparentSideralTime(_epoch, st, is_local);
|
||||||
return cctEngine.apparentSideralTime(_epoch, st, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
error_t EO(mcc_angle_c auto* eo)
|
error_t EO(mcc_angle_c auto* eo) const
|
||||||
{
|
{
|
||||||
return cctEngine.equationOrigins(_epoch, eo);
|
return cctEngine.equationOrigins(_epoch, eo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dist_result_t distance(MccGenericSkyPoint const& sp) const
|
||||||
|
// dist_result_t distance(mcc_skypoint_c auto const& sp)
|
||||||
|
{
|
||||||
|
double x, y;
|
||||||
|
|
||||||
|
if (_pairKind == sp.pairKind() && utils::isEqual(_epoch.MJD(), sp.epoch().MJD())) {
|
||||||
|
x = sp.co_lon();
|
||||||
|
y = sp.co_lat();
|
||||||
|
} else { // convert to the same coordinates kind
|
||||||
|
MccGenericSkyPoint p{sp};
|
||||||
|
p.to(_pairKind, _epoch);
|
||||||
|
|
||||||
|
x = p.co_lon();
|
||||||
|
y = p.co_lat();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto d = utils::distanceOnSphere(_x, _y, x, y);
|
||||||
|
|
||||||
|
return {.dist = std::get<2>(d), .dx = std::get<0>(d), .dy = std::get<1>(d), .x2 = x, .y2 = y};
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double _x{0.0}, _y{0.0};
|
double _x{0.0}, _y{0.0};
|
||||||
MccCoordPairKind _pairKind{MccCoordPairKind::COORDS_KIND_RADEC_ICRS};
|
MccCoordPairKind _pairKind{MccCoordPairKind::COORDS_KIND_RADEC_ICRS};
|
||||||
MccCelestialCoordEpoch _epoch{}; // J2000.0
|
MccCelestialCoordEpoch _epoch{}; // J2000.0
|
||||||
|
|
||||||
|
|
||||||
template <mcc_skypoint_c T>
|
template <mcc_skypoint_c T>
|
||||||
void fromOtherSkyPoint(T&& other)
|
void fromOtherSkyPoint(T&& other)
|
||||||
{
|
{
|
||||||
@@ -659,30 +800,30 @@ protected:
|
|||||||
// HA, DEC to AZ, ALT (AZ from the South through the West)
|
// HA, DEC to AZ, ALT (AZ from the South through the West)
|
||||||
void hadec2azalt(double ha, double dec, double phi, double& az, double& alt) const
|
void hadec2azalt(double ha, double dec, double phi, double& az, double& alt) const
|
||||||
{
|
{
|
||||||
eraHd2ae(ha, dec, phi, &az, &alt);
|
// eraHd2ae(ha, dec, phi, &az, &alt);
|
||||||
// from ERFA "from N" to "from S"
|
// // from ERFA "from N" to "from S"
|
||||||
if (az > std::numbers::pi) {
|
// if (az > std::numbers::pi) {
|
||||||
az -= std::numbers::pi;
|
// az -= std::numbers::pi;
|
||||||
} else {
|
// } else {
|
||||||
az += std::numbers::pi;
|
// az += std::numbers::pi;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
const auto cos_phi = std::cos(phi), sin_phi = std::sin(phi);
|
const auto cos_phi = std::cos(phi), sin_phi = std::sin(phi);
|
||||||
const auto cos_dec = std::cos(dec), sin_dec = std::sin(dec);
|
const auto cos_dec = std::cos(dec), sin_dec = std::sin(dec);
|
||||||
const auto cos_ha = std::cos(ha), sin_ha = std::sin(ha);
|
const auto cos_ha = std::cos(ha), sin_ha = std::sin(ha);
|
||||||
|
|
||||||
auto x = sin_phi * cos_dec * cos_ha - cos_phi * sin_dec;
|
auto x = sin_phi * cos_dec * cos_ha - cos_phi * sin_dec;
|
||||||
auto y = -cos_dec * sin_ha;
|
auto y = cos_dec * sin_ha;
|
||||||
auto z = cos_phi * cos_dec * cos_ha + sin_phi * sin_dec;
|
auto z = cos_phi * cos_dec * cos_ha + sin_phi * sin_dec;
|
||||||
|
|
||||||
auto xx = x * x, yy = y * y;
|
auto xx = x * x, yy = y * y;
|
||||||
decltype(x) r;
|
decltype(x) r;
|
||||||
if (xx < yy) {
|
if (xx < yy) {
|
||||||
r = yy * sqrt(1.0 + xx / yy);
|
r = std::abs(y) * sqrt(1.0 + xx / yy);
|
||||||
} else {
|
} else {
|
||||||
r = xx * sqrt(1.0 + yy / xx);
|
r = std::abs(x) * sqrt(1.0 + yy / xx);
|
||||||
}
|
}
|
||||||
|
|
||||||
az = utils::isEqual(r, 0.0) ? 0.0 : std::atan2(y, x);
|
az = utils::isEqual(r, 0.0) ? 0.0 : std::atan2(y, x);
|
||||||
@@ -697,10 +838,10 @@ protected:
|
|||||||
// AZ, ALT to HA, DEC (AZ from the South through the West)
|
// AZ, ALT to HA, DEC (AZ from the South through the West)
|
||||||
void azalt2hadec(double az, double alt, double phi, double& ha, double& dec) const
|
void azalt2hadec(double az, double alt, double phi, double& ha, double& dec) const
|
||||||
{
|
{
|
||||||
az += std::numbers::pi;
|
// az += std::numbers::pi;
|
||||||
eraAe2hd(az, alt, phi, &ha, &dec);
|
// eraAe2hd(az, alt, phi, &ha, &dec);
|
||||||
|
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
const auto cos_phi = std::cos(phi), sin_phi = std::sin(phi);
|
const auto cos_phi = std::cos(phi), sin_phi = std::sin(phi);
|
||||||
const auto cos_az = std::cos(az), sin_az = std::sin(az);
|
const auto cos_az = std::cos(az), sin_az = std::sin(az);
|
||||||
@@ -713,9 +854,9 @@ protected:
|
|||||||
auto xx = x * x, yy = y * y;
|
auto xx = x * x, yy = y * y;
|
||||||
decltype(x) r;
|
decltype(x) r;
|
||||||
if (xx < yy) {
|
if (xx < yy) {
|
||||||
r = yy * sqrt(1.0 + xx / yy);
|
r = std::abs(y) * sqrt(1.0 + xx / yy);
|
||||||
} else {
|
} else {
|
||||||
r = xx * sqrt(1.0 + yy / xx);
|
r = std::abs(x) * sqrt(1.0 + yy / xx);
|
||||||
}
|
}
|
||||||
|
|
||||||
ha = utils::isEqual(r, 0.0) ? 0.0 : std::atan2(y, x);
|
ha = utils::isEqual(r, 0.0) ? 0.0 : std::atan2(y, x);
|
||||||
@@ -731,10 +872,22 @@ protected:
|
|||||||
double phi = cctEngine.getStateERFA().lat;
|
double phi = cctEngine.getStateERFA().lat;
|
||||||
double ra_icrs, dec_icrs, ra, dec, ha, az, zd, alt, lst, eo;
|
double ra_icrs, dec_icrs, ra, dec, ha, az, zd, alt, lst, eo;
|
||||||
|
|
||||||
|
static_assert(PT::pairKind != MccCoordPairKind::COORDS_KIND_LONLAT, "UNSUPPORTED SKY POINT TRANSFORMATION!");
|
||||||
|
// static_assert(PT::pairKind != MccCoordPairKind::COORDS_KIND_XY, "UNSUPPORTED SKY POINT TRANSFORMATION!");
|
||||||
static_assert(PT::pairKind != MccCoordPairKind::COORDS_KIND_GENERIC, "UNSUPPORTED SKY POINT TRANSFORMATION!");
|
static_assert(PT::pairKind != MccCoordPairKind::COORDS_KIND_GENERIC, "UNSUPPORTED SKY POINT TRANSFORMATION!");
|
||||||
static_assert(PT::pairKind != MccCoordPairKind::COORDS_KIND_UNKNOWN, "UNSUPPORTED SKY POINT TRANSFORMATION!");
|
static_assert(PT::pairKind != MccCoordPairKind::COORDS_KIND_UNKNOWN, "UNSUPPORTED SKY POINT TRANSFORMATION!");
|
||||||
|
|
||||||
|
|
||||||
|
if constexpr (PT::pairKind == MccCoordPairKind::COORDS_KIND_LONLAT) { // returns geographic site coordinates
|
||||||
|
std::pair<double, double> pos;
|
||||||
|
cctEngine.geoPosition(&pos);
|
||||||
|
|
||||||
|
cpair.setX(pos.first);
|
||||||
|
cpair.setY(pos.second);
|
||||||
|
|
||||||
|
return error_t{};
|
||||||
|
}
|
||||||
|
|
||||||
if (_pairKind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS &&
|
if (_pairKind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS &&
|
||||||
PT::pairKind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS) { // from ICRS to ICRS - just copy and exit
|
PT::pairKind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS) { // from ICRS to ICRS - just copy and exit
|
||||||
cpair = PT(typename PT::x_t(_x), typename PT::y_t(_y));
|
cpair = PT(typename PT::x_t(_x), typename PT::y_t(_y));
|
||||||
@@ -756,7 +909,8 @@ protected:
|
|||||||
// 1) convert stored coordinates to ICRS ones
|
// 1) convert stored coordinates to ICRS ones
|
||||||
// 2) convert from the computed ICRS coordinates to required ones
|
// 2) convert from the computed ICRS coordinates to required ones
|
||||||
MccCoordPairKind pkind = _pairKind;
|
MccCoordPairKind pkind = _pairKind;
|
||||||
if (!utils::isEqual(_epoch.MJD(), cpair.MJD())) { // convert stored pair to ICRS one (ra_icrs, dec_icrs)
|
if (!utils::isEqual(_epoch.MJD(),
|
||||||
|
cpair.MJD())) { // convert stored pair to ICRS one (ra_icrs, dec_icrs)
|
||||||
if (_pairKind != MccCoordPairKind::COORDS_KIND_RADEC_ICRS) {
|
if (_pairKind != MccCoordPairKind::COORDS_KIND_RADEC_ICRS) {
|
||||||
pkind = MccCoordPairKind::COORDS_KIND_RADEC_ICRS;
|
pkind = MccCoordPairKind::COORDS_KIND_RADEC_ICRS;
|
||||||
|
|
||||||
@@ -925,7 +1079,8 @@ protected:
|
|||||||
cpair.setY(dec);
|
cpair.setY(dec);
|
||||||
} else {
|
} else {
|
||||||
obj->hadec2azalt(ha, dec, phi, az, alt);
|
obj->hadec2azalt(ha, dec, phi, az, alt);
|
||||||
if constexpr (mccIsObsCoordPairKind<PT::pairKind>) { // RADEC_OBS, HADEC_OBS, AZALT, AZZD
|
if constexpr (mccIsObsCoordPairKind<PT::pairKind>) { // RADEC_OBS, HADEC_OBS,
|
||||||
|
// AZALT, AZZD
|
||||||
// correct for refraction: alt += dz_refr
|
// correct for refraction: alt += dz_refr
|
||||||
double dZ;
|
double dZ;
|
||||||
ccte_err = cctEngine.refractionInverseCorrection(MCC_HALF_PI - alt, &dZ);
|
ccte_err = cctEngine.refractionInverseCorrection(MCC_HALF_PI - alt, &dZ);
|
||||||
@@ -978,7 +1133,8 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* MCC-LIBRARY DEFAULT SKY POINT CLASS IMPLEMENTATION BASED ON THE ERFA LIBRARY */
|
/* MCC-LIBRARY DEFAULT SKY POINT CLASS IMPLEMENTATION BASED ON THE ERFA LIBRARY
|
||||||
|
*/
|
||||||
|
|
||||||
typedef MccGenericSkyPoint<mcc::ccte::erfa::MccCCTE_ERFA> MccSkyPoint;
|
typedef MccGenericSkyPoint<mcc::ccte::erfa::MccCCTE_ERFA> MccSkyPoint;
|
||||||
|
|
||||||
466
include/mcc/mcc_deserializer.h
Normal file
466
include/mcc/mcc_deserializer.h
Normal file
@@ -0,0 +1,466 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "mcc_coordinate.h"
|
||||||
|
#include "mcc_epoch.h"
|
||||||
|
#include "mcc_serialization_common.h"
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class MccDeserializerErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_UNDERLYING_DESERIALIZER,
|
||||||
|
ERROR_INVALID_SERIALIZED_VALUE,
|
||||||
|
ERROR_COORD_TRANSFORM
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class is_error_code_enum<mcc::impl::MccDeserializerErrorCode> : public true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// error category
|
||||||
|
struct MccDeserializerCategory : public std::error_category {
|
||||||
|
MccDeserializerCategory() : std::error_category() {}
|
||||||
|
|
||||||
|
const char* name() const noexcept
|
||||||
|
{
|
||||||
|
return "MCC-DESERIALIZER-ERR-CATEGORY";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message(int ec) const
|
||||||
|
{
|
||||||
|
MccDeserializerErrorCode err = static_cast<MccDeserializerErrorCode>(ec);
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
case MccDeserializerErrorCode::ERROR_OK:
|
||||||
|
return "OK";
|
||||||
|
case MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER:
|
||||||
|
return "error returned by underlying deserializer";
|
||||||
|
case MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE:
|
||||||
|
return "invalid serialized value";
|
||||||
|
case MccDeserializerErrorCode::ERROR_COORD_TRANSFORM:
|
||||||
|
return "coordinates transformation error";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const MccDeserializerCategory& get()
|
||||||
|
{
|
||||||
|
static const MccDeserializerCategory constInst;
|
||||||
|
return constInst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline std::error_code make_error_code(MccDeserializerErrorCode ec)
|
||||||
|
{
|
||||||
|
return std::error_code(static_cast<int>(ec), MccDeserializerCategory::get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* BASE DESERIALIZER CLASS (FOR IMPLEMENTATIONS BELOW) */
|
||||||
|
|
||||||
|
struct MccDeserializerBase : mcc_deserializer_interface_t<MccError> {
|
||||||
|
using typename mcc_deserializer_interface_t<MccError>::error_t;
|
||||||
|
|
||||||
|
virtual ~MccDeserializerBase() = default;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
MccDeserializerBase() = default;
|
||||||
|
|
||||||
|
//
|
||||||
|
// empty == true, if the 'input' is empty or if all elements consist of only spaces
|
||||||
|
//
|
||||||
|
static std::vector<std::string_view> splitValueIntoElements(traits::mcc_input_char_range auto const& input,
|
||||||
|
mcc_serialization_params_c auto const& params,
|
||||||
|
bool& empty)
|
||||||
|
{
|
||||||
|
static_assert(std::ranges::contiguous_range<decltype(input)>, "NOT IMPLEMENTED FOR NON-CONTIGUIUS RANGES!!!");
|
||||||
|
|
||||||
|
std::vector<std::string_view> res;
|
||||||
|
|
||||||
|
if (std::ranges::size(input)) {
|
||||||
|
empty = true;
|
||||||
|
|
||||||
|
std::ranges::for_each(std::views::split(input, params.elem_delim), [&res, &empty](auto const& el) {
|
||||||
|
std::back_inserter(res) = utils::trimSpaces(std::string_view{el.begin(), el.end()});
|
||||||
|
if (empty && res.back().size()) {
|
||||||
|
empty = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
empty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VT, std::ranges::output_range<VT> R, typename... DeserParamsT>
|
||||||
|
static error_t deserializingRange(mcc_deserializer_c auto& dsr,
|
||||||
|
traits::mcc_input_char_range auto const& input,
|
||||||
|
R& r,
|
||||||
|
mcc_serialization_params_c auto const& params)
|
||||||
|
{
|
||||||
|
if (std::ranges::size(input) == 0) { // ignore an empty input, just return empty range?!!
|
||||||
|
r = R{};
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// auto r_str = std::views::split(input, params.seq_delim);
|
||||||
|
auto r_str = std::views::split(input, params.elem_delim);
|
||||||
|
VT val;
|
||||||
|
|
||||||
|
auto it = r.begin();
|
||||||
|
for (auto const& el : r_str) {
|
||||||
|
// auto err = dsr(el, val, std::forward<DeserParamsT>(params)...);
|
||||||
|
auto err = dsr(el, val, params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it == r.end()) {
|
||||||
|
if constexpr (!traits::mcc_fixed_size_range<R>) {
|
||||||
|
std::back_inserter(r) = val;
|
||||||
|
it = r.end();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*it = val;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* MAIN (FALLBACK) TEMPLATED IMPLEMENTATION */
|
||||||
|
|
||||||
|
|
||||||
|
template <typename VT>
|
||||||
|
struct MccDeserializer : MccDeserializerBase {
|
||||||
|
static constexpr std::string_view deserializerName{"MCC-FALLBACK-DESERIALIZER"};
|
||||||
|
|
||||||
|
virtual ~MccDeserializer() = default;
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_input_char_range auto const& input,
|
||||||
|
VT& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
if constexpr (std::is_arithmetic_v<VT>) {
|
||||||
|
auto v = mcc::utils::numFromStr<VT>(utils::trimSpaces(input));
|
||||||
|
if (!v.has_value()) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = v.value();
|
||||||
|
} else if constexpr (mcc::traits::mcc_output_char_range<VT>) {
|
||||||
|
VT r;
|
||||||
|
if constexpr (traits::mcc_array_c<VT>) {
|
||||||
|
size_t N =
|
||||||
|
std::ranges::size(r) <= std::ranges::size(input) ? std::ranges::size(r) : std::ranges::size(input);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < N; ++i) {
|
||||||
|
r[i] = input[i];
|
||||||
|
}
|
||||||
|
if (std::ranges::size(r) > N) {
|
||||||
|
for (size_t i = N; i < std::ranges::size(r); ++i) {
|
||||||
|
r[i] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::ranges::copy(input, std::back_inserter(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
value = r;
|
||||||
|
} else if constexpr (std::ranges::range<VT>) {
|
||||||
|
using el_t = std::ranges::range_value_t<VT>;
|
||||||
|
|
||||||
|
static_assert(std::ranges::output_range<VT, el_t>, "INVALID RANGE TYPE!!!");
|
||||||
|
|
||||||
|
// no reference or constants allowed
|
||||||
|
static_assert(!(std::is_reference_v<el_t> || std::is_const_v<el_t>), "INVALID RANGE ELEMENT TYPE!!!");
|
||||||
|
|
||||||
|
MccDeserializer<el_t> dsr;
|
||||||
|
return deserializingRange<el_t>(dsr, input, value, params);
|
||||||
|
} else if constexpr (traits::mcc_time_duration_c<VT>) {
|
||||||
|
typename VT::rep vd;
|
||||||
|
|
||||||
|
MccDeserializer<typename VT::rep> dsr;
|
||||||
|
|
||||||
|
auto err = dsr(utils::trimSpaces(input), vd, params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = VT{vd};
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNSUPPORTED VALUE TYPE!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* SPECIALIZATION FOR THE SOME CONCEPTS */
|
||||||
|
|
||||||
|
template <mcc_coord_epoch_c VT>
|
||||||
|
struct MccDeserializer<VT> : MccDeserializerBase {
|
||||||
|
static constexpr std::string_view deserializerName{"MCC-COORD-EPOCH-DESERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_input_char_range auto const& input,
|
||||||
|
VT& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
bool ok = value.fromCharRange(input);
|
||||||
|
if (!ok) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <typename VT>
|
||||||
|
requires(!std::is_arithmetic_v<VT> && mcc_angle_c<VT>)
|
||||||
|
struct MccDeserializer<VT> : MccDeserializerBase {
|
||||||
|
static constexpr std::string_view deserializerName{"MCC-ANGLE-DESERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_input_char_range auto const& input,
|
||||||
|
VT& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
bool hms = params.angle_format == MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURS;
|
||||||
|
|
||||||
|
auto res = utils::parsAngleString(input, hms);
|
||||||
|
if (res) { // returned angle is in degrees!!!
|
||||||
|
value = res.value() * MCC_DEGRESS_TO_RADS;
|
||||||
|
} else {
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_skypoint_c VT>
|
||||||
|
struct MccDeserializer<VT> : MccDeserializerBase {
|
||||||
|
static constexpr std::string_view deserializerName{"MCC-SKYPOINT-DESERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_input_char_range auto const& input,
|
||||||
|
VT& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
auto pars = params;
|
||||||
|
|
||||||
|
// valid format: X<elem-delim>Y[<elem-delim>TIME-POINT<elem-delim>PAIR-KIND]
|
||||||
|
// X<elem-delim>Y (assumed RADEC_ICRS and J2000.0 epoch)
|
||||||
|
|
||||||
|
// valid format: X<elem-delim>Y<elem-delim>PAIRKIND<elem-delim>EPOCH
|
||||||
|
// X<elem-delim>Y<elem-delim>PAIRKIND (assumed epoch is NOW, or J2000.0 if PAIRKIND == RADEC-ICRS)
|
||||||
|
// X<elem-delim>Y (assumed RADEC-ICRS and J2000.0 epoch)
|
||||||
|
|
||||||
|
bool empty;
|
||||||
|
|
||||||
|
auto elems = MccDeserializerBase::splitValueIntoElements(input, params, empty);
|
||||||
|
|
||||||
|
if (empty || (elems.size() < 2)) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MccCoordPairKind pair_kind{MccCoordPairKind::COORDS_KIND_RADEC_ICRS};
|
||||||
|
MccCelestialCoordEpoch epoch; // J2000.0
|
||||||
|
|
||||||
|
MccAngle x, y;
|
||||||
|
MccDeserializer<MccAngle> dsr_ang;
|
||||||
|
|
||||||
|
typename MccDeserializer<MccAngle>::error_t dsr_err;
|
||||||
|
|
||||||
|
if (elems.size() > 2) { // no epoch
|
||||||
|
// deserialize pair kind string
|
||||||
|
pair_kind = MccCoordStrToPairKind(elems[2]);
|
||||||
|
if (pair_kind == MccCoordPairKind::COORDS_KIND_UNKNOWN) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pair_kind != MccCoordPairKind::COORDS_KIND_RADEC_ICRS) {
|
||||||
|
epoch = MccCelestialCoordEpoch::now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elems.size() > 3) { // full format
|
||||||
|
// epoch
|
||||||
|
if (pair_kind != MccCoordPairKind::COORDS_KIND_RADEC_ICRS) { // ignore epoch if PAIRKIND == RADEC-ICRS
|
||||||
|
bool ok = epoch.fromCharRange(elems[3]);
|
||||||
|
if (!ok) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// deserialize X and Y
|
||||||
|
if (params.coordpair_format == MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURDEG) {
|
||||||
|
pars.angle_format = MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURS;
|
||||||
|
} else {
|
||||||
|
pars.angle_format = MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
dsr_err = dsr_ang(elems[0], x, pars);
|
||||||
|
if (dsr_err) {
|
||||||
|
return mcc_deduced_err(dsr_err, MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
pars.angle_format = MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGS;
|
||||||
|
dsr_err = dsr_ang(elems[1], y, pars);
|
||||||
|
if (dsr_err) {
|
||||||
|
return mcc_deduced_err(dsr_err, MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (pair_kind) {
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_ICRS:
|
||||||
|
value.from(MccSkyRADEC_ICRS{(double)x, (double)y});
|
||||||
|
break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_OBS:
|
||||||
|
value.from(MccSkyRADEC_OBS{(double)x, (double)y, epoch});
|
||||||
|
break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_APP:
|
||||||
|
value.from(MccSkyRADEC_APP{(double)x, (double)y, epoch});
|
||||||
|
break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_HADEC_OBS:
|
||||||
|
value.from(MccSkyHADEC_OBS{(double)x, (double)y, epoch});
|
||||||
|
break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_HADEC_APP:
|
||||||
|
value.from(MccSkyHADEC_APP{(double)x, (double)y, epoch});
|
||||||
|
break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_AZZD:
|
||||||
|
value.from(MccSkyAZZD{(double)x, (double)y, epoch});
|
||||||
|
break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_AZALT:
|
||||||
|
value.from(MccSkyAZALT{(double)x, (double)y, epoch});
|
||||||
|
break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_XY:
|
||||||
|
value.from(MccGenXY{(double)x, (double)y, epoch});
|
||||||
|
break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_GENERIC:
|
||||||
|
value.from(MccCoordPair{(double)x, (double)y, epoch});
|
||||||
|
break;
|
||||||
|
case MccCoordPairKind::COORDS_KIND_LONLAT:
|
||||||
|
value.from(MccGeoLONLAT{(double)x, (double)y});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct MccDeserializer<MccCoordPairKind> : MccDeserializerBase {
|
||||||
|
static constexpr std::string_view deserializerName{"MCC-COORDPAIR-DESERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_input_char_range auto const& input,
|
||||||
|
MccCoordPairKind& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
value = MccCoordStrToPairKind(input);
|
||||||
|
|
||||||
|
if (value == MccCoordPairKind::COORDS_KIND_UNKNOWN) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct MccDeserializer<MccSerializedAngleFormatPrec> : MccDeserializerBase {
|
||||||
|
static constexpr std::string_view deserializerName{"MCC-ANGLE-FORMAT-PREC-DESERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_input_char_range auto const& input,
|
||||||
|
MccSerializedAngleFormatPrec& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
// valid format: hour_prec[<params.elem_delim>deg_prec<params.elem_delim>decimals]
|
||||||
|
|
||||||
|
std::vector<uint8_t> v;
|
||||||
|
|
||||||
|
auto err = MccDeserializer<decltype(v)>{}(input, v);
|
||||||
|
if (err) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v.size() > 0) {
|
||||||
|
value.hour_prec = v[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v.size() > 1) {
|
||||||
|
value.deg_prec = v[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (v.size() > 2) {
|
||||||
|
value.decimals = v[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct MccDeserializer<MccSerializedCoordPairFormat> : MccDeserializerBase {
|
||||||
|
static constexpr std::string_view deserializerName{"MCC-COORDPAIR-FORMAT-DESERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_input_char_range auto const& input,
|
||||||
|
MccSerializedCoordPairFormat& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
value = MccSerializedCoordPairFormatStrToValue(input);
|
||||||
|
|
||||||
|
if (value != MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_UNKNOWN) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
} else {
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
@@ -198,7 +198,7 @@ public:
|
|||||||
error_t operator()(traits::mcc_input_char_range auto const& input, VT& value)
|
error_t operator()(traits::mcc_input_char_range auto const& input, VT& value)
|
||||||
{
|
{
|
||||||
if constexpr (std::is_arithmetic_v<VT>) {
|
if constexpr (std::is_arithmetic_v<VT>) {
|
||||||
auto v = mcc::utils::numFromStr<VT>(trimSpaces(input));
|
auto v = mcc::utils::numFromStr<VT>(utils::trimSpaces(input));
|
||||||
if (!v.has_value()) {
|
if (!v.has_value()) {
|
||||||
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
}
|
}
|
||||||
@@ -302,8 +302,8 @@ public:
|
|||||||
{
|
{
|
||||||
if constexpr (mcc_angle_c<VT>) { // scalar
|
if constexpr (mcc_angle_c<VT>) { // scalar
|
||||||
auto res = utils::parsAngleString(input, hms);
|
auto res = utils::parsAngleString(input, hms);
|
||||||
if (res) {
|
if (res) { // returned angle is in degrees!!!
|
||||||
value = res.value();
|
value = res.value() * MCC_DEGRESS_TO_RADS;
|
||||||
} else {
|
} else {
|
||||||
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
}
|
}
|
||||||
@@ -62,6 +62,26 @@ public:
|
|||||||
fromTimePoint(std::forward<decltype(other)>(other).UTC());
|
fromTimePoint(std::forward<decltype(other)>(other).UTC());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MccCelestialCoordEpoch(traits::mcc_input_char_range auto&& str)
|
||||||
|
{
|
||||||
|
// ignore possible errors!!!
|
||||||
|
fromCharRange(std::forward<decltype(str)>(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename ClockT, typename DurT>
|
||||||
|
MccCelestialCoordEpoch(std::chrono::time_point<ClockT, DurT> const& tp) : MccCelestialCoordEpoch()
|
||||||
|
{
|
||||||
|
fromTimePoint(tp);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VT>
|
||||||
|
MccCelestialCoordEpoch(VT&& mjd)
|
||||||
|
requires std::is_arithmetic_v<std::remove_cvref_t<VT>>
|
||||||
|
{
|
||||||
|
// ignore possible errors!!!
|
||||||
|
fromMJD(std::forward<decltype(mjd)>(mjd));
|
||||||
|
}
|
||||||
|
|
||||||
MccCelestialCoordEpoch& operator=(mcc_coord_epoch_c auto&& other)
|
MccCelestialCoordEpoch& operator=(mcc_coord_epoch_c auto&& other)
|
||||||
{
|
{
|
||||||
fromTimePoint(std::forward<decltype(other)>(other).UTC());
|
fromTimePoint(std::forward<decltype(other)>(other).UTC());
|
||||||
@@ -79,17 +99,17 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
template <typename ClockT, typename DurT>
|
template <typename ClockT, typename DurT>
|
||||||
MccCelestialCoordEpoch& operator=(std::chrono::time_point<ClockT, DurT>&& tp)
|
MccCelestialCoordEpoch& operator=(std::chrono::time_point<ClockT, DurT> const& tp)
|
||||||
{
|
{
|
||||||
// ignore possible errors!!!
|
// ignore possible errors!!!
|
||||||
auto ok = fromTimePoint(std::forward<decltype(tp)>(tp));
|
auto ok = fromTimePoint(tp);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename VT>
|
template <typename VT>
|
||||||
MccCelestialCoordEpoch& operator=(VT&& mjd)
|
MccCelestialCoordEpoch& operator=(VT&& mjd)
|
||||||
requires std::is_arithmetic_v<VT>
|
requires std::is_arithmetic_v<std::remove_cvref_t<VT>>
|
||||||
{
|
{
|
||||||
// ignore possible errors!!!
|
// ignore possible errors!!!
|
||||||
auto ok = fromMJD(std::forward<decltype(mjd)>(mjd));
|
auto ok = fromMJD(std::forward<decltype(mjd)>(mjd));
|
||||||
@@ -139,17 +159,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ClockT, typename DurT>
|
template <typename ClockT, typename DurT>
|
||||||
bool fromTimePoint(std::chrono::time_point<ClockT, DurT>&& tp)
|
bool fromTimePoint(std::chrono::time_point<ClockT, DurT> const& tp)
|
||||||
{
|
{
|
||||||
if constexpr (std::same_as<ClockT, std::chrono::system_clock>) {
|
if constexpr (std::same_as<ClockT, std::chrono::system_clock>) {
|
||||||
_UTC = std::chrono::time_point_cast<decltype(_UTC)::duration>(std::forward<decltype(tp)>(tp));
|
_UTC = std::chrono::time_point_cast<decltype(_UTC)::duration>(tp);
|
||||||
} else if constexpr (std::same_as<ClockT, std::chrono::utc_clock>) {
|
} else if constexpr (std::same_as<ClockT, std::chrono::utc_clock>) {
|
||||||
auto stp = std::chrono::utc_clock::to_sys(std::forward<decltype(tp)>(tp));
|
auto stp = std::chrono::utc_clock::to_sys(tp);
|
||||||
_UTC = std::chrono::time_point_cast<decltype(_UTC)::duration>(std::forward<decltype(tp)>(stp));
|
_UTC = std::chrono::time_point_cast<decltype(_UTC)::duration>(stp);
|
||||||
} else if constexpr (std::same_as<ClockT, std::chrono::tai_clock>) {
|
} else if constexpr (std::same_as<ClockT, std::chrono::tai_clock>) {
|
||||||
return fromTimePoint(ClockT::to_utc(std::forward<decltype(tp)>(tp)));
|
return fromTimePoint(ClockT::to_utc(tp));
|
||||||
} else if constexpr (std::same_as<ClockT, std::chrono::gps_clock>) {
|
} else if constexpr (std::same_as<ClockT, std::chrono::gps_clock>) {
|
||||||
return fromTimePoint(ClockT::to_utc(std::forward<decltype(tp)>(tp)));
|
return fromTimePoint(ClockT::to_utc(tp));
|
||||||
} else {
|
} else {
|
||||||
static_assert(false, "UNSUPPORTED CLOCK!!!");
|
static_assert(false, "UNSUPPORTED CLOCK!!!");
|
||||||
}
|
}
|
||||||
@@ -407,6 +427,5 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
static_assert(mcc_coord_epoch_c<MccCelestialCoordEpoch>, "!!!");
|
static_assert(mcc_coord_epoch_c<MccCelestialCoordEpoch>, "!!!");
|
||||||
|
static_assert(requires(MccCelestialCoordEpoch ep) { ep = std::chrono::system_clock::now(); });
|
||||||
|
|
||||||
} // namespace mcc::impl
|
} // namespace mcc::impl
|
||||||
@@ -53,7 +53,7 @@ struct std::formatter<mcc::impl::MccError, char> {
|
|||||||
// _currFmt.push_back(*(++it));
|
// _currFmt.push_back(*(++it));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (it++ != ctx.end() || it++ != '}') {
|
if (it++ != ctx.end() || *(it++) != '}') {
|
||||||
_delim = *(++it);
|
_delim = *(++it);
|
||||||
}
|
}
|
||||||
case '}':
|
case '}':
|
||||||
268
include/mcc/mcc_generic_mount.h
Normal file
268
include/mcc/mcc_generic_mount.h
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
* *
|
||||||
|
* MOUNT CONTROL COMPONENTS LIBRARY *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* IMPLEMENTATION OF A GENERIC MOUNT CLASS *
|
||||||
|
* (A SOME OF POSSIBLE GENERIC IMPLEMENTATIONS) *
|
||||||
|
* *
|
||||||
|
****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include "mcc/mcc_spdlog.h"
|
||||||
|
#include "mcc_error.h"
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class MccGenericMountErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_HW_INIT,
|
||||||
|
ERROR_HW_STOP,
|
||||||
|
ERROR_HW_GETSTATE,
|
||||||
|
ERROR_SET_TARGET,
|
||||||
|
ERROR_MOUNT_SLEW,
|
||||||
|
ERROR_MOUNT_TRACK,
|
||||||
|
ERROR_GET_TELEMETRY,
|
||||||
|
ERROR_UNSUPPORTED_TARGET_COORDPAIR,
|
||||||
|
ERROR_PZONE_COMP,
|
||||||
|
ERROR_TARGET_IN_ZONE
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
|
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class is_error_code_enum<mcc::impl::MccGenericMountErrorCode> : public true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
// error category
|
||||||
|
struct MccGenericMountCategory : public std::error_category {
|
||||||
|
MccGenericMountCategory() : std::error_category() {}
|
||||||
|
|
||||||
|
const char* name() const noexcept
|
||||||
|
{
|
||||||
|
return "MCC-GENERIC-MOUNT";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message(int ec) const
|
||||||
|
{
|
||||||
|
MccGenericMountErrorCode err = static_cast<MccGenericMountErrorCode>(ec);
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
case MccGenericMountErrorCode::ERROR_OK:
|
||||||
|
return "OK";
|
||||||
|
case MccGenericMountErrorCode::ERROR_HW_INIT:
|
||||||
|
return "an error occured while initializing mount hardware";
|
||||||
|
case MccGenericMountErrorCode::ERROR_HW_STOP:
|
||||||
|
return "an error occured while stopping mount";
|
||||||
|
case MccGenericMountErrorCode::ERROR_HW_GETSTATE:
|
||||||
|
return "cannot get state of hardware";
|
||||||
|
case MccGenericMountErrorCode::ERROR_SET_TARGET:
|
||||||
|
return "cannot set target coordinates";
|
||||||
|
case MccGenericMountErrorCode::ERROR_MOUNT_SLEW:
|
||||||
|
return "slewing error";
|
||||||
|
case MccGenericMountErrorCode::ERROR_MOUNT_TRACK:
|
||||||
|
return "tracking error";
|
||||||
|
case MccGenericMountErrorCode::ERROR_GET_TELEMETRY:
|
||||||
|
return "cannot get telemetry data";
|
||||||
|
case MccGenericMountErrorCode::ERROR_UNSUPPORTED_TARGET_COORDPAIR:
|
||||||
|
return "unsupported coordinate pair of target";
|
||||||
|
case MccGenericMountErrorCode::ERROR_PZONE_COMP:
|
||||||
|
return "an error occured while computing prohibited zone";
|
||||||
|
case MccGenericMountErrorCode::ERROR_TARGET_IN_ZONE:
|
||||||
|
return "target coordinates are in prohibitted zone";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const MccGenericMountCategory& get()
|
||||||
|
{
|
||||||
|
static const MccGenericMountCategory constInst;
|
||||||
|
return constInst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline std::error_code make_error_code(MccGenericMountErrorCode ec)
|
||||||
|
{
|
||||||
|
return std::error_code(static_cast<int>(ec), MccGenericMountCategory::get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_telemetry_c TELEMETRY_T,
|
||||||
|
mcc_pzone_container_c PZONE_CONT_T,
|
||||||
|
mcc_movement_controls_c MOVE_CNTRL_T,
|
||||||
|
mcc_logger_c LOGGER_T = utils::MccSpdlogLogger>
|
||||||
|
class MccGenericMount : public TELEMETRY_T, public PZONE_CONT_T, public MOVE_CNTRL_T, public LOGGER_T
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using LOGGER_T::logDebug;
|
||||||
|
using LOGGER_T::logError;
|
||||||
|
using LOGGER_T::logInfo;
|
||||||
|
using LOGGER_T::logTrace;
|
||||||
|
using LOGGER_T::logWarn;
|
||||||
|
|
||||||
|
typedef MccError error_t;
|
||||||
|
|
||||||
|
using typename TELEMETRY_T::telemetry_data_t;
|
||||||
|
|
||||||
|
enum class mount_status_t : int {
|
||||||
|
MOUNT_STATUS_ERROR,
|
||||||
|
MOUNT_STATUS_IDLE,
|
||||||
|
MOUNT_STATUS_UNINITIALIZED,
|
||||||
|
MOUNT_STATUS_INITIALIZATION,
|
||||||
|
MOUNT_STATUS_STOPPED,
|
||||||
|
MOUNT_STATUS_STOPPING,
|
||||||
|
MOUNT_STATUS_SLEWING,
|
||||||
|
MOUNT_STATUS_ADJUSTING,
|
||||||
|
MOUNT_STATUS_GUIDING,
|
||||||
|
MOUNT_STATUS_TRACKING
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename... TelemetryCtorTs,
|
||||||
|
typename... PzoneContCtorTs,
|
||||||
|
typename... MoveCntrCtorTs,
|
||||||
|
typename... LoggerCtorTs>
|
||||||
|
MccGenericMount(std::tuple<TelemetryCtorTs...> telemetry_ctor_args,
|
||||||
|
std::tuple<PzoneContCtorTs...> pzone_cont_ctor_ars,
|
||||||
|
std::tuple<MoveCntrCtorTs...> move_cntrl_ctor_ars,
|
||||||
|
std::tuple<LoggerCtorTs...> logger_ctor_args)
|
||||||
|
: TELEMETRY_T(std::make_from_tuple<TELEMETRY_T>(std::move(telemetry_ctor_args))),
|
||||||
|
PZONE_CONT_T(std::make_from_tuple<PZONE_CONT_T>(std::move(pzone_cont_ctor_ars))),
|
||||||
|
MOVE_CNTRL_T(std::make_from_tuple<MOVE_CNTRL_T>(std::move(move_cntrl_ctor_ars))),
|
||||||
|
LOGGER_T(std::make_from_tuple<LOGGER_T>(std::move(logger_ctor_args)))
|
||||||
|
{
|
||||||
|
// logDebug(std::format("Create MccGenericMount class instance (thread: {})", std::this_thread::get_id()));
|
||||||
|
logDebug("Create MccGenericMount class instance (thread: {})", std::this_thread::get_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... TelemetryCtorTs,
|
||||||
|
typename... PzoneContCtorTs,
|
||||||
|
typename... MoveCntrCtorTs,
|
||||||
|
typename... LoggerCtorTs>
|
||||||
|
requires std::derived_from<LOGGER_T, utils::MccSpdlogLogger>
|
||||||
|
MccGenericMount(std::tuple<TelemetryCtorTs...> telemetry_ctor_args,
|
||||||
|
std::tuple<PzoneContCtorTs...> pzone_cont_ctor_ars,
|
||||||
|
std::tuple<MoveCntrCtorTs...> move_cntrl_ctor_ars,
|
||||||
|
LoggerCtorTs... logger_ctor_args)
|
||||||
|
: TELEMETRY_T(std::make_from_tuple<TELEMETRY_T>(std::move(telemetry_ctor_args))),
|
||||||
|
PZONE_CONT_T(std::make_from_tuple<PZONE_CONT_T>(pzone_cont_ctor_ars)),
|
||||||
|
MOVE_CNTRL_T(std::make_from_tuple<MOVE_CNTRL_T>(move_cntrl_ctor_ars)),
|
||||||
|
mcc::utils::MccSpdlogLogger(logger_ctor_args...)
|
||||||
|
{
|
||||||
|
// logDebug(std::format("Create MccGenericMount class instance (thread: {})", std::this_thread::get_id()));
|
||||||
|
logDebug("Create MccGenericMount class instance (thread: {})", std::this_thread::get_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* movable-only class */
|
||||||
|
|
||||||
|
MccGenericMount(const MccGenericMount&) = delete;
|
||||||
|
MccGenericMount(MccGenericMount&&) = default;
|
||||||
|
|
||||||
|
MccGenericMount& operator=(const MccGenericMount&) = delete;
|
||||||
|
MccGenericMount& operator=(MccGenericMount&&) = default;
|
||||||
|
|
||||||
|
virtual ~MccGenericMount()
|
||||||
|
{
|
||||||
|
// auto err = MOVE_CNTRL_T::stopMount();
|
||||||
|
// if (err) {
|
||||||
|
// logError(formatError(err));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// WARNING: it is assumed here that mount stopping is performed in a derived class or, it is more logicaly,
|
||||||
|
// in MOVE_CNTRL_T-class
|
||||||
|
|
||||||
|
// logDebug(std::format("Delete MccGenericMount class instance (thread: {})", std::this_thread::get_id()));
|
||||||
|
logDebug("Delete MccGenericMount class instance (thread: {})", std::this_thread::get_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
error_t initMount()
|
||||||
|
{
|
||||||
|
logInfo("Start MccGenericMount class initialization (thread: {}) ...", std::this_thread::get_id());
|
||||||
|
|
||||||
|
*_mountStatus = mount_status_t::MOUNT_STATUS_IDLE;
|
||||||
|
|
||||||
|
return *_lastMountError = MccGenericMountErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
mount_status_t mountStatus() const
|
||||||
|
{
|
||||||
|
return _mountStatus->load();
|
||||||
|
}
|
||||||
|
|
||||||
|
error_t mountLastError() const
|
||||||
|
{
|
||||||
|
return _lastMountError->load();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* log-method wrappers for non-MccSpdlogger classes */
|
||||||
|
|
||||||
|
template <std::formattable<char>... ArgTs>
|
||||||
|
requires(!std::derived_from<LOGGER_T, utils::MccSpdlogLogger>)
|
||||||
|
void logInfo(std::format_string<ArgTs...> fmt, ArgTs&&... args)
|
||||||
|
{
|
||||||
|
LOGGER_T::logInfo(std::format(fmt, std::forward<ArgTs>(args)...));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::formattable<char>... ArgTs>
|
||||||
|
requires(!std::derived_from<LOGGER_T, utils::MccSpdlogLogger>)
|
||||||
|
void logDebug(std::format_string<ArgTs...> fmt, ArgTs&&... args)
|
||||||
|
{
|
||||||
|
LOGGER_T::logDebug(std::format(fmt, std::forward<ArgTs>(args)...));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::formattable<char>... ArgTs>
|
||||||
|
requires(!std::derived_from<LOGGER_T, utils::MccSpdlogLogger>)
|
||||||
|
void logError(std::format_string<ArgTs...> fmt, ArgTs&&... args)
|
||||||
|
{
|
||||||
|
LOGGER_T::logError(std::format(fmt, std::forward<ArgTs>(args)...));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::formattable<char>... ArgTs>
|
||||||
|
requires(!std::derived_from<LOGGER_T, utils::MccSpdlogLogger>)
|
||||||
|
void logWarn(std::format_string<ArgTs...> fmt, ArgTs&&... args)
|
||||||
|
{
|
||||||
|
LOGGER_T::logWarn(std::format(fmt, std::forward<ArgTs>(args)...));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::formattable<char>... ArgTs>
|
||||||
|
requires(!std::derived_from<LOGGER_T, utils::MccSpdlogLogger>)
|
||||||
|
void logTrace(std::format_string<ArgTs...> fmt, ArgTs&&... args)
|
||||||
|
{
|
||||||
|
LOGGER_T::logTrace(std::format(fmt, std::forward<ArgTs>(args)...));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::unique_ptr<std::atomic<mount_status_t>> _mountStatus{
|
||||||
|
new std::atomic<mount_status_t>{mount_status_t::MOUNT_STATUS_UNINITIALIZED}};
|
||||||
|
|
||||||
|
std::unique_ptr<std::atomic<error_t>> _lastMountError{new std::atomic<error_t>{MccGenericMountErrorCode::ERROR_OK}};
|
||||||
|
|
||||||
|
std::string formatError(error_t const& err, std::string_view prefix = "") const
|
||||||
|
{
|
||||||
|
return std::format("{}{} (category: {}, code: {})", prefix, err.message(), err.category().name(), err.value());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
720
include/mcc/mcc_generic_movecontrols.h
Normal file
720
include/mcc/mcc_generic_movecontrols.h
Normal file
@@ -0,0 +1,720 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
* *
|
||||||
|
* MOUNT CONTROL COMPONENTS LIBRARY *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* GENERIC IMPLEMENTATION OF MOUNT MOVEMENT CONTROLS *
|
||||||
|
* *
|
||||||
|
****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <fstream>
|
||||||
|
#include <future>
|
||||||
|
#include <thread>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
|
||||||
|
#include <print>
|
||||||
|
|
||||||
|
#include "mcc_coordinate.h"
|
||||||
|
#include "mcc_error.h"
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
// mount movement-related generic errors
|
||||||
|
enum class MccGenericMovementControlsErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_IN_PZONE,
|
||||||
|
ERROR_NEAR_PZONE,
|
||||||
|
ERROR_SLEW_TIMEOUT,
|
||||||
|
ERROR_STOP_TIMEOUT,
|
||||||
|
ERROR_HARDWARE,
|
||||||
|
ERROR_TELEMETRY_TIMEOUT
|
||||||
|
};
|
||||||
|
} // namespace mcc::impl
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
template <>
|
||||||
|
class is_error_code_enum<mcc::impl::MccGenericMovementControlsErrorCode> : public true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
// error category
|
||||||
|
struct MccGenericMovementControlsErrorCategory : std::error_category {
|
||||||
|
const char* name() const noexcept
|
||||||
|
{
|
||||||
|
return "MCC-GENERIC-MOVECONTRL";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message(int ec) const
|
||||||
|
{
|
||||||
|
MccGenericMovementControlsErrorCode err = static_cast<MccGenericMovementControlsErrorCode>(ec);
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
case MccGenericMovementControlsErrorCode::ERROR_OK:
|
||||||
|
return "OK";
|
||||||
|
case MccGenericMovementControlsErrorCode::ERROR_IN_PZONE:
|
||||||
|
return "target is in zone";
|
||||||
|
case MccGenericMovementControlsErrorCode::ERROR_NEAR_PZONE:
|
||||||
|
return "mount is near zone";
|
||||||
|
case MccGenericMovementControlsErrorCode::ERROR_SLEW_TIMEOUT:
|
||||||
|
return "a timeout occured while slewing";
|
||||||
|
case MccGenericMovementControlsErrorCode::ERROR_STOP_TIMEOUT:
|
||||||
|
return "a timeout occured while mount stopping";
|
||||||
|
case MccGenericMovementControlsErrorCode::ERROR_HARDWARE:
|
||||||
|
return "a hardware error occured";
|
||||||
|
case MccGenericMovementControlsErrorCode::ERROR_TELEMETRY_TIMEOUT:
|
||||||
|
return "telemetry data timeout";
|
||||||
|
default:
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const MccGenericMovementControlsErrorCategory& get()
|
||||||
|
{
|
||||||
|
static const MccGenericMovementControlsErrorCategory constInst;
|
||||||
|
return constInst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline std::error_code make_error_code(MccGenericMovementControlsErrorCode ec)
|
||||||
|
{
|
||||||
|
return std::error_code(static_cast<int>(ec), MccGenericMovementControlsErrorCategory::get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct MccGenericMovementControlsParams {
|
||||||
|
// timeout to telemetry updating
|
||||||
|
std::chrono::milliseconds telemetryTimeout{3000};
|
||||||
|
|
||||||
|
// braking acceleration after execution of mount stopping command (in rads/s^2)
|
||||||
|
// it must be given as non-negative value!!!
|
||||||
|
double brakingAccelX{0.0};
|
||||||
|
double brakingAccelY{0.0};
|
||||||
|
|
||||||
|
// ******* slewing mode *******
|
||||||
|
|
||||||
|
// coordinates difference to stop slewing (in radians)
|
||||||
|
double slewToleranceRadius{5.0_arcsecs};
|
||||||
|
|
||||||
|
// slewing trajectory file. if empty - just skip saving
|
||||||
|
std::string slewingPathFilename{};
|
||||||
|
|
||||||
|
|
||||||
|
// ******* tracking mode *******
|
||||||
|
|
||||||
|
// maximal target-to-mount difference for tracking process (in arcsecs)
|
||||||
|
// it it is greater then the current mount coordinates are used as target one
|
||||||
|
double trackingMaxCoordDiff{20.0};
|
||||||
|
|
||||||
|
// tracking trajectory file. if empty - just skip saving
|
||||||
|
std::string trackingPathFilename{};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* UTILITY CLASS TO HOLD AND SAVE MOUNT MOVING TRAJECTORY */
|
||||||
|
|
||||||
|
struct MccMovementPathFile {
|
||||||
|
static constexpr std::string_view commentSeq{"# "};
|
||||||
|
static constexpr std::string_view lineDelim{"\n"};
|
||||||
|
|
||||||
|
void setCommentSeq(traits::mcc_input_char_range auto const& s)
|
||||||
|
{
|
||||||
|
_commentSeq.clear();
|
||||||
|
std::ranges::copy(s, std::back_inserter(_commentSeq));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLineDelim(traits::mcc_input_char_range auto const& s)
|
||||||
|
{
|
||||||
|
_lineDelim.clear();
|
||||||
|
std::ranges::copy(s, std::back_inserter(_lineDelim));
|
||||||
|
}
|
||||||
|
|
||||||
|
// add comment string/strings
|
||||||
|
template <traits::mcc_input_char_range RT, traits::mcc_input_char_range... RTs>
|
||||||
|
void addComment(RT const& r, RTs const&... rs)
|
||||||
|
{
|
||||||
|
std::ranges::copy(_commentSeq, std::back_inserter(_buffer));
|
||||||
|
if constexpr (std::is_pointer_v<std::decay_t<RT>>) { // const char*, char*, char[]
|
||||||
|
std::ranges::copy(std::string_view{r}, std::back_inserter(_buffer));
|
||||||
|
} else {
|
||||||
|
std::ranges::copy(r, std::back_inserter(_buffer));
|
||||||
|
}
|
||||||
|
std::ranges::copy(lineDelim, std::back_inserter(_buffer));
|
||||||
|
|
||||||
|
if constexpr (sizeof...(RTs)) {
|
||||||
|
addComment(rs...);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// comment corresponded to addToPath(mcc_telemetry_data_c auto const& tdata)
|
||||||
|
void addDefaultComment()
|
||||||
|
{
|
||||||
|
addComment("Format (time is in milliseconds, coordinates are in degrees, speeds are in degrees/s):");
|
||||||
|
addComment(
|
||||||
|
" <UNIXTIME> <mount X> <mount Y> <target X> <target Y> <dX_{mount-target}> "
|
||||||
|
"<dY_{mount-target}> <mount-to-target-distance> <mount X-speed> <mount Y-speed> <moving state>");
|
||||||
|
}
|
||||||
|
|
||||||
|
// general purpose method
|
||||||
|
// template <std::formattable<char>... ArgTs>
|
||||||
|
// void addToPath(std::format_string<ArgTs...> fmt, ArgTs&&... args)
|
||||||
|
// {
|
||||||
|
// std::format_to(std::back_inserter(_buffer), fmt, std::forward<ArgTs>(args)...);
|
||||||
|
// std::ranges::copy(lineDelim, std::back_inserter(_buffer));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// general purpose method
|
||||||
|
template <std::formattable<char>... ArgTs>
|
||||||
|
void addToPath(std::string_view fmt, ArgTs&&... args)
|
||||||
|
{
|
||||||
|
std::vformat_to(std::back_inserter(_buffer), fmt, std::make_format_args(args...));
|
||||||
|
std::ranges::copy(lineDelim, std::back_inserter(_buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
// default-implemented method
|
||||||
|
void addToPath(mcc_telemetry_data_c auto const& tdata)
|
||||||
|
{
|
||||||
|
// UNIX-time millisecs, mount X, mount Y, target X, target Y, dX(mount-target), dY(mount-target), dist, speedX,
|
||||||
|
// speedY, state
|
||||||
|
auto dist = tdata.mountPos.distance(tdata.targetPos);
|
||||||
|
|
||||||
|
using d_t = std::chrono::milliseconds;
|
||||||
|
|
||||||
|
auto tp = std::chrono::duration_cast<d_t>(tdata.mountPos.epoch().UTC().time_since_epoch());
|
||||||
|
|
||||||
|
const std::string_view d_fmt = "{:14.8f}";
|
||||||
|
const auto v = std::views::repeat(d_fmt, 9) | std::views::join_with(' ');
|
||||||
|
std::string fmt = "{} " + std::string(v.begin(), v.end()) + " {}";
|
||||||
|
|
||||||
|
|
||||||
|
int state = (int)tdata.hwState.movementState;
|
||||||
|
auto tp_val = tp.count();
|
||||||
|
|
||||||
|
double mnt_x = MccAngle(tdata.mountPos.co_lon()).degrees(), mnt_y = MccAngle(tdata.mountPos.co_lon()).degrees(),
|
||||||
|
tag_x = dist.x2.degrees(), tag_y = dist.y2.degrees(), dx = dist.dx.degrees(), dy = dist.dy.degrees(),
|
||||||
|
dd = dist.dist.degrees();
|
||||||
|
|
||||||
|
addToPath(std::string_view(fmt.begin(), fmt.end()), tp_val, mnt_x, mnt_y, tag_x, tag_y, dx, dy, dd,
|
||||||
|
tdata.hwState.speedXY.x().degrees(), tdata.hwState.speedXY.y().degrees(), state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearPath()
|
||||||
|
{
|
||||||
|
_buffer.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool saveToFile(std::string const& filename, std::ios_base::openmode mode = std::ios::out | std::ios::trunc)
|
||||||
|
{
|
||||||
|
if (filename.empty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ofstream fst(filename, mode);
|
||||||
|
|
||||||
|
if (fst.is_open()) {
|
||||||
|
fst << _buffer;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::string _buffer{};
|
||||||
|
|
||||||
|
std::string _commentSeq{commentSeq};
|
||||||
|
std::string _lineDelim{lineDelim};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum class MccGenericMovementControlsPolicy : int { POLICY_ASYNC, POLICY_BLOCKING };
|
||||||
|
|
||||||
|
template <std::movable PARAMS_T,
|
||||||
|
MccGenericMovementControlsPolicy EXEC_POLICY = MccGenericMovementControlsPolicy::POLICY_ASYNC>
|
||||||
|
class MccGenericMovementControls
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr MccGenericMovementControlsPolicy executePolicy = EXEC_POLICY;
|
||||||
|
|
||||||
|
static constexpr std::chrono::seconds defaultWaitTimeout{3};
|
||||||
|
|
||||||
|
typedef MccError error_t;
|
||||||
|
|
||||||
|
typedef PARAMS_T movement_params_t;
|
||||||
|
|
||||||
|
template <std::invocable<bool> SLEW_FUNC_T, std::invocable<> TRACK_FUNC_T, std::invocable<> STOP_FUNC_T>
|
||||||
|
MccGenericMovementControls(SLEW_FUNC_T&& slew_func, TRACK_FUNC_T&& track_func, STOP_FUNC_T&& stop_func)
|
||||||
|
: _slewFunc(std::forward<SLEW_FUNC_T>(slew_func)),
|
||||||
|
_trackFunc(std::forward<TRACK_FUNC_T>(track_func)),
|
||||||
|
_stopFunc(std::forward<STOP_FUNC_T>(stop_func))
|
||||||
|
{
|
||||||
|
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
|
||||||
|
// *_stopMovementRequest = false;
|
||||||
|
|
||||||
|
// *_fsmState = STATE_IDLE;
|
||||||
|
|
||||||
|
// // start thread of movements
|
||||||
|
// _fstFuture = std::async(
|
||||||
|
// [this](std::stop_token stoken) {
|
||||||
|
// auto do_state = _fsmState->load();
|
||||||
|
|
||||||
|
// while (!stoken.stop_requested()) {
|
||||||
|
// std::println("\n{:*^80}\n", " WAIT LOCK ");
|
||||||
|
// // wait here ...
|
||||||
|
// _wakeupRequest->wait(false, std::memory_order_relaxed);
|
||||||
|
|
||||||
|
// _wakeupRequest->clear();
|
||||||
|
|
||||||
|
// std::println("\n{:*^80}\n", " UNLOCKED ");
|
||||||
|
|
||||||
|
// // if (stoken.stop_requested()) {
|
||||||
|
// // break;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// do_state = _fsmState->load();
|
||||||
|
|
||||||
|
// if (do_state & STATE_STOP) {
|
||||||
|
// // if (_fsmState->load() & STATE_STOP) {
|
||||||
|
// *_stopMovementRequest = true;
|
||||||
|
// _stopFunc();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (do_state & STATE_SLEW) {
|
||||||
|
// // if (_fsmState->load() & STATE_SLEW) {
|
||||||
|
// *_stopMovementRequest = false;
|
||||||
|
// _slewFunc(_slewAndStop->load());
|
||||||
|
// } else if (do_state & STATE_TRACK) {
|
||||||
|
// // } else if (_fsmState->load() & STATE_TRACK) {
|
||||||
|
// *_stopMovementRequest = false;
|
||||||
|
// _trackFunc();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// _fstStopSource.get_token());
|
||||||
|
|
||||||
|
startAsyncMovementCycle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MccGenericMovementControls(const MccGenericMovementControls&) = delete;
|
||||||
|
MccGenericMovementControls(MccGenericMovementControls&& other) = default;
|
||||||
|
|
||||||
|
MccGenericMovementControls& operator=(const MccGenericMovementControls&) = delete;
|
||||||
|
MccGenericMovementControls& operator=(MccGenericMovementControls&&) = default;
|
||||||
|
|
||||||
|
virtual ~MccGenericMovementControls()
|
||||||
|
{
|
||||||
|
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
|
||||||
|
// *_fsmState = STATE_IDLE;
|
||||||
|
// _fstStopSource.request_stop();
|
||||||
|
|
||||||
|
// _wakeupRequest->test_and_set();
|
||||||
|
// _wakeupRequest->notify_one();
|
||||||
|
|
||||||
|
// std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
|
|
||||||
|
// if (_fstFuture.valid()) {
|
||||||
|
// auto status = _fstFuture.wait_for(_waitTimeout->load());
|
||||||
|
// }
|
||||||
|
|
||||||
|
stopAsyncMovementCycle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename SelfT>
|
||||||
|
void stopAsyncMovementCycle(this SelfT&& self)
|
||||||
|
requires(EXEC_POLICY == MccGenericMovementControlsPolicy::POLICY_ASYNC)
|
||||||
|
{
|
||||||
|
*self._fsmState = STATE_IDLE;
|
||||||
|
self._fstStopSource.request_stop();
|
||||||
|
|
||||||
|
self._wakeupRequest->test_and_set();
|
||||||
|
self._wakeupRequest->notify_all();
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
|
|
||||||
|
if (self._fstFuture.valid()) {
|
||||||
|
auto status = self._fstFuture.wait_for(self._waitTimeout->load());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename SelfT>
|
||||||
|
void startAsyncMovementCycle(this SelfT& self)
|
||||||
|
requires(EXEC_POLICY == MccGenericMovementControlsPolicy::POLICY_ASYNC)
|
||||||
|
{
|
||||||
|
using self_t = std::decay_t<SelfT>;
|
||||||
|
|
||||||
|
if (self._fstFuture.valid()) {
|
||||||
|
self.stopAsyncMovementCycle();
|
||||||
|
}
|
||||||
|
|
||||||
|
*self._stopMovementRequest = false;
|
||||||
|
|
||||||
|
self._fstStopSource = std::stop_source{};
|
||||||
|
|
||||||
|
*self._fsmState = STATE_IDLE;
|
||||||
|
|
||||||
|
// start thread of movements
|
||||||
|
self._fstFuture = std::async(
|
||||||
|
std::launch::async,
|
||||||
|
[&self](std::stop_token stoken) mutable {
|
||||||
|
auto do_state = self._fsmState->load();
|
||||||
|
|
||||||
|
std::string log_str;
|
||||||
|
while (!stoken.stop_requested()) {
|
||||||
|
log_str = std::format("\n{:*^80}\n", " WAIT LOCK ");
|
||||||
|
if constexpr (mcc_generic_mount_c<self_t>) {
|
||||||
|
self.logTrace(log_str);
|
||||||
|
} else {
|
||||||
|
std::println("{}", log_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait here ...
|
||||||
|
self._wakeupRequest->wait(false, std::memory_order_relaxed);
|
||||||
|
|
||||||
|
self._wakeupRequest->clear();
|
||||||
|
|
||||||
|
|
||||||
|
// if (stoken.stop_requested()) {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
do_state = self._fsmState->load();
|
||||||
|
|
||||||
|
log_str = std::format(" UNLOCKED WITH STATE (STOP = {} SLEW = {} TRACK = {}) ",
|
||||||
|
do_state & STATE_STOP, do_state & STATE_SLEW, do_state & STATE_TRACK);
|
||||||
|
|
||||||
|
log_str = std::format("\n{:*^80}\n", log_str);
|
||||||
|
if constexpr (mcc_generic_mount_c<self_t>) {
|
||||||
|
self.logTrace(log_str);
|
||||||
|
} else {
|
||||||
|
std::println("{}", log_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (do_state & STATE_STOP) {
|
||||||
|
// if (_fsmState->load() & STATE_STOP) {
|
||||||
|
*self._stopMovementRequest = true;
|
||||||
|
self._stopFunc();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (do_state & STATE_SLEW) {
|
||||||
|
// if (_fsmState->load() & STATE_SLEW) {
|
||||||
|
*self._stopMovementRequest = false;
|
||||||
|
self._slewFunc(self._slewAndStop->load());
|
||||||
|
} else if (do_state & STATE_TRACK) {
|
||||||
|
// } else if (_fsmState->load() & STATE_TRACK) {
|
||||||
|
*self._stopMovementRequest = false;
|
||||||
|
self._trackFunc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
self._fstStopSource.get_token());
|
||||||
|
}
|
||||||
|
|
||||||
|
error_t slewToTarget(bool slew_and_stop)
|
||||||
|
{
|
||||||
|
// *_stopMovementRequest = false;
|
||||||
|
|
||||||
|
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
|
||||||
|
auto prev_state = _fsmState->load();
|
||||||
|
|
||||||
|
*_fsmState = STATE_SLEW;
|
||||||
|
|
||||||
|
if (prev_state & STATE_SLEW || prev_state & STATE_TRACK) {
|
||||||
|
*_fsmState |= STATE_STOP;
|
||||||
|
|
||||||
|
*_stopMovementRequest = true; // to exit from slewing or tracking
|
||||||
|
}
|
||||||
|
|
||||||
|
*_slewAndStop = slew_and_stop;
|
||||||
|
|
||||||
|
_wakeupRequest->test_and_set();
|
||||||
|
_wakeupRequest->notify_one();
|
||||||
|
|
||||||
|
return MccGenericMovementControlsErrorCode::ERROR_OK;
|
||||||
|
} else if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_BLOCKING) {
|
||||||
|
return _slewFunc(slew_and_stop);
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNKNOWN EXECUTION POLICY!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error_t trackTarget()
|
||||||
|
{
|
||||||
|
// *_stopMovementRequest = false;
|
||||||
|
|
||||||
|
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
|
||||||
|
auto prev_state = _fsmState->load();
|
||||||
|
|
||||||
|
if (!(prev_state & STATE_TRACK)) {
|
||||||
|
*_fsmState = STATE_TRACK;
|
||||||
|
|
||||||
|
if (prev_state & STATE_SLEW) {
|
||||||
|
*_fsmState |= STATE_STOP;
|
||||||
|
|
||||||
|
*_stopMovementRequest = true; // to exit from slewing
|
||||||
|
}
|
||||||
|
|
||||||
|
_wakeupRequest->test_and_set();
|
||||||
|
_wakeupRequest->notify_one();
|
||||||
|
} // already tracking, just ignore
|
||||||
|
|
||||||
|
return MccGenericMovementControlsErrorCode::ERROR_OK;
|
||||||
|
} else if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_BLOCKING) {
|
||||||
|
return _trackFunc();
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNKNOWN EXECUTION POLICY!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error_t stopMount()
|
||||||
|
{
|
||||||
|
// *_stopMovementRequest = true;
|
||||||
|
|
||||||
|
if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC) {
|
||||||
|
*_fsmState = STATE_STOP;
|
||||||
|
|
||||||
|
*_stopMovementRequest = true; // to exit from slewing or tracking
|
||||||
|
|
||||||
|
_wakeupRequest->test_and_set();
|
||||||
|
_wakeupRequest->notify_one();
|
||||||
|
|
||||||
|
return MccGenericMovementControlsErrorCode::ERROR_OK;
|
||||||
|
} else if constexpr (executePolicy == MccGenericMovementControlsPolicy::POLICY_BLOCKING) {
|
||||||
|
return _stopFunc();
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNKNOWN EXECUTION POLICY!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error_t setMovementParams(movement_params_t const& pars)
|
||||||
|
{
|
||||||
|
std::lock_guard lock{*_currentMovementParamsMutex};
|
||||||
|
|
||||||
|
_currentMovementParams = pars;
|
||||||
|
|
||||||
|
return MccGenericMovementControlsErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
movement_params_t getMovementParams() const
|
||||||
|
{
|
||||||
|
std::lock_guard lock{*_currentMovementParamsMutex};
|
||||||
|
|
||||||
|
return _currentMovementParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::unique_ptr<std::mutex> _currentMovementParamsMutex{new std::mutex{}};
|
||||||
|
PARAMS_T _currentMovementParams{};
|
||||||
|
|
||||||
|
std::unique_ptr<std::atomic_bool> _stopMovementRequest{new std::atomic_bool{false}};
|
||||||
|
|
||||||
|
std::function<error_t(bool)> _slewFunc{};
|
||||||
|
std::function<error_t()> _trackFunc{};
|
||||||
|
std::function<error_t()> _stopFunc{};
|
||||||
|
|
||||||
|
std::unique_ptr<std::atomic<std::chrono::nanoseconds>> _waitTimeout{
|
||||||
|
new std::atomic<std::chrono::nanoseconds>{defaultWaitTimeout}};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::conditional_t<executePolicy == MccGenericMovementControlsPolicy::POLICY_ASYNC,
|
||||||
|
std::future<void>,
|
||||||
|
std::nullptr_t>
|
||||||
|
_fstFuture{};
|
||||||
|
|
||||||
|
std::stop_source _fstStopSource{};
|
||||||
|
|
||||||
|
std::unique_ptr<std::atomic_flag> _wakeupRequest{new std::atomic_flag};
|
||||||
|
std::unique_ptr<std::atomic_bool> _slewAndStop{new std::atomic_bool{false}};
|
||||||
|
|
||||||
|
enum { STATE_IDLE = 0x00, STATE_SLEW = 0x01, STATE_TRACK = 0x02, STATE_STOP = 0x04 };
|
||||||
|
|
||||||
|
std::unique_ptr<std::atomic_int> _fsmState{new std::atomic_int};
|
||||||
|
|
||||||
|
|
||||||
|
// template <typename SelfT>
|
||||||
|
// void mainCycle(this SelfT&& self, std::stop_token stoken)
|
||||||
|
// {
|
||||||
|
// using self_t = std::decay_t<SelfT>;
|
||||||
|
|
||||||
|
// auto do_state = _fsmState->load();
|
||||||
|
|
||||||
|
// std::string log_str;
|
||||||
|
|
||||||
|
// while (!stoken.stop_requested()) {
|
||||||
|
// log_str = std::format("\n{:*^80}\n", " WAIT LOCK ");
|
||||||
|
// if constexpr (mcc_generic_mount_c<self_t>) {
|
||||||
|
// self.logTrace(log_str);
|
||||||
|
// } else {
|
||||||
|
// std::println(log_str);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // wait here ...
|
||||||
|
// _wakeupRequest->wait(false, std::memory_order_relaxed);
|
||||||
|
|
||||||
|
// _wakeupRequest->clear();
|
||||||
|
|
||||||
|
// log_str = std::format("\n{:*^80}\n", " UNLOCKED ");
|
||||||
|
// if constexpr (mcc_generic_mount_c<self_t>) {
|
||||||
|
// self.logTrace(log_str);
|
||||||
|
// } else {
|
||||||
|
// std::println(log_str);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // if (stoken.stop_requested()) {
|
||||||
|
// // break;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// do_state = _fsmState->load();
|
||||||
|
|
||||||
|
// if (do_state & STATE_STOP) {
|
||||||
|
// // if (_fsmState->load() & STATE_STOP) {
|
||||||
|
// *_stopMovementRequest = true;
|
||||||
|
// _stopFunc();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (do_state & STATE_SLEW) {
|
||||||
|
// // if (_fsmState->load() & STATE_SLEW) {
|
||||||
|
// *_stopMovementRequest = false;
|
||||||
|
// _slewFunc(_slewAndStop->load());
|
||||||
|
// } else if (do_state & STATE_TRACK) {
|
||||||
|
// // } else if (_fsmState->load() & STATE_TRACK) {
|
||||||
|
// *_stopMovementRequest = false;
|
||||||
|
// _trackFunc();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// utility methods
|
||||||
|
|
||||||
|
// the method calculates the change in coordinates of a point over a given time given the current speed and braking
|
||||||
|
// acceleration. a position after given 'time' interval is returned
|
||||||
|
auto coordsAfterTime(mcc_coord_pair_c auto const& cp,
|
||||||
|
mcc_coord_pair_c auto const& speedXY, // in radians per seconds
|
||||||
|
mcc_coord_pair_c auto const& braking_accelXY, // in radians per seconds in square
|
||||||
|
traits::mcc_time_duration_c auto const& time,
|
||||||
|
mcc_coord_pair_c auto* dxy = nullptr)
|
||||||
|
{
|
||||||
|
// time to stop mount with given current speed and constant braking acceleration
|
||||||
|
double tx_stop = std::abs(speedXY.x()) / braking_accelXY.x();
|
||||||
|
double ty_stop = std::abs(speedXY.y()) / braking_accelXY.y();
|
||||||
|
|
||||||
|
using secs_t = std::chrono::duration<double>; // seconds as double
|
||||||
|
|
||||||
|
double tx = std::chrono::duration_cast<secs_t>(time).count();
|
||||||
|
double ty = std::chrono::duration_cast<secs_t>(time).count();
|
||||||
|
|
||||||
|
if (std::isfinite(tx_stop) && (tx > tx_stop)) {
|
||||||
|
tx = tx_stop;
|
||||||
|
}
|
||||||
|
if (std::isfinite(ty_stop) && (ty > ty_stop)) {
|
||||||
|
ty = ty_stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the distance:
|
||||||
|
// here, one must take into account the sign of the speed!!!
|
||||||
|
double dx = speedXY.x() * tx - std::copysign(braking_accelXY.x(), speedXY.x()) * tx * tx / 2.0;
|
||||||
|
double dy = speedXY.y() * ty - std::copysign(braking_accelXY.y(), speedXY.y()) * ty * ty / 2.0;
|
||||||
|
|
||||||
|
std::remove_cvref_t<decltype(cp)> cp_res{};
|
||||||
|
cp_res.setEpoch(cp.epoch() + time);
|
||||||
|
|
||||||
|
cp_res.setX((double)cp.x() + dx);
|
||||||
|
cp_res.setY((double)cp.y() + dy);
|
||||||
|
|
||||||
|
if (dxy) {
|
||||||
|
dxy->setX(dx);
|
||||||
|
dxy->setY(dy);
|
||||||
|
dxy->setEpoch(cp_res.epoch());
|
||||||
|
}
|
||||||
|
|
||||||
|
return cp_res;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto coordsAfterTime(mcc_skypoint_c auto const& sp,
|
||||||
|
mcc_coord_pair_c auto const& speedXY, // in radians per seconds
|
||||||
|
mcc_coord_pair_c auto const& braking_accelXY, // in radians per seconds in square
|
||||||
|
traits::mcc_time_duration_c auto const& time,
|
||||||
|
mcc_coord_pair_c auto* dxy = nullptr)
|
||||||
|
{
|
||||||
|
auto run_func = [&, this](auto& cp) {
|
||||||
|
sp.toAtSameEpoch(cp);
|
||||||
|
|
||||||
|
auto new_cp = coordsAfterTime(cp, speedXY, braking_accelXY, time, dxy);
|
||||||
|
|
||||||
|
std::remove_cvref_t<decltype(sp)> sp_res{};
|
||||||
|
|
||||||
|
sp_res.from(cp);
|
||||||
|
|
||||||
|
return sp_res;
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (sp.pairKind()) {
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_ICRS: {
|
||||||
|
MccSkyRADEC_ICRS rd;
|
||||||
|
return run_func(rd);
|
||||||
|
};
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_OBS: {
|
||||||
|
MccSkyRADEC_OBS rd;
|
||||||
|
return run_func(rd);
|
||||||
|
};
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_APP: {
|
||||||
|
MccSkyRADEC_APP rd;
|
||||||
|
return run_func(rd);
|
||||||
|
};
|
||||||
|
case MccCoordPairKind::COORDS_KIND_HADEC_OBS: {
|
||||||
|
MccSkyHADEC_OBS hd;
|
||||||
|
return run_func(hd);
|
||||||
|
};
|
||||||
|
case MccCoordPairKind::COORDS_KIND_HADEC_APP: {
|
||||||
|
MccSkyHADEC_APP hd;
|
||||||
|
return run_func(hd);
|
||||||
|
};
|
||||||
|
case MccCoordPairKind::COORDS_KIND_AZZD: {
|
||||||
|
MccSkyAZZD azzd;
|
||||||
|
return run_func(azzd);
|
||||||
|
};
|
||||||
|
case MccCoordPairKind::COORDS_KIND_AZALT: {
|
||||||
|
MccSkyAZALT azalt;
|
||||||
|
return run_func(azalt);
|
||||||
|
};
|
||||||
|
case MccCoordPairKind::COORDS_KIND_GENERIC:
|
||||||
|
case MccCoordPairKind::COORDS_KIND_XY: {
|
||||||
|
MccGenXY xy;
|
||||||
|
return run_func(xy);
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return sp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <std::default_initializable PARAMS_T>
|
||||||
|
using MccGenericBlockingMovementControls =
|
||||||
|
MccGenericMovementControls<PARAMS_T, MccGenericMovementControlsPolicy::POLICY_BLOCKING>;
|
||||||
|
|
||||||
|
template <std::default_initializable PARAMS_T>
|
||||||
|
using MccGenericAsyncMovementControls =
|
||||||
|
MccGenericMovementControls<PARAMS_T, MccGenericMovementControlsPolicy::POLICY_ASYNC>;
|
||||||
|
|
||||||
|
|
||||||
|
static_assert(mcc_movement_controls_c<MccGenericAsyncMovementControls<MccGenericMovementControlsParams>>, "!!!");
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
615
include/mcc/mcc_keyvalue.h
Normal file
615
include/mcc/mcc_keyvalue.h
Normal file
@@ -0,0 +1,615 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
* *
|
||||||
|
* MOUNT CONTROL COMPONENTS LIBRARY *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* IMPLEMENTATION OF KEY-VALUE PAIRS HOLDER *
|
||||||
|
* *
|
||||||
|
****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
|
#include "mcc_deserializer.h"
|
||||||
|
#include "mcc_serializer.h"
|
||||||
|
#include "mcc_utils.h"
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class MccKeyValueHolderErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_INVALID_KEY,
|
||||||
|
ERROR_INCOMPATIBLE_TYPE,
|
||||||
|
ERROR_DESERIAL,
|
||||||
|
ERROR_SERIAL
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
|
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class is_error_code_enum<mcc::impl::MccKeyValueHolderErrorCode> : public true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
// error category
|
||||||
|
struct MccKeyValueHolderCategory : public std::error_category {
|
||||||
|
MccKeyValueHolderCategory() : std::error_category() {}
|
||||||
|
|
||||||
|
const char* name() const noexcept override
|
||||||
|
{
|
||||||
|
return "MCC-KEYVALUEHOLDER-ERR-CATEGORY";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message(int ec) const override
|
||||||
|
{
|
||||||
|
MccKeyValueHolderErrorCode err = static_cast<MccKeyValueHolderErrorCode>(ec);
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
case MccKeyValueHolderErrorCode::ERROR_OK:
|
||||||
|
return "OK";
|
||||||
|
case MccKeyValueHolderErrorCode::ERROR_INVALID_KEY:
|
||||||
|
return "invalid key value";
|
||||||
|
case MccKeyValueHolderErrorCode::ERROR_INCOMPATIBLE_TYPE:
|
||||||
|
return "incompatible type";
|
||||||
|
case MccKeyValueHolderErrorCode::ERROR_DESERIAL:
|
||||||
|
return "deserialization error";
|
||||||
|
case MccKeyValueHolderErrorCode::ERROR_SERIAL:
|
||||||
|
return "serialization error";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const MccKeyValueHolderCategory& get()
|
||||||
|
{
|
||||||
|
static const MccKeyValueHolderCategory constInst;
|
||||||
|
return constInst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline std::error_code make_error_code(MccKeyValueHolderErrorCode ec)
|
||||||
|
{
|
||||||
|
return std::error_code(static_cast<int>(ec), MccKeyValueHolderCategory::get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// to follow std::variant requirements (not references, not array, not void)
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_record_value_c = requires { !std::is_array_v<T> && !std::is_void_v<T> && !std::is_reference_v<T>; };
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_keyvalue_record_c = requires(T t) {
|
||||||
|
requires std::same_as<decltype(t.key), const std::string_view>; // key name is immutable!!!
|
||||||
|
requires mcc_record_value_c<decltype(t.value)>; // value is mutable
|
||||||
|
requires mcc_record_value_c<decltype(t.default_value)>; // default value is mutable
|
||||||
|
requires mcc_serialization_params_c<decltype(t.serial_pars)>; // serialization parameters
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// must be a std::tuple of mcc_keyvalue_record_c
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_keyvalue_desc_c = requires(T t) { []<mcc_keyvalue_record_c... Ts>(std::tuple<Ts...>) {}(t); };
|
||||||
|
|
||||||
|
|
||||||
|
// use of 'inline' here to avoid '-Wsubobject-linkage' GCC-warning
|
||||||
|
inline constexpr char MCC_KV_COMMENT_SEQ_ARR[] = "#";
|
||||||
|
inline constexpr char MCC_KV_KEY_VALUE_DELIM_SEQ_ARR[] = "=";
|
||||||
|
inline constexpr char MCC_KV_COMPOSITE_VALUE_DELIM_SEQ_ARR[] = ",";
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_keyvalue_desc_c DESCR_T,
|
||||||
|
const char* COMM_SEQ = MCC_KV_COMMENT_SEQ_ARR, // comment char sequence
|
||||||
|
const char* KV_DELIM = MCC_KV_KEY_VALUE_DELIM_SEQ_ARR // key-value delimiter
|
||||||
|
>
|
||||||
|
class MccKeyValueHolder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum OutputPolicy {
|
||||||
|
OPOLICY_CHANGED_ONLY, // serialize only changed and previously deserialized (by fromCharRange method) key-value
|
||||||
|
// pairs
|
||||||
|
OPOLICY_FULL // serialize entire set of key-value pairs
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr std::string_view DEFAULT_RECORD_DELIMITER{"\n"};
|
||||||
|
|
||||||
|
static constexpr std::string_view COMMENT_SEQ{COMM_SEQ == nullptr ? MCC_KV_COMMENT_SEQ_ARR
|
||||||
|
: COMM_SEQ[0] == '\0' ? MCC_KV_COMMENT_SEQ_ARR
|
||||||
|
: COMM_SEQ};
|
||||||
|
|
||||||
|
static constexpr std::string_view KEY_VALUE_DELIM{KV_DELIM == nullptr ? MCC_KV_KEY_VALUE_DELIM_SEQ_ARR
|
||||||
|
: KV_DELIM[0] == '\0' ? MCC_KV_KEY_VALUE_DELIM_SEQ_ARR
|
||||||
|
: KV_DELIM};
|
||||||
|
|
||||||
|
static constexpr size_t NUMBER_OF_RECORDS = std::tuple_size_v<DESCR_T>;
|
||||||
|
|
||||||
|
MccKeyValueHolder(DESCR_T desc) : _keyValue(desc)
|
||||||
|
{
|
||||||
|
[this]<size_t... I>(std::index_sequence<I...>) {
|
||||||
|
((_hashes[I] = utils::FNV1aHash(std::get<I>(_keyValue).key)), ...);
|
||||||
|
}(std::make_index_sequence<NUMBER_OF_RECORDS>());
|
||||||
|
|
||||||
|
_changedKey.insert_range(_hashes);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccKeyValueHolder(MccKeyValueHolder const& other) : MccKeyValueHolder(other._keyValue)
|
||||||
|
{
|
||||||
|
copyInst(other);
|
||||||
|
};
|
||||||
|
|
||||||
|
MccKeyValueHolder(MccKeyValueHolder&& other)
|
||||||
|
{
|
||||||
|
moveInst(std::move(other));
|
||||||
|
};
|
||||||
|
|
||||||
|
MccKeyValueHolder& operator=(MccKeyValueHolder const& other)
|
||||||
|
{
|
||||||
|
copyInst(other);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
};
|
||||||
|
|
||||||
|
MccKeyValueHolder& operator=(MccKeyValueHolder&& other)
|
||||||
|
{
|
||||||
|
moveInst(std::move(other));
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr std::array<std::string_view, NUMBER_OF_RECORDS> keys() const
|
||||||
|
{
|
||||||
|
return [this]<size_t... Is>(std::index_sequence<Is...>) {
|
||||||
|
return std::array<std::string_view, NUMBER_OF_RECORDS>{std::get<Is>(_keyValue).key...};
|
||||||
|
}(std::make_index_sequence<NUMBER_OF_RECORDS>{});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setToDefaults()
|
||||||
|
{
|
||||||
|
[this]<size_t... Is>(std::index_sequence<Is...>) {
|
||||||
|
((std::get<Is>(_keyValue).value = std::get<Is>(_keyValue).default_value), ...);
|
||||||
|
}(std::make_index_sequence<NUMBER_OF_RECORDS>{});
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, std::ranges::contiguous_range R>
|
||||||
|
std::expected<T, std::error_code> getValue(R const& key) const
|
||||||
|
{
|
||||||
|
return getValue<T>(std::string_view{key});
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::expected<T, std::error_code> getValue(std::string_view key) const
|
||||||
|
{
|
||||||
|
// ugly, but works for non-default constructible values
|
||||||
|
alignas(T) unsigned char buff[sizeof(T)];
|
||||||
|
auto err = forKey(key, [&buff](auto const& rec) -> std::error_code {
|
||||||
|
using VT = decltype(rec.value);
|
||||||
|
if constexpr (std::constructible_from<T, VT>) {
|
||||||
|
new (buff) T(rec.value);
|
||||||
|
} else {
|
||||||
|
return MccKeyValueHolderErrorCode::ERROR_INCOMPATIBLE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccKeyValueHolderErrorCode::ERROR_OK;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
return std::unexpected(err);
|
||||||
|
} else {
|
||||||
|
auto ptr = reinterpret_cast<T*>(&buff[0]);
|
||||||
|
auto v = std::move(*ptr);
|
||||||
|
ptr->~T(); // one needs explicitly call destructor here to avvoid side effects!!!
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// template <typename T>
|
||||||
|
// std::expected<T, std::error_code> getValue(std::string_view key) const
|
||||||
|
// {
|
||||||
|
// T v;
|
||||||
|
// auto err = forKey(key, [&v](auto const& rec) -> std::error_code {
|
||||||
|
// using VT = decltype(rec.value);
|
||||||
|
// if constexpr (std::convertible_to<VT, T>) {
|
||||||
|
// v = rec.value;
|
||||||
|
// } else if constexpr (std::constructible_from<T, VT>) {
|
||||||
|
// v = T(rec.value);
|
||||||
|
// } else {
|
||||||
|
// return MccKeyValueHolderErrorCode::ERROR_INCOMPATIBLE_TYPE;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return MccKeyValueHolderErrorCode::ERROR_OK;
|
||||||
|
// });
|
||||||
|
|
||||||
|
// if (err) {
|
||||||
|
// return std::unexpected(err);
|
||||||
|
// } else {
|
||||||
|
// return v;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
template <std::ranges::contiguous_range R, typename T>
|
||||||
|
std::error_code setValue(R const& key, const T& value)
|
||||||
|
{
|
||||||
|
return setValue(std::string_view{key}, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::error_code setValue(std::string_view key, const T& value)
|
||||||
|
{
|
||||||
|
const size_t hash = utils::FNV1aHash(key);
|
||||||
|
|
||||||
|
auto ec = forHash(hash, [&value](auto& rec) -> std::error_code {
|
||||||
|
using VT = decltype(rec.value);
|
||||||
|
if constexpr (requires { rec.value = value; }) {
|
||||||
|
rec.value = value;
|
||||||
|
} else if constexpr (std::constructible_from<VT, T>) {
|
||||||
|
rec.value = VT(value);
|
||||||
|
} else if constexpr (std::ranges::range<VT> && std::ranges::range<T> &&
|
||||||
|
requires(std::ranges::range_value_t<VT> v, std::ranges::range_value_t<T> t) {
|
||||||
|
v = t;
|
||||||
|
}) {
|
||||||
|
const auto& val = std::is_pointer_v<std::decay_t<T>> ? std::span{value} : value;
|
||||||
|
|
||||||
|
size_t N = std::ranges::distance(rec.value.begin(), rec.value.end());
|
||||||
|
size_t M = std::ranges::distance(val.begin(), val.end());
|
||||||
|
|
||||||
|
auto it = std::ranges::begin(rec.value);
|
||||||
|
std::ranges::for_each_n(val.begin(), N > M ? M : N, [&it](auto const& el) {
|
||||||
|
*it = el;
|
||||||
|
++it;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (N >= M) { // resize to match the size of the input range
|
||||||
|
if constexpr (!traits::mcc_non_resizable_range<VT>) {
|
||||||
|
rec.value.resize(M);
|
||||||
|
}
|
||||||
|
} else { // append if allowed
|
||||||
|
if constexpr (!traits::mcc_fixed_size_range<VT>) {
|
||||||
|
std::ranges::for_each_n(val.begin(), N, [&it](auto const& el) {
|
||||||
|
*it = el;
|
||||||
|
++it;
|
||||||
|
});
|
||||||
|
|
||||||
|
std::ranges::for_each(val | std::views::drop(N),
|
||||||
|
[&rec](auto const& el) { std::back_inserter(rec.value) = el; });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return MccKeyValueHolderErrorCode::ERROR_INCOMPATIBLE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccKeyValueHolderErrorCode::ERROR_OK;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!ec) {
|
||||||
|
_changedKey.insert(hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ec;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range R,
|
||||||
|
traits::mcc_input_char_range RecDelimT = std::string_view,
|
||||||
|
mcc_serialization_params_c SerParamsT = mcc_serialization_params_t>
|
||||||
|
std::error_code fromCharRange(const R& buffer,
|
||||||
|
size_t skip_records = 0, // number of skipped records (from the beginning)
|
||||||
|
RecDelimT rec_delim = DEFAULT_RECORD_DELIMITER // records delimiter
|
||||||
|
)
|
||||||
|
requires std::ranges::contiguous_range<R>
|
||||||
|
{
|
||||||
|
if constexpr (std::is_array_v<std::decay_t<R>>) { // char*, const char*
|
||||||
|
if constexpr (std::is_array_v<std::decay_t<RecDelimT>>) {
|
||||||
|
return fromCharRange(std::string_view{buffer}, std::string_view(rec_delim));
|
||||||
|
} else {
|
||||||
|
return fromCharRange(std::string_view{buffer}, std::move(rec_delim));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if constexpr (std::is_array_v<std::decay_t<RecDelimT>>) {
|
||||||
|
return fromCharRange(buffer, std::string_view(rec_delim));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::error_code ec{};
|
||||||
|
std::string_view rec, key, svalue, inline_comm;
|
||||||
|
std::vector<std::optional<std::string>> head_comm;
|
||||||
|
size_t key_hash;
|
||||||
|
|
||||||
|
_headComment.clear();
|
||||||
|
_inlineComment.clear();
|
||||||
|
_changedKey.clear();
|
||||||
|
|
||||||
|
// set values to its defaults
|
||||||
|
setToDefaults();
|
||||||
|
|
||||||
|
auto recs = std::views::split(buffer, std::move(rec_delim)) | std::views::drop(skip_records);
|
||||||
|
|
||||||
|
for (auto const& el : recs) {
|
||||||
|
rec = mcc::utils::trimSpaces(el, utils::TrimType::TRIM_LEFT);
|
||||||
|
|
||||||
|
inline_comm = {};
|
||||||
|
|
||||||
|
if (rec.size()) {
|
||||||
|
auto found = std::ranges::search(rec, COMMENT_SEQ);
|
||||||
|
if (found.begin() != rec.end()) { // there was the comment sequence in record
|
||||||
|
if (found.begin() != rec.begin()) { // inline comment
|
||||||
|
inline_comm =
|
||||||
|
std::string_view{found.begin() + COMMENT_SEQ.size(), rec.end()}; // mark inline comment
|
||||||
|
} else { // head comment
|
||||||
|
head_comm.push_back(std::string{found.end(), rec.end()});
|
||||||
|
}
|
||||||
|
|
||||||
|
rec = std::string_view(rec.begin(), found.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rec.size()) {
|
||||||
|
found = std::ranges::search(rec, KEY_VALUE_DELIM);
|
||||||
|
if (found.begin() != rec.begin()) {
|
||||||
|
key = trimSpaces(std::string_view(rec.begin(), found.begin()), utils::TrimType::TRIM_RIGHT);
|
||||||
|
svalue = std::string_view(found.end(), rec.end());
|
||||||
|
|
||||||
|
key_hash = utils::FNV1aHash(key);
|
||||||
|
|
||||||
|
ec = forHash(key_hash, [&key_hash, svalue, this]<typename REC_T>(REC_T& v) {
|
||||||
|
using VT = decltype(v.value);
|
||||||
|
auto err = MccDeserializer<VT>{}(svalue, v.value, v.serial_pars);
|
||||||
|
if (err) {
|
||||||
|
return MccKeyValueHolderErrorCode::ERROR_DESERIAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
_changedKey.insert(key_hash);
|
||||||
|
|
||||||
|
return MccKeyValueHolderErrorCode::ERROR_OK;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ec) { // exit in the case of error
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// save head comment
|
||||||
|
_headComment[key_hash] = head_comm;
|
||||||
|
head_comm.clear();
|
||||||
|
_inlineComment[key_hash] = inline_comm;
|
||||||
|
} else { // an empty key
|
||||||
|
ec = MccKeyValueHolderErrorCode::ERROR_INVALID_KEY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} // just comment string starting from the beginning, just skip it (no error)
|
||||||
|
|
||||||
|
} else { // empty record, just skip it (no error)
|
||||||
|
// head_comm.push_back({el.begin(), el.end()});
|
||||||
|
head_comm.push_back(std::nullopt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ec;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <OutputPolicy OPOLICY = MccKeyValueHolder::OPOLICY_CHANGED_ONLY,
|
||||||
|
traits::mcc_output_char_range R,
|
||||||
|
traits::mcc_input_char_range RecDelimT = std::string_view>
|
||||||
|
std::error_code toCharRange(R& output_buffer, RecDelimT rec_delim = DEFAULT_RECORD_DELIMITER)
|
||||||
|
{
|
||||||
|
if (std::is_pointer_v<std::decay_t<RecDelimT>>) { // char*, const char*, char[], conat char[]
|
||||||
|
return toCharRange(output_buffer, std::string_view{rec_delim});
|
||||||
|
}
|
||||||
|
|
||||||
|
std::error_code ec{};
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
// to fix GCC compilation crash for the versions < 16
|
||||||
|
#if GCC_VERSION < 160000
|
||||||
|
auto write_rec = [&output_buffer, &rec_delim, &ec, obj_ptr = this]<size_t I = 0>(this auto& self) -> void {
|
||||||
|
#else
|
||||||
|
auto write_rec = [&output_buffer, &rec_delim, &ec, this]<size_t I = 0>(this auto& self) -> void {
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
if constexpr (I < NUMBER_OF_RECORDS) {
|
||||||
|
if constexpr (OPOLICY == MccKeyValueHolder::OPOLICY_CHANGED_ONLY) {
|
||||||
|
#ifdef __GNUG__
|
||||||
|
// to fix GCC compilation crash for the versions < 16
|
||||||
|
#if GCC_VERSION < 160000
|
||||||
|
if (obj_ptr->_changedKey.count(obj_ptr->_hashes[I]) == 0) {
|
||||||
|
#else
|
||||||
|
if (_changedKey.count(_hashes[I]) == 0) {
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
self.template operator()<I + 1>();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
// to fix GCC compilation crash for the versions < 16
|
||||||
|
#if GCC_VERSION < 160000
|
||||||
|
ec = obj_ptr->template formatRecord<I>(output_buffer, rec_delim);
|
||||||
|
#else
|
||||||
|
ec = formatRecord<I>(output_buffer, rec_delim);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
if (ec) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.template operator()<I + 1>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
write_rec();
|
||||||
|
|
||||||
|
// [&write_rec]<size_t... Is>(std::index_sequence<Is...>) {
|
||||||
|
// (write_rec.template operator()<Is>(), ...);
|
||||||
|
// }(std::make_index_sequence<NUMBER_OF_RECORDS>());
|
||||||
|
|
||||||
|
return ec;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
DESCR_T _keyValue;
|
||||||
|
|
||||||
|
std::array<size_t, NUMBER_OF_RECORDS> _hashes{}; // key hashes
|
||||||
|
std::unordered_map<size_t, std::vector<std::optional<std::string>>>
|
||||||
|
_headComment{}; // comment string/strings before key
|
||||||
|
std::unordered_map<size_t, std::string> _inlineComment{}; // inline (after key=value pair) comment
|
||||||
|
std::unordered_set<size_t> _changedKey{}; // loaded keys (see fromCharRange)
|
||||||
|
|
||||||
|
//
|
||||||
|
// NOTE: deduced this is needed here to use "forKey" method in getter and setter (const and non-const contexts)!!!
|
||||||
|
//
|
||||||
|
|
||||||
|
std::error_code forKey(this auto&& self, std::string_view key, auto&& func)
|
||||||
|
{
|
||||||
|
return std::forward<decltype(self)>(self).template forHash<0>(utils::FNV1aHash(key),
|
||||||
|
std::forward<decltype(func)>(func));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'func' signature:
|
||||||
|
// std::error func(mcc_keyvalue_record_c&&)
|
||||||
|
// e.g.:
|
||||||
|
// [](auto const& rec)->std::error_code {}
|
||||||
|
// [](auto& rec)->std::error_code {}
|
||||||
|
//
|
||||||
|
template <size_t I = 0>
|
||||||
|
std::error_code forHash(this auto&& self, size_t hash, auto&& func)
|
||||||
|
{
|
||||||
|
if constexpr (I < NUMBER_OF_RECORDS) {
|
||||||
|
if (hash == std::forward<decltype(self)>(self)._hashes[I]) {
|
||||||
|
return std::forward<decltype(func)>(func)(std::get<I>(std::forward<decltype(self)>(self)._keyValue));
|
||||||
|
} else {
|
||||||
|
return std::forward<decltype(self)>(self).template forHash<I + 1>(hash,
|
||||||
|
std::forward<decltype(func)>(func));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccKeyValueHolderErrorCode::ERROR_INVALID_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t I = 0, traits::mcc_output_char_range R, traits::mcc_input_char_range RecDelimT>
|
||||||
|
std::error_code formatRecord(R& output_buffer, RecDelimT rec_delim, bool is_default = false)
|
||||||
|
{
|
||||||
|
if constexpr (I < NUMBER_OF_RECORDS) {
|
||||||
|
auto key = std::get<I>(_keyValue).key;
|
||||||
|
using val_t = std::remove_cvref_t<decltype(std::get<I>(_keyValue).value)>;
|
||||||
|
|
||||||
|
const val_t& val = is_default ? std::get<I>(_keyValue).default_value : std::get<I>(_keyValue).value;
|
||||||
|
|
||||||
|
std::string buff;
|
||||||
|
// auto err = MccSerializer<val_t>{}(buff, std::get<I>(_keyValue).value,
|
||||||
|
// std::get<I>(_keyValue).serial_pars);
|
||||||
|
auto err = MccSerializer<val_t>{}(buff, val, std::get<I>(_keyValue).serial_pars);
|
||||||
|
if (err) {
|
||||||
|
return MccKeyValueHolderErrorCode::ERROR_SERIAL;
|
||||||
|
} else {
|
||||||
|
size_t hash = _hashes[I];
|
||||||
|
// write head comment
|
||||||
|
if (_headComment[hash].size()) {
|
||||||
|
for (auto const& comm : _headComment[hash]) {
|
||||||
|
if (comm.has_value()) {
|
||||||
|
std::format_to(std::back_inserter(output_buffer), "{}{}", COMM_SEQ, comm.value());
|
||||||
|
}
|
||||||
|
std::ranges::copy(rec_delim, std::back_inserter(output_buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// key and value
|
||||||
|
std::format_to(std::back_inserter(output_buffer), "{}{}{}", key, KEY_VALUE_DELIM, buff);
|
||||||
|
|
||||||
|
// inline comment
|
||||||
|
if (_inlineComment[hash].size()) {
|
||||||
|
std::format_to(std::back_inserter(output_buffer), " {}{}", COMMENT_SEQ, _inlineComment[hash]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// record delimiter
|
||||||
|
std::ranges::copy(rec_delim, std::back_inserter(output_buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccKeyValueHolderErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <size_t I = 0>
|
||||||
|
void copyInst(MccKeyValueHolder const& other)
|
||||||
|
{
|
||||||
|
if constexpr (I < NUMBER_OF_RECORDS) {
|
||||||
|
// here one needs check equality of the keys!!!
|
||||||
|
if (_hashes[I] == other._hashes[I]) {
|
||||||
|
auto& orec = std::get<I>(other._keyValue);
|
||||||
|
std::get<I>(_keyValue).value = orec.value;
|
||||||
|
std::get<I>(_keyValue).default_value = orec.default_value;
|
||||||
|
std::get<I>(_keyValue).serial_pars = orec.serial_pars;
|
||||||
|
|
||||||
|
if (auto it = other._headComment.find(_hashes[I]); it != other._headComment.end()) {
|
||||||
|
_headComment[_hashes[I]] = it->second;
|
||||||
|
}
|
||||||
|
if (auto it = other._inlineComment.find(_hashes[I]); it != other._inlineComment.end()) {
|
||||||
|
_inlineComment[_hashes[I]] = it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
_changedKey.insert(_hashes[I]);
|
||||||
|
}
|
||||||
|
|
||||||
|
copyInst<I + 1>(other);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t I = 0>
|
||||||
|
void moveInst(MccKeyValueHolder&& other)
|
||||||
|
{
|
||||||
|
if constexpr (I < NUMBER_OF_RECORDS) {
|
||||||
|
// here one needs check equality of the keys!!!
|
||||||
|
if (_hashes[I] == other._hashes[I]) {
|
||||||
|
auto& orec = std::get<I>(other._keyValue);
|
||||||
|
std::get<I>(_keyValue).value = std::move(orec.value);
|
||||||
|
std::get<I>(_keyValue).default_value = std::move(orec.default_value);
|
||||||
|
std::get<I>(_keyValue).serial_pars = std::move(orec.serial_pars);
|
||||||
|
|
||||||
|
if (auto it = other._headComment.find(_hashes[I]); it != other._headComment.end()) {
|
||||||
|
_headComment[_hashes[I]] = std::move(it->second);
|
||||||
|
}
|
||||||
|
if (auto it = other._inlineComment.find(_hashes[I]); it != other._inlineComment.end()) {
|
||||||
|
_inlineComment[_hashes[I]] = std::move(it->second);
|
||||||
|
}
|
||||||
|
|
||||||
|
_changedKey.insert(_hashes[I]);
|
||||||
|
}
|
||||||
|
|
||||||
|
moveInst<I + 1>(other);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <mcc_record_value_c T>
|
||||||
|
struct mcc_simple_kv_record_t {
|
||||||
|
const std::string_view key;
|
||||||
|
T value, default_value;
|
||||||
|
mcc_serialization_params_t serial_pars;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <mcc_record_value_c T>
|
||||||
|
static mcc_simple_kv_record_t<T> mcc_make_simple_kv_record(
|
||||||
|
std::string_view key,
|
||||||
|
T const& def_value,
|
||||||
|
mcc_serialization_params_t const& spars = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
return mcc_simple_kv_record_t<T>{key, def_value, def_value, spars};
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
1059
include/mcc/mcc_movement_controls.h
Normal file
1059
include/mcc/mcc_movement_controls.h
Normal file
File diff suppressed because it is too large
Load Diff
1262
include/mcc/mcc_netserver.h
Normal file
1262
include/mcc/mcc_netserver.h
Normal file
File diff suppressed because it is too large
Load Diff
512
include/mcc/mcc_netserver_endpoint.h
Normal file
512
include/mcc/mcc_netserver_endpoint.h
Normal file
@@ -0,0 +1,512 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* NETWORK SERVER ENDPOINT CLASS IMPLEMENTATION */
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
#include <charconv>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <ranges>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
#include "mcc_traits.h"
|
||||||
|
|
||||||
|
namespace mcc::network
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
|
||||||
|
static constexpr bool mcc_char_range_compare(const traits::mcc_char_view auto& what,
|
||||||
|
const traits::mcc_char_view auto& where,
|
||||||
|
bool case_insensitive = false)
|
||||||
|
{
|
||||||
|
if (std::ranges::size(what) == std::ranges::size(where)) {
|
||||||
|
if (case_insensitive) {
|
||||||
|
auto f = std::ranges::search(where,
|
||||||
|
std::views::transform(what, [](const char& ch) { return std::tolower(ch); }));
|
||||||
|
return !f.empty();
|
||||||
|
} else {
|
||||||
|
auto f = std::ranges::search(where, what);
|
||||||
|
return !f.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace utils
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Very simple various protocols endpoint parser and holder class
|
||||||
|
*
|
||||||
|
* endpoint: proto_mark://host_name:port_num/path
|
||||||
|
* where "path" is optional for all non-local protocol kinds;
|
||||||
|
*
|
||||||
|
* for local kind of protocols the endpoint must be given as:
|
||||||
|
* local://stream/PATH
|
||||||
|
* local://seqpacket/PATH
|
||||||
|
* local://serial/PATH
|
||||||
|
* where 'stream' and 'seqpacket' "host_name"-field marks the
|
||||||
|
* stream-type and seqpacket-type UNIX domain sockets protocols;
|
||||||
|
* 'serial' marks a serial (RS232/485) protocol.
|
||||||
|
* here, possible "port_num" field is allowed but ignored.
|
||||||
|
*
|
||||||
|
* NOTE: "proto_mark" and "host_name" (for local kind) fields are parsed in case-insensitive manner!
|
||||||
|
*
|
||||||
|
* EXAMPLES: tcp://192.168.70.130:3131
|
||||||
|
* local://serial/dev/ttyS1
|
||||||
|
* local://seqpacket/tmp/BM70_SERVER_SOCK
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class MccNetServerEndpoint
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr std::string_view protoHostDelim = "://";
|
||||||
|
static constexpr std::string_view hostPortDelim = ":";
|
||||||
|
static constexpr std::string_view portPathDelim = "/";
|
||||||
|
|
||||||
|
enum proto_id_t : uint8_t {
|
||||||
|
PROTO_ID_LOCAL,
|
||||||
|
PROTO_ID_SEQLOCAL,
|
||||||
|
PROTO_ID_SERLOCAL,
|
||||||
|
PROTO_ID_TCP,
|
||||||
|
PROTO_ID_TLS,
|
||||||
|
PROTO_ID_UNKNOWN
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr std::string_view protoMarkLocal{"local"}; // UNIX domain
|
||||||
|
static constexpr std::string_view protoMarkTCP{"tcp"}; // TCP
|
||||||
|
static constexpr std::string_view protoMarkTLS{"tls"}; // TLS
|
||||||
|
|
||||||
|
static constexpr std::array validProtoMarks{protoMarkLocal, protoMarkTCP, protoMarkTLS};
|
||||||
|
|
||||||
|
|
||||||
|
static constexpr std::string_view localProtoTypeStream{"stream"}; // UNIX domain stream
|
||||||
|
static constexpr std::string_view localProtoTypeSeqpacket{"seqpacket"}; // UNIX domain seqpacket
|
||||||
|
static constexpr std::string_view localProtoTypeSerial{"serial"}; // serial (RS232/485)
|
||||||
|
|
||||||
|
static constexpr std::array validLocalProtoTypes{localProtoTypeStream, localProtoTypeSeqpacket,
|
||||||
|
localProtoTypeSerial};
|
||||||
|
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range R>
|
||||||
|
MccNetServerEndpoint(const R& ept)
|
||||||
|
{
|
||||||
|
fromRange(ept);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccNetServerEndpoint(const MccNetServerEndpoint& other)
|
||||||
|
{
|
||||||
|
copyInst(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccNetServerEndpoint(MccNetServerEndpoint&& other)
|
||||||
|
{
|
||||||
|
moveInst(std::move(other));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~MccNetServerEndpoint() = default;
|
||||||
|
|
||||||
|
|
||||||
|
MccNetServerEndpoint& operator=(const MccNetServerEndpoint& other)
|
||||||
|
{
|
||||||
|
copyInst(other);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MccNetServerEndpoint& operator=(MccNetServerEndpoint&& other)
|
||||||
|
{
|
||||||
|
moveInst(std::move(other));
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range R>
|
||||||
|
requires std::ranges::contiguous_range<R>
|
||||||
|
bool fromRange(const R& ept)
|
||||||
|
{
|
||||||
|
_isValid = false;
|
||||||
|
|
||||||
|
// at least 'ws://a' (proto, proto-host delimiter and at least a single character of hostname)
|
||||||
|
if (std::ranges::size(ept) < 6) {
|
||||||
|
return _isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (std::is_array_v<std::remove_cvref_t<R>>) {
|
||||||
|
_endpoint = ept;
|
||||||
|
} else {
|
||||||
|
_endpoint.clear();
|
||||||
|
std::ranges::copy(ept, std::back_inserter(_endpoint));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto found = std::ranges::search(_endpoint, protoHostDelim);
|
||||||
|
if (found.empty()) {
|
||||||
|
return _isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ssize_t idx;
|
||||||
|
if ((idx = checkProtoMark(std::string_view{_endpoint.begin(), found.begin()})) < 0) {
|
||||||
|
return _isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
_proto = validProtoMarks[idx];
|
||||||
|
|
||||||
|
_host = std::string_view{found.end(), _endpoint.end()};
|
||||||
|
|
||||||
|
auto f1 = std::ranges::search(_host, portPathDelim);
|
||||||
|
// std::string_view port_sv;
|
||||||
|
if (f1.empty() && isLocal()) { // no path, but it is mandatory for 'local'!
|
||||||
|
return _isValid;
|
||||||
|
} else {
|
||||||
|
_host = std::string_view(_host.begin(), f1.begin());
|
||||||
|
|
||||||
|
_path = std::string_view(f1.end(), &*_endpoint.end());
|
||||||
|
|
||||||
|
f1 = std::ranges::search(_host, hostPortDelim);
|
||||||
|
if (f1.empty() && !isLocal()) { // no port, but it is mandatory for non-local!
|
||||||
|
return _isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
_portView = std::string_view(f1.end(), _host.end());
|
||||||
|
if (_portView.size()) {
|
||||||
|
_host = std::string_view(_host.begin(), f1.begin());
|
||||||
|
|
||||||
|
if (!isLocal()) {
|
||||||
|
// convert port string to int
|
||||||
|
auto end_ptr = _portView.data() + _portView.size();
|
||||||
|
|
||||||
|
auto [ptr, ec] = std::from_chars(_portView.data(), end_ptr, _port);
|
||||||
|
if (ec != std::errc() || ptr != end_ptr) {
|
||||||
|
return _isValid;
|
||||||
|
}
|
||||||
|
} else { // ignore for local
|
||||||
|
_port = -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_port = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLocal()) { // check for special values
|
||||||
|
idx = 0;
|
||||||
|
if (std::ranges::any_of(validLocalProtoTypes, [&idx, this](const auto& el) {
|
||||||
|
bool ok = utils::mcc_char_range_compare(_host, el, true);
|
||||||
|
if (!ok) {
|
||||||
|
++idx;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
})) {
|
||||||
|
_host = validLocalProtoTypes[idx];
|
||||||
|
} else {
|
||||||
|
return _isValid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_isValid = true;
|
||||||
|
|
||||||
|
return _isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool isValid() const
|
||||||
|
{
|
||||||
|
return _isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
auto endpoint() const
|
||||||
|
{
|
||||||
|
return _endpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_view_or_output_char_range R>
|
||||||
|
R proto() const
|
||||||
|
{
|
||||||
|
return part<R>(PROTO_PART);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view proto() const
|
||||||
|
{
|
||||||
|
return proto<std::string_view>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_view_or_output_char_range R>
|
||||||
|
R host() const
|
||||||
|
{
|
||||||
|
return part<R>(HOST_PART);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view host() const
|
||||||
|
{
|
||||||
|
return host<std::string_view>();
|
||||||
|
}
|
||||||
|
|
||||||
|
int port() const
|
||||||
|
{
|
||||||
|
return _port;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_view_or_output_char_range R>
|
||||||
|
R portView() const
|
||||||
|
{
|
||||||
|
return part<R>(PORT_PART);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view portView() const
|
||||||
|
{
|
||||||
|
return portView<std::string_view>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_output_char_range R, traits::mcc_input_char_range RR = std::string_view>
|
||||||
|
R path(RR&& root_path) const
|
||||||
|
{
|
||||||
|
if (_path.empty()) {
|
||||||
|
if constexpr (traits::mcc_output_char_range<R>) {
|
||||||
|
R res;
|
||||||
|
std::ranges::copy(std::forward<RR>(root_path), std::back_inserter(res));
|
||||||
|
|
||||||
|
return res;
|
||||||
|
} else { // can't add root path!!!
|
||||||
|
return part<R>(PATH_PART);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto N = std::ranges::distance(root_path.begin(), root_path.end());
|
||||||
|
|
||||||
|
if (N) {
|
||||||
|
R res;
|
||||||
|
std::filesystem::path pt(root_path.begin(), root_path.end());
|
||||||
|
|
||||||
|
if (isLocal() && _path[0] == '\0') {
|
||||||
|
std::ranges::copy(std::string_view(" "), std::back_inserter(res));
|
||||||
|
pt /= _path.substr(1);
|
||||||
|
std::ranges::copy(pt.string(), std::back_inserter(res));
|
||||||
|
*res.begin() = '\0';
|
||||||
|
} else {
|
||||||
|
pt /= _path;
|
||||||
|
std::ranges::copy(pt.string(), std::back_inserter(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
return part<R>(PATH_PART);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range RR = std::string_view>
|
||||||
|
std::string path(RR&& root_path) const
|
||||||
|
{
|
||||||
|
return path<std::string, RR>(std::forward<RR>(root_path));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_view_or_output_char_range R>
|
||||||
|
R path() const
|
||||||
|
{
|
||||||
|
return part<R>(PATH_PART);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view path() const
|
||||||
|
{
|
||||||
|
return path<std::string_view>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool isLocal() const
|
||||||
|
{
|
||||||
|
return proto() == protoMarkLocal;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isLocalStream() const
|
||||||
|
{
|
||||||
|
return host() == localProtoTypeStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isLocalSerial() const
|
||||||
|
{
|
||||||
|
return host() == localProtoTypeSerial;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isLocalSeqpacket() const
|
||||||
|
{
|
||||||
|
return host() == localProtoTypeSeqpacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool isTCP() const
|
||||||
|
{
|
||||||
|
return proto() == protoMarkTCP;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isTLS() const
|
||||||
|
{
|
||||||
|
return proto() == protoMarkTLS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// add '\0' char (or replace special-meaning char/char-sequence) to construct UNIX abstract namespace
|
||||||
|
// endpoint path
|
||||||
|
template <typename T = std::nullptr_t>
|
||||||
|
MccNetServerEndpoint& makeAbstract(const T& mark = nullptr)
|
||||||
|
requires(traits::mcc_input_char_range<T> || std::same_as<std::remove_cv_t<T>, char> ||
|
||||||
|
std::is_null_pointer_v<std::remove_cv_t<T>>)
|
||||||
|
{
|
||||||
|
if (!(isLocalStream() || isLocalSeqpacket())) { // only local proto is valid!
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (std::is_null_pointer_v<T>) { // just insert '\0'
|
||||||
|
auto it = _endpoint.insert(std::string::const_iterator(_path.begin()), '\0');
|
||||||
|
_path = std::string_view(it, _endpoint.end());
|
||||||
|
} else if constexpr (std::same_as<std::remove_cv_t<T>, char>) { // replace a character (mark)
|
||||||
|
auto pos = std::distance(_endpoint.cbegin(), std::string::const_iterator(_path.begin()));
|
||||||
|
if (_endpoint[pos] == mark) {
|
||||||
|
_endpoint[pos] = '\0';
|
||||||
|
}
|
||||||
|
} else { // replace a character range (mark)
|
||||||
|
if (std::ranges::equal(_path | std::views::take(std::ranges::size(mark), mark))) {
|
||||||
|
auto pos = std::distance(_endpoint.cbegin(), std::string::const_iterator(_path.begin()));
|
||||||
|
_endpoint.replace(pos, std::ranges::size(mark), 1, '\0');
|
||||||
|
_path = std::string_view(_endpoint.begin() + pos, _endpoint.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::string _endpoint;
|
||||||
|
std::string_view _proto, _host, _path, _portView;
|
||||||
|
int _port;
|
||||||
|
bool _isValid;
|
||||||
|
|
||||||
|
|
||||||
|
virtual ssize_t checkProtoMark(std::string_view proto_mark)
|
||||||
|
{
|
||||||
|
ssize_t idx = 0;
|
||||||
|
|
||||||
|
// case-insensitive look-up
|
||||||
|
bool found = std::ranges::any_of(MccNetServerEndpoint::validProtoMarks, [&idx, &proto_mark](const auto& el) {
|
||||||
|
bool ok = utils::mcc_char_range_compare(proto_mark, el, true);
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
++idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
});
|
||||||
|
|
||||||
|
return found ? idx : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum EndpointPart { PROTO_PART, HOST_PART, PATH_PART, PORT_PART };
|
||||||
|
|
||||||
|
template <traits::mcc_view_or_output_char_range R>
|
||||||
|
R part(EndpointPart what) const
|
||||||
|
{
|
||||||
|
R res;
|
||||||
|
|
||||||
|
// if (!_isValid) {
|
||||||
|
// return res;
|
||||||
|
// }
|
||||||
|
|
||||||
|
auto part = _proto;
|
||||||
|
|
||||||
|
switch (what) {
|
||||||
|
case PROTO_PART:
|
||||||
|
part = _proto;
|
||||||
|
break;
|
||||||
|
case HOST_PART:
|
||||||
|
part = _host;
|
||||||
|
break;
|
||||||
|
case PATH_PART:
|
||||||
|
part = _path;
|
||||||
|
break;
|
||||||
|
case PORT_PART:
|
||||||
|
part = _portView;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (std::ranges::view<R>) {
|
||||||
|
return {part.begin(), part.end()};
|
||||||
|
} else {
|
||||||
|
std::ranges::copy(part, std::back_inserter(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void copyInst(const MccNetServerEndpoint& other)
|
||||||
|
{
|
||||||
|
if (&other != this) {
|
||||||
|
if (other._isValid) {
|
||||||
|
_isValid = other._isValid;
|
||||||
|
_endpoint = other._endpoint;
|
||||||
|
_proto = other._proto;
|
||||||
|
|
||||||
|
std::iterator_traits<const char*>::difference_type idx;
|
||||||
|
if (other.isLocal()) { // for 'local' host is one of static class constants
|
||||||
|
_host = other._host;
|
||||||
|
} else {
|
||||||
|
idx = std::distance(other._endpoint.c_str(), other._host.data());
|
||||||
|
_host = std::string_view(_endpoint.c_str() + idx, other._host.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
idx = std::distance(other._endpoint.c_str(), other._path.data());
|
||||||
|
_path = std::string_view(_endpoint.c_str() + idx, other._path.size());
|
||||||
|
|
||||||
|
idx = std::distance(other._endpoint.c_str(), other._portView.data());
|
||||||
|
_portView = std::string_view(_endpoint.c_str() + idx, other._portView.size());
|
||||||
|
|
||||||
|
_port = other._port;
|
||||||
|
} else {
|
||||||
|
_isValid = false;
|
||||||
|
_endpoint = std::string();
|
||||||
|
_proto = std::string_view();
|
||||||
|
_host = std::string_view();
|
||||||
|
_path = std::string_view();
|
||||||
|
_portView = std::string_view();
|
||||||
|
_port = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void moveInst(MccNetServerEndpoint&& other)
|
||||||
|
{
|
||||||
|
if (&other != this) {
|
||||||
|
if (other._isValid) {
|
||||||
|
_isValid = std::move(other._isValid);
|
||||||
|
_endpoint = std::move(other._endpoint);
|
||||||
|
_proto = other._proto;
|
||||||
|
_host = std::move(other._host);
|
||||||
|
_path = std::move(other._path);
|
||||||
|
_port = std::move(other._port);
|
||||||
|
_portView = std::move(other._portView);
|
||||||
|
} else {
|
||||||
|
_isValid = false;
|
||||||
|
_endpoint = std::string();
|
||||||
|
_proto = std::string_view();
|
||||||
|
_host = std::string_view();
|
||||||
|
_path = std::string_view();
|
||||||
|
_portView = std::string_view();
|
||||||
|
_port = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc::network
|
||||||
605
include/mcc/mcc_netserver_proto.h
Normal file
605
include/mcc/mcc_netserver_proto.h
Normal file
@@ -0,0 +1,605 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
||||||
|
|
||||||
|
/* BASIC NETWORK PROTOCOL DEFINITIONS */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
|
||||||
|
#include "mcc_deserializer.h"
|
||||||
|
#include "mcc_serializer.h"
|
||||||
|
#include "mcc_utils.h"
|
||||||
|
|
||||||
|
namespace mcc::network
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The network protocol is the ASCII-based, case-sensitive textual protocol.
|
||||||
|
* The "client-server" communication is performed through messages.
|
||||||
|
* The message is a minimal unit of this communication.
|
||||||
|
* The model of network communication is a simple "client-server" one, i.e.,
|
||||||
|
* client asks - server responds.
|
||||||
|
*
|
||||||
|
* network communication message format:
|
||||||
|
* <keyword>[[<key-param-delim>]<param1>[<param-param-delim>][<param2>]...]<stop-seq>
|
||||||
|
*
|
||||||
|
* where
|
||||||
|
* <keyword> - mandatory message keyword (one or more ASCII symbols)
|
||||||
|
* <key-param-delim>
|
||||||
|
*
|
||||||
|
* e.g.
|
||||||
|
* "TARGET 12:23:45.56 00:32:21.978\n"
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* low-level network message format definitions */
|
||||||
|
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_STOP_SEQ = "\n";
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYPARAM_DELIM_SEQ = " ";
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_PARAMPARAM_DELIM_SEQ = ";";
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ = ",";
|
||||||
|
|
||||||
|
|
||||||
|
/* server special keywords */
|
||||||
|
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR = "ACK"; // ACK
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_SERVER_ERROR_STR = "ERROR"; // mount operational error
|
||||||
|
// pre-defined errors
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_SERVER_ERROR_INVKEY_STR = "INVKEY"; // invalid keyword
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_SERVER_ERROR_INVPAR_STR = "INVPAR"; // invalid parameter
|
||||||
|
|
||||||
|
|
||||||
|
/* server control keywords */
|
||||||
|
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_RESTART_SERVER_STR = "RESTART"; // restart server
|
||||||
|
|
||||||
|
|
||||||
|
/* BELOW IS ONE OF THE PROTOCOL OPTIONS CORRESPONDING MCC_GENERIC_MOUNT_C CONCEPT */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* keywords */
|
||||||
|
|
||||||
|
// NOTE: THE COORDINATES AND TIME-RELATED QUANTITIES CAN BE EXPRESSED IN THE TWO FORMATS:
|
||||||
|
// 1) fixed-point real number, e.g. 123.43987537359 or -0.09775
|
||||||
|
// 2) sexagesimal number, e.g. 10:43:43.12 or -123:54:12.435
|
||||||
|
//
|
||||||
|
// IN THE FIRST CASE ALL NUMBERS MUST BE INTERPRETATED AS DEGREES,
|
||||||
|
// IN THE SECOND CASE NUMBERS MUST BE INTERPRETATED ACCORDING TO ITS TYPE:
|
||||||
|
// ALL TIME-RELATED QUANTITIES AND RA/HA COORDINATES MUST BE EXPRESSED
|
||||||
|
// IN FORMAT 'HOURS:MINUTES:SECONDS', WHILE DEC/ALT/AZ/ZD COORDINATES MUST
|
||||||
|
// BE EXPRESSED AS '+/-DEGREES:ARCMINUTES:ARCSECONDS'
|
||||||
|
//
|
||||||
|
// USER-ENTERED (FROM NETWORK CLIENTS) COORDINATE PAIR CAN BE PROVIDED IN A MIXED FORM, I.E.,
|
||||||
|
// 12.34436658678 10:32:11.432 or
|
||||||
|
// 10:32:11.432 12.34436658678
|
||||||
|
//
|
||||||
|
// SERVER-RESPONDED COORDINATES ARE ALWAYS IN THE SAME FORMAT, SEXAGESIMAL OR FIXED-POINT
|
||||||
|
//
|
||||||
|
|
||||||
|
// format of output coordinates:
|
||||||
|
// "COORDFMT FMT-type\n"
|
||||||
|
// e.g.:
|
||||||
|
// "COORDFMT SGM\n"
|
||||||
|
// "COORDFMT\n"
|
||||||
|
//
|
||||||
|
// server must return "ACK" or "ERROR INVPAR" in the case of 'set'-operation and
|
||||||
|
// "ACK COORDFMT FMT-type" in the case of 'get'-operation
|
||||||
|
// e.g.:
|
||||||
|
// "COORDFMT FIX\n" -> "ACK\n"
|
||||||
|
// "COORDFMT SXT\n" -> "ERROR INVPAR\n" (invalid parameter of format type)
|
||||||
|
// "COORDFMT\n" -> "ACK COORDFMT FIX\n"
|
||||||
|
//
|
||||||
|
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_COORDFMT_STR = "COORDFMT";
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_COORDFMT_SEXGM_STR = "SGM"; // sexagesimal
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_COORDFMT_FIXED_STR = "FIX"; // fixed point
|
||||||
|
|
||||||
|
|
||||||
|
// precision (number of decimal places) of returned coordinates:
|
||||||
|
// "COORDPREC seconds-prec arcseconds-prec\n"
|
||||||
|
// seconds-prec - precision of hour-based coordinates (RA and HA) or time-related quantities
|
||||||
|
// arcseconds-prec - precision of degree-based coordinates (DEC, AZ, ZD, ALT)
|
||||||
|
// precision must be given as non-negative integer number
|
||||||
|
// e.g.
|
||||||
|
// "COORDPREC 2,1\n" (output sexagesimal RA=12:34:56.67, DEC=32:54:21.9)
|
||||||
|
//
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_COORDPREC_STR = "COORDPREC";
|
||||||
|
|
||||||
|
|
||||||
|
// set/get target coordinates
|
||||||
|
// "TARGET X-coord Y-coord XY-kind\n", if 'XY-kind' is omitted then one should assume RADEC_ICRS
|
||||||
|
// e.g.:
|
||||||
|
// "TARGET 12.7683487 10:23:09.75 AZZD\n"
|
||||||
|
// "TARGET HADEC\n"
|
||||||
|
// "TARGET\n"
|
||||||
|
//
|
||||||
|
// server must return "ACK" or "ERROR INVPAR" in the case of 'set'-operation and
|
||||||
|
// "ACK TARGET X-coord Y-coord XY-kind" in the case of 'get'-operation
|
||||||
|
// e.g.:
|
||||||
|
// "TARGET 12.7683487 10:23:09.75 AZZD\n" -> "ACK\n"
|
||||||
|
// "TARGET 12.7683487 10:23:09.75 AZZE\n" -> "ERROR INVPAR\n" (invalid parameter of coordinates pair kind)
|
||||||
|
//
|
||||||
|
// "TARGET HADEC\n" -> "ACK TARGET 20:21:56.32 -01:32:34.2 HADEC\n"
|
||||||
|
// "TARGET\n" -> "ACK TARGET 20:21:56.32 -01:32:34.2 RADEC_ICRS\n"
|
||||||
|
//
|
||||||
|
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_TARGET_STR = "TARGET";
|
||||||
|
|
||||||
|
// get mount coordinates:
|
||||||
|
// "MOUNT coord-kind", if 'coord-kind' is omitted then coordinates are according to mount type,
|
||||||
|
// i.e., HADEC for equathorial-type mount and AZZD for alt-azimuthal one
|
||||||
|
// e.g.:
|
||||||
|
// "MOUNT RADEC\n" (get current apparent RA and DEC mount coordinates)
|
||||||
|
//
|
||||||
|
// server must return "ACK MOUNT X-coord Y-coord XY-kind" or "ERROR INVPAR"
|
||||||
|
// e.g.
|
||||||
|
// "MOUNT AZALT\n" -> "ACK MOUNT 1.2332325 54.23321312 AZALT\n"
|
||||||
|
// "MOUNT AZAL\n" -> "ERROR INVPAR\n" (invalid parameter of coordinates pair kind)
|
||||||
|
// "MOUNT\n" -> "ACK MOUNT 1.2332325 54.23321312 AZZD\n" for alt-azimuthal mount
|
||||||
|
// "MOUNT\n" -> "ACK MOUNT 1.2332325 54.23321312 HADEC\n" for equathorial mount
|
||||||
|
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_MOUNT_STR = "MOUNT";
|
||||||
|
|
||||||
|
|
||||||
|
// get entered target coordinates:
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_ENTEREDTAG_STR = "ENTEREDTAG";
|
||||||
|
|
||||||
|
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_TELEMETRY_STR = "TELEMETRY";
|
||||||
|
|
||||||
|
// init mount
|
||||||
|
// "INIT\n"
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_INIT_STR = "INIT";
|
||||||
|
|
||||||
|
// stop any movements
|
||||||
|
// "STOP\n"
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_STOP_STR = "STOP";
|
||||||
|
|
||||||
|
// slew mount and track target:
|
||||||
|
// "SLEW\n"
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_SLEW_STR = "SLEW";
|
||||||
|
|
||||||
|
// slew mount and stop:
|
||||||
|
// "MOVE\n"
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_MOVE_STR = "MOVE";
|
||||||
|
|
||||||
|
// track target
|
||||||
|
// "TRACK\n"
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_TRACK_STR = "TRACK";
|
||||||
|
|
||||||
|
// get mount status
|
||||||
|
// "STATUS\n"
|
||||||
|
static constexpr std::string_view MCC_COMMPROTO_KEYWORD_STATUS_STR = "STATUS";
|
||||||
|
|
||||||
|
// valid keywords
|
||||||
|
// static constexpr std::array MCC_COMMPROTO_VALID_KEYS = {
|
||||||
|
// MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR, MCC_COMMPROTO_KEYWORD_SERVER_ERROR_STR, MCC_COMMPROTO_KEYWORD_COORDFMT_STR,
|
||||||
|
// MCC_COMMPROTO_KEYWORD_COORDPREC_STR, MCC_COMMPROTO_KEYWORD_TARGET_STR, MCC_COMMPROTO_KEYWORD_MOUNT_STR,
|
||||||
|
// MCC_COMMPROTO_KEYWORD_ENTEREDTAG_STR, MCC_COMMPROTO_KEYWORD_TELEMETRY_STR, MCC_COMMPROTO_KEYWORD_INIT_STR,
|
||||||
|
// MCC_COMMPROTO_KEYWORD_STOP_STR, MCC_COMMPROTO_KEYWORD_SLEW_STR, MCC_COMMPROTO_KEYWORD_MOVE_STR,
|
||||||
|
// MCC_COMMPROTO_KEYWORD_TRACK_STR, MCC_COMMPROTO_KEYWORD_STATUS_STR};
|
||||||
|
|
||||||
|
|
||||||
|
// // hashes of valid keywords
|
||||||
|
// static constexpr std::array MCC_COMMPROTO_VALID_KEYS_HASH = []<size_t... Is>(std::index_sequence<Is...>) {
|
||||||
|
// return std::array{mcc::utils::FNV1aHash(MCC_COMMPROTO_VALID_KEYS[Is])...};
|
||||||
|
// }(std::make_index_sequence<MCC_COMMPROTO_VALID_KEYS.size()>());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_netmsg_valid_keys_c = requires(T t) {
|
||||||
|
// std::array of valid message keywords
|
||||||
|
[]<size_t N>(std::array<std::string_view, N>) {
|
||||||
|
// to ensure T::NETMSG_VALID_KEYWORDS can be used as compile-time constant
|
||||||
|
static constexpr auto v0 = T::NETMSG_VALID_KEYWORDS[0];
|
||||||
|
return v0;
|
||||||
|
}(T::NETMSG_VALID_KEYWORDS);
|
||||||
|
|
||||||
|
// std::array of valid message keywords hashes
|
||||||
|
[]<size_t N>(std::array<size_t, N>) {
|
||||||
|
// to ensure T::NETMSG_VALID_KEYWORD_HASHES can be used as compile-time constant
|
||||||
|
static constexpr auto v0 = T::NETMSG_VALID_KEYWORD_HASHES[0];
|
||||||
|
return v0;
|
||||||
|
}(T::NETMSG_VALID_KEYWORD_HASHES);
|
||||||
|
|
||||||
|
requires T::NETMSG_VALID_KEYWORDS.size() == T::NETMSG_VALID_KEYWORD_HASHES.size();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct MccNetMessageValidKeywords {
|
||||||
|
static constexpr std::array NETMSG_VALID_KEYWORDS = {
|
||||||
|
MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR, MCC_COMMPROTO_KEYWORD_SERVER_ERROR_STR,
|
||||||
|
MCC_COMMPROTO_KEYWORD_COORDFMT_STR, MCC_COMMPROTO_KEYWORD_COORDPREC_STR,
|
||||||
|
MCC_COMMPROTO_KEYWORD_TARGET_STR, MCC_COMMPROTO_KEYWORD_MOUNT_STR,
|
||||||
|
MCC_COMMPROTO_KEYWORD_ENTEREDTAG_STR, MCC_COMMPROTO_KEYWORD_TELEMETRY_STR,
|
||||||
|
MCC_COMMPROTO_KEYWORD_INIT_STR, MCC_COMMPROTO_KEYWORD_STOP_STR,
|
||||||
|
MCC_COMMPROTO_KEYWORD_SLEW_STR, MCC_COMMPROTO_KEYWORD_MOVE_STR,
|
||||||
|
MCC_COMMPROTO_KEYWORD_TRACK_STR, MCC_COMMPROTO_KEYWORD_STATUS_STR};
|
||||||
|
|
||||||
|
|
||||||
|
// hashes of valid keywords
|
||||||
|
static constexpr std::array NETMSG_VALID_KEYWORD_HASHES = []<size_t... Is>(std::index_sequence<Is...>) {
|
||||||
|
return std::array{mcc::utils::FNV1aHash(NETMSG_VALID_KEYWORDS[Is])...};
|
||||||
|
}(std::make_index_sequence<NETMSG_VALID_KEYWORDS.size()>());
|
||||||
|
|
||||||
|
constexpr static const size_t* isKeywordValid(std::string_view key)
|
||||||
|
{
|
||||||
|
const auto hash = mcc::utils::FNV1aHash(key);
|
||||||
|
|
||||||
|
for (auto const& h : NETMSG_VALID_KEYWORD_HASHES) {
|
||||||
|
if (h == hash) {
|
||||||
|
return &h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(mcc_netmsg_valid_keys_c<MccNetMessageValidKeywords>, "");
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_netmessage_c = requires(T t) { T(); };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc::traits::mcc_char_range BYTEREPR_T = std::string_view,
|
||||||
|
mcc_netmsg_valid_keys_c BASE_T = MccNetMessageValidKeywords>
|
||||||
|
class MccNetMessage
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
// just a wrapper class to hold MccSerializer<T> specializations
|
||||||
|
struct DefaultSerializer {
|
||||||
|
template <traits::mcc_output_char_range OR, typename T>
|
||||||
|
auto operator()(OR& bytes, const T& value, mcc_serialization_params_c auto const& pars) const
|
||||||
|
{
|
||||||
|
return impl::MccSerializer<T>{}(bytes, value, pars);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef BASE_T valid_keys_t;
|
||||||
|
typedef BYTEREPR_T byte_repr_t;
|
||||||
|
|
||||||
|
enum MccNetMessageError { ERROR_OK, ERROR_EMPTY_MESSAGE, ERROR_INVALID_KEYWORD, ERROR_EMPTY_KEYWORD };
|
||||||
|
|
||||||
|
MccNetMessage() = default;
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range KT, typename... PTs>
|
||||||
|
MccNetMessage(KT&& key, PTs&&... params)
|
||||||
|
requires traits::mcc_output_char_range<BYTEREPR_T>
|
||||||
|
{
|
||||||
|
construct(_defaultSerializer, std::forward<KT>(key), std::forward<PTs>(params)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range R>
|
||||||
|
constexpr MccNetMessage(const R& msg)
|
||||||
|
requires traits::mcc_input_char_range<BYTEREPR_T>
|
||||||
|
{
|
||||||
|
fromCharRange(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// constexpr MccNetMessage(const BYTEREPR_T& msg)
|
||||||
|
// requires traits::mcc_input_char_range<BYTEREPR_T>
|
||||||
|
// {
|
||||||
|
// fromCharRange(msg);
|
||||||
|
// }
|
||||||
|
|
||||||
|
virtual ~MccNetMessage() = default;
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range KT>
|
||||||
|
constexpr bool withKey(const KT& key) const
|
||||||
|
{
|
||||||
|
if constexpr (std::is_pointer_v<std::decay_t<KT>>) {
|
||||||
|
return withKey(std::string_view{key});
|
||||||
|
}
|
||||||
|
|
||||||
|
return mcc::utils::FNV1aHash(key) == _keywordHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <traits::mcc_view_or_output_char_range R>
|
||||||
|
R keyword() const
|
||||||
|
{
|
||||||
|
if constexpr (traits::mcc_char_view<R>) {
|
||||||
|
return R{_keyword.begin(), _keyword.end()};
|
||||||
|
} else {
|
||||||
|
R r;
|
||||||
|
std::ranges::copy(_keyword, std::back_inserter(r));
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view keyword() const
|
||||||
|
{
|
||||||
|
return _keyword;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t paramSize() const
|
||||||
|
{
|
||||||
|
return _params.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::ranges::range R>
|
||||||
|
R params(size_t start_idx = 0, size_t Nelemes = std::numeric_limits<size_t>::max()) const
|
||||||
|
requires(traits::mcc_view_or_output_char_range<R> || traits::mcc_range_of_char_range<R>)
|
||||||
|
{
|
||||||
|
if (start_idx >= _params.size()) {
|
||||||
|
return R{};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto stop_idx = start_idx + Nelemes - 1;
|
||||||
|
if (stop_idx >= _params.size()) {
|
||||||
|
stop_idx = _params.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (traits::mcc_range_of_char_range<R>) { // returm parameters as array
|
||||||
|
using el_t = std::ranges::range_value_t<R>;
|
||||||
|
|
||||||
|
R r;
|
||||||
|
if constexpr (traits::mcc_char_view<el_t> || traits::mcc_output_char_range<el_t>) {
|
||||||
|
for (size_t i = start_idx; i <= stop_idx; ++i) {
|
||||||
|
auto& el = _params[i];
|
||||||
|
std::back_inserter(r) = el_t{el.begin(), el.end()};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNSUPPORTED RANGE TYPE!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
} else {
|
||||||
|
if constexpr (traits::mcc_char_view<R>) { // return joined parameters as a single char-range
|
||||||
|
return R{_params[start_idx].begin(), _params[stop_idx].end()};
|
||||||
|
} else {
|
||||||
|
R r;
|
||||||
|
std::ranges::copy(std::string_view{_params[start_idx].begin(), _params[stop_idx].end()},
|
||||||
|
std::back_inserter(r));
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view params(size_t start_idx = 0, size_t Nelemes = std::numeric_limits<size_t>::max()) const
|
||||||
|
{
|
||||||
|
return params<std::string_view>(start_idx, Nelemes);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_view_or_output_char_range R>
|
||||||
|
R param(size_t idx) const
|
||||||
|
{
|
||||||
|
if (idx >= _params.size()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (traits::mcc_char_view<R>) {
|
||||||
|
return R{_params[idx].begin(), _params[idx].end()};
|
||||||
|
} else {
|
||||||
|
R r;
|
||||||
|
std::ranges::copy(_params[idx], std::back_inserter(r));
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view param(size_t idx) const
|
||||||
|
{
|
||||||
|
if (idx >= _params.size()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return _params[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename DeserFuncT>
|
||||||
|
std::expected<T, std::error_code> paramValue(size_t idx, DeserFuncT&& deser_func) const
|
||||||
|
{
|
||||||
|
static_assert(std::invocable<DeserFuncT, typename decltype(_params)::value_type const&, T&,
|
||||||
|
impl::mcc_serialization_params_t const&>,
|
||||||
|
"INVALID DESERIALIZATION FUNCTION!");
|
||||||
|
static_assert(std::same_as<std::invoke_result_t<DeserFuncT, typename decltype(_params)::value_type const&, T&,
|
||||||
|
impl::mcc_serialization_params_t const&>,
|
||||||
|
std::error_code>,
|
||||||
|
"INVALID DESERIALIZATION FUNCTION!");
|
||||||
|
|
||||||
|
if (idx >= _params.size()) {
|
||||||
|
return std::unexpected{std::make_error_code(std::errc::value_too_large)};
|
||||||
|
}
|
||||||
|
|
||||||
|
T val;
|
||||||
|
|
||||||
|
auto ec = std::forward<DeserFuncT>(deser_func)(_params[idx], val, _serializationParams);
|
||||||
|
if (ec) {
|
||||||
|
return std::unexpected(ec);
|
||||||
|
} else {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::expected<T, std::error_code> paramValue(size_t idx) const
|
||||||
|
{
|
||||||
|
return paramValue<T>(
|
||||||
|
idx, impl::MccDeserializer<T>{}); // use one of specialization of MccDeserializer templated class
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <traits::mcc_view_or_output_char_range R>
|
||||||
|
R byteRepr() const
|
||||||
|
{
|
||||||
|
if constexpr (traits::mcc_char_view<R>) {
|
||||||
|
return R{_msgBuffer.begin(), _msgBuffer.end()};
|
||||||
|
} else {
|
||||||
|
R r;
|
||||||
|
std::ranges::copy(_msgBuffer, std::back_inserter(r));
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view byteRepr() const
|
||||||
|
{
|
||||||
|
return byteRepr<std::string_view>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range KT, typename... PTs>
|
||||||
|
std::error_code construct(KT&& key, PTs&&... params)
|
||||||
|
requires traits::mcc_output_char_range<BYTEREPR_T>
|
||||||
|
{
|
||||||
|
return construct(_defaultSerializer, std::forward<KT>(key), std::forward<PTs>(params)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// serializing function SerFuncT - a callable with the signature:
|
||||||
|
// template<typename T, mcc_output_char_range R>
|
||||||
|
// void ser_func(R&& buffer, const T& val, mcc_serialization_params_t const& pars)
|
||||||
|
//
|
||||||
|
template <typename SerFuncT, traits::mcc_input_char_range KT, typename... PTs>
|
||||||
|
std::error_code construct(SerFuncT&& ser_func, KT&& key, PTs&&... params)
|
||||||
|
requires(traits::mcc_output_char_range<BYTEREPR_T> &&
|
||||||
|
!traits::mcc_input_char_range<std::remove_cvref_t<SerFuncT>>)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_pointer_v<std::decay_t<KT>>) {
|
||||||
|
return construct(std::forward<SerFuncT>(ser_func), std::string_view(key), std::forward<PTs>(params)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!std::ranges::size(key)) {
|
||||||
|
return std::make_error_code(std::errc::invalid_argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto r = valid_keys_t::isKeywordValid(key);
|
||||||
|
if (!r) {
|
||||||
|
return std::make_error_code(std::errc::not_supported);
|
||||||
|
}
|
||||||
|
|
||||||
|
_keywordHash = *r;
|
||||||
|
|
||||||
|
_msgBuffer = BYTEREPR_T{};
|
||||||
|
|
||||||
|
std::ranges::copy(std::forward<KT>(key), std::back_inserter(_msgBuffer));
|
||||||
|
// _keyword = {_msgBuffer.begin(), _msgBuffer.end()};
|
||||||
|
size_t key_idx = std::distance(_msgBuffer.begin(), _msgBuffer.end());
|
||||||
|
std::vector<size_t> par_idx;
|
||||||
|
|
||||||
|
_params.clear();
|
||||||
|
|
||||||
|
if constexpr (sizeof...(PTs)) {
|
||||||
|
std::ranges::copy(MCC_COMMPROTO_KEYPARAM_DELIM_SEQ, std::back_inserter(_msgBuffer));
|
||||||
|
|
||||||
|
convertFunc(std::forward<SerFuncT>(ser_func), par_idx, std::forward<PTs>(params)...);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < par_idx.size(); i += 2) {
|
||||||
|
_params.emplace_back(_msgBuffer.begin() + par_idx[i], _msgBuffer.begin() + par_idx[i + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_keyword = std::string_view{_msgBuffer.begin(), _msgBuffer.begin() + key_idx};
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range R>
|
||||||
|
constexpr MccNetMessageError fromCharRange(const R& r)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_pointer_v<std::decay_t<R>>) {
|
||||||
|
return fromCharRange(std::string_view(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (std::ranges::size(r) == 0) {
|
||||||
|
return ERROR_EMPTY_MESSAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view key;
|
||||||
|
|
||||||
|
// auto prev_msg_buff = _msgBuffer;
|
||||||
|
|
||||||
|
if constexpr (traits::mcc_output_char_range<BYTEREPR_T>) {
|
||||||
|
_msgBuffer = BYTEREPR_T{};
|
||||||
|
std::ranges::copy(r, std::back_inserter(_msgBuffer));
|
||||||
|
} else {
|
||||||
|
_msgBuffer = {std::begin(r), std::end(r)};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto found = std::ranges::search(_msgBuffer, MCC_COMMPROTO_KEYPARAM_DELIM_SEQ);
|
||||||
|
|
||||||
|
if (found.empty()) { // only keyword
|
||||||
|
key = mcc::utils::trimSpaces(std::string_view{_msgBuffer.begin(), _msgBuffer.end()});
|
||||||
|
} else {
|
||||||
|
key = mcc::utils::trimSpaces(std::string_view{_msgBuffer.begin(), found.begin()});
|
||||||
|
}
|
||||||
|
|
||||||
|
auto kv = valid_keys_t::isKeywordValid(key);
|
||||||
|
if (!kv) {
|
||||||
|
// _msgBuffer = prev_msg_buff; // restore previous netmessage state
|
||||||
|
return ERROR_INVALID_KEYWORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
_keywordHash = *kv;
|
||||||
|
_keyword = key;
|
||||||
|
|
||||||
|
if (!found.empty()) { // params ...
|
||||||
|
_params.clear();
|
||||||
|
auto pr =
|
||||||
|
std::views::split(std::string_view{found.end(), _msgBuffer.end()}, MCC_COMMPROTO_PARAMPARAM_DELIM_SEQ);
|
||||||
|
for (auto const& p : pr) {
|
||||||
|
_params.emplace_back(p.begin(), p.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
size_t _keywordHash{};
|
||||||
|
std::string_view _keyword{};
|
||||||
|
std::vector<std::string_view> _params{};
|
||||||
|
|
||||||
|
BYTEREPR_T _msgBuffer{};
|
||||||
|
|
||||||
|
DefaultSerializer _defaultSerializer{};
|
||||||
|
|
||||||
|
impl::mcc_serialization_params_t _serializationParams{.seq_delim{MCC_COMMPROTO_PARAMPARAM_DELIM_SEQ},
|
||||||
|
.elem_delim{MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ}};
|
||||||
|
|
||||||
|
template <typename SerFuncT, typename T, typename... Ts>
|
||||||
|
void convertFunc(SerFuncT&& ser_func, std::vector<size_t>& idx, const T& par, const Ts&... pars)
|
||||||
|
{
|
||||||
|
if constexpr (std::same_as<T, MccSerializedCoordPairFormat>) {
|
||||||
|
_serializationParams.coordpair_format = par;
|
||||||
|
} else if constexpr (std::same_as<T, MccSerializedAngleFormatPrec>) {
|
||||||
|
_serializationParams.angle_prec = par;
|
||||||
|
} else {
|
||||||
|
idx.emplace_back(std::distance(_msgBuffer.begin(), _msgBuffer.end()));
|
||||||
|
|
||||||
|
std::forward<SerFuncT>(ser_func)(_msgBuffer, par, _serializationParams);
|
||||||
|
|
||||||
|
idx.emplace_back(std::distance(_msgBuffer.begin(), _msgBuffer.end()));
|
||||||
|
|
||||||
|
if constexpr (sizeof...(Ts)) {
|
||||||
|
std::ranges::copy(_serializationParams.seq_delim, std::back_inserter(_msgBuffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (sizeof...(Ts)) {
|
||||||
|
convertFunc(std::forward<SerFuncT>(ser_func), idx, pars...);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(MccNetMessage<std::string, MccNetMessageValidKeywords>{"ACK"}.withKey("ACK"));
|
||||||
|
static_assert(MccNetMessage{"ACK"}.withKey("ACK"));
|
||||||
|
|
||||||
|
} // namespace mcc::network
|
||||||
900
include/mcc/mcc_pcm.h
Normal file
900
include/mcc/mcc_pcm.h
Normal file
@@ -0,0 +1,900 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
* *
|
||||||
|
* MOUNT CONTROL COMPONENTS LIBRARY *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* A REFERENCE "POINTING-CORRECTION-MODEL" CLASS IMPLEMENTATION *
|
||||||
|
* *
|
||||||
|
****************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
#include "mcc_bsplines.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "mcc_concepts.h"
|
||||||
|
#include "mcc_coordinate.h"
|
||||||
|
#include "mcc_deserializer.h"
|
||||||
|
#include "mcc_serializer.h"
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class MccDefaultPCMErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_CCTE,
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
ERROR_INVALID_INPUTS_BISPLEV,
|
||||||
|
ERROR_INVALID_BSPLINE_KNOTS,
|
||||||
|
#endif
|
||||||
|
ERROR_EXCEED_MAX_ITERS,
|
||||||
|
ERROR_NULLPTR,
|
||||||
|
ERROR_JACINV
|
||||||
|
};
|
||||||
|
|
||||||
|
/* error category definition */
|
||||||
|
|
||||||
|
// error category
|
||||||
|
struct MccDefaultPCMCategory : public std::error_category {
|
||||||
|
MccDefaultPCMCategory() : std::error_category() {}
|
||||||
|
|
||||||
|
const char* name() const noexcept
|
||||||
|
{
|
||||||
|
return "MCC-DEFAULT-PCM-ERROR-CATEGORY";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message(int ec) const
|
||||||
|
{
|
||||||
|
MccDefaultPCMErrorCode err = static_cast<MccDefaultPCMErrorCode>(ec);
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
case MccDefaultPCMErrorCode::ERROR_OK:
|
||||||
|
return "OK";
|
||||||
|
case MccDefaultPCMErrorCode::ERROR_CCTE:
|
||||||
|
return "CCTE calculation error";
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
case MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV:
|
||||||
|
return "invalid input arguments for bispev";
|
||||||
|
case MccDefaultPCMErrorCode::ERROR_INVALID_BSPLINE_KNOTS:
|
||||||
|
return "invalid B-spline knots vector";
|
||||||
|
#endif
|
||||||
|
case MccDefaultPCMErrorCode::ERROR_EXCEED_MAX_ITERS:
|
||||||
|
return "exceed maximum of iterations number";
|
||||||
|
case MccDefaultPCMErrorCode::ERROR_NULLPTR:
|
||||||
|
return "nullptr input argument";
|
||||||
|
case MccDefaultPCMErrorCode::ERROR_JACINV:
|
||||||
|
return "Jacobian is near singular";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const MccDefaultPCMCategory& get()
|
||||||
|
{
|
||||||
|
static const MccDefaultPCMCategory constInst;
|
||||||
|
return constInst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline std::error_code make_error_code(MccDefaultPCMErrorCode ec)
|
||||||
|
{
|
||||||
|
return std::error_code(static_cast<int>(ec), MccDefaultPCMCategory::get());
|
||||||
|
}
|
||||||
|
} // namespace mcc::impl
|
||||||
|
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class is_error_code_enum<mcc::impl::MccDefaultPCMErrorCode> : public true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
// The routine generates a sequence of length 'innerN'+2 elements.
|
||||||
|
// Th e first element is 'start_border' and the last one is 'stop_border'
|
||||||
|
// (i.e. it returns at least 2-elements std::vector)
|
||||||
|
// 'innerN' is a number of inner elements
|
||||||
|
static std::vector<double> mccGenerateBsplineKnots(double start_border, double stop_border, size_t innerN)
|
||||||
|
{
|
||||||
|
std::vector<double> res(innerN + 2);
|
||||||
|
res.front() = start_border;
|
||||||
|
res.back() = stop_border;
|
||||||
|
|
||||||
|
if (innerN) {
|
||||||
|
const double step = (stop_border - start_border) / (innerN + 1);
|
||||||
|
std::ranges::for_each(std::views::iota(1, (int)innerN + 1),
|
||||||
|
[&](auto const& i) { res[i] = start_border + i * step; });
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// type of PCM corrections (algorithm used):
|
||||||
|
// PCM_TYPE_GEOMETRY - "classic" geometry-based correction coefficients
|
||||||
|
// PCM_TYPE_GEOMETRY_BSPLINE - previous one and additional 2D B-spline corrections
|
||||||
|
// PCM_TYPE_BSPLINE - pure 2D B-spline corrections
|
||||||
|
enum class MccDefaultPCMType { PCM_TYPE_GEOMETRY, PCM_TYPE_GEOMETRY_BSPLINE, PCM_TYPE_BSPLINE };
|
||||||
|
|
||||||
|
template <MccDefaultPCMType TYPE>
|
||||||
|
static constexpr std::string_view MccDefaultPCMTypeString =
|
||||||
|
TYPE == MccDefaultPCMType::PCM_TYPE_GEOMETRY ? "GEOMETRY"
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
: TYPE == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE ? "GEOMETRY-BSPLINE"
|
||||||
|
: TYPE == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE ? "BSPLINE"
|
||||||
|
#endif
|
||||||
|
: "UNKNOWN";
|
||||||
|
|
||||||
|
|
||||||
|
static constexpr std::string_view mccDefaultPCMTypeString(MccDefaultPCMType type)
|
||||||
|
{
|
||||||
|
return type == MccDefaultPCMType::PCM_TYPE_GEOMETRY ? "GEOMETRY"
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
: type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE ? "GEOMETRY-BSPLINE"
|
||||||
|
: type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE ? "BSPLINE"
|
||||||
|
#endif
|
||||||
|
: "UNKNOWN";
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct MccSerializer<MccDefaultPCMType> : MccSerializerBase {
|
||||||
|
constexpr static std::string_view serializerName{"MCC-DEFAULT-PCMTYPE-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
MccDefaultPCMType const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
std::ranges::copy(mccDefaultPCMTypeString(value), std::back_inserter(output));
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct MccDeserializer<MccDefaultPCMType> : MccDeserializerBase {
|
||||||
|
static constexpr std::string_view deserializerName{"MCC-COORD-EPOCH-DESERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_input_char_range auto const& input,
|
||||||
|
MccDefaultPCMType& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
auto s = mcc::utils::trimSpaces(input);
|
||||||
|
|
||||||
|
if (s == mcc::impl::MccDefaultPCMTypeString<mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY>) {
|
||||||
|
value = mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY;
|
||||||
|
} else if (s == mcc::impl::MccDefaultPCMTypeString<mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE>) {
|
||||||
|
value = mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY;
|
||||||
|
} else if (s == mcc::impl::MccDefaultPCMTypeString<mcc::impl::MccDefaultPCMType::PCM_TYPE_BSPLINE>) {
|
||||||
|
value = mcc::impl::MccDefaultPCMType::PCM_TYPE_BSPLINE;
|
||||||
|
} else {
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <MccMountType MOUNT_TYPE>
|
||||||
|
class MccDefaultPCM : public mcc_pcm_interface_t<std::error_code>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// static constexpr MccMountType mountType = MOUNT_TYPE;
|
||||||
|
static constexpr MccMountType pcmMountType = MOUNT_TYPE;
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
static constexpr std::string_view pcmName{"MCC-GEOMETRY-BSPLINES-PCM"};
|
||||||
|
#else
|
||||||
|
static constexpr std::string_view pcmName{"MCC-GEOMETRY-ONLY-PCM"};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef std::error_code error_t;
|
||||||
|
typedef double coord_t;
|
||||||
|
|
||||||
|
|
||||||
|
// "classic" geometric PCM coefficients
|
||||||
|
struct pcm_geom_coeffs_t {
|
||||||
|
typedef double coeff_t;
|
||||||
|
|
||||||
|
coeff_t zeroPointX;
|
||||||
|
coeff_t zeroPointY;
|
||||||
|
coeff_t collimationErr; // tube collimation error
|
||||||
|
coeff_t nonperpendErr; // X-Y axes nonperpendicularity
|
||||||
|
coeff_t misalignErr1; // misalignment of hour-angle/azimuth axis: left-right for equatorial, East-West for
|
||||||
|
// alt-azimuthal
|
||||||
|
coeff_t misalignErr2; // misalignment of hour-angle/azimuth axis: vertical for equatorial, North-South for
|
||||||
|
// alt-azimuthal
|
||||||
|
|
||||||
|
coeff_t tubeFlexure;
|
||||||
|
coeff_t DECaxisFlexure; // declination axis flexure
|
||||||
|
coeff_t forkFlexure;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
// B-splines related data structure (coefficients, knots ...)
|
||||||
|
struct pcm_bspline_t {
|
||||||
|
typedef double knot_t;
|
||||||
|
typedef double coeff_t;
|
||||||
|
|
||||||
|
size_t bsplDegreeX = 3;
|
||||||
|
size_t bsplDegreeY = 3;
|
||||||
|
|
||||||
|
std::vector<knot_t> knotsX{}; // inner knots vector (at least 2-element)
|
||||||
|
std::vector<knot_t> knotsY{}; // inner knots vector (at least 2-element)
|
||||||
|
|
||||||
|
std::vector<coeff_t> coeffsX{}; // B-spline coefficients for relation func(CelestialX - hardwareX)
|
||||||
|
std::vector<coeff_t> coeffsY{}; // B-spline coefficients for relation func(CelestialY - hardwareY)
|
||||||
|
|
||||||
|
std::vector<coeff_t> inverseCoeffsX{}; // B-spline coefficients for relation func(hardwareX - CelestialX)
|
||||||
|
std::vector<coeff_t> inverseCoeffsY{}; // B-spline coefficients for relation func(hardwareY - CelestialY)
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct pcm_data_t {
|
||||||
|
typedef MccDefaultPCM pcm_t;
|
||||||
|
|
||||||
|
MccDefaultPCMType type{MccDefaultPCMType::PCM_TYPE_GEOMETRY};
|
||||||
|
double siteLatitude{0.0}; // in radians
|
||||||
|
|
||||||
|
// from encoder to observed celestial
|
||||||
|
pcm_geom_coeffs_t geomCoefficients{};
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
pcm_bspline_t bspline{};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// from observed celestial to encoder
|
||||||
|
pcm_geom_coeffs_t inverseGeomCoefficients{};
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
pcm_bspline_t inverseBspline{};
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
// constructors
|
||||||
|
|
||||||
|
MccDefaultPCM() = default;
|
||||||
|
MccDefaultPCM(pcm_data_t pdata) : MccDefaultPCM()
|
||||||
|
{
|
||||||
|
setPCMData(std::move(pdata));
|
||||||
|
}
|
||||||
|
|
||||||
|
MccDefaultPCM(MccDefaultPCM&& other) = default;
|
||||||
|
MccDefaultPCM& operator=(MccDefaultPCM&& other) = default;
|
||||||
|
|
||||||
|
MccDefaultPCM(const MccDefaultPCM&) = delete;
|
||||||
|
MccDefaultPCM& operator=(const MccDefaultPCM&) = delete;
|
||||||
|
|
||||||
|
virtual ~MccDefaultPCM() = default;
|
||||||
|
|
||||||
|
// virtual ~MccDefaultPCM() {
|
||||||
|
// // _pcmData.geomCoefficients.DECaxisFlexure = 0.0;
|
||||||
|
// };
|
||||||
|
|
||||||
|
void setPCMData(pcm_data_t pdata)
|
||||||
|
{
|
||||||
|
std::lock_guard lock(*_pcmDataMutex);
|
||||||
|
|
||||||
|
_pcmData = std::move(pdata);
|
||||||
|
|
||||||
|
_cosPhi = std::cos(_pcmData.siteLatitude);
|
||||||
|
_sinPhi = std::sin(_pcmData.siteLatitude);
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
// recompute full set of B-spline knots
|
||||||
|
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE ||
|
||||||
|
_pcmData.type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
|
||||||
|
if (_pcmData.bspline.knotsX.size() > 1 && _pcmData.bspline.knotsY.size() > 1) {
|
||||||
|
_knotsX.resize(_pcmData.bspline.knotsX.size() + 6);
|
||||||
|
_knotsY.resize(_pcmData.bspline.knotsY.size() + 6);
|
||||||
|
} else {
|
||||||
|
_knotsX.clear();
|
||||||
|
_knotsY.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// full set of B-spline knots
|
||||||
|
_knotsX[0] = _knotsX[1] = _knotsX[2] = _pcmData.bspline.knotsX[0];
|
||||||
|
_knotsX[_knotsX.size() - 1] = _knotsX[_knotsX.size() - 2] = _knotsX[_knotsX.size() - 3] =
|
||||||
|
_pcmData.bspline.knotsX.back();
|
||||||
|
|
||||||
|
_knotsY[0] = _knotsY[1] = _knotsY[2] = _pcmData.bspline.knotsY[0];
|
||||||
|
_knotsY[_knotsY.size() - 1] = _knotsY[_knotsY.size() - 2] = _knotsY[_knotsY.size() - 3] =
|
||||||
|
_pcmData.bspline.knotsY.back();
|
||||||
|
|
||||||
|
for (size_t i = 0; i < _pcmData.bspline.knotsX.size(); ++i) {
|
||||||
|
_knotsX[3 + i] = _pcmData.bspline.knotsX[i];
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < _pcmData.bspline.knotsY.size(); ++i) {
|
||||||
|
_knotsY[3 + i] = _pcmData.bspline.knotsY[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pcm_data_t getPCMData() const
|
||||||
|
{
|
||||||
|
std::lock_guard lock(*_pcmDataMutex);
|
||||||
|
|
||||||
|
return _pcmData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPCMType(MccDefaultPCMType type)
|
||||||
|
{
|
||||||
|
std::lock_guard lock(*_pcmDataMutex);
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
_pcmData.type = type;
|
||||||
|
#else
|
||||||
|
_pcmData.type = MccDefaultPCMType::PCM_TYPE_GEOMETRY;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
MccDefaultPCMType getPCMType() const
|
||||||
|
{
|
||||||
|
std::lock_guard lock(*_pcmDataMutex);
|
||||||
|
|
||||||
|
return _pcmData.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The computed PCM quantities must be interpretated as:
|
||||||
|
// observed_X = encoder_X + res.pcmX
|
||||||
|
// observed_Y = encoder_Y + res.pcmY
|
||||||
|
// so, input hw_coord is assumed to be coordinates pair of mount axis encoder readouts
|
||||||
|
template <typename T = std::nullptr_t>
|
||||||
|
error_t computePCM(mcc_coord_pair_c auto const& hw_coord, mcc_pcm_result_c auto* res, T* obs_skycoord = nullptr)
|
||||||
|
requires(mcc_skypoint_c<T> || std::is_null_pointer_v<T>)
|
||||||
|
{
|
||||||
|
if (res == nullptr) {
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::lock_guard lock(*_pcmDataMutex);
|
||||||
|
|
||||||
|
res->pcmX = 0.0;
|
||||||
|
res->pcmY = 0.0;
|
||||||
|
|
||||||
|
// auto ret = _compResult(hw_coord.x(), hw_coord.y(), res, false);
|
||||||
|
auto ret = _computeFuncDeriv(hw_coord.x(), hw_coord.y(), res);
|
||||||
|
if (ret) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (mcc_is_equatorial_mount<MOUNT_TYPE>) { // equatorial (HA and DEC axes)
|
||||||
|
if constexpr (mcc_skypoint_c<T>) {
|
||||||
|
obs_skycoord->from(MccSkyHADEC_OBS{double(hw_coord.x() + res->pcmX), double(hw_coord.y() + res->pcmY),
|
||||||
|
hw_coord.epoch()});
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if constexpr (mcc_is_altaz_mount<MOUNT_TYPE>) {
|
||||||
|
if constexpr (mcc_skypoint_c<T>) {
|
||||||
|
obs_skycoord->from(
|
||||||
|
MccSkyAZZD{double(hw_coord.x() + res->pcmX), double(hw_coord.y() + res->pcmY), hw_coord.epoch()});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNSUPPORTED MOUNT TYPE");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// computed inverse PCM corrections must be interpretated as:
|
||||||
|
// X_encoder = X_observed + res->pcmX
|
||||||
|
// Y_encoder = Y_observed + res->pcmY
|
||||||
|
//
|
||||||
|
template <typename T>
|
||||||
|
error_t computeInversePCM(mcc_skypoint_c auto const& obs_skycoord, mcc_pcm_result_c auto* res, T* hw_pt = nullptr)
|
||||||
|
requires(mcc_coord_pair_c<T> || std::is_null_pointer_v<T>)
|
||||||
|
{
|
||||||
|
error_t ret = MccDefaultPCMErrorCode::ERROR_OK;
|
||||||
|
|
||||||
|
if constexpr (mcc_coord_pair_c<T>) {
|
||||||
|
static_assert(
|
||||||
|
T::pairKind == MccCoordPairKind::COORDS_KIND_GENERIC || T::pairKind == MccCoordPairKind::COORDS_KIND_XY,
|
||||||
|
"Invalid output coordinate pair type!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// to be computed as observed celestial X and Y cordinate according to mount type (HA-DEC or AZ-ZD)
|
||||||
|
double x, y;
|
||||||
|
|
||||||
|
auto getXY = [&, this](auto& cp) -> error_t {
|
||||||
|
auto err = obs_skycoord.toAtSameEpoch(cp);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccDefaultPCMErrorCode::ERROR_CCTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
x = cp.x();
|
||||||
|
y = cp.y();
|
||||||
|
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_OK;
|
||||||
|
};
|
||||||
|
|
||||||
|
if constexpr (mcc_is_equatorial_mount<MOUNT_TYPE>) {
|
||||||
|
MccSkyHADEC_OBS hadec;
|
||||||
|
ret = getXY(hadec);
|
||||||
|
} else if constexpr (mcc_is_altaz_mount<MOUNT_TYPE>) {
|
||||||
|
MccSkyAZZD azzd;
|
||||||
|
ret = getXY(azzd);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::lock_guard lock(*_pcmDataMutex);
|
||||||
|
|
||||||
|
if (_pcmData.type != MccDefaultPCMType::PCM_TYPE_BSPLINE) { // compute using Newton-Raphson correction
|
||||||
|
struct {
|
||||||
|
double pcmX, pcmY;
|
||||||
|
} dfx, dfy, df; // partial derivatives
|
||||||
|
|
||||||
|
ret = _computeFuncDeriv(x, y, res, true, &dfx, &dfy);
|
||||||
|
if (ret) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// are all geometry coeffs equal to 0?
|
||||||
|
if (utils::isEqual(dfx.pcmX, 0.0) && utils::isEqual(dfy.pcmX, 0.0) && utils::isEqual(dfx.pcmY, 0.0) &&
|
||||||
|
utils::isEqual(dfy.pcmY, 0.0)) {
|
||||||
|
if constexpr (mcc_coord_pair_c<T>) {
|
||||||
|
*hw_pt = MccCoordPair<typename T::x_t, typename T::y_t>{x, y, obs_skycoord.epoch()};
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
dfx.pcmX += 1.0; // a
|
||||||
|
dfx.pcmY += 1.0; // b
|
||||||
|
dfy.pcmX += 1.0; // c
|
||||||
|
dfy.pcmY += 1.0; // d
|
||||||
|
|
||||||
|
// Jacobian determinant
|
||||||
|
auto detJ = dfx.pcmX * dfy.pcmY - dfx.pcmY * dfy.pcmX;
|
||||||
|
if (utils::isEqual(detJ, 0.0)) {
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_JACINV;
|
||||||
|
}
|
||||||
|
|
||||||
|
// | a b |
|
||||||
|
// if A = | c d |, then
|
||||||
|
//
|
||||||
|
// -1 | d -b |
|
||||||
|
// A = 1/detA * | -c a |
|
||||||
|
//
|
||||||
|
// and
|
||||||
|
//
|
||||||
|
// -1 | pcmX | | d*pcmX - b*pcmY |
|
||||||
|
// A * | pcmY | = | -c*pcmX + a*pcmY |
|
||||||
|
//
|
||||||
|
|
||||||
|
df.pcmX = (dfy.pcmY * res->pcmX - dfx.pcmY * res->pcmY) / detJ;
|
||||||
|
df.pcmY = (-dfy.pcmX * res->pcmX + dfx.pcmX * res->pcmY) / detJ;
|
||||||
|
|
||||||
|
res->pcmX = -df.pcmX;
|
||||||
|
res->pcmY = -df.pcmY;
|
||||||
|
// res->pcmX -= df.pcmX;
|
||||||
|
// res->pcmY -= df.pcmY;
|
||||||
|
|
||||||
|
// if constexpr (mcc_coord_pair_c<T>) {
|
||||||
|
// *hw_pt = MccCoordPair<typename T::x_t, typename T::y_t>{res->pcmX, res->pcmY, obs_skycoord.epoch()};
|
||||||
|
// }
|
||||||
|
if constexpr (mcc_coord_pair_c<T>) {
|
||||||
|
*hw_pt =
|
||||||
|
MccCoordPair<typename T::x_t, typename T::y_t>{x + res->pcmX, y + res->pcmY, obs_skycoord.epoch()};
|
||||||
|
}
|
||||||
|
} else { // for B-splines the result is computed directly from inverse B-spline coefficients
|
||||||
|
ret = _computeFuncDeriv(x, y, res, true);
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
if constexpr (mcc_coord_pair_c<T>) {
|
||||||
|
*hw_pt = MccCoordPair<typename T::x_t, typename T::y_t>{x + res->pcmX, y + res->pcmY,
|
||||||
|
obs_skycoord.epoch()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ret = _compResult(x, y, res, true);
|
||||||
|
// if (!ret) {
|
||||||
|
// if constexpr (mcc_coord_pair_c<T>) {
|
||||||
|
// *hw_pt =
|
||||||
|
// MccCoordPair<typename T::x_t, typename T::y_t>{x + res->pcmX, y + res->pcmY,
|
||||||
|
// obs_skycoord.epoch()};
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
template <typename T>
|
||||||
|
error_t computeInversePCM(mcc_skypoint_c auto const& obs_skycoord,
|
||||||
|
mcc_pcm_result_c auto* result,
|
||||||
|
T* hw_pt = nullptr)
|
||||||
|
requires(mcc_coord_pair_c<T> || std::is_null_pointer_v<T>)
|
||||||
|
{
|
||||||
|
error_t ret = MccDefaultPCMErrorCode::ERROR_OK;
|
||||||
|
|
||||||
|
if constexpr (mcc_coord_pair_c<T>) {
|
||||||
|
static_assert(
|
||||||
|
T::pairKind == MccCoordPairKind::COORDS_KIND_GENERIC || T::pairKind == MccCoordPairKind::COORDS_KIND_XY,
|
||||||
|
"Invalid output coordinate pair type!");
|
||||||
|
}
|
||||||
|
|
||||||
|
double x, y;
|
||||||
|
|
||||||
|
auto comp_func = [&, this](auto& cp) {
|
||||||
|
auto err = obs_skycoord.toAtSameEpoch(cp);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccDefaultPCMErrorCode::ERROR_CCTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
x = cp.x();
|
||||||
|
y = cp.y();
|
||||||
|
|
||||||
|
return computePCM(cp, result);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// for small corrections only!!!
|
||||||
|
if constexpr (mcc_is_equatorial_mount<MOUNT_TYPE>) {
|
||||||
|
MccSkyHADEC_OBS hadec;
|
||||||
|
ret = comp_func(hadec);
|
||||||
|
} else if constexpr (mcc_is_altaz_mount<MOUNT_TYPE>) {
|
||||||
|
MccSkyAZZD azzd;
|
||||||
|
ret = comp_func(azzd);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (mcc_coord_pair_c<T>) {
|
||||||
|
*hw_pt = MccCoordPair<typename T::x_t, typename T::y_t>{x - result->pcmX, y - result->pcmY};
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
private:
|
||||||
|
pcm_data_t _pcmData{};
|
||||||
|
double _cosPhi{}, _sinPhi{};
|
||||||
|
|
||||||
|
std::vector<double> _knotsX{}, _knotsY{}; // store a full set of B-spline knots
|
||||||
|
|
||||||
|
std::unique_ptr<std::mutex> _pcmDataMutex{new std::mutex};
|
||||||
|
|
||||||
|
|
||||||
|
// compute PCM function and its partial derivatives if asked
|
||||||
|
template <typename DXT = std::nullptr_t, typename DYT = std::nullptr_t>
|
||||||
|
error_t _computeFuncDeriv(double x,
|
||||||
|
double y,
|
||||||
|
mcc_pcm_result_c auto* res,
|
||||||
|
bool inverse = false,
|
||||||
|
DXT derivX = nullptr,
|
||||||
|
DYT derivY = nullptr)
|
||||||
|
requires((std::is_null_pointer_v<DXT> || mcc_pcm_result_c<std::remove_pointer_t<DXT>>) &&
|
||||||
|
(std::is_null_pointer_v<DYT> || mcc_pcm_result_c<std::remove_pointer_t<DYT>>))
|
||||||
|
{
|
||||||
|
if constexpr (std::is_null_pointer_v<DXT> || std::is_null_pointer_v<DYT>) {
|
||||||
|
if (_pcmData.type != MccDefaultPCMType::PCM_TYPE_BSPLINE && inverse) {
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_NULLPTR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if constexpr (mcc_is_equatorial_mount<MOUNT_TYPE>) { // HA - DEC system (needs normalization)
|
||||||
|
if (!inverse) {
|
||||||
|
x = MccAngleHA_OBS(x);
|
||||||
|
y = MccAngleDEC_OBS(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// in the case of inverse PCM it is assumed that angles are already normalized (inputs are celestial
|
||||||
|
// coordiinates)
|
||||||
|
}
|
||||||
|
|
||||||
|
pcm_geom_coeffs_t* geom_coeffs = &_pcmData.geomCoefficients;
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_BSPLINE ||
|
||||||
|
_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
|
||||||
|
if (_knotsX.empty() || _knotsY.empty()) {
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_INVALID_BSPLINE_KNOTS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pcm_bspline_t* bspline = &_pcmData.bspline;
|
||||||
|
// pcm_bspline_t* inv_bspline = &_pcmData.inverseBspline;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY ||
|
||||||
|
_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
|
||||||
|
#endif
|
||||||
|
const auto tanY = std::tan(y);
|
||||||
|
const auto sinX = std::sin(x);
|
||||||
|
const auto cosX = std::cos(x);
|
||||||
|
const auto cosY = std::cos(y);
|
||||||
|
const auto sinY = std::sin(y);
|
||||||
|
|
||||||
|
|
||||||
|
if (utils::isEqual(cosY, 0.0)) {
|
||||||
|
res->pcmX = _pcmData.geomCoefficients.zeroPointX;
|
||||||
|
if constexpr (!std::is_null_pointer_v<DXT>) {
|
||||||
|
derivX->pcmX = 0.0; // dpcmX/dX
|
||||||
|
derivX->pcmY = 0.0; // dpcmX/dY
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res->pcmX = geom_coeffs->zeroPointX + geom_coeffs->collimationErr / cosY +
|
||||||
|
geom_coeffs->nonperpendErr * tanY - geom_coeffs->misalignErr1 * cosX * tanY +
|
||||||
|
geom_coeffs->misalignErr2 * sinX * tanY + geom_coeffs->tubeFlexure * _cosPhi * sinX / cosY -
|
||||||
|
geom_coeffs->DECaxisFlexure * (_cosPhi * cosX + _sinPhi * tanY);
|
||||||
|
|
||||||
|
if constexpr (!std::is_null_pointer_v<DXT>) {
|
||||||
|
auto cos2Y = cosY * cosY;
|
||||||
|
|
||||||
|
derivX->pcmX = (geom_coeffs->misalignErr1 * sinX + geom_coeffs->misalignErr2 * cosX) * tanY +
|
||||||
|
geom_coeffs->tubeFlexure * _cosPhi * cosX / cosY +
|
||||||
|
geom_coeffs->DECaxisFlexure * _cosPhi * sinX; // dpcmX/dX
|
||||||
|
|
||||||
|
derivX->pcmY =
|
||||||
|
(geom_coeffs->collimationErr * sinY + geom_coeffs->nonperpendErr -
|
||||||
|
geom_coeffs->misalignErr1 * cosX + geom_coeffs->misalignErr2 * sinX +
|
||||||
|
geom_coeffs->tubeFlexure * _cosPhi * sinX * sinY - geom_coeffs->DECaxisFlexure * _sinPhi) /
|
||||||
|
cos2Y; // dpcmX/dY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res->pcmY = geom_coeffs->zeroPointY + geom_coeffs->misalignErr1 * sinX + geom_coeffs->misalignErr2 * cosX +
|
||||||
|
geom_coeffs->tubeFlexure * (_cosPhi * cosX * sinY - _sinPhi * cosY);
|
||||||
|
|
||||||
|
if constexpr (!std::is_null_pointer_v<DYT>) {
|
||||||
|
derivY->pcmX = geom_coeffs->misalignErr1 * cosX - geom_coeffs->misalignErr2 * sinX -
|
||||||
|
geom_coeffs->tubeFlexure * _cosPhi * sinX * sinY; // dpcmY/dX
|
||||||
|
|
||||||
|
derivY->pcmY = geom_coeffs->tubeFlexure * (_cosPhi * cosX * cosY + _sinPhi * sinY); // dpcmY/dY
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (pcmMountType == MccMountType::FORK_TYPE) {
|
||||||
|
if (!utils::isEqual(cosX, 0.0)) {
|
||||||
|
res->pcmY += geom_coeffs->forkFlexure / cosX;
|
||||||
|
|
||||||
|
if constexpr (!std::is_null_pointer_v<DYT>) {
|
||||||
|
derivY->pcmY += geom_coeffs->forkFlexure * sinX / cosX / cosY; // dpcmY/dY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_BSPLINE ||
|
||||||
|
(_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE && !inverse)) {
|
||||||
|
double spl_valX, spl_valY;
|
||||||
|
|
||||||
|
int ret = bsplines::fitpack_eval_spl2d(_knotsX, _knotsY, bspline->coeffsX, x, y, spl_valX,
|
||||||
|
bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
// int ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsX, x, y,
|
||||||
|
// spl_valX,
|
||||||
|
// bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
res->pcmX = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
res->pcmY = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ret = bsplines::fitpack_eval_spl2d(_knotsX, _knotsY, bspline->coeffsY, x, y, spl_valY, bspline->bsplDegreeX,
|
||||||
|
bspline->bsplDegreeY);
|
||||||
|
// ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsY, x, y, spl_valY,
|
||||||
|
// bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
res->pcmX = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
res->pcmY = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
res->pcmX += spl_valX;
|
||||||
|
res->pcmY += spl_valY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute partial derivatives of the bivariate B-spline
|
||||||
|
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE && inverse) {
|
||||||
|
double dspl_valX, dspl_valY;
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if constexpr (!std::is_null_pointer_v<DXT>) {
|
||||||
|
ret = bsplines::fitpack_parder_spl2d(_knotsX, _knotsY, bspline->coeffsX, x, y, dspl_valX, 1, 0,
|
||||||
|
bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
// ret = bsplines::fitpack_parder_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsX, x, y,
|
||||||
|
// dspl_valX, 1, 0, bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
derivX->pcmX += dspl_valX; // dpcmX/dX
|
||||||
|
|
||||||
|
ret = bsplines::fitpack_parder_spl2d(_knotsX, _knotsY, bspline->coeffsX, x, y, dspl_valX, 0, 1,
|
||||||
|
bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
// ret = bsplines::fitpack_parder_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsX, x, y,
|
||||||
|
// dspl_valX, 0, 1, bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
derivX->pcmY += dspl_valX; // dpcmX/dY
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (!std::is_null_pointer_v<DYT>) {
|
||||||
|
ret = bsplines::fitpack_parder_spl2d(_knotsX, _knotsY, bspline->coeffsY, x, y, dspl_valY, 1, 0,
|
||||||
|
bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
// ret = bsplines::fitpack_parder_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsY, x, y,
|
||||||
|
// dspl_valY, 1, 0, bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
derivY->pcmX += dspl_valY; // dpcmY/dX
|
||||||
|
|
||||||
|
ret = bsplines::fitpack_parder_spl2d(_knotsX, _knotsY, bspline->coeffsY, x, y, dspl_valY, 0, 1,
|
||||||
|
bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
// ret = bsplines::fitpack_parder_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsY, x, y,
|
||||||
|
// dspl_valY, 0, 1, bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
derivY->pcmY += dspl_valY; // dpcmY/dY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// for inverse PCM the inverse spline coefficients are used (derivatives are not computed)!!!
|
||||||
|
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_BSPLINE && inverse) {
|
||||||
|
double spl_valX, spl_valY;
|
||||||
|
|
||||||
|
int ret = bsplines::fitpack_eval_spl2d(_knotsX, _knotsY, bspline->inverseCoeffsX, x, y, spl_valX,
|
||||||
|
bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
// int ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->inverseCoeffsX, x, y,
|
||||||
|
// spl_valX, bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
res->pcmX = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
res->pcmY = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ret = bsplines::fitpack_eval_spl2d(_knotsX, _knotsY, bspline->inverseCoeffsY, x, y, spl_valY,
|
||||||
|
bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
// ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->inverseCoeffsY, x, y,
|
||||||
|
// spl_valY, bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
res->pcmX = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
res->pcmY = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
res->pcmX = spl_valX;
|
||||||
|
res->pcmY = spl_valY;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_t _compResult(double x, double y, mcc_pcm_result_c auto* res, bool inverse)
|
||||||
|
{
|
||||||
|
pcm_geom_coeffs_t* geom_coeffs;
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
pcm_bspline_t* bspline;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
geom_coeffs = inverse ? &_pcmData.inverseGeomCoefficients : &_pcmData.geomCoefficients;
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
bspline = inverse ? &_pcmData.inverseBspline : &_pcmData.bspline;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY ||
|
||||||
|
_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
|
||||||
|
#endif
|
||||||
|
const auto tanY = std::tan(y);
|
||||||
|
const auto sinX = std::sin(x);
|
||||||
|
const auto cosX = std::cos(x);
|
||||||
|
const auto cosY = std::cos(y);
|
||||||
|
|
||||||
|
|
||||||
|
if (utils::isEqual(cosY, 0.0)) {
|
||||||
|
res->pcmX = _pcmData.geomCoefficients.zeroPointX;
|
||||||
|
} else {
|
||||||
|
res->pcmX = geom_coeffs->zeroPointX + geom_coeffs->collimationErr / cosY +
|
||||||
|
geom_coeffs->nonperpendErr * tanY - geom_coeffs->misalignErr1 * cosX * tanY +
|
||||||
|
geom_coeffs->misalignErr2 * sinX * tanY + geom_coeffs->tubeFlexure * _cosPhi * sinX / cosY -
|
||||||
|
geom_coeffs->DECaxisFlexure * (_cosPhi * cosX + _sinPhi * tanY);
|
||||||
|
}
|
||||||
|
|
||||||
|
res->pcmY = geom_coeffs->zeroPointY + geom_coeffs->misalignErr1 * sinX + geom_coeffs->misalignErr2 * cosX +
|
||||||
|
geom_coeffs->tubeFlexure * (_cosPhi * cosX * std::sin(y) - _sinPhi * cosY);
|
||||||
|
|
||||||
|
// if constexpr (mountType == MccMountType::FORK_TYPE) {
|
||||||
|
if constexpr (pcmMountType == MccMountType::FORK_TYPE) {
|
||||||
|
if (!utils::isEqual(cosX, 0.0)) {
|
||||||
|
res->pcmY += geom_coeffs->forkFlexure / cosX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_BSPLINE ||
|
||||||
|
_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
|
||||||
|
double spl_valX, spl_valY;
|
||||||
|
|
||||||
|
int ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsX, x, y, spl_valX,
|
||||||
|
bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
res->pcmX = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
res->pcmY = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsY, x, y, spl_valY,
|
||||||
|
bspline->bsplDegreeX, bspline->bsplDegreeY);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
res->pcmX = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
res->pcmY = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
res->pcmX += spl_valX;
|
||||||
|
res->pcmY += spl_valY;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return MccDefaultPCMErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef MccDefaultPCM<MccMountType::ALTAZ_TYPE> MccMountDefaultAltAzPec;
|
||||||
|
typedef MccDefaultPCM<MccMountType::FORK_TYPE> MccMountDefaultForkPec;
|
||||||
|
|
||||||
|
static_assert(mcc_pcm_c<MccMountDefaultForkPec>, "");
|
||||||
|
static_assert(std::movable<MccMountDefaultForkPec>);
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
618
include/mcc/mcc_pcm_construct.h
Normal file
618
include/mcc/mcc_pcm_construct.h
Normal file
@@ -0,0 +1,618 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
* *
|
||||||
|
* MOUNT CONTROL COMPONENTS LIBRARY *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* "POINTING-CORRECTION-MODEL" FITTER *
|
||||||
|
* *
|
||||||
|
****************************************************************************************/
|
||||||
|
|
||||||
|
#include <eigen3/Eigen/Dense>
|
||||||
|
|
||||||
|
#include "mcc_concepts.h"
|
||||||
|
#include "mcc_coordinate.h"
|
||||||
|
#include "mcc_pcm.h"
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class MccDefaultPCMConstructorErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_NOT_ENOUGH_DATA,
|
||||||
|
ERROR_INVALID_INDEX,
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
ERROR_INVALID_KNOTS_NUMBER,
|
||||||
|
ERROR_BSPLINE_FIT
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
// error category
|
||||||
|
|
||||||
|
struct MccDefaultPCMConstructorErrorCategory : std::error_category {
|
||||||
|
MccDefaultPCMConstructorErrorCategory() = default;
|
||||||
|
|
||||||
|
const char* name() const noexcept
|
||||||
|
{
|
||||||
|
return "MCC-DEFAULT-PCM-CONSTRUCTOR-ERROR-CATEGORY";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message(int ec) const
|
||||||
|
{
|
||||||
|
MccDefaultPCMConstructorErrorCode err = static_cast<MccDefaultPCMConstructorErrorCode>(ec);
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
case MccDefaultPCMConstructorErrorCode::ERROR_OK:
|
||||||
|
return "OK";
|
||||||
|
case MccDefaultPCMConstructorErrorCode::ERROR_NOT_ENOUGH_DATA:
|
||||||
|
return "not enough data point";
|
||||||
|
case MccDefaultPCMConstructorErrorCode::ERROR_INVALID_INDEX:
|
||||||
|
return "invalid index of data point";
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
case MccDefaultPCMConstructorErrorCode::ERROR_INVALID_KNOTS_NUMBER:
|
||||||
|
return "invalid number of B-spline knots";
|
||||||
|
case MccDefaultPCMConstructorErrorCode::ERROR_BSPLINE_FIT:
|
||||||
|
return "B-spline fitting error";
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const MccDefaultPCMConstructorErrorCategory& get()
|
||||||
|
{
|
||||||
|
static const MccDefaultPCMConstructorErrorCategory constInst;
|
||||||
|
return constInst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline std::error_code make_error_code(MccDefaultPCMConstructorErrorCode ec)
|
||||||
|
{
|
||||||
|
return std::error_code(static_cast<int>(ec), MccDefaultPCMConstructorErrorCategory::get());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
|
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class is_error_code_enum<mcc::impl::MccDefaultPCMConstructorErrorCode> : public true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
template <MccMountType MOUNT_TYPE>
|
||||||
|
class MccPCMConstructor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using ref_coordpair_t = std::conditional_t<mcc_is_equatorial_mount<MOUNT_TYPE>,
|
||||||
|
MccSkyHADEC_OBS,
|
||||||
|
std::conditional_t<mcc_is_altaz_mount<MOUNT_TYPE>, MccSkyAZZD, void>>;
|
||||||
|
|
||||||
|
static_assert(!std::is_void_v<ref_coordpair_t>, "UNSUPPORTED MOUNT TYPE!");
|
||||||
|
|
||||||
|
struct table_t {
|
||||||
|
std::vector<double> target_colon{}, target_colat{};
|
||||||
|
std::vector<double> hw_colon{}, hw_colat{};
|
||||||
|
std::vector<double> colon_res{}, colat_res{}; // target - hw
|
||||||
|
};
|
||||||
|
|
||||||
|
struct compute_result_t {
|
||||||
|
MccDefaultPCMType pcm_type;
|
||||||
|
MccError error{}; // final model computation error
|
||||||
|
|
||||||
|
size_t final_iter{}; // number of final iteration
|
||||||
|
|
||||||
|
std::vector<double> model_colon{}, model_colat{}; // fitting model values
|
||||||
|
std::vector<double> colon_res{}, colat_res{}; // target - model
|
||||||
|
std::vector<double> colon_weight{}, colat_weight; // Tukey's weights
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
int bspline_fit_err{}; // bivariate B-spline fitting exit code (see FITPACK)
|
||||||
|
|
||||||
|
// quantities below are computed only fo pcm_type == MccDefaultPCMType::PCM_TYPE_BSPLINE
|
||||||
|
std::vector<double> inv_model_colon, inv_model_colat; // fitted inverse model values
|
||||||
|
std::vector<double> inv_colon_res, inv_colat_res; // encoder - model
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
struct compute_params_t {
|
||||||
|
size_t max_iter{100}; // max number of iterations for robust linear regression method
|
||||||
|
double c{4.685}; // Tukey's parameter
|
||||||
|
double tolerance{1.0E-6}; //
|
||||||
|
};
|
||||||
|
|
||||||
|
template <mcc_coord_pair_c TAG_T, mcc_coord_pair_c HW_T>
|
||||||
|
MccError addPoint(TAG_T target_coords, HW_T const& hw_counts)
|
||||||
|
requires(TAG_T::pairKind == ref_coordpair_t::pairKind && HW_T::pairKind == MccCoordPairKind::COORDS_KIND_XY)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// TODO: target_coords.epoch() != hw_counts.epoch() ?!!!!!!!!!
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
_tableEpoch.emplace_back(hw_counts.epoch());
|
||||||
|
|
||||||
|
_table.target_colon.emplace_back(target_coords.x());
|
||||||
|
_table.target_colat.emplace_back(target_coords.y());
|
||||||
|
|
||||||
|
_table.hw_colon.emplace_back(hw_counts.x());
|
||||||
|
_table.hw_colat.emplace_back(hw_counts.y());
|
||||||
|
|
||||||
|
_table.colon_res.emplace_back((double)target_coords.x() - (double)hw_counts.x());
|
||||||
|
_table.colat_res.emplace_back((double)target_coords.y() - (double)hw_counts.y());
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
MccError addPoint(mcc_skypoint_c auto const& target_coords, mcc_coord_pair_c auto const& hw_counts)
|
||||||
|
requires(std::decay_t<decltype(hw_counts)>::pairKind == MccCoordPairKind::COORDS_KIND_XY)
|
||||||
|
{
|
||||||
|
ref_coordpair_t cp;
|
||||||
|
|
||||||
|
cp.setEpoch(hw_counts.epoch());
|
||||||
|
auto err = target_coords.to(cp);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccDefaultPCMErrorCode::ERROR_CCTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return addPoint(cp, hw_counts);
|
||||||
|
|
||||||
|
// auto err = target_coords.to(ref_coordpair_t::pairKind, hw_counts.epoch());
|
||||||
|
// if (err) {
|
||||||
|
// return mcc_deduced_err(err, MccDefaultPCMErrorCode::ERROR_CCTE);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _tableEpoch.emplace_back(hw_counts.epoch());
|
||||||
|
|
||||||
|
// _table.target_colon.emplace_back(target_coords.co_lon());
|
||||||
|
// _table.target_colat.emplace_back(target_coords.co_lat());
|
||||||
|
|
||||||
|
// _table.hw_colon.emplace_back(hw_counts.x());
|
||||||
|
// _table.hw_colat.emplace_back(hw_counts.y());
|
||||||
|
|
||||||
|
// _table.colon_res.emplace_back(target_coords.co_lon() - hw_counts.x());
|
||||||
|
// _table.colat_res.emplace_back(target_coords.co_lat() - hw_counts.y());
|
||||||
|
|
||||||
|
// return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const table_t& getTable() const
|
||||||
|
{
|
||||||
|
return _table;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <mcc_coord_pair_c TAG_T, mcc_coord_pair_c HW_T>
|
||||||
|
MccError getPoint(size_t idx, std::tuple<TAG_T, HW_T>& point)
|
||||||
|
requires(std::same_as<typename TAG_T::x_t, typename ref_coordpair_t::x_t> &&
|
||||||
|
std::same_as<typename TAG_T::y_t, typename ref_coordpair_t::y_t> &&
|
||||||
|
HW_T::pairKind == MccCoordPairKind::COORDS_KIND_XY)
|
||||||
|
{
|
||||||
|
if (idx > _table.target_colon.size()) {
|
||||||
|
return MccDefaultPCMConstructorErrorCode::ERROR_INVALID_INDEX;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::get<0>(point).setX(_table.target_colon[idx]);
|
||||||
|
std::get<0>(point).setY(_table.target_colat[idx]);
|
||||||
|
std::get<0>(point).setEpoch(_tableEpoch[idx]);
|
||||||
|
|
||||||
|
std::get<1>(point).setX(_table.hw_colon[idx]);
|
||||||
|
std::get<1>(point).setY(_table.hw_colat[idx]);
|
||||||
|
std::get<1>(point).setEpoch(_tableEpoch[idx]);
|
||||||
|
|
||||||
|
return MccDefaultPCMConstructorErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t numberOfPoints() const
|
||||||
|
{
|
||||||
|
return _table.colon_res.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void deletePoints()
|
||||||
|
{
|
||||||
|
_tableEpoch.clear();
|
||||||
|
|
||||||
|
_table.target_colon.clear();
|
||||||
|
_table.target_colat.clear();
|
||||||
|
|
||||||
|
_table.hw_colon.clear();
|
||||||
|
_table.hw_colat.clear();
|
||||||
|
|
||||||
|
_table.colon_res.clear();
|
||||||
|
_table.colat_res.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// for B-splines interior knots along axes must be given in 'pcm_data'
|
||||||
|
// NOTE: the size of the interior knots array must be at least 2 as
|
||||||
|
// it are interpretated as border knots and final full knots set is:
|
||||||
|
// knots = [input_knots[0], input_knots[0], input_knots[0], input_knots[0], input_knots[1], input_knots[2],
|
||||||
|
// ..., input_knots[N-1], input_knots[N-1], input_knots[N-1], input_knots[N-1]], where N = input_knots.size()
|
||||||
|
//
|
||||||
|
// WARNING: the input knots for inverse B-spline are ignored so the direct and inverse B-spline coefficients are
|
||||||
|
// calculated on the same mesh!
|
||||||
|
compute_result_t computeModel(MccDefaultPCM<MOUNT_TYPE>::pcm_data_t& pcm_data,
|
||||||
|
compute_params_t const& comp_params = {})
|
||||||
|
{
|
||||||
|
compute_result_t result{.pcm_type = pcm_data.type, .error = MccDefaultPCMConstructorErrorCode::ERROR_OK};
|
||||||
|
|
||||||
|
size_t min_data_size = 2; // 2 is for BSPLINE
|
||||||
|
|
||||||
|
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
|| pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
|
||||||
|
min_data_size = 9;
|
||||||
|
} else {
|
||||||
|
min_data_size = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numberOfPoints() < min_data_size) {
|
||||||
|
result.error = MccDefaultPCMConstructorErrorCode::ERROR_NOT_ENOUGH_DATA;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// robust linear regression with Tukey's loss function
|
||||||
|
result = robustLinearRegress(pcm_data, comp_params);
|
||||||
|
} else {
|
||||||
|
if (numberOfPoints() < min_data_size) {
|
||||||
|
result.error = MccDefaultPCMConstructorErrorCode::ERROR_NOT_ENOUGH_DATA;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
|
||||||
|
return bsplineFitting(pcm_data);
|
||||||
|
} else if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
|
||||||
|
// the fitting for geometrical coefficients is already done above so
|
||||||
|
// one must fit residuals by bivariate B-splines
|
||||||
|
|
||||||
|
std::vector<double> xres = _table.colon_res, yres = _table.colat_res;
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
_table.colon_res[i] = _table.target_colon[i] - result.model_colon[i];
|
||||||
|
_table.colat_res[i] = _table.target_colat[i] - result.model_colat[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
auto r = bsplineFitting(pcm_data);
|
||||||
|
result.error = r.error;
|
||||||
|
result.bspline_fit_err = r.bspline_fit_err;
|
||||||
|
|
||||||
|
if (!r.error) {
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
result.model_colon[i] += r.model_colon[i];
|
||||||
|
result.model_colat[i] += r.model_colat[i];
|
||||||
|
|
||||||
|
result.colon_res[i] = _table.target_colon[i] - result.model_colon[i];
|
||||||
|
result.colat_res[i] = _table.target_colat[i] - result.model_colat[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// restore original residuals
|
||||||
|
_table.colon_res = xres;
|
||||||
|
_table.colat_res = yres;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// std::vector<table_elem_t> _table;
|
||||||
|
table_t _table{};
|
||||||
|
std::vector<MccCelestialCoordEpoch> _tableEpoch{};
|
||||||
|
|
||||||
|
compute_result_t bsplineFitting(MccDefaultPCM<MOUNT_TYPE>::pcm_data_t& pcm_data)
|
||||||
|
{
|
||||||
|
compute_result_t result{.pcm_type = pcm_data.type, .error = MccDefaultPCMConstructorErrorCode::ERROR_OK};
|
||||||
|
|
||||||
|
// at least border knots must be given ([t_min, t_max])
|
||||||
|
if (pcm_data.bspline.knotsX.size() < 2 || pcm_data.bspline.knotsY.size() < 2) {
|
||||||
|
result.error = MccDefaultPCMConstructorErrorCode::ERROR_INVALID_KNOTS_NUMBER;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
double resi2x, resi2y; // sum of fitting residuals squares
|
||||||
|
|
||||||
|
// full knot vectors: [t_min, t_min, t_min, t_min, ..., t_1, t_2, ..., t_max, t_max, t_max, t_max]
|
||||||
|
std::vector<double> tx(pcm_data.bspline.knotsX.size() + 6), ty(pcm_data.bspline.knotsY.size() + 6);
|
||||||
|
std::vector<double> theta_hw(numberOfPoints()), theta_tag(numberOfPoints());
|
||||||
|
|
||||||
|
/*
|
||||||
|
WARNING:
|
||||||
|
FITPACK B-spline on sphere: in the fitting routines the first angle argument is THETA - co-latitude
|
||||||
|
coordinate and the second one is PHI - co-longitude!!!
|
||||||
|
|
||||||
|
In the fitting routines the first angle argument THETA must be in the range of [0.0, PI]
|
||||||
|
(while celestial declination is in the range of [-PI/2, PI/2])!!!
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
theta_hw[i] = _table.hw_colat[i] + MCC_HALF_PI;
|
||||||
|
}
|
||||||
|
|
||||||
|
tx[0] = tx[1] = tx[2] = pcm_data.bspline.knotsX[0];
|
||||||
|
tx[tx.size() - 1] = tx[tx.size() - 2] = tx[tx.size() - 3] =
|
||||||
|
pcm_data.bspline.knotsX[pcm_data.bspline.knotsX.size() - 1];
|
||||||
|
|
||||||
|
ty[0] = ty[1] = ty[2] = pcm_data.bspline.knotsY[0] + MCC_HALF_PI;
|
||||||
|
ty[ty.size() - 1] = ty[ty.size() - 2] = ty[ty.size() - 3] =
|
||||||
|
pcm_data.bspline.knotsY[pcm_data.bspline.knotsY.size() - 1] + MCC_HALF_PI;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < pcm_data.bspline.knotsX.size(); ++i) {
|
||||||
|
tx[3 + i] = pcm_data.bspline.knotsX[i];
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < pcm_data.bspline.knotsY.size(); ++i) {
|
||||||
|
ty[3 + i] = pcm_data.bspline.knotsY[i] + MCC_HALF_PI;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Ncoeffs = (tx.size() - 4) * (ty.size() - 4);
|
||||||
|
|
||||||
|
pcm_data.bspline.coeffsX.resize(Ncoeffs);
|
||||||
|
pcm_data.bspline.coeffsY.resize(Ncoeffs);
|
||||||
|
|
||||||
|
|
||||||
|
// direct (celestial = encoder + pcm)
|
||||||
|
result.bspline_fit_err = bsplines::fitpack_sphere_fit(theta_hw, _table.hw_colon, _table.colon_res, 1.0, ty, tx,
|
||||||
|
pcm_data.bspline.coeffsX, resi2x);
|
||||||
|
if (result.bspline_fit_err > 0) {
|
||||||
|
result.error = MccDefaultPCMConstructorErrorCode::ERROR_BSPLINE_FIT;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.bspline_fit_err = bsplines::fitpack_sphere_fit(theta_hw, _table.hw_colon, _table.colat_res, 1.0, ty, tx,
|
||||||
|
pcm_data.bspline.coeffsY, resi2y);
|
||||||
|
if (result.bspline_fit_err > 0) {
|
||||||
|
result.error = MccDefaultPCMConstructorErrorCode::ERROR_BSPLINE_FIT;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.coeffsX, theta_hw, _table.hw_colon,
|
||||||
|
result.model_colon); // get fitted residuals!!!
|
||||||
|
|
||||||
|
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.coeffsY, theta_hw, _table.hw_colon,
|
||||||
|
result.model_colat); // get fitted residuals!!!
|
||||||
|
|
||||||
|
|
||||||
|
result.colon_res.resize(numberOfPoints());
|
||||||
|
result.colat_res.resize(numberOfPoints());
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
result.colon_res[i] = _table.colon_res[i] - result.model_colon[i]; // = target - model
|
||||||
|
result.colat_res[i] = _table.colat_res[i] - result.model_colat[i]; // = target - model
|
||||||
|
// result.model_colon[i] += _table.hw_colon[i]; // == hw + fitted_pcmX
|
||||||
|
// result.model_colat[i] += _table.hw_colat[i]; // == hw + fitted_pcmY
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
|
||||||
|
// here both direct and inverse coefficients will be calculated
|
||||||
|
pcm_data.inverseBspline.coeffsX.resize(Ncoeffs);
|
||||||
|
pcm_data.inverseBspline.coeffsY.resize(Ncoeffs);
|
||||||
|
|
||||||
|
std::vector<double> theta_tag(numberOfPoints());
|
||||||
|
|
||||||
|
// inverse (encoder = celestial + pcm)
|
||||||
|
|
||||||
|
std::vector<double> colon_res = _table.colon_res;
|
||||||
|
std::vector<double> colat_res = _table.colat_res;
|
||||||
|
for (size_t i = 0; i < colat_res.size(); ++i) {
|
||||||
|
colon_res[i] = -colon_res[i];
|
||||||
|
colat_res[i] = -colat_res[i];
|
||||||
|
|
||||||
|
theta_tag[i] = _table.target_colat[i] + MCC_HALF_PI;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.bspline_fit_err = bsplines::fitpack_sphere_fit(theta_tag, _table.target_colon, colon_res, 1.0, ty,
|
||||||
|
tx, pcm_data.bspline.inverseCoeffsX, resi2x);
|
||||||
|
if (result.bspline_fit_err > 0) {
|
||||||
|
result.error = MccDefaultPCMConstructorErrorCode::ERROR_BSPLINE_FIT;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.bspline_fit_err = bsplines::fitpack_sphere_fit(theta_tag, _table.target_colon, colat_res, 1.0, ty,
|
||||||
|
tx, pcm_data.bspline.inverseCoeffsY, resi2y);
|
||||||
|
if (result.bspline_fit_err > 0) {
|
||||||
|
result.error = MccDefaultPCMConstructorErrorCode::ERROR_BSPLINE_FIT;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.inverseCoeffsX, theta_tag, _table.target_colon,
|
||||||
|
result.inv_model_colon); // get fitted residuals!!!
|
||||||
|
|
||||||
|
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.inverseCoeffsY, theta_tag, _table.target_colon,
|
||||||
|
result.inv_model_colat); // get fitted residuals!!!
|
||||||
|
|
||||||
|
result.inv_colon_res.resize(numberOfPoints());
|
||||||
|
result.inv_colat_res.resize(numberOfPoints());
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
result.inv_colon_res[i] = _table.colon_res[i] - result.inv_model_colon[i]; // = hw - model
|
||||||
|
result.inv_colat_res[i] = _table.colat_res[i] - result.inv_model_colat[i]; // = hw - model
|
||||||
|
// result.inv_model_colon[i] += _table.target_colon[i]; // == target +
|
||||||
|
// fitted_pcmX result.inv_model_colat[i] += _table.target_colat[i]; // == target
|
||||||
|
// + fitted_pcmY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
compute_result_t robustLinearRegress(MccDefaultPCM<MOUNT_TYPE>::pcm_data_t& pcm_data,
|
||||||
|
compute_params_t const& comp_params)
|
||||||
|
{
|
||||||
|
auto tukey_weight = [](Eigen::VectorXd const& resi, double tukey_c, Eigen::VectorXd& tukey_weight) {
|
||||||
|
Eigen::ArrayXd u = (resi / tukey_c).cwiseAbs();
|
||||||
|
auto mask = (u < 1.0);
|
||||||
|
|
||||||
|
Eigen::VectorXd r = mask.select(1.0 - u * u, 0.0);
|
||||||
|
|
||||||
|
tukey_weight = r.array() * r.array();
|
||||||
|
};
|
||||||
|
|
||||||
|
auto gastwirth_est = [](Eigen::VectorXd const& r) {
|
||||||
|
// auto gastwirth_est = [](Eigen::VectorXd const& resi) {
|
||||||
|
auto resi = r;
|
||||||
|
std::nth_element(resi.begin(), resi.begin() + resi.size() / 2, resi.end());
|
||||||
|
double md = resi(resi.size() / 2);
|
||||||
|
resi = resi.array() - md;
|
||||||
|
|
||||||
|
// Gastwirth’s estimation: 0.3*Q(1/3) + 0.4*Q(1/2) + 0.3*Q(2/3)
|
||||||
|
|
||||||
|
Eigen::ArrayXd arr = resi.cwiseAbs();
|
||||||
|
|
||||||
|
std::nth_element(arr.begin(), arr.begin() + 2 * arr.size() / 3, arr.end());
|
||||||
|
|
||||||
|
// add 1.0E-8 to avoid 0.0
|
||||||
|
return (0.3 * arr(arr.size() / 3) + 0.4 * arr(arr.size() / 2) + 0.3 * arr(2 * arr.size() / 3)) / 0.6745 +
|
||||||
|
1.0E-8;
|
||||||
|
|
||||||
|
// std::nth_element(arr.begin(), arr.begin() + arr.size() / 2, arr.end());
|
||||||
|
|
||||||
|
// return arr(arr.size() / 2) / 0.6745 + 1.0E-8;
|
||||||
|
};
|
||||||
|
|
||||||
|
compute_result_t result{.pcm_type = pcm_data.type, .error = MccDefaultPCMConstructorErrorCode::ERROR_OK};
|
||||||
|
|
||||||
|
const size_t n_coeffs = MOUNT_TYPE == MccMountType::FORK_TYPE ? 9 : 8;
|
||||||
|
|
||||||
|
Eigen::MatrixXd X(2 * numberOfPoints(), n_coeffs);
|
||||||
|
Eigen::VectorXd y(2 * numberOfPoints()), beta = Eigen::VectorXd::Zero(n_coeffs), new_beta(n_coeffs);
|
||||||
|
Eigen::VectorXd model;
|
||||||
|
|
||||||
|
Eigen::RowVectorXd row(n_coeffs);
|
||||||
|
double tgY, sinY, cosY, rcosY, cosX, sinX, cosPhi = std::cos(pcm_data.siteLatitude),
|
||||||
|
sinPhi = std::sin(pcm_data.siteLatitude);
|
||||||
|
|
||||||
|
// system matrix and right-hand vector
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
cosY = std::cos(_table.target_colat[i]);
|
||||||
|
sinY = std::sin(_table.target_colat[i]);
|
||||||
|
rcosY = 1.0 / cosY;
|
||||||
|
tgY = std::tan(_table.target_colat[i]);
|
||||||
|
cosX = std::cos(_table.target_colon[i]);
|
||||||
|
sinX = std::sin(_table.target_colon[i]);
|
||||||
|
|
||||||
|
|
||||||
|
// [X0, Y0, collim, nonperp, misal1, misal2, tubefl, DECaxfl, forkfl] or
|
||||||
|
// [X0, Y0, collim, nonperp, misal1, misal2, tubefl, DECaxfl]
|
||||||
|
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
|
||||||
|
if (utils::isEqual(cosY, 0.0)) {
|
||||||
|
row << 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0;
|
||||||
|
} else {
|
||||||
|
row << 1.0, 0.0, rcosY, tgY, -cosX * tgY, sinX * tgY, cosPhi * sinX * rcosY,
|
||||||
|
-(cosPhi * cosX + sinPhi * tgY), 0.0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (utils::isEqual(cosY, 0.0)) {
|
||||||
|
row << 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0;
|
||||||
|
} else {
|
||||||
|
row << 1.0, 0.0, rcosY, tgY, -cosX * tgY, sinX * tgY, cosPhi * sinX * rcosY,
|
||||||
|
-(cosPhi * cosX + sinPhi * tgY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
X.row(i) = row;
|
||||||
|
|
||||||
|
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
|
||||||
|
if (utils::isEqual(cosX, 0.0)) {
|
||||||
|
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0, 0.0;
|
||||||
|
} else {
|
||||||
|
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0, 1.0 / cosX;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
X.row(i + numberOfPoints()) = row;
|
||||||
|
|
||||||
|
y(i) = _table.colon_res[i];
|
||||||
|
y(i + numberOfPoints()) = _table.colat_res[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
Eigen::VectorXd resi = y;
|
||||||
|
Eigen::VectorXd weights(2 * numberOfPoints());
|
||||||
|
|
||||||
|
double scale;
|
||||||
|
|
||||||
|
Eigen::MatrixXd WX;
|
||||||
|
Eigen::VectorXd Wy;
|
||||||
|
|
||||||
|
// initial parameters estimation (least squares)
|
||||||
|
beta = X.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(y);
|
||||||
|
model = X * beta;
|
||||||
|
resi = y - model;
|
||||||
|
|
||||||
|
// resi = y;
|
||||||
|
|
||||||
|
for (result.final_iter = 1; result.final_iter <= comp_params.max_iter; ++result.final_iter) {
|
||||||
|
scale = gastwirth_est(resi);
|
||||||
|
|
||||||
|
tukey_weight(resi / scale, comp_params.c, weights);
|
||||||
|
|
||||||
|
// Eigen::MatrixXd XtW = X.transpose() * weights.asDiagonal();
|
||||||
|
// Eigen::MatrixXd XtWX = XtW * X;
|
||||||
|
// Eigen::VectorXd XtWy = XtW * y;
|
||||||
|
|
||||||
|
// new_beta = XtWX.ldlt().solve(XtWy);
|
||||||
|
|
||||||
|
WX = weights.asDiagonal() * X;
|
||||||
|
Wy = weights.asDiagonal() * y;
|
||||||
|
new_beta = WX.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(Wy);
|
||||||
|
|
||||||
|
if ((new_beta - beta).norm() < comp_params.tolerance) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
beta = new_beta;
|
||||||
|
|
||||||
|
model = X * beta;
|
||||||
|
resi = y - model;
|
||||||
|
}
|
||||||
|
|
||||||
|
pcm_data.geomCoefficients.zeroPointX = new_beta(0);
|
||||||
|
pcm_data.geomCoefficients.zeroPointY = new_beta(1);
|
||||||
|
pcm_data.geomCoefficients.collimationErr = new_beta(2);
|
||||||
|
pcm_data.geomCoefficients.nonperpendErr = new_beta(3);
|
||||||
|
pcm_data.geomCoefficients.misalignErr1 = new_beta(4);
|
||||||
|
pcm_data.geomCoefficients.misalignErr2 = new_beta(5);
|
||||||
|
pcm_data.geomCoefficients.tubeFlexure = new_beta(6);
|
||||||
|
pcm_data.geomCoefficients.DECaxisFlexure = new_beta(7);
|
||||||
|
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
|
||||||
|
pcm_data.geomCoefficients.forkFlexure = new_beta(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.model_colon = {model.begin(), model.begin() + numberOfPoints()};
|
||||||
|
result.model_colat = {model.begin() + numberOfPoints(), model.end()};
|
||||||
|
result.colon_res.resize(numberOfPoints());
|
||||||
|
result.colat_res.resize(numberOfPoints());
|
||||||
|
|
||||||
|
result.colon_weight = {weights.begin(), weights.begin() + numberOfPoints()};
|
||||||
|
result.colat_weight = {weights.begin() + numberOfPoints(), weights.end()};
|
||||||
|
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
result.colon_res[i] = _table.colon_res[i] - result.model_colon[i]; // = target - model
|
||||||
|
result.colat_res[i] = _table.colat_res[i] - result.model_colat[i]; // = target - model
|
||||||
|
// result.model_colon[i] += _table.hw_colon[i]; // == hw + fitted_pcmX
|
||||||
|
// result.model_colat[i] += _table.hw_colat[i]; // == hw + fitted_pcmY
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
707
include/mcc/mcc_pcm_fit.h
Normal file
707
include/mcc/mcc_pcm_fit.h
Normal file
@@ -0,0 +1,707 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
* *
|
||||||
|
* MOUNT CONTROL COMPONENTS LIBRARY *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* "POINTING-CORRECTION-MODEL" FITTER *
|
||||||
|
* *
|
||||||
|
****************************************************************************************/
|
||||||
|
|
||||||
|
#include <eigen3/Eigen/Dense>
|
||||||
|
|
||||||
|
#include "mcc_concepts.h"
|
||||||
|
#include "mcc_coordinate.h"
|
||||||
|
#include "mcc_pcm.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class MccPCMFitterErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_INVALID_EPOCH,
|
||||||
|
ERROR_NOT_ENOUGH_DATA,
|
||||||
|
ERROR_INVALID_INDEX,
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
ERROR_INVALID_KNOTS_NUMBER,
|
||||||
|
ERROR_BSPLINE_FIT
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
// error category
|
||||||
|
|
||||||
|
struct MccPCMFitterErrorCategory : std::error_category {
|
||||||
|
MccPCMFitterErrorCategory() = default;
|
||||||
|
|
||||||
|
const char* name() const noexcept
|
||||||
|
{
|
||||||
|
return "MCC-DEFAULT-PCM-CONSTRUCTOR-ERROR-CATEGORY";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message(int ec) const
|
||||||
|
{
|
||||||
|
MccPCMFitterErrorCode err = static_cast<MccPCMFitterErrorCode>(ec);
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
case MccPCMFitterErrorCode::ERROR_OK:
|
||||||
|
return "OK";
|
||||||
|
case MccPCMFitterErrorCode::ERROR_INVALID_EPOCH:
|
||||||
|
return "invalid epoch";
|
||||||
|
case MccPCMFitterErrorCode::ERROR_NOT_ENOUGH_DATA:
|
||||||
|
return "not enough data point";
|
||||||
|
case MccPCMFitterErrorCode::ERROR_INVALID_INDEX:
|
||||||
|
return "invalid index of data point";
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
case MccPCMFitterErrorCode::ERROR_INVALID_KNOTS_NUMBER:
|
||||||
|
return "invalid number of B-spline knots";
|
||||||
|
case MccPCMFitterErrorCode::ERROR_BSPLINE_FIT:
|
||||||
|
return "B-spline fitting error";
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const MccPCMFitterErrorCategory& get()
|
||||||
|
{
|
||||||
|
static const MccPCMFitterErrorCategory constInst;
|
||||||
|
return constInst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline std::error_code make_error_code(MccPCMFitterErrorCode ec)
|
||||||
|
{
|
||||||
|
return std::error_code(static_cast<int>(ec), MccPCMFitterErrorCategory::get());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
|
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class is_error_code_enum<mcc::impl::MccPCMFitterErrorCode> : public true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
template <MccMountType MOUNT_TYPE>
|
||||||
|
class MccPCMFitter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using ref_coordpair_t = std::conditional_t<mcc_is_equatorial_mount<MOUNT_TYPE>,
|
||||||
|
MccSkyHADEC_OBS,
|
||||||
|
std::conditional_t<mcc_is_altaz_mount<MOUNT_TYPE>, MccSkyAZZD, void>>;
|
||||||
|
|
||||||
|
static_assert(!std::is_void_v<ref_coordpair_t>, "UNSUPPORTED MOUNT TYPE!");
|
||||||
|
|
||||||
|
struct compute_result_t {
|
||||||
|
MccDefaultPCMType pcm_type;
|
||||||
|
MccError error{}; // final model computation error
|
||||||
|
|
||||||
|
size_t final_iter{}; // number of final iteration
|
||||||
|
|
||||||
|
std::vector<double> model_colonRES{}, model_colatRES{}; // fitting model values: fit(target-hw)
|
||||||
|
std::vector<double> colon_err{}, colat_err{}; // fitting residuals: (target-hw) - fit
|
||||||
|
std::vector<double> colon_weight{}, colat_weight; // Tukey's weights
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
std::array<int, 4> bspline_fit_err{
|
||||||
|
0, 0, 0, 0}; // bivariate B-spline fitting exit code (see FITPACK)
|
||||||
|
// 0 - pcmX(X,Y), 1 - pcmY(X,Y), 2 - revPcmX(COLON, COLAT), 3 - revPcmY(COLON, COLAT)
|
||||||
|
|
||||||
|
// quantities below are computed only fo pcm_type == MccDefaultPCMType::PCM_TYPE_BSPLINE
|
||||||
|
std::vector<double> inv_model_colonRES{}, inv_model_colatRES{}; // fitted inverse model values
|
||||||
|
std::vector<double> inv_colon_err{}, inv_colat_err{}; // encoder - model
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
struct compute_params_t {
|
||||||
|
size_t max_iter{100}; // max number of iterations for robust linear regression method
|
||||||
|
double c{4.685}; // Tukey's parameter for robust linear regression method
|
||||||
|
double tolerance{1.0E-6}; // tolerance value for bivariare B-spline fitting
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct pcm_table_elem_t {
|
||||||
|
ref_coordpair_t target{}; // celestial
|
||||||
|
MccGenXY hw{}; // hardware (encoder)
|
||||||
|
MccGenXY res{}; // residuals: celestial - hardware
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<pcm_table_elem_t> pcm_table_t;
|
||||||
|
|
||||||
|
|
||||||
|
size_t numberOfPoints() const
|
||||||
|
{
|
||||||
|
return _targetCOLON.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void deletePoints()
|
||||||
|
{
|
||||||
|
_epoch.clear();
|
||||||
|
_targetCOLON.clear();
|
||||||
|
_targetCOLAT.clear();
|
||||||
|
_colatRES.clear();
|
||||||
|
_colonRES.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <mcc_coord_pair_c TAG_T, mcc_coord_pair_c HW_T>
|
||||||
|
MccError addPoint(TAG_T const& target_coords, HW_T const& hw_counts)
|
||||||
|
requires(TAG_T::pairKind == ref_coordpair_t::pairKind && HW_T::pairKind == MccCoordPairKind::COORDS_KIND_XY)
|
||||||
|
{
|
||||||
|
if (hw_counts.epoch() != target_coords.epoch()) {
|
||||||
|
return MccPCMFitterErrorCode::ERROR_INVALID_EPOCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
_epoch.emplace_back(hw_counts.epoch());
|
||||||
|
|
||||||
|
// to ensure the input celestial coordinates are normalized
|
||||||
|
typename ref_coordpair_t::x_t ang_x{(double)target_coords.x()};
|
||||||
|
typename ref_coordpair_t::y_t ang_y{(double)target_coords.y()};
|
||||||
|
|
||||||
|
_targetCOLON.emplace_back((double)ang_x);
|
||||||
|
_targetCOLAT.emplace_back((double)ang_y);
|
||||||
|
|
||||||
|
// normalize encoder coordinates to the range of corresponding celestial ones
|
||||||
|
|
||||||
|
ang_x = (double)hw_counts.x();
|
||||||
|
ang_y = (double)hw_counts.y();
|
||||||
|
_hwX.emplace_back((double)ang_x);
|
||||||
|
_hwY.emplace_back((double)ang_y);
|
||||||
|
|
||||||
|
_colonRES.emplace_back(_targetCOLON.back() - _hwX.back());
|
||||||
|
_colatRES.emplace_back(_targetCOLAT.back() - _hwY.back());
|
||||||
|
|
||||||
|
return MccPCMFitterErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MccError addPoint(mcc_skypoint_c auto const& target_coords, mcc_coord_pair_c auto const& hw_counts)
|
||||||
|
requires(std::decay_t<decltype(hw_counts)>::pairKind == MccCoordPairKind::COORDS_KIND_XY)
|
||||||
|
{
|
||||||
|
ref_coordpair_t cp;
|
||||||
|
|
||||||
|
cp.setEpoch(hw_counts.epoch());
|
||||||
|
auto err = target_coords.to(cp);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccDefaultPCMErrorCode::ERROR_CCTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return addPoint(cp, hw_counts);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename COLON_T, typename COLAT_T>
|
||||||
|
MccError addPoint(COLON_T const& colon, COLAT_T const& colat, mcc_coord_pair_c auto const& hw_counts)
|
||||||
|
requires(std::is_arithmetic_v<COLON_T> && std::is_arithmetic_v<COLAT_T> &&
|
||||||
|
(std::decay_t<decltype(hw_counts)>::pairKind == MccCoordPairKind::COORDS_KIND_XY))
|
||||||
|
{
|
||||||
|
ref_coordpair_t cp{typename ref_coordpair_t::x_t{colon}, typename ref_coordpair_t::y_t{colat},
|
||||||
|
hw_counts.epoch()};
|
||||||
|
|
||||||
|
return addPoint(cp, hw_counts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename COLON_T, typename COLAT_T, typename HW_X_T, typename HW_Y_T>
|
||||||
|
MccError addPoint(COLON_T const& colon,
|
||||||
|
COLAT_T const& colat,
|
||||||
|
HW_X_T const& x,
|
||||||
|
HW_Y_T const& y,
|
||||||
|
mcc_coord_epoch_c auto const& epoch)
|
||||||
|
requires(std::is_arithmetic_v<COLON_T> && std::is_arithmetic_v<COLAT_T> && std::is_arithmetic_v<HW_X_T> &&
|
||||||
|
std::is_arithmetic_v<HW_Y_T>)
|
||||||
|
{
|
||||||
|
ref_coordpair_t cp{typename ref_coordpair_t::x_t{colon}, typename ref_coordpair_t::y_t{colat}, epoch};
|
||||||
|
MccGenXY hw{x, y, epoch};
|
||||||
|
|
||||||
|
return addPoint(cp, hw);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_coord_pair_c TAG_T, mcc_coord_pair_c HW_T>
|
||||||
|
MccError getPoint(size_t idx, std::tuple<TAG_T, HW_T>& point)
|
||||||
|
requires(std::same_as<typename TAG_T::x_t, typename ref_coordpair_t::x_t> &&
|
||||||
|
std::same_as<typename TAG_T::y_t, typename ref_coordpair_t::y_t> &&
|
||||||
|
HW_T::pairKind == MccCoordPairKind::COORDS_KIND_XY)
|
||||||
|
{
|
||||||
|
if (idx > numberOfPoints()) {
|
||||||
|
return MccPCMFitterErrorCode::ERROR_INVALID_INDEX;
|
||||||
|
} else {
|
||||||
|
std::get<0>(point).setX(_targetCOLON[idx]);
|
||||||
|
std::get<0>(point).setY(_targetCOLAT[idx]);
|
||||||
|
std::get<0>(point).setEpoch(_epoch[idx]);
|
||||||
|
|
||||||
|
std::get<1>(point).setX(_hwX[idx]);
|
||||||
|
std::get<1>(point).setY(_hwY[idx]);
|
||||||
|
std::get<1>(point).setEpoch(_epoch[idx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccPCMFitterErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pcm_table_t getPCMTable() const
|
||||||
|
{
|
||||||
|
pcm_table_t tab;
|
||||||
|
|
||||||
|
if (numberOfPoints()) {
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
tab.emplace_back(pcm_table_elem_t{.target{typename ref_coordpair_t::x_t{_targetCOLON[i]},
|
||||||
|
typename ref_coordpair_t::y_t{_targetCOLAT[i]}, _epoch[i]},
|
||||||
|
.hw{MccAngleX{_hwX[i]}, MccAngleY{_hwY[i]}, _epoch[i]},
|
||||||
|
.res{MccAngleX{_colonRES[i]}, MccAngleY{_colatRES[i]}, _epoch[i]}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// for B-splines interior knots along axes must be given in 'pcm_data'
|
||||||
|
// NOTE: the size of the interior knots array must be at least 2 as
|
||||||
|
// it are interpretated as border knots and final full knots set is:
|
||||||
|
// knots = [input_knots[0], input_knots[0], input_knots[0], input_knots[0], input_knots[1], input_knots[2],
|
||||||
|
// ..., input_knots[N-1], input_knots[N-1], input_knots[N-1], input_knots[N-1]], where N = input_knots.size()
|
||||||
|
//
|
||||||
|
// WARNING: the input knots for inverse B-spline are ignored so the direct and inverse B-spline coefficients are
|
||||||
|
// calculated on the same mesh!
|
||||||
|
template <typename PCM_DATA_T>
|
||||||
|
compute_result_t computeModel(PCM_DATA_T& pcm_data, compute_params_t const& comp_params = {})
|
||||||
|
requires(std::derived_from<typename PCM_DATA_T::pcm_t, MccDefaultPCM<MOUNT_TYPE>>)
|
||||||
|
{
|
||||||
|
compute_result_t result{.pcm_type = pcm_data.type, .error = MccPCMFitterErrorCode::ERROR_OK};
|
||||||
|
|
||||||
|
size_t min_data_size = 2; // 2 is for BSPLINE
|
||||||
|
|
||||||
|
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
|| pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
|
||||||
|
min_data_size = 9;
|
||||||
|
} else {
|
||||||
|
min_data_size = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numberOfPoints() < min_data_size) {
|
||||||
|
result.error = MccPCMFitterErrorCode::ERROR_NOT_ENOUGH_DATA;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// robust linear regression with Tukey's loss function
|
||||||
|
result = robustLinearRegress(pcm_data, comp_params);
|
||||||
|
} else {
|
||||||
|
if (numberOfPoints() < min_data_size) {
|
||||||
|
result.error = MccPCMFitterErrorCode::ERROR_NOT_ENOUGH_DATA;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
|
||||||
|
return bsplineFitting(pcm_data);
|
||||||
|
} else if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
|
||||||
|
// the fitting for geometrical coefficients is already done above so
|
||||||
|
// one must fit residuals by bivariate B-splines
|
||||||
|
|
||||||
|
std::vector<double> xres = _colonRES, yres = _colatRES;
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
_colonRES[i] = _targetCOLON[i] - result.model_colonRES[i];
|
||||||
|
_colatRES[i] = _targetCOLAT[i] - result.model_colatRES[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
auto r = bsplineFitting(pcm_data);
|
||||||
|
result.error = r.error;
|
||||||
|
result.bspline_fit_err = r.bspline_fit_err;
|
||||||
|
|
||||||
|
if (!r.error) {
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
result.model_colonRES[i] += r.model_colonRES[i];
|
||||||
|
result.model_colatRES[i] += r.model_colatRES[i];
|
||||||
|
|
||||||
|
result.colon_err[i] = _targetCOLON[i] - result.model_colonRES[i];
|
||||||
|
result.colat_err[i] = _targetCOLAT[i] - result.model_colatRES[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// restore original residuals
|
||||||
|
_colonRES = xres;
|
||||||
|
_colatRES = yres;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// store coordinates in radians
|
||||||
|
std::vector<double> _targetCOLON{}, _targetCOLAT{}, _hwX, _hwY;
|
||||||
|
std::vector<double> _colonRES{}, _colatRES{}; // target - hw
|
||||||
|
std::vector<MccCelestialCoordEpoch> _epoch{};
|
||||||
|
|
||||||
|
|
||||||
|
// void computeModelResi(compute_result_t& result)
|
||||||
|
// {
|
||||||
|
// result.colon_err.resize(numberOfPoints());
|
||||||
|
// result.colat_err.resize(numberOfPoints());
|
||||||
|
|
||||||
|
// for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
// result.colon_err[i] = _colonRES[i] - result.model_colonRES[i]; // = target - model
|
||||||
|
// result.colat_err[i] = _colatRES[i] - result.model_colatRES[i]; // = target - model
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #ifdef USE_BSPLINE_PCM
|
||||||
|
// if (result.pcm_type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
|
||||||
|
// result.inv_colon_err.resize(numberOfPoints());
|
||||||
|
// result.inv_colat_err.resize(numberOfPoints());
|
||||||
|
// for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
// result.inv_colon_err[i] = _colonRES[i] - result.inv_model_colonRES[i]; // = hw - model
|
||||||
|
// result.inv_colat_err[i] = _colatRES[i] - result.inv_model_colatRES[i]; // = hw - model
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// #endif
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_BSPLINE_PCM
|
||||||
|
compute_result_t bsplineFitting(MccDefaultPCM<MOUNT_TYPE>::pcm_data_t& pcm_data)
|
||||||
|
{
|
||||||
|
compute_result_t result{.pcm_type = pcm_data.type, .error = MccPCMFitterErrorCode::ERROR_OK};
|
||||||
|
|
||||||
|
// at least border knots must be given ([t_min, t_max])
|
||||||
|
if (pcm_data.bspline.knotsX.size() < 2 || pcm_data.bspline.knotsY.size() < 2) {
|
||||||
|
result.error = MccPCMFitterErrorCode::ERROR_INVALID_KNOTS_NUMBER;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
double resi2x, resi2y; // sum of fitting residuals squares
|
||||||
|
|
||||||
|
// full knot vectors: [t_min, t_min, t_min, t_min, ..., t_1, t_2, ..., t_max, t_max, t_max, t_max]
|
||||||
|
std::vector<double> tx(pcm_data.bspline.knotsX.size() + 6), ty(pcm_data.bspline.knotsY.size() + 6);
|
||||||
|
|
||||||
|
std::vector<double>*theta_hw = &_hwY, *theta_tag = &_targetCOLAT, *phi_hw = &_hwX, *phi_tag = &_targetCOLON;
|
||||||
|
std::vector<double> theta, phi;
|
||||||
|
|
||||||
|
// full set of B-spline knots
|
||||||
|
tx[0] = tx[1] = tx[2] = pcm_data.bspline.knotsX[0];
|
||||||
|
tx[tx.size() - 1] = tx[tx.size() - 2] = tx[tx.size() - 3] =
|
||||||
|
pcm_data.bspline.knotsX[pcm_data.bspline.knotsX.size() - 1];
|
||||||
|
|
||||||
|
ty[0] = ty[1] = ty[2] = pcm_data.bspline.knotsY[0];
|
||||||
|
ty[ty.size() - 1] = ty[ty.size() - 2] = ty[ty.size() - 3] =
|
||||||
|
pcm_data.bspline.knotsY[pcm_data.bspline.knotsY.size() - 1];
|
||||||
|
|
||||||
|
for (size_t i = 0; i < pcm_data.bspline.knotsX.size(); ++i) {
|
||||||
|
tx[3 + i] = pcm_data.bspline.knotsX[i];
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < pcm_data.bspline.knotsY.size(); ++i) {
|
||||||
|
ty[3 + i] = pcm_data.bspline.knotsY[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
WARNING:
|
||||||
|
FITPACK B-spline on sphere: in the fitting routines the first angle argument is THETA - co-latitude
|
||||||
|
coordinate and the second one is PHI - co-longitude!!!
|
||||||
|
|
||||||
|
In the fitting routines the first angle argument THETA must be in the range of [0.0, PI]
|
||||||
|
(while celestial declination is in the range of [-PI/2, PI/2])!!!
|
||||||
|
The second angle argument is the PHI and its valid range is [0, 2*PI]
|
||||||
|
(while celestial hour angle is assumed to be in the range of [-PI, PI])
|
||||||
|
*/
|
||||||
|
|
||||||
|
if constexpr (std::same_as<ref_coordpair_t, MccSkyHADEC_OBS>) {
|
||||||
|
theta.resize(numberOfPoints());
|
||||||
|
phi.resize(numberOfPoints());
|
||||||
|
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
theta[i] = _hwY[i] + MCC_HALF_PI;
|
||||||
|
phi[i] = _hwX[i] + std::numbers::pi;
|
||||||
|
}
|
||||||
|
theta_hw = θ
|
||||||
|
phi_hw = φ
|
||||||
|
|
||||||
|
for (size_t i = 0; i < tx.size(); ++i) {
|
||||||
|
tx[i] += std::numbers::pi;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < ty.size(); ++i) {
|
||||||
|
ty[i] += MCC_HALF_PI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Ncoeffs = (tx.size() - 4) * (ty.size() - 4);
|
||||||
|
|
||||||
|
pcm_data.bspline.coeffsX.resize(Ncoeffs);
|
||||||
|
pcm_data.bspline.coeffsY.resize(Ncoeffs);
|
||||||
|
|
||||||
|
|
||||||
|
// direct (celestial = encoder + pcm)
|
||||||
|
result.bspline_fit_err[0] =
|
||||||
|
bsplines::fitpack_sphere_fit(*theta_hw, *phi_hw, _colonRES, 1.0, ty, tx, pcm_data.bspline.coeffsX, resi2x);
|
||||||
|
if (result.bspline_fit_err[0] > 0) {
|
||||||
|
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.bspline_fit_err[1] =
|
||||||
|
bsplines::fitpack_sphere_fit(*theta_hw, *phi_hw, _colatRES, 1.0, ty, tx, pcm_data.bspline.coeffsY, resi2y);
|
||||||
|
if (result.bspline_fit_err[1] > 0) {
|
||||||
|
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.coeffsX, *theta_hw, *phi_hw,
|
||||||
|
result.model_colonRES); // get fitted residuals!!!
|
||||||
|
|
||||||
|
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.coeffsY, *theta_hw, *phi_hw,
|
||||||
|
result.model_colatRES); // get fitted residuals!!!
|
||||||
|
|
||||||
|
result.colon_err.resize(numberOfPoints());
|
||||||
|
result.colat_err.resize(numberOfPoints());
|
||||||
|
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
result.colon_err[i] = _colonRES[i] - result.model_colonRES[i]; // = target - model
|
||||||
|
result.colat_err[i] = _colatRES[i] - result.model_colatRES[i]; // = target - model
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pcm_data.type == MccDefaultPCMType::PCM_TYPE_BSPLINE) {
|
||||||
|
// here both direct and inverse coefficients will be calculated
|
||||||
|
pcm_data.inverseBspline.coeffsX.resize(Ncoeffs);
|
||||||
|
pcm_data.inverseBspline.coeffsY.resize(Ncoeffs);
|
||||||
|
|
||||||
|
// inverse (encoder = celestial + pcm)
|
||||||
|
|
||||||
|
if constexpr (std::same_as<ref_coordpair_t, MccSkyHADEC_OBS>) {
|
||||||
|
theta_tag = θ
|
||||||
|
phi_tag = φ
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<double> colon_res = _colonRES;
|
||||||
|
std::vector<double> colat_res = _colatRES;
|
||||||
|
for (size_t i = 0; i < colat_res.size(); ++i) {
|
||||||
|
colon_res[i] = -colon_res[i];
|
||||||
|
colat_res[i] = -colat_res[i];
|
||||||
|
|
||||||
|
if constexpr (std::same_as<ref_coordpair_t, MccSkyHADEC_OBS>) {
|
||||||
|
(*theta_tag)[i] = _targetCOLAT[i] + MCC_HALF_PI;
|
||||||
|
(*phi_tag)[i] = _targetCOLON[i] + std::numbers::pi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.bspline_fit_err[2] = bsplines::fitpack_sphere_fit(*theta_tag, *phi_tag, colon_res, 1.0, ty, tx,
|
||||||
|
pcm_data.bspline.inverseCoeffsX, resi2x);
|
||||||
|
if (result.bspline_fit_err[2] > 0) {
|
||||||
|
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.bspline_fit_err[3] = bsplines::fitpack_sphere_fit(*theta_tag, *phi_tag, colat_res, 1.0, ty, tx,
|
||||||
|
pcm_data.bspline.inverseCoeffsY, resi2y);
|
||||||
|
if (result.bspline_fit_err[3] > 0) {
|
||||||
|
result.error = MccPCMFitterErrorCode::ERROR_BSPLINE_FIT;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.inverseCoeffsX, *theta_tag, *phi_tag,
|
||||||
|
result.inv_model_colonRES); // get fitted residuals!!!
|
||||||
|
|
||||||
|
bsplines::fitpack_eval_spl2d(ty, tx, pcm_data.bspline.inverseCoeffsY, *theta_tag, *phi_tag,
|
||||||
|
result.inv_model_colatRES); // get fitted residuals!!!
|
||||||
|
|
||||||
|
result.inv_colon_err.resize(numberOfPoints());
|
||||||
|
result.inv_colat_err.resize(numberOfPoints());
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
result.inv_colon_err[i] = colon_res[i] - result.inv_model_colonRES[i]; // = hw - model
|
||||||
|
result.inv_colat_err[i] = colat_res[i] - result.inv_model_colatRES[i]; // = hw - model
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
compute_result_t robustLinearRegress(MccDefaultPCM<MOUNT_TYPE>::pcm_data_t& pcm_data,
|
||||||
|
compute_params_t const& comp_params)
|
||||||
|
{
|
||||||
|
auto tukey_weight = [](Eigen::VectorXd const& resi, double tukey_c, Eigen::VectorXd& tukey_weight) {
|
||||||
|
Eigen::ArrayXd u = (resi / tukey_c).cwiseAbs();
|
||||||
|
auto mask = (u < 1.0);
|
||||||
|
|
||||||
|
Eigen::VectorXd r = mask.select(1.0 - u * u, 0.0);
|
||||||
|
|
||||||
|
tukey_weight = r.array() * r.array();
|
||||||
|
};
|
||||||
|
|
||||||
|
auto gastwirth_est = [](Eigen::VectorXd const& r) {
|
||||||
|
// auto gastwirth_est = [](Eigen::VectorXd const& resi) {
|
||||||
|
auto resi = r;
|
||||||
|
std::nth_element(resi.begin(), resi.begin() + resi.size() / 2, resi.end());
|
||||||
|
double md = resi(resi.size() / 2);
|
||||||
|
resi = resi.array() - md;
|
||||||
|
|
||||||
|
// Gastwirth’s estimation: 0.3*Q(1/3) + 0.4*Q(1/2) + 0.3*Q(2/3)
|
||||||
|
|
||||||
|
Eigen::ArrayXd arr = resi.cwiseAbs();
|
||||||
|
|
||||||
|
std::nth_element(arr.begin(), arr.begin() + 2 * arr.size() / 3, arr.end());
|
||||||
|
|
||||||
|
// add 1.0E-8 to avoid 0.0
|
||||||
|
return (0.3 * arr(arr.size() / 3) + 0.4 * arr(arr.size() / 2) + 0.3 * arr(2 * arr.size() / 3)) / 0.6745 +
|
||||||
|
1.0E-8;
|
||||||
|
|
||||||
|
// std::nth_element(arr.begin(), arr.begin() + arr.size() / 2, arr.end());
|
||||||
|
|
||||||
|
// return arr(arr.size() / 2) / 0.6745 + 1.0E-8;
|
||||||
|
};
|
||||||
|
|
||||||
|
compute_result_t result{.pcm_type = pcm_data.type, .error = MccPCMFitterErrorCode::ERROR_OK};
|
||||||
|
|
||||||
|
const size_t n_coeffs = MOUNT_TYPE == MccMountType::FORK_TYPE ? 9 : 8;
|
||||||
|
|
||||||
|
Eigen::MatrixXd X(2 * numberOfPoints(), n_coeffs);
|
||||||
|
Eigen::VectorXd y(2 * numberOfPoints()), beta = Eigen::VectorXd::Zero(n_coeffs), new_beta(n_coeffs);
|
||||||
|
Eigen::VectorXd model;
|
||||||
|
|
||||||
|
Eigen::RowVectorXd row(n_coeffs);
|
||||||
|
double tgY, sinY, cosY, rcosY, cosX, sinX, cosPhi = std::cos(pcm_data.siteLatitude),
|
||||||
|
sinPhi = std::sin(pcm_data.siteLatitude);
|
||||||
|
|
||||||
|
// system matrix and right-hand vector
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
cosY = std::cos(_targetCOLAT[i]);
|
||||||
|
sinY = std::sin(_targetCOLAT[i]);
|
||||||
|
rcosY = 1.0 / cosY;
|
||||||
|
tgY = std::tan(_targetCOLAT[i]);
|
||||||
|
cosX = std::cos(_targetCOLON[i]);
|
||||||
|
sinX = std::sin(_targetCOLON[i]);
|
||||||
|
|
||||||
|
|
||||||
|
// [X0, Y0, collim, nonperp, misal1, misal2, tubefl, DECaxfl, forkfl] or
|
||||||
|
// [X0, Y0, collim, nonperp, misal1, misal2, tubefl, DECaxfl]
|
||||||
|
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
|
||||||
|
if (utils::isEqual(cosY, 0.0)) {
|
||||||
|
row << 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0;
|
||||||
|
} else {
|
||||||
|
row << 1.0, 0.0, rcosY, tgY, -cosX * tgY, sinX * tgY, cosPhi * sinX * rcosY,
|
||||||
|
-(cosPhi * cosX + sinPhi * tgY), 0.0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (utils::isEqual(cosY, 0.0)) {
|
||||||
|
row << 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0;
|
||||||
|
} else {
|
||||||
|
row << 1.0, 0.0, rcosY, tgY, -cosX * tgY, sinX * tgY, cosPhi * sinX * rcosY,
|
||||||
|
-(cosPhi * cosX + sinPhi * tgY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
X.row(i) = row;
|
||||||
|
|
||||||
|
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
|
||||||
|
if (utils::isEqual(cosX, 0.0)) {
|
||||||
|
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0, 0.0;
|
||||||
|
} else {
|
||||||
|
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0, 1.0 / cosX;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row << 0.0, 1.0, 0.0, 0.0, sinX, cosX, cosPhi * cosX * sinY - sinPhi * cosY, 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
X.row(i + numberOfPoints()) = row;
|
||||||
|
|
||||||
|
y(i) = _colonRES[i];
|
||||||
|
y(i + numberOfPoints()) = _colatRES[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
Eigen::VectorXd resi = y;
|
||||||
|
Eigen::VectorXd weights(2 * numberOfPoints());
|
||||||
|
|
||||||
|
double scale;
|
||||||
|
|
||||||
|
Eigen::MatrixXd WX;
|
||||||
|
Eigen::VectorXd Wy;
|
||||||
|
|
||||||
|
// initial parameters estimation (least squares)
|
||||||
|
beta = X.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(y);
|
||||||
|
model = X * beta;
|
||||||
|
resi = y - model;
|
||||||
|
|
||||||
|
// resi = y;
|
||||||
|
|
||||||
|
for (result.final_iter = 1; result.final_iter <= comp_params.max_iter; ++result.final_iter) {
|
||||||
|
scale = gastwirth_est(resi);
|
||||||
|
|
||||||
|
tukey_weight(resi / scale, comp_params.c, weights);
|
||||||
|
|
||||||
|
// Eigen::MatrixXd XtW = X.transpose() * weights.asDiagonal();
|
||||||
|
// Eigen::MatrixXd XtWX = XtW * X;
|
||||||
|
// Eigen::VectorXd XtWy = XtW * y;
|
||||||
|
|
||||||
|
// new_beta = XtWX.ldlt().solve(XtWy);
|
||||||
|
|
||||||
|
WX = weights.asDiagonal() * X;
|
||||||
|
Wy = weights.asDiagonal() * y;
|
||||||
|
new_beta = WX.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(Wy);
|
||||||
|
|
||||||
|
if ((new_beta - beta).norm() < comp_params.tolerance) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
beta = new_beta;
|
||||||
|
|
||||||
|
model = X * beta;
|
||||||
|
resi = y - model;
|
||||||
|
}
|
||||||
|
|
||||||
|
pcm_data.geomCoefficients.zeroPointX = new_beta(0);
|
||||||
|
pcm_data.geomCoefficients.zeroPointY = new_beta(1);
|
||||||
|
pcm_data.geomCoefficients.collimationErr = new_beta(2);
|
||||||
|
pcm_data.geomCoefficients.nonperpendErr = new_beta(3);
|
||||||
|
pcm_data.geomCoefficients.misalignErr1 = new_beta(4);
|
||||||
|
pcm_data.geomCoefficients.misalignErr2 = new_beta(5);
|
||||||
|
pcm_data.geomCoefficients.tubeFlexure = new_beta(6);
|
||||||
|
pcm_data.geomCoefficients.DECaxisFlexure = new_beta(7);
|
||||||
|
if constexpr (MOUNT_TYPE == MccMountType::FORK_TYPE) {
|
||||||
|
pcm_data.geomCoefficients.forkFlexure = new_beta(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.model_colonRES = {model.begin(), model.begin() + numberOfPoints()};
|
||||||
|
result.model_colatRES = {model.begin() + numberOfPoints(), model.end()};
|
||||||
|
result.colon_err.resize(numberOfPoints());
|
||||||
|
result.colat_err.resize(numberOfPoints());
|
||||||
|
|
||||||
|
result.colon_weight = {weights.begin(), weights.begin() + numberOfPoints()};
|
||||||
|
result.colat_weight = {weights.begin() + numberOfPoints(), weights.end()};
|
||||||
|
|
||||||
|
result.colon_err.resize(numberOfPoints());
|
||||||
|
result.colat_err.resize(numberOfPoints());
|
||||||
|
|
||||||
|
for (size_t i = 0; i < numberOfPoints(); ++i) {
|
||||||
|
result.colon_err[i] = _colonRES[i] - result.model_colonRES[i]; // = target - model
|
||||||
|
result.colat_err[i] = _colatRES[i] - result.model_colatRES[i]; // = target - model
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
@@ -13,12 +13,14 @@
|
|||||||
#include "mcc_concepts.h"
|
#include "mcc_concepts.h"
|
||||||
#include "mcc_constants.h"
|
#include "mcc_constants.h"
|
||||||
#include "mcc_coordinate.h"
|
#include "mcc_coordinate.h"
|
||||||
|
#include "mcc_deserializer.h"
|
||||||
|
#include "mcc_serializer.h"
|
||||||
|
|
||||||
namespace mcc::impl
|
namespace mcc::impl
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
enum class MccPZoneErrorCode : int { ERROR_OK, ERROR_NULLPTR, ERROR_COORD_TRANSFROM, ERROR_PCM_COMP };
|
enum class MccPZoneErrorCode : int { ERROR_OK, ERROR_NULLPTR, ERROR_COORD_TRANSFROM, ERROR_NO_PCM, ERROR_PCM_COMP };
|
||||||
|
|
||||||
} // namespace mcc::impl
|
} // namespace mcc::impl
|
||||||
|
|
||||||
@@ -56,6 +58,8 @@ struct MccPZoneCategory : public std::error_category {
|
|||||||
return "input argument os nullptr";
|
return "input argument os nullptr";
|
||||||
case MccPZoneErrorCode::ERROR_COORD_TRANSFROM:
|
case MccPZoneErrorCode::ERROR_COORD_TRANSFROM:
|
||||||
return "coordinate transformation error";
|
return "coordinate transformation error";
|
||||||
|
case MccPZoneErrorCode::ERROR_NO_PCM:
|
||||||
|
return "PCM was not set";
|
||||||
case MccPZoneErrorCode::ERROR_PCM_COMP:
|
case MccPZoneErrorCode::ERROR_PCM_COMP:
|
||||||
return "PCM computation error";
|
return "PCM computation error";
|
||||||
default:
|
default:
|
||||||
@@ -89,6 +93,7 @@ public:
|
|||||||
|
|
||||||
MccAltLimitPZ(mcc_angle_c auto const& alt_limit, mcc_angle_c auto const& latitude)
|
MccAltLimitPZ(mcc_angle_c auto const& alt_limit, mcc_angle_c auto const& latitude)
|
||||||
: _altLimit(MccAngle(alt_limit).normalize<MccAngle::NORM_KIND_90_90>()),
|
: _altLimit(MccAngle(alt_limit).normalize<MccAngle::NORM_KIND_90_90>()),
|
||||||
|
_latitude(MccAngle::normalizeAngle<MccAngle::NORM_KIND_90_90>(latitude)),
|
||||||
_cosALim(cos(_altLimit)),
|
_cosALim(cos(_altLimit)),
|
||||||
_sinAlim(sin(_altLimit)),
|
_sinAlim(sin(_altLimit)),
|
||||||
_cosLat(cos(latitude)),
|
_cosLat(cos(latitude)),
|
||||||
@@ -106,6 +111,32 @@ public:
|
|||||||
: KIND == MccAltLimitKind::MAX_ALT_LIMIT ? "MAXALT-ZONE"
|
: KIND == MccAltLimitKind::MAX_ALT_LIMIT ? "MAXALT-ZONE"
|
||||||
: "ALTLIMIT-UNKNOWN";
|
: "ALTLIMIT-UNKNOWN";
|
||||||
|
|
||||||
|
MccAltLimitPZ& operator=(MccAltLimitPZ&&) = default;
|
||||||
|
MccAltLimitPZ& operator=(const MccAltLimitPZ&) = default;
|
||||||
|
|
||||||
|
template <mcc_angle_c T>
|
||||||
|
T altLimit() const
|
||||||
|
requires(!std::derived_from<T, MccAngle>)
|
||||||
|
{
|
||||||
|
return _altLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
MccAngle altLimit() const
|
||||||
|
{
|
||||||
|
return _altLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <mcc_angle_c T>
|
||||||
|
T latitude() const
|
||||||
|
requires(!std::derived_from<T, MccAngle>)
|
||||||
|
{
|
||||||
|
return _latitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
MccAngle latitude() const
|
||||||
|
{
|
||||||
|
return _latitude;
|
||||||
|
}
|
||||||
|
|
||||||
error_t inPZone(mcc_skypoint_c auto const& coords, bool* result)
|
error_t inPZone(mcc_skypoint_c auto const& coords, bool* result)
|
||||||
{
|
{
|
||||||
@@ -230,7 +261,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
double _altLimit, _cosALim, _sinAlim;
|
double _altLimit, _cosALim, _sinAlim;
|
||||||
double _cosLat, _sinLat, _absLat, _latLim;
|
double _latitude, _cosLat, _sinLat, _absLat, _latLim;
|
||||||
|
|
||||||
bool doesObjectReachZone(const double& dec_app)
|
bool doesObjectReachZone(const double& dec_app)
|
||||||
{
|
{
|
||||||
@@ -321,15 +352,88 @@ protected:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static_assert(std::is_copy_assignable_v<MccAltLimitPZ<MccAltLimitKind::MIN_ALT_LIMIT>>);
|
||||||
|
|
||||||
|
/*
|
||||||
|
to be serialized in format:
|
||||||
|
ALT-LIMIT<seq-delim>LATITUDE
|
||||||
|
*/
|
||||||
|
template <MccAltLimitKind KIND>
|
||||||
|
struct MccSerializer<MccAltLimitPZ<KIND>> : MccSerializerBase {
|
||||||
|
constexpr static std::string_view serializerName{"MCC-ALTITUDE-PZONE-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
MccAltLimitPZ<KIND> const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
MccSerializer<MccAngle> aser;
|
||||||
|
|
||||||
|
auto err = aser(output, value.altLimit(), params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::format_to(std::back_inserter(output), "{}", params.seq_delim);
|
||||||
|
|
||||||
|
err = aser(output, value.latitude(), params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <MccAltLimitKind KIND>
|
||||||
|
struct MccDeserializer<MccAltLimitPZ<KIND>> : MccDeserializerBase {
|
||||||
|
static constexpr std::string_view deserializerName{"MCC-ALTITUDE-PZONE-DESERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_input_char_range auto const& input,
|
||||||
|
MccAltLimitPZ<KIND>& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
std::vector<std::string_view> s;
|
||||||
|
MccDeserializer<MccAngle> ades;
|
||||||
|
|
||||||
|
auto seq = std::views::split(input, params.seq_delim);
|
||||||
|
if (std::ranges::distance(seq.begin(), seq.end()) > 1) {
|
||||||
|
for (auto const& seq_el : seq) {
|
||||||
|
s.push_back(utils::trimSpaces(seq_el, utils::TrimType::TRIM_BOTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
MccAngle alt, lat;
|
||||||
|
|
||||||
|
auto err = ades(s[0], alt, params);
|
||||||
|
if (err) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ades(s[1], lat, params);
|
||||||
|
if (err) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = MccAltLimitPZ<KIND>(alt, lat);
|
||||||
|
} else {
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* co-longitude axis (HA or AZ) limit switch prohibited zone */
|
|
||||||
|
/* co-longitude axis (HA or AZ) and co-latitude (DEC, ZD) limit switch prohibited zone */
|
||||||
|
|
||||||
template <MccCoordKind AXIS_KIND>
|
template <MccCoordKind AXIS_KIND>
|
||||||
class MccAxisLimitSwitchPZ : public mcc_pzone_interface_t<std::error_code>
|
class MccAxisLimitSwitchPZ : public mcc_pzone_interface_t<std::error_code>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static_assert(AXIS_KIND == MccCoordKind::COORDS_KIND_AZ || AXIS_KIND == MccCoordKind::COORDS_KIND_HA_OBS,
|
static_assert(AXIS_KIND == MccCoordKind::COORDS_KIND_AZ || AXIS_KIND == MccCoordKind::COORDS_KIND_HA_OBS ||
|
||||||
|
AXIS_KIND == MccCoordKind::COORDS_KIND_ZD || AXIS_KIND == MccCoordKind::COORDS_KIND_DEC_OBS,
|
||||||
"UNSUPPORTED AXIS TYPE!");
|
"UNSUPPORTED AXIS TYPE!");
|
||||||
|
|
||||||
typedef std::error_code error_t;
|
typedef std::error_code error_t;
|
||||||
@@ -339,33 +443,89 @@ public:
|
|||||||
static constexpr MccProhibitedZonePolicy pzPolicy = MccProhibitedZonePolicy::PZ_POLICY_FLIP;
|
static constexpr MccProhibitedZonePolicy pzPolicy = MccProhibitedZonePolicy::PZ_POLICY_FLIP;
|
||||||
|
|
||||||
//
|
//
|
||||||
// min_limit_val and max_limit_val are hardware encoder angles in radians!
|
// min_limit_val and max_limit_val are hardware encoder angles!
|
||||||
|
// pcm is nullptr or pointer to mcc_pcm_c
|
||||||
//
|
//
|
||||||
MccAxisLimitSwitchPZ(mcc_angle_c auto const& min_limit_val,
|
template <typename PCM_T>
|
||||||
mcc_angle_c auto const& max_limit_val,
|
MccAxisLimitSwitchPZ(mcc_angle_c auto const& min_limit_val, mcc_angle_c auto const& max_limit_val, PCM_T pcm)
|
||||||
mcc_pcm_c auto* pcm)
|
requires(std::is_null_pointer_v<PCM_T> || mcc_pcm_c<std::remove_pointer_t<PCM_T>>)
|
||||||
: _minLimit(min_limit_val), _maxLimit(max_limit_val)
|
: _minLimit(min_limit_val), _maxLimit(max_limit_val)
|
||||||
{
|
{
|
||||||
_correctForPCM = [pcm](MccSkyPoint const& skypt, MccGenXY* hw_coords) {
|
if constexpr (std::is_null_pointer_v<PCM_T>) {
|
||||||
struct pcm_res_t {
|
_correctForPCM = [](MccSkyPoint const&, MccGenXY*) -> error_t { return MccPZoneErrorCode::ERROR_NO_PCM; };
|
||||||
double pcmX, pcmY;
|
} else {
|
||||||
|
_correctForPCM = [pcm](MccSkyPoint const& skypt, MccGenXY* hw_coords) {
|
||||||
|
struct pcm_res_t {
|
||||||
|
double pcmX, pcmY;
|
||||||
|
};
|
||||||
|
|
||||||
|
pcm_res_t res;
|
||||||
|
|
||||||
|
auto err = pcm->computeInversePCM(skypt, &res, hw_coords);
|
||||||
|
|
||||||
|
return mcc_deduced_err(err, MccPZoneErrorCode::ERROR_PCM_COMP);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
pcm_res_t res;
|
|
||||||
|
|
||||||
auto err = pcm->computeInversePCM(skypt, &res, hw_coords);
|
|
||||||
|
|
||||||
return mcc_deduced_err(err, MccPZoneErrorCode::ERROR_PCM_COMP);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static constexpr std::string_view pzoneName = axisKind == MccCoordKind::COORDS_KIND_AZ ? "AZ_AXIS-LIMITSWITCH_ZONE"
|
static constexpr std::string_view pzoneName =
|
||||||
: axisKind == MccCoordKind::COORDS_KIND_HA_OBS
|
axisKind == MccCoordKind::COORDS_KIND_AZ ? "AZ-AXIS-LIMITSWITCH-ZONE"
|
||||||
? "HA_AXIS-LIMITSWITCH_ZONE"
|
: axisKind == MccCoordKind::COORDS_KIND_HA_OBS ? "HA-AXIS-LIMITSWITCH-ZONE"
|
||||||
: "UKNOWN";
|
: axisKind == MccCoordKind::COORDS_KIND_ZD ? "ZD-AXIS-LIMITSWITCH-ZONE"
|
||||||
|
: axisKind == MccCoordKind::COORDS_KIND_DEC_OBS ? "DEC-AXIS-LIMITSWITCH-ZONE"
|
||||||
|
: "UKNOWN";
|
||||||
|
|
||||||
|
MccAxisLimitSwitchPZ(const MccAxisLimitSwitchPZ&) = default;
|
||||||
|
MccAxisLimitSwitchPZ(MccAxisLimitSwitchPZ&&) = default;
|
||||||
|
|
||||||
|
MccAxisLimitSwitchPZ& operator=(const MccAxisLimitSwitchPZ&) = default;
|
||||||
|
MccAxisLimitSwitchPZ& operator=(MccAxisLimitSwitchPZ&&) = default;
|
||||||
|
|
||||||
|
template <mcc_angle_c T>
|
||||||
|
T minLimit() const
|
||||||
|
requires(!std::derived_from<T, MccAngle>)
|
||||||
|
{
|
||||||
|
return _minLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
MccAngle minLimit() const
|
||||||
|
{
|
||||||
|
return _minLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <mcc_angle_c T>
|
||||||
|
T maxLimit() const
|
||||||
|
requires(!std::derived_from<T, MccAngle>)
|
||||||
|
{
|
||||||
|
return _maxLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
MccAngle maxLimit() const
|
||||||
|
{
|
||||||
|
return _maxLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename PCM_T>
|
||||||
|
void setPCM(PCM_T pcm)
|
||||||
|
requires(std::is_null_pointer_v<PCM_T> || mcc_pcm_c<std::remove_pointer_t<PCM_T>>)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_null_pointer_v<PCM_T>) {
|
||||||
|
_correctForPCM = [](MccSkyPoint const&, MccGenXY*) -> error_t { return MccPZoneErrorCode::ERROR_NO_PCM; };
|
||||||
|
} else {
|
||||||
|
_correctForPCM = [pcm](MccSkyPoint const& skypt, MccGenXY* hw_coords) {
|
||||||
|
struct pcm_res_t {
|
||||||
|
double pcmX, pcmY;
|
||||||
|
};
|
||||||
|
|
||||||
|
pcm_res_t res;
|
||||||
|
|
||||||
|
auto err = pcm->computeInversePCM(skypt, &res, hw_coords);
|
||||||
|
|
||||||
|
return mcc_deduced_err(err, MccPZoneErrorCode::ERROR_PCM_COMP);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
error_t inPZone(mcc_skypoint_c auto const& coords, bool* result)
|
error_t inPZone(mcc_skypoint_c auto const& coords, bool* result)
|
||||||
{
|
{
|
||||||
@@ -430,15 +590,36 @@ protected:
|
|||||||
coords.to(xy);
|
coords.to(xy);
|
||||||
}
|
}
|
||||||
|
|
||||||
double x = xy.x();
|
|
||||||
|
|
||||||
if constexpr (AXIS_KIND == MccCoordKind::COORDS_KIND_HA_OBS) {
|
if constexpr (AXIS_KIND == MccCoordKind::COORDS_KIND_HA_OBS) {
|
||||||
|
double x = xy.x();
|
||||||
|
|
||||||
if (from_time) { // timeFromPZone
|
if (from_time) { // timeFromPZone
|
||||||
time_ang = (_minLimit - x) / MCC_SIDERAL_TO_UT1_RATIO; // to UT1 scale
|
time_ang = (_minLimit - x) / MCC_SIDERAL_TO_UT1_RATIO; // to UT1 scale
|
||||||
} else { // timeToPZone
|
} else { // timeToPZone
|
||||||
time_ang = (_maxLimit - x) / MCC_SIDERAL_TO_UT1_RATIO; // to UT1 scale
|
time_ang = (_maxLimit - x) / MCC_SIDERAL_TO_UT1_RATIO; // to UT1 scale
|
||||||
}
|
}
|
||||||
|
} else if constexpr (AXIS_KIND == MccCoordKind::COORDS_KIND_DEC_OBS) {
|
||||||
|
double y = xy.y();
|
||||||
|
|
||||||
|
// TODO: !!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
// assume here sideral speed moving! so, observed DEC is near constant
|
||||||
|
if (from_time) { // timeFromPZone
|
||||||
|
if (y < _minLimit || y > _maxLimit) {
|
||||||
|
time_ang = std::numeric_limits<double>::max();
|
||||||
|
} else {
|
||||||
|
time_ang = 0;
|
||||||
|
}
|
||||||
|
} else { // timeToPZone
|
||||||
|
if (y < _minLimit || y > _maxLimit) { // already in the zone
|
||||||
|
time_ang = 0;
|
||||||
|
} else {
|
||||||
|
time_ang = std::numeric_limits<double>::max();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if constexpr (AXIS_KIND == MccCoordKind::COORDS_KIND_AZ) {
|
} else if constexpr (AXIS_KIND == MccCoordKind::COORDS_KIND_AZ) {
|
||||||
|
static_assert(false, "NOT IMPLEMENTED YET!!!");
|
||||||
|
} else {
|
||||||
|
static_assert(false, "NOT IMPLEMENTED YET!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::chrono::nanoseconds ns{
|
std::chrono::nanoseconds ns{
|
||||||
@@ -451,5 +632,81 @@ protected:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static_assert(std::is_copy_assignable_v<MccAxisLimitSwitchPZ<MccCoordKind::COORDS_KIND_HA_OBS>>);
|
||||||
|
static_assert(std::is_copy_assignable_v<MccAxisLimitSwitchPZ<MccCoordKind::COORDS_KIND_DEC_OBS>>);
|
||||||
|
|
||||||
|
/*
|
||||||
|
to be serialized in format:
|
||||||
|
MIN_LIMIT<seq-delim>MAX_LIMIT
|
||||||
|
*/
|
||||||
|
template <MccCoordKind AXIS_KIND>
|
||||||
|
struct MccSerializer<MccAxisLimitSwitchPZ<AXIS_KIND>> : MccSerializerBase {
|
||||||
|
constexpr static std::string_view serializerName{"MCC-AXIS-LIMIT-SWITCH-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
MccAxisLimitSwitchPZ<AXIS_KIND> const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
MccSerializer<MccAngle> aser;
|
||||||
|
|
||||||
|
auto err = aser(output, value.minLimit(), params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::format_to(std::back_inserter(output), "{}", params.seq_delim);
|
||||||
|
|
||||||
|
err = aser(output, value.maxLimit(), params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <MccCoordKind AXIS_KIND>
|
||||||
|
struct MccDeserializer<MccAxisLimitSwitchPZ<AXIS_KIND>> : MccDeserializerBase {
|
||||||
|
static constexpr std::string_view deserializerName{"MCC-AXIS-LIMIT-SWITCH-DESERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_input_char_range auto const& input,
|
||||||
|
MccAxisLimitSwitchPZ<AXIS_KIND>& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
std::vector<std::string_view> s;
|
||||||
|
MccDeserializer<MccAngle> ades;
|
||||||
|
|
||||||
|
auto seq = std::views::split(input, params.seq_delim);
|
||||||
|
// if (std::ranges::size(seq) < 2) {
|
||||||
|
if (std::ranges::distance(seq.begin(), seq.end()) > 1) {
|
||||||
|
for (auto const& seq_el : seq) {
|
||||||
|
s.push_back(utils::trimSpaces(seq_el, utils::TrimType::TRIM_BOTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
MccAngle minLim, maxLim;
|
||||||
|
|
||||||
|
auto err = ades(s[0], minLim, params);
|
||||||
|
if (err) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ades(s[1], maxLim, params);
|
||||||
|
if (err) {
|
||||||
|
return MccDeserializerErrorCode::ERROR_UNDERLYING_DESERIALIZER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// WARNING: the class below is created without the PCM-class pointer!!!
|
||||||
|
value = MccAxisLimitSwitchPZ<AXIS_KIND>(minLim, maxLim, nullptr);
|
||||||
|
} else {
|
||||||
|
return MccDeserializerErrorCode::ERROR_INVALID_SERIALIZED_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccDeserializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace mcc::impl
|
} // namespace mcc::impl
|
||||||
@@ -115,7 +115,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto sptr = std::make_shared<decltype(zone)>(std::move(zone));
|
auto sptr = std::make_shared<decltype(zone)>(std::move(zone));
|
||||||
|
|
||||||
_inZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, bool* res) {
|
_inZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, bool* res) -> error_t {
|
||||||
auto err = sptr->inPZone(pt, res);
|
auto err = sptr->inPZone(pt, res);
|
||||||
if (err) {
|
if (err) {
|
||||||
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_INZONE_FUNC);
|
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_INZONE_FUNC);
|
||||||
@@ -125,7 +125,7 @@ public:
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
_timeToZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, duration_t* res) {
|
_timeToZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, duration_t* res) -> error_t {
|
||||||
auto err = sptr->timeToPZone(pt, res);
|
auto err = sptr->timeToPZone(pt, res);
|
||||||
if (err) {
|
if (err) {
|
||||||
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_TIMETO_FUNC);
|
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_TIMETO_FUNC);
|
||||||
@@ -135,7 +135,7 @@ public:
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
_timeFromZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, duration_t* res) {
|
_timeFromZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, duration_t* res) -> error_t {
|
||||||
auto err = sptr->timeFromPZone(pt, res);
|
auto err = sptr->timeFromPZone(pt, res);
|
||||||
if (err) {
|
if (err) {
|
||||||
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_TIMEFROM_FUNC);
|
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_TIMEFROM_FUNC);
|
||||||
@@ -144,17 +144,26 @@ public:
|
|||||||
return MccPZoneContainerErrorCode::ERROR_OK;
|
return MccPZoneContainerErrorCode::ERROR_OK;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_names.push_back(std::format("{}", zone.pzoneName));
|
||||||
|
|
||||||
return _inZoneFunc.size();
|
return _inZoneFunc.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearZones()
|
void clearPZones()
|
||||||
{
|
{
|
||||||
_inZoneFunc.clear();
|
_inZoneFunc.clear();
|
||||||
_timeToZoneFunc.clear();
|
_timeToZoneFunc.clear();
|
||||||
_timeFromZoneFunc.clear();
|
_timeFromZoneFunc.clear();
|
||||||
|
|
||||||
|
_names.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<std::string> pzoneNames() const
|
||||||
|
{
|
||||||
|
return _names;
|
||||||
|
}
|
||||||
|
|
||||||
error_t inPZone(mcc_skypoint_c auto const& coords, bool* at_least_one, std::ranges::output_range<bool> auto* result)
|
error_t inPZone(mcc_skypoint_c auto const& coords, bool* at_least_one, std::ranges::output_range<bool> auto* result)
|
||||||
{
|
{
|
||||||
auto err = forEach(_inZoneFunc, coords, result);
|
auto err = forEach(_inZoneFunc, coords, result);
|
||||||
@@ -188,9 +197,11 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
typedef std::chrono::nanoseconds duration_t;
|
typedef std::chrono::nanoseconds duration_t;
|
||||||
|
|
||||||
std::vector<std::function<error_t(MccSkyPoint const& pt, bool*)>> _inZoneFunc;
|
std::vector<std::function<error_t(MccSkyPoint const& pt, bool*)>> _inZoneFunc{};
|
||||||
std::vector<std::function<error_t(MccSkyPoint const& pt, duration_t*)>> _timeToZoneFunc;
|
std::vector<std::function<error_t(MccSkyPoint const& pt, duration_t*)>> _timeToZoneFunc{};
|
||||||
std::vector<std::function<error_t(MccSkyPoint const& pt, duration_t*)>> _timeFromZoneFunc;
|
std::vector<std::function<error_t(MccSkyPoint const& pt, duration_t*)>> _timeFromZoneFunc{};
|
||||||
|
|
||||||
|
std::vector<std::string> _names{};
|
||||||
|
|
||||||
error_t forEach(auto& func_cont, MccSkyPoint const& pt, auto* result)
|
error_t forEach(auto& func_cont, MccSkyPoint const& pt, auto* result)
|
||||||
{
|
{
|
||||||
@@ -205,7 +216,7 @@ protected:
|
|||||||
|
|
||||||
res_elem_t res_elem;
|
res_elem_t res_elem;
|
||||||
|
|
||||||
size_t res_sz = std::ranges::size(*result);
|
// size_t res_sz = std::ranges::size(*result);
|
||||||
auto it = result->begin();
|
auto it = result->begin();
|
||||||
|
|
||||||
for (auto& func : func_cont) {
|
for (auto& func : func_cont) {
|
||||||
390
include/mcc/mcc_serialization_common.h
Normal file
390
include/mcc/mcc_serialization_common.h
Normal file
@@ -0,0 +1,390 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
* *
|
||||||
|
* MOUNT CONTROL COMPONENTS LIBRARY *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* COMMON DEFINITIONS FOR DATA SERIALIZATION/DESERIALIZATION *
|
||||||
|
* *
|
||||||
|
****************************************************************************************/
|
||||||
|
|
||||||
|
#include "mcc_concepts.h"
|
||||||
|
#include "mcc_error.h"
|
||||||
|
#include "mcc_traits.h"
|
||||||
|
|
||||||
|
namespace mcc
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/* celestial angle serialization */
|
||||||
|
|
||||||
|
enum class MccSerializedAngleFormat {
|
||||||
|
MCC_SERIALIZED_FORMAT_DEGREES, // degrees as floating-point number
|
||||||
|
MCC_SERIALIZED_FORMAT_SXGM_HOURS, // sexagesimal representation: hours:mins:secs
|
||||||
|
MCC_SERIALIZED_FORMAT_SXGM_DEGS, // sexagesimal representation: degs:arcmins:arcsecs
|
||||||
|
MCC_SERIALIZED_FORMAT_UNKNOWN
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr std::string_view MCC_SERIALIZED_ANG_FORMAT_DEGREES_STR = "SRANG-FORMAT-DEGREES";
|
||||||
|
static constexpr std::string_view MCC_SERIALIZED_ANG_FORMAT_SXGM_HOURS_STR = "SRANG-FORMAT-SXGM_HOURDEG";
|
||||||
|
static constexpr std::string_view MCC_SERIALIZED_ANG_FORMAT_SXGM_DEGS_STR = "SRANG-FORMAT-SXGM_DEGDEG";
|
||||||
|
|
||||||
|
|
||||||
|
static constexpr std::string_view MccSerializedAngleFormatToStr(MccSerializedAngleFormat fmt)
|
||||||
|
{
|
||||||
|
return fmt == MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_DEGREES ? MCC_SERIALIZED_ANG_FORMAT_DEGREES_STR
|
||||||
|
: fmt == MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURS
|
||||||
|
? MCC_SERIALIZED_ANG_FORMAT_SXGM_HOURS_STR
|
||||||
|
: fmt == MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGS ? MCC_SERIALIZED_ANG_FORMAT_SXGM_DEGS_STR
|
||||||
|
: MCC_SERIALIZED_ANG_FORMAT_DEGREES_STR;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range R>
|
||||||
|
static constexpr MccSerializedAngleFormat MccSerializedAngleFormatStrToValue(R&& str)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_array_v<std::decay_t<R>>) {
|
||||||
|
return MccSerializedAngleFormatStrToValue(std::string_view{str});
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto hash = mcc::utils::FNV1aHash(std::forward<R>(str));
|
||||||
|
|
||||||
|
return hash == mcc::utils::FNV1aHash(MCC_SERIALIZED_ANG_FORMAT_DEGREES_STR)
|
||||||
|
? MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_DEGREES
|
||||||
|
: hash == mcc::utils::FNV1aHash(MCC_SERIALIZED_ANG_FORMAT_SXGM_HOURS_STR)
|
||||||
|
? MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURS
|
||||||
|
: hash == mcc::utils::FNV1aHash(MCC_SERIALIZED_ANG_FORMAT_SXGM_DEGS_STR)
|
||||||
|
? MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGS
|
||||||
|
: MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* coordinates pair serialization */
|
||||||
|
|
||||||
|
enum class MccSerializedCoordPairFormat {
|
||||||
|
MCC_SERIALIZED_FORMAT_DEGREES, // both angles are in degrees as floating-point number
|
||||||
|
MCC_SERIALIZED_FORMAT_SXGM_HOURDEG, // X is in hour (if RA or HA) and Y is in degree sexagesimal representation
|
||||||
|
MCC_SERIALIZED_FORMAT_SXGM_DEGDEG, // both angles are in sexagesimal degrees
|
||||||
|
MCC_SERIALIZED_FORMAT_UNKNOWN
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr std::string_view MCC_SERIALIZED_CP_FORMAT_DEGREES_STR = "SRCP-FORMAT-DEGREES";
|
||||||
|
static constexpr std::string_view MCC_SERIALIZED_CP_FORMAT_SXGM_HOURDEG_STR = "SRCP-FORMAT-SXGM_HOURDEG";
|
||||||
|
static constexpr std::string_view MCC_SERIALIZED_CP_FORMAT_SXGM_DEGDEG_STR = "SRCP-FORMAT-SXGM_DEGDEG";
|
||||||
|
|
||||||
|
|
||||||
|
static constexpr std::string_view MccSerializedCoordPairFormatToStr(MccSerializedCoordPairFormat fmt)
|
||||||
|
{
|
||||||
|
return fmt == MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_DEGREES ? MCC_SERIALIZED_CP_FORMAT_DEGREES_STR
|
||||||
|
: fmt == MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURDEG
|
||||||
|
? MCC_SERIALIZED_CP_FORMAT_SXGM_HOURDEG_STR
|
||||||
|
: fmt == MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGDEG
|
||||||
|
? MCC_SERIALIZED_CP_FORMAT_SXGM_DEGDEG_STR
|
||||||
|
: MCC_SERIALIZED_CP_FORMAT_DEGREES_STR;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range R>
|
||||||
|
static constexpr MccSerializedCoordPairFormat MccSerializedCoordPairFormatStrToValue(R&& str)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_array_v<std::decay_t<R>>) {
|
||||||
|
return MccSerializedCoordPairFormatStrToValue(std::string_view{str});
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto hash = mcc::utils::FNV1aHash(std::forward<R>(str));
|
||||||
|
|
||||||
|
return hash == mcc::utils::FNV1aHash(MCC_SERIALIZED_CP_FORMAT_DEGREES_STR)
|
||||||
|
? MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_DEGREES
|
||||||
|
: hash == mcc::utils::FNV1aHash(MCC_SERIALIZED_CP_FORMAT_SXGM_HOURDEG_STR)
|
||||||
|
? MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURDEG
|
||||||
|
: hash == mcc::utils::FNV1aHash(MCC_SERIALIZED_CP_FORMAT_SXGM_DEGDEG_STR)
|
||||||
|
? MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGDEG
|
||||||
|
: MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* precision of representation of serialized celestial angle/coordinates pair */
|
||||||
|
|
||||||
|
struct MccSerializedAngleFormatPrec {
|
||||||
|
uint8_t hour_prec = 2; // number of decimal places in hour seconds (sexagesimal format)
|
||||||
|
uint8_t deg_prec = 1; // number of decimal places in arcseconds (sexagesimal format)
|
||||||
|
// slightly better than 0.1 arcsecond precision
|
||||||
|
uint8_t decimals = 6; // number of decimal places in degrees (floating-point number format)
|
||||||
|
// if 0, then number of decimal places is according to formating rules of 'double' type
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class MccTimePointFormat {
|
||||||
|
MCC_TIMEPOINT_FORMAT_DATE, // UTC date
|
||||||
|
MCC_TIMEPOINT_FORMAT_MJD, // MJD
|
||||||
|
MCC_TIMEPOINT_FORMAT_JD, // JD
|
||||||
|
MCC_TIMEPOINT_FORMAT_JEPOCH, // Julian epoch
|
||||||
|
MCC_TIMEPOINT_FORMAT_UNKNOWN
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr std::string_view MCC_TIMEPOINT_FORMAT_DATE_STR = "TP-FORMAT-DATE";
|
||||||
|
static constexpr std::string_view MCC_TIMEPOINT_FORMAT_MJD_STR = "TP-FORMAT-MJD";
|
||||||
|
static constexpr std::string_view MCC_TIMEPOINT_FORMAT_JD_STR = "TP-FORMAT-JD";
|
||||||
|
static constexpr std::string_view MCC_TIMEPOINT_FORMAT_JEPOCH_STR = "TP-FORMAT-JEPOCH";
|
||||||
|
|
||||||
|
static constexpr std::string_view MccTimePointFormatToStr(MccTimePointFormat fmt)
|
||||||
|
{
|
||||||
|
return fmt == MccTimePointFormat::MCC_TIMEPOINT_FORMAT_DATE ? MCC_TIMEPOINT_FORMAT_DATE_STR
|
||||||
|
: fmt == MccTimePointFormat::MCC_TIMEPOINT_FORMAT_MJD ? MCC_TIMEPOINT_FORMAT_MJD_STR
|
||||||
|
: fmt == MccTimePointFormat::MCC_TIMEPOINT_FORMAT_JD ? MCC_TIMEPOINT_FORMAT_JD_STR
|
||||||
|
: fmt == MccTimePointFormat::MCC_TIMEPOINT_FORMAT_JEPOCH ? MCC_TIMEPOINT_FORMAT_JEPOCH_STR
|
||||||
|
: MCC_TIMEPOINT_FORMAT_MJD_STR;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <traits::mcc_input_char_range R>
|
||||||
|
static constexpr MccTimePointFormat MccTimePointFormatStrToValue(R&& str)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_array_v<std::decay_t<R>>) {
|
||||||
|
return MccTimePointFormatStrToValue(std::string_view{str});
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto hash = mcc::utils::FNV1aHash(std::forward<R>(str));
|
||||||
|
|
||||||
|
return hash == mcc::utils::FNV1aHash(MCC_TIMEPOINT_FORMAT_DATE_STR) ? MccTimePointFormat::MCC_TIMEPOINT_FORMAT_DATE
|
||||||
|
: hash == mcc::utils::FNV1aHash(MCC_TIMEPOINT_FORMAT_MJD_STR) ? MccTimePointFormat::MCC_TIMEPOINT_FORMAT_MJD
|
||||||
|
: hash == mcc::utils::FNV1aHash(MCC_TIMEPOINT_FORMAT_JD_STR) ? MccTimePointFormat::MCC_TIMEPOINT_FORMAT_JD
|
||||||
|
: hash == mcc::utils::FNV1aHash(MCC_TIMEPOINT_FORMAT_JEPOCH_STR)
|
||||||
|
? MccTimePointFormat::MCC_TIMEPOINT_FORMAT_JEPOCH
|
||||||
|
: MccTimePointFormat::MCC_TIMEPOINT_FORMAT_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* SERIALIZATION/DESERIALIZATION PROCESS TUNING PARAMETERS */
|
||||||
|
|
||||||
|
// delimiter between items of serializing values sequence
|
||||||
|
static constexpr std::string_view MCC_SERIALIZING_DEFAULT_SEQ_DELIMITER{";"};
|
||||||
|
|
||||||
|
// delimiter between items of aggregative (multi-element) serializing value
|
||||||
|
static constexpr std::string_view MCC_SERIALIZING_DEFAULT_ELEM_DELIMITER{","};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_serialization_params_c = std::copyable<T> && requires(T t) {
|
||||||
|
requires traits::mcc_output_char_range<decltype(t.seq_delim)>;
|
||||||
|
requires traits::mcc_output_char_range<decltype(t.elem_delim)>;
|
||||||
|
|
||||||
|
requires std::same_as<decltype(t.angle_format), MccSerializedAngleFormat>;
|
||||||
|
requires std::same_as<decltype(t.angle_prec), MccSerializedAngleFormatPrec>;
|
||||||
|
requires std::same_as<decltype(t.coordpair_format), MccSerializedCoordPairFormat>;
|
||||||
|
requires std::same_as<decltype(t.timepoint_format), MccTimePointFormat>;
|
||||||
|
|
||||||
|
// a format string for mcc_systime_c types (std;:chrono::sys_time)
|
||||||
|
requires std::same_as<decltype(t.systime_format), std::string_view>;
|
||||||
|
|
||||||
|
// if true - normalize angle in sexagesimal format (to control rounding)
|
||||||
|
// (to avoid something like "24:00:00.0" for sexagesimal 'hours:minutes:seconds' format)
|
||||||
|
requires std::convertible_to<decltype(t.norm_sxgm), bool>;
|
||||||
|
|
||||||
|
// if true - interpretate serialized angle in sexagesimal format as 'hours:minutes:seconds'
|
||||||
|
// otherwise as 'degrees:arcmins:arcsecs'
|
||||||
|
requires std::convertible_to<decltype(t.sxgm_hms), bool>;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* SERIALIZER/DESERIALIZER CONCEPTS */
|
||||||
|
|
||||||
|
template <mcc_error_c RetT>
|
||||||
|
struct mcc_serializer_interface_t {
|
||||||
|
virtual ~mcc_serializer_interface_t() = default;
|
||||||
|
|
||||||
|
typedef RetT error_t;
|
||||||
|
|
||||||
|
template <std::derived_from<mcc_serializer_interface_t> SelfT, traits::mcc_output_char_range R, typename ValueT>
|
||||||
|
RetT operator()(this SelfT&& self, R& output, ValueT const& value)
|
||||||
|
{
|
||||||
|
return std::forward<SelfT>(self)(output, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::derived_from<mcc_serializer_interface_t> SelfT, traits::mcc_output_char_range R, typename ValueT>
|
||||||
|
RetT operator()(this SelfT&& self, R& output, ValueT const& value, mcc_serialization_params_c auto const& params)
|
||||||
|
{
|
||||||
|
return std::forward<SelfT>(self)(output, value, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
mcc_serializer_interface_t() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_serializer_c =
|
||||||
|
std::derived_from<T, mcc_serializer_interface_t<typename T::error_t>> && requires(T t, const T t_const) {
|
||||||
|
// static const variable with name of the serializer
|
||||||
|
requires std::formattable<decltype(T::serializerName), char> && std::is_const_v<decltype(T::serializerName)>;
|
||||||
|
|
||||||
|
// // must define a type "params_t"
|
||||||
|
// requires mcc_serialization_params_c<typename T::params_t>;
|
||||||
|
|
||||||
|
// { t.setParams(std::declval<typename T::params_t const&>()) };
|
||||||
|
|
||||||
|
// { t_const.getParams() } -> std::same_as<typename T::params_t>;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_error_c RetT>
|
||||||
|
struct mcc_deserializer_interface_t {
|
||||||
|
virtual ~mcc_deserializer_interface_t() = default;
|
||||||
|
|
||||||
|
typedef RetT error_t;
|
||||||
|
|
||||||
|
template <std::derived_from<mcc_deserializer_interface_t> SelfT, traits::mcc_input_char_range R, typename ValueT>
|
||||||
|
RetT operator()(this SelfT&& self, R const& input, ValueT& value)
|
||||||
|
{
|
||||||
|
return std::forward<SelfT>(self)(input, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::derived_from<mcc_deserializer_interface_t> SelfT, traits::mcc_input_char_range R, typename ValueT>
|
||||||
|
RetT operator()(this SelfT&& self, R const& input, ValueT& value, mcc_serialization_params_c auto& params)
|
||||||
|
{
|
||||||
|
return std::forward<SelfT>(self)(input, value, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
mcc_deserializer_interface_t() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept mcc_deserializer_c =
|
||||||
|
std::derived_from<T, mcc_deserializer_interface_t<typename T::error_t>> && requires(T t, const T t_const) {
|
||||||
|
// static const variable with name of the deserializer
|
||||||
|
requires std::formattable<decltype(T::deserializerName), char> &&
|
||||||
|
std::is_const_v<decltype(T::deserializerName)>;
|
||||||
|
|
||||||
|
// // must define a type "params_t"
|
||||||
|
// requires mcc_serialization_params_c<typename T::params_t>;
|
||||||
|
|
||||||
|
// { t.setParams(std::declval<typename T::params_t const&>()) };
|
||||||
|
|
||||||
|
// { t_const.getParams() } -> std::same_as<typename T::params_t>;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* BASE CLASS IMPLEMENTATION FOR SERIALIZER/DESERIALIZER */
|
||||||
|
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
|
// default definition of serialization/deserialization process parameters structure
|
||||||
|
struct mcc_serialization_params_t {
|
||||||
|
std::string seq_delim{MCC_SERIALIZING_DEFAULT_SEQ_DELIMITER};
|
||||||
|
std::string elem_delim{MCC_SERIALIZING_DEFAULT_ELEM_DELIMITER};
|
||||||
|
|
||||||
|
MccSerializedAngleFormat angle_format{MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_DEGREES};
|
||||||
|
|
||||||
|
MccSerializedAngleFormatPrec angle_prec{MccSerializedAngleFormatPrec{.hour_prec = 2, .deg_prec = 1, .decimals = 6}};
|
||||||
|
|
||||||
|
MccSerializedCoordPairFormat coordpair_format{MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURDEG};
|
||||||
|
|
||||||
|
MccTimePointFormat timepoint_format{MccTimePointFormat::MCC_TIMEPOINT_FORMAT_DATE};
|
||||||
|
|
||||||
|
std::string_view systime_format{"{:%FT%T}"};
|
||||||
|
|
||||||
|
bool norm_sxgm{false};
|
||||||
|
|
||||||
|
bool sxgm_hms{false};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static_assert(mcc_serialization_params_c<mcc_serialization_params_t>, "!!!");
|
||||||
|
|
||||||
|
namespace details
|
||||||
|
{
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT>
|
||||||
|
struct _params_manipulator_t {
|
||||||
|
virtual ~_params_manipulator_t() = default;
|
||||||
|
|
||||||
|
typedef ParamsT params_t;
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c p_t>
|
||||||
|
void setParams(p_t const& pars)
|
||||||
|
{
|
||||||
|
if constexpr (std::same_as<p_t, params_t>) {
|
||||||
|
_params = pars;
|
||||||
|
} else {
|
||||||
|
_params.seq_delim = pars.seq_delim;
|
||||||
|
_params.elem_delim = pars.elem_delim;
|
||||||
|
_params.coordpair_format = pars.coordpair_format;
|
||||||
|
_params.angle_prec = pars.angle_prec;
|
||||||
|
_params.timepoint_format = pars.timepoint_format;
|
||||||
|
_params.norm_sxgm = pars.norm_sxgm;
|
||||||
|
_params.sxgm_hms = pars.sxgm_hms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c p_t>
|
||||||
|
requires(!std::same_as<p_t, params_t>)
|
||||||
|
p_t getParams() const
|
||||||
|
{
|
||||||
|
p_t pars;
|
||||||
|
|
||||||
|
pars.seq_delim = _params.seq_delim;
|
||||||
|
pars.elem_delim = _params.elem_delim;
|
||||||
|
pars.coordpair_format = _params.coordpair_format;
|
||||||
|
pars.angle_prec = _params.angle_prec;
|
||||||
|
pars.timepoint_format = _params.timepoint_format;
|
||||||
|
pars.norm_sxgm = _params.norm_sxgm;
|
||||||
|
pars.sxgm_hms = _params.sxgm_hms;
|
||||||
|
|
||||||
|
return pars;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
params_t getParams() const
|
||||||
|
{
|
||||||
|
return _params;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
_params_manipulator_t() = default;
|
||||||
|
|
||||||
|
params_t _params;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace details
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// struct MccDeserializerBase : mcc_deserializer_interface_t<MccError> {
|
||||||
|
// virtual ~MccDeserializerBase() = default;
|
||||||
|
|
||||||
|
// using typename mcc_deserializer_interface_t<MccError>::error_t;
|
||||||
|
|
||||||
|
// protected:
|
||||||
|
// MccDeserializerBase() = default;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// template <mcc_serialization_params_c ParamsT>
|
||||||
|
// struct MccSerializerBase : mcc_serializer_interface_t<MccError>, details::_params_manipulator_t<ParamsT> {
|
||||||
|
// virtual ~MccSerializerBase() = default;
|
||||||
|
|
||||||
|
// using typename mcc_serializer_interface_t<MccError>::error_t;
|
||||||
|
|
||||||
|
// using typename details::_params_manipulator_t<ParamsT>::params_t;
|
||||||
|
|
||||||
|
// protected:
|
||||||
|
// MccSerializerBase() = default;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// template <mcc_serialization_params_c ParamsT>
|
||||||
|
// struct MccDeserializerBase : mcc_deserializer_interface_t<MccError>, details::_params_manipulator_t<ParamsT> {
|
||||||
|
// virtual ~MccDeserializerBase() = default;
|
||||||
|
|
||||||
|
// using typename mcc_deserializer_interface_t<MccError>::error_t;
|
||||||
|
|
||||||
|
// using typename details::_params_manipulator_t<ParamsT>::params_t;
|
||||||
|
|
||||||
|
// protected:
|
||||||
|
// MccDeserializerBase() = default;
|
||||||
|
// };
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
|
|
||||||
|
} // namespace mcc
|
||||||
777
include/mcc/mcc_serializer.h
Normal file
777
include/mcc/mcc_serializer.h
Normal file
@@ -0,0 +1,777 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "mcc_coordinate.h"
|
||||||
|
#include "mcc_serialization_common.h"
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class MccSerializerErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_UNDERLYING_SERIALIZER,
|
||||||
|
ERROR_INVALID_EPOCH,
|
||||||
|
ERROR_COORD_TRANSFORM
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class is_error_code_enum<mcc::impl::MccSerializerErrorCode> : public true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
|
||||||
|
namespace mcc::impl
|
||||||
|
{
|
||||||
|
|
||||||
|
// error category
|
||||||
|
struct MccSerializerCategory : public std::error_category {
|
||||||
|
MccSerializerCategory() : std::error_category() {}
|
||||||
|
|
||||||
|
const char* name() const noexcept
|
||||||
|
{
|
||||||
|
return "MCC-SERIALIZER-ERR-CATEGORY";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message(int ec) const
|
||||||
|
{
|
||||||
|
MccSerializerErrorCode err = static_cast<MccSerializerErrorCode>(ec);
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
case MccSerializerErrorCode::ERROR_OK:
|
||||||
|
return "OK";
|
||||||
|
case MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER:
|
||||||
|
return "error returned by underlying serializer";
|
||||||
|
case MccSerializerErrorCode::ERROR_INVALID_EPOCH:
|
||||||
|
return "invalid coordinate epoch";
|
||||||
|
case MccSerializerErrorCode::ERROR_COORD_TRANSFORM:
|
||||||
|
return "coordinates transformation error";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const MccSerializerCategory& get()
|
||||||
|
{
|
||||||
|
static const MccSerializerCategory constInst;
|
||||||
|
return constInst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline std::error_code make_error_code(MccSerializerErrorCode ec)
|
||||||
|
{
|
||||||
|
return std::error_code(static_cast<int>(ec), MccSerializerCategory::get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* BASE SERIALIZER CLASS (FOR IMPLEMENTATIONS BELOW) */
|
||||||
|
|
||||||
|
struct MccSerializerBase : mcc_serializer_interface_t<MccError> {
|
||||||
|
virtual ~MccSerializerBase() = default;
|
||||||
|
|
||||||
|
using typename mcc_serializer_interface_t<MccError>::error_t;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
MccSerializerBase() = default;
|
||||||
|
|
||||||
|
enum CoordType { CO_LON, CO_LAT };
|
||||||
|
|
||||||
|
static void addElemDelimiter(traits::mcc_output_char_range auto& output,
|
||||||
|
mcc_serialization_params_c auto const& params)
|
||||||
|
{
|
||||||
|
std::format_to(std::back_inserter(output), "{}", params.elem_delim);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void addSeqDelimiter(traits::mcc_output_char_range auto& output,
|
||||||
|
mcc_serialization_params_c auto const& params)
|
||||||
|
{
|
||||||
|
std::format_to(std::back_inserter(output), "{}", params.seq_delim);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// set serialized angle format according to coordinates pair format and type of
|
||||||
|
// serializing mcc_coord_pair_c::pairKind
|
||||||
|
template <MccCoordPairKind PAIRKIND, CoordType TYPE = MccSerializerBase::CO_LON>
|
||||||
|
static void angleFormatFromCoordPairType(mcc_serialization_params_c auto& pars)
|
||||||
|
{
|
||||||
|
if (pars.coordpair_format == MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_DEGREES) {
|
||||||
|
pars.angle_format = MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_DEGREES;
|
||||||
|
} else { // format to sexagesimal form according to celestial coordinate type
|
||||||
|
if constexpr (TYPE == MccSerializerBase::CO_LON) {
|
||||||
|
if (pars.coordpair_format == MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGDEG) {
|
||||||
|
pars.angle_format = MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGS;
|
||||||
|
} else if (pars.coordpair_format == MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURDEG) {
|
||||||
|
if constexpr (PAIRKIND == MccCoordPairKind::COORDS_KIND_AZZD ||
|
||||||
|
PAIRKIND == MccCoordPairKind::COORDS_KIND_AZALT ||
|
||||||
|
PAIRKIND == MccCoordPairKind::COORDS_KIND_XY ||
|
||||||
|
PAIRKIND == MccCoordPairKind::COORDS_KIND_GENERIC) { // azimuth is in degrees
|
||||||
|
pars.angle_format = MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGS;
|
||||||
|
pars.norm_sxgm = true;
|
||||||
|
} else { // RA or HA
|
||||||
|
pars.angle_format = MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURS;
|
||||||
|
pars.norm_sxgm = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// !!!!!!!!!!!!!!!!!!
|
||||||
|
}
|
||||||
|
} else { // Y-coordinates (co-latitude one, DEC, ALT, ZD, generic X) is always in degrees for celestial
|
||||||
|
// point
|
||||||
|
pars.angle_format = MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VT, typename R>
|
||||||
|
requires(std::ranges::input_range<R> && std::same_as<VT, std::ranges::range_value_t<R>>)
|
||||||
|
static error_t serializeRange(mcc_serializer_c auto& sr,
|
||||||
|
R const& r,
|
||||||
|
traits::mcc_output_char_range auto& output,
|
||||||
|
mcc_serialization_params_c auto const& params)
|
||||||
|
{
|
||||||
|
size_t i = 0, N = std::ranges::size(r);
|
||||||
|
|
||||||
|
for (auto const& el : r) {
|
||||||
|
auto err = sr(output, el, params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
if (++i < N) {
|
||||||
|
// MccSerializerBase::addSeqDelimiter(output, params);
|
||||||
|
MccSerializerBase::addElemDelimiter(output, params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* MAIN (FALLBACK) TEMPLATED IMPLEMENTATION */
|
||||||
|
|
||||||
|
template <typename VT>
|
||||||
|
struct MccSerializer : MccSerializerBase {
|
||||||
|
constexpr static std::string_view serializerName{"MCC-FALLBACK-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
VT const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
if constexpr (std::convertible_to<VT, std::string>) {
|
||||||
|
std::string s = value;
|
||||||
|
std::ranges::copy(s, std::back_inserter(output));
|
||||||
|
// auto err = MccSerializer<std::string>{}(output, static_cast<std::string>(value), params);
|
||||||
|
// if (err) {
|
||||||
|
// return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
// }
|
||||||
|
} else if constexpr (std::ranges::range<VT>) {
|
||||||
|
using value_t = std::remove_cv_t<std::ranges::range_value_t<VT>>;
|
||||||
|
|
||||||
|
// special range (character sequence)
|
||||||
|
if constexpr (std::same_as<value_t, char>) {
|
||||||
|
std::ranges::copy(value, std::back_inserter(output));
|
||||||
|
} else {
|
||||||
|
MccSerializer<value_t> sr;
|
||||||
|
|
||||||
|
return MccSerializerBase::serializeRange<value_t>(sr, value, output, params);
|
||||||
|
}
|
||||||
|
} else if constexpr (std::formattable<VT, char>) {
|
||||||
|
std::format_to(std::back_inserter(output), "{}", value);
|
||||||
|
} else {
|
||||||
|
static_assert(false, "UNSUPPORTED TYPE!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* SPECIALIZATION FOR THE SOME CONCEPTS */
|
||||||
|
|
||||||
|
|
||||||
|
template <traits::mcc_time_duration_c VT>
|
||||||
|
struct MccSerializer<VT> : MccSerializerBase {
|
||||||
|
virtual ~MccSerializer() = default;
|
||||||
|
|
||||||
|
constexpr static std::string_view serializerName{"MCC-TIME-DURATION-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
VT const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
std::format_to(std::back_inserter(output), "{}", value.count());
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* std::chrono::sys_time variants and its sequence */
|
||||||
|
|
||||||
|
template <traits::mcc_systime_c VT>
|
||||||
|
struct MccSerializer<VT> : MccSerializerBase {
|
||||||
|
virtual ~MccSerializer() = default;
|
||||||
|
|
||||||
|
constexpr static std::string_view serializerName{"MCC-SYSTIME-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
VT const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
// std::vformat_to(std::back_inserter(output), params.systime_format, std::make_format_args(value));
|
||||||
|
auto tp = std::chrono::round<std::chrono::milliseconds>(value);
|
||||||
|
std::vformat_to(std::back_inserter(output), params.systime_format, std::make_format_args(tp));
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename VT>
|
||||||
|
requires(!std::is_arithmetic_v<VT> && mcc_angle_c<VT>)
|
||||||
|
struct MccSerializer<VT> : MccSerializerBase {
|
||||||
|
constexpr static std::string_view serializerName{"MCC-ANGLE-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
VT const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
double v = (double)value; // radians (see mcc_angle_c concept)
|
||||||
|
std::string sgm;
|
||||||
|
|
||||||
|
switch (params.angle_format) {
|
||||||
|
case MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_DEGREES: {
|
||||||
|
v *= MCC_RADS_TO_DEGRESS;
|
||||||
|
std::string_view fmt = "{:." + std::to_string(params.angle_prec.decimals) + "f}";
|
||||||
|
std::vformat_to(std::back_inserter(output), fmt, std::make_format_args(v));
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
// return MccSerializer<double>{}(output, v, params);
|
||||||
|
case MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_DEGS:
|
||||||
|
if (params.norm_sxgm) {
|
||||||
|
sgm = utils::rad2sxg<true>(v, false, params.angle_prec.deg_prec);
|
||||||
|
} else {
|
||||||
|
sgm = utils::rad2sxg<false>(v, false, params.angle_prec.deg_prec);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURS:
|
||||||
|
if (params.norm_sxgm) {
|
||||||
|
sgm = utils::rad2sxg<true>(v, true, params.angle_prec.hour_prec);
|
||||||
|
} else {
|
||||||
|
sgm = utils::rad2sxg<false>(v, true, params.angle_prec.hour_prec);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto err = MccSerializer<std::string>{}(output, sgm, params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_coord_epoch_c VT>
|
||||||
|
struct MccSerializer<VT> : MccSerializerBase {
|
||||||
|
constexpr static std::string_view serializerName{"MCC-COORD-EPOCH-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
VT const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
double jd;
|
||||||
|
|
||||||
|
switch (params.timepoint_format) {
|
||||||
|
case MccTimePointFormat::MCC_TIMEPOINT_FORMAT_DATE: {
|
||||||
|
auto tp = value.UTC();
|
||||||
|
auto err = MccSerializer<decltype(tp)>{}(output, tp, params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
};
|
||||||
|
case MccTimePointFormat::MCC_TIMEPOINT_FORMAT_JEPOCH: {
|
||||||
|
auto ep = value.JEpoch();
|
||||||
|
auto err = MccSerializer<decltype(ep)>{}(output, ep, params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
} break;
|
||||||
|
case MccTimePointFormat::MCC_TIMEPOINT_FORMAT_JD:
|
||||||
|
jd = value.MJD() + MCC_J2000_MJD;
|
||||||
|
break;
|
||||||
|
case MccTimePointFormat::MCC_TIMEPOINT_FORMAT_MJD:
|
||||||
|
jd = value.MJD();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
auto err = MccSerializer<double>{}(output, jd, params);
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_coord_pair_c VT>
|
||||||
|
struct MccSerializer<VT> : MccSerializerBase {
|
||||||
|
constexpr static std::string_view serializerName{"MCC-COORD-PAIR-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
VT const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
// format: X<elem-delim>Y<elem-delim>PAIRKIND<elem-delim>EPOCH
|
||||||
|
|
||||||
|
auto pars = params;
|
||||||
|
|
||||||
|
|
||||||
|
// X-coordinate
|
||||||
|
MccSerializerBase::angleFormatFromCoordPairType<VT::pairKind, MccSerializerBase::CO_LON>(pars);
|
||||||
|
|
||||||
|
auto err = MccSerializer<MccAngle>{}(output, value.x(), pars);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, params);
|
||||||
|
|
||||||
|
// pars.norm_sxgm = false; // do not normalize co-latitude angle
|
||||||
|
|
||||||
|
// Y-coordinate
|
||||||
|
MccSerializerBase::angleFormatFromCoordPairType<VT::pairKind, MccSerializerBase::CO_LAT>(pars);
|
||||||
|
|
||||||
|
err = MccSerializer<MccAngle>{}(output, value.y(), pars);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, params);
|
||||||
|
|
||||||
|
// pair kind
|
||||||
|
auto pk_err = MccSerializer<std::string_view>{}(output, MccCoordPairKindToStr(VT::pairKind), params);
|
||||||
|
if (pk_err) {
|
||||||
|
return mcc_deduced_err(pk_err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, params);
|
||||||
|
|
||||||
|
// epoch
|
||||||
|
auto ep = value.epoch();
|
||||||
|
auto ep_err = MccSerializer<decltype(ep)>{}(output, ep, params);
|
||||||
|
if (ep_err) {
|
||||||
|
return mcc_deduced_err(ep_err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_skypoint_c VT>
|
||||||
|
struct MccSerializer<VT> : MccSerializerBase {
|
||||||
|
constexpr static std::string_view serializerName{"MCC-SKYPOINT-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
VT const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
auto serialize_cpair = [&]<typename T>(T& cp) -> error_t {
|
||||||
|
auto ccte_err = value.toAtSameEpoch(cp);
|
||||||
|
if (ccte_err) {
|
||||||
|
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto err = MccSerializer<T>{}(output, cp, params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (value.pairKind()) {
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_ICRS: {
|
||||||
|
MccSkyRADEC_ICRS cp;
|
||||||
|
return serialize_cpair(cp);
|
||||||
|
}
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_OBS: {
|
||||||
|
MccSkyRADEC_OBS cp;
|
||||||
|
return serialize_cpair(cp);
|
||||||
|
}
|
||||||
|
case MccCoordPairKind::COORDS_KIND_RADEC_APP: {
|
||||||
|
MccSkyRADEC_APP cp;
|
||||||
|
return serialize_cpair(cp);
|
||||||
|
}
|
||||||
|
case MccCoordPairKind::COORDS_KIND_HADEC_OBS: {
|
||||||
|
MccSkyHADEC_OBS cp;
|
||||||
|
return serialize_cpair(cp);
|
||||||
|
}
|
||||||
|
case MccCoordPairKind::COORDS_KIND_HADEC_APP: {
|
||||||
|
MccSkyHADEC_APP cp;
|
||||||
|
return serialize_cpair(cp);
|
||||||
|
}
|
||||||
|
case MccCoordPairKind::COORDS_KIND_AZZD: {
|
||||||
|
MccSkyAZZD cp;
|
||||||
|
return serialize_cpair(cp);
|
||||||
|
}
|
||||||
|
case MccCoordPairKind::COORDS_KIND_AZALT: {
|
||||||
|
MccSkyAZALT cp;
|
||||||
|
return serialize_cpair(cp);
|
||||||
|
}
|
||||||
|
case MccCoordPairKind::COORDS_KIND_XY: {
|
||||||
|
MccGenXY cp;
|
||||||
|
return serialize_cpair(cp);
|
||||||
|
}
|
||||||
|
case MccCoordPairKind::COORDS_KIND_GENERIC: {
|
||||||
|
MccGenXY cp;
|
||||||
|
return serialize_cpair(cp);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return MccSerializerErrorCode::ERROR_COORD_TRANSFORM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <mcc_telemetry_data_c VT>
|
||||||
|
struct MccSerializer<VT> : MccSerializerBase {
|
||||||
|
constexpr static std::string_view serializerName{"MCC-TELEMETRY-DATA-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
VT const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
// FORMAT: RA_OBS_MOUNT, DEC_OBS_MOUNT, RA_APP_MOUNT, DEC_APP_MOUNT, HA_APP_MOUNT, AZ_MOUNT, ZD_MOUNT,
|
||||||
|
// REFR_CORR_MOUNT, ENC_X, ENC_Y, PCM_X, PCM_Y, RA_APP_TAG, DEC_APP_TAG, AZ_TAG, ZD_TAG, LAST, EO, TIMEPOINT,
|
||||||
|
// STATUS
|
||||||
|
|
||||||
|
// NOTE: One must assume that the returned RA coordinates are in format of underlying celestial coordinate
|
||||||
|
// transformation engine used in the mcc_skypoint_c class implementation. E.g. ERFA-library uses the
|
||||||
|
// CIO-based representation of RA
|
||||||
|
|
||||||
|
auto pars_h = params;
|
||||||
|
|
||||||
|
auto pars_d = params;
|
||||||
|
|
||||||
|
|
||||||
|
pars_h.norm_sxgm = true;
|
||||||
|
pars_h.coordpair_format = MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURDEG;
|
||||||
|
pars_d.norm_sxgm = true;
|
||||||
|
pars_d.coordpair_format = MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURDEG;
|
||||||
|
|
||||||
|
MccSkyRADEC_OBS rd_obs;
|
||||||
|
MccSkyRADEC_APP rd_app;
|
||||||
|
MccSkyHADEC_APP hd_app;
|
||||||
|
MccSkyAZZD azzd;
|
||||||
|
|
||||||
|
// quantities in hour representation
|
||||||
|
MccSerializerBase::angleFormatFromCoordPairType<MccCoordPairKind::COORDS_KIND_RADEC_ICRS,
|
||||||
|
MccSerializerBase::CO_LON>(pars_h);
|
||||||
|
|
||||||
|
// quantities in degree representation
|
||||||
|
MccSerializerBase::angleFormatFromCoordPairType<MccCoordPairKind::COORDS_KIND_RADEC_ICRS,
|
||||||
|
MccSerializerBase::CO_LAT>(pars_d);
|
||||||
|
|
||||||
|
MccSerializer<MccAngle> ang_sr;
|
||||||
|
|
||||||
|
// RA_OBS_MOUNT, DEC_OBS_MOUNT
|
||||||
|
auto ccte_err = value.mountPos.toAtSameEpoch(rd_obs);
|
||||||
|
if (ccte_err) {
|
||||||
|
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto err = ang_sr(output, rd_obs.x(), pars_h);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
err = ang_sr(output, rd_obs.y(), pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
// RA_APP_MOUNT, DEC_APP_MOUNT
|
||||||
|
ccte_err = value.mountPos.toAtSameEpoch(rd_app);
|
||||||
|
if (ccte_err) {
|
||||||
|
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ang_sr(output, rd_app.x(), pars_h);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
err = ang_sr(output, rd_app.y(), pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
// HA_APP_MOUNT
|
||||||
|
ccte_err = value.mountPos.toAtSameEpoch(hd_app);
|
||||||
|
if (ccte_err) {
|
||||||
|
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ang_sr(output, hd_app.x(), pars_h);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
// AZ_MOUNT, ZD_MOUNT
|
||||||
|
ccte_err = value.mountPos.toAtSameEpoch(azzd);
|
||||||
|
if (ccte_err) {
|
||||||
|
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ang_sr(output, azzd.x(), pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
err = ang_sr(output, azzd.y(), pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
// refraction correction
|
||||||
|
|
||||||
|
MccAngle ang;
|
||||||
|
ccte_err = value.mountPos.refractCorrection(&ang);
|
||||||
|
if (ccte_err) {
|
||||||
|
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ang_sr(output, ang, pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
|
||||||
|
// encoder X and Y
|
||||||
|
|
||||||
|
err = ang_sr(output, value.hwState.XY.x(), pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
err = ang_sr(output, value.hwState.XY.y(), pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
|
||||||
|
// PCM X and Y
|
||||||
|
|
||||||
|
err = ang_sr(output, value.pcmCorrection.pcmX, pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
err = ang_sr(output, value.pcmCorrection.pcmY, pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
|
||||||
|
// RA_APP_TAG, DEC_APP_TAG
|
||||||
|
ccte_err = value.targetPos.toAtSameEpoch(rd_app);
|
||||||
|
if (ccte_err) {
|
||||||
|
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ang_sr(output, rd_app.x(), pars_h);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
err = ang_sr(output, rd_app.y(), pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
// AZ_TAG, ZD_TAG
|
||||||
|
ccte_err = value.targetPos.toAtSameEpoch(azzd);
|
||||||
|
if (ccte_err) {
|
||||||
|
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ang_sr(output, azzd.x(), pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
err = ang_sr(output, azzd.y(), pars_d);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
|
||||||
|
// LAST, local apparent sideral time
|
||||||
|
|
||||||
|
ccte_err = value.mountPos.appSideralTime(&ang, true);
|
||||||
|
if (ccte_err) {
|
||||||
|
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ang_sr(output, ang, pars_h);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
|
||||||
|
// EO, equation of origins
|
||||||
|
|
||||||
|
ccte_err = value.mountPos.EO(&ang);
|
||||||
|
if (ccte_err) {
|
||||||
|
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ang_sr(output, ang, pars_h);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
// coordinates epoch
|
||||||
|
|
||||||
|
auto ep_err = MccSerializer<MccCelestialCoordEpoch>{}(output, value.mountPos.epoch(), pars_d);
|
||||||
|
if (ep_err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
|
|
||||||
|
// status (it must be formattable, see mcc_concepts.h)
|
||||||
|
|
||||||
|
auto st_err =
|
||||||
|
MccSerializer<decltype(value.hwState.movementState)>{}(output, value.hwState.movementState, pars_d);
|
||||||
|
if (st_err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct MccSerializer<MccSerializedCoordPairFormat> : MccSerializerBase {
|
||||||
|
constexpr static std::string_view serializerName{"MCC-COORDPAIR-FORMAT-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
MccSerializedCoordPairFormat const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
std::ranges::copy(MccSerializedCoordPairFormatToStr(value), std::back_inserter(output));
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct MccSerializer<MccSerializedAngleFormatPrec> : MccSerializerBase {
|
||||||
|
constexpr static std::string_view serializerName{"MCC-ANGLE-FORMAT-PREC-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
MccSerializedAngleFormatPrec const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
auto err = MccSerializer<decltype(value.hour_prec)>{}(output, value.hour_prec, params);
|
||||||
|
if (!err) {
|
||||||
|
auto err = MccSerializer<decltype(value.deg_prec)>{}(output, value.deg_prec, params);
|
||||||
|
if (!err) {
|
||||||
|
auto err = MccSerializer<decltype(value.decimals)>{}(output, value.decimals, params);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MccSerializerErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static_assert(mcc_serializer_c<MccSerializer<MccAngle>>, "!!!");
|
||||||
|
|
||||||
|
} // namespace mcc::impl
|
||||||
@@ -104,20 +104,26 @@ inline std::error_code make_error_code(MccTelemetryErrorCode ec)
|
|||||||
|
|
||||||
|
|
||||||
template <mcc_hardware_c HARDWARE_T>
|
template <mcc_hardware_c HARDWARE_T>
|
||||||
class MccTelemetry
|
class MccTelemetry : public mcc_telemetry_interface_t<MccError>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef HARDWARE_T hardware_t;
|
typedef HARDWARE_T hardware_t;
|
||||||
|
|
||||||
typedef std::error_code error_t;
|
typedef MccError error_t;
|
||||||
|
|
||||||
|
|
||||||
struct telemetry_data_t {
|
struct telemetry_data_t {
|
||||||
MccSkyPoint targetPos{};
|
MccSkyPoint targetPos{}; // celestial coordinates
|
||||||
|
|
||||||
MccSkyPoint mountPos{};
|
MccGenXY targetXY{}; // encoder coordinates
|
||||||
|
|
||||||
typename HARDWARE_T::hardware_state_t hwState{};
|
struct {
|
||||||
|
double pcmX{}, pcmY{};
|
||||||
|
} pcmReverseCorrection{};
|
||||||
|
|
||||||
|
MccSkyPoint mountPos{}; // celestial coordinates
|
||||||
|
|
||||||
|
typename HARDWARE_T::hardware_state_t hwState{}; // here encoder coordinates
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
double pcmX{}, pcmY{};
|
double pcmX{}, pcmY{};
|
||||||
@@ -210,8 +216,8 @@ public:
|
|||||||
mcc_deduced_err(hw_err, MccTelemetryErrorCode::ERROR_HARDWARE_GETSTATE);
|
mcc_deduced_err(hw_err, MccTelemetryErrorCode::ERROR_HARDWARE_GETSTATE);
|
||||||
} else {
|
} else {
|
||||||
// compute PCM corrections and observed (corrected for PCM) mount coordinates
|
// compute PCM corrections and observed (corrected for PCM) mount coordinates
|
||||||
auto pcm_err = pcm_ptr->computePCM(_tdataPtr->hwState.XY, &_tdataPtr->pcmCorrection,
|
auto pcm_err = pcm_ptr->computePCM(_tdataPtr->hwState.XY, &(_tdataPtr->pcmCorrection),
|
||||||
&_tdataPtr->mountPos);
|
&(_tdataPtr->mountPos));
|
||||||
|
|
||||||
if (!pcm_err) {
|
if (!pcm_err) {
|
||||||
// set target coordinates
|
// set target coordinates
|
||||||
@@ -229,14 +235,46 @@ public:
|
|||||||
mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
|
mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_tdataPtr->pcmReverseCorrection.pcmX = -pcm_corr.pcmX;
|
||||||
|
_tdataPtr->pcmReverseCorrection.pcmY = -pcm_corr.pcmY;
|
||||||
} else {
|
} else {
|
||||||
_lastUpdateError =
|
_lastUpdateError =
|
||||||
mcc_deduced_err(ccte_err, MccTelemetryErrorCode::ERROR_COORD_TRANSFORM);
|
mcc_deduced_err(ccte_err, MccTelemetryErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
}
|
}
|
||||||
} else { // observed, apparent or ICRS
|
|
||||||
_tdataPtr->targetPos = _enteredTargetPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
} else { // observed, apparent or ICRS
|
||||||
|
// _tdataPtr->targetPos = _enteredTargetPos;
|
||||||
|
using pcm_t = std::remove_pointer_t<decltype(pcm_ptr)>;
|
||||||
|
|
||||||
|
std::conditional_t<mcc_is_equatorial_mount<pcm_t::pcmMountType>,
|
||||||
|
MccSkyHADEC_OBS,
|
||||||
|
std::conditional_t<mcc_is_altaz_mount<pcm_t::pcmMountType>,
|
||||||
|
MccSkyAZZD, std::nullptr_t>>
|
||||||
|
cp;
|
||||||
|
|
||||||
|
static_assert(!std::is_null_pointer_v<decltype(cp)>, "UNKNOW MOUNT TYPE!");
|
||||||
|
|
||||||
|
// calculate target celestial coordinates (of the same type as .mountPos) at the
|
||||||
|
// epoch of the current mount position
|
||||||
|
cp.setEpoch(_tdataPtr->mountPos.epoch());
|
||||||
|
auto ccte_err = _enteredTargetPos.to(cp);
|
||||||
|
if (ccte_err) {
|
||||||
|
_lastUpdateError =
|
||||||
|
mcc_deduced_err(ccte_err, MccTelemetryErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
} else {
|
||||||
|
_tdataPtr->targetPos.from(cp);
|
||||||
|
|
||||||
|
// calculate reverse PCM corrections for the current target position and
|
||||||
|
// its encoder XY
|
||||||
|
auto pcm_err = pcm_ptr->computeInversePCM(_tdataPtr->targetPos,
|
||||||
|
&_tdataPtr->pcmReverseCorrection,
|
||||||
|
&_tdataPtr->targetXY);
|
||||||
|
if (pcm_err) {
|
||||||
|
_lastUpdateError =
|
||||||
|
mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_lastUpdateError = mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
|
_lastUpdateError = mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
|
||||||
}
|
}
|
||||||
@@ -252,6 +290,85 @@ public:
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_updatingStopSource.get_token(), hardware, pcm);
|
_updatingStopSource.get_token(), hardware, pcm);
|
||||||
|
|
||||||
|
|
||||||
|
_updateFunc = [hw=hardware, pcm_ptr=pcm, this](telemetry_data_t* tdata) mutable -> error_t {
|
||||||
|
_tdataPtr = tdata;
|
||||||
|
if (_tdataPtr != nullptr && hw && pcm_ptr) {
|
||||||
|
_lastUpdateError = MccTelemetryErrorCode::ERROR_OK;
|
||||||
|
|
||||||
|
// get hardware state (coordinates, speeds and so on)
|
||||||
|
auto hw_err = hw->hardwareGetState(&_tdataPtr->hwState);
|
||||||
|
if (hw_err) {
|
||||||
|
_lastUpdateError = mcc_deduced_err(hw_err, MccTelemetryErrorCode::ERROR_HARDWARE_GETSTATE);
|
||||||
|
} else {
|
||||||
|
// compute PCM corrections and observed (corrected for PCM) mount coordinates
|
||||||
|
auto pcm_err =
|
||||||
|
pcm_ptr->computePCM(_tdataPtr->hwState.XY, &(_tdataPtr->pcmCorrection), &(_tdataPtr->mountPos));
|
||||||
|
|
||||||
|
if (!pcm_err) {
|
||||||
|
// set target coordinates
|
||||||
|
if (_enteredTargetPos.pairKind() == MccCoordPairKind::COORDS_KIND_XY) {
|
||||||
|
// hardware coordinates
|
||||||
|
MccGenXY xy;
|
||||||
|
auto ccte_err = _enteredTargetPos.toAtSameEpoch(xy);
|
||||||
|
|
||||||
|
if (!ccte_err) {
|
||||||
|
decltype(_tdataPtr->pcmCorrection) pcm_corr;
|
||||||
|
|
||||||
|
pcm_err = pcm_ptr->computePCM(xy, &pcm_corr, &_tdataPtr->targetPos);
|
||||||
|
if (pcm_err) {
|
||||||
|
_lastUpdateError = mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
_tdataPtr->pcmReverseCorrection.pcmX = -pcm_corr.pcmX;
|
||||||
|
_tdataPtr->pcmReverseCorrection.pcmY = -pcm_corr.pcmY;
|
||||||
|
} else {
|
||||||
|
_lastUpdateError =
|
||||||
|
mcc_deduced_err(ccte_err, MccTelemetryErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { // observed, apparent or ICRS
|
||||||
|
// _tdataPtr->targetPos = _enteredTargetPos;
|
||||||
|
using pcm_t = std::remove_pointer_t<decltype(pcm_ptr)>;
|
||||||
|
|
||||||
|
std::conditional_t<
|
||||||
|
mcc_is_equatorial_mount<pcm_t::pcmMountType>, MccSkyHADEC_OBS,
|
||||||
|
std::conditional_t<mcc_is_altaz_mount<pcm_t::pcmMountType>, MccSkyAZZD, std::nullptr_t>>
|
||||||
|
cp;
|
||||||
|
|
||||||
|
static_assert(!std::is_null_pointer_v<decltype(cp)>, "UNKNOW MOUNT TYPE!");
|
||||||
|
|
||||||
|
// calculate target celestial coordinates (of the same type as .mountPos) at the
|
||||||
|
// epoch of the current mount position
|
||||||
|
cp.setEpoch(_tdataPtr->mountPos.epoch());
|
||||||
|
auto ccte_err = _enteredTargetPos.to(cp);
|
||||||
|
if (ccte_err) {
|
||||||
|
_lastUpdateError =
|
||||||
|
mcc_deduced_err(ccte_err, MccTelemetryErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
|
} else {
|
||||||
|
_tdataPtr->targetPos.from(cp);
|
||||||
|
|
||||||
|
// calculate reverse PCM corrections for the current target position and
|
||||||
|
// its encoder XY
|
||||||
|
auto pcm_err = pcm_ptr->computeInversePCM(
|
||||||
|
_tdataPtr->targetPos, &_tdataPtr->pcmReverseCorrection, &_tdataPtr->targetXY);
|
||||||
|
if (pcm_err) {
|
||||||
|
_lastUpdateError = mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_lastUpdateError = mcc_deduced_err(pcm_err, MccTelemetryErrorCode::ERROR_PCM_COMP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_lastUpdateError = MccTelemetryErrorCode::ERROR_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _lastUpdateError;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
MccTelemetry(MccTelemetry&&) = default;
|
MccTelemetry(MccTelemetry&&) = default;
|
||||||
@@ -278,14 +395,34 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error_t setTarget(mcc_skypoint_c auto const& sp)
|
error_t setPointingTarget(mcc_skypoint_c auto const& sp)
|
||||||
{
|
{
|
||||||
|
std::lock_guard lock{*_updateMutex};
|
||||||
|
|
||||||
_enteredTargetPos = sp;
|
_enteredTargetPos = sp;
|
||||||
|
|
||||||
return MccTelemetryErrorCode::ERROR_OK;
|
return MccTelemetryErrorCode::ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
auto getPointingTarget() const
|
||||||
|
{
|
||||||
|
std::lock_guard lock{*_updateMutex};
|
||||||
|
|
||||||
|
return _enteredTargetPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// error_t getPointingTarget(mcc_skypoint_c auto* sp)
|
||||||
|
// {
|
||||||
|
// if (sp) {
|
||||||
|
// *sp = _enteredTargetPos;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return MccTelemetryErrorCode::ERROR_OK;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// blocks the current thread until telemetry data is received.
|
// blocks the current thread until telemetry data is received.
|
||||||
// the maximum blocking time is equal to the set timeout (see setTelemetryDataTimeout method)
|
// the maximum blocking time is equal to the set timeout (see setTelemetryDataTimeout method)
|
||||||
@@ -296,6 +433,11 @@ public:
|
|||||||
|
|
||||||
_lastUpdateError = MccTelemetryErrorCode::ERROR_OK;
|
_lastUpdateError = MccTelemetryErrorCode::ERROR_OK;
|
||||||
|
|
||||||
|
// 12.10.2026: try to catch dead-lock
|
||||||
|
// use here mutex-free non-timedout implementation
|
||||||
|
return _updateFunc(tdata);
|
||||||
|
// tdata = _tdataPtr;
|
||||||
|
|
||||||
_tdataPtr = tdata;
|
_tdataPtr = tdata;
|
||||||
|
|
||||||
// trigger updating
|
// trigger updating
|
||||||
@@ -313,12 +455,14 @@ public:
|
|||||||
return _lastUpdateError;
|
return _lastUpdateError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set a timeout for the telemetry receiving process
|
// Set a timeout for the telemetry receiving process
|
||||||
//
|
//
|
||||||
void setTelemetryDataTimeout(traits::mcc_time_duration_c auto const& timeout)
|
template <traits::mcc_time_duration_c DT>
|
||||||
|
void setTelemetryDataTimeout(DT const& timeout)
|
||||||
{
|
{
|
||||||
if constexpr (std::floating_point<typename decltype(timeout)::rep>) {
|
if constexpr (std::floating_point<typename DT::rep>) {
|
||||||
if (utils::isEqual(timeout.count(), 0.0) || timeout.count() < 0.0) {
|
if (utils::isEqual(timeout.count(), 0.0) || timeout.count() < 0.0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -346,7 +490,7 @@ private:
|
|||||||
// HARDWARE_T* _hardware{nullptr};
|
// HARDWARE_T* _hardware{nullptr};
|
||||||
MccSkyPoint _enteredTargetPos{};
|
MccSkyPoint _enteredTargetPos{};
|
||||||
|
|
||||||
// std::function<error_t(telemetry_data_t*)> _updateFunc{};
|
std::function<error_t(telemetry_data_t*)> _updateFunc{};
|
||||||
telemetry_data_t* _tdataPtr;
|
telemetry_data_t* _tdataPtr;
|
||||||
|
|
||||||
std::unique_ptr<std::atomic_flag> _dataUpdatingRequested{new std::atomic_flag{}};
|
std::unique_ptr<std::atomic_flag> _dataUpdatingRequested{new std::atomic_flag{}};
|
||||||
@@ -56,7 +56,13 @@ template <typename R>
|
|||||||
concept mcc_range_of_output_char_range =
|
concept mcc_range_of_output_char_range =
|
||||||
std::ranges::range<R> && traits::mcc_output_char_range<std::ranges::range_value_t<R>>;
|
std::ranges::range<R> && traits::mcc_output_char_range<std::ranges::range_value_t<R>>;
|
||||||
|
|
||||||
|
// std::array, std::span(v_t, N), std::tuple
|
||||||
|
template <typename R>
|
||||||
|
concept mcc_fixed_size_range = std::ranges::range<R> && requires { std::tuple_size<std::remove_cvref_t<R>>::value; };
|
||||||
|
|
||||||
|
// non-resizable ranges
|
||||||
|
template <typename R>
|
||||||
|
concept mcc_non_resizable_range = std::ranges::range<R> && !requires(R r, std::size_t n) { r.resize(n); };
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/72430369/how-to-check-that-a-type-is-formattable-using-type-traits-concepts)
|
// https://stackoverflow.com/questions/72430369/how-to-check-that-a-type-is-formattable-using-type-traits-concepts)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -16,7 +16,8 @@ namespace mcc::utils
|
|||||||
{
|
{
|
||||||
|
|
||||||
static const std::regex decimalNumberRx{" *[-+]?([0-9]*[.])?[0-9]+([eE][-+]?[0-9]+)? *"};
|
static const std::regex decimalNumberRx{" *[-+]?([0-9]*[.])?[0-9]+([eE][-+]?[0-9]+)? *"};
|
||||||
static const std::regex sexagesimalReprRx{" *[-+]?[0-9]{1,2}:[0-9]{1,2}:([0-9]{0,2}[.])?[0-9]+ *"};
|
// static const std::regex sexagesimalReprRx{" *[-+]?[0-9]{1,2}:[0-9]{1,2}:([0-9]{0,2}[.])?[0-9]+ *"};
|
||||||
|
static const std::regex sexagesimalReprRx{" *[-+]?[0-9]{1,}:[0-9]{1,2}:([0-9]{0,2}[.])?[0-9]+ *"};
|
||||||
|
|
||||||
|
|
||||||
constexpr static bool isEqual(std::floating_point auto const& v1, std::floating_point auto const& v2)
|
constexpr static bool isEqual(std::floating_point auto const& v1, std::floating_point auto const& v2)
|
||||||
@@ -68,7 +69,7 @@ constexpr static std::string_view trimSpaces(const char* r, TrimType type = Trim
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, std::ranges::contiguous_range R>
|
template <typename T, std::ranges::contiguous_range R>
|
||||||
std::optional<T> numFromStr(R&& r)
|
static std::optional<T> numFromStr(R&& r)
|
||||||
requires((std::integral<T> || std::floating_point<T>) &&
|
requires((std::integral<T> || std::floating_point<T>) &&
|
||||||
std::same_as<char, std::remove_cvref_t<std::ranges::range_value_t<R>>>)
|
std::same_as<char, std::remove_cvref_t<std::ranges::range_value_t<R>>>)
|
||||||
{
|
{
|
||||||
@@ -340,7 +341,10 @@ static std::string AZZD_rad2sxg(double az, double zd, std::string_view delim = "
|
|||||||
// "12:43:23.423, 102:43:12.124"
|
// "12:43:23.423, 102:43:12.124"
|
||||||
// " 12.3453467, 102:43:12.124 "
|
// " 12.3453467, 102:43:12.124 "
|
||||||
template <mcc::traits::mcc_input_char_range R>
|
template <mcc::traits::mcc_input_char_range R>
|
||||||
std::pair<double, double> parseAnglePair(R&& str, bool hms1 = false, bool hms2 = false, std::string_view delim = ",")
|
static std::pair<double, double> parseAnglePair(R&& str,
|
||||||
|
bool hms1 = false,
|
||||||
|
bool hms2 = false,
|
||||||
|
std::string_view delim = ",")
|
||||||
{
|
{
|
||||||
std::pair<double, double> res{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
|
std::pair<double, double> res{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
|
||||||
auto found1 = std::ranges::search(std::forward<R>(str), delim);
|
auto found1 = std::ranges::search(std::forward<R>(str), delim);
|
||||||
@@ -376,6 +380,40 @@ std::pair<double, double> parseAnglePair(R&& str, bool hms1 = false, bool hms2 =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// calculate distance between two point on sphere:
|
||||||
|
// the function returns a std::tuple with
|
||||||
|
// 0th element: difference along co-longitude axis
|
||||||
|
// 1st element: difference along co-latitude axis
|
||||||
|
// 2nd element: distance
|
||||||
|
|
||||||
|
static std::tuple<double, double, double> distanceOnSphere(double co_lon1,
|
||||||
|
double co_lat1,
|
||||||
|
double co_lon2,
|
||||||
|
double co_lat2)
|
||||||
|
{
|
||||||
|
std::tuple<double, double, double> res{};
|
||||||
|
|
||||||
|
std::get<0>(res) = co_lon1 - co_lon2;
|
||||||
|
std::get<1>(res) = co_lat1 - co_lat2;
|
||||||
|
|
||||||
|
double cosDco_lon = std::cos(std::abs(std::get<0>(res)));
|
||||||
|
|
||||||
|
double cos1 = std::cos(co_lat1);
|
||||||
|
double sin1 = std::sin(co_lat1);
|
||||||
|
|
||||||
|
double cos2 = std::cos(co_lat2);
|
||||||
|
double sin2 = std::sin(co_lat2);
|
||||||
|
|
||||||
|
double term1 = cos2 * std::sin(std::abs(std::get<0>(res)));
|
||||||
|
double term2 = cos1 * sin2 - sin1 * cos2 * cosDco_lon;
|
||||||
|
|
||||||
|
std::get<2>(res) = std::atan2(sqrt(term1 * term1 + term2 * term2), sin1 * sin2 + cos1 * cos2 * cosDco_lon);
|
||||||
|
|
||||||
|
// std::get<2>(res) = acos(sin1 * sin2 + cos1 * cos2 * cosDco_lon);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
template <traits::mcc_input_char_range R>
|
template <traits::mcc_input_char_range R>
|
||||||
static constexpr size_t FNV1aHash(const R& r)
|
static constexpr size_t FNV1aHash(const R& r)
|
||||||
{
|
{
|
||||||
@@ -1,647 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
|
||||||
namespace mcc::ccte::iers::defaults
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
// https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat
|
|
||||||
|
|
||||||
static std::string MCC_DEFAULT_LEAP_SECONDS_FILE = R"--(
|
|
||||||
|
|
||||||
# Value of TAI-UTC in second valid beetween the initial value until
|
|
||||||
# the epoch given on the next line. The last line reads that NO
|
|
||||||
# leap second was introduced since the corresponding date
|
|
||||||
# Updated through IERS Bulletin 71 issued in January 2026
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# File expires on 28 December 2026
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# MJD Date TAI-UTC (s)
|
|
||||||
# day month year
|
|
||||||
# --- -------------- ------
|
|
||||||
#
|
|
||||||
41317.0 1 1 1972 10
|
|
||||||
41499.0 1 7 1972 11
|
|
||||||
41683.0 1 1 1973 12
|
|
||||||
42048.0 1 1 1974 13
|
|
||||||
42413.0 1 1 1975 14
|
|
||||||
42778.0 1 1 1976 15
|
|
||||||
43144.0 1 1 1977 16
|
|
||||||
43509.0 1 1 1978 17
|
|
||||||
43874.0 1 1 1979 18
|
|
||||||
44239.0 1 1 1980 19
|
|
||||||
44786.0 1 7 1981 20
|
|
||||||
45151.0 1 7 1982 21
|
|
||||||
45516.0 1 7 1983 22
|
|
||||||
46247.0 1 7 1985 23
|
|
||||||
47161.0 1 1 1988 24
|
|
||||||
47892.0 1 1 1990 25
|
|
||||||
48257.0 1 1 1991 26
|
|
||||||
48804.0 1 7 1992 27
|
|
||||||
49169.0 1 7 1993 28
|
|
||||||
49534.0 1 7 1994 29
|
|
||||||
50083.0 1 1 1996 30
|
|
||||||
50630.0 1 7 1997 31
|
|
||||||
51179.0 1 1 1999 32
|
|
||||||
53736.0 1 1 2006 33
|
|
||||||
54832.0 1 1 2009 34
|
|
||||||
56109.0 1 7 2012 35
|
|
||||||
57204.0 1 7 2015 36
|
|
||||||
57754.0 1 1 2017 37
|
|
||||||
)--";
|
|
||||||
|
|
||||||
|
|
||||||
// https://datacenter.iers.org/data/latestVersion/bulletinA.txt
|
|
||||||
|
|
||||||
static std::string MCC_DEFAULT_IERS_BULLETIN_A_FILE = R"--(
|
|
||||||
|
|
||||||
|
|
||||||
**********************************************************************
|
|
||||||
* *
|
|
||||||
* I E R S B U L L E T I N - A *
|
|
||||||
* *
|
|
||||||
* Rapid Service/Prediction of Earth Orientation *
|
|
||||||
**********************************************************************
|
|
||||||
8 January 2026 Vol. XXXIX No. 002
|
|
||||||
______________________________________________________________________
|
|
||||||
GENERAL INFORMATION:
|
|
||||||
MJD = Julian Date - 2 400 000.5 days
|
|
||||||
UT2-UT1 = 0.022 sin(2*pi*T) - 0.012 cos(2*pi*T)
|
|
||||||
- 0.006 sin(4*pi*T) + 0.007 cos(4*pi*T)
|
|
||||||
where pi = 3.14159265... and T is the date in Besselian years.
|
|
||||||
TT = TAI + 32.184 seconds
|
|
||||||
DUT1= (UT1-UTC) transmitted with time signals
|
|
||||||
= +0.1 seconds beginning 10 July 2025 at 0000 UTC
|
|
||||||
Beginning 1 January 2017:
|
|
||||||
TAI-UTC = 37.000 000 seconds
|
|
||||||
***********************************************************************
|
|
||||||
* ANNOUNCEMENTS: *
|
|
||||||
* *
|
|
||||||
* There will NOT be a leap second introduced in UTC *
|
|
||||||
* at the end of June 2026. *
|
|
||||||
* *
|
|
||||||
* The primary source for IERS Rapid Service/Prediction Center (RS/PC) *
|
|
||||||
* data products is the official IERS RS/PC website: *
|
|
||||||
* https://maia.usno.navy.mil *
|
|
||||||
* *
|
|
||||||
* IERS RS/PC products are also available from: *
|
|
||||||
* NASA CDDIS: https://cddis.nasa.gov/archive/products/iers/ *
|
|
||||||
* NASA CDDIS: ftps://gdc.cddis.eosdis.nasa.gov/products/iers/ *
|
|
||||||
* IERS Central Bureau: https://datacenter.iers.org/eop.php *
|
|
||||||
* *
|
|
||||||
* Questions about IERS RS/PC products can be emailed to: *
|
|
||||||
* eopcp@us.navy.mil *
|
|
||||||
* *
|
|
||||||
* Distribution statement A: *
|
|
||||||
* Approved for public release: distribution unlimited. *
|
|
||||||
* *
|
|
||||||
***********************************************************************
|
|
||||||
________________________________________________________________________
|
|
||||||
The contributed observations used in the preparation of this Bulletin
|
|
||||||
are available at <http://www.usno.navy.mil/USNO/earth-orientation/
|
|
||||||
eo-info/general/input-data>. The contributed analysis results are based
|
|
||||||
on data from Very Long Baseline Interferometry (VLBI), Satellite Laser
|
|
||||||
Ranging (SLR), the Global Positioning System (GPS) satellites, Lunar
|
|
||||||
Laser Ranging (LLR), and meteorological predictions of variations in
|
|
||||||
Atmospheric Angular Momentum (AAM).
|
|
||||||
________________________________________________________________________
|
|
||||||
|
|
||||||
COMBINED EARTH ORIENTATION PARAMETERS:
|
|
||||||
|
|
||||||
IERS Rapid Service
|
|
||||||
MJD x error y error UT1-UTC error
|
|
||||||
" " " " s s
|
|
||||||
26 1 2 61042 0.10962 .00009 0.33249 .00009 0.074152 0.000020
|
|
||||||
26 1 3 61043 0.10827 .00009 0.33355 .00009 0.074367 0.000021
|
|
||||||
26 1 4 61044 0.10690 .00009 0.33455 .00009 0.074487 0.000020
|
|
||||||
26 1 5 61045 0.10554 .00009 0.33551 .00009 0.074361 0.000015
|
|
||||||
26 1 6 61046 0.10404 .00009 0.33628 .00009 0.073991 0.000015
|
|
||||||
26 1 7 61047 0.10253 .00009 0.33692 .00009 0.073470 0.000012
|
|
||||||
26 1 8 61048 0.10121 .00009 0.33746 .00009 0.072861 0.000008
|
|
||||||
|
|
||||||
IERS Final Values
|
|
||||||
MJD x y UT1-UTC
|
|
||||||
" " s
|
|
||||||
25 11 2 60981 0.1750 0.3194 0.09220
|
|
||||||
25 11 3 60982 0.1735 0.3187 0.09112
|
|
||||||
25 11 4 60983 0.1718 0.3187 0.09005
|
|
||||||
25 11 5 60984 0.1699 0.3183 0.08916
|
|
||||||
25 11 6 60985 0.1679 0.3182 0.08854
|
|
||||||
25 11 7 60986 0.1659 0.3179 0.08822
|
|
||||||
25 11 8 60987 0.1640 0.3171 0.08814
|
|
||||||
25 11 9 60988 0.1630 0.3163 0.08819
|
|
||||||
25 11 10 60989 0.1625 0.3158 0.08820
|
|
||||||
25 11 11 60990 0.1615 0.3153 0.08801
|
|
||||||
25 11 12 60991 0.1602 0.3151 0.08763
|
|
||||||
25 11 13 60992 0.1583 0.3154 0.08711
|
|
||||||
25 11 14 60993 0.1564 0.3157 0.08644
|
|
||||||
25 11 15 60994 0.1545 0.3160 0.08566
|
|
||||||
25 11 16 60995 0.1530 0.3163 0.08494
|
|
||||||
25 11 17 60996 0.1511 0.3167 0.08433
|
|
||||||
25 11 18 60997 0.1491 0.3165 0.08390
|
|
||||||
25 11 19 60998 0.1474 0.3163 0.08366
|
|
||||||
25 11 20 60999 0.1456 0.3161 0.08357
|
|
||||||
25 11 21 61000 0.1437 0.3157 0.08363
|
|
||||||
25 11 22 61001 0.1419 0.3149 0.08381
|
|
||||||
25 11 23 61002 0.1398 0.3143 0.08403
|
|
||||||
25 11 24 61003 0.1380 0.3136 0.08426
|
|
||||||
25 11 25 61004 0.1373 0.3137 0.08431
|
|
||||||
25 11 26 61005 0.1360 0.3146 0.08417
|
|
||||||
25 11 27 61006 0.1351 0.3149 0.08377
|
|
||||||
25 11 28 61007 0.1343 0.3153 0.08305
|
|
||||||
25 11 29 61008 0.1334 0.3153 0.08209
|
|
||||||
25 11 30 61009 0.1325 0.3157 0.08097
|
|
||||||
25 12 1 61010 0.1316 0.3160 0.07984
|
|
||||||
|
|
||||||
_______________________________________________________________________
|
|
||||||
|
|
||||||
PREDICTIONS:
|
|
||||||
The following formulas will not reproduce the predictions given below,
|
|
||||||
but may be used to extend the predictions beyond the end of this table.
|
|
||||||
|
|
||||||
x = 0.1611 - 0.0626 cos A - 0.1221 sin A + 0.0025 cos C + 0.0585 sin C
|
|
||||||
y = 0.3836 - 0.1091 cos A + 0.0516 sin A + 0.0585 cos C - 0.0025 sin C
|
|
||||||
UT1-UTC = 0.0617 + 0.00005 (MJD - 61056) - (UT2-UT1)
|
|
||||||
|
|
||||||
where A = 2*pi*(MJD-61048)/365.25 and C = 2*pi*(MJD-61048)/435.
|
|
||||||
|
|
||||||
TAI-UTC(MJD 61049) = 37.0
|
|
||||||
The accuracy may be estimated from the expressions:
|
|
||||||
S x,y = 0.00068 (MJD-61048)**0.80 S t = 0.00025 (MJD-61048)**0.75
|
|
||||||
Estimated accuracies are: Predictions 10 d 20 d 30 d 40 d
|
|
||||||
Polar coord's 0.004 0.007 0.010 0.013
|
|
||||||
UT1-UTC 0.0014 0.0024 0.0032 0.0040
|
|
||||||
|
|
||||||
MJD x(arcsec) y(arcsec) UT1-UTC(sec)
|
|
||||||
2026 1 9 61049 0.1001 0.3380 0.07228
|
|
||||||
2026 1 10 61050 0.0993 0.3385 0.07180
|
|
||||||
2026 1 11 61051 0.0985 0.3390 0.07149
|
|
||||||
2026 1 12 61052 0.0978 0.3396 0.07136
|
|
||||||
2026 1 13 61053 0.0971 0.3403 0.07142
|
|
||||||
2026 1 14 61054 0.0964 0.3411 0.07168
|
|
||||||
2026 1 15 61055 0.0957 0.3418 0.07209
|
|
||||||
2026 1 16 61056 0.0949 0.3426 0.07260
|
|
||||||
2026 1 17 61057 0.0942 0.3434 0.07313
|
|
||||||
2026 1 18 61058 0.0935 0.3442 0.07360
|
|
||||||
2026 1 19 61059 0.0928 0.3450 0.07391
|
|
||||||
2026 1 20 61060 0.0921 0.3458 0.07400
|
|
||||||
2026 1 21 61061 0.0915 0.3466 0.07380
|
|
||||||
2026 1 22 61062 0.0909 0.3474 0.07332
|
|
||||||
2026 1 23 61063 0.0903 0.3482 0.07264
|
|
||||||
2026 1 24 61064 0.0897 0.3490 0.07185
|
|
||||||
2026 1 25 61065 0.0892 0.3499 0.07110
|
|
||||||
2026 1 26 61066 0.0886 0.3507 0.07051
|
|
||||||
2026 1 27 61067 0.0881 0.3516 0.07015
|
|
||||||
2026 1 28 61068 0.0876 0.3524 0.07004
|
|
||||||
2026 1 29 61069 0.0872 0.3533 0.07016
|
|
||||||
2026 1 30 61070 0.0867 0.3542 0.07040
|
|
||||||
2026 1 31 61071 0.0863 0.3551 0.07062
|
|
||||||
2026 2 1 61072 0.0858 0.3560 0.07069
|
|
||||||
2026 2 2 61073 0.0855 0.3569 0.07052
|
|
||||||
2026 2 3 61074 0.0851 0.3578 0.07011
|
|
||||||
2026 2 4 61075 0.0847 0.3587 0.06952
|
|
||||||
2026 2 5 61076 0.0844 0.3596 0.06884
|
|
||||||
2026 2 6 61077 0.0841 0.3605 0.06818
|
|
||||||
2026 2 7 61078 0.0838 0.3615 0.06763
|
|
||||||
2026 2 8 61079 0.0835 0.3624 0.06723
|
|
||||||
2026 2 9 61080 0.0832 0.3634 0.06700
|
|
||||||
2026 2 10 61081 0.0830 0.3643 0.06696
|
|
||||||
2026 2 11 61082 0.0828 0.3653 0.06706
|
|
||||||
2026 2 12 61083 0.0826 0.3662 0.06727
|
|
||||||
2026 2 13 61084 0.0824 0.3672 0.06753
|
|
||||||
2026 2 14 61085 0.0822 0.3682 0.06774
|
|
||||||
2026 2 15 61086 0.0821 0.3692 0.06784
|
|
||||||
2026 2 16 61087 0.0820 0.3702 0.06774
|
|
||||||
2026 2 17 61088 0.0819 0.3711 0.06738
|
|
||||||
2026 2 18 61089 0.0818 0.3721 0.06675
|
|
||||||
2026 2 19 61090 0.0818 0.3731 0.06590
|
|
||||||
2026 2 20 61091 0.0817 0.3741 0.06493
|
|
||||||
2026 2 21 61092 0.0817 0.3751 0.06395
|
|
||||||
2026 2 22 61093 0.0817 0.3761 0.06311
|
|
||||||
2026 2 23 61094 0.0818 0.3771 0.06250
|
|
||||||
2026 2 24 61095 0.0818 0.3781 0.06215
|
|
||||||
2026 2 25 61096 0.0819 0.3792 0.06203
|
|
||||||
2026 2 26 61097 0.0820 0.3802 0.06204
|
|
||||||
2026 2 27 61098 0.0821 0.3812 0.06206
|
|
||||||
2026 2 28 61099 0.0823 0.3822 0.06196
|
|
||||||
2026 3 1 61100 0.0824 0.3832 0.06165
|
|
||||||
2026 3 2 61101 0.0826 0.3842 0.06111
|
|
||||||
2026 3 3 61102 0.0828 0.3852 0.06037
|
|
||||||
2026 3 4 61103 0.0831 0.3862 0.05951
|
|
||||||
2026 3 5 61104 0.0833 0.3872 0.05864
|
|
||||||
2026 3 6 61105 0.0836 0.3882 0.05787
|
|
||||||
2026 3 7 61106 0.0839 0.3893 0.05726
|
|
||||||
2026 3 8 61107 0.0842 0.3903 0.05686
|
|
||||||
2026 3 9 61108 0.0846 0.3913 0.05667
|
|
||||||
2026 3 10 61109 0.0849 0.3922 0.05667
|
|
||||||
2026 3 11 61110 0.0853 0.3932 0.05681
|
|
||||||
2026 3 12 61111 0.0857 0.3942 0.05703
|
|
||||||
2026 3 13 61112 0.0861 0.3952 0.05725
|
|
||||||
2026 3 14 61113 0.0866 0.3962 0.05737
|
|
||||||
2026 3 15 61114 0.0870 0.3972 0.05732
|
|
||||||
2026 3 16 61115 0.0875 0.3981 0.05703
|
|
||||||
2026 3 17 61116 0.0880 0.3991 0.05647
|
|
||||||
2026 3 18 61117 0.0886 0.4000 0.05564
|
|
||||||
2026 3 19 61118 0.0891 0.4010 0.05462
|
|
||||||
2026 3 20 61119 0.0897 0.4019 0.05355
|
|
||||||
2026 3 21 61120 0.0903 0.4029 0.05256
|
|
||||||
2026 3 22 61121 0.0909 0.4038 0.05180
|
|
||||||
2026 3 23 61122 0.0916 0.4047 0.05132
|
|
||||||
2026 3 24 61123 0.0922 0.4056 0.05111
|
|
||||||
2026 3 25 61124 0.0929 0.4065 0.05107
|
|
||||||
2026 3 26 61125 0.0936 0.4074 0.05108
|
|
||||||
2026 3 27 61126 0.0943 0.4083 0.05100
|
|
||||||
2026 3 28 61127 0.0950 0.4092 0.05075
|
|
||||||
2026 3 29 61128 0.0958 0.4101 0.05028
|
|
||||||
2026 3 30 61129 0.0966 0.4109 0.04959
|
|
||||||
2026 3 31 61130 0.0974 0.4118 0.04876
|
|
||||||
2026 4 1 61131 0.0982 0.4126 0.04787
|
|
||||||
2026 4 2 61132 0.0990 0.4134 0.04702
|
|
||||||
2026 4 3 61133 0.0998 0.4142 0.04629
|
|
||||||
2026 4 4 61134 0.1007 0.4150 0.04574
|
|
||||||
2026 4 5 61135 0.1016 0.4158 0.04540
|
|
||||||
2026 4 6 61136 0.1025 0.4166 0.04526
|
|
||||||
2026 4 7 61137 0.1034 0.4174 0.04528
|
|
||||||
2026 4 8 61138 0.1044 0.4181 0.04540
|
|
||||||
2026 4 9 61139 0.1053 0.4188 0.04556
|
|
||||||
2026 4 10 61140 0.1063 0.4196 0.04566
|
|
||||||
2026 4 11 61141 0.1073 0.4203 0.04563
|
|
||||||
2026 4 12 61142 0.1083 0.4210 0.04539
|
|
||||||
2026 4 13 61143 0.1093 0.4217 0.04489
|
|
||||||
2026 4 14 61144 0.1103 0.4223 0.04411
|
|
||||||
2026 4 15 61145 0.1114 0.4230 0.04311
|
|
||||||
2026 4 16 61146 0.1124 0.4236 0.04198
|
|
||||||
2026 4 17 61147 0.1135 0.4242 0.04088
|
|
||||||
2026 4 18 61148 0.1146 0.4248 0.03995
|
|
||||||
2026 4 19 61149 0.1157 0.4254 0.03929
|
|
||||||
2026 4 20 61150 0.1168 0.4260 0.03893
|
|
||||||
2026 4 21 61151 0.1180 0.4265 0.03881
|
|
||||||
2026 4 22 61152 0.1191 0.4271 0.03879
|
|
||||||
2026 4 23 61153 0.1203 0.4276 0.03874
|
|
||||||
2026 4 24 61154 0.1214 0.4281 0.03855
|
|
||||||
2026 4 25 61155 0.1226 0.4286 0.03815
|
|
||||||
2026 4 26 61156 0.1238 0.4291 0.03757
|
|
||||||
2026 4 27 61157 0.1250 0.4295 0.03685
|
|
||||||
2026 4 28 61158 0.1262 0.4299 0.03606
|
|
||||||
2026 4 29 61159 0.1275 0.4304 0.03532
|
|
||||||
2026 4 30 61160 0.1287 0.4308 0.03468
|
|
||||||
2026 5 1 61161 0.1300 0.4311 0.03422
|
|
||||||
2026 5 2 61162 0.1312 0.4315 0.03397
|
|
||||||
2026 5 3 61163 0.1325 0.4318 0.03394
|
|
||||||
2026 5 4 61164 0.1338 0.4322 0.03410
|
|
||||||
2026 5 5 61165 0.1350 0.4325 0.03439
|
|
||||||
2026 5 6 61166 0.1363 0.4327 0.03475
|
|
||||||
2026 5 7 61167 0.1376 0.4330 0.03509
|
|
||||||
2026 5 8 61168 0.1389 0.4332 0.03536
|
|
||||||
2026 5 9 61169 0.1402 0.4335 0.03547
|
|
||||||
2026 5 10 61170 0.1416 0.4337 0.03538
|
|
||||||
2026 5 11 61171 0.1429 0.4339 0.03505
|
|
||||||
2026 5 12 61172 0.1442 0.4340 0.03452
|
|
||||||
2026 5 13 61173 0.1456 0.4342 0.03383
|
|
||||||
2026 5 14 61174 0.1469 0.4343 0.03311
|
|
||||||
2026 5 15 61175 0.1482 0.4344 0.03249
|
|
||||||
2026 5 16 61176 0.1496 0.4345 0.03211
|
|
||||||
2026 5 17 61177 0.1509 0.4345 0.03204
|
|
||||||
2026 5 18 61178 0.1523 0.4345 0.03225
|
|
||||||
2026 5 19 61179 0.1537 0.4346 0.03262
|
|
||||||
2026 5 20 61180 0.1550 0.4346 0.03301
|
|
||||||
2026 5 21 61181 0.1564 0.4345 0.03328
|
|
||||||
2026 5 22 61182 0.1577 0.4345 0.03336
|
|
||||||
2026 5 23 61183 0.1591 0.4344 0.03325
|
|
||||||
2026 5 24 61184 0.1605 0.4343 0.03299
|
|
||||||
2026 5 25 61185 0.1618 0.4342 0.03268
|
|
||||||
2026 5 26 61186 0.1632 0.4341 0.03241
|
|
||||||
2026 5 27 61187 0.1646 0.4339 0.03224
|
|
||||||
2026 5 28 61188 0.1659 0.4338 0.03225
|
|
||||||
2026 5 29 61189 0.1673 0.4336 0.03246
|
|
||||||
2026 5 30 61190 0.1686 0.4333 0.03289
|
|
||||||
2026 5 31 61191 0.1700 0.4331 0.03352
|
|
||||||
2026 6 1 61192 0.1713 0.4328 0.03429
|
|
||||||
2026 6 2 61193 0.1727 0.4326 0.03515
|
|
||||||
2026 6 3 61194 0.1740 0.4323 0.03602
|
|
||||||
2026 6 4 61195 0.1754 0.4319 0.03683
|
|
||||||
2026 6 5 61196 0.1767 0.4316 0.03751
|
|
||||||
2026 6 6 61197 0.1781 0.4312 0.03801
|
|
||||||
2026 6 7 61198 0.1794 0.4308 0.03831
|
|
||||||
2026 6 8 61199 0.1807 0.4304 0.03841
|
|
||||||
2026 6 9 61200 0.1820 0.4300 0.03835
|
|
||||||
2026 6 10 61201 0.1833 0.4295 0.03823
|
|
||||||
2026 6 11 61202 0.1846 0.4291 0.03815
|
|
||||||
2026 6 12 61203 0.1859 0.4286 0.03824
|
|
||||||
2026 6 13 61204 0.1872 0.4280 0.03860
|
|
||||||
2026 6 14 61205 0.1885 0.4275 0.03924
|
|
||||||
2026 6 15 61206 0.1897 0.4270 0.04009
|
|
||||||
2026 6 16 61207 0.1910 0.4264 0.04101
|
|
||||||
2026 6 17 61208 0.1922 0.4258 0.04185
|
|
||||||
2026 6 18 61209 0.1935 0.4252 0.04250
|
|
||||||
2026 6 19 61210 0.1947 0.4245 0.04293
|
|
||||||
2026 6 20 61211 0.1959 0.4239 0.04317
|
|
||||||
2026 6 21 61212 0.1971 0.4232 0.04333
|
|
||||||
2026 6 22 61213 0.1983 0.4225 0.04352
|
|
||||||
2026 6 23 61214 0.1995 0.4218 0.04381
|
|
||||||
2026 6 24 61215 0.2007 0.4211 0.04428
|
|
||||||
2026 6 25 61216 0.2018 0.4203 0.04496
|
|
||||||
2026 6 26 61217 0.2030 0.4195 0.04586
|
|
||||||
2026 6 27 61218 0.2041 0.4187 0.04695
|
|
||||||
2026 6 28 61219 0.2052 0.4179 0.04820
|
|
||||||
2026 6 29 61220 0.2063 0.4171 0.04955
|
|
||||||
2026 6 30 61221 0.2074 0.4162 0.05092
|
|
||||||
2026 7 1 61222 0.2085 0.4154 0.05224
|
|
||||||
2026 7 2 61223 0.2095 0.4145 0.05344
|
|
||||||
2026 7 3 61224 0.2106 0.4136 0.05447
|
|
||||||
2026 7 4 61225 0.2116 0.4127 0.05530
|
|
||||||
2026 7 5 61226 0.2126 0.4118 0.05595
|
|
||||||
2026 7 6 61227 0.2136 0.4108 0.05644
|
|
||||||
2026 7 7 61228 0.2146 0.4098 0.05686
|
|
||||||
2026 7 8 61229 0.2155 0.4088 0.05730
|
|
||||||
2026 7 9 61230 0.2164 0.4078 0.05787
|
|
||||||
2026 7 10 61231 0.2174 0.4068 0.05866
|
|
||||||
2026 7 11 61232 0.2183 0.4058 0.05971
|
|
||||||
2026 7 12 61233 0.2191 0.4048 0.06099
|
|
||||||
2026 7 13 61234 0.2200 0.4037 0.06238
|
|
||||||
2026 7 14 61235 0.2208 0.4026 0.06374
|
|
||||||
2026 7 15 61236 0.2217 0.4015 0.06490
|
|
||||||
2026 7 16 61237 0.2225 0.4004 0.06580
|
|
||||||
2026 7 17 61238 0.2232 0.3993 0.06643
|
|
||||||
2026 7 18 61239 0.2240 0.3982 0.06686
|
|
||||||
2026 7 19 61240 0.2247 0.3970 0.06720
|
|
||||||
2026 7 20 61241 0.2255 0.3959 0.06757
|
|
||||||
2026 7 21 61242 0.2262 0.3947 0.06804
|
|
||||||
2026 7 22 61243 0.2268 0.3935 0.06865
|
|
||||||
2026 7 23 61244 0.2275 0.3923 0.06942
|
|
||||||
2026 7 24 61245 0.2281 0.3911 0.07035
|
|
||||||
2026 7 25 61246 0.2287 0.3899 0.07139
|
|
||||||
2026 7 26 61247 0.2293 0.3887 0.07253
|
|
||||||
2026 7 27 61248 0.2299 0.3875 0.07369
|
|
||||||
2026 7 28 61249 0.2304 0.3862 0.07483
|
|
||||||
2026 7 29 61250 0.2309 0.3849 0.07589
|
|
||||||
2026 7 30 61251 0.2314 0.3837 0.07681
|
|
||||||
2026 7 31 61252 0.2319 0.3824 0.07755
|
|
||||||
2026 8 1 61253 0.2323 0.3811 0.07812
|
|
||||||
2026 8 2 61254 0.2327 0.3798 0.07854
|
|
||||||
2026 8 3 61255 0.2331 0.3785 0.07889
|
|
||||||
2026 8 4 61256 0.2335 0.3772 0.07925
|
|
||||||
2026 8 5 61257 0.2338 0.3759 0.07972
|
|
||||||
2026 8 6 61258 0.2342 0.3746 0.08039
|
|
||||||
2026 8 7 61259 0.2344 0.3733 0.08130
|
|
||||||
2026 8 8 61260 0.2347 0.3719 0.08241
|
|
||||||
2026 8 9 61261 0.2350 0.3706 0.08365
|
|
||||||
2026 8 10 61262 0.2352 0.3692 0.08486
|
|
||||||
2026 8 11 61263 0.2354 0.3679 0.08590
|
|
||||||
2026 8 12 61264 0.2355 0.3665 0.08667
|
|
||||||
2026 8 13 61265 0.2357 0.3652 0.08710
|
|
||||||
2026 8 14 61266 0.2358 0.3638 0.08724
|
|
||||||
2026 8 15 61267 0.2359 0.3624 0.08725
|
|
||||||
2026 8 16 61268 0.2359 0.3611 0.08727
|
|
||||||
2026 8 17 61269 0.2360 0.3597 0.08741
|
|
||||||
2026 8 18 61270 0.2360 0.3583 0.08772
|
|
||||||
2026 8 19 61271 0.2360 0.3570 0.08823
|
|
||||||
2026 8 20 61272 0.2359 0.3556 0.08889
|
|
||||||
2026 8 21 61273 0.2359 0.3542 0.08975
|
|
||||||
2026 8 22 61274 0.2358 0.3528 0.09075
|
|
||||||
2026 8 23 61275 0.2356 0.3515 0.09173
|
|
||||||
2026 8 24 61276 0.2355 0.3501 0.09267
|
|
||||||
2026 8 25 61277 0.2353 0.3487 0.09354
|
|
||||||
2026 8 26 61278 0.2351 0.3473 0.09418
|
|
||||||
2026 8 27 61279 0.2349 0.3460 0.09450
|
|
||||||
2026 8 28 61280 0.2346 0.3446 0.09461
|
|
||||||
2026 8 29 61281 0.2344 0.3432 0.09454
|
|
||||||
2026 8 30 61282 0.2340 0.3419 0.09433
|
|
||||||
2026 8 31 61283 0.2337 0.3405 0.09408
|
|
||||||
2026 9 1 61284 0.2334 0.3391 0.09392
|
|
||||||
2026 9 2 61285 0.2330 0.3378 0.09389
|
|
||||||
2026 9 3 61286 0.2326 0.3364 0.09406
|
|
||||||
2026 9 4 61287 0.2321 0.3351 0.09437
|
|
||||||
2026 9 5 61288 0.2317 0.3337 0.09483
|
|
||||||
2026 9 6 61289 0.2312 0.3324 0.09533
|
|
||||||
2026 9 7 61290 0.2306 0.3311 0.09572
|
|
||||||
2026 9 8 61291 0.2301 0.3298 0.09587
|
|
||||||
2026 9 9 61292 0.2295 0.3285 0.09576
|
|
||||||
2026 9 10 61293 0.2289 0.3272 0.09541
|
|
||||||
2026 9 11 61294 0.2283 0.3259 0.09492
|
|
||||||
2026 9 12 61295 0.2277 0.3246 0.09452
|
|
||||||
2026 9 13 61296 0.2270 0.3233 0.09420
|
|
||||||
2026 9 14 61297 0.2263 0.3220 0.09410
|
|
||||||
2026 9 15 61298 0.2256 0.3208 0.09416
|
|
||||||
2026 9 16 61299 0.2248 0.3195 0.09433
|
|
||||||
2026 9 17 61300 0.2241 0.3183 0.09465
|
|
||||||
2026 9 18 61301 0.2233 0.3170 0.09510
|
|
||||||
2026 9 19 61302 0.2225 0.3158 0.09562
|
|
||||||
2026 9 20 61303 0.2216 0.3146 0.09615
|
|
||||||
2026 9 21 61304 0.2208 0.3134 0.09657
|
|
||||||
2026 9 22 61305 0.2199 0.3122 0.09690
|
|
||||||
2026 9 23 61306 0.2190 0.3110 0.09704
|
|
||||||
2026 9 24 61307 0.2180 0.3099 0.09702
|
|
||||||
2026 9 25 61308 0.2171 0.3087 0.09681
|
|
||||||
2026 9 26 61309 0.2161 0.3076 0.09642
|
|
||||||
2026 9 27 61310 0.2151 0.3065 0.09591
|
|
||||||
2026 9 28 61311 0.2141 0.3054 0.09537
|
|
||||||
2026 9 29 61312 0.2130 0.3043 0.09501
|
|
||||||
2026 9 30 61313 0.2119 0.3032 0.09489
|
|
||||||
2026 10 1 61314 0.2109 0.3022 0.09500
|
|
||||||
2026 10 2 61315 0.2097 0.3011 0.09526
|
|
||||||
2026 10 3 61316 0.2086 0.3001 0.09568
|
|
||||||
2026 10 4 61317 0.2075 0.2991 0.09602
|
|
||||||
2026 10 5 61318 0.2063 0.2981 0.09613
|
|
||||||
2026 10 6 61319 0.2051 0.2971 0.09602
|
|
||||||
2026 10 7 61320 0.2039 0.2962 0.09573
|
|
||||||
2026 10 8 61321 0.2027 0.2952 0.09526
|
|
||||||
2026 10 9 61322 0.2014 0.2943 0.09470
|
|
||||||
2026 10 10 61323 0.2001 0.2934 0.09420
|
|
||||||
2026 10 11 61324 0.1989 0.2925 0.09382
|
|
||||||
2026 10 12 61325 0.1976 0.2917 0.09360
|
|
||||||
2026 10 13 61326 0.1962 0.2908 0.09354
|
|
||||||
2026 10 14 61327 0.1949 0.2900 0.09367
|
|
||||||
2026 10 15 61328 0.1935 0.2892 0.09395
|
|
||||||
2026 10 16 61329 0.1922 0.2884 0.09436
|
|
||||||
2026 10 17 61330 0.1908 0.2876 0.09484
|
|
||||||
2026 10 18 61331 0.1894 0.2869 0.09525
|
|
||||||
2026 10 19 61332 0.1880 0.2862 0.09550
|
|
||||||
2026 10 20 61333 0.1865 0.2855 0.09558
|
|
||||||
2026 10 21 61334 0.1851 0.2848 0.09543
|
|
||||||
2026 10 22 61335 0.1836 0.2841 0.09503
|
|
||||||
2026 10 23 61336 0.1821 0.2835 0.09443
|
|
||||||
2026 10 24 61337 0.1807 0.2829 0.09372
|
|
||||||
2026 10 25 61338 0.1792 0.2823 0.09295
|
|
||||||
2026 10 26 61339 0.1776 0.2817 0.09229
|
|
||||||
2026 10 27 61340 0.1761 0.2812 0.09186
|
|
||||||
2026 10 28 61341 0.1746 0.2807 0.09174
|
|
||||||
2026 10 29 61342 0.1730 0.2802 0.09188
|
|
||||||
2026 10 30 61343 0.1715 0.2797 0.09217
|
|
||||||
2026 10 31 61344 0.1699 0.2792 0.09250
|
|
||||||
2026 11 1 61345 0.1683 0.2788 0.09272
|
|
||||||
2026 11 2 61346 0.1667 0.2784 0.09267
|
|
||||||
2026 11 3 61347 0.1651 0.2780 0.09243
|
|
||||||
2026 11 4 61348 0.1635 0.2777 0.09199
|
|
||||||
2026 11 5 61349 0.1619 0.2773 0.09144
|
|
||||||
2026 11 6 61350 0.1603 0.2770 0.09088
|
|
||||||
2026 11 7 61351 0.1587 0.2767 0.09046
|
|
||||||
2026 11 8 61352 0.1571 0.2765 0.09016
|
|
||||||
2026 11 9 61353 0.1554 0.2763 0.09004
|
|
||||||
2026 11 10 61354 0.1538 0.2760 0.09011
|
|
||||||
2026 11 11 61355 0.1521 0.2759 0.09033
|
|
||||||
2026 11 12 61356 0.1505 0.2757 0.09067
|
|
||||||
2026 11 13 61357 0.1488 0.2756 0.09106
|
|
||||||
2026 11 14 61358 0.1471 0.2755 0.09148
|
|
||||||
2026 11 15 61359 0.1455 0.2754 0.09178
|
|
||||||
2026 11 16 61360 0.1438 0.2753 0.09198
|
|
||||||
2026 11 17 61361 0.1421 0.2753 0.09203
|
|
||||||
2026 11 18 61362 0.1405 0.2753 0.09194
|
|
||||||
2026 11 19 61363 0.1388 0.2753 0.09161
|
|
||||||
2026 11 20 61364 0.1371 0.2754 0.09115
|
|
||||||
2026 11 21 61365 0.1354 0.2755 0.09063
|
|
||||||
2026 11 22 61366 0.1338 0.2756 0.09016
|
|
||||||
2026 11 23 61367 0.1321 0.2757 0.08988
|
|
||||||
2026 11 24 61368 0.1304 0.2759 0.08982
|
|
||||||
2026 11 25 61369 0.1287 0.2760 0.09000
|
|
||||||
2026 11 26 61370 0.1271 0.2762 0.09038
|
|
||||||
2026 11 27 61371 0.1254 0.2765 0.09073
|
|
||||||
2026 11 28 61372 0.1237 0.2767 0.09096
|
|
||||||
2026 11 29 61373 0.1221 0.2770 0.09110
|
|
||||||
2026 11 30 61374 0.1204 0.2773 0.09103
|
|
||||||
2026 12 1 61375 0.1188 0.2777 0.09070
|
|
||||||
2026 12 2 61376 0.1171 0.2780 0.09027
|
|
||||||
2026 12 3 61377 0.1155 0.2784 0.08987
|
|
||||||
2026 12 4 61378 0.1139 0.2788 0.08951
|
|
||||||
2026 12 5 61379 0.1122 0.2793 0.08932
|
|
||||||
2026 12 6 61380 0.1106 0.2797 0.08929
|
|
||||||
2026 12 7 61381 0.1090 0.2802 0.08941
|
|
||||||
2026 12 8 61382 0.1074 0.2807 0.08977
|
|
||||||
2026 12 9 61383 0.1058 0.2813 0.09031
|
|
||||||
2026 12 10 61384 0.1042 0.2819 0.09092
|
|
||||||
2026 12 11 61385 0.1026 0.2824 0.09153
|
|
||||||
2026 12 12 61386 0.1011 0.2831 0.09210
|
|
||||||
2026 12 13 61387 0.0995 0.2837 0.09261
|
|
||||||
2026 12 14 61388 0.0980 0.2844 0.09296
|
|
||||||
2026 12 15 61389 0.0964 0.2851 0.09308
|
|
||||||
2026 12 16 61390 0.0949 0.2858 0.09298
|
|
||||||
2026 12 17 61391 0.0934 0.2865 0.09271
|
|
||||||
2026 12 18 61392 0.0919 0.2873 0.09223
|
|
||||||
2026 12 19 61393 0.0904 0.2881 0.09183
|
|
||||||
2026 12 20 61394 0.0889 0.2889 0.09151
|
|
||||||
2026 12 21 61395 0.0875 0.2897 0.09140
|
|
||||||
2026 12 22 61396 0.0860 0.2906 0.09146
|
|
||||||
2026 12 23 61397 0.0846 0.2914 0.09172
|
|
||||||
2026 12 24 61398 0.0832 0.2923 0.09217
|
|
||||||
2026 12 25 61399 0.0818 0.2933 0.09256
|
|
||||||
2026 12 26 61400 0.0804 0.2942 0.09281
|
|
||||||
2026 12 27 61401 0.0791 0.2952 0.09278
|
|
||||||
2026 12 28 61402 0.0777 0.2962 0.09251
|
|
||||||
2026 12 29 61403 0.0764 0.2972 0.09213
|
|
||||||
2026 12 30 61404 0.0751 0.2982 0.09173
|
|
||||||
2026 12 31 61405 0.0738 0.2993 0.09140
|
|
||||||
2027 1 1 61406 0.0725 0.3004 0.09123
|
|
||||||
2027 1 2 61407 0.0713 0.3015 0.09132
|
|
||||||
2027 1 3 61408 0.0700 0.3026 0.09160
|
|
||||||
2027 1 4 61409 0.0688 0.3037 0.09200
|
|
||||||
2027 1 5 61410 0.0676 0.3049 0.09264
|
|
||||||
2027 1 6 61411 0.0665 0.3061 0.09344
|
|
||||||
2027 1 7 61412 0.0653 0.3072 0.09426
|
|
||||||
2027 1 8 61413 0.0642 0.3085 0.09509
|
|
||||||
These predictions are based on all announced leap seconds.
|
|
||||||
|
|
||||||
CELESTIAL POLE OFFSET SERIES:
|
|
||||||
NEOS Celestial Pole Offset Series
|
|
||||||
MJD dpsi error deps error
|
|
||||||
(msec. of arc)
|
|
||||||
61026 -114.45 1.33 -7.19 0.16
|
|
||||||
61027 -114.43 1.33 -7.42 0.16
|
|
||||||
61028 -114.48 1.33 -7.64 0.16
|
|
||||||
61029 -114.51 1.19 -7.67 0.18
|
|
||||||
61030 -114.39 1.19 -7.49 0.18
|
|
||||||
61031 -114.09 1.24 -7.26 0.16
|
|
||||||
61032 -113.74 1.35 -7.13 0.06
|
|
||||||
61033 -113.52 1.35 -7.11 0.06
|
|
||||||
|
|
||||||
IERS Celestial Pole Offset Final Series
|
|
||||||
MJD dpsi deps
|
|
||||||
(msec. of arc)
|
|
||||||
60981 -117.6 -9.0
|
|
||||||
60982 -117.8 -8.8
|
|
||||||
60983 -118.0 -8.6
|
|
||||||
60984 -117.8 -8.6
|
|
||||||
60985 -117.5 -8.8
|
|
||||||
60986 -117.1 -8.9
|
|
||||||
60987 -116.8 -8.7
|
|
||||||
60988 -116.9 -8.5
|
|
||||||
60989 -117.0 -8.6
|
|
||||||
60990 -116.9 -8.8
|
|
||||||
60991 -116.6 -8.8
|
|
||||||
60992 -116.5 -8.5
|
|
||||||
60993 -116.5 -8.0
|
|
||||||
60994 -116.6 -7.7
|
|
||||||
60995 -116.6 -7.6
|
|
||||||
60996 -116.4 -7.5
|
|
||||||
60997 -116.1 -7.5
|
|
||||||
60998 -115.6 -7.8
|
|
||||||
60999 -115.5 -8.3
|
|
||||||
61000 -115.9 -8.6
|
|
||||||
61001 -116.0 -8.6
|
|
||||||
61002 -115.9 -8.5
|
|
||||||
61003 -115.7 -8.3
|
|
||||||
61004 -115.4 -8.2
|
|
||||||
61005 -115.1 -8.2
|
|
||||||
61006 -114.7 -8.1
|
|
||||||
61007 -114.4 -7.9
|
|
||||||
61008 -114.3 -7.9
|
|
||||||
61009 -114.6 -7.8
|
|
||||||
61010 -115.2 -7.6
|
|
||||||
|
|
||||||
IAU2000A Celestial Pole Offset Series
|
|
||||||
MJD dX error dY error
|
|
||||||
(msec. of arc)
|
|
||||||
61026 0.512 0.531 -0.092 0.161
|
|
||||||
61027 0.519 0.531 -0.101 0.161
|
|
||||||
61028 0.523 0.531 -0.107 0.161
|
|
||||||
61029 0.527 0.474 -0.112 0.176
|
|
||||||
61030 0.530 0.474 -0.114 0.176
|
|
||||||
61031 0.533 0.494 -0.114 0.156
|
|
||||||
61032 0.536 0.536 -0.113 0.059
|
|
||||||
61033 0.539 0.536 -0.111 0.059
|
|
||||||
|
|
||||||
|
|
||||||
IAU2000A Celestial Pole Offset Final Series
|
|
||||||
MJD dX dY
|
|
||||||
(msec. of arc)
|
|
||||||
60981 0.40 0.03
|
|
||||||
60982 0.38 0.02
|
|
||||||
60983 0.37 0.00
|
|
||||||
60984 0.42 -0.05
|
|
||||||
60985 0.41 -0.05
|
|
||||||
60986 0.34 -0.00
|
|
||||||
60987 0.33 0.01
|
|
||||||
60988 0.36 -0.01
|
|
||||||
60989 0.41 -0.04
|
|
||||||
60990 0.46 -0.06
|
|
||||||
60991 0.45 -0.05
|
|
||||||
60992 0.42 -0.02
|
|
||||||
60993 0.39 0.01
|
|
||||||
60994 0.33 0.07
|
|
||||||
60995 0.29 0.12
|
|
||||||
60996 0.30 0.14
|
|
||||||
60997 0.38 0.10
|
|
||||||
60998 0.59 -0.02
|
|
||||||
60999 0.62 -0.11
|
|
||||||
61000 0.51 -0.14
|
|
||||||
61001 0.41 -0.14
|
|
||||||
61002 0.35 -0.10
|
|
||||||
61003 0.32 -0.06
|
|
||||||
61004 0.33 -0.03
|
|
||||||
61005 0.38 -0.07
|
|
||||||
61006 0.47 -0.10
|
|
||||||
61007 0.57 -0.11
|
|
||||||
61008 0.57 -0.10
|
|
||||||
61009 0.48 -0.08
|
|
||||||
61010 0.35 -0.06
|
|
||||||
|
|
||||||
)--";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace mcc::ccte::iers::defaults
|
|
||||||
|
|
||||||
470
mcc_pcm.h
470
mcc_pcm.h
@@ -1,470 +0,0 @@
|
|||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
|
||||||
|
|
||||||
/* A REFERENCE "POINTING-CORRECTION-MODEL" CLASS IMPLEMENTATION */
|
|
||||||
|
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
#include "fitpack/mcc_bsplines.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "mcc_concepts.h"
|
|
||||||
#include "mcc_coordinate.h"
|
|
||||||
|
|
||||||
namespace mcc::impl
|
|
||||||
{
|
|
||||||
|
|
||||||
enum class MccDefaultPCMErrorCode : int {
|
|
||||||
ERROR_OK,
|
|
||||||
ERROR_CCTE,
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
ERROR_INVALID_INPUTS_BISPLEV,
|
|
||||||
#endif
|
|
||||||
ERROR_EXCEED_MAX_ITERS,
|
|
||||||
ERROR_NULLPTR
|
|
||||||
};
|
|
||||||
|
|
||||||
/* error category definition */
|
|
||||||
|
|
||||||
// error category
|
|
||||||
struct MccDefaultPCMCategory : public std::error_category {
|
|
||||||
MccDefaultPCMCategory() : std::error_category() {}
|
|
||||||
|
|
||||||
const char* name() const noexcept
|
|
||||||
{
|
|
||||||
return "ADC_GENERIC_DEVICE";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string message(int ec) const
|
|
||||||
{
|
|
||||||
MccDefaultPCMErrorCode err = static_cast<MccDefaultPCMErrorCode>(ec);
|
|
||||||
|
|
||||||
switch (err) {
|
|
||||||
case MccDefaultPCMErrorCode::ERROR_OK:
|
|
||||||
return "OK";
|
|
||||||
case MccDefaultPCMErrorCode::ERROR_CCTE:
|
|
||||||
return "CCTE calculation error";
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
case MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV:
|
|
||||||
return "invalid input arguments for bispev";
|
|
||||||
#endif
|
|
||||||
case MccDefaultPCMErrorCode::ERROR_EXCEED_MAX_ITERS:
|
|
||||||
return "exceed maximum of iterations number";
|
|
||||||
case MccDefaultPCMErrorCode::ERROR_NULLPTR:
|
|
||||||
return "nullptr input argument";
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const MccDefaultPCMCategory& get()
|
|
||||||
{
|
|
||||||
static const MccDefaultPCMCategory constInst;
|
|
||||||
return constInst;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
inline std::error_code make_error_code(MccDefaultPCMErrorCode ec)
|
|
||||||
{
|
|
||||||
return std::error_code(static_cast<int>(ec), MccDefaultPCMCategory::get());
|
|
||||||
}
|
|
||||||
} // namespace mcc::impl
|
|
||||||
|
|
||||||
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
|
|
||||||
template <>
|
|
||||||
class is_error_code_enum<mcc::impl::MccDefaultPCMErrorCode> : public true_type
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace mcc::impl
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
// type of PCM corrections (algorithm used):
|
|
||||||
// PCM_TYPE_GEOMETRY - "classic" geometry-based correction coefficients
|
|
||||||
// PCM_TYPE_GEOMETRY_BSPLINE - previous one and additional 2D B-spline corrections
|
|
||||||
// PCM_TYPE_BSPLINE - pure 2D B-spline corrections
|
|
||||||
enum class MccDefaultPCMType { PCM_TYPE_GEOMETRY, PCM_TYPE_GEOMETRY_BSPLINE, PCM_TYPE_BSPLINE };
|
|
||||||
|
|
||||||
template <MccDefaultPCMType TYPE>
|
|
||||||
static constexpr std::string_view MccDefaultPCMTypeString =
|
|
||||||
TYPE == MccDefaultPCMType::PCM_TYPE_GEOMETRY ? "GEOMETRY"
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
: TYPE == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE ? "GEOMETRY-BSPLINE"
|
|
||||||
: TYPE == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE ? "BSPLINE"
|
|
||||||
#endif
|
|
||||||
: "UNKNOWN";
|
|
||||||
|
|
||||||
template <MccMountType MOUNT_TYPE>
|
|
||||||
class MccDefaultPCM : public mcc_pcm_interface_t<std::error_code>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static constexpr MccMountType mountType = MOUNT_TYPE;
|
|
||||||
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
static constexpr std::string_view pcmName{"MCC-GEOMETRY-BSPLINES-PCM"};
|
|
||||||
#else
|
|
||||||
static constexpr std::string_view pcmName{"MCC-GEOMETRY-ONLY-PCM"};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef std::error_code error_t;
|
|
||||||
typedef double coord_t;
|
|
||||||
|
|
||||||
|
|
||||||
// "classic" geometric PCM coefficients
|
|
||||||
struct pcm_geom_coeffs_t {
|
|
||||||
typedef double coeff_t;
|
|
||||||
|
|
||||||
coeff_t zeroPointX;
|
|
||||||
coeff_t zeroPointY;
|
|
||||||
coeff_t collimationErr; // tube collimation error
|
|
||||||
coeff_t nonperpendErr; // X-Y axes nonperpendicularity
|
|
||||||
coeff_t misalignErr1; // misalignment of hour-angle/azimuth axis: left-right for equatorial, East-West for
|
|
||||||
// alt-azimuthal
|
|
||||||
coeff_t misalignErr2; // misalignment of hour-angle/azimuth axis: vertical for equatorial, North-South for
|
|
||||||
// alt-azimuthal
|
|
||||||
|
|
||||||
coeff_t tubeFlexure;
|
|
||||||
coeff_t forkFlexure;
|
|
||||||
coeff_t DECaxisFlexure; // declination axis flexure
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
// B-splines related data structure (coefficients, knots ...)
|
|
||||||
struct pcm_bspline_t {
|
|
||||||
typedef double knot_t;
|
|
||||||
typedef double coeff_t;
|
|
||||||
|
|
||||||
size_t bsplDegreeX = 3;
|
|
||||||
size_t bsplDegreeY = 3;
|
|
||||||
|
|
||||||
std::vector<knot_t> knotsX{};
|
|
||||||
std::vector<knot_t> knotsY{};
|
|
||||||
|
|
||||||
std::vector<coeff_t> coeffsX{};
|
|
||||||
std::vector<coeff_t> coeffsY{};
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct pcm_data_t {
|
|
||||||
MccDefaultPCMType type{MccDefaultPCMType::PCM_TYPE_GEOMETRY};
|
|
||||||
double siteLatitude{0.0}; // in radians
|
|
||||||
|
|
||||||
// from encoder to observed celestial
|
|
||||||
pcm_geom_coeffs_t geomCoefficients{};
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
pcm_bspline_t bspline{};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// from observed celestial to encoder
|
|
||||||
pcm_geom_coeffs_t inverseGeomCoefficients{};
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
pcm_bspline_t inverseBspline{};
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
// constructors
|
|
||||||
|
|
||||||
MccDefaultPCM() = default;
|
|
||||||
MccDefaultPCM(pcm_data_t pdata) : MccDefaultPCM()
|
|
||||||
{
|
|
||||||
_pcmData = std::move(pdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
MccDefaultPCM(MccDefaultPCM&& other) = default;
|
|
||||||
MccDefaultPCM& operator=(MccDefaultPCM&& other) = default;
|
|
||||||
|
|
||||||
MccDefaultPCM(const MccDefaultPCM&) = delete;
|
|
||||||
MccDefaultPCM& operator=(const MccDefaultPCM&) = delete;
|
|
||||||
|
|
||||||
virtual ~MccDefaultPCM() = default;
|
|
||||||
|
|
||||||
// virtual ~MccDefaultPCM() {
|
|
||||||
// // _pcmData.geomCoefficients.DECaxisFlexure = 0.0;
|
|
||||||
// };
|
|
||||||
|
|
||||||
void setPCMData(pcm_data_t pdata)
|
|
||||||
{
|
|
||||||
std::lock_guard lock(*_pcmDataMutex);
|
|
||||||
|
|
||||||
_pcmData = std::move(pdata);
|
|
||||||
|
|
||||||
_cosPhi = std::cos(_pcmData.siteLatitude);
|
|
||||||
_sinPhi = std::sin(_pcmData.siteLatitude);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pcm_data_t getPCMData() const
|
|
||||||
{
|
|
||||||
std::lock_guard lock(*_pcmDataMutex);
|
|
||||||
|
|
||||||
return _pcmData;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPCMType(MccDefaultPCMType type)
|
|
||||||
{
|
|
||||||
std::lock_guard lock(*_pcmDataMutex);
|
|
||||||
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
_pcmData.type = type;
|
|
||||||
#else
|
|
||||||
_pcmData.type = MccDefaultPCMType::PCM_TYPE_GEOMETRY;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
MccDefaultPCMType getPCMType() const
|
|
||||||
{
|
|
||||||
std::lock_guard lock(*_pcmDataMutex);
|
|
||||||
|
|
||||||
return _pcmData.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The computed PCM quantities must be interpretated as:
|
|
||||||
// observed_X = encoder_X + res.pcmX
|
|
||||||
// observed_Y = encoder_Y + res.pcmY
|
|
||||||
// so, input hw_coord is assumed to be coordinates pair of mount axis encoder readouts
|
|
||||||
template <typename T = std::nullptr_t>
|
|
||||||
error_t computePCM(mcc_coord_pair_c auto const& hw_coord, mcc_pcm_result_c auto* res, T* obs_skycoord = nullptr)
|
|
||||||
requires(mcc_skypoint_c<T> || std::is_null_pointer_v<T>)
|
|
||||||
{
|
|
||||||
if (res == nullptr) {
|
|
||||||
return MccDefaultPCMErrorCode::ERROR_NULLPTR;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::lock_guard lock(*_pcmDataMutex);
|
|
||||||
|
|
||||||
res->pcmX = 0.0;
|
|
||||||
res->pcmY = 0.0;
|
|
||||||
|
|
||||||
auto ret = _compResult(hw_coord.x(), hw_coord.y(), res, false);
|
|
||||||
if (ret) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if constexpr (mcc_is_equatorial_mount<MOUNT_TYPE>) { // equatorial (HA and DEC axes)
|
|
||||||
if constexpr (mcc_skypoint_c<T>) {
|
|
||||||
obs_skycoord->from(MccSkyHADEC_OBS{double(hw_coord.x() + res->pcmX), double(hw_coord.y() + res->pcmY),
|
|
||||||
hw_coord.epoch()});
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if constexpr (mcc_is_altaz_mount<MOUNT_TYPE>) {
|
|
||||||
if constexpr (mcc_skypoint_c<T>) {
|
|
||||||
obs_skycoord->from(
|
|
||||||
MccSkyAZZD{double(hw_coord.x() + res->pcmX), double(hw_coord.y() + res->pcmY), hw_coord.epoch()});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
static_assert(false, "UNSUPPORTED MOUNT TYPE");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return MccDefaultPCMErrorCode::ERROR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// computed inverse PCM corrections must be interpretated as:
|
|
||||||
// X_encoder = X_observed + res->pcmX
|
|
||||||
// Y_encoder = Y_observed + res->pcmY
|
|
||||||
//
|
|
||||||
template <typename T>
|
|
||||||
error_t computeInversePCM(mcc_skypoint_c auto const& obs_skycoord, mcc_pcm_result_c auto* res, T* hw_pt = nullptr)
|
|
||||||
requires(mcc_coord_pair_c<T> || std::is_null_pointer_v<T>)
|
|
||||||
{
|
|
||||||
error_t ret = MccDefaultPCMErrorCode::ERROR_OK;
|
|
||||||
|
|
||||||
if constexpr (mcc_coord_pair_c<T>) {
|
|
||||||
static_assert(
|
|
||||||
T::pairKind == MccCoordPairKind::COORDS_KIND_GENERIC || T::pairKind == MccCoordPairKind::COORDS_KIND_XY,
|
|
||||||
"Invalid output coordinate pair type!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// to be computed as observed celestial X and Y cordinate according to mount type (HA-DEC or AZ-ZD)
|
|
||||||
double x, y;
|
|
||||||
|
|
||||||
auto getXY = [&, this](auto& cp) {
|
|
||||||
auto err = obs_skycoord.toAtSameEpoch(cp);
|
|
||||||
if (err) {
|
|
||||||
return mcc_deduced_err(err, MccDefaultPCMErrorCode::ERROR_CCTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
x = cp.x();
|
|
||||||
y = cp.y();
|
|
||||||
|
|
||||||
return MccDefaultPCMErrorCode::ERROR_OK;
|
|
||||||
};
|
|
||||||
|
|
||||||
if constexpr (mcc_is_equatorial_mount<MOUNT_TYPE>) {
|
|
||||||
MccSkyHADEC_OBS hadec;
|
|
||||||
ret = getXY(hadec);
|
|
||||||
} else if constexpr (mcc_is_altaz_mount<MOUNT_TYPE>) {
|
|
||||||
MccSkyAZZD azzd;
|
|
||||||
ret = getXY(azzd);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::lock_guard lock(*_pcmDataMutex);
|
|
||||||
|
|
||||||
ret = _compResult(x, y, res, true);
|
|
||||||
if (!ret) {
|
|
||||||
if constexpr (mcc_coord_pair_c<T>) {
|
|
||||||
*hw_pt = MccCoordPair<typename T::x_t, typename T::y_t>{x + res->pcmX, y + res->pcmY};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
template <typename T>
|
|
||||||
error_t computeInversePCM(mcc_skypoint_c auto const& obs_skycoord,
|
|
||||||
mcc_pcm_result_c auto* result,
|
|
||||||
T* hw_pt = nullptr)
|
|
||||||
requires(mcc_coord_pair_c<T> || std::is_null_pointer_v<T>)
|
|
||||||
{
|
|
||||||
error_t ret = MccDefaultPCMErrorCode::ERROR_OK;
|
|
||||||
|
|
||||||
if constexpr (mcc_coord_pair_c<T>) {
|
|
||||||
static_assert(
|
|
||||||
T::pairKind == MccCoordPairKind::COORDS_KIND_GENERIC || T::pairKind == MccCoordPairKind::COORDS_KIND_XY,
|
|
||||||
"Invalid output coordinate pair type!");
|
|
||||||
}
|
|
||||||
|
|
||||||
double x, y;
|
|
||||||
|
|
||||||
auto comp_func = [&, this](auto& cp) {
|
|
||||||
auto err = obs_skycoord.toAtSameEpoch(cp);
|
|
||||||
if (err) {
|
|
||||||
return mcc_deduced_err(err, MccDefaultPCMErrorCode::ERROR_CCTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
x = cp.x();
|
|
||||||
y = cp.y();
|
|
||||||
|
|
||||||
return computePCM(cp, result);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// for small corrections only!!!
|
|
||||||
if constexpr (mcc_is_equatorial_mount<MOUNT_TYPE>) {
|
|
||||||
MccSkyHADEC_OBS hadec;
|
|
||||||
ret = comp_func(hadec);
|
|
||||||
} else if constexpr (mcc_is_altaz_mount<MOUNT_TYPE>) {
|
|
||||||
MccSkyAZZD azzd;
|
|
||||||
ret = comp_func(azzd);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if constexpr (mcc_coord_pair_c<T>) {
|
|
||||||
*hw_pt = MccCoordPair<typename T::x_t, typename T::y_t>{x - result->pcmX, y - result->pcmY};
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
private:
|
|
||||||
pcm_data_t _pcmData{};
|
|
||||||
double _cosPhi{}, _sinPhi{};
|
|
||||||
|
|
||||||
std::unique_ptr<std::mutex> _pcmDataMutex{new std::mutex};
|
|
||||||
|
|
||||||
error_t _compResult(double x, double y, mcc_pcm_result_c auto* res, bool inverse)
|
|
||||||
{
|
|
||||||
pcm_geom_coeffs_t* geom_coeffs;
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
pcm_bspline_t* bspline;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
geom_coeffs = inverse ? &_pcmData.inverseGeomCoefficients : &_pcmData.geomCoefficients;
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
bspline = inverse ? &_pcmData.inverseBspline : &_pcmData.bspline;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
|| _pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
const auto tanY = std::tan(y);
|
|
||||||
const auto sinX = std::sin(x);
|
|
||||||
const auto cosX = std::cos(x);
|
|
||||||
const auto cosY = std::cos(y);
|
|
||||||
|
|
||||||
|
|
||||||
if (utils::isEqual(cosY, 0.0)) {
|
|
||||||
res->pcmX = _pcmData.geomCoefficients.zeroPointX;
|
|
||||||
} else {
|
|
||||||
res->pcmX = geom_coeffs->zeroPointX + geom_coeffs->collimationErr / cosY +
|
|
||||||
geom_coeffs->nonperpendErr * tanY - geom_coeffs->misalignErr1 * cosX * tanY +
|
|
||||||
geom_coeffs->misalignErr2 * sinX * tanY + geom_coeffs->tubeFlexure * _cosPhi * sinX / cosY -
|
|
||||||
geom_coeffs->DECaxisFlexure * (_cosPhi * cosX + _sinPhi * tanY);
|
|
||||||
}
|
|
||||||
|
|
||||||
res->pcmY = geom_coeffs->zeroPointY + geom_coeffs->misalignErr1 * sinX + geom_coeffs->misalignErr2 * cosX +
|
|
||||||
geom_coeffs->tubeFlexure * (_cosPhi * cosX * std::sin(y) - _sinPhi * cosY);
|
|
||||||
|
|
||||||
if constexpr (mountType == MccMountType::FORK_TYPE) {
|
|
||||||
if (!utils::isEqual(cosX, 0.0)) {
|
|
||||||
res->pcmY += geom_coeffs->forkFlexure / cosX;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_BSPLINE_PCM
|
|
||||||
if (_pcmData.type == MccDefaultPCMType::PCM_TYPE_BSPLINE ||
|
|
||||||
_pcmData.type == MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
|
|
||||||
double spl_valX, spl_valY;
|
|
||||||
|
|
||||||
int ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsX, x, y, spl_valX,
|
|
||||||
bspline->bsplDegreeX, bspline->bsplDegreeY);
|
|
||||||
|
|
||||||
if (ret) {
|
|
||||||
res->pcmX = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
res->pcmY = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ret = bsplines::fitpack_eval_spl2d(bspline->knotsX, bspline->knotsY, bspline->coeffsY, x, y, spl_valY,
|
|
||||||
bspline->bsplDegreeX, bspline->bsplDegreeY);
|
|
||||||
|
|
||||||
if (ret) {
|
|
||||||
res->pcmX = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
res->pcmY = std::numeric_limits<double>::quiet_NaN();
|
|
||||||
return MccDefaultPCMErrorCode::ERROR_INVALID_INPUTS_BISPLEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
res->pcmX += spl_valX;
|
|
||||||
res->pcmY += spl_valY;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return MccDefaultPCMErrorCode::ERROR_OK;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
typedef MccDefaultPCM<MccMountType::ALTAZ_TYPE> MccMountDefaultAltAzPec;
|
|
||||||
typedef MccDefaultPCM<MccMountType::FORK_TYPE> MccMountDefaultForkPec;
|
|
||||||
|
|
||||||
static_assert(mcc_pcm_c<MccMountDefaultForkPec>, "");
|
|
||||||
static_assert(std::movable<MccMountDefaultForkPec>);
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace mcc::impl
|
|
||||||
488
tests/bulletinA.txt
Normal file
488
tests/bulletinA.txt
Normal file
@@ -0,0 +1,488 @@
|
|||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* *
|
||||||
|
* I E R S B U L L E T I N - A *
|
||||||
|
* *
|
||||||
|
* Rapid Service/Prediction of Earth Orientation *
|
||||||
|
**********************************************************************
|
||||||
|
8 October 2026 Vol. XXXIX No. 041
|
||||||
|
______________________________________________________________________
|
||||||
|
GENERAL INFORMATION:
|
||||||
|
MJD = Julian Date - 2 400 000.5 days
|
||||||
|
UT2-UT1 = 0.022 sin(2*pi*T) - 0.012 cos(2*pi*T)
|
||||||
|
- 0.006 sin(4*pi*T) + 0.007 cos(4*pi*T)
|
||||||
|
where pi = 3.14159265... and T is the date in Besselian years.
|
||||||
|
TT = TAI + 32.184 seconds
|
||||||
|
DUT1= (UT1-UTC) transmitted with time signals
|
||||||
|
= 0.0 seconds beginning 09 April 2026 at 0000 UTC
|
||||||
|
Beginning 1 January 2017:
|
||||||
|
TAI-UTC = 37.000 000 seconds
|
||||||
|
***********************************************************************
|
||||||
|
* ANNOUNCEMENTS: *
|
||||||
|
* *
|
||||||
|
* There will NOT be a leap second introduced in UTC *
|
||||||
|
* at the end of December 2026. *
|
||||||
|
* *
|
||||||
|
* The primary source for IERS Rapid Service/Prediction Center (RS/PC) *
|
||||||
|
* data products is the official IERS RS/PC website: *
|
||||||
|
* https://maia.usno.navy.mil *
|
||||||
|
* *
|
||||||
|
* IERS RS/PC products are also available from: *
|
||||||
|
* NASA CDDIS: https://cddis.nasa.gov/archive/products/iers/ *
|
||||||
|
* NASA CDDIS: ftps://gdc.cddis.eosdis.nasa.gov/products/iers/ *
|
||||||
|
* IERS Central Bureau: https://datacenter.iers.org/eop.php *
|
||||||
|
* *
|
||||||
|
* Questions about IERS RS/PC products can be emailed to: *
|
||||||
|
* eopcp@us.navy.mil *
|
||||||
|
* *
|
||||||
|
* Distribution statement A: *
|
||||||
|
* Approved for public release: distribution unlimited. *
|
||||||
|
* *
|
||||||
|
***********************************************************************
|
||||||
|
________________________________________________________________________
|
||||||
|
The contributed observations used in the preparation of this Bulletin
|
||||||
|
are available at <http://www.usno.navy.mil/USNO/earth-orientation/
|
||||||
|
eo-info/general/input-data>. The contributed analysis results are based
|
||||||
|
on data from Very Long Baseline Interferometry (VLBI), Satellite Laser
|
||||||
|
Ranging (SLR), the Global Positioning System (GPS) satellites, Lunar
|
||||||
|
Laser Ranging (LLR), and meteorological predictions of variations in
|
||||||
|
Atmospheric Angular Momentum (AAM).
|
||||||
|
________________________________________________________________________
|
||||||
|
|
||||||
|
COMBINED EARTH ORIENTATION PARAMETERS:
|
||||||
|
|
||||||
|
IERS Rapid Service
|
||||||
|
MJD x error y error UT1-UTC error
|
||||||
|
" " " " s s
|
||||||
|
26 10 2 61315 0.17334 .00009 0.32459 .00009 -0.023137 0.000021
|
||||||
|
26 10 3 61316 0.17258 .00009 0.32394 .00009 -0.023648 0.000022
|
||||||
|
26 10 4 61317 0.17187 .00009 0.32345 .00009 -0.024220 0.000021
|
||||||
|
26 10 5 61318 0.17095 .00009 0.32294 .00009 -0.025006 0.000022
|
||||||
|
26 10 6 61319 0.16982 .00009 0.32250 .00009 -0.026011 0.000022
|
||||||
|
26 10 7 61320 0.16879 .00009 0.32217 .00009 -0.027264 0.000023
|
||||||
|
26 10 8 61321 0.16813 .00009 0.32221 .00009 -0.028742 0.000022
|
||||||
|
|
||||||
|
_______________________________________________________________________
|
||||||
|
|
||||||
|
PREDICTIONS:
|
||||||
|
The following formulas will not reproduce the predictions given below,
|
||||||
|
but may be used to extend the predictions beyond the end of this table.
|
||||||
|
|
||||||
|
x = 0.1598 + 0.0465 cos A - 0.1071 sin A - 0.0426 cos C + 0.0358 sin C
|
||||||
|
y = 0.3762 - 0.0906 cos A - 0.0441 sin A + 0.0358 cos C + 0.0426 sin C
|
||||||
|
UT1-UTC = -0.1023 - 0.00035 (MJD - 61329) - (UT2-UT1)
|
||||||
|
|
||||||
|
where A = 2*pi*(MJD-61321)/365.25 and C = 2*pi*(MJD-61321)/435.
|
||||||
|
|
||||||
|
TAI-UTC(MJD 61322) = 37.0
|
||||||
|
The accuracy may be estimated from the expressions:
|
||||||
|
S x,y = 0.00068 (MJD-61321)**0.80 S t = 0.00025 (MJD-61321)**0.75
|
||||||
|
Estimated accuracies are: Predictions 10 d 20 d 30 d 40 d
|
||||||
|
Polar coord's 0.004 0.007 0.010 0.013
|
||||||
|
UT1-UTC 0.0014 0.0024 0.0032 0.0040
|
||||||
|
|
||||||
|
MJD x(arcsec) y(arcsec) UT1-UTC(sec)
|
||||||
|
2026 10 9 61322 0.1672 0.3223 -0.03029
|
||||||
|
2026 10 10 61323 0.1664 0.3225 -0.03180
|
||||||
|
2026 10 11 61324 0.1656 0.3226 -0.03321
|
||||||
|
2026 10 12 61325 0.1646 0.3227 -0.03444
|
||||||
|
2026 10 13 61326 0.1636 0.3227 -0.03546
|
||||||
|
2026 10 14 61327 0.1624 0.3225 -0.03625
|
||||||
|
2026 10 15 61328 0.1614 0.3223 -0.03684
|
||||||
|
2026 10 16 61329 0.1603 0.3222 -0.03732
|
||||||
|
2026 10 17 61330 0.1593 0.3221 -0.03778
|
||||||
|
2026 10 18 61331 0.1583 0.3220 -0.03834
|
||||||
|
2026 10 19 61332 0.1573 0.3220 -0.03904
|
||||||
|
2026 10 20 61333 0.1563 0.3220 -0.03991
|
||||||
|
2026 10 21 61334 0.1553 0.3220 -0.04102
|
||||||
|
2026 10 22 61335 0.1542 0.3220 -0.04236
|
||||||
|
2026 10 23 61336 0.1532 0.3221 -0.04389
|
||||||
|
2026 10 24 61337 0.1521 0.3221 -0.04556
|
||||||
|
2026 10 25 61338 0.1511 0.3222 -0.04727
|
||||||
|
2026 10 26 61339 0.1500 0.3222 -0.04888
|
||||||
|
2026 10 27 61340 0.1489 0.3223 -0.05031
|
||||||
|
2026 10 28 61341 0.1478 0.3224 -0.05150
|
||||||
|
2026 10 29 61342 0.1467 0.3225 -0.05251
|
||||||
|
2026 10 30 61343 0.1456 0.3226 -0.05343
|
||||||
|
2026 10 31 61344 0.1445 0.3227 -0.05437
|
||||||
|
2026 11 1 61345 0.1434 0.3228 -0.05546
|
||||||
|
2026 11 2 61346 0.1423 0.3230 -0.05677
|
||||||
|
2026 11 3 61347 0.1412 0.3231 -0.05830
|
||||||
|
2026 11 4 61348 0.1401 0.3233 -0.05999
|
||||||
|
2026 11 5 61349 0.1390 0.3235 -0.06177
|
||||||
|
2026 11 6 61350 0.1379 0.3237 -0.06353
|
||||||
|
2026 11 7 61351 0.1368 0.3239 -0.06518
|
||||||
|
2026 11 8 61352 0.1357 0.3242 -0.06664
|
||||||
|
2026 11 9 61353 0.1346 0.3244 -0.06789
|
||||||
|
2026 11 10 61354 0.1334 0.3247 -0.06892
|
||||||
|
2026 11 11 61355 0.1323 0.3250 -0.06976
|
||||||
|
2026 11 12 61356 0.1312 0.3253 -0.07049
|
||||||
|
2026 11 13 61357 0.1301 0.3256 -0.07117
|
||||||
|
2026 11 14 61358 0.1290 0.3259 -0.07187
|
||||||
|
2026 11 15 61359 0.1279 0.3263 -0.07267
|
||||||
|
2026 11 16 61360 0.1268 0.3266 -0.07362
|
||||||
|
2026 11 17 61361 0.1257 0.3270 -0.07477
|
||||||
|
2026 11 18 61362 0.1246 0.3274 -0.07612
|
||||||
|
2026 11 19 61363 0.1235 0.3278 -0.07765
|
||||||
|
2026 11 20 61364 0.1224 0.3283 -0.07931
|
||||||
|
2026 11 21 61365 0.1213 0.3287 -0.08103
|
||||||
|
2026 11 22 61366 0.1203 0.3292 -0.08270
|
||||||
|
2026 11 23 61367 0.1192 0.3296 -0.08420
|
||||||
|
2026 11 24 61368 0.1181 0.3301 -0.08546
|
||||||
|
2026 11 25 61369 0.1171 0.3306 -0.08647
|
||||||
|
2026 11 26 61370 0.1160 0.3311 -0.08729
|
||||||
|
2026 11 27 61371 0.1149 0.3317 -0.08807
|
||||||
|
2026 11 28 61372 0.1139 0.3322 -0.08895
|
||||||
|
2026 11 29 61373 0.1129 0.3328 -0.09003
|
||||||
|
2026 11 30 61374 0.1118 0.3334 -0.09134
|
||||||
|
2026 12 1 61375 0.1108 0.3340 -0.09284
|
||||||
|
2026 12 2 61376 0.1098 0.3346 -0.09444
|
||||||
|
2026 12 3 61377 0.1088 0.3352 -0.09603
|
||||||
|
2026 12 4 61378 0.1078 0.3359 -0.09752
|
||||||
|
2026 12 5 61379 0.1068 0.3365 -0.09884
|
||||||
|
2026 12 6 61380 0.1058 0.3372 -0.09995
|
||||||
|
2026 12 7 61381 0.1048 0.3379 -0.10085
|
||||||
|
2026 12 8 61382 0.1038 0.3386 -0.10156
|
||||||
|
2026 12 9 61383 0.1029 0.3393 -0.10213
|
||||||
|
2026 12 10 61384 0.1019 0.3400 -0.10261
|
||||||
|
2026 12 11 61385 0.1010 0.3408 -0.10308
|
||||||
|
2026 12 12 61386 0.1001 0.3416 -0.10361
|
||||||
|
2026 12 13 61387 0.0992 0.3423 -0.10426
|
||||||
|
2026 12 14 61388 0.0983 0.3431 -0.10506
|
||||||
|
2026 12 15 61389 0.0974 0.3439 -0.10604
|
||||||
|
2026 12 16 61390 0.0965 0.3447 -0.10718
|
||||||
|
2026 12 17 61391 0.0956 0.3456 -0.10847
|
||||||
|
2026 12 18 61392 0.0948 0.3464 -0.10983
|
||||||
|
2026 12 19 61393 0.0939 0.3473 -0.11117
|
||||||
|
2026 12 20 61394 0.0931 0.3481 -0.11241
|
||||||
|
2026 12 21 61395 0.0923 0.3490 -0.11346
|
||||||
|
2026 12 22 61396 0.0915 0.3499 -0.11427
|
||||||
|
2026 12 23 61397 0.0907 0.3508 -0.11490
|
||||||
|
2026 12 24 61398 0.0900 0.3517 -0.11543
|
||||||
|
2026 12 25 61399 0.0892 0.3527 -0.11604
|
||||||
|
2026 12 26 61400 0.0885 0.3536 -0.11683
|
||||||
|
2026 12 27 61401 0.0877 0.3546 -0.11789
|
||||||
|
2026 12 28 61402 0.0870 0.3555 -0.11917
|
||||||
|
2026 12 29 61403 0.0863 0.3565 -0.12060
|
||||||
|
2026 12 30 61404 0.0857 0.3575 -0.12202
|
||||||
|
2026 12 31 61405 0.0850 0.3585 -0.12334
|
||||||
|
2027 1 1 61406 0.0844 0.3595 -0.12446
|
||||||
|
2027 1 2 61407 0.0837 0.3606 -0.12535
|
||||||
|
2027 1 3 61408 0.0831 0.3616 -0.12600
|
||||||
|
2027 1 4 61409 0.0825 0.3626 -0.12645
|
||||||
|
2027 1 5 61410 0.0820 0.3637 -0.12674
|
||||||
|
2027 1 6 61411 0.0814 0.3647 -0.12694
|
||||||
|
2027 1 7 61412 0.0809 0.3658 -0.12711
|
||||||
|
2027 1 8 61413 0.0804 0.3669 -0.12733
|
||||||
|
2027 1 9 61414 0.0799 0.3680 -0.12767
|
||||||
|
2027 1 10 61415 0.0794 0.3691 -0.12816
|
||||||
|
2027 1 11 61416 0.0789 0.3702 -0.12883
|
||||||
|
2027 1 12 61417 0.0785 0.3713 -0.12967
|
||||||
|
2027 1 13 61418 0.0781 0.3724 -0.13064
|
||||||
|
2027 1 14 61419 0.0777 0.3735 -0.13169
|
||||||
|
2027 1 15 61420 0.0773 0.3747 -0.13273
|
||||||
|
2027 1 16 61421 0.0769 0.3758 -0.13369
|
||||||
|
2027 1 17 61422 0.0766 0.3769 -0.13448
|
||||||
|
2027 1 18 61423 0.0762 0.3781 -0.13506
|
||||||
|
2027 1 19 61424 0.0759 0.3793 -0.13544
|
||||||
|
2027 1 20 61425 0.0757 0.3804 -0.13570
|
||||||
|
2027 1 21 61426 0.0754 0.3816 -0.13596
|
||||||
|
2027 1 22 61427 0.0752 0.3827 -0.13639
|
||||||
|
2027 1 23 61428 0.0749 0.3839 -0.13707
|
||||||
|
2027 1 24 61429 0.0747 0.3851 -0.13803
|
||||||
|
2027 1 25 61430 0.0746 0.3863 -0.13935
|
||||||
|
2027 1 26 61431 0.0744 0.3875 -0.14075
|
||||||
|
2027 1 27 61432 0.0743 0.3887 -0.14210
|
||||||
|
2027 1 28 61433 0.0742 0.3899 -0.14327
|
||||||
|
2027 1 29 61434 0.0741 0.3911 -0.14422
|
||||||
|
2027 1 30 61435 0.0740 0.3923 -0.14491
|
||||||
|
2027 1 31 61436 0.0740 0.3935 -0.14540
|
||||||
|
2027 2 1 61437 0.0739 0.3947 -0.14572
|
||||||
|
2027 2 2 61438 0.0739 0.3959 -0.14595
|
||||||
|
2027 2 3 61439 0.0740 0.3971 -0.14614
|
||||||
|
2027 2 4 61440 0.0740 0.3983 -0.14638
|
||||||
|
2027 2 5 61441 0.0741 0.3995 -0.14674
|
||||||
|
2027 2 6 61442 0.0742 0.4007 -0.14726
|
||||||
|
2027 2 7 61443 0.0743 0.4019 -0.14799
|
||||||
|
2027 2 8 61444 0.0744 0.4031 -0.14890
|
||||||
|
2027 2 9 61445 0.0746 0.4043 -0.14998
|
||||||
|
2027 2 10 61446 0.0748 0.4055 -0.15115
|
||||||
|
2027 2 11 61447 0.0750 0.4067 -0.15235
|
||||||
|
2027 2 12 61448 0.0752 0.4079 -0.15347
|
||||||
|
2027 2 13 61449 0.0754 0.4091 -0.15446
|
||||||
|
2027 2 14 61450 0.0757 0.4103 -0.15526
|
||||||
|
2027 2 15 61451 0.0760 0.4115 -0.15586
|
||||||
|
2027 2 16 61452 0.0763 0.4127 -0.15632
|
||||||
|
2027 2 17 61453 0.0767 0.4139 -0.15676
|
||||||
|
2027 2 18 61454 0.0770 0.4151 -0.15731
|
||||||
|
2027 2 19 61455 0.0774 0.4162 -0.15809
|
||||||
|
2027 2 20 61456 0.0778 0.4174 -0.15917
|
||||||
|
2027 2 21 61457 0.0783 0.4186 -0.16054
|
||||||
|
2027 2 22 61458 0.0787 0.4197 -0.16207
|
||||||
|
2027 2 23 61459 0.0792 0.4209 -0.16363
|
||||||
|
2027 2 24 61460 0.0797 0.4221 -0.16506
|
||||||
|
2027 2 25 61461 0.0802 0.4232 -0.16628
|
||||||
|
2027 2 26 61462 0.0808 0.4243 -0.16724
|
||||||
|
2027 2 27 61463 0.0814 0.4255 -0.16796
|
||||||
|
2027 2 28 61464 0.0820 0.4266 -0.16848
|
||||||
|
2027 3 1 61465 0.0826 0.4277 -0.16888
|
||||||
|
2027 3 2 61466 0.0832 0.4288 -0.16923
|
||||||
|
2027 3 3 61467 0.0839 0.4299 -0.16960
|
||||||
|
2027 3 4 61468 0.0845 0.4310 -0.17006
|
||||||
|
2027 3 5 61469 0.0853 0.4321 -0.17068
|
||||||
|
2027 3 6 61470 0.0860 0.4332 -0.17149
|
||||||
|
2027 3 7 61471 0.0867 0.4342 -0.17250
|
||||||
|
2027 3 8 61472 0.0875 0.4353 -0.17368
|
||||||
|
2027 3 9 61473 0.0883 0.4363 -0.17499
|
||||||
|
2027 3 10 61474 0.0891 0.4373 -0.17634
|
||||||
|
2027 3 11 61475 0.0899 0.4384 -0.17764
|
||||||
|
2027 3 12 61476 0.0908 0.4394 -0.17880
|
||||||
|
2027 3 13 61477 0.0917 0.4404 -0.17976
|
||||||
|
2027 3 14 61478 0.0925 0.4414 -0.18051
|
||||||
|
2027 3 15 61479 0.0935 0.4423 -0.18111
|
||||||
|
2027 3 16 61480 0.0944 0.4433 -0.18163
|
||||||
|
2027 3 17 61481 0.0954 0.4442 -0.18221
|
||||||
|
2027 3 18 61482 0.0963 0.4452 -0.18298
|
||||||
|
2027 3 19 61483 0.0973 0.4461 -0.18401
|
||||||
|
2027 3 20 61484 0.0983 0.4470 -0.18533
|
||||||
|
2027 3 21 61485 0.0994 0.4479 -0.18686
|
||||||
|
2027 3 22 61486 0.1004 0.4488 -0.18850
|
||||||
|
2027 3 23 61487 0.1015 0.4496 -0.19010
|
||||||
|
2027 3 24 61488 0.1026 0.4505 -0.19153
|
||||||
|
2027 3 25 61489 0.1037 0.4513 -0.19271
|
||||||
|
2027 3 26 61490 0.1048 0.4521 -0.19364
|
||||||
|
2027 3 27 61491 0.1060 0.4529 -0.19435
|
||||||
|
2027 3 28 61492 0.1071 0.4537 -0.19490
|
||||||
|
2027 3 29 61493 0.1083 0.4545 -0.19538
|
||||||
|
2027 3 30 61494 0.1095 0.4552 -0.19585
|
||||||
|
2027 3 31 61495 0.1107 0.4560 -0.19639
|
||||||
|
2027 4 1 61496 0.1119 0.4567 -0.19707
|
||||||
|
2027 4 2 61497 0.1132 0.4574 -0.19794
|
||||||
|
2027 4 3 61498 0.1144 0.4581 -0.19902
|
||||||
|
2027 4 4 61499 0.1157 0.4587 -0.20031
|
||||||
|
2027 4 5 61500 0.1170 0.4594 -0.20177
|
||||||
|
2027 4 6 61501 0.1183 0.4600 -0.20334
|
||||||
|
2027 4 7 61502 0.1196 0.4606 -0.20493
|
||||||
|
2027 4 8 61503 0.1209 0.4612 -0.20645
|
||||||
|
2027 4 9 61504 0.1223 0.4618 -0.20783
|
||||||
|
2027 4 10 61505 0.1237 0.4623 -0.20906
|
||||||
|
2027 4 11 61506 0.1250 0.4629 -0.21016
|
||||||
|
2027 4 12 61507 0.1264 0.4634 -0.21122
|
||||||
|
2027 4 13 61508 0.1278 0.4639 -0.21237
|
||||||
|
2027 4 14 61509 0.1292 0.4644 -0.21370
|
||||||
|
2027 4 15 61510 0.1306 0.4648 -0.21529
|
||||||
|
2027 4 16 61511 0.1321 0.4652 -0.21712
|
||||||
|
2027 4 17 61512 0.1335 0.4657 -0.21911
|
||||||
|
2027 4 18 61513 0.1350 0.4661 -0.22114
|
||||||
|
2027 4 19 61514 0.1364 0.4664 -0.22304
|
||||||
|
2027 4 20 61515 0.1379 0.4668 -0.22469
|
||||||
|
2027 4 21 61516 0.1394 0.4671 -0.22598
|
||||||
|
2027 4 22 61517 0.1409 0.4674 -0.22690
|
||||||
|
2027 4 23 61518 0.1424 0.4677 -0.22747
|
||||||
|
2027 4 24 61519 0.1439 0.4680 -0.22778
|
||||||
|
2027 4 25 61520 0.1454 0.4682 -0.22790
|
||||||
|
2027 4 26 61521 0.1469 0.4684 -0.22795
|
||||||
|
2027 4 27 61522 0.1485 0.4686 -0.22799
|
||||||
|
2027 4 28 61523 0.1500 0.4688 -0.22810
|
||||||
|
2027 4 29 61524 0.1515 0.4689 -0.22834
|
||||||
|
2027 4 30 61525 0.1531 0.4691 -0.22872
|
||||||
|
2027 5 1 61526 0.1547 0.4692 -0.22926
|
||||||
|
2027 5 2 61527 0.1562 0.4693 -0.22992
|
||||||
|
2027 5 3 61528 0.1578 0.4693 -0.23065
|
||||||
|
2027 5 4 61529 0.1594 0.4694 -0.23137
|
||||||
|
2027 5 5 61530 0.1609 0.4694 -0.23200
|
||||||
|
2027 5 6 61531 0.1625 0.4694 -0.23246
|
||||||
|
2027 5 7 61532 0.1641 0.4693 -0.23268
|
||||||
|
2027 5 8 61533 0.1657 0.4693 -0.23267
|
||||||
|
2027 5 9 61534 0.1672 0.4692 -0.23249
|
||||||
|
2027 5 10 61535 0.1688 0.4691 -0.23225
|
||||||
|
2027 5 11 61536 0.1704 0.4690 -0.23209
|
||||||
|
2027 5 12 61537 0.1720 0.4688 -0.23211
|
||||||
|
2027 5 13 61538 0.1736 0.4687 -0.23238
|
||||||
|
2027 5 14 61539 0.1752 0.4685 -0.23287
|
||||||
|
2027 5 15 61540 0.1768 0.4683 -0.23350
|
||||||
|
2027 5 16 61541 0.1783 0.4680 -0.23417
|
||||||
|
2027 5 17 61542 0.1799 0.4678 -0.23477
|
||||||
|
2027 5 18 61543 0.1815 0.4675 -0.23522
|
||||||
|
2027 5 19 61544 0.1831 0.4672 -0.23549
|
||||||
|
2027 5 20 61545 0.1847 0.4668 -0.23553
|
||||||
|
2027 5 21 61546 0.1862 0.4665 -0.23532
|
||||||
|
2027 5 22 61547 0.1878 0.4661 -0.23490
|
||||||
|
2027 5 23 61548 0.1894 0.4657 -0.23447
|
||||||
|
2027 5 24 61549 0.1909 0.4653 -0.23402
|
||||||
|
2027 5 25 61550 0.1925 0.4648 -0.23356
|
||||||
|
2027 5 26 61551 0.1940 0.4643 -0.23305
|
||||||
|
2027 5 27 61552 0.1956 0.4638 -0.23271
|
||||||
|
2027 5 28 61553 0.1971 0.4633 -0.23256
|
||||||
|
2027 5 29 61554 0.1986 0.4628 -0.23252
|
||||||
|
2027 5 30 61555 0.2002 0.4622 -0.23259
|
||||||
|
2027 5 31 61556 0.2017 0.4616 -0.23260
|
||||||
|
2027 6 1 61557 0.2032 0.4610 -0.23253
|
||||||
|
2027 6 2 61558 0.2047 0.4604 -0.23231
|
||||||
|
2027 6 3 61559 0.2062 0.4597 -0.23185
|
||||||
|
2027 6 4 61560 0.2076 0.4591 -0.23119
|
||||||
|
2027 6 5 61561 0.2091 0.4584 -0.23032
|
||||||
|
2027 6 6 61562 0.2106 0.4576 -0.22943
|
||||||
|
2027 6 7 61563 0.2120 0.4569 -0.22870
|
||||||
|
2027 6 8 61564 0.2135 0.4561 -0.22819
|
||||||
|
2027 6 9 61565 0.2149 0.4553 -0.22786
|
||||||
|
2027 6 10 61566 0.2163 0.4545 -0.22767
|
||||||
|
2027 6 11 61567 0.2177 0.4537 -0.22763
|
||||||
|
2027 6 12 61568 0.2191 0.4529 -0.22757
|
||||||
|
2027 6 13 61569 0.2205 0.4520 -0.22745
|
||||||
|
2027 6 14 61570 0.2218 0.4511 -0.22711
|
||||||
|
2027 6 15 61571 0.2232 0.4502 -0.22646
|
||||||
|
2027 6 16 61572 0.2245 0.4493 -0.22558
|
||||||
|
2027 6 17 61573 0.2258 0.4483 -0.22449
|
||||||
|
2027 6 18 61574 0.2271 0.4473 -0.22329
|
||||||
|
2027 6 19 61575 0.2284 0.4464 -0.22201
|
||||||
|
2027 6 20 61576 0.2297 0.4453 -0.22078
|
||||||
|
2027 6 21 61577 0.2309 0.4443 -0.21958
|
||||||
|
2027 6 22 61578 0.2321 0.4433 -0.21855
|
||||||
|
2027 6 23 61579 0.2334 0.4422 -0.21767
|
||||||
|
2027 6 24 61580 0.2346 0.4411 -0.21699
|
||||||
|
2027 6 25 61581 0.2357 0.4400 -0.21648
|
||||||
|
2027 6 26 61582 0.2369 0.4389 -0.21610
|
||||||
|
2027 6 27 61583 0.2380 0.4378 -0.21582
|
||||||
|
2027 6 28 61584 0.2392 0.4366 -0.21555
|
||||||
|
2027 6 29 61585 0.2403 0.4354 -0.21520
|
||||||
|
2027 6 30 61586 0.2413 0.4342 -0.21476
|
||||||
|
2027 7 1 61587 0.2424 0.4330 -0.21407
|
||||||
|
2027 7 2 61588 0.2435 0.4318 -0.21326
|
||||||
|
2027 7 3 61589 0.2445 0.4306 -0.21229
|
||||||
|
2027 7 4 61590 0.2455 0.4293 -0.21142
|
||||||
|
2027 7 5 61591 0.2465 0.4281 -0.21066
|
||||||
|
2027 7 6 61592 0.2474 0.4268 -0.21015
|
||||||
|
2027 7 7 61593 0.2483 0.4255 -0.20989
|
||||||
|
2027 7 8 61594 0.2493 0.4242 -0.20984
|
||||||
|
2027 7 9 61595 0.2501 0.4228 -0.20994
|
||||||
|
2027 7 10 61596 0.2510 0.4215 -0.20988
|
||||||
|
2027 7 11 61597 0.2519 0.4202 -0.20959
|
||||||
|
2027 7 12 61598 0.2527 0.4188 -0.20900
|
||||||
|
2027 7 13 61599 0.2535 0.4174 -0.20815
|
||||||
|
2027 7 14 61600 0.2542 0.4160 -0.20703
|
||||||
|
2027 7 15 61601 0.2550 0.4146 -0.20571
|
||||||
|
2027 7 16 61602 0.2557 0.4132 -0.20432
|
||||||
|
2027 7 17 61603 0.2564 0.4118 -0.20294
|
||||||
|
2027 7 18 61604 0.2571 0.4103 -0.20162
|
||||||
|
2027 7 19 61605 0.2577 0.4089 -0.20047
|
||||||
|
2027 7 20 61606 0.2583 0.4074 -0.19943
|
||||||
|
2027 7 21 61607 0.2589 0.4060 -0.19858
|
||||||
|
2027 7 22 61608 0.2595 0.4045 -0.19794
|
||||||
|
2027 7 23 61609 0.2600 0.4030 -0.19744
|
||||||
|
2027 7 24 61610 0.2605 0.4015 -0.19706
|
||||||
|
2027 7 25 61611 0.2610 0.4000 -0.19671
|
||||||
|
2027 7 26 61612 0.2615 0.3985 -0.19636
|
||||||
|
2027 7 27 61613 0.2619 0.3970 -0.19587
|
||||||
|
2027 7 28 61614 0.2623 0.3955 -0.19523
|
||||||
|
2027 7 29 61615 0.2627 0.3940 -0.19436
|
||||||
|
2027 7 30 61616 0.2631 0.3924 -0.19338
|
||||||
|
2027 7 31 61617 0.2634 0.3909 -0.19242
|
||||||
|
2027 8 1 61618 0.2637 0.3893 -0.19156
|
||||||
|
2027 8 2 61619 0.2639 0.3878 -0.19089
|
||||||
|
2027 8 3 61620 0.2642 0.3862 -0.19047
|
||||||
|
2027 8 4 61621 0.2644 0.3847 -0.19032
|
||||||
|
2027 8 5 61622 0.2646 0.3831 -0.19038
|
||||||
|
2027 8 6 61623 0.2647 0.3816 -0.19045
|
||||||
|
2027 8 7 61624 0.2648 0.3800 -0.19036
|
||||||
|
2027 8 8 61625 0.2649 0.3784 -0.19005
|
||||||
|
2027 8 9 61626 0.2650 0.3768 -0.18939
|
||||||
|
2027 8 10 61627 0.2650 0.3753 -0.18850
|
||||||
|
2027 8 11 61628 0.2650 0.3737 -0.18736
|
||||||
|
2027 8 12 61629 0.2650 0.3721 -0.18613
|
||||||
|
2027 8 13 61630 0.2649 0.3706 -0.18490
|
||||||
|
2027 8 14 61631 0.2649 0.3690 -0.18367
|
||||||
|
2027 8 15 61632 0.2647 0.3674 -0.18263
|
||||||
|
2027 8 16 61633 0.2646 0.3658 -0.18175
|
||||||
|
2027 8 17 61634 0.2644 0.3643 -0.18101
|
||||||
|
2027 8 18 61635 0.2642 0.3627 -0.18047
|
||||||
|
2027 8 19 61636 0.2640 0.3611 -0.18006
|
||||||
|
2027 8 20 61637 0.2638 0.3596 -0.17971
|
||||||
|
2027 8 21 61638 0.2635 0.3580 -0.17944
|
||||||
|
2027 8 22 61639 0.2631 0.3565 -0.17920
|
||||||
|
2027 8 23 61640 0.2628 0.3549 -0.17893
|
||||||
|
2027 8 24 61641 0.2624 0.3534 -0.17850
|
||||||
|
2027 8 25 61642 0.2620 0.3518 -0.17787
|
||||||
|
2027 8 26 61643 0.2616 0.3503 -0.17711
|
||||||
|
2027 8 27 61644 0.2611 0.3488 -0.17636
|
||||||
|
2027 8 28 61645 0.2606 0.3472 -0.17574
|
||||||
|
2027 8 29 61646 0.2601 0.3457 -0.17539
|
||||||
|
2027 8 30 61647 0.2596 0.3442 -0.17532
|
||||||
|
2027 8 31 61648 0.2590 0.3427 -0.17563
|
||||||
|
2027 9 1 61649 0.2584 0.3412 -0.17620
|
||||||
|
2027 9 2 61650 0.2577 0.3398 -0.17690
|
||||||
|
2027 9 3 61651 0.2571 0.3383 -0.17757
|
||||||
|
2027 9 4 61652 0.2564 0.3368 -0.17804
|
||||||
|
2027 9 5 61653 0.2557 0.3354 -0.17821
|
||||||
|
2027 9 6 61654 0.2549 0.3339 -0.17804
|
||||||
|
2027 9 7 61655 0.2541 0.3325 -0.17762
|
||||||
|
2027 9 8 61656 0.2533 0.3311 -0.17702
|
||||||
|
2027 9 9 61657 0.2525 0.3297 -0.17639
|
||||||
|
2027 9 10 61658 0.2516 0.3283 -0.17578
|
||||||
|
2027 9 11 61659 0.2508 0.3269 -0.17523
|
||||||
|
2027 9 12 61660 0.2498 0.3255 -0.17482
|
||||||
|
2027 9 13 61661 0.2489 0.3242 -0.17451
|
||||||
|
2027 9 14 61662 0.2479 0.3228 -0.17443
|
||||||
|
2027 9 15 61663 0.2470 0.3215 -0.17454
|
||||||
|
2027 9 16 61664 0.2459 0.3202 -0.17483
|
||||||
|
2027 9 17 61665 0.2449 0.3189 -0.17520
|
||||||
|
2027 9 18 61666 0.2438 0.3176 -0.17547
|
||||||
|
2027 9 19 61667 0.2427 0.3163 -0.17563
|
||||||
|
2027 9 20 61668 0.2416 0.3151 -0.17573
|
||||||
|
2027 9 21 61669 0.2405 0.3138 -0.17562
|
||||||
|
2027 9 22 61670 0.2393 0.3126 -0.17534
|
||||||
|
2027 9 23 61671 0.2381 0.3114 -0.17497
|
||||||
|
2027 9 24 61672 0.2369 0.3102 -0.17466
|
||||||
|
2027 9 25 61673 0.2356 0.3091 -0.17446
|
||||||
|
2027 9 26 61674 0.2344 0.3079 -0.17452
|
||||||
|
2027 9 27 61675 0.2331 0.3068 -0.17491
|
||||||
|
2027 9 28 61676 0.2318 0.3057 -0.17557
|
||||||
|
2027 9 29 61677 0.2305 0.3046 -0.17637
|
||||||
|
2027 9 30 61678 0.2291 0.3035 -0.17727
|
||||||
|
2027 10 1 61679 0.2277 0.3025 -0.17809
|
||||||
|
2027 10 2 61680 0.2263 0.3015 -0.17865
|
||||||
|
2027 10 3 61681 0.2249 0.3005 -0.17894
|
||||||
|
2027 10 4 61682 0.2235 0.2995 -0.17892
|
||||||
|
2027 10 5 61683 0.2220 0.2985 -0.17866
|
||||||
|
2027 10 6 61684 0.2205 0.2976 -0.17834
|
||||||
|
2027 10 7 61685 0.2190 0.2966 -0.17806
|
||||||
|
2027 10 8 61686 0.2175 0.2957 -0.17778
|
||||||
|
These predictions are based on all announced leap seconds.
|
||||||
|
|
||||||
|
CELESTIAL POLE OFFSET SERIES:
|
||||||
|
NEOS Celestial Pole Offset Series
|
||||||
|
MJD dpsi error deps error
|
||||||
|
(msec. of arc)
|
||||||
|
61292 -123.28 1.24 -11.48 0.12
|
||||||
|
61293 -123.30 1.24 -11.30 0.12
|
||||||
|
61294 -123.26 1.24 -11.15 0.12
|
||||||
|
61295 -123.29 0.32 -11.07 0.16
|
||||||
|
61296 -123.59 0.32 -11.08 0.16
|
||||||
|
61297 -124.16 0.32 -11.18 0.16
|
||||||
|
61298 -124.72 0.32 -11.31 0.16
|
||||||
|
61299 -124.96 0.32 -11.38 0.16
|
||||||
|
61300 -124.76 0.32 -11.31 0.16
|
||||||
|
61301 -124.26 0.32 -11.17 0.16
|
||||||
|
61302 -123.69 0.32 -11.09 0.16
|
||||||
|
61303 -123.26 1.03 -11.12 0.11
|
||||||
|
61304 -123.06 1.03 -11.23 0.11
|
||||||
|
61305 -123.09 1.03 -11.27 0.11
|
||||||
|
|
||||||
|
IAU2000A Celestial Pole Offset Series
|
||||||
|
MJD dX error dY error
|
||||||
|
(msec. of arc)
|
||||||
|
61292 0.457 0.492 -0.206 0.116
|
||||||
|
61293 0.457 0.492 -0.198 0.116
|
||||||
|
61294 0.456 0.492 -0.190 0.116
|
||||||
|
61295 0.455 0.128 -0.182 0.160
|
||||||
|
61296 0.453 0.128 -0.175 0.160
|
||||||
|
61297 0.450 0.128 -0.167 0.160
|
||||||
|
61298 0.447 0.128 -0.160 0.160
|
||||||
|
61299 0.443 0.128 -0.152 0.160
|
||||||
|
61300 0.438 0.128 -0.145 0.160
|
||||||
|
61301 0.434 0.128 -0.138 0.160
|
||||||
|
61302 0.429 0.128 -0.131 0.160
|
||||||
|
61303 0.424 0.409 -0.124 0.113
|
||||||
|
61304 0.419 0.409 -0.117 0.113
|
||||||
|
61305 0.414 0.409 -0.109 0.113
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// #include <mcc_ccte_erfa.h>
|
#include <mcc/mcc_deserializer.h>
|
||||||
#include <mcc_coordinate.h>
|
#include <mcc/mcc_serializer.h>
|
||||||
#include <mcc_serializer.h>
|
|
||||||
|
|
||||||
using namespace mcc::impl;
|
using namespace mcc::impl;
|
||||||
|
|
||||||
@@ -25,19 +25,36 @@ void serialize(VT const& value)
|
|||||||
{
|
{
|
||||||
MccSerializer<VT> ser;
|
MccSerializer<VT> ser;
|
||||||
std::string s;
|
std::string s;
|
||||||
|
mcc_serialization_params_t pars{};
|
||||||
|
pars.norm_sxgm = true;
|
||||||
|
pars.coordpair_format = mcc::MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURDEG;
|
||||||
|
|
||||||
auto err = ser(s, value);
|
auto err = ser(s, value, pars);
|
||||||
if (err) {
|
if (err) {
|
||||||
std::cout << "SERIALIZing ERR: " << err << "\n";
|
std::cout << "SERIALIZING ERR: " << err.message() << "\n";
|
||||||
} else {
|
} else {
|
||||||
std::cout << "SERIALIZED: " << s << "\n";
|
std::cout << "SERIALIZED: " << s << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
template <typename VT>
|
||||||
|
void deserialize(mcc::traits::mcc_input_char_range auto const& s, VT& value)
|
||||||
|
{
|
||||||
|
MccDeserializer<VT> deser;
|
||||||
|
|
||||||
|
auto err = deser(s, value);
|
||||||
|
if (err) {
|
||||||
|
std::cout << "DESERIALIZING ERR: " << err << "\n";
|
||||||
|
} else {
|
||||||
|
std::cout << "DESERIALIZION IS OK\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
skypt_t::cctEngine.setStateERFA(saoras);
|
skypt_t::cctEngine.setStateERFA(saoras);
|
||||||
|
|
||||||
|
|
||||||
skypt_t pt;
|
skypt_t pt;
|
||||||
MccSkyRADEC_ICRS icrs(0.0, 70.0_degs);
|
MccSkyRADEC_ICRS icrs(0.0, 70.0_degs);
|
||||||
|
|
||||||
@@ -122,6 +139,9 @@ int main()
|
|||||||
std::cout << "\tfor 'double' type: ";
|
std::cout << "\tfor 'double' type: ";
|
||||||
serialize(v);
|
serialize(v);
|
||||||
|
|
||||||
|
std::cout << "\tfor 'coord pair' type: ";
|
||||||
|
serialize(icrs);
|
||||||
|
|
||||||
std::cout << "\tfor 'coord pair' type: ";
|
std::cout << "\tfor 'coord pair' type: ";
|
||||||
serialize(radec_obs);
|
serialize(radec_obs);
|
||||||
|
|
||||||
@@ -141,5 +161,35 @@ int main()
|
|||||||
std::cout << "\tfor 'sky point' type: ";
|
std::cout << "\tfor 'sky point' type: ";
|
||||||
serialize(pt);
|
serialize(pt);
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "\n\nDESERIALIZATION TEST:\n";
|
||||||
|
v = 0.0;
|
||||||
|
|
||||||
|
std::string s = "123.7687";
|
||||||
|
|
||||||
|
deserialize(s, v);
|
||||||
|
std::cout << "\tfor 'double' type: v = " << v << "\n";
|
||||||
|
|
||||||
|
s = " 11:22:33.453, -32.19820931,65632.87987987,RADEC-OBS ";
|
||||||
|
deserialize(s, pt);
|
||||||
|
pt.toAtSameEpoch(radec_obs);
|
||||||
|
std::cout << "\tfor 'sky point' type: x = " << radec_obs.x().sexagesimal(true)
|
||||||
|
<< ", y = " << radec_obs.y().degrees() << ", epoch = " << pt.epoch().MJD()
|
||||||
|
<< ", kind = " << MccCoordPairKindToStr(pt.pairKind()) << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "\n\n";
|
||||||
|
std::string ba_fname = "/tmp/bulletinA.txt";
|
||||||
|
if (argc > 1) {
|
||||||
|
ba_fname = argv[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
auto err = skypt_t::cctEngine.updateBulletinA(ba_fname);
|
||||||
|
if (err) {
|
||||||
|
std::cout << "Cannot load BulletinA file: '" << ba_fname << "' (err = " << err.message() << ")\n";
|
||||||
|
} else {
|
||||||
|
std::cout << "BulletinA file: '" << ba_fname << " was loaded successfully!\n";
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
127
tests/mcc_fitpack_test.cpp
Normal file
127
tests/mcc_fitpack_test.cpp
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <random>
|
||||||
|
#include <ranges>
|
||||||
|
|
||||||
|
#include <mcc/mcc_bsplines.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
size_t nt = 30, np = 60, N = nt * np, i = 1;
|
||||||
|
// size_t nt = 10, np = 20, N = nt * np, i = 1;
|
||||||
|
double ts = std::numbers::pi / (nt + 1);
|
||||||
|
double ps = 2.0 * std::numbers::pi / (np + 1);
|
||||||
|
|
||||||
|
std::vector<double> tetha(N), phi(N), func(N);
|
||||||
|
|
||||||
|
auto gen_func = [](double st, size_t& idx) {
|
||||||
|
double v = st * idx;
|
||||||
|
++idx;
|
||||||
|
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto print_func = [](const auto& r, std::string_view name) {
|
||||||
|
std::cout << name << ": ";
|
||||||
|
for (auto& el : r) {
|
||||||
|
std::cout << el << " ";
|
||||||
|
}
|
||||||
|
std::cout << "\n";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// std::ranges::generate(tetha, std::bind(gen_func, ts, i));
|
||||||
|
|
||||||
|
// i = 1;
|
||||||
|
// std::ranges::generate(phi, std::bind(gen_func, ps, i));
|
||||||
|
|
||||||
|
size_t k = 1;
|
||||||
|
i = 0;
|
||||||
|
for (size_t j = 0; j < nt; ++j) {
|
||||||
|
std::ranges::fill_n(tetha.begin() + i * np, np, ts * (i + 1));
|
||||||
|
std::ranges::generate(phi | std::views::drop(i * np) | std::views::take(np), std::bind(gen_func, ps, k));
|
||||||
|
++i;
|
||||||
|
k = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// std::uniform_real_distribution<double> distr{-0.1, 0.1};
|
||||||
|
std::normal_distribution<double> distr{0.0, 1.0};
|
||||||
|
std::random_device device;
|
||||||
|
std::mt19937 engine{device()};
|
||||||
|
|
||||||
|
std::ranges::generate(func, [ii = 0, &distr, &engine, &tetha, &phi]() mutable {
|
||||||
|
double v = (5.0 + tetha[ii]) * 1.3 + (3.0 + phi[ii]) * 3.1 + distr(engine);
|
||||||
|
++ii;
|
||||||
|
return v;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
int ntk = 24, npk = 29, nf = (ntk + 4) * (npk + 4);
|
||||||
|
// int ntk = 3, npk = 6, nf = (ntk + 4) * (npk + 4);
|
||||||
|
std::vector<double> tk(ntk + 8), pk(npk + 8), coeffs(nf);
|
||||||
|
ts = std::numbers::pi / (ntk + 1);
|
||||||
|
ps = 2.0 * std::numbers::pi / (npk + 1);
|
||||||
|
|
||||||
|
i = 1;
|
||||||
|
std::ranges::generate(tk | std::views::drop(4) | std::views::take(ntk), std::bind(gen_func, ts, i));
|
||||||
|
i = 1;
|
||||||
|
std::ranges::generate(pk | std::views::drop(4) | std::views::take(npk), std::bind(gen_func, ps, i));
|
||||||
|
|
||||||
|
|
||||||
|
double rs = 0.0;
|
||||||
|
int ec = mcc::bsplines::fitpack_sphere_fit(tetha, phi, func, 1.0, tk, pk, coeffs, rs);
|
||||||
|
|
||||||
|
std::cout << "FIT EC = " << ec << "\n";
|
||||||
|
std::cout << "FIT RESI = " << rs << "\n";
|
||||||
|
|
||||||
|
ntk += 8;
|
||||||
|
npk += 8;
|
||||||
|
std::ranges::fill(tk, -1);
|
||||||
|
std::ranges::fill(pk, -1);
|
||||||
|
ec = mcc::bsplines::fitpack_sphere_smooth(tetha, phi, func, 1.0, 1800.0, ntk, npk, tk, pk, coeffs, rs);
|
||||||
|
|
||||||
|
std::cout << "FIT EC = " << ec << "\n";
|
||||||
|
std::cout << "FIT RESI = " << rs << "\n";
|
||||||
|
std::cout << "NKNOTS: " << ntk << ", " << npk << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
print_func(coeffs, "coeffs");
|
||||||
|
|
||||||
|
// print_func(tetha, "tetha");
|
||||||
|
// print_func(phi, "phi");
|
||||||
|
print_func(tk, "tetha_knots");
|
||||||
|
print_func(pk, "phi_knots");
|
||||||
|
print_func(func, "func");
|
||||||
|
|
||||||
|
std::cout << "\n\n";
|
||||||
|
|
||||||
|
k = 1;
|
||||||
|
ts = std::numbers::pi / (nt + 1);
|
||||||
|
std::ranges::generate_n(tetha.begin(), nt, std::bind(gen_func, ts, k));
|
||||||
|
|
||||||
|
std::vector<double> f_func;
|
||||||
|
tetha.resize(nt);
|
||||||
|
phi.resize(np);
|
||||||
|
|
||||||
|
tk.resize(ntk);
|
||||||
|
pk.resize(npk);
|
||||||
|
|
||||||
|
print_func(tetha, "TETHA:");
|
||||||
|
print_func(phi, "PHI:");
|
||||||
|
|
||||||
|
ec = mcc::bsplines::fitpack_eval_spl2d(tk, pk, coeffs, tetha, phi, f_func);
|
||||||
|
// ec = mcc::bsplines::fitpack_eval_spl2d(pk, tk, coeffs, phi, tetha, f_func);
|
||||||
|
std::cout << "EVAL EC = " << ec << "\n";
|
||||||
|
print_func(f_func, "func");
|
||||||
|
|
||||||
|
std::cout << "\n\n";
|
||||||
|
|
||||||
|
for (size_t l = 0; l < f_func.size(); ++l) {
|
||||||
|
auto r = f_func[l] - func[l];
|
||||||
|
std::cout << r << " ";
|
||||||
|
}
|
||||||
|
std::cout << "\n";
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
178
tests/mcc_keyvalue_test.cpp
Normal file
178
tests/mcc_keyvalue_test.cpp
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
#include <print>
|
||||||
|
|
||||||
|
#include <mcc/mcc_keyvalue.h>
|
||||||
|
|
||||||
|
using namespace mcc::impl;
|
||||||
|
|
||||||
|
|
||||||
|
// example of non-default constructible class
|
||||||
|
struct VT {
|
||||||
|
VT(int v) : _v(v) {}
|
||||||
|
|
||||||
|
void set(int v)
|
||||||
|
{
|
||||||
|
_v = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
int v() const
|
||||||
|
{
|
||||||
|
return _v;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int _v{};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct mcc::impl::MccSerializer<VT> : MccSerializerBase {
|
||||||
|
static constexpr std::string_view serializerName{"MCC-VT-SERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_output_char_range auto& output,
|
||||||
|
VT const& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
return MccSerializer<int>{}(output, value.v(), params);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct mcc::impl::MccDeserializer<VT> : MccDeserializerBase {
|
||||||
|
static constexpr std::string_view deserializerName{"MCC-VT-DESERIALIZER"};
|
||||||
|
|
||||||
|
template <mcc_serialization_params_c ParamsT = mcc_serialization_params_t>
|
||||||
|
error_t operator()(traits::mcc_input_char_range auto const& input,
|
||||||
|
VT& value,
|
||||||
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
|
{
|
||||||
|
int v;
|
||||||
|
auto err = MccDeserializer<int>{}(input, v, params);
|
||||||
|
if (!err) {
|
||||||
|
value.set(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static auto kv_desc = std::make_tuple(
|
||||||
|
mcc_simple_kv_record_t{"bb", MccAngle{11.5_degs}, MccAngle{11.5_degs}, mcc_serialization_params_t{}},
|
||||||
|
mcc_simple_kv_record_t{"aaa", std::string("AAA"), std::string("AAA"), mcc_serialization_params_t{}},
|
||||||
|
mcc_simple_kv_record_t{"cc", MccCelestialCoordEpoch{}, MccCelestialCoordEpoch{}, mcc_serialization_params_t{}},
|
||||||
|
mcc_simple_kv_record_t{
|
||||||
|
"ddd", MccAngle{11.5_degs}, MccAngle{11.5_degs},
|
||||||
|
mcc_serialization_params_t{.angle_format = mcc::MccSerializedAngleFormat::MCC_SERIALIZED_FORMAT_SXGM_HOURS}},
|
||||||
|
mcc_make_simple_kv_record("eee", 1.5),
|
||||||
|
mcc_make_simple_kv_record("arr", std::vector<int>{1, 2, 3, 4, 5, 6, 7}),
|
||||||
|
mcc_make_simple_kv_record("vt", VT(77)),
|
||||||
|
mcc_make_simple_kv_record("sarr", std::array<double, 3>{1, 2, 3}));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static std::string STR = R"--(
|
||||||
|
|
||||||
|
aaa = dewl_ewkj23+23998
|
||||||
|
|
||||||
|
#
|
||||||
|
# this is angle
|
||||||
|
bb=1.24534
|
||||||
|
cc= 2026-05-15T05:53:20.921723918 # date UTC
|
||||||
|
|
||||||
|
)--";
|
||||||
|
|
||||||
|
static std::string STR1 = R"--(
|
||||||
|
aaa = dewl_ewkj23+23998
|
||||||
|
|
||||||
|
#
|
||||||
|
# this is obs date
|
||||||
|
cc= 2026-05-15T05:53:20.921723918 # date UTC
|
||||||
|
|
||||||
|
ddd = 01:02:33.434 # HA in hours:mins:secs
|
||||||
|
)--";
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::error_code err;
|
||||||
|
std::string buff;
|
||||||
|
|
||||||
|
MccKeyValueHolder kv(kv_desc);
|
||||||
|
|
||||||
|
err = kv.toCharRange(buff);
|
||||||
|
if (err) {
|
||||||
|
std::println("ERR = {}", err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::println("DEFAULT VALUES:");
|
||||||
|
std::println("--(\n{})--", buff);
|
||||||
|
std::println("\n\n");
|
||||||
|
|
||||||
|
|
||||||
|
err = kv.setValue("eee", 15.1515);
|
||||||
|
if (err) {
|
||||||
|
std::println("ERR = {}", err);
|
||||||
|
// return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// auto err = kv.fromCharRange(STR);
|
||||||
|
err = kv.fromCharRange(STR1);
|
||||||
|
if (err) {
|
||||||
|
std::println("ERR = {}", err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::println("{} = {}", "bb", kv.getValue<MccAngle>(std::string{"bb"}).value().sexagesimal());
|
||||||
|
std::println("{} = {}", "cc", kv.getValue<MccCelestialCoordEpoch>("cc").value().UTC());
|
||||||
|
|
||||||
|
err = kv.setValue("cc", std::chrono::system_clock::now());
|
||||||
|
if (err) {
|
||||||
|
std::println("ERR = {}", err);
|
||||||
|
// return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = kv.setValue("aaa", "OK");
|
||||||
|
if (err) {
|
||||||
|
std::println("ERR = {}", err);
|
||||||
|
// return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = kv.setValue("ddd", 37.5_degs);
|
||||||
|
if (err) {
|
||||||
|
std::println("ERR = {}", err);
|
||||||
|
// return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = kv.setValue("arr", std::array{10, 20, 30});
|
||||||
|
if (err) {
|
||||||
|
std::println("ERR = {}", err);
|
||||||
|
// return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = kv.setValue("sarr", std::vector{10, 20, 30, 40, 50});
|
||||||
|
if (err) {
|
||||||
|
std::println("ERR = {}", err);
|
||||||
|
// return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::println("------------------------------------");
|
||||||
|
|
||||||
|
|
||||||
|
buff.clear();
|
||||||
|
err = kv.toCharRange<decltype(kv)::OPOLICY_FULL>(buff);
|
||||||
|
// err = kv.toCharRange(buff);
|
||||||
|
if (err) {
|
||||||
|
std::println("ERR = {}", err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::println("--(\n{}\n)--", buff);
|
||||||
|
|
||||||
|
std::print("KEYS: ");
|
||||||
|
for (auto const& k : kv.keys()) {
|
||||||
|
std::print("{} ", k);
|
||||||
|
}
|
||||||
|
std::println("");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
77
tests/mcc_netmsg_test.cpp
Normal file
77
tests/mcc_netmsg_test.cpp
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#include <list>
|
||||||
|
#include <print>
|
||||||
|
|
||||||
|
#include <mcc/mcc_netserver_proto.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using msg1_t = mcc::network::MccNetMessage<std::string_view>;
|
||||||
|
using msg2_t = mcc::network::MccNetMessage<std::string>;
|
||||||
|
|
||||||
|
mcc::network::MccNetMessage msg3("ACK");
|
||||||
|
|
||||||
|
std::string_view sv{"TARGET 11:22:33.212; -0.23876984; RADEC "};
|
||||||
|
std::vector<char> arr{sv.begin(), sv.end()};
|
||||||
|
|
||||||
|
msg1_t msg1;
|
||||||
|
|
||||||
|
msg1.fromCharRange(arr);
|
||||||
|
|
||||||
|
std::println("msg.key = <{}>", msg1.keyword());
|
||||||
|
std::println("msg.par[1] = <{}>", msg1.param(1));
|
||||||
|
|
||||||
|
std::vector<double> vd{1.1, 2.2, 3.3};
|
||||||
|
msg2_t msg2("ACK", 12.43298042, "EEE", std::chrono::seconds(10), vd);
|
||||||
|
// msg2_t msg2("ACK");
|
||||||
|
|
||||||
|
std::println("msg.bytes = <{}>", msg2.byteRepr());
|
||||||
|
std::println("msg.key = <{}>", msg2.keyword());
|
||||||
|
std::println("msg.par[1] = <{}>", msg2.param(1));
|
||||||
|
std::println("msg.par[2] = <{}>", msg2.param(2));
|
||||||
|
|
||||||
|
|
||||||
|
auto p2 = msg2.paramValue<std::chrono::seconds>(2);
|
||||||
|
std::println("msg.parvalue[2] = <{}>", p2.value_or(std::chrono::seconds{}));
|
||||||
|
|
||||||
|
|
||||||
|
std::print("msg.parvalue[3] = <");
|
||||||
|
auto p3 = msg2.paramValue<decltype(vd)>(3);
|
||||||
|
if (p3.has_value()) {
|
||||||
|
for (auto const& el : p3.value()) {
|
||||||
|
std::print("{} ", el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::println(">");
|
||||||
|
|
||||||
|
|
||||||
|
std::println("msg.par[1-2] joined = <{}>", msg2.params(1, 2));
|
||||||
|
|
||||||
|
auto vv = msg2.params<std::list<std::string_view>>(1, 3);
|
||||||
|
std::print("msg.par[1-3] array = <");
|
||||||
|
for (auto const& el : vv) {
|
||||||
|
std::print("{} ", el);
|
||||||
|
}
|
||||||
|
std::println(">");
|
||||||
|
|
||||||
|
|
||||||
|
std::println("\n\n");
|
||||||
|
|
||||||
|
mcc::impl::MccSkyPoint spt(mcc::impl::MccSkyRADEC_APP{"10:00:00.0"_hms, 12.098687_degs});
|
||||||
|
|
||||||
|
msg2.construct("ACK", "MOUNT", mcc::MccSerializedAngleFormatPrec{3, 2}, spt);
|
||||||
|
std::println("msg2.bytes = <{}>", msg2.byteRepr());
|
||||||
|
|
||||||
|
auto spt_d = msg2.paramValue<mcc::impl::MccSkyPoint>(1);
|
||||||
|
|
||||||
|
if (spt_d) {
|
||||||
|
std::println("msg2.parvalue(1).pairKind() = {}", MccCoordPairKindToStr(spt_d->pairKind()));
|
||||||
|
std::println("msg2.parvalue(1).epoch() = {}", spt_d->epoch().MJD() + mcc::MCC_MJD_ZERO);
|
||||||
|
} else {
|
||||||
|
std::println("cannot deserialize MccSkyPoint value!");
|
||||||
|
}
|
||||||
|
|
||||||
|
msg2.construct("ACK", "MOUNT", mcc::MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_DEGREES, spt);
|
||||||
|
std::println("msg2.bytes = <{}>", msg2.byteRepr());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
185
tests/mcc_pcm_test.cpp
Normal file
185
tests/mcc_pcm_test.cpp
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
#include <print>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
|
|
||||||
|
#include <mcc/mcc_pcm_construct.h>
|
||||||
|
#include <mcc/mcc_pcm_fit.h>
|
||||||
|
|
||||||
|
struct pcm_res_t {
|
||||||
|
double pcmX, pcmY;
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr mcc::MccMountType MOUNT_TYPE{mcc::MccMountType::FORK_TYPE};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using pcm_t = mcc::impl::MccDefaultPCM<MOUNT_TYPE>;
|
||||||
|
using pcm_const_t = mcc::impl::MccPCMConstructor<MOUNT_TYPE>;
|
||||||
|
using pcm_fit_t = mcc::impl::MccPCMFitter<MOUNT_TYPE>;
|
||||||
|
|
||||||
|
pcm_t pcm;
|
||||||
|
pcm_const_t pcm_const;
|
||||||
|
pcm_fit_t pcm_fitter;
|
||||||
|
|
||||||
|
pcm_t::pcm_data_t pcm_data{.type = mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY,
|
||||||
|
.siteLatitude = 43.6466666667_degs,
|
||||||
|
// .geomCoefficients = {.zeroPointX = 2.434534_degs,
|
||||||
|
// .zeroPointY = -3.382549_degs,
|
||||||
|
.geomCoefficients = {.zeroPointX = 2.434534_arcsecs,
|
||||||
|
.zeroPointY = -3.382549_arcsecs,
|
||||||
|
.collimationErr = 10.534_arcsecs,
|
||||||
|
.nonperpendErr = 21.86834_arcsecs,
|
||||||
|
.misalignErr1 = 7.345768_arcsecs,
|
||||||
|
.misalignErr2 = -12.87934_arcsecs,
|
||||||
|
.tubeFlexure = 5.9083_arcsecs,
|
||||||
|
.DECaxisFlexure = 3.48379812_arcsecs,
|
||||||
|
.forkFlexure = 9.342354_arcsecs}};
|
||||||
|
|
||||||
|
|
||||||
|
size_t haM = 10; // number of B-spline inner knots along HA-axis
|
||||||
|
size_t decM = 10; // number of B-spline inner knots along DEC-axis
|
||||||
|
|
||||||
|
double ha_step = 360.0_degs / (haM - 1);
|
||||||
|
pcm_data.bspline.knotsX.resize(haM);
|
||||||
|
// for (size_t i = 0; i < haM; ++i) { // [0, 360]
|
||||||
|
// pcm_data.bspline.knotsX[i] = i * ha_step;
|
||||||
|
// }
|
||||||
|
for (size_t i = 0; i < haM; ++i) { // [-180, 180]
|
||||||
|
pcm_data.bspline.knotsX[i] = i * ha_step - std::numbers::pi;
|
||||||
|
}
|
||||||
|
|
||||||
|
double dec_start = -35.0_degs;
|
||||||
|
double dec_step = (90.0_degs - dec_start) / (decM - 1);
|
||||||
|
pcm_data.bspline.knotsY.resize(decM);
|
||||||
|
for (size_t i = 0; i < decM; ++i) {
|
||||||
|
pcm_data.bspline.knotsY[i] = dec_start + i * dec_step;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pcm.setPCMData(pcm_data);
|
||||||
|
|
||||||
|
|
||||||
|
size_t N = 100; // number of measurements
|
||||||
|
|
||||||
|
std::vector<mcc::impl::MccAngle> encX(N), encY(N), ha(N), dec(N), pcmX(N), pcmY(N);
|
||||||
|
std::vector<mcc::impl::MccAngle> resX(N), resY(N);
|
||||||
|
pcm_res_t pcm_res;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
auto comp_hadec = [&]() {
|
||||||
|
mcc::impl::MccSkyPoint hadec;
|
||||||
|
for (size_t i = 0; i < N; ++i) {
|
||||||
|
auto err = pcm.computePCM(mcc::impl::MccGenXY{(double)encX[i], (double)encY[i]}, &pcm_res, &hadec);
|
||||||
|
if (err) {
|
||||||
|
std::println("Error in PCM computing: {}", err.message());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pcmX[i] = pcm_res.pcmX;
|
||||||
|
pcmY[i] = pcm_res.pcmY;
|
||||||
|
|
||||||
|
ha[i] = hadec.co_lon();
|
||||||
|
dec[i] = hadec.co_lat();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
double start_encX = 1.2423_degs, stop_encX = 354.896124_degs;
|
||||||
|
double start_encY = -32.2423_degs, stop_encY = 84.896124_degs;
|
||||||
|
|
||||||
|
double x_step = (stop_encX - start_encX) / (N - 1), y_step = (stop_encY - start_encY) / (N - 1);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < N; ++i) {
|
||||||
|
encX[i] = start_encX + i * x_step;
|
||||||
|
encY[i] = start_encY + i * y_step;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
comp_hadec();
|
||||||
|
|
||||||
|
std::println("X Y HA DEC (pcmX pcmY):");
|
||||||
|
for (size_t i = 0; i < N; ++i) {
|
||||||
|
std::println("{:12.7f} {:12.7f} {:12.7f} {:12.7f} ({:10.7f} {:10.7f})", encX[i].degrees(), encY[i].degrees(),
|
||||||
|
ha[i].degrees(), dec[i].degrees(), pcmX[i].degrees(), pcmY[i].degrees());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// add 'noise'
|
||||||
|
// double sigma = 24.3248792_arcsecs / 2.355;
|
||||||
|
double sigma = 4.3248792_arcsecs;
|
||||||
|
|
||||||
|
std::random_device rd{};
|
||||||
|
std::mt19937 gen{rd()};
|
||||||
|
std::normal_distribution dist{0.0, sigma};
|
||||||
|
|
||||||
|
mcc::impl::MccSkyPoint hadec;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < N; ++i) {
|
||||||
|
ha[i] += dist(gen);
|
||||||
|
dec[i] += dist(gen);
|
||||||
|
|
||||||
|
resX[i] = ha[i] - encX[i];
|
||||||
|
resY[i] = dec[i] - encY[i];
|
||||||
|
|
||||||
|
// hadec.from(mcc::impl::MccSkyHADEC_OBS{(double)ha[i], (double)dec[i]});
|
||||||
|
|
||||||
|
// pcm_const.addPoint(hadec, mcc::impl::MccGenXY{(double)encX[i], (double)encY[i]});
|
||||||
|
|
||||||
|
pcm_fitter.addPoint((double)ha[i], (double)dec[i], (double)encX[i], (double)encY[i],
|
||||||
|
mcc::impl::MccCelestialCoordEpoch{});
|
||||||
|
}
|
||||||
|
|
||||||
|
pcm_t::pcm_data_t fit_pcm_data{.type = pcm_data.type, .siteLatitude = pcm_data.siteLatitude};
|
||||||
|
|
||||||
|
// auto r = pcm_const.computeModel(fit_pcm_data);
|
||||||
|
auto r = pcm_fitter.computeModel(fit_pcm_data);
|
||||||
|
if (r.error) {
|
||||||
|
std::println("error: {}", r.error.message());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::println("FITTED STATUS:");
|
||||||
|
std::println("\tNUM OF ITERS: {}", r.final_iter);
|
||||||
|
|
||||||
|
std::println("FITTED COEFFS:");
|
||||||
|
std::println("X0 = {} ({}), Y0 = {} ({})", mcc::impl::MccAngleFancyString(fit_pcm_data.geomCoefficients.zeroPointX),
|
||||||
|
mcc::impl::MccAngleFancyString(pcm_data.geomCoefficients.zeroPointX),
|
||||||
|
mcc::impl::MccAngleFancyString(fit_pcm_data.geomCoefficients.zeroPointY),
|
||||||
|
mcc::impl::MccAngleFancyString(pcm_data.geomCoefficients.zeroPointY));
|
||||||
|
|
||||||
|
// std::println("X0 = {} ({}), Y0 = {} ({})",
|
||||||
|
// mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.zeroPointX).degrees(),
|
||||||
|
// mcc::impl::MccAngle(pcm_data.geomCoefficients.zeroPointX).degrees(),
|
||||||
|
// mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.zeroPointY).degrees(),
|
||||||
|
// mcc::impl::MccAngle(pcm_data.geomCoefficients.zeroPointY).degrees());
|
||||||
|
|
||||||
|
std::println("collimErr = {} ({})", mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.collimationErr).arcsecs(),
|
||||||
|
mcc::impl::MccAngle(pcm_data.geomCoefficients.collimationErr).arcsecs());
|
||||||
|
|
||||||
|
std::println("nonperpErr = {} ({})", mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.nonperpendErr).arcsecs(),
|
||||||
|
mcc::impl::MccAngle(pcm_data.geomCoefficients.nonperpendErr).arcsecs());
|
||||||
|
|
||||||
|
std::println("misalignErr1 = {} ({}), misalignErr2 = {} ({})",
|
||||||
|
mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.misalignErr1).arcsecs(),
|
||||||
|
mcc::impl::MccAngle(pcm_data.geomCoefficients.misalignErr1).arcsecs(),
|
||||||
|
mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.misalignErr2).arcsecs(),
|
||||||
|
mcc::impl::MccAngle(pcm_data.geomCoefficients.misalignErr2).arcsecs());
|
||||||
|
|
||||||
|
std::println("tubeflexErr = {} ({})", mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.tubeFlexure).arcsecs(),
|
||||||
|
mcc::impl::MccAngle(pcm_data.geomCoefficients.tubeFlexure).arcsecs());
|
||||||
|
|
||||||
|
std::println("DECaxflexErr = {} ({})", mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.DECaxisFlexure).arcsecs(),
|
||||||
|
mcc::impl::MccAngle(pcm_data.geomCoefficients.DECaxisFlexure).arcsecs());
|
||||||
|
|
||||||
|
std::println("forkflexErr = {} ({})", mcc::impl::MccAngle(fit_pcm_data.geomCoefficients.forkFlexure).arcsecs(),
|
||||||
|
mcc::impl::MccAngle(pcm_data.geomCoefficients.forkFlexure).arcsecs());
|
||||||
|
|
||||||
|
|
||||||
|
// std::println("\n\n{}", r.colon_res);
|
||||||
|
// std::println("\n\n{}", r.colat_res);
|
||||||
|
std::println("\n\n{}", r.model_colonRES);
|
||||||
|
std::println("\n\n{}", r.model_colatRES);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
177
tests/mcc_pcm_z1000_test.cpp
Normal file
177
tests/mcc_pcm_z1000_test.cpp
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
#include <fstream>
|
||||||
|
#include <print>
|
||||||
|
|
||||||
|
#include <mcc/mcc_pcm_construct.h>
|
||||||
|
#include <mcc/mcc_pcm_fit.h>
|
||||||
|
|
||||||
|
static constexpr mcc::MccMountType MOUNT_TYPE{mcc::MccMountType::CROSSAXIS_TYPE};
|
||||||
|
|
||||||
|
using namespace mcc::impl;
|
||||||
|
|
||||||
|
int main(int narg, char* argv[])
|
||||||
|
{
|
||||||
|
MccPCMConstructor<MOUNT_TYPE> pcm_cstr;
|
||||||
|
mcc::impl::MccPCMFitter<MOUNT_TYPE> pcm_fitter;
|
||||||
|
|
||||||
|
// MccSkyPoint sp;
|
||||||
|
MccSkyHADEC_OBS hadec;
|
||||||
|
MccGenXY xy;
|
||||||
|
|
||||||
|
MccDefaultPCM<MOUNT_TYPE>::pcm_data_t fit_pcm_data;
|
||||||
|
|
||||||
|
size_t haM = 10; // number of B-spline inner knots along HA-axis
|
||||||
|
size_t decM = 10; // number of B-spline inner knots along DEC-axis
|
||||||
|
|
||||||
|
double ha_step = 360.0_degs / (haM - 1);
|
||||||
|
fit_pcm_data.bspline.knotsX.resize(haM);
|
||||||
|
for (size_t i = 0; i < haM; ++i) {
|
||||||
|
// fit_pcm_data.bspline.knotsX[i] = i * ha_step; // [0, 360]
|
||||||
|
fit_pcm_data.bspline.knotsX[i] = i * ha_step - std::numbers::pi; // [-180, 180]
|
||||||
|
}
|
||||||
|
|
||||||
|
double dec_start = -25.0_degs;
|
||||||
|
double dec_step = (90.0_degs - dec_start) / (decM - 1);
|
||||||
|
fit_pcm_data.bspline.knotsY.resize(decM);
|
||||||
|
for (size_t i = 0; i < decM; ++i) {
|
||||||
|
fit_pcm_data.bspline.knotsY[i] = dec_start + i * dec_step;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ifstream fst;
|
||||||
|
|
||||||
|
std::string fname = "z1000_pcm_measu.data";
|
||||||
|
|
||||||
|
if (narg > 1) {
|
||||||
|
fname = argv[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fst.open(fname);
|
||||||
|
if (!fst.is_open()) {
|
||||||
|
std::println("Cannot open file {}", fname);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
double x, y, diff_x, diff_y, tag_ha, tag_dec;
|
||||||
|
|
||||||
|
std::println("READ DATA:");
|
||||||
|
|
||||||
|
MccCelestialCoordEpoch ep = MccCelestialCoordEpoch::now();
|
||||||
|
|
||||||
|
size_t i = 0;
|
||||||
|
while (!fst.eof()) {
|
||||||
|
// x - degs, y -degs, diff_x - arcsecs, diff_y - arcsecs
|
||||||
|
fst >> x >> y >> diff_x >> diff_y;
|
||||||
|
|
||||||
|
// std::println("\t{}\t{:10.6f} {:10.6f} {:8.6f} {:8.6f}", i++, x, y, diff_x, diff_y);
|
||||||
|
std::print("\t{}\t{:10.6f} {:10.6f} {:8.6f} {:8.6f}", i++, x, y, diff_x, diff_y);
|
||||||
|
|
||||||
|
tag_ha = x + diff_x / 3600.0;
|
||||||
|
tag_dec = y + diff_y / 3600.0;
|
||||||
|
|
||||||
|
hadec = MccSkyHADEC_OBS{MccAngleHA_OBS(tag_ha, mcc_degrees), MccAngleDEC_OBS(tag_dec, mcc_degrees), ep};
|
||||||
|
// sp.from(hadec);
|
||||||
|
|
||||||
|
xy = MccGenXY(MccAngleX(x, mcc_degrees), MccAngleY(y, mcc_degrees), ep);
|
||||||
|
|
||||||
|
std::println("\t[encX = {:10.6f} encY = {:10.6f} HA = {} DEC = {}]", xy.x().degrees(), xy.y().degrees(),
|
||||||
|
hadec.x().sexagesimal(true), hadec.y().sexagesimal());
|
||||||
|
|
||||||
|
// pcm_cstr.addPoint(sp, xy);
|
||||||
|
pcm_cstr.addPoint(hadec, xy);
|
||||||
|
|
||||||
|
pcm_fitter.addPoint(hadec, xy);
|
||||||
|
}
|
||||||
|
|
||||||
|
fst.close();
|
||||||
|
|
||||||
|
auto r = pcm_cstr.computeModel(fit_pcm_data);
|
||||||
|
auto fr = pcm_fitter.computeModel(fit_pcm_data);
|
||||||
|
|
||||||
|
// if (r.error) {
|
||||||
|
// std::println("error: {}", r.error.message());
|
||||||
|
// return 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (fr.error) {
|
||||||
|
std::println("error: {}", fr.error.message());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::println("\n\n{:*^40}\n", " FITTED RESULT (TYPE = GEOMETRY) ");
|
||||||
|
// std::println("\tNUM OF ITERS: {}", r.final_iter);
|
||||||
|
std::println("\tNUM OF ITERS: {}", fr.final_iter);
|
||||||
|
|
||||||
|
std::println("FITTED COEFFS:");
|
||||||
|
std::println("X0 = {}, Y0 = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.zeroPointX),
|
||||||
|
MccAngleFancyString(fit_pcm_data.geomCoefficients.zeroPointY));
|
||||||
|
|
||||||
|
std::println("collimErr = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.collimationErr));
|
||||||
|
std::println("nonperpErr = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.nonperpendErr));
|
||||||
|
std::println("misalignErr1 = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.misalignErr1));
|
||||||
|
std::println("misalignErr2 = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.misalignErr2));
|
||||||
|
std::println("tubeflexErr = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.tubeFlexure));
|
||||||
|
std::println("DECaxflexErr = {}", MccAngleFancyString(fit_pcm_data.geomCoefficients.DECaxisFlexure));
|
||||||
|
|
||||||
|
std::println("\n\n{:*^40}\n", " FITTED DIFFS ");
|
||||||
|
auto tab = pcm_cstr.getTable();
|
||||||
|
// for (size_t i = 0; i < pcm_cstr.numberOfPoints(); ++i) {
|
||||||
|
// std::println("{} {} {} {:6.2f}% ({:5.3f}) {} {} {:6.2f}% ({:5.3f}) (HA = {} DEC = {})", i,
|
||||||
|
// MccAngleFancyString(tab.colon_res[i]), MccAngleFancyString(r.model_colon[i]),
|
||||||
|
// std::abs((tab.colon_res[i] - r.model_colon[i]) / tab.colon_res[i]) * 100.0, r.colon_weight[i],
|
||||||
|
// MccAngleFancyString(tab.colat_res[i]), MccAngleFancyString(r.model_colat[i]),
|
||||||
|
// std::abs((tab.colat_res[i] - r.model_colat[i]) / tab.colat_res[i]) * 100.0, r.colat_weight[i],
|
||||||
|
// MccAngle(tab.hw_colon[i]).sexagesimal(true), MccAngle(tab.hw_colat[i]).sexagesimal());
|
||||||
|
// }
|
||||||
|
|
||||||
|
auto pcm_tab = pcm_fitter.getPCMTable();
|
||||||
|
for (size_t i = 0; i < pcm_fitter.numberOfPoints(); ++i) {
|
||||||
|
std::println("{} {} {} {:6.2f}% ({:5.3f}) {} {} {:6.2f}% ({:5.3f}) (HA = {} DEC = {})", i,
|
||||||
|
MccAngleFancyString(pcm_tab[i].res.x()), MccAngleFancyString(fr.model_colonRES[i]),
|
||||||
|
std::abs(fr.colon_err[i]) / pcm_tab[i].res.x() * 100.0, fr.colon_weight[i],
|
||||||
|
MccAngleFancyString(pcm_tab[i].res.y()), MccAngleFancyString(fr.model_colatRES[i]),
|
||||||
|
std::abs(fr.colat_err[i]) / pcm_tab[i].res.y() * 100.0, fr.colat_weight[i],
|
||||||
|
pcm_tab[i].hw.x().sexagesimal(true), pcm_tab[i].hw.y().sexagesimal());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::println("\n\n{:*^40}\n", " FITTED RESULT (TYPE = BSPLINE) ");
|
||||||
|
|
||||||
|
fit_pcm_data.type = MccDefaultPCMType::PCM_TYPE_BSPLINE;
|
||||||
|
|
||||||
|
// r = pcm_cstr.computeModel(fit_pcm_data);
|
||||||
|
fr = pcm_fitter.computeModel(fit_pcm_data);
|
||||||
|
|
||||||
|
// if (r.error) {
|
||||||
|
// std::println("error: {}", r.error.message());
|
||||||
|
// std::println("b-spline error: {}", r.bspline_fit_err);
|
||||||
|
// return 1;
|
||||||
|
// }
|
||||||
|
if (fr.error) {
|
||||||
|
std::println("error: {}", fr.error.message());
|
||||||
|
std::println("b-spline error: {}", fr.bspline_fit_err);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
std::println("b-spline fit exit code: {}", fr.bspline_fit_err);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::println("\n\n{:*^40}\n", " FITTED DIFFS ");
|
||||||
|
// for (size_t i = 0; i < pcm_cstr.numberOfPoints(); ++i) {
|
||||||
|
// std::println("{} {} {} {:6.2f}% {} {} {:6.2f}% (HA = {} DEC = {})", i,
|
||||||
|
// MccAngleFancyString(tab.colon_res[i]), MccAngleFancyString(r.model_colon[i]),
|
||||||
|
// std::abs((tab.colon_res[i] - r.model_colon[i]) / tab.colon_res[i]) * 100.0,
|
||||||
|
// MccAngleFancyString(tab.colat_res[i]), MccAngleFancyString(r.model_colat[i]),
|
||||||
|
// std::abs((tab.colat_res[i] - r.model_colat[i]) / tab.colat_res[i]) * 100.0,
|
||||||
|
// MccAngle(tab.hw_colon[i]).sexagesimal(true), MccAngle(tab.hw_colat[i]).sexagesimal());
|
||||||
|
// }
|
||||||
|
|
||||||
|
for (size_t i = 0; i < pcm_fitter.numberOfPoints(); ++i) {
|
||||||
|
std::println("{} {} {} {:6.2f}% {} {} {:6.2f}% (HA = {} DEC = {})", i,
|
||||||
|
MccAngleFancyString(pcm_tab[i].res.x()), MccAngleFancyString(fr.model_colonRES[i]),
|
||||||
|
std::abs(fr.colon_err[i]) / pcm_tab[i].res.x() * 100.0, MccAngleFancyString(pcm_tab[i].res.y()),
|
||||||
|
MccAngleFancyString(fr.model_colatRES[i]), std::abs(fr.colat_err[i]) / pcm_tab[i].res.y() * 100.0,
|
||||||
|
pcm_tab[i].hw.x().sexagesimal(true), pcm_tab[i].hw.y().sexagesimal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <mcc_coordinate.h>
|
#include <mcc/mcc_coordinate.h>
|
||||||
#include <mcc_pzone.h>
|
#include <mcc/mcc_pzone.h>
|
||||||
#include <mcc_pzone_container.h>
|
#include <mcc/mcc_pzone_container.h>
|
||||||
|
|
||||||
using namespace mcc::impl;
|
using namespace mcc::impl;
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#include <mcc_pcm.h>
|
#include <mcc/mcc_pcm.h>
|
||||||
#include <mcc_telemetry.h>
|
#include <mcc/mcc_serializer.h>
|
||||||
|
#include <mcc/mcc_telemetry.h>
|
||||||
|
|
||||||
static std::random_device rd;
|
static std::random_device rd;
|
||||||
static std::mt19937 gen(rd());
|
static std::mt19937 gen(rd());
|
||||||
@@ -14,7 +14,11 @@ static std::uniform_real_distribution<double> y_distrib(1000, 7000);
|
|||||||
static std::uniform_real_distribution<double> xs_distrib(100, 700);
|
static std::uniform_real_distribution<double> xs_distrib(100, 700);
|
||||||
static std::uniform_real_distribution<double> ys_distrib(100, 700);
|
static std::uniform_real_distribution<double> ys_distrib(100, 700);
|
||||||
|
|
||||||
|
static std::uniform_int_distribution<uint8_t> err_distrib(0, 255);
|
||||||
|
|
||||||
|
|
||||||
struct hw_t {
|
struct hw_t {
|
||||||
|
static constexpr mcc::MccMountType hwMountType{mcc::MccMountType::ALTAZ_TYPE};
|
||||||
static constexpr std::string_view hardwareName{"HW-TEST"};
|
static constexpr std::string_view hardwareName{"HW-TEST"};
|
||||||
|
|
||||||
typedef int error_t;
|
typedef int error_t;
|
||||||
@@ -52,15 +56,47 @@ struct hw_t {
|
|||||||
|
|
||||||
*state = hardware_state_t{.XY{x_distrib(gen), y_distrib(gen)}, .speedXY{xs_distrib(gen), ys_distrib(gen)}};
|
*state = hardware_state_t{.XY{x_distrib(gen), y_distrib(gen)}, .speedXY{xs_distrib(gen), ys_distrib(gen)}};
|
||||||
|
|
||||||
return 0;
|
// return 0;
|
||||||
|
return err_distrib(gen) < 5 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_t hardwareInit()
|
error_t hardwareInit()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_t hardwareShutdown()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct std::formatter<hw_t::hardware_movement_state_t, char> : std::formatter<std::string_view> {
|
||||||
|
auto format(hw_t::hardware_movement_state_t e, auto& ctx) const
|
||||||
|
{
|
||||||
|
return formatter<std::string_view>::format(e == hw_t::hardware_movement_state_t::HW_MOVE_ERROR ? "ERROR"
|
||||||
|
: e == hw_t::hardware_movement_state_t::HW_MOVE_STOPPED ? "STOPPED"
|
||||||
|
: e == hw_t::hardware_movement_state_t::HW_MOVE_STOPPING ? "STOPPING"
|
||||||
|
: e == hw_t::hardware_movement_state_t::HW_MOVE_SLEWING ? "SLEWING"
|
||||||
|
: e == hw_t::hardware_movement_state_t::HW_MOVE_TRACKING ? "TRACKING"
|
||||||
|
: "UNKNOWN",
|
||||||
|
ctx);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// template <>
|
||||||
|
// struct std::formatter<hw_t::hardware_movement_state_t, char>
|
||||||
|
// : std::formatter<std::underlying_type_t<hw_t::hardware_movement_state_t>, char> {
|
||||||
|
// auto format(hw_t::hardware_movement_state_t e, auto& ctx) const
|
||||||
|
// {
|
||||||
|
// return formatter<std::underlying_type_t<hw_t::hardware_movement_state_t>>::format(
|
||||||
|
// std::underlying_type_t<hw_t::hardware_movement_state_t>(e), ctx);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static_assert(mcc::mcc_hardware_c<hw_t>, "!!!!!");
|
static_assert(mcc::mcc_hardware_c<hw_t>, "!!!!!");
|
||||||
|
|
||||||
@@ -86,5 +122,18 @@ int main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mcc::impl::MccSerializer<typename t_t::telemetry_data_t> ser;
|
||||||
|
|
||||||
|
std::string str;
|
||||||
|
|
||||||
|
auto err = ser(str, tdata);
|
||||||
|
if (err) {
|
||||||
|
std::cout << "ERR: " << err.message() << "\n";
|
||||||
|
} else {
|
||||||
|
std::cout << "\n\n";
|
||||||
|
std::cout << str << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
140
tests/z1000_pcm_measu.data
Normal file
140
tests/z1000_pcm_measu.data
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
1.520984700000000078e+00 1.232847220000000021e+01 1.402137262519520178e+01 1.397878249028015496e+01
|
||||||
|
1.567091000000000012e+00 1.232847220000000021e+01 1.424221519655054280e+01 1.437419514622014383e+01
|
||||||
|
6.264433299999999427e+00 -1.137611109999999925e+01 1.609993788111976443e+01 2.083793765095746053e+01
|
||||||
|
6.310283200000000647e+00 -1.137611109999999925e+01 1.600192960162873845e+01 2.076926873683415309e+01
|
||||||
|
1.320332130000000070e+01 -2.892950000000000088e+01 2.286358732164985597e+01 2.038207784249622989e+01
|
||||||
|
1.324478129999999965e+01 -2.892950000000000088e+01 2.248315269968074404e+01 2.051349697694966778e+01
|
||||||
|
1.005094109999999930e+01 2.557805600000000013e+00 1.345883399999999952e+01 1.297186102799999929e+01
|
||||||
|
1.009740339999999925e+01 2.557805600000000013e+00 1.326531023999999981e+01 1.318907880000000077e+01
|
||||||
|
1.819215270000000118e+01 -1.671441670000000101e+01 1.757270074759864187e+01 2.073781269238157776e+01
|
||||||
|
1.823382970000000114e+01 -1.671441670000000101e+01 1.719913032287585608e+01 2.159752316061812039e+01
|
||||||
|
9.454526500000000055e+00 2.196961110000000161e+01 1.482182478753721178e+01 1.522155672575341079e+01
|
||||||
|
9.504631399999999175e+00 2.196961110000000161e+01 1.482390743949157219e+01 1.546582945276367305e+01
|
||||||
|
2.858336930000000109e+01 -3.186847219999999936e+01 1.815660005051495318e+01 1.896053456618076893e+01
|
||||||
|
2.862927249999999901e+01 -3.186847219999999936e+01 1.850526919508024193e+01 1.859472000360627675e+01
|
||||||
|
2.080040939999999949e+01 -3.467750000000000110e+00 1.427837004000000043e+01 1.049487843600000048e+01
|
||||||
|
2.084243520000000061e+01 -3.467750000000000110e+00 1.392372287999999969e+01 1.070905834799999923e+01
|
||||||
|
3.178236109999999925e+01 -1.952702779999999905e+01 2.167696316880000040e+01 7.249305960000000049e+00
|
||||||
|
3.182417189999999962e+01 -1.952702779999999905e+01 2.107618156799999909e+01 7.154861040000000116e+00
|
||||||
|
2.025673900000000316e+01 1.231291670000000060e+01 1.436658588000000059e+01 1.183834008000000004e+01
|
||||||
|
2.030284879999999958e+01 1.231291670000000060e+01 1.484159112000000036e+01 1.183364388000000034e+01
|
||||||
|
3.314437089999999841e+01 -6.282416699999999743e+00 2.048238615196899914e+01 7.555537013118320822e+00
|
||||||
|
3.318626649999999501e+01 -6.282416699999999743e+00 2.031546532784667392e+01 7.571803502585704670e+00
|
||||||
|
8.174148100000000028e+00 3.654522219999999777e+01 1.639438091999999969e+01 1.128399083999999952e+01
|
||||||
|
8.216073199999998522e+00 3.654522219999999777e+01 1.619869643999999909e+01 1.116389412000000014e+01
|
||||||
|
4.632874819999999971e+01 -1.946261110000000016e+01 1.886964740984793565e+01 1.896071441598940766e+01
|
||||||
|
4.637499929999999893e+01 -1.946261110000000016e+01 1.901053297014212262e+01 1.879686615692279261e+01
|
||||||
|
3.209061599999999714e+01 7.740944400000000059e+00 1.394660492906758975e+01 1.057056646642546838e+01
|
||||||
|
3.213633280000000525e+01 7.740944400000000059e+00 1.454147081652134155e+01 1.048048837084878748e+01
|
||||||
|
4.606433260000000018e+01 -6.610166699999999729e+00 2.024269522053099024e+01 7.028883369354944399e+00
|
||||||
|
4.610631639999999720e+01 -6.610166699999999729e+00 2.008559742574616891e+01 7.285131484084857334e+00
|
||||||
|
2.557915640000000224e+01 2.401413889999999896e+01 2.206382168907072838e+01 3.091156579791847037e+01
|
||||||
|
2.562517580000000095e+01 2.401413889999999896e+01 2.185121724273789923e+01 3.089656382159016701e+01
|
||||||
|
4.441593019999999825e+01 6.551638900000000376e+00 2.138349297490188761e+01 7.594698645765957323e+00
|
||||||
|
4.446164799999999673e+01 6.551638900000000376e+00 2.124548303456616338e+01 7.418561932720165508e+00
|
||||||
|
5.938992389999999943e+01 -4.837027800000000433e+00 2.579655702151784524e+01 1.373940562244154151e+01
|
||||||
|
5.943173099999999920e+01 -4.837027800000000433e+00 2.481252225932640698e+01 1.363269486445296153e+01
|
||||||
|
3.922132889999999605e+01 2.050424999999999898e+01 1.569271679999999947e+01 1.195416540000000083e+01
|
||||||
|
3.926743869999999959e+01 2.050424999999999898e+01 1.624694759999999860e+01 1.218877991999999999e+01
|
||||||
|
5.713390349999999529e+01 8.016138899999999623e+00 2.168379360000000133e+01 6.897207132000000129e+00
|
||||||
|
5.717997259999999926e+01 8.016138899999999623e+00 2.087569799999999987e+01 6.670144224000000399e+00
|
||||||
|
2.315225480000000147e+01 3.622719440000000191e+01 1.595990555999999927e+01 1.805808528000000024e+01
|
||||||
|
2.319800610000000063e+01 3.622719440000000191e+01 1.597561235999999951e+01 1.796384700000000123e+01
|
||||||
|
7.287439289999998948e+01 -1.305166700000000013e+00 2.576865240000000057e+01 1.750716986400000152e+01
|
||||||
|
7.292050640000000783e+01 -1.305166700000000013e+00 2.601736560000000154e+01 1.740492781200000039e+01
|
||||||
|
5.241497720000000271e+01 2.105997220000000070e+01 1.449506880000000031e+01 2.160073476000000170e+01
|
||||||
|
5.246108759999999904e+01 2.105997220000000070e+01 1.456931520000000013e+01 2.150408664000000059e+01
|
||||||
|
7.017244069999999567e+01 1.134838889999999978e+01 2.463619680000000045e+01 6.664804199999999845e+00
|
||||||
|
7.021428889999999967e+01 1.134838889999999978e+01 2.494610279999999847e+01 7.221205079999999832e+00
|
||||||
|
4.148476039999999898e+01 3.390825000000000244e+01 1.546144920000000056e+01 1.949037948000000142e+01
|
||||||
|
4.152660319999999672e+01 3.390825000000000244e+01 1.542145320000000019e+01 1.942556112000000113e+01
|
||||||
|
6.571000529999999173e+01 2.375494439999999940e+01 2.398345559999999921e+01 9.226117079999999859e+00
|
||||||
|
6.575224749999999574e+01 2.375494439999999940e+01 2.429307359999999960e+01 9.506921399999999522e+00
|
||||||
|
8.313718609999999387e+01 1.553819440000000007e+01 2.553773400000000038e+01 5.589535320000000418e+00
|
||||||
|
8.317920920000000251e+01 1.553819440000000007e+01 2.566232640000000131e+01 5.497365959999999774e+00
|
||||||
|
5.664400189999999924e+01 3.583738890000000055e+01 1.499639400000000045e+01 1.867782131999999962e+01
|
||||||
|
5.668571370000000087e+01 3.583738890000000055e+01 1.540229760000000070e+01 1.859227848000000094e+01
|
||||||
|
7.922477899999999806e+01 2.799013890000000160e+01 2.362876560000000126e+01 6.580477799999999711e+00
|
||||||
|
7.926706470000000593e+01 2.799013890000000160e+01 2.353645799999999966e+01 6.421130640000000334e+00
|
||||||
|
3.602889239999999660e+01 4.569222220000000334e+01 1.798344795599999912e+01 1.992703824000000168e+01
|
||||||
|
3.607534499999999866e+01 4.569222220000000334e+01 1.757011147200000067e+01 1.963801223999999834e+01
|
||||||
|
7.167516279999999540e+01 3.981491669999999772e+01 2.730168000000000106e+01 4.396943160000000184e+00
|
||||||
|
7.172162199999999643e+01 3.981491669999999772e+01 2.758881600000000134e+01 4.321002960000000392e+00
|
||||||
|
9.365174939999999992e+01 3.263280559999999753e+01 2.346876719999999850e+01 3.615082919999999866e+00
|
||||||
|
9.369333170000000166e+01 3.263280559999999753e+01 2.361300479999999880e+01 3.798333720000000024e+00
|
||||||
|
5.527943479999999710e+01 4.997355559999999741e+01 1.764283680000000132e+01 1.635428664000000154e+01
|
||||||
|
5.532101030000000463e+01 4.997355559999999741e+01 1.794565079999999924e+01 1.647901475999999832e+01
|
||||||
|
8.746503839999999741e+01 4.482541669999999812e+01 2.703027600000000064e+01 4.956216480000000146e+00
|
||||||
|
8.750675139999999885e+01 4.482541669999999812e+01 2.728551960000000065e+01 5.177633039999999909e+00
|
||||||
|
1.836906730000000110e+01 5.078408329999999893e+01 1.513158156000000076e+01 1.963362311999999932e+01
|
||||||
|
1.841507449999999935e+01 5.078408329999999893e+01 1.555693991999999959e+01 1.961264051999999936e+01
|
||||||
|
1.098856539000000083e+02 3.701522219999999663e+01 2.812074120000000121e+01 8.143354439999999528e+00
|
||||||
|
1.099319399000000033e+02 3.701522219999999663e+01 2.774962800000000129e+01 8.819404920000000203e+00
|
||||||
|
7.370027499999999065e+01 5.570875000000000199e+01 1.911301560000000066e+01 1.426220711999999935e+01
|
||||||
|
7.374202760000000012e+01 5.570875000000000199e+01 1.958580359999999843e+01 1.418687820000000066e+01
|
||||||
|
1.054113698000000028e+02 4.963983329999999938e+01 2.650104359999999915e+01 3.480223679999999931e+00
|
||||||
|
1.054574365000000000e+02 4.963983329999999938e+01 2.563602840000000072e+01 3.547053360000000044e+00
|
||||||
|
4.287370680000000078e+01 6.094122219999999857e+01 1.950798104640000119e+01 1.674774251999999919e+01
|
||||||
|
4.291527359999999902e+01 6.094122219999999857e+01 1.944132720480000032e+01 1.652185980000000143e+01
|
||||||
|
9.504052040000000545e+01 6.157588890000000248e+01 2.899145160000000132e+01 1.187110224000000080e+01
|
||||||
|
9.508667239999999765e+01 6.157588890000000248e+01 2.922239880000000056e+01 1.173974544000000009e+01
|
||||||
|
1.262694429999999954e+02 5.295780560000000037e+01 2.512014479999999850e+01 5.389958880000000008e+00
|
||||||
|
1.263113367999999923e+02 5.295780560000000037e+01 2.474463959999999929e+01 5.645870279999999575e+00
|
||||||
|
6.514408500000000402e+01 7.005941669999999988e+01 2.277777599999999936e+01 1.499814287999999962e+01
|
||||||
|
6.518613349999999684e+01 7.005941669999999988e+01 2.273392079999999993e+01 1.499271264000000059e+01
|
||||||
|
1.229067255999999873e+02 6.578094439999999565e+01 2.971857960000000176e+01 4.189588200000000207e+00
|
||||||
|
1.699135779999999940e+01 6.312358329999999995e+01 1.640872511999999972e+01 1.090696175999999973e+01
|
||||||
|
1.703309279999999859e+01 6.312358329999999995e+01 1.615176684000000051e+01 1.092368160000000010e+01
|
||||||
|
1.495277770000000146e+02 5.364572220000000158e+01 2.561597640000000098e+01 9.143114759999999563e+00
|
||||||
|
1.495777611000000036e+02 5.364572220000000158e+01 2.615466239999999942e+01 9.095307840000000255e+00
|
||||||
|
1.496408456999999999e+02 5.364572220000000158e+01 2.569897800000000032e+01 9.134006039999999160e+00
|
||||||
|
1.496825650000000110e+02 5.364572220000000158e+01 2.538529559999999918e+01 9.201327479999999781e+00
|
||||||
|
1.554850708999999824e+02 6.604155559999999525e+01 1.374083279999999974e+01 1.656775620000000160e+01
|
||||||
|
2.097634289999999879e+01 7.733791669999999385e+01 3.654347508000000033e+01 1.654487531999999916e+01
|
||||||
|
2.102212970000000070e+01 7.733791669999999385e+01 3.636662867999999804e+01 1.636760591999999903e+01
|
||||||
|
2.277917999999999887e-01 4.876380559999999775e+01 1.549041624000000006e+01 2.101689756000000031e+01
|
||||||
|
2.698421999999999765e-01 4.876380559999999775e+01 1.567145015999999913e+01 2.112695172000000099e+01
|
||||||
|
3.437143795000000068e+02 6.973677779999999871e+01 2.734230528000000149e+01 1.563275916000000088e+01
|
||||||
|
3.437643578999999932e+02 6.973677779999999871e+01 2.747603627999999887e+01 1.552329648000000084e+01
|
||||||
|
3.428005334000000062e+02 5.725041670000000238e+01 1.862290619999999919e+01 2.019176136000000099e+01
|
||||||
|
3.428463540000000194e+02 5.725041670000000238e+01 1.902524400000000071e+01 1.999220255999999907e+01
|
||||||
|
3.132811045999999919e+02 5.910019439999999946e+01 1.386552672000000008e+01 2.278168667999999997e+01
|
||||||
|
3.133275363999999854e+02 5.910019439999999946e+01 1.297295568000000010e+01 2.274937272000000021e+01
|
||||||
|
2.965399057000000198e+02 5.068380559999999946e+01 1.367059320000000078e+01 1.617027119999999840e+01
|
||||||
|
2.965815953999999692e+02 5.068380559999999946e+01 1.380345480000000080e+01 1.598343335999999937e+01
|
||||||
|
3.257878496999999811e+02 4.907274999999999920e+01 1.085804279999999977e+01 1.542084984000000070e+01
|
||||||
|
3.258295864000000392e+02 4.907274999999999920e+01 1.075048776000000039e+01 1.556499203999999992e+01
|
||||||
|
2.902964226000000281e+02 3.914441670000000073e+01 1.082279879999999928e+01 1.847305116000000069e+01
|
||||||
|
2.903381570000000238e+02 3.914441670000000073e+01 1.094891400000000026e+01 1.845031463999999843e+01
|
||||||
|
2.749723357999999962e+02 2.495291669999999939e+01 9.267801453194630668e+00 2.204314769561360876e+01
|
||||||
|
2.750181547000000251e+02 2.495291669999999939e+01 9.561938187156854951e+00 2.212146414090760160e+01
|
||||||
|
3.104860874999999965e+02 4.047155560000000207e+01 2.503505160000000007e+00 2.629696320000000043e+01
|
||||||
|
3.105277801999999951e+02 4.047155560000000207e+01 2.478829680000000035e+00 2.638967832000000158e+01
|
||||||
|
2.893916831000000229e+02 2.652719439999999906e+01 7.161947999999999759e+00 2.132319744000000128e+01
|
||||||
|
2.894339892000000418e+02 2.652719439999999906e+01 7.297700400000000087e+00 2.116063008000000067e+01
|
||||||
|
3.442205288000000110e+02 4.347533330000000262e+01 1.224662507999999939e+01 2.312353152000000023e+01
|
||||||
|
3.442623588000000154e+02 4.347533330000000262e+01 1.267768799999999985e+01 2.312872199999999978e+01
|
||||||
|
3.051667480000000410e+02 2.895936109999999886e+01 6.215158800000000205e+00 1.870388495999999989e+01
|
||||||
|
3.052088808999999969e+02 2.895936109999999886e+01 5.764748400000000217e+00 1.910548547999999869e+01
|
||||||
|
2.911102161999999680e+02 1.363227780000000067e+01 9.305172000000000665e+00 2.179789488000000119e+01
|
||||||
|
2.911558619999999564e+02 1.363227780000000067e+01 9.093934799999999541e+00 2.161481724000000071e+01
|
||||||
|
3.243215236000000345e+02 3.372363889999999742e+01 7.080469199999999574e+00 2.694746879999999933e+01
|
||||||
|
3.243635280000000307e+02 3.372363889999999742e+01 7.326476640000000096e+00 2.712567239999999913e+01
|
||||||
|
3.046386173999999869e+02 1.638005559999999861e+01 6.457255199999999640e+00 2.061839772000000082e+01
|
||||||
|
3.046847496999999976e+02 1.638005559999999861e+01 6.420866400000000418e+00 2.073321108000000024e+01
|
||||||
|
3.193266790000000128e+02 2.156905559999999866e+01 5.235109200000000129e+00 2.829552083999999823e+01
|
||||||
|
3.193686405999999920e+02 2.156905559999999866e+01 5.254743600000000292e+00 2.829559031999999874e+01
|
||||||
|
3.388107006999999840e+02 3.196724999999999994e+01 1.399715531999999918e+01 2.574566423999999998e+01
|
||||||
|
3.388564878999999905e+02 3.196724999999999994e+01 1.397006387999999966e+01 2.558194991999999957e+01
|
||||||
|
3.198125034999999912e+02 9.226666700000000887e+00 9.206690399999999386e+00 1.879983248399999951e+01
|
||||||
|
3.198588174000000208e+02 9.226666700000000887e+00 8.986637520000000379e+00 1.901963516400000032e+01
|
||||||
|
3.332647567000000208e+02 1.820433329999999827e+01 1.270149407999999980e+01 2.713799159999999944e+01
|
||||||
|
3.333110732000000098e+02 1.820433329999999827e+01 1.282294367999999984e+01 2.709816479999999927e+01
|
||||||
|
3.348553427000000511e+02 5.763472199999999823e+00 1.454280083999999995e+01 2.613845635199999862e+01
|
||||||
|
3.349014428000000407e+02 5.763472199999999823e+00 1.437523739999999961e+01 2.595185341199999840e+01
|
||||||
|
3.464526741000000243e+02 1.971349999999999980e+01 1.390370039999999996e+01 2.627868923999999851e+01
|
||||||
|
3.464945554999999899e+02 1.971349999999999980e+01 1.411688015999999912e+01 2.608611155999999909e+01
|
||||||
|
3.492393445999999813e+02 6.771111099999999716e+00 1.530963359999999973e+01 2.449470556800000054e+01
|
||||||
|
3.492810100000000375e+02 6.771111099999999716e+00 1.541423123999999945e+01 2.451735334800000032e+01
|
||||||
|
3.487188694999999825e+02 -1.504255560000000003e+01 1.589037876000000082e+01 2.229864480000000171e+01
|
||||||
|
3.487647154000000000e+02 -1.504255560000000003e+01 1.546261739999999918e+01 2.259952668000000031e+01
|
||||||
5
tests/z1000_pcm_measu.data.desc
Normal file
5
tests/z1000_pcm_measu.data.desc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#
|
||||||
|
# SAO RAS Zeiss-1000 pointing precision measurements
|
||||||
|
#
|
||||||
|
# Format:
|
||||||
|
# ENCODER_HA(degs) ENCODER_DEC(degs) DIFF_HA(CELESTIAL-ENCODER, arcsecs) DIFF_DEC(CELESTIAL-ENCODER, arcsecs)
|
||||||
36
update_iers_data.sh
Executable file
36
update_iers_data.sh
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# $1 - output filename
|
||||||
|
#
|
||||||
|
|
||||||
|
if [[ $# -eq 0 ]]; then
|
||||||
|
res_file="mcc_ccte_iers_default.h"
|
||||||
|
else
|
||||||
|
res_file=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo -e '#pragma once\n
|
||||||
|
|
||||||
|
#include <string>\n
|
||||||
|
|
||||||
|
namespace mcc::ccte::iers::defaults\n
|
||||||
|
{
|
||||||
|
|
||||||
|
// https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat\n
|
||||||
|
static std::string MCC_DEFAULT_LEAP_SECONDS_FILE = R"--(\n' > $res_file
|
||||||
|
|
||||||
|
wget --quiet https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat -O - >> $res_file
|
||||||
|
|
||||||
|
echo -e ')--";\n\n' >> $res_file
|
||||||
|
|
||||||
|
echo -e '// https://datacenter.iers.org/data/latestVersion/bulletinA.txt\n
|
||||||
|
static std::string MCC_DEFAULT_IERS_BULLETIN_A_FILE = R"--(\n' >> $res_file
|
||||||
|
|
||||||
|
wget --quiet https://datacenter.iers.org/data/latestVersion/bulletinA.txt -O - >> $res_file
|
||||||
|
|
||||||
|
echo -e ')--";\n
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace mcc::ccte::iers::defaults\n' >> $res_file
|
||||||
Reference in New Issue
Block a user