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.

419 lines
12 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. INITIALIZE_ID = 100
  13. SETVALUE_ID = 101
  14. GETVALUE_ID = 102
  15. RESETDEVICE_ID = 103
  16. SCAN_ID = 104
  17. SCAN_NEXT_ID = 105
  18. SCAN_FINISHED_ID = 106
  19. CANCELSCAN_ID = 107
  20. '
  21. ' Value ID defines
  22. '
  23. DIM XRESOLUTION
  24. DIM YRESOLUTION
  25. DIM XPOSITION
  26. DIM YPOSITION
  27. DIM XEXTENT
  28. DIM YEXTENT
  29. DIM BRIGHTNESS
  30. DIM CONTRAST
  31. DIM DATATYPE
  32. DIM BITDEPTH
  33. DIM NEGATIVE
  34. DIM PIXELORDER
  35. DIM PIXELFORMAT
  36. DIM BEDWIDTH
  37. DIM BEDHEIGHT
  38. DIM OPTICALX
  39. DIM OPTICALY
  40. DIM ADFSUPPORT
  41. DIM TPASUPPORT
  42. DIM ADFWIDTH
  43. DIM ADFHEIGHT
  44. DIM ADFVJUSTIFY
  45. DIM ADFHJUSTIFY
  46. DIM ADFMAXPAGES
  47. DIM FIRMWAREVER
  48. XRESOLUTION = 2
  49. YRESOLUTION = 3
  50. XPOSITION = 4
  51. YPOSITION = 5
  52. XEXTENT = 6
  53. YEXTENT = 7
  54. BRIGHTNESS = 8
  55. CONTRAST = 9
  56. DATATYPE = 10
  57. BITDEPTH = 11
  58. NEGATIVE = 12
  59. PIXELORDER = 13
  60. PIXELFORMAT = 14
  61. BEDWIDTH = 15
  62. BEDHEIGHT = 16
  63. OPTICALX = 17
  64. OPTICALY = 18
  65. ADFSUPPORT = 19
  66. TPASUPPORT = 20
  67. ADFWIDTH = 21
  68. ADFHEIGHT = 22
  69. ADFVJUSTIFY = 23
  70. ADFHJUSTIFY = 24
  71. ADFMAXPAGES = 25
  72. FIRMWAREVER = 26
  73. ' **************************************************************************************
  74. ' * SCRIPTING EVENTS *
  75. ' * *
  76. ' * Events called from WIAFBDRV WIA driver to envoke scripting actions for the device. *
  77. ' * *
  78. ' * *
  79. ' **************************************************************************************
  80. Sub DeviceAction_DeviceActionEvent
  81. Select Case DeviceAction.Action
  82. Case INITIALIZE_ID
  83. '
  84. ' Initialize Device Properties
  85. '
  86. Call IntializeDeviceProperies()
  87. Case SETVALUE_ID
  88. Select Case DeviceAction.ValueID
  89. Case XRESOLUTION
  90. Call SetXResolution(DeviceAction.Value)
  91. Case YRESOLUTION
  92. Call SetYResolution(DeviceAction.Value)
  93. Case DATATYPE
  94. Call SetDataType(DeviceAction.Value)
  95. Case NEGATIVE
  96. Call SetNegative(DeviceAction.Value)
  97. Case XPOSITION
  98. Call SetXPosition(DeviceAction.Value)
  99. Case YPOSITION
  100. Call SetYPosition(DeviceAction.Value)
  101. Case XEXTENT
  102. Call SetXExtent(DeviceAction.Value)
  103. Case YEXTENT
  104. Call SetYExtent(DeviceAction.Value)
  105. Case CONTRAST
  106. Call SetContrast(DeviceAction.Value)
  107. Case BRIGHTNESS
  108. Call SetBrightness(DeviceAction.Value)
  109. Case Else
  110. End Select
  111. Case GETVALUE_ID
  112. Select Case DeviceAction.ValueID
  113. Case XRESOLUTION
  114. Call GetXResolution(DeviceAction.Value)
  115. Case YRESOLUTION
  116. Call GetYResolution(DeviceAction.Value)
  117. Case DATATYPE
  118. Call GetDataType(DeviceAction.Value)
  119. Case NEGATIVE
  120. Call GetNegative(DeviceAction.Value)
  121. Case XPOSITION
  122. Call GetXPosition(DeviceAction.Value)
  123. Case YPOSITION
  124. Call GetYPosition(DeviceAction.Value)
  125. Case XEXTENT
  126. Call GetXExtent(DeviceAction.Value)
  127. Case YEXTENT
  128. Call GetYExtent(DeviceAction.Value)
  129. Case Else
  130. End Select
  131. Case RESETDEVICE_ID
  132. Call ResetDevice(DeviceAction.Value)
  133. Case SCAN_ID
  134. Call StartScan(DeviceAction.Value)
  135. Case SCAN_NEXT_ID
  136. Call ScanNext(DeviceAction.Value)
  137. Case SCAN_FINISHED_ID
  138. Call ScanFinished(DeviceAction.Value)
  139. Case CANCELSCAN_ID
  140. Call CancelScan(DeviceAction.Value)
  141. Case Else
  142. End Select
  143. End Sub
  144. Sub IntializeDeviceProperies
  145. ' **************************************************************************************
  146. ' To change the x resolution valid value types, just use one of
  147. ' the following methods of DeviceProperty:
  148. '
  149. ' SetValidRange() represents resolution in RANGE form.
  150. ' SetValidList() represents resolution in LIST form.
  151. 'Call DeviceProperty.SetValidRange(XRESOLUTION,12,1200,150,1) ' set valid x resolutions (RANGE form)
  152. 'Call DeviceProperty.SetValidRange(YRESOLUTION,12,1200,150,1) ' set valid y resolutions (RANGE form)
  153. DIM ValidResolutions
  154. ValidResolutions = Array(75,100,150,200,300,600,1200)
  155. Call DeviceProperty.SetValidList(XRESOLUTION,ValidResolutions)' set valid x resolutions (LIST form)
  156. Call DeviceProperty.SetValidList(YRESOLUTION,ValidResolutions)' set valid y resolutions (LIST form)
  157. Call DeviceProperty.SetCurrentValue(XRESOLUTION, 150) ' set current x resolution
  158. Call DeviceProperty.SetCurrentValue(YRESOLUTION, 150) ' set current y resolution
  159. ' ****************************************************************************************
  160. Call DeviceProperty.SetValidRange(XPOSITION,0,2549,2549,1) ' set valid x positions
  161. Call DeviceProperty.SetCurrentValue(XPOSITION,0) ' set current x position
  162. Call DeviceProperty.SetValidRange(YPOSITION,0,3506,3506,1) ' set valid y positions
  163. Call DeviceProperty.SetCurrentValue(YPOSITION,0) ' set current y position
  164. Call DeviceProperty.SetValidRange(XEXTENT,1,2550,1,1) ' set valid x extents
  165. Call DeviceProperty.SetCurrentValue(XEXTENT,2550) ' set current x extent
  166. Call DeviceProperty.SetValidRange(YEXTENT,1,3507,1,1) ' set valid y extents
  167. Call DeviceProperty.SetCurrentValue(YEXTENT,3507) ' set current y extent
  168. Call DeviceProperty.SetValidRange(BRIGHTNESS,-127,127,32,1) ' set valid brightness
  169. Call DeviceProperty.SetCurrentValue(BRIGHTNESS,32) ' set current brightness
  170. Call DeviceProperty.SetValidRange(CONTRAST,-127,127,12,1) ' set valid contrast
  171. Call DeviceProperty.SetCurrentValue(CONTRAST,12) ' set current contrast
  172. DIM ValidDataTypes
  173. ValidDataTypes = Array(0,2,3)
  174. Call DeviceProperty.SetValidList(DATATYPE,ValidDataTypes) ' set valid data types
  175. Call DeviceProperty.SetCurrentValue(DATATYPE,2) ' set current data type
  176. Call DeviceProperty.SetCurrentValue(BITDEPTH,8) ' set current bit depth
  177. Call DeviceProperty.SetCurrentValue(NEGATIVE,1) ' set negative option (TRUE)
  178. Call DeviceProperty.SetCurrentValue(PIXELORDER,0) ' set raw pixel packing order option (WIA_PACKED_PIXEL)
  179. Call DeviceProperty.SetCurrentValue(PIXELFORMAT,1) ' set raw pixel format option (WIA_ORDER_BGR)
  180. Call DeviceProperty.SetCurrentValue(BEDWIDTH,8500) ' set bed width
  181. Call DeviceProperty.SetCurrentValue(BEDHEIGHT,11693) ' set bed height
  182. Call DeviceProperty.SetCurrentValue(OPTICALX,300) ' set x optical resolution
  183. Call DeviceProperty.SetCurrentValue(OPTICALY,300) ' set y optical resolution
  184. Call DeviceProperty.SetCurrentValue(ADFSUPPORT,0) ' set ADF support option
  185. Call DeviceProperty.SetCurrentValue(TPASUPPORT,0) ' set TPA support option
  186. Call DeviceProperty.SetCurrentValue(ADFWIDTH,0) ' set ADF width
  187. Call DeviceProperty.SetCurrentValue(ADFHEIGHT,0) ' set ADF height
  188. Call DeviceProperty.SetCurrentValue(ADFVJUSTIFY,0) ' set ADF vertical justification (TOP_JUSTIFIED)
  189. Call DeviceProperty.SetCurrentValue(ADFHJUSTIFY,0) ' set ADF horizontal justification (LEFT_JUSTIFIED)
  190. Call DeviceProperty.SetCurrentValue(ADFMAXPAGES,30) ' set ADF page capacity
  191. Call DeviceProperty.SetCurrentValue(FIRMWAREVER,"1.02a") ' set firmware version
  192. End Sub
  193. Sub SetXResolution(Value)
  194. Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "R",(4 + Len(CStr(Value))),100)
  195. End Sub
  196. Sub SetYResolution(Value)
  197. Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "S",(4 + Len(CStr(Value))),100)
  198. End Sub
  199. Sub SetDataType(Value)
  200. Select Case Value
  201. Case 0 ' WIA_DATA_THRESHOLD
  202. Call DeviceControl.RawWrite(0,chr(27) + "*a0T",5,100) ' set data type
  203. Call DeviceControl.RawWrite(0,chr(27) + "*a1G",5,100) ' set bits per pixel
  204. Case 2 ' WIA_DATA_GRAYSCALE
  205. Call DeviceControl.RawWrite(0,chr(27) + "*a4T",5,100) ' set data type
  206. Call DeviceControl.RawWrite(0,chr(27) + "*a8G",5,100) ' set bits per pixel
  207. Case 3 ' WIA_DATA_COLOR
  208. Call DeviceControl.RawWrite(0,chr(27) + "*a5T",5,100) ' set data type
  209. Call DeviceControl.RawWrite(0,chr(27) + "*a24G",5,100) ' set bits per pixel
  210. Case Else
  211. End Select
  212. End Sub
  213. Sub SetNegative(Value)
  214. Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "I",(4 + Len(CStr(Value))),100)
  215. End Sub
  216. Sub SetXPosition(Value)
  217. '
  218. ' get current x resolution, for calculation of 300 dpi optical offset
  219. '
  220. DIM XResSetting
  221. Call DeviceProperty.GetCurrentValue(XRESOLUTION, XResSetting)
  222. '
  223. ' calculate new position
  224. '
  225. DIM OpticalValue
  226. OpticalValue = CLng(Value)
  227. OpticalValue = CLng((OpticalValue * 300) / XResSetting)
  228. Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "X",(4 + Len(CStr(OpticalValue))),100)
  229. End Sub
  230. Sub SetYPosition(Value)
  231. '
  232. ' get current y resolution, for calculation of 300 dpi optical offset
  233. '
  234. DIM YResSetting
  235. Call DeviceProperty.GetCurrentValue(YRESOLUTION, YResSetting)
  236. '
  237. ' calculate new position
  238. '
  239. DIM OpticalValue
  240. OpticalValue = CLng(Value)
  241. OpticalValue = CLng((OpticalValue * 300) / YResSetting)
  242. Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "Y",(4 + Len(CStr(OpticalValue))),100)
  243. End Sub
  244. Sub SetXExtent(Value)
  245. '
  246. ' get current x resolution, for calculation of 300 dpi optical offset
  247. '
  248. DIM XResSetting
  249. Call DeviceProperty.GetCurrentValue(XRESOLUTION, XResSetting)
  250. '
  251. ' calculate new position
  252. '
  253. DIM OpticalValue
  254. OpticalValue = CLng(Value)
  255. OpticalValue = CLng((OpticalValue * 300) / XResSetting)
  256. Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "P",(4 + Len(CStr(OpticalValue))),100)
  257. End Sub
  258. Sub SetYExtent(Value)
  259. '
  260. ' get current y resolution, for calculation of 300 dpi optical offset
  261. '
  262. DIM YResSetting
  263. Call DeviceProperty.GetCurrentValue(YRESOLUTION, YResSetting)
  264. '
  265. ' calculate new position
  266. '
  267. DIM OpticalValue
  268. OpticalValue = CLng(Value)
  269. OpticalValue = CLng((OpticalValue * 300) / YResSetting)
  270. Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "Q",(4 + Len(CStr(OpticalValue))),100)
  271. End Sub
  272. Sub SetContrast(Value)
  273. Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "K",(4 + Len(CStr(Value))),100)
  274. End Sub
  275. Sub SetBrightness(Value)
  276. Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "L",(4 + Len(CStr(Value))),100)
  277. End Sub
  278. Sub GetXResolution(Value)
  279. End Sub
  280. Sub GetYResolution(Value)
  281. End Sub
  282. Sub GetDataType(Value)
  283. End Sub
  284. Sub GetNegative(Value)
  285. End Sub
  286. Sub GetXPosition(Value)
  287. End Sub
  288. Sub GetYPosition(Value)
  289. End Sub
  290. Sub GetXExtent(Value)
  291. End Sub
  292. Sub GetYExtent(Value)
  293. End Sub
  294. Sub ResetDevice(Value)
  295. End Sub
  296. Sub StartScan(Value)
  297. ' start a scan
  298. Call DeviceControl.RawWrite(0,chr(27)+"*f0S",5,100)
  299. ' read some data
  300. ScanNext(Value)
  301. End Sub
  302. Sub ScanNext(Value)
  303. Call DeviceControl.ScanRead(0,100)
  304. End Sub
  305. Sub ScanFinished(Value)
  306. 'Call ResetScanner()
  307. End Sub
  308. Sub ResetScanner()
  309. Call DeviceControl.RawWrite(0,chr(27) + chr(69),2,100)
  310. End Sub
  311. Sub CancelScan(Value)
  312. End Sub