async void ac_ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { double x = args.Reading.AccelerationX * 100d; double y = args.Reading.AccelerationY * 100d; double z = args.Reading.AccelerationZ * 100d; System.Diagnostics.Debug.WriteLine("X={0:NO},Y={1:NO},Z={2}", x, y, z); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => { if (Math.Abs(x) > 100d || Math.Abs(y) > 60d || Math.Abs(z) > 50d) { try { int imageIndex = new Random().Next(1, 5); //this codes is going to read the image file from the storage that in the phone rather than in the computer. Windows.Storage.StorageFile theFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri(string.Format("ms-appx:///Assets/f{0}.png", imageIndex), UriKind.Absolute)); BitmapImage bitmap = new BitmapImage(); bitmap.SetSource(await theFile.OpenReadAsync()); this.img.Source= bitmap; } catch (Exception e) { throw e; } } }); }
private void ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { var reading = args.Reading; Vector current = new Vector(reading.AccelerationX, reading.AccelerationY, reading.AccelerationZ); var delta = new Vector(current.X - _previousValue.X, current.Y - _previousValue.Y, current.Z - _previousValue.Z); _previousValue = current; if (delta.Length() > 1.0) { Dispatcher.BeginInvoke(() => { statusTextBlock.Text = "receiving data from accelerometer."; // Show the numeric values xTextBlock.Text = "X: " + reading.AccelerationX.ToString("0.00"); yTextBlock.Text = "Y: " + reading.AccelerationY.ToString("0.00"); zTextBlock.Text = "Z: " + reading.AccelerationZ.ToString("0.00"); // Show the values graphically xLine.X2 = xLine.X1 + reading.AccelerationX * 100; yLine.Y2 = yLine.Y1 - reading.AccelerationY * 100; zLine.X2 = zLine.X1 - reading.AccelerationZ * 50; zLine.Y2 = zLine.Y1 + reading.AccelerationZ * 50; }); } }
void acc_ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { Dispatcher.BeginInvoke(() => { accOut.Text = "Accelerometer: <" + args.Reading.AccelerationX + ", " + args.Reading.AccelerationY + ", " + args.Reading.AccelerationZ + ">"; }); }
public MainPage() { InitializeComponent(); _accelerometer = Accelerometer.GetDefault(); _accelerometer.ReadingChanged += _accelerometer_ReadingChanged; }
void accelerometer_ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { double magnitude = Math.Sqrt( args.Reading.AccelerationX * args.Reading.AccelerationX + args.Reading.AccelerationY * args.Reading.AccelerationY + args.Reading.AccelerationZ * args.Reading.AccelerationZ); if (magnitude > 1.01 && !stepping) { stepping = true; steps += 1; // Prevent a race condition of the last subscriber unsubscribing // before we get to the null check. EventHandler<int> handler = Stepped; // Event will be null if there are no subscribers if (handler != null) { handler(this, steps); } } else if (magnitude < 1.0) { stepping = false; } }
private async void CalculateDeviceRotation(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { // Compute the rotation angle based on the accelerometer's position var angle = Math.Atan2(args.Reading.AccelerationY, args.Reading.AccelerationX) * toDegrees; // Since our arrow points upwards insted of the right, we rotate the coordinate system by 90 degrees angle += 90; // Ensure that the range of the value is between [0, 360) if (angle < 0) { angle += 360; } rotationAngle = angle; // Update the UI with the new value await Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => { deviceRotation.Text = rotationAngle.ToString(); UpdateArrowForRotation(); }); }
public MainPage() { InitializeComponent(); // this.NavigationCacheMode = NavigationCacheMode.Required; //DataEntry.saveAll(); //DataEntry.loadAll(); this.accelSensor = Accelerometer.GetDefault(); if (this.accelSensor != null) this.accelSensor.ReadingChanged += new TypedEventHandler<Accelerometer, AccelerometerReadingChangedEventArgs>(myAccelHandler); this.compSensor = Compass.GetDefault(); if (this.compSensor != null) this.compSensor.ReadingChanged += new TypedEventHandler<Compass, CompassReadingChangedEventArgs>(myCompassHandler); this.gyroSensor = Gyrometer.GetDefault(); if (this.gyroSensor != null) this.gyroSensor.ReadingChanged += new TypedEventHandler<Gyrometer, GyrometerReadingChangedEventArgs>(myGyroHandler); this.incliSensor = Inclinometer.GetDefault(); if (this.incliSensor != null) this.incliSensor.ReadingChanged += new TypedEventHandler<Inclinometer, InclinometerReadingChangedEventArgs>(myIncliHandler); this.lightSensor = LightSensor.GetDefault(); if (this.lightSensor != null) this.lightSensor.ReadingChanged += new TypedEventHandler<LightSensor, LightSensorReadingChangedEventArgs>(myLightHandler); accelX = accelY = accelZ = comp = gyroX = gyroY = gyroZ = incliYaw = incliPitch = incliRoll = light = 0; // Sample code to localize the ApplicationBar //BuildLocalizedApplicationBar(); }
private async void Accelerometer_ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { await toggleAccelerometer.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() => { var val = 0f; if (togglePID.IsOn) { // Limit the accelerometer PID control to 500 RPM max val = (float)args.Reading.AccelerationZ * -500f; if (val > 500) val = 500; if (val < 0) val = 0; pid.SetPoint = (float)val; Slider.Value = (int)val; } else { val = (float)args.Reading.AccelerationZ * -100f; if (val > 100) val = 100; if (val < 0) val = 0; motor.Throttle = (double)val; Slider.Value = (int)val * 12.0; } })); }
/// <summary> /// Initialise the input system. Note that accelerometer input defaults to off. /// </summary> /// <param name="game"></param> public InputManager(Project2Game game) : base(game) { // initialisation useMouseDelta = false; accelerometerEnabled = false; mouseDelta = new Vector2(); keyboardManager = new KeyboardManager(game); mouseManager = new MouseManager(game); pointerManager = new PointerManager(game); keyMapping = new KeyMapping(); // get the accelerometer. Returns null if no accelerometer found accelerometer = Accelerometer.GetDefault(); window = Window.Current.CoreWindow; // Set up the gesture recognizer. In this game, it only responds to TranslateX, TranslateY and Tap events gestureRecognizer = new Windows.UI.Input.GestureRecognizer(); gestureRecognizer.GestureSettings = GestureSettings.ManipulationTranslateX | GestureSettings.ManipulationTranslateY | GestureSettings.Tap; // Register event handlers for pointer events window.PointerPressed += OnPointerPressed; window.PointerMoved += OnPointerMoved; window.PointerReleased += OnPointerReleased; // automatically enable accelerometer if we have one this.AccelerometerEnabled(true); this.MouseDeltaEnabled(true); }
/// <summary> /// Background task entry point. /// </summary> /// <param name="taskInstance"></param> public void Run(IBackgroundTaskInstance taskInstance) { Accelerometer = Accelerometer.GetDefault(); if (null != Accelerometer) { SampleCount = 0; // Select a report interval that is both suitable for the purposes of the app and supported by the sensor. uint minReportIntervalMsecs = Accelerometer.MinimumReportInterval; Accelerometer.ReportInterval = minReportIntervalMsecs > 16 ? minReportIntervalMsecs : 16; // Subscribe to accelerometer ReadingChanged events. Accelerometer.ReadingChanged += new TypedEventHandler<Accelerometer, AccelerometerReadingChangedEventArgs>(ReadingChanged); // Take a deferral that is released when the task is completed. Deferral = taskInstance.GetDeferral(); // Get notified when the task is canceled. taskInstance.Canceled += new BackgroundTaskCanceledEventHandler(OnCanceled); // Store a setting so that the app knows that the task is running. ApplicationData.Current.LocalSettings.Values["IsBackgroundTaskActive"] = true; } }
public ControlPage() { this.InitializeComponent(); turn = Turn.none; direction = Direction.none; accelerometer = App.accelerometer; bluetooth = App.bluetooth; arduino = App.arduino; if (accelerometer == null || bluetooth == null || arduino == null) { Frame.Navigate(typeof(MainPage)); return; } startButton.IsEnabled = true; stopButton.IsEnabled = true; disconnectButton.IsEnabled = true; keepScreenOnRequest = new DisplayRequest(); keepScreenOnRequest.RequestActive(); App.arduino.pinMode(enableA, PinMode.OUTPUT); App.arduino.pinMode(MotorA1, PinMode.OUTPUT); App.arduino.pinMode(MotorA2, PinMode.OUTPUT); App.arduino.pinMode(enableB, PinMode.OUTPUT); App.arduino.pinMode(MotorB1, PinMode.OUTPUT); App.arduino.pinMode(MotorB2, PinMode.OUTPUT); arduino.digitalWrite(enableA, PinState.HIGH); arduino.digitalWrite(enableB, PinState.HIGH); }
async void accelerometer_ReadingChanged(Windows.Devices.Sensors.Accelerometer sender, Windows.Devices.Sensors.AccelerometerReadingChangedEventArgs args) { try { if (_locator.LocationStatus != PositionStatus.Disabled) { try { Geoposition pos = await _locator.GetGeopositionAsync(); System.Diagnostics.Debug.WriteLine("LAT " + pos.Coordinate.Latitude + " " + pos.Coordinate.Longitude); updateCoordList(pos.Coordinate.Latitude, pos.Coordinate.Longitude); //update EndTime this.setEndTime(); } catch (Exception ex) { if (ex.HResult != unchecked ((int)0x800705b4)) { System.Diagnostics.Debug.WriteLine(ex); } } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } }
public ControlPageMaisto() { this.InitializeComponent(); turn = Turn.none; direction = Direction.none; accelerometer = App.accelerometer; bluetooth = App.bluetooth; arduino = App.arduino; if( accelerometer == null || bluetooth == null || arduino == null ) { Frame.Navigate( typeof( MainPage ) ); return; } startButton.IsEnabled = true; stopButton.IsEnabled = true; disconnectButton.IsEnabled = true; bluetooth.ConnectionLost += Bluetooth_ConnectionLost; keepScreenOnRequest = new DisplayRequest(); keepScreenOnRequest.RequestActive(); App.arduino.pinMode( FORWARD_CONTROL_PIN, PinMode.OUTPUT ); App.arduino.pinMode( REVERSE_CONTROL_PIN, PinMode.OUTPUT ); App.arduino.pinMode( LEFT_CONTROL_PIN, PinMode.OUTPUT ); App.arduino.pinMode( RIGHT_CONTROL_PIN, PinMode.OUTPUT ); }
public AccelerationViewModel(AgresivityCalculator calculator) { ReportInterval = 5; _calculator = calculator; _accelerometer = Accelerometer.GetDefault(); _accelerometer.ReportInterval = ReportInterval; }
private AccelerometerObservable() { _accel = Accelerometer.GetDefault(); #region + Event Subscriptions + Action<ReadingChangedHandler> subscribeEvent = h => { _accel.ReadingChanged += h; if (_accel.ReportInterval < _reportInterval) _accel.ReportInterval = _reportInterval; }; Action<ReadingChangedHandler> unsubscribeEvent = h => { _accel.ReadingChanged -= h; _accel.ReportInterval = 0; }; #endregion if (_accel != null) { _reportInterval = _accel.MinimumReportInterval; if (_reportInterval < MIN_REPORT_INTERVAL) _reportInterval = MIN_REPORT_INTERVAL; _accelObs = Observable.FromEventPattern<ReadingChangedHandler, AccelerometerReadingChangedEventArgs> (subscribeEvent, unsubscribeEvent) .Select(x => ToVector(x.EventArgs.Reading)) .Publish() .RefCount(); } else { _accelObs = Observable.Empty<Vector>(); } }
public ControlPage() { this.InitializeComponent(); turn = Turn.none; direction = Direction.none; accelerometer = App.accelerometer; bluetooth = App.bluetooth; arduino = App.arduino; if( accelerometer == null || bluetooth == null || arduino == null ) { Frame.Navigate( typeof( MainPage ) ); return; } startButton.IsEnabled = true; stopButton.IsEnabled = true; disconnectButton.IsEnabled = true; bluetooth.ConnectionLost += Bluetooth_ConnectionLost; keepScreenOnRequest = new DisplayRequest(); keepScreenOnRequest.RequestActive(); App.arduino.pinMode( LR_DIRECTION_CONTROL_PIN, PinMode.OUTPUT ); App.arduino.pinMode( FB_DIRECTION_CONTROL_PIN, PinMode.OUTPUT ); App.arduino.pinMode( LR_MOTOR_CONTROL_PIN, PinMode.PWM ); App.arduino.pinMode( FB_MOTOR_CONTROL_PIN, PinMode.PWM ); App.arduino.pinMode(HEARTBEAT_LED_PIN, PinMode.OUTPUT); }
void accelerometer_ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { Deployment.Current.Dispatcher.BeginInvoke(() => { accelerometerReading = args.Reading; ShowData(); }); }
void accelerometer_Shaken(Accelerometer sender, AccelerometerShakenEventArgs args) { Deployment.Current.Dispatcher.BeginInvoke(() => { statusTextBlock.Text = "手机在摇动 时间点" + args.Timestamp.DateTime.ToLongTimeString(); }); }
async void Accelerometer_Shaken(Accelerometer sender, AccelerometerShakenEventArgs args) { var dispatcher = App.Dispatcher; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, (DispatchedHandler)(() => { _shaken(this, args); })); }
async void accelerometer_Shaken(Accelerometer sender, AccelerometerShakenEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { shakes++; ShakeCount.Text = shakes.ToString(); }); }
/// <summary> /// Reads in the Accelerometer data for windows8 devices. /// </summary> private void Windows8AccelerometerChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { // For whatever reason, this is insconsistent with windows phone... // so lets swap the reading here. _currentReading.X = -(float)args.Reading.AccelerationY; _currentReading.Y = -(float)args.Reading.AccelerationX; _currentReading.Z = -(float)args.Reading.AccelerationZ; }
private async void AccelerometerOnShaken(Sensor.Accelerometer sender, Sensor.AccelerometerShakenEventArgs args) { await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { ShakeCount = ShakeCount + 1; }); }
async void accelerometer_ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { XValue.Text = args.Reading.AccelerationX.ToString(); YValue.Text = args.Reading.AccelerationY.ToString(); ZValue.Text = args.Reading.AccelerationZ.ToString(); }); }
/// <summary> /// Stops this instance. /// </summary> partial void Stop() { var accelerometer = AccelerometerSensor.GetDefault(); if (accelerometer != null) { accelerometer.ReadingChanged -= AccelerometerOnReadingChanged; } }
async void a_ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { System.Diagnostics.Debug.WriteLine(args + "改变了。。。"); // 拿到变化值 await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { }); }
public void Start() { if (_accelerometer != null) { throw new MvxException("Accelerometer already started"); } _accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault(); _accelerometer.ReadingChanged += AccelerometerOnReadingChanged; }
public void Stop() { if (_accelerometer == null) { throw new MvxException("Accelerometer not started"); } _accelerometer.ReadingChanged -= AccelerometerOnReadingChanged; _accelerometer = null; }
private async void OnAccelerometerReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { var top = args.Reading.AccelerationZ; var left = args.Reading.AccelerationX; await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { this.ViewModel.MoveBalls(top, left); }); }
private void SetupSensor() { _accelerometer = Sensor.Accelerometer.GetDefault(); if (_accelerometer == null) { // tell user no accelerometer } }
void _accelerometer_ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { Dispatcher.BeginInvoke(() => { lblX.Text = args.Reading.AccelerationX.ToString(); lblY.Text = args.Reading.AccelerationY.ToString(); lblZ.Text = args.Reading.AccelerationZ.ToString(); }); }
private void SetupSensor() { _accelerometer = Sensor.Accelerometer.GetDefault(); if ( _accelerometer == null ) { // tell user no accelerometer } }
private void OnAccelerometerReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args) { Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { this.tbx.Text = string.Format("X: {0}", args.Reading.AccelerationX); this.tby.Text = string.Format("Y: {0}", args.Reading.AccelerationY); this.tbz.Text = string.Format("Z: {0}", args.Reading.AccelerationZ); }); }
public MainPage() { accelerometer = Accelerometer.GetDefault(); pid = new PidController.PidController(PROPORTIONAL_GAIN, INTEGRAL_GAIN, DERIVATIVE_GAIN, 100f, 0f); pid.SetPoint = 0; motor = new Motor(0, 36, 250); this.InitializeComponent(); }
private void RegisterShaken() { shakenHandler = new TypedEventHandler<Accelerometer, AccelerometerShakenEventArgs>(OnShaken); accelerometer = Accelerometer.GetDefault(); if (accelerometer != null) { accelerometer.Shaken += shakenHandler; } }
internal static void PlatformStart(SensorSpeed sensorSpeed) { sensor = DefaultSensor; var interval = sensorSpeed.ToPlatform(); sensor.ReportInterval = sensor.MinimumReportInterval >= interval ? sensor.MinimumReportInterval : interval; sensor.ReadingChanged += DataUpdated; }
static Sensor GetSensor() { try { return(Sensor.GetDefault()); } catch { return(null); } }
void OnReadingChanged(Sensor sender, AccelerometerReadingChangedEventArgs args) { var handler = changed; if (handler != null) { var value = ConvertToVector(args.Reading); var e = new AccelerometerEventArgs(value); handler.Invoke(this, e); } }
public void startUpdates() { if (_accelerometer == null) { _accelerometer = Sensors.Accelerometer.GetDefault(); if (_accelerometer == null) { throw new Exception("No Accelerometer found"); } } _accelerometer.ReadingChanged += new TypedEventHandler <Sensors.Accelerometer, Sensors.AccelerometerReadingChangedEventArgs>(ReadingChanged); }
private async void AccelerometerOnReadingChanged(Sensor.Accelerometer sender, Sensor.AccelerometerReadingChangedEventArgs args) { await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { XAcceleration = args.Reading.AccelerationX; YAcceleration = args.Reading.AccelerationY; ZAcceleration = args.Reading.AccelerationZ; SetupNewLocation(); }); }
private void AccelerometerOnReadingChanged(Windows.Devices.Sensors.Accelerometer sender, AccelerometerReadingChangedEventArgs args) { var handler = ReadingAvailable; if (handler == null) { return; } var reading = ToReading(args.Reading); handler(this, new MvxValueEventArgs <MvxAccelerometerReading>(reading)); }
/// <summary> /// Starts this instance. /// </summary> partial void Start() { var accelerometer = AccelerometerSensor.GetDefault(); if (accelerometer == null) { return; } accelerometer.ReportInterval = (uint)this.Interval; accelerometer.ReadingChanged += AccelerometerOnReadingChanged; }
private void Initsensor() { //Accelerometer 相關 _accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault(); //Gyromete 相關 _gyrometer = Gyrometer.GetDefault(); //Create log file Alog = new TestLog("TestAccelerometer.txt"); Glog = new TestLog("TestGyrometer.txt"); Hlog = new TestLog("TestAS7000HRM.txt"); }
// Connect to the BLE device and send the data private async Task UpdateAllData() { if (device == null) { Debug.WriteLine("Device NULL"); return; } // Heartbeat Data var heartRateHex = bs.GetHeartRateHexForMioty(); // Configure and send Heartbeat data using the AT command var HeartbeatData = ATCMGS.Concat(HEARTBEAT_SIZE_CR).Concat(HEARTBEAT_ID).Concat(heartRateHex).Concat(AT_SUFFIX).ToArray(); await MiotyTransmitter(character, HeartbeatData, "Heartbeat"); // Accelerometer Data _accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault(); if (_accelerometer == null) { Debug.WriteLine("No accelerometer found"); } // Configure and send Accelerometer data using the AT command AccelerometerReading reading = _accelerometer.GetCurrentReading(); _accelerometer = null; var AccelerometerHex = ConvertAccelerometerForMioty(reading); var AccelData = ATCMGS.Concat(ACCEL_SIZE_CR).Concat(ACCEL_ID).Concat(AccelerometerHex).Concat(AT_SUFFIX).ToArray(); await MiotyTransmitter(character, AccelData, "Accelerometer"); // NFC Data if (bNFCText) { var NFCHex = StringIntoHexForMioty(NFCText); var Size = IntIntoHexForMioty(NFCHex.Count() + 2); var NFCData = ATCMGS.Concat(Size).Concat(CR).Concat(NFC_ID).Concat(NFCHex).Concat(AT_SUFFIX).ToArray(); bNFCText = false; await MiotyTransmitter(character, NFCData, "NFC"); } return; }
public Accelerometer() { this.InitializeComponent(); _accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault(); if (_accelerometer != null) { // Select a report interval that is both suitable for the purposes of the app and supported by the sensor. // This value will be used later to activate the sensor. uint minReportInterval = _accelerometer.MinimumReportInterval; _desiredReportInterval = minReportInterval > 16 ? minReportInterval : 16; } else { //rootPage.NotifyUser("No accelerometer found", NotifyType.ErrorMessage); MessageBlock.Text = "No accelerometer found"; } }
internal static void PlatformStart(SensorSpeed sensorSpeed) { sensor = DefaultSensor; var interval = NormalInterval; switch (sensorSpeed) { case SensorSpeed.Fastest: interval = FastestInterval; break; case SensorSpeed.Game: interval = GameInterval; break; } sensor.ReportInterval = sensor.MinimumReportInterval >= interval ? sensor.MinimumReportInterval : interval; sensor.ReadingChanged += DataUpdated; }
void Sensor_ReadingChanged(Windows.Devices.Sensors.Accelerometer sender, AccelerometerReadingChangedEventArgs args) { var reading = args.Reading; OnChanged(new MotionVector(reading.AccelerationX, reading.AccelerationY, reading.AccelerationZ)); }
private void AccelerometerOnReadingChanged(AccelerometerSensor sender, AccelerometerReadingChangedEventArgs args) { LatestReading = args.Reading.AsVector3(); readingAvailable.Invoke(sender, LatestReading); }
void PageLoaded(object sender, RoutedEventArgs e) { accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault(); accelerometer.ReadingChanged += new Windows.Foundation.TypedEventHandler <Accelerometer, AccelerometerReadingChangedEventArgs>(ReadingChanged); Random rnd = new Random(); m_csi = ((uint)rnd.Next()) & 0xFFFFFF00; m_audioSwitchInfo = (WMEAudioComponent.SWITCHINFO)NavigationService.GetNavigationData(); m_videoSwitchInfo.app_share = m_audioSwitchInfo.app_share; m_videoSwitchInfo.enable_audio = m_audioSwitchInfo.enable_audio; m_videoSwitchInfo.enable_video = m_audioSwitchInfo.enable_video; m_videoSwitchInfo.calliope = m_audioSwitchInfo.calliope; m_videoSwitchInfo.fec = m_audioSwitchInfo.fec; m_videoSwitchInfo.loop = m_audioSwitchInfo.loop; m_videoSwitchInfo.multi_stream = m_audioSwitchInfo.multi_stream; m_videoSwitchInfo.srtp = m_audioSwitchInfo.srtp; m_videoSwitchInfo.tc_aec = m_audioSwitchInfo.tc_aec; m_videoSwitchInfo.video_hw = m_audioSwitchInfo.video_hw; m_videoSwitchInfo.vpio = m_audioSwitchInfo.vpio; m_videoSwitchInfo.dump_audio = m_audioSwitchInfo.dump_audio; m_videoSwitchInfo.dump_video = m_audioSwitchInfo.dump_video; m_server = NavigationService.GetNavigationString1(); m_linus = NavigationService.GetNavigationString2(); m_bgProcessid = NavigationService.GetNavigationInt(); m_bTA = NavigationService.GetNavigationTA(); m_Videohost.SetDataChannelDelegate(DataChannelDataAvailable); m_Videohost.Start(m_csi); StartHeartBeatTimer(); StartStatisticTimer(); //var stopwatch = new Stopwatch(); //stopwatch.Start(); try { if (m_AudioHost == null) { m_AudioHost = (WMEAudioHost)WindowsRuntimeMarshal.GetActivationFactory(typeof(WMEAudioHost)).ActivateInstance(); } } catch (InvalidCastException err) { Debug.WriteLine("[App] Error launching VoIP background process. UI may no longer be in the foreground. Exception: " + err.Message); throw; } //long elapsed_time = stopwatch.ElapsedMilliseconds; //Debug.WriteLine(elapsed_time); m_AudioHost.Start(m_bTA, m_csi); Start_Call(); //this.Dispatcher.BeginInvoke(new StartAudioCallDelegate(Start_Call), this); if (m_bTA) { m_Videohost.InitTAContext(); } }