diff --git a/apps/abs/models.py b/apps/abs/models.py index e0a0368..c631307 100644 --- a/apps/abs/models.py +++ b/apps/abs/models.py @@ -561,7 +561,7 @@ class ABSConfiguration(Configuration): # Create the datagram socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.settimeout(1) - local_ip = os.environ.get('LOCAL_IP', '192.168.2.128') + local_ip = os.environ.get('LOCAL_IP', '192.168.1.128') sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip)) sock.sendto(message.encode(), multicast_group) print('Sending ' + message) diff --git a/apps/abs/urls.py b/apps/abs/urls.py index a45ebe4..017d3ac 100644 --- a/apps/abs/urls.py +++ b/apps/abs/urls.py @@ -11,7 +11,7 @@ urlpatterns = ( path('/change_beam//', views.send_beam, name='url_send_beam'), path('/plot/', views.plot_patterns, name='url_plot_abs_patterns'), path('/plot//', views.plot_patterns, name='url_plot_abs_patterns'), - path('/plot///pattern.png', views.plot_pattern, name='url_plot_beam'), + path('/plot///pattern.png', views.plot_pattern, name='url_plot_beam'), path('/add_beam/', views.add_beam, name='url_add_abs_beam'), path('/beam//delete/', views.remove_beam, name='url_remove_abs_beam'), path('/beam//edit/', views.edit_beam, name='url_edit_abs_beam'), diff --git a/apps/abs/utils/overJroShow.py b/apps/abs/utils/overJroShow.py index 7fcaa7a..ede70b5 100644 --- a/apps/abs/utils/overJroShow.py +++ b/apps/abs/utils/overJroShow.py @@ -468,8 +468,8 @@ class JroPattern(): yy1 = self.dcosy[numpy.min(nny):numpy.max(nny)+1] # fitting data into the main beam. - import gaussfit - params = gaussfit.fitgaussian(mm1) + from .gaussfit import fitgaussian + params = fitgaussian(mm1) # Tranforming from indexes to axis' values xcenter = xx1[0] + (((xx1[xx1.size-1] - xx1[0])/(xx1.size -1))*(params[1])) @@ -629,7 +629,7 @@ class BField(): rr = numpy.zeros((heights.size,3)) rgc = numpy.zeros((heights.size,3)) - ObjGeodetic = Astro_Coords.Geodetic(gdlat,gdalt) + ObjGeodetic = Geodetic(gdlat,gdalt) [gclat,gcalt] = ObjGeodetic.change2geocentric() gclat = gclat*numpy.pi/180. @@ -1362,7 +1362,7 @@ class overJroShow: vect_polar = Misc_Routines.Vector(numpy.array(vect_geo),direction=1).Polar2Rect() - [ra,dec,ha] = Astro_Coords.AltAz(vect_polar[1],vect_polar[0],self.junkjd).change2equatorial() + [ra,dec,ha] = AltAz(vect_polar[1],vect_polar[0],self.junkjd).change2equatorial() print('Main beam position (HA(min), DEC(degrees)): %f %f')%(ha*4.,dec) @@ -1421,7 +1421,7 @@ class overJroShow: vect_polar = Misc_Routines.Vector(vect_geo,direction=1).Polar2Rect() - [ra,dec,ha] = Astro_Coords.AltAz(vect_polar[1,:],vect_polar[0,:],self.junkjd).change2equatorial() + [ra,dec,ha] = AltAz(vect_polar[1,:],vect_polar[0,:],self.junkjd).change2equatorial() val = numpy.where(ha>=180) @@ -1609,7 +1609,7 @@ class overJroShow: julian = Time(year,month,dom).change2julday() - [powr,time, lst] = Astro_Coords.CelestialBodies().skyNoise(julian) + [powr,time, lst] = CelestialBodies().skyNoise(julian) SkyNoisePlot([year,month,dom],powr,time,lst).getPlot(self.path4plotname,self.plotname2) diff --git a/apps/rc/models.py b/apps/rc/models.py index 58c0697..695a7d3 100644 --- a/apps/rc/models.py +++ b/apps/rc/models.py @@ -1,9 +1,8 @@ - - import ast import json import requests import numpy as np +import time from base64 import b64encode from struct import pack @@ -555,6 +554,8 @@ class RCConfiguration(Configuration): print("write device") if not raw: + pass + ''' clock = RCClock.objects.get(rc_configuration=self) if clock.mode: data = {'default': clock.frequency} @@ -567,8 +568,10 @@ class RCConfiguration(Configuration): self.message = payload['setfreq'] if payload['setfreq'] == 'fail': self.message = 'RC write: error programming CGS chip' + ''' values = [] + print('ok') for pulse, delay in zip(self.get_pulses(), self.get_delays()): while delay > 65536: values.append((pulse, 65535)) @@ -608,9 +611,11 @@ class RCConfiguration(Configuration): #payload = self.request('write', 'post', data=b64encode(bytearray((139, 62))), timeout=20) n = len(data) x = 0 - #while x < n: - payload = self.request('write', 'post', data=b64encode(data)) - # x += 1024 + while x < n: + payload = self.request('write', 'post', data=b64encode(data[x:x+1024])) + x += 1024 + time.sleep(1) + print('writing... ', x) if payload['write']=='ok': self.device.status = 3 @@ -1039,4 +1044,4 @@ class RCClock(models.Model): multiplier = models.PositiveIntegerField(default=60) divisor = models.PositiveIntegerField(default=10) reference = models.PositiveSmallIntegerField(default=1, choices=((0, 'Internal (25MHz)'), (1, 'External (10MHz)'))) - frequency = models.FloatField(default=60.0) \ No newline at end of file + frequency = models.FloatField(default=60.0) diff --git a/apps/rc/views.py b/apps/rc/views.py index 55ad73b..f6bd8c2 100644 --- a/apps/rc/views.py +++ b/apps/rc/views.py @@ -1,4 +1,3 @@ - import json from django.contrib import messages @@ -118,7 +117,7 @@ def conf_edit(request, conf_id): form.save() #update lines fields - extras.sort() + extras.sort(key=lambda x: int(x.split('|')[0])) #print("Inicio extras") #print(extras) #print("Fin extras") @@ -433,4 +432,4 @@ def plot_pulses2(request, conf_id): def conf_raw(request, conf_id): conf = get_object_or_404(RCConfiguration, pk=conf_id) raw = conf.write_device(raw=True) - return HttpResponse(raw, content_type='application/json') \ No newline at end of file + return HttpResponse(raw, content_type='application/json') diff --git a/docker-compose.yml b/docker-compose.yml index 2186e2a..564509e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,42 +1,44 @@ version: '2' services: # Django app - web: - container_name: 'radarsys' - build: . - restart: always - image: radarsys - command: gunicorn radarsys.wsgi:application -w 2 -b :8000 - # command: python manage.py runserver 0.0.0.0:8030 - # ports: - # - 8030:8030 - env_file: .env + # web: + # container_name: 'radarsys' + # build: . + # restart: always + # image: radarsys + # command: gunicorn radarsys.wsgi:application -w 2 -b :8000 + # # command: python manage.py runserver 0.0.0.0:8030 + # # ports: + # # - 8030:8030 + # env_file: .env - links: - - redis - - postgres - volumes: - - './:/radarsys' - - '${DOCKER_DATA}/static:/radarsys/static' - depends_on: - - redis - - postgres + # links: + # - redis + # - postgres + # volumes: + # - './:/radarsys' + # - '${DOCKER_DATA}/static:/radarsys/static' + # depends_on: + # - redis + # - postgres redis: container_name: 'radarsys-redis' image: 'redis:3.2-alpine' volumes: - '${DOCKER_DATA}/redis:/data' + ports: + - 6300:6379 celery_worker: container_name: 'radarsys-celery' image: radarsys env_file: .env command: celery -A radarsys worker -l info - volumes_from: - - web - depends_on: - - web + # volumes_from: + # - web + # depends_on: + # - web # PostgreSQL postgres: @@ -44,25 +46,25 @@ services: build: ./postgres/ volumes: - ./postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d - - pgdata:/var/lib/postgresql/data - # ports: - # - 5432:5432 + - /data/dockers/radarsys/postgres:/var/lib/postgresql/data + ports: + - 5400:5432 env_file: .env # Web Server - nginx: - container_name: 'radarsys-nginx' - restart: always - build: ./nginx/ - ports: - - '8030:8030' - volumes_from: - - web - links: - - web:web - depends_on: - - web + # nginx: + # container_name: 'radarsys-nginx' + # restart: always + # build: ./nginx/ + # ports: + # - '8030:8030' + # volumes_from: + # - web + # links: + # - web:web + # depends_on: + # - web -volumes: - pgdata: - driver: local + # volumes: + # pgdata: + # driver: local diff --git a/radarsys/settings.py b/radarsys/settings.py index ac92360..5598208 100644 --- a/radarsys/settings.py +++ b/radarsys/settings.py @@ -28,7 +28,7 @@ ALLOWED_HOSTS = ['*'] # Application definition -INSTALLED_APPS = [ +INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -42,12 +42,12 @@ INSTALLED_APPS = [ 'apps.misc', 'apps.rc', 'apps.dds', + 'apps.dds_rest', 'apps.jars', 'apps.usrp', 'apps.abs', 'apps.cgs', - 'apps.dds_rest', -] +) MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', @@ -65,7 +65,7 @@ ROOT_URLCONF = 'radarsys.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, "templates")], + 'DIRS': [os.path.join(BASE_DIR, "templates").replace('\\', '/'),], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -89,30 +89,28 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'radarsys.sqlite', + # 'ENGINE': 'django.db.backends.postgresql_psycopg2', + # 'NAME': os.environ.get('DB_NAME', 'radarsys'), + # 'USER': os.environ.get('DB_USER', 'docker'), + # 'PASSWORD': os.environ.get('DB_PASSWORD', 'docker'), + # 'HOST': os.environ.get('POSTGRES_PORT_5432_TCP_ADDR', 'localhost'), + # 'PORT': os.environ.get('POSTGRES_PORT_5432_TCP_PORT', '5400'), + } } - # 'default': { - # 'ENGINE': 'django.db.backends.postgresql_psycopg2', - # 'NAME': os.environ.get('DB_NAME', 'radarsys'), - # 'USER': os.environ.get('DB_USER', 'docker'), - # 'PASSWORD': os.environ.get('DB_PASSWORD', 'docker'), - # 'HOST': os.environ.get('POSTGRES_PORT_5432_TCP_ADDR', 'localhost'), - # 'PORT': os.environ.get('POSTGRES_PORT_5432_TCP_PORT', '5400'), - #} -} # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'en-us' -USE_TZ = False #True - TIME_ZONE = os.environ.get('TZ', 'America/Lima') USE_I18N = True USE_L10N = True +USE_TZ = False + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ @@ -128,19 +126,15 @@ STATICFILES_FINDERS = ( ) # Celery stuff - -REDIS_HOST = os.environ.get('REDIS_HOST', 'localhost') -#REDIS_HOST = os.environ.get('REDIS_HOST', '127.0.0.1') -REDIS_PORT = os.environ.get('REDIS_PORT', 6379) +REDIS_HOST = os.environ.get('REDIS_HOST', '127.0.0.1') +REDIS_PORT = os.environ.get('REDIS_PORT', 6300) BROKER_TRANSPORT = 'redis' -#BROKER_URL = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT) -BROKER_URL = 'redis://{}:{}'.format(REDIS_HOST, REDIS_PORT) +BROKER_URL = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT) -CELERY_RESULT_BACKEND = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT) -CELERY_BROKER_TRANSPORT = BROKER_URL -CELERY_ACCEPT_CONTENT = ['application/json'] -CELERY_TASK_SERIALIZER = 'json' +CELERY_RESULT_BACKEND = 'redis://{}:{}/0'.format(REDIS_HOST, REDIS_PORT) +CELERY_BROKER_TRANSPORT = BROKER_URL +CELERY_ACCEPT_CONTENT = ['application/json'] +CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' -CELERY_ENABLE_UTC = False -CELERY_TIMEZONE = 'America/Lima' \ No newline at end of file +CELERY_ENABLE_UTC = False