Ticket #11 (accepted enhancement)

Opened 16 years ago

Last modified 14 years ago

Add a minimal cost per page when using ink accounting

Reported by: jerome Owned by: jerome
Priority: minor Milestone: 1.27 final
Component: pykota Version: development
Keywords: Cc:

Description

With ink accounting almost empty sheets are accounted for almost no credits. A base price per page could be used to set a minimum. Alternatively, the actual computation formula could be modified.

Attachments

PyKotaPrinterCostsCalculator.ods (14.3 kB) - added by jerome 14 years ago.
pkpgcounter-mediawork.patch (13.3 kB) - added by jerome 14 years ago.
Patch for pkpgcounter to extract additional informations from print jobs
pykota-costing-rework.patch (23.0 kB) - added by jerome 14 years ago.
Patch to improve the computation of a print job's cost.

Change History

Changed 14 years ago by jerome

  • status changed from new to accepted
  • milestone set to 1.27 final

Trever L. Adams contributed big patches to improve the situation.

Changed 14 years ago by jerome

Changed 14 years ago by jerome

Patch for pkpgcounter to extract additional informations from print jobs

Changed 14 years ago by jerome

Patch to improve the computation of a print job's cost.

Changed 14 years ago by jerome

Trever wrote :

I have these patches working here for my printers. These do have some dead code removal. The
+following configuration is part of what is working here.

[general]
default_media_type = Plain
default_media_size = Letter

mediacost_Plain_Letter = 0.00719800000000000000

[HPLJ6MP]
impression_cost = 0.001
inkcost_black = 0.45495000000000000000
preaccounter : media(ink, bw, 72)
accounter : media(ink, bw, 72)

I have also used the cmyk. If you don't want ink accounting, set the it to media(none)

Changes Needed in Configurations:
coefficient_ -> inkcost_ and changes to amount in money (0.01 for 1 cent
at 100% coverage)

default_media_size = Plain
default_media_type = Letter

impression_cost = money

mediacost_Type_Size = money
mediacost_Plain_Letter = 0.01
mediacost_default can also be set, but is unneeded if you set the
defaults for media and have the right mediacost_Type_Size setup.

Attached is a spreadsheet that will help you figure out the costs, it can be distributed with
+PyKota. This is based on a real printer. Hopefully you see that the impressions_cost are fixed
+costs per page. Mediacost is the paper. inkcost is variable and unless in comparing
+color/blackwhite for the ink, it scales with paper size.

This is only implemented for Postscript. Those knowing PCL, et al, should be able to add them
+quickly as the function is simple. Duplexing appears to be working for Postscript. I haven't messed
+with it much yet.

Pagecost should go away in all configuration and code. NOTICE: I have made no changes to the
+configuration costs nor the various backends.
Jobcost is currently not computed/added to the totalprice. I think this should be an option similar
+to those above in nature; not as it currently is as a required part of the printer definition. It
+should be added always, set to 0.0 by default.

Other than a bit of the configuration utils (page cost, job cost) I believe all utilities should
+remain working just fine. I haven't messed with the CGI yet. pkinvoice works fine.

Changed 14 years ago by jerome

Once again, Trever wrote :

Hello everyone,

I was just reviewing the pcl345 and pcxl files. Other than a few small
changes, being:
Y/N instead of Duplex/Simplex
and an appropriate version of (which could do the translation mentioned
above):
    def getMediaFormat(self) :
        """Discover media fomats/sizes in PostScript document."""
        result = []
        self.copies = 1
        (nbpages, notrust, pages) = self.natively()
        for k in pages :
            if k > 0 :
                if pages[k]["duplex"] == "Duplex" or pages[k]["duplex"]
== 1 :
                               pages[k]["duplex"] = "Y"
                else :
                               pages[k]["duplex"] = "N"
                result.append({"MT" : pages[k]["mediatype"],
                               "MS" : pages[k]["mediasize"],
                               "DU" : pages[k]["duplex"],
                              })
        return ((["MT", "MS", "DU"]), result)

and having an appropriate getJobSize used instead of self.natively above
which returns self.pages as the third return (second since they don't
use notrust), they are completely compatible with my costing stuff. It
seems the pcl345 or pclxl may use mediaduplex instead of duplex in a way
that would work above. A quick and dirty if above was included to
translate to Y/N from other duplex values.

Those such as escp2 which do not return enough data, should probably
have the following function:
    def getMediaFormat(self) :
        """Discover media fomats/sizes in PostScript document."""
        result = []
        self.copies = 1
        nbpages = self.getJobSize
        envdm = pjlparser.environment_variables.get("DUPLEX", "")
        if envdm :
               if envdm.upper() == "ON" :
                        duplexmode = "Y"
               else :
                        duplexmode = "N"
               envps = pjlparser.environment_variables.get("PAPER", "")
               if envps :
                        papersize = envps
               else :
                        papersize = "Default"
        for k in pages :
            if k > 0 :
                result.append({"MT" :  "Plain",
                               "MS" : papersize,
                               "DU" : "N",
                              })
        return ((["MT", "MS", "DU"]), result)

or whatever the CUPS environment variables say. If they can provide such
information, we may or may not want to extend them, but the above works
for now. I think that the right answer is to use the CUPS environment
variables for now on anything that doesn't supply such information, or
that we haven't already coded for, such as the above has. I do not know
if there is an environment variable for mediatype. Trying to find it in
the cups documentation for 1.4 seems to suggest that PAPER and DUPLEX
aren't there either.

One caveat on PCL345/PCLXL, Duplex needs to be on the FIRST page in the
set to be duplexed, not the second. Now, if the language, such as
postscript allows pages to say duplex me with following if you can, that
is handled properly. If PCL has the duplex code on the second size of a
sheet, then there needs to be a -1 index correction.
Hopefully this will help move things along.

Thank you,
Trever

P.S.

In pclxl.py around line 670:
                defaultps = pjlparser.default_variables.get("PAPER", "")
                if defaultps :
                    defaultpapersize = defaultps
                envps = pjlparser.environment_variables.get("PAPER", "")
                if envps :
                    papersize = envps
                else :
                    if not oldpapersize :
                        papersize = defaultpapersize
                    else :
                        papersize = oldpapersize

change envps = pjlparser.environment_variables.get("PAPER", "") to envps
= defaultps. If python will allow it all to still work, you save a
system call.
Note: See TracTickets for help on using tickets.