' ' 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 DIM COMMITSETTINGS_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 COMMITSETTINGS_ID = 108 ' ' 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 FUNCTIONS * ' * * ' * Object Name: DeviceControl * ' * Functions: * ' * ReadRegister(PipeNumber, - IO Pipe to use for Reading the Register * ' * RegisterNumber, - Register Number of Target Register to Read * ' * RegisterToReadInto, - Newly Read Register Value * ' * IOTimeout) - IO Opertation Timeout value (ms) * ' * * ' * SetBitsInByte(ByteMask, - Mask representing bits to use for setting. * ' * ValueToSet, - Value to set in ByteMask's ON bit locations.* ' * ByteValueToSet) - * ' * * ' * * ' ************************************************************************************** DeviceControl : SetBitsInByte(bLampMask,0,Register12) ReadRegister(2,12,Register12,0) ' ************************************************************************************** ' * 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 COMMITSETTINGS_ID Call CommitSettings(DeviceAction.Value) 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) 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 CommitSettings(DeviceAction.Value) End Sub Sub SetXResolution(Value) End Sub Sub SetYResolution(Value) ' Set X and Y Resolutions at the same time End Sub Sub SetDataType(Value) Select Case Value Case 0 ' WIA_DATA_THRESHOLD Case 2 ' WIA_DATA_GRAYSCALE Case 3 ' WIA_DATA_COLOR Case Else End Select End Sub Sub SetNegative(Value) 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) 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) 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) 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) End Sub Sub SetContrast(Value) End Sub Sub SetBrightness(Value) 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 ' ************************************************************************************** ' * SCANNING CALLS * ' * * ' * This is where the call is made to initiate a scan, and continue filling buffers. * ' * * ' * * ' ************************************************************************************** Sub StartScan(Value) ' start a scan ' read some data ScanNext(Value) End Sub Sub ScanNext(Value) ' Prepare buffer request instructions, and send them to device. ' Read data from device. Call DeviceControl.ScanRead(0,100) End Sub Sub ScanFinished(Value) ' Home carriage Call HomeCarriage() End Sub Sub LampON() DIM bLampMask As Byte bLampMask = CByte(128); ' 10000000 DIM Register12 Call DeviceControl.ReadRegister(2,12,Register12,0) ' flip bit 7 ON Call DeviceControl.SetBitsInByte(CByte(bLampMask),1,CByte(Register12)) ' write register back to device Call DeviceControl.WriteRegister(2,Register12,0) End Sub Sub LampOFF() DIM bLampMask As Byte bLampMask = CByte(128); ' 10000000 DIM Register12 Call DeviceControl.ReadRegister(2,12,Register12,0) ' flip bit 7 OFF Call DeviceControl.SetBitsInByte(bLampMask,0,Register12) ' write register back to device Call DeviceControl.WriteRegister(2,Register12,0); End Sub Sub HomeCarriage() EndSub Sub ResetScanner() End Sub Sub CancelScan(Value) End Sub