Merged r9433:9527 from features/gr-usrp2 into trunk. Adds usrp2 and gr-usrp2 top...
[debian/gnuradio] / usrp2 / fpga / opencores / ethernet_tri_mode / sim / rtl_sim / ncsim_sim / script / set_stimulus.tcl
1 proc set_stimulus {} {
2     toplevel .stimulus   
3     focus .stimulus
4     wm title .stimulus "Setting Stimulus Prameters"
5     
6     variable StartLength  
7     variable EndLength
8     variable PacketNumber
9     variable Random
10     variable Broadcast
11     variable help_string
12     
13 set help_string {
14 Set Stimulus Help:
15     You can select to generate packet with sequential packet length or 
16 random packet length. If you choise random packet length, the length of
17 generated packet  will be a random value between the "Packet begin length" 
18 to the "Packet end length". "Total  Gen Packet number"is used to set the
19 number of packet will be generated as stimulus
20    As well, you can select "sequence" mode . The first Packet will be
21 generated with "Packet begin length",and the next Packet length will be
22 "Packet begin length" pluse one untile the packet length reach the value
23 of "Packet end length". Packet in each length will be generated according
24 to the value of "Packet number per length" }    
25     
26     
27   if {[catch {open ../data/config.ini r} fileid]} {
28       set StartLength 46
29       set EndLength 60   
30       set PacketNumber 1
31       set Random 0
32       set Broadcast 0
33       } \
34       else {
35       gets $fileid content
36       scan $content "%d,%d,%d,%d,%d" StartLength EndLength  PacketNumber Random Broadcast
37       close $fileid
38        }
39
40     frame .stimulus.f1 
41     label .stimulus.f1.lb -text "Packet begin length:"
42     entry .stimulus.f1.en -textvariable StartLength 
43     pack .stimulus.f1 -fill x
44     pack .stimulus.f1.en .stimulus.f1.lb  -side right
45
46     frame .stimulus.f2 
47     label .stimulus.f2.lb -text "Packet end length:"
48     entry .stimulus.f2.en -textvariable EndLength 
49     pack .stimulus.f2 -fill x
50     pack .stimulus.f2.en .stimulus.f2.lb   -side right
51
52     
53     frame .stimulus.f3 
54     label .stimulus.f3.lb -text "Packet number per length:"
55     entry .stimulus.f3.en -textvariable PacketNumber 
56     pack .stimulus.f3 -fill x
57     pack .stimulus.f3.en .stimulus.f3.lb  -side right
58
59     frame .stimulus.f4
60     radiobutton .stimulus.f4.1 -text "Sequence" -variable Random -value 0 \
61                 -command {.stimulus.f3.lb config -text "Packet number per length:"}
62     radiobutton .stimulus.f4.2 -text "Random" -variable Random -value 1 \
63                 -command {.stimulus.f3.lb config -text "Total  Gen Packet number:"}
64     pack .stimulus.f4 -fill x 
65     pack .stimulus.f4.1 .stimulus.f4.2 -side right
66  
67     frame .stimulus.f5
68     checkbutton .stimulus.f5.1 -text "Broadcast" -variable Broadcast
69     pack .stimulus.f5 -fill x 
70     pack .stimulus.f5.1 -side right
71          
72     frame .stimulus.f20 
73     button .stimulus.f20.1 -text "Save" -width 10 \
74         -command {  set fileid [open ../data/config.ini w 0600]
75                 puts $fileid "$StartLength,$EndLength,$PacketNumber,$Random,$Broadcast"
76                 close $fileid
77                 destroy .stimulus
78                 }
79     button .stimulus.f20.2 -text "Save as" -command {sti_save_as $StartLength $EndLength $PacketNumber $Random $Broadcast} -width 10
80     button .stimulus.f20.3 -text "Cancel" -command {destroy .stimulus} -width 10
81     button .stimulus.f20.4 -text "Help" -width 10 -command {print_help $help_string}
82     pack .stimulus.f20 -fill x
83     pack .stimulus.f20.1 .stimulus.f20.2 .stimulus.f20.3 .stimulus.f20.4 -side left
84 }
85
86 proc sti_save_as {StartLength EndLength PacketNumber Random Broadcast} {
87     global fileselect
88     cd ../data
89     fileselect
90     tkwait window .fileSelectWindow
91     if {$fileselect(canceled)==1} {
92         return
93     } elseif {$fileselect(selectedfile)==""} {
94         warning_message "file have not been selected!"
95     } else {
96         set fileid [open $fileselect(selectedfile) w 0600]
97         puts $fileid "$StartLength,$EndLength,$PacketNumber,$Random,$Broadcast"
98         close $fileid
99         destroy .stimulus
100     }
101 }