-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsim.py
More file actions
executable file
·44 lines (32 loc) · 1.06 KB
/
Copy pathsim.py
File metadata and controls
executable file
·44 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
import cmd
from SpiceParser import SpiceParser
from SpiceCircuit import SpiceCircuit, SpiceException
class SpiceInteractive(cmd.Cmd):
def __init__(self, parser, circuit):
cmd.Cmd.__init__(self)
self.prompt = "spice% "
self.__Parser = parser
self.__Circuit = circuit
def do_show(self, line):
print "ANALYSES:", self.__Circuit.GetAnalyses()
print "BRANCHES:", self.__Circuit.GetBranches()
print "NODES:", self.__Circuit.GetNodes()
def do_reset(self, line):
self.__Circuit.reset_plotter()
def default(self, line):
try:
self.__Parser.ParseLine("."+line)
except SpiceException, e:
print str(e)
def do_EOF(self, line):
print "Thank you! Exiting.\n"
sys.exit(0)
if __name__=="__main__":
# command line version
import sys
file_name = sys.argv[1]
x = SpiceParser(file_name)
cir = x.GetCircuit()
interpreter = SpiceInteractive(x, x.GetCircuit())
interpreter.cmdloop("Welcome to spice!")