tags:

views:

1145

answers:

2

For some interop with a legacy POS application, I was wondering if it was possible to implement a phony OPOS device in C#.

Basically I would implement a phony keyboard that took web requests and passed on key presses to the legacy application.

Does anyone know if this is possible or where to get documentation? I figured OPOS just called COM objects which are configured by registry keys. All of which should be implementable in C#.

+4  A: 

Yes it's certainly possible.

You can develop an OPOS SO (Service Object) which implements the COM interface expected by OPOS in C#. This can then implement the API in any way you want.

I suggest you download Curtiss Monroe's OPOS Common Control Objects from http://monroecs.com/oposccos.htm.

This will give you the type libraries you need to implement for your Service object(s), and probably has some links to the OPOS documentation. NB I think OPOS uses late-binding so you will need to implement a dual interface.

A caveat: IMHO OPOS is technically a horrible API, designed by a committee peripheral vendors to expose the capabilities of their peripherals rather than to provide a useful abstraction for POS application developers.

A particularly striking example of this is the so-called ToneIndicator device, which exposes the capabilities of a tone generator in a Fujitsu keyboard to sound a repeated sequence of two tones of different pitch and volume.

UPDATE

I have implemented OPOS Service Objects before, but it's been a long time. Here's some more info to get you started on a POSKeyboard SO.

  • The Control object (CO) will load your Service Object (SO) using late-binding. So in fact there is no COM IID or type library that you implement. Instead you need to implement all the required methods and events defined in the appropriate version of the OPOS specs (e.g. one of the docs on this page: http://monroecs.com/oposreleases.htm). The info below is based on the 1.6 Control Programer's Guide (CPG) linked on this page.

  • Chapter 2 of the CPG describes what you need to implement. Note that OPOS uses a weird method for getting/setting properties. Whereas the Control Object (CO) exposes properties with sensible names (e.g. DeviceEnabled, DeviceName, DeviceDescription), these all call into the same methods GetPropertyString (for string properties) or GetPropertyNumber (for integer properties), passing an integer "property index" as an argument that defines which property is to be retrieved. The "property indexes" are all defined in header files supplied with the OPOS standard.

  • From a quick glance at the CCO PosKeyboard source, the method names you need to implement are listed in s_SOMethodNames in the source file POSKeyboardImpl.cpp.

  • The registry entries you need to set up are defined in the OPOS Application Programmer's Guide (APG) appendix "OPOS Registry Usage". In your case you will need to create a registry key HKLM\OleForRetail\ServiceOPOS\POSKeyboard\DefaultPOSKeyboard (where DefaultPOSKeyboard is the device name you are passing the Open method). This registry key needs to have a default value which is the ProgId of your SO class. You can also store other values there (e.g. configuration information used by your SO).

Good luck with this - it will be a painful process with plenty of WTF's.

Joe
Great! I thought my question might not get answered, since OPOS is quite old...I have been looking at this monroecs site for a while, it has lots of information (and is a bit confusing), but not what I specifically need.I have not exactly figured out:a) Which COM interface to implement from which dll (I assume POSKeyboard of some kind)b) How to register my dll for OPOS to use (I know HKLM\OleForRetail\ServiceObjects is the place, just need a doc on it)d) I finally want to load up the POS app (it just uses the LDN of DefaultPOSKeyboard), and see my C# code pop up some MessageBoxes
Jonathan.Peppers
PS - it would be nice to implement the test feature a lot of devices implement from the OPOS config app.
Jonathan.Peppers
"the OPOS config app" - which config app?
Joe
As excellent of an answer as I could get.This is something interesting to me, and if it works out I may post my results on codeplex.
Jonathan.Peppers
Oh, the opos config app, is All-Programs->OPOS->SetupOPOS. It's under the Program Files\OPOS\Epson folder on my computer. Might be specific to Epson printers.
Jonathan.Peppers
"Might be specific to Epson printers". Yes it is Epson-specific. Another weakness of OPOS is that it doesn't provide a standard way to configure service objects...
Joe
A: 

... and if it works out I may post my results on codeplex

I am trying to do something very similar. I need to write a slightly specialized LineDisplay simulator for a Legacy OPOS App, and I have all the same questions you had. If you had any code you could share to start me off I'd really appreciate it.

Andy Abel
I actually cannot. I would recommend reading up on COM interop and C# and the details in implementing COM interfaces for native programs to use.
Jonathan.Peppers