[plt-scheme] frtime

From: geb a (geb_a at yahoo.com)
Date: Wed Jan 16 16:50:47 EST 2008

Hello,
I am trying to convert the following module to frtime
but I've run into several difficulties mainly
resolving the differences between mzscheme and frtime.
I was trying to set up a pipe between the camera and
output string but was unable to get it to compile.

The purpose of the code is to provide an output string
holding a current photograph at any given instant. 
Does it even make sense to use Frtime for this
purpose?

Thank you in advance for all of your help.  I really
appreciate all of the past support.

(module camera01  mzscheme
  
  (require  (lib "url.ss" "net")
            (lib "etc.ss")
            (lib "process.ss"))       
  
  (define-struct camera (ip type direction mode
resolution quality interval size preset language ))
  ;a camera is a structure where ip..language are
strings ; deleted for brevity...
  
  ;camera->string: camera -> string
  ;takes a camera and produces a string that
represents the required state of the camera.
  (define (camera->string a-camera) 
    (string-append "http://" 
                   (camera-ip a-camera) 
                   "/"
                   (camera-type a-camera)
                   "?Mode=" (camera-mode a-camera)
                   "&Direction=" (camera-direction
a-camera)                
                   "&Quality=" (camera-quality
a-camera)
                   "&Resolution=" (camera-resolution
a-camera)
                   "&Interval=" (camera-interval
a-camera)
                   "&Size=" (camera-size a-camera)
                   "&PresetOperation=" (camera-preset
a-camera)
                   "&Language=" (camera-language
a-camera)))
  
  
  (define camera1 (make-camera "10.1.50.1"
"SnapshotJPEG" "" "Refresh"  "640x480" "Clarity" "10"
"STD" "Move" "0"))

  
  (define (picture->file a-camera)
    (local [(define in (get-pure-port
(string->url(camera->string a-camera))))
            (define (read-loop out input)
              (let ([byte (read-byte input)])
                (cond
                  [(eof-object? byte)
(close-input-port input)]
                  (else (begin
                          (write-byte byte out)
                          (read-loop out input))))))] 
 
      (let ((o (open-output-string)))
        (begin
          (read-loop o in )
          o)))))

  ;example usage
  (picture->file camera1)
  



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



Posted on the users mailing list.