在C#中实现OPOS设备 [英] Implement OPOS Device in C#

查看:233
本文介绍了在C#中实现OPOS设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一些与传统POS应用程序的互操作,我想知道是否可能在C#中实现一个假的OPOS设备。



基本上我会实现一个假的键盘。



有人知道这是否可能,或在哪里获得文档?我认为OPOS只是调用COM对象,它是由注册表项配置的。所有这些都应该在C#中实现。

解决方案

是的,这是可能的。



您可以开发一个OPOS SO(服务对象),实现OPOS在C#中期望的COM接口。



我建议您从 http://monroecs.com/oposccos.htm



这将给你类型库您需要为您的Service对象实现,并且可能有一些到OPOS文档的链接。 NB我认为OPOS使用后期绑定,所以你需要实现一个双界面。



注意:IMHO OPOS在技术上是一个可怕的API,由委员会外设供应商暴露他们的外围设备的能力,而不是为POS应用程序开发人员提供有用的抽象。



一个特别引人注目的例子是所谓的ToneIndicator设备,富士通键盘中的音调发生器能够发出不同音调和音量的重复序列。



UPDATE



我已经实现了OPOS服务对象,但它已经很长时间了。




  • 控制对象(CO)将加载您的服务对象SO)使用晚期结合。因此,实际上没有COM IID或类型库你实现。相反,您需要实现在适当的OPOS规范版本中定义的所有必需的方法和事件(例如本页上的一个文档: http://monroecs.com/oposreleases.htm )。以下信息基于本页链接的1.6控制程序员指南(CPG)。


  • CPG第2章描述了您需要实现的内容。注意,OPOS使用一个奇怪的方法来获取/设置属性。而控制对象(CO)暴露具有合理名称(例如DeviceEnabled,DeviceName,DeviceDescription)的属性,这些都调用相同的方法GetPropertyString(对于字符串属性)或GetPropertyNumber(对于整数属性),传递整数属性索引定义要检索哪个属性的参数。 属性索引都在OPOS标准提供的头文件中定义。


  • 通过快速浏览CCO PosKeyboard源,您需要的方法名称要实现的注册表项在源文件POSKeyboardImpl.cpp中的s_SOMethodNames中列出。


  • 您需要设置的注册表项在OPOS应用程序员指南)附录OPOS注册表使用。在你的情况下,你需要创建一个注册表项HKLM \OleForRetail\ServiceOPOS\POSKeyboard\DefaultPOSKeyboard(其中DefaultPOSKeyboard是你传递Open方法的设备名称)。此注册表项需要有一个默认值,它是您的SO类的ProgId。您还可以存储其他值(例如您的SO使用的配置信息)。




将是一个痛苦的过程与大量的WTF的。


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#.

解决方案

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.

这篇关于在C#中实现OPOS设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆