개정판 f6c65544
issue #563: fix line type auto determine
Change-Id: I523e4babdb5d6dc6a8e4ff07fd03a8f04d74a341
DTI_PID/DTI_PID/LineTypeConditions.py | ||
---|---|---|
45 | 45 |
if len(items) == len([condition for condition in self.conditions if condition[0] and condition[0] != '']): |
46 | 46 |
for condition in self.conditions: |
47 | 47 |
if not condition[0]: continue |
48 |
matches = [] |
|
48 | 49 |
if condition[0] == 'Instrument': |
49 |
matches = [item for item in items if type(item) is QEngineeringInstrumentItem] |
|
50 |
for index in range(len(items)): |
|
51 |
if type(items[index]) is QEngineeringInstrumentItem: |
|
52 |
matches.append([items[index], index]) |
|
50 | 53 |
if not matches: return False |
51 | 54 |
elif condition[0] == 'Line': |
52 |
matches = [item for item in items if type(item) is QEngineeringLineItem] |
|
55 |
for index in range(len(items)): |
|
56 |
if type(items[index]) is QEngineeringLineItem: |
|
57 |
matches.append([items[index], index]) |
|
53 | 58 |
if not matches: return False |
54 | 59 |
|
55 | 60 |
if condition[1]: |
56 | 61 |
res = False |
57 |
for item in matches: |
|
62 |
for item, index in matches:
|
|
58 | 63 |
ret = eval(condition[1]) |
59 |
if ret == True: res = True |
|
60 |
|
|
61 |
if res == False: return False |
|
64 |
if ret == True: |
|
65 |
res = True |
|
66 |
break |
|
67 |
|
|
68 |
if res == False: |
|
69 |
return False |
|
70 |
else: |
|
71 |
items.pop(index) |
|
72 |
else: |
|
73 |
items.pop(matches[0][1]) |
|
62 | 74 |
|
63 | 75 |
return True |
64 | 76 |
except Exception as ex: |
내보내기 Unified diff