PDA

View Full Version : g2g send event weird error



yonu
October 13th, 2013, 10:58 AM
I am setting up a g2g event to send the batterylevel from one laptop to the server as a test to see if I can get something to work the way I want howwver I get this error

G2G: Fail No Connection 192.168.1.6
G2G: TriggerRemoteEvent nil
G2G: Error in WP function: ...m Files\Promixis\Girder5\luascript\Girder2Girder.lua :171: bad argument #1 to `SendEvent' (string expected, got nil)
G2G: Fail No Connection Beach-PC


The connection is there if I run ping it goes through

here is the script I am running

require('Girder2Girder')

Battlvl = 90

print (Battlvl)
g2g.SendEvent(test, 232, 1, Battlvl)
--g2g.Ping()


Oh and I get the same thing if i use the sendclient

Ron
October 13th, 2013, 01:08 PM
looks like the variable 'test' is null. Make sure it has something in it!

Ron
October 13th, 2013, 01:09 PM
you probably meant to type:



g2g.SendEvent("test", 232, 1, Battlvl)

yonu
October 13th, 2013, 04:42 PM
Thanks,
I didn't think to quote the event

yonu
October 13th, 2013, 05:48 PM
thanks that did it quick question I wrote this up to test if the event string is the one I want figured then I could have multiples in one scripting action the problem is that everytime it comes up it prints no even though the actions that result are a perfect match other than the payload am I totally missing something or does this just not work the way I think it should.

if eventstring == "Sensor update doghouse-batwatch.camperpc: batterylevel, unknown type" then
print("YES")
else
print("No")
--g2g.SendEvent("Bearnetbat", 232, 0, Battlvl)
end

Ron
October 13th, 2013, 07:14 PM
I think you mean to do



if EventString == "...


Lua is case sensitive. To be sure add a print statement to see if you are getting thing as expected.



print("Event: ", EventString)

yonu
October 13th, 2013, 07:41 PM
thanks turns out I wasn't getting the eventstring. but I did some diggin on the forum and found a chuck of code to do exactly what I need to I modififed but I have a little issue each time it runs it doubles what is in the print statement so by the 6th run I have 5 ac online or bat lvls each time it prints edit sorry it isa actually running additional times

gir.AddEventHandler('Sensor update doghouse-batwatch.camperpc: acstatus, unknown type', 0, 99999,
function(eventstring, device, modifier, payloads, handler)
if eventstring == "Sensor update doghouse-batwatch.camperpc: batterylevel, unknown type" then
Battlvl = pld1
print ("current bat ".. Battlvl)
else
-- print ("no")
end
if eventstring == "Sensor update doghouse-batwatch.camperpc: acstatus, unknown type" then
acstatus = pld1
print ("current AC is ".. acstatus)
else
-- print ("no")
end


end)


Sorry for being a Dumbass

yonu
October 14th, 2013, 07:03 PM
found the issue I changed

gir.AddEventHandler('Sensor update doghouse-batwatch.camperpc: acstatus, unknown type', 0, 99999,

to

gir.AddEventHandler('Sensor update doghouse-batwatch.camperpc: acstatus, unknown type', 0, 2,

and it is behaving now

yonu
October 14th, 2013, 07:46 PM
I was wrong changing the 99999 to 2 only worked til it rebooted out of curiosity what does the 99999 modifier do

Ron
October 14th, 2013, 07:48 PM
The manual has a bit more info too. The 99999 is the upper range of event devices that will match.

yonu
October 14th, 2013, 10:19 PM
ok after reading the manual it turns out and I feel stupid for not catching it that the first param 0 is the min device number and the 99999 is the maxdevice number is there away to determin exactly the device mumber I have coming in so that I can shorten the range as I assume this is what it keeps multiplying itself on reach run

Ron
October 15th, 2013, 08:26 AM
inside the eventHandler print device to get the device number used.

yonu
October 15th, 2013, 10:12 AM
thanks that got me the device number but that didn't help I still get multiple runs everytime the ac status changes but I am only getting one event in

Ron
October 15th, 2013, 11:14 AM
The windows APM subsystem generates multiple events. Just filter then in your code...

yonu
October 15th, 2013, 02:27 PM
ok I decided to do a simple test to see what happens

here is the code

gir.AddEventHandler('.*', 0, 99999,
function(eventstring, device, modifier, payloads, handler)
if eventstring == "TaskSwitch" then
acstatus = 'online'
print ("current AC is ".. acstatus)
else
print ("no")
end
end)

here is the logger data after 4 runs

Time Date Source Details Payloads
14:22:59:373 10/15/2013 TaskSwitch Girder.exe
14:22:59:389 10/15/2013 Battery Level Lua Success (Nothing Triggered)bat test.gml:\New\Battery Level
14:23:02:242 10/15/2013 TaskSwitch Girder.exe
14:23:02:257 10/15/2013 Battery Level Lua Success (Nothing Triggered)bat test.gml:\New\Battery Level
14:23:03:293 10/15/2013 TaskSwitch Girder.exe
14:23:03:310 10/15/2013 Battery Level Lua Success (Nothing Triggered)bat test.gml:\New\Battery Level
14:23:07:914 10/15/2013 TaskSwitch Girder.exe
14:23:07:941 10/15/2013 Battery Level Lua Success (Nothing Triggered)bat test.gml:\New\Battery Level

Here is the lua console after the same 4
6601

hope this makes sense as I have no idea what is going on or at least why the variable keeps increasing

yonu
October 16th, 2013, 02:30 PM
I won't be able to test this until I get home this evening as I don't have a battery or anything in the PC I use for code testing here at the office but I chopped the code down to this
if EventString == "Girder.exe" then
local acstatus = 'online'
print ("current AC is ".. acstatus)
else
print ("no")
end

and it seems to be workin so apparently my issue is in the function I am using but I just don't see the issue based on the syntax and examples in the manual

Ron
October 16th, 2013, 02:38 PM
Looks like you are using the taskswitch event... I'm not sure that is what you intended. I suggest you narrow down the event filtering in your handler to only process APM events.

I won't be able to answer again until next week Monday I'm afraid. Taking a few days off with the family.

yonu
October 16th, 2013, 03:09 PM
I am just using it for testing purposes here on this PC to see what the if is doing

Enjoy the time off

Ron
October 16th, 2013, 03:13 PM
Aaaah carry on then!

Thanks, it's time for a bit of time off. It's been crazy and the next few months are crazy.... good problems to have I guess :D