// // Copyright (c) Eastman Kodak Company. All rights reserved. // // Purpose: // // USB Bidi JavaScript Extension File for Kodak AiO OPL Devices. // function sendCommand(strQuery, printerStream) { var strRead = ""; var bufWrite = []; var i = 0; for (i = 0; i < strQuery.length; i++) { bufWrite.push(strQuery.charCodeAt(i)); } bufWrite = bufWrite.concat(0x3F); // add ? var nBytesWritten = printerStream.write(bufWrite); if (nBytesWritten === bufWrite.length) { var bufRead = printerStream.read(4097); var nBytesRead = bufRead.length; for (i = 0; (nBytesRead > 0) && (i < nBytesRead); i++) { strRead += String.fromCharCode(bufRead.shift()); } } return strRead; } function setSchemaResponse(strRead, printerBidiSchemaResponses) { if (strRead.length > 0) { var strResponseDuplexInstalled = "DeviceSettings.System.Configuration.DuplexerInstalled=YES"; var strResponseDuplexNotInstalled = "DeviceSettings.System.Configuration.DuplexerInstalled=NO"; var strResponseInputTray1PositionControlInstalled = "DeviceCapabilities.MechConfig.InputTray1PositionControl=Auto"; var strResponseInputTray2PositionControlInstalled = "DeviceCapabilities.MechConfig.InputTray2PositionControl=Auto"; var strResponseInputTray3PositionControlInstalled = "DeviceCapabilities.MechConfig.InputTray3PositionControl=Auto"; var strResponseInputTray1PlainPaperCapacityInstalled = "DeviceCapabilities.MechConfig.InputTray1PlainPaperCapacity=40"; var strResponseInputTray2PlainPaperCapacityInstalled = "DeviceCapabilities.MechConfig.InputTray2PlainPaperCapacity=40"; var strResponseInputTray3PlainPaperCapacityInstalled = "DeviceCapabilities.MechConfig.InputTray3PlainPaperCapacity=40"; if (strRead.indexOf(strResponseDuplexInstalled, 0) >= 0) { printerBidiSchemaResponses.addBool("\\Printer.Configuration.DuplexUnit:Installed", true); } else if (strRead.indexOf(strResponseDuplexNotInstalled, 0) >= 0) { printerBidiSchemaResponses.addBool("\\Printer.Configuration.DuplexUnit:Installed", false); } var bPhotoTrayInstalled = false; if (strRead.indexOf(strResponseInputTray2PositionControlInstalled, 0) >= 0) { bPhotoTrayInstalled = true; printerBidiSchemaResponses.addBool("\\Printer.Configuration.PhotoTray:Installed", true); } else if (strRead.indexOf(strResponseInputTray3PositionControlInstalled, 0) >= 0) { bPhotoTrayInstalled = true; printerBidiSchemaResponses.addBool("\\Printer.Configuration.PhotoTray:Installed", true); } else if (strRead.indexOf(strResponseInputTray1PositionControlInstalled, 0) >= 0) { bPhotoTrayInstalled = true; printerBidiSchemaResponses.addBool("\\Printer.Configuration.PhotoTray:Installed", true); } if (bPhotoTrayInstalled === false) { if (strRead.indexOf(strResponseInputTray2PlainPaperCapacityInstalled, 0) >= 0) { bPhotoTrayInstalled = true; printerBidiSchemaResponses.addBool("\\Printer.Configuration.PhotoTray:Installed", true); } else if (strRead.indexOf(strResponseInputTray3PlainPaperCapacityInstalled, 0) >= 0) { bPhotoTrayInstalled = true; printerBidiSchemaResponses.addBool("\\Printer.Configuration.PhotoTray:Installed", true); } else if (strRead.indexOf(strResponseInputTray1PlainPaperCapacityInstalled, 0) >= 0) { bPhotoTrayInstalled = true; printerBidiSchemaResponses.addBool("\\Printer.Configuration.PhotoTray:Installed", true); } } if (bPhotoTrayInstalled === false) { printerBidiSchemaResponses.addBool("\\Printer.Configuration.PhotoTray:Installed", false); } } } /// Get the requested Schema(s) /// /// @param driverProperties - Placeholder: IPrinterScriptablePropertyBag for printer driver properties /// @param printerStream - Allows the script to Write/Read data from the attached USB device /// @param schemaRequests - Contains all the requested Query Keys. /// @param printerBidiSchemaResponses - Object the script will use to store all responses to query keys /// /// The script can use the schemaRequests object to iterate through the Query Keys requested by the user. Based on the query keys /// the script should use the printerStream object to communicate with the USB print device and determine the values of one or more Bidi /// Schema elements. For each Bidi Schema element the new value can be returned to the caller by using functions of the printerBidiSchemaResponses /// object. Once all query keys have been processed and all values added to the printerBidiSchemaResponses object the script can return /// function getSchemas(driverProperties, printerStream, schemaRequests, printerBidiSchemaResponses) { var nReturnValue = 0; if (printerStream === null || schemaRequests === null || printerBidiSchemaResponses === null) { return nReturnValue; } var index = 0; for (index = 0; index < schemaRequests.length; index++) { var strKey = schemaRequests[index]; if (strKey === "Configuration") { var strQueryDuplex = "DeviceSettings.System.Configuration.DuplexerInstalled"; var strQueryMechConfig = "DeviceCapabilities.MechConfig"; var strRead = sendCommand(strQueryDuplex, printerStream); setSchemaResponse(strRead, printerBidiSchemaResponses); strRead = ""; strRead = sendCommand(strQueryMechConfig, printerStream); setSchemaResponse(strRead, printerBidiSchemaResponses); } } return nReturnValue; } /// /// Set a requested Bidi Schema Value in the device /// /// @param driverProperties - Placeholder: IPrinterScriptablePropertyBag for printer driver properties /// @param printerStream - Allows the script to Write/Read data from the attached USB device /// @param printerBidiSchemaElement - Contains all the data associated with the Bidi Schema Value to set /// /// The script can interpret the incoming Bidi Schema value to either set data in the device or perform an action on the device. /// function setSchema(driverProperties, printerStream, printerBidiSchemaElement) { var nReturnValue = 0; return nReturnValue; } /// /// Retrieve unsolicited Bidi Schema value updates from the USB device during printing /// /// @param printerStream - Allows the script to Write/Read data from the attached USB device /// @param printerBidiSchemaResponses - Object the script will use to store all responses to query keys /// /// This function is only called when a job is printing. /// function getStatus(driverProperties, printerStream, printerBidiSchemaResponses) { var nReturnValue = 0; return nReturnValue; }