INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Micros interface with c# service and a webservice

Micros interface with c# service and a webservice

(OP)
thread693-1766570: MICROS Interface

@Moregelen
In reference to the other thread, I'm trying to write a c# service layer to receive the values from Micros 3700 SIM and pass the values (after some processing/formatting) to a SOAP web service. Whatever the SOAP Web Service returns will be sent (after processing/formatting) by c# service layer back to Micros.

I read the thread and noticed an interface and a test module was written. I'm new to the interface program. Can you share your sample code and help? Thanks a ton in advance.

RE: Micros interface with c# service and a webservice

What specifically are you asking for? I don't write interfaces like this all that often anymore - last one I had to create was a couple of months ago - and I've so thoroughly black-boxed my interface code I've almost forgotten everything that went into it. I do have the source still of course. These days most of what I'm working on involves node webkit stuff which ties back into Micros. Things like digital menu boards that automatically refresh the price, or Online Order confirmation boards that track the order's status, etc. Having fun playing in a new medium.

The sample code is all still there, though I do see it isn't quite complete enough to just copy-paste it and have it work. The code has evolved as my understanding of C# evolved (I was fairly new to the language at the time), so it has changed a lot since I posted it. I'm not quite willing to post the code in completion here - my current boss wouldn't mind, but the guy who runs our internal I.T. security is the type of guy who goes to The Lawyers first, so I'd prefer him not to have any reason to put me on his naughty list. If you have specific questions though, I am certainly willing to provide answers and code snippets.

RE: Micros interface with c# service and a webservice

(OP)
Thanks for your comments.
I'm trying to send a discount code, business date, check details from micros to a service (Windows Service - like you have suggested with c#).
So, first I've used the phone number, address, etc sample of .isl code from your original posting and written the sim code. Then I've written the c# service which says 'Received'. Now, I'm trying to send back the data to Micros but not sure how to format it. That is why I was asking for your original code snippet... if you could throw some sample/reference which suggests how to write written format, that would be great.

I saw your other posting http://www.tek-tips.com/viewthread.cfm?qid=1766570 as well but I couldn't interpret which portion of it can I use to send back the data from c# to Micros... can you help pls smile

RE: Micros interface with c# service and a webservice

So when sending it back to Micros, you have to format it into ISL format.

I have an object called Micros message with attributes that I call read/set, but when I send the message back I just ToString() the message. Here is what the ToString() looks like, which shows you the formatting. If what I'm receiving is just a keep alive message, I just send back the same message I was sent as Micros doesn't really care that it changes. It just wants a response.

CODE

public override string ToString()
        {
            if (_IsKeepAlive)
                return _RawMessage;
            return StartOfHeader + ID + StartOfText + FieldSeparator + ApplicationSequence + ApplicationDataString + EndOfText + _CheckSum + EndOfTransmission;
        }
        #endregion

        #region CONSTANTS
        public const char StartOfHeader = '\x001';
        public const char StartOfText = '\x002';
        public const char EndOfText = '\x003';
        public const char EndOfTransmission = '\x004';
        public const char FieldSeparator = '\x1C';
        #endregion 

RE: Micros interface with c# service and a webservice

(OP)
Thanks.
I've one more question.
Say, if I receive a and b via a method call (say SumOfTwoNumbers) and return some processed value (say a*b or a+b, etc), how should I structure my return? Can you advise...

Thanks again for your assistance.

RE: Micros interface with c# service and a webservice

Ok, so that is actually what the ToString does, but let me walk you through what all you need to send back.

Let me use your example, assuming you are calling back and want to trigger the rxmsg event SumOfTwoNumbers. My implementation would look like this, ignoring any kind of stupid proofing:

CODE

private void Startup()
{
    MicrosInterface microsInterface = new MicrosInterface(MessageHandler, 4524);
    microsInterface.Start();
}
private MicrosMessage MessageHandler(MicrosMessage message)
{
    int a = int.Parse(message.ApplicationData[1]);
    int b = int.Parse(message.ApplicationData[2]);
    int result = a + b;
    return message.CreateReply("SumOfTwoNumbers", result);
} 

And the sim file would look something like this:

CODE

event inq : 1
rxmsg 10, 5
waitforrxmsg
endevent event rxmsg: SumOfTwoNumbers
var result : N12
rxmsg result
infomessage result
endevent

The result of hitting the button linked to inquiry 1 would be an infomessage with 15 in it.

So obviously there is a lot more going on in the background. To explain how to implement your own create reply you have to know what Micros expects in reply. Here is the format it wants:

CODE

StartOfHeader + ID + StartOfText + FieldSeparator + ApplicationSequence + ApplicationDataString + EndOfText + CheckSum + EndOfTransmission 

Lets break this down a bit..

StartOfHeader is just a symbol letting micros know that "hey, the header data starts here". I won't get into how networking works, but you normally need things like this to control when you start and stop listening. TCP handles this itself, but we're dealing with a legacy compatible stuff here. Start of header would be the character: '\x001'

Directly after the StartOfHeader, Micros expects the ID. The ID is defined as the POS uws number (either 2 or 9 digits as defined by the interface settings) and the interface name (up to 16 characters). The total length of the ID should be 27 bytes. So assuming my interface name is AddTwoNumbers and I have it set to 9 digits and am sending the message from my server which is UWS 99, my message so far looks like:

CODE

'\x001' + "000000099" + "   AddTwoNumbers" 

Next, to separate this header data from the actual application content we have our STX, or start of text character. So now we have:

CODE

'\x001' + "000000099" + "   AddTwoNumbers" + '\x002' 

After our STX, you need the field separator. Yes, even though we aren't separating anything yet, you start with this. So now:


CODE

'\x001' + "000000099" + "   AddTwoNumbers" + '\x002' + '\x1C' 

Now micros wants the application sequence, which is a transmission sequence number followed by a flag indicating if its a retransmit or not. If you're working with an interface that deals with things like money, you need to keep track of these sequence numbers; sometimes you will get the same sequence number twice from Micros with an R in the retransmission flag spot. If you get this, it is because Micros failed to get a response. If you already processed it, just resend the same response back. If you didn't, process it (obviously).

CODE

'\x001' + "000000099" + "   AddTwoNumbers" + '\x002' + '\x1C' + "03 " 

Next we include the application data. No separator here, just go straight into the application data. Its still a fixed width so far so micros knows where this starts. Documentation says you can have a max of 32K here, but I've never come close to hitting that in a single message. Keep it in mind though. This is where you put ALL your data. Start with the rxmsg event you are trying to invoke, then a field separator, and then each piece of data, separated with field separators. So in our example its:

CODE

'\x001' + "000000099" + "   AddTwoNumbers" + '\x002' + '\x1C' + "03 " + "SumOfTwoNumbers" + '\x1C' + "15" 

After the data you're sending back, an end of text (ETX) character is expected so micros knows that the rest of the message isn't actually data. So:

CODE

'\x001' + "000000099" + "   AddTwoNumbers" + '\x002' + '\x1C' + "03 " + "SumOfTwoNumbers" + '\x1C' + "15" + '\x003' 

After the end of text you should include a check sum, however, this field doesn't really matter when working in TCP. TCP has its own data validation which micros recognizes, so this is only used when your interface works over serial (which is what dictates this legacy formatting). So we're just going to leave it off. Which means our final character to include is the end of transmission character, or EOT.

CODE

'\x001' + "000000099" + "   AddTwoNumbers" + '\x002' + '\x1C' + "03 " + "SumOfTwoNumbers" + '\x1C' + "15" + '\x003' + '\x004' 

So that would be our entire message, so just write that back on the stream and you'll get your infomessage!

That all make sense?

RE: Micros interface with c# service and a webservice

(OP)
THANKS A TON.
This is awesome. I'll go thru everything and do my stuff. I'll update you sure with the outcome.
Thanks again.

RE: Micros interface with c# service and a webservice

(OP)
One more doubt. Thanks in advance. :Your code snippet refers MicrosInterface, MicrosMessage - should i be worried about how this is done? I couldn't find its definition in any threads.

RE: Micros interface with c# service and a webservice

Well, the micros interface part is just my TCP implementation. This wouldn't be the correct forum for assistance with that, not really. TCP isn't handled differently with Micros. The MicrosMessage part is just a wrapper that contains things like the string format I just walked you through, so that I don't have to look at all that mess while creating an interface.

RE: Micros interface with c# service and a webservice

(OP)
Wow. It is too far for me now to write such a common class. I'll try hard to use the current sample that you shared and see what happens. I'll update you. Thanks.

RE: Micros interface with c# service and a webservice

(OP)
Thank you. It has come out very well. I'm at preliminary stage but I'm able to pass the data back to Micros and throw it in InfoMessage.

I need a clarification on how the VOID button works. I mean which isl does it point to? Can you advise please?

RE: Micros interface with c# service and a webservice

I'm not sure what you mean. The touchscreen buttons are all programmable. Void can point to anything. In our system, it points to a SIM file due to our EMV integration. In most systems, it is linked to a built in transaction function, void. There is no hard rule how a void button is going to be setup.

RE: Micros interface with c# service and a webservice

(OP)
Understood. Thank you again.

RE: Micros interface with c# service and a webservice

(OP)
Moregelen, I found this document and it gave me lots of insight into VOID and other feature around 3700. Thought I would share with you.
This document is great… it has both the VOID statements.


http://docplayer.net/storage/58/41497028/151389644...

RE: Micros interface with c# service and a webservice

Ah. Yes the void item command in ISL. it’s documented in the help file in the Micros documentation folder that comes with every install of Micros.

RE: Micros interface with c# service and a webservice

(OP)
I've done the code. It works as I wanted it to. Thanks to your assistance. It was wonderful to have such an expert advise.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close