Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Micros interface with c# service and a webservice

Status
Not open for further replies.

rajinikanths

Programmer
Dec 11, 2017
13
US
thread693-1766570

@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.
 
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.
 
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 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 :)
 
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
 
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.
 
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:
[COLOR=#0000FF]private[/color] [COLOR=#0000FF]void[/color] Startup()
{
    [COLOR=#2B91AF]MicrosInterface[/color] microsInterface = [COLOR=#0000FF]new[/color] [COLOR=#2B91AF]MicrosInterface[/color](MessageHandler, 4524);
    microsInterface.Start();
}
[COLOR=#0000FF]private[/color] [COLOR=#2B91AF]MicrosMessage[/color] MessageHandler([COLOR=#2B91AF]MicrosMessage[/color] message)
{
    [COLOR=#0000FF]int[/color] a = [COLOR=#0000FF]int[/color].Parse(message.ApplicationData[1]);
    [COLOR=#0000FF]int[/color] b = [COLOR=#0000FF]int[/color].Parse(message.ApplicationData[2]);
    [COLOR=#0000FF]int[/color] result = a + b;
    [COLOR=#0000FF]return[/color] message.CreateReply([COLOR=#A31515]"SumOfTwoNumbers"[/color], result);
}

And the sim file would look something like this:

Code:
event inq : 1
[indent]rxmsg 10, 5[/indent]
[indent]waitforrxmsg[/indent]
endevent

event rxmsg: SumOfTwoNumbers
[indent]var result : N12[/indent]
[indent]rxmsg result[/indent]
[indent]infomessage result[/indent]
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?
 
 
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.
 
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.
 
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.
 
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.
 
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?
 
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.
 
thread693-1750660
You have referred to a RES document in this thread. Can I pls request you repost it please? It has expired.
 
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.
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top