A device object generation method, device and device
By generating standardized configuration files and classes for IoT devices and using unique identifiers to generate device objects, it solves the problems of device calling complexity and programming difficulty in the existing technology, and achieves efficient and standardized generation and calling of device objects.
Patent Information
- Application Number
- CN201811280515.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-10-30
- Publication Date
- 2024-10-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing device calling solutions in the Internet of Things have problems such as high programming difficulty, high iteration costs, and non-standardized device capability descriptions, resulting in complicated device access and calling processes.
By generating a standardized configuration file for the target device, describing its capabilities, and generating device objects based on the configuration file, using unique identifiers and classes to generate device objects, the device calling process is simplified.
It realizes the standardized generation of device objects, reduces programming difficulty and iteration costs, allows users to easily call target devices without knowing the specific loading and driving process of the device, and improves the reliability and efficiency of device objects.
Smart Images

Figure CN111198677B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus and device for generating a device object. Background Art
[0002] A device object refers to an object that represents a device in the field of the Internet of Things. It describes the properties, methods, and events of the device.
[0003] The current device calling scheme generally generates a device object on demand to connect the device to the Internet of Things, and writes drivers for each device separately, with various driver format protocols; then, the device capabilities are continuously iterated and changed as needed, and the device interface is exposed to the outside for calling.
[0004] Therefore, a more reliable device object generation scheme is needed. Summary of the invention
[0005] The embodiments of this specification provide a method for generating a device object, which is used to provide a standardized device object generation solution to reduce the programming difficulty of the device.
[0006] The embodiment of this specification also provides a method for generating a device object, including:
[0007] Determine the unique identifier of the target device;
[0008] Determining a class corresponding to the target device, the class being generated based on a configuration file describing capabilities of the target device;
[0009] Based on the class and the unique identifier, a device object for the target device is generated.
[0010] The embodiment of this specification also provides a method for generating a device object, including:
[0011] Obtaining a configuration file corresponding to a target device, wherein the configuration file is used to describe capabilities of the target device;
[0012] The configuration file is provided to a server, so that the server generates a class corresponding to the target device based on the configuration file, and generates a device object of the target device based on a unique identifier of the target device and the class.
[0013] The embodiment of this specification also provides a device object generation apparatus, including:
[0014] A first determination module, configured to determine a unique identifier of a target device;
[0015] A second determination module, configured to determine a class corresponding to the target device, wherein the class is generated based on a configuration file describing capabilities of the target device;
[0016] A generating module is used to generate a device object of the target device based on the class and the unique identifier.
[0017] The embodiment of this specification also provides a device object generation apparatus, including:
[0018] An acquisition module, used to acquire a configuration file corresponding to a target device, wherein the configuration file is used to describe the capability of the target device;
[0019] A module is provided, which is used to provide the configuration file to a server, so that the server generates a class corresponding to the target device based on the configuration file, and generates a device object of the target device based on a unique identifier of the target device and the class.
[0020] The embodiment of the present specification also provides an electronic device, including:
[0021] Processor; and
[0022] A memory is arranged to store computer executable instructions, which, when executed, cause the processor to perform the steps of the device object generation method as described above.
[0023] The embodiments of the present specification also provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the device object generation method as described above are implemented.
[0024] At least one of the above technical solutions adopted in the embodiments of this specification can achieve the following beneficial effects:
[0025] The target device's corresponding class is generated by a configuration file that describes the target device's capabilities in a standardized manner, and the target device's device object is generated based on the target device's corresponding class and the target device's unique identifier. Compared with the chaotic device call programming scheme used in the prior art, the target device's device object is efficiently generated through the standardized configuration file of the target device provided by the device manufacturer or a third party, so that the relevant user can clearly know all the capabilities of the target device without knowing the specific loading, driving and other processes of the target device, and can easily implement the target device's device object call. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0027] Figure 1 A schematic diagram of an application scenario provided in this manual;
[0028] Figure 2 A schematic diagram of a flow chart of a method for generating a device object provided in an embodiment of this specification;
[0029] Figure 3 A schematic diagram of an implementation method of a device object calling step provided in an embodiment of this specification;
[0030] Figure 4 A schematic diagram of another implementation method of the device object calling step provided in an embodiment of this specification;
[0031] Figure 5 A schematic diagram of a flow chart of a method for generating a device object provided in another embodiment of this specification;
[0032] Figure 6 A flowchart of a method for generating a device object provided in another embodiment of the present specification;
[0033] Figure 7 A schematic diagram of the structure of a device object generation apparatus provided in an embodiment of this specification;
[0034] Figure 8 A schematic diagram of the structure of a device object generation apparatus provided in another embodiment of the present specification;
[0035] Fig. 9 A schematic diagram of the structure of an electronic device provided in one embodiment of this specification. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0037] As stated in the background technology section, when a target device needs to be connected to the Internet of Things, the traditional method is to first connect to the target device, and then the developer writes a driver and exposes the development application programming interface (API) to the outside.
[0038] However, since different developers may write different drivers and driver format protocols, the device capabilities described for the same device may also be different, resulting in very high device iteration costs. Moreover, since the development of API interfaces cannot be standardized, other users who want to call the target device need to understand the target device's capabilities, driver protocols, interface protocols and other details, making programming very difficult.
[0039] The Internet of Things refers to the Internet that connects everything. This has two meanings: first, the core and foundation of the Internet of Things is still the Internet, and it is an extended and expanded network based on the Internet; second, its user end extends and expands to any object to exchange information and communicate, that is, everything communicates with each other.
[0040] Based on this, the present invention provides a device object generation method, which first requires the manufacturer of the target device or a third party to provide a set of configuration files corresponding to the target device in a standard data format to describe all the capabilities of the target device; then, the class of the target device is generated based on the configuration file, and the device object of the target device is generated based on the class and the unique identifier of the target device, so that the relevant user can call the device object to control the target device. On the basis of clearly knowing all the capabilities of the target device, the relevant user can easily call the device object of the target device without knowing the specific loading, driving and other processes of the target device.
[0041] Among them, the device object can be a dynamic code, which is a code dynamically generated by code, and the generation process is automatically completed by the code without manual writing; the unique identifier refers to a tool for identifying the device, which is used to distinguish it from other devices to ensure the uniqueness of the device. Generally refers to the number configured for the device during the generation process; the configuration file is used to describe the device capabilities, including: properties, services and events. The class is the basis for object-oriented programming (OOP) to implement information encapsulation. It is a user-defined type, also known as a class type. Each class contains a data description and a set of functions that operate data or transmit messages.
[0042] See below Figure 1 The application scenarios of the present invention are exemplified.
[0043] The application scenario includes: a server 110, a device object requester 120 and a configuration file provider 130, wherein:
[0044] The configuration file provider 130 refers to the terminal device of the device manufacturer or the terminal device of a third party authorized by the manufacturer, which is used to construct a configuration file in a standard data format corresponding to each device type based on the product design specifications of each device type produced, and provide it to the server 110;
[0045] Among them, product design description refers to a relatively detailed description of the equipment in a stylistic way, which is used to comprehensively and clearly introduce the equipment name, purpose, nature, performance, principle, structure, specifications, usage, maintenance, precautions, etc.; standard data format refers to a set of standardized equipment configuration file formats provided by the manufacturer or a third party to the server, such as: JavaScript Object Notation (Json) file format; configuration file refers to a protocol file based on the standard data format for describing the capabilities of the device.
[0046] The device object requester 120 refers to a terminal device of the device owner or a terminal device of another user authorized by the owner, and is used to initiate a request to the server to connect the target device to the Internet of Things, and the request includes a unique identifier of the target device;
[0047] The server 110 may be a server of the configuration file provider 130 or a server of another user, and is used to convert and abstract configuration files corresponding to each device type from the configuration file provider 130 into corresponding classes and save them; in response to a request from the device object requester 120, find out the class corresponding to the device type to which the target device belongs, and generate a device object for the target device based on the class and the unique identifier of the target device.
[0048] The server 110 may be a gateway, a cloud server, etc. The device object requester 120 and the configuration file provider 130 may be a PC or a mobile terminal. A mobile terminal or a mobile communication terminal refers to a computer device that can be used on the move, which generally includes mobile phones, notebooks, tablet computers, POS machines, and even vehicle-mounted computers. However, in most cases, it refers to a mobile phone or a smart phone with multiple application functions and a tablet computer.
[0049] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0050] Figure 2 A schematic diagram of a device object generation method provided in an embodiment of this specification, which can be Figure 1 The server 110 in the embodiment is executed, see Figure 2 , the method may specifically include the following steps:
[0051] Step 220: Determine the unique identifier of the target device; specifically, it may be:
[0052] An access request for requesting to connect a target device to the Internet of Things is received, wherein the access request includes a unique identifier of the target device; the access request may come from a device object requester or from another user.
[0053] Among them, the unique identifier can be the device number configured before leaving the factory, or it can be a unique identifier used when connecting with the outside world after leaving the factory, such as: physical address, IP address, etc.; the unique identifier can be a word, number, letter, symbol, or it can be composed of the above elements.
[0054] Step 240: Determine a class corresponding to the target device, where the class is generated based on a configuration file describing capabilities of the target device;
[0055] It should be noted that one implementation of step 240 may be:
[0056] Step S1: determining a configuration file corresponding to the target device based on the unique identifier;
[0057] It should be noted that the configuration file corresponding to the target device is a configuration file of the target device or a configuration file corresponding to a device type to which the target device belongs.
[0058] If it is the former, the configuration file of the target device can be found from the database based on the unique identifier; if it is the latter, the device type described by the target device can be determined based on the unique identifier, and then the configuration file corresponding to the device type can be found from the database.
[0059] The database stores configuration files for each device or each device type in a standard data format provided by a configuration file provider; preferably, the configuration file provider provides the configuration file in the dimension of device type. Since the configurations of devices of the same type are the same or nearly the same, providing one configuration file for one device type will not affect the construction accuracy of the device object, and can effectively reduce the amount of device configuration files provided by the configuration file provider.
[0060] Step S2: Generate a class corresponding to the target device based on the configuration file.
[0061] The configuration file includes: attributes, services and events, wherein the attributes are characteristics of the target device, the services are actions performed by the target device, and the events are responses of the target device.
[0062] Accordingly, step S2 may be implemented as follows:
[0063] Based on the properties and services of the target device, member variables and methods of the class are generated respectively; based on the events of the target device, a message monitoring interface of the device is generated; based on the member variables, methods and message monitoring interface of the class, a class is generated.
[0064] It should be noted that another implementation of step 240 may be:
[0065] Before step 240, a configuration file corresponding to each device type is obtained, and based on the configuration file, a class corresponding to each device type is generated.
[0066] Based on this, the device type to which the target device belongs can be determined based on the unique identifier, and the class corresponding to the device type is used as the class corresponding to the device.
[0067] Step 240: Generate a device object of the target device based on the class and the unique identifier. Specifically, it may be:
[0068] The unique identifier is written into the class to obtain a device object of the target device.
[0069] That is, for the device object of the device type to which the target device belongs obtained through the above steps, since it is applicable to all devices of this device type, in order to avoid calling errors, the unique identifier of the target device needs to be written into the class to ensure the uniqueness of the device object.
[0070] Optionally, after the device object is constructed, the construction result can be returned to the device object requester for calling the device object to control the relevant device, see Figure 3 , one implementation of the device object calling step can be:
[0071] Step 320: Obtain a script file corresponding to the target device, wherein the script file includes device parameters corresponding to the target device;
[0072] Among them, the script file is generally a programming language provided by the application, similar to the batch file in the DOS operating system, which can combine different commands and automatically and continuously execute them in a certain order.
[0073] The script file can be sent by the device object requester or by other pre-authorized users. That is, this embodiment allows calling a device object in an 'open source' form. However, in order to avoid malicious programs, this embodiment will further perform code vulnerability detection on script files from other users.
[0074] Step 340: Replace the device parameters with the device object of the target device; specifically, the following example may be used:
[0075] Assume that the script file includes: module.exports = function (door, light);
[0076] Among them, the exposed device parameters include door and light. In order to determine which specific door and light door and light represent respectively, it is necessary to replace the device parameters with specific unique device objects, that is, the device objects of the door and light generated based on the above steps 220 to 260, so as to realize the calling of the device objects.
[0077] Step 360: Execute the script file to control the target device. Specifically, the script file may be:
[0078] Assume the script file is:
[0079]
[0080] Then, you can run the script file to call the curtain and hue related drivers of the target device to realize the control of the curtain and hue of the home scene.
[0081] See also Figure 4 , another implementation of the device object calling step can be:
[0082] Step 420: The server responds to the access request sent by the call requester and sends a device object to the target device;
[0083] The access request includes a unique identifier of the target device, so that the server can generate a device object of the target device based on the above steps 220 to 260, or search for a device object of the generated target device; the call requester can be a device object requester or another user; for the latter, before responding to the access request, the access request is further authenticated and code vulnerability detected to avoid malicious calls.
[0084] Step 440: The calling requester replaces the device parameter in the script file corresponding to the target device with the device object of the target device;
[0085] The script file corresponding to the target device is used to call the device object of the target device to execute a series of programs for the target device. Since the implementation of step 440 is similar to that of step 340, it will not be described here.
[0086] Step 460: The calling requester executes the script file to control the target device.
[0087] Since the implementation methods of step 460 and step 360 are similar, step 460 will not be described in detail here.
[0088] for Figure 3 and Figure 4 The corresponding device object calling steps, the difference between the two is, Figure 3 The script is executed on the server. Figure 4 The script file in is executed on the calling request side.
[0089] It can be seen that this embodiment generates a class corresponding to the target device through a configuration file that describes the capabilities of the target device in a standardized manner, and generates a device object of the target device based on the class corresponding to the target device and the unique identifier of the target device. Compared with the chaotic device call programming scheme used in the prior art, the device object of the target device is efficiently generated through the standardized configuration file of the target device provided by the device manufacturer or a third party, so that the relevant users can clearly know all the capabilities of the target device without knowing the specific loading, driving and other processes of the target device, and can easily realize the device object call of the target device.
[0090] Figure 5 A schematic diagram of a flow chart of a device object generation method provided in another embodiment of this specification, which can be Figure 1 The device object requester 120 or the configuration file provider 130 in Figure 5 , the method may specifically include the following steps:
[0091] Step 520: Obtain a configuration file corresponding to the target device, where the configuration file is used to describe the capabilities of the target device;
[0092] Among them, the configuration file corresponding to the target device is the configuration file of the target device or the configuration file corresponding to the device type to which the target device belongs; the configuration file includes: attributes, services and events, the attributes are the characteristics of the target device, the services are the actions performed by the target device, and the events are the responses of the target device.
[0093] Step 540: Provide the configuration file to the server, so that the server generates a class corresponding to the target device based on the configuration file, and generates a device object of the target device based on the unique identifier of the target device and the class.
[0094] Optionally, the method further includes a step of calling a device object, which may specifically be:
[0095] A script file corresponding to the target device is sent to the server, the script file including device parameters of the target device object, so that the server replaces the device parameters with the device object of the target device and executes the script file.
[0096] Due to the relevant steps in this embodiment, Figure 2 The corresponding embodiments have been described in detail, so they will not be described again here.
[0097] It can be seen that this embodiment constructs a device configuration file in a standard data format to describe all capabilities of each device type, and configures a unique identifier for each device to determine the device type to which the device belongs, and then generates a class corresponding to the device type based on the configuration file, and then generates a device object of the device based on the class and the unique identifier of the device for calling. Compared with the chaotic device calling programming scheme used in the prior art, this embodiment enables the relevant users to clearly know all the capabilities of the target device without knowing the specific loading, driving and other processes of the target device, and can easily realize the device object calling of the target device.
[0098] Figure 6 A flow chart of a method for generating a device object provided in another embodiment of this specification is shown in FIG. Figure 6 , the method may specifically include the following steps:
[0099] Step 602: receiving a call request initiated by a user and generating a scheduling task;
[0100] The call request includes: the property file and script file of the target object to be called, the property file includes key and value, the key indicates that a parameter of the script file represents a device (eg, door, light), and the value is the unique identifier ID of the device.
[0101] Step 604: load multiple scheduling tasks, parse the property file, and obtain value;
[0102] Among them, each scheduling task corresponds to a value, and each value corresponds to a device.
[0103] Step 606: Receive the Json file format of the unified and standardized device configuration files of each device type provided by the configuration file provider;
[0104] The device configuration Json file format includes: attributes, services, and events, which are used to describe all capabilities of each device.
[0105] Step 608: Convert the Json file format into an abstract class for each device type; specifically, it can be:
[0106] According to the get Profile, the Json file format is dynamically converted into each device Class through different language syntax. The Class includes: attributes, services, and events.
[0107] Among them, each attribute can be dynamically converted into a member variable of the Class, the service can be dynamically converted into a method of the Class, and the event can be converted into a message listening interface of the device.
[0108] The specific transformation abstract logic can be exemplified as follows:
[0109] Get properties: device object.properties
[0110] Set property: device object.property = a value
[0111] Call service: device object.method(parameter 1, parameter 2...)
[0112] Listening events: device object.on("event name", function)
[0113] Based on this, a unified programming method can be exposed to the upper layer, and the device developer can change the code details without affecting the use of the upper-level users.
[0114] Furthermore, the implementation style may be slightly different depending on the development language used, for example:
[0115] You can also use device object.get(value) to get properties.
[0116] The property setting uses object.set(key,value) to encapsulate getting or setting all the properties of the device.
[0117] Step 610: Generate a unique device object for each device according to the generated Class and value;
[0118] Step 612: Load the device object to replace the input device parameters (eg, door, light) in the script file with the generated device object, and execute the script file.
[0119] Based on this, after executing the script file, initDevice can be called arbitrarily, and then the devices can be linked arbitrarily and applications can be developed with one click to realize the various computing capabilities of the devices.
[0120] It can be seen that the method of this embodiment mainly overcomes the glue code problem caused by the traditional programming mode, which may do a lot of disorganized and fragmented process connection work. When the devices are interconnected, it is impossible to connect all the devices to a control center. In addition, when faced with non-standardized device programming, it is even more difficult to know how to call and access each device. It is equivalent to asking each Taobao store owner to open a Taobao website, which will be very cumbersome and complicated without uniformity, and the workload will never be completed. However, with the method of dynamically generating the device Class model of this embodiment, it is equivalent to automation, and programming can be performed for the configuration file, so that the seller, merchant, and customer only need to provide the driver and the configuration file format of the device, and the model of all device access can be easily achieved, unifying all devices even those with non-standard protocols.
[0121] Moreover, this embodiment provides a new edge computing programming framework. Users do not need to pay attention to device details. They can write device-oriented programming methods according to the Json configuration of the device, shielding the differences in implementation details such as the device's own driver; it also provides a new integrated programming interaction process from the cloud console to edge computing, which can achieve integration without difference at the edge and cloud, create a device object model, initialize user code, load and execute user code, and provide serverless services. Upper-level users do not need to worry about when the code is loaded, how it runs, where it runs, and how the device is driven, how the device is loaded, and how the device is controlled.
[0122] In addition, for the sake of simplicity, the above method implementations are described as a series of action combinations, but those skilled in the art should know that the implementations of the present invention are not limited by the described order of actions, because according to the implementations of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the implementations described in the specification are all preferred implementations, and the actions involved are not necessarily required for the implementations of the present invention.
[0123] Figure 7 This is a schematic diagram of a device object generation apparatus provided in an embodiment of this specification, see Figure 7 The device may specifically include: a first determining module 71, a second determining module 72 and a generating module 73, wherein:
[0124] A first determination module 71, configured to determine a unique identifier of a target device;
[0125] A second determination module 72, configured to determine a class corresponding to the target device, the class being generated based on a configuration file describing capabilities of the target device;
[0126] The generating module 73 is used to generate a device object of the target device based on the class and the unique identifier.
[0127] Optionally, the second determining module 72 is specifically configured to:
[0128] Based on the unique identifier, a configuration file corresponding to the target device is determined; based on the configuration file, a class corresponding to the target device is generated.
[0129] Optionally, the configuration file corresponding to the target device is a configuration file of the target device or a configuration file corresponding to a device type to which the target device belongs.
[0130] Optionally, the configuration file includes: attributes, services and events, wherein the attributes are characteristics of the target device, the services are actions performed by the target device, and the events are responses of the target device;
[0131] The second determining module 72 is specifically configured to:
[0132] Based on the properties and services of the target device, member variables and methods of the class are generated respectively; based on the events of the target device, a message monitoring interface of the device is generated; based on the member variables, methods and message monitoring interface of the class, a class is generated.
[0133] Optionally, the device further comprises:
[0134] A preprocessing module, used to obtain a configuration file corresponding to each device type, and generate a class corresponding to each device type based on the configuration file;
[0135] The second determining module 72 is specifically configured to:
[0136] Based on the unique identifier, the device type to which the target device belongs is determined, and the class corresponding to the device type is used as the class corresponding to the device.
[0137] Optionally, the configuration file is a file in a standard data format provided by the manufacturer of the target device or a third party.
[0138] Optionally, the generating module 73 is specifically used for:
[0139] The unique identifier is written into the class to obtain a device object of the target device.
[0140] Optionally, the device further comprises:
[0141] The calling module is used to obtain a script file corresponding to the target device, wherein the script file includes device parameters corresponding to the target device; replace the device parameters with the device object of the target device, and execute the script file.
[0142] It can be seen that this embodiment generates a class corresponding to the target device through a configuration file that describes the capabilities of the target device in a standardized manner, and generates a device object of the target device based on the class corresponding to the target device and the unique identifier of the target device. Compared with the chaotic device call programming scheme used in the prior art, the device object of the target device is efficiently generated through the standardized configuration file of the target device provided by the device manufacturer or a third party, so that the relevant users can clearly know all the capabilities of the target device without knowing the specific loading, driving and other processes of the target device, and can easily realize the device object call of the target device.
[0143] Figure 8 This is a schematic diagram of a device object generation apparatus provided in another embodiment of this specification, see Figure 8 The device may specifically include: an acquisition module 81 and a providing module 82, wherein:
[0144] An acquisition module 81 is used to acquire a configuration file corresponding to a target device, where the configuration file is used to describe the capabilities of the target device;
[0145] The providing module 82 is used to provide the configuration file to the server, so that the server generates a class corresponding to the target device based on the configuration file, and generates a device object of the target device based on the unique identifier of the target device and the class.
[0146] Optionally, the configuration file corresponding to the target device is a configuration file of the target device or a configuration file corresponding to a device type to which the target device belongs.
[0147] Optionally, the configuration file includes: attributes, services and events, wherein the attributes are characteristics of the target device, the services are actions performed by the target device, and the events are responses of the target device.
[0148] Optionally, also include:
[0149] The sending module is used to send a script file corresponding to the target device to the server, wherein the script file includes device parameters of the target device object, so that the server replaces the device parameters with the device object of the target device and executes the script file.
[0150] It can be seen that this embodiment constructs a device configuration file in a standard data format to describe all capabilities of each device type, and configures a unique identifier for each device to determine the device type to which the device belongs, and then generates a class corresponding to the device type based on the configuration file, and then generates a device object of the device based on the class and the unique identifier of the device for calling. Compared with the chaotic device calling programming scheme used in the prior art, this embodiment enables the relevant users to clearly know all the capabilities of the target device without knowing the specific loading, driving and other processes of the target device, and can easily realize the device object calling of the target device.
[0151] In addition, for the above-mentioned device implementation, since it is basically similar to the method implementation, the description is relatively simple, and the relevant parts can refer to the partial description of the method implementation. Moreover, it should be noted that among the various components of the device of the present invention, the components are logically divided according to the functions to be implemented, but the present invention is not limited thereto, and the various components can be re-divided or combined as needed.
[0152] Fig. 9 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this specification, see Fig. 9 , the electronic device includes a processor, an internal bus, a network interface, a memory and a non-volatile memory, and of course may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a device object generation device at the logical level. Of course, in addition to software implementation methods, this application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0153] The network interface, processor and memory can be connected to each other through a bus system. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0154] The memory is used to store programs. Specifically, the program may include program code, and the program code includes computer operation instructions. The memory may include read-only memory and random access memory, and provide instructions and data to the processor. The memory may include high-speed random access memory (RAM), and may also include non-volatile memory (non-volatile memory), such as at least one disk storage.
[0155] The processor is used to execute the program stored in the memory, and specifically perform:
[0156] Determine the unique identifier of the target device;
[0157] Determining a class corresponding to the target device, the class being generated based on a configuration file describing capabilities of the target device;
[0158] Based on the class and the unique identifier, a device object for the target device is generated.
[0159] or,
[0160] Obtaining a configuration file corresponding to a target device, wherein the configuration file is used to describe capabilities of the target device;
[0161] The configuration file is provided to a server, so that the server generates a class corresponding to the target device based on the configuration file, and generates a device object of the target device based on a unique identifier of the target device and the class.
[0162] The above application Figure 7-8The method performed by the device object generation device or the manager (Master) node disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0163] The device object generator can also execute Figure 2-6 and implement the method executed by the manager node.
[0164] Based on the same invention, the embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by an electronic device including multiple application programs, the electronic device executes Figure 2-6 The corresponding embodiment provides a method for generating a device object.
[0165] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0166] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0167] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0168] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0169] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0170] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0171] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0172] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0173] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0174] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0175] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0176] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for generating a device object, characterized in that: include: Receiving an access request for requesting the target device to access the Internet of Things, the access request including a unique identifier of the target device, the unique identifier being a device number configured before leaving the factory or a unique identifier used when connecting to the outside world after leaving the factory; Based on the unique identifier, determine a configuration file corresponding to the target device, wherein the configuration file corresponding to the target device is a configuration file corresponding to the device type to which the target device belongs, wherein the database stores configuration files of each device type in a standard data format constructed based on product design specifications of each device type produced by the manufacturer of the target device or a third party; Based on the configuration file, generating a class corresponding to the target device; generating a device object for the target device based on the class and the unique identifier; Acquire a script file corresponding to the target device, wherein the script file includes device parameters corresponding to the target device; The device parameters are replaced with the device object of the target device, and the script file is executed.
2. The method according to claim 1, characterized in that The configuration file includes: attributes, services and events, wherein the attributes are characteristics of the target device, the services are actions performed by the target device, and the events are responses of the target device; Wherein, based on the configuration file, generating a class corresponding to the target device includes: Generate class member variables and methods based on the properties and services of the target device; generate the device's message monitoring interface based on the events of the target device; Generate a class based on the member variables, methods and message listening interface of the class.
3. The method according to claim 1, characterized in that Before determining the class corresponding to the target device, the method further includes: Obtain configuration files corresponding to each device type, and generate classes corresponding to each device type based on the configuration files; Wherein, determining the class corresponding to the target device includes: Based on the unique identifier, the device type to which the target device belongs is determined, and the class corresponding to the device type is used as the class corresponding to the device.
4. The method according to claim 1, characterized in that: Based on the class and the unique identifier, generating a device object for the target device includes: The unique identifier is written into the class to obtain a device object of the target device.
5. A method for generating a device object, characterized in that: include: Obtaining a configuration file corresponding to the target device, wherein the configuration file corresponding to the target device is a configuration file corresponding to the device type to which the target device belongs, wherein the database stores configuration files of each device type in a standard data format constructed based on product design specifications of each device type produced by the manufacturer of the target device or a third party; Providing the configuration file to a server, so that the server generates a class corresponding to the target device based on the configuration file, and generates a device object of the target device based on a unique identifier of the target device and the class, wherein the unique identifier is a device number configured before leaving the factory or a unique identifier used when connecting to the outside world after leaving the factory, and the unique identifier of the target device is determined by receiving an access request for requesting the target device to be connected to the Internet of Things by the server, and the access request includes the unique identifier of the target device; A script file corresponding to the target device is sent to the server, the script file including device parameters of the target device object, so that the server replaces the device parameters with the device object of the target device and executes the script file.
6. The method according to claim 5, characterized in that The configuration file includes: attributes, services and events, wherein the attributes are characteristics of the target device, the services are actions performed by the target device, and the events are responses of the target device.
7. A device object generation apparatus, characterized in that: include: A first determination module is used to receive an access request for requesting the target device to access the Internet of Things, wherein the access request includes a unique identifier of the target device, wherein the unique identifier is a device number configured before leaving the factory or a unique identifier used when connecting to the outside world after leaving the factory; A second determination module is used to determine a configuration file corresponding to the target device based on the unique identifier, wherein the configuration file corresponding to the target device is a configuration file of the target device or a configuration file corresponding to a device type to which the target device belongs, wherein a configuration file of each device or each device type in a standard data format constructed based on a product design description of each device type produced provided by a manufacturer of the target device or a third party is stored in the database; Based on the configuration file, generating a class corresponding to the target device; A generating module, configured to generate a device object of the target device based on the class and the unique identifier; The calling module is used to obtain a script file corresponding to the target device, wherein the script file includes device parameters corresponding to the target device; replace the device parameters with the device object of the target device, and execute the script file.
8. A device object generation apparatus, characterized in that: include: an acquisition module, used to acquire a configuration file corresponding to a target device, wherein the configuration file corresponding to the target device is a configuration file of the target device or a configuration file corresponding to a device type to which the target device belongs, wherein a configuration file of each device or each device type in a standard data format constructed based on a product design description of each device type produced provided by a manufacturer of the target device or a third party is stored in the database; A module is provided, which is used to provide the configuration file to a server, so that the server generates a class corresponding to the target device based on the configuration file, and generates a device object of the target device based on a unique identifier of the target device and the class, wherein the unique identifier is a device number configured before leaving the factory or a unique identifier used when connecting with the outside world after leaving the factory, and the unique identifier of the target device is determined by the server receiving an access request for requesting the target device to be connected to the Internet of Things, and the access request includes the unique identifier of the target device; The sending module is used to send a script file corresponding to the target device to the server, wherein the script file includes device parameters of the target device object, so that the server replaces the device parameters with the device object of the target device and executes the script file.
9. An electronic device, characterized in that: include: processor; as well as A memory arranged to store computer executable instructions which, when executed, cause the processor to perform the steps of the method as claimed in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Computer system that provides a systematically abstract representation of a smart device and a computer-implemented method thereof
CN107239416A
Intelligent household system building method and device, intelligent household system and terminal
WO2018014553A1
