private QiServiceModule( string name, QiSession session, IEnumerable<string> methodNames, IEnumerable<string> signalNames ) { Name = name; Session = session; MethodNames = methodNames.ToArray(); SignalNames = signalNames.ToArray(); }
static void Main(string[] args) { string host = "http://pepper1.local"; Task.Run(async () => { try { using (var rawSession = new QiSession(host)) using (var writer = new StreamWriter("socket_datas.txt")) using (var session = new LoggingQiSession(rawSession, writer)) { var tts = await session.LoadService("ALTextToSpeech"); await tts.Invoke("setLanguage", "English"); await tts.Invoke("say", "Hello."); } } catch(Exception ex) { Console.WriteLine(ex.Message); } }).Wait(); }
/// <summary>メソッド名やシグナル名の情報をもとにインスタンスを生成します。</summary> /// <param name="data">メソッド/シグナル名情報を含むサーバからのデータ全体</param> /// <returns>新しいインスタンス</returns> public static QiServiceModule CreateFromMetaObject(QiSession session, JObject data) { string name = (string)((data["result"]["pyobject"] as JValue).Value); var methodNames = (data["result"]["metaobject"]["methods"] as JObject) .Values() .Select(jt => (string)((jt as JValue).Value)); var signalNames = (data["result"]["metaobject"]["signals"] as JObject) .Values() .Select(jt => (string)((jt as JValue).Value)); return new QiServiceModule(name, session, methodNames, signalNames); }