public BalanceBoardInformation(IBalanceBoard board)
 {
     _Board = board;
     _BoxX = (float)_Random.NextDouble();
     _BoxY = (float)_Random.NextDouble();
     this.Build();
 }
 public BalanceBoardInformation(IBalanceBoard board)
 {
     _Board = board;
     _BoxX  = (float)_Random.NextDouble();
     _BoxY  = (float)_Random.NextDouble();
     this.Build();
 }
Esempio n. 3
0
        public void OnBalanceChanged(IBalanceBoard newBalance, IGame game)
        {
            if (_writer == null)
            {
                return;
            }
            _currentData[0] = new Vub.Etro.IO.Vector4(newBalance.CenterOfPressure.X, newBalance.CenterOfPressure.Y, newBalance.Weight, 0);

            writeGameObjects(game, (int)labels.Length);

            _writer.WriteIntFrame(_currentData);
            WriteAnalogData(game);
        }
Esempio n. 4
0
        public void ProcessBalanceBoard(IBalanceBoard balanceBoard)
        {
            BalanceBoardProcessRequest p = new BalanceBoardProcessRequest();

            p.Analyzer       = _analyzer as IBalanceBoardAnalyzer;
            p.CurrentBalance = balanceBoard;

            lock (_lockObject)
            {
                _requestQueue.Enqueue(p);

                if (_requestQueue.Count == 1) // the only element that we just inserted is there
                {
                    Monitor.Pulse(_lockObject);
                }
            }
        }
Esempio n. 5
0
        static void deviceProvider_DeviceFound(object sender, DeviceInfoEventArgs e)
        {
            IDeviceProvider deviceProvider = (IDeviceProvider)sender;

            Console.WriteLine("A device has been found.");
            IDeviceInfo foundDeviceInfo = e.DeviceInfo;

            // Example 2. Connecting to a discovered device.
            // When you connect to a discovered device, it will result in a IDevice.
            // IDevice represents the device when connected.
            Console.WriteLine("Connecting to the device...");
            IDevice device = deviceProvider.Connect(foundDeviceInfo);

            Console.WriteLine("Connected to the device.");

            // You have connected to the device,
            // and can now use 'device' to interact with the connected device.
            // Note that 'device.DeviceInfo' is refering to 'foundDeviceInfo', which we used to connect to the device.
            // We can use the Disconnected event to stay informed if we can still use the device.
            device.Disconnected += device_Disconnected;

            // When the 'device' is an 'IDevice' you can only access properties that are common to
            // all Devices (Wiimote, BalanceBoard, etc...).
            // These devices have their own types in WiiDeviceLibrary: IWiimote and IBalanceBoard. Both of these types inherit from IDevice.
            // To use properties specific to the devices you will have to cast the 'device' to the proper interface.

            // First we check if the device is the desired type.
            if (device is IWiimote)
            {
                IWiimote wiimote = (IWiimote)device;
                Console.WriteLine("We have connected to a Wiimote device.");
                // Here we have access to all the operations that we can perform on a Wiimote.
                // That's it for connecting to Wii devices.
            }
            else if (device is IBalanceBoard)
            {
                IBalanceBoard balanceboard = (IBalanceBoard)device;
                Console.WriteLine("We have connected to a BalanceBoard device.");
                // Here we have access to all the operations that we can perform on a BalanceBoard.
            }

            // If we don't want to be connected to the device, we can disconnect like this:
            device.Disconnect();
        }
Esempio n. 6
0
        void DeviceFound(object sender, DeviceInfoEventArgs args)
        {
            IDevice device = deviceProvider.Connect(args.DeviceInfo);

            Console.WriteLine("Found device: " + device.ToString());

            board = (IBalanceBoard)device;

            connected(sender, args);

            Console.WriteLine("Waiting 2 seconds for tare...");
            Thread.Sleep(2000);
            Console.WriteLine("Tare done.");

            tare[0] = board.TopLeftWeight;
            tare[1] = board.BottomLeftWeight;

            tare[2] = board.TopRightWeight;
            tare[3] = board.BottomRightWeight;

            board.Updated += Updated;
        }
Esempio n. 7
0
 ///<summary>
 /// Constructor that sets current balance state for the event. </summary>
 public BalanceChangedEventArgs(IBalanceBoard balance)
 {
     _balance = balance;
 }