How can I abort Pepper speech via Tablet touchscreen? - pepper

I would like to interrupt Pepper's TextToSpeech service while it speaks by using Pepper Tablet application?
What is the method I need to call to terminate it's speech?

ALTextToSpeech API offers the function stopAll()
To utilize the Pepper Tablet Application, you could make a javascript call to a function like:
function stopTalking() {
QiSession(function (session) {
session.service("ALTextToSpeech").then(function (tts) {
tts.stopAll()
}, function (error) {
console.log("An error occurred:", error)
})
})
}

Related

Async Mutex in Microsoft CppRest SDK

I try to share some data between processes in my backend. How to protect them in async application without mutexes? I try to find something in documentation, but there is nothing in search on 'mutex' request.
I expect something like this:
http_listener listener(on_host);
listener.support([](http_request request) {
GLOBAL_VAR.Async_Mutex.lock(); {
GLOBAL_VAR.do_something();
} GLOBAL_VAR.Async_Mutex.unlock();
return request.reply(200);
});
listener
.open()
.wait();

Does Ember provide a hook to know when there are no outstanding async operations running?

Protractor provides a great API wrapper around selenium-webdriver tests, but one of the ways it does that is by using a hook that Angular provides to denote the completion of all outstanding async/polling operations. This includes http calls, intervals, etc.
I'm fairly new to Ember, but I suspect the equivalent would need to be aware of route changes, http calls, and one or more aspects of the run loop. I've confirmed that such a hook would likely open the door to using Protractor with Ember apps, which is ultimately my goal.
So, is there a way to detect when Ember has entered this "quiet" state?
Here's how Ember does it (only in test mode, and Test is available on the Ember namespace)
function wait(app, value) {
return Test.promise(function(resolve) {
// If this is the first async promise, kick off the async test
if (++countAsync === 1) {
Test.adapter.asyncStart();
}
// Every 10ms, poll for the async thing to have finished
var watcher = setInterval(function() {
// 1. If the router is loading, keep polling
var routerIsLoading = !!app.__container__.lookup('router:main').router.activeTransition;
if (routerIsLoading) { return; }
// 2. If there are pending Ajax requests, keep polling
if (Test.pendingAjaxRequests) { return; }
// 3. If there are scheduled timers or we are inside of a run loop, keep polling
if (run.hasScheduledTimers() || run.currentRunLoop) { return; }
if (Test.waiters && Test.waiters.any(function(waiter) {
var context = waiter[0];
var callback = waiter[1];
return !callback.call(context);
})) { return; }
// Stop polling
clearInterval(watcher);
// If this is the last async promise, end the async test
if (--countAsync === 0) {
Test.adapter.asyncEnd();
}
// Synchronously resolve the promise
run(null, resolve, value);
}, 10);
});
}

Call web service in background while accessing UI

I have a situation where as soon as app starts i have to call a web service to post unsaved data back to the server while i keep on accessing the app. I should be able to navigate to different views, perform UI tasks.
I can use Task
Task CallWebService()
{
return Task.Factory.StartNew(() => {
// make your service call.
});
}
CallWebService().ContinueWith(task => {
if(task.isFaulted)
throw new AggregateException(task.Exception.InnerException.Message);
// Runs when the task is finished
InvokeOnMainThread(() => {
// Hide your activity indicator here.
StopActivityIndicator();
});
});
I dont know where to call InvokeOnMainThread as user could be on any view. How do we handle that.
I would create the downloader as a static class with event handlers (or use dependency resolver). In your view controllers override ViewDidAppear and ViewDidDisappear where you will subscribe and unsubscribe to the events.
In your AppDelegate.cs, You can add your "Task" to the FinishedLaunching override and the OnActivated override, assuming you have a way to determine if there is any "unsaved" data, that needs to be sent to the server.
public override void OnActivated (UIApplication application)
{
}
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
}

Windows Store App Unit Testing a USB device

I'm writing a USB device API for Windows Store Apps that uses Windows.Devices.USB API from Windows 8.1 to connect and communicate with the custom USB device. I'm using the Visual Studio 2013 dev preview IDE.
The following function in the library is used to connect to the USB device.
(Simplified for clarity)
public static async Task<string> ConnectUSB()
{
string deviceId = string.Empty;
string result = UsbDevice.GetDeviceSelector(new Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"));
var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(result, null);
if (myDevices.Count > 0)
{
deviceId = myDevices[0].Id;
}
UsbDevice usbDevice = null;
try
{
usbDevice = await UsbDevice.FromIdAsync(deviceId);
}
catch (Exception)
{
throw;
}
if (usbDevice != null)
return "Connected";
return string.Empty;
}
When called from the Windows Store App project, this function connects to the device flawlessly. However, when called from the Unit Test Library for Windows Store Apps project, the statement in the try block throws an exception.
A method was called at an unexpected time. (Exception from HRESULT: 0x8000000E)
from what I've looked around, this happens when an Async function is called without the await keyword. But I'm using the await keyword alright!
Some more info, I am unable to use NUnit to write unit tests for Store Apps so am using the MSTest Framework.
[TestClass]
public class UnitTest1
{
[TestMethod]
public async Task TestMethod1()
{
await ConnectToUSB.ConnectUSB();
}
}
Also, I've included the following capability tags in the manifest files of both the App store projects too without which it's impossible for the Store Apps to connect to devices.
<m2:DeviceCapability Name="usb">
<m2:Device Id="vidpid:ZZZZ XXXX">
<m2:Function Type="name:vendorSpecific" />
</m2:Device>
</m2:DeviceCapability>
Is there something I'm missing or is this a bug in the MSTest Framework?
I think the problem is that
await UsbDevice.FromIdAsync(deviceId);
must be called on the UI thread because the app has to ask the user for access.
You have to CoreDispatcher.RunAsync to ensure you're on the UI thread or actually be in the code behind for a page.
I had the same problem with Unit Test App (Universal Windows) in VS 2017.
I verify answer of my predecessor Greg Gorman(see below). And I found this is true.
If you uses inside method body this construct:
Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
Windows.UI.Core.CoreDispatcherPriority.Normal,
async () =>
{
...
UsbDevice usbDevice = await UsbDevice.FromIdAsync(deviceId);
...
}).AsTask().Wait();
the FromIDAsync will work as you expect.
For your example change the test method to this:
[TestClass]
public class UnitTest1
{
[TestMethod]
public async Task TestMethod1()
{
Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
Windows.UI.Core.CoreDispatcherPriority.Normal,
async () =>
{
await ConnectToUSB.ConnectUSB();
}).AsTask().Wait();
}
}

J2me application showing error in some mobile

i have a j2me application with web service stub.
it worked in some mobiles.
but in some mobiles "Application Error" comes up.
i tried creating package making versions MIDP 2.0 and CLDC 1.0(made stub for CLDC 1.0 also)
still it is showing "Application Error"
if I create the package without stub the application works properly.
The stub was generated using "Sun Java Wireless Toolkit 2.5.2 for CLDC"
can anyone help?
new Thread(new Runnable(){
public void run()
{
try {
MobiService_Stub ms = new MobiService_Stub();
resultBox.setString(ms.sendString( textbox.getString()));
}catch (JAXRPCException cnfe){
resultBox.setString("No connection found");
} catch (RemoteException e) {
// TODO Auto-generated catch block
resultBox.setString(e.getMessage());
}
}
}).start();
resultBox.addCommand(cmd_Cancel);
}
I have come up with "Application Error" messages when I try to run a Midlet that uses a JSR not available in that device. You should verify that the JSR or APIs you import are supported by your testing devices.