Ejemplo n.º 1
0
        private string GetStatus()
        {
            var client       = new PiServer.ServiceSoapClient();
            var sensorStatus = client.GetSensorStatusAsync().Result;

            return(sensorStatus.Body.GetSensorStatusResult);
        }
Ejemplo n.º 2
0
        private async void ProcessSignal()
        {
            var client = new PiServer.ServiceSoapClient();

            relayPin.Write(GpioPinValue.High);
            await Task.Delay(500);

            relayPin.Write(GpioPinValue.Low);

            client.UpdateStatusAsync("SignalGarageDoor", "Idle");
        }
Ejemplo n.º 3
0
        private void CheckPhoneTimer_Tick(object sender, object e)
        {
            var client = new PiServer.ServiceSoapClient();
            var result = client.CheckForPhoneAsync().Result;

            if (result)
            {
                tblk_PhoneHome.Text = "Phone is at home";
            }
            else
            {
                tblk_PhoneHome.Text = "Phone is not at home";
            }
        }
Ejemplo n.º 4
0
        private async void DistanceTimer_Tick(object sender, object e)
        {
            pinTrigger.Write(GpioPinValue.High);
            await Task.Delay(10);

            pinTrigger.Write(GpioPinValue.Low);
            while (pinEcho.Read() == GpioPinValue.Low)
            {
                sw_Distance.Start();
            }

            while (pinEcho.Read() == GpioPinValue.High)
            {
            }
            sw_Distance.Stop();

            var elapsed  = sw_Distance.Elapsed.TotalSeconds;
            var distance = elapsed * 34000;

            sw_Distance.Reset();
            distance /= 2;
            var client = new PiServer.ServiceSoapClient();

            if (distance > 20)
            {
                client.UpdateStatusAsync("CarPresent", "No").AsAsyncAction().AsTask().Wait();
                Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    el_Car.Fill = grayBrush;
                });
            }
            else
            {
                client.UpdateStatusAsync("CarPresent", "Yes").AsAsyncAction().AsTask().Wait();
                Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    el_Car.Fill = redBrush;
                });
            }
        }
Ejemplo n.º 5
0
        private void DoorSensor_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            var client = new PiServer.ServiceSoapClient();

            if (sender.Read() == GpioPinValue.High)
            {
                client.UpdateStatusAsync("GarageDoor", "Open");
                Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    el_GarageDoor.Fill = grayBrush;
                });
            }
            else
            {
                client.UpdateStatusAsync("GarageDoor", "Closed");
                Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                                                      () =>
                {
                    el_GarageDoor.Fill = redBrush;
                });
            }
        }