Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Interactive Mode #70 #76

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Optional arguments include:
- `-S | --save SAVENAME` Saves current query for future reuse.
- `-R | --reload SAVENAME` Loads a saved query. Requires query name as string.
- `--btable` Print the wire value table at breakpoints to `stdout` (`-b` is required).
- `-p` User parameter for starting time window, ending time window and visible wires to generate waveform

*Note: For more detailed information on the query language, check out [syntax.md](syntax.md)

Expand Down
20 changes: 20 additions & 0 deletions sootty/SoottyConfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class SoottyConfig:
def __init__(self, user_start=None, user_end=None, visible_wires=None):
self.user_start = user_start
self.user_end = user_end
self.visible_wires = visible_wires if visible_wires is not None else []

def set_user_start(self, user_start):
self.user_start = user_start

def set_user_end(self, user_end):
self.user_end = user_end

def set_visible_wires(self, visible_wires):
self.visible_wires = visible_wires

def get_time_window(self):
return self.user_start, self.user_end

def get_visible_wires(self):
return self.visible_wires
16 changes: 14 additions & 2 deletions sootty/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from .save import save_query, reload_query
from .storage import WireTrace
from .visualizer import Visualizer
from .SoottyConfig import SoottyConfig
from .parser import parameter_query


def parse_args():
Expand Down Expand Up @@ -96,6 +98,9 @@ def parse_args():
help="Loads a saved query. Requires query name as string.",
)

parser.add_argument('-p', '--parameters', help='Specify parameter query')


args = parser.parse_args()
if args.save is not None and args.reload is not None:
raise SoottyError(
Expand All @@ -118,11 +123,12 @@ def parse_args():
args.end,
args.output,
args.radix,
args.parameters
)


def main():
filename, wires, breakpoints, btable, length, start, end, output, radix = parse_args()
filename, wires, breakpoints, btable, length, start, end, output, radix, parameters = parse_args()

if filename is None:
raise SoottyError("Input file is required. See --help for more info.")
Expand Down Expand Up @@ -152,8 +158,14 @@ def main():
if breakpoints is not None:
breakpoints = wiretrace.evaluate(breakpoints)

# Create SoottyConfig instance and set user-defined time window
config = SoottyConfig(user_start=None, user_end=None, visible_wires=None)

if parameters:
config = parameter_query(parameters, config)

# Convert wiretrace to graphical vector image.
image = Visualizer().to_svg(
image = Visualizer(config=config).to_svg(
wiretrace,
start=start,
length=length,
Expand Down
16 changes: 16 additions & 0 deletions sootty/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,19 @@ def parse_list(self, expressions: str):


parser = ExpressionParser() # initialize global parser object

def parameter_query(parameter_query, config):
key_values = parameter_query.replace('\n', '').split(':')

for key_value in key_values:
if key_value[0][0] == 's': #start= 0 1 2 3 4 5
config.set_user_start(int(key_value[6:len(key_value)]))
elif key_value[0][0] == 'e': #end= 0 1 2 3
config.set_user_end(int(key_value[4:len(key_value)]))
elif key_value[0][0] == 'v': #visible_wires 0 1 2 3 4 5 6 7 8 9 10 11 12 13
val = key_value[14:len(key_value)]
config.set_visible_wires(val.split(','))

return config


Loading