diff --git a/apps/jars/models.py b/apps/jars/models.py
index 8cd7f69..85727ee 100644
--- a/apps/jars/models.py
+++ b/apps/jars/models.py
@@ -46,10 +46,10 @@ class JARSConfiguration(Configuration):
acq_profiles = models.PositiveIntegerField(verbose_name='Acquired Profiles', validators=[MaxValueValidator(5000)], default=400)
profiles_block = models.PositiveIntegerField(verbose_name='Profiles Per Block', validators=[MaxValueValidator(5000)], default=400)
fftpoints = models.PositiveIntegerField(verbose_name='FFT Points',default=16)
- incohe_integr = models.PositiveIntegerField(verbose_name='Incoherent Integrations',validators=[MinValueValidator(1)], default = 30)
+ incohe_integr = models.PositiveIntegerField(verbose_name='Incoherent Integrations',validators=[MinValueValidator(1)], default=30)
filter = models.ForeignKey(JARSfilter, on_delete=models.CASCADE, null=True, blank=True)
- spectral_number = models.PositiveIntegerField(verbose_name='# Spectral Combinations',validators=[MinValueValidator(1)], null=True, blank=True)
- spectral = models.CharField(verbose_name='Combinations', max_length=5000, default = '[0,0]')
+ spectral_number = models.PositiveIntegerField(verbose_name='# Spectral Combinations',validators=[MinValueValidator(1)], default=1)
+ spectral = models.CharField(verbose_name='Combinations', max_length=5000, default = '[0, 0],')
create_directory = models.BooleanField(verbose_name='Create Directory Per Day', default=True)
include_expname = models.BooleanField(verbose_name='Experiment Name in Directory', default=True)
acq_link = models.BooleanField(verbose_name='Acquisition Link', default=True)
diff --git a/apps/jars/templates/jars_conf_edit.html b/apps/jars/templates/jars_conf_edit.html
index 0162f09..81c2500 100644
--- a/apps/jars/templates/jars_conf_edit.html
+++ b/apps/jars/templates/jars_conf_edit.html
@@ -14,6 +14,10 @@ $(document).ready(function() {
save_ch_dc = $("#id_save_ch_dc")
add_spec_button = $("#add_spectral_button")
del_spec_button = $("#delete_spectral_button")
+ sel_spec_button = $("#self_spectral_button")
+ cro_spec_button = $("#cross_spectral_button")
+ all_spec_button = $("#all_spectral_button")
+
if (type == 0) {
$(spectral_number).attr('readonly', true);
$(spectral).attr('readonly', true);
@@ -22,7 +26,9 @@ $(document).ready(function() {
$(save_ch_dc).attr('readonly', true);
$(add_spec_button).attr('disabled', true);
$(del_spec_button).attr('disabled', true);
-
+ $(sel_spec_button).attr('disabled', true);
+ $(cro_spec_button).attr('disabled', true);
+ $(all_spec_button).attr('disabled', true);
}
else {
$(spectral_number).attr('readonly', false);
@@ -32,6 +38,9 @@ $(document).ready(function() {
$(save_ch_dc).attr('readonly', false);
$(add_spec_button).attr('disabled', false);
$(del_spec_button).attr('disabled', false);
+ $(sel_spec_button).attr('disabled', false);
+ $(cro_spec_button).attr('disabled', false);
+ $(all_spec_button).attr('disabled', false);
}
});
@@ -43,6 +52,10 @@ $("#id_exp_type").change(function() {
save_ch_dc = $("#id_save_ch_dc")
add_spec_button = $("#add_spectral_button")
del_spec_button = $("#delete_spectral_button")
+ sel_spec_button = $("#self_spectral_button")
+ cro_spec_button = $("#cross_spectral_button")
+ all_spec_button = $("#all_spectral_button")
+
if (type == 0) {
$(spectral_number).attr('readonly', true);
$(spectral).attr('readonly', true);
@@ -51,7 +64,9 @@ $("#id_exp_type").change(function() {
$(save_ch_dc).attr('readonly', true);
$(add_spec_button).attr('disabled', true);
$(del_spec_button).attr('disabled', true);
-
+ $(sel_spec_button).attr('disabled', true);
+ $(cro_spec_button).attr('disabled', true);
+ $(all_spec_button).attr('disabled', true);
}
else {
$(spectral_number).attr('readonly', false);
@@ -61,43 +76,59 @@ $("#id_exp_type").change(function() {
$(save_ch_dc).attr('readonly', false);
$(add_spec_button).attr('disabled', false);
$(del_spec_button).attr('disabled', false);
+ $(sel_spec_button).attr('disabled', false);
+ $(cro_spec_button).attr('disabled', false);
+ $(all_spec_button).attr('disabled', false);
}
});
+
+$("#id_cards_number").on('change', function() {
+ var cards_number = $("#id_cards_number").val();
+ channels_number = $("#id_channels_number")
+ $(channels_number).val(cards_number*2)
+ updateChannelsNumber();
+});
+
+
$("#id_channels_number").on('change', function() {
updateChannelsNumber();
});
-
+
+
+$("#id_spectral").on('change', function() {
+ updateSpectralNumber();
+});
+
+
+function updateSpectralNumber(){
+ var spectral_comb = $("#id_spectral").val();
+ var num = spectral_comb.length;
+ var cont = 0
+ for (i = 0; i < num; i++) {
+ if (spectral_comb[i] == "]"){
+ cont = cont + 1
+ }
+ }
+ $("#id_spectral_number").val(cont)
+}
+
+
function updateChannelsNumber() {
var channels_number = $("#id_channels_number").val();
channels = $("#id_channels")
+ sequence = ""
- if (channels_number == 1) {
- $(channels).val('1')
- }
- else if (channels_number == 2){
- $(channels).val('1,2')
- }
- else if (channels_number == 3){
- $(channels).val('1,2,3')
- }
- else if (channels_number == 4){
- $(channels).val('1,2,3,4')
+ for (i = 1; i <= channels_number; i++) {
+ if (i==1){
+ sequence = i.toString()
+ }
+ else{
+ sequence = sequence + "," + i.toString()
+ }
}
- else if (channels_number == 5){
- $(channels).val('1,2,3,4,5')
- }
- else if (channels_number == 6){
- $(channels).val('1,2,3,4,5,6')
- }
- else if (channels_number == 7){
- $(channels).val('1,2,3,5,6,7')
- }
- else {
- $(channels).val('1,2,3,4,5,6,7,8')
- }
-
+ $(channels).val(sequence)
}
{% endblock %}
\ No newline at end of file
diff --git a/apps/jars/widgets.py b/apps/jars/widgets.py
index f6695fb..197f46f 100644
--- a/apps/jars/widgets.py
+++ b/apps/jars/widgets.py
@@ -16,26 +16,32 @@ class SpectralWidget(forms.widgets.TextInput):
disabled = 'disabled' if attrs.get('disabled', False) else ''
name = attrs.get('name', label)
if '[' in value:
- value = ast.literal_eval(value)
+ if value[len(value)-1] == ",":
+ value = ast.literal_eval(value)
+ else:
+ value = value + ","
+ value = ast.literal_eval(value)
codes = value
if not isinstance(value, list):
- if len(value) > 1:
- text=''
- for val in value:
- text = text+str(val)+','
+ text=''
+ #lista = []
+ #if len(value) > 1:
+ for val in value:
+ text = text+str(val)+','
+ #lista.append(val)
codes=text
else:
- codes=value+","
+ codes=''
html = '''
-
-
-
+
+
+
'''.format(disabled, label, name, codes)
script = '''
@@ -47,9 +53,13 @@ class SpectralWidget(forms.widgets.TextInput):
$("#all_spectral_button").click(function(){{
- alert(spectral_comb)
+ var sequence1 = selfSpectral()
+ var sequence2 = crossSpectral()
+ $("#id_spectral").val(sequence1+sequence2)
+ updateSpectralNumber()
}});
+
$("#add_spectral_button").click(function(){{
var spectral_comb = $("#id_spectral").val();
var spectral_number1 = $("#num1").val();
@@ -59,9 +69,65 @@ class SpectralWidget(forms.widgets.TextInput):
var n = spectral_comb.search(str);
if (n==-1){
$("#id_spectral").val(spectral_comb+"["+$("#num1").val()+", "+$("#num2").val()+"],")
- }
+ }
+ updateSpectralNumber()
+ }});
+
+
+ $("#self_spectral_button").click(function(){{
+ var sequence = selfSpectral()
+ $("#id_spectral").val(sequence)
+
+ updateSpectralNumber()
}});
+ $("#cross_spectral_button").click(function(){{
+ var sequence = crossSpectral()
+ $("#id_spectral").val(sequence)
+
+ updateSpectralNumber()
+ }});
+
+
+ function selfSpectral() {
+ var channels = $("#id_channels").val();
+ var n = (channels.length)-1;
+ var num = parseInt(channels[n]);
+ sequence = ""
+ for (i = 0; i < num; i++) {
+ sequence = sequence + "[" + i.toString() + ", " + i.toString() + "],"
+ }
+ return sequence
+ }
+
+
+ function crossSpectral() {
+ var channels = $("#id_channels").val();
+ var n = (channels.length)-1;
+ var num = parseInt(channels[n]);
+ sequence = ""
+ for (i = 0; i < num; i++) {
+ for (j = i+1; j < num; j++) {
+ sequence = sequence + "[" + i.toString() + ", " + j.toString() + "],"
+ }
+ }
+ return sequence
+ }
+
+
+ function updateSpectralNumber(){
+ var spectral_comb = $("#id_spectral").val();
+ var num = spectral_comb.length;
+ var cont = 0
+ for (i = 0; i < num; i++) {
+ if (spectral_comb[i] == "]"){
+ cont = cont + 1
+ }
+ }
+ $("#id_spectral_number").val(cont)
+ }
+
+
$("#delete_spectral_button").click(function(){{
var spectral_comb = $("#id_spectral").val();
var spectral_number1 = $("#num1").val();
@@ -86,9 +152,11 @@ class SpectralWidget(forms.widgets.TextInput):
var tuple = "["+$("#num1").val()+", "+$("#num2").val()+"],"
var txt = spectral_comb.replace(tuple,'');
$("#id_spectral").val(txt)
- }
+ }
+ updateSpectralNumber()
}});
+
}});
'''