Chat with us, powered by LiveChat

SDK for UWP .NET – Getting started

Update Microsoft.NETCore.UniversalWindowsPlatform reference

After creating a new blank app it is important to make sure that the installed Microsoft.NETCore.UniversalWindowsPlatform NuGet package reference is version 5.2.2 or above.
Right-click on references and select Manage NuGet Packages.

The Microsoft.NETCore.UniversalWindowsPlatform should be installed by default, select it and check which version of the package is installed. If the version is below 5.2.2 update the package by selecting the desired version and clicking on the Update button.

Add SDK References to the project

Right-click on the References map in your project and click Add Reference:

Reference external libraries (*.dll files) by selecting them via the ‘Browse’ button and reference project files (*.csproj) by adding them to your solution and referencing the project. (Important! When using the PalmSens SDK without the simplified wrapper, the CoreDependencies must be initiated before you run a measurement, to do this invoke the PalmSens.Core.UniversalWindows.CoreDependencies.Init() method one time beforehand, see the section on initiating the Core dependencies below)

The PalmSens.Core.dll and PalmSens.Core.UniversalWindows.dll libraries should always be referenced. If you wish to use the simplified wrapper to control your devices the PalmSens.Core.Simplified.csproj and PalmSens.Core.Simplified.UniversalWindows.csproj should be referenced. To use the plot control the SDKPlot.csprojSDKPlot.UWP.csprojOxyPlot.dll, and OxyPlot.Windows.csproj should be referenced.

Add PSCommSimpleWinforms component to your user interface (simplified wrapper only)

First import the PalmSens.Core.Simplified.csproj and PalmSens.Core.Simplified.UniversalWindows.csproj into your solution and build the PalmSens.Core.Simplified.UniversalWindows project. Then reference these projects in your project. Next, go to the designer of your Main Page and look for the psCommSimpleUWP control in your toolbox. Drag and drop this component on your Form. Alternatively, you can add the following lines of code to the XAML code of the Main Page:

<UniversalWindows:PSCommSimpleUWP x:Name="psCommSimpleUWP"/>

Initiating the Core dependencies

In order to be able to perform measurements with the PalmSens.Core the Core dependencies must be initiated first. After adding the references to the PalmSens Core SDK libraries edit the App.xaml.cs that was automatically generated when you created your new project.

Navigate to the method for the OnLaunched event.

At the end of the OnLaunched event method add the following line of code:


Defining the App capabilities

In order to communicate with a PalmSens/EmStat device and to load and save data the app requires permission, the app’s permissions are defined in the Package.appxmanifest file in your project. The PalmSens UWP SDK only supports EmStat and PalmSens 4 devices at the moment. EmStat devices must be set in VCP mode in order to work with PalmSens UWP SDK, see the section on programming the EmStat mode below.

To add the permissions to the Package.appxmanifest file, edit its code by right-clicking on it and selecting view code.

The capabilities are described at the end of the document.

To use an Emstat device in VCP mode add the following code to the capabilities:

 <DeviceCapability Name="serialcommunication">
    <Device Id="any">
       <Function Type="name:serialPort" />

To use a PalmSens 4 device add the following code to the capabilities:

 <DeviceCapability Name="usb">
    <Device Id="vidpid:0403 D182">
       <Function Type="classId:02 * *" />
       <Function Type="name:cdcControl" />


For adding the capabilities that allow your app to read and write from internal and external storage we refer you to the following MSDN pages: 1, 2, 3.

Programming EmStat in VCP mode

To program an EmStat in VCP mode or back to its default mode open the Program Emstat folder in the SDK. Connect the EmStat to your computer (only one EmStat may be connected at a time). Run “Program ES VCP.bat” to program your EmStat device in VCP mode. To program it back to its default mode run either “Program ES3.bat” or “Program ES3+.bat” depending on the type of EmStat 3 that you have (Warning! programming your Emstat with the incorrect bat file will result in it working incorrectly, reprogram it with the correct bat to fix this).