Slightly different topic today: Programming a POS application.
I have been working on a lettings management program with built in till for use in our Sports Lettings. Couldn’t find anything out there that met all of our needs at a suitable price. So, I have took it upon myself to develop an application that does what we want.
Anyway, program written, and the final part was to make both the lettings and the till use a Cash Drawer and Receipt Printer. The devices that we had purchased for this are a Star Micronics TSP113 Thermal Receipt Printer & a Star Micronics CB2002 Cash Drawer. Both are claimed to support POS for .NET.
Parts arrived, and wired up. Things that you have to do next (with this model at least)
- Go into the Star Configuration Utility. Select Star Line Mode when asked.
- On the OPOS section, specify Device Names for both the printer and the cash drawer. Then, select each item, click Configure and specify a Logical Device Name.
- I advise then running the sample application to check that you can connect and operate the two devices.
- Close the Star Configuration Utility.
With this complete, I believed that I should be able to operate the drawer and the printer from within an application. In a new application (so not to change my final application whilst discovering how this all worked), I inserted two buttons and entered the following code:
Dim POSExplorer As New PosExplorer Dim POSDevice As DeviceInfo Dim RPrinter As Microsoft.PointOfService.PosPrinter = Nothing Dim CDrawer As Microsoft.PointOfService.CashDrawer = Nothing
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
POSDevice = POSExplorer.GetDevice(DeviceType.CashDrawer, "CD1_1") CDrawer = POSExplorer.CreateInstance(POSDevice) CDrawer.Open() CDrawer.Claim(5000) CDrawer.DeviceEnabled = True CDrawer.OpenDrawer() CDrawer.WaitForDrawerClose(13000, 4000, 400, 1500) CDrawer.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
POSDevice = POSExplorer.GetDevice(DeviceType.PosPrinter, "PRINT1_1") RPrinter = POSExplorer.CreateInstance(POSDevice) RPrinter.Open() RPrinter.Claim(5000) RPrinter.DeviceEnabled = True RPrinter.PrintNormal(PrinterStation.Receipt, "This is a Test String") RPrinter.DeviceEnabled = False RPrinter.Close()
End Sub
Everytime the application was ran, and I clicked either of the buttons to either print the test line or open the cash drawer, I got an error on the line RPrinter.Open() or CDrawer.Open(). The error was
Open threw an exception. The device cannot perform the requested procedure.
Next I confirmed that the OPOS settings in the Star Configuration Utility were correct, and double checked that I had put Open and Claim commands in the right order.
Next came a considerable amount of time researching Service Objects and OPOS definitions and standards to try and understand how all of the POS systems are meant to work together.
After a while, I found that there are some Common Control Objects (CCO) which are available and interface between your application and your device. I was currenly using the objects supplied with the printer.
The CCO are available using the link below:
http://www.monroecs.com/files/OposCCOs-1_13_000.zip
This site also gives (IMHO) a great overview of POS, POS for .NET, OPOS and JavaPOS. A good place for beginners in programming POS systems to get some background information.
The fix for me was to do the following:
- Download and extract the OPOS CCO’s from above.
- Register the DLL’s (register batch script provided)
- In Visual Studio 2010, Add a Reference to the extracted DLL that you require. In my case I added two references, one for OPOSCashDrawer.ocx and one for OPOSPOSPrinter.ocx.
- Rebuild and run your application.
The code above then works to open the cash drawer and print a single test line on the receipt printer.
Although this post was written about Receipt Printers and Cash Drawers, I understand from my research that the problem can affect all types of POS devices. I beleive this fix may work ifyou are having issues with other devices too. Just change the name of the OCX file that you add as a reference in step 3 above to the device type that you are including.
Shortly I am going to need to find out if I need to copy these CCO’s into the application when I build it for final release. If anyone knows the answer, it would be great if you could post. If not, I will post my findings when I get that far.
I was having trouble with this issue, thank you for the post.
I think suppose this problem exist because the Microsoft POS for dot net is only compatible with the CCO that you downloaded from monroe not from the star manufacturer. Actually POS for .net only works and compatible with some device manufacturer until you download the MONROE CCO.
To solve your last ocx. problem I think all is automatically included
in your project when you use Set Up and Deployment Project.
Brilliant post. Had exactly the same problem, was using an Epson till printer until the cash draw port broke, swapped to a Star TSP100 and all hell broke loose.
Thanks for the post
James
Hey Now;
Nice Post on POS.NET
Thx 4 the info;
Catto
Great Post. Thanks
nice post. thanks.
Thank you soooo much for posting this. I was having the exact same problem.
VS2010!!
VB rather then C sharp!!
OCX files!!
Not sure what shocks me more. Got to be the OCX files.