private static void measure()
        {
            _connectedMtwData.Clear();

            foreach (var detectedDevices in _xda._DetectedDevices)
            {
                _measuringDevice = _xda.getDevice(detectedDevices.deviceId());
                _measuringDevice.gotoMeasurement();
                var deviceIds = _measuringDevice.children();
                for (uint i = 0; i < deviceIds.size(); i++)
                {
                    var trackingDevice = new XsDevice(deviceIds.at(i));
                    var callback       = new MyMtCallback();

                    var mtwData = new ConnectedMtData();
                    _connectedMtwData.Add(trackingDevice.deviceId().toInt(), mtwData);

                    // connect signals
                    callback.DataAvailable += new EventHandler <DataAvailableArgs>(_callbackHandler_DataAvailable);

                    trackingDevice.addCallbackHandler(callback);
                    _measuringMts.Add(trackingDevice, callback);
                    logger.Log($"Completed setting up tracker {trackingDevice.deviceId().toInt().ToString()} for measuring.");
                }
                logger.Log($"Completed setting up device {detectedDevices.deviceId().toInt().ToString()} for measuring.");
            }
        }
Exemplo n.º 2
0
    private void ScanForStations()
    {
        List <MasterInfo> _stations = new List <MasterInfo>();

        _xda.scanPorts();

        if (_xda._DetectedDevices.Count > 0)
        {
            foreach (XsPortInfo portInfo in _xda._DetectedDevices)
            {
                if (portInfo.deviceId().isWirelessMaster() || portInfo.deviceId().isAwindaStation())
                {
                    UnityEngine.Debug.Log("found wireless connector");
                    _xda.openPort(portInfo);
                    MasterInfo ai = new MasterInfo(portInfo.deviceId());
                    ai.ComPort  = portInfo.portName();
                    ai.BaudRate = portInfo.baudrate();
                    _stations.Add(ai);
                    break;
                }
            }

            if (_stations.Count > 0)
            {
                UnityEngine.Debug.Log("Found station: " + _stations[0].ToString() + " ... creating master device.");
                _masterDevice = _xda.getDevice(_stations[0].DeviceId);

                if (!_masterDevice.gotoConfig())
                {
                    throw new UnityException("could not enter configuration mode of created master device");
                }
                UnityEngine.Debug.Log("master device created successfully, ready to enable radio");
            }
            else
            {
                throw new UnityException("no station could be found, make sure drivers are installed correctly");
            }
        }
    }