##// END OF EJS Templates

File last commit:

r276:33881bc25110
r314:8d83194b6bd7 merge
Show More
models.py
164 lines | 5.7 KiB | text/x-python | PythonLexer
Juan C. Espinoza
Proyecto base en Django (refs #259) ...
r0 from django.db import models
Juan C. Espinoza
Updating base models and views ...
r6 from apps.main.models import Configuration
Fiorella Quino
DDS files have been updated...
r262 from apps.main.utils import Params
Juan C. Espinoza
Proyecto base en Django (refs #259) ...
r0 # Create your models here.
Juan C. Espinoza
Updating base models and views ...
r6
Miguel Urco
DDS model added...
r12 from django.core.validators import MinValueValidator, MaxValueValidator
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 from django.core.exceptions import ValidationError
Miguel Urco
DDS model added...
r12
Miguel Urco
DDS commands working...
r57 from devices.dds import api, data
Miguel Urco
DDS app updated...
r32
Miguel Urco
DDS model updated...
r55 ENABLE_TYPE = (
(False, 'Disabled'),
(True, 'Enabled'),
)
Miguel Urco
Campaign has been added to RadarSys Model...
r13 MOD_TYPES = (
Miguel Urco
DDS model updated...
r55 (0, 'Single Tone'),
(1, 'FSK'),
(2, 'Ramped FSK'),
(3, 'Chirp'),
(4, 'BPSK'),
)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Updating base models and views ...
r6 class DDSConfiguration(Configuration):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 DDS_NBITS = 48
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Fiorella Quino
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@166 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r145 clock = models.FloatField(verbose_name='Clock In (MHz)',validators=[MinValueValidator(5), MaxValueValidator(75)], null=True, default=60)
Miguel Urco
Campaign has been added to RadarSys Model...
r13 multiplier = models.PositiveIntegerField(verbose_name='Multiplier',validators=[MinValueValidator(1), MaxValueValidator(20)], default=4)
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26
Fiorella Quino
DDS models: default values...
r97 frequencyA_Mhz = models.DecimalField(verbose_name='Frequency A (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)], max_digits=19, decimal_places=16, null=True, default=49.9200)
frequencyA = models.BigIntegerField(verbose_name='Frequency A (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**DDS_NBITS-1)], blank=True, null=True)
Miguel Urco
DDS model updated...
r55
frequencyB_Mhz = models.DecimalField(verbose_name='Frequency B (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)], max_digits=19, decimal_places=16, blank=True, null=True)
frequencyB = models.BigIntegerField(verbose_name='Frequency B (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**DDS_NBITS-1)], blank=True, null=True)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 phaseA_degrees = models.FloatField(verbose_name='Phase A (Degrees)', validators=[MinValueValidator(0), MaxValueValidator(360)], default=0)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS commands working...
r57 phaseB_degrees = models.FloatField(verbose_name='Phase B (Degrees)', validators=[MinValueValidator(0), MaxValueValidator(360)], blank=True, null=True)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
Buttons "Import", "Export, "Read" and "Write" added to Configuration View...
r30 modulation = models.PositiveIntegerField(verbose_name='Modulation Type', choices = MOD_TYPES, default = 0)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 amplitude_enabled = models.BooleanField(verbose_name='Amplitude Control', choices=ENABLE_TYPE, default=False)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 amplitudeI = models.PositiveIntegerField(verbose_name='Amplitude CH1',validators=[MinValueValidator(0), MaxValueValidator(2**12-1)], blank=True, null=True)
amplitudeQ = models.PositiveIntegerField(verbose_name='Amplitude CH2',validators=[MinValueValidator(0), MaxValueValidator(2**12-1)], blank=True, null=True)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 def get_nbits(self):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 return self.DDS_NBITS
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 def clean(self):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 if self.modulation in [1,2,3]:
Miguel Urco
DDS model updated...
r55 if self.frequencyB is None or self.frequencyB_Mhz is None:
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 raise ValidationError({
Miguel Urco
DDS model updated...
r55 'frequencyB': 'Frequency modulation has to be defined when FSK or Chirp modulation is selected'
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 })
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 if self.modulation in [4,]:
Miguel Urco
DDS model updated...
r55 if self.phaseB_degrees is None:
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 raise ValidationError({
Miguel Urco
DDS model updated...
r55 'phaseB': 'Phase modulation has to be defined when BPSK modulation is selected'
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 })
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS commands working...
r57 self.frequencyA_Mhz = data.binary_to_freq(self.frequencyA, self.clock*self.multiplier)
self.frequencyB_Mhz = data.binary_to_freq(self.frequencyB, self.clock*self.multiplier)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 def verify_frequencies(self):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@44 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71
r26 return True
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS commands working...
r57 def parms_to_text(self):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Fiorella Quino
Task #1068: Export racp and jars files function has been implemented...
r276 my_dict = self.parms_to_dict()['configurations']['byId'][str(self.id)]
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS commands working...
r57 text = data.dict_to_text(my_dict)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS commands working...
r57 return text
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 def status_device(self):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update DDS model...
r187 try:
answer = api.status(ip = self.device.ip_address,
Fiorella Quino
import/export functions have been updated...
r243 port = self.device.port_address)
if 'clock' in answer:
Juan C. Espinoza
Update DDS model...
r187 self.device.status = 1
else:
Fiorella Quino
import/export functions have been updated...
r243 self.device.status = answer[0]
self.message = 'DDS - {}'.format(answer[2:])
Juan C. Espinoza
Update DDS model...
r187 except Exception as e:
Fiorella Quino
import/export functions have been updated...
r243 self.message = str(e)
Juan C. Espinoza
Update DDS model...
r187 self.device.status = 0
Fiorella Quino
import/export functions have been updated...
r243
Juan C. Espinoza
Fix status_device in DDS model...
r188 self.device.save()
Fiorella Quino
import/export functions have been updated...
r243
Juan C. Espinoza
Fix status_device in DDS model...
r188 if self.device.status in (0, '0'):
return False
else:
return True
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 def reset_device(self):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 answer = api.reset(ip = self.device.ip_address,
port = self.device.port_address)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 if answer[0] != "1":
Juan C. Espinoza
Add scheduler for campaigns/experiments using celery #718, fix views and models bugs...
r196 self.message = 'DDS - {}'.format(answer[2:])
Miguel Urco
DDS model updated...
r55 return 0
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Add scheduler for campaigns/experiments using celery #718, fix views and models bugs...
r196 self.message = 'DDS - {}'.format(answer[2:])
Miguel Urco
DDS model updated...
r55 return 1
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 def stop_device(self):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update DDS model...
r187 try:
answer = api.disable_rf(ip = self.device.ip_address,
port = self.device.port_address)
Fiorella Quino
import/export functions have been updated...
r243
Juan C. Espinoza
Update DDS model methods...
r232 return self.status_device()
Fiorella Quino
import/export functions have been updated...
r243
Juan C. Espinoza
Update DDS model...
r187 except Exception as e:
self.message = str(e)
return False
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 def start_device(self):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update DDS model...
r187 try:
answer = api.enable_rf(ip = self.device.ip_address,
port = self.device.port_address)
Fiorella Quino
import/export functions have been updated...
r243
Juan C. Espinoza
Update DDS model methods...
r232 return self.status_device()
Fiorella Quino
import/export functions have been updated...
r243
Juan C. Espinoza
Update DDS model...
r187 except Exception as e:
self.message = str(e)
return False
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 def read_device(self):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 parms = api.read_config(ip = self.device.ip_address,
port = self.device.port_address)
if not parms:
self.message = "Could not read DDS parameters from this device"
return parms
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 self.message = ""
return parms
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
DDS model updated...
r55 def write_device(self):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update DDS model...
r187 try:
answer = api.write_config(ip = self.device.ip_address,
port = self.device.port_address,
Fiorella Quino
Task #1068: Export racp and jars files function has been implemented...
r276 parms = self.parms_to_dict()['configurations']['byId'][str(self.id)])
Fiorella Quino
import/export functions have been updated...
r243
Juan C. Espinoza
Update DDS model methods...
r232 return self.status_device()
Fiorella Quino
import/export functions have been updated...
r243
Juan C. Espinoza
Update DDS model...
r187 except Exception as e:
self.message = str(e)
Fiorella Quino
import/export functions have been updated...
r243 return False
Juan C. Espinoza
Updating base models and views ...
r6 class Meta:
db_table = 'dds_configurations'