Author Topic: Announcing: a Graphical switch sender and lamp visualizer (for OSC mode)  (Read 11822 times)

uncivil engineer

  • Wizard
  • *****
  • Posts: 118
  • Alan
    • View Profile
Well I am still a bit puzzled as to why this doesn't work.
I have attached a screen shot of what I am seeing in my virtual machine.  I have even tried using the flags for forcing the IP address as well as the port.
Uncivil Engineer

MOcean

  • P3 Developers
  • *
  • Posts: 822
  • Michael Ocean
    • View Profile
When I run the server and the client I do not specify the IP address or the port and the defaults (localhost) work for me. I assume they do not work for you and you've tried that first?

If you're using Brian's OSC Mode and not mine, lamps will not work.  The code may blow up too, I haven't tried to connect my client to Brian's OSC mode.


uncivil engineer

  • Wizard
  • *****
  • Posts: 118
  • Alan
    • View Profile
Michael,
Yes, I am trying to use Brians OSC mode.  I was unaware there was a difference. 
I take it the OSC mode you are using is the OSC.py file that is on your Github.  Where are you placing that file?  In the game directory, or with the native modes to pyprocgames? 
--Uncivil Engineer

MOcean

  • P3 Developers
  • *
  • Posts: 822
  • Michael Ocean
    • View Profile
Announcing: a Graphical switch sender and lamp visualizer (for OSC mode)
« Reply #48 on: April 07, 2015, 06:26:43 PM »
Sorry to take so long to reply.  I needed to have my code handy for copy-paste.

So, I use the osc mode by loading it in my game class; I did not hack the game.py to include it (not that I haven't hacked my game.py, though).

So, in my game class' python file, I do the following.

In __init__():

Code: [Select]
        # add support for OSC
        OSC_closed_switches = ['troughL','troughC','troughR']

        self.osc = modes.OSC_Mode(game=self, priority=1, closed_switches=OSC_closed_switches)

        self.modes.add(self.osc)

but it's worth noting that if you want to do things 'right' you have to be prepared that your init() or your run_loop() might fail, so most my init() function call is defined in a try block and the except calls end_run_loop() -- in main, my run_loop() is in a try and the except there also calls end_run_loop().  end_run_loop() is responsible for killing osc mode if it's there and active, like such:

Code: [Select]
    def end_run_loop(self):
        if(hasattr(self,'osc') and self.osc is not None):
            self.osc.OSC_shutdown()
        super(BuffyGame, self).end_run_loop()

In the Except for init, I reraise the original exception.  Going beyond simply calling 'raise' at the end of an except, it makes sense to store the original exception and reraise it to preserve the original call stack and line numbers.  This block explains it pretty well:
http://www.ianbicking.org/blog/2007/09/re-raising-exceptions.html

Of course, this should be the default behavior not just in Buffy but also in SkeletonGame; I guess I should double check this is actually the case :P
« Last Edit: April 07, 2015, 06:31:46 PM by MOcean »

uncivil engineer

  • Wizard
  • *****
  • Posts: 118
  • Alan
    • View Profile
Alright, I got your osc.py file, and put it into my modes folder in pyprocgames. 

So now things really start to get interesting.  I can now connect to my flash OSC server (yeah!) but appears to be a one way connection, and I cannot connect with switch matrix client.  I can only connect from an old Ipad I have running TouchOSC.  I set up start button on TouchOSC, and it appears to work, and the crashes.  Attached is the screen shot of the crash message.  It seems to me that osc.py cannot talk back to TouchOSC, and the it appears to be using a garbage port (62625?).

I am starting to wish I hadn't decided to use my virtual machine for my development.  It has been quite the PIA.
--Uncivil Engineer

MOcean

  • P3 Developers
  • *
  • Posts: 822
  • Michael Ocean
    • View Profile
Did you remove the other OSC.py file and references to it in your procgame?  The only reason I ask is in case the globals from one are clobbering the other.   edit: There are no globals in the osc.py Mode.  I was thinking of the osc client

I also haven't tested my latest hacked up mode with TouchOSC (which may legitimately be sending that port number). What happens when you try to use my graphical client?  That is the only client that I've tested.

Thanks

EDIT#2:
In light of all of this, I've changed SkeletonGame to support automatically launching your game, catching exceptions, shutting down the sdl2.ext window, and closing the osc thread, if open.  Now the game launch code looks like:

Code: [Select]
if __name__ == '__main__':
    from procgame.game.skeletongame import run_proc_game
    # change T2Game to be the class defined in this file!
    run_proc_game(T2Game)

run_game_loop, end_game_loop, exception handling.... you are banished!
« Last Edit: April 08, 2015, 10:00:34 AM by MOcean »

Curbfeeler

  • Wizard
  • *****
  • Posts: 239
  • Dan - Des Moines, IA
    • View Profile
I also only use Michael's desktop interface.  I was trying the phone, tablet, etc. route for a while early on and had various problems and inconsistencies, but the desktop version is a godsend.  Especially with new transparent lamp circles.  I launch it via a bat file. 

Code: [Select]
python switchMatrixClient.py -y config/pinbot.yaml -p 9000 -i PinBotPf.jpg -l pinbot.layout
The first time you run it you leave off the -l pinbot.layout bit since that file doesn't exist yet.  Occasionally the tool will stop responding after several hours of inactivity and I will have to restart the tool via the bat file, but that's the only issue I've had at all.

Dan

uncivil engineer

  • Wizard
  • *****
  • Posts: 118
  • Alan
    • View Profile
So tonight I broke down and installed OSC on my old windows computer that sits next to my pinball machine, and spends most of it's time running the brains of my Flash pinball machine.

Guess what, it works.  I now can send switch event to my flash machine.  I think all the communication issues I had were indeed related to my virtual windows 7 machine I run on my Mac Pro.

So while the chair is not as comfortable as the one in front of the Mac, I can now at least do some development after the kids go to bed.

bonnevil69

  • P3 Developers
  • *
  • Posts: 698
  • Matthew Bonnema
    • View Profile
 Okay Michael,   I just got around to installing your Graphical switch sender   its pretty amazing i must say  Even though i wasted about 3 hours because now i had to hook up my touch screen from my other machine and just push buttons playing around instead of building parts :)    thanks so much for taking the time to make this   Awesome 

-Matt
DeadPin and Doom

MOcean

  • P3 Developers
  • *
  • Posts: 822
  • Michael Ocean
    • View Profile
Announcing: a Graphical switch sender and lamp visualizer (for OSC mode)
« Reply #54 on: April 11, 2015, 02:54:18 AM »
Happy to help, Matt!

If people don't mind posting screenshots of their games running on the gui, that'd be cool to see.
« Last Edit: April 11, 2015, 03:07:59 AM by MOcean »

uncivil engineer

  • Wizard
  • *****
  • Posts: 118
  • Alan
    • View Profile
Well here is how I am now using it. 
My IDE is Wing 101.  It seems to do what I need it to do, which is primarily be just a text editor.  I have thought about upgrading to a full version of Wing IDE, but I really don't see the reason to right now.

I was lucky to find a good picture of my playfield online that I used as my switch background.