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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RxMsg message from TCP server

Status
Not open for further replies.

RitwickGupta

Programmer
Aug 21, 2014
96
CA
So I am using a TCP server program to simulate the PMS. I can send all the data needed using TxMsg command, but I don't know what to send back from the PMS to my ISL code in SIM. My code looks like

Code:
var ref             		 : A32 \ 

event inq : 1 //Use Inquiry key #1 to get order info.

//Doing menu stuff here

TxMsg "Pay", @ttldue, @Cknum, menuItemCount, menuItemName[], menuItemCount, menuItemTtl[], menuItemCount, menuItemQty[]

waitforrxmsg "Communicating with Payments..."

LoadKybdMacro key(9, 199)
loadkybdmacro makekeys(total),@key_enter
loadkybdmacro makekeys(ref),@key_enter

endevent

event tmed : 199
window 7, 50, "Payment Info"
display 1,2, "Total: ", total
display 2,2, "Reference Code: ", ref
waitforenter
endevent

event rxmsg : *
rxmsg ref   
endevent

I want to send back a "Yes" or a "No" back to rxmsg. What should be the msg which is being sent back to SIM from the TCP server?
 
There are a few options. The easiest is that you can actually have your interface specify which event to process.


For example, you can send back:

display_error,Fatal Error,A fatal error (167) was encounterd

And then in your isl:

Code:
event rxmsg : display_error
[indent]var title : A40
var message : A40
rxmsg title,message
infomessage title,message
exitcontinue
[/indent]endevent

This is the easiest method. Things get a bit more complicated, though still fairly straightforward, when you're receiving an array back.
 
Where can I get a good documentation for this and how to program the tcp server msgs back to SIM. I am still not sure about the TCP message back. Will sending back "display_error,Fatal Error,A fatal error (167) was encountered" work? I am talking about the exact format.
 
Here is an example of an interface I wrote for a delivery joint. It allows them to print google maps directions at the register.

Code:
var sql_h : n12

EVENT INQ : 1

	If @CustomerSeq[ 1 ] < 1
		Exitwitherror "Please select customer first!"
	endif

	@CustomerInfo = 1
	var addrLine1 : A200 = @CustomerInfoLine[ 3 ]
	var addrLine2 : A200 = @CustomerInfoLine[ 4 ]
	var cityZip   : A200 = @CustomerInfoLine[ 5 ]

	IF addrLine1 = "" OR cityZip = ""
		exitwitherror "Missing address information!"
	ENDIF

	var destination : A2000
	format destination as addrLine1, ", ", addrLine2, ", ", cityZip

	txmsg "get_directions", "** PUT YOUR START ADDRESS HERE **", destination
	VAR MESSAGE : A78 = "Please wait; getting Google Maps directions"
	VAR CENTER : N3 = (78-LEN(MESSAGE))/2
	WINDOW 3,78
	DISPLAY 2, CENTER, MESSAGE
	waitforrxmsg
	
ENDEVENT


EVENT RXMSG : ERROR_MESSAGE

	VAR ERROR : A200
	RXMSG ERROR
	EXITWITHERROR ERROR

ENDEVENT

EVENT RXMSG : PRINT_DIRECTIONS

	VAR STEPS : N3
	VAR STEP[ 500 ] : A200
	VAR PARTA : A40
	VAR PARTB : A160
	VAR TOTALTIME : A50
	VAR TOTALDISTANCE : A50
	RXMSG TOTALTIME, TOTALDISTANCE, STEPS, STEP[]
	VAR I2 : N3

	@CustomerInfo = 1
	var addrLine1 : A200 = @CustomerInfoLine[ 3 ]
	var addrLine2 : A200 = @CustomerInfoLine[ 4 ]
	var cityZip      : A200 = @CustomerInfoLine[ 5 ]

	STARTPRINT @CHK
		PRINTLINE "   Google Maps Directions"
		PRINTLINE ""
		PRINTLINE "Estimated Time: ", TOTALTIME
		PRINTLINE "Total Distance: ", TOTALDISTANCE
		PRINTLINE ""
		PRINTLINE "Destination:"
		PRINTLINE addrLine1
		PRINTLINE addrLine2
		PRINTLINE cityZip
		PRINTLINE ""
		
		FOR I2 = 1 TO STEPS
			PRINTLINE CHR(27), CHR(64), " ", STEP[I2]
		ENDFOR
	ENDPRINT
ENDEVENT
 
I understand the SIM code. My question is, what did you send from TCP server back to SIM so that the command "RXMSG TOTALTIME, TOTALDISTANCE, STEPS, STEP[]" worked properly. How is that msg formatted?
 
Its old school - think serial communication over TCP protocols.
 
Ok then..

Some C# code I wrote way back when I was first doing interfaces for Micros:

Code:
[COLOR=#0000FF]private[/color] [COLOR=#0000FF]string[/color] FormatMessage([COLOR=#2B91AF]MicrosMessage[/color] microsMessage, [COLOR=#0000FF]string[/color] functionName, [COLOR=#0000FF]params[/color] [COLOR=#0000FF]object[/color]&#91;&#93; values)
{
    [COLOR=#0000FF]string[/color] message = functionName;
    [COLOR=#2B91AF]LogManager[/color].PrintEvent([COLOR=#A31515]&quot;Calling GetObjectString&quot;[/color], [COLOR=#2B91AF]MessagePriority[/color].DEBUG_PRINT);
    message += GetObjectString(values);
    [COLOR=#2B91AF]LogManager[/color].PrintEvent([COLOR=#A31515]&quot;parsed array into &quot;[/color] + message, [COLOR=#2B91AF]MessagePriority[/color].DEBUG_PRINT);
    message = [COLOR=#0000FF]string[/color].Format([COLOR=#A31515]&quot;\x001{0}{1}\x002\x1c{2}{3}{4}\x003\x004&quot;[/color],
                                microsMessage.UWS,
                                microsMessage.InterfaceMessage,
                                microsMessage.TransmissionNumber,
                                microsMessage.RetransmissionFlag,
                                message);
    [COLOR=#2B91AF]LogManager[/color].PrintEvent([COLOR=#A31515]&quot;Return message formatted as &quot;[/color] + message, [COLOR=#2B91AF]MessagePriority[/color].DEBUG_PRINT);
    [COLOR=#0000FF]return[/color] message;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top