#373 Private Method Listing
# Send a message out
def sndgsd(message)
conn_.send(message)
end
#Process Response message
def response(message)
#Message format: From, To, Priority, Type, Command [Param1 Param1Value]..
#Our Format: To Type Command [Param Value] ...
#split the messages up into chunks
messages = message.split(" ")
if messages.length < 3 then
error
else
to = messages[0].to_i
type = messages[1].to_i
cmd = messages[2].to_i
#we now have enough information to create a command object
cmd = Command.new(device_.devid_, to, 1, type, cmd)
#now to populate parameters of the command
pointer = 3
while (messages.length > pointer)
cmd.params_[messages[pointer].to_i] = messages[pointer + 1]
pointer += 2
end
SendCommand(cmd)
end
end
def error
msg = 'Syntax Error'
sndgsd(msg)
end
def prompt
msg = 'TO TYPE CMD Param1 Param1value ...'
sndgsd(msg)
end
#373 Private Method Listing END
#350 Process Incoming Data
while(true)
buff=conn_.RecvDelimited(0x13.chr,50)
if(buff.length() == 0)
break
end
recv = recv + buff
if recv[-1] == 13.chr then
response(recv)
recv = ''
end
end
#350 Process Incoming Data END