home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_11 / 2n11075a < prev    next >
Text File  |  1991-10-01  |  24KB  |  705 lines

  1. //  VCR.CPP - VCR device driver class.
  2. //      VCR::VCR - Constructor for VCR
  3. //      VCR::~VCR - Destructor for VCR
  4. //      VCR::SendCommand - Send command string to VCR
  5. //      VCR::Stop - Puts the VCR into Stop mode.
  6. //      VCR::Eject - Causes the tape to be ejected from the VCR.
  7. //      VCR::Rewind - Places the VCR into full speed rewind.
  8. //      VCR::FastForward - Places the VCR into full speed fast forward.
  9. //      VCR::PlayFastReverse - Places the VCR into fast reverse play.
  10. //      VCR::PlayFastForward - Places the VCR into fast forward play.
  11. //      VCR::Still - Causes the VCR to Still on the current frame.
  12. //      VCR::Record - Begin recording mode.
  13. //      VCR::Play - Begins normal play mode.
  14. //      VCR::ReversePlay - Begins normal reverse play mode;
  15. //      VCR::StepForward - From a still frame, advance to next field.
  16. //      VCR::StepReverse - From a still frame, step to previous field.
  17. //      VCR::PowerToggle - Toggle VCR power.
  18. //      VCR::ValidateFrame - Adjust frame format to ensure validity
  19. //      VCR::ReceiveResponse - Receive VCR response to request
  20. //      VCR::ShuttleOn - Enables jog/shuttle mode
  21. //      VCR::ShuttleUp - Increase shuttle speed
  22. //      VCR::ShuttleDown - Decrease shuttle speed
  23. //      VCR::ForwardShuttle - Forward shuttle
  24. //      VCR::ReverseShuttle - Reverse Shuttle
  25. //      VCR::CueToFrame - Cue to frame
  26. //      VCR::SetCueType - Set cue type
  27. //      VCR::PlayToFrame - Play to frame
  28. //      VCR::PlaySegment - Play segment
  29. //      VCR:AudioInsertToFrame - Audio insert to frame
  30. //      VCR::AudioVideoInsertToFrame - Audio/Video insert to frame
  31. //      VCR::Preplay - Preroll play
  32. //      VCR::Calibrate - Calibrate
  33. //      VCR::ClearCounter - Clear frame count
  34. //      VCR::AudioSelect - Audio select
  35. //      VCR::ResetVCR - Perform VCR reset
  36. //      VCR::RequestFrame - Request current frame count
  37. //      VCR::RequestMode - Request current VCR mode
  38.  
  39. #include    <stdio.h>
  40.  
  41. #include    "VCR.h"
  42.  
  43.  
  44. /******************************************************************
  45. *   VCR::ReceiveResponse - Receive VCR response to command
  46. *
  47. *
  48. *   Class Variables Used:
  49. *       Port *SerialPort
  50. *
  51. *   Returns:
  52. *       Str sResponse
  53. *
  54. *   Copyright:
  55. *       Original code by William H. Roetzheim (619) 669-6970
  56. *       Copyright (c) 1991 by William H. Roetzheim
  57. *       All rights reserved.
  58. **********************************************************************/
  59. Str VCR::ReceiveResponse (void)
  60.  
  61. {
  62.     int     i = 0;
  63.     char    szBuffer [21];
  64.  
  65.     // wait for start of command string
  66.     while (i != 0x02) i = spSerialPort->InChar();
  67.  
  68.     // Receive actual response
  69.     int nBufferIndex = 0;
  70.     i = spSerialPort->InChar ();
  71.     while (i != 0x03)
  72.     {
  73.         szBuffer [nBufferIndex++] = i;
  74.         i = spSerialPort->InChar ();
  75.     }
  76.     szBuffer [nBufferIndex] = 0;
  77.     return (Str) szBuffer;
  78. }
  79.  
  80.  
  81.  
  82. /******************************************************************
  83. *   VCR::ValidateFrame - Adjust frame fields to ensure validity
  84. *
  85. *   Parameters:
  86. *       struct Frame& sfFrame (in/out) - frame to be adjusted.
  87. *
  88. **********************************************************************/
  89. void    VCR::ValidateFrame (struct Frame& sfFrame)
  90. {
  91.     // If out of range, attempt to bring into range
  92.     if (sfFrame.nFrame < 0) sfFrame.nFrame = 0;
  93.     sfFrame.nSecond += (sfFrame.nFrame / 30);
  94.     sfFrame.nFrame %= 30;
  95.     if (sfFrame.nSecond < 0) sfFrame.nSecond = 0;
  96.     sfFrame.nMinute += (sfFrame.nSecond / 60);
  97.     sfFrame.nSecond %= 60;
  98.     if (sfFrame.nMinute < 0) sfFrame.nMinute = 0;
  99.     sfFrame.nHour += (sfFrame.nMinute / 60);
  100.     sfFrame.nMinute %= 60;
  101.     if (sfFrame.nHour < 0) sfFrame.nHour = 0;
  102.     if (sfFrame.nHour > 9) sfFrame.nHour = 9;
  103. }
  104.  
  105.  
  106.  
  107. /******************************************************************
  108. *   VCR::ShuttleOn - Enables jog/shuttle mode
  109. *
  110. *   Notes:
  111. *       1.  When received, the VCR enters the shuttle mode.  This
  112. *           enables the shuttle up/down commands and the field
  113. *           step commands.
  114. *
  115. *       2.  The VCR responds to this command by Still framing at
  116. *           the current tape position.
  117. *
  118. *       3.  Executing Still or Stop commands will terminate this
  119. *           mode.
  120. *
  121.  
  122. *       4.  Command duration is 300 mSec.  Up to 1 seconds may be
  123. *           required for the VCR to obtain a clean still frame.
  124. *
  125. *       5.  Audio is muted, video playback is output.
  126. *
  127. **********************************************************************/
  128. void VCR::ShuttleOn (void)
  129. {
  130.     SendCommand ("A@S");
  131. }
  132.  
  133.  
  134.  
  135. /******************************************************************
  136. *   VCR::ShuttleUp - Increase shuttle speed
  137. *
  138. *   Notes:
  139. *       1.  Each time this command is received, the VCR increases
  140. *           the speed of the shuttle mode playback.  This is
  141. *           equivalent to turning the shuttle ring on the VCR
  142. *           clockwise.
  143. *
  144. *       2.  From a still frame, each command steps through 9
  145. *           speeds, varying from slow field advance to fast
  146. *           forward playback.
  147. *
  148. *       3.  Once maximum speed is attained, additional commands have
  149. *           no effect.
  150. *
  151. *       4.  Maximum command duration is 300 mSec.
  152. *
  153. *       5.  Audio is muted in all but normal playback speed, video
  154. *           is output at all speeds.
  155. *
  156. **********************************************************************/
  157. void    VCR::ShuttleUp (void)
  158. {
  159.     SendCommand ("A@O");
  160. }
  161.  
  162.  
  163.  
  164. /******************************************************************
  165. *   VCR::ShuttleDown - Decrease shuttle speed
  166. *
  167. *   Notes:
  168. *       1.  Each time this command is received, the VCR decreases
  169. *           the speed of the shuttle mode playback.  This is
  170. *           equivalent to turning the shuttle ring on the VCR
  171. *           counterclockwise.
  172. *
  173. *       2.  From a still frame, each command steps through 9
  174. *           speeds, varying from slow field advance to fast
  175. *           reverse playback.
  176. *
  177. *       3.  Once maximum speed is attained, additional commands have
  178. *           no effect.
  179. *
  180. *       4.  Maximum command duration is 300 mSec.
  181. *
  182.  
  183. *       5.  Audio is muted in all but normal playback speed, video
  184. *           is output at all speeds.
  185. *
  186. **********************************************************************/
  187. void    VCR::ShuttleDown (void)
  188. {
  189.     SendCommand ("A@P");
  190. }
  191.  
  192.  
  193.  
  194.  
  195. /******************************************************************
  196. *   VCR::ForwardShuttle - Forward shuttle
  197. *
  198. *   Parameters:
  199. *       int nSpeed - Speed in range of 0 to 8
  200. *
  201. *   Notes:
  202. *       1.  This command places the VCR into the forward shuttle
  203. *           mode at the specified speed.  When changing shuttle
  204. *           speeds, the VCR will gradually change from the
  205. *           current speed to the new speed.
  206. *
  207. *       2.  A speed of 0 will select still frame.  To freeze the
  208. *           picture faster, use ShuttleOn() instead.
  209. *
  210. *       3.  The speed argument consists of a number from 0 to 8,
  211. *           where 8 is the maximum forward play speed.  Numbers
  212. *           outside of this range are brought into range.
  213. *
  214. *       4.  It may take several seconds to change from the current
  215. *           speed to the specified speed.
  216. *
  217. *       5.  Video is output in all modes, audio is output at normal
  218. *           play speed.
  219. *
  220. **********************************************************************/
  221. void VCR::ForwardShuttle (int nSpeed)
  222. {
  223.     char    szBuffer [6];
  224.  
  225.     if (nSpeed < 0) nSpeed = 0;
  226.     if (nSpeed > 8) nSpeed = 8;
  227.     sprintf (szBuffer, "AAF%d", nSpeed);
  228.     SendCommand (szBuffer);
  229. }
  230.  
  231. /******************************************************************
  232. *   VCR::ReverseShuttle - Reverse shuttle
  233. *
  234. *   Parameters:
  235. *       int nSpeed - Speed in range of 0 to 8
  236. *
  237. *   Notes:
  238. *       1.  This command places the VCR into the reverse shuttle
  239. *           mode at the specified speed.  When changing shuttle
  240. *           speeds, the VCR will gradually change from the
  241. *           current speed to the new speed.
  242. *
  243.  
  244. *       2.  A speed of 0 will select still frame.  To freeze the
  245. *           picture faster, use ShuttleOn() instead.
  246. *
  247. *       3.  The speed argument consists of a number from 0 to 8,
  248. *           where 8 is the maximum reverse play speed.  Numbers
  249. *           outside of this range are brought into range.
  250. *
  251. *       4.  It may take several seconds to change from the current
  252. *           speed to the specified speed.
  253. *
  254. *       5.  Video is output in all modes, audio is output at normal
  255. *           play speed.
  256. *
  257. **********************************************************************/
  258. void VCR::ReverseShuttle (int nSpeed)
  259. {
  260.     char    szBuffer [6];
  261.  
  262.     if (nSpeed < 0) nSpeed = 0;
  263.     if (nSpeed > 8) nSpeed = 8;
  264.     sprintf (szBuffer, "AAG%d", nSpeed);
  265.     SendCommand (szBuffer);
  266. }
  267.  
  268.  
  269.  
  270. /******************************************************************
  271. *   VCR::CueToFrame - Cue to frame
  272. *
  273. *   Parameters:
  274. *       struct Frame NewFrame - Frame to cue to.
  275. *
  276. *   Notes:
  277. *       1.  Within frame structure:
  278. *               nHour is 0 - 9
  279. *               nMinute is 0 - 59
  280. *               nSecond is 0 - 59
  281. *               nFrame is 0 - 29
  282. *
  283. *       2.  There are 30 frames in each second.
  284. *
  285. *       3.  This command searches to the selected frame, then
  286. *           stills.  No audio or video is enabled on completion of
  287. *           the cue.  To enable video, send a still command upon
  288. *           completion of the cue.  To begin playing at this
  289. *           location, send a play command after the cue.
  290. *
  291. *       4.  Audio and video are set to passthrough during the search
  292. *           process.
  293. *
  294. *       5.  This command is the recommended way of changing the
  295. *           position of the tape, since it will automatically accelerate
  296. *           and declerate the tape when nearing the cue point.  To prevent
  297. *           cueing errors, do not send cue commands that would cause the
  298. *           VCR to run off the beginning or end of the recorded portion
  299. *           of the tape.
  300. *
  301. *       6.  If frame accuracy is not required, use the SetCueType command
  302. *           to set Coarse mode.  This will allow the VCR to cue at high
  303. *           speed, but with lower accuracy.
  304.  
  305. *
  306. *       7.  You can use the RequestMode() command to tell when this
  307. *           command is complete.  Wait until RequestMode() returns
  308. *           StillMode.
  309. *
  310. *       8.  This command may take several minutes to complete,
  311. *           depending on the frame position.
  312. *
  313. *       9.  Audio and video are set to passthrough.
  314. *
  315. *       10. This command will automatically adjust NewFrame
  316. *           field values to be within the valid ranges.
  317. *
  318. **********************************************************************/
  319. void VCR::CueToFrame (struct Frame NewFrame)
  320. {
  321.     char    szBuffer [12];
  322.  
  323.     // Check ranges of NewFrame fields
  324.     ValidateFrame (NewFrame);
  325.  
  326.     // Build ASCII command string
  327.     sprintf (szBuffer, "A@T%01d%02d%02d%02d", NewFrame.nHour,
  328.         NewFrame.nMinute, NewFrame.nSecond, NewFrame.nFrame);
  329.  
  330.     SendCommand (szBuffer);
  331. }
  332.  
  333.  
  334. /******************************************************************
  335. *   VCR::SetCueType - Set cue type
  336. *
  337. *   Parameters:
  338. *       CueType ctType - Fine or Coarse
  339. *
  340. *   Notes:
  341. *       1.  This command determines if the VCR will perform the
  342. *           cue command in a coarse or fine mode.  The coarse
  343. *           cue is faster, but will result in errors in the tape
  344. *           frame counter.  If high accuracy is desired, the
  345. *           cue type must be set to fine mode.
  346. *
  347. **********************************************************************/
  348. void VCR::SetCueType (CueType ctType)
  349. {
  350.     if (ctType == Fine) SendCommand ("AAD0");
  351.     else SendCommand ("AAD1");
  352. }
  353.  
  354.  
  355. /******************************************************************
  356. *   VCR::PlayToFrame - Play to frame
  357. *
  358. *   Parameters:
  359. *       struct Frame EndFrame - frame to play to
  360. *
  361. *   Notes:
  362. *       1.  This command is usually used after a selected frame
  363. *           has been reached using the Cue command.  Once the cue
  364. *           has completed, the PlayToFrame command allows the
  365.  
  366. *           selected video scene to be viewed.  Upon reaching the
  367. *           end frame, the VCR automatically stills and the audio
  368. *           and video are muted.
  369. *
  370. **********************************************************************/
  371. void VCR::PlayToFrame (struct Frame EndFrame)
  372. {
  373.     char    szBuffer [12];
  374.  
  375.     // Check ranges of EndFrame fields
  376.     ValidateFrame (EndFrame);
  377.  
  378.     // Build ASCII command string
  379.     sprintf (szBuffer, "A@U%01d%02d%02d%02d", EndFrame.nHour,
  380.         EndFrame.nMinute, EndFrame.nSecond, EndFrame.nFrame);
  381.  
  382.     SendCommand (szBuffer);
  383. }
  384.  
  385. /******************************************************************
  386. *   VCR::PlaySegment - Play segment
  387. *
  388. *   Parameters:
  389. *       struct Frame StartFrame
  390. *       struct Frame EndFrame
  391. *
  392. *   Notes:
  393. *       1.  This command searches to StartFrame (using the selected
  394. *           cue type), then immediately begins normal playback.
  395. *           When EndFrame is reaches, the VCR goes into still frame
  396. *           mode.
  397. *
  398. *       2.  During the search, audio and video are muted.  They are also
  399. *           muted when EndFrame is reached.
  400. *
  401. *       3.  RequestMode() can be used to tell when the segment is complete.
  402. *           Wait for the mode to equal StillMode.
  403. *
  404. **********************************************************************/
  405. void    VCR::PlaySegment (struct Frame StartFrame, struct Frame EndFrame)
  406. {
  407.     char    szBuffer [22];
  408.  
  409.     // Check ranges of StartFrame fields
  410.     ValidateFrame (StartFrame);
  411.  
  412.     // check ranges of EndFrame fields
  413.     ValidateFrame (EndFrame);
  414.  
  415.     // Build ASCII command string
  416.     sprintf (szBuffer, "A@Q%01d%02d%02d%02d%01d%02d%02d%02d",
  417.             StartFrame.nHour, StartFrame.nMinute, StartFrame.nSecond,
  418.                 StartFrame.nFrame,
  419.             EndFrame.nHour, EndFrame.nMinute, EndFrame.nSecond,
  420.                 EndFrame.nFrame);
  421.  
  422.     SendCommand (szBuffer);
  423. }
  424.  
  425.  
  426.  
  427.  
  428. /******************************************************************
  429. *   VCR::AudioInsertToFrame - Audio insert to frame
  430. *
  431. *   Parameters:
  432. *       struct Frame EndFrame
  433. *
  434. *   Notes:
  435. *       1.  This command dubs over any existing normal audio tracks,
  436. *           leaving the HI-FI audio unchanged.  For accurate edits,
  437. *           place the VCR in Still at the starting frame using the
  438. *           cue or still commands.  When ready to begin dubbing,
  439. *           send the AudioInsertToFrame() command.  The VCR will
  440. *           first perform a preroll action.  This causes the tape
  441. *           to be reversed for a few seconds, and then begin forward
  442. *           play.  This allows proper video synchronization to be
  443. *           established prior to the insert edit.  Once the edit point
  444. *           is reached, the VCR will begin recording over the audio,
  445. *           and will then still on the selected EndFrame.
  446. *
  447. *       2.  For proper recording, there must be video recorded on the
  448. *           tape for the duration of the over dub.  Existing video is
  449. *           left unchanged.
  450. *
  451. *       3.  For the source VCR for the audio, you should use the
  452. *           PrePlay() command to begin audio playback.  The preroll time
  453. *           will then be matched to ensure audio and video synchronization.
  454. *
  455. **********************************************************************/
  456. void VCR::AudioInsertToFrame (struct Frame EndFrame)
  457. {
  458.     char    szBuffer [12];
  459.  
  460.     // Check ranges of EndFrame fields
  461.     ValidateFrame (EndFrame);
  462.  
  463.     // Build ASCII command string
  464.     sprintf (szBuffer, "AA@%01d%02d%02d%02d", EndFrame.nHour,
  465.         EndFrame.nMinute, EndFrame.nSecond, EndFrame.nFrame);
  466.  
  467.     SendCommand (szBuffer);
  468. }
  469.  
  470.  
  471. /******************************************************************
  472. *   VCR::AudioVideoInsertToFrame - Audio/video insert to frame
  473. *
  474. *   Parameters:
  475. *       struct Frame EndFrame
  476. *
  477. *   Notes:
  478. *       1.  This command edits over any existing video and audio
  479. *           tracks.  For accurate edits,
  480. *           place the VCR in Still at the starting frame using the
  481. *           cue or still commands.  When ready to begin dubbing,
  482. *           send the AudioVideoInsertToFrame() command.  The VCR will
  483. *           first perform a preroll action.  This causes the tape
  484. *           to be reversed for a few seconds, and then begin forward
  485. *           play.  This allows proper video synchronization to be
  486. *           established prior to the insert edit.  Once the edit point
  487.  
  488. *           is reached, the VCR will begin recording
  489. *           and will then still on the selected EndFrame.
  490. *
  491. *       2.  For proper recording, there must be video recorded on the
  492. *           tape for the duration of the over dub.
  493. *
  494. *       3.  For the source VCR for the audio, you should use the
  495. *           PrePlay() command to begin playback.  The preroll time
  496. *           will then be matched to ensure audio and video synchronization.
  497. *
  498. **********************************************************************/
  499. void VCR::AudioVideoInsertToFrame (struct Frame EndFrame)
  500. {
  501.     char    szBuffer [12];
  502.  
  503.     // Check ranges of EndFrame fields
  504.     ValidateFrame (EndFrame);
  505.  
  506.     // Build ASCII command string
  507.     sprintf (szBuffer, "AAB%01d%02d%02d%02d", EndFrame.nHour,
  508.         EndFrame.nMinute, EndFrame.nSecond, EndFrame.nFrame);
  509.  
  510.     SendCommand (szBuffer);
  511. }
  512.  
  513.  
  514. /******************************************************************
  515. *   VCR::Preplay - Preroll play
  516. *
  517. *   Notes:
  518. *       1.  This command begins play mode, after first performing
  519. *           a preroll action.  The preroll will cause the tape
  520. *           to be reverse played for a few seconds, before
  521. *           beginning normal forward play.  This ensures that
  522. *           proper video synchronization is in place prior to the
  523. *           start of an edit.
  524. *
  525. *       2.  The preroll time in this command is matched to the preroll
  526. *           time in the audio and video insert commands.  This ensures
  527. *           that two VCRs will perform exact and clean insert edits.
  528. *
  529. *       3.  The actual preroll requires 3 seconds.
  530. *
  531. **********************************************************************/
  532. void VCR::PrePlay (void)
  533. {
  534.     SendCommand ("AAC");
  535. }
  536.  
  537.  
  538.  
  539. /******************************************************************
  540. *   VCR::Calibrate - Calibrate
  541. *
  542. *   Notes:
  543. *       1.  Since the VCR uses video frame counts to establish tape
  544. *           position, it is important to set a starting reference
  545. *           point for the count.  The calibrate command automatically
  546. *           sets this point to the start of the video tape.  This
  547. *           should be performed every time a new tape is placed in
  548.  
  549. *           the VCR, and may be repeated should tape errors
  550. *           accumulate after excessive tape starting and stopping.
  551. *
  552. *       2.  When issued, the tape rewinds to the beginning and the
  553. *           frame counter is reset on the tape leader.  Thereafter,
  554. *           the frame counter reports the number of video frames counted
  555. *           since the beginning of the tape.
  556. *
  557. **********************************************************************/
  558. void VCR::Calibrate (void)
  559. {
  560.     SendCommand ("A@V");
  561. }
  562.  
  563.  
  564. /******************************************************************
  565. *   VCR::ClearCounter - Clear frame count
  566. *
  567. *   Notes:
  568. *       1.  In some instances, it may be desirable to manually
  569. *           reset the tape frame counter.  This allows the
  570. *           frame counter to be referenced from a starting
  571. *           point other than the start of tape.  To accomplish
  572. *           this, the tape should be positioned to the desired
  573. *           reference frame, then placed in still.  Issue the
  574. *           ClearCounter() command to reset the counter.
  575. *
  576. *       2.  Note that the VCR will not cue to less than 0.  Ensure
  577. *           that the reference point is set prior to any frames
  578. *           that will need to be accessed using the cue time.
  579. *
  580. **********************************************************************/
  581. void VCR::ClearCounter (void)
  582. {
  583.     SendCommand ("A@X");
  584. }
  585.  
  586.  
  587.  
  588. /******************************************************************
  589. *   VCR::AudioSelect - Audio select
  590. *
  591. *   Notes:
  592. *       1.  This command changes the audio output mode from
  593. *           mono, stereo, HI-FI.  Every time the command is
  594. *           received, the audio mode steps to the next type.
  595. *
  596. **********************************************************************/
  597. void VCR::AudioSelect (void)
  598. {
  599.     SendCommand ("AAE");
  600. }
  601.  
  602.  
  603. /******************************************************************
  604. *   VCR::ResetVCR - Perform VCR reset
  605. *
  606. *   Notes:
  607. *       1.  This command cancels any command in process.  It will
  608. *           immediately place the VCR into Stop mode, and turn
  609.  
  610. *           on audio and video.  It is recommended that this command
  611. *           be issued by the computer control program each time
  612. *           the program is started.
  613. *
  614. **********************************************************************/
  615. void VCR::ResetVCR (void)
  616. {
  617.     SendCommand ("A@Z");
  618. }
  619.  
  620.  
  621.  
  622. /******************************************************************
  623. *   VCR::RequestFrame - Request current frame count
  624. *
  625. *   Returns:
  626. *       struct Frame
  627. *
  628. *   Notes:
  629. *       1.  This command returns the current frame value.  It may
  630. *           be sent while another command is still in the process
  631. *           of being executed.  Negative frame counts are returned
  632. *           as 0.
  633. *
  634. *       2.  Normal reply time for this command is 30 mSec.
  635. *
  636. **********************************************************************/
  637. struct Frame VCR::RequestFrame (void)
  638. {
  639.     Str sReturn;
  640.     struct  Frame sfFrame;
  641.     Str sBuffer;
  642.  
  643.     SendCommand ("ZI");
  644.     sReturn = ReceiveResponse ();
  645.  
  646.     // Parse hours
  647.     sBuffer = sReturn.Slice (0, 0);
  648.     sfFrame.nHour = sBuffer.ToInt ();
  649.  
  650.     // Parse minutes
  651.     sBuffer = sReturn.Slice (1, 2);
  652.     sfFrame.nMinute = sBuffer.ToInt ();
  653.  
  654.     // Parse seconds
  655.     sBuffer = sReturn.Slice (3,4);
  656.     sfFrame.nSecond = sBuffer.ToInt ();
  657.  
  658.     // Parse frames
  659.     sBuffer = sReturn.Slice (5,6);
  660.     sfFrame.nFrame = sBuffer.ToInt ();
  661.  
  662.     return sfFrame;
  663. }
  664.  
  665. /******************************************************************
  666. *   VCR::RequestMode - Request current VCR mode
  667. *
  668. *   Returns:
  669. *       VCRMode
  670.  
  671. *
  672. *   Notes:
  673. *       1.  This command asks the VCR what operating mode it is
  674. *           currently in.  For some commands, such as Cue, the
  675. *           VCR mode will change as the tape is fast forwarded,
  676. *           played, and stilled.
  677. *
  678. *       2.  This command should be used to determine if a tape
  679. *           is in the VCR and the power is on.
  680. *
  681. *       3.  Normal reply time is 30 mSec.
  682. *
  683. **********************************************************************/
  684. VCRMode VCR::RequestMode (void)
  685. {
  686.     Str sReturn;
  687.  
  688.     SendCommand ("ZA");
  689.     sReturn = ReceiveResponse ();
  690.  
  691.     if (sReturn.Find ("A@@") != INVALID) return StopMode;
  692.     if (sReturn.Find ("A@A") != INVALID) return EjectMode;
  693.     if (sReturn.Find ("A@B") != INVALID) return RewindMode;
  694.     if (sReturn.Find ("A@C") != INVALID) return FFMode;
  695.     if (sReturn.Find ("A@D") != INVALID) return PlayFRMode;
  696.     if (sReturn.Find ("A@E") != INVALID) return PlayFFMode;
  697.     if (sReturn.Find ("A@F") != INVALID) return StillMode;
  698.     if (sReturn.Find ("A@H") != INVALID) return RecordMode;
  699.     if (sReturn.Find ("A@J") != INVALID) return PlayMode;
  700.     if (sReturn.Find ("A@O") != INVALID) return PowerOffMode;
  701.     if (sReturn.Find ("A@Z") != INVALID) return NoTapeMode;
  702.     return INVALID;
  703. }
  704. // End of File
  705.