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.
205 lines
6.7 KiB
205 lines
6.7 KiB
#include "stdGSD.gsd"
|
|
|
|
// script for control of HP SCL scanners
|
|
|
|
function VOID DeviceAction_DeviceActionEvent()
|
|
{
|
|
// Handle initialization of device properties
|
|
|
|
if(DeviceAction.Action == INITIALIZE_ID)
|
|
{
|
|
// this will call the device's specific property
|
|
// initialization script function specified in the
|
|
// product line file.
|
|
InitializeDeviceProperties();
|
|
}
|
|
|
|
// Handle setting a device property
|
|
|
|
else if(DeviceAction.Action == SETVALUE_ID)
|
|
{
|
|
if(DeviceAction.ValueID == XRESOLUTION)
|
|
{
|
|
LONG DataLength = 0;
|
|
DataLength = (4 + LEN(STR(DeviceAction.Value)));
|
|
DeviceControl.RawWrite(0,
|
|
CHR(27) +
|
|
"*a" +
|
|
STR(DeviceAction.Value) +
|
|
"R",DataLength,100)
|
|
}
|
|
else if(DeviceAction.ValueID == YRESOLUTION)
|
|
{
|
|
LONG DataLength = 0;
|
|
DataLength = (4 + LEN(STR(DeviceAction.Value)));
|
|
DeviceControl.RawWrite(0,
|
|
CHR(27) +
|
|
"*a" +
|
|
STR(DeviceAction.Value) +
|
|
"S",DataLength,100) }
|
|
else if(DeviceAction.ValueID == XPOSITION)
|
|
{
|
|
LONG XresSetting = 0;
|
|
DeviceProperty.GetCurrentValue(XRESOLUTION,
|
|
XResSetting);
|
|
LONG NewXPos = DeviceAction.Value;
|
|
NewXPos = ((NewXPos * 300) / XResSetting);
|
|
LONG DataLength = 0;
|
|
DataLength = (4 + LEN(STR(NewXPos)));
|
|
DeviceControl.RawWrite(0,CHR(27) +
|
|
"*f" +
|
|
STR(NewXPos) +
|
|
"X",DataLength,100)
|
|
}
|
|
else if(DeviceAction.ValueID == YPOSITION)
|
|
{
|
|
LONG YResSetting = 0;
|
|
DeviceProperty.GetCurrentValue(YRESOLUTION,
|
|
YResSetting);
|
|
LONG NewYPos = DeviceAction.Value;
|
|
NewYPos = ((NewYPos * 300) / YResSetting);
|
|
LONG DataLength = 0;
|
|
DataLength = (4 + LEN(STR(NewYPos)));
|
|
DeviceControl.RawWrite(0,CHR(27) +
|
|
"*f" +
|
|
STR(NewYPos) +
|
|
"Y",DataLength,100)
|
|
}
|
|
else if(DeviceAction.ValueID == XEXTENT)
|
|
{
|
|
LONG XresSetting = 0;
|
|
DeviceProperty.GetCurrentValue(XRESOLUTION,
|
|
XResSetting);
|
|
LONG NewXExt = DeviceAction.Value;
|
|
NewXExt = ((NewXExt * 300) / XResSetting);
|
|
LONG DataLength = 0;
|
|
DataLength = (4 + LEN(STR(NewXExt)));
|
|
DeviceControl.RawWrite(0,CHR(27) +
|
|
"*f" +
|
|
STR(NewXExt) +
|
|
"P",DataLength,100)
|
|
}
|
|
else if(DeviceAction.ValueID == YEXTENT)
|
|
{
|
|
LONG YResSetting = 0;
|
|
DeviceProperty.GetCurrentValue(YRESOLUTION,
|
|
YResSetting);
|
|
LONG NewYExt = DeviceAction.Value;
|
|
NewYExt = ((NewYExt * 300) / YResSetting);
|
|
LONG DataLength = 0;
|
|
DataLength = (4 + LEN(STR(NewYExt)));
|
|
DeviceControl.RawWrite(0,CHR(27) +
|
|
"*f" +
|
|
STR(NewYExt) +
|
|
"Q",DataLength,100)
|
|
}
|
|
else if(DeviceAction.ValueID == DATATYPE)
|
|
{
|
|
if(DeviceAction.Value == 0)
|
|
{
|
|
DeviceControl.RawWrite(0,CHR(27) + "*a0T",5,100);
|
|
DeviceControl.RawWrite(0,CHR(27) + "*a1G",5,100);
|
|
}
|
|
if(DeviceAction.Value == 2)
|
|
{
|
|
DeviceControl.RawWrite(0,CHR(27) + "*a4T",5,100);
|
|
DeviceControl.RawWrite(0,CHR(27) + "*a8G",5,100);
|
|
}
|
|
|
|
if(DeviceAction.Value == 3)
|
|
{
|
|
DeviceControl.RawWrite(0,CHR(27) + "*a5T",5,100);
|
|
DeviceControl.RawWrite(0,CHR(27) + "*a24G",6,100);
|
|
}
|
|
else
|
|
{
|
|
// unsupported data type, FAIL this call
|
|
}
|
|
}
|
|
else if(DeviceAction.ValueID == BRIGHTNESS)
|
|
{
|
|
LONG DataLength = 0;
|
|
DataLength = (4 + LEN(STR(DeviceAction.Value)));
|
|
DeviceControl.RawWrite(0,
|
|
CHR(27) +
|
|
"*a" +
|
|
STR(DeviceAction.Value) +
|
|
"K",DataLength,100)
|
|
}
|
|
else if(DeviceAction.ValueID == CONTRAST)
|
|
{
|
|
LONG DataLength = 0;
|
|
DataLength = (4 + LEN(STR(DeviceAction.Value)));
|
|
DeviceControl.RawWrite(0,
|
|
CHR(27) +
|
|
"*a" +
|
|
STR(DeviceAction.Value) +
|
|
"L",DataLength,100)
|
|
}
|
|
else if(DeviceAction.ValueID == NEGATIVE)
|
|
{
|
|
DeviceControl.RawWrite(0,chr(27) + "*a1I",5,100);
|
|
}
|
|
}
|
|
|
|
// Handle getting a device property
|
|
|
|
else if(DeviceAction.Action == GETVALUE_ID)
|
|
{
|
|
|
|
}
|
|
|
|
// Handle getting a device property
|
|
|
|
else if(DeviceAction.Action == RESETDEVICE_ID)
|
|
{
|
|
|
|
}
|
|
|
|
// Handle starting a scan
|
|
|
|
else if(DeviceAction.Action == SCAN_FIRST_ID)
|
|
{
|
|
DeviceControl.RawWrite(0,CHR(27)+"*f0S",5,100);
|
|
GetDataFromDevice(DeviceAction.Value);
|
|
}
|
|
|
|
// Handle scanning data
|
|
|
|
else if(DeviceAction.Action == SCAN_NEXT_ID)
|
|
{
|
|
GetDataFromDevice(DeviceAction.Value);
|
|
}
|
|
|
|
// Handle finishing a scan
|
|
|
|
else if(DeviceAction.Action == SCANFINISHED_ID)
|
|
{
|
|
DeviceControl.RawWrite(0,CHR(27) + CHR(69),2,100);
|
|
}
|
|
|
|
// Handle canceling a scan
|
|
|
|
else if(DeviceAction.Action == SCAN_CANCEL_ID)
|
|
{
|
|
DeviceControl.RawWrite(0,CHR(27) + CHR(69),2,100);
|
|
}
|
|
|
|
// Handle default case
|
|
|
|
else
|
|
{
|
|
// unknown action ID
|
|
}
|
|
}
|
|
|
|
function BOOL GetDataFromDevice(LONG lBytesToRead)
|
|
{
|
|
LONG lBytesRead = 0;
|
|
LONG lErrorCode = S_OK;
|
|
DeviceControl.ScanRead(0,lBytesToRead,lBytesRead,100);
|
|
lErrorCode = LastError.GetLastError();
|
|
if(lErrorCode == S_OK)
|
|
return TRUE;
|
|
}
|
|
|