# PYROS (PYthon Robotic Observatory System)
A Python software for the management of a Telescope control center

COPYRIGHT (C) 2012-2018 IRAP (Institut de Recherche en Astrophysique et Planetologie) Toulouse - France

Authors : etienne.pallier@irap.omp.eu, alain.klotz@irap.omp.eu, patrick.maeght@irap.omp.eu, paul.carensac@epitech.eu, alexandru.burlacu11@gmail.com, jeremy.barneron@gmail.com, quentin.durand@epitech.eu

GPL License (http://www.gnu.org/copyleft/gpl.html) - See the file LICENSE.txt

This software runs with Python 3 and Django 2

To install it, go into the "install/" folder, and read the document INSTALLATION 
(better is to go to https://docs.google.com/document/d/1m7wUGMUPNPE2gdsQNLILDeF738oIk9OlQjVjNzQyWA8/edit#heading=h.aqi3gs3yp2s3)

This file is written in the markdown format (see https://openclassrooms.com/en/courses/1304236-redigez-en-markdown, https://michelf.ca/projets/php-markdown/syntaxe, https://daringfireball.net/projects/markdown/syntax)

-----------------------------------------------------------------------------------------------------------
## Tested platforms

This software has been tested and validated with the following configurations :

- Centos 7 (test server planetoweb2) :
	- Python: 3.5
	- Mysql:
	- Apache:

- Ubuntu 14LTS (Paul Carensac's laptop) :
	- Python: 3.5
	- Mysql: 5.5.46
	- Apache:

- Ubuntu 16.04 LTS (Jérémy Barneron's laptop) :
	- Python: 3.5.2
	- Mysql: 5.7.15
	- Apache: 2.4.18
	- Django: 1.10.2

- Mac OS 10.11.4 (Etienne Pallier's laptop)
	- Python: 3.5
	- XAMPP for OS X 5.6.3, which comes with :
		- MySQL: 5.6.21
		- Apache 2.4.10

--------------------------------------------------------------------------------------------
## Project structure (OBSOLETE)

    - src/ : conteneur du projet (le nom est sans importance)
    	- manage.py : utilitaire en ligne de commande permettant differentes actions sur le projet
    	- pyros/ : the actual Python package of the project
    		- settings.py : project settings and configuration
	    	- urls.py : déclaration des URLs du projet
    		- wsgi.py : point d'entrée pour déployer le projet avec WSGI

	- database/ : database configuration and documentation

	- doc/ : project documentation

	- install/ : project installation howto

	- private/ : the content of this folder is private and thus not commited to git ; it should contain your Python3 virtual environment
	
	- simulators/ : the devices simulators

	- public/ : this folder contains all public files like the web html files
		- static/

--------------------------------------------------------------------------------------------
## LAST VERSION

Date: 19/06/2019

Author: E. Pallier (epallier@irap.omp.eu)

VERSION: 0.30.12

Comment :
- "./pyros install -p -d" => (-p = --packages_only ; -d = --database_only)
 

	RAPPELS SUR L'UTILISATION :
	
	- (TEST) Scenarios de test :
		1) ./pyros test
		2) ./pyros testall
		3) Lancer agents A et B en mode simu (option -t): 
			./pyros.py -t start agentA,agentB
			Attendre 1 à 2mn jusqu'à obtenir les 2 résultats suivants:
			(AgentA): Finished testing => result is ok
			(AgentB): Finished testing => result is ok
		4) Lancer agentDevice et agentTelescopeRequester en mode simu (-t) :
			./pyros.py -t start agentTelescopeRequester,agentDevice
		
	- (RUN) Mode opératoire pour lancer un agent (en mode normal, hors test) :
		- pour lancer agentA seulement : ./pyros.py start agentA [-c configfile]
		- pour lancer plusieurs agents : ./pyros.py start agentA,agentB,... [-c configfile]
		(ou encore: activer l'environnement virtuel, puis lancer "cd src/.../agent/ ; ./AgentA.py configfile")
		- pour utiliser thread ou processus : il suffit de mettre la constante RUN_IN_THREAD de AgentA (ou AgentB ou AgentX) à False ou True
	
--------------------------------------------------------------------------------------------
- TECHNICAL DOC: tinyurl.com/pyros-doc
- CURRENT STATUS (TODO LIST) : https://projects.irap.omp.eu/projects/pyros/issues?query_id=257
- CURRENT VERSION (v0.20): https://projects.irap.omp.eu/versions/208
- ROADMAP: https://projects.irap.omp.eu/projects/pyros/roadmap
- (OLD DEV PLAN: https://docs.google.com/spreadsheets/d/1Gy6c-9fhUDBx5Bc6YrcGvfgP-HukWdhUh8oT11_y88g/edit#gid=664458270) 
- (OLD, TO BE UPDATED) https://projects.irap.omp.eu/versions/158

--------------------------------------------------------------------------------------------
## MAIN CHANGES HISTORY (MILESTONES):

Full list of commits: https://gitlab.irap.omp.eu/epallier/pyros/commits/master

(The new official changes history is here :  https://tinyurl.com/pyros-dev#heading=h.2r55bflctpt5)


**19/06/2019 : v0.30.11 (EP)**

	- Bugfixed AgentM
	- Named test database "test_pyros" explicitely
	- Keep test database test_pyros (do not delete it after tests)


**12/06-17/06/2019 : v0.30.3-9 (EP)**

	- Restructuration du projet - phase 1 : /src/ => /pyros_django/
	- Restructuration du projet - phase 2 : /pyros_django/ => /src/core/pyros_django/
	- Restructuration du projet - phase 3 : /devices_channel/ => /src/devices_controller/
	- Restructuration du projet - phase 4 : /src/core/pyros_django/utils/celme/ => /src/core/celme/
	- Restructuration du projet - phase 5a : /src/devices_controller/ => réorganisation interne 1/2 :
		- sortir /src/devices_controller/client/channel => /src/devices_controller/channel/
		- sortir /src/devices_controller/client/devices_abstract/ => /src/devices_controller/devices_abstract/
		- supprimer dossier client/
		- rename channel/ => channels/
		- rename devices_abstract/ => devices_controller_abstract_component/
	- Restructuration du projet - phase 5b : /src/devices_controller/ => réorganisation interne 2/2 :
		- create folder devices_controller/devices_controller_concrete/
		- migrer le dossier devices_controller/server/ => devices_controller/devices_controller_concrete/server/
		- rename server/ => device_simulator_common/	
	- Deplacement de tous les devices concrets dans leurs dossiers respectifs (Gemini, AK, ...)
	- Ajouté 2 HOWTO (pour test et run) à la racine du projet
	
	
**11/06/2019 : v0.30.2 (EP)**

	- Ajouté options "test" et "testall" dans pyros.py pour exécution des (anciens) tests unitaires
	- Restructuring : private/ => venv/


**26/04/19 : Version 0.20.42 (EP)**

	- plantUML diagrams créés récursivement dans les dossiers doc/


**Fin mars 19 : Version 0.20.40 ? (EP)**

	- AgentDeviceTelescopeStatus : 1 seule ligne mise à jour dans la table
	- AgentDevice + AgentDeviceTelescopeStatus + AgentTelescopeRequester :
		- AgentDevice met à jour la table AgentDeviceTelescopeStatus
		- AgentTelescopeRequester interroge AgentDevice
		- Mode opératoire:
			./pyros start agentDevice
			ou, en mode simu:
			./pyros -t start agentTelescopeRequester,agentDevice 	
	- Génération automatique des diagrammes PlantUML avec "pyros update"
	- Implémentation complète du "Command state diag"
	- Nouveaux diagrammes UML pour Command (state diag) et Agent (activity diag)
	- Déplacé AgentM dans src/monitoring/ (pyros start agentM)
	- Implémenté la commande "restart_init" (voir doc "play with a pyros agent") et refactorisation de run()
	- Implémenté le "abort" dans le simulateur
	- Optimisation log_agent_status() (ex update_survey())
	- AgentM (début) pour remplacer progressivement l'agent monitoring
	- routine_process() : envoi commande n'est plus bloquant
	- pyros.py peut lancer plusieurs agents (A et B) en même temps
	- run(N) : run only N iterations
	- send_command() implemented
	- EVAL is now a generic command
	- mode DEBUG (2 niveaux pour print)
	- flush_command : nouvelle commande pour purger les commmandes en attente
	- routine_process() implemented
	- Eval command implemented
	- self.print() pour les agents
	- Chaque agent a son propre scenario de commandes à envoyer
	- GROSSE OPTIMISATION : plus besoin du script intermédiaire "start_agent.py" !!!
		==> pyros.py lance directement "cd src/agent/ ; python AgentX.py"


**17/01/19 : Version 20190117.0.000.0 (EP)**

	- NO MORE CELERY (removed from everywhere)


**10/10/18 : Version 2018.0.011 (E. Pallier)**

	- NEW versionning plan : YYYYMMDD.M.mmm.b
		- YYYYMMDD = Day (UTC)
		- M = Major version number
		- mmm = Minor version number
		- b = Bugfix number
	- Global Version number is now in src/__init__.py (idem for each pyros application) 
	- new devices_channel/ folder containing the new DeviceControllerAbstract and ClientChannelAbstract classes (independant from pyros for the moment, but will soon be integrated)
	- new src/utils/celme (celestial mecanics) library from Alain Klotz (more and more used inside pyros)
	- better README.md formatted file


**14/05/18 : Version 2018.0.001 (Q. Durand)**
- Update all dependencies, update to django 2 and work in progress on the dashboard

**23/03/18	Version 0.16.11 (E. Pallier)**
- All unit tests now pass WITHOUT celery (./manage.py test or ./pyros.py test)

**22/03/18	Version 0.16.10 (E. Pallier)**
- New global variable USE_CELERY (false by default) in pyros.settings

**13/03/18	Version 0.16.7 (E. Pallier)**
- Each agent (envmonitor, majordome, alert) can be started independently with a script (new script start_agent in each agent directory)
- New command "pyros start" to start pyros in different ways (different options : everything or only some components)

**22/02/18	Version 0.16.5 (E. Pallier)**
- Better isolation of Monitoring for easier testing (+ tuto)

**01/02/18	Version 0.16.3 (Q. Durand)**
- New installation script src/install/install.py multiplatform (Lin-Mac-Win10, but also tested on Win7)
			
**24/02/17    Version 0.15.1 - Added comments (Jeremy Barneron)**
- Details added to describe the functions behavior
- https://projects.irap.omp.eu/versions/158

**18/01/17    Version 0.15 - Execution with simulators**
- Simulators evolution / majordome / monitoring / installer
- https://projects.irap.omp.eu/versions/158

**15/12/16    Version 0.14.1 - Final version 0.14**
- Scenarist first versions
- https://projects.irap.omp.eu/versions/152

02/08/16	Version 0.12.4 - Final version 0.12
			Simulators first versions
			https://projects.irap.omp.eu/versions/129

20/07/16	Version 0.11.4 - Final version 0.11
			Alert manager second version
			https://projects.irap.omp.eu/versions/128

05/07/16	Version 0.10.2 - Final version 0.10
			Monitoring first version
			https://projects.irap.omp.eu/versions/120

05/07/16	Version 0.9.2 - Final version 0.9
			Analysis skeleton
			https://projects.irap.omp.eu/versions/119

28/06/16	Version 0.8.3 - Final version 0.8
			Execution (majordome & obs manager), first version
			https://projects.irap.omp.eu/versions/118

23/06/16		Version 0.7.8 - Final version 0.7
			Routine manager, first version
			https://projects.irap.omp.eu/versions/117

20/05/16		Version 0.6.1 - Final version 0.6
			Complete user management
			https://projects.irap.omp.eu/versions/123

20/05/16		Version 0.5.4 - Final version 0.5
			Complete alert manager first version
			https://projects.irap.omp.eu/versions/116

20/05/16		Version 0.4.2 - Final version 0.4
			Complete scheduler update
			https://projects.irap.omp.eu/versions/90

10/05/16		Version 0.3.12 - Final version 0.3
			Complete workflow skeleton
			https://projects.irap.omp.eu/versions/88

13/04/16		Version 0.2.7 - Final version 0.2
			Integrate PLANNER module
			https://projects.irap.omp.eu/versions/97

12/04/16		Version 0.1.1 - Final version 0.1
			Multi-platform skeleton easy install + admin interface on database + start dashboard
			https://projects.irap.omp.eu/versions/87

04/04/16 	Installable version (install script)


--------------------------------------------------------------------------------------------
## TODO LIST (URGENT)

DEMO:
- SIMULATOR: 
    - (AC) réserver cette page à un login superuser sinon n'importe qui pourra faire n'importe quoi à distance...
    - 1) PLC : 
        - ajouter boutons "START" et "STOP"
        - implémenter weather et site OK/KO
    - 2) TELE : implémenter "start" et "stop"
    - 3) General : implement set to night/day