A data acquisition, storage and query system for power equipment production
By designing a data acquisition, storage and query system for power equipment production and adopting random matching and multi-layer encryption technology, the problem of insecure data acquisition and storage of power equipment is solved, and automated and secure data acquisition and storage is achieved.
Patent Information
- Application Number
- CN202410867057.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2044-07-01
AI Technical Summary
Existing power equipment lacks a universal solution in the data collection process, resulting in insecure data collection and storage, prone to data leakage and errors, and complex manual operations, making it difficult to meet the diverse needs of power equipment.
A data acquisition, storage and query system for power equipment production was designed. It includes an acquisition module, a storage module and a query module. Random matching and multi-layer encryption technologies are used to ensure secure data transmission and storage, and digital certificate verification is used to improve communication security.
It achieves automation and security in data collection and storage, reduces labor costs, ensures data security and consistency, avoids data leakage and errors, and simplifies software development workload.
Smart Images

Figure CN118820271B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data acquisition, and specifically to a data acquisition, storage and query system for power equipment production. Background Art
[0002] Against the backdrop of "Industry 4.0," "Smart Manufacturing," and "Industrial Internet," and with the rapid development of Industrial Internet of Things (IIoT) technology, the increasing diversity of power equipment types, models, and functions in China has necessitated dedicated personnel for data collection and entry during the production of circuit equipment. However, current power equipment is typically equipped with a stand-alone database to collect and store data. These stand-alone databases, such as Access and SQLite, lack a universal solution for data collection on the market, and manual data aggregation and entry are prone to data leaks and errors. Summary of the Invention
[0003] In view of the shortcomings of the existing technology, the purpose of the present invention is to provide a data acquisition, storage and query system for power equipment production
[0004] To achieve the above objectives, the present invention provides the following technical solutions: a data acquisition, storage, and query system for power equipment production, comprising an acquisition module, a storage module, and a query module. The acquisition module is configured based on the number of actual high-voltage power stations. The storage module is configured to store data sent by the acquisition module. There are at least three storage modules, and all storage modules back up each other's data. The query module is configured to extract data from the storage module for data processing or data query.
[0005] The acquisition module includes a data acquisition module, an acquisition parameter configuration module and a PC terminal. The data acquisition module and the acquisition parameter configuration module are arranged in the PC terminal, and the PC terminal communicates with the power equipment data acquisition terminal.
[0006] The data acquisition module includes an acquisition parameter information query interface unit, an acquisition unified interface unit, an acquisition software management unit, an acquisition software type management unit and a data acquisition software monitoring unit;
[0007] The acquisition parameter configuration module includes a device ID information configuration unit, a database information configuration unit and an acquisition software type information configuration unit;
[0008] The acquisition parameter information query interface unit and the acquisition unified interface unit communicate with the power equipment data acquisition terminal. The acquisition parameter information query interface unit receives the equipment information and communicates with the acquisition parameter configuration module to match the data. After receiving the matched data information, the acquisition unified interface unit sends the data information to the acquisition software type management unit. The acquisition software type management unit calls the matching acquisition software in the acquisition software management unit based on the received data information. The acquisition unified interface unit returns to the PC end through the called acquisition software for data acquisition and stores the collected data in the local PC end database.
[0009] The PC terminal also includes a random matching unit 1 and a data encryption unit. The random matching unit 1 is provided with the link information of all storage modules. The random matching unit 1 randomly extracts a storage module link information, and the PC terminal communicates with the storage module. The data collected by the PC terminal is encrypted by the data encryption unit and then transmitted to the linked storage module.
[0010] The storage module includes an independently set storage server, a data decryption unit 1 set in the storage server, a data encryption storage unit, a data update synchronization unit, a digital certificate unit 1 and a storage database.
[0011] The encryption algorithm of the data encryption storage unit is different from the encryption algorithm of the data encryption unit. The data decryption unit 1 is used to decrypt the data encrypted by the data encryption unit. The data encryption storage unit is used to encrypt the data decrypted by the data decryption unit 1 and store it in the storage database. The data update synchronization unit is used to monitor the data in the storage database. When the data encryption storage unit stores the encrypted data in the storage database, the data update synchronization unit is triggered to run. The data update synchronization unit is used to communicate with the storage servers of all other remaining storage modules, and the data stored in the storage database of this storage server is synchronized to other storage servers to keep the storage database data of all storage servers consistent. The digital certificate unit 1 stores certificate information related to all query modules, which is used to verify the communication legalization link of the query module;
[0012] The query module includes a query terminal, a digital certificate unit 2 set in the query terminal, a data decryption unit 2, and a random matching unit 2. The random matching unit 2 is provided with link information of all storage modules. The random matching unit 2 randomly extracts a storage module link information, and the query terminal communicates with the storage module. The digital certificate unit 2 stores the digital certificate of the query terminal. The digital certificate unit 1 is used to verify the digital certificate unit 2 and, after verification, to link the network communication between the query terminal and the storage server. After the query terminal extracts the corresponding data from the storage database, the data decryption unit 2 is used to decrypt the encrypted data.
[0013] The operation mode of the random matching unit 1 is:
[0014] (1) Sort and number the link information of all storage modules and form the original array;
[0015] (2) Using the shuffling algorithm, the original array is shuffled and randomly sorted to form a random array;
[0016] (3) Extract the numbers at the corresponding positions in the random array according to the preset extraction sorting number;
[0017] (4) Based on the extracted number corresponding to the corresponding link information, the PC end is realized through the link information and the storage module corresponding to the link information;
[0018] (5) According to step (4), when the PC terminal is not communicating with the storage module for the first time, the random matching unit removes the number corresponding to the last link information from the original array, and then shuffles the array randomly by using a shuffling algorithm to form a corresponding random array;
[0019] (6) Then, after extracting the corresponding link information through steps (3) and (4), communication between the PC and the storage module is realized;
[0020] The random matching unit 2 and the data matching unit 1 are processed in the same manner, and the extraction order of the random matching unit 2 is inconsistent with the extraction order of the random matching unit 1.
[0021] In some embodiments, the acquisition modules are numbered according to the corresponding high-voltage power stations, and each number is matched with the high-voltage electric data acquisition equipment information corresponding to the high-voltage power station. Each time the data is transmitted to the storage module by the PC end, it includes the high-voltage power station number, transmission time, corresponding high-voltage electric data acquisition equipment information, and data collected by the acquisition equipment. The storage module receives the above information to establish a database index and performs index matching on the above information. The query module queries the relevant data information required on the storage module according to the index.
[0022] In some embodiments, the digital certificate unit includes a digital certificate parsing unit, a digital certificate verification unit and a digital certificate library. The digital certificate library contains digital certificate information related to all query modules. The digital certificate parsing unit is used to parse the digital certificate carried by the linked query terminal. The digital certificate verification unit is used to match the parsed information with the digital certificate library. After the match is verified correctly, the storage database in the storage module communicates with the corresponding query terminal.
[0023] In some embodiments, the acquisition parameter information query interface unit is specifically implemented as follows:
[0024] Connect to the database: First, use the create_engine function in the SQLAlchemy library to establish a connection to the SQLite database;
[0025] Get table information: Then, use the MetaData object to obtain metadata information in the database, including table structure, etc.
[0026] Query parameters: Next, construct a query statement using the select method of the Table object, specifying that the query is for the parameters table and filtering out rows where the device_id column is equal to the given parameter device_id;
[0027] Execute query: Use the execute method of the connection object to execute the query statement and get the query results;
[0028] Process query results: traverse the query results and add the parameter name and parameter value of each row to a dictionary;
[0029] Close the connection: Finally, close the database connection and release resources;
[0030] Return parameter dictionary: Returns a dictionary containing the queried parameters.
[0031] In some embodiments, the unified acquisition interface unit is specifically implemented as follows:
[0032] (1) Accept a parameter dictionary parameters, which contains parameter names and corresponding values;
[0033] Traverse the parameter dictionary, call the call_external_api function for each parameter, and store the returned data in the collected_data dictionary;
[0034] Returns the collected data dictionary collected_data;
[0035] (2) Accept parameter name and value;
[0036] Match the dictionary consisting of parameter names and values to call the corresponding external API and return the corresponding data;
[0037] (3) Accept a data dictionary data, which contains data collected from the external API;
[0038] Call the call_third_party_api function, passing the collected data as parameters, and store the returned integration results in the integration_result dictionary;
[0039] Returns the integration result dictionary integration_result;
[0040] (4) Accept a data dictionary data, which contains the collected data;
[0041] Returns a dictionary containing the success status, calls the corresponding third-party API, and returns the corresponding integration result.
[0042] In some embodiments, the acquisition software management unit is specifically implemented as follows:
[0043] Import necessary modules: Use from flask import Flask, request, jsonify to import the Flask framework and related modules;
[0044] Create a Flask application: Use app = Flask(__name__);
[0045] Define routes and view functions: Use the @app.route() decorator to define multiple routes and specify the corresponding HTTP request methods;
[0046] Install software: In the install_software() view function, extract the software name from the JSON data of the POST request and add it to the installed_software dictionary to indicate that the software has been installed;
[0047] Configure software: In the configure_software() view function, extract the software name from the JSON data of the POST request and return a successful configuration message;
[0048] Start the software: In the start_software() view function, extract the software name from the JSON data of the POST request and return a successful startup message;
[0049] Stop the software: In the stop_software() view function, extract the software name from the JSON data of the POST request and return a message indicating a successful stop.
[0050] Update software: In the update_software() view function, extract the software name from the JSON data of the POST request and return a successful update message;
[0051] Start the application: Use app.run(debug=True) to start the Flask application and enable debugging mode.
[0052] In some embodiments, the acquisition software type management unit is specifically implemented as follows:
[0053] Import necessary modules: Use from flask import Flask, request, jsonify to import the Flask framework and related modules;
[0054] Create a Flask application: Use app = Flask(__name__);
[0055] Define routes and view functions: Use the @app.route() decorator to define a route / match_software_type and specify the corresponding HTTP request method as POST;
[0056] Matching software type: In the match_software_type() view function, extract the data type data_type from the JSON data of the POST request.
[0057] If data_type is in the software_types dictionary, get the corresponding software type and return it.
[0058] If data_type is not in the software_types dictionary, a message is returned indicating that no matching software type was found, and a status code of 404 is returned;
[0059] Start the application: Use app.run(debug=True) to start the Flask application and enable debugging mode.
[0060] In some embodiments, the data acquisition software monitoring unit is specifically implemented as follows:
[0061] Import necessary modules: import the logging module for logging, import the time module for time operations, import the BackgroundScheduler class and related functional modules for background task scheduling;
[0062] Configure logging: Use logging.basicConfig() to configure the logger, set the log level to INFO, and specify the log format;
[0063] Define monitoring data collection function: define monitor_data_collection() function for monitoring data collection, which records monitoring information;
[0064] Define exception handling function: define handle_exception(e) function to handle exceptions during task execution, and record exception information;
[0065] Create a background task scheduler: Create a BackgroundScheduler instance scheduler for background task scheduling;
[0066] Add a scheduled task: Use the scheduler.add_job() method to add a scheduled task to the scheduler to execute the monitor_data_collection() function every 60 seconds;
[0067] Add an exception listener: Use the scheduler.add_listener() method to add an exception listener to the scheduler to monitor exceptions during task execution. When an exception occurs in a task, the handle_exception() function is called to handle it.
[0068] Start the scheduler: Use scheduler.start() to start the background task scheduler and start executing scheduled tasks;
[0069] Main loop and keyboard interrupt processing: Use while True to enter the main loop and keep the program running.
[0070] Use time.sleep(2) to make the program execute the loop body every 2 seconds to avoid excessive consumption of CPU resources.
[0071] Use the try-except block to catch keyboard interrupt exceptions. When a keyboard interrupt signal is received, call scheduler.shutdown() to stop the scheduler and log information indicating that the scheduler has stopped.
[0072] In some embodiments, the encryption algorithm of the data encryption storage unit is an asymmetric encryption algorithm RSA, and the encryption algorithm of the data encryption unit is a Keccak hash algorithm.
[0073] In some embodiments, the digital certificate corresponding to the digital certificate unit 2 is generated by the administrator through an encrypted digital certificate generator, and when the digital certificate is generated, the corresponding query terminal matching information is added, and then locked through an independent memory. At the same time, when the digital certificate is generated, the corresponding digital certificate verification information is generated and transmitted to the corresponding digital certificate library in all storage modules through an encrypted network for storage. When in use, the independent memory is inserted into the query terminal that matches it, and the digital certificate unit 2 on the query terminal extracts the digital certificate in the independent memory and pairs it with the query terminal. If the pairing is successful, the digital certificate is loaded. If the pairing is unsuccessful, the independent memory is disconnected from the query terminal.
[0074] Compared with the existing technology, the present invention has the following advantages: data collection configuration information is placed on the PC side, the collection software is decoupled from the configuration information, the configuration information is collected and parsed, and tasks are executed according to the collection rules; by separating the software and business concerns, the complexity of software business division and the workload of software development are reduced; maintenance personnel only need to understand basic SQL statements to complete basic business changes, without the involvement of developers, reducing labor costs, and at the same time realizing automated data collection and aggregation;
[0075] At the same time, through the setting of storage modules, data can be stored in different places, and multiple storage servers can be set up, which avoids data damage and the confidentiality and security of data links, and ensures the security of high-voltage electricity collection data;
[0076] The multi-layer encryption method within the storage module can prevent the encrypted data on the PC from being inconsistent with the encrypted data in the storage module's database, ensuring data alienation and pairing. This prevents unauthorized personnel from intercepting information during network transmission of encrypted data on the PC and stealing and decrypting the information in the storage module's database, thus ensuring data security.
[0077] By setting up the query module and setting up a digital certificate in the query module, the communication security between the storage module and the query module is improved;
[0078] By setting up a random matching unit, it is possible to avoid the same network matching in two adjacent communication connections, avoid the comparison of network monitoring information by irrelevant personnel, and ensure that different network matching information is used for each communication.
[0079] Details of one or more embodiments of the present application are presented in the following drawings and descriptions to make other features, purposes and advantages of the present application more concise and easy to understand, and the present application is fully described and understood through the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] Figure 1 This is a system principle block diagram of the present invention;
[0081] Figure 2 This is a communication diagram between the acquisition module and the storage module of the present invention;
[0082] Figure 3 A communication diagram between storage modules of the present invention;
[0083] Figure 4 A communication diagram between the query module and the storage of the present invention;
[0084] Figure 5 This is the data collection flow chart for the PC side. DETAILED DESCRIPTION
[0085] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0086] Example 1
[0087] See also Figures 1 to 5 The present invention provides a technical solution: a data acquisition, storage and query system for power equipment production, comprising an acquisition module, a storage module and a query module. The acquisition module is configured according to the actual number of high-voltage power stations. The storage module is configured to store data sent by the acquisition module. There are at least three storage modules, and all storage modules back up each other's data. The query module is configured to extract data from the storage module for data processing or data query.
[0088] The acquisition module includes a data acquisition module, an acquisition parameter configuration module and a PC terminal. The data acquisition module and the acquisition parameter configuration module are arranged in the PC terminal, and the PC terminal communicates with the power equipment data acquisition terminal.
[0089] The data acquisition module includes an acquisition parameter information query interface unit, an acquisition unified interface unit, an acquisition software management unit, an acquisition software type management unit and a data acquisition software monitoring unit;
[0090] The acquisition parameter configuration module includes a device ID information configuration unit, a database information configuration unit and an acquisition software type information configuration unit;
[0091] The acquisition parameter information query interface unit and the acquisition unified interface unit communicate with the power equipment data acquisition terminal. The acquisition parameter information query interface unit receives the equipment information and communicates with the acquisition parameter configuration module to match the data. After receiving the matched data information, the acquisition unified interface unit sends the data information to the acquisition software type management unit. The acquisition software type management unit calls the matching acquisition software in the acquisition software management unit based on the received data information. The acquisition unified interface unit returns to the PC end through the called acquisition software for data acquisition and stores the collected data in the local PC end database.
[0092] The PC terminal also includes a random matching unit 1 and a data encryption unit. The random matching unit 1 is provided with the link information of all storage modules. The random matching unit 1 randomly extracts a storage module link information, and the PC terminal communicates with the storage module. The data collected by the PC terminal is encrypted by the data encryption unit and then transmitted to the linked storage module.
[0093] The storage module includes an independently set storage server, a data decryption unit 1 set in the storage server, a data encryption storage unit, a data update synchronization unit, a digital certificate unit 1 and a storage database.
[0094] The encryption algorithm of the data encryption storage unit is different from the encryption algorithm of the data encryption unit. The data decryption unit 1 is used to decrypt the data encrypted by the data encryption unit. The data encryption storage unit is used to encrypt the data decrypted by the data decryption unit 1 and store it in the storage database. The data update synchronization unit is used to monitor the data in the storage database. When the data encryption storage unit stores the encrypted data in the storage database, the data update synchronization unit is triggered to run. The data update synchronization unit is used to communicate with the storage servers of all other remaining storage modules, and the data stored in the storage database of this storage server is synchronized to other storage servers to keep the storage database data of all storage servers consistent. The digital certificate unit 1 stores certificate information related to all query modules, which is used to verify the communication legalization link of the query module;
[0095] The query module includes a query terminal, a digital certificate unit 2 set in the query terminal, a data decryption unit 2, and a random matching unit 2. The random matching unit 2 is provided with link information of all storage modules. The random matching unit 2 randomly extracts a storage module link information, and the query terminal communicates with the storage module. The digital certificate unit 2 stores the digital certificate of the query terminal. The digital certificate unit 1 is used to verify the digital certificate unit 2 and, after verification, to link the network communication between the query terminal and the storage server. After the query terminal extracts the corresponding data from the storage database, the data decryption unit 2 is used to decrypt the encrypted data.
[0096] The operation mode of the random matching unit 1 is:
[0097] (1) Sort and number the link information of all storage modules and form the original array;
[0098] (2) Using the shuffling algorithm, the original array is shuffled and randomly sorted to form a random array;
[0099] (3) Extract the numbers at the corresponding positions in the random array according to the preset extraction sorting number;
[0100] (4) Based on the extracted number corresponding to the corresponding link information, the PC end is realized through the link information and the storage module corresponding to the link information;
[0101] (5) According to step (4), when the PC terminal is not communicating with the storage module for the first time, the random matching unit removes the number corresponding to the last link information from the original array, and then shuffles the array randomly by using a shuffling algorithm to form a corresponding random array;
[0102] (6) Then, after extracting the corresponding link information through steps (3) and (4), communication between the PC and the storage module is realized;
[0103] The random matching unit 2 is processed in the same manner as the data matching unit 1, and the extraction order of the random matching unit 2 is inconsistent with the extraction order of the random matching unit 1. For example, the extraction order of the random matching unit 1 is 1, and the extraction order of the random matching unit 2 is 2, that is, in the corresponding random array, the first number or the second number is extracted.
[0104] The acquisition modules are numbered according to the corresponding high-voltage power stations, and each number is matched with the high-voltage electricity data acquisition equipment information corresponding to the high-voltage power station. Each time the PC transmits data to the storage module, it includes the high-voltage power station number, transmission time, corresponding high-voltage electricity data acquisition equipment information, and data collected by the acquisition equipment. The storage module receives the above information to establish a database index and performs index matching on the above information. The query module queries the relevant data information required on the storage module according to the index.
[0105] The digital certificate unit 1 includes a digital certificate parsing unit, a digital certificate verification unit and a digital certificate library. The digital certificate library contains digital certificate information related to all query modules. The digital certificate parsing unit is used to parse the digital certificate carried by the linked query terminal. The digital certificate verification unit is used to match the parsed information with the digital certificate library. After the match is verified to be correct, the storage database in the storage module communicates with the corresponding query terminal.
[0106] The encryption algorithm of the data encryption storage unit is the asymmetric encryption algorithm RSA, and the encryption algorithm of the data encryption unit is the Keccak hash algorithm.
[0107] The digital certificate corresponding to the digital certificate unit 2 is generated by the administrator through an encrypted digital certificate generator, and when the digital certificate is generated, the corresponding query terminal matching information is added, and then locked through an independent memory. At the same time, when the digital certificate is generated, the corresponding digital certificate verification information is generated and transmitted to the corresponding digital certificate library in all storage modules through an encrypted network for storage. When in use, the independent memory is inserted into the query terminal that matches it, and the digital certificate unit 2 on the query terminal extracts the digital certificate in the independent memory and pairs it with the query terminal. If the pairing is successful, the digital certificate is loaded. If the pairing is unsuccessful, the independent memory is disconnected from the query terminal.
[0108] Example 2
[0109] The acquisition parameter information query interface unit is specifically implemented as follows:
[0110] Connect to the database: First, use the create_engine function in the SQLAlchemy library to establish a connection to the SQLite database;
[0111] Get table information: Then, use the MetaData object to obtain metadata information in the database, including table structure, etc.
[0112] Query parameters: Next, construct a query statement using the select method of the Table object, specifying that the query is for the parameters table and filtering out rows where the device_id column is equal to the given parameter device_id;
[0113] Execute query: Use the execute method of the connection object to execute the query statement and get the query results;
[0114] Process query results: traverse the query results and add the parameter name and parameter value of each row to a dictionary;
[0115] Close the connection: Finally, close the database connection and release resources;
[0116] Return parameter dictionary: Returns a dictionary containing the queried parameters.
[0117] The specific process of the above method is as follows:
[0118] def query_parameters(device_id):
[0119] parameters = {}
[0120] from sqlalchemy import create_engine, MetaData, Table, select
[0121] engine = create_engine('sqlite: / / / parameters.db')
[0122] conn = engine.connect()
[0123] metadata = MetaData()
[0124] parameters_table = Table('parameters', metadata, autoload=True,autoload_with=engine)
[0125] query = select([parameters_table]).where(parameters_table.columns.device_id == device_id)
[0126] result = conn.execute(query)
[0127] for row in result:
[0128] parameters[row['parameter_name']] = row['parameter_value']
[0129] conn.close()
[0130] return parameters
[0131] The specific implementation of the unified acquisition interface unit is as follows:
[0132] (1) Accept a parameter dictionary parameters, which contains parameter names and corresponding values;
[0133] Traverse the parameter dictionary, call the call_external_api function for each parameter, and store the returned data in the collected_data dictionary;
[0134] Returns the collected data dictionary collected_data;
[0135] (2) Accept parameter name and value;
[0136] Match the dictionary consisting of parameter names and values to call the corresponding external API and return the corresponding data;
[0137] (3) Accept a data dictionary data, which contains data collected from the external API;
[0138] Call the call_third_party_api function, passing the collected data as parameters, and store the returned integration results in the integration_result dictionary;
[0139] Returns the integration result dictionary integration_result;
[0140] (4) Accept a data dictionary data, which contains the collected data;
[0141] Returns a dictionary containing the success status, calls the corresponding third-party API, and returns the corresponding integration result.
[0142] The specific process of the above method is as follows:
[0143] def collect_data(parameters):
[0144] collected_data = {}
[0145] for parameter, value in parameters.items():
[0146] collected_data[parameter] = call_external_api(parameter,value)
[0147] return collected_data
[0148] def call_external_api(parameter, value):
[0149] return {'value': value}
[0150] def integrate_with_third_party(data):
[0151] integration_result = {}
[0152] integration_result = call_third_party_api(data)
[0153] return integration_result
[0154] def call_third_party_api(data):
[0155] return {'status': 'success'}
[0156] The acquisition software management unit is specifically implemented as follows:
[0157] Import necessary modules: Use from flask import Flask, request, jsonify to import the Flask framework and related modules;
[0158] Create a Flask application: Use app = Flask(__name__);
[0159] Define routes and view functions: Use the @app.route() decorator to define multiple routes and specify the corresponding HTTP request methods;
[0160] Install software: In the install_software() view function, extract the software name from the JSON data of the POST request and add it to the installed_software dictionary to indicate that the software has been installed;
[0161] Configure software: In the configure_software() view function, extract the software name from the JSON data of the POST request and return a successful configuration message;
[0162] Start the software: In the start_software() view function, extract the software name from the JSON data of the POST request and return a successful startup message;
[0163] Stop the software: In the stop_software() view function, extract the software name from the JSON data of the POST request and return a message indicating a successful stop.
[0164] Update software: In the update_software() view function, extract the software name from the JSON data of the POST request and return a successful update message;
[0165] Start the application: Use app.run(debug=True) to start the Flask application and enable debugging mode.
[0166] The specific process of the above method is as follows:
[0167] from flask import Flask, request, jsonify
[0168] app = Flask(__name__)
[0169] installed_software = {}
[0170] @app.route(' / install_software', methods=['POST'])
[0171] def install_software():
[0172] software_name = request.json.get('name')
[0173] installed_software[software_name] = True
[0174] return jsonify({'message': f'{software_name} installedsuccessfully.'})
[0175] @app.route(' / configure_software', methods=['POST'])
[0176] def configure_software():
[0177] software_name = request.json.get('name')
[0178] return jsonify({'message': f'{software_name} configuredsuccessfully.'})
[0179] @app.route(' / start_software', methods=['POST'])
[0180] def start_software():
[0181] software_name = request.json.get('name')
[0182] return jsonify({'message': f'{software_name} startedsuccessfully.'})
[0183] @app.route(' / stop_software', methods=['POST'])
[0184] def stop_software():
[0185] software_name = request.json.get('name')
[0186] return jsonify({'message': f'{software_name} stoppedsuccessfully.'})
[0187] @app.route(' / update_software', methods=['POST'])
[0188] def update_software():
[0189] software_name = request.json.get('name')
[0190] return jsonify({'message': f'{software_name} updatedsuccessfully.'})
[0191] if __name__ == '__main__':
[0192] app.run(debug=True)
[0193] The specific implementation of the acquisition software type management unit is as follows:
[0194] Import necessary modules: Use from flask import Flask, request, jsonify to import the Flask framework and related modules;
[0195] Create a Flask application: Use app = Flask(__name__);
[0196] Define routes and view functions: Use the @app.route() decorator to define a route / match_software_type and specify the corresponding HTTP request method as POST;
[0197] Matching software type: In the match_software_type() view function, extract the data type data_type from the JSON data of the POST request.
[0198] If data_type is in the software_types dictionary, get the corresponding software type and return it.
[0199] If data_type is not in the software_types dictionary, a message is returned indicating that no matching software type was found, and a status code of 404 is returned;
[0200] Start the application: Use app.run(debug=True) to start the Flask application and enable debugging mode.
[0201] The specific process of the above method is as follows:
[0202] from flask import Flask, request, jsonify
[0203] app = Flask(__name__)
[0204] software_types = {
[0205] 'type1': 'os1',
[0206] 'type2': 'os2',
[0207] 'type3': 'os1',
[0208] }
[0209] @app.route(' / match_software_type', methods=['POST'])
[0210] def match_software_type():
[0211] data_info = request.json
[0212] data_type = data_info.get('data_type')
[0213] if data_type in software_types:
[0214] software_type = software_types[data_type]
[0215] return jsonify({'software_type': software_type})
[0216] else:
[0217] return jsonify({'message': 'No matching software typefound.'}), 404
[0218] if __name__ == '__main__':
[0219] app.run(debug=True)
[0220] The data acquisition software monitoring unit is specifically implemented as follows:
[0221] Import necessary modules: import the logging module for logging, import the time module for time operations, import the BackgroundScheduler class and related functional modules for background task scheduling;
[0222] Configure logging: Use logging.basicConfig() to configure the logger, set the log level to INFO, and specify the log format;
[0223] Define monitoring data collection function: define monitor_data_collection() function for monitoring data collection, which records monitoring information;
[0224] Define exception handling function: define handle_exception(e) function to handle exceptions during task execution, and record exception information;
[0225] Create a background task scheduler: Create a BackgroundScheduler instance scheduler for background task scheduling;
[0226] Add a scheduled task: Use the scheduler.add_job() method to add a scheduled task to the scheduler to execute the monitor_data_collection() function every 60 seconds;
[0227] Add an exception listener: Use the scheduler.add_listener() method to add an exception listener to the scheduler to monitor exceptions during task execution. When an exception occurs in a task, the handle_exception() function is called to handle it.
[0228] Start the scheduler: Use scheduler.start() to start the background task scheduler and start executing scheduled tasks;
[0229] Main loop and keyboard interrupt processing: Use while True to enter the main loop and keep the program running.
[0230] Use time.sleep(2) to make the program execute the loop body every 2 seconds to avoid excessive consumption of CPU resources.
[0231] Use the try-except block to catch keyboard interrupt exceptions. When a keyboard interrupt signal is received, call scheduler.shutdown() to stop the scheduler and log information indicating that the scheduler has stopped.
[0232] The specific process of the above method is as follows:
[0233] import logging
[0234] import time
[0235] from apscheduler.schedulers.background import BackgroundScheduler
[0236] logging.basicConfig(level=logging.INFO,
[0237] format='%(asctime)s - %(levelname)s - %(message)s')
[0238] def monitor_data_collection():
[0239] logging.info("Monitoring data collection...")
[0240] def handle_exception(e):
[0241] logging.error(f"An error occurred: {e}")
[0242] scheduler = BackgroundScheduler()
[0243] scheduler.add_job(monitor_data_collection, 'interval', seconds=60) #Execute the monitoring function every 60 seconds
[0244] scheduler.add_listener(handle_exception, 'job_error') # listen for exceptions during task execution
[0245] scheduler.start()
[0246] try:
[0247] while True:
[0248] time.sleep(2)
[0249] except KeyboardInterrupt:
[0250] scheduler.shutdown()
[0251] logging.info("Scheduler stopped.")
[0252] Example 3
[0253] Through the technical solution of this application, when used:
[0254] (1) By configuring the PC end, the PC end is embedded with the management software of the corresponding high-voltage electric data acquisition device, and the management software is connected to the corresponding high-voltage electric data acquisition device to perform data communication;
[0255] (2) After the corresponding high-voltage electricity data acquisition device detects the corresponding data, the PC collects the data and aggregates the data of all high-voltage electricity data acquisition devices of the high-voltage power station corresponding to the PC according to a preset timestamp to form a data packet under the timestamp, and encrypts the data packet through the data encryption unit;
[0256] (3) Randomly extract the link information of the storage module based on the random matching unit 1, establish a network connection with the corresponding storage server through the extracted link information, and upload the encrypted data packet;
[0257] (4) After receiving the data packet, the storage server decrypts the data encrypted by the data encryption unit through the data decryption unit 1;
[0258] (5) The decrypted data packet is then re-encrypted by the data encryption storage unit and stored in the storage database, while the storage database generates an index corresponding to the data packet;
[0259] (6) After the data encryption storage unit stores the encrypted data in the storage database, it triggers the data update synchronization unit to run, and communicates with the storage servers of all other storage modules through the data update synchronization unit, and synchronizes the stored data in the storage database of this storage server to other storage servers, so as to keep the storage database data of all storage servers consistent;
[0260] (7) When data query is required, the query terminal is connected to the matching storage device with the digital certificate installed to load the corresponding digital certificate;
[0261] (8) Then, the random matching unit 2 randomly extracts the link information of the storage module, and establishes a network connection with the corresponding storage server through the extracted link information. During the connection process, the storage server receives the digital certificate in the query terminal, and parses the digital certificate of the linked query terminal through the digital certificate parsing unit, and matches the parsed information with the digital certificate library through the digital certificate verification unit. After the matching verification is correct, the storage database in the storage server communicates with the corresponding query terminal;
[0262] (9) Then, the required data is searched through the index directory in the storage database and the data is extracted to the query terminal;
[0263] (10) The query terminal decrypts the extracted data through the data decryption unit 2 to obtain the final actual collected data.
[0264] In addition, in order to achieve distributed processing of storage servers, all storage servers are not placed in the same center, ensuring the security of the storage servers.
[0265] The above embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
[0266] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A data acquisition, storage and query system for power equipment production, characterized by: It includes an acquisition module, a storage module, and a query module. The acquisition module is set according to the actual number of high-voltage power stations. The storage module is used to store the data sent by the acquisition module. There are at least three storage modules, and all storage modules back up each other's data. The query module is used to extract data from the storage module for data processing or data query. The acquisition module includes a data acquisition module, an acquisition parameter configuration module and a PC terminal. The data acquisition module and the acquisition parameter configuration module are arranged in the PC terminal, and the PC terminal communicates with the power equipment data acquisition terminal. The data acquisition module includes an acquisition parameter information query interface unit, an acquisition unified interface unit, an acquisition software management unit, an acquisition software type management unit and a data acquisition software monitoring unit; The acquisition parameter configuration module includes a device ID information configuration unit, a database information configuration unit and an acquisition software type information configuration unit; The acquisition parameter information query interface unit and the acquisition unified interface unit communicate with the power equipment data acquisition terminal. The acquisition parameter information query interface unit receives the equipment information and communicates with the acquisition parameter configuration module to match the data. After receiving the matched data information, the acquisition unified interface unit sends the data information to the acquisition software type management unit. The acquisition software type management unit calls the matching acquisition software in the acquisition software management unit based on the received data information. The acquisition unified interface unit returns to the PC end through the called acquisition software for data acquisition and stores the collected data in the local PC end database. The PC terminal also includes a random matching unit 1 and a data encryption unit. The random matching unit 1 is provided with the link information of all storage modules. The random matching unit 1 randomly extracts a storage module link information, and the PC terminal communicates with the storage module. The data collected by the PC terminal is encrypted by the data encryption unit and then transmitted to the linked storage module. The storage module includes an independently set storage server, a data decryption unit 1 set in the storage server, a data encryption storage unit, a data update synchronization unit, a digital certificate unit 1 and a storage database. The encryption algorithm of the data encryption storage unit is different from the encryption algorithm of the data encryption unit. The data decryption unit 1 is used to decrypt the data encrypted by the data encryption unit. The data encryption storage unit is used to encrypt the data decrypted by the data decryption unit 1 and store it in the storage database. The data update synchronization unit is used to monitor the data in the storage database. When the data encryption storage unit stores the encrypted data in the storage database, the data update synchronization unit is triggered to run. The data update synchronization unit is used to communicate with the storage servers of all other remaining storage modules, and the data stored in the storage database of this storage server is synchronized to other storage servers to keep the storage database data of all storage servers consistent. The digital certificate unit 1 stores certificate information related to all query modules, which is used to verify the communication legalization link of the query module; The query module includes a query terminal, a digital certificate unit 2 set in the query terminal, a data decryption unit 2, and a random matching unit 2. The random matching unit 2 is provided with link information of all storage modules. The random matching unit 2 randomly extracts a storage module link information, and the query terminal communicates with the storage module. The digital certificate unit 2 stores the digital certificate of the query terminal. The digital certificate unit 1 is used to verify the digital certificate unit 2 and, after verification, to link the network communication between the query terminal and the storage server. After the query terminal extracts the corresponding data from the storage database, the data decryption unit 2 is used to decrypt the encrypted data. The operation mode of the random matching unit 1 is: (1) Sort and number the link information of all storage modules and form the original array; (2) Using the shuffling algorithm, the original array is shuffled and randomly sorted to form a random array; (3) Extract the numbers at the corresponding positions in the random array according to the preset extraction sorting number; (4) Based on the extracted number corresponding to the corresponding link information, the PC end is realized through the link information and the storage module corresponding to the link information; (5) According to step (4), when the PC terminal is not communicating with the storage module for the first time, the random matching unit removes the number corresponding to the last link information from the original array, and then shuffles the array randomly by using a shuffling algorithm to form a corresponding random array; (6) Then, after extracting the corresponding link information through steps (3) and (4), communication between the PC and the storage module is realized; The random matching unit 2 and the data matching unit 1 are processed in the same manner, and the extraction order of the random matching unit 2 is inconsistent with the extraction order of the random matching unit 1.
2. A data acquisition, storage and query system for power equipment production according to claim 1, characterized in that: The acquisition modules are numbered according to the corresponding high-voltage power stations, and each number is matched with the high-voltage electricity data acquisition equipment information corresponding to the high-voltage power station. Each time the data is transmitted to the storage module from the PC, it includes the high-voltage power station number, transmission time, corresponding high-voltage electricity data acquisition equipment information, and data collected by the acquisition equipment. The storage module receives the above information to establish a database index and performs index matching on the above information. The query module queries the relevant data information required on the storage module according to the index.
3. The data acquisition, storage and query system for power equipment production according to claim 1, characterized in that: The digital certificate unit 1 includes a digital certificate parsing unit, a digital certificate verification unit and a digital certificate library. The digital certificate library contains digital certificate information related to all query modules. The digital certificate parsing unit is used to parse the digital certificate carried by the linked query terminal. The digital certificate verification unit is used to match the parsed information with the digital certificate library. After the match is verified to be correct, the storage database in the storage module communicates with the corresponding query terminal.
4. The data acquisition, storage and query system for power equipment production according to claim 1, characterized in that: The acquisition parameter information query interface unit is specifically implemented as follows: Connect to the database: First, use the create_engine function in the SQLAlchemy library to establish a connection to the SQLite database; Get table information: Then, use the MetaData object to obtain metadata information in the database, including the table structure; Query parameters: Next, construct a query statement using the select method of the Table object, specifying that the query is for the parameters table and filtering out rows where the device_id column is equal to the given parameter device_id; Execute query: Use the execute method of the connection object to execute the query statement and get the query results; Process query results: traverse the query results and add the parameter name and parameter value of each row to a dictionary; Close the connection: Finally, close the database connection and release resources; Return parameter dictionary: Returns a dictionary containing the queried parameters.
5. The data acquisition, storage and query system for power equipment production according to claim 1, characterized in that: The specific implementation of the unified acquisition interface unit is as follows: (1) Accept a parameter dictionary parameters, which contains parameter names and corresponding values; Traverse the parameter dictionary, call the call_external_api function for each parameter, and store the returned data in the collected_data dictionary; Returns the collected data dictionary collected_data; (2) Accept parameter name and value; Match the dictionary consisting of parameter names and values to call the corresponding external API and return the corresponding data; (3) Accept a data dictionary data, which contains data collected from the external API; Call the call_third_party_api function, passing the collected data as parameters, and store the returned integration results in the integration_result dictionary; Returns the integration result dictionary integration_result; (4) Accept a data dictionary data, which contains the collected data; Returns a dictionary containing the success status, calls the corresponding third-party API, and returns the corresponding integration result.
6. The data acquisition, storage and query system for power equipment production according to claim 1, characterized in that: The acquisition software management unit is specifically implemented as follows: Import modules: Use from flask import Flask, request, jsonify to import the Flask framework and related modules; Create a Flask application: Use app = Flask(__name__); Define routes and view functions: Use the @app.route() decorator to define multiple routes and specify the corresponding HTTP request methods; Install software: In the install_software() view function, extract the software name from the JSON data of the POST request and add it to the installed_software dictionary to indicate that the software has been installed; Configure software: In the configure_software() view function, extract the software name from the JSON data of the POST request and return a successful configuration message; Start the software: In the start_software() view function, extract the software name from the JSON data of the POST request and return a successful startup message; Stop the software: In the stop_software() view function, extract the software name from the JSON data of the POST request and return a message indicating a successful stop. Update software: In the update_software() view function, extract the software name from the JSON data of the POST request and return a successful update message; Start the application: Use app.run(debug=True) to start the Flask application and enable debugging mode.
7. The data acquisition, storage and query system for power equipment production according to claim 1, characterized in that: The specific implementation of the acquisition software type management unit is as follows: Import modules: Use from flask import Flask, request, jsonify to import the Flask framework and related modules; Create a Flask application: Use app = Flask(__name__); Define routes and view functions: Use the @app.route() decorator to define a route / match_software_type and specify the corresponding HTTP request method as POST; Matching software type: In the match_software_type() view function, extract the data type data_type from the JSON data of the POST request. If data_type is in the software_types dictionary, get the corresponding software type and return it. If data_type is not in the software_types dictionary, a message is returned indicating that no matching software type was found, and a status code of 404 is returned; Start the application: Use app.run(debug=True) to start the Flask application and enable debugging mode.
8. The data acquisition, storage and query system for power equipment production according to claim 1, characterized in that: The data acquisition software monitoring unit is specifically implemented as follows: Import modules: Import the logging module for logging, import the time module for time operations, and import the BackgroundScheduler class and related functional modules for background task scheduling; Configure logging: Use logging.basicConfig() to configure the logger, set the log level to INFO, and specify the log format; Define monitoring data collection function: define monitor_data_collection() function for monitoring data collection, which records monitoring information; Define exception handling function: define handle_exception(e) function to handle exceptions during task execution, and record exception information; Create a background task scheduler: Create a BackgroundScheduler instance scheduler for background task scheduling; Add a scheduled task: Use the scheduler.add_job() method to add a scheduled task to the scheduler to execute the monitor_data_collection() function every 60 seconds; Add an exception listener: Use the scheduler.add_listener() method to add an exception listener to the scheduler to monitor exceptions during task execution. When an exception occurs in a task, the handle_exception() function is called to handle it. Start the scheduler: Use scheduler.start() to start the background task scheduler and start executing scheduled tasks; Main loop and keyboard interrupt processing: Use while True to enter the main loop and keep the program running. Use time.sleep(2) to make the program execute the loop body every 2 seconds to avoid excessive consumption of CPU resources. Use the try-except block to catch keyboard interrupt exceptions. When a keyboard interrupt signal is received, call scheduler.shutdown() to stop the scheduler and log information indicating that the scheduler has stopped.
9. The data acquisition, storage and query system for power equipment production according to claim 1, characterized in that: The encryption algorithm of the data encryption storage unit is the asymmetric encryption algorithm RSA, and the encryption algorithm of the data encryption unit is the Keccak hash algorithm.
10. The data acquisition, storage and query system for electric power equipment production according to claim 3, characterized in that: The digital certificate corresponding to the digital certificate unit 2 is generated by the management personnel through the encrypted digital certificate generator, and when the digital certificate is generated, the corresponding query terminal matching information is added, and then it is locked through an independent memory. At the same time, when the digital certificate is generated, the corresponding digital certificate verification information is generated and transmitted to the corresponding digital certificate library in all storage modules through an encrypted network for storage. When in use, the independent memory is inserted into the query terminal that matches it, and the digital certificate unit 2 on the query terminal extracts the digital certificate in the independent memory and pairs it with the query terminal. If the pairing is successful, the digital certificate is loaded. If the pairing is unsuccessful, the independent memory is disconnected from the query terminal.
Citation Information
Patent Citations
Power big data transmission method and system based on rapid matching and integrity detection
CN106506453A
Data management method and device of transformer substation and electronic equipment
CN118051934A