Commit 527116ca235e81f2d6b8d39cc373dbfdb95fd071
0 parents
Exists in
master
first commit
Showing
22 changed files
with
1366 additions
and
0 deletions
Show diff stats
1 | +++ a/LICENCE | ||
@@ -0,0 +1,31 @@ | @@ -0,0 +1,31 @@ | ||
1 | +Copyright (c) 2022-2022, Astroguita Developers | ||
2 | + | ||
3 | +All rights reserved. | ||
4 | + | ||
5 | +Redistribution and use in source and binary forms, | ||
6 | +with or without modification, | ||
7 | +are permitted provided that the following conditions are met: | ||
8 | + | ||
9 | +Redistributions of source code must retain the above copyright notice, | ||
10 | +this list of conditions and the following disclaimer. | ||
11 | + | ||
12 | +Redistributions in binary form must reproduce the above copyright notice, | ||
13 | +this list of conditions and the following disclaimer in the documentation | ||
14 | +and/or other materials provided with the distribution. | ||
15 | + | ||
16 | +Neither the name of the Astroguita Team nor the names of its contributors | ||
17 | +may be used to endorse or promote products derived from this software | ||
18 | +without specific prior written permission. | ||
19 | + | ||
20 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
21 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
22 | +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
23 | +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS | ||
24 | +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
25 | +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
26 | +OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
27 | +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
28 | +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
29 | +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
30 | +POSSIBILITY OF SUCH DAMAGE. | ||
31 | + |
1 | +++ a/README.md | ||
@@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
1 | +# Guitastro Camera BASLER library | ||
2 | + | ||
3 | +GUITAstro stands for General Use of Instruments and Telescopes in ASTROnomy. | ||
4 | + | ||
5 | +GuitAstro is a Python module that provides classes and methods to write easily Python scripts for astronomical observations. | ||
6 | + | ||
7 | +[GIT repository: https://gitlab.irap.omp.eu/guitastrolib/guitastro.git](https://gitlab.irap.omp.eu/guitastrolib/guitastro.git) | ||
8 | + | ||
9 | +Guitastro Camera BASLER complete Guitastro to provide access to BASLER camera drivers: | ||
10 | + | ||
11 | +[GIT repository: https://gitlab.irap.omp.eu/guitastrolib/guitastro_device_deltatau.git](https://gitlab.irap.omp.eu/guitastrolib/guitastro_device_deltatau.git) | ||
12 | + | ||
13 | +## Few basic examples of use | ||
14 | + | ||
15 | +First example: To connect a DeltaTau controler and slew a telescope: | ||
16 | +``` | ||
17 | +import guitastro | ||
18 | +import guitastro_device_deltatau | ||
19 | + | ||
20 | +dev = guitastro_device_deltatau.Device_Deltatau() | ||
21 | +dev.open(False) | ||
22 | +dev.commandstring("mount SET target 'RADEC 12h56m -10d23m'") | ||
23 | +dev.commandstring("mount DO RADEC_GOTO") | ||
24 | +``` | ||
25 | + | ||
26 | +## Guitastro functionalities | ||
27 | + | ||
28 | +GuitAstro device DeltaTau wraps the driver functions dispatched into the classe: | ||
29 | + | ||
30 | +- **Device_Deltatau**: Manage device DeltaTau drivers. | ||
31 | + | ||
32 | +This class inheritate from the classes Component* of Guitastro. | ||
33 | +As a consequece, it is needed to install Guitastro before using Guitastro DeltaTau. | ||
34 | + | ||
35 | +A complete documentation can be generated from .rst files in the folder doc/doc_rst | ||
36 | + | ||
37 | +## Support and contact | ||
38 | + | ||
39 | +The main author is alain.klotz@irap.omp.eu | ||
40 | + |
1 | +++ a/docs/Makefile | ||
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +# Minimal makefile for Sphinx documentation | ||
2 | +# | ||
3 | + | ||
4 | +# You can set these variables from the command line, and also | ||
5 | +# from the environment for the first two. | ||
6 | +SPHINXOPTS ?= | ||
7 | +SPHINXBUILD ?= sphinx-build | ||
8 | +SOURCEDIR = source | ||
9 | +BUILDDIR = build | ||
10 | + | ||
11 | +# Put it first so that "make" without argument is like "make help". | ||
12 | +help: | ||
13 | + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
14 | + | ||
15 | +.PHONY: help Makefile | ||
16 | + | ||
17 | +# Catch-all target: route all unknown targets to Sphinx using the new | ||
18 | +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
19 | +%: Makefile | ||
20 | + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
1 | +++ a/docs/make.bat | ||
@@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
1 | +@echo off | ||
2 | + | ||
3 | +echo This batch must be launched with PowerShell in administrator mode. | ||
4 | +call :ResolvePath path_guitastro %cd%\.. | ||
5 | +echo Guitastro Camera ASCOM in the directory %path_guitastro% | ||
6 | + | ||
7 | +rem Search where is Anaconda | ||
8 | +set path_anacondas=c:\Users\%USERNAME%\Anaconda3 C:\ProgramData\Anaconda3 | ||
9 | +for %%p in (%path_anacondas%) do ( | ||
10 | + rem echo %%p | ||
11 | + if exist %%p ( | ||
12 | + rem file exists | ||
13 | + set path_anaconda=%%p | ||
14 | + ) | ||
15 | +) | ||
16 | +echo Anaconda found in the directory %path_anaconda% | ||
17 | + | ||
18 | +rem pyreverse | ||
19 | +set pyreverse=%path_anaconda%\Scripts\pyreverse | ||
20 | +echo ===== Analyze source code with %pyreverse% | ||
21 | +echo cd %path_guitastro%\src | ||
22 | +cd %path_guitastro%\src | ||
23 | +echo %pyreverse% -p guitastro_device_deltatau -o png guitastro_device_deltatau | ||
24 | +%pyreverse% -p guitastro_device_deltatau -o png guitastro_device_deltatau | ||
25 | +echo move classes_guitastro_device_deltatau.png %path_guitastro%\docs\source\doc_images\generated | ||
26 | +move classes_guitastro_device_deltatau.png %path_guitastro%\docs\source\doc_images\generated | ||
27 | +echo move packages_guitastro_device_deltatau.png %path_guitastro%\docs\source\doc_images\generated | ||
28 | +move packages_guitastro_device_deltatau.png %path_guitastro%\docs\source\doc_images\generated | ||
29 | + | ||
30 | +rem sphinx | ||
31 | +echo Compile doc with sphinx | ||
32 | +set sphinx=%path_anaconda%\Scripts\sphinx-build.exe | ||
33 | +echo ===== Compile doc with %sphinx% | ||
34 | +echo cd %path_guitastro%\docs | ||
35 | +cd %path_guitastro%\docs | ||
36 | +echo %sphinx% -b html .\source .\build\html | ||
37 | +%sphinx% -b html .\source .\build\html | ||
38 | +%sphinx% -b pdf .\source .\build\pdf | ||
39 | + | ||
40 | +exit /b | ||
41 | +rem === Functions === | ||
42 | + | ||
43 | +rem Resolve path to absolute. | ||
44 | +rem Param 1: Name of output variable. | ||
45 | +rem Param 2: Path to resolve. | ||
46 | +rem Return: Resolved absolute path. | ||
47 | +:ResolvePath | ||
48 | + set %1=%~dpfn2 | ||
49 | + exit /b |
1 | +++ a/docs/make_doc | ||
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
1 | +#!/bin/bash | ||
2 | + | ||
3 | +# Step 1) (if not done) change the file attribute: | ||
4 | +# > chmod +x make_doc | ||
5 | +# Step 2) execute the file: | ||
6 | +# > ./make_doc | ||
7 | + | ||
8 | +echo | ||
9 | +echo "-- generating guitastro_device_deltatau UML class diagrams (with pyreverse)" | ||
10 | +echo | ||
11 | +cd ../src | ||
12 | +pyreverse -p guitastro_device_deltatau -o png guitastro_device_deltatau | ||
13 | +mv classes_guitastro_device_deltatau.png ../docs/source/doc_images/generated/ | ||
14 | +mv packages_guitastro_device_deltatau.png ../docs/source/doc_images/generated/ | ||
15 | + | ||
16 | +cd ../docs | ||
17 | + | ||
18 | +echo | ||
19 | +echo "-- Generating guitastro_device_deltatau API doc in HTML format (from RST with sphinx)" | ||
20 | +echo "-- You can open this doc by pointing your browser to docs/build/html/index.html (from guitastro_device_deltatau dir)" | ||
21 | +echo | ||
22 | +sphinx-build -b html ./source/ ./build/html/ | ||
23 | + | ||
24 | +echo | ||
25 | +echo "-- Generating guitastro_device_deltatau API doc in PDF format (from RST with sphinx)" | ||
26 | +echo "-- You can open this doc by opening docs/build/pdf/guitastro_device_deltatau.pdf (from guitastro_device_deltatau dir)" | ||
27 | +echo | ||
28 | +sphinx-build -b pdf ./source/ ./build/pdf/ | ||
29 | + |
1 | +++ a/docs/source/autodoc_guitastro.rst | ||
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +************************************* | ||
2 | +Classes for GuitAstro Device DeltaTau | ||
3 | +************************************* | ||
4 | + | ||
5 | +This section is the documentation for developpers of classes related to GuitAstro Device DeltaTau. | ||
6 | + | ||
7 | +This page is generated according the docstrings of the python code. | ||
8 | +It displays only public methods of classes. | ||
9 | + | ||
10 | +.. image:: doc_images/generated/classes_guitastro_device_deltatau.png | ||
11 | + | ||
12 | +.. image:: doc_images/generated/packages_guitastro_device_deltatau.png | ||
13 | + | ||
14 | +Module guitastro_device_deltatau | ||
15 | +================================ | ||
16 | + | ||
17 | +.. automodule:: guitastro_device_deltatau |
1 | +++ a/docs/source/conf.py | ||
@@ -0,0 +1,385 @@ | @@ -0,0 +1,385 @@ | ||
1 | +# astromecca documentation build configuration file, created by | ||
2 | +# sphinx-quickstart on Sun Jun 26 00:00:43 2016. | ||
3 | +# | ||
4 | +# This file is execfile()d with the current directory set to its | ||
5 | +# containing dir. | ||
6 | +# | ||
7 | +# Note that not all possible configuration values are present in this | ||
8 | +# autogenerated file. | ||
9 | +# | ||
10 | +# All configuration values have a default; values that are commented out | ||
11 | +# serve to show the default. | ||
12 | + | ||
13 | +# If extensions (or modules to document with autodoc) are in another directory, | ||
14 | +# add these directories to sys.path here. If the directory is relative to the | ||
15 | +# documentation root, use os.path.abspath to make it absolute, like shown here. | ||
16 | +# | ||
17 | +# import os | ||
18 | +# import sys | ||
19 | +# sys.path.insert(0, os.path.abspath('.')) | ||
20 | + | ||
21 | +# -- General configuration ------------------------------------------------ | ||
22 | + | ||
23 | +# If your documentation needs a minimal Sphinx version, state it here. | ||
24 | +# | ||
25 | +# needs_sphinx = '1.0' | ||
26 | + | ||
27 | +# Add any Sphinx extension module names here, as strings. They can be | ||
28 | +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
29 | +# ones. | ||
30 | +extensions = [] | ||
31 | + | ||
32 | +# Add any paths that contain templates here, relative to this directory. | ||
33 | +templates_path = ['_templates'] | ||
34 | + | ||
35 | +# The suffix(es) of source filenames. | ||
36 | +# You can specify multiple suffix as a list of string: | ||
37 | +# | ||
38 | +# source_suffix = ['.rst', '.md'] | ||
39 | +source_suffix = '.rst' | ||
40 | + | ||
41 | +# The encoding of source files. | ||
42 | +# | ||
43 | +# source_encoding = 'utf-8-sig' | ||
44 | + | ||
45 | +# The master toctree document. | ||
46 | +master_doc = 'index' | ||
47 | + | ||
48 | +# General information about the project. | ||
49 | +project = u'GuitAstro Device DeltaTau' | ||
50 | +copyright = u'2022, IRAP' | ||
51 | +author = u'A. Klotz' | ||
52 | + | ||
53 | +# The version info for the project you're documenting, acts as replacement for | ||
54 | +# |version| and |release|, also used in various other places throughout the | ||
55 | +# built documents. | ||
56 | +# | ||
57 | +# The short X.Y version. | ||
58 | +version = u'1.0' | ||
59 | +# The full version, including alpha/beta/rc tags. | ||
60 | +release = u'1.0.0' | ||
61 | + | ||
62 | +# The language for content autogenerated by Sphinx. Refer to documentation | ||
63 | +# for a list of supported languages. | ||
64 | +# | ||
65 | +# This is also used if you do content translation via gettext catalogs. | ||
66 | +# Usually you set "language" from the command line for these cases. | ||
67 | +language = 'en' | ||
68 | + | ||
69 | +# There are two options for replacing |today|: either, you set today to some | ||
70 | +# non-false value, then it is used: | ||
71 | +# | ||
72 | +# today = '' | ||
73 | +# | ||
74 | +# Else, today_fmt is used as the format for a strftime call. | ||
75 | +# | ||
76 | +# today_fmt = '%B %d, %Y' | ||
77 | + | ||
78 | +# List of patterns, relative to source directory, that match files and | ||
79 | +# directories to ignore when looking for source files. | ||
80 | +# These patterns also affect html_static_path and html_extra_path | ||
81 | +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] | ||
82 | + | ||
83 | +# The reST default role (used for this markup: `text`) to use for all | ||
84 | +# documents. | ||
85 | +# | ||
86 | +# default_role = None | ||
87 | + | ||
88 | +# If true, '()' will be appended to :func: etc. cross-reference text. | ||
89 | +# | ||
90 | +# add_function_parentheses = True | ||
91 | + | ||
92 | +# If true, the current module name will be prepended to all description | ||
93 | +# unit titles (such as .. function::). | ||
94 | +# | ||
95 | +# add_module_names = True | ||
96 | + | ||
97 | +# If true, sectionauthor and moduleauthor directives will be shown in the | ||
98 | +# output. They are ignored by default. | ||
99 | +# | ||
100 | +# show_authors = False | ||
101 | + | ||
102 | +# The name of the Pygments (syntax highlighting) style to use. | ||
103 | +pygments_style = 'sphinx' | ||
104 | + | ||
105 | +# A list of ignored prefixes for module index sorting. | ||
106 | +# modindex_common_prefix = [] | ||
107 | + | ||
108 | +# If true, keep warnings as "system message" paragraphs in the built documents. | ||
109 | +# keep_warnings = False | ||
110 | + | ||
111 | +# If true, `todo` and `todoList` produce output, else they produce nothing. | ||
112 | +todo_include_todos = False | ||
113 | + | ||
114 | + | ||
115 | +# -- Options for HTML output ---------------------------------------------- | ||
116 | + | ||
117 | +# The theme to use for HTML and HTML Help pages. See the documentation for | ||
118 | +# a list of builtin themes. | ||
119 | +# | ||
120 | +html_theme = 'alabaster' | ||
121 | + | ||
122 | +# Theme options are theme-specific and customize the look and feel of a theme | ||
123 | +# further. For a list of options available for each theme, see the | ||
124 | +# documentation. | ||
125 | +# | ||
126 | +# html_theme_options = {} | ||
127 | + | ||
128 | +# Add any paths that contain custom themes here, relative to this directory. | ||
129 | +# html_theme_path = [] | ||
130 | + | ||
131 | +# The name for this set of Sphinx documents. | ||
132 | +# "<project> v<release> documentation" by default. | ||
133 | +# | ||
134 | +# html_title = u'astromecca vastromecca' | ||
135 | + | ||
136 | +# A shorter title for the navigation bar. Default is the same as html_title. | ||
137 | +# | ||
138 | +# html_short_title = None | ||
139 | + | ||
140 | +# The name of an image file (relative to this directory) to place at the top | ||
141 | +# of the sidebar. | ||
142 | +# | ||
143 | +# html_logo = None | ||
144 | + | ||
145 | +# The name of an image file (relative to this directory) to use as a favicon of | ||
146 | +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 | ||
147 | +# pixels large. | ||
148 | +# | ||
149 | +# html_favicon = None | ||
150 | + | ||
151 | +# Add any paths that contain custom static files (such as style sheets) here, | ||
152 | +# relative to this directory. They are copied after the builtin static files, | ||
153 | +# so a file named "default.css" will overwrite the builtin "default.css". | ||
154 | +# html_static_path = ['_static'] | ||
155 | + | ||
156 | +# Add any extra paths that contain custom files (such as robots.txt or | ||
157 | +# .htaccess) here, relative to this directory. These files are copied | ||
158 | +# directly to the root of the documentation. | ||
159 | +# | ||
160 | +# html_extra_path = [] | ||
161 | + | ||
162 | +# If not None, a 'Last updated on:' timestamp is inserted at every page | ||
163 | +# bottom, using the given strftime format. | ||
164 | +# The empty string is equivalent to '%b %d, %Y'. | ||
165 | +# | ||
166 | +# html_last_updated_fmt = None | ||
167 | + | ||
168 | +# Custom sidebar templates, maps document names to template names. | ||
169 | +# | ||
170 | +# html_sidebars = {} | ||
171 | + | ||
172 | +# Additional templates that should be rendered to pages, maps page names to | ||
173 | +# template names. | ||
174 | +# | ||
175 | +# html_additional_pages = {} | ||
176 | + | ||
177 | +# If false, no module index is generated. | ||
178 | +# | ||
179 | +# html_domain_indices = True | ||
180 | + | ||
181 | +# If false, no index is generated. | ||
182 | +# | ||
183 | +# html_use_index = True | ||
184 | + | ||
185 | +# If true, the index is split into individual pages for each letter. | ||
186 | +# | ||
187 | +# html_split_index = False | ||
188 | + | ||
189 | +# If true, links to the reST sources are added to the pages. | ||
190 | +# | ||
191 | +# html_show_sourcelink = True | ||
192 | + | ||
193 | +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. | ||
194 | +# | ||
195 | +# html_show_sphinx = True | ||
196 | + | ||
197 | +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. | ||
198 | +# | ||
199 | +# html_show_copyright = True | ||
200 | + | ||
201 | +# If true, an OpenSearch description file will be output, and all pages will | ||
202 | +# contain a <link> tag referring to it. The value of this option must be the | ||
203 | +# base URL from which the finished HTML is served. | ||
204 | +# | ||
205 | +# html_use_opensearch = '' | ||
206 | + | ||
207 | +# This is the file name suffix for HTML files (e.g. ".xhtml"). | ||
208 | +# html_file_suffix = None | ||
209 | + | ||
210 | +# Language to be used for generating the HTML full-text search index. | ||
211 | +# Sphinx supports the following languages: | ||
212 | +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' | ||
213 | +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' | ||
214 | +# | ||
215 | +# html_search_language = 'en' | ||
216 | + | ||
217 | +# A dictionary with options for the search language support, empty by default. | ||
218 | +# 'ja' uses this config value. | ||
219 | +# 'zh' user can custom change `jieba` dictionary path. | ||
220 | +# | ||
221 | +# html_search_options = {'type': 'default'} | ||
222 | + | ||
223 | +# The name of a javascript file (relative to the configuration directory) that | ||
224 | +# implements a search results scorer. If empty, the default will be used. | ||
225 | +# | ||
226 | +# html_search_scorer = 'scorer.js' | ||
227 | + | ||
228 | +# Output file base name for HTML help builder. | ||
229 | +htmlhelp_basename = 'guitastro_device_deltatau' | ||
230 | + | ||
231 | +# -- Options for LaTeX output --------------------------------------------- | ||
232 | + | ||
233 | +latex_elements = { | ||
234 | + # The paper size ('letterpaper' or 'a4paper'). | ||
235 | + # | ||
236 | + # 'papersize': 'letterpaper', | ||
237 | + | ||
238 | + # The font size ('10pt', '11pt' or '12pt'). | ||
239 | + # | ||
240 | + # 'pointsize': '10pt', | ||
241 | + | ||
242 | + # Additional stuff for the LaTeX preamble. | ||
243 | + # | ||
244 | + # 'preamble': '', | ||
245 | + | ||
246 | + # Latex figure (float) alignment | ||
247 | + # | ||
248 | + # 'figure_align': 'htbp', | ||
249 | +} | ||
250 | + | ||
251 | +# Grouping the document tree into LaTeX files. List of tuples | ||
252 | +# (source start file, target name, title, | ||
253 | +# author, documentclass [howto, manual, or own class]). | ||
254 | +latex_documents = [ | ||
255 | + (master_doc, 'guitastro_device_deltatau.tex', u'Guitastro Device DeltaTau Documentation', | ||
256 | + u'guitastro_device_deltatau', 'manual'), | ||
257 | +] | ||
258 | + | ||
259 | +# The name of an image file (relative to this directory) to place at the top of | ||
260 | +# the title page. | ||
261 | +# | ||
262 | +# latex_logo = None | ||
263 | + | ||
264 | +# If true, show page references after internal links. | ||
265 | +# | ||
266 | +# latex_show_pagerefs = False | ||
267 | + | ||
268 | +# If true, show URL addresses after external links. | ||
269 | +# | ||
270 | +# latex_show_urls = False | ||
271 | + | ||
272 | +# Documents to append as an appendix to all manuals. | ||
273 | +# | ||
274 | +# latex_appendices = [] | ||
275 | + | ||
276 | +# If false, no module index is generated. | ||
277 | +# | ||
278 | +# latex_domain_indices = True | ||
279 | + | ||
280 | + | ||
281 | +# -- Options for manual page output --------------------------------------- | ||
282 | + | ||
283 | +# One entry per manual page. List of tuples | ||
284 | +# (source start file, name, description, authors, manual section). | ||
285 | +man_pages = [ | ||
286 | + (master_doc, 'guitastro_device_deltatau', u'guitastro Device DeltaTau Documentation', | ||
287 | + [author], 1) | ||
288 | +] | ||
289 | + | ||
290 | +# If true, show URL addresses after external links. | ||
291 | +# | ||
292 | +# man_show_urls = False | ||
293 | + | ||
294 | + | ||
295 | +# -- Options for Texinfo output ------------------------------------------- | ||
296 | + | ||
297 | +# Grouping the document tree into Texinfo files. List of tuples | ||
298 | +# (source start file, target name, title, author, | ||
299 | +# dir menu entry, description, category) | ||
300 | +texinfo_documents = [ | ||
301 | + (master_doc, 'guitastro_device_deltatau', u'guitastro Device DeltaTau Documentation', | ||
302 | + author, 'guitastro_device_deltatau', 'One line description of project.', | ||
303 | + 'Miscellaneous'), | ||
304 | +] | ||
305 | + | ||
306 | +# Documents to append as an appendix to all manuals. | ||
307 | +# | ||
308 | +# texinfo_appendices = [] | ||
309 | + | ||
310 | +# If false, no module index is generated. | ||
311 | +# | ||
312 | +# texinfo_domain_indices = True | ||
313 | + | ||
314 | +# How to display URL addresses: 'footnote', 'no', or 'inline'. | ||
315 | +# | ||
316 | +# texinfo_show_urls = 'footnote' | ||
317 | + | ||
318 | +# If true, do not generate a @detailmenu in the "Top" node's menu. | ||
319 | +# | ||
320 | +# texinfo_no_detailmenu = False | ||
321 | + | ||
322 | +# -- A random example ----------------------------------------------------- | ||
323 | + | ||
324 | +import sys, os | ||
325 | +sys.path.insert(0, os.path.abspath('../../src')) | ||
326 | +sys.path.insert(0, os.path.abspath('../../../guitastro/src')) # guitastro must be also present | ||
327 | +print(f"============ sys.path={sys.path}") | ||
328 | +# exclude_patterns = ['zzz'] | ||
329 | + | ||
330 | +numfig = True | ||
331 | +#language = 'ja' | ||
332 | + | ||
333 | +extensions.append('sphinx.ext.todo') | ||
334 | +extensions.append('sphinx.ext.autodoc') | ||
335 | +#extensions.append('sphinx.ext.autosummary') | ||
336 | +extensions.append('sphinx.ext.intersphinx') | ||
337 | +extensions.append('sphinx.ext.mathjax') | ||
338 | +extensions.append('sphinx.ext.viewcode') | ||
339 | +extensions.append('sphinx.ext.graphviz') | ||
340 | +try: | ||
341 | + extensions.append('sphinx_pyreverse') | ||
342 | +except ModuleNotFoundError: | ||
343 | + pass # pip install sphinx_pyreverse | ||
344 | + | ||
345 | +try: | ||
346 | + import rst2pdf | ||
347 | + extensions.append('rst2pdf.pdfbuilder') | ||
348 | +except ModuleNotFoundError: | ||
349 | + pass # no rst2pdf for you | ||
350 | +extensions.append('sphinx.ext.napoleon') | ||
351 | +# Napoleon settings | ||
352 | +napoleon_google_docstring = True | ||
353 | +napoleon_numpy_docstring = True | ||
354 | +napoleon_include_init_with_doc = False | ||
355 | +napoleon_include_private_with_doc = False | ||
356 | +napoleon_include_special_with_doc = True | ||
357 | +napoleon_use_admonition_for_examples = False | ||
358 | +napoleon_use_admonition_for_notes = False | ||
359 | +napoleon_use_admonition_for_references = False | ||
360 | +napoleon_use_ivar = False | ||
361 | +napoleon_use_param = True | ||
362 | +napoleon_use_rtype = True | ||
363 | +napoleon_preprocess_types = False | ||
364 | +napoleon_type_aliases = None | ||
365 | +napoleon_attr_annotations = True | ||
366 | + | ||
367 | +autodoc_typehints = "description" | ||
368 | + | ||
369 | +pdf_documents = [ | ||
370 | + ('index', u'guitastro_device_deltatau', u'Guitastro Device DeltaTau', u'Alain Klotz'), | ||
371 | +] | ||
372 | + | ||
373 | +pdf_documents = [('index', u'guitastro_device_deltatau', u'Guitastro Device DeltaTau', u'Alain Klotz')] | ||
374 | + | ||
375 | +# A comma-separated list of custom stylesheets. Example: | ||
376 | +pdf_stylesheets = ['sphinx', 'kerning', 'a4', 'twocolumn'] | ||
377 | + | ||
378 | +# pip install sphinx rst2pdf build pdf docs | ||
379 | +pdf_use_index = False | ||
380 | + | ||
381 | +autosummary_generate = True | ||
382 | +html_theme = 'default' | ||
383 | +#html_theme = "nature" | ||
384 | +#html_theme = "alabaster" | ||
385 | +#source_suffix = ['.rst', '.txt'] |
19 KB
1 | +++ a/docs/source/generate_documentation.rst | ||
@@ -0,0 +1,74 @@ | @@ -0,0 +1,74 @@ | ||
1 | +******************************************** | ||
2 | +Generate this documentation | ||
3 | +******************************************** | ||
4 | + | ||
5 | +This documentation is generated by the use of Sphinx and Pyreverse. | ||
6 | +Sphinx uses the `Restructured Text format <https://en.wikipedia.org/wiki/ReStructuredText>`_. | ||
7 | +The following links gives some informations about the syntax: | ||
8 | + | ||
9 | + * `Tutorial Sphinx 1 <https://deusyss.developpez.com/tutoriels/Python/SphinxDoc/>`_. | ||
10 | + * `Tutorial Sphinx 2 <https://www.mankier.com/1/sphinx-all>`_. | ||
11 | + * `Tutorial documentation <https://www.codeflow.site/fr/article/documenting-python-code>`_. | ||
12 | + * `Tutorial reST <https://thomas-cokelaer.info/tutorials/sphinx/rest_syntax.html>`_. | ||
13 | + * `Tutorial Napoleon extension <https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html#module-sphinx.ext.napoleon>`_. | ||
14 | + * `Pandoc to convert many formats into reST <https://pandoc.org/>`_. | ||
15 | + | ||
16 | +Installation of Sphinx and Pyreverse | ||
17 | +*********************************************** | ||
18 | + | ||
19 | +For Linux users | ||
20 | +=============== | ||
21 | + | ||
22 | +.. code-block:: bash | ||
23 | + | ||
24 | + sudo apt-get install graphviz graphviz-dev | ||
25 | + cd ~/Documents/guitastro/install | ||
26 | + python3 -m pip install -r requirements_dev.txt | ||
27 | + | ||
28 | +For Windows users | ||
29 | +================= | ||
30 | + | ||
31 | +First you must download and install `Graphviz <https://graphviz.org/>`_. | ||
32 | + | ||
33 | +Open a Powershell as administrator. | ||
34 | +A quick way to open Powershell as administrator is | ||
35 | +Win+R (execute commands) and put: | ||
36 | + | ||
37 | +.. code-block:: bash | ||
38 | + | ||
39 | + powershell Start-Process powershell -Verb runAs | ||
40 | + | ||
41 | +Then, in the Powershell terminal: | ||
42 | + | ||
43 | +.. code-block:: bash | ||
44 | + | ||
45 | + cd C:\Users\xxx\Documents\guitastro\install | ||
46 | + python -m pip install -r requirements_dev.txt | ||
47 | + | ||
48 | +Generate the documentation | ||
49 | +*********************************************** | ||
50 | + | ||
51 | +To generate the documentation you must use the doc_rst batch. It starts to execute pyreverse | ||
52 | +and then sphinx. | ||
53 | + | ||
54 | +Procedure for Linux. Open a terminal: | ||
55 | + | ||
56 | +.. code-block:: bash | ||
57 | + | ||
58 | + cd ~/Documents/guitastro/doc/doc_rst/ | ||
59 | + ./make_doc | ||
60 | + | ||
61 | +make_doc will generate UML diagrams from the Python code, the html and the PDF documentations. | ||
62 | +To generate only html and pdf documentation, you can use: | ||
63 | + | ||
64 | +.. code-block:: bash | ||
65 | + | ||
66 | + cd ~/Documents/guitastro/doc/doc_rst/ | ||
67 | + make html | ||
68 | + | ||
69 | +Procedure for Windows. Open a PowerShell as administrator: | ||
70 | + | ||
71 | +.. code-block:: bash | ||
72 | + | ||
73 | + cd C:\Users\xxx\Documents\guitastro\doc\doc_rst | ||
74 | + .\make_doc |
1 | +++ a/docs/source/guitastro_examples.rst | ||
@@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
1 | +******************************************** | ||
2 | +Guitastro Device DeltaTau examples | ||
3 | +******************************************** | ||
4 | + | ||
5 | + | ||
6 | +To execute the simple tests, first open a Python console and import guitastro and guitastro_device_deltatau: | ||
7 | + | ||
8 | +For Linux: | ||
9 | + | ||
10 | +.. code-block:: bash | ||
11 | + | ||
12 | + cd ~/Documents/guitastro_device_deltatau/src | ||
13 | + python3 | ||
14 | + | ||
15 | +.. code-block:: python | ||
16 | + | ||
17 | + >>> import guitastro | ||
18 | + >>> import guitastro_device_deltatau | ||
19 | + | ||
20 | +For Windows (using powershell): | ||
21 | + | ||
22 | +.. code-block:: bash | ||
23 | + | ||
24 | + cd C:\Users\xxx\Documents\guitastro_device_deltatau\src | ||
25 | + python | ||
26 | + | ||
27 | +.. code-block:: python | ||
28 | + | ||
29 | + >>> import guitastro | ||
30 | + >>> import guitastro_device_deltatau | ||
31 | + | ||
32 | + | ||
33 | +1. List Components of a device | ||
34 | +************************************** | ||
35 | + | ||
36 | +.. code-block:: python | ||
37 | + | ||
38 | + >>> dev = guitastro_device_deltatau.Device_Deltatau("TCA") | ||
39 | + >>> print("Components are:") | ||
40 | + >>> for key, val in dev.components().items(): | ||
41 | + >>> print(f" * {key} of type {val[0]}") | ||
42 | + | ||
43 | +2. Open the connection and send commands | ||
44 | +****************************************** | ||
45 | + | ||
46 | +.. code-block:: python | ||
47 | + | ||
48 | + >>> dev = guitastro_device_deltatau.Device_Deltatau("TCA") | ||
49 | + >>> dev.open(False) | ||
50 | + >>> dev.commandstring("mount SET target 'RADEC 12h56m -10d23m'") | ||
51 | + >>> dev.commandstring("mount DO RADEC_GOTO") | ||
52 | + >>> res = dev.commandstring("mount GET motion") | ||
53 | + >>> res = dev.commandstring("focuser GET motion") |
1 | +++ a/docs/source/guitastro_simple_examples.rst | ||
@@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
1 | +******************************************** | ||
2 | +Guitastro Device DeltaTau simple examples | ||
3 | +******************************************** | ||
4 | + | ||
5 | + | ||
6 | +To execute the simple tests, first open a Python console and import guitastro and guitastro_device_deltatau: | ||
7 | + | ||
8 | +For Linux: | ||
9 | + | ||
10 | +.. code-block:: bash | ||
11 | + | ||
12 | + cd ~/Documents/guitastro_device_deltatau/src | ||
13 | + python3 | ||
14 | + | ||
15 | +.. code-block:: python | ||
16 | + | ||
17 | + >>> import guitastro | ||
18 | + >>> import guitastro_device_deltatau | ||
19 | + | ||
20 | +For Windows (using powershell): | ||
21 | + | ||
22 | +.. code-block:: bash | ||
23 | + | ||
24 | + cd C:\Users\xxx\Documents\guitastro_device_deltatau\src | ||
25 | + python | ||
26 | + | ||
27 | +.. code-block:: python | ||
28 | + | ||
29 | + >>> import guitastro | ||
30 | + >>> import guitastro_device_deltatau | ||
31 | + | ||
32 | + | ||
33 | +1. List Components of a device | ||
34 | +************************************** | ||
35 | + | ||
36 | +.. code-block:: python | ||
37 | + | ||
38 | + >>> dev = guitastro_device_deltatau.Device_Deltatau("TCA") | ||
39 | + >>> print("Components are:") | ||
40 | + >>> for key, val in dev.components().items(): | ||
41 | + >>> print(f" * {key} of type {val[0]}") | ||
42 | + | ||
43 | +2. Open the connection and send commands | ||
44 | +****************************************** | ||
45 | + | ||
46 | +.. code-block:: python | ||
47 | + | ||
48 | + >>> dev = guitastro_device_deltatau.Device_Deltatau("TCA") | ||
49 | + >>> dev.open(False) | ||
50 | + >>> dev.commandstring("mount SET target 'RADEC 12h56m -10d23m'") | ||
51 | + >>> dev.commandstring("mount DO RADEC_GOTO") | ||
52 | + >>> res = dev.commandstring("mount GET motion") | ||
53 | + >>> res = dev.commandstring("focuser GET motion") |
1 | +++ a/docs/source/index.rst | ||
@@ -0,0 +1,81 @@ | @@ -0,0 +1,81 @@ | ||
1 | +************************************************************* | ||
2 | +Welcome in the GuitAstro Device DeltaTau module documentation | ||
3 | +************************************************************* | ||
4 | + | ||
5 | +1. What is GuitAstro Device DeltaTau? | ||
6 | +************************************* | ||
7 | + | ||
8 | +GuitAstro is a Python module that provides classes and methods | ||
9 | +to write scripts for astronomical observations. GuitAstro wraps | ||
10 | +the classical astronomical Python modules (AstroPy, etc.) and | ||
11 | +adds functionalities. | ||
12 | + | ||
13 | +All information are provided in the Git repository `https://gitlab.irap.omp.eu/aklotz/guitastro.git <https://gitlab.irap.omp.eu/aklotz/guitastro.git>`_. | ||
14 | + | ||
15 | +GuitAstro Device DeltaTau is a complement of GuitAstro to add | ||
16 | +the class device_deltatau. By this way, it is possible to | ||
17 | +use mount, filter wheel and focuser driven by DeltaTau. | ||
18 | + | ||
19 | +`DeltaTau <http://www.observatorysciences.co.uk/deltatau.php/>`_ provides a motion controler between application | ||
20 | +(as GuitAstro) to drive telescope motors. | ||
21 | + | ||
22 | +.. figure:: doc_images/deltatau1.jpg | ||
23 | + :height: 100px | ||
24 | + :align: center | ||
25 | + | ||
26 | + DeltaTau Logo. | ||
27 | + | ||
28 | +2. Installation of Guitastro Device DeltaTau | ||
29 | +********************************************* | ||
30 | + | ||
31 | +See the documentation of `GuitAstro <https://gitlab.irap.omp.eu/aklotz/guitastro.git>`_. | ||
32 | +The principles are exactly the same. The main folder guitastro_device_deltatau must lie at | ||
33 | +the same tree level than guitastro as shown below: | ||
34 | + | ||
35 | +.. code-block:: bash | ||
36 | + | ||
37 | + guitastro_packages/ | ||
38 | + |---guitastro/ | ||
39 | + | ... | ||
40 | + |---guitastro_device_deltatau/ | ||
41 | + | ... | ||
42 | + | ||
43 | +3. External resources | ||
44 | +********************* | ||
45 | + | ||
46 | +No external source is needed. | ||
47 | + | ||
48 | +4. Some very simple tests | ||
49 | +************************* | ||
50 | + | ||
51 | +.. toctree:: | ||
52 | + :maxdepth: 3 | ||
53 | + | ||
54 | + guitastro_simple_examples | ||
55 | + | ||
56 | +5. Example collection | ||
57 | +********************* | ||
58 | + | ||
59 | +.. toctree:: | ||
60 | + :maxdepth: 3 | ||
61 | + | ||
62 | + guitastro_examples | ||
63 | + | ||
64 | +6. Class and method documentation | ||
65 | +*********************************** | ||
66 | + | ||
67 | +For developers of Python code of GuitAstro: | ||
68 | + | ||
69 | +.. toctree:: | ||
70 | + :maxdepth: 3 | ||
71 | + | ||
72 | + generate_documentation | ||
73 | + | ||
74 | +The classes of GuitAstro Devices DeltaTau. | ||
75 | + | ||
76 | +.. toctree:: | ||
77 | + :maxdepth: 3 | ||
78 | + | ||
79 | + autodoc_guitastro | ||
80 | + | ||
81 | + |
1 | +++ a/setup.py | ||
@@ -0,0 +1,79 @@ | @@ -0,0 +1,79 @@ | ||
1 | +#!/usr/bin/env python | ||
2 | +# -*- coding: utf-8 -*- | ||
3 | +# | ||
4 | +# === To install with setup.py | ||
5 | +# git https://gitlab.irap.omp.eu/aklotz/guitastro_camera_basler.git | ||
6 | +# cd guitastro_camera_basler | ||
7 | +# python setup.py install | ||
8 | +# | ||
9 | +# === To check it is installed: | ||
10 | +# Windows: pip freeze | findstr guitastro_camera_basler | ||
11 | +# Linux: pip freeze | grep guitastro_camera_basler | ||
12 | +# | ||
13 | +# === To uninstall: | ||
14 | +# pip uninstall guitastro_camera_basler | ||
15 | +# | ||
16 | +from setuptools import setup, find_packages | ||
17 | +import os | ||
18 | + | ||
19 | +__version__ = '0.1' | ||
20 | +python_cmd='python' | ||
21 | + | ||
22 | +def copy_file(file_in, file_out): | ||
23 | + # used by generate_requirements | ||
24 | + with open(file_in, 'r') as fid: | ||
25 | + lines = fid.readlines() | ||
26 | + with open(file_out, 'w') as fid: | ||
27 | + fid.writelines(lines) | ||
28 | + | ||
29 | +def compile_requirements(python_cmd='python', requirement_in_file='requirements.in'): | ||
30 | + # used by generate_requirements | ||
31 | + os.system('python -m pip install --no-input pip-tools') | ||
32 | + import piptools | ||
33 | + #infile = os.path.join(os.getcwd(), requirement_in_file) | ||
34 | + command = f"{python_cmd} -m piptools compile {requirement_in_file}" | ||
35 | + print(f"compile_requirements: {command}") | ||
36 | + os.system(command) | ||
37 | + root, ext = os.path.splitext(requirement_in_file) | ||
38 | + requirement_file = root + ".txt" | ||
39 | + print(f"compile_requirements: {requirement_file} is generated.") | ||
40 | + return requirement_file | ||
41 | + | ||
42 | +def read_requirements(requirement_file='requirements.txt'): | ||
43 | + # used by generate_requirements | ||
44 | + requirements = [] | ||
45 | + with open(requirement_file, 'r') as fid: | ||
46 | + lines = fid.readlines() | ||
47 | + for line in lines: | ||
48 | + line = line.strip() | ||
49 | + if len(line) < 1: | ||
50 | + continue | ||
51 | + if line[0] == "#": | ||
52 | + continue | ||
53 | + requirements.append(line) | ||
54 | + return requirements | ||
55 | + | ||
56 | +def generate_requirements(python_cmd='python', requirement_gen = 'requirements'): | ||
57 | + # copy .in from install | ||
58 | + requirement_in_file = requirement_gen + ".in" | ||
59 | + copy_file(os.path.join('install', requirement_in_file), requirement_in_file) | ||
60 | + # compile .in | ||
61 | + requirement_file = compile_requirements(python_cmd, requirement_in_file) | ||
62 | + # read .txt | ||
63 | + requirements = read_requirements(requirement_file) | ||
64 | + os.remove(requirement_in_file) | ||
65 | + return requirements | ||
66 | + | ||
67 | +requirements = generate_requirements(python_cmd, 'requirements') | ||
68 | + | ||
69 | +setup( | ||
70 | + name='guitastro_camera_basler', | ||
71 | + version=__version__, | ||
72 | + description='General Use of Instruments and Telescopes in ASTROnomy Camera BALSER', | ||
73 | + author='Alain klotz', | ||
74 | + author_email='aklotz@irap.omp.eu', | ||
75 | + url='https://gitlab.irap.omp.eu/aklotz/guitastro_camera_basler.git', | ||
76 | + install_requires=requirements, | ||
77 | + package_dir = {'': 'src'}, | ||
78 | + packages=['guitastro_camera_basler'], | ||
79 | +) |
1 | +++ a/src/guitastro_device_deltatau/__init__.py | ||
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | +""" | ||
2 | +guitastro_device_deltatau.device_deltatau | ||
3 | +------------------------------------------- | ||
4 | +.. automodule:: guitastro_device_deltatau.device_deltatau | ||
5 | + :members: | ||
6 | + | ||
7 | +""" | ||
8 | +from __future__ import (absolute_import, division, print_function, | ||
9 | + unicode_literals) | ||
10 | + | ||
11 | +import glob | ||
12 | +import os | ||
13 | + | ||
14 | +from .device_deltatau import Device_Deltatau | ||
15 | + |
src/guitastro_device_deltatau/component_detector_focuser_deltatau.py
0 → 100644
1 | +++ a/src/guitastro_device_deltatau/component_detector_focuser_deltatau.py | ||
@@ -0,0 +1,88 @@ | @@ -0,0 +1,88 @@ | ||
1 | +# -*- coding: utf-8 -*- | ||
2 | +import os | ||
3 | +import sys | ||
4 | + | ||
5 | +try: | ||
6 | + # guitastro is installed with setup.py | ||
7 | + from guitastro import ComponentDetectorFocuser, ComponentException | ||
8 | +except: | ||
9 | + # guitastro is installed with only requirements.in | ||
10 | + # guitastro_camera_* folders must be copied at the same root folder than guitastro | ||
11 | + pwd = os.getcwd() | ||
12 | + short_paths = ['../../../guitastro/src'] | ||
13 | + for short_path in short_paths: | ||
14 | + path = os.path.abspath(os.path.join(pwd, short_path)) | ||
15 | + if path not in sys.path: | ||
16 | + sys.path.insert(0, path) | ||
17 | + from guitastro.component import ComponentException | ||
18 | + from guitastro.component_detector_focuser import ComponentDetectorFocuser | ||
19 | + | ||
20 | +# ##################################################################### | ||
21 | +# ##################################################################### | ||
22 | +# ##################################################################### | ||
23 | +# Class Component Detector Focuser DeltaTau | ||
24 | +# ##################################################################### | ||
25 | +# ##################################################################### | ||
26 | +# ##################################################################### | ||
27 | + | ||
28 | +class ComponentDetectorFocuserDeltatau(ComponentDetectorFocuser): | ||
29 | + """Component for Detector focuser Deltatau | ||
30 | + | ||
31 | + Usage : ComponentDetectorFocuserDeltatau("Z", name="test") | ||
32 | + """ | ||
33 | + | ||
34 | + def _my_do(self, *args, **kwargs): | ||
35 | + value = None | ||
36 | + operation = args[0].upper() | ||
37 | + operations = list(self.prop()['DO'].keys()) | ||
38 | + if operation not in operations: | ||
39 | + msg = f"{operation} not found amongst {operations}" | ||
40 | + raise ComponentException(ComponentException.ERR_OPERATION_NOT_FOUND, msg) | ||
41 | + # --- | ||
42 | + axis_foc = self._param["CONTROLLER_FOCUS_ID"] | ||
43 | + if operation == "GOTO": | ||
44 | + self._verify_chan() | ||
45 | + target = float(args[1]) | ||
46 | + # transform to native command to start the goto | ||
47 | + cmd = f"#{axis_foc}p={target}" | ||
48 | + self.log = cmd | ||
49 | + self._chan.put_chan(cmd) | ||
50 | + # Launch a thread to wait the end of pointing and trig the drift | ||
51 | + elif operation == "COORD": | ||
52 | + # transform to native command to get coords | ||
53 | + cmd = f"#{axis_foc}p" | ||
54 | + self.log = cmd | ||
55 | + value = float(self._chan.put_chan(cmd)) | ||
56 | + if operation == "STOP": | ||
57 | + self._verify_chan() | ||
58 | + # transform to native command to stop | ||
59 | + cmd = f"#{axis_foc}k" | ||
60 | + self.log = cmd | ||
61 | + self._chan.put_chan(cmd) | ||
62 | + return value | ||
63 | + | ||
64 | +# ##################################################################### | ||
65 | +# ##################################################################### | ||
66 | +# ##################################################################### | ||
67 | +# Main | ||
68 | +# ##################################################################### | ||
69 | +# ##################################################################### | ||
70 | +# ##################################################################### | ||
71 | + | ||
72 | +if __name__ == "__main__": | ||
73 | + default = 0 | ||
74 | + example = input(f"Select the example (0 to 0) ({default}) ") | ||
75 | + try: | ||
76 | + example = int(example) | ||
77 | + except: | ||
78 | + example = default | ||
79 | + | ||
80 | + print("Example = {}".format(example)) | ||
81 | + | ||
82 | + if example == 0: | ||
83 | + """ | ||
84 | + Basic example | ||
85 | + """ | ||
86 | + comp = ComponentDetectorFocuserDeltatau("Z", name="test") | ||
87 | + comp.verbose = 1 | ||
88 | + res = comp.command("DO", "STOP") |
src/guitastro_device_deltatau/component_mount_pointing_deltatau.py
0 → 100644
1 | +++ a/src/guitastro_device_deltatau/component_mount_pointing_deltatau.py | ||
@@ -0,0 +1,94 @@ | @@ -0,0 +1,94 @@ | ||
1 | +# -*- coding: utf-8 -*- | ||
2 | +import os | ||
3 | +import sys | ||
4 | + | ||
5 | +try: | ||
6 | + # guitastro is installed with setup.py | ||
7 | + from guitastro import ComponentMountPointing, ComponentException | ||
8 | +except: | ||
9 | + # guitastro is installed with only requirements.in | ||
10 | + # guitastro_camera_* folders must be copied at the same root folder than guitastro | ||
11 | + pwd = os.getcwd() | ||
12 | + short_paths = ['../../../guitastro/src'] | ||
13 | + for short_path in short_paths: | ||
14 | + path = os.path.abspath(os.path.join(pwd, short_path)) | ||
15 | + if path not in sys.path: | ||
16 | + sys.path.insert(0, path) | ||
17 | + from guitastro.component import ComponentException | ||
18 | + from guitastro.component_mount_pointing import ComponentMountPointing | ||
19 | + | ||
20 | +# ##################################################################### | ||
21 | +# ##################################################################### | ||
22 | +# ##################################################################### | ||
23 | +# Class Component Mount Pointing DeltaTau | ||
24 | +# ##################################################################### | ||
25 | +# ##################################################################### | ||
26 | +# ##################################################################### | ||
27 | + | ||
28 | +class ComponentMountPointingDeltatau(ComponentMountPointing): | ||
29 | + """Component for Mount Pointing Deltatau | ||
30 | + | ||
31 | + Usage : ComponentMountPointingDeltatau("HADEC", name="test") | ||
32 | + """ | ||
33 | + | ||
34 | + def _my_do(self, *args, **kwargs): | ||
35 | + value = None | ||
36 | + operation = args[0].upper() | ||
37 | + operations = list(self.prop()['DO'].keys()) | ||
38 | + if operation not in operations: | ||
39 | + msg = f"{operation} not found amongst {operations}" | ||
40 | + raise ComponentException(ComponentException.ERR_OPERATION_NOT_FOUND, msg) | ||
41 | + # --- | ||
42 | + axis_ha = self._param["CONTROLLER_BASE_ID"] | ||
43 | + axis_dec = self._param["CONTROLLER_POLAR_ID"] | ||
44 | + if operation == "RADEC_GOTO": | ||
45 | + self._verify_chan() | ||
46 | + #target = self._param["target"] | ||
47 | + ra, dec, equinox, epoch, dra, ddec = kwargs['computed'] | ||
48 | + # transform to native command to start the goto | ||
49 | + cmd = f"#{axis_ha}p=123456 #{axis_dec}p=123456" | ||
50 | + self.log = cmd | ||
51 | + self._chan.put_chan(cmd) | ||
52 | + # Launch a thread to wait the end of pointing and trig the drift | ||
53 | + elif operation == "RADEC_COORD": | ||
54 | + # transform to native command to get coords | ||
55 | + cmd = f"#{axis_ha}p #{axis_dec}p" | ||
56 | + self.log = cmd | ||
57 | + values = self._chan.put_chan(cmd) | ||
58 | + ha_adu = float(values[0]) | ||
59 | + dec_adu = float(values[1]) | ||
60 | + value = f"{ha_adu} {dec_adu}" | ||
61 | + value = "12h00m45.78s -06d55m23.2s" | ||
62 | + if operation == "STOP": | ||
63 | + self._verify_chan() | ||
64 | + # transform to native command to stop | ||
65 | + cmd = f"#{axis_ha}k #{axis_dec}k" | ||
66 | + self.log = cmd | ||
67 | + self._chan.put_chan(cmd) | ||
68 | + return value | ||
69 | + | ||
70 | +# ##################################################################### | ||
71 | +# ##################################################################### | ||
72 | +# ##################################################################### | ||
73 | +# Main | ||
74 | +# ##################################################################### | ||
75 | +# ##################################################################### | ||
76 | +# ##################################################################### | ||
77 | + | ||
78 | +if __name__ == "__main__": | ||
79 | + default = 0 | ||
80 | + example = input(f"Select the example (0 to 0) ({default}) ") | ||
81 | + try: | ||
82 | + example = int(example) | ||
83 | + except: | ||
84 | + example = default | ||
85 | + | ||
86 | + print("Example = {}".format(example)) | ||
87 | + | ||
88 | + if example == 0: | ||
89 | + """ | ||
90 | + Basic example | ||
91 | + """ | ||
92 | + comp = ComponentMountPointingDeltatau("HADEC", name="test") | ||
93 | + comp.verbose = 1 | ||
94 | + res = comp.command("DO", "STOP") |
1 | +++ a/src/guitastro_device_deltatau/device_deltatau.py | ||
@@ -0,0 +1,244 @@ | @@ -0,0 +1,244 @@ | ||
1 | +# -*- coding: utf-8 -*- | ||
2 | +import os | ||
3 | +import sys | ||
4 | +import shlex | ||
5 | + | ||
6 | +try: | ||
7 | + from .component_detector_focuser_deltatau import ComponentDetectorFocuserDeltatau | ||
8 | +except: | ||
9 | + from component_detector_focuser_deltatau import ComponentDetectorFocuserDeltatau | ||
10 | + | ||
11 | +try: | ||
12 | + from .component_mount_pointing_deltatau import ComponentMountPointingDeltatau | ||
13 | +except: | ||
14 | + from component_mount_pointing_deltatau import ComponentMountPointingDeltatau | ||
15 | + | ||
16 | +try: | ||
17 | + # guitastro is installed with setup.py | ||
18 | + from guitastro import Communication, GuitastroException, GuitastroTools, Ephemeris | ||
19 | +except: | ||
20 | + # guitastro is installed with only requirements.in | ||
21 | + # guitastro_camera_* folders must be copied at the same root folder than guitastro | ||
22 | + pwd = os.getcwd() | ||
23 | + short_paths = ['../../../guitastro/src'] | ||
24 | + for short_path in short_paths: | ||
25 | + path = os.path.abspath(os.path.join(pwd, short_path)) | ||
26 | + if path not in sys.path: | ||
27 | + sys.path.insert(0, path) | ||
28 | + from guitastro.communications import Communication | ||
29 | + from guitastro.guitastrotools import GuitastroException, GuitastroTools | ||
30 | + from guitastro.ephemeris import Ephemeris | ||
31 | + | ||
32 | +# ##################################################################### | ||
33 | +# ##################################################################### | ||
34 | +# ##################################################################### | ||
35 | +# Class Device_Deltatau | ||
36 | +# ##################################################################### | ||
37 | +# ##################################################################### | ||
38 | +# ##################################################################### | ||
39 | + | ||
40 | +class Device_DeltatauException(GuitastroException): | ||
41 | + | ||
42 | + ERR_FILE_NOT_EXISTS = 0 | ||
43 | + ERR_COMMAND = 1 | ||
44 | + ERR_COMPONENT_NOT_FOUND = 2 | ||
45 | + | ||
46 | + errors = [""]*3 | ||
47 | + errors[ERR_FILE_NOT_EXISTS] = "The named file was not found" | ||
48 | + errors[ERR_COMMAND] = "Command error" | ||
49 | + errors[ERR_COMPONENT_NOT_FOUND] = "Component not found" | ||
50 | + | ||
51 | + | ||
52 | +class Device_Deltatau(Device_DeltatauException, GuitastroTools): | ||
53 | + """Driver for device DeltaTau | ||
54 | + | ||
55 | + All commands are linked to the same communication channel | ||
56 | + """ | ||
57 | + | ||
58 | + _real = False | ||
59 | + _chan = None | ||
60 | + | ||
61 | +# ===================================================================== | ||
62 | +# ===================================================================== | ||
63 | +# Private methods | ||
64 | +# ===================================================================== | ||
65 | +# ===================================================================== | ||
66 | + | ||
67 | +# ===================================================================== | ||
68 | +# ===================================================================== | ||
69 | +# Methods for experimented users (debug, etc) | ||
70 | +# ===================================================================== | ||
71 | +# ===================================================================== | ||
72 | + | ||
73 | +# ===================================================================== | ||
74 | +# ===================================================================== | ||
75 | +# Methods for users | ||
76 | +# ===================================================================== | ||
77 | +# ===================================================================== | ||
78 | + | ||
79 | + def open(self, real:bool): | ||
80 | + self._real = real | ||
81 | + if self._chan == None: | ||
82 | + host = dev._unit_params["HOST"] | ||
83 | + port = dev._unit_params["PORT"] | ||
84 | + chan = Communication("TCP", HOSTNAME = host, PORT = port, DELAY_PUT_READ = 0.1, REAL = real) | ||
85 | + chan.open_chan() | ||
86 | + self._chan = chan | ||
87 | + # - set the channel to all components | ||
88 | + components = self.components(True) | ||
89 | + for component in components: | ||
90 | + self._comp[component].channel = chan | ||
91 | + | ||
92 | + def close(self): | ||
93 | + if self._real == True: | ||
94 | + del(self._chan) | ||
95 | + self._chan = None | ||
96 | + # - reset the channel to all components | ||
97 | + components = self.components(True) | ||
98 | + for component in components: | ||
99 | + self._comp[component].channel = None | ||
100 | + | ||
101 | + def components(self, just_names: bool=False): | ||
102 | + """ Return a dictionary of components | ||
103 | + | ||
104 | + The key is the name of the component. | ||
105 | + The value is a tupple: | ||
106 | + | ||
107 | + * category | ||
108 | + * Python access to the object | ||
109 | + | ||
110 | + """ | ||
111 | + if just_names==True: | ||
112 | + return list(self._comp.keys()) | ||
113 | + dico = {} | ||
114 | + for name, comp in self._comp.items(): | ||
115 | + category = comp.category | ||
116 | + dico[name] = (category, comp) | ||
117 | + return dico | ||
118 | + | ||
119 | + def commandstring(self, cmd:str): | ||
120 | + """Execute a command as a string entry | ||
121 | + """ | ||
122 | + cmds = shlex.split(cmd) | ||
123 | + component_name = cmds[0] | ||
124 | + action = cmds[1].upper() | ||
125 | + args = cmds[2:] | ||
126 | + return self.command(component_name, action, *args) | ||
127 | + | ||
128 | + def command(self, component_name:str, action:str, *args, **kwargs): | ||
129 | + """Execute a command as a string entry | ||
130 | + """ | ||
131 | + components = self.components(True) | ||
132 | + if component_name not in components: | ||
133 | + msg = f"Component {component_name} not found amongst {components}" | ||
134 | + raise Device_DeltatauException(Device_DeltatauException.ERR_COMPONENT_NOT_FOUND, msg) | ||
135 | + try: | ||
136 | + result = self._comp[component_name].command(action, *args, **kwargs) | ||
137 | + except: | ||
138 | + msg = f"Problem with component {component_name} command {action} {args} {kwargs}" | ||
139 | + raise Device_DeltatauException(Device_DeltatauException.ERR_COMMAND, msg) | ||
140 | + return result | ||
141 | + | ||
142 | +# ===================================================================== | ||
143 | +# ===================================================================== | ||
144 | +# Special methods | ||
145 | +# ===================================================================== | ||
146 | +# ===================================================================== | ||
147 | + | ||
148 | + def __init__(self, *args, **kwargs): | ||
149 | + """ | ||
150 | + Conversion from Uniform Python object into protocol language | ||
151 | + Usage : Mountastro("HADEC", name="SCX11") | ||
152 | + """ | ||
153 | + # === Decode params | ||
154 | + # --- Use the __init__ of the parent class Mountastro | ||
155 | + #super(Device_Deltatau,self).__init__(*args, **kwargs) | ||
156 | + # --- Special params for this mount | ||
157 | + # --- Dicos of optional and mandatory parameters | ||
158 | + params_optional = {} | ||
159 | + # --- special SCX11 for TALK function | ||
160 | + params_optional["NAME"] = (str, "Unknown") | ||
161 | + params_optional["CONTROLLER_BASE_ID"] = (int, 1) | ||
162 | + params_optional["CONTROLLER_POLAR_ID"] = (int, 2) | ||
163 | + params_optional["CONTROLLER_FOCUS_ID"] = (int, 3) | ||
164 | + params_optional["CONTROLLER_FILTER_ID"] = (int, 4) | ||
165 | + | ||
166 | + # --- Dico of unit_types and their parameters | ||
167 | + unit_types = {} | ||
168 | + # --- unit choice | ||
169 | + unit_types["TCA"] = {"MANDATORY" : {}, "OPTIONAL" : {"HOST":[str,"192.168.30.41"], "PORT":[int,1025]} } | ||
170 | + unit_types["TCH"] = {"MANDATORY" : {}, "OPTIONAL" : {"HOST":[str,"192.168.10.46"], "PORT":[int,1025]} } | ||
171 | + # --- Decode args and kwargs parameters | ||
172 | + self._unit_params = self.decode_args_kwargs(0, unit_types, params_optional, *args, **kwargs) | ||
173 | + # === | ||
174 | + self.unit_type = self._unit_params["SELECTED_ARG"] | ||
175 | + name = self._unit_params["NAME"] | ||
176 | + # --- init ephemeris | ||
177 | + eph = Ephemeris() | ||
178 | + if self.unit_type=="TCA": | ||
179 | + eph.set_home("910") | ||
180 | + name = self.unit_type | ||
181 | + lim_inf = 1000 | ||
182 | + lim_sup = 33000 | ||
183 | + elif self.unit_type=="TCH": | ||
184 | + eph.set_home("262") | ||
185 | + name = self.unit_type | ||
186 | + lim_inf = 1000 | ||
187 | + lim_sup = 33000 | ||
188 | + else: | ||
189 | + name = self._unit_params["NAME"] | ||
190 | + lim_inf = 1000 | ||
191 | + lim_sup = 33000 | ||
192 | + # === Instanciate components of the device | ||
193 | + self._comp = {} | ||
194 | + # --- init component detector focuser | ||
195 | + self._comp["focuser"] = ComponentDetectorFocuserDeltatau("Z", name=name, model="Umac", manufacturer="DeltaTau", description="4 axis controler", lim_inf=lim_inf, lim_sup=lim_sup) | ||
196 | + self._comp["focuser"].command("SET", "lim_inf", lim_inf) | ||
197 | + self._comp["focuser"].command("SET", "lim_sup", lim_sup) | ||
198 | + self._comp["focuser"].command("SET", "CONTROLLER_FOCUS_ID", self._unit_params["CONTROLLER_FOCUS_ID"]) | ||
199 | + # --- init component mount pointing | ||
200 | + self._comp["mount"] = ComponentMountPointingDeltatau("HADEC", name=name, model="Umac", manufacturer="DeltaTau", description="4 axis controler", configuration="fork") | ||
201 | + self._comp["mount"]._eph.set_home(eph.home.gps) | ||
202 | + self._comp["mount"].command("SET", "CONTROLLER_BASE_ID", self._unit_params["CONTROLLER_BASE_ID"]) | ||
203 | + self._comp["mount"].command("SET", "CONTROLLER_POLAR_ID", self._unit_params["CONTROLLER_POLAR_ID"]) | ||
204 | + | ||
205 | + def __del__(self): | ||
206 | + try: | ||
207 | + self.close() | ||
208 | + except: | ||
209 | + pass | ||
210 | + | ||
211 | +# ##################################################################### | ||
212 | +# ##################################################################### | ||
213 | +# ##################################################################### | ||
214 | +# Main | ||
215 | +# ##################################################################### | ||
216 | +# ##################################################################### | ||
217 | +# ##################################################################### | ||
218 | + | ||
219 | +if __name__ == "__main__": | ||
220 | + default = 0 | ||
221 | + example = input(f"Select the example (0 to 0) ({default}) ") | ||
222 | + try: | ||
223 | + example = int(example) | ||
224 | + except: | ||
225 | + example = default | ||
226 | + | ||
227 | + print("Example = {}".format(example)) | ||
228 | + | ||
229 | + if example == 0: | ||
230 | + """ | ||
231 | + Basic example | ||
232 | + """ | ||
233 | + #home = Home("GPS 2.0375 E 43.6443484725 136.9") | ||
234 | + #site = Siteobs(home) | ||
235 | + dev = Device_Deltatau("TCA") | ||
236 | + print("Components are:") | ||
237 | + for key, val in dev.components().items(): | ||
238 | + print(f" * {key} of type {val[0]}") | ||
239 | + dev.open(False) | ||
240 | + dev.commandstring("mount SET target 'RADEC 12h56m -10d23m'") | ||
241 | + dev.commandstring("mount DO RADEC_GOTO") | ||
242 | + res = dev.commandstring("mount GET motion") | ||
243 | + res = dev.commandstring("focuser GET motion") | ||
244 | + |