There are several requirements for this:

  1. Printing once per day
  2. Printing every X minutes
  3. printing X mins after the last job arrived
  4. Printing any other time interval, longer then a day.
  5. etc.

And as well, there are several solutions for this issue:

  1. Using the Windows Queue time based printing possibilities
  2. Using the MS DOS command AT (Windows 7)
  3. Using the Windows Scheduler SCHTASKS.EXE (Windows 8 or newer)

Printing once per day (Windows platform)

This can be handled with MS Windows standard Queue settings:

Open the properties of the queue, switch to the enhanced tab and enter the start and end time for printing. ELP can send the jobs to that queue using the outport or the CALL command.

Theory of printing any time

All following time based samples do have this in in common:

  1. The print files need to be stored somewhere in an archive directory and
  2. They are most likely copied with a MS DOS batch file or Linux Shell-Script to the destination queue. Here is an easy batch file content, which can be generated with any ASCII editor like Notepad++;:

    Content of file MyCopy.bat Command description
    c: change to volume where the archive files are located
    cd c:\ProgramData\Welp\archive change prompt to the directory containing the archived files
    copy /b invoice*.* \\127.0.0.1\QueueShareName

    send all files of the folder in one(!) file to the windows queue on the same PC
    Notes:

    • If you need single files (Each archived file as one job) then use this command:
      FOR %%i in (invoice*.*) do cmd /c copy /b "%%i" \\127.0.0.1\Sharename
    • If you need all files, simply remove the word invoice, also in the next command
    • You may use any other command line utility for sending or moving or copying the files
      FOR %%i in (invoice*.*) do lpr -S 127.0.0.1 -P SharedPort "%%i"
    del /Q invoice*.* Delete all copied files with the file name starting invoice (the parameter /Q avoids a confirmation prompt)
  3. Now use the scheduler of your choice and call this batch file at the needed time. If needed nail down rules to the receiving queue or call just another iniFile for all jobs coming into that queue. Example 2

Instead of using a batch file a DOS echo command can send a test to an ELP activated queue, which then prints all files. See sample Example: MyPrintArchive - Collect4Printing

The extended example: Our application sends X jobs, we want to collect them all and print them in one job, so that nobody else can interfere with his job.

The theory of the implementation:

This configuration fixes the problem, that the application sends 1000s of small jobs to the printer, which unfortunately needs a big initialization time between each job. So the over all printing speed went down.

With the following configuration the printer starts printing all jobs together at full speed, latest 3 minutes after the last job arrived.

Here the convert.ini:

[Global]

; Any of your stuff

VARIABLE=MyConversion:Not Available

; store the actual minutes to the variable: MyStartMin

Variable=#MyHelpVar#:LEFT(#ACTTIME#,5)
Variable=MyStartMin:RIGHT(#MyHelpVar#,2)

; store the actual Hour to the variable: MyStartStd

Variable=MyStartStd:LEFT(#ACTTIME#,2)

; Reset the temp variable to 0 seconds

Variable=MyHelpVar:0

SetTrigger=1:ON

[This data stream was the collected resend one]

; When this trigger statement was found in the stream (right at the beginning)

Search_Binary=%-12345X@PJL SET COMMENT="2nd run"

; then pass the job through and exit the rule interpretation

PassThrough=ON
EXIT=ON

 

; **********
; Those rules are processed after the job was completely read into the process.
; All the primary rules below gets always true, because of TRIGGER_BINARY=!

[Increase now the Minutes by 2 minutes]

; As the printing should start max 3 mins after the last job arrived

Trigger_Binary=1

; routine only valid up to a wait time of 59 minutes!

Counter=#MyStartMin#;+2

[Check if minutes go over the hour]

Trigger_Binary=1
Trigger_Variable=#MyStartMin#>59

; then reduce it by 59 seconds

Counter=#MyStartMin#;+2

; and add one hour

Counter=#MyStartStd#

[Check if hour goes over 23]

Trigger_Binary=1
Trigger_Variable=#MyStartStd#>23

; set to after midnight

Variable=#MyStartStd#:00

[Store the job and set the timer]

; As the printing should start max 3 mins after the last job arrived

Trigger_Binary=1

; Store the file to the archive

OutArchiveDir=#ELP_FORMS_PATH#Archive;#DATESERIAL#

; do not print anything

NoPrinting=ON

; Store the file to the archive

OutArchiveDir=#ELP_FORMS_PATH#Archive;#DATESERIAL#

; and call the batch file SetTime.bat with those arguments:
; 1. Time when timer should start #MyStartStd#:#MyStartMin#
; 2. Which software the timer shall call #ELP_FORMS_PATH#DoAt.bat
; 3. For reprinting the path to the Workpath folder #ELP_FORMS_PATH#
; 4. To which \\server\Queue the jobs shall be sent as one print job #PRINTERSHARENAME#

call=#ELP_FORMS_PATH#SetTime.bat "#MyStartStd#:#MyStartMin#" "#ELP_FORMS_PATH#DoAt.bat" "#ELP_FORMS_PATH#" \\127.0.0.1\#PRINTERSHARENAME#;OFF

So the batch file SetTime.bat in the Workpath folder (default c:\ProgramData\Welp) is in charge of setting the new timer time. Here the content of the file SetTime.bat:

echo "Time passed in" %1
echo "batchfile to be called after time is reached" %2
echo "Where are my data" %3
echo "Where to send the collected streams" %4
REM Delete the actual timer setting of timer 1
AT 1 /DELETE
REM Set the new timer time program operand1 operand2
AT %1 %2 %3 %4

On Windows 10 or newer the AT command does not work anymore. So you need to use the task scheduler SCHTASKS.EXE instead. The batch file SetTime.bat needs to look like this:

SCHTASKS /DELETE /TN "ELPTASK" /F
SCHTASKS /CREATE /TN "ELPTASK" /TR "cmd /c '%2 %3 %4" /SC ONCE /ST %1

In other words, this DOS Command file does

  1. delete a possible existing timer from last job
  2. set the timer, so that
    - after the time is reached (#MyStartStd#:#MyStartMin# e.g. 12:45)
    - the software #ELP_FORMS_PATH#DoAt.bat is called
    - with the 2 additional parameters of where to copy the collected data streams form #ELP_FORMS_PATH# (Workpath folder c:\ProgramData\Welp, the additional subfolder is added in batch file)
    - and where the files are sent to, actually the same queue: #PRINTERSHARENAME# (e.g. \\127.0.0.1\ELP_Out)

And the second batch file #ELP_FORMS_PATH#DoAt.bat which is called by the DOS AT command or SCHTASKS: DoAt.bat

echo "Start Path for archived files " %1
echo "Port to be sent" %2
rem init.pcl contains the differentiator for standard print files and final prints
copy /b %1init.pcl+%1archive\*.* %2
rem delete the stored files.
del /Q %1archive\*.*

Finally the content of the init.pcl file also stored at #ELP_FORMS_PATH#:

\x1B%-12345X @PJL SET COMMENT="2nd run"
\x1B%-12345X

The copy comand of DoAt.bat copies that file in front of the data stream. The file holds valid PJL commands, but does actually do nothing. The comment text is used to by the ELP rules, to identify the collected print job, that it is passed through and not again stored. Please generate that job also with Notepad++. The Escape signs (\x1B) can be entered by holding down the ALT key and entering on the num pad 027.


Testing the configuration (with the AT command. For Windows 10 and newer please use the SCHTASKS commands like described above):

    1. After the first job is sent, check the c:\ProgramData\Welp\archive folder if a file was stored
    2. Open a DOS Box and start the command AT (the content should be pretty similar)

      at
      Status. Day Time Command
      -------------------------------------------------------------------------------
      1 Today 09:47 c:\ProgramData\Welp\DoAt.bat c:\ProgramData\Welp\ \\127.0.0.1\ELP_OUT
    3. If you like you can delete that timer. Any way, sending a second job does resset the timer

      AT 1 /delete
    4. The files should be printed after the time was reached. If not here is how to debug the solution:

      4.1 check first if the AT command still has a Job with the ID 1. If yes, the timer did not start yet.

      4.2 If gone, then try to initalize the timer event by hand, it is the eaxct same command as the timer showed:

      #ELP_FORMS_PATH#DoAt.bat c:\ProgramData\Welp\ \\127.0.0.1\ELP_OUT

      Any error should be now displayed in the DOS box.
    5. Sometimes MS Windows can't handle the localhost IP 127.0.0.1. Then please change in the convert.ini the last argument of the call key the 127.0.01 with the real server name or with the variable #HOSTNAME#.
    6. Of course the queue needs to be shared!

Addon: Maybe in addition you whish to print always when X jobs have arrived. Those modifications need to be done:

[Global]

; Add to the AS400in rule section this line:

JobCounter=#ELP_FORMS_PATH#job_counter.var

Generate a new rule

[On every 50th job]

Trigger_Binary=1

; Primary trigger, which comes for all jobs true

Trigger_Variable=#JOB_COUNTER#:50
CloseArchivesBeforeCall=ON
Call=#ELP_FORMS_PATH#DoAt.bat "#ELP_FORMS_PATH#" \\127.0.0.1\#PRINTERSHARENAME#;OFF

And finally add to the DoAt.bat batch file the command for erasing the job_counter file:
del /Q %1job_counter.var

 

Related articles: Collection small single jobs to eliminate the printer job setup time