Commit 6324b6f3 authored by Daniel Brown's avatar Daniel Brown
Browse files

more fixes with new node code and updated block generation for kat files

parent d03c076a
......@@ -23,9 +23,9 @@ kat.parseCommands(code)
kat.add(cavity('cav1', 'm1', 'n3', 'm2', 'n4'))
kat.add(photodiode('pd_cav','n4',[]))
kat.add(photodiode('pd_ref','n2',[]))
kat.add(photodiode('pd_trs','n5',[]))
kat.add(photodiode('pd_cav','n4'))
kat.add(photodiode('pd_ref','n2'))
kat.add(photodiode('pd_trs','n5'))
kat.add(xaxis("lin", [0, 360], kat.m2, kat.m2.phi, 100))
......
......@@ -19,6 +19,7 @@ class Detector(object) :
self.noplot = False
self.enabled = True
self.tag = None
self.__node = None
if node.find('*'):
self._alternate_beam = True
......@@ -27,7 +28,7 @@ class Detector(object) :
self.__requested_node = node
def _on_kat_add(self, kat):
self._node = kat.nodes.createNode(self.__requested_node)
self.__node = kat.nodes.createNode(self.__requested_node)
@staticmethod
def parseFinesseText(text):
......@@ -40,8 +41,8 @@ class Detector(object) :
def getQGraphicsItem(self):
return None
def getNodes(self):
return [self._node]
@property
def node(self): return self.__node
def __getname(self):
return self.__name
......@@ -86,7 +87,7 @@ class photodiode(Detector):
self.values[key] = SIfloat(value)
def __init__(self, name, node, senstype, num_demods, demods):
def __init__(self, name, node, senstype=None, num_demods=0, demods=[]):
Detector.__init__(self, name, node)
if num_demods>2:
raise NotImplementedError("pd with more than two demodulations not implemented yet")
......@@ -94,10 +95,10 @@ class photodiode(Detector):
self.senstype = senstype
# every second element into f (starting at 1)
self.f(demods[::2])
print self.f[1]
# every second element into phi (starting at 2)
self.phi([1,2])
print self.phi[1]
for i in demods[1::2]:
self.phi.append(i)
......@@ -148,9 +149,9 @@ class photodiode(Detector):
rtn = []
if self._alternate_beam:
rtn.append("pd {0} {1}".format(self.name, self._node.name))
rtn.append("pd {0} {1}".format(self.name, self.node.name))
else:
rtn.append("pd {0} {1}*".format(self.name, self._node.name))
rtn.append("pd {0} {1}*".format(self.name, self.node.name))
if self.noplot:
rtn.append("noplot {0}".format(self.name))
......@@ -161,7 +162,7 @@ class photodiode(Detector):
def getQGraphicsItem(self):
if self._svgItem == None:
self._svgItem = ComponentQGraphicsItem(":/resources/photodiode_red.svg",self,[(-5,11,self._node)])
self._svgItem = ComponentQGraphicsItem(":/resources/photodiode_red.svg",self,[(-5,11,self.node)])
return self._svgItem
......@@ -198,11 +198,10 @@ class kat(object):
else:
print "Parsing `{0}` into pykat object not implemented yet, added as extra line.".format(line)
obj = line
self.__blocks[self.__currentTag].contents.append(obj)
# manually add the line to the block contents
self.__blocks[self.__currentTag].contents.append(line)
if not isinstance(obj, str):
self.__blocks[self.__currentTag].contents.append(obj)
self.add(obj)
self.__currentTag = NO_BLOCK
......@@ -342,10 +341,10 @@ class kat(object):
print fe
def add(self, obj) :
print type(obj)
def add(self, obj):
try:
obj.tag = self.__currentTag
self.__blocks[self.__currentTag].contents.append(obj)
if isinstance(obj, Component):
......@@ -409,8 +408,8 @@ class kat(object):
for key in self.__blocks:
objs = self.__blocks[key].contents
print key, objs
out.append("%%% FTblock " + key)
out.append("%%% FTblock " + key + "\n")
for obj in objs:
if isinstance(obj, str):
......@@ -425,7 +424,7 @@ class kat(object):
else:
out.append(txt + "\n")
out.append("%%% FTend " + key)
out.append("%%% FTend " + key + "\n")
if self.noxaxis != None and self.noxaxis == True:
out.append("noxaxis\n")
......
......@@ -35,8 +35,8 @@ class NodeNetwork(object):
list = []
for name in node_names:
n = createNode(name)
self.connectNodeToComp(node, comp, do_callback=False)
n = self.createNode(name)
self.connectNodeToComp(n, comp, do_callback=False)
list.append(n)
self.__componentNodes[comp.id] = tuple(list)
......
Markdown is supported
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