Monday, May 24, 2004

Today was spent refactoring the transitive query code for the new syntax. It was looking pretty messy by Friday night, with two methods doing all of the work: resolveTransitiveConstraint() and inferTransitiveStatements(). After the syntax was changed, the former ended up full of if statements trying to handle the separate cases of anchored and unanchored queries, with the result that the code was becoming illegible. This was principally due to the method needing to return a tuples with either 1 or 2 columns depending on whether or not the transitive constraint was anchored.

Today's effort pulled the first method apart into two separate methods: resolveUnanchoredTransitive() and resolveAnchoredTransitive(). These are now significantly simpler. Making all the changes in these methods also allowed inferTransitiveStatements() to remain almost completely unchanged.

The above doesn't look like that much work, and it wasn't. I hadn't checked my email at all over the weekend, and it seemed I had quite a bit to attend to today. Other than the obligatory spam, I also had quite a few questions on RDF stores. This was both internal, and external, and even a few external emails which had been forwarded to me internally. I'm on top of it all now, though it means I have quite a bit of unit testing to attend to tomorrow.

Printer Drivers
Other than familial commitments, one thing keeping me from coding at home over the last few days has been our new printer. It's an Epson Stylus Photo R310. I've been very impressed with it so far when printing via USB from Anne's iBook running OS X. The print quality is superb, and the price of the ink is better than most.

However, configuration of this thing has been driving me crazy.

OS X uses CUPS to print, and the GUI setup was pretty easy to follow. That was good, as it allowed me to check out the resulting text configuration files knowing that they worked. The reason for this was so I could change them to use Bluetooth as the output rather than the USB port, since the printer supports Bluetooth.

CUPS expects to use several filter programs (read from stdin, write to stdout) to process the data appropriately for the printer, and then output it to the correct device. The device to be used is defined in the file /etc/cups/printers.conf with the line DeviceURI. For USB on Linux it might be:
For Bluetooth it could be:
(no, that's not the real address of the printer - I just used a handy Mac address as an example).

The printers.conf file also describes a printer definition file (PPD file) to use for the printer. These are in the /etc/cups/ppd directory. This file describes all the capabilities of the printer, and importantly for CUPS, it also describes the name of the final filter to use to generate instructions for the printer.

CUPS provides an Epson PhotoStylus driver that fits into this system neatly, but it doesn't handle the full resolution of the printer, and it is very slow. I've been able to get this to work on both OS X and on Linux, but the image quality has been disappointing.

Fortunately, Epson themselves provide drivers for this model of printer, in the form of a PPD file and a filter. However, these drivers do not conform to normal CUPS standards, as the filter does no write to stdout. Intead, on OS X it goes straight to the USB port (the DeviceURI line is set to file:///dev/null). This means that on the iBook there is no way to use this driver with the Bluetooth adapter!

Linux is not so bad. Here the filter writes to a pipe via the normal stdout mechanism, and this pipe is then read by a daemon that writes to the USB port. The reason for this is so the daemon can also listen on a network socket for utility programs that want to check ink levels, or other non-standard tasks. This all seems to work fine, except that the filter provided does not work!

Fortunately the filter comes with source code. After spending some time debugging I've been able to work out that it is not reading the PPD file correctly, and it exits accordingly. I don't know anything about the Epson printer control language, so I was grateful to see that the problem is in an area I might be able to fix.

Anyway, time has been a precious commodity around here lately, so I haven't finished looking at this yet. I'll spend a little time on it tonight, before getting back to JRDF.

No comments: