Method, device and equipment for switching electric energy meter account charging mode and medium

CN122906787APending Publication Date: 2026-10-13SHENZHEN STAR INSTR
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611061755.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-16
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

[0003]本发明实施例提供一种电能表账户计费模式的切换方法、装置、设备及介质,以解决计费模式切换时因数据折算导致的精度损失、计费中断及安全性不足的问题

Benefits of technology

[0012]综上,本公开的电能表账户计费模式的切换方法、装置、设备及介质,该方法包括:响应于针对目标账户的计费模式切换信号,确定目标账户的计费数据锁定状态;基于计费数据锁定状态,获取目标账户的计费数据互斥锁;基于计费数据互斥锁,暂停对目标账户的计费,并生成目标账户的当前计费数据快照;基于计费模式切换信号,确定对应的预设计费模式模板;基于预设计费模式模板,更新目标账户的账户静态配置数据,并基于更新后的账户静态配置数据,确定目标计费策略;基于目标计费策略和当前计费数据快照,恢复对目标账户的计费,并释放计费数据互斥锁。本方法通过计费数据互斥锁,在切换过程中锁定计费数据,避免因并发操作导致数据不一致,通过计费数据快照和预设计费模式模板,确保切换前后计费数据的完整性和准确性,避免计费模式切换时的数据折算,从而提高计费模式切换的可靠性和效率,保障电能表账户计费系统的稳定运行。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122906787A_ABST
    Figure CN122906787A_ABST
Patent Text Reader

Abstract

The application discloses a kind of electric energy meter account billing mode switching method, device, equipment and medium, comprising: in response to the billing mode switching signal for target account, determine the billing data lock state of target account;Based on billing data lock state, obtain the billing data mutual exclusion lock of target account;Based on billing data mutual exclusion lock, suspend the billing of target account, and generate the current billing data snapshot of target account;Based on billing mode switching signal, determine the corresponding pre-design billing mode template;Based on pre-design billing mode template, update the account static configuration data of target account, and determine target billing strategy based on updated account static configuration data;Based on target billing strategy and current billing data snapshot, resume the billing of target account, and release billing data mutual exclusion lock.Through billing data mutual exclusion lock, avoid the data inconsistency caused by concurrent operation, through pre-design billing mode template, improve the accuracy of mode switching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of smart power supply technology, and in particular to a method, apparatus, device, and medium for switching the billing mode of an electricity meter account. Background Technology

[0002] With the development of smart grid technology, smart meters have widely supported various billing modes such as prepaid, postpaid, peak-valley time-of-use pricing, and tiered pricing. Online switching of billing modes is required based on operational needs, policy adjustments, or user applications. In related technologies, when switching billing modes, the current billing data is typically converted to equivalent data under the target billing mode, and then billing is restored based on the equivalent data. However, this conversion method is prone to introducing accuracy loss, especially when dealing with complex rate rules or data spanning long periods, where errors may accumulate and amplify, affecting billing accuracy. Therefore, there is an urgent need for a billing mode switching solution for electricity meter accounts that can avoid conversion errors and ensure billing continuity and data integrity. Summary of the Invention

[0003] This invention provides a method, apparatus, device, and medium for switching the billing mode of an electricity meter account, in order to solve the problems of accuracy loss, billing interruption, and insufficient security caused by data conversion during billing mode switching.

[0004] In a first aspect, the present invention provides a method for switching the billing mode of an electricity meter account, comprising: In response to a billing mode switching signal for the target account, determine the billing data lock status of the target account; Based on the billing data lock status, acquire the billing data mutex lock for the target account; Based on the billing data mutex lock, suspend billing for the target account and generate a snapshot of the target account's current billing data; Based on the billing mode switching signal, determine the corresponding pre-designed billing mode template; Based on the pre-designed billing model template, update the static account configuration data of the target account, and determine the target billing strategy based on the updated static account configuration data; Based on the target billing policy and the current billing data snapshot, resume billing for the target account and release the billing data mutex lock.

[0005] In some embodiments, prior to responding to a billing mode switching signal for the target account, at least one of the following is included: Obtain the switching trigger identifier of the target account, perform consistency verification between the switching trigger identifier and the pre-configured trigger reference data, and generate a billing mode switching signal after the consistency verification passes. The system periodically acquires the real-time clock and preset switching activation time of the target account. When the real-time clock is greater than or equal to the preset switching activation time, a billing mode switching signal is generated, and the preset switching activation time is cleared. Receive mode switching call requests, verify the operation permissions corresponding to the call requests, and generate a billing mode switching signal after the operation permissions are verified.

[0006] In some embodiments, determining the billing data lock status of the target account includes: Get the current status value of the preset lock execution flag; If the current status value is the first preset value, then it is determined that the billing data of the target account is locked. If the current status value is the second preset value, then it is determined that the billing data of the target account is in an unlocked state.

[0007] In some embodiments, acquiring a billing data mutex lock for a target account based on the billing data lock status includes: If the billing data is in an unlocked state, then obtain the operating status of the electricity meter corresponding to the target account; If the electricity meter is in normal billing status, then the billing data mutex lock is acquired. If the billing data mutex lock is successfully acquired within the preset time, the current status value will be updated from the second preset value to the first preset value. If the billing data mutex lock is not successfully acquired within the preset time, an acquisition failure alarm message will be generated, and the billing mode switching for the target account will be terminated.

[0008] In some embodiments, based on a pre-designed fee model template, the static account configuration data of the target account is updated, including: Back up the account's static configuration data to obtain the backup static configuration data; Retrieve the static configuration data of the pre-design fee model template; Based on preset configuration mapping rules, the mapping relationship between template static configuration data and account static configuration data is determined; Based on the mapping relationship, the static configuration data of the account is replaced with the static configuration data of the template to obtain candidate static configuration data; Based on the candidate static configuration data and the backup static configuration data, the updated account static configuration data is determined.

[0009] In some embodiments, determining updated account static configuration data based on candidate static configuration data and backup static configuration data includes: Perform consistency verification on the candidate static configuration data to obtain the data consistency verification result; If the data consistency verification result is successful, the candidate static configuration data will be determined as the updated account static configuration data. If the data consistency check fails, the system will roll back to the backup static configuration data and generate a configuration update anomaly alarm.

[0010] In some embodiments, restoring billing to a target account based on a target billing policy and a current billing data snapshot includes: Obtain incremental electricity consumption data for the target account during the period of suspended billing; Based on the current billing data snapshot and electricity consumption increment data, determine the baseline data for restoration; Based on the restored baseline data and the target billing strategy, restore billing to the target account.

[0011] Secondly, the present invention provides a device for switching the billing mode of an electricity meter account, comprising: The response module is used to respond to the billing mode switching signal for the target account and determine the billing data lock status of the target account; The acquisition module is used to acquire the billing data mutex lock for the target account based on the billing data lock status. The pause module is used to pause billing for a target account based on a billing data mutex lock and generate a snapshot of the target account's current billing data. The template determination module is used to determine the corresponding pre-designed billing mode template based on the billing mode switching signal; The update module is used to update the static account configuration data of the target account based on the pre-designed billing model template, and determine the target billing strategy based on the updated static account configuration data. The recovery module is used to restore billing to the target account based on the target billing policy and the current billing data snapshot, and release the billing data mutex lock.

[0012] In summary, the present disclosure discloses a method, apparatus, device, and medium for switching the billing mode of an electricity meter account. The method includes: in response to a billing mode switching signal for a target account, determining the billing data lock state of the target account; acquiring a billing data mutex lock for the target account based on the billing data lock state; suspending billing for the target account based on the billing data mutex lock and generating a snapshot of the current billing data of the target account; determining a corresponding pre-designed billing mode template based on the billing mode switching signal; updating the static configuration data of the target account based on the pre-designed billing mode template, and determining a target billing strategy based on the updated static configuration data; and resuming billing for the target account based on the target billing strategy and the current billing data snapshot, and releasing the billing data mutex lock. This method uses a billing data mutex lock to lock the billing data during the switching process, avoiding data inconsistency caused by concurrent operations. By using billing data snapshots and pre-designed billing mode templates, it ensures the integrity and accuracy of billing data before and after the switch, avoids data conversion during billing mode switching, thereby improving the reliability and efficiency of billing mode switching and ensuring the stable operation of the electricity meter account billing system. Attached Figure Description

[0013] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0014] Figure 1 This is a flowchart of a method for switching the billing mode of an electricity meter account in one embodiment of the present invention; Figure 2 This is another flowchart of a method for switching the billing mode of an electricity meter account in one embodiment of the present invention; Figure 3 This is another flowchart of a method for switching the billing mode of an electricity meter account in one embodiment of the present invention; Figure 4 This is another flowchart of a method for switching the billing mode of an electricity meter account in one embodiment of the present invention; Figure 5 This is another flowchart of a method for switching the billing mode of an electricity meter account in one embodiment of the present invention; Figure 6 This is another flowchart of a method for switching the billing mode of an electricity meter account in one embodiment of the present invention; Figure 7 This is a schematic block diagram of a switching device for electricity meter account billing mode in one embodiment of the present invention; Figure 8 This is a schematic block diagram of a computer device according to an embodiment of the present invention. Detailed Implementation

[0015] As an example, such as Figure 1 As shown, a method for switching the billing mode of an electricity meter account is provided, including: S101, in response to a billing mode switching signal for the target account, determines the billing data lock status of the target account; S102, Based on the billing data lock status, acquire the billing data mutex lock for the target account; S103, based on the billing data mutex lock, suspend billing for the target account and generate a snapshot of the current billing data of the target account; S104, Based on the billing mode switching signal, determine the corresponding pre-designed billing mode template; S105, based on the pre-designed billing model template, update the static account configuration data of the target account, and determine the target billing strategy based on the updated static account configuration data; S106, based on the target billing policy and the current billing data snapshot, resume billing for the target account and release the billing data mutex lock.

[0016] As an example, in step S101, a billing mode switching trigger signal for the target account can be received, and it can be determined whether the target account currently meets the switching execution conditions in order to determine the corresponding billing data lock status.

[0017] The target account is an independent logical unit within the smart meter that is responsible for real-time billing, deduction, and settlement. A single smart meter can have one or more target accounts set. The billing logic of each account is independent of each other, and switching a single account does not affect the normal operation of other accounts. The billing data lock status is used to indicate whether the current account can perform the switching operation. This embodiment does not limit the specific implementation form of the signal triggering method and status judgment.

[0018] In one embodiment, the billing mode switching signal can be triggered by any one or more of the following methods: special identifier triggering, timed automatic triggering, and operation and maintenance interface call triggering, or other switching triggering methods.

[0019] In one embodiment, the determination of the billing data lock status can be made by using a dedicated status flag, or by switching a counter, directly reading the lock holding status, etc.

[0020] As an example, in step S102, based on the obtained billing data lock status, a mutex lock on the billing data of the target account can be acquired when the switch can be performed, thereby enabling exclusive access to the billing data of the target account and preventing inconsistencies caused by concurrent data modification by other services during the switch process.

[0021] Among them, the billing data mutex lock is an account-level access control mechanism that only restricts the billing data access permissions of the target account and does not affect the normal operation of other functions of the electricity meter or other accounts.

[0022] In one embodiment, before acquiring the mutex lock, the overall operating status of the electricity meter can be checked first, and the lock can be acquired only when the electricity meter is in a normal metering state. Alternatively, the lock can be acquired directly without additional status checks.

[0023] In one embodiment, the acquisition of the mutex lock can be achieved through a timeout waiting mechanism, or through non-blocking direct return, high-priority service preemption, or other lock acquisition methods. After successful acquisition, the corresponding status flag can be updated; if acquisition fails, the process can be terminated or an alarm can be returned. Alternatively, the acquisition can be retried according to the configuration.

[0024] As an example, in step S103, after successfully acquiring the mutex lock, the billing operation logic of the target account can be paused, the billing status at the moment of switching is recorded and a snapshot of the current billing data is generated, providing a unified benchmark for subsequent billing recovery.

[0025] In this embodiment, suspending billing only stops the calculation logic related to the billing rules and does not affect the operation of other basic functions such as electricity metering and communication; the current billing data snapshot is backup data of the billing state at the moment of switching. This embodiment does not limit the implementation method of suspension, the storage content of the snapshot and the storage medium.

[0026] In one embodiment, the scope of suspending billing may be limited to stopping the software-side logic for accumulating electricity and deducting balance, while the hardware metering data acquisition can continue to run, and the acquired metering data can be temporarily stored for processing when the system is restored.

[0027] In one embodiment, the current billing data snapshot may include dynamic metering data such as cumulative electricity consumption and account balance, or it may include other operational status data such as billing status, alarm flags, and rate phases. The current billing data snapshot may be stored in temporary memory or backed up to non-volatile storage to avoid loss in case of power failure.

[0028] As an example, in step S104, the corresponding pre-designed billing mode template can be determined according to the target mode type pointed to by the billing mode switching signal, so as to provide a parameter source for subsequent configuration updates.

[0029] Among them, the pre-designed fee mode template is a set of configuration parameters for the corresponding billing mode, which can be stored independently of the active account in operation. This embodiment does not limit the storage form or matching determination method of the template.

[0030] In one embodiment, the billing mode template can be stored, for example, in a separate configuration storage area on the local side of the electricity meter, or it can be a set of configurations that are temporarily sent from a remote location and dynamically generated according to rules when a switch is triggered.

[0031] In one embodiment, the pre-designed billing mode template may include configurations for various billing modes such as prepaid, postpaid, peak-valley time-of-use pricing, and tiered pricing. The same template can be reused by multiple target accounts within the electricity meter, without the need to store complete configurations separately for each account.

[0032] In one embodiment, the pre-designed billing mode template is stored in an independent storage area within the electricity meter, separate from the DLMS / COSEM standard framework. This storage structure is a data structure that is autonomously maintained within the electricity meter and is not a passive account as defined by the DLMS / COSEM standard, nor does it possess complete account attributes: it only stores static configuration parameters related to the billing mode, does not store any dynamic operating data such as credit balance or cumulative electricity consumption, and does not participate in any billing calculation logic; the parameter values ​​in the template are pre-written and independently maintained by the operator through the communication interface before the switch occurs, and are completely decoupled from the current operating status of the target account.

[0033] As an example, in step S105, the static configuration data of the target account can be updated based on the determined billing mode template, and an adapted target billing policy can be generated according to the updated configuration to complete the switching of billing rules.

[0034] Among them, static configuration data are rule-based parameters that do not change with real-time billing, and dynamic operating data such as balance and cumulative electricity consumption are kept unmodified during the configuration update process.

[0035] In one embodiment, the original configuration data can be backed up before updating the static configuration. After the write is completed, data consistency verification can be performed. If the verification fails, the configuration can be rolled back to the backup configuration. Alternatively, configuration updates can be completed by direct overwrite, atomic transaction write, etc., without the need for additional backup verification.

[0036] In one embodiment, configuration writing can be performed by writing template parameters to the corresponding storage address through a predefined attribute mapping relationship, or by using block copy, field-by-field assignment, or other writing methods.

[0037] In one embodiment, the generation of the target billing policy can be based on whether the billing mode has changed, by selecting full reload or partial parameter refresh, or by uniformly adopting the full load method to generate a new policy.

[0038] As an example, in step S106, the billing operation of the target account can be restored based on the generated target billing policy and the previously generated snapshot of the current billing data. After confirming that the billing is running normally, the billing data mutex lock is released, so that the target account returns to the normal billing state and the mode switch is completed.

[0039] In one embodiment, when resuming billing, the current metering starting point can be obtained by using snapshot data as the metering benchmark and adding the metering increment temporarily stored during the suspension period, or metering can be continued directly from the state recorded in the snapshot.

[0040] In one embodiment, after billing is restored, the billing operation status can be checked. If a startup abnormality occurs, a default policy can be loaded to perform abnormal recovery, or the billing process can be restarted directly to avoid abnormal billing of the target account.

[0041] In one embodiment, the mutex lock can be released, for example, after billing starts normally, or it can be released early after configuration updates are completed and policies are generated.

[0042] In summary, the present disclosure discloses a method, apparatus, device, and medium for switching the billing mode of an electricity meter account. The method includes: in response to a billing mode switching signal for a target account, determining the billing data lock state of the target account; acquiring a billing data mutex lock for the target account based on the billing data lock state; suspending billing for the target account based on the billing data mutex lock and generating a snapshot of the current billing data of the target account; determining a corresponding pre-designed billing mode template based on the billing mode switching signal; updating the static configuration data of the target account based on the pre-designed billing mode template, and determining a target billing strategy based on the updated static configuration data; and resuming billing for the target account based on the target billing strategy and the current billing data snapshot, and releasing the billing data mutex lock. This method uses a billing data mutex lock to lock the billing data during the switching process, avoiding data inconsistency caused by concurrent operations. By using billing data snapshots and pre-designed billing mode templates, it ensures the integrity and accuracy of billing data before and after the switch, avoids data conversion during billing mode switching, thereby improving the reliability and efficiency of billing mode switching and ensuring the stable operation of the electricity meter account billing system.

[0043] As an example, such as Figure 2 As shown, in step S101, i.e., before responding to the billing mode switching signal for the target account, at least one of the following is included: S201, obtain the switching trigger identifier of the target account, perform consistency verification between the switching trigger identifier and the pre-configured trigger reference data, and generate a billing mode switching signal after the consistency verification passes; S202, periodically acquire the real-time clock and preset switching activation time of the target account. When the real-time clock is greater than or equal to the preset switching activation time, generate a billing mode switching signal and clear the preset switching activation time. S203: Receive mode switching call request, verify the operation permission corresponding to the call request, and generate a billing mode switching signal after the operation permission verification is passed.

[0044] As an example, in step S201, a switchover can be triggered by matching a special identifier. The switchover trigger identifier is trigger data written to the storage address corresponding to the target account, and the trigger reference data is a pre-stored matching baseline value on the electricity meter. Whether to trigger a switchover is determined by verifying the consistency of the two. This embodiment does not limit the method of writing the trigger identifier or the specific value of the reference data.

[0045] In one embodiment, the trigger reference data can be set to a 128-bit all-1 constant. The length design of this 128-bit all-1 constant is incompatible with the encoding length of the conventional timestamp attribute (usually 32 bits or 48 bits). Any normal time write operation cannot generate this value, thus forming a natural isolation from the conventional operation at the protocol parsing level and avoiding accidental triggering.

[0046] In one embodiment, consistency verification can be performed by comparing bits one by one, or by other data verification methods such as checksum comparison or hash value comparison.

[0047] As an example, in step S202, the preset time can be automatically triggered by timed polling, which can be used for the unified switching of batch energy meters during off-peak periods.

[0048] The real-time clock is a time source associated with the electricity meter or the target account. The preset switching activation time is a pre-configured planned switching time. It is automatically triggered and the configuration is cleared after the time is reached to avoid repeated triggering. This embodiment does not limit the specific values ​​of the time source type and the polling period.

[0049] In one embodiment, the polling period can be configured to be from 1 second to 10 seconds, and can also be flexibly adjusted according to the power consumption requirements of the electricity meter to balance the triggering real-time performance and operating power consumption.

[0050] In one embodiment, the preset switching activation time is cleared after triggering, and its configuration value can be written to 0 or an invalid value to avoid repeated triggering at the same time point.

[0051] As an example, in step S203, the switching can be triggered by an interface call, which can be used for manual operation scenarios such as on-site maintenance and user applications.

[0052] Among them, the mode switching call request is a switching instruction sent by the external system to the energy meter. The operation permission verification is used to verify the legality of the requester's operation. After the verification is passed, the switching is triggered. This embodiment does not limit the form of the calling interface or the permission verification method.

[0053] In one embodiment, permission verification may employ any one or more combinations of password verification, role-based permission verification, and device whitelist verification, allowing only authorized entities to initiate the switch.

[0054] In one embodiment, the call request may carry parameters such as target mode identifier and operator information, and after verification, it is transmitted to subsequent steps along with the switching signal.

[0055] It should be understood that S201~S203 are optional triggering steps, and any one of them can be enabled individually or multiple can be enabled simultaneously according to actual needs. This embodiment does not limit the combination of triggering methods or the order of detection and polling.

[0056] In one embodiment, when multiple triggering methods are enabled simultaneously, a trigger source priority arbitration mechanism can be configured. For example, step S201 has the highest priority, step S202 has the next highest priority, and step S203 has the lowest priority. When multiple triggering sources simultaneously meet the triggering conditions, only the switching signal generated by the triggering source with the highest priority is responded to, thus avoiding duplicate triggering from the source. Furthermore, after any triggering source generates a billing mode switching signal, any subsequent triggers are ignored, avoiding duplicate responses in the same round of switching process.

[0057] As an example, such as Figure 3 As shown, step S101, which determines the target account's billing data lock status, includes: S301, Obtain the current status value of the preset lock execution flag; S302, if the current status value is the first preset value, then it is determined that the billing data of the target account is in a locked state; S303, if the current status value is the second preset value, then it is determined that the billing data of the target account is in an unlocked state.

[0058] As an example, in step S301, a preset lock execution flag corresponding to the target account can be read as the basis for determining the lock status. The lock execution flag is a dedicated identifier used to mark the execution status of the switching process and can be bound and stored with the target account.

[0059] In one embodiment, the lock execution flag can be stored in the configuration storage header field of the target account. When the electricity meter is powered on, it is automatically initialized to an unlocked state value to avoid accidental triggering of repeated switching after power-on.

[0060] In one embodiment, the lock execution flag can be set to a single-byte flag or, depending on storage requirements, a multi-byte flag; this disclosure does not limit this.

[0061] As an example, in step S302, the value of the preset lock execution flag can be used to determine whether the current account is in a locked state. The locked state indicates that a switching process is currently in progress for the target account, billing data is occupied, and a new switching process cannot be initiated.

[0062] In one embodiment, the first preset value can be set to the value 1. When the flag bit is 1, it is determined that the billing data is in a locked state, and new switching trigger requests are directly ignored.

[0063] In one embodiment, after determining that the state is locked, a busy status code indicating that the target account is currently in a switching state can be returned to the triggering party, or the triggering request can be discarded without responding.

[0064] As an example, in step S303, the value of the preset lock execution flag can be used to determine whether the current account is in a switchable unlocked state. The unlocked state indicates that the target account currently has no switching process being executed, billing data is idle, and the subsequent mutex lock acquisition process can proceed.

[0065] In one embodiment, the second preset value can be set to the value 0. When the flag bit is 0, it is determined that the billing data is in an unlocked state, allowing the subsequent locking process to proceed.

[0066] In one embodiment, after determining that the state is unlocked, the type flag of the current trigger source can be recorded and passed to subsequent steps for auditing.

[0067] It should be understood that the locked state can also be directly determined by the holding state of the mutex lock without the need to set an additional dedicated flag bit, and this disclosure does not limit this.

[0068] As an example, such as Figure 4 As shown, step S102, which involves acquiring a billing data mutex lock for the target account based on the billing data lock status, includes: S401, If ​​the billing data is locked but not locked, then obtain the operating status of the electricity meter corresponding to the target account; S402, If the electricity meter is in normal billing status, then the billing data mutex lock is acquired. S403, If the billing data mutex lock is successfully acquired within the preset time, the current status value is updated from the second preset value to the first preset value; S404 If the billing data mutex lock is not successfully acquired within the preset time, an acquisition failure alarm message is generated, and the billing mode switching for the target account is terminated.

[0069] As an example, in step S401, when the billing data is in an unlocked state, the operating status of the electricity meter corresponding to the target account can be obtained first as a preliminary judgment basis for whether the locking operation can be performed. The electricity meter operating status is an identifier of the global operating status of the electricity meter, used to exclude abnormal scenarios where switching cannot be performed.

[0070] In one embodiment, the operating state of the electricity meter may include firmware upgrade state, power failure protection state, metering fault state, and normal billing state, and the subsequent locking process is only entered during the normal billing state.

[0071] In one embodiment, the operating status of the electricity meter can be obtained by reading the global status register of the electricity meter, or by polling the operating flags of each functional module to make a comprehensive judgment.

[0072] As an example, in step S402, when the electricity meter is in normal billing mode, the billing data mutex lock can be acquired to achieve exclusive access to the billing data of the target account. Here, normal billing mode refers to the operating state of the electricity meter, which can normally perform metering and billing functions. The billing data mutex lock is an account-level access control lock that only restricts the billing data access permissions of the target account, without affecting the normal operation of other functions of the electricity meter or other accounts.

[0073] In one embodiment, the billing data mutex lock can be implemented using a semaphore mechanism or an atomic variable marking mechanism. This disclosure does not limit the specific form of the mutex lock, as long as it can achieve the effect of exclusive access.

[0074] As an example, in step S403, if the billing data mutex lock is successfully acquired within a preset time, the current status value is updated from the second preset value to the first preset value, marking the target account as entering a locked state. Here, the current status value can be the value of the lock execution flag bit read in step S301, the second preset value is the identifier value corresponding to the unlocked state, and the first preset value is the identifier value corresponding to the locked state.

[0075] In one embodiment, the preset time can be set to 100ms to avoid blocking other high-priority services such as recharge and meter reading for a long time.

[0076] In one embodiment, when updating the current state value from the second preset value to the first preset value, an atomic write operation can be used to avoid the intermediate value being read by other services during the state update process, which could lead to incorrect state judgment.

[0077] In one embodiment, after the state value is updated, a locking timestamp can be recorded for subsequent timeout detection.

[0078] For example, a pre-check operation can be performed before acquiring the billing data mutex lock to confirm that the electricity meter is not currently undergoing firmware upgrade or in an emergency power outage state. The subsequent locking process will only proceed after the pre-check is passed. If the billing data mutex lock is not acquired within a preset time, a failure will be returned and an audit event will be recorded.

[0079] As an example, in step S404, if the billing data mutex lock is not successfully acquired within a preset time, an acquisition failure alarm message is generated, and the billing mode switch for the target account is terminated. The acquisition failure alarm message is an event message used to identify the failure to acquire the billing data mutex lock, and terminating the billing mode switch for the target account is an operation to end the current switch process and restore the target account to its initial triggerable state.

[0080] In one embodiment, the failure alarm information may carry information such as the target account identifier, failure reason, and timestamp, and be reported to the electricity meter event log for operation and maintenance troubleshooting.

[0081] In one embodiment, when the billing mode switch for the target account is terminated, the temporary variables of this switch can be cleared, the trigger flag can be reset, and the system can wait for the next trigger.

[0082] As an example, such as Figure 5 As shown, step S105, which is to update the static account configuration data of the target account based on the pre-designed fee model template, includes: S501 backs up the account's static configuration data to obtain the backup static configuration data; S502, retrieve the template static configuration data in the pre-design fee mode template; S503, based on preset configuration mapping rules, determines the mapping relationship between template static configuration data and account static configuration data; S504, based on the mapping relationship, replace the account static configuration data with template static configuration data to obtain candidate static configuration data; S505 determines the updated account static configuration data based on candidate static configuration data and backup static configuration data.

[0083] As an example, in step S501, the original static configuration data of the target account can be backed up before updating the configuration to obtain backup static configuration data, which serves as the basis for rollback in case of configuration update anomalies. The static configuration data consists of rule-based parameters in the target account that do not change with real-time billing, including but not limited to payment mode identifiers, rate tables, credit limits, alarm thresholds, etc. The backup static configuration data is a complete copy of the original configuration.

[0084] In one embodiment, the backup static configuration data can be stored in the temporary memory of the electricity meter, or it can be synchronously backed up to a non-volatile storage area to avoid the loss of the original configuration due to power failure during the update process.

[0085] In one embodiment, the backup operation only backs up the account's static configuration data, and does not back up dynamic operating data such as account balance, cumulative power consumption, and cumulative number of recharges, thereby reducing the amount of backup data and preventing the dynamic data from being modified in the process.

[0086] As an example, in step S502, the configuration parameters stored in the pre-designed billing mode template can be read to obtain the template static configuration data. The pre-designed billing mode template is a set of configurations stored independently of the active account, and the template static configuration data is the complete set of rule parameters under the target billing mode.

[0087] In one embodiment, a pre-designed billing mode template can be stored in a separate configuration container of the electricity meter, containing configuration parameters for various billing modes such as prepaid, postpaid, peak-valley time-of-use pricing, and tiered pricing.

[0088] In one embodiment, the same pre-designed fee pattern template can be reused by multiple target accounts within the electricity meter, eliminating the need to store the complete configuration separately for each account and saving storage space.

[0089] As an example, in step S503, the account configuration storage location corresponding to each parameter in the template static configuration data can be matched based on preset configuration mapping rules to determine the mapping relationship between the two. The preset configuration mapping rules are a pre-configured table of correspondence between parameter attributes and storage addresses, used to guide the template parameters to be written to the correct location in the target account.

[0090] In one embodiment, the mapping relationship can be flexibly configured according to the storage structure of the electricity meter to adapt to different models and storage layouts of electricity meters.

[0091] In one embodiment, the preset configuration mapping rules are driven by a built-in mapping table in the firmware. The switching function performs batch parameter copying operations by traversing the mapping table. When adding or modifying parameter items that need to be switched, only the mapping table needs to be updated. There is no need to modify the main switching logic code, which is beneficial for the modular maintenance and flexible expansion of the meter firmware.

[0092] As an example, in step S504, the template static configuration data can be written to the corresponding storage address of the target account according to the determined mapping relationship, replacing the original account static configuration data to obtain candidate static configuration data. The candidate static configuration data is a temporary configuration that has been written to the template parameters but has not yet been validated and taken effect.

[0093] In one embodiment, the parameter writing process only accesses the storage address corresponding to the account's static configuration data, without reading or modifying the address of the dynamic running data in the account, keeping dynamic data such as balance and accumulated power unchanged, without needing to perform balance conversion, thus avoiding conversion errors at the source.

[0094] In one embodiment, parameter writing can be done by assigning values ​​field by field or by writing in batches using block copying, both of which can complete the configuration replacement.

[0095] As an example, in step S505, the final effective updated account static configuration data can be determined based on the candidate static configuration data obtained from the write operation and the previously backed-up backup static configuration data. The updated account static configuration data is the final valid configuration used to generate the billing policy.

[0096] In one embodiment, once the candidate static configuration data passes the verification, it can be determined as the updated account static configuration data; if the verification fails, it can be rolled back based on the backup static configuration data.

[0097] In one embodiment, the candidate static configuration data can be subjected to consistency verification to obtain the data consistency verification result; if the data consistency verification result is that the verification passes, the candidate static configuration data is determined as the updated account static configuration data; if the data consistency verification result is that the verification fails, the data is rolled back to the backup static configuration data and a configuration update anomaly alarm message is generated.

[0098] In other words, when determining the updated account static configuration data, a readback consistency check can be performed on the candidate static configuration data: read back the actual value of the written address one by one and compare it with the template static configuration data. If all forced copy attribute readback values ​​are consistent with the template values, the check passes and the candidate static configuration data is determined as the updated account static configuration data; if there are inconsistencies in the forced copy attribute readback values, roll back all modified configuration addresses based on the backup static configuration data and restore the original configuration.

[0099] The rollback operation can use atomic write to ensure that all modified addresses are restored at once, avoiding the abnormal state of partial rollback. After the rollback is completed, the temporary variables of this switch can be automatically cleared and the lock flag of the target account can be reset to the unlocked state.

[0100] In an optional embodiment, if only the conditional copy attribute write fails during verification, only the configuration exception log can be recorded without triggering an overall rollback. The candidate static configuration data can still be determined as the updated account static configuration data, thus balancing switching reliability and flexibility.

[0101] In one optional embodiment, after the updated account static configuration data takes effect, a configuration update audit record can be generated, which includes information such as update time, original mode, target mode, and update result, and written to the electricity meter event log.

[0102] In one optional embodiment, if a power outage occurs during the configuration update process, the electricity meter can automatically roll back to the state before the update based on the backup static configuration data after power-on, avoiding billing anomalies caused by the half-update state.

[0103] In one embodiment, the steps from suspending billing to resuming billing for the target account (such as steps S103-S106) constitute an indivisible single-stage atomic transaction unit: either the switchover is successfully completed, or a complete recovery to the pre-switch state is achieved through rollback; no intermediate state is visible to the outside world. If an unexpected power outage occurs during the switchover process, the power-on initialization program of the electricity meter will automatically execute a rollback after detecting the incomplete transaction marker, ensuring the consistency of the system state.

[0104] As an example, such as Figure 6 As shown, step S106, which is to restore billing to the target account based on the target billing policy and the current billing data snapshot, includes: S601, Obtain incremental electricity consumption data for the target account during the period of suspended billing; S602, based on the current billing data snapshot and electricity consumption increment data, determine the restoration baseline data; S603, based on the recovery baseline data and target billing policy, restores billing to the target account.

[0105] As an example, in step S601, the electricity consumption data temporarily stored during the billing suspension period can be read to obtain the incremental electricity consumption data of the target account during the billing suspension period. The incremental electricity consumption data refers to the electricity actually used by the user during the billing suspension period that has not yet been included in the software billing.

[0106] In one embodiment, the hardware metering pulse acquisition circuit of the electricity meter continues to operate during the suspension of billing. The acquired electricity pulses are temporarily stored in a hardware register or a dedicated buffer. When billing resumes, the pulse count difference in the buffer is read and converted into incremental electricity data to ensure that electricity is not lost during the suspension.

[0107] In one embodiment, the incremental electricity consumption data may include only the incremental active power consumption, or it may also include the incremental reactive power consumption, demand, and other metering data, depending on the metering requirements of the electricity meter.

[0108] As an example, in step S602, the metering baseline value recorded in the current billing data snapshot can be accumulated with the incremental electricity consumption data to obtain the initial value for resuming billing, i.e., the restoration baseline data. Here, the current billing data snapshot is the metering data such as cumulative electricity consumption and account balance frozen at the moment billing is suspended, and the restoration baseline data is the initial metering starting point when a new billing strategy is started.

[0109] In one embodiment, the restored baseline data may include a cumulative electricity consumption baseline value and a remaining balance baseline value. During calculation, the cumulative electricity consumption in the snapshot is added to the electricity consumption increment to obtain a new cumulative electricity consumption starting point. The balance remains unchanged from the value in the snapshot, and no data conversion is required.

[0110] In one embodiment, the restored baseline data may also include other operational status data such as rate phase and billing status, which are consistent with the status recorded in the snapshot to ensure the continuity of billing logic.

[0111] As an example, in step S603, the generated target billing strategy can be loaded, the initial billing value can be set to the calculated recovery baseline data, the billing calculation for the target account can be started, and normal billing for the target account can be restored. The target billing strategy is a billing rule adapted to the new billing mode, generated after updating the static configuration. After billing is restored, the electricity meter will complete billing logic such as electricity accumulation, balance deduction, tiered calculation, and peak-valley calculation according to the new rules.

[0112] In one embodiment, when starting billing, the billing context can be initialized first, the recovery baseline data can be written into the billing runtime variable, the calculation callback of the target billing policy can be attached, the billing cycle task can be started, and the billing recovery can be completed.

[0113] In one embodiment, after billing is restored, the running status of the billing task can be verified to confirm that the billing logic is executing normally.

[0114] In an optional embodiment, if an anomaly such as failure to load the target billing strategy or invalid parameters is detected during billing recovery, the default billing strategy preset by the electricity meter can be automatically loaded, and billing can be started based on the recovery baseline data to avoid metering interruption. The target strategy will be updated after subsequent strategy repair.

[0115] In one optional embodiment, after billing returns to normal, a switchover completion audit record can be generated, including information such as total switchover duration, original billing mode, target billing mode, and electricity consumption increment, and written to the electricity meter event log; after confirming stable billing operation, the billing data mutex lock is released, the lock execution flag is updated to the second preset value, and the switchover of this billing mode is completed.

[0116] In one optional embodiment, after billing is restored, the temporarily stored incremental electricity consumption cache can be cleared to prepare for the next switchover; alternatively, incremental data can be retained for switchover audit verification.

[0117] In one embodiment, a device for switching the billing mode of an electricity meter account is provided, which corresponds one-to-one with the method for switching the billing mode of an electricity meter account in the above embodiments. For example... Figure 7 As shown, the device for switching the billing mode of the electricity meter account includes a response module 701, an acquisition module 702, a pause module 703, a template determination module 704, an update module 705, and a recovery module 706. Detailed descriptions of each functional module are as follows: The response module 701 is used to determine the billing data lock status of the target account in response to a billing mode switching signal for the target account. The acquisition module 702 is used to acquire the billing data mutex lock of the target account based on the billing data lock status; The pause module 703 is used to pause billing for the target account based on a billing data mutex lock and generate a snapshot of the current billing data of the target account. The template determination module 704 is used to determine the corresponding pre-designed billing mode template based on the billing mode switching signal; The update module 705 is used to update the static account configuration data of the target account based on the pre-designed billing model template, and to determine the target billing strategy based on the updated static account configuration data. Recovery module 706 is used to restore billing to the target account based on the target billing policy and the current billing data snapshot, and release the billing data mutex lock.

[0118] In one embodiment, the response module 701 is further configured to obtain the switching trigger identifier of the target account, perform consistency verification between the switching trigger identifier and the pre-configured trigger reference data, and generate a billing mode switching signal after the consistency verification passes. The system periodically acquires the real-time clock and preset switching activation time of the target account. When the real-time clock is greater than or equal to the preset switching activation time, a billing mode switching signal is generated, and the preset switching activation time is cleared. Receive mode switching call requests, verify the operation permissions corresponding to the call requests, and generate a billing mode switching signal after the operation permissions are verified.

[0119] In one embodiment, the response module 701 is further configured to obtain the current status value of the preset lock execution flag bit; If the current status value is the first preset value, then it is determined that the billing data of the target account is locked. If the current status value is the second preset value, then it is determined that the billing data of the target account is in an unlocked state.

[0120] In one embodiment, the acquisition module 702 is further configured to acquire the operating status of the electricity meter corresponding to the target account if the billing data lock status is unlocked. If the electricity meter is in normal billing status, then the billing data mutex lock is acquired. If the billing data mutex lock is successfully acquired within the preset time, the current status value will be updated from the second preset value to the first preset value. If the billing data mutex lock is not successfully acquired within the preset time, an acquisition failure alarm message will be generated, and the billing mode switching for the target account will be terminated.

[0121] In one embodiment, the update module 705 is further configured to back up the account static configuration data to obtain backed-up static configuration data; Retrieve the static configuration data of the pre-design fee model template; Based on preset configuration mapping rules, the mapping relationship between template static configuration data and account static configuration data is determined; Based on the mapping relationship, the static configuration data of the account is replaced with the static configuration data of the template to obtain candidate static configuration data; Based on the candidate static configuration data and the backup static configuration data, the updated account static configuration data is determined.

[0122] In one embodiment, the update module 705 is further configured to perform a consistency check on the candidate static configuration data to obtain a data consistency check result; If the data consistency verification result is successful, the candidate static configuration data will be determined as the updated account static configuration data. If the data consistency check fails, the system will roll back to the backup static configuration data and generate a configuration update anomaly alarm.

[0123] In one embodiment, the recovery module 706 is further configured to acquire incremental electricity consumption data of the target account during the period of suspended billing; Based on the current billing data snapshot and electricity consumption increment data, determine the baseline data for restoration; Based on the restored baseline data and the target billing strategy, restore billing to the target account.

[0124] This invention provides a device for switching billing modes for an electricity meter account, comprising: a response module, configured to determine the billing data lock state of the target account in response to a billing mode switching signal for the target account; an acquisition module, configured to acquire the billing data mutex lock of the target account based on the billing data lock state; a pause module, configured to pause billing for the target account based on the billing data mutex lock and generate a snapshot of the current billing data of the target account; a template determination module, configured to determine a corresponding pre-designed billing mode template based on the billing mode switching signal; an update module, configured to update the static configuration data of the target account based on the pre-designed billing mode template and determine a target billing strategy based on the updated static configuration data; and a recovery module, configured to resume billing for the target account based on the target billing strategy and the current billing data snapshot and release the billing data mutex lock. This device uses a billing data mutex lock to lock the billing data during the switching process, preventing data inconsistency caused by concurrent operations. By using billing data snapshots and pre-designed billing mode templates, it ensures the integrity and accuracy of billing data before and after the switch, avoiding data conversion during billing mode switching. This improves the reliability and efficiency of billing mode switching and ensures the stable operation of the electricity meter account billing system.

[0125] In one embodiment, a computer device is provided, which may be a smart energy meter, and its internal structure diagram may be as follows: Figure 8 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database stores data used in the method for switching electricity meter account billing modes. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it can implement a method for switching electricity meter account billing modes.

[0126] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements a method for switching the billing mode of an electricity meter account.

[0127] In one embodiment, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program, which, when executed by a processor, implements a method for switching the billing mode of an electricity meter account.

[0128] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), IAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0129] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0130] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A method for switching the billing mode of an electricity meter account, characterized in that, include: In response to a billing mode switching signal for a target account, determine the billing data lock status of the target account; Based on the billing data lock status, obtain the billing data mutex lock for the target account; Based on the billing data mutex lock, billing for the target account is suspended, and a snapshot of the current billing data for the target account is generated; Based on the billing mode switching signal, the corresponding pre-designed billing mode template is determined; Based on the pre-designed billing model template, update the static account configuration data of the target account, and determine the target billing strategy based on the updated static account configuration data; Based on the target billing policy and the current billing data snapshot, resume billing for the target account and release the billing data mutex lock.

2. The method according to claim 1, characterized in that, Prior to responding to the billing mode switching signal for the target account, at least one of the following is included: Obtain the switching trigger identifier of the target account, perform a consistency check between the switching trigger identifier and the pre-configured trigger reference data, and generate the billing mode switching signal after the consistency check passes. The system periodically acquires the real-time clock and preset switching activation time of the target account. When the real-time clock is greater than or equal to the preset switching activation time, it generates the billing mode switching signal and clears the preset switching activation time. The system receives a mode switching request, verifies the operation permission corresponding to the request, and generates the billing mode switching signal after the operation permission verification is successful.

3. The method according to claim 1, characterized in that, Determining the billing data lock status of the target account includes: Get the current status value of the preset lock execution flag; If the current status value is a first preset value, then it is determined that the billing data of the target account is in a locked state; If the current status value is the second preset value, then it is determined that the billing data of the target account is in an unlocked state.

4. The method according to claim 3, characterized in that, The step of acquiring the billing data mutex lock for the target account based on the billing data lock status includes: If the billing data is locked, then obtain the operating status of the electricity meter corresponding to the target account; If the electricity meter is in normal billing status, then the billing data mutex lock is acquired. If the billing data mutex is successfully acquired within a preset time, the current status value is updated from the second preset value to the first preset value. If the billing data mutex lock is not successfully acquired within a preset time, an acquisition failure alarm message is generated, and the billing mode switching for the target account is terminated.

5. The method according to claim 1, characterized in that, The step of updating the static account configuration data of the target account based on the pre-designed fee model template includes: The account static configuration data is backed up to obtain backup static configuration data; Obtain the template static configuration data from the pre-design fee model template; Based on preset configuration mapping rules, the mapping relationship between the template static configuration data and the account static configuration data is determined; Based on the mapping relationship, the static configuration data of the account is replaced with the static configuration data of the template to obtain candidate static configuration data; Based on the candidate static configuration data and the backup static configuration data, the updated account static configuration data is determined.

6. The method according to claim 5, characterized in that, The step of determining the updated account static configuration data based on the candidate static configuration data and the backup static configuration data includes: Perform a consistency check on the candidate static configuration data to obtain the data consistency check result; If the data consistency verification result is successful, then the candidate static configuration data is determined as the updated account static configuration data; If the data consistency verification result is that the verification fails, the system will roll back to the backup static configuration data and generate a configuration update anomaly alarm message.

7. The method according to claim 1, characterized in that, The step of restoring billing to the target account based on the target billing policy and the current billing data snapshot includes: Obtain the incremental electricity consumption data of the target account during the period of billing suspension; Based on the current billing data snapshot and the incremental electricity consumption data, determine the recovery baseline data; Based on the recovery baseline data and the target billing policy, billing for the target account is restored.

8. A switching device for electricity meter account billing modes, characterized in that, include: The response module is used to determine the billing data lock status of the target account in response to a billing mode switching signal for the target account. The acquisition module is used to acquire the billing data mutex lock of the target account based on the billing data lock status; The pause module is used to pause billing for the target account based on the billing data mutex lock, and generate a snapshot of the current billing data of the target account; The template determination module is used to determine the corresponding pre-designed billing mode template based on the billing mode switching signal; The update module is used to update the static account configuration data of the target account based on the pre-designed billing model template, and to determine the target billing strategy based on the updated static account configuration data. The recovery module is used to restore billing to the target account based on the target billing policy and the current billing data snapshot, and release the billing data mutex lock.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method for switching the billing mode of the electricity meter account as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the method for switching the billing mode of the electricity meter account as described in any one of claims 1 to 7.