home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / mprocs / em_setup.icn < prev    next >
Text File  |  2000-07-29  |  3KB  |  102 lines

  1. ############################################################################
  2. #
  3. #    File:     em_setup.icn
  4. #
  5. #    Subject:  Procedures to set up execution monitors 
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     March 3, 1997
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  These procedures provide support for the routine parts of building
  18. #  Icon execution monitors, including what's necessary for them to
  19. #  run stand-alone as well as under the control of monitor coordinators
  20. #  like eve and vc.
  21. #
  22. #      vis_setup(args[])    opens a window with attributes given
  23. #                by args[]
  24. #
  25. #    em_setup(sp)        loads sp as the program to be monitored
  26. #
  27. #    context_setup(mask)    returns table of graphics context for
  28. #                mask    
  29. #
  30. #    prog_name()        returns the name of the source program
  31. #                for the SP set up by em_setup()
  32. #
  33. #    em_end()        hold visualization window open if (a)
  34. #                there is one and (b) monitoring is
  35. #                stand alone
  36. #
  37. ############################################################################
  38. #
  39. #  Requires:  Version 9 MT Icon, instrumentation, and graphics
  40. #
  41. ############################################################################
  42. #
  43. #  Links:  evinit, interact, typebind, graphics
  44. #
  45. ############################################################################
  46. #
  47. #  Includes: evdefs.icn
  48. #
  49. ############################################################################
  50.  
  51. link evinit
  52. link interact
  53. link typebind
  54. link graphics
  55.  
  56. $include "evdefs.icn"
  57.  
  58. global Coordination        # if nonnull, vc is in charge
  59. global Visualization        # visualization window
  60. global EventSource        # vc's event source
  61.  
  62. procedure vis_setup(args[])    #: set up visualization window
  63.  
  64.    Visualization := (WOpen ! args) |
  65.       stop("*** cannot open window for visualization")
  66.  
  67.    return Visualization
  68.  
  69. end
  70.  
  71. procedure em_setup(sp)        #: set up program to be monitored
  72.    local trash
  73.  
  74.    trash := open("/dev/null", "w") |
  75.       stop("*** cannot open /dev/null")
  76.  
  77.    EvInit(sp, , trash, trash) | stop("*** cannot load SP")
  78.  
  79.    return
  80.  
  81. end
  82.  
  83. procedure context_setup(mask)    #: table of graphics contexts for mask
  84.  
  85.    return typebind(Visualization, mask)
  86.  
  87. end
  88.  
  89. procedure prog_name()        #: name of monitored source program
  90.  
  91.    return variable("&progname", EventSource) || ".icn"
  92.  
  93. end
  94.  
  95. procedure em_end()        #: hold event monitoring for event at end
  96.    local back
  97.  
  98.    back := WOpen("canvas=hidden", "bg=light gray")
  99.    if /Coordination then ExitNotice(back, "Normal termination of SP")
  100.  
  101. end
  102.