コード例 #1
0
        public void Parser_EmptyFile()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing empty file
            string[] emptyFile = { };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(emptyFile, ownDevice);

            Assert.IsTrue(!ownDevice.Location.HasValue);
            Assert.IsTrue(!ownDevice.Orientation.HasValue);
        }
コード例 #2
0
        public void Parser_GarbageValue()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing garbage
            string[] garbageValue = { "ASDAWDSD ASCAASASSSFVRSDFFSEFSEFSEFSFSEF;';';AASDASD>AS:>DPASDPA<S?><./,>?A<S?>D,/.,./?A>S<d  as.d,./sd ,as/.", "ASD##@$?>?SDF{++_#_@$)#+_)+_V VV   S FDF SDF location", "location: d233 2aSDASd,/.,/.as,d/.as,das][[[=--=[=-[=-[" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(garbageValue, ownDevice);

            Assert.IsTrue(!ownDevice.Location.HasValue);
            Assert.IsTrue(!ownDevice.Orientation.HasValue);
        }
コード例 #3
0
        public void Parser_CorrectInput()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing Correct Input
            string[] correctInput = { "location:2.0 2.0", "orientation:90.0" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(correctInput, ownDevice);

            Assert.AreEqual(ownDevice.Orientation.Value, 90.0);
            Assert.AreEqual(ownDevice.Location.Value.ToString(), new Point(2.0, 2.0).ToString());
        }
コード例 #4
0
        //[TestMethod]
        public void TestMethod1()
        {
            MSEMultiSurface mse = new MSEMultiSurface(30,20, false);
            mse.Start();

            Console.WriteLine("Sleeping for 10s after starting MSE");
            Thread.Sleep(10000);

            IAIntAirAct intAirAct = IAIntAirAct.New();
            intAirAct.Port = 3456;
            intAirAct.Route(Routes.GetAllDeviceInfoRoute, delegate(IARequest request, IAResponse response)
            {
                response.SetBodyWithString("[{\"identifier\": \"SENG10(2)\", \"orientation\": 30,\"location\": \"30.0, 40.0\",\"isComplete\": true}]");

            });

            intAirAct.Start();

            //Wait for them to find each other
            Console.WriteLine("Sleeping for 10s after starting IntAirAct server");
            Thread.Sleep(10000);

            mse.Locator.GetDevicesInSystem(delegate(List<MSEDevice> devices)
            {
                Console.WriteLine(devices);

            }, delegate(Exception error)
            {

            });

            Console.WriteLine("Sleeping for 5m");
            Thread.Sleep(300000);

            Console.WriteLine("Done");
        }
コード例 #5
0
        public void Teardown()
        {
            Client.Stop();
            Server.Stop();

            Client = null;
            Server = null;
        }
コード例 #6
0
        public void Setup()
        {
            Client = new MSEMultiSurface();
            Server = new MSEKinectManager(false);
            clientConnected = false;
            serverConnected = false;
            doneWaitingForResponse = false;

            Client.IntAirAct.Port = ClientPort;
            Server.IntAirAct.Port = ServerPort;

            // Increment the port numbers, so that if the current test run crashes, we don't try to use unreclaimed ports on the next test
            ClientPort++;
            ServerPort++;

            // In the tests, we wait on clientConnected and serverConnected, to be certain that each IntAirAct instance has registered the other
            // We use known ports to 'uniquely' identify instances during the test, since other IntAirAct devices may exist on the network during the test
            Client.IntAirAct.DeviceFound += delegate(IADevice device, bool ownDevice)
            {
                if (device.Port == Server.IntAirAct.Port)
                    clientConnected = true;
            };

            Server.IntAirAct.DeviceFound += delegate(IADevice device, bool ownDevice)
            {
                if (device.Port == Client.IntAirAct.Port)
                    serverConnected = true;
            };
        }
コード例 #7
0
        public void Parser_InvalidLeftSide()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing invalid left side
            string[] invalidLeftValue = { "funk rating:20.0", "value:off the charts" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(invalidLeftValue, ownDevice);

            Assert.IsTrue(!ownDevice.Location.HasValue);
            Assert.IsTrue(!ownDevice.Orientation.HasValue);
        }
コード例 #8
0
        public void Parser_SlightlyOffValue()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing slightly off formatting that should be acceptable
            string[] slightlyOffValue = { "location: \t2.0    2", "orientation:    \t 90.0" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(slightlyOffValue, ownDevice);

            //         Assert.AreEqual(ownDevice.Orientation.Value, 90.0);
            //         Assert.AreEqual(ownDevice.Location.Value.ToString(), new Point(2.0, 2.0).ToString());
        }
コード例 #9
0
        public void Parser_SingleLocationValue()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing single value for location
            string[] singleValue = { "location:20.0", "orientation:90.0" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(singleValue, ownDevice);

            Assert.IsTrue(!ownDevice.Location.HasValue);
            Assert.AreEqual(ownDevice.Orientation.Value, 90.0);
        }
コード例 #10
0
        public void Parser_NegativeValue()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing negative values
            string[] negativeValue = { "location:" + Double.MinValue.ToString("R") + " " + Double.MinValue.ToString("R"), "orientation:" + Double.MinValue.ToString("R") };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(negativeValue, ownDevice);

            Assert.AreEqual(ownDevice.Location.Value.ToString(), new Point(Double.MinValue, Double.MinValue).ToString());
            Assert.AreEqual(ownDevice.Orientation.Value, Double.MinValue);
        }
コード例 #11
0
        public void Parser_LargeValue()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing large values. toString("R") prevents weird rounding that causes overflow
            string[] largeValue = { "location:" + Double.MaxValue.ToString("R") + " " + Double.MaxValue.ToString("R"), "orientation:" + Double.MaxValue.ToString("R") };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(largeValue, ownDevice);

            Assert.AreEqual(ownDevice.Location.Value.ToString(), new Point(Double.MaxValue, Double.MaxValue).ToString());
            Assert.AreEqual(ownDevice.Orientation.Value, Double.MaxValue);
        }
コード例 #12
0
        public void Parser_InvalidRightSide()
        {
            MSEMultiSurface target = new MSEMultiSurface(0.0, 0.0, false);

            // Testing a non double value
            string[] nonDoubleValue = { "location:POTATO POTATO", "orientation:HELLOWORLD" };
            MSEDevice ownDevice = new MSEDevice();
            target.ParseConfigurationFile(nonDoubleValue, ownDevice);

            Assert.IsTrue(!ownDevice.Location.HasValue);
            Assert.IsTrue(!ownDevice.Orientation.HasValue);
        }
コード例 #13
0
ファイル: MainWindow.xaml.cs プロジェクト: ase-lab/MSEAPI-CS
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            mseMultiSurface = new MSEMultiSurface(30.0, 30.0, false);

            mseMultiSurface.Ready += new MSEMultiSurface.MSEOnReadyHandler(mseMultiSurface_Ready);

            mseMultiSurface.AddReceivedDictionaryHandler(delegate(Dictionary<string, string> dictionary, String dictionaryType, MSEDevice originDevice, MSEGesture originGesture)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    DataTextBlock.Text += "Key\t\tValue\n\n";

                    foreach (KeyValuePair<string, string> pair in dictionary)
                    {
                        DataTextBlock.Text += pair.Key + "\t" + pair.Value + "\n";
                    }

                    DataTextBlock.Text += "\n";

                }));

            });

            mseMultiSurface.ReceivedDataHandlers.Add(delegate(byte[] data, MSEDevice originDevice, MSEGesture originGesture)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    DataTextBlock.Text += System.Text.Encoding.ASCII.GetString(data) + "\n\n";
                }));

            });

            mseMultiSurface.ReceivedImageHandlers.Add(delegate(System.Drawing.Image image, String imageName, MSEDevice originDevice, MSEGesture originGesture)
            {

                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    OutputImage.Source = Util.ConvertFromImageToBitmap(image);

                }));

            });

            mseMultiSurface.IntAirAct.DeviceFound += delegate(IntAirAct.IADevice device, bool ownDevice) {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    StatusTextBlock.Text += "Found " + device.Name.ToString() + "\n";
                }));
            };

            mseMultiSurface.IntAirAct.DeviceLost += delegate(IntAirAct.IADevice device)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    StatusTextBlock.Text += "Lost " + device.Name.ToString() + "\n";
                }));
            };

            mseMultiSurface.Ready += delegate(MSEDevice ownDevice) {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    StatusTextBlock.Text += "MSE API Ready. Identifier - " + ownDevice.Identifier + "\n";
                }));
            };

            mseMultiSurface.Start();
        }