CN111105563B - Water card data writing method, device, equipment and storage medium for preventing data loss - Google Patents

Water card data writing method, device, equipment and storage medium for preventing data loss Download PDF

Info

Publication number
CN111105563B
CN111105563B CN201911300866.3A CN201911300866A CN111105563B CN 111105563 B CN111105563 B CN 111105563B CN 201911300866 A CN201911300866 A CN 201911300866A CN 111105563 B CN111105563 B CN 111105563B
Authority
CN
China
Prior art keywords
data
water
card
area
writing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911300866.3A
Other languages
Chinese (zh)
Other versions
CN111105563A (en
Inventor
唐良帅
林兴发
陈允彬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiamen Jixun Internet Of Things Technology Co ltd
Original Assignee
Xiamen Jixun Internet Of Things Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xiamen Jixun Internet Of Things Technology Co ltd filed Critical Xiamen Jixun Internet Of Things Technology Co ltd
Priority to CN201911300866.3A priority Critical patent/CN111105563B/en
Publication of CN111105563A publication Critical patent/CN111105563A/en
Application granted granted Critical
Publication of CN111105563B publication Critical patent/CN111105563B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G07CHECKING-DEVICES
    • G07FCOIN-FREED OR LIKE APPARATUS
    • G07F15/00Coin-freed apparatus with meter-controlled dispensing of liquid, gas or electricity
    • G07F15/06Coin-freed apparatus with meter-controlled dispensing of liquid, gas or electricity with means for prepaying basic charges, e.g. rent for meters

Abstract

The invention discloses a water card data writing method, a device, equipment and a storage medium for preventing data loss, wherein the method comprises the following steps: reading a current approaching water card through an NFC module; when the effective mark of the data area of the water card is judged to be effective, reading the current first water data of the data area, writing the first water data into a first backup area, writing the second water data to be written into a second backup area, and locally storing the current first water card state of the data area; setting the valid identifier of the data area as invalid, writing the second water data into the data area, and updating the first water card state of the data area into a second water card state; the effective identification of the data area is set to be effective, the writing-in of the water card data is completed, and the water card data can be guaranteed not to be lost.

Description

Water card data writing method, device, equipment and storage medium for preventing data loss
Technical Field
The invention relates to the technical field of Internet of things, in particular to a water card data writing method, a water card data writing device, water card data writing equipment and a storage medium for preventing data loss.
Background
In the growth process of crops, for guaranteeing the good development of crops, need irrigate crops, mostly be the extraction groundwater when irrigating crops, caused local groundwater level to descend, ground subsides, and along with the water resource shortage of china is serious gradually, most can irrigate the mode through the expense of paying earlier at present, carries out the management and control to groundwater to save the water resource.
Current be used for agricultural irrigation prevent water card data write in equipment that data lost and include display module, storage module, NFC card swiping module, MCU module, metering module, the MCU module respectively with display module, storage module, NFC card swiping module, MCU module, metering module electricity are connected and are constituteed, and wherein, the water intaking mode of swiping card is: firstly, the method comprises the following steps: and when the MCU module is not operated, the display module is controlled by the MCU module to display a standby interface. Secondly, the method comprises the following steps: when the water card is close to the NFC card swiping module for the first time, the MCU module reads the water card information and displays the water card information on the display module. Thirdly, the method comprises the following steps: when the water card is close to the NFC card swiping module for the second time, the MCU module reads the water card information and stores the water card information in the storage module (simultaneously stores the state of the water card), the available water amount of the water card is cleared, then the water consumption of a user is calculated through the metering module, and meanwhile the display module displays the available residual water amount information. Fourthly: when the water card is close to the NFC card swiping module for the third time, the MCU module reads the water card information, writes the available water amount information back into the water card, and displays a standby interface on the display module (clears the available water amount information and the card swiping state information of the storage module). However, in the card swiping mode, the card writing process is easily affected by electromagnetism, water pump interference and irregular user operation, so that written data is not correct or data is lost, and therefore user loss is caused, or in the card writing process, a user does not complete card writing and then breaks away from the card writing process, and data writing is incomplete.
Disclosure of Invention
In view of the foregoing problems, an object of the present invention is to provide a method, an apparatus, a device, and a storage medium for writing water card data to prevent data loss, which can ensure that the water card data is not lost.
In a first aspect, an embodiment of the present invention provides a water card data writing method for preventing data loss, including:
reading a current approaching water card through an NFC module; the water card is provided with a data area for storing current water quantity information, a card number area for storing card number information, a first backup area and a second backup area; the data area, the first backup area and the second backup area are used for storing effective identification for identifying whether water consumption data are effective or not, water consumption data and a water card state;
judging whether the effective identification of the data area of the water card is effective or not;
when the valid identifier of the data area of the water card is judged to be valid, reading the current first water data of the data area, writing the first water data into the first backup area, writing the second water data to be written into the second backup area, and locally storing the current first water card state of the data area of the water card;
setting the valid identifier of the data area of the water card as invalid, writing the second water data into the data area of the water card, and updating the first water card state of the data area into a second water card state;
and setting the valid identifier of the data area of the water card to be valid so as to complete the writing of the water card data.
Preferably, when the valid identifier of the data area of the water card is judged to be invalid, the current water card state of the data area of the water card and a first water card state stored locally are acquired;
when the current water card state of the data area is judged to be consistent with a first water card state stored locally, reading water consumption data in a first backup area, writing the water consumption data into the data area, and setting the effective identification of the data area of the water card to be effective;
and when the water card state of the data area is judged to be inconsistent with the first local water card state stored locally, reading the water consumption data in the second backup area, writing the water consumption data into the data area, and setting the effective identification of the data area of the water card to be effective.
Preferably, the valid identifier is a string of special character strings for identifying whether the water consumption data stored in each area is valid; the water card status includes: an invalid state, a card writing-free state, a card data emptying state and a card writing-in data state; the water use data comprises: the amount of water available and the unit price of the water.
Preferably, before setting the valid identifier of the data area of the water card to be valid to complete the writing of the water card data, the method further includes:
comparing whether the third water data of the data area is consistent with the second water data after writing;
setting the valid identifier of the data area of the water card to be valid so as to complete the writing of the water card data:
and when the third water data written into the data area is judged to be consistent with the second water data to be written, setting the valid identifier of the data area of the water card to be valid so as to finish the writing of the water card data.
In a second aspect, an embodiment of the present invention further provides a water card data writing device for preventing data loss, including:
the water card reading unit is used for reading a water card which is close to the current position through the NFC module; the water card is provided with a data area for storing current water quantity information, a card number area for storing card number information, a first backup area and a second backup area; the data area, the first backup area and the second backup area are used for storing effective identification for identifying whether water consumption data are effective or not, water consumption data and a water card state;
the effective identification judging unit is used for judging whether the effective identification of the data area of the water card is effective or not;
the water consumption data reading unit is used for reading current first water data of the data area, writing the first water data into the first backup area, writing second water data to be written into the second backup area and locally storing the current first water card state of the data area of the water card when the effective identifier of the data area of the water card is judged to be effective;
the water card state updating unit is used for setting the valid identifier of the data area of the water card to be invalid, writing the second water data into the data area of the water card, and updating the first water card state of the data area to be a second water card state;
and the water card data writing unit is used for setting the valid identifier of the data area of the water card to be valid so as to complete the writing of the water card data.
Preferably, the method comprises the following steps:
the water card state acquisition unit is used for acquiring the current water card state of the data area of the water card and a first water card state stored locally when the valid identifier of the data area of the water card is judged to be invalid;
the first backup area water consumption data reading unit is used for reading the water consumption data in the first backup area and writing the water consumption data into the data area when the current water card state of the data area is judged to be consistent with the first water card state stored locally, and meanwhile, setting the effective identification of the data area of the water card to be effective;
and the second backup area water consumption data reading unit is used for reading the water consumption data in the second backup area and writing the water consumption data into the data area when the water card state of the data area is judged to be inconsistent with the first local water card state stored locally, and meanwhile, setting the valid identifier of the data area of the water card to be valid.
Preferably, the valid identifier is a string of special character strings for identifying whether the water consumption data stored in each area is valid; the water card status includes: an invalid state, a card writing-free state, a card data emptying state and a card writing-in data state; the water use data comprises: the amount of water available and the unit price of the water.
Preferably, the method further comprises the following steps:
the water use data comparison unit is used for comparing whether the third water use data written in the data area is consistent with the second water use data;
and the water card data writing unit is also used for setting the valid identifier of the data area of the water card to be valid when judging that the third water data written into the data area is consistent with the second water data to be written, so as to finish the writing of the water card data.
An embodiment of the present invention further provides a water card data writing device for preventing data loss, which includes a processor, a memory, and a computer program stored in the memory, where the computer program is executable by the processor to implement the water card data writing method for preventing data loss according to the first aspect.
The embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium includes a stored computer program, and when the computer program runs, the apparatus where the computer-readable storage medium is located is controlled to execute the above-mentioned water card data writing method for preventing data loss.
In the embodiment, the water card is provided with a data area for storing current water quantity information, a card number area for storing card number information, a first backup area and a second backup area, and each area is stored with data for identifying whether water consumption data is effective or not, water consumption data and a water card state; then through setting up the effective sign of the data area of water card when effective, just can carry out the reading of the water data of water card and write in operation, simultaneously through writing in first water data first backup area to and write in the second water data that will wait to write in second backup area ensures that water card data can not lead to writing in data mistake, lose and write in incomplete problem because of electromagnetism, water pump interference and the influence that operates the irregularity at the in-process of writing in the card, in order to avoid water card data loss and guarantee water card data integrality.
Drawings
In order to more clearly illustrate the technical solution of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flow chart of a water card data writing method for preventing data loss according to a first embodiment of the present invention.
Fig. 2 is a schematic structural diagram of a water card data writing device for preventing data loss according to a third embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
For better understanding of the technical solutions of the present invention, the following detailed descriptions of the embodiments of the present invention are provided with reference to the accompanying drawings.
It should be understood that the described embodiments are only some embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
In the embodiments, the references to "first \ second" are merely to distinguish similar objects and do not represent a specific ordering for the objects, and it is to be understood that "first \ second" may be interchanged with a specific order or sequence, where permitted. It should be understood that "first \ second" distinct objects may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced in sequences other than those illustrated or described herein.
The first embodiment is as follows:
referring to fig. 1, a first embodiment of the present invention provides a method for writing data into a water card to prevent data loss, which is performed by a water card data writing device (hereinafter referred to as "data writing device") to prevent data loss, and in particular, is performed by one or more processors in the card data writing device, and includes at least the following steps:
s101, reading a current approaching water card through an NFC module; the water card is provided with a data area for storing current water quantity information, a card number area for storing card number information, a first backup area and a second backup area; the data area, the first backup area and the second backup area are used for storing effective identification used for identifying whether the water consumption data are effective or not, the water consumption data and the water card state.
In this embodiment, the data writing device exchanges data with the water card through the NFC module, and when the water card is close to the NFC module, the NFC module reads the water card information in the water card and writes the water card information into the data writing device, or the NFC module writes back the available water volume information stored in the device into the water card.
Wherein the water card status comprises: an invalid state, a card writing-free state, a card data emptying state and a card writing-in data state; the water use data comprises: the amount of water available and the unit price of the water.
Table 1:
Figure BDA0002321733930000071
s102, judging whether the valid identification of the data area of the water card is valid.
In this embodiment, an effective identifier of a string of special character strings is provided in each region, and is used to identify whether the water consumption data stored in each region is effective, specifically, when the read special character string in the data region is inconsistent with the pre-agreed special character string, it indicates that the water consumption data stored in the data region is invalid and the water consumption data in the data region cannot be read, and only when the read special character string in the data region is consistent with the pre-agreed special character string, the water consumption data in the data region can be read, for example, when the read special character string in the data region is H, T @ -% I { T-, D @ H) - — I [ P ^ Z $ V }, and the pre-agreed special character string is H, T @ -% H { F }, w @ Z) - -L [ E- - [ N $ I }, then judge that the effective sign of the data area of disconnected water card is invalid, if a string of special character in the data area who reads is H, T @ -% H { F- -, W @ Z) - -L [ E- - [ N $ I }, the special character string agreed in advance is H, T @ -% H { F- -, W @ Z) - -L [ E- - [ N $ I }, then judge that the effective sign of the data area of disconnected water card is valid.
S103, when the valid identifier of the data area of the water card is judged to be valid, reading the current first water data of the data area, writing the first water data into the first backup area, writing the second water data to be written into the second backup area, and locally storing the current first water card state of the data area of the water card.
In this embodiment, in order to ensure that the problems of data writing errors, data loss and incomplete writing caused by electromagnetic interference, water pump interference, incomplete writing and irregular operation of the water card data in the card writing process are avoided, the current first water data of the data area is written into the first backup area for storage, the current second water data to be written is written into the second backup area for storage, and the current first water card state of the data area of the water card is locally stored, so that the water data in the data area can be selected to be restored from the first backup area or the second backup area according to actual conditions, and the water card data loss is avoided.
It should be noted that, the first water card state at this time may be, for example, a card-write-free state.
And S104, setting the valid identifier of the data area of the water card to be invalid, writing the second water data into the data area of the water card, and updating the first water card state of the data area to be the second water card state.
In this embodiment, by setting the valid identifier of the data area of the water card to be invalid, the data area can only be written with the water consumption data and cannot read or use the water consumption data of the data area.
Wherein, the second water card state can be a card writing state, for example.
And S105, setting the valid identifier of the data area of the water card to be valid so as to complete the writing of the water card data.
In this embodiment, in order to verify the integrity of the water card data, the method further includes comparing whether the third water data in the data area after writing is consistent with the second water data; and when the third water data written into the data area is judged to be consistent with the second water data to be written, setting the valid identifier of the data area of the water card to be valid so as to finish the writing of the water card data.
In summary, the water card is provided with a data area for storing current water quantity information, a card number area for storing card number information, a first backup area and a second backup area, and each area is stored with data for identifying whether water consumption data is valid, water consumption data and a water card state; then through setting up the effective sign of the data area of water card when effective, just can carry out the reading of the water data of water card and write in operation, simultaneously through writing in first water data first backup area to and write in the second water data that will wait to write in second backup area ensures that water card data can not lead to writing in data mistake, lose and write in incomplete problem because of electromagnetism, water pump interference and the influence that operates the irregularity at the in-process of writing in the card, in order to avoid water card data loss and guarantee water card data integrality.
On the basis of the above embodiment, in a preferred embodiment of the present invention, the method further includes:
when the valid identifier of the data area of the water card is judged to be invalid, acquiring the current water card state of the data area of the water card and a first water card state stored locally;
when the current water card state of the data area is judged to be consistent with a first water card state stored locally, reading water consumption data in a first backup area, writing the water consumption data into the data area, and setting the effective identification of the data area of the water card to be effective;
and when the water card state of the data area is judged to be inconsistent with the first local water card state stored locally, reading the water consumption data in the second backup area, writing the water consumption data into the data area, and setting the effective identification of the data area of the water card to be effective.
According to the above embodiment, in step S104, the valid identifier of the data area of the water card is set to be invalid, that is, the water card cannot use the water use data of the data area until the writing in S105 is completed, and the valid identifier of the data area of the water card is set to be valid again. If the user removes the water card during the data writing process or the data cannot be written due to interference, the valid identification set of the data area of the water card is kept invalid, that is, the water card cannot be used, and the actual water consumption data of the water card may be lost or abnormal.
For this reason, in this embodiment, when the valid identifier of the data area of the water card is found to be invalid, the water use data for restoring the data area from the first backup area or the second backup area is selected according to the card status of the data area of the water card.
According to the step S103, the first water card state is stored in the equipment. In S104, if the water card is removed when the device has not written the second water data into the data area of the water card, the card status of the data area of the water card at this time remains the first water card status, that is, consistent with the local storage of the device. And if the water card is removed after the equipment writes the second water data into the data area of the water card, updating the card state of the data area of the water card to be the second water card state, namely inconsistent with the local storage of the equipment.
Therefore, when the current water card state of the data area is judged to be consistent with the first water card state stored locally, the data are not written successfully by the equipment, at the moment, the water consumption data in the first backup area are read, the water consumption data are written into the data area, and meanwhile, the effective identification of the data area of the water card is set to be effective;
and when the water card state of the data area is judged to be inconsistent with the first local water card state stored locally, the data is indicated to be written successfully, at the moment, the water consumption data in the second backup area is read, the water consumption data is written into the data area, and meanwhile, the effective identification of the data area of the water card is set to be effective.
So, can guarantee that the water data accuracy of data area just can not lose, the effective sign of the data area of water card just can be automatic from invalid setting for effective when punching the card moreover, the user can reuse the water card, and need not to make things convenient for user's use to experience and the pressure of backstage through relevant personnel change at the backstage again greatly.
Second embodiment of the invention:
referring to fig. 2, a second embodiment of the present invention further provides a water card data writing device for preventing data loss, including:
a water card reading unit 100, configured to read a currently approaching water card through an NFC module; the water card is provided with a data area for storing current water quantity information, a card number area for storing card number information, a first backup area and a second backup area; the data area, the first backup area and the second backup area are used for storing effective identification for identifying whether water consumption data are effective or not, water consumption data and a water card state;
a valid identifier determining unit 200, configured to determine whether a valid identifier of the data area of the water card is valid;
a water data reading unit 300, configured to, when it is determined that the valid identifier of the data area of the water card is valid, read current first water data of the data area, write the first water data into the first backup area, write second water data to be written into the second backup area, and locally store a current first water card state of the data area of the water card;
the water card state updating unit 400 is configured to set the valid identifier of the data area of the water card to be invalid, write the second water data into the data area of the water card, and update the first water card state of the data area to be the second water card state;
and the water card data writing unit 500 is used for setting the valid identifier of the data area of the water card to be valid so as to complete the writing of the water card data.
On the basis of the above embodiments, a preferred embodiment of the present invention includes:
the water card state acquisition unit is used for acquiring the current water card state of the data area of the water card and a first water card state stored locally when the valid identifier of the data area of the water card is judged to be invalid;
the first backup area water consumption data reading unit is used for reading the water consumption data in the first backup area and writing the water consumption data into the data area when the current water card state of the data area is judged to be consistent with the first water card state stored locally, and meanwhile, setting the effective identification of the data area of the water card to be effective;
and the second backup area water consumption data reading unit is used for reading the water consumption data in the second backup area and writing the water consumption data into the data area when the water card state of the data area is judged to be inconsistent with the first local water card state stored locally, and meanwhile, setting the valid identifier of the data area of the water card to be valid.
On the basis of the foregoing embodiment, in a preferred embodiment of the present invention, the valid identifier is a string of special character strings, and is used to identify whether the water consumption data stored in each area is valid; the water card status includes: an invalid state, a card writing-free state, a card data emptying state and a card writing-in data state; the water use data comprises: the amount of water available and the unit price of the water.
On the basis of the above embodiment, in a preferred embodiment of the present invention, the method further includes:
the water use data comparison unit is used for comparing whether the third water use data written in the data area is consistent with the second water use data;
the water card data writing unit 500 is further configured to set the valid identifier of the data area of the water card to be valid when it is determined that the third water data written into the data area is consistent with the second water data to be written, so as to complete the writing of the water card data this time.
A third embodiment of the present invention provides a water card data writing device for preventing data loss, which includes a processor, a memory, and a computer program stored in the memory, where the computer program is executable by the processor to implement the water card data writing method for preventing data loss as described above.
A fourth embodiment of the present invention provides a computer-readable storage medium, where the computer-readable storage medium includes a stored computer program, where when the computer program runs, the apparatus where the computer-readable storage medium is located is controlled to execute the above-mentioned water card data writing method for preventing data loss.
Illustratively, the computer program may be divided into one or more units, which are stored in the memory and executed by the processor to accomplish the present invention. The one or more units may be a series of instruction segments of the computer program capable of performing specific functions, and the instruction segments are used for describing the execution process of the computer program in the water card data writing device for preventing data loss.
The data writing device may include, but is not limited to, a processor, a memory. It will be understood by those skilled in the art that the schematic diagram is merely an example of the data loss prevention water card data writing device, and does not constitute a limitation of the data loss prevention water card data writing device, and may include more or less components than those shown, or combine some components, or different components, for example, the data loss prevention water card data writing device may further include an input-output device, a network access device, a bus, etc.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, the control center of the data writing device connecting the various parts of the overall data writing device using various interfaces and lines.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the data writing apparatus by executing or executing the computer programs and/or modules stored in the memory and calling data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
The unit integrated with the water card data writing device for preventing data loss can be stored in a computer readable storage medium if the unit is realized in the form of a software functional unit and sold or used as an independent product. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
It should be noted that the above-described device embodiments are merely illustrative, where the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. In addition, in the drawings of the embodiment of the apparatus provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, and may be specifically implemented as one or more communication buses or signal lines. One of ordinary skill in the art can understand and implement it without inventive effort.
While the foregoing is directed to the preferred embodiment of the present invention, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention.

Claims (8)

1. A water card data writing method for preventing data loss is characterized by comprising the following steps:
reading a current approaching water card through an NFC module; the water card is provided with a data area for storing current water quantity information, a card number area for storing card number information, a first backup area and a second backup area; the data area, the first backup area and the second backup area are used for storing effective identification for identifying whether water consumption data are effective or not, water consumption data and a water card state;
judging whether the effective identification of the data area of the water card is effective or not;
when the valid identifier of the data area of the water card is judged to be valid, reading the current first water data of the data area, writing the first water data into the first backup area, writing the second water data to be written into the second backup area, and locally storing the current first water card state of the data area of the water card;
setting the valid identifier of the data area of the water card as invalid, writing the second water data into the data area of the water card, and updating the first water card state of the data area into a second water card state;
setting the valid identifier of the data area of the water card as valid to finish the writing of the water card data;
when the valid identifier of the data area of the water card is judged to be invalid, acquiring the current water card state of the data area of the water card and a first water card state stored locally; when the current water card state of the data area is judged to be consistent with a first water card state stored locally, reading water consumption data in a first backup area, writing the water consumption data into the data area, and setting the effective identification of the data area of the water card to be effective; and when the water card state of the data area is judged to be inconsistent with the first local water card state stored locally, reading the water consumption data in the second backup area, writing the water consumption data into the data area, and setting the effective identification of the data area of the water card to be effective.
2. The method for writing the water card data for preventing the data loss according to claim 1, wherein the valid identifier is a string of special character strings for identifying whether the water consumption data stored in each area is valid; the water card status includes: an invalid state, a card writing-free state, a card data emptying state and a card writing-in data state; the water use data comprises: the amount of water available and the unit price of the water.
3. The method for writing the water card data for preventing the data loss according to claim 2, before setting the valid flag of the data area of the water card to be valid to complete the writing of the water card data, further comprising:
comparing whether the third water data of the data area is consistent with the second water data after writing;
setting the valid identifier of the data area of the water card to be valid so as to complete the writing of the water card data:
and when the third water data written into the data area is judged to be consistent with the second water data to be written, setting the valid identifier of the data area of the water card to be valid so as to finish the writing of the water card data.
4. A water card data writing device for preventing data loss is characterized by comprising:
the water card reading unit is used for reading a water card which is close to the current position through the NFC module; the water card is provided with a data area for storing current water quantity information, a card number area for storing card number information, a first backup area and a second backup area; the data area, the first backup area and the second backup area are used for storing effective identification for identifying whether water consumption data are effective or not, water consumption data and a water card state;
the effective identification judging unit is used for judging whether the effective identification of the data area of the water card is effective or not;
the water consumption data reading unit is used for reading current first water data of the data area, writing the first water data into the first backup area, writing second water data to be written into the second backup area and locally storing the current first water card state of the data area of the water card when the effective identifier of the data area of the water card is judged to be effective;
the water card state updating unit is used for setting the valid identifier of the data area of the water card to be invalid, writing the second water data into the data area of the water card, and updating the first water card state of the data area to be a second water card state;
the water card data writing unit is used for setting the valid identifier of the data area of the water card to be valid so as to complete the writing of the water card data; the water card state acquisition unit is used for acquiring the current water card state of the data area of the water card and a first water card state stored locally when the valid identifier of the data area of the water card is judged to be invalid; the first backup area water consumption data reading unit is used for reading the water consumption data in the first backup area and writing the water consumption data into the data area when the current water card state of the data area is judged to be consistent with the first water card state stored locally, and meanwhile, setting the effective identification of the data area of the water card to be effective; and the second backup area water consumption data reading unit is used for reading the water consumption data in the second backup area and writing the water consumption data into the data area when the water card state of the data area is judged to be inconsistent with the first local water card state stored locally, and meanwhile, setting the valid identifier of the data area of the water card to be valid.
5. The water card data writing device for preventing data loss according to claim 4, wherein the valid identifier is a string of special character strings for identifying whether the water use data stored in each area is valid; the water card status includes: an invalid state, a card writing-free state, a card data emptying state and a card writing-in data state; the water use data comprises: the amount of water available and the unit price of the water.
6. The water card data writing device for preventing data loss according to claim 5, further comprising:
the water use data comparison unit is used for comparing whether the third water use data written in the data area is consistent with the second water use data;
and the water card data writing unit is also used for setting the valid identifier of the data area of the water card to be valid when judging that the third water data written into the data area is consistent with the second water data to be written, so as to finish the writing of the water card data.
7. A water card data writing device for preventing data loss, comprising a processor, a memory, and a computer program stored in the memory, the computer program being executable by the processor to implement the water card data writing method for preventing data loss according to any one of claims 1 to 3.
8. A computer-readable storage medium, comprising a stored computer program, wherein when the computer program runs, the computer-readable storage medium controls an apparatus to execute the method for writing data in a water card for preventing data loss according to any one of claims 1 to 3.
CN201911300866.3A 2019-12-17 2019-12-17 Water card data writing method, device, equipment and storage medium for preventing data loss Active CN111105563B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911300866.3A CN111105563B (en) 2019-12-17 2019-12-17 Water card data writing method, device, equipment and storage medium for preventing data loss

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911300866.3A CN111105563B (en) 2019-12-17 2019-12-17 Water card data writing method, device, equipment and storage medium for preventing data loss

Publications (2)

Publication Number Publication Date
CN111105563A CN111105563A (en) 2020-05-05
CN111105563B true CN111105563B (en) 2021-08-24

Family

ID=70423019

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911300866.3A Active CN111105563B (en) 2019-12-17 2019-12-17 Water card data writing method, device, equipment and storage medium for preventing data loss

Country Status (1)

Country Link
CN (1) CN111105563B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114639198B (en) * 2022-02-17 2023-07-25 山东华特智慧科技有限公司 NFC-based M1 card read-write recharging method for water selling

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1996025743A1 (en) * 1995-02-16 1996-08-22 Gemplus Method for the secure updating of an eeprom memory
CN1369853A (en) * 2001-12-25 2002-09-18 航天信息股份有限公司 Anti-pulling method for non-contact logic encryption card terminal
WO2003102956A1 (en) * 2002-06-04 2003-12-11 Koninklijke Philips Electronics N.V. Roll back method for a smart card
CN101226604A (en) * 2007-01-19 2008-07-23 东信和平智能卡股份有限公司 Smart card and data write-in method
CN101699476A (en) * 2009-10-29 2010-04-28 北京握奇数据系统有限公司 Data processing method and device of smart cards
CN103150125A (en) * 2013-02-20 2013-06-12 郑州信大捷安信息技术股份有限公司 Method for prolonging service life of power-down protection date buffer memory and smart card
CN103377099A (en) * 2012-04-19 2013-10-30 中国移动通信集团公司 Method and device of data backup and recovery for NFC mobile terminals
CN104536847A (en) * 2014-12-18 2015-04-22 飞天诚信科技股份有限公司 Method for improving data writing integrity
CN204576673U (en) * 2015-04-22 2015-08-19 周明望 A kind of IC-card intelligent metering timing water meter
CN106227680A (en) * 2016-07-26 2016-12-14 成都三零嘉微电子有限公司 A kind of data process and power fail preventing data guard method
CN106776362A (en) * 2015-11-24 2017-05-31 中芯国际集成电路制造(上海)有限公司 The control method and device of memory
CN206363383U (en) * 2016-08-09 2017-07-28 西安微立方测控技术有限公司 A kind of pipeline intelligent watermeter amount controller of remote payment
CN109685190A (en) * 2018-12-28 2019-04-26 江苏恒宝智能系统技术有限公司 A kind of IC card power-off protection method and device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7028896B2 (en) * 2002-08-22 2006-04-18 Arthur Blank & Company, Inc. Transaction card fabrication control system and method
CN103824101B (en) * 2014-03-18 2017-01-04 高新现代智能系统股份有限公司 Logic card reading/writing method and system
CN105590367B (en) * 2015-05-11 2019-12-24 中国银联股份有限公司 Processing method for transaction abnormity of IC card and acceptance terminal for realizing processing method
CN107247680B (en) * 2017-06-19 2020-08-21 苏州浪潮智能科技有限公司 Multi-user sharing equipment IO card hot insertion method and device

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1996025743A1 (en) * 1995-02-16 1996-08-22 Gemplus Method for the secure updating of an eeprom memory
CN1369853A (en) * 2001-12-25 2002-09-18 航天信息股份有限公司 Anti-pulling method for non-contact logic encryption card terminal
WO2003102956A1 (en) * 2002-06-04 2003-12-11 Koninklijke Philips Electronics N.V. Roll back method for a smart card
CN101226604A (en) * 2007-01-19 2008-07-23 东信和平智能卡股份有限公司 Smart card and data write-in method
CN101699476A (en) * 2009-10-29 2010-04-28 北京握奇数据系统有限公司 Data processing method and device of smart cards
CN103377099A (en) * 2012-04-19 2013-10-30 中国移动通信集团公司 Method and device of data backup and recovery for NFC mobile terminals
CN103150125A (en) * 2013-02-20 2013-06-12 郑州信大捷安信息技术股份有限公司 Method for prolonging service life of power-down protection date buffer memory and smart card
CN104536847A (en) * 2014-12-18 2015-04-22 飞天诚信科技股份有限公司 Method for improving data writing integrity
CN204576673U (en) * 2015-04-22 2015-08-19 周明望 A kind of IC-card intelligent metering timing water meter
CN106776362A (en) * 2015-11-24 2017-05-31 中芯国际集成电路制造(上海)有限公司 The control method and device of memory
CN106227680A (en) * 2016-07-26 2016-12-14 成都三零嘉微电子有限公司 A kind of data process and power fail preventing data guard method
CN206363383U (en) * 2016-08-09 2017-07-28 西安微立方测控技术有限公司 A kind of pipeline intelligent watermeter amount controller of remote payment
CN109685190A (en) * 2018-12-28 2019-04-26 江苏恒宝智能系统技术有限公司 A kind of IC card power-off protection method and device

Also Published As

Publication number Publication date
CN111105563A (en) 2020-05-05

Similar Documents

Publication Publication Date Title
CN112040476B (en) Upgrading method and device for terminal of Internet of things
CN104461631B (en) A kind of system OTA upgrade methods and device
CN111105563B (en) Water card data writing method, device, equipment and storage medium for preventing data loss
CN107463341A (en) Method for deleting, device and the mobile terminal of FLASH chip
CN107908340A (en) Method, mobile terminal and the device with store function of factory reset
CN110413312B (en) Method, device and equipment for managing application program and storage medium
CN109884427B (en) Electrostatic detection method and related device
CN110675249A (en) Matching method, device, server and storage medium for network lending
CN110390463B (en) Wind control data processing method and device and terminal equipment
CN109032678A (en) The method for controlling the method, apparatus of BIOS type information amount, medium and type information
CN112612498A (en) Embedded equipment upgrading method and embedded equipment
CN113272785B (en) Method for mounting file system, terminal equipment and storage medium
CN110032474B (en) Method, system and related components for determining snapshot occupied capacity
CN112633731A (en) Method and device for detecting whether product is qualified or not, processor and electronic equipment
CN108958765B (en) Method and device for upgrading optical module firmware
CN116541742A (en) Abnormal transaction behavior identification method and system based on dynamic sequence regularity
CN108805543A (en) A kind of method and terminal of output Receiving information
CN109559235A (en) Asset reallocation method and device, storage medium and electronic equipment
CN108520063A (en) Processing method, device and the terminal device of event log
CN114860362A (en) Interface updating method and device
CN114064077A (en) Automobile ECU cloud software upgrading method based on TC397 microcontroller address mapping
CN107046600A (en) A kind of determination method and device of android system standard time
CN107590028B (en) Information processing method and server
CN110647455A (en) Storage device restart recording method and system
CN105898467A (en) Processing mode entering method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP02 Change in the address of a patent holder

Address after: 361000 room 1402, No. 39, xishanwei Road, phase III, software park, Xiamen, Fujian

Patentee after: XIAMEN JIXUN INTERNET OF THINGS TECHNOLOGY Co.,Ltd.

Address before: 361000 1504-2, No. 358, Chengyi street, phase III, software park, Xiamen, Fujian

Patentee before: XIAMEN JIXUN INTERNET OF THINGS TECHNOLOGY Co.,Ltd.

CP02 Change in the address of a patent holder