//--------------------------------------------------------------------// // M e t h o d // // s e n d R e q u e s t // //--------------------------------------------------------------------// // // // Send previously generated request data to target. // // // //--------------------------------------------------------------------// public static void sendRequest(PJLCommands.eCmdIndex cmdIndx) { PJLCommands.eRequestType reqType = PJLCommands.getType(cmdIndx); if ((reqType == PJLCommands.eRequestType.FSDirList) || (reqType == PJLCommands.eRequestType.FSQuery)) { //------------------------------------------------------------// // // // PJL FileSystem query; request types: // // - FSDIRLIST // // - FSQUERY // // Response from printer expected. // // // //------------------------------------------------------------// TargetCore.requestStreamWrite(true); } else if (reqType == PJLCommands.eRequestType.FSUpload) { //------------------------------------------------------------// // // // PJL FileSystem upload to host workstation; request types: // // - FSUPLOAD // // Response from printer expected - write this direct to the // // target file (it could be (much) larger than standard reply // // buffer. // // // //------------------------------------------------------------// TargetCore.requestStreamWrite(true); } else { //------------------------------------------------------------// // // // PJL FileSystem action; request types: // // - FSAPPEND // // - FSDELETE // // - FSDOWNLOAD // // - FSINIT // // - FSMDKIR // // Response from printer not expected. // // // //------------------------------------------------------------// TargetCore.requestStreamWrite(false); } }
//--------------------------------------------------------------------// // M e t h o d // // r e a d R e s p o n s e // //--------------------------------------------------------------------// // // // Read response from target. // // // //--------------------------------------------------------------------// public static String readResponse( PJLCommands.eCmdIndex cmdIndx, String binTgtFilenamePJLFS) { PJLCommands.eRequestType reqType = PJLCommands.getType(cmdIndx); if ((reqType == PJLCommands.eRequestType.FSDirList) || (reqType == PJLCommands.eRequestType.FSQuery)) { //------------------------------------------------------------// // // // PJL FileSystem query; request types: // // - FSDIRLIST // // - FSQUERY // // Response from printer expected. // // // //------------------------------------------------------------// return(readResponseQuery()); } else if (reqType == PJLCommands.eRequestType.FSUpload) { //------------------------------------------------------------// // // // PJL FileSystem upload; request types: // // - FSUPLOAD // // // //------------------------------------------------------------// return(readResponseUpload(binTgtFilenamePJLFS)); } else { //------------------------------------------------------------// // // // PJL FileSystem action; request types: // // - FSAPPEND // // - FSDELETE // // - FSDOWNLOAD // // - FSINIT // // - FSMDKIR // // Response from printer not expected. // // // //------------------------------------------------------------// return("No response is expected from the " + PJLCommands.getName(cmdIndx) + " action command"); } }
//--------------------------------------------------------------------// // C o n s t r u c t o r // // P J L C o m m a n d // // // //--------------------------------------------------------------------// public PJLCommand(PJLCommands.eCmdIndex indx, PJLCommands.eCmdFormat format, PJLCommands.eRequestType type, String desc) { if (indx == PJLCommands.eCmdIndex.Null) { _cmdName = PJLCommands.nullCmdKey; } else { _cmdName = indx.ToString(); } _cmdDesc = desc; _cmdFormat = format; _reqType = type; _statsCtParent = 0; _statsCtChild = 0; }
//--------------------------------------------------------------------// // M e t h o d // // g e n e r a t e R e q u e s t // //--------------------------------------------------------------------// // // // Generate status readback request data. // // // //--------------------------------------------------------------------// public static void generateRequest(BinaryWriter prnWriter, PJLCommands.eCmdIndex cmdIndx, Int32 indexCategory, Int32 indexVariable, String customCat, String customVar) { String seq; if (cmdIndx != PJLCommands.eCmdIndex.Unknown) { PJLCommands.eRequestType reqType; String cmdName; reqType = PJLCommands.getType(cmdIndx); cmdName = PJLCommands.getName(cmdIndx); if (reqType == PJLCommands.eRequestType.Category) { if (indexCategory < PJLCategories.getCount()) { if (PJLCategories.getType(indexCategory) == PJLCategories.eCategoryType.Custom) { seq = "\x1b" + "%-12345X" + "@PJL ECHO PCLParaphernalia" + "\x0d\x0a" + "@PJL " + cmdName + " " + customCat + "\x0d\x0a" + "\x1b" + "%-12345X"; } else { String categoryName; categoryName = PJLCategories.getName(indexCategory); seq = "\x1b" + "%-12345X" + "@PJL ECHO PCLParaphernalia" + "\x0d\x0a" + "@PJL " + cmdName + " " + categoryName + "\x0d\x0a" + "\x1b" + "%-12345X"; } prnWriter.Write(seq.ToCharArray(), 0, seq.Length); } } else { if (indexVariable < PJLVariables.getCount()) { PJLVariables.eVarType varType; varType = PJLVariables.getType(indexVariable); if (varType == PJLVariables.eVarType.Custom) { seq = "\x1b" + "%-12345X" + "@PJL ECHO PCLParaphernalia" + "\x0d\x0a" + "@PJL " + cmdName + " " + customVar + "\x0d\x0a" + "\x1b" + "%-12345X"; } else { String variableName; String personality; variableName = PJLVariables.getName(indexVariable); if (varType == PJLVariables.eVarType.PCL) { personality = "LPARM : PCL "; } else if (varType == PJLVariables.eVarType.PDF) { personality = "LPARM : PDF "; } else if (varType == PJLVariables.eVarType.PS) { personality = "LPARM : POSTSCRIPT "; } else { personality = ""; } seq = "\x1b" + "%-12345X" + "@PJL ECHO PCLParaphernalia" + "\x0d\x0a" + "@PJL " + cmdName + " " + personality + variableName + "\x0d\x0a" + "\x1b" + "%-12345X"; } prnWriter.Write(seq.ToCharArray(), 0, seq.Length); } } } }
//--------------------------------------------------------------------// // M e t h o d // // g e n e r a t e R e q u e s t // //--------------------------------------------------------------------// // // // Generate file system command data. // // // //--------------------------------------------------------------------// public static void generateRequest(BinaryWriter prnWriter, PJLCommands.eCmdIndex cmdIndx, Boolean secJob, String password, String pathname, String binSrcFilename, Int32 option1, Int32 option2) { String seq; String jobHddr; String jobEnd; if (cmdIndx != PJLCommands.eCmdIndex.Unknown) { PJLCommands.eRequestType reqType; String cmdName; reqType = PJLCommands.getType(cmdIndx); cmdName = PJLCommands.getName(cmdIndx); if (secJob) { jobHddr = "\x1b" + "%-12345X" + "@PJL JOB PASSWORD="******"\x0d\x0a"; jobEnd = "\x1b" + "%-12345X"; } else { jobHddr = "\x1b" + "%-12345X"; jobEnd = "\x1b" + "%-12345X"; } if (reqType == PJLCommands.eRequestType.FSBinSrc) { Boolean OK = true; Int64 fileSize = 0; OK = binSrcFileOpen(binSrcFilename, ref fileSize); if (OK) { seq = jobHddr + "@PJL " + cmdName + " FORMAT:BINARY SIZE=" + fileSize.ToString() + " NAME=" + '"' + pathname + '"' + "\x0d\x0a"; prnWriter.Write(seq.ToCharArray(), 0, seq.Length); // Read and send content of binSrcFilename binSrcFileCopy(prnWriter); binSrcFileClose(); // terminate job with UEL prnWriter.Write(jobEnd.ToCharArray(), 0, jobEnd.Length); } } else if (reqType == PJLCommands.eRequestType.FSDirList) { seq = jobHddr + "@PJL " + cmdName + " NAME=" + '"' + pathname + '"' + " ENTRY=" + option2.ToString() + " COUNT=" + option1.ToString() + "\x0d\x0a" + jobEnd; prnWriter.Write(seq.ToCharArray(), 0, seq.Length); } else if (reqType == PJLCommands.eRequestType.FSInit) { seq = jobHddr + "@PJL " + cmdName + " VOLUME=" + '"' + pathname + '"' + "\x0d\x0a" + jobEnd; prnWriter.Write(seq.ToCharArray(), 0, seq.Length); } else if (reqType == PJLCommands.eRequestType.FSUpload) { seq = jobHddr + "@PJL " + cmdName + " NAME=" + '"' + pathname + '"' + " OFFSET=" + option2.ToString() + " SIZE=" + option1.ToString() + "\x0d\x0a" + jobEnd; prnWriter.Write(seq.ToCharArray(), 0, seq.Length); } else { seq = jobHddr + "@PJL " + cmdName + " NAME=" + '"' + pathname + '"' + "\x0d\x0a" + jobEnd; prnWriter.Write(seq.ToCharArray(), 0, seq.Length); } } }