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.
 
 
 
 
 
 

422 lines
12 KiB

'
' device initialization script for hp scanjet scanners
'
'
' constants section: This will be in another file.
'
DIM INITIALIZE_ID
DIM SETVALUE_ID
DIM GETVALUE_ID
DIM RESETDEVICE_ID
DIM SCAN_ID
DIM SCAN_NEXT_ID
DIM SCAN_FINISHED_ID
DIM CANCELSCAN_ID
INITIALIZE_ID = 100
SETVALUE_ID = 101
GETVALUE_ID = 102
RESETDEVICE_ID = 103
SCAN_ID = 104
SCAN_NEXT_ID = 105
SCAN_FINISHED_ID = 106
CANCELSCAN_ID = 107
'
' Value ID defines
'
DIM XRESOLUTION
DIM YRESOLUTION
DIM XPOSITION
DIM YPOSITION
DIM XEXTENT
DIM YEXTENT
DIM BRIGHTNESS
DIM CONTRAST
DIM DATATYPE
DIM BITDEPTH
DIM NEGATIVE
DIM PIXELORDER
DIM PIXELFORMAT
DIM BEDWIDTH
DIM BEDHEIGHT
DIM OPTICALX
DIM OPTICALY
DIM ADFSUPPORT
DIM TPASUPPORT
DIM ADFWIDTH
DIM ADFHEIGHT
DIM ADFVJUSTIFY
DIM ADFHJUSTIFY
DIM ADFMAXPAGES
DIM FIRMWAREVER
XRESOLUTION = 2
YRESOLUTION = 3
XPOSITION = 4
YPOSITION = 5
XEXTENT = 6
YEXTENT = 7
BRIGHTNESS = 8
CONTRAST = 9
DATATYPE = 10
BITDEPTH = 11
NEGATIVE = 12
PIXELORDER = 13
PIXELFORMAT = 14
BEDWIDTH = 15
BEDHEIGHT = 16
OPTICALX = 17
OPTICALY = 18
ADFSUPPORT = 19
TPASUPPORT = 20
ADFWIDTH = 21
ADFHEIGHT = 22
ADFVJUSTIFY = 23
ADFHJUSTIFY = 24
ADFMAXPAGES = 25
FIRMWAREVER = 26
' **************************************************************************************
' * SCRIPTING EVENTS *
' * *
' * Events called from WIAFBDRV WIA driver to envoke scripting actions for the device. *
' * *
' * *
' **************************************************************************************
Sub DeviceAction_DeviceActionEvent
Select Case DeviceAction.Action
Case INITIALIZE_ID
'
' Initialize Device Properties
'
Call IntializeDeviceProperies()
Case SETVALUE_ID
Select Case DeviceAction.ValueID
Case XRESOLUTION
Call SetXResolution(DeviceAction.Value)
Case YRESOLUTION
Call SetYResolution(DeviceAction.Value)
Case DATATYPE
Call SetDataType(DeviceAction.Value)
Case NEGATIVE
Call SetNegative(DeviceAction.Value)
Case XPOSITION
Call SetXPosition(DeviceAction.Value)
Case YPOSITION
Call SetYPosition(DeviceAction.Value)
Case XEXTENT
Call SetXExtent(DeviceAction.Value)
Case YEXTENT
Call SetYExtent(DeviceAction.Value)
Case CONTRAST
Call SetContrast(DeviceAction.Value)
Case BRIGHTNESS
Call SetBrightness(DeviceAction.Value)
Case Else
End Select
Case GETVALUE_ID
Select Case DeviceAction.ValueID
Case XRESOLUTION
Call GetXResolution(DeviceAction.Value)
Case YRESOLUTION
Call GetYResolution(DeviceAction.Value)
Case DATATYPE
Call GetDataType(DeviceAction.Value)
Case NEGATIVE
Call GetNegative(DeviceAction.Value)
Case XPOSITION
Call GetXPosition(DeviceAction.Value)
Case YPOSITION
Call GetYPosition(DeviceAction.Value)
Case XEXTENT
Call GetXExtent(DeviceAction.Value)
Case YEXTENT
Call GetYExtent(DeviceAction.Value)
Case Else
End Select
Case RESETDEVICE_ID
Call ResetDevice(DeviceAction.Value)
Case SCAN_ID
Call StartScan(DeviceAction.Value)
Case SCAN_NEXT_ID
Call ScanNext(DeviceAction.Value)
Case SCAN_FINISHED_ID
Call ScanFinished(DeviceAction.Value)
Case CANCELSCAN_ID
Call CancelScan(DeviceAction.Value)
Case Else
End Select
End Sub
Sub IntializeDeviceProperies
' **************************************************************************************
' To change the x resolution valid value types, just use one of
' the following methods of DeviceProperty:
'
' SetValidRange() represents resolution in RANGE form.
' SetValidList() represents resolution in LIST form.
'Call DeviceProperty.SetValidRange(XRESOLUTION,12,1200,150,1) ' set valid x resolutions (RANGE form)
'Call DeviceProperty.SetValidRange(YRESOLUTION,12,1200,150,1) ' set valid y resolutions (RANGE form)
DIM ValidResolutions
ValidResolutions = Array(75,100,150,200,300,600,1200)
Call DeviceProperty.SetValidList(XRESOLUTION,ValidResolutions)' set valid x resolutions (LIST form)
Call DeviceProperty.SetValidList(YRESOLUTION,ValidResolutions)' set valid y resolutions (LIST form)
Call DeviceProperty.SetCurrentValue(XRESOLUTION, 150) ' set current x resolution
Call DeviceProperty.SetCurrentValue(YRESOLUTION, 150) ' set current y resolution
' ****************************************************************************************
Call DeviceProperty.SetValidRange(XPOSITION,0,2549,2549,1) ' set valid x positions
Call DeviceProperty.SetCurrentValue(XPOSITION,0) ' set current x position
Call DeviceProperty.SetValidRange(YPOSITION,0,3506,3506,1) ' set valid y positions
Call DeviceProperty.SetCurrentValue(YPOSITION,0) ' set current y position
Call DeviceProperty.SetValidRange(XEXTENT,1,2550,1,1) ' set valid x extents
Call DeviceProperty.SetCurrentValue(XEXTENT,2550) ' set current x extent
Call DeviceProperty.SetValidRange(YEXTENT,1,3507,1,1) ' set valid y extents
Call DeviceProperty.SetCurrentValue(YEXTENT,3507) ' set current y extent
Call DeviceProperty.SetValidRange(BRIGHTNESS,-127,127,32,1) ' set valid brightness
Call DeviceProperty.SetCurrentValue(BRIGHTNESS,32) ' set current brightness
Call DeviceProperty.SetValidRange(CONTRAST,-127,127,12,1) ' set valid contrast
Call DeviceProperty.SetCurrentValue(CONTRAST,12) ' set current contrast
DIM ValidDataTypes
ValidDataTypes = Array(0,2,3)
Call DeviceProperty.SetValidList(DATATYPE,ValidDataTypes) ' set valid data types
Call DeviceProperty.SetCurrentValue(DATATYPE,2) ' set current data type
Call DeviceProperty.SetCurrentValue(BITDEPTH,8) ' set current bit depth
Call DeviceProperty.SetCurrentValue(NEGATIVE,1) ' set negative option (TRUE)
Call DeviceProperty.SetCurrentValue(PIXELORDER,0) ' set raw pixel packing order option (WIA_PACKED_PIXEL)
Call DeviceProperty.SetCurrentValue(PIXELFORMAT,1) ' set raw pixel format option (WIA_ORDER_BGR)
Call DeviceProperty.SetCurrentValue(BEDWIDTH,8500) ' set bed width
Call DeviceProperty.SetCurrentValue(BEDHEIGHT,11693) ' set bed height
Call DeviceProperty.SetCurrentValue(OPTICALX,300) ' set x optical resolution
Call DeviceProperty.SetCurrentValue(OPTICALY,300) ' set y optical resolution
Call DeviceProperty.SetCurrentValue(ADFSUPPORT,0) ' set ADF support option
Call DeviceProperty.SetCurrentValue(TPASUPPORT,0) ' set TPA support option
Call DeviceProperty.SetCurrentValue(ADFWIDTH,0) ' set ADF width
Call DeviceProperty.SetCurrentValue(ADFHEIGHT,0) ' set ADF height
Call DeviceProperty.SetCurrentValue(ADFVJUSTIFY,0) ' set ADF vertical justification (TOP_JUSTIFIED)
Call DeviceProperty.SetCurrentValue(ADFHJUSTIFY,0) ' set ADF horizontal justification (LEFT_JUSTIFIED)
Call DeviceProperty.SetCurrentValue(ADFMAXPAGES,30) ' set ADF page capacity
Call DeviceProperty.SetCurrentValue(FIRMWAREVER,"1.02a") ' set firmware version
End Sub
Sub SetXResolution(Value)
Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "R",(4 + Len(CStr(Value))),100)
End Sub
Sub SetYResolution(Value)
Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "S",(4 + Len(CStr(Value))),100)
End Sub
Sub SetDataType(Value)
Select Case Value
Case 0 ' WIA_DATA_THRESHOLD
Call DeviceControl.RawWrite(0,chr(27) + "*a0T",5,100) ' set data type
Call DeviceControl.RawWrite(0,chr(27) + "*a1G",5,100) ' set bits per pixel
Case 2 ' WIA_DATA_GRAYSCALE
Call DeviceControl.RawWrite(0,chr(27) + "*a4T",5,100) ' set data type
Call DeviceControl.RawWrite(0,chr(27) + "*a8G",5,100) ' set bits per pixel
Case 3 ' WIA_DATA_COLOR
Call DeviceControl.RawWrite(0,chr(27) + "*a5T",5,100) ' set data type
Call DeviceControl.RawWrite(0,chr(27) + "*a24G",5,100) ' set bits per pixel
Case Else
End Select
End Sub
Sub SetNegative(Value)
Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "I",(4 + Len(CStr(Value))),100)
End Sub
Sub SetXPosition(Value)
'
' get current x resolution, for calculation of 300 dpi optical offset
'
DIM XResSetting
Call DeviceProperty.GetCurrentValue(XRESOLUTION, XResSetting)
'
' calculate new position
'
DIM OpticalValue
OpticalValue = CLng(Value)
OpticalValue = CLng((OpticalValue * 300) / XResSetting)
Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "X",(4 + Len(CStr(OpticalValue))),100)
End Sub
Sub SetYPosition(Value)
'
' get current y resolution, for calculation of 300 dpi optical offset
'
DIM YResSetting
Call DeviceProperty.GetCurrentValue(YRESOLUTION, YResSetting)
'
' calculate new position
'
DIM OpticalValue
OpticalValue = CLng(Value)
OpticalValue = CLng((OpticalValue * 300) / YResSetting)
Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "Y",(4 + Len(CStr(OpticalValue))),100)
End Sub
Sub SetXExtent(Value)
'
' get current x resolution, for calculation of 300 dpi optical offset
'
DIM XResSetting
Call DeviceProperty.GetCurrentValue(XRESOLUTION, XResSetting)
'
' calculate new position
'
DIM OpticalValue
OpticalValue = CLng(Value)
OpticalValue = CLng((OpticalValue * 300) / XResSetting)
Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "P",(4 + Len(CStr(OpticalValue))),100)
End Sub
Sub SetYExtent(Value)
'
' get current y resolution, for calculation of 300 dpi optical offset
'
DIM YResSetting
Call DeviceProperty.GetCurrentValue(YRESOLUTION, YResSetting)
'
' calculate new position
'
DIM OpticalValue
OpticalValue = CLng(Value)
OpticalValue = CLng((OpticalValue * 300) / YResSetting)
Call DeviceControl.RawWrite(0,chr(27) + "*f" + CStr(OpticalValue) + "Q",(4 + Len(CStr(OpticalValue))),100)
End Sub
Sub SetContrast(Value)
Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "K",(4 + Len(CStr(Value))),100)
End Sub
Sub SetBrightness(Value)
Call DeviceControl.RawWrite(0,chr(27) + "*a" + CStr(Value) + "L",(4 + Len(CStr(Value))),100)
End Sub
Sub GetXResolution(Value)
End Sub
Sub GetYResolution(Value)
End Sub
Sub GetDataType(Value)
End Sub
Sub GetNegative(Value)
End Sub
Sub GetXPosition(Value)
End Sub
Sub GetYPosition(Value)
End Sub
Sub GetXExtent(Value)
End Sub
Sub GetYExtent(Value)
End Sub
Sub ResetDevice(Value)
End Sub
Sub StartScan(Value)
' start a scan
Call DeviceControl.RawWrite(0,chr(27)+"*f0S",5,100)
' read some data
ScanNext(Value)
End Sub
Sub ScanNext(Value)
Call DeviceControl.ScanRead(0,100)
End Sub
Sub ScanFinished(Value)
'Call ResetScanner()
End Sub
Sub ResetScanner()
Call DeviceControl.RawWrite(0,chr(27) + chr(69),2,100)
End Sub
Sub CancelScan(Value)
End Sub