#!/bin/sh

echo "$0 may take a very long time to complete.  Please wait..."

passes='1,1,1 2,1,1 1,2,1 1,2,2 1,4,1 4,1,1 4,2,1 2,2,1 1,4,2 2,2,2 2,4,2 8,1,1'

# All numbers of jets used by any printer.
jets='1 2 4 8 15 20 21 24 32 47 48 59 60 64 90 96 128 144 180 192 208 360'

# All nozzle separations used by any printer at any resolution.
separations='1 2 3 4 6 8 12 16'

# Weave strategies
strategies='0 1 2 3 4'
# Strategy 5 is currently broken
#strategies='5'

# Color head arrangement (for offset-head printers such as the Epson C80)
arrangements='0 1'

# Set to the largest possible multiple of the number of heads and
# the nozzle separation.  At present, the PM-970C has 360 heads spaced
# 1/360" apart, with a maximum resolution of 2880x2880.  There's no
# point right now in testing anything higher than this, and it's very
# time consuming.
head_limit=2880

if [ $# -eq 0 ] ; then
    QUIET=1
    export QUIET
fi

# For valgrind use, use
# valgrind --partial-loads-ok=no --num-callers=50 --leak-check=yes
#
# and use these suppressions:
#
#{
#   gettext
#   Addr4
#   fun:__dcigettext
#   fun:__dcgettext
#}
#
#{
#   nl_load_locale
#   Addr4
#   fun:_nl_load_locale
#   fun:_nl_find_locale
#   fun:setlocale
#}
#
#{
#   setlocale
#   Addr4
#   fun:setlocale
#}
#
#{
#   c_strlen
#   Addr4
#   fun:c_strlen
#}

(
for strategy in $strategies ; do
    for jet in $jets ; do
	for sep in $separations ; do
	    start=`expr $jet \* $sep`
	    if [ $start -le $head_limit ] ; then
		rows=`expr $start \* 5`
		if [ $rows -lt 200 ] ; then
		    rows=200
		fi
		s1=`expr $start - 1`
		for f in 0 41 $start $s1 ; do
		    end=`expr $rows + $f + $start`
		    end1=`expr $rows + $f`
		    end2=`expr $rows + $f + 35`
		    for g in $end $end1 $end2 ; do
			for pass in $passes ; do
			    for arrangement in $arrangements; do
				echo "$jet $sep $pass $rows $f $g $arrangement $strategy"
			    done
			done
		    done
		done
	    fi
	done
    done
done) | sed 's/,/ /g' | ./escp2-weavetest
