home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_10 / 2n10053a < prev    next >
Text File  |  1991-09-05  |  14KB  |  412 lines

  1. @cplus = //  VCR.CPP - VCR device driver class.<R>
  2. //      VCR::VCR - Constructor for VCR<R>
  3. //      VCR::~VCR - Destructor for VCR<R>
  4. //      VCR::SendCommand - Send command string to VCR<R>
  5. //      VCR::Stop - Puts the VCR into Stop mode.<R>
  6. //      VCR::Eject - Causes the tape to be ejected from the VCR.<R>
  7. //      VCR::Rewind - Places the VCR into full speed rewind.<R>
  8. //      VCR::FastForward - Places the VCR into full speed fast forward.<R>
  9. //      VCR::PlayFastReverse - Places the VCR into fast reverse play.<R>
  10. //      VCR::PlayFastForward - Places the VCR into fast forward play.<R>
  11. //      VCR::Still - Causes the VCR to Still on the current frame.<R>
  12. //      VCR::Record - Begin recording mode.<R>
  13. //      VCR::Play - Begins normal play mode.<R>
  14. //      VCR::ReversePlay - Begins normal reverse play mode;<R>
  15. //      VCR::StepForward - From a still frame, advance to next field.<R>
  16. //      VCR::StepReverse - From a still frame, step to previous field.<R>
  17. //      VCR::PowerToggle - Toggle VCR power.<R>
  18. <R>
  19. #include    "VCR.h"<R>
  20. <R>
  21. /******************************************************************<R>
  22. *   VCR::VCR - Constructor for VCR<R>
  23. *<R>
  24. *   Parameters:<R>
  25. *       int nNewPortAddress - default is address for COM1:<R>
  26. *<R>
  27. *   Class Variables Used:<R>
  28. *       SerialPort *spSerialPort;<R>
  29. *<R>
  30. *   Returns:<R>
  31. *       Nothing<R>
  32. *<R>
  33. *   Notes:<R>
  34. *       1.  Configures serial port to 9600 baud, 8 data bits,<R>
  35. *           no parity, and 1 stop bit.<R>
  36. *   Copyright:<R>
  37. *       Original code by William H. Roetzheim (619) 669-6970<R>
  38. *       Copyright (c) 1991 by William H. Roetzheim<R>
  39. *       All rights reserved.<R>
  40. *<R>
  41. **********************************************************************/<R>
  42. VCR::VCR (int nNewPortAddress)<R>
  43. {<R>
  44.     spSerialPort = new SerialPort (nNewPortAddress, "VCR");<R>
  45.     spSerialPort->>SetBaud (9600);<R>
  46.     spSerialPort->>SetBitsPerWord (8);<R>
  47.     spSerialPort->>SetStopBits (1);<R>
  48.     spSerialPort->>SetParity (NoParity);<R>
  49. }<R>
  50. <R>
  51. <R>
  52. /******************************************************************<R>
  53. *   VCR::~VCR - Destructor for VCR<R>
  54. *<R>
  55. *   Parameters:<R>
  56. *       None.<R>
  57. *<R>
  58. *   Class Variables Used:<R>
  59. *       Port *SerialPort
  60.  
  61. @cplus = *<R>
  62. **********************************************************************/<R>
  63. VCR::~VCR ()<R>
  64. {<R>
  65.     delete spSerialPort;<R>
  66. }<R>
  67. <R>
  68. <R>
  69. <R>
  70. /******************************************************************<R>
  71. *   VCR::SendCommand - Send command string to VCR<R>
  72. *<R>
  73. *   Parameters:<R>
  74. *       Str sCommandString - String to be output<R>
  75. *<R>
  76. *   Class Variables Used:<R>
  77. *       Port *SerialPort<R>
  78. *<R>
  79. **********************************************************************/<R>
  80. void VCR::SendCommand (Str sCommandString)<R>
  81. {<R>
  82.     // Send start of command string character<R>
  83.     spSerialPort->>OutChar (0x02);<R>
  84. <R>
  85.     // Send command string<R>
  86.     int     i;<R>
  87.     for (i = 0; i << sCommandString.Length (); i++)<R>
  88.     {<R>
  89.         spSerialPort->>OutChar (sCommandString.Slice (i));<R>
  90.     }<R>
  91. <R>
  92.     // Send end of command string character<R>
  93.     spSerialPort->>OutChar (0x03);<R>
  94. }<R>
  95. <R>
  96. <R>
  97. /******************************************************************<R>
  98. *   VCR::Stop - Puts the VCR into Stop mode.<R>
  99. *<R>
  100. *   Notes:<R>
  101. *       1.  This will abort any command in process, and stop<R>
  102. *           any tape motion.<R>
  103. *<R>
  104. *       2.  This command should not normally be used to terminate<R>
  105. *           an assembly or insert edit.  Stop will immediately<R>
  106. *           stop the VCR, preventing a clean edit transition.  Use<R>
  107. *           Still instead to allow the VCR to establish proper<R>
  108. *           sync at the edit out point.<R>
  109. *<R>
  110. *       3.  The tape is left loaded on the head to allow quick<R>
  111. *           resynchronization after a new play command.<R>
  112. *<R>
  113. *       4.  Maximum command duration is 300 ms.<R>
  114. *<R>
  115. *       5.  Audio and video are immediately placed into passthrough.<R>
  116. *<R>
  117. **********************************************************************/<R>
  118. void VCR::Stop (void)<R>
  119. {<R>
  120.     SendCommand ("A@@");
  121.  
  122. @cplus = }<R>
  123. <R>
  124. <R>
  125. /******************************************************************<R>
  126. *   VCR::Eject - Causes the tape to be ejected from the VCR<R>
  127. *<R>
  128. *   Notes:<R>
  129. *       1.  Reception of this command will abort any command<R>
  130. *           in process, and eject the tape.  If no tape is<R>
  131. *           in the VCR, the command has no effect.<R>
  132. *<R>
  133. *       2.  After a tape has been ejected, it can only be reloaded<R>
  134. *           into the VCR manually.<R>
  135. *<R>
  136. *       3.  Maximum command duration is 5 seconds.<R>
  137. *<R>
  138. *       4.  Audio and video are immediately placed into passthrough.<R>
  139. *<R>
  140. **********************************************************************/<R>
  141. void VCR::Eject (void)<R>
  142. {<R>
  143.     SendCommand ("A@A");<R>
  144. }<R>
  145. <R>
  146. <R>
  147. /******************************************************************<R>
  148. *   VCR::Rewind - Places the VCR into full speed rewind<R>
  149. *<R>
  150. *   Notes:<R>
  151. *       1.  This is the fastest way to position the tape in the<R>
  152. *           reverse direction.  No audio or video is output during<R>
  153. *           the rewind.<R>
  154. *<R>
  155. *       2.  This command cannot be used if high accuracy is required.<R>
  156. *           Since the tape is moved at high speed, minor errors in the<R>
  157. *           frame count will result every time this command is executed.<R>
  158. *           If high accuracy is required, the PlayFastReverse () command<R>
  159. *           must be used instead.<R>
  160. *<R>
  161. *       3.  Maximum command duration, 300 mSeconds to start rewinding.<R>
  162. *<R>
  163. *       4.  Audio and video are placed into passthrough.<R>
  164. *<R>
  165. **********************************************************************/<R>
  166. void VCR::Rewind (void)<R>
  167. {<R>
  168.     SendCommand ("A@B");<R>
  169. }<R>
  170. <R>
  171. <R>
  172. /******************************************************************<R>
  173. *   VCR::FastForward - Places the VCR into full speed fast forward<R>
  174. *<R>
  175. *   Notes:<R>
  176. *       1.  This is the fastest way to position the tape in the<R>
  177. *           forward direction.  No audio or video is output<R>
  178. *           during the fast forward.<R>
  179. *<R>
  180. *       2.  This command cannot be used if high accuracy is<R>
  181. *           required.  Since the tape is moved at high speed,
  182.  
  183. @cplus = *           minor errors in the frame count will result every time<R>
  184. *           this command is executed.  If high accuracy is required,<R>
  185. *           the PlayFastForward () command must be used instead.<R>
  186. *<R>
  187. *       3.  Maximum command duration is 300 mSeconds to begin fast<R>
  188. *           forwarding.<R>
  189. *<R>
  190. *       4.  Audio and video are placed in passthrough.<R>
  191. *<R>
  192. **********************************************************************/<R>
  193. void VCR::FastForward (void)<R>
  194. {<R>
  195.     SendCommand ("A@C");<R>
  196. }<R>
  197. <R>
  198. <R>
  199. /******************************************************************<R>
  200. *   VCR::PlayFastReverse - Places the VCR into fast reverse play<R>
  201. *<R>
  202. *   Notes:<R>
  203. *       1.  This mode moves the tape as fast as possible, while<R>
  204. *           still providing a video picture.  No audio is output<R>
  205. *           during the motion.<R>
  206. *<R>
  207. *       2.  This is the fastest way to move the tape in the reverse<R>
  208. *           direction and still maintain high tape count accuracy.<R>
  209. *<R>
  210. *       3.  The tape speed in this mode is 7X play (SP mode) or 21X<R>
  211. *           play (SLP mode).<R>
  212. *<R>
  213. *       4.  If very high accuracy is required, use of the CueToFrame ()<R>
  214. *           command is preferred, since abrupt tape stops may cause minor<R>
  215. *           count errors.  Allowing the tape to run off the beginning<R>
  216. *           may also cause errors in the tape count.<R>
  217. *<R>
  218. *       5.  Maximum command duration is 300 mSeconds to begin play.<R>
  219. *<R>
  220. *       6.  Video plays (with high speed noise bars), audio is muted.<R>
  221. *<R>
  222. **********************************************************************/<R>
  223. void VCR::PlayFastReverse (void)<R>
  224. {<R>
  225.     SendCommand ("A@D");<R>
  226. }<R>
  227. <R>
  228. <R>
  229. /******************************************************************<R>
  230. *   VCR::PlayFastForward - Places the VCR into fast forward play<R>
  231. *<R>
  232. *   Notes:<R>
  233. *       1.  This mode moves the tape as fast as possible, while<R>
  234. *           still providing a video picture.  No audio is output<R>
  235. *           during the motion.<R>
  236. *<R>
  237. *       2.  This is the fastest way to move the tape in the forward<R>
  238. *           direction and still maintain high tape count accuracy.<R>
  239. *<R>
  240. *       3.  The tape speed in this mode is 7X play (SP mode) or 21X<R>
  241. *           play (SLP mode).<R>
  242. *
  243.  
  244. @cplus = *       4.  If very high accuracy is required, use of the CueToFrame ()<R>
  245. *           command is preferred, since abrupt tape stops may cause minor<R>
  246. *           count errors.  Allowing the tape to run off the end<R>
  247. *           may also cause errors in the tape count.<R>
  248. *<R>
  249. *       5.  Maximum command duration is 300 mSeconds to begin play.<R>
  250. *<R>
  251. *       6.  Video plays (with high speed noise bars), audio is muted.<R>
  252. *<R>
  253. *<R>
  254. **********************************************************************/<R>
  255. void VCR::PlayFastForward (void)<R>
  256. {<R>
  257.     SendCommand ("A@E");<R>
  258. }<R>
  259. <R>
  260. <R>
  261. <R>
  262. /******************************************************************<R>
  263. *   VCR::Still - Causes the VCR to Still on the current frame<R>
  264. *<R>
  265. *   Notes:<R>
  266. *       1.  The VCR will always attempt to provide a clean picture<R>
  267. *           when executing this command.  To establish correct video<R>
  268. *           sync, up to three frames may be stepped through until<R>
  269. *           the picture is free of noise bars.  This command is also<R>
  270. *           useful for turning on the video at the completion of<R>
  271. *           a CueToFrame () command.<R>
  272. *<R>
  273. *       2.  Maximum duration is 300 mSeconds to execute the command,<R>
  274. *           but up to 1 second may be required to produce a noise<R>
  275. *           free picture.<R>
  276. *<R>
  277. *       3.  Video is displayed, audio is muted.<R>
  278. *<R>
  279. **********************************************************************/<R>
  280. void VCR::Still (void)<R>
  281. {<R>
  282.     SendCommand ("A@F");<R>
  283. }<R>
  284. <R>
  285. <R>
  286. <R>
  287. /******************************************************************<R>
  288. *   VCR::Record - Begin recording mode<R>
  289. *<R>
  290. *   Notes:<R>
  291. *       1.  Attempting to record on a tape which has the erasure<R>
  292. *           tab removed will cause the tape to be ejected from<R>
  293. *           the VCR.<R>
  294. *<R>
  295. *       2.  Maximum command time is 300 mSeconds.<R>
  296. *<R>
  297. *       3.  The audio and video being recorded are output.<R>
  298. *<R>
  299. **********************************************************************/<R>
  300. void VCR::Record (void)<R>
  301. {<R>
  302.     SendCommand ("A@H");<R>
  303. }
  304.  
  305. @cplus = <R>
  306. <R>
  307. <R>
  308. <R>
  309. /******************************************************************<R>
  310. *   VCR::Play - Begin normal play mode<R>
  311. *<R>
  312. *   Notes:<R>
  313. *       1.  Four seconds are required until playback begins from a<R>
  314. *           full stop condition.<R>
  315. *<R>
  316. **********************************************************************/<R>
  317. void VCR::Play (void)<R>
  318. {<R>
  319.     SendCommand ("A@J");<R>
  320. }<R>
  321. <R>
  322. <R>
  323. <R>
  324. /******************************************************************<R>
  325. *   VCR::ReversePlay - Begins normal reverse play mode<R>
  326. *<R>
  327. *   Notes:<R>
  328. *       1.  Four seconds are required until playback begins from<R>
  329. *           a full stop condition.<R>
  330. *<R>
  331. **********************************************************************/<R>
  332. void VCR::ReversePlay (void)<R>
  333. {<R>
  334.     SendCommand ("A@K");<R>
  335. }<R>
  336. <R>
  337. <R>
  338. <R>
  339. <R>
  340. /******************************************************************<R>
  341. *   VCR::StepForward - From a still frame, advance to next field<R>
  342. *<R>
  343. *   Notes:<R>
  344. *       1.  A video frame consists of two fields.  This command<R>
  345. *           steps forward one field, so the frame counter advances<R>
  346. *           after every other field step.<R>
  347. *<R>
  348. *       2.  The VCR will automatically stop if left in still frame<R>
  349. *           longer than 5 minutes without moving the tape.<R>
  350. *<R>
  351. *       3.  This command requires 300 mSec. to execute.<R>
  352. *<R>
  353. *       4.  Video is output, audio is muted.<R>
  354. *<R>
  355. **********************************************************************/<R>
  356. void VCR::StepForward (void)<R>
  357. {<R>
  358.     SendCommand ("A@L");<R>
  359. }<R>
  360. <R>
  361. <R>
  362. <R>
  363. <R>
  364. /******************************************************************
  365.  
  366. @cplus = *   VCR::StepReverse - From a still frame, step to previous field<R>
  367. *<R>
  368. *   Notes:<R>
  369. *       1.  A video frame consists of two fields.  This command<R>
  370. *           steps backward one field, so the frame counter decreases<R>
  371. *           after every other field step.<R>
  372. *<R>
  373. *       2.  The VCR will automatically stop if left in still frame<R>
  374. *           longer than 5 minutes without moving the tape.<R>
  375. *<R>
  376. *       3.  This command requires 300 mSec. to execute.<R>
  377. *<R>
  378. *       4.  Video is output, audio is muted.<R>
  379. *<R>
  380. *<R>
  381. **********************************************************************/<R>
  382. void VCR::StepReverse (void)<R>
  383. {<R>
  384.     SendCommand ("A@M");<R>
  385. }<R>
  386. <R>
  387. <R>
  388. <R>
  389. <R>
  390. /******************************************************************<R>
  391. *   VCR::PowerToggle - Toggle VCR power.<R>
  392. *<R>
  393. *   Notes:<R>
  394. *       1.  This command toggles the VCR power on/off.  Turning the<R>
  395. *           VCR power off does not inhibit communication with the<R>
  396. *           VCR serial processor.<R>
  397. *<R>
  398. *       2.  RequestMode() can be used to determine if the VCR<R>
  399. *           power is currently off.<R>
  400. *<R>
  401. *       3.  Three seconds may be required to turn off the power if<R>
  402. *           it is in the play mode.<R>
  403. *<R>
  404. *       4.  Audio and video are muted.<R>
  405. *<R>
  406. **********************************************************************/<R>
  407. void VCR::PowerToggle (void)<R>
  408. {<R>
  409.     SendCommand ("ACM");<R>
  410. }<R>
  411. // End of File
  412.