Method and device for dynamic access and automatic storage of multimodal IoT device data for health and elderly care
By automating the processing of XML configuration files for device data access and storage, the complexity of device data access and storage in the health and elderly care system is solved, achieving efficient device access and storage, and improving system stability and user experience.
Patent Information
- Application Number
- CN202210252892.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-15
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2042-03-15
AI Technical Summary
In the context of health and elderly care, the access and storage of device data in health and elderly care application systems based on the MQTT protocol are complex and error-prone, resulting in a poor user experience and hindering the promotion and use of the system.
By updating the XML configuration file, the system automates device data subscription, database selection, table creation, and data saving. It uses a timer to read the configuration file and automatically handle device access and storage processes, supporting multiple database types.
It enables efficient and dynamic access and storage of device data, simplifies operation and maintenance, improves system stability and user experience, and supports big data analysis and artificial intelligence applications.
Smart Images

Figure CN114722040B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of health care and the Internet of Things, and specifically relates to a method and device for dynamic access and automatic storage of multimodal IoT device data for health care and the Internet of Things. Background Art
[0002] With the continuous development of Internet technology and Internet of Things technology, more and more smart homes and health care equipment are entering the field of health care, and the integration between the Internet of Things and the field of health care is becoming closer. At present, the home-based model of health care is taking the family as the core, uploading the data of health care terminal equipment in the family through the Internet of Things protocol, and being managed and operated by community centers or third-party organizations, providing various elderly care services for home-based elderly care users in the jurisdiction, and improving the quality of life of elderly users at home. New business model.
[0003] As an instant messaging protocol with low overhead and low bandwidth usage, the MQTT protocol is widely used in the Internet of Things, small devices, mobile applications, etc. Taking the health care scenario as an example, through the MQTT protocol, health detection devices can upload the physiological data of the elderly, environmental perception devices can regularly upload the elderly's home environment data, and security monitoring devices can upload the elderly's alarm information in real time.
[0004] In the context of health care and elderly care scenarios, the health care and elderly care application system based on the MQTT protocol includes various types of health care and elderly care terminal devices or terminal gateways in multiple families, multiple MQTT servers provided by themselves or third-party organizations, and edge servers and data warehouses centered on communities or third-party service providers.
[0005] Among them, in the edge servers and data warehouses centered on communities or third-party service providers, a series of manual operations are required to manage MQTT subscriptions and data, including adding or canceling MQTT subscription topics, and establishing and performing database operations based on new subscription data. For non-professionals, this is a very time-consuming and laborious task, requiring more time to learn and try. At the same time, errors in subscription and database operations may cause system failures, which have a negative impact on user experience and subsequent data analysis, hindering the promotion and use of health and elderly care services based on the MQTT protocol in community centers or third-party service providers. Summary of the invention
[0006] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a method and device for dynamic access and automatic storage of multimodal IoT device data for health and elderly care, so as to improve the efficiency of device data access and storage.
[0007] The present invention solves the technical problem by the following technical solutions:
[0008] A method for dynamic access and automatic storage of multimodal IoT device data for health and elderly care, characterized in that: in the process of dynamic device access to the device system, the method automatically completes device data subscription, database selection, table creation and data preservation by updating the XML file configuration, and the method specifically includes the following steps:
[0009] 1) Automatic configuration file of acquisition device:
[0010] The function of this file is to describe the collection device subscription topic, storage type, and data format in XML format. The subscription module parses and establishes the corresponding device table according to the XML configuration file and completes the device data subscription. The data module loads the corresponding data into the specified database table according to the configuration file. Therefore, you only need to update the configuration file to automatically complete the establishment of multiple databases for new device types in the community and the update and cancellation of subscription topics. The semantics of the XML automatic configuration file is:
[0011] · Equipmentstore is the root tag, which can contain multiple equipmentsub tags and equipmentdb tags
[0012] The equipmentsub tag identifies an MQTT subscription topic corresponding to the equipment
[0013] Among them: the server tag identifies the IP address of the subscription topic server, the port tag identifies the subscription topic port number, and the subject tag identifies the subscription topic name. The same equipmentsub tag can contain multiple subject tags;
[0014] The subject tag contains the db attribute. When the db attribute value is 0, it means that the database corresponding to the device needs to be created. When the db attribute value is 1, it means that the database corresponding to the device has been created. The subject tag contains the flag attribute. When the flag attribute value is 0, it means that the topic needs to be subscribed. When the flag attribute value is 1, it means that the topic has been subscribed. When the flag attribute value is 2, it means that the topic needs to be unsubscribed. When the flag attribute value is 3, it means that the topic has been unsubscribed.
[0015] The equipmentdb tag identifies the data storage structure information of the data warehouse
[0016] Among them: the sub tag indicates the subscription topic corresponding to the data warehouse, the type tag indicates the database type of the data warehouse to be established, the table tag indicates the table name of this data warehouse, and the field tag indicates the field to be established when the database type is mysql. When the type tag is mysql, one equipmentdb tag can contain multiple field tags. The field tag contains the type attribute to indicate the type of the field.
[0017] 2) New device topic tracking:
[0018] Through the timer, set up a scheduled execution task, read the above XML configuration file regularly, read the equipmentsub and equipmentdb nodes under the root node, obtain the corresponding server IP address and port number information by traversing all equipmentsub nodes, and obtain all subject nodes under the equipmentsub node and traverse them. When the flag attribute is 0, start a subscription subprocess, save the subprocess information to the MySQL database and change the flag attribute to 1; when the flag attribute is 1, output the subscribed information; when the flag attribute is 2, query the corresponding process information of the topic in the MySQL database, close the corresponding subscription process, change the flag attribute value to 3, and output the unsubscribed information when the flag attribute is 3;
[0019] 3) Equipment data table generation:
[0020] This system supports the establishment of mongodb and mysql database tables, and will be expanded to other database tables in the same way later. When traversing all subject nodes, when the flag attribute is 0, the db attribute value is determined at the same time. When the db attribute is 0, query the equipmentdb node whose subject node value is consistent with the sub node value in equipmentdb. When its type node is determined to be mongodb, execute the mongodb collection creation operation and insert the first document for verification;
[0021] When the type node is determined to be mysql, the mysql table creation operation is executed. The default necessary fields include the id field, which is the auto-increment primary key, and the create_time field, which indicates the current record insertion time.
[0022] After the table creation operation is completed, the name of the field to be added is obtained according to the field node value, the type of the field is obtained according to the type attribute, and the field addition operation is performed. If the field node is not found, no additional field is added;
[0023] 4) Data loading:
[0024] After the subscription process is started, a topic subscription client is established according to the passed parameters, and the process information and topic information of the subscription process are saved to MySQL. The data loading class is instantiated according to the topic information. The data loading class reads the XML configuration file, obtains the equipmentdb node corresponding to this topic, initializes the instance attributes according to the node's type database type and table name, and finally establishes a connection between the client and the subscribed server according to the passed parameters;
[0025] After receiving the subscription message, pass the message body to the data loading instance and call the save method of the example. The save method first obtains the current time, converts the message body into json format, and determines the database type and table name where the topic message should be stored based on the instance attributes. When it is determined to be mongodb, the json format message body is directly saved as a document. When it is determined to be mysql, first insert a new record based on the acquisition time, and then update the value value to the corresponding field of the record based on the field name corresponding to the key value of the message body.
[0026] A device for dynamic access and automatic storage of multimodal IoT device data for health care and elderly care, characterized in that: it includes an MQTT terminal gateway device, an edge server device and an MQTT cloud server device, the MQTT terminal gateway device and the edge server device are connected and communicated through the MQTT cloud server device; the MQTT terminal gateway device is used to access health care and elderly care devices without MQTT capabilities, and perform protocol conversion and upload device data that does not support the MQTT protocol; the MQTT cloud server device provides MQTT server function support; the edge server device is used to carry a dynamic access and automatic storage method and data warehouse.
[0027] The advantages and beneficial effects of the present invention are:
[0028] 1. The method and device for dynamic access and automatic storage of multimodal IoT device data for health and elderly care of the present invention can support dynamic access and storage of multimodal device data without interrupting system operation, and realize standardization of database operations to support operation and maintenance personnel to efficiently maintain and update the system, and facilitate the application of big data analysis and artificial intelligence algorithms in smart home environments for health and elderly care.
[0029] 2. The method and device for dynamic access and automatic storage of multimodal IoT device data for health and elderly care of the present invention improves the efficiency of device data access and storage. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a schematic diagram of an application scenario of the present invention;
[0031] Figure 2 It is a schematic diagram of the system architecture of the present invention;
[0032] Figure 3 is a flow chart of the method of the present invention;
[0033] Figure 4 Schematic diagram of the device of the present invention. DETAILED DESCRIPTION
[0034] The present invention is further described in detail below through specific examples. The following examples are only illustrative and not restrictive, and the protection scope of the present invention cannot be limited thereto.
[0035] A method for dynamic access and automatic storage of multimodal IoT device data for health and elderly care, characterized in that: in the process of dynamic device access to the device system, the method automatically completes device data subscription, database selection, table creation and data preservation by updating the XML file configuration, and the method specifically includes the following steps:
[0036] 1) Automatic configuration file of acquisition device:
[0037] The function of this file is to describe the collection device subscription topic, storage type, and data format in XML format. The subscription module parses and establishes the corresponding device table according to the XML configuration file and completes the device data subscription. The data module loads the corresponding data into the specified database table according to the configuration file. Therefore, you only need to update the configuration file to automatically complete the establishment of multiple databases for new device types in the community and the update and cancellation of subscription topics. The semantics of the XML automatic configuration file is:
[0038] · Equipmentstore is the root tag, which can contain multiple equipmentsub tags and equipmentdb tags
[0039] The equipmentsub tag identifies an MQTT subscription topic corresponding to the equipment
[0040] Among them: the server tag identifies the IP address of the subscription topic server, the port tag identifies the subscription topic port number, and the subject tag identifies the subscription topic name. The same equipmentsub tag can contain multiple subject tags;
[0041] The subject tag contains the db attribute. When the db attribute value is 0, it means that the database corresponding to the device needs to be created. When the db attribute value is 1, it means that the database corresponding to the device has been created. The subject tag contains the flag attribute. When the flag attribute value is 0, it means that the topic needs to be subscribed. When the flag attribute value is 1, it means that the topic has been subscribed. When the flag attribute value is 2, it means that the topic needs to be unsubscribed. When the flag attribute value is 3, it means that the topic has been unsubscribed.
[0042] The equipmentdb tag identifies the data storage structure information of the data warehouse
[0043] Among them: the sub tag indicates the subscription topic corresponding to the data warehouse, the type tag indicates the database type of the data warehouse to be established, the table tag indicates the table name of this data warehouse, and the field tag indicates the field to be established when the database type is mysql. When the type tag is mysql, one equipmentdb tag can contain multiple field tags. The field tag contains the type attribute to indicate the type of the field.
[0044] The following is an example of an xml configuration file:
[0045]
[0046]
[0047] 2) New device topic tracking:
[0048] Through the timer, set up a scheduled execution task, read the above XML configuration file regularly, read the equipmentsub and equipmentdb nodes under the root node, obtain the corresponding server IP address and port number information by traversing all equipmentsub nodes, and obtain all subject nodes under the equipmentsub node and traverse them. When the flag attribute is 0, start a subscription subprocess, save the subprocess information to the MySQL database and change the flag attribute to 1; when the flag attribute is 1, output the subscribed information; when the flag attribute is 2, query the corresponding process information of the topic in the MySQL database, close the corresponding subscription process, change the flag attribute value to 3, and output the unsubscribed information when the flag attribute is 3;
[0049] 3) Equipment data table generation:
[0050] This system supports the establishment of mongodb and mysql database tables, and will be expanded to other database tables in the same way later. When traversing all subject nodes, when the flag attribute is 0, the db attribute value is determined at the same time. When the db attribute is 0, query the equipmentdb node whose subject node value is consistent with the sub node value in equipmentdb. When its type node is determined to be mongodb, execute the mongodb collection creation operation and insert the first document for verification;
[0051] When the type node is determined to be mysql, the mysql table creation operation is executed. The default necessary fields include the id field, which is the auto-increment primary key, and the create_time field, which indicates the current record insertion time.
[0052] After the table creation operation is completed, as shown in Table 1, the name of the field to be added is obtained according to the field node value, the type of the field is obtained according to the type attribute, and the field addition operation is performed. If the field node is not found, no additional field is added;
[0053] Table 1 Equipment data sheet
[0054] Serial number Column Name Data Types length Primary Key Allow Empty illustrate 1. id Int 11 yes no Table primary key 2. create_time varchar 50 no no Current record insertion time
[0055] 4) Data loading:
[0056] After the subscription process is started, a topic subscription client is established according to the passed parameters, and the process information and topic information of the subscription process are saved to MySQL. The data loading class is instantiated according to the topic information. The data loading class reads the XML configuration file, obtains the equipmentdb node corresponding to this topic, initializes the instance attributes according to the node's type database type and table name, and finally establishes a connection between the client and the subscribed server according to the passed parameters;
[0057] After receiving the subscription message, pass the message body to the data loading instance and call the save method of the example. The save method first obtains the current time, converts the message body into json format, and determines the database type and table name where the topic message should be stored based on the instance attributes. When it is determined to be mongodb, the json format message body is directly saved as a document. When it is determined to be mysql, first insert a new record based on the acquisition time, and then update the value value to the corresponding field of the record based on the field name corresponding to the key value of the message body.
[0058] A device for dynamic access and automatic storage of multimodal IoT device data for health care and elderly care, characterized in that: it includes an MQTT terminal gateway device, an edge server device and an MQTT cloud server device, the MQTT terminal gateway device and the edge server device are connected and communicated through the MQTT cloud server device; the MQTT terminal gateway device is used to access health care and elderly care devices without MQTT capabilities, and perform protocol conversion and upload device data that does not support the MQTT protocol; the MQTT cloud server device provides MQTT server function support; the edge server device is used to carry a dynamic access and automatic storage method and data warehouse.
[0059] The following is a detailed description of the smart home model room for health and elderly care. The application scenario of this method is Figure 1 The application scenario includes multiple health and elderly care IoT devices and MQTT terminal gateways in the model room using the MQTT protocol, multiple MQTT servers in the cloud, and an edge server in the community center. Assume that the types of model room devices to be connected in this embodiment include:
[0060] Environmental sensing devices, such as temperature and humidity sensors
[0061] Safety monitoring equipment, such as fall alarm cameras, pressure sensing mattresses, and one-button alarms
[0062] ·Health testing equipment, such as ECG collection mattresses
[0063] The data formats and sampling frequencies of various devices are different. For devices with high sampling frequencies, such as temperature and humidity sensors, which require fast reading and writing speeds, MongoDB can be used for data storage. For alarm devices such as one-button alarms, which have high transaction requirements for data, MySQL can be used for data storage.
[0064] The method provided by the present invention is applied to the edge server of the community center, and the edge server is responsible for subscribing and storing the device data of the family health and elderly care Internet of Things devices within the jurisdiction.
[0065] Assume that in the initial state 01, the community center needs to access the equipment information of the temperature and humidity sensor, fall alarm camera, and ECG collection mattress in the model room, and the database of the relevant equipment has not been established. In this case, the configuration file needs to configure the equipmentsub tag and equipmentdb tag. At this time, the db attribute value under the subject node in the equipmentsub tag is 0, the flag attribute value is 0, and the configuration file is:
[0066]
[0067]
[0068] After starting the program, the system parses the configuration file, subscribes to the corresponding topic, and automatically establishes the corresponding database according to the configuration. The initial state 01 migrates to state 02. At this time, the community center has subscribed to the equipment information of the temperature and humidity sensor, fall alarm camera, and ECG collection mattress in the model room, and the database of the relevant equipment has been established. The equipment data in the sample room is automatically saved to the edge center data warehouse. At this time, the db attribute value and flag attribute value under the subject node in the equipmentsub tag of the configuration file in state 02 will be automatically modified to 1. The configuration file in state 02 is:
[0069]
[0070]
[0071] Assume that you need to add and cancel the data subscription of the temperature and humidity sensor. The operation and maintenance personnel do not need to interrupt the system operation. They only need to modify the flag attribute value of the corresponding topic xml to 2:
[0072]
[0073] The system loads the updated XML configuration, reads the process information of the temperature and humidity sensor topic in the database, closes the subscription process, and updates the XML configuration file. At this time, in state 03, the db attribute value under the subject node in the equipmentsub tag corresponding to the configuration file is 1, the flag attribute value is 3, and the configuration file is:
[0074]
[0075]
[0076] Assume that you need to subscribe to a new one-key alarm device data, and assume that the alarm MQTT server is the same as the temperature and humidity sensor MQTT server, and the edge server has not created a new corresponding database. The operation and maintenance personnel only need to add a subject node to the equipmentsub tag under the original configuration file, and set the db attribute value to 0 and the flag attribute value to 0.
[0077]
[0078] The edge server system loads the new xml configuration, subscribes to the new device topic and establishes the database, and updates the xml configuration file. The new data is automatically saved in the edge server data warehouse. At this time, in state 04, the db attribute value and flag attribute value of the newly added subject node in the configuration file are automatically modified to 1. The configuration file is:
[0079]
[0080]
[0081] Although the embodiments and drawings of the present invention are disclosed for illustrative purposes, those skilled in the art will appreciate that various substitutions, changes and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the scope of the present invention is not limited to the contents disclosed in the embodiments and drawings.
Claims
1. A method for dynamic access and automatic storage of multimodal IoT device data for health and elderly care. Features: The method uses the updated XML file configuration to automatically complete the device data subscription, database selection, table creation and data preservation work during the process of the device dynamically accessing the device system. The method specifically includes the following steps: 1) Automatic configuration file of acquisition device: The function of this file is to describe the collection device subscription topic, storage type, and data format in XML format. The subscription module parses and establishes the corresponding device table according to the XML configuration file and completes the device data subscription. The data module loads the corresponding data into the specified database table according to the configuration file. Therefore, only the configuration file needs to be updated to automatically complete the establishment of multiple databases for new device types in the community and the update and cancellation of subscription topics. The semantics of the XML automatic configuration file are: ·equipmentstore is the root tag, which contains multiple equipmentsub tags and equipmentdb tags. ·equipmentsub tag identifies an mqtt subscription topic corresponding to the device Among them: the server tag identifies the IP address of the subscription topic server, the port tag identifies the subscription topic port number, the subject tag identifies the subscription topic name, and the same equipmentsub tag contains multiple subject tags; The subject tag contains the db attribute. When the db attribute value is 0, it means that the database corresponding to the device needs to be created. When the db attribute value is 1, it means that the database corresponding to the device has been created. The subject tag contains the flag attribute. When the flag attribute value is 0, it means that the topic needs to be subscribed. When the flag attribute value is 1, it means that the topic has been subscribed. When the flag attribute value is 2, it means that the topic needs to be unsubscribed. When the flag attribute value is 3, it means that the topic has been unsubscribed. The equipmentdb tag identifies the data storage structure information of the data warehouse Among them: the sub tag indicates the subscription topic corresponding to the data warehouse, the type tag indicates the database type of the data warehouse to be established, the table tag indicates the table name of this data warehouse, and the field tag indicates the field to be established when the database type is mysql. When the type tag is mysql, a equipmentdb tag contains multiple field tags, and the field tag contains the type attribute, which indicates the type of the field; 2) New device topic tracking: Through the timer, set up a scheduled execution task, read the above XML configuration file regularly, read the equipmentsub and equipmentdb nodes under the root node, obtain the corresponding server IP address and port number information by traversing all equipmentsub nodes, and obtain all subject nodes under the equipmentsub node and traverse them. When the flag attribute is 0, start a subscription subprocess, save the subprocess information to the MySQL database and change the flag attribute to 1; when the flag attribute is 1, output the subscribed information; when the flag attribute is 2, query the corresponding process information of the topic in the MySQL database, close the corresponding subscription process, change the flag attribute value to 3, and output the unsubscribed information when the flag attribute is 3; 3) Equipment data table generation: This system supports the establishment of mongodb and mysql database tables, and will be expanded to other database tables in the same way later. When traversing all subject nodes, when the flag attribute is 0, the db attribute value is determined at the same time. When the db attribute is 0, query the equipmentdb node whose subject node value is consistent with the sub node value in equipmentdb. When its type node is determined to be mongodb, execute the mongodb collection creation operation and insert the first document for verification; When the type node is determined to be mysql, the mysql table creation operation is executed. The default necessary fields include the id field, which is the auto-increment primary key, and the create_time field, which indicates the current record insertion time. After the table creation operation is completed, the name of the field to be added is obtained according to the field node value, the type of the field is obtained according to the type attribute, and the field addition operation is performed. If the field node is not found, no additional field is added; 4) Data loading: After the subscription process is started, a topic subscription client is established according to the passed parameters, and the process information and topic information of the subscription process are saved to MySQL. The data loading class is instantiated according to the topic information. The data loading class reads the XML configuration file, obtains the equipmentdb node corresponding to this topic, initializes the instance attributes according to the node's type database type and table name, and finally establishes a connection between the client and the subscribed server according to the passed parameters; After receiving the subscription message, pass the message body to the data loading instance and call the save method of the example. The save method first obtains the current time, converts the message body into json format, and determines the database type and table name where the topic message should be stored based on the instance attributes. When it is determined to be mongodb, the json format message body is directly saved as a document. When it is determined to be mysql, first insert a new record based on the acquisition time, and then update the value value to the corresponding field of the record based on the field name corresponding to the key value of the message body.
2. The device for dynamic access and automatic storage of multimodal IoT device data for health and elderly care according to claim 1, Features: It includes an MQTT terminal gateway device, an edge server device and an MQTT cloud server device. The MQTT terminal gateway device and the edge server device are connected and communicated through the MQTT cloud server device; the MQTT terminal gateway device is used to access health and elderly care equipment without MQTT capabilities, and perform protocol conversion and upload the data of devices that do not support the MQTT protocol; The MQTT cloud server device provides MQTT server function support; the edge server device is used to carry dynamic access and automatic storage methods and data warehouses.
Citation Information
Patent Citations
Apparatus and method for providing decoupling of data exchange details for providing high performance communication between software processes
CA2001621A1
Multi-mode comprehensive application system based on 5G-IoT and method thereof
CN112269320A
Multi-source heterogeneous IoT device data unified access and storage system and method
CN112995153A
Processing, storing and sharing method for mass Internet of Things data modeling
CN113986873A
Residence comprehensive information processing system and method based on edge computing
CN114051043A
