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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206 | ###############################################################################
# Copyright (c) 2009-2024 by Altair Engineering, Inc.
# All rights reserved.
#
# Altair Engineering, Inc. makes this software available as part of the Vision
# tool platform. As long as you are a licensee of the Vision tool platform
# you may make copies of the software and modify it to be used within the
# Vision tool platform, but you must include all of this notice on any copy.
# Redistribution without written permission to any third party, with or
# without modification, is not permitted.
# Altair Engineering, Inc. does not warrant that this software is error free
# or fit for any purpose. Altair Engineering, Inc. disclaims any liability for
# all claims, expenses, losses, damages and costs any user may incur as a
# result of using, copying or modifying the software.
# =============================================================================
# @userware
# Search the Analog Waveform Database
# @section
# Miscellaneous Userware Examples
# @description
# Example to parse spice simulation results and to retrieve
# the contained data.
# @files
# analogWave/search.tcl
# @example
# demo/spice/Fig24_30/Fig24_30.sp
# demo/spice/Fig24_30/Fig24_30.csv
# @tag
# gui analog
###############################################################################
##
#
#
set script_path [file dirname [file normalize [info script]]]
source [file join $script_path print_functions.tcl]
##
# This function loads the waveform parser
# and makes the functions af_wp_... and af_sv_... available.
#
af_waveform_parser_create
##
# Sets the logger level to receive all error messages.
#
af_wp_set_logger_level 3
##
# Parse a waveform file.
#
set file_name "${script_path}/../../spice/Fig24_30/Fig24_30.csv"
set file_name [tk_getOpenFile -title "Open Waveform File" \
-initialdir $script_path \
-initialfile $file_name]
set return_code [af_wp_read_file $file_name]
##
# File parsing succeeded
#
if {${return_code} eq "ok"} {
##
# Parse succeeded. We print some search results.
#
set output_fp stdout
set output_dir [pwd]
set output_file [tk_getSaveFile -title "Open Data Output File" \
-initialdir $output_dir]
if {${output_file} ne ""} {
set output_fp [open $output_file w]
}
puts $output_fp " === waveform parser data read from file ${file_name}"
##
# match y axis unit
#
set search_string "prop_variable_y_axis_unit == \"A\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# match y axis type index
#
set search_string "prop_variable_y_axis_type_index == 2"
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# exact match
#
set search_string "prop_variable_name == \"i(vin3b)\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# wildcard and mismatch
#
set search_string "prop_variable_name != \"*XOPAMP*\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# wildcard
#
set search_string "prop_variable_name == \"I(*T.B)\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# wildcard
#
set search_string "prop_variable_name == \"I(R?)\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# regular expressions
#
set search_string "prop_variable_name =~ \"(I\\()(.*)\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# regular expressions mismatch operator "!~"
#
set search_string "prop_variable_name !~ \"(V\\()(.*)\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# using an or operator
#
set search_string "prop_variable_name == \"I(*2.G)\" || prop_variable_name "
append search_string "== \"I(*2.D)\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# defining a section name
#
set search_string "prop_section_name == \"four*\" && prop_variable_name == "
append search_string "\"i(vin3?)\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# using a section identifier. It must be an an integer.
#
set search_string "prop_section_identifier >= 100 && prop_variable_name == "
append search_string "\"I(*3.B)\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# regular expressions
#
set search_string "prop_section_identifier >= 100 && prop_variable_name =~ "
append search_string "\"(V\\(VIN\\)|V\\(VOUT\\))\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
set search_string "prop_section_name =~ \"(Fig24_30)(.*)\" && "
append search_string "prop_variable_name =~ \"(V\\(VIN\\)|V\\(VOUT\\))\""
set search_results [af_wp_find_curves $search_string]
print_search_results $output_fp $search_string $search_results
##
# searching only curves in individual sections
#
set nb_sections [af_wp_get_number_of_sections]
for {set section_index 0} \
{$section_index<$nb_sections} \
{incr section_index} \
{
puts $output_fp "---------- section $section_index"
set section_id [af_wp_get_section_identifier $section_index]
set search_string "prop_variable_name == \"I(RF)\""
set search_results [af_wp_find_curves_in_section $section_id \
$search_string]
##
# the returned vector still contains the section id and is therefore
# compatible with af_waveform_parser_print.print_search_results
#
print_search_results $output_fp $search_string $search_results
}
if {${output_file} != ""} {
close $output_fp
}
} else {
zmessage print ERR "failed to load file ${file_name}"
}
##
# Everything is released.
#
af_wp_release_all
##
# unloads the waveform parser
#
af_waveform_parser_delete
|