Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

465 lines
14 KiB

  1. '
  2. ' constants section: This will be in another file.
  3. '
  4. DIM INITIALIZE_ID
  5. DIM SETVALUE_ID
  6. DIM GETVALUE_ID
  7. DIM RESETDEVICE_ID
  8. DIM SCAN_ID
  9. DIM SCAN_NEXT_ID
  10. DIM SCAN_FINISHED_ID
  11. DIM CANCELSCAN_ID
  12. DIM COMMITSETTINGS_ID
  13. INITIALIZE_ID = 100
  14. SETVALUE_ID = 101
  15. GETVALUE_ID = 102
  16. RESETDEVICE_ID = 103
  17. SCAN_ID = 104
  18. SCAN_NEXT_ID = 105
  19. SCAN_FINISHED_ID = 106
  20. CANCELSCAN_ID = 107
  21. COMMITSETTINGS_ID = 108
  22. '
  23. ' Value ID defines
  24. '
  25. DIM XRESOLUTION
  26. DIM YRESOLUTION
  27. DIM XPOSITION
  28. DIM YPOSITION
  29. DIM XEXTENT
  30. DIM YEXTENT
  31. DIM BRIGHTNESS
  32. DIM CONTRAST
  33. DIM DATATYPE
  34. DIM BITDEPTH
  35. DIM NEGATIVE
  36. DIM PIXELORDER
  37. DIM PIXELFORMAT
  38. DIM BEDWIDTH
  39. DIM BEDHEIGHT
  40. DIM OPTICALX
  41. DIM OPTICALY
  42. DIM ADFSUPPORT
  43. DIM TPASUPPORT
  44. DIM ADFWIDTH
  45. DIM ADFHEIGHT
  46. DIM ADFVJUSTIFY
  47. DIM ADFHJUSTIFY
  48. DIM ADFMAXPAGES
  49. DIM FIRMWAREVER
  50. XRESOLUTION = 2
  51. YRESOLUTION = 3
  52. XPOSITION = 4
  53. YPOSITION = 5
  54. XEXTENT = 6
  55. YEXTENT = 7
  56. BRIGHTNESS = 8
  57. CONTRAST = 9
  58. DATATYPE = 10
  59. BITDEPTH = 11
  60. NEGATIVE = 12
  61. PIXELORDER = 13
  62. PIXELFORMAT = 14
  63. BEDWIDTH = 15
  64. BEDHEIGHT = 16
  65. OPTICALX = 17
  66. OPTICALY = 18
  67. ADFSUPPORT = 19
  68. TPASUPPORT = 20
  69. ADFWIDTH = 21
  70. ADFHEIGHT = 22
  71. ADFVJUSTIFY = 23
  72. ADFHJUSTIFY = 24
  73. ADFMAXPAGES = 25
  74. FIRMWAREVER = 26
  75. ' **************************************************************************************
  76. ' * SCRIPTING FUNCTIONS *
  77. ' * *
  78. ' * Object Name: DeviceControl *
  79. ' * Functions: *
  80. ' * ReadRegister(PipeNumber, - IO Pipe to use for Reading the Register *
  81. ' * RegisterNumber, - Register Number of Target Register to Read *
  82. ' * RegisterToReadInto, - Newly Read Register Value *
  83. ' * IOTimeout) - IO Opertation Timeout value (ms) *
  84. ' * *
  85. ' * SetBitsInByte(ByteMask, - Mask representing bits to use for setting. *
  86. ' * ValueToSet, - Value to set in ByteMask's ON bit locations.*
  87. ' * ByteValueToSet) - *
  88. ' * *
  89. ' * *
  90. ' **************************************************************************************
  91. DeviceControl :
  92. SetBitsInByte(bLampMask,0,Register12)
  93. ReadRegister(2,12,Register12,0)
  94. ' **************************************************************************************
  95. ' * SCRIPTING EVENTS *
  96. ' * *
  97. ' * Events called from WIAFBDRV WIA driver to envoke scripting actions for the device. *
  98. ' * *
  99. ' * *
  100. ' **************************************************************************************
  101. Sub DeviceAction_DeviceActionEvent
  102. Select Case DeviceAction.Action
  103. Case INITIALIZE_ID
  104. '
  105. ' Initialize Device Properties
  106. '
  107. Call IntializeDeviceProperies()
  108. Case SETVALUE_ID
  109. Select Case DeviceAction.ValueID
  110. Case XRESOLUTION
  111. Call SetXResolution(DeviceAction.Value)
  112. Case YRESOLUTION
  113. Call SetYResolution(DeviceAction.Value)
  114. Case DATATYPE
  115. Call SetDataType(DeviceAction.Value)
  116. Case NEGATIVE
  117. Call SetNegative(DeviceAction.Value)
  118. Case XPOSITION
  119. Call SetXPosition(DeviceAction.Value)
  120. Case YPOSITION
  121. Call SetYPosition(DeviceAction.Value)
  122. Case XEXTENT
  123. Call SetXExtent(DeviceAction.Value)
  124. Case YEXTENT
  125. Call SetYExtent(DeviceAction.Value)
  126. Case CONTRAST
  127. Call SetContrast(DeviceAction.Value)
  128. Case BRIGHTNESS
  129. Call SetBrightness(DeviceAction.Value)
  130. Case Else
  131. End Select
  132. Case GETVALUE_ID
  133. Select Case DeviceAction.ValueID
  134. Case XRESOLUTION
  135. Call GetXResolution(DeviceAction.Value)
  136. Case YRESOLUTION
  137. Call GetYResolution(DeviceAction.Value)
  138. Case DATATYPE
  139. Call GetDataType(DeviceAction.Value)
  140. Case NEGATIVE
  141. Call GetNegative(DeviceAction.Value)
  142. Case XPOSITION
  143. Call GetXPosition(DeviceAction.Value)
  144. Case YPOSITION
  145. Call GetYPosition(DeviceAction.Value)
  146. Case XEXTENT
  147. Call GetXExtent(DeviceAction.Value)
  148. Case YEXTENT
  149. Call GetYExtent(DeviceAction.Value)
  150. Case Else
  151. End Select
  152. Case COMMITSETTINGS_ID
  153. Call CommitSettings(DeviceAction.Value)
  154. Case RESETDEVICE_ID
  155. Call ResetDevice(DeviceAction.Value)
  156. Case SCAN_ID
  157. Call StartScan(DeviceAction.Value)
  158. Case SCAN_NEXT_ID
  159. Call ScanNext(DeviceAction.Value)
  160. Case SCAN_FINISHED_ID
  161. Call ScanFinished(DeviceAction.Value)
  162. Case CANCELSCAN_ID
  163. Call CancelScan(DeviceAction.Value)
  164. Case Else
  165. End Select
  166. End Sub
  167. Sub IntializeDeviceProperies
  168. ' **************************************************************************************
  169. ' To change the x resolution valid value types, just use one of
  170. ' the following methods of DeviceProperty:
  171. '
  172. ' SetValidRange() represents resolution in RANGE form.
  173. ' SetValidList() represents resolution in LIST form.
  174. 'Call DeviceProperty.SetValidRange(XRESOLUTION,12,1200,150,1) ' set valid x resolutions (RANGE form)
  175. 'Call DeviceProperty.SetValidRange(YRESOLUTION,12,1200,150,1) ' set valid y resolutions (RANGE form)
  176. DIM ValidResolutions
  177. ValidResolutions = Array(75,100,150,200,300,600)
  178. Call DeviceProperty.SetValidList(XRESOLUTION,ValidResolutions)' set valid x resolutions (LIST form)
  179. Call DeviceProperty.SetValidList(YRESOLUTION,ValidResolutions)' set valid y resolutions (LIST form)
  180. Call DeviceProperty.SetCurrentValue(XRESOLUTION, 150) ' set current x resolution
  181. Call DeviceProperty.SetCurrentValue(YRESOLUTION, 150) ' set current y resolution
  182. ' ****************************************************************************************
  183. Call DeviceProperty.SetValidRange(XPOSITION,0,2549,2549,1) ' set valid x positions
  184. Call DeviceProperty.SetCurrentValue(XPOSITION,0) ' set current x position
  185. Call DeviceProperty.SetValidRange(YPOSITION,0,3506,3506,1) ' set valid y positions
  186. Call DeviceProperty.SetCurrentValue(YPOSITION,0) ' set current y position
  187. Call DeviceProperty.SetValidRange(XEXTENT,1,2550,1,1) ' set valid x extents
  188. Call DeviceProperty.SetCurrentValue(XEXTENT,2550) ' set current x extent
  189. Call DeviceProperty.SetValidRange(YEXTENT,1,3507,1,1) ' set valid y extents
  190. Call DeviceProperty.SetCurrentValue(YEXTENT,3507) ' set current y extent
  191. Call DeviceProperty.SetValidRange(BRIGHTNESS,-127,127,32,1) ' set valid brightness
  192. Call DeviceProperty.SetCurrentValue(BRIGHTNESS,32) ' set current brightness
  193. Call DeviceProperty.SetValidRange(CONTRAST,-127,127,12,1) ' set valid contrast
  194. Call DeviceProperty.SetCurrentValue(CONTRAST,12) ' set current contrast
  195. DIM ValidDataTypes
  196. ValidDataTypes = Array(0,2,3)
  197. Call DeviceProperty.SetValidList(DATATYPE,ValidDataTypes) ' set valid data types
  198. Call DeviceProperty.SetCurrentValue(DATATYPE,2) ' set current data type
  199. Call DeviceProperty.SetCurrentValue(BITDEPTH,8) ' set current bit depth
  200. Call DeviceProperty.SetCurrentValue(NEGATIVE,1) ' set negative option (TRUE)
  201. Call DeviceProperty.SetCurrentValue(PIXELORDER,0) ' set raw pixel packing order option (WIA_PACKED_PIXEL)
  202. Call DeviceProperty.SetCurrentValue(PIXELFORMAT,1) ' set raw pixel format option (WIA_ORDER_BGR)
  203. Call DeviceProperty.SetCurrentValue(BEDWIDTH,8500) ' set bed width
  204. Call DeviceProperty.SetCurrentValue(BEDHEIGHT,11693) ' set bed height
  205. Call DeviceProperty.SetCurrentValue(OPTICALX,300) ' set x optical resolution
  206. Call DeviceProperty.SetCurrentValue(OPTICALY,300) ' set y optical resolution
  207. Call DeviceProperty.SetCurrentValue(ADFSUPPORT,0) ' set ADF support option
  208. Call DeviceProperty.SetCurrentValue(TPASUPPORT,0) ' set TPA support option
  209. Call DeviceProperty.SetCurrentValue(ADFWIDTH,0) ' set ADF width
  210. Call DeviceProperty.SetCurrentValue(ADFHEIGHT,0) ' set ADF height
  211. Call DeviceProperty.SetCurrentValue(ADFVJUSTIFY,0) ' set ADF vertical justification (TOP_JUSTIFIED)
  212. Call DeviceProperty.SetCurrentValue(ADFHJUSTIFY,0) ' set ADF horizontal justification (LEFT_JUSTIFIED)
  213. Call DeviceProperty.SetCurrentValue(ADFMAXPAGES,30) ' set ADF page capacity
  214. Call DeviceProperty.SetCurrentValue(FIRMWAREVER,"1.02a") ' set firmware version
  215. End Sub
  216. Sub CommitSettings(DeviceAction.Value)
  217. End Sub
  218. Sub SetXResolution(Value)
  219. End Sub
  220. Sub SetYResolution(Value)
  221. ' Set X and Y Resolutions at the same time
  222. End Sub
  223. Sub SetDataType(Value)
  224. Select Case Value
  225. Case 0 ' WIA_DATA_THRESHOLD
  226. Case 2 ' WIA_DATA_GRAYSCALE
  227. Case 3 ' WIA_DATA_COLOR
  228. Case Else
  229. End Select
  230. End Sub
  231. Sub SetNegative(Value)
  232. End Sub
  233. Sub SetXPosition(Value)
  234. '
  235. ' get current x resolution, for calculation of 300 dpi optical offset
  236. '
  237. DIM XResSetting
  238. Call DeviceProperty.GetCurrentValue(XRESOLUTION, XResSetting)
  239. '
  240. ' calculate new position
  241. '
  242. DIM OpticalValue
  243. OpticalValue = CLng(Value)
  244. OpticalValue = CLng((OpticalValue * 300) / XResSetting)
  245. End Sub
  246. Sub SetYPosition(Value)
  247. '
  248. ' get current y resolution, for calculation of 300 dpi optical offset
  249. '
  250. DIM YResSetting
  251. Call DeviceProperty.GetCurrentValue(YRESOLUTION, YResSetting)
  252. '
  253. ' calculate new position
  254. '
  255. DIM OpticalValue
  256. OpticalValue = CLng(Value)
  257. OpticalValue = CLng((OpticalValue * 300) / YResSetting)
  258. End Sub
  259. Sub SetXExtent(Value)
  260. '
  261. ' get current x resolution, for calculation of 300 dpi optical offset
  262. '
  263. DIM XResSetting
  264. Call DeviceProperty.GetCurrentValue(XRESOLUTION, XResSetting)
  265. '
  266. ' calculate new position
  267. '
  268. DIM OpticalValue
  269. OpticalValue = CLng(Value)
  270. OpticalValue = CLng((OpticalValue * 300) / XResSetting)
  271. End Sub
  272. Sub SetYExtent(Value)
  273. '
  274. ' get current y resolution, for calculation of 300 dpi optical offset
  275. '
  276. DIM YResSetting
  277. Call DeviceProperty.GetCurrentValue(YRESOLUTION, YResSetting)
  278. '
  279. ' calculate new position
  280. '
  281. DIM OpticalValue
  282. OpticalValue = CLng(Value)
  283. OpticalValue = CLng((OpticalValue * 300) / YResSetting)
  284. End Sub
  285. Sub SetContrast(Value)
  286. End Sub
  287. Sub SetBrightness(Value)
  288. End Sub
  289. Sub GetXResolution(Value)
  290. End Sub
  291. Sub GetYResolution(Value)
  292. End Sub
  293. Sub GetDataType(Value)
  294. End Sub
  295. Sub GetNegative(Value)
  296. End Sub
  297. Sub GetXPosition(Value)
  298. End Sub
  299. Sub GetYPosition(Value)
  300. End Sub
  301. Sub GetXExtent(Value)
  302. End Sub
  303. Sub GetYExtent(Value)
  304. End Sub
  305. Sub ResetDevice(Value)
  306. End Sub
  307. ' **************************************************************************************
  308. ' * SCANNING CALLS *
  309. ' * *
  310. ' * This is where the call is made to initiate a scan, and continue filling buffers. *
  311. ' * *
  312. ' * *
  313. ' **************************************************************************************
  314. Sub StartScan(Value)
  315. ' start a scan
  316. ' read some data
  317. ScanNext(Value)
  318. End Sub
  319. Sub ScanNext(Value)
  320. ' Prepare buffer request instructions, and send them to device.
  321. ' Read data from device.
  322. Call DeviceControl.ScanRead(0,100)
  323. End Sub
  324. Sub ScanFinished(Value)
  325. ' Home carriage
  326. Call HomeCarriage()
  327. End Sub
  328. Sub LampON()
  329. DIM bLampMask As Byte
  330. bLampMask = CByte(128); ' 10000000
  331. DIM Register12
  332. Call DeviceControl.ReadRegister(2,12,Register12,0)
  333. ' flip bit 7 ON
  334. Call DeviceControl.SetBitsInByte(CByte(bLampMask),1,CByte(Register12))
  335. ' write register back to device
  336. Call DeviceControl.WriteRegister(2,Register12,0)
  337. End Sub
  338. Sub LampOFF()
  339. DIM bLampMask As Byte
  340. bLampMask = CByte(128); ' 10000000
  341. DIM Register12
  342. Call DeviceControl.ReadRegister(2,12,Register12,0)
  343. ' flip bit 7 OFF
  344. Call DeviceControl.SetBitsInByte(bLampMask,0,Register12)
  345. ' write register back to device
  346. Call DeviceControl.WriteRegister(2,Register12,0);
  347. End Sub
  348. Sub HomeCarriage()
  349. EndSub
  350. Sub ResetScanner()
  351. End Sub
  352. Sub CancelScan(Value)
  353. End Sub