Hello every body, I'm new on Processing and i've a problem with a sketch which was given to me. In short, i want to control many printers with processing. So i sent from a max patch two kind of osc message, one for say which image Processing has to charge and the second one for say on which printer it has to use for print. the first message reception is good and processing charge correctly all my image but for the second one processing send a message of error type:
ERROR @ OscP5 ERROR. an error occured while forwarding
an OscMessage
to a method in your program. please check your code for any
possible errors that might occur in the method where incoming
OscMessages are parsed e.g. check for casting errors, possible
when i desactivate one line which is // setPrinter(printerId)
it works correctly but prints only on the default printer...
(this line is on the second point allmost at the end and is now desactivate.)
But I don't manage to find what is the probleme in this fonction....
I send you the three sketchs and thank you for your help...
thank you A LOT.
// INITIALISATION DES RESSOURCES void setup() { size(420, 595);
/* create a new instance of oscP5. * 11000 is the port number you are listening for incoming osc messages. */ oscP5 = new OscP5(this,11000);
imageChargee = false;
printersList(); }
// EXECUTION void draw() { background(255, 0, 0);
if (imageChargee) image(b, 0, 0); }
/** * oscP5broadcastClient by andreas schlegel * an osc broadcast client. * an example for broadcast server is located in the oscP5broadcaster exmaple. * oscP5 website at http://www.sojamo.de/oscP5 */ import oscP5.*; import netP5.*;
OscP5 oscP5;
/* a NetAddress contains the ip address and port number of a remote location in the network. */ NetAddress myBroadcastLocation;
/* create a new instance of oscP5. * 11000 is the port number you are listening for incoming osc messages. */ int myListeningPort = 11000;
/* incoming osc message are forwarded to the oscEvent method. */ void oscEvent(OscMessage theOscMessage) {
/* get and print the address pattern and the typetag of the received OscMessage */ theOscMessage.print();
// si nous reçevons un message avec un identifiant "/image" if (theOscMessage.checkAddrPattern("/image") == true) {
// si nous reçevons dans ce message un symbol (le nom de l'image) if (theOscMessage.checkTypetag("s")) {
// Images must be in the "data" directory to load correctly b = loadImage(nomImage); // ex : monImage-1.jpg
imageChargee = true; } } // sinon, si nous reçevons un message avec un identifiant "/imprime" else if (theOscMessage.checkAddrPattern("/imprime") == true) {
// si nous reçevons dans ce message un int (le numéro d'imprimante) if (theOscMessage.checkTypetag("i")) {
int printerId = theOscMessage.get(0).intValue();
//setPrinter(printerId);
delay(1000);
printStage();
delay(5000); } } }
PrinterJob job;
// called by the main code to start a new print job as a thread void printStageThreaded() {
// Create an object that will hold all print parameters, such as // page size, printer resolution. In addition, it manages the print // process (job). job = PrinterJob.getPrinterJob();
Runnable printRunner = new Runnable() { public void run() { handlePrint(); } }; javax.swing.SwingUtilities.invokeLater(printRunner); }
// called by the main code to start a new print job void printStage() {
// Create an object that will hold all print parameters, such as // page size, printer resolution. In addition, it manages the print // process (job). job = PrinterJob.getPrinterJob(); handlePrint(); }
// called by printThread to set the print job for the stage. void handlePrint() {