diff --git a/main.py b/main.py index 14c2fd5..bea5a4c 100644 --- a/main.py +++ b/main.py @@ -257,23 +257,6 @@ class BeamlineEditor(QtWidgets.QMainWindow, Ui_BeamlineGUI): nextVar=None return - if a > 2: - root = self.elementDB[id0].firstElementID - domain=self.elementDB[root] - tree = self.editor.flatten(root, alt+1) - subsec = [] - for ele in tree.path: - if isinstance(self.elementDB[ele], LineContainer): - container=self.elementDB[ele].Name - self.exporter.writeSection(container,self.elementDB[ele].LengthRes) - startid = self.elementDB[ele].firstElementID - if startid in self.elementDB.keys(): - subtree=self.editor.flatten(startid, alt+1) - for atomic in subtree.path: - self.exporter.writeElement(container,self.elementDB[atomic]) - subsec.append(container) - self.exporter.writeDomain(references[sec],sec,domain.LengthRes,subsec) - self.exporter.buildCaseFooter() def exportLayoutasPL(self): ok = export_table_to_excel(self.UIProtoList,"Protolist/Export/protolist.xlsx","Proto-HL") @@ -469,26 +452,26 @@ class BeamlineEditor(QtWidgets.QMainWindow, Ui_BeamlineGUI): self.elementDB[key].LengthRes=self.branchingTemp[key] return line - def unwrap(self, name, node_id,line,case_num): + def unwrap(self, name, node_id,line,case_num) -> bool : if self.verbose: - print('Unwrapping Line: %s' % name) - tree=self.editor.flatten(node_id,case_num) - secondBranch = False + print('Unwrapping Line: %s' % name) # this is a container -> checked in flattenSingleLine + tree=self.editor.flatten(node_id,case_num) # get the tree + secondBranch = False # default go along primary branch for ele in tree.path: - if self.targetReached: - return - self.report(ele, name) - type = self.editor.getElementType(ele) - if type == 'Line': + if self.targetReached: # a Target element (Marker) encountered -> no need to further unroll the line + return False # no branching needed + self.report(ele, name) # if self.verbose -> print element name and type + type = self.editor.getElementType(ele) # get type of element in the trunc path of the container. + if type == 'Line': # if it is a line container (in a line container -> unwrap this line) line.append(self.elementDB[ele],sRef=0,Ref='relative') subline = self.elementDB[ele] subline.clear() name1 = subline.Name ref = subline.firstElementID - if ref in self.elementDB.keys(): - secondBranch = self.unwrap(name + name1, ref, subline,case_num) + if ref in self.elementDB.keys(): # unwrap the line container in a recursive manner + secondBranch = self.unwrap(name + name1, ref, subline,case_num) # returns true if the subline has a branching point(dipole) if secondBranch: - print('Was branching - should continue with second branch, returning from',name+name1) + #print('Sub-Container',name+name1," has branching - should continue with second branch") break # do not continue with any other elements else: if self.verbose: @@ -506,6 +489,7 @@ class BeamlineEditor(QtWidgets.QMainWindow, Ui_BeamlineGUI): print(' Target reached:',self.elementDB[ele].Name) self.targetReached=True else: + # this is a basic (atomic element), excluding line containers, markers and variable containers sRef=self.elementDB[ele].OffsetS Ref='absolute' if self.elementDB[ele].relOff: @@ -528,21 +512,23 @@ class BeamlineEditor(QtWidgets.QMainWindow, Ui_BeamlineGUI): self.elementDB[ele].angle = self.elementDB[ele].design_angle line.hasBranchPoint = True secondBranch=True - return secondBranch + break else: self.elementDB[ele].angle=0 line.hasBranchPoint = False if secondBranch: - print("There should be now following the second branch from container:", name,tree.secondary) + #print("There should be now following the second branch from container:", name) if tree.secondary: - print("Has secondary tree", name) - self.unwrap(name, tree.secondary.node_id, line, case_num) + #print("Has secondary tree", name) + secondBranch = self.unwrap(name, tree.secondary.node_id, line, case_num) + #print('Still needs branching one level above after unwrapping second branch:',secondBranch) + return secondBranch else: - print("Has no secondary tree", name,'- returning to parent container') + #print("Has no secondary tree", name,'- returning to parent container') return secondBranch else: if tree.primary: - self.unwrap(name,tree.primary.node_id,line,case_num) + secondBranch = self.unwrap(name,tree.primary.node_id,line,case_num) return secondBranch diff --git a/protoliste.py b/protoliste.py index bcf2267..e4acf69 100644 --- a/protoliste.py +++ b/protoliste.py @@ -334,6 +334,8 @@ class ProtoListe(ApplicationTemplate): channels=ele['PSChannels'] if ele.Baugruppe=='U15': channels=channels+1 + elif ele.Baugruppe == 'SFPlus-U12-AB': + channels=channels+1 if ele.Baugruppe == 'UE38': channels = channels + 2 if ele.Baugruppe=='QFU':