1 # -*- coding: utf-8 -*-
3 # (c) Copyright 2003-2007 Hewlett-Packard Development Company, L.P.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 PJL_ENTER_LANG = "@PJL ENTER LANGUAGE=PCL3GUI\n"
33 PJL_BEGIN_JOB = '@PJL JOB NAME="unnamed"\n'
34 PJL_END_JOB = '@PJL EOJ\n'
36 def buildPCLCmd(punc, letter1, letter2, data=None, value=None):
38 return ''.join([ESC, punc, letter1, str(value), letter2])
40 return ''.join([ESC, punc, letter1, str(len(data)), letter2, data])
43 def buildEmbeddedPML(pml):
44 return ''.join([UEL, PJL_ENTER_LANG, RESET, pml, RESET, UEL])
47 def buildEmbeddedPML2(pml):
48 return ''.join([RESET, UEL, PJL_BEGIN_JOB, PJL_ENTER_LANG, RESET, pml, RESET, PJL_END_JOB, RESET, UEL])
51 def buildDynamicCounter(counter):
52 #return ''.join([UEL, PJL_ENTER_LANG, ESC, '*o5W\xc0\x01', struct.pack(">I", counter)[1:], UEL])
53 return ''.join([UEL, PJL_ENTER_LANG, ESC, '*o5W\xc0\x01', struct.pack(">I", counter)[1:], PJL_END_JOB, UEL])
55 def buildRP(a, b, c, d, e):
56 return ''.join(['\x00'*600, RESET, UEL, PJL_ENTER_LANG, buildPCLCmd('&', 'b', 'W', pml.buildEmbeddedPMLSetPacket('1.1.1.36', a + b + c + d + e, pml.TYPE_STRING)), RESET, UEL])