Commit 566039c515e9e1585a7ff3d1ad08d83f296272bf
Exists in
dev
Merge done
Showing
12 changed files
with
94 additions
and
30 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( |
... | ... | @@ -818,17 +819,18 @@ class WeatherWatchHistory(models.Model): |
818 | 819 | return (str(self.datetime)) |
819 | 820 | |
820 | 821 | |
822 | +class PyrosState(Enum): | |
823 | + START = 'Starting' | |
824 | + PA = 'Passive' | |
825 | + INI = "INIT" | |
826 | + STAND = "Standby" | |
827 | + SCHED_START = 'Scheduler startup' | |
828 | + SCHED = 'Scheduler' | |
829 | + SCHED_CLOSE = 'Scheduler closing' | |
830 | + | |
821 | 831 | class Config(models.Model): |
822 | - SCHEDULER_STATE = ( | |
823 | - ('0', 'starting'), | |
824 | - ('1', 'passive'), | |
825 | - ('2', 'Init'), | |
826 | - ('3', 'Standby'), | |
827 | - ('4', 'Scheduler startup'), | |
828 | - ('5', 'Scheduler'), | |
829 | - ('6', 'Scheduler closing'), | |
830 | - ('7', 'Passive'), | |
831 | - ) | |
832 | + SCHEDULER_STATE = ["Starting", 'Passive', "INIT", "Standby", 'Scheduler startup','Scheduler', 'Scheduler closing' ] | |
833 | + | |
832 | 834 | id = models.IntegerField(default='1', primary_key=True) |
833 | 835 | latitude = models.FloatField(default=1) |
834 | 836 | local_time_zone = models.FloatField(default=1) |
... | ... | @@ -844,7 +846,7 @@ class Config(models.Model): |
844 | 846 | global_mode = models.BooleanField(default='True') |
845 | 847 | ack = models.BooleanField(default='False') |
846 | 848 | bypass = models.BooleanField(default='True') |
847 | - pyros_state = models.CharField(max_length=1, choices=SCHEDULER_STATE, default=0) | |
849 | + pyros_state = models.CharField(max_length=25, default=SCHEDULER_STATE[0]) | |
848 | 850 | force_passive_mode = models.BooleanField(default='False') |
849 | 851 | plc_timeout_seconds = models.PositiveIntegerField(default=60) |
850 | 852 | ... | ... |
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
... | ... | @@ -100,7 +100,7 @@ def retrieve_main_icon(request): |
100 | 100 | if request.is_ajax(): |
101 | 101 | try: |
102 | 102 | weather_status = WeatherWatch.objects.latest('updated') |
103 | - plc_mode = PlcDeviceStatus.objects.latest('created').plc_mode | |
103 | + plc_mode = PlcDeviceStatus.objects.exclude(plc_mode=None).latest('created').plc_mode | |
104 | 104 | |
105 | 105 | weather = serializers.serialize('json', [weather_status]) |
106 | 106 | weather = json.loads(weather) |
... | ... | @@ -269,7 +269,11 @@ def change_activate(request, pk): |
269 | 269 | |
270 | 270 | @login_required |
271 | 271 | def send_command_to_telescope(request): |
272 | - return render(request, "dashboard/send_command_telescope.html") | |
272 | + data = "lol" | |
273 | + with open('../simulators/config/grammar.json') as f: | |
274 | + data = json.load(f) | |
275 | + json_str = json.dumps(data) | |
276 | + return render(request, "dashboard/send_command_telescope.html", locals()) | |
273 | 277 | |
274 | 278 | @login_required |
275 | 279 | 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
... | ... | @@ -216,19 +216,13 @@ a { |
216 | 216 | $.get("{% url 'retrieve_env_navbar' %}", function (weather_status) { |
217 | 217 | if (weather_status) |
218 | 218 | { |
219 | - /* | |
220 | - *** totally arbitrary method for day/night cycle, just for demonstration | |
221 | - */ | |
222 | - //var hour = new Date().getTime(); | |
223 | - //var site_time = new Date(hour - 9 * 3600 * 1000).getHours(); | |
224 | - | |
225 | - var sunelev = parseInt(weather_status[0]['sunelev']); | |
219 | + var sunelev = parseFloat(weather_status[0]['sunelev']); | |
226 | 220 | var max_sunelev = parseInt(weather_status[0]['max_sunelev']); |
227 | 221 | |
228 | 222 | set_elev(sunelev); |
229 | 223 | change_color(sunelev, max_sunelev); |
230 | 224 | |
231 | - var _img_day_night =document.createElement('img'); | |
225 | + var _img_day_night = document.createElement('img'); | |
232 | 226 | if (sunelev >= max_sunelev) |
233 | 227 | _img_day_night.src ="{% static 'media/rising_sun.png' %}"; |
234 | 228 | 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 | ... | ... |