##// END OF EJS Templates
Fix importing racp, fix sub-baudio windows reference ...
Juan C. Espinoza -
r237:d6f68eb3d3c3
parent child
Show More
@@ -714,14 +714,14 class RCLine(models.Model):
714 codes = [line for line in self.get_lines(line_type__name='codes') if int(json.loads(line.params)['TX_ref'])==int(tx_id)]
714 codes = [line for line in self.get_lines(line_type__name='codes') if int(json.loads(line.params)['TX_ref'])==int(tx_id)]
715
715
716 if codes:
716 if codes:
717 tx_width = float(json.loads(RCLine.objects.get(pk=tx_id).params)['pulse_width'])*km2unit/len(json.loads(codes[0].params)['codes'][0])
717 tx_width = float(json.loads(RCLine.objects.get(pk=tx_id).params)['pulse_width'])*km2unit/len(json.loads(codes[0].params)['codes'][0])
718 else:
718 else:
719 tx_width = float(json.loads(RCLine.objects.get(pk=tx_id).params)['pulse_width'])*km2unit
719 tx_width = float(json.loads(RCLine.objects.get(pk=tx_id).params)['pulse_width'])*km2unit
720
720
721 if ref=='first_baud':
721 if ref=='first_baud':
722 return int(1 + round((tx_width + 1)/2 + params['first_height']*km2unit - params['resolution']*km2unit))
722 return int(1 + round((tx_width + 1)/2 + params['first_height']*km2unit - params['resolution']*km2unit))
723 elif ref=='sub_baud':
723 elif ref=='sub_baud':
724 return int(1 + round(params['first_height']*km2unit - params['resolution']*km2unit/2))
724 return np.ceil(1 + params['first_height']*km2unit - params['resolution']*km2unit/2)
725 else:
725 else:
726 return 0
726 return 0
727
727
@@ -808,17 +808,20 class RCLine(models.Model):
808 tx_params = json.loads(tx.params)
808 tx_params = json.loads(tx.params)
809 delays = [float(d)*km2unit for d in tx_params['delays'].split(',') if d]
809 delays = [float(d)*km2unit for d in tx_params['delays'].split(',') if d]
810 f = int(float(tx_params['pulse_width'])*km2unit/len(params['codes'][0]))
810 f = int(float(tx_params['pulse_width'])*km2unit/len(params['codes'][0]))
811 codes = [(np.fromstring(''.join([s*f for s in code]), dtype=np.uint8)-48).astype(np.int8) for code in params['codes']]
811 codes = [(np.fromstring(''.join([s*f for s in code]), dtype=np.uint8)-48).astype(np.int8) for code in params['codes']]
812 codes = [self.array_to_points(code) for code in codes]
812 codes = [self.array_to_points(code) for code in codes]
813 n = len(codes)
813 n = len(codes)
814
814
815 for i, tup in enumerate(tx.pulses_as_points()):
816 code = codes[i%n]
817 y.extend([(c[0]+tup[0], c[1]+tup[0]) for c in code])
818
819 ranges = tx_params['range'].split(',')
815 ranges = tx_params['range'].split(',')
820 if len(ranges)>0 and ranges[0]!='0':
816 if len(ranges)>0 and ranges[0]!='0':
821 y = self.mask_ranges(y, ranges)
817 dum = self.mask_ranges(tx.pulses_as_points(), ranges)
818 else:
819 dum = tx.pulses_as_points()
820
821 for i, tup in enumerate(dum):
822 if tup==(0,0): continue
823 code = codes[i%n]
824 y.extend([(c[0]+tup[0], c[1]+tup[0]) for c in code])
822
825
823 elif self.line_type.name=='sync':
826 elif self.line_type.name=='sync':
824 params = json.loads(self.params)
827 params = json.loads(self.params)
@@ -846,8 +849,7 class RCLine(models.Model):
846 y.extend(y_pp)
849 y.extend(y_pp)
847
850
848 elif self.line_type.name=='windows':
851 elif self.line_type.name=='windows':
849 params = json.loads(self.params)
852 params = json.loads(self.params)
850
851 if 'params' in params and len(params['params'])>0:
853 if 'params' in params and len(params['params'])>0:
852 tr_params = json.loads(self.get_lines(line_type__name='tr')[0].params)
854 tr_params = json.loads(self.get_lines(line_type__name='tr')[0].params)
853 tr_ranges = tr_params['range'].split(',')
855 tr_ranges = tr_params['range'].split(',')
@@ -855,12 +857,13 class RCLine(models.Model):
855 y_win = self.points(ntx, ipp_u,
857 y_win = self.points(ntx, ipp_u,
856 p['resolution']*p['number_of_samples']*km2unit,
858 p['resolution']*p['number_of_samples']*km2unit,
857 before=int(self.rc_configuration.time_before*us2unit),
859 before=int(self.rc_configuration.time_before*us2unit),
858 sync=self.get_win_ref(p, params['TX_ref'], km2unit))
860 sync=self.rc_configuration.sync+self.get_win_ref(p, params['TX_ref'], km2unit))
859
861
862
860 if len(tr_ranges)>0 and tr_ranges[0]!='0':
863 if len(tr_ranges)>0 and tr_ranges[0]!='0':
861 y_win = self.mask_ranges(y_win, tr_ranges)
864 y_win = self.mask_ranges(y_win, tr_ranges)
862
865
863 y.extend(y_win)
866 y.extend(y_win)
864
867
865 elif self.line_type.name=='mix':
868 elif self.line_type.name=='mix':
866 values = self.rc_configuration.parameters.split('-')
869 values = self.rc_configuration.parameters.split('-')
@@ -955,7 +958,7 class RCLine(models.Model):
955 args = [int(a) for a in index.split('-')]
958 args = [int(a) for a in index.split('-')]
956 y[args[0]-1:args[1]] = Y[args[0]-1:args[1]]
959 y[args[0]-1:args[1]] = Y[args[0]-1:args[1]]
957 else:
960 else:
958 y[int(index-1)] = Y[int(index-1)]
961 y[int(index)-1] = Y[int(index)-1]
959
962
960 return y
963 return y
961
964
@@ -1,6 +1,23
1
1
2 import json
2 import json
3
3
4
5 def parse_range(s):
6
7 vars = ('TXA,', 'A,', 'TXB,', 'B,', 'TXA', 'TXB', 'A', 'B')
8
9 for var in vars:
10 if var in s:
11 s = s.replace(var, '')
12 if 'A' in var:
13 ref = 'TXA'
14 else:
15 ref = 'TXB'
16 return ref, s
17
18 return '0', s
19
20
4 class RCFile(object):
21 class RCFile(object):
5 '''
22 '''
6 Class to handle Radar controller configuration files
23 Class to handle Radar controller configuration files
@@ -9,6 +26,7 class RCFile(object):
9 def __init__(self, f=None):
26 def __init__(self, f=None):
10
27
11 self.data = {}
28 self.data = {}
29 self.line = ''
12 if isinstance(f, str):
30 if isinstance(f, str):
13 self.f = open(f)
31 self.f = open(f)
14 self.name = f.split('/')[-1]
32 self.name = f.split('/')[-1]
@@ -78,21 +96,7 class RCFile(object):
78
96
79 #Add TR line
97 #Add TR line
80 if 'Pulse selection_TR' in data:
98 if 'Pulse selection_TR' in data:
81 if 'A,' in data['Pulse selection_TR']:
99 ref, rng = parse_range(data['Pulse selection_TR'])
82 rng = data['Pulse selection_TR'].replace('A,', '')
83 ref = 'TXA'
84 elif 'A' in data['Pulse selection_TR']:
85 rng = data['Pulse selection_TR'].replace('A', '')
86 ref = 'TXA'
87 elif 'B,' in data['Pulse selection_TR']:
88 rng = data['Pulse selection_TR'].replace('B,', '')
89 ref = 'TXB'
90 elif 'B' in data['Pulse selection_TR']:
91 rng = data['Pulse selection_TR'].replace('B', '')
92 ref = 'TXB'
93 else:
94 rng = data['Pulse selection_TR']
95 ref = '0'
96 line = {'type':'tr', 'range': rng if rng else '0', 'TX_ref':ref}
100 line = {'type':'tr', 'range': rng if rng else '0', 'TX_ref':ref}
97 else:
101 else:
98 line = {'type': 'tr', 'range': '0', 'TX_ref': '0'}
102 line = {'type': 'tr', 'range': '0', 'TX_ref': '0'}
General Comments 0
You need to be logged in to leave comments. Login now