Commit 99b161a1 authored by Daniel Brown's avatar Daniel Brown
Browse files

block changes and fixing mirror param

parent e5c36c9b
......@@ -156,7 +156,7 @@ class mirror(Component):
self.__ybeta = float(ybeta)
@property
def r_ap(self): return Param('r_ap', self.__mass)
def r_ap(self): return Param('r_ap', self.__r_ap)
@r_ap.setter
def r_ap(self,value): self.__aperture = float(value)
......
......@@ -42,7 +42,8 @@ from pykat.commands import Command, xaxis
from pykat.gui.gui import pyKatGUI
NO_GUI = False
NO_BLOCK = "NO_BLOCK"
class katRun(object):
def __init__(self):
self.runDateTime = datetime.datetime.now()
......@@ -66,7 +67,7 @@ class katRun(object):
class Block:
def __init__(self, name):
self.__name = name
self.contents = {} # dictionary of objects and strings of finesse code
self.contents = [] # List of objects and strings of finesse code
self.enabled = True
@property
......@@ -130,7 +131,10 @@ class kat(object):
def parseCommands(self, commands):
blockComment = False
self.__currentTag= ""
self.__currentTag= NO_BLOCK
if not (NO_BLOCK in self.__blocks):
self.__blocks[NO_BLOCK] = Block(NO_BLOCK)
for line in commands.split("\n"):
if len(line.strip()) >= 2:
......@@ -148,11 +152,11 @@ class kat(object):
if newTag in self.__blocks:
raise pkex.BasePyKatException("Block `{0}` has already been read")
self.__blocks{newTag} = [] # create new list to store all references to components in block
self.__blocks[newTag] = Block(newTag) # create new list to store all references to components in block
self.__currentTag = newTag
if values[1] == "FTend":
self.__currentTag = None
self.__currentTag = NO_BLOCK
continue
#warnings.warn("current tag {0}".format(self.__currentTag))
......@@ -170,20 +174,27 @@ class kat(object):
continue
first = line.split(" ",1)[0]
obj = None
if(first == "m"):
self.add(pykat.components.mirror.parseFinesseText(line))
obj = pykat.components.mirror.parseFinesseText(line)
elif(first == "s"):
self.add(pykat.components.space.parseFinesseText(line))
obj = pykat.components.space.parseFinesseText(line)
elif(first == "l"):
self.add(pykat.components.laser.parseFinesseText(line))
obj = pykat.components.laser.parseFinesseText(line)
elif(first == "xaxis" or first == "x2axis" or first == "xaxis*" or first == "x2axis*"):
self.add(pykat.commands.xaxis.parseFinesseText(line))
obj = pykat.commands.xaxis.parseFinesseText(line)
else:
print "Parsing `{0}` into pykat object not implemented yet, added as extra line.".format(line)
self.__extra_lines.append(line + "\n")
obj = line
self.__block[self.__currentTag].contents.append(obj)
if not isinstance(line, str):
self.__block[self.__currentTag].contents.append(obj)
self.add(obj)
self.__currentTag= ""
self.__currentTag = NO_BLOCK
def run(self, printout=1, printerr=1, save_output=False, save_kat=False,kat_name=None) :
"""
......@@ -378,37 +389,27 @@ class kat(object):
out = []
for key in self.__components:
txt = self.__components[key].getFinesseText()
if txt != None:
if isinstance(txt,list):
for t in txt: out.append(t+ "\n")
else:
out.append(txt + "\n")
for key in self.__detectors:
txt = self.__detectors[key].getFinesseText()
for key in self.__blocks:
objs = self.__blocks[key]
out.append("%%% FTblock " + key)
if txt != None:
if isinstance(txt,list):
for t in txt: out.append(t+ "\n")
else:
out.append(txt + "\n")
for obj in objs:
if isinstance(obj, str):
out.append(lines + '\n')
elif isinstance(obj, Component) or isinstance(obj, Detector) or isinstance(obj, Command):
txt = obj.getFinesseText()
if txt != None:
if isinstance(txt,list):
for t in txt: out.append(t + "\n")
else:
out.append(txt + "\n")
out.append("%%% FTend " + key)
if self.noxaxis != None and self.noxaxis == True:
out.append("noxaxis\n")
for key in self.__commands:
if self.noxaxis == None or (self.noxaxis == True and isinstance(self.__commands[key], xaxis)):
txt = self.__commands[key].getFinesseText()
if txt != None:
if isinstance(txt,list):
for t in txt: out.append(t+ "\n")
else:
out.append(txt + "\n")
# now loop through all the nodes and get any gauss commands
for key in self.nodes.getNodes():
......@@ -422,14 +423,7 @@ class kat(object):
if self.phase != None: out.append("phase {0}\n".format(self.phase))
if self.maxtem != None: out.append("maxtem {0}\n".format(self.maxtem))
# There maybe extra lines we want to include in the kat
# script which aren't parseable into components, detectors
# or commands. Typically when something hasn't been fully
# supported yet. So bung these extra lines on at the end
for lines in self.__extra_lines:
out.append(lines)
# ensure we don't do any plotting. That should be handled
# by user themselves
out.append("gnuterm no\n")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment