1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -420,9 +420,10 class ABSConfiguration(Configuration): | |||||
420 | try: |
|
420 | try: | |
421 | data, address = sock.recvfrom(1024) |
|
421 | data, address = sock.recvfrom(1024) | |
422 | print (address, data) |
|
422 | print (address, data) | |
423 |
|
423 | data = data.decode("utf-8") | ||
424 | if data == '1': |
|
424 | if data == '1': | |
425 | status[int(address[0][10:])-1] = '3' |
|
425 | status[int(address[0][10:])-1] = '3' | |
|
426 | #print (int(address[0][10:])-1) | |||
426 | elif data == '0': |
|
427 | elif data == '0': | |
427 | status[int(address[0][10:])-1] = '1' |
|
428 | status[int(address[0][10:])-1] = '1' | |
428 | except socket.timeout: |
|
429 | except socket.timeout: | |
@@ -477,6 +478,7 class ABSConfiguration(Configuration): | |||||
477 | print('Inicia intento de salvar device.status') |
|
478 | print('Inicia intento de salvar device.status') | |
478 | self.device.status = 3 |
|
479 | self.device.status = 3 | |
479 | self.module_status = ''.join(status) |
|
480 | self.module_status = ''.join(status) | |
|
481 | #print(status) | |||
480 | self.save() |
|
482 | self.save() | |
481 | print('Estatus salvado') |
|
483 | print('Estatus salvado') | |
482 | conf_active, __ = ABSActive.objects.get_or_create(pk=1) |
|
484 | conf_active, __ = ABSActive.objects.get_or_create(pk=1) |
@@ -6,6 +6,9 import json | |||||
6 | from datetime import timedelta, datetime |
|
6 | from datetime import timedelta, datetime | |
7 | from celery.task import task |
|
7 | from celery.task import task | |
8 |
|
8 | |||
|
9 | from celery.utils.log import get_task_logger | |||
|
10 | logger = get_task_logger(__name__) | |||
|
11 | ||||
9 | @task(name='task_change_beam') |
|
12 | @task(name='task_change_beam') | |
10 | def task_change_beam(id_conf): |
|
13 | def task_change_beam(id_conf): | |
11 |
|
14 | |||
@@ -37,12 +40,12 def task_change_beam(id_conf): | |||||
37 | abs_conf.send_beam_num(i+1) |
|
40 | abs_conf.send_beam_num(i+1) | |
38 | next_beam.set_as_activebeam() |
|
41 | next_beam.set_as_activebeam() | |
39 | task = task_change_beam.apply_async((abs_conf.pk,), eta=date) |
|
42 | task = task_change_beam.apply_async((abs_conf.pk,), eta=date) | |
40 | print next_beam |
|
43 | print (next_beam) | |
41 | else: |
|
44 | else: | |
42 | abs_conf.send_beam_num(1) |
|
45 | abs_conf.send_beam_num(1) | |
43 | beams_list[0].set_as_activebeam() |
|
46 | beams_list[0].set_as_activebeam() | |
44 | task = task_change_beam.apply_async((abs_conf.pk,), eta=date) |
|
47 | task = task_change_beam.apply_async((abs_conf.pk,), eta=date) | |
45 | print beams_list[0] |
|
48 | print (beams_list[0]) | |
46 | i=0 |
|
49 | i=0 | |
47 |
|
50 | |||
48 | else: |
|
51 | else: |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -5,6 +5,13 from celery import task | |||||
5 | from datetime import timedelta, datetime |
|
5 | from datetime import timedelta, datetime | |
6 |
|
6 | |||
7 | from .models import Experiment |
|
7 | from .models import Experiment | |
|
8 | from celery import Celery | |||
|
9 | ||||
|
10 | from celery.utils.log import get_task_logger | |||
|
11 | ||||
|
12 | from django.utils import timezone | |||
|
13 | ||||
|
14 | logger = get_task_logger(__name__) | |||
8 |
|
15 | |||
9 | @task |
|
16 | @task | |
10 | def task_start(id_exp): |
|
17 | def task_start(id_exp): | |
@@ -17,6 +24,9 def task_start(id_exp): | |||||
17 | now = datetime.now() |
|
24 | now = datetime.now() | |
18 | start = datetime.combine(now.date(), exp.start_time) |
|
25 | start = datetime.combine(now.date(), exp.start_time) | |
19 | end = datetime.combine(now.date(), exp.end_time) |
|
26 | end = datetime.combine(now.date(), exp.end_time) | |
|
27 | print(now) | |||
|
28 | print(start) | |||
|
29 | print(end) | |||
20 | if end < start: |
|
30 | if end < start: | |
21 | end += timedelta(1) |
|
31 | end += timedelta(1) | |
22 | try: |
|
32 | try: | |
@@ -26,7 +36,7 def task_start(id_exp): | |||||
26 | print('Error') |
|
36 | print('Error') | |
27 | exp.status = 0 |
|
37 | exp.status = 0 | |
28 | if exp.status == 2: |
|
38 | if exp.status == 2: | |
29 |
task = task_stop.apply_async((id_exp,), |
|
39 | task = task_stop.apply_async((id_exp,),eta=end) #Antiguo eta=end+timedelta(hours=5)) | |
30 | exp.task = task.id |
|
40 | exp.task = task.id | |
31 | exp.save() |
|
41 | exp.save() | |
32 | return exp.status |
|
42 | return exp.status | |
@@ -44,7 +54,7 def task_stop(id_exp): | |||||
44 |
|
54 | |||
45 | now = datetime.now() |
|
55 | now = datetime.now() | |
46 | start = datetime.combine(now.date()+timedelta(1), exp.start_time) |
|
56 | start = datetime.combine(now.date()+timedelta(1), exp.start_time) | |
47 |
task = task_start.apply_async((id_exp, ), eta=start |
|
57 | task = task_start.apply_async((id_exp, ), eta=start) #Antiguo eta=start+timedelta(hours=5)) | |
48 | exp.task = task.id |
|
58 | exp.task = task.id | |
49 | exp.status = 3 |
|
59 | exp.status = 3 | |
50 | exp.save() |
|
60 | exp.save() | |
@@ -53,7 +63,7 def task_stop(id_exp): | |||||
53 | #Task to get status |
|
63 | #Task to get status | |
54 | @task |
|
64 | @task | |
55 | def task_status(id_exp): |
|
65 | def task_status(id_exp): | |
56 |
|
66 | print ("task status"+str(id_exp)) | ||
57 | exp = Experiment.objects.get(pk=id_exp) |
|
67 | exp = Experiment.objects.get(pk=id_exp) | |
58 | if exp.status==2: |
|
68 | if exp.status==2: | |
59 | run_every = timedelta(minutes=1) |
|
69 | run_every = timedelta(minutes=1) |
@@ -46,6 +46,7 urlpatterns = ( | |||||
46 |
|
46 | |||
47 | path('experiment/<int:id_exp>/new_dev_conf/', views.dev_conf_new, name='url_add_dev_conf'), |
|
47 | path('experiment/<int:id_exp>/new_dev_conf/', views.dev_conf_new, name='url_add_dev_conf'), | |
48 | path('experiment/<int:id_exp>/new_dev_conf/<int:id_dev>/', views.dev_conf_new, name='url_add_dev_conf'), |
|
48 | path('experiment/<int:id_exp>/new_dev_conf/<int:id_dev>/', views.dev_conf_new, name='url_add_dev_conf'), | |
|
49 | ||||
49 | path('dev_conf/', views.dev_confs, name='url_dev_confs'), |
|
50 | path('dev_conf/', views.dev_confs, name='url_dev_confs'), | |
50 | path('dev_conf/<int:id_conf>/', views.dev_conf, name='url_dev_conf'), |
|
51 | path('dev_conf/<int:id_conf>/', views.dev_conf, name='url_dev_conf'), | |
51 | path('dev_conf/<int:id_conf>/edit/', views.dev_conf_edit, name='url_edit_dev_conf'), |
|
52 | path('dev_conf/<int:id_conf>/edit/', views.dev_conf_edit, name='url_edit_dev_conf'), |
@@ -13,6 +13,8 from django.contrib import messages | |||||
13 | from django.http.request import QueryDict |
|
13 | from django.http.request import QueryDict | |
14 | from django.contrib.auth.decorators import login_required, user_passes_test |
|
14 | from django.contrib.auth.decorators import login_required, user_passes_test | |
15 |
|
15 | |||
|
16 | from django.utils.timezone import is_aware | |||
|
17 | ||||
16 | try: |
|
18 | try: | |
17 | from urllib.parse import urlencode |
|
19 | from urllib.parse import urlencode | |
18 | except ImportError: |
|
20 | except ImportError: | |
@@ -21,8 +23,6 except ImportError: | |||||
21 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm, NewForm |
|
23 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm, LocationForm, UploadFileForm, DownloadFileForm, OperationForm, NewForm | |
22 | from .forms import OperationSearchForm, FilterForm, ChangeIpForm |
|
24 | from .forms import OperationSearchForm, FilterForm, ChangeIpForm | |
23 |
|
25 | |||
24 | from .tasks import task_start |
|
|||
25 |
|
||||
26 | from apps.rc.forms import RCConfigurationForm, RCLineCode, RCMixConfigurationForm |
|
26 | from apps.rc.forms import RCConfigurationForm, RCLineCode, RCMixConfigurationForm | |
27 | from apps.dds.forms import DDSConfigurationForm |
|
27 | from apps.dds.forms import DDSConfigurationForm | |
28 | from apps.jars.forms import JARSConfigurationForm |
|
28 | from apps.jars.forms import JARSConfigurationForm | |
@@ -41,9 +41,10 from apps.rc.models import RCConfiguration, RCLine, RCLineType, RCClock | |||||
41 | from apps.dds.models import DDSConfiguration |
|
41 | from apps.dds.models import DDSConfiguration | |
42 | from apps.dds_rest.models import DDSRestConfiguration |
|
42 | from apps.dds_rest.models import DDSRestConfiguration | |
43 |
|
43 | |||
|
44 | from .tasks import task_start | |||
44 | from radarsys.celery import app |
|
45 | from radarsys.celery import app | |
45 |
|
46 | |||
46 |
|
47 | #comentario test | ||
47 | CONF_FORMS = { |
|
48 | CONF_FORMS = { | |
48 | 'rc': RCConfigurationForm, |
|
49 | 'rc': RCConfigurationForm, | |
49 | 'dds': DDSConfigurationForm, |
|
50 | 'dds': DDSConfigurationForm, | |
@@ -1793,9 +1794,21 def radar_start(request, id_camp, id_radar): | |||||
1793 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
1794 | campaign = get_object_or_404(Campaign, pk=id_camp) | |
1794 | experiments = campaign.get_experiments_by_radar(id_radar)[0]['experiments'] |
|
1795 | experiments = campaign.get_experiments_by_radar(id_radar)[0]['experiments'] | |
1795 | now = datetime.now() |
|
1796 | now = datetime.now() | |
|
1797 | ||||
1796 | for exp in experiments: |
|
1798 | for exp in experiments: | |
|
1799 | #app.control.revoke(exp.task) | |||
|
1800 | print(exp.status) | |||
1797 | start = datetime.combine(datetime.now().date(), exp.start_time) |
|
1801 | start = datetime.combine(datetime.now().date(), exp.start_time) | |
1798 | end = datetime.combine(datetime.now().date(), exp.end_time) |
|
1802 | end = datetime.combine(datetime.now().date(), exp.end_time) | |
|
1803 | print(exp.start_time) | |||
|
1804 | print(exp.end_time) | |||
|
1805 | ||||
|
1806 | print(start) | |||
|
1807 | print(end) | |||
|
1808 | print(is_aware(start)) | |||
|
1809 | print(campaign.start_date) | |||
|
1810 | print(campaign.end_date) | |||
|
1811 | print(is_aware(campaign.start_date)) | |||
1799 | if end < start: |
|
1812 | if end < start: | |
1800 | end += timedelta(1) |
|
1813 | end += timedelta(1) | |
1801 |
|
1814 | |||
@@ -1814,8 +1827,9 def radar_start(request, id_camp, id_radar): | |||||
1814 | continue |
|
1827 | continue | |
1815 |
|
1828 | |||
1816 | app.control.revoke(exp.task) |
|
1829 | app.control.revoke(exp.task) | |
1817 |
|
1830 | print("Llego luego del revoke") | ||
1818 | if now > start and now <= end: |
|
1831 | if now > start and now <= end: | |
|
1832 | print("Caso now >start and <end") | |||
1819 | task = task_start.delay(exp.id) |
|
1833 | task = task_start.delay(exp.id) | |
1820 | exp.status = task.wait() |
|
1834 | exp.status = task.wait() | |
1821 | if exp.status == 0: |
|
1835 | if exp.status == 0: | |
@@ -1823,12 +1837,11 def radar_start(request, id_camp, id_radar): | |||||
1823 | if exp.status == 2: |
|
1837 | if exp.status == 2: | |
1824 | messages.success(request, 'Experiment {} started'.format(exp)) |
|
1838 | messages.success(request, 'Experiment {} started'.format(exp)) | |
1825 | else: |
|
1839 | else: | |
1826 | task = task_start.apply_async( |
|
1840 | print("Caso now < start o >end") | |
1827 |
|
|
1841 | task = task_start.apply_async((exp.pk, ), eta=start)#start+timedelta(hours=5)) | |
1828 | exp.task = task.id |
|
1842 | exp.task = task.id | |
1829 | exp.status = 3 |
|
1843 | exp.status = 3 | |
1830 | messages.success( |
|
1844 | messages.success(request, 'Experiment {} programmed to start at {}'.format(exp, start)) | |
1831 | request, 'Experiment {} programmed to start at {}'.format(exp, start)) |
|
|||
1832 |
|
1845 | |||
1833 | exp.save() |
|
1846 | exp.save() | |
1834 |
|
1847 | |||
@@ -1840,12 +1853,16 def radar_stop(request, id_camp, id_radar): | |||||
1840 |
|
1853 | |||
1841 | campaign = get_object_or_404(Campaign, pk=id_camp) |
|
1854 | campaign = get_object_or_404(Campaign, pk=id_camp) | |
1842 | experiments = campaign.get_experiments_by_radar(id_radar)[0]['experiments'] |
|
1855 | experiments = campaign.get_experiments_by_radar(id_radar)[0]['experiments'] | |
1843 |
|
1856 | print("Ingreso en stop radar_stop") | ||
1844 | for exp in experiments: |
|
1857 | for exp in experiments: | |
1845 |
|
1858 | |||
1846 | if exp.task: |
|
1859 | if exp.task: | |
|
1860 | print("Ingreso antes de revoke stop") | |||
1847 | app.control.revoke(exp.task) |
|
1861 | app.control.revoke(exp.task) | |
1848 | if exp.status == 2: |
|
1862 | ||
|
1863 | ||||
|
1864 | if exp.status == 2: #status 2 es started | |||
|
1865 | print("llama a exp.stop") | |||
1849 | exp.stop() |
|
1866 | exp.stop() | |
1850 | messages.warning(request, 'Experiment {} stopped'.format(exp)) |
|
1867 | messages.warning(request, 'Experiment {} stopped'.format(exp)) | |
1851 | exp.status = 1 |
|
1868 | exp.status = 1 | |
@@ -1861,8 +1878,11 def radar_refresh(request, id_camp, id_radar): | |||||
1861 | experiments = campaign.get_experiments_by_radar(id_radar)[0]['experiments'] |
|
1878 | experiments = campaign.get_experiments_by_radar(id_radar)[0]['experiments'] | |
1862 |
|
1879 | |||
1863 | i = app.control.inspect() |
|
1880 | i = app.control.inspect() | |
1864 | scheduled = i.scheduled().values()[0] |
|
1881 | print(i) | |
1865 | revoked = i.revoked().values()[0] |
|
1882 | print(i.scheduled()) | |
|
1883 | print(i.scheduled().values()) | |||
|
1884 | scheduled = list(i.scheduled().values())[0] | |||
|
1885 | revoked = list(i.revoked().values())[0] | |||
1866 |
|
1886 | |||
1867 | for exp in experiments: |
|
1887 | for exp in experiments: | |
1868 | if exp.task in revoked: |
|
1888 | if exp.task in revoked: | |
@@ -1880,14 +1900,14 def radar_refresh(request, id_camp, id_radar): | |||||
1880 | def revoke_tasks(request, id_camp): |
|
1900 | def revoke_tasks(request, id_camp): | |
1881 |
|
1901 | |||
1882 | i = app.control.inspect() |
|
1902 | i = app.control.inspect() | |
1883 | scheduled = i.scheduled().values()[0] |
|
1903 | scheduled = list(i.scheduled().values())[0] | |
1884 | revoked = i.revoked().values()[0] |
|
1904 | revoked = list(i.revoked().values())[0] | |
1885 |
|
1905 | |||
1886 | for t in scheduled: |
|
1906 | for t in scheduled: | |
1887 | if t['request']['id'] in revoked: |
|
1907 | if t['request']['id'] in revoked: | |
1888 | continue |
|
1908 | continue | |
1889 | app.control.revoke(t['request']['id']) |
|
1909 | app.control.revoke(t['request']['id']) | |
1890 | exp = Experiment.objects.get(pk=eval(t['request']['args'])[0]) |
|
1910 | exp = Experiment.objects.get(pk=eval(str(t['request']['args']))[0]) | |
1891 | eta = t['eta'] |
|
1911 | eta = t['eta'] | |
1892 | task = t['request']['name'].split('.')[-1] |
|
1912 | task = t['request']['name'].split('.')[-1] | |
1893 | messages.warning(request, 'Scheduled {} at {} for experiment {} revoked'.format(task, eta, exp.name)) |
|
1913 | messages.warning(request, 'Scheduled {} at {} for experiment {} revoked'.format(task, eta, exp.name)) | |
@@ -1898,13 +1918,13 def revoke_tasks(request, id_camp): | |||||
1898 | def show_tasks(request, id_camp): |
|
1918 | def show_tasks(request, id_camp): | |
1899 |
|
1919 | |||
1900 | i = app.control.inspect() |
|
1920 | i = app.control.inspect() | |
1901 | scheduled = i.scheduled().values()[0] |
|
1921 | scheduled = list(i.scheduled().values())[0] | |
1902 | revoked = i.revoked().values()[0] |
|
1922 | revoked = list(i.revoked().values())[0] | |
1903 |
|
1923 | |||
1904 | for t in scheduled: |
|
1924 | for t in scheduled: | |
1905 | if t['request']['id'] in revoked: |
|
1925 | if t['request']['id'] in revoked: | |
1906 | continue |
|
1926 | continue | |
1907 | exp = Experiment.objects.get(pk=eval(t['request']['args'])[0]) |
|
1927 | exp = Experiment.objects.get(pk=eval(str(t['request']['args']))[0]) | |
1908 | eta = t['eta'] |
|
1928 | eta = t['eta'] | |
1909 | task = t['request']['name'].split('.')[-1] |
|
1929 | task = t['request']['name'].split('.')[-1] | |
1910 | messages.success(request, 'Task {} scheduled at {} for experiment {}'.format(task, eta, exp.name)) |
|
1930 | messages.success(request, 'Task {} scheduled at {} for experiment {}'.format(task, eta, exp.name)) |
@@ -6,7 +6,7 from django.conf import settings | |||||
6 | # set the default Django settings module for the 'celery' program. |
|
6 | # set the default Django settings module for the 'celery' program. | |
7 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'radarsys.settings') |
|
7 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'radarsys.settings') | |
8 | app = Celery('radarsys') |
|
8 | app = Celery('radarsys') | |
9 |
|
9 | app.conf.timezone = 'America/Lima' | ||
10 | # Using a string here means the worker will not have to |
|
10 | # Using a string here means the worker will not have to | |
11 | # pickle the object when using Windows. |
|
11 | # pickle the object when using Windows. | |
12 | app.config_from_object('django.conf:settings') |
|
12 | app.config_from_object('django.conf:settings') |
@@ -105,14 +105,14 DATABASES = { | |||||
105 |
|
105 | |||
106 | LANGUAGE_CODE = 'en-us' |
|
106 | LANGUAGE_CODE = 'en-us' | |
107 |
|
107 | |||
|
108 | USE_TZ = False | |||
|
109 | ||||
108 | TIME_ZONE = os.environ.get('TZ', 'America/Lima') |
|
110 | TIME_ZONE = os.environ.get('TZ', 'America/Lima') | |
109 |
|
111 | |||
110 | USE_I18N = True |
|
112 | USE_I18N = True | |
111 |
|
113 | |||
112 | USE_L10N = True |
|
114 | USE_L10N = True | |
113 |
|
115 | |||
114 | USE_TZ = False |
|
|||
115 |
|
||||
116 | # Static files (CSS, JavaScript, Images) |
|
116 | # Static files (CSS, JavaScript, Images) | |
117 | # https://docs.djangoproject.com/en/1.8/howto/static-files/ |
|
117 | # https://docs.djangoproject.com/en/1.8/howto/static-files/ | |
118 |
|
118 | |||
@@ -129,7 +129,7 STATICFILES_FINDERS = ( | |||||
129 |
|
129 | |||
130 | # Celery stuff |
|
130 | # Celery stuff | |
131 | REDIS_HOST = os.environ.get('REDIS_HOST', '127.0.0.1') |
|
131 | REDIS_HOST = os.environ.get('REDIS_HOST', '127.0.0.1') | |
132 |
REDIS_PORT = os.environ.get('REDIS_PORT', 63 |
|
132 | REDIS_PORT = os.environ.get('REDIS_PORT', 6379) | |
133 |
|
133 | |||
134 | BROKER_TRANSPORT = 'redis' |
|
134 | BROKER_TRANSPORT = 'redis' | |
135 | BROKER_URL = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT) |
|
135 | BROKER_URL = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT) | |
@@ -140,3 +140,4 CELERY_ACCEPT_CONTENT = ['application/json'] | |||||
140 | CELERY_TASK_SERIALIZER = 'json' |
|
140 | CELERY_TASK_SERIALIZER = 'json' | |
141 | CELERY_RESULT_SERIALIZER = 'json' |
|
141 | CELERY_RESULT_SERIALIZER = 'json' | |
142 | CELERY_ENABLE_UTC = False |
|
142 | CELERY_ENABLE_UTC = False | |
|
143 | CELERY_TIMEZONE = 'America/Lima' |
General Comments 0
You need to be logged in to leave comments.
Login now