Skip to content

Commit

Permalink
linear views, callbacks, more ports on relays
Browse files Browse the repository at this point in the history
  • Loading branch information
PetePupalaikis committed Feb 2, 2021
1 parent 70d2424 commit 46f3690
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions SignalIntegrity/App/SParameterProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self,preferences=False):
self.Add(XMLPropertyDefaultBool('ShowExcessInductance',False))
self.Add(XMLPropertyDefaultBool('ShowExcessCapacitance',False))
self.Add(XMLPropertyDefaultBool('LogScale',False))
self.Add(XMLPropertyDefaultBool('LinearVerticalScale',False))

class ZoomJoinProperties(XMLConfiguration):
def __init__(self):
Expand Down
12 changes: 10 additions & 2 deletions SignalIntegrity/App/SParameterViewerWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def __init__(self, parent,sp,filename=None,title=None,buttonLabels=None):
self.ShowExcessInductanceDoer = Doer(self.onShowExcessInductance).AddHelpElement('Control-Help:Show-Excess-Inductance').AddToolTip('Show excess inductance in plots')
self.ShowExcessCapacitanceDoer = Doer(self.onShowExcessCapacitance).AddHelpElement('Control-Help:Show-Excess-Capacitance').AddToolTip('Show excess capacitance in plots')
self.LogScaleDoer = Doer(self.onLogScale).AddHelpElement('Control-Help:Log-Scale').AddToolTip('Show frequency plots log scale')
self.LinearVerticalScaleDoer = Doer(self.onLinearVerticalScale).AddHelpElement('Control-Help:Linear-Vertical-Scale').AddToolTip('Show frequency plots linear vertical scale')
# ------
self.Zoom={
'AreSParameterLike':False,
Expand Down Expand Up @@ -171,6 +172,7 @@ def __init__(self, parent,sp,filename=None,title=None,buttonLabels=None):
self.ShowExcessInductanceDoer.AddCheckButtonMenuElement(ViewMenu,label='Show Excess Inductance',underline=13)
self.ShowExcessCapacitanceDoer.AddCheckButtonMenuElement(ViewMenu,label='Show Excess Capacitance',underline=12)
self.LogScaleDoer.AddCheckButtonMenuElement(ViewMenu,label='Log Scale',underline=4)
self.LinearVerticalScaleDoer.AddCheckButtonMenuElement(ViewMenu,label='Linear Vertical Scale',underline=8)
#-------
ZoomMenu=tk.Menu(self)
TheMenu.add_cascade(label='Zoom',menu=ZoomMenu,underline=0)
Expand Down Expand Up @@ -463,6 +465,11 @@ def onLogScale(self):
SignalIntegrity.App.Preferences.SaveToFile()
self.PlotSParameter()

def onLinearVerticalScale(self):
SignalIntegrity.App.Preferences['SParameterProperties.Plot.LinearVerticalScale']=self.LinearVerticalScaleDoer.Bool()
SignalIntegrity.App.Preferences.SaveToFile()
self.PlotSParameter()

def ZoomJoinActivations(self):
self.Zoom['Frequencies']['Join']['All'].Activate(self.Zoom['Frequencies']['JoinWithOthers'].Bool())
self.Zoom['Frequencies']['Join']['OffDiagonal'].Activate(self.Zoom['Frequencies']['JoinWithOthers'].Bool() and not self.Zoom['Frequencies']['Join']['All'].Bool() and self.Zoom['AreSParameterLike'])
Expand Down Expand Up @@ -818,6 +825,7 @@ def UpdatePreferences(self):
self.ShowExcessInductanceDoer.Set(SignalIntegrity.App.Preferences['SParameterProperties.Plot.ShowExcessInductance'])
self.ShowExcessCapacitanceDoer.Set(SignalIntegrity.App.Preferences['SParameterProperties.Plot.ShowExcessCapacitance'])
self.LogScaleDoer.Set(SignalIntegrity.App.Preferences['SParameterProperties.Plot.LogScale'])
self.LinearVerticalScaleDoer.Set(SignalIntegrity.App.Preferences['SParameterProperties.Plot.LinearVerticalScale'])
self.Zoom['Frequencies']['JoinWithin'].Set(SignalIntegrity.App.Preferences['SParameterProperties.Zoom.Frequencies.JoinWithin'])
self.Zoom['Times']['JoinWithin'].Set(SignalIntegrity.App.Preferences['SParameterProperties.Zoom.Times.JoinWithin'])
self.Zoom['Frequencies']['JoinWithOthers'].Set(SignalIntegrity.App.Preferences['SParameterProperties.Zoom.Frequencies.JoinWithOthers'])
Expand Down Expand Up @@ -932,7 +940,7 @@ def PlotSParameter(self):
fr=self.sp.FrequencyResponse(self.toPort,self.fromPort)
ir=fr.ImpulseResponse()

y=fr.Response('dB')
y=fr.Response('mag') if self.LinearVerticalScaleDoer.Bool() else fr.Response('dB')

self.freqLabel=ToSI(fr.Frequencies()[-1],'Hz')[-3:]
freqLabelDivisor=FromSI('1. '+self.freqLabel,'Hz')
Expand Down Expand Up @@ -1004,7 +1012,7 @@ def PlotSParameter(self):
self.topLeftPlot.set_ylim(bottom=self.topLeftPlotProperties['MinY'])
self.topLeftPlot.set_ylim(top=self.topLeftPlotProperties['MaxY'])

self.topLeftPlot.set_ylabel('magnitude (dB)',fontsize=10)
self.topLeftPlot.set_ylabel('magnitude (abs)' if self.LinearVerticalScaleDoer.Bool() else 'magnitude (dB)',fontsize=10)
self.topLeftPlot.set_xlabel('frequency ('+self.freqLabel+')',fontsize=10)

if self.ShowGridsDoer.Bool():
Expand Down
13 changes: 9 additions & 4 deletions SignalIntegrity/App/SignalIntegrityAppHeadless.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def NetListText(self):
def config(self,cursor=None):
pass

def CalculateSParameters(self):
def CalculateSParameters(self,callback=None):
import SignalIntegrity.Lib as si
if not hasattr(self.Drawing,'canCalculate'):
self.Drawing.DrawSchematic()
Expand All @@ -202,14 +202,16 @@ def CalculateSParameters(self):
SignalIntegrity.App.Project['CalculationProperties.FrequencyPoints']
),
cacheFileName=cacheFileName)
if not callback == None:
spnp.InstallCallback(callback)
spnp.AddLines(netListText)
try:
sp=spnp.SParameters()
except si.SignalIntegrityException as e:
return None
return (sp,self.fileparts.FullFilePathExtension('s'+str(sp.m_P)+'p'))

def Simulate(self):
def Simulate(self,callback=None):
if not hasattr(self.Drawing,'canCalculate'):
self.Drawing.DrawSchematic()
if self.Drawing.canSimulateNetworkAnalyzerModel:
Expand All @@ -227,6 +229,8 @@ def Simulate(self):
cacheFileName=self.fileparts.FileNameTitle()
si.sd.Numeric.trySVD=SignalIntegrity.App.Preferences['Calculation.TrySVD']
snp=si.p.SimulatorNumericParser(fd,cacheFileName=cacheFileName)
if not callback == None:
snp.InstallCallback(callback)
snp.AddLines(netListText)
try:
transferMatrices=snp.TransferMatrices()
Expand Down Expand Up @@ -397,8 +401,9 @@ def Device(self,ref):
"""
devices=self.Drawing.schematic.deviceList
for device in devices:
if device['ref']['Value']==ref:
return device
if device['ref'] != None:
if device['ref']['Value'] == ref:
return device
return None

def SimulateNetworkAnalyzerModel(self,SParameters=False):
Expand Down
2 changes: 1 addition & 1 deletion SignalIntegrity/Lib/Parsers/Devices/DeviceParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def __init__Contd2(self):
ParserDevice('ffe',2,True,{'':'[1.0]','td':None,'pre':0},True,"FFE(f,\
float(arg['td']),eval(arg['']),eval(arg['pre']),50.)"),
ParserDevice('laplace',2,True,{'':''},True,"Laplace(f,str(arg['']),50.)"),
ParserDevice('relay','2,3,4,5,6,7,8,9,10,11,12,13,14,15,16',True,{'':0,'term':1e9,
ParserDevice('relay','2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17',True,{'':0,'term':1e9,
'z0':50.},False,"IdealRelay(ports,int(arg['']),float(arg['term']),\
float(arg['z0']))")
]))
Expand Down

0 comments on commit 46f3690

Please sign in to comment.