[Architecture Pattern] device projection (I)

Source: Internet
Author: User

Motivation:

When developing a real-time system, you often need to create a set of objects to map remote devices.
This set of objects displays the status and notifications of remote devices.
This group of objects is used to encapsulate the operations and management of remote devices.

 

However, before the image remote device provides the above features.
You also need to provide the function of exploring remote devices to create a list of remote devices.
In this way, we can provide complete services.

 

This article introduces a "device projection mode 』,
Defines the responsibilities and interactions between objects to encapsulate the functions required to map remote devices.
This allows developers to have a reference architecture when they need to implement relevant functions.

 

Structure:

This is the pattern, and the whole looks a bit complicated.
We will deploy the graph for ease of understanding.

 

Device objects:
The first is device-related objects. These objects mainly provide the following functions:
-Present the status and notification of the remote device through this group of objects.
-Use this group of objects to encapsulate Operations and Management of remote devices.

 

Major participants include:
Idevicesketch
-Interfaces that encapsulate the identity attributes of remote devices.
-For devices connected to the network, the identifier attribute of idevicesketch may use IP addresses as the identifier attribute.

 

Idevicecontrol
-After the call start method, It proactively provides real-time information and encapsulated operation interfaces, which are active objects dedicated to devices.
-For devices connected to the network, idevicecontrol provides online device status and remote control commands.

 

Device
-Objects actually provided to external modules.
-Encapsulate the attributes and methods provided by idevicecontrol and idevicesketch.
-The device property data is updated by accepting additional idevicesketch as the property source.

 

In addition, we can also find that the inotifypropertychanged interface is implemented for the main objects involved.
This is an interface contained in system. componentmodel. It is mainly used to provide Event Notifications for changes of a property.
The "device projection mode" uses this interface to notify external modules of changes in nature.

 

The following figure shows the interaction process between devices.

 

 

 

 

 

Devicemanager objects:
Let's take a look at the devicemanager objects. These objects mainly provide the following functions:
-Explore the functions of remote devices and create a list of remote devices.

 

Major participants include:
Idevicesketchexplorer
-After the call start method, the system proactively provides interfaces for exploring remote devices. This is an active object dedicated to devicemanager.
-Create a New idevicesketch and send an event notification when new remote devices are found to join the system.
-When you discover that the old remote device leaves the system, create a new idevicesketch and send an event notification.

 

Idevicefactory
-This interface is mainly used to encapsulate the function of establishing a device and updating the device, and cut related dependent objects from the system.
-It is also responsible for the establishment of the idevicecontrol interface required by the device, and the related dependent objects are cut from the system.

 

Devicecollection
-The set object actually stored by the device object in the mode.
-In addition to providing internal access mode, it is also available to external modules.

 

Devicemanager
-Objects that provide the mode function.
-Accepts the events sent by idevicesketchexplorer and adds and deletes the devicecollection content.
-Use idevicefactory to create and update Device objects.
-As the host of the entire module, the devicecollection attribute is available for external modules.
-An event notification is sent when a remote device is added to or removed from the system.

 

The following figure shows the interaction process between devicemanager objects.

 

 

 

 

 

To be continued...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.