diff --git a/apps/dds/forms.py b/apps/dds/forms.py
index 1415a5c..a4d57d6 100644
--- a/apps/dds/forms.py
+++ b/apps/dds/forms.py
@@ -4,11 +4,6 @@ from .models import DDSConfiguration
# from django.core.validators import MinValueValidator, MaxValueValidator
-EXT_TYPES = (
- ('dds', '.dds'),
- ('json', '.json'),
-)
-
class DDSConfigurationForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
@@ -26,10 +21,10 @@ class DDSConfigurationForm(forms.ModelForm):
self.fields['device'].widget.choices = [(device.id, device) for device in devices]
-
- def clean(self):
- # Custom validation to force an integer when type of unit = "Unit"
- return
+#
+# def clean(self):
+# # Custom validation to force an integer when type of unit = "Unit"
+# return
class Meta:
model = DDSConfiguration
diff --git a/apps/dds/models.py b/apps/dds/models.py
index 0c44067..ba2d7d0 100644
--- a/apps/dds/models.py
+++ b/apps/dds/models.py
@@ -5,7 +5,7 @@ from apps.main.models import Configuration
from django.core.validators import MinValueValidator, MaxValueValidator
from django.core.exceptions import ValidationError
-from devices.dds import api, data, files
+from devices.dds import api, data
ENABLE_TYPE = (
(False, 'Disabled'),
@@ -32,10 +32,10 @@ class DDSConfiguration(Configuration):
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)
- phaseB_degrees = models.FloatField(verbose_name='Phase B (Degrees)', validators=[MinValueValidator(0), MaxValueValidator(360)], blank=True, null=True)
-
phaseA_degrees = models.FloatField(verbose_name='Phase A (Degrees)', validators=[MinValueValidator(0), MaxValueValidator(360)], default=0)
+ phaseB_degrees = models.FloatField(verbose_name='Phase B (Degrees)', validators=[MinValueValidator(0), MaxValueValidator(360)], blank=True, null=True)
+
modulation = models.PositiveIntegerField(verbose_name='Modulation Type', choices = MOD_TYPES, default = 0)
amplitude_enabled = models.BooleanField(verbose_name='Amplitude Control', choices=ENABLE_TYPE, default=False)
@@ -61,7 +61,10 @@ class DDSConfiguration(Configuration):
raise ValidationError({
'phaseB': 'Phase modulation has to be defined when BPSK modulation is selected'
})
-
+
+ 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)
+
def verify_frequencies(self):
return True
@@ -72,17 +75,30 @@ class DDSConfiguration(Configuration):
parameters['clock'] = float(self.clock)
parameters['multiplier'] = int(self.multiplier)
+
parameters['frequencyA'] = int(self.frequencyA)
- parameters['frequencyB'] = int(self.frequencyB)
+ parameters['frequencyA_Mhz'] = float(self.frequencyA_Mhz)
+
parameters['phaseA'] = data.phase_to_binary(self.phaseA_degrees)
- parameters['phaseB'] = data.phase_to_binary(self.phaseB_degrees)
- parameters['frequencyA_Mhz'] = int(self.frequencyA_Mhz)
- parameters['frequencyB_Mhz'] = int(self.frequencyB_Mhz)
parameters['phaseA_degrees'] = float(self.phaseA_degrees)
- parameters['phaseB_degrees'] = float(self.phaseB_degrees)
+
parameters['modulation'] = int(self.modulation)
- parameters['amplitude_enabled'] = int(self.amplitude_enabled)
+ parameters['amplitude_enabled'] = bool(self.amplitude_enabled)
+
+ if self.frequencyB:
+ parameters['frequencyB'] = int(self.frequencyB)
+ parameters['frequencyB_Mhz'] = float(self.frequencyB_Mhz)
+ else:
+ parameters['frequencyB'] = 0
+ parameters['frequencyB_Mhz'] = 0
+ if self.phaseB_degrees:
+ parameters['phaseB_degrees'] = float(self.phaseB_degrees)
+ parameters['phaseB'] = data.phase_to_binary(self.phaseB_degrees)
+ else:
+ parameters['phaseB_degrees'] = 0
+ parameters['phaseB'] = 0
+
if self.amplitudeI:
parameters['amplitudeI'] = int(self.amplitudeI)
else:
@@ -95,6 +111,14 @@ class DDSConfiguration(Configuration):
return parameters
+ def parms_to_text(self):
+
+ my_dict = self.parms_to_dict()
+
+ text = data.dict_to_text(my_dict)
+
+ return text
+
def dict_to_parms(self, parameters):
self.clock = parameters['clock']
@@ -109,18 +133,19 @@ class DDSConfiguration(Configuration):
self.amplitude_enabled = parameters['amplitude_enabled']
def import_from_file(self, fp):
-
- import os
-
+
+ import os, json
+
parms = {}
-
- path, ext = os.path.splitext(fp)
-
+
+ path, ext = os.path.splitext(fp.name)
+
if ext == '.json':
- parms = files.read_json_file(fp)
-
+ parms = json.load(fp)
+
if ext == '.dds':
- parms = files.read_dds_file(fp)
+ lines = fp.readlines()
+ parms = data.text_to_dict(lines)
return parms
diff --git a/apps/dds/views.py b/apps/dds/views.py
index a83ee90..8cb7d4b 100644
--- a/apps/dds/views.py
+++ b/apps/dds/views.py
@@ -14,7 +14,7 @@ def dds_conf(request, id_conf):
kwargs = {}
- kwargs['status'] = conf.device.status
+ kwargs['status'] = conf.device.get_status_display()
# if not kwargs['connected']:
# messages.error(request, message=answer)
@@ -65,7 +65,7 @@ def dds_conf_edit(request, id_conf):
return redirect('url_dds_conf', id_conf=conf.id)
##ERRORS
-
+
kwargs = {}
kwargs['id_dev'] = conf.id
kwargs['form'] = form
diff --git a/apps/main/forms.py b/apps/main/forms.py
index 7e611f0..23c643d 100644
--- a/apps/main/forms.py
+++ b/apps/main/forms.py
@@ -3,6 +3,20 @@ from django.utils.safestring import mark_safe
from .models import DeviceType, Device, Experiment, Campaign, Configuration, Location
+FILE_FORMAT = (
+ ('json', 'json'),
+ )
+
+DDS_FILE_FORMAT = (
+ ('json', 'json'),
+ ('text', 'dds')
+ )
+
+RC_FILE_FORMAT = (
+ ('json', 'json'),
+ ('text', 'rc')
+ )
+
def add_empty_choice(choices, pos=0, label='-----'):
if len(choices)>0:
choices = list(choices)
@@ -68,10 +82,22 @@ class DeviceTypeForm(forms.Form):
class UploadFileForm(forms.Form):
file = forms.FileField()
-
+
class DownloadFileForm(forms.Form):
- format = forms.ComboField()
+ format = forms.ChoiceField(choices= ((0, 'json'),) )
+
+ def __init__(self, device_type, *args, **kwargs):
+
+ super(DownloadFileForm, self).__init__(*args, **kwargs)
+
+ self.fields['format'].choices = FILE_FORMAT
+
+ if device_type == 'dds':
+ self.fields['format'].choices = DDS_FILE_FORMAT
+
+ if device_type == 'rc':
+ self.fields['format'].choices = RC_FILE_FORMAT
class OperationForm(forms.Form):
# today = datetime.today()
diff --git a/apps/main/models.py b/apps/main/models.py
index ac9c19a..eb6bd0d 100644
--- a/apps/main/models.py
+++ b/apps/main/models.py
@@ -163,9 +163,9 @@ class Configuration(PolymorphicModel):
db_table = 'db_configurations'
def __unicode__(self):
- return u'[%s - %s]: %s' % (self.experiment.name,
- self.experiment.name,
- self.device.name)
+ return u'[%s, %s]: %s' % (self.experiment.name,
+ self.device.name,
+ self.name)
def parms_to_dict(self):
@@ -176,6 +176,18 @@ class Configuration(PolymorphicModel):
return parameters
+ def parms_to_text(self):
+
+ raise NotImplementedError, "This method should be implemented in %s Configuration model" %str(self.device.device_type.name).upper()
+
+ return ''
+
+ def parms_to_binary(self):
+
+ raise NotImplementedError, "This method should be implemented in %s Configuration model" %str(self.device.device_type.name).upper()
+
+ return ''
+
def dict_to_parms(self, parameters):
if type(parameters) != type({}):
@@ -188,19 +200,22 @@ class Configuration(PolymorphicModel):
import json
- content_type = 'application/json'
- filename = '%s.json' %self.name
- content = json.dumps(self.params_to_dict())
+ content_type = ''
if format == 'text':
content_type = 'text/plain'
- filename = '%s.%s' %(self.name, self.device.device_type.name)
- content = self.params_to_text()
+ filename = '%s_%s.%s' %(self.device.device_type.name, self.name, self.device.device_type.name)
+ content = self.parms_to_text()
if format == 'binary':
content_type = 'application/octet-stream'
- filename = '%s.bin' %self.name
- content = self.params_to_binary()
+ filename = '%s_%s.bin' %(self.device.device_type.name, self.name)
+ content = self.parms_to_binary()
+
+ if not content_type:
+ content_type = 'application/json'
+ filename = '%s_%s.json' %(self.device.device_type.name, self.name)
+ content = json.dumps(self.parms_to_dict())
fields = {'content_type':content_type,
'filename':filename,
@@ -209,39 +224,46 @@ class Configuration(PolymorphicModel):
return fields
- def import_from_file(self, filename):
+ def import_from_file(self, fp):
+
+ import os, json
+
+ parms = {}
+
+ path, ext = os.path.splitext(fp.name)
- raise NotImplementedError, "This method should be implemented in each Configuration model"
+ if ext == '.json':
+ parms = json.load(fp)
- return {}
+ return parms
def status_device(self):
- raise NotImplementedError, "This method should be implemented in each Configuration model"
+ raise NotImplementedError, "This method should be implemented in %s Configuration model" %str(self.device.device_type.name).upper()
return None
def stop_device(self):
- raise NotImplementedError, "This method should be implemented in each Configuration model"
+ raise NotImplementedError, "This method should be implemented in %s Configuration model" %str(self.device.device_type.name).upper()
return None
def start_device(self):
- raise NotImplementedError, "This method should be implemented in each Configuration model"
+ raise NotImplementedError, "This method should be implemented in %s Configuration model" %str(self.device.device_type.name).upper()
return None
def write_device(self, parms):
- raise NotImplementedError, "This method should be implemented in each Configuration model"
+ raise NotImplementedError, "This method should be implemented in %s Configuration model" %str(self.device.device_type.name).upper()
return None
def read_device(self):
- raise NotImplementedError, "This method should be implemented in each Configuration model"
+ raise NotImplementedError, "This method should be implemented in %s Configuration model" %str(self.device.device_type.name).upper()
return None
diff --git a/apps/main/templates/base.html b/apps/main/templates/base.html
index 926318d..73f6681 100644
--- a/apps/main/templates/base.html
+++ b/apps/main/templates/base.html
@@ -41,11 +41,13 @@
Operation
- Configuration
+ New
diff --git a/apps/main/templates/dev_conf.html b/apps/main/templates/dev_conf.html
index 7da644e..7b406cd 100644
--- a/apps/main/templates/dev_conf.html
+++ b/apps/main/templates/dev_conf.html
@@ -28,7 +28,7 @@
Status |
- {%if status %} {{status}} {% else %} Disconnected {% endif %} |
+ {%if status != "No connected" %} {{status}} {% else %} {{status}} {% endif %} |
{% for key in dev_conf_keys %}
diff --git a/apps/main/views.py b/apps/main/views.py
index dfa8ef6..e685a10 100644
--- a/apps/main/views.py
+++ b/apps/main/views.py
@@ -514,7 +514,7 @@ def dev_conf_edit(request, id_conf):
###### SIDEBAR ######
kwargs.update(sidebar(conf))
- return render(request, 'dev_conf_edit.html', kwargs)
+ return render(request, '%s_conf_edit.html' %conf.device.device_type.name, kwargs)
def dev_conf_start(request, id_conf):
@@ -528,7 +528,9 @@ def dev_conf_start(request, id_conf):
messages.success(request, conf.message)
else:
messages.error(request, conf.message)
-
+
+ conf.status_device()
+
return redirect(conf.get_absolute_url())
def dev_conf_stop(request, id_conf):
@@ -544,6 +546,8 @@ def dev_conf_stop(request, id_conf):
else:
messages.error(request, conf.message)
+ conf.status_device()
+
return redirect(conf.get_absolute_url())
def dev_conf_status(request, id_conf):
@@ -571,16 +575,20 @@ def dev_conf_write(request, id_conf):
conf = DevConfModel.objects.get(pk=id_conf)
answer = conf.write_device()
+ conf.status_device()
if answer:
messages.success(request, conf.message)
+ #Creating a historical configuration
conf.pk = None
conf.id = None
conf.type = 1
conf.template = 0
conf.save()
+ #Original configuration
+ conf = DevConfModel.objects.get(pk=id_conf)
else:
messages.error(request, conf.message)
@@ -598,6 +606,7 @@ def dev_conf_read(request, id_conf):
if request.method=='GET':
parms = conf.read_device()
+ conf.status_device()
if not parms:
messages.error(request, conf.message)
@@ -609,10 +618,8 @@ def dev_conf_read(request, id_conf):
form = DevConfForm(request.POST, instance=conf)
if form.is_valid():
- dev_model = form.save(commit=False)
-
- if dev_model.save():
- return redirect(conf.get_absolute_url())
+ form.save()
+ return redirect(conf.get_absolute_url())
messages.error(request, "Parameters could not be saved")
@@ -626,7 +633,7 @@ def dev_conf_read(request, id_conf):
###### SIDEBAR ######
kwargs.update(sidebar(conf))
- return render(conf.get_absolute_url_edit())
+ return render(request, '%s_conf_edit.html' %conf.device.device_type.name, kwargs)
def dev_conf_import(request, id_conf):
@@ -648,9 +655,8 @@ def dev_conf_import(request, id_conf):
parms = conf.import_from_file(request.FILES['file'])
if parms:
-
messages.success(request, "Parameters imported from: '%s'." %request.FILES['file'].name)
-
+ print parms
form = DevConfForm(initial=parms, instance=conf)
kwargs = {}
@@ -689,13 +695,13 @@ def dev_conf_export(request, id_conf):
conf = DevConfModel.objects.get(pk=id_conf)
if request.method == 'GET':
- file_form = DownloadFileForm()
+ file_form = DownloadFileForm(conf.device.device_type.name)
if request.method == 'POST':
- file_form = DownloadFileForm(request.POST)
+ file_form = DownloadFileForm(conf.device.device_type.name, request.POST)
if file_form.is_valid():
- fields = conf.export_to_file(format = file_form.format)
+ fields = conf.export_to_file(format = file_form.cleaned_data['format'])
response = HttpResponse(content_type=fields['content_type'])
response['Content-Disposition'] = 'attachment; filename="%s"' %fields['filename']
diff --git a/apps/rc/utils.py b/apps/rc/utils.py
index 01aeec7..910df06 100644
--- a/apps/rc/utils.py
+++ b/apps/rc/utils.py
@@ -1,8 +1,8 @@
import ast
import json
-import numpy as np
-import matplotlib.pyplot as plt
-from matplotlib import cm
+# import numpy as np
+# import matplotlib.pyplot as plt
+# from matplotlib import cm
class Pulse_Design_Racp:
"""A class to define the .racp output from Pulse Design """
diff --git a/devices/dds/data.py b/devices/dds/data.py
index 085c37c..7bc5dab 100644
--- a/devices/dds/data.py
+++ b/devices/dds/data.py
@@ -4,34 +4,179 @@ Created on Feb 15, 2016
@author: Miguel Urco
'''
import struct
+import string
DDS_NBITS = 48
+FILE_STRUCTURE = """Phase Adjust Register 1
+-----------------------
+00000000
+00000000
+-----------------------
+Phase Adjust Register 2
+-----------------------
+00000000
+00000000
+-----------------------
+Frequency Tuning Word 1
+-----------------------
+00000000
+00000000
+00000000
+00000000
+00000000
+00000000
+-----------------------
+Frequency Tuning Word 2
+-----------------------
+00000000
+00000000
+00000000
+00000000
+00000000
+00000000
+-----------------------
+Delta Frequency Word
+-----------------------
+00000000
+00000000
+00000000
+00000000
+00000000
+00000000
+-----------------------
+Update Clock
+-----------------------
+00000000
+00000000
+00000000
+00000000
+-----------------------
+Ramp Rate Clock
+-----------------------
+00000000
+00000000
+00000000
+-----------------------
+Control Register
+-----------------------
+00000000
+00000000
+00000000
+00000000
+-----------------------
+Output Shaped Keying I
+Multiplier
+-----------------------
+00000000
+00000000
+-----------------------
+Output Shaped Keying Q
+Multiplier
+-----------------------
+00000000
+00000000
+-----------------------
+Output Shaped Keying
+Ramp Rate
+-----------------------
+00000000
+-----------------------
+QDAC
+-----------------------
+00000000
+00000000
+-----------------------
+CLOCK INPUT
+-----------------------
+10.00000000"""
+
def freq_to_binary(freq, mclock):
- binary = (float(freq)/mclock)*(2**DDS_NBITS)
+ if not mclock:
+ return None
+
+ try:
+ binary = int((float(freq)/mclock)*(2**DDS_NBITS))
+ except:
+ return 0
return binary
def binary_to_freq(binary, mclock):
- freq = (float(binary)/(2**DDS_NBITS))*mclock
+ if not mclock:
+ return None
+
+ try:
+ freq = (float(binary)/(2**DDS_NBITS))*mclock
+ except:
+ return 0
return freq
def phase_to_binary(phase):
- binary = float(phase)*8192/180.0
+ try:
+ binary = int(float(phase)*8192/180.0)
+ except:
+ return 0
return binary
def binary_to_phase(binary):
- phase = float(binary)*180.0/8192
+ try:
+ phase = float(binary)*180.0/8192
+ except:
+ return 0
return phase
-def dds_str_to_dict(registers):
+def __fill_dds_dict(parms):
+
+ my_dict = {'clock' : None,
+ 'multiplier' : 1,
+ 'frequencyA' : 0,
+ 'frequencyB' : 0,
+ 'frequencyA_Mhz' : 0,
+ 'frequencyB_Mhz' : 0,
+ 'phaseA_degress' : 0,
+ 'phaseB_degress' : 0,
+ 'modulation' : 0,
+ 'amplitudeI' : 0,
+ 'amplitudeQ' : 0,
+ 'amplitude_enabled' : 0,
+ 'delta_frequency' : 0,
+ 'update_clock' : 0,
+ 'ramp_rate_clock' : 0,
+ 'amplitude_ramp_rate' : 0,
+ 'qdac' : 0
+ }
+
+ my_dict.update(parms)
+ my_dict['phaseA'] = phase_to_binary(my_dict['phaseA_degrees'])
+ my_dict['phaseB'] = phase_to_binary(my_dict['phaseB_degrees'])
+
+ pll_range = 0
+ if my_dict['clock'] >= 200:
+ pll_range = 1
+
+ pll_bypass = 0
+ if my_dict['multiplier'] < 4:
+ pll_bypass = 1
+
+ control_register = (1 << 28) + \
+ (pll_range << 22) + (pll_bypass << 21) + \
+ (my_dict['multiplier'] << 16) + \
+ (my_dict['modulation'] << 9) + \
+ (my_dict['amplitude_enabled'] << 5)
+
+ my_dict['control_register'] = control_register
+
+ return my_dict
+
+def dds_str_to_dict(registers, clock=None):
"""
Output:
@@ -80,12 +225,20 @@ def dds_str_to_dict(registers):
modulation = (control_register & 0x00000E00) >> 9
amplitude_enabled = (control_register & 0x00000020) >> 5
- parms = {'clock' : None,
+ frequencyA_Mhz = None
+ frequencyB_Mhz = None
+
+ if clock:
+ mclock = clock*multiplier
+ frequencyA_Mhz = binary_to_freq(frequencyA, mclock)
+ frequencyB_Mhz = binary_to_freq(frequencyB, mclock)
+
+ parms = {'clock' : clock,
'multiplier' : multiplier,
'frequencyA' : frequencyA,
'frequencyB' : frequencyB,
- 'frequencyA_Mhz' : None,
- 'frequencyB_Mhz' : None,
+ 'frequencyA_Mhz' : frequencyA_Mhz,
+ 'frequencyB_Mhz' : frequencyB_Mhz,
'phaseA' : phaseA,
'phaseB' : phaseB,
'phaseA_degrees' : binary_to_phase(phaseA),
@@ -117,35 +270,10 @@ def dict_to_dds_str(parms):
amplitudeQ : 0 to (2**12-1) equivalent to: 0 - 100%
"""
- my_dict = {'clock' : None,
- 'multiplier' : 1,
- 'frequencyA' : 0,
- 'frequencyB' : 0,
- 'frequencyA_Mhz' : 0,
- 'frequencyB_Mhz' : 0,
- 'phaseA_degress' : 0,
- 'phaseB_degress' : 0,
- 'modulation' : 0,
- 'amplitudeI' : 0,
- 'amplitudeQ' : 0,
- 'amplitude_enabled' : 0,
- 'delta_frequency' : 0,
- 'update_clock' : 0,
- 'ramp_rate_clock' : 0,
- 'amplitude_ramp_rate' : 0,
- 'qdac' : 0
- }
-
- print "PArms", parms
-
- my_dict.update(parms)
- my_dict['phaseA'] = phase_to_binary(my_dict['phaseA_degrees'])
- my_dict['phaseB'] = phase_to_binary(my_dict['phaseB_degrees'])
+ my_dict = __fill_dds_dict(parms)
registers = ""
- control_register = (my_dict['multiplier'] << 16) + (my_dict['modulation'] << 9) + (my_dict['amplitude_enabled'] << 5)
-
registers += struct.pack(">H", my_dict['phaseA'])
registers += struct.pack(">H", my_dict['phaseB'])
@@ -158,7 +286,7 @@ def dict_to_dds_str(parms):
registers += struct.pack(">I", my_dict['ramp_rate_clock'])[1:]
- registers += struct.pack(">I", control_register)
+ registers += struct.pack(">I", my_dict['control_register'])
registers += struct.pack(">H", my_dict['amplitudeI'])
@@ -168,4 +296,115 @@ def dict_to_dds_str(parms):
registers += struct.pack(">H", my_dict['qdac'])
- return registers
\ No newline at end of file
+ return registers
+
+def text_to_dict(lines):
+
+ registers = ""
+ registers_v2 = []
+
+ for this_line in lines:
+ this_line = str.strip(this_line)
+
+ if str.isalpha(this_line):
+ continue
+
+ if not str.isdigit(this_line):
+ try:
+ value = float(this_line)
+ except:
+ continue
+
+ registers_v2.append(value)
+ continue
+
+ if len(this_line) != 8:
+ continue
+
+ registers += chr(string.atoi(this_line,2))
+
+ mclock = None
+ if len(registers_v2) > 0:
+ mclock = registers_v2[0]
+
+ my_dict = dds_str_to_dict(registers, mclock)
+
+ return my_dict
+
+def dict_to_text(parms):
+ """
+ It creates formatted DDS text using dictionary values.
+ """
+ my_dict = __fill_dds_dict(parms)
+
+ lines = FILE_STRUCTURE.split('\n')
+
+ cad = '{0:016b}'.format(my_dict['phaseA'])
+ lines[2] = cad[0:8]
+ lines[3] = cad[8:16]
+
+ cad = '{0:016b}'.format(my_dict['phaseB'])
+ lines[7] = cad[0:8]
+ lines[8] = cad[8:16]
+
+ cad = '{0:048b}'.format(my_dict['frequencyA'])
+ lines[12] = cad[0:8]
+ lines[13] = cad[8:16]
+ lines[14] = cad[16:24]
+ lines[15] = cad[24:32]
+ lines[16] = cad[32:40]
+ lines[17] = cad[40:48]
+
+ cad = '{0:048b}'.format(my_dict['frequencyB'])
+ lines[21] = cad[0:8]
+ lines[22] = cad[8:16]
+ lines[23] = cad[16:24]
+ lines[24] = cad[24:32]
+ lines[25] = cad[32:40]
+ lines[26] = cad[40:48]
+
+ cad = '{0:048b}'.format(my_dict['delta_frequency'])
+ lines[30] = cad[0:8]
+ lines[31] = cad[8:16]
+ lines[32] = cad[16:24]
+ lines[33] = cad[24:32]
+ lines[34] = cad[32:40]
+ lines[35] = cad[40:48]
+
+ cad = '{0:032b}'.format(my_dict['update_clock'])
+ lines[39] = cad[0:8]
+ lines[40] = cad[8:16]
+ lines[41] = cad[16:24]
+ lines[42] = cad[24:32]
+
+ cad = '{0:024b}'.format(my_dict['ramp_rate_clock'])
+ lines[46] = cad[0:8]
+ lines[47] = cad[8:16]
+ lines[48] = cad[16:24]
+
+ cad = '{0:032b}'.format(my_dict['control_register'])
+ lines[52] = cad[0:8]
+ lines[53] = cad[8:16]
+ lines[54] = cad[16:24]
+ lines[55] = cad[24:32]
+
+ cad = '{0:016b}'.format(my_dict['amplitudeI'])
+ lines[60] = cad[0:8]
+ lines[61] = cad[8:16]
+
+ cad = '{0:016b}'.format(my_dict['amplitudeQ'])
+ lines[66] = cad[0:8]
+ lines[67] = cad[8:16]
+
+ cad = '{0:08b}'.format(my_dict['amplitude_ramp_rate'])
+ lines[72] = cad[0:8]
+
+ cad = '{0:016b}'.format(my_dict['qdac'])
+ lines[76] = cad[0:8]
+ lines[77] = cad[8:16]
+
+ lines[81] = '%10.8f' %my_dict['clock']
+
+ text = '\n'.join(lines)
+
+ return text
\ No newline at end of file
diff --git a/devices/dds/files.py b/devices/dds/files.py
deleted file mode 100644
index 3a66c95..0000000
--- a/devices/dds/files.py
+++ /dev/null
@@ -1,67 +0,0 @@
-'''
-Created on Feb 8, 2016
-
-@author: Miguel Urco
-'''
-
-import string
-import data
-
-def read_dds_file(fp):
- """
- Function to extract the parameters from a text file with the next format:
-
- Input:
-
- File with the next content:
-
- Phase Adjust Register 1
- -----------------------
- 00000000
- 00000000
-
- .....
-
- -----------------------
- Frequency Tuning Word 1
- -----------------------
- 00110101
- 01111111
- 11111111
- 11111111
- 10100000
- 00000000
-
- Output:
- Return configuration parameters for DDS: multiplier, frequency, phase, amplitude, etc.
-
- """
-
- registers = ""
-
- for this_line in fp:
- this_line = str.strip(this_line)
-
- if not str.isdigit(this_line):
- continue
-
- if len(this_line) != 8:
- continue
-
- registers += chr(string.atoi(this_line,2))
-
- parms = data.dds_str_to_dict(registers)
-
- return parms
-
-def read_json_file(fp):
-
- kwargs = {}
-
- return kwargs
-
-def write_dds_file(filename):
- pass
-
-def write_json_file(filename):
- pass
\ No newline at end of file
diff --git a/devices/rc/files.py b/devices/rc/files.py
deleted file mode 100644
index e6ef6ba..0000000
--- a/devices/rc/files.py
+++ /dev/null
@@ -1,67 +0,0 @@
-'''
-Created on Feb 8, 2016
-
-@author: Miguel Urco
-'''
-
-import string
-import data
-
-def read_rc_file(fp):
- """
- Function to extract the parameters from a text file with the next format:
-
- Input:
-
- File with the next content:
-
- Phase Adjust Register 1
- -----------------------
- 00000000
- 00000000
-
- .....
-
- -----------------------
- Frequency Tuning Word 1
- -----------------------
- 00110101
- 01111111
- 11111111
- 11111111
- 10100000
- 00000000
-
- Output:
- Return configuration parameters for DDS: multiplier, frequency, phase, amplitude, etc.
-
- """
-
- registers = ""
-
- for this_line in fp:
- this_line = str.strip(this_line)
-
- if not str.isdigit(this_line):
- continue
-
- if len(this_line) != 8:
- continue
-
- registers += chr(string.atoi(this_line,2))
-
- parms = data.rc_str_to_dict(registers)
-
- return parms
-
-def read_json_file(fp):
-
- kwargs = {}
-
- return kwargs
-
-def write_cr_file(filename):
- pass
-
-def write_json_file(filename):
- pass
\ No newline at end of file