Browse Source

tuio ip+port as application parameters

Alexander Hendrich 10 years ago
parent
commit
6c0f6e6283

+ 4 - 3
bbiwarg/Constants.cs

@@ -4,6 +4,7 @@ using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Net;
 
 using bbiwarg.Utility;
 
@@ -35,9 +36,9 @@ namespace bbiwarg
         public static readonly String OutputTitle = "BBIWARG - Output";
 
         // TUIO
-        public static readonly bool TuioEnabled = false;
-        public static readonly String TuioIP = "127.0.0.1";
-        public static readonly int TuioPort = 3333;
+        public static bool TuioEnabled = false;
+        public static IPAddress TuioIP = new IPAddress(new byte[4]{127,0,0,1});
+        public static Int16 TuioPort = 3333;
 
         // image
         public static readonly Vector2D MaxPixel = new Vector2D(319, 239);

+ 1 - 1
bbiwarg/InputHandler.cs

@@ -73,7 +73,7 @@ namespace bbiwarg
 
             if (Constants.TuioEnabled)
             {
-                tuioCommunicator = new TuioCommunicator(Constants.TuioIP, Constants.TuioPort);
+                tuioCommunicator = new TuioCommunicator(Constants.TuioIP.ToString(), Constants.TuioPort);
                 touchTracker.TouchDown += tuioCommunicator.touchDown;
                 touchTracker.TouchMove += tuioCommunicator.touchMove;
                 touchTracker.TouchUp += tuioCommunicator.touchUp;

+ 42 - 2
bbiwarg/MainBBWIWARG.cs

@@ -5,8 +5,10 @@ using System.Threading;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Net;
 using bbiwarg.Graphics;
 using bbiwarg.InputProviders;
+using bbiwarg.Server;
 
 namespace bbiwarg
 {
@@ -14,8 +16,13 @@ namespace bbiwarg
     {
         static void Main(string[] args)
         {
-            Console.SetWindowSize(Constants.ConsoleWidth, Constants.ConsoleHeight);
+            if (args.Length > 0)
+            {
+                handleArgs(args);     
+            }
 
+            Console.SetWindowSize(Constants.ConsoleWidth, Constants.ConsoleHeight);
+            
             InputProvider inputProvider;
             if (Constants.InputSource == InputType.Movie)
                 inputProvider = new VideoInputProvider(Constants.InputMoviePath);
@@ -24,7 +31,6 @@ namespace bbiwarg
 
             inputProvider.start();
 
-
             InputHandler inputHandler = new InputHandler(inputProvider);
 
             OutputWindow outputWindow = new OutputWindow(inputProvider, inputHandler);
@@ -32,5 +38,39 @@ namespace bbiwarg
 
             inputProvider.stop();
         }
+
+        private static void handleArgs(String[] args)
+        {
+            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 (!TuioCommunicator.tryParseIPAddress(ipString, out Constants.TuioIP))
+            {
+                Console.WriteLine("Please insert the TUIO-Client's IP (Default is 127.0.0.1):");
+                ipString = Console.ReadLine();
+            }
+            Console.WriteLine("TUIO-IP is set to:" + Constants.TuioIP.ToString());
+
+            while (!TuioCommunicator.tryParsePort(portString, out Constants.TuioPort))
+            {
+                Console.WriteLine("Please insert the TUIO-Client's Port (Default is 3333):");
+                portString = Console.ReadLine();
+            }
+            Console.WriteLine("TUIO-PORT is set to:" + Constants.TuioPort);
+
+            Constants.TuioEnabled = true;
+        }
     }
 }

+ 10 - 0
bbiwarg/Server/TuioCommunicator.cs

@@ -3,6 +3,8 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Net;
+using System.Net.Sockets;
 using bbiwarg.Recognition.TouchRecognition;
 using bbiwarg.Utility;
 using TUIO;
@@ -60,5 +62,13 @@ namespace bbiwarg.Server
             }
             cursors.Clear();
         }
+
+        public static bool tryParseIPAddress(String ipString, out IPAddress ipAddress) {
+            return (IPAddress.TryParse(ipString, out ipAddress) && ipAddress.AddressFamily == AddressFamily.InterNetwork);
+        }
+
+        public static bool tryParsePort(String portString, out Int16 port) {
+            return Int16.TryParse(portString, out port);
+        }
     }
 }

+ 32 - 1
bbiwarg/bbiwarg.csproj

@@ -11,6 +11,21 @@
     <AssemblyName>bbiwarg</AssemblyName>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>x86</PlatformTarget>
@@ -138,7 +153,23 @@
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <BootstrapperPackage Include=".NETFramework,Version=v4.5">
+      <Visible>False</Visible>
+      <ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

+ 16 - 0
bbiwarg/bbiwarg.csproj.user

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+    <StartArguments>127.0.0.1:3333</StartArguments>
+  </PropertyGroup>
+  <PropertyGroup>
+    <PublishUrlHistory>publish\</PublishUrlHistory>
+    <InstallUrlHistory />
+    <SupportUrlHistory />
+    <UpdateUrlHistory />
+    <BootstrapperUrlHistory />
+    <ErrorReportUrlHistory />
+    <FallbackCulture>en-US</FallbackCulture>
+    <VerifyUploadedFiles>false</VerifyUploadedFiles>
+  </PropertyGroup>
+</Project>