Commit bb697c3148b03475cadfed5f68d64a57d5a500b5
1 parent
eebd68b3
Exists in
dev
Auto stash before merge of "dev" and "origin/dev"
Showing
13 changed files
with
96 additions
and
33 deletions
Show diff stats
... | ... | @@ -0,0 +1,14 @@ |
1 | +import json | |
2 | + | |
3 | +def main(): | |
4 | + with open('grammar.json', 'r') as f: | |
5 | + #print(f) | |
6 | + content = json.load(f) | |
7 | + content = content["Telescope"]["set"][0]["input_label"][0]["R.A."][0] | |
8 | + print(content) | |
9 | + #for c in content: | |
10 | + #print (c["R.A."]) | |
11 | + #print("\n") | |
12 | + | |
13 | + | |
14 | +main() | ... | ... |
... | ... | @@ -0,0 +1,14 @@ |
1 | +import json | |
2 | + | |
3 | +def main(): | |
4 | + with open('grammar.json', 'r') as f: | |
5 | + #print(f) | |
6 | + content = json.load(f) | |
7 | + content = content["Telescope"]["set"][0]["input_label"][0]["R.A."] | |
8 | + print(content) | |
9 | + #for c in content: | |
10 | + #print (c["R.A."]) | |
11 | + #print("\n") | |
12 | + | |
13 | + | |
14 | +main() | ... | ... |
src/common/models.py
... | ... | @@ -2,6 +2,7 @@ from __future__ import unicode_literals |
2 | 2 | |
3 | 3 | from django.contrib.auth.models import AbstractUser |
4 | 4 | from django.db import models |
5 | +from enum import Enum | |
5 | 6 | |
6 | 7 | class Album(models.Model): |
7 | 8 | sequence = models.ForeignKey( |
... | ... | @@ -819,14 +820,18 @@ class WeatherWatchHistory(models.Model): |
819 | 820 | return (str(self.datetime)) |
820 | 821 | |
821 | 822 | |
823 | +class PyrosState(Enum): | |
824 | + START = 'Starting' | |
825 | + PA = 'Passive' | |
826 | + INI = "INIT" | |
827 | + STAND = "Standby" | |
828 | + SCHED_START = 'Scheduler startup' | |
829 | + SCHED = 'Scheduler' | |
830 | + SCHED_CLOSE = 'Scheduler closing' | |
831 | + | |
822 | 832 | class Config(models.Model): |
823 | - SCHEDULER_STATE = ( | |
824 | - ('0', 'init'), | |
825 | - ('1', 'sleeping'), | |
826 | - ('2', 'startup'), | |
827 | - ('3', 'observing'), | |
828 | - ('4', 'shutdown'), | |
829 | - ) | |
833 | + SCHEDULER_STATE = ["Starting", 'Passive', "INIT", "Standby", 'Scheduler startup','Scheduler', 'Scheduler closing' ] | |
834 | + | |
830 | 835 | id = models.IntegerField(default='1', primary_key=True) |
831 | 836 | latitude = models.FloatField(default=1) |
832 | 837 | local_time_zone = models.FloatField(default=1) |
... | ... | @@ -842,7 +847,7 @@ class Config(models.Model): |
842 | 847 | global_mode = models.BooleanField(default='True') |
843 | 848 | ack = models.BooleanField(default='False') |
844 | 849 | bypass = models.BooleanField(default='True') |
845 | - scheduler_state = models.CharField(max_length=1, choices=SCHEDULER_STATE, default=0) | |
850 | + pyros_state = models.CharField(max_length=25, default=SCHEDULER_STATE[0]) | |
846 | 851 | force_passive_mode = models.BooleanField(default='False') |
847 | 852 | plc_timeout_seconds = models.PositiveIntegerField(default=60) |
848 | 853 | ... | ... |
src/dashboard/templates/dashboard/operator_state.html
... | ... | @@ -92,12 +92,8 @@ |
92 | 92 | <br><br><br> |
93 | 93 | <div class="text-center"> |
94 | 94 | <a id="button" class="btn btn-primary btn-lg" href="{% url "change_globalMode" %}" onclick="return confirm('Are you sure you want to switch the controller mode ?')"> {% global_mode_state request %} </a> |
95 | - <br> <a id="button" class="btn btn-primary btn-lg" href="{% url "change_ack" %}" onclick="return confirm('Are you sure you want to acknowledge for the next night ?')"> {% ack request %} </a> | |
96 | - {% if config.bypass == True %} | |
97 | - <br> <a id="button" class="btn btn-danger btn-lg" href="{% url "change_bypass" %}" onclick="return confirm('Are you sure you want to bypass the Plc ?')"> {% bypass request %} </a> | |
98 | - {% else %} | |
99 | - <br> <a id="button" class="btn btn-primary btn-lg" href="{% url "change_bypass" %}" onclick="return confirm('Are you sure you want to remove the plc bypass')"> {% bypass request %} </a> | |
100 | - {% endif %} | |
95 | + <br> <a id="button" class="btn btn-danger btn-lg" href="{% url "change_bypass" %}" onclick="return confirm('Are you sure you want to bypass the Plc ?')"> {% bypass request %} </a> | |
96 | + | |
101 | 97 | </div> |
102 | 98 | |
103 | 99 | {% endblock %} |
104 | 100 | \ No newline at end of file | ... | ... |
src/dashboard/templates/dashboard/send_command_telescope.html
... | ... | @@ -98,9 +98,11 @@ |
98 | 98 | </div> |
99 | 99 | </div> |
100 | 100 | </div> |
101 | + <script> var data = {{ json_str | safe }}</script> | |
101 | 102 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> |
102 | 103 | <script src="{% static "/js/command_control.js" %}" type=text/javascript></script> |
103 | 104 | <script> |
105 | + | |
104 | 106 | $( "#command_form" ).submit(function( event ) { |
105 | 107 | alert( "Handler for .submit() called." ); |
106 | 108 | event.preventDefault(); | ... | ... |
src/dashboard/templatetags/tags.py
1 | 1 | from django import template |
2 | -from common.models import Config, PyrosUser | |
2 | +from common.models import Config, PyrosUser, PyrosState | |
3 | 3 | |
4 | 4 | register = template.Library() |
5 | 5 | |
6 | 6 | @register.simple_tag |
7 | 7 | def global_mode(request): |
8 | 8 | try: |
9 | - if (Config.objects.get(id=1).global_mode == True): | |
10 | - return("SCHEDULER MODE") | |
11 | - else: | |
12 | - return("REMOTE MODE") | |
9 | + state = Config.objects.get(id=1).pyros_state | |
10 | + if state: | |
11 | + return state | |
12 | + raise Config.DoesNotExist | |
13 | 13 | except Config.DoesNotExist: |
14 | 14 | return ("NO CONFIG DB") |
15 | 15 | ... | ... |
src/dashboard/views.py
... | ... | @@ -104,7 +104,7 @@ def retrieve_main_icon(request): |
104 | 104 | if request.is_ajax(): |
105 | 105 | try: |
106 | 106 | weather_status = WeatherWatch.objects.latest('updated') |
107 | - plc_mode = PlcDeviceStatus.objects.latest('created').plc_mode | |
107 | + plc_mode = PlcDeviceStatus.objects.exclude(plc_mode=None).latest('created').plc_mode | |
108 | 108 | |
109 | 109 | weather = serializers.serialize('json', [weather_status]) |
110 | 110 | weather = json.loads(weather) |
... | ... | @@ -274,7 +274,11 @@ def change_activate(request, pk): |
274 | 274 | |
275 | 275 | @login_required |
276 | 276 | def send_command_to_telescope(request): |
277 | - return render(request, "dashboard/send_command_telescope.html") | |
277 | + data = "lol" | |
278 | + with open('../simulators/config/grammar.json') as f: | |
279 | + data = json.load(f) | |
280 | + json_str = json.dumps(data) | |
281 | + return render(request, "dashboard/send_command_telescope.html", locals()) | |
278 | 282 | |
279 | 283 | @login_required |
280 | 284 | def submit_command_to_telescope(request): | ... | ... |
src/misc/static/js/command_control.js
... | ... | @@ -3,6 +3,14 @@ var expert_mode = false; |
3 | 3 | |
4 | 4 | jQuery(document).ready(function(){ |
5 | 5 | |
6 | + var t = data["Telescope"]["set"][0]["input_label"][0]; | |
7 | + | |
8 | + | |
9 | + t.forEach(function(entry) { | |
10 | + //console.log(entry); | |
11 | + console.log("-------------------"); | |
12 | +}); | |
13 | + | |
6 | 14 | function command_set() |
7 | 15 | { |
8 | 16 | var form = $("#command_form"); | ... | ... |
src/misc/templates/base.html
... | ... | @@ -210,19 +210,13 @@ a { |
210 | 210 | $.get("{% url 'retrieve_env_navbar' %}", function (weather_status) { |
211 | 211 | if (weather_status) |
212 | 212 | { |
213 | - /* | |
214 | - *** totally arbitrary method for day/night cycle, just for demonstration | |
215 | - */ | |
216 | - //var hour = new Date().getTime(); | |
217 | - //var site_time = new Date(hour - 9 * 3600 * 1000).getHours(); | |
218 | - | |
219 | - var sunelev = parseInt(weather_status[0]['sunelev']); | |
213 | + var sunelev = parseFloat(weather_status[0]['sunelev']); | |
220 | 214 | var max_sunelev = parseInt(weather_status[0]['max_sunelev']); |
221 | 215 | |
222 | 216 | set_elev(sunelev); |
223 | 217 | change_color(sunelev, max_sunelev); |
224 | 218 | |
225 | - var _img_day_night =document.createElement('img'); | |
219 | + var _img_day_night = document.createElement('img'); | |
226 | 220 | if (sunelev >= max_sunelev) |
227 | 221 | _img_day_night.src ="{% static 'media/rising_sun.png' %}"; |
228 | 222 | else | ... | ... |
src/pyros/settings.py.bak
... | ... | @@ -53,7 +53,7 @@ SECRET_KEY = '0*@w)$rq4x1c2w!c#gn58*$*u$w=s8uw2zpr_c3nj*u%qlxc23' |
53 | 53 | # SECURITY WARNING: don't run with debug turned on in production! |
54 | 54 | DEBUG = True |
55 | 55 | |
56 | -ALLOWED_HOSTS = ['localhost'] | |
56 | +ALLOWED_HOSTS = ['localhost', '127.0.0.1'] | |
57 | 57 | |
58 | 58 | |
59 | 59 | # Application definition |
... | ... | @@ -85,13 +85,12 @@ INSTALLED_APPS = [ |
85 | 85 | #'kombu.transport.django' |
86 | 86 | ] |
87 | 87 | |
88 | -MIDDLEWARE_CLASSES = [ | |
88 | +MIDDLEWARE = [ | |
89 | 89 | 'django.middleware.security.SecurityMiddleware', |
90 | 90 | 'django.contrib.sessions.middleware.SessionMiddleware', |
91 | 91 | 'django.middleware.common.CommonMiddleware', |
92 | 92 | 'django.middleware.csrf.CsrfViewMiddleware', |
93 | 93 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
94 | - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | |
95 | 94 | 'django.contrib.messages.middleware.MessageMiddleware', |
96 | 95 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
97 | 96 | ] |
... | ... | @@ -120,12 +119,17 @@ FIXTURE_DIRS = ( |
120 | 119 | 'misc/fixtures/', |
121 | 120 | ) |
122 | 121 | |
122 | +EMAIL_HOST = 'smtp.gmail.com' | |
123 | +EMAIL_PORT = 587 | |
124 | +EMAIL_HOST_USER = 'colibricontrolcenter' | |
125 | +EMAIL_HOST_PASSWORD = '!ColibriCC31!' | |
126 | +EMAIL_USE_TLS = True | |
123 | 127 | LOGIN_URL = "/" |
124 | 128 | |
125 | 129 | ''' DO NOT TOUCH THESE VARIABLES |
126 | 130 | "$ pyros.py simulator_development" will automatically set them to "True" |
127 | 131 | ''' |
128 | -# FOR SIMULATOR (TODO: remove because not used) | |
132 | +# FOR SIMULATOR (htopTODO: remove because not used) | |
129 | 133 | SIMULATOR = True |
130 | 134 | # FOR SIMULATOR (and TESTS) |
131 | 135 | CELERY_TEST = False | ... | ... |