Compartir a través de


Initializing the Device

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Initialize the device information, add a service, and start the device stack.

The static class Dpws.Device.Device represents the device stack itself. This class provides infrastructure functionality for DPWS-enabled devices as well as acting as the host for services you write. Include a call to Dpws.Device.Device.Start in your application’s main class to start the DPWS device stack.

The Device class also serves to contain parameters used by the device stack, such as the device’s endpoint address. The Device.ThisModel class contains information specific to the device model, such as the model name and model number, and the Device.ThisDevice class contains information specific to the device itself, such as serial number. Your Main method should set these as appropriate, using code like the following.

// Set device information (in Main)
Device.EndpointAddress = "https://localhost:1234";
Device.ThisModel.Manufacturer = "Microsoft Corporation";
Device.ThisModel.ManufacturerUrl = "https://www.microsoft.com/";
Device.ThisModel.ModelName = "SampleService Test Device";
Device.ThisModel.ModelNumber = "12021345";
Device.ThisModel.ModelUrl = "https://www.microsoft.com/";
Device.ThisModel.PresentationUrl = "https://www.microsoft.com/";

Device.ThisDevice.FriendlyName = "SampleService Device";
Device.ThisDevice.FirmwareVersion = "alpha";
Device.ThisDevice.SerialNumber = "12345678";

// add a service
Device.HostedServices.Add(typeof(TestService), typeof(ITestService), 
                          new Uri("https://localhost:1234/TestService/"));

// Start the device stack
Device.Start();