Skip to content

Commit

Permalink
Equations
Browse files Browse the repository at this point in the history
Equations basically working
also added rounding of display digits in preferences
UI is very clunky!

fixed strange bug

text editor fill window

tabs and read only

import only non-read-only parameters
experimental variables button

Added variable and equation icons

fixed wirebond tests

Added ur to materials selection

added some tests

revamped RoundWireBondMaterial -- added ur to material calculation
removed button for variables

equation debugging and execution

fix for mm and test relearns and updates
most test updates caused by AutoDebug in equations
and change in displayed precision.

fixed small bug in simulator legends when no traces displayed

beginnings of autoindent

disable autoindent for now

fixed bug in auto debug of equations

equation validity checking on calculation
also some chlorophyll editor stuff

equation protection and single calculation
equation is protected from accessing project
also, equations are calculated one time only until changed

fixed bug in which equations were always valid

limit text in variable and device attributes

fix for Laplace test
just a picture change based on text length limiting
but added equation usage, as it really applies here
also fixed z=e^(1j*2*pi*f/Fs)

trying to fix x expansion of variables dialog
the entry box does not expand with the scrollbar
for now, a hack workaround -- only use the scrollbar
if the number of entries exceeds 30.

fixed bug in variable device file names
previously, if the device was a variable, it never displayed the box
for the device variables nor the box to pass down the calculation properties.
Now, if the variable points to a project file name, it does.

control text area size in equation editor

control minimum size of variables dialog
  • Loading branch information
PetePupalaikis committed Mar 4, 2023
1 parent edb8b92 commit e412c2b
Show file tree
Hide file tree
Showing 282 changed files with 6,720 additions and 1,687 deletions.
7 changes: 7 additions & 0 deletions SignalIntegrity/App/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,21 @@ def NetListLine(self):
def PinCoordinates(self):
return self.partPicture.current.PinCoordinates()
def CreateVisiblePropertiesList(self):
import SignalIntegrity.App.Project
textLimit = SignalIntegrity.App.Preferences['Appearance.LimitText']
visiblePartPropertyList=[]
for partProperty in self.propertiesList:
propertyString=partProperty.PropertyString(stype='attr')
if propertyString != '':
if propertyString != '':
if len(propertyString) > textLimit:
propertyString = propertyString[:textLimit]+'...'
visiblePartPropertyList.append(propertyString)
for variable in self.variablesList:
displayString=variable.DisplayString(True,True,False)
if displayString != '':
if len(displayString) > textLimit:
displayString = displayString[:textLimit]+'...'
visiblePartPropertyList.insert(0,displayString)
self.partPicture.current.InsertVisiblePartProperties(visiblePartPropertyList)
def SetWaveform(self,wf):
Expand Down
21 changes: 18 additions & 3 deletions SignalIntegrity/App/DeviceProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,14 @@ def __init__(self,parent,device,advancedMode=False):
if isinstance(self.device,Device): # part other than file - allow viewing
fileTypeKeywords = list(set(['wffile','file']).intersection(set([property['Keyword'] for property in self.device.propertiesList])))
if len(fileTypeKeywords) == 1:
self.isAProjectDevice = self.device[fileTypeKeywords[0]]['Value'].split('.')[-1]=='si'
filename=self.device[fileTypeKeywords[0]]['Value']
if (len(filename)>1) and (filename[0]=='='):
import SignalIntegrity.App.Project
if filename[1:] in SignalIntegrity.App.Project['Variables'].Names():
filename = SignalIntegrity.App.Project['Variables'].VariableByName(filename[1:])['Value']
if filename == None:
filename=''
self.isAProjectDevice = filename.split('.')[-1]=='si'
else:
if self.device.netlist['DeviceName']=='device':
self.partViewButton.pack(expand=tk.NO,fill=tk.NONE,anchor=tk.CENTER)
Expand Down Expand Up @@ -315,7 +322,8 @@ def __init__(self,parent,device,advancedMode=False):
tk.Button(self.rotationFrame,text='toggle',command=self.onToggleRotation).pack(side=tk.LEFT,expand=tk.NO,fill=tk.X)
tk.Frame(self.rotationFrame,height=2,bd=2,relief=tk.RAISED).pack(side=tk.LEFT,fill=tk.X,padx=5,pady=5)
tk.Button(self.rotationFrame,text='help',command=self.onHelp).pack(side=tk.LEFT,expand=tk.NO,fill=tk.X)
if isinstance(self.device,SignalIntegrity.App.Device.DeviceFile):
from SignalIntegrity.App.Device import DeviceFile
if isinstance(self.device,DeviceFile):
try:
extension = self.device['file']['Value'].split('.')[-1]
if extension[0].lower() == 's' and extension[-1].lower() == 'p' and int(extension[1:-1]) > 0:
Expand Down Expand Up @@ -396,7 +404,14 @@ def UpdatePicture(self):
if isinstance(self.device,Device): # part other than file - allow viewing
fileTypeKeywords = list(set(['wffile','file']).intersection(set([property['Keyword'] for property in self.device.propertiesList])))
if len(fileTypeKeywords) == 1:
self.isAProjectDevice = self.device[fileTypeKeywords[0]]['Value'].split('.')[-1]=='si'
filename=self.device[fileTypeKeywords[0]]['Value']
if (len(filename)>1) and (filename[0]=='='):
import SignalIntegrity.App.Project
if filename[1:] in SignalIntegrity.App.Project['Variables'].Names():
filename = SignalIntegrity.App.Project['Variables'].VariableByName(filename[1:])['Value']
if filename == None:
filename=''
self.isAProjectDevice = filename.split('.')[-1]=='si'
else:
if self.device.netlist['DeviceName']=='device':
self.partViewButton.pack(expand=tk.NO,fill=tk.NONE,anchor=tk.CENTER)
Expand Down
223 changes: 223 additions & 0 deletions SignalIntegrity/App/EquationsDialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
"""
EquationsDialog.py
"""
# Copyright (c) 2018 Teledyne LeCroy, Inc.
# All rights reserved worldwide.
#
# This file is part of SignalIntegrity.
#
# SignalIntegrity is free software: You can redistribute it and/or modify it under the terms
# of the GNU General Public License as published by the Free Software Foundation, either
# version 3 of the License, or any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>
import sys
if sys.version_info.major < 3:
import Tkinter as tk
import tkFont as font
import tkMessageBox as messagebox
else:
import tkinter as tk
from tkinter import font
from tkinter import messagebox

import os

import SignalIntegrity.App.Project
from SignalIntegrity.App.FilePicker import AskSaveAsFilename,AskOpenFileName
from SignalIntegrity.App.MenuSystemHelpers import Doer,StatusBar

import re

class EquationsDialog(tk.Toplevel):
def __init__(self,parent):
tk.Toplevel.__init__(self, parent)
self.project='Equations'
self.titleText='Equations'
self.parent=parent
self.__root = self
self.withdraw()

self.statusbar=StatusBar(self)

# the Doers - the holder of the commands, menu elements, toolbar elements, and key bindings
self.NewFileDoer = Doer(self.onNewFile)
self.OpenFileDoer = Doer(self.onOpenFile)
self.SaveFileDoer = Doer(self.onSaveFile)
# ------
self.ExitDoer = Doer(self.onExit)

self.CutDoer = Doer(self.onCut)
self.CopyDoer = Doer(self.onCopy)
self.PasteDoer = Doer(self.onPaste)

self.AutoDebugDoer = Doer(self.onAutoDebug).AddHelpElement('Control-Help:Equations-Auto-Debug').AddToolTip('Automatically debug script as edited')
self.ExcuteDoer = Doer(self.onExecute).AddHelpElement('Control-Help:Equations-Execute').AddToolTip('Execute the script')

self.AboutDoer = Doer(self.onAbout).AddHelpElement('sec:Equations')

# The menu system
TheMenu=tk.Menu(self)
self.config(menu=TheMenu)
# FileMenu=tk.Menu(self)
# TheMenu.add_cascade(label='File',menu=FileMenu,underline=0)
# self.NewFileDoer.AddMenuElement(FileMenu,label="New",accelerator='Ctrl+N',underline=0)
# self.OpenFileDoer.AddMenuElement(FileMenu,label="Open",accelerator='Ctrl+O',underline=0)
# self.SaveFileDoer.AddMenuElement(FileMenu,label="Save",accelerator='Ctrl+S',underline=0)
# FileMenu.add_separator()
# self.ExitDoer.AddMenuElement(FileMenu,label="Exit",accelerator='Ctrl+X',underline=1)
# ------
EditMenu=tk.Menu(self)
TheMenu.add_cascade(label='Edit',menu=EditMenu,underline=0)
self.CutDoer.AddMenuElement(EditMenu,label="Cut",accelerator='Ctrl+C',underline=0)
self.CopyDoer.AddMenuElement(EditMenu,label="Copy",accelerator='Ctrl+X',underline=1)
self.PasteDoer.AddMenuElement(EditMenu,label="Paste",accelerator='Ctrl+V',underline=0)
# ------
DebugMenu=tk.Menu(self)
TheMenu.add_cascade(label='Debug',menu=DebugMenu,underline=0)
self.ExcuteDoer.AddMenuElement(DebugMenu,label='Execute script',underline=0)
DebugMenu.add_separator()
self.AutoDebugDoer.AddCheckButtonMenuElement(DebugMenu,label='Auto debug',underline=0)
self.AutoDebugDoer.Set(SignalIntegrity.App.Project['Equations.AutoDebug'])
# ------
HelpMenu=tk.Menu(self)
TheMenu.add_cascade(label='Help',menu=HelpMenu,underline=0)
self.AboutDoer.AddMenuElement(HelpMenu,label='About',underline=0)

# text area
use_chlorophyll=True
if use_chlorophyll:
try:
from chlorophyll import CodeView
self.TextArea = CodeView(self.__root,height=1)
except:
self.TextArea = tk.Text(self.__root,height=1)
else:
self.TextArea = tk.Text(self.__root)
self.TextArea.bind('<Button-1>',self.onTouched)
self.TextArea.bind('<Return>',self.onTouched)
self.TextArea.pack(expand=tk.TRUE, fill=tk.BOTH)
thisfont = font.Font(font=self.TextArea['font'])
# Set Tab size
tab_size = thisfont.measure(' ')
self.TextArea.config(tabs=tab_size)
self.__file = None
self.__root.title(self.titleText)
self.TextArea.insert(1.0,SignalIntegrity.App.Project[self.project].GetTextString())
self.TextArea.config(height=min(25,max(1,len(SignalIntegrity.App.Project[self.project]['Lines']))))
self.protocol("WM_DELETE_WINDOW", self.onExit)
self.statusbar.pack(side=tk.BOTTOM,fill=tk.X,expand=tk.NO)
# self.TextArea.bind(":", self.autoindent)
self.onTouched()
self.deiconify()

def autoindent(self,event):
# the text widget that received the event
widget = event.widget

# get current line
line = widget.get("insert linestart", "insert lineend")

# compute the indentation of the current line
match = re.match(r'^(\s+)', line)
current_indent = len(match.group(0)) if match else 0

# compute the new indentation
new_indent = current_indent + 4

# insert the character that triggered the event,
# a newline, and then new indentation
widget.insert("insert", event.char + "\n" + " "*new_indent)

# return 'break' to prevent the default behavior
return "break"

def onExit(self):
SignalIntegrity.App.Project[self.project].PutTextString(self.TextArea.get(1.0,tk.END))
self.parent.statusbar.set(self.titleText+' Modified')
self.parent.history.Event('modify '+self.titleText)
self.__root.destroy()
self.parent.Drawing.DrawSchematic()

def onAbout(self):
self.AboutDoer.OpenHelp()

def onOpenFile(self):
self.__file = AskOpenFileName(defaultextension=".txt",
filetypes=[("All Files","*.*"),
("Text Documents","*.txt")])
if self.__file == "":
# no file to open
self.__file = None
else:
# Try to open the file
# set the window title
self.__root.title(os.path.basename(self.__file) + " - Notepad")
self.TextArea.delete(1.0,tk.END)

file = open(self.__file,"r")

self.TextArea.insert(1.0,file.read())

file.close()

def onNewFile(self):
self.__root.title("Untitled - Notepad")
self.__file = None
self.TextArea.delete(1.0,tk.END)

def onSaveFile(self):

if self.__file == None:
# Save as new file
self.__file = AskSaveAsFilename(initialfile='Untitled.txt',
defaultextension=".txt",
filetypes=[("All Files","*.*"),
("Text Documents","*.txt")])

if self.__file == "":
self.__file = None
else:
# Try to save the file
file = open(self.__file,"w")
file.write(self.TextArea.get(1.0,tk.END))
file.close()
# Change the window title
self.__root.title(os.path.basename(self.__file) + " - Notepad")
else:
file = open(self.__file,"w")
file.write(self.TextArea.get(1.0,tk.END))
file.close()

def onCut(self):
self.TextArea.event_generate("<<Cut>>")

def onCopy(self):
self.TextArea.event_generate("<<Copy>>")

def onPaste(self):
self.TextArea.event_generate("<<Paste>>")

def onAutoDebug(self):
SignalIntegrity.App.Project['Equations.AutoDebug']=self.AutoDebugDoer.Bool()
self.onTouched()

def onExecute(self):
self.onTouched(None,True)
SignalIntegrity.App.Project[self.project].PutTextString(self.TextArea.get(1.0,tk.END))
self.parent.Drawing.DrawSchematic()

def onTouched(self,event=None,force=False):
if force or SignalIntegrity.App.Project['Equations.AutoDebug']:
result=SignalIntegrity.App.Project.EvaluateEquations(self.TextArea.get(1.0,tk.END))
if result == None:
self.statusbar.set('No Errors')
else:
self.statusbar.set(str(result))
else:
self.statusbar.set('')
3 changes: 3 additions & 0 deletions SignalIntegrity/App/Examples/CascCableFilter.si
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,7 @@
</Devices>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
3 changes: 3 additions & 0 deletions SignalIntegrity/App/Examples/DeembedCableFilter.si
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,7 @@
</Devices>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
3 changes: 3 additions & 0 deletions SignalIntegrity/App/Examples/DwellTime.si
Original file line number Diff line number Diff line change
Expand Up @@ -798,4 +798,7 @@
</Wires>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
3 changes: 3 additions & 0 deletions SignalIntegrity/App/Examples/HDMICable/PRBSTest.si
Original file line number Diff line number Diff line change
Expand Up @@ -707,4 +707,7 @@
</Wires>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
3 changes: 3 additions & 0 deletions SignalIntegrity/App/Examples/NetTest.si
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,7 @@
</Wires>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
3 changes: 3 additions & 0 deletions SignalIntegrity/App/Examples/PRBSExample/CommonModeProbe.si
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,7 @@
</Wires>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
3 changes: 3 additions & 0 deletions SignalIntegrity/App/Examples/PRBSExample/PAM4Example.si
Original file line number Diff line number Diff line change
Expand Up @@ -923,4 +923,7 @@
</Wires>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
3 changes: 3 additions & 0 deletions SignalIntegrity/App/Examples/PRBSExample/PRBSGenerator.si
Original file line number Diff line number Diff line change
Expand Up @@ -733,4 +733,7 @@
</Wires>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
3 changes: 3 additions & 0 deletions SignalIntegrity/App/Examples/PRBSExample/PRBSTest.si
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,7 @@
</Wires>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
3 changes: 3 additions & 0 deletions SignalIntegrity/App/Examples/PRBSExample/PRBSTest2.si
Original file line number Diff line number Diff line change
Expand Up @@ -718,4 +718,7 @@
</Wires>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
<Schematic>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,7 @@
</Wires>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
3 changes: 3 additions & 0 deletions SignalIntegrity/App/Examples/PowerIntegrity/TestVRM.si
Original file line number Diff line number Diff line change
Expand Up @@ -1107,4 +1107,7 @@
</Wires>
</Schematic>
</Drawing>
<Equations>
<AutoDebug>True</AutoDebug>
</Equations>
</Project>
Loading

0 comments on commit e412c2b

Please sign in to comment.