Mode Switching Method, Device, Power Equipment and Medium
By setting priority and signal protection mechanisms, the problem of unreasonable mode switching in the multi-service meter reading state of power equipment is solved, the rationality and friendliness of mode switching are realized, and data acquisition efficiency and integrity are improved.
Patent Information
- Application Number
- CN202211348667.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-31
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2042-10-31
AI Technical Summary
In the prior art, the mode switching mechanism of power equipment in the multi-service meter reading state is simple and crude, resulting in unreasonable mode switching, affecting the collection efficiency and data integrity.
By setting the priority and signal protection mechanism of each acquisition mode, the corresponding meter service processing order of each mode is determined based on whether the target signal is acquired, ensuring the rationality and friendliness of the mode switching.
It improves the rationality and friendliness of mode switching, avoids resource waste caused by task interruption during mode switching, and improves the overall efficiency and integrity of data acquisition.
Smart Images

Figure CN115685832B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of control technologies, and more particularly, to a mode switching method, apparatus, power device, and medium. Background Art
[0002] In the multi-service meter reading state, mode switching is often required. In the prior art, the mode switching method in the corresponding situation has not been deeply studied, resulting in a simple and crude switching mechanism and the need to improve its rationality. Summary of the Invention
[0003] One of the purposes of the present invention is to provide, for example, a mode switching method, apparatus, power device, and medium to at least partially improve the rationality of mode switching in the meter reading state.
[0004] Embodiments of the present invention can be implemented as follows:
[0005] In a first aspect, the present invention provides a mode switching method applied to a power device. The power device includes a carrier port, and each acquisition mode priority is pre-stored in the power device. The method includes:
[0006] In the carrier port working mode, in response to a meter reading instruction, load the meter reading task to be executed;
[0007] Determine all target acquisition modes corresponding to the meter reading task, and sequentially load the meter reading services corresponding to each target acquisition mode to the carrier port according to the priorities of each target acquisition mode;
[0008] Based on the carrier port, insert the obtained meter reading service into the pending queue according to the priority to obtain an updated pending queue. After receiving a target signal indicating that the meter reading service in the updated pending queue is allowed to be processed, sequentially execute the meter reading services corresponding to each acquisition mode according to the updated pending queue.
[0009] In an alternative embodiment, the acquisition modes include a concurrent mode, a single-shot mode, a broadcast mode, and a transparent transmission mode;
[0010] The priorities of each acquisition mode are as follows: the priorities of the broadcast mode and the transparent transmission mode are the same, the priorities of the concurrent mode and the single-shot mode are the same, and the priorities of the broadcast mode and the transparent transmission mode are higher than those of the concurrent mode and the single-shot mode.
[0011] In an alternative embodiment, the method further includes a step of obtaining the target signal, and this step includes:
[0012] Based on the carrier port, send the data packet corresponding to the meter reading service being executed to the corresponding device to be acquired;
[0013] If a response message returned by the to-be-collected device is received and the condition for executing at least one meter service in the updated to-be-processed queue is satisfied, a target signal indicating permission to process at least one meter service in the updated to-be-processed queue is generated.
[0014] In an alternative embodiment, the generating the target signal indicating permission to process at least one meter service in the updated to-be-processed queue includes:
[0015] Classify the meter services based on the concurrent mode, single-shot mode, broadcast mode, and pass-through mode. The meter services corresponding to the concurrent mode are regarded as concurrent services, and the meter services corresponding to the single-shot mode, broadcast mode, and pass-through mode are regarded as non-concurrent services.
[0016] In the case of entering the data sending and receiving mode, for the concurrent services to be sent, if there are non-concurrent services in the concurrent pool, wait for the target signal mcond of the concurrent services. After the non-concurrent services in the concurrent pool are sent, generate the target signal mcond to permit the sending of the concurrent services. Before obtaining the target signal mcond, keep the concurrent services in a blocked state. For the non-concurrent services to be sent, if there are concurrent services in the concurrent pool, wait for the target signal scond of the non-concurrent services. After the concurrent services being executed in the concurrent pool are completed, generate the target signal scond to permit the sending of the non-concurrent services. Before obtaining the target signal scond, keep the non-concurrent services in a blocked state.
[0017] In the case of exiting the sending and receiving mode, for the concurrent services to be sent, if there are no concurrent services in the concurrent pool, generate the target signal scond of the non-concurrent services. For the non-concurrent services to be sent, if there are non-concurrent services in the concurrent pool, generate the target signal scond of the non-concurrent services. For the non-concurrent services to be sent, if there are no non-concurrent services in the concurrent pool, generate the target signal mcond of the concurrent services.
[0018] In an alternative embodiment, the generating the target signal indicating permission to process at least one meter service in the updated to-be-processed queue includes:
[0019] In the data sending stage, if the meter service at the front of the updated queue to be processed corresponds to the concurrent mode, determine whether there are sending tasks for the meter services corresponding to the broadcast mode and the transparent transmission mode. If so, after waiting for the sending tasks to be completed, generate a first target signal, where the first target signal indicates permission to execute the meter service corresponding to the concurrent mode in the updated queue to be processed;
[0020] If the meter service at the front of the updated queue to be processed corresponds to the single - send mode, determine whether there are sending tasks for the meter services corresponding to the broadcast mode and the transparent transmission mode. If so, after waiting for the sending tasks to be completed, generate a second target signal, where the second target signal indicates permission to execute the meter service corresponding to the single - send mode in the updated queue to be processed;
[0021] If the meter service at the front of the updated queue to be processed corresponds to the broadcast mode or the transparent transmission mode, directly generate a third target signal, where the third target signal indicates permission to execute the meter service corresponding to the broadcast mode or the transparent transmission mode in the updated queue to be processed.
[0022] In an alternative embodiment, generating a target signal indicating permission to process at least one meter service in the updated queue to be processed includes:
[0023] In the data receiving stage, if the received response message corresponds to the concurrent mode, decrement the concurrent count by 1. When the meter service at the front of the updated queue to be processed corresponds to the broadcast mode or the transparent transmission mode, directly generate a third target signal, where the third target signal indicates permission to execute the meter service corresponding to the broadcast mode or the transparent transmission mode in the updated queue to be processed; when the meter service at the front of the updated queue to be processed corresponds to the concurrent mode and the concurrent count is non - zero, maintain the first target signal; when the meter service at the front of the updated queue to be processed corresponds to the single - send mode, generate a second target signal, where the second target signal indicates permission to execute the meter service corresponding to the single - send mode in the updated queue to be processed;
[0024] If the received response message corresponds to the single - send mode, when the meter service at the front of the updated queue to be processed corresponds to the broadcast mode or the transparent transmission mode, generate a third target signal, where the third target signal indicates permission to execute the meter service corresponding to the broadcast mode or the transparent transmission mode in the updated queue to be processed; when the meter service at the front of the updated queue to be processed corresponds to the concurrent mode, directly generate the first target signal; when the meter service at the front of the updated queue to be processed corresponds to the single - send mode, maintain the second target signal.
[0025] In an alternative embodiment, the method further includes:
[0026] Performing a legality and integrity check on each of the response messages;
[0027] If the legality and integrity checks pass, storing the data based on the response message;
[0028] If the legality or integrity check fails, resending the data message to the corresponding device to be collected until the legality and integrity checks of the newly obtained response message pass; and
[0029] For the meter services in the updated queue to be processed that have not received the corresponding target signal, maintaining a blocked state until the corresponding target signal is obtained.
[0030] In an alternative embodiment, the step of inserting the obtained meter services into the queue to be processed according to the priority to obtain the updated queue to be processed includes:
[0031] Determining the obtained meter services and the priorities corresponding to each meter service in the queue to be processed;
[0032] If there is a first meter service among the obtained meter services, and the priority corresponding to the first meter service is higher than the priorities corresponding to at least one existing meter service in the queue to be processed, inserting the first meter service into the queue to be processed so that the first meter service is located before each of the existing meter services;
[0033] If there is a second meter service among the obtained meter services, and the priority corresponding to the second meter service is lower than the priorities corresponding to at least one existing meter service in the queue to be processed, inserting the second meter service into the queue to be processed so that the second meter service is located after each of the existing meter services.
[0034] In a second aspect, an embodiment of the present invention provides a mode switching device, which is applied to a power device. The power device includes a carrier port, and the priorities of each acquisition mode are pre-stored in the power device. The mode switching device includes:
[0035] A data loading module, configured to, in the working mode of the carrier port, in response to a meter reading instruction, load the meter reading tasks to be executed; determine all corresponding target acquisition modes according to the meter reading tasks, and sequentially load the meter services corresponding to each target acquisition mode to the carrier port according to the priorities of each target acquisition mode;
[0036] A data processing module, configured to insert the obtained meter services into a to-be-processed queue based on the carrier port according to priorities to obtain an updated to-be-processed queue, and after receiving a target signal indicating that the meter services in the updated to-be-processed queue are allowed to be processed, sequentially execute the meter services corresponding to the respective acquisition modes according to the updated to-be-processed queue.
[0037] In a third aspect, an embodiment of the present invention provides a power device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the program, the mode switching method according to any one of the foregoing embodiments is implemented.
[0038] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where the computer-readable storage medium includes a computer program, and when the computer program runs, it controls a power device where the computer-readable storage medium is located to execute the mode switching method according to any one of the foregoing embodiments.
[0039] The beneficial effects of the embodiments of the present invention include, for example: updating the to-be-processed queue according to the priorities of the meter services, and after receiving a target signal indicating that the meter services in the to-be-processed queue are allowed to be processed, then executing the corresponding meter services, thereby ensuring the rationality of the processing of each meter service. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present invention, and thus should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0041] Figure 1 FIG. shows a schematic diagram of an application scenario provided by an embodiment of the present invention.
[0042] Figure 2 FIG. shows a schematic flowchart of a mode switching method provided by an embodiment of the present invention.
[0043] Figure 3 FIG. shows another schematic flowchart of a mode switching method provided by an embodiment of the present invention.
[0044] Figure 4 FIG. shows another schematic flowchart of a mode switching method provided by an embodiment of the present invention.
[0045] Figure 5 FIG. shows an exemplary structural block diagram of a mode switching device provided by an embodiment of the present invention.
[0046] Icons: 100 - Power equipment; 110 - Memory; 120 - Processor; 130 - Communication module; 140 - Mode switching device; 141 - Data loading module; 142 - Data processing module. Detailed implementation
[0047] Currently, in the multi-service meter reading state of power equipment, the mode switching mechanism is often relatively simple and crude, and its rationality needs to be improved. For example, when switching from Mode 1 to Mode 2, the tasks related to Mode 1 are often directly interrupted and the tasks related to Mode 2 are executed instead. Using this switching method, the tasks corresponding to Mode 1 may be switched to Mode 2 directly before they are completed, resulting in the waste of the already interacted content in Mode 1. For example, the message corresponding to Mode 1 has been sent, but the response message has not been received and it is directly switched to Mode 2, which will cause the subsequent response message corresponding to Mode 1 to be discarded as an invalid message, invisibly wasting the service collection efficiency and data integrity, thus affecting the overall efficiency of the data collected by the power equipment. Another example is that there is a lack of reliable research and design on the timing and conditions of each mode switching, resulting in the need to improve the rationality of mode switching.
[0048] Based on the above research, the embodiments of the present invention provide a mode switching scheme. By setting priorities and a signal-based protection mechanism, it is possible to determine whether to execute each service corresponding to each mode according to whether the target signal is obtained. It is simple, efficient, and user-friendly, and improves the rationality of mode switching.
[0049] Regarding the defects existing in the above solutions, they are all the results obtained by the inventor after practice and careful research. Therefore, the process of discovering the above problems and the solutions proposed by the embodiments of the present invention below for the above problems should all be the contributions made by the inventor during the invention process.
[0050] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Usually, the components of the embodiments of the present invention described and illustrated herein can be arranged and designed in various different configurations.
[0051] Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the present invention claimed, but merely represents the selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts fall within the scope of protection of the present invention.
[0052] It should be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or apparatus comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or apparatus. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising said element.
[0053] It should be noted that like reference numerals and letters denote like items in the following figures, and thus, once an item is defined in one figure, it is not necessary to further define and explain it in subsequent figures.
[0054] It should be noted that, without conflict, the features in the embodiments of the present invention may be combined with each other.
[0055] Please refer to Figure 1 , which is a block diagram of a power device 100 provided in this embodiment. The power device 100 in this embodiment may be a server, a processing device, a processing platform, etc. that can perform data interaction and execute a meter reading task. The power device 100 includes a memory 110, a processor 120, and a communication module 130. Each of the memory 110, the processor 120, and the communication module 130 is directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these elements may be electrically connected to each other through one or more communication buses or signal lines.
[0056] Among them, the memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc.
[0057] The processor 120 is used to read / write the data or programs stored in the memory 110 and perform corresponding functions.
[0058] The communication module 130 is used to establish a communication connection between the power device 100 and other communication terminals through the network, and is used to send and receive data through the network.
[0059] It should be understood that Figure 1 The structure shown is only a schematic diagram of the structure of the power device 100, and the power device 100 may further include more or fewer components than those shown in Figure 1 or have a different configuration from that shown in Figure 1 shown. Figure 1 Each component shown in can be implemented by hardware, software, or a combination thereof. For example, the power device 100 may further include a carrier port, a 485 port, etc.
[0060] Please refer to Figure 2 , which is a schematic flowchart of a mode switching method provided by an embodiment of the present invention, and can be executed by Figure 1 the power device 100, for example, can be executed by the processor 120 in the power device 100. The power device includes a carrier port, and the priorities of each acquisition mode are pre-stored in the power device. The mode switching method includes S110, S120, and S130.
[0061] S110, in the carrier port working mode, in response to a meter reading instruction, load the meter reading task to be executed.
[0062] S120, determine all target acquisition modes corresponding to the meter reading task, and load the meter reading services corresponding to each target acquisition mode to the carrier port in sequence according to the priorities of each target acquisition mode.
[0063] S130, based on the carrier port, insert the obtained meter reading services into the pending queue according to the priority to obtain an updated pending queue, and after receiving a target signal indicating permission to process the meter reading services in the updated pending queue, execute the meter reading services corresponding to each acquisition mode in sequence according to the updated pending queue.
[0064] In the embodiment of the present invention, by setting priorities and a signal-based protection mechanism, after receiving a target signal indicating permission to process the meter reading services in the pending queue, the corresponding meter reading services are executed, ensuring smooth switching between modes, improving the friendliness of mode switching, and the rationality of processing each meter reading service.
[0065] The acquisition modes supported by the carrier port can be various. For example, they can include the concurrent mode, the single-shot mode, the broadcast mode, the transparent transmission mode, etc. According to the requirements of each scenario, the priorities of each acquisition mode can be flexibly set. For example, in one implementation, the priorities of each acquisition mode can include: the priorities of the broadcast mode and the transparent transmission mode are the same, the priorities of the concurrent mode and the single-shot mode are the same, and the priorities of the broadcast mode and the transparent transmission mode are higher than those of the concurrent mode and the single-shot mode. For another example, in another implementation, the priorities of each acquisition mode can include: the priority of the broadcast mode is higher than that of the transparent transmission mode, the priority of the transparent transmission mode is higher than that of the concurrent mode, and the priority of the concurrent mode is higher than that of the single-shot mode. This embodiment does not list them one by one.
[0066] In S110, each acquisition mode is in the working mode of the carrier port of the power device, supporting the concurrent mode. When receiving a meter reading instruction, it starts to load the meter reading parameters of the power acquisition device to obtain the meter reading task to be executed, and then performs the carrier meter reading service based on the meter reading task.
[0067] Among them, the meter reading instruction can be obtained in various ways. For example, it can be sent in real time by the user. For another example, it can be automatically sent at set time intervals, conditions, etc. For another example, it can be generated according to the operations performed by the user. This embodiment does not limit this.
[0068] In S120, the meter reading task may correspond to multiple acquisition modes. Correspondingly, when performing the carrier meter reading service, business acquisitions of each acquisition mode will be carried out, and the meter reading services corresponding to each acquisition mode will be loaded onto the carrier port according to the priorities of each acquisition mode for subsequent processing.
[0069] The carrier port arranges each meter reading service according to the priorities of each acquisition mode, and the meter reading service with a higher priority is processed first. In this embodiment, the orderly processing of each meter reading service can be achieved by maintaining a queue to be processed. Correspondingly, in S130, inserting the obtained meter reading service into the queue to be processed according to the priority to obtain the updated queue to be processed can include: determining the obtained meter reading service and the priorities corresponding to each meter reading service in the queue to be processed. If there is a first meter reading service among the obtained meter reading services, and the priority corresponding to the first meter reading service is higher than the priorities corresponding to at least one existing meter reading service in the queue to be processed, insert the first meter reading service into the queue to be processed so that the first meter reading service is located before each of the existing meter reading services.
[0070] For example, if the priority of the first meter reading service is higher than the priorities of three existing meter reading services in the queue to be processed, then insert the first meter reading service into the queue to be processed before the three existing meter reading services, so that the first meter reading service is executed before the three existing meter reading services with lower priorities.
[0071] If there is a second meter service among the obtained meter services, and the priority corresponding to the second meter service is lower than the priority corresponding to at least one existing meter service in the to-be-processed queue, insert the second meter service into the to-be-processed queue so that the second meter service is located after each of the existing meter services.
[0072] For example, if the priority of the second meter service is lower than the priorities of two existing meter services in the to-be-processed queue, insert the second meter service into the to-be-processed queue after the two existing meter services, so that the second meter service is executed after the two existing meter services with higher priorities.
[0073] Among them, the obtained meter services can be one or more. For each obtained meter service, it is processed in the above manner to ensure that each obtained meter service is located in the updated to-be-processed queue before the meter services with lower priorities and after the meter services with higher priorities. Thus, in the updated to-be-processed queue, the meter services are arranged according to the priorities of the corresponding collection modes.
[0074] According to the application requirements of each scenario, in S130, the target signal can be obtained flexibly. For example, in order to avoid interruption of the task being executed due to mode switching, so that the already-interacted content generated for the task being executed is wasted, when the power device has sent the data packet corresponding to the meter service being executed to the corresponding device to be collected, it can be determined whether to generate a target signal according to whether a response packet returned by the device to be collected is received. When a response packet for the data packet has been received, it indicates that the task being executed has completed the interaction and the next task can be started. In this case, a target signal indicating that it is allowed to process the meter services in the updated to-be-processed queue can be generated, so that the meter services in the to-be-processed queue can be controlled to be executed in sequence within a reasonable time, the collection modes can be smoothly switched, and the already-interacted content will not be wasted, thereby improving the overall data collection efficiency and integrity.
[0075] Exemplarily, when the priorities of the broadcast mode and the transparent transmission mode are the same, and the priorities of the concurrent mode and the single-shot mode are the same, and the priorities of the broadcast mode and the transparent transmission mode are higher than those of the concurrent mode and the single-shot mode, if only the meter service corresponding to the concurrent mode and the meter service corresponding to the single-shot mode are being executed simultaneously at a certain moment in the power device, and during this process, the meter service corresponding to the broadcast mode or the transparent transmission mode is triggered, the carrier port will rearrange the newly added meter service corresponding to the high-priority mode (the meter service corresponding to the broadcast mode or the transparent transmission mode) to the front end of the processing queue. For example, the transmission message of the newly added meter service corresponding to the high-priority mode is arranged to the front end of the untransmitted queue pool. After processing the meter services corresponding to the concurrent mode and the single-shot mode that are already being executed, such as processing the messages already in the transmission pool, a target signal is generated, and based on the target signal, the transmission message of the newly added meter service corresponding to the high-priority mode is allowed to be executed, and the transmission message of the meter service corresponding to the high-priority mode is sent.
[0076] Among them, the power device can determine whether the messages already in the transmission pool have been processed by whether a corresponding response message is received. If so, it is determined that the messages already in the transmission pool have been processed; if not, it is determined that the messages already in the transmission pool have not been processed.
[0077] In this embodiment, the data interaction during the execution of each meter service generally involves framing messages according to the protocol for interaction between the power device and the device to be collected, and performing message sending and receiving processing, which will not be elaborated here.
[0078] To ensure the reliability of data interaction and ensure that the required collected data can be obtained based on the response message, the response message can also be verified. Please refer to Figure 3 , the process of verifying the response message can be implemented through S210, S220, and S230.
[0079] S210, perform legality and integrity verification for each of the response messages.
[0080] S220, if the legality and integrity verification pass, store the data based on the response message.
[0081] S230, if the legality or integrity verification fails, resend the data message to the corresponding device to be collected until the legality and integrity verification of the newly obtained response message pass.
[0082] By verifying the response message, the reliability of each data collection is ensured, and thus the overall collection efficiency is ensured.
[0083] To improve the convenience and reliability of model switching management, corresponding target signals can be set for each acquisition mode, and the execution permissions of the meter services corresponding to each acquisition mode can be determined by whether the target signals are obtained. Correspondingly, please refer to Figure 4 , this embodiment provides another implementation manner for obtaining the target signal, including S310 and S320.
[0084] S310, based on the carrier port, send the data packet corresponding to the meter service being executed to the corresponding device to be acquired.
[0085] S320, if a response packet returned by the device to be acquired is received and the condition for executing at least one meter service in the updated pending queue is satisfied, generate a target signal indicating that it is allowed to process at least one meter service in the updated pending queue.
[0086] Among them, the condition for executing at least one meter service in the updated pending queue can be set according to the priority.
[0087] For example, in the data sending stage, if the meter service at the front of the updated pending queue corresponds to the concurrent mode, determine whether there are sending tasks for the meter services corresponding to the broadcast mode and the transparent transmission mode. If so, after waiting for the sending tasks to be completed, generate a first target signal, and the first target signal indicates that it is allowed to execute the meter service corresponding to the concurrent mode in the updated pending queue. Thus, the switch from the broadcast mode or the transparent transmission mode to the concurrent mode is completed.
[0088] After obtaining the first target signal, the meter service corresponding to the concurrent mode in the updated pending queue can be executed. In the case where the first target signal is not obtained, the meter service corresponding to the concurrent mode in the updated pending queue remains blocked.
[0089] Another example is that in the data sending stage, if the meter service at the front of the updated pending queue corresponds to the single-shot mode, determine whether there are sending tasks for the meter services corresponding to the broadcast mode and the transparent transmission mode. If so, after waiting for the sending tasks to be completed, generate a second target signal, and the second target signal indicates that it is allowed to execute the meter service corresponding to the single-shot mode in the updated pending queue. Thus, the switch from the broadcast mode or the transparent transmission mode to the single-shot mode is completed.
[0090] After obtaining the second target signal, the meter service corresponding to the single-shot mode in the updated pending queue can be executed. In the case where the second target signal is not obtained, the meter service corresponding to the single-shot mode in the updated pending queue remains blocked.
[0091] For another example, in the data sending stage, if the meter service at the front of the updated queue to be processed corresponds to the broadcast mode or the transparent transmission mode, since the broadcast mode and the transparent transmission mode have the highest priority and a response message indicating that the previous data interaction has been completed has been received, a third target signal can be directly generated. The third target signal indicates that the meter service corresponding to the broadcast mode or the transparent transmission mode in the updated queue to be processed is allowed to be executed. Thus, the switching from other modes to the broadcast mode or the transparent transmission mode is completed.
[0092] In the case where the third target signal is not obtained, the meter services corresponding to the broadcast mode or the transparent transmission mode in the updated queue to be processed remain blocked.
[0093] For another example, in the data receiving stage, if the received response message corresponds to the concurrent mode, it indicates that the meter service corresponding to the previous concurrent mode has been completed, so the number of concurrent operations is decreased by 1. In the case where the meter service at the front of the updated queue to be processed corresponds to the broadcast mode or the transparent transmission mode, since the broadcast mode and the transparent transmission mode have the highest priority and a response message indicating that the previous data interaction has been completed has been received, a third target signal can be directly generated. The third target signal indicates that the meter service corresponding to the broadcast mode or the transparent transmission mode in the updated queue to be processed is allowed to be executed. After the third target signal is obtained, the meter service corresponding to the broadcast mode or the transparent transmission mode in the updated queue to be processed can be executed. Thus, the switching from the concurrent mode to the broadcast mode or the transparent transmission mode is completed.
[0094] In the case where the third target signal is not obtained, the meter services corresponding to the broadcast mode or the transparent transmission mode in the updated queue to be processed remain blocked.
[0095] In the case where the meter service at the front of the updated queue to be processed corresponds to the concurrent mode and the number of concurrent operations is non-zero, since the meter service corresponding to the concurrent mode is still to be executed subsequently, the first target signal is maintained.
[0096] In the case where the meter service at the front of the updated queue to be processed corresponds to the single-shot mode, a second target signal is generated. The second target signal indicates that the meter service corresponding to the single-shot mode in the updated queue to be processed is allowed to be executed. After the third target signal is obtained, the meter service corresponding to the single-shot mode in the updated queue to be processed can be executed. Thus, the switching from the concurrent mode to the single-shot mode is completed.
[0097] Similarly, if the received response message corresponds to the single - transmission mode, when the meter service at the front of the updated queue to be processed corresponds to the broadcast mode or the transparent - transmission mode, a third target signal is generated to complete the switch from the single - transmission mode to the broadcast mode or the transparent - transmission mode. When the meter service at the front of the updated queue to be processed corresponds to the concurrent mode, a first target signal is directly generated to complete the switch from the single - transmission mode to the concurrent mode. When the meter service at the front of the updated queue to be processed corresponds to the single - transmission mode, the second target signal is maintained.
[0098] The switching logic between the broadcast mode and the transparent - transmission mode and other modes is similar and will not be elaborated one by one here.
[0099] Exemplarily, to more conveniently implement signal preemption between modes and scheduling of each service, the acquisition modes can be classified. For example, the data request of the meter service corresponding to the concurrent mode is characterized as M. The single - transmission mode, the broadcast mode, and the transparent - transmission mode are all regarded as non - concurrent modes, and the data request of the meter service corresponding to the non - concurrent mode is characterized as S. The maximum number of requests that can be sent simultaneously in the concurrent mode is N. Then:
[0100] When entering the data sending and receiving mode, for the M to be sent, if there is S in the concurrent pool, wait for the target signal mcond of M (mcond <= N). After the S in the concurrent pool is sent, generate the target signal mcond to allow the sending of M. Before getting the target signal mcond, M remains blocked. For the S to be sent, if there is M in the concurrent pool, wait for the target signal scond of S. After the M being executed in the concurrent pool is completed, generate the target signal scond to allow the sending of S. Before getting the target signal scond, S remains blocked.
[0101] When exiting the sending and receiving mode, for the M to be sent, if there is no M in the concurrent pool, generate the target signal scond of S. For the S to be sent, if there is S in the concurrent pool, generate the target signal scond of S. For the S to be sent, if there is no S in the concurrent pool, generate the target signal mcond of M.
[0102] Among them, the concurrent pool is a service in the concurrent mode, which means that multiple messages can be sent out simultaneously for processing by the carrier port. When multiple messages are sent out, it is necessary to wait for multiple received messages to come back. Therefore, it is characterized by the concurrent pool. For example, if five messages are sent out concurrently, then five received messages are required to come back. If only one message has come back, then four more are still awaited. At this time, there are only 4 sent messages in the concurrent pool. If one more received message comes back, then there are three sent messages left in the sending pool until all five received messages have come back, indicating that the sending tasks being executed in the concurrent pool have been fully processed, and the target signal can be obtained according to the strategy to process the next task according to the priority.
[0103] In one implementation, concurrent multiplicity is a characteristic of the broadband module, supporting the concurrent function. The sent messages in the concurrent mode and other modes are all in the same queue pool, which is also called the concurrent pool, sending pool, and task pool in this embodiment. The carrier port layer manages the queue pool, arranges the priorities of the sent messages, and combines the target signal to manage the timing of sending the messages.
[0104] Based on the above settings, the service preemption signal can be used according to different modes to handle the scheduling relationship between services. Based on this setting and the priority setting, in the sending stage, when entering the send-receive function interface, if the meter service M corresponding to the concurrent mode comes in at this time, first judge whether there is a sending task S for the meter service corresponding to the non-concurrent mode. If S exists, then it is necessary to wait for the target signal mcond corresponding to the concurrent mode. Only when the target signal mcond is obtained is the meter service corresponding to the concurrent mode allowed to execute, otherwise it will be blocked and wait until the target signal mcond is obtained to allow the meter service corresponding to the concurrent mode to execute. The purpose is to give priority to the execution of the meter service corresponding to the non-concurrent mode (such as the meter service corresponding to the broadcast mode, transparent transmission mode, etc.). Conversely, if entering the meter service S corresponding to the non-concurrent mode, then it is necessary to wait for the target signal scond, and only when the target signal scond is obtained is the meter service corresponding to the non-concurrent mode allowed to send.
[0105] In the receiving stage, if the current receiving service is the meter service corresponding to the concurrent mode, then the concurrent number (N) is decremented by 1. If there is a sending service corresponding to the non-concurrent mode (such as the broadcast mode, transparent transmission mode) at this time, then the target signal scond corresponding to the non-concurrent mode is obtained. If there is no sending service corresponding to the non-concurrent mode and the concurrent number (N) is non-zero, then the real-time signal is still the target signal mcond corresponding to the concurrent mode. Conversely, if the current receiving service is the meter service corresponding to the non-concurrent mode and the number of sending services exists, then the target signal scond corresponding to the non-concurrent mode is obtained, otherwise it is set to the target signal mcond.
[0106] The above is only an enumeration of the processing strategies during one of the mode switching processes. It can be understood that according to different priority divisions and different application requirements, there can be other processing strategies. For example, corresponding target signals can be set for each acquisition mode respectively, or the same target signal can be set for two of the acquisition modes. Different target signals are generated based on the priority and the business status being executed in the sending pool to perform mode switching, and this embodiment will not elaborate on each of them one by one. Another example is that when performing meter reading services for the first time, since there are no tasks being executed in the sending pool, the first processing can be carried out without waiting for the target signal, that is, the first sending is idle.
[0107] By adopting the above solution in this embodiment, the current signal status of the sending pool can be known in real time. Before performing mode switching, query whether the corresponding target signal is in a waiting state. Only when the corresponding target signal is obtained is it allowed to execute. Through the signal blocking strategy, friendly waiting is carried out until the current task exits, and then tasks with higher priorities are processed, thereby avoiding forcibly interrupting the currently running sending and receiving services and avoiding the waste of the already interacted content. By controlling each mode switching through the target signal, the convenience and friendliness of mode switching management are improved, and the acquisition efficiency, real-time performance, and data integrity can be effectively improved.
[0108] After completing the meter reading task, such as realizing the message interaction for each acquisition mode, data storage processing can be performed on the received messages for subsequent applications.
[0109] In order to execute the corresponding steps in the above embodiments and all possible ways, an implementation manner of a mode switching device is given below. Please refer to Figure 5 , Figure 5 which is a functional module diagram of a mode switching device 140 provided by an embodiment of the present invention. The mode switching device 140 can be applied to the Figure 1 shown power device 100. The power device includes a carrier port, and the priorities of each acquisition mode are pre-stored in the power device. It should be noted that for the mode switching device 140 provided in this embodiment, its basic principle and the technical effects generated are the same as those in the above method embodiment. For the sake of brief description, for the parts not mentioned in this embodiment, reference can be made to the corresponding content in the above method embodiment. The mode switching device 140 includes a data loading module 141 and a data processing module 142.
[0110] Among them, the data loading module 141 is used to, in the working mode of the carrier port, in response to a meter reading instruction, load the meter reading tasks to be executed; determine all corresponding target acquisition modes according to the meter reading tasks, and sequentially load the meter reading services corresponding to each target acquisition mode to the carrier port according to the priorities of each target acquisition mode.
[0111] A data processing module 142, configured to insert the obtained meter services into a to-be-processed queue based on the carrier port according to priorities to obtain an updated to-be-processed queue, and after receiving a target signal indicating permission to process the meter services in the updated to-be-processed queue, sequentially execute the meter services corresponding to the respective acquisition modes according to the updated to-be-processed queue.
[0112] On the basis described above, an embodiment of the present invention further provides a computer-readable storage medium. The computer-readable storage medium includes a computer program, and when the computer program runs, it controls the power device where the computer-readable storage medium is located to execute the above-mentioned mode switching method.
[0113] By adopting the above solution in the embodiment of the present invention, the task acquisition data of each mode is processed by the carrier port layer service, rather than being managed by the traditional local meter reading service layer, which improves the management convenience. The blocking signal is more friendly. Instead of violently forcing the end of the currently executing task of sending and receiving packets in the task pool, it can completely process the services currently executed in the task pool. The concurrent service pool more friendly takes into account the broadcast mode and the transparent transmission mode, facilitating the priority execution of the services of these two high-priority modes, and improving the timeliness and reliability of the acquisition of high-priority services. The interruption, waiting, and running of the task pool service mode completely depend on the acquisition of signal permissions. If in a waiting signal state, the services in the current task pool are preferentially processed at this time, and only after the signal is obtained, is it allowed to run and process according to the priority level of the task pool. For smooth switching between each mode, the time window is not wasted, and the to-be-executed sending and receiving packets in the service pool can be replenished in a timely manner.
[0114] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code includes one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order from that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0115] In addition, in each embodiment of the present invention, each functional module may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0116] If the above-mentioned function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs.
[0117] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A mode switching method, characterized in that, Applied to power equipment, the power equipment includes a carrier port, and priorities of each acquisition mode are pre-stored in the power equipment. The method includes: In the working mode of the carrier port, in response to a meter reading instruction, load a meter reading task to be executed; Determine all corresponding target acquisition modes according to the meter reading task, and sequentially load the meter reading services corresponding to each target acquisition mode to the carrier port according to the priorities of each target acquisition mode; the acquisition modes include a concurrent mode, a single-shot mode, a broadcast mode, and a transparent transmission mode; the priorities of each acquisition mode are as follows: the priorities of the broadcast mode and the transparent transmission mode are the same, the priorities of the concurrent mode and the single-shot mode are the same, and the priorities of the broadcast mode and the transparent transmission mode are higher than those of the concurrent mode and the single-shot mode; Based on the carrier port, insert the obtained meter reading service into the pending queue according to the priority to obtain an updated pending queue. After receiving a target signal indicating permission to process the meter reading service in the updated pending queue, sequentially execute the meter reading services corresponding to each acquisition mode according to the updated pending queue; Wherein, the target signal is obtained based on the following steps: Based on the carrier port, send a data packet corresponding to the meter reading service being executed to the corresponding device to be acquired; if a response packet returned by the device to be acquired is received and the condition for executing at least one meter reading service in the updated pending queue is satisfied, then generate a target signal indicating permission to process at least one meter reading service in the updated pending queue.
2. The mode switching method according to claim 1, wherein The generating the target signal indicating permission to process at least one meter reading service in the updated pending queue includes: Classify the meter reading services based on the concurrent mode, single-shot mode, broadcast mode, and transparent transmission mode, and regard the meter reading services corresponding to the concurrent mode as concurrent services, and regard the meter reading services corresponding to the single-shot mode, broadcast mode, and transparent transmission mode as non-concurrent services; In the case of entering the data sending and receiving mode, for the pending concurrent services, if there are non-concurrent services in the concurrent pool, wait for the target signal mcond of the concurrent services. After the non-concurrent services in the concurrent pool are sent, then generate the target signal mcond to allow the sending of the concurrent services. Before obtaining the target signal mcond, keep the concurrent services in a blocked state; for the pending non-concurrent services, if there are concurrent services in the concurrent pool, wait for the target signal scond of the non-concurrent services. After the concurrent services being executed in the concurrent pool are completed, then generate the target signal scond to allow the sending of the non-concurrent services. Before obtaining the target signal scond, keep the non-concurrent services in a blocked state; In the case of exiting the sending and receiving mode, for the concurrent type of services to be sent, if there is no concurrent type of service in the concurrent pool, a target signal scond for the non-concurrent type of service is generated; for the non-concurrent type of services to be sent, if there is a non-concurrent type of service in the concurrent pool, a target signal scond for the non-concurrent type of service is generated; for the non-concurrent type of services to be sent, if there is no non-concurrent type of service in the concurrent pool, a target signal mcond for the concurrent type of service is generated.
3. The mode switching method according to claim 1, wherein The generating of a target signal indicating permission to process at least one meter service in the updated queue to be processed includes: In the data sending stage, if the meter service at the front of the updated queue to be processed corresponds to the concurrent mode, determine whether there are sending tasks for the meter services corresponding to the broadcast mode and the transparent transmission mode. If so, after waiting for the sending tasks to be completed, generate a first target signal, where the first target signal indicates permission to execute the meter service corresponding to the concurrent mode in the updated queue to be processed; If the meter service at the front of the updated queue to be processed corresponds to the single-send mode, determine whether there are sending tasks for the meter services corresponding to the broadcast mode and the transparent transmission mode. If so, after waiting for the sending tasks to be completed, generate a second target signal, where the second target signal indicates permission to execute the meter service corresponding to the single-send mode in the updated queue to be processed; If the meter service at the front of the updated queue to be processed corresponds to the broadcast mode or the transparent transmission mode, directly generate a third target signal, where the third target signal indicates permission to execute the meter service corresponding to the broadcast mode or the transparent transmission mode in the updated queue to be processed; In the data receiving stage, if the received response message corresponds to the concurrent mode, decrement the concurrent count by 1. In the case where the meter service at the front of the updated queue to be processed corresponds to the broadcast mode or the transparent transmission mode, directly generate a third target signal, where the third target signal indicates permission to execute the meter service corresponding to the broadcast mode or the transparent transmission mode in the updated queue to be processed; in the case where the meter service at the front of the updated queue to be processed corresponds to the concurrent mode and the concurrent count is non-zero, maintain the first target signal; in the case where the meter service at the front of the updated queue to be processed corresponds to the single-send mode, generate a second target signal, where the second target signal indicates permission to execute the meter service corresponding to the single-send mode in the updated queue to be processed; If the received response message corresponds to the single-send mode, in the case where the meter service at the front of the updated queue to be processed corresponds to the broadcast mode or the transparent transmission mode, generate a third target signal, where the third target signal indicates permission to execute the meter service corresponding to the broadcast mode or the transparent transmission mode in the updated queue to be processed; in the case where the meter service at the front of the updated queue to be processed corresponds to the concurrent mode, directly generate the first target signal; in the case where the meter service at the front of the updated queue to be processed corresponds to the single-send mode, maintain the second target signal.
4. The mode switching method according to claim 1, wherein The method further includes: Perform legality and integrity verification for each of the said response messages; If the legality and integrity verification passes, perform data storage based on the response message; If the legality or integrity verification fails, resend the data message to the corresponding device to be collected until the legality and integrity verification of the newly obtained response message passes; and For the meter services in the updated queue to be processed that have not received the corresponding target signal, remain in a blocked state until the corresponding target signal is obtained.
5. The mode switching method according to claim 1, wherein Said inserting the obtained meter services into the queue to be processed according to the priority to obtain the updated queue to be processed includes: Determine the obtained meter services and the priorities corresponding to each meter service in the queue to be processed; If there is a first meter service among the obtained meter services, and the priority corresponding to the first meter service is higher than the priorities corresponding to at least one existing meter service in the queue to be processed, insert the first meter service into the queue to be processed so that the first meter service is located before each of the existing meter services; If there is a second meter service among the obtained meter services, and the priority corresponding to the second meter service is lower than the priorities corresponding to at least one existing meter service in the queue to be processed, insert the second meter service into the queue to be processed so that the second meter service is located after each of the existing meter services.
6. A mode switching device, characterized in that, Applied to a power device, the power device includes a carrier port, and the priorities of each acquisition mode are pre-stored in the power device. The mode switching device includes: A data loading module, configured to, in the working mode of the carrier port, in response to a meter reading instruction, load the meter reading tasks to be executed; determine all corresponding target acquisition modes according to the meter reading tasks, and sequentially load the meter services corresponding to each target acquisition mode to the carrier port according to the priorities of each target acquisition mode; the acquisition modes include a concurrent mode, a single-shot mode, a broadcast mode, and a transparent transmission mode; the priorities of each acquisition mode include: the priorities of the broadcast mode and the transparent transmission mode are the same, the priorities of the concurrent mode and the single-shot mode are the same, and the priorities of the broadcast mode and the transparent transmission mode are higher than the priorities of the concurrent mode and the single-shot mode; A data processing module, configured to, based on the carrier port, insert the obtained meter services into the queue to be processed according to the priority to obtain the updated queue to be processed, and after receiving a target signal indicating that the meter services in the updated queue to be processed are allowed to be processed, sequentially execute the meter services corresponding to each acquisition mode according to the updated queue to be processed; Wherein, the target signal is obtained in the following manner: based on the carrier port, send the data message corresponding to the meter service being executed to the corresponding device to be collected; if a response message returned by the device to be collected is received and meets the condition of executing at least one meter service in the updated queue to be processed, generate a target signal indicating that at least one meter service in the updated queue to be processed is allowed to be processed.
7. A power device, characterized in that, Including: A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the program, the method for mode switching according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a computer program, and when the computer program runs, it controls the power device where the computer-readable storage medium is located to execute the method for mode switching according to any one of claims 1 to 5.
Citation Information
Patent Citations
Meter reading method and device and power acquisition terminal
CN110728838A
Business processing method and power terminal applying same
CN114296890A