Commit 2102cd68 authored by vertighel's avatar vertighel
Browse files

First commit, layer 1

parent 0bbe0457
Loading
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line

# Specific file to ignore
nodes.ini
ob/*json

*~
*#
.#*

# Emacs specific files
*~        # Backup files (e.g., file.txt~)
\#*
.#*       # Lock files (e.g., .#file.txt)
*.elc     # Compiled Emacs Lisp files
auto-save-list # Auto-save-list directory

README.md

0 → 100644
+195 −0
Original line number Diff line number Diff line
# software-di-controllo

Instrument Control Software for small class observatory.
Currently in use at OARPAF

## Python dependencies:

```
# For the core routines:
pip3 install requests loguru astropy
pip3 install gnuplotlib pyvantagepro # maybe I'll drop these.

# For the API:
pip3 install flask flask-restx werkzeug
# Tested with flask==3.0.2 werkzeug-3.0.1 flask-restx==1.3.0 

# For the web interface:
pip3 install flask flask-socketio flask-httpauth
# Tested with flask==3.0.2 werkzeug-3.0.1 flask-socketio==5.3.6 flask-httpauth==4.8.0

```

## Add the nodes of your observatory:

For example, in `config/nodes.ini`:

```
[MY_ASCOM_REMOTE_SERVER]
protocol = http
ip = 192.168.1.111
hostname = ascom.myobservatory.net
port = 533
endpoint = /api/v1

[MY_SONOFF_ADDRESS]
protocol = https
user = admin
password = admin
ip = 192.168.1.222
hostname = sonoff.myobservatory.net
port = 1234

```

## Connect the devices in your observatory to the nodes:

For example, in `config/devices.ini`:

```
[my_tel]            
module = alpaca 
class = Telescope
node = MY_ASCOM_REMOTE_SERVER   

[my_dome]            
module = alpaca  
class = Dome    
node = MY_ASCOM_REMOTE_SERVER

[my_light]
module = domotics
class = Switch
node = MY_SONOFF_ADDRESS
outlet = 3

[my_dome_temperature]
module = domotics
class = Sensor
node = MY_SONOFF_ADDRESS
outlet1 = 1
outlet2 = 2

```

## Low-level control of your devices using ipython:

```

import devices
devices.my_dome.azimuth # 123
devices.my_dome.azimuth = 234

```

## Give to every device a REST API endpoint, or more

For example, in `config/api.ini`:

```
[/dome/position]
resource = Position
device = my_dome


[/dome/light]
resource = State
device = my_light

[/alias/to/light]
resource = State
device = my_light

[/dome/temperature]
resource = State
device = my_dome_temperature

[/telescope/coordinates]
resource = Coordinates
device = my_tel

```

## REST API-level control of your devices using curl:

First, start the API server with `./app.py 1111 localhost --noweb`

```
curl http://localhost:1111/api/dome/position

# {
#   "error" : [],
#   "raw" : true,
#   "response" : {
#      "azimuth" : 123.00,
#      "parked" : "Yes"
#   },
#   "timestamp" : "2024-03-26T16:48:13.766195"
# }

# other examples:

# Change azimuth
curl -X POST http://localhost:1111/api/dome/position -d '234' -H 'Content-Type:application/json'

# Retrieve all GET endpoints relative to the dome 
curl http://localhost:1111/all/dome

```

## Web-based control of your observatory:

Doc in progress

# Dome board:

```
sudo apt-get install python-dev libusb-dev swig libwxgtk3.0-gtk3-dev
git clone https://github.com/rm-hull/k8055.git
cd k8055

sed -i.bak 's/CC = gcc/CC = g++/' Makefile
sed -i.bak 's/\t/    /g' pyk8055/pyk8055.py
sed -i.bak 's/IOError, "Could not open device"/IOError("Could not open device")/g' pyk8055/pyk8055.py

make all
sudo make install
make pylib k8055gui
sudo make pyinstall guiinstall
```

# Dome software + Alpaca driver:
```
git clone https://github.com/lfini/SW-OPC-2.git
```

## git configuration on observatory pc

To push directly on observatory pc (for people without access to INAF repo)

```
# on obseravatory pc
git config receive.denyCurrentBranch updateInstead

# on local machine
git remote add machine user@machine:software-di-controllo
git push machine main
```

## System dependencies:

```
sudo apt install gnuplot gnupot-x11
sudo /home/zap/MBB/mbb -w 9000 -i 22000 -l /home/zap/MBB/mbb.log 10.185.119.248
```

# Branches:

- main
- dev

[![pipeline status](https://www.ict.inaf.it/gitlab/davide.ricci/software-di-controllo/badges/main/pipeline.svg)](https://www.ict.inaf.it/gitlab/davide.ricci/software-di-controllo/commits/main)

[![Latest Release](https://www.ict.inaf.it/gitlab/davide.ricci/software-di-controllo/-/badges/release.svg)](https://www.ict.inaf.it/gitlab/davide.ricci/software-di-controllo/-/releases)

+2 −0
Original line number Diff line number Diff line
__version__ = "0.1.1" # Updated version
print(f"Noctua package v{__version__} initializing (revised)...")

noctua/config/api.ini

0 → 100644
+275 −0
Original line number Diff line number Diff line

# #####################################################
# [/my/endpoint/name]    # You choose
# resource = class implementing a CRUD operation
# device =  You defined it in devices.ini
# get-priority = defines a GET hierarchy.
# #####################################################

##############
# dome
##############

[/dome/connection]
resource = Connection
device = dom
get-priority = 1

[/dome/light]
resource = State
device = light

[/dome/shutter]
resource = Shutter
device = dom

[/dome/shutter/movement]
resource = ShutterMovement
device = dom

[/dome/position]
resource = Position
device = dom

[/dome/position/movement]
resource = PositionMovement
device = dom

[/dome/position/movement/park]
resource = PositionMovementPark
device = dom

[/dome/position/movement/azimuth]
resource = PositionMovementAzimuth
device = dom

[/dome/position/slaved]
resource = PositionSlaved
device = dom

[/dome/position/sync]
resource = PositionSync
device = dom

##############
# telescope
##############

[/telescope/power]
resource = State
device = cab
get-priority = 1

[/telescope/clock]
resource = Clock
device = tel
get-priority = 2

[/telescope/lamp]
resource = State
device = lamp

[/telescope/cover]
resource = Cover
device = tel

[/telescope/cover/movement]
resource = CoverMovement
device = tel

[/telescope/coordinates]
resource = Coordinates
device = tel

[/telescope/coordinates/movement]
resource = CoordinatesMovement
device = tel

[/telescope/coordinates/movement/radec]
resource = CoordinatesMovementRadec
device = tel

[/telescope/coordinates/movement/altaz]
resource = CoordinatesMovementAltaz
device = tel

[/telescope/coordinates/movement/atpark]
resource = CoordinatesMovementAtpark
device = tel

[/telescope/coordinates/movement/park]
resource = CoordinatesMovementPark
device = tel

[/telescope/coordinates/movement/unpark]
resource = CoordinatesMovementUnpark
device = tel

[/telescope/coordinates/offset]
resource = CoordinatesOffset
device = tel

[/telescope/coordinates/tracking]
resource = CoordinatesTracking
device = tel

[/telescope/connection]
resource = Connection
device = tel

[/telescope/error]
resource = Error
device = tel

[/telescope/error/details]
resource = ErrorDetails
device = tel

[/telescope/focuser]
resource = Focuser
device = foc

[/telescope/focuser/movement]
resource = FocuserMovement
device = foc

[/telescope/rotator]
resource = Rotator
device = rot

[/telescope/rotator/movement]
resource = RotatorMovement
device = rot

##############
# camera
##############

[/camera/power]
resource = State
device = sof
get-priority = 1

[/camera/frame/binning]
resource = FrameBinning
device = cam

[/camera/cooler]
resource = Cooler
device = cam

# [/camera/cooler/fan]
# resource = CoolerFan
# device = cam

# [/camera/cooler/temperature]
# resource = CoolerTemperature
# device = cam

[/camera/cooler/temperature/setpoint]
resource = CoolerTemperatureSetpoint
device = cam

[/camera/filters]
resource = Filters
device = cam

[/camera/filter]
resource = Filter
device = cam

[/camera/filter/movement]
resource = FilterMovement
device = cam

# [/camera/frame]
# resource = Frame
# device = cam

[/camera/frame/custom]
resource = FrameCustom
device = cam

[/camera/frame/full]
resource = FrameFull
device = cam

[/camera/frame/half]
resource = FrameHalf
device = cam

[/camera/frame/small]
resource = FrameSmall
device = cam

# [/camera/frame/temperature]
# resource = FrameTemperature
# device = cam

[/camera/snapshot]
resource = Snapshot
device = cam

[/camera/snapshot/state]
resource = SnapshotState
device = cam

[/camera/snapshot/acquisition]
resource = SnapshotAcquisition
device = cam

[/camera/snapshot/recenter]
resource = SnapshotRecenter
device = cam

[/camera/snapshot/domeslewing]
resource = SnapshotDomeslewing
device = cam

[/camera/cooler/warmup]
resource = CoolerWarmup
device = cam

[/camera/settings]
resource = Settings
device = cam

# [/camera/status]
# resource = Status
# device = cam

##############
# webcam
##############

[/webcam/snapshot]
resource = Snapshot
device = ipcam

[/webcam/position]
resource = Pointing
device = ipcam

##############
# environment
##############

# [/environment/external/telescope]
# resource = Temperature
# device = tel_temp

# [/environment/internal/telescope]
# resource = Temperature
# device = tel_temp

# [/environment/internal/fork]
# resource = Temperature
# device = fork

# [/environment/internal/rack]
# resource = Temperature
# device = fork

# [/environment/internal/reception]
# resource = Temperature
# device = rec
+140 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Telescope

lat = 44.5912  # [°] Latitude North from Greenwich.
lon = 9.2034  # [°] Longitude East from Greenwich.
alt = 1469  # [m] Altitude above sea level.

############
# Dome
############

dome_park_position = 57 # azimuth
telescope_flat_position = [24, 240] # alt, az to point the screen with dome parked

open_state = {
    0: "Open",
    1: "Closed",
    2: "Opening",
    3: "Closing",
    4: "Error",
    None: "Off",
}

yes_no = {
    True: "Yes",
    False: "No",
    None: "N/A",
}

############
# Switches
############

on_off = {
    True: "On",
    False: "Off",
    None: "N/A",
}

############
# Camera
############

xmax = [0, 4145]  # max xrange in binning 1.
ymax = [0, 4126]  # max yrange in binning 1.

pixscale = 0.283  # arcsec/px in binning 1. From a resolved FITS
rotangle = -89.67  # -90 # typical rotation angle. From a resolved FITS

temp_fits = "temp.fits"
temp_fits0 = "temp0.fits"

filter_state = {
    0: "Idle",
    1: "Moving",
    2: "Error",
    None: "Off",
}

filter_name = {
    0: "Undef.",
    1: "U",
    2: "B",
    3: "V",
    4: "R",
    5: "I",
    6: "Halpha",
    7: "Free",
    15: "Filter_error",
    None: "Off",
}

# Reversing filter_name
filter_number = {v: k for k, v in filter_name.items()}

camera_state = {
    0: "Idle",
    2: "Exposing",
    3: "Readout",
    5: "Error",
    None: "Off",
}

# Reversing camera state
camera_number = {v: k for k, v in camera_state.items()}

frame_type = {
    0: "Dark",
    1: "Light",
    2: "Bias",
    3: "Flat",
}

# Reversing frame_type
frame_number = {v: k for k, v in frame_type.items()}

image_state = {
    0: "Not ready for download",
    1: "Ready for download",
}

# Reversing image_state
image_number = {v: k for k, v in image_state.items()}

############
# Directories
############

data_folder = "data"
fits_folder = "fits"
focus_folder = "focus"
log_folder = "log"

dir_type = {
    0: "dark",
    1: "object",
    2: "bias",
    3: "flat",
}

# Reversing dir_type
dir_number = {v: k for k, v in dir_type.items()}

############
# FITS
############

# keywords
imagetyp = "IMAGETYP"  # 'Light'
dateobs = "DATE-OBS"  # '2021-12-18T05:09:56.163'

# File prefix
prefix = "OARPAF."

# File extension
ext = ".fits"
log_ext = ".log"
focus_ext = ".foc"
Loading