Skip to content
Snippets Groups Projects
Commit b4e85dbe authored by Daniel Brown's avatar Daniel Brown
Browse files

Adding exception handling to add puts as extra lines if they can't be handled...

Adding exception handling to add puts as extra lines if they can't be handled for backward compatiability
parent aa3205bd
Branches
No related tags found
No related merge requests found
...@@ -320,6 +320,77 @@ class gauss(object): ...@@ -320,6 +320,77 @@ class gauss(object):
else: else:
kat.nodes[node].setGauss(kat.components[component], gpx, gpy) kat.nodes[node].setGauss(kat.components[component], gpx, gpy)
# class tf(Command):
#
# class fQ(object):
# def __init__(self, f, Q, tf):
# assert(tf is not None)
# self._tf = tf
# self.__f = Param("f", self, None, canFsig=False, isPutable=True, isPutter=False, isTunable=True)
# self.__Q = Param("Q", self, None, canFsig=False, isPutable=True, isPutter=False, isTunable=True)
#
# def _register_param(self, param):
# self._tf._params.append(param)
#
# @property
# def f(self): return self.__f
# @f.setter
# def f(self,value): self.__f.value = SIfloat(value)
#
# @property
# def Q(self): return self.__Q
# @Q.setter
# def Q(self,value): self.__Q.value = SIfloat(value)
#
# def __init__(self, name):
# Command.__init__(self, name, False)
# self.zeros = []
# self.poles = []
# self.gain = 1
# self.phase = 0
# self._params = []
#
# def addPole(self,f, Q):
# self.poles.append(tf.fQ(SIfloat(f), SIfloat(Q), self))
#
# def addZero(self,f, Q):
# self.zeros.append(tf.fQ(SIfloat(f), SIfloat(Q), self))
#
# @staticmethod
# def parseFinesseText(text):
# values = text.split()
#
# if ((len(values)-4) % 3) != 0:
# raise pkex.BasePyKatException("Transfer function Finesse code format incorrect '{0}'".format(text))
#
# _tf = tf(values[1])
#
# _tf.gain = SIfloat(values[2])
# _tf.phase = SIfloat(values[3])
#
# N = int((len(values)-4) / 3)
#
# for i in range(1,N+1):
# if values[i*3+1] == 'p':
# _tf.addPole(SIfloat(values[i*3+2]), SIfloat(values[i*3+3]))
# elif values[i*3+1] == 'z':
# _tf.addZero(SIfloat(values[i*3+2]), SIfloat(values[i*3+3]))
# else:
# raise pkex.BasePyKatException("Transfer function pole/zero Finesse code format incorrect '{0}'".format(text))
#
# return _tf
#
# def getFinesseText(self):
# rtn = "tf {name} {gain} {phase} ".format(name=self.name,gain=self.gain,phase=self.phase)
#
# for p in self.poles:
# rtn += "p {f} {Q} ".format(f=p.f, Q=p.Q)
#
# for z in self.zeros:
# rtn += "p {f} {Q} ".format(f=z.f, Q=z.Q)
#
# return rtn
class tf(Command): class tf(Command):
class fQ(object): class fQ(object):
......
...@@ -1268,6 +1268,7 @@ class kat(object): ...@@ -1268,6 +1268,7 @@ class kat(object):
target = values[2] target = values[2]
variable = values[3] variable = values[3]
try:
if not hasattr(self, obj): if not hasattr(self, obj):
raise pkex.BasePyKatException("put command `{0}` refers to non-existing component".format(line)) raise pkex.BasePyKatException("put command `{0}` refers to non-existing component".format(line))
...@@ -1283,6 +1284,16 @@ class kat(object): ...@@ -1283,6 +1284,16 @@ class kat(object):
target.put(self.getVariable(variable.replace('$', '')), alt) target.put(self.getVariable(variable.replace('$', '')), alt)
except pkex.BasePyKatException as ex:
if self.verbose:
print("Warning: ", ex.msg)
print ("Parsing `{0}` into pykat object not implemented yet, added as extra line.".format(line))
obj = line
# manually add the line to the block contents
self.__blocks[block].contents.append(line)
elif (first == "scale"): elif (first == "scale"):
v = line.split() v = line.split()
accepted = ["psd","psd_hf","asd","asd_hf","meter", "ampere", "deg", "rad", "1/deg", "1/rad",] accepted = ["psd","psd_hf","asd","asd_hf","meter", "ampere", "deg", "rad", "1/deg", "1/rad",]
...@@ -1419,7 +1430,7 @@ class kat(object): ...@@ -1419,7 +1430,7 @@ class kat(object):
except pkex.BasePyKatException as ex: except pkex.BasePyKatException as ex:
pkex.PrintError("Error parsing line: '%s':"% line, ex) pkex.PrintError("Pykat error parsing line: '%s':"% line, ex)
sys.exit(1) sys.exit(1)
def saveScript(self, filename=None): def saveScript(self, filename=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment