123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- using BBIWARG.Input.InputHandling;
- using BBIWARG.Input.InputProviding;
- using BBIWARG.Output.DebugOutput;
- using BBIWARG.Output.GlassesOutput;
- using BBIWARG.TUIO;
- using System;
- using System.Linq;
- using System.Threading;
- using System.Windows.Forms;
- namespace BBIWARG
- {
-
-
-
- internal class BBIWARG
- {
-
-
-
- private DebugWindow debugWindow;
-
-
-
- private bool debugWindowEnabled;
-
-
-
- private Thread debugWindowThread;
-
-
-
- private GlassesWindow glassesWindow;
-
-
-
- private bool glassesWindowEnabled;
-
-
-
- private Thread glassesWindowThread;
-
-
-
- private InputHandler inputHandler;
-
-
-
- private IInputProvider inputProvider;
-
-
-
- private TuioCommunicatorHack tuioCommunicatorHack;
- private TuioCommunicator tuioCommunicator;
-
-
-
- private bool tuioEnabled;
-
-
-
- private String tuioIP;
-
-
-
- private Int16 tuioPort;
-
-
-
-
- public BBIWARG(string[] args)
- {
- handleArgs(args);
-
- debugWindowEnabled = Parameters.DebugWindowEnabled;
- glassesWindowEnabled = Parameters.GlassesWindowEnabled && Screen.AllScreens.Count() >= 2;
-
- createInputProvider();
- inputProvider.initialize();
- inputProvider.DeviceStartedEvent += handleDeviceStartedEvent;
-
- inputHandler = new InputHandler(inputProvider);
-
- if (tuioEnabled)
- {
- tuioCommunicatorHack = new TuioCommunicatorHack(tuioIP, tuioPort);
- inputHandler.NewProcessedFrameEvent += tuioCommunicatorHack.handleNewFrameData;
- tuioCommunicator = new TuioCommunicator("127.0.0.1", 3333);
- inputHandler.NewProcessedFrameEvent += tuioCommunicator.handleNewFrameData;
- }
-
- if (debugWindowEnabled)
- debugWindowThread = new Thread(new ThreadStart(debugWindowThreadStart));
-
- if (glassesWindowEnabled)
- glassesWindowThread = new Thread(new ThreadStart(glassesWindowThreadStart));
- }
-
-
-
- public void run()
- {
- inputProvider.start();
- }
-
-
-
-
- private static void Main(string[] args)
- {
- System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(API.Server));
- host.Open();
- BBIWARG program = new BBIWARG(args);
- program.run();
- }
-
-
-
- private void createInputProvider()
- {
- if (Parameters.InputSource == InputType.Movie)
- inputProvider = new VideoInputProvider(Parameters.InputMoviePath);
- else if (Parameters.InputSource == InputType.DS325)
- inputProvider = new InputProviderIisu();
- else
- inputProvider = new InputProviderIntel();
- }
-
-
-
- private void debugWindowThreadStart()
- {
- debugWindow = new DebugWindow(inputProvider, inputHandler, Parameters.DebugWindowTitle, Parameters.DebugWindowUpdateIntervall);
- Application.Run(debugWindow);
- }
-
-
-
- private void glassesWindowThreadStart()
- {
- glassesWindow = new GlassesWindow(inputProvider, inputHandler, Parameters.GlassesWindowTitle, Screen.AllScreens[1], Parameters.GlassesWindowUpdateInterval);
- Application.Run(glassesWindow);
- }
-
-
-
-
- private void handleArgs(String[] args)
- {
- if (args.Length > 0)
- {
- tuioEnabled = true;
- String ipString = null;
- String portString = null;
- if (args.Length == 2)
- {
- ipString = args[0];
- portString = args[1];
- }
- else if (args.Length == 1)
- {
- String[] parts = args[0].Split(':');
- ipString = parts[0];
- if (parts.Length == 2)
- portString = parts[1];
- }
- while (!TuioCommunicatorHack.tryParseIPAddress(ipString, out tuioIP))
- {
- Console.WriteLine("Please insert the TUIO-Client's IP (Default is " + Parameters.TuioDefaultIP + "):");
- ipString = Console.ReadLine();
- }
- Console.WriteLine("TUIO-IP is set to:" + tuioIP);
- while (!TuioCommunicatorHack.tryParsePort(portString, out tuioPort))
- {
- Console.WriteLine("Please insert the TUIO-Client's Port (Default is " + Parameters.TuioDefaultPort + "):");
- portString = Console.ReadLine();
- }
- Console.WriteLine("TUIO-PORT is set to:" + tuioPort);
- }
- else
- {
- tuioEnabled = Parameters.TuioEnabledByDefault;
- tuioIP = Parameters.TuioDefaultIP;
- tuioPort = Parameters.TuioDefaultPort;
- }
- }
-
-
-
-
-
- private void handleDeviceStartedEvent(object sender, EventArgs e)
- {
- if (debugWindowEnabled)
- debugWindowThread.Start();
- if (glassesWindowEnabled)
- glassesWindowThread.Start();
- }
- }
- }
|