示例#1
0
        // Greeting functions
        private string GreetingCommands(string returnMessage, MessageReplyModels messageReply, string key)
        {
            var greeting = messageReply.Methods[key][0];

            LemurianHub.LemurianGreeting(greeting);
            return(returnMessage);
        }
示例#2
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);
        }
示例#3
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";
            }
        }
示例#4
0
        // Move fuctions
        private void StopMovement()
        {
            MotorSpeedModels speed = new MotorSpeedModels();

            speed.ForwardSpeed  = 0;
            speed.BackwardSpeed = 0;
            speed.LeftSpeed     = 0;
            speed.RightSpeed    = 0;
            MovementTimer.Stop();
            LemurianHub.LemurianMove("stop", speed);
        }
示例#5
0
 // Music functions
 private void MusicFuctions(string status, bool isSearch)
 {
     if (status == "Stop")
     {
         LemurianHub.LemurianMusic(false, "", isSearch);
     }
     else
     {
         LemurianHub.LemurianMusic(true, status, isSearch);
     }
 }
示例#6
0
        public SpeechServices(IDependencyResolver Resolver)
        {
            DefaultHubManager LemurianResolver = new DefaultHubManager(Resolver);

            LemurianHub = LemurianResolver.ResolveHub("LemuriaHub") as LemuriaHub;
            LemurianHub.LemurianSignal("messenger");
            if (MovementTimer == null)
            {
                MovementTimer           = new Timer();
                MovementTimer.Elapsed  += MovementTimer_Tick;
                MovementTimer.AutoReset = false;
            }
        }
示例#7
0
        // Volume functions
        private string VolumeCommands(string returnMessage, MessageReplyModels messageReply, Match m, string key)
        {
            var volume = messageReply.Methods[key][0];

            if (volume == _INT)
            {
                volume        = m.Groups[2].Value;
                returnMessage = returnMessage.Replace(_INT, volume);
            }

            LemurianHub.LemurianVolume(Convert.ToInt32(volume));

            return(returnMessage);
        }
示例#8
0
        // Load functions
        private string LoadTextCommands(string returnMessage, MessageReplyModels messageReply, Match m, string key)
        {
            var type = messageReply.Methods[key][0];
            var text = messageReply.Methods[key][1];

            if (text == _STR)
            {
                text          = m.Groups[2].Value;
                returnMessage = returnMessage.Replace(_STR, text);
            }

            // Sort out the mapping
            if (type == "Analyse")
            {
                var foundWord = false;
                foreach (var item in mevitaeNLPMappingModels)
                {
                    if (foundWord)
                    {
                        break;
                    }

                    foreach (var word in item.Words)
                    {
                        if (word == text.ToLower())
                        {
                            text      = item.Version1;
                            foundWord = true;
                            break;
                        }
                    }
                }
            }

            LemurianHub.LemurianLoadText(type, text);
            return(returnMessage);
        }
示例#9
0
        private void MoveFunctions(string timer, string direction, MotorSpeedModels speed)
        {
            MovementTimer.Stop();

            if (direction == "Stop")
            {
                MovementStatus = false;
            }
            else
            {
                MovementStatus = true;
            }

            if (MovementStatus & direction != "Stop")
            {
                MovementTimer.Interval = Convert.ToInt32(timer) * 1000;
                LemurianHub.LemurianMove(direction.ToLower(), speed);
                MovementTimer.Start();
            }
            else
            {
                StopMovement();
            }
        }
示例#10
0
 // Motor
 private async void StartMotorBSpeed_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
 {
     await LemurianHub.Invoke <bool>("SetStartMotorBSpeed", (int)e.NewValue);
 }
示例#11
0
 private async void TopLeftIRSensor_Toggled(object sender, RoutedEventArgs e)
 {
     UpdateIRStatus();
     await LemurianHub.Invoke <bool>("SetTopLeftIRSensor", ((ToggleSwitch)sender).IsOn);
 }
示例#12
0
 private async void FrontSonarSensor_Toggled(object sender, RoutedEventArgs e)
 {
     await LemurianHub.Invoke <bool>("SetFrontSonarSensor", ((ToggleSwitch)sender).IsOn);
 }
示例#13
0
 // Temperature
 private async void TemperatureHumiditySensor_Toggled(object sender, RoutedEventArgs e)
 {
     await LemurianHub.Invoke <bool>("SetTemperatureHumiditySensor", ((ToggleSwitch)sender).IsOn);
 }
示例#14
0
 // Face detection
 private async void FaceDetectionCamera_Toggled(object sender, RoutedEventArgs e)
 {
     await LemurianHub.Invoke <bool>("SetFaceDetectionCamera", ((ToggleSwitch)sender).IsOn);
 }
示例#15
0
 private async void LemurianMove(string direction, MotorSpeedModels speed)
 {
     // Send this data to the Server
     await LemurianHub.Invoke("LemurianMove", new object[] { direction, speed });
 }