#!/bin/sh # the next line restarts using wish \ exec wish "$0" "$@" wm title . " El Pendulo" proc show_ayuda {} { catch {destroy .ayuda} set w .ayuda toplevel $w wm title $w "Ayuda" frame $w.buttons pack $w.buttons -side bottom -fill x -pady 2m button $w.buttons.ok -text OK -command "destroy $w" pack $w.buttons.ok -side left -expand 1 text $w.text -relief sunken -bd 2 -yscrollcommand "$w.scroll set" -setgrid 1 \ -height 30 -width 70 scrollbar $w.scroll -command "$w.text yview" pack $w.scroll -side right -fill y pack $w.text -expand yes -fill both $w.text insert 0.0 \ { Esto es un programa que depliega soluciones a la ecuacion de moviemiento de una masa bajo la influencia de un resorte, y''=-y, donde y es la posicion vertical de la masa. Para iniciar, hay que picar el boton "INTEGRAR". Puedes cambiar las condiciones iniciales (posicion y velocidad inicial) antes de empezar. IMPORTANTE: 1. Hay que darle un "ENTER" despues de meter las condiciones iniciales. 2. Cuando picas el boton "PARAR" se tarda un rato en parar, porque el programa del despliegue grafico ("Geomview") es lento en responder. 3. El programa no esta protegido en contra de datos inapropiados (ejes con longitud negativa, datos no numericos ....etc), asi que tendras que "matar" el programa e iniciar de nuevo en caso que metiste datos malos. } $w.text mark set insert 0.0 } set run 0 set y0 .5 set y1 0 set v 5 set cf [open "/tmp/command_file" w] ################################################# frame .posicion pack .posicion -side top -fill x -pady 2m label .posicion.label -text " Posicion inicial (radian) " entry .posicion.entry -width 4 -relief sunken -textvariable y0 bind .posicion.entry { puts "p $y0";puts "V $y1";flush stdout} pack .posicion.label .posicion.entry -side left ################################################# frame .velocidad pack .velocidad -side top -fill x -pady 2m label .velocidad.label -text " Velocidad inicial (rad/seg)" entry .velocidad.entry -width 4 -relief sunken -textvariable y1 bind .velocidad.entry { puts "p $y0"; puts "V $y1";flush stdout} pack .velocidad.label .velocidad.entry -side left ############################################################## scale .scale -orient horizontal -from 1 -to 9 \ -label " Velocidad de la integracion" -tickinterval 1 -length 200 \ -variable v -command velo -showvalue 0 -sliderlength 10 proc velo v {puts "v $v";flush stdout; upvar cf cf; seek $cf 0 puts $cf v; flush $cf;.parar invoke; .parar flash} pack .scale ############################################################## frame .buttons pack .buttons -side top -fill x frame .buttons.run pack .buttons.run -side left -fill y radiobutton .integrar -text "INTEGRAR" -variable run \ -value 1 -command { seek $cf 0 puts -nonewline $cf g; flush $cf puts -nonewline g; flush stdout} radiobutton .parar -text "PARAR"\ -variable run \ -value 0 -command { seek $cf 0 puts -nonewline $cf s; flush $cf } pack .integrar .parar -side top -in .buttons.run \ -pady 10 -padx 10 -anchor w frame .buttons.right pack .buttons.right -in .buttons -side left button .help -text Ayuda -command show_ayuda button .salir -text Salir -command { seek $cf 0;puts -nonewline $cf q close $cf puts q;flush stdout destroy .} pack .help .salir -in .buttons -side top -pady 10 -padx 10 ######################## resorte ######################################