Friday, September 18, 2009

Pos .Net Series, Post #8 – How Can I Create My Own Service Object ?




The first thing you should be asking yourself, is do I really need to ?

There are times when you do need to write your own service object;

    You’re an independent hardware vendor and want to make your device OPOS compatible.

    You want to be community minded and publish a free service object for a device that doesn’t already have one.

    You have an existing system that works with Pos .Net/OPOS and it will be at least as much work, or a better architecture, to write your own service object for a device that doesn’t already have one than to re-code the rest of your system to cope with this non Pos .Net device. 

Notice that in the first case you are actually providing hardware, and in the last two cases the caveat is FOR A DEVICE THAT DOESN’T ALREADY HAVE ONE.   

I see a lot of people on various forums or message boards saying things along the lines of;

“I want to use the Pos .Net to create my service object but I am newbie and don’t know where to start. Can someone tell me how to create service object for pos printer ?”

Now, language barriers aside (and no, that wasn’t intended to be poking fun at anyone), most of these people actually DON’T WANT TO CREATE A SERVICE OBJECT.

What they want to do is operate a device using a service object.

I think part of the problem is the same SDK Microsoft ship for consumers of Pos .Net includes documentation, samples and classes for creating your own service objects, something that is not a trivial task.

People reading the documentation and looking at the libraries get confused and think they need to create their own service objects instead of realising they need to obtain one.

Also, anyone considering writing their own service object needs to realise how big a job this is. Apart from implementing the interfaces and classes in Pos .Net you need to perform all the low level device interaction for input and output, as well as status handling to do a good job. You also need to have read, understand and followed the UPOS specification to ensure that your service object behaves according the published rules.

One poor developer I saw asked why he was getting a ‘Method Not Implemented’ when he called base.PrintNormal in a class inheriting from the PosPrinter service object base class. He didn’t realise that he has to implement all the work of actually doing the printing and sending data to the device. The PrintNormal on the base class is just there to ensure you have that method on your interface (although why it isn’t abstract rather than a virtual method that throws an exception I don’t know).

If you still want to create a service object and you’re stuck at where to begin, then by all means set about learning what you need to know but realise that you’re a very long way off having anything that works. Posting in forums saying can someone provide me a sample isn’t likely to get you very far for complex devices like printers, you might get some for barcode scanners, Msrs and cash drawers but even then you’re likely to be just pointed at the samples that come with Pos .Net.

If you really do need to create a service object, and you understand everything I just said, then sorry… this post wasn’t very helpful to you.

If I’ve convinced you not to write your own service object, but now you need to find one, try my list of service object vendors.

Technorati Tags: ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Windows Live Tags: Post,Create,Service,Object,STOP,times,vendor,OPOS,system,architecture,code,Notice,cases,caveat,DEVICE,message,printer,language,Microsoft,consumers,documentation,classes,objects,task,interaction,output,status,UPOS,specification,rules,Method,PrintNormal,PosPrinter,data,interface,exception,devices,Msrs,cash,forums,barriers,interfaces,printers,vendors,hardware

WordPress Tags: Post,Create,Service,Object,STOP,times,vendor,OPOS,system,architecture,code,Notice,cases,caveat,DEVICE,message,printer,language,Microsoft,consumers,documentation,classes,objects,task,interaction,output,status,UPOS,specification,rules,Method,PrintNormal,PosPrinter,data,interface,exception,devices,Msrs,cash,forums,barriers,interfaces,printers,vendors,hardware

Blogger Labels: Post,Create,Service,Object,STOP,times,vendor,OPOS,system,architecture,code,Notice,cases,caveat,DEVICE,message,printer,language,Microsoft,consumers,documentation,classes,objects,task,interaction,output,status,UPOS,specification,rules,Method,PrintNormal,PosPrinter,data,interface,exception,devices,Msrs,cash,forums,barriers,interfaces,printers,vendors,hardware

No comments:

Post a Comment