Example #1
0
        async Task <bool> TryConnectToLemuria(string ip)
        {
            var hasConnected = false;

            try
            {
                IPAddress = ip;
                var hubConnection = new HubConnection(ip);
                LemurianHub = hubConnection.CreateHubProxy("LemuriaHub");
                LemurianHub.On <bool>("NotifyTopLeftIR", NotifyTopLeftIRCallback);
                LemurianHub.On <bool>("NotifyTopRightIR", NotifyTopRightIRCallback);
                LemurianHub.On <bool>("NotifyBottomLeftIR", NotifyBottomLeftIRCallback);
                LemurianHub.On <bool>("NotifyBottomRightIR", NotifyBottomRightIRCallback);
                LemurianHub.On <double>("NotifySonarDistance", NotifySonarDistanceCallback);
                LemurianHub.On <double, double>("NotifyTemperatureHumidity", NotifyTemperatureHumidityCallback);
                await hubConnection.Start(new LongPollingTransport());

                // Start the Lemuria
                hasConnected = await LemurianHub.Invoke <bool>("LemurianSignal", "master");
            }
            catch (Exception)
            {
                hasConnected = false;
            }


            return(hasConnected);
        }
Example #2
0
        private async void ConnectButton_Click(object sender, RoutedEventArgs e)
        {
            var ip = "";

            if (IPAddressText.Text == "" || IPAddressText.Text == "default")
            {
                ip = IPAddress;
            }
            else
            {
                ip = IPAddressText.Text;
            }
            ConnectStatusText.Text = "Loading...";
            if (await TryConnectToLemuria(ip))
            {
                SelectPage("main");
                CoreWindow.GetForCurrentThread().KeyDown += MainPage_KeyDown;
                CoreWindow.GetForCurrentThread().KeyUp   += MainPage_KeyUp;
                UpdateSettingsPage(await LemurianHub.Invoke <SettingsModels>("GetLemurianSettings", "master"));
                ConnectStatusText.Text = "Connect to the server";
            }
            else
            {
                ConnectStatusText.Text = "Please check the IP Address and try again";
            }
        }
Example #3
0
 // Motor
 private async void StartMotorBSpeed_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
 {
     await LemurianHub.Invoke <bool>("SetStartMotorBSpeed", (int)e.NewValue);
 }
Example #4
0
 private async void TopLeftIRSensor_Toggled(object sender, RoutedEventArgs e)
 {
     UpdateIRStatus();
     await LemurianHub.Invoke <bool>("SetTopLeftIRSensor", ((ToggleSwitch)sender).IsOn);
 }
Example #5
0
 private async void FrontSonarSensor_Toggled(object sender, RoutedEventArgs e)
 {
     await LemurianHub.Invoke <bool>("SetFrontSonarSensor", ((ToggleSwitch)sender).IsOn);
 }
Example #6
0
 // Temperature
 private async void TemperatureHumiditySensor_Toggled(object sender, RoutedEventArgs e)
 {
     await LemurianHub.Invoke <bool>("SetTemperatureHumiditySensor", ((ToggleSwitch)sender).IsOn);
 }
Example #7
0
 // Face detection
 private async void FaceDetectionCamera_Toggled(object sender, RoutedEventArgs e)
 {
     await LemurianHub.Invoke <bool>("SetFaceDetectionCamera", ((ToggleSwitch)sender).IsOn);
 }
Example #8
0
 private async void LemurianMove(string direction, MotorSpeedModels speed)
 {
     // Send this data to the Server
     await LemurianHub.Invoke("LemurianMove", new object[] { direction, speed });
 }