What happens when a software developer wants to learn Angular 2.0 and needs a image frame at the same time? That's right! They make one! But can it even work out? My first and favorite project because it gives me a lot of joy every day.
It also gave me an opportunity to think about architecture patterns for Windows IoT. The OS allows one UI application (headed) and n-background applications (headless, that's rather how I feel on new and full moons after two flasks of wine).
UWP Cross-process CommunicationI created a dedicated background service for the FEZ HAT. This decoupling gives advantage of not having any GPIO logic inside main application. Making it simpler to start the application on PC, which is a great advantage for debugging. The service returns current reading whenever the main application requests it.
var message = args.Request.Message["Request"] as string;
switch (message)
{
case "SensorData":
CrossCuttingRT.Dto.SensorsDataDto sd = _proxy.ReadSensorData();
returnMessage.Add("Temperature", sd.Temperature);
returnMessage.Add("LightLevel", sd.LightLevel);
break;
}
returnMessage.Add("Response", "OK");
The request and response are simple KeyValue pairs, allowing only simple data types. The headed application runs a cyclic request. The only really thrilling part is finding the right service.
using (var dataService = new AppServiceConnection())
{
var listing = await AppServiceCatalog.FindAppServiceProvidersAsync("DataCollectorInterface");
var packageName = "";
// there may be cases where other applications could expose the same App Service Name, in our case
// we only have the one
if (listing.Count == 1)
{
packageName = listing[0].PackageFamilyName;
}
dataService.AppServiceName = "DataCollectorInterface";
dataService.PackageFamilyName = packageName;
var status = await dataService.OpenAsync();
if (status == AppServiceConnectionStatus.Success)
{
var msg = new ValueSet();
msg.Add("Request", "SensorData");
AppServiceResponse request = await dataService.SendMessageAsync(msg);
if (request.Status == AppServiceResponseStatus.Success)
{
CrossCuttingRT.Dto.SensorsDataDto data = new CrossCuttingRT.Dto.SensorsDataDto();
data.Temperature = request.Message["Temperature"] as double?;
data.LightLevel = request.Message["LightLevel"] as double?;
result = data;
}
else
{
System.Diagnostics.Debug.WriteLine("Request Response Status: " + status.ToString());
}
}
}
The Angular app as well runs a poller every few seconds to update the UI. In theory, it is possible to register callback functions from C# to JavaScript. In theory. I had the same problem like many who tried and failed.
The User InterfaceThe User Interface is simple. Put in a USB stick. Switch to the storage view.
Click Copy and enjoy your photos.
What are actually the advantages of using JavaScript? It possesses a huge collection of image libraries that can be easily included to create cool slideshows or collages.
Comments
Please log in or sign up to comment.