public static void SendToBase(string header, string msg) { SynchronisationData syncData = SynchronisationData.PackDataSingle(header, msg); LatestData = syncData; LattePandaCommunication.SendObjectAsJson(syncData); }
public static SynchronisationData PackDataSingle(string header, string data) { SynchronisationData syncData = new SynchronisationData(); switch (header) { case "Navigation": syncData.Navigation = data; break; case "BaseMovement": syncData.BaseMovement = data; break; case "Gesture": syncData.Gesture = data; break; case "GenerateQR": syncData.GenerateQR = data; break; case "Speech": syncData.Speech = data; break; case "PicturePath": syncData.PicturePath = data; break; case "VideoPath": syncData.VideoPath = data; break; case "Telepresence": syncData.Telepresence = data; break; case "ChatBot": syncData.ChatBot = data; break; case "GuidedTour": syncData.GuidedTour = data; break; case "AskQuestion": syncData.AskQuestion = data; break; case "DisplayMedia": syncData.DisplayMedia = data; break; } return(syncData); }
private static async Task HandleBotResponse(IEnumerable <Activity> activities, string userQuery) { foreach (Activity activity in activities) { if (activity.Text != null) { string[] allAnswers = activity.Text.Split('|'); Random rand = new Random(); string randomAns = allAnswers[rand.Next(allAnswers.Length)]; AnswerTemplate answer = new AnswerTemplate(); answer.SplitMessage(randomAns); ConversationGlobalFlow.AskAgain = false; //answer.MessageToSpeak = "ask again" Debug.WriteLine("Reply: " + answer.MessageToSpeak); ExcelHelper.AddData(userQuery, answer.MessageToSpeak); if (GlobalFlowControl.moduleActivated == false) { return; } if (answer.MessageToSpeak.ToLower().Contains("ask again")) { if (GlobalFlowControl.moduleActivated == false || GlobalFlowControl.ChatbotInterrupted == true) { return; } /*ConversationGlobalFlow.AskAgain = true; * askAgainCount++; * if (askAgainCount == 2) * { * GlobalFlowControl.SendToBase("ChatBot", "StopTalking"); * askAgainCount = 0; * ConversationGlobalFlow.AskAgain = false; * return; * } */ //GlobalFlowControl.SendToBase("ChatBot", "IsTalking"); //SpeechGeneration.SpeakSync("Sorry. I don't understand!"); answer.MessageToSpeak = "Sorry. I don't understand"; //return; } else { askAgainCount = 0; } if (GlobalFlowControl.moduleActivated == false) { return; } if (answer.PicturePath != null) { if (answer.AutoNavLocation != null) { answer.PicturePath = @"locations\" + answer.PicturePath; } else { answer.PicturePath = @"qna\" + answer.PicturePath; } GlobalFlowControl.SendToBase("DisplayMedia", answer.PicturePath); if (answer.DisplayMediaDuration == 0) { answer.DisplayMediaDuration += 2; } } try { if (GlobalFlowControl.moduleActivated == false) { return; } GlobalFlowControl.SendToBase("ChatBot", "IsTalking"); SaySync(answer.MessageToSpeak); if (answer.VideoPath != null) { GlobalFlowControl.SendToBase("VideoPath", answer.VideoPath); } if (answer.DisplayMediaDuration > 0) { Thread.Sleep(1000 * answer.DisplayMediaDuration); } if (answer.AutoNavLocation != null) { SaySync("Do you want me to lead you there?"); SayAsync("Yes or No?"); GlobalFlowControl.SendToBase("DisplayMedia", GlobalData.ListeningModeImg); string reply = await SpeechRecognition.RecognizeQuery(3000).ConfigureAwait(false); if (reply != null) { reply = reply.ToLower(); if (reply.Contains("yes") || reply.Contains("yeah") || reply.Contains("yup") || reply.Contains("ok")) { SaySync("OK! Follow me"); GlobalFlowControl.IsNavigationInChatBot = true; GlobalFlowControl.IsReachedGoal = false; GlobalFlowControl.IsCancelledNavigation = false; var data = new SynchronisationData { Navigation = answer.AutoNavLocation, ChatBot = "NavigationOn" }; GlobalFlowControl.SendToBase(data); /*while (!GlobalFlowControl.IsReachedGoal * && !GlobalFlowControl.IsCancelledNavigation) ; * Thread.Sleep(500); * GlobalFlowControl.SendToBase("Navigation", "Stop"); * if (GlobalFlowControl.IsCancelledNavigation) return; */ return; } SaySync("Thank you, have a nice day"); } } } catch { if (GlobalFlowControl.ChatbotInterrupted) { continue; } } GlobalFlowControl.SendToBase("ChatBot", "StopTalking"); } } }
public static void SendToBase(SynchronisationData data) { LattePandaCommunication.SendObjectAsJson(data); }