Disclosure of Invention
The invention provides a token identification method and a system of STS (service standard specification) aiming at the problem that tokens cannot be identified by an electric meter due to human factors such as wrong token input sequence, no timely recharging and the like when a user recharges in a prepaid electric power system, and combining the characteristics of limited TID recording space stored by a prepaid meter and the like.
The token identification method of STS provided by the invention comprises the following steps:
under the initialization state of the ammeter, calculating an initial TID sliding window offset interval according to the relevant parameter setting of the sliding window;
after the ammeter is initialized, according to the initial TID sliding window offset interval, carrying out validity identification on the token input currently;
after the currently input token is verified to be the valid token, the key validity of the currently input token is judged according to the STS standard, if the key validity is verified, a preset TID sliding window offset mechanism is triggered, a TID sliding window offset interval of the next input token is obtained, and the TID of the valid token is stored in a corresponding TID storage area.
As an implementation manner, in the initialization state of the electric meter, the calculating an initial TID sliding window offset interval according to the relevant parameter setting for the sliding window includes the following steps:
step A: judging whether the ammeter is in an initialization state or not; if yes, the TID value TID of token of the current input electric meterC=TIDF,TIDFEntering step B and step C, wherein the TID is the TID minimum value of the token which can be identified but does not comprise the TID minimum value; if not, directly entering the step B and the step C;
and B: calculating TID sliding window lower limit TIDNE: comparing TIDsFAnd (TID)C-TIDN) The larger one is selected as TID lower limit TID of TID sliding windowNE(ii) a Wherein, TIDND, entering step D for the TID interval minutes of backward allowable deviation of the sliding window;
and C: calculating TID sliding window upper limit TIDPO:TIDPO=TIDC+TIDP(ii) a Determining TIDPOWhether or not to exceed 224If the boundary is not exceeded, the TID sliding window upper limit value is TIDPOWhether or notFor TID upper limit value TID of TID sliding windowPOAssigned value of 224-1; wherein, TIDPD, entering step D for the TID interval minutes of forward allowable offset of the sliding window;
step D: according to the TID sliding window lower limit TID calculated in the step BNEAnd step C, calculating the TID sliding window upper limit TIDPOAnd obtaining an initial TID sliding window offset interval.
As an implementation manner, after the electric meter is initialized, according to the initial TID sliding window offset interval, performing validity identification on the token input for the first time includes the following steps:
step E: judging whether the TID value of the currently input token is larger than a preset TID sliding window bottom value or not; if yes, entering step F; otherwise, ending the TID identification process and returning the result;
step F: judging whether the TID value of the token currently input falls into the initial TID sliding window offset interval or not, and entering the step G if the TID value of the token currently input falls into the initial TID sliding window offset interval; if the TID does not fall into the TID identification flow, the TID identification flow is ended and the result is returned;
step G: judging whether the TID of the currently input token is in a storage area of the ammeter, if so, ending the TID identification process and returning a result; and if the TID of the currently input token is not in the storage area of the electric meter, judging that the currently input token is an effective token.
As an embodiment, the token recognition method for STS of the present invention further includes the following steps:
and resetting the TID sliding window bottom value according to the maximum storage space of the electric meter recorded in the system and a preset new bottom value after the TID storage space in the storage area of the electric meter reaches the limit.
As an implementation manner, after TID storage space in the storage area of the electric meter reaches the limit, the TID sliding window bottom value is reset according to the maximum storage space of the electric meter recorded in the system and a preset new bottom value, further comprising the following steps:
step H: judging the size of the new bottom value and the original TID bottom value stored in the ammeter, and entering the step I if the new bottom value is larger than the original TID bottom value; otherwise, ending the reset flow;
step I: judging whether the new bottom value is smaller than the minimum TID stored in the TID storage area in the ammeter, if so, ending the resetting process; if not, entering step J;
step J: clearing all TID records which are stored in a TID storage area in the ammeter and are smaller than the new base value, and entering a step K;
step K: and setting the new bottom value as the TID sliding window bottom value in the current ammeter.
Correspondingly, the invention also provides a token identification system of the STS, which comprises a calculation module, an identification module and a storage module;
the calculation module is used for calculating an initial TID sliding window offset interval according to the relevant parameter setting of the sliding window in the state of the initialization of the ammeter;
the identification module is used for carrying out validity identification on the currently input token according to the initial TID sliding window offset interval after the ammeter is initialized;
and the storage module is used for judging the validity of the key of the currently input token according to the STS standard after verifying that the currently input token is the valid token, triggering a preset TID sliding window offset mechanism if the currently input token is valid, obtaining a TID sliding window offset interval of the next input token, and storing the TID of the valid token in a corresponding TID storage area.
As an implementation manner, the calculation module includes an initialization judgment unit, a sliding window lower limit value calculation unit, a sliding window upper limit value calculation unit, and an offset interval calculation unit;
the initialization judging unit is used for judging whether the ammeter is in an initialization state or not; if so, then the currentTID value TID of token of input electric meterC=TIDF,TIDFEntering a TID sliding window bottom value, a TID minimum value of the recognizable token, but not the TID minimum value, into a sliding window lower limit value calculating unit and a sliding window upper limit value calculating unit; if not, directly entering the sliding window lower limit value calculation unit and the sliding window upper limit value calculation unit;
the sliding window lower limit value calculating unit is used for calculating the TID sliding window lower limit value TIDNE: comparing TIDsFAnd (TID)C-TIDN) The larger one is selected as TID lower limit TID of TID sliding windowNE(ii) a Wherein, TIDNEntering TID interval minutes of backward allowable offset of the sliding window into the offset interval calculation unit;
the sliding window upper limit value calculating unit is used for calculating the TID sliding window upper limit value TIDPO:TIDPO=TIDC+TIDP(ii) a Determining TIDPOWhether or not to exceed 224If the boundary is not exceeded, the TID sliding window upper limit value is TIDPOOtherwise, the TID is set to the upper limit value TID of the TID sliding windowPOAssigned value of 224-1; wherein, TIDPEntering TID interval minutes for allowing the sliding window to shift forwards into the shift interval calculation unit;
the offset interval calculation unit is used for calculating the TID lower limit TID of the sliding window according to the TID lower limit TID calculated by the sliding window lower limit calculation unitNEAnd TID sliding window upper limit value TID calculated by the sliding window upper limit value calculating unitPOAnd obtaining an initial TID sliding window offset interval.
As an implementation manner, the identification module includes a first determination unit, a second determination unit and a third determination unit;
the first judging unit is used for judging whether the TID value of the token currently input is larger than a preset TID sliding window bottom value; if yes, entering a second judgment unit; otherwise, ending the TID identification process and returning the result;
the second judging unit is used for judging whether the TID value of the token currently input falls into the initial TID sliding window offset interval or not, and if the TID value of the token currently input falls into the initial TID sliding window offset interval, the third judging unit is started; if the TID does not fall into the TID identification flow, the TID identification flow is ended and the result is returned;
the third judging unit is used for judging whether the TID of the currently input token is in the storage area of the ammeter, if so, ending the TID identification process and returning a result; and if the TID of the currently input token is not in the storage area of the electric meter, judging that the currently input token is an effective token.
As an implementable embodiment, the token recognition system of the present invention further includes a floor resetting module;
and the bottom value resetting module is used for resetting the TID sliding window bottom value according to the maximum storage space of the electric meter recorded in the system and a preset new bottom value after the TID storage space in the storage area of the electric meter reaches the limit.
As an implementation manner, the floor value resetting module includes a fourth judging unit, a fifth judging unit, a clearing unit and a resetting unit;
the fourth judging unit is used for judging the size of the new bottom value and the original TID bottom value stored in the ammeter, and if the new bottom value is larger than the original TID bottom value, the fourth judging unit enters the fifth judging unit; otherwise, ending the reset flow;
the fifth judging unit is used for judging whether the new bottom value is smaller than the minimum TID stored in the TID storage area in the ammeter, and if so, the resetting process is ended; if not, entering the clearing unit;
the clearing unit is used for clearing all TID records which are stored in the TID storage area in the ammeter and are smaller than the new bottom value, and entering the resetting unit;
and the resetting unit is used for setting the new bottom value as the TID sliding window bottom value in the current ammeter.
Compared with the prior art, the invention has the beneficial effects that:
according to the token identification method and system of the STS, an initial TID sliding window offset interval is calculated according to the relevant parameter setting of the sliding window in the state of the initialization of the ammeter; then after the ammeter is initialized, according to the initial TID sliding window offset interval, carrying out validity identification on the currently input token; and finally, after the currently input token is verified to be the effective token, judging the key effectiveness of the currently input token according to the STS standard, if the key effectiveness is verified, triggering a preset TID sliding window offset mechanism to obtain a TID sliding window offset interval of the next input token, and storing the TID of the effective token in a corresponding TID storage area. And subsequently, sequentially identifying the input token according to the TID sliding window offset interval obtained last time.
The token identification method and system for STS provided by the invention are simple and feasible, are accurate in identification, effectively solve the problem of accurate identification of the validity of the token by an electric meter, simultaneously solve the problem of accidental expiration of the normal and effective token, limit the effective time period of user recharging, and provide a technical basis for power recharging management of a prepaid power system.
Detailed Description
The above and further features and advantages of the present invention will be apparent from the following, complete description of the invention, taken in conjunction with the accompanying drawings, wherein the described embodiments are merely some, but not all embodiments of the invention.
The Token identification method and system of STS provided by the invention solve the problem that the normal and effective Token can not be identified by the electric meter due to the user operation by setting the sliding window judgment mechanism and the bottom value resetting operation and combining the characteristic of storing TID of the Token (namely the Token) in the electric meter, and provide technical basis and data source for the electricity recharging management and analysis of the prepayment electric system indirectly because the bottom value of the sliding window needs to be set by important units such as electricity selling points and the like.
Before the beginning of the life cycle of the electric meter, the register of the electric meter is equipped with a corresponding register for storing the following parameters:
list TIDL[M]: storing all TIDs of Token input to the electric meter in the electric meter, wherein M is the total number of storable TID records;
TIDC: TID of Token of the current input electric meter;
TIDF: a TID floor value of the sliding window, defining the minimum value of the TID of Token that can be identified, but not including this value;
TIDNE: a sliding window lower limit TID value;
TIDPO: a sliding window upper limit TID value;
TIDN: sliding window backward allows for offset TID interval minutes;
TIDP: sliding the window forward to allow for the number of TID intervals minutes of offset;
TIDFvalue, TIDNValue and TIDPThe value can be set according to actual conditions.
With the acceptance of Token by the electric meter identification, the electric meter stores the TID of Token in a storage area of the electric meter, and the TID in a corresponding register of the electric meterFValue, TIDNEValue, TIDPOValue, TIDCThe values are also changed accordingly. The calculation formulas of the upper and lower limit values of the sliding window deviation are respectively as follows:
TIDPO=TIDC+TIDP
TIDNE=TIDC-TIDN
in general, the upper TID value TID of the sliding windowPOFor the current TID value and TIDPThe sum of the values; lower limit TID value TID of sliding windowNEFor the current TID value and TIDNThe difference in value.
For example: suppose TIDCIs 100, TIDPTID of 20, thenPO100+ 20-120; TIDNTID of 30NEIs 100-30 ═ 70.
Referring to fig. 1a to 1e, five states of the electric meter during one reference time from the preparation of the electric meter access system to start service to the normal operation of the electric meter to the operation of the electric meter close to the next reference time are enumerated, wherein the electric meter is operated at 2014/1/100: 00 is reference time, 2016/1/100: base value TID of 00F(TIDF1051200), the TID interval minutes allowed by the sliding window to move forwards and backwards are 131040(3 months) and 87840(2 months), and the electric meter can store the TID interval minutesUp to 50 TID records.
According to the method, firstly, TID domain of token is used for calculating the upper and lower limits of the sliding window offset, so that a TID sliding window offset interval is obtained, and judgment conditions are provided for TID identification of the ammeter.
Referring to fig. 2, the token identification method for STS provided in the embodiment of the present invention includes the following steps:
s100, in an electric meter initialization state, calculating an initial TID sliding window offset interval according to the relevant parameter setting of the sliding window;
s200, after the ammeter is initialized, according to the initial TID sliding window offset interval, carrying out validity identification on the currently input token;
s300, after the currently input token is verified to be the valid token, the key validity of the currently input token is judged according to the STS standard, if the key validity is valid, a preset TID sliding window offset mechanism is triggered, a TID sliding window offset interval of the next input token is obtained, and the TID of the valid token is stored in a corresponding TID storage area.
The following is a detailed description of the above examples:
when the ammeter is in an initialization state, the related parameters of the sliding window need to be set, and an initial TID sliding window offset interval is obtained. In state one of fig. 1a the meter is in the initialized state and the TID storage area is empty.
The initial TID sliding window offset range calculation for the meter is shown in figure 3. Firstly, judging whether the electric meter is in an initialized state, if so, judging that the current TID is in the initialized stateC=TIDF(ii) a Otherwise TIDCThe TID of the currently received Token. Then calculating the TID sliding window lower limit TIDNEIs TIDNE=TIDC-TIDN. Determining TIDFWhether to compare TIDNELarge if TIDF>TIDNEThen TIDFPreferentially as the lower limit value of the sliding window; otherwise, the lower limit value of the sliding window is TIDNE. Then, calculateTID sliding window upper limit TIDPOIs TIDPO=TIDC+TIDP. Determining TIDPOWhether or not to exceed 224If the boundary is not exceeded, the TID sliding window upper limit value is TIDPOOtherwise, the TID sliding window upper limit value is 224-1. According to the parameter values in the above procedures and examples, the initial TID sliding window offset interval is obtained to be between 1051200 and 1182240.
Here, it should be noted that, according to the STS standard transmission specification, the length of TID is 24bits, and the maximum value is 224-1 (when 24bits are all 1), if 24bits are exceeded, it means that the whole STS system (electricity meter, electricity selling system, key management center, etc.) enters the next life cycle.
Next, the meter initializes to normal service and begins accepting the first token. The electric meter firstly identifies Token and determines that Token is effective, otherwise, the electric meter cannot be triggered to carry out TID sliding window offset operation.
As shown in FIG. 4, the TID for identifying token is first determined whether the TID is larger than the TID set as the bottom value in the tableF. If yes, carrying out the next step; otherwise, ending the TID identification process and returning the result. And then, judging whether the TID of token falls within the TID sliding window offset range. If the TID falls into the offset range of the sliding window, carrying out the next step; otherwise, ending the TID identification process and returning the result. Next, it is determined whether the TID of token has been used. If the TID is stored in the storage area of the electric meter, the Token is used, the TID identification process is ended, and a result is returned; if this TID record does not exist in the meter TID memory area, the TID is unused. And finally, judging the token to be an effective token.
And triggering the TID sliding window offset mechanism after the token key is effectively judged according to the STS standard specification. Thus, assuming that the TID of the first token is 1051202, the meter determines from the above description that this token is a valid token and that the range interval for obtaining the next acceptable token TID is between 1051200 and 1182242, as shown in state two of FIG. 1 b. Finally, the electric meter stores the TID in the corresponding TID storage area.
When the user recharges a plurality of tokens at a time, the user can input the tokens into the meter without depending on the order of token generation when the plurality of tokens are input into the meter. The token identification process (see fig. 3) and the TID sliding window offset calculation process (see fig. 2) are performed once every time a token meter is input. As the token TID value input into the table becomes larger, according to TID sliding window offset mechanism, when the TID value of token is received (assuming TID value is 1237840) and the TID of the lower limit TID of the sliding windowNIs greater than the base TIDFI.e. TIDNE>TIDFAt the moment, the range of the TID sliding window is TIDNETo TIDPOIn the interval 1150000-1368880 as shown in state III of FIG. 1 c. The meter then stores the TID of token in the TID storage area.
Along with the normal operation of the electric meter, the TID storage space of the electric meter reaches the limit after the token is received for a certain time, and the electricity selling system needs to reset the bottom value TID for the electric meter according to the maximum storage space of the electric meter recorded in the system when a user purchases electricity for the next time (or earlier, according to the TID storage space of the electric meter)FThe method and the device can prevent the electric meter from automatically replacing the oldest TID in the storage area with the TID of the current token when the token is identified by the electric meter due to insufficient storage space, and the replaced token can be reused. And after the bottom value of the electric meter is reset, the electricity selling point sells electricity again. Assume a new floor TIDFTo 1237840, the electricity vending system sends a bottom TIDFResetting the command and the specific parameters to the ammeter, and starting to execute the TID after the ammeter receives the command and the dataFAnd (4) resetting operation. The specific operation process is shown in fig. 5:
step 1: determine new bottom value TIDFAnd the TID bottom value of the electric meter. If new TIDFIf the bottom value is larger than the bottom value in the ammeter, the next bottom value judgment is carried out; otherwise, the new bottom value is invalid, and the resetting process is ended to return information.
Step 2: and judging whether the new bottom value is smaller than the smallest TID in the TID storage area in the table. If so, the new bottom value is invalid, and the resetting process is ended to return information; if not, the new bottom value is indicated to be valid and the next step is carried out.
And 3, step 3: clearing newer TID in tableFSmall (including and new TID)FEqual value) to provide space for subsequent token TID storage.
And 4, step 4: ammeter resets background TIDF。
And 5, step 5: determining TIDFWith the current TIDCSize. When TIDF>TIDCThen TIDC=TIDF(ii) a Otherwise no operation is performed.
And 6, step 6: the specific flow of calculating the sliding window offset interval after resetting the floor value is shown in fig. 5, and the steps are similar to those of calculating the sliding window offset interval before.
And 7, step 7: and finishing the process of resetting the bottom value of the electric meter after the calculation of the sliding window deviation interval is finished, and enabling the electric meter to enter a normal service mode.
The electric meter finishes the whole bottom value TIDFAfter resetting, as shown in state four of fig. 1d, there will be space in the TID storage area for continuously storing the valid TID after the TID is stored, which provides space for receiving the TID of token after the electric meter is stored. When the next TID record of the electric meter is full, the electricity selling point again requires the electric meter to execute the operation of resetting the TID sliding window bottom value. Before the meter is normally operated to reach the next STS reference time, the electricity point may need to perform multiple bottom value resets on the meter to ensure that there is enough space in the table storage area to store the TID of token to support the normal execution of the determination mechanism. Therefore, the electricity selling system needs to record the current bottom value of the electricity meter and the recharging record corresponding to the current bottom value to determine the next bottom value, and the record can be used for the power consumption recharging analysis and management of units such as a power bureau and the like.
When the next reference time is reached, according to the sliding window offset mechanism, the TID sliding window offsets the upper limit TIDPOWill exceed 224A boundary. When the calculated sliding window upper limit TID is obtained as shown in state five of FIG. 1ePOIf the threshold value is larger than the boundary value, the inter-region upper limit of the TID sliding window is determinedValue TIDPO16777215, the recognizable token TID range is 16689374 ~ 16777215.
Based on the same inventive concept, the token identification system of STS provided by the embodiment of the invention comprises a calculation module, an identification module and a storage module; the calculation module is used for calculating an initial TID sliding window offset interval according to the relevant parameter setting of the sliding window in the state of the initialization of the ammeter; the identification module is used for carrying out validity identification on the currently input token according to the initial TID sliding window offset interval after the ammeter is initialized; and the storage module is used for judging the validity of the key of the currently input token according to the STS standard after verifying that the currently input token is the valid token, triggering a preset TID sliding window offset mechanism if the currently input token is valid, obtaining a TID sliding window offset interval of the next input token, and storing the TID of the valid token in a corresponding TID storage area.
As an implementation manner, the calculation module includes an initialization judgment unit, a sliding window lower limit value calculation unit, a sliding window upper limit value calculation unit and an offset interval calculation unit;
the initialization judging unit is used for judging whether the ammeter is in an initialization state or not; if yes, the TID value TID of token of the current input electric meterC=TIDF,TIDFEntering a sliding window lower limit value calculating unit and a sliding window upper limit value calculating unit, wherein the TID is a TID minimum value of the token which can be identified, but the TID minimum value does not comprise the TID minimum value; if not, directly entering a sliding window lower limit value calculation unit and a sliding window upper limit value calculation unit;
a sliding window lower limit value calculation unit for calculating TID sliding window lower limit value TIDNE: comparing TIDsFAnd (TID)C-TIDN) The larger one is selected as TID lower limit TID of TID sliding windowNE(ii) a Wherein, TIDNEntering a deviation interval calculation unit for TID interval minutes of backward deviation allowance of the sliding window;
a sliding window upper limit value calculating unit usingIn the calculation of TID sliding window upper limit TIDPO:TIDPO=TIDC+TIDP(ii) a Determining TIDPOWhether or not to exceed 224If the boundary is not exceeded, the TID sliding window upper limit value is TIDPOOtherwise, the TID is set to the upper limit value TID of the TID sliding windowPOAssigned value of 224-1; wherein, TIDPEntering a deviation interval calculation unit for TID interval minutes of forward deviation allowance of the sliding window;
an offset interval calculation unit for calculating TID lower limit TID of the sliding window based on the TID lower limit calculated by the sliding window lower limit calculation unitNETID sliding window upper limit value TID calculated by sliding window upper limit value calculating unitPOAnd obtaining an initial TID sliding window offset interval.
As an implementation manner, the identification module includes a first determination unit, a second determination unit and a third determination unit; the first judgment unit is used for judging whether the TID value of the token currently input is larger than a preset TID sliding window bottom value; if yes, entering a second judgment unit; otherwise, ending the TID identification process and returning the result; the second judgment unit is used for judging whether the TID value of the token currently input falls into the initial TID sliding window offset interval or not, and if the TID value of the token currently input falls into the initial TID sliding window offset interval, the third judgment unit is started; if the TID does not fall into the TID identification flow, the TID identification flow is ended and the result is returned; a third judging unit, configured to judge whether the TID of the token currently input is in the storage area of the electric meter, and if yes, end the TID identification process and return a result; and if the TID of the currently input token is not in the storage area of the electric meter, judging that the currently input token is an effective token.
As an implementable embodiment, the token recognition system of the present invention further includes a floor resetting module; and the bottom value resetting module is used for resetting the TID sliding window bottom value according to the maximum storage space of the electric meter recorded in the system and a preset new bottom value after the TID storage space in the storage area of the electric meter reaches the limit.
As an implementation manner, the floor value resetting module includes a fourth judging unit, a fifth judging unit, a clearing unit and a resetting unit; the fourth judging unit is used for judging the size of the new bottom value and the original TID bottom value stored in the ammeter, and if the new bottom value is larger than the original TID bottom value, the fifth judging unit is started; otherwise, ending the reset flow; a fifth judging unit, configured to judge whether the new bottom value is smaller than the minimum TID stored in the TID storage area in the electric meter, and if so, end the reset process; if not, entering a clearing unit; the clearing unit is used for clearing all TID records which are stored in the TID storage area in the ammeter and are smaller than the new base value, and entering the resetting unit; and the resetting unit is used for setting the new bottom value as the TID sliding window bottom value in the current ammeter.
The token identification system of STS provided by the embodiment of the present invention is the same inventive concept as the token identification method, and the inventive principle is the same, and the implementation process thereof can be implemented by referring to the method, which is not described in detail herein.
The invention solves the problem of accurate identification of token validity by the electric meter, also solves the problem of accidental expiration of a normal and effective token, can limit the effective time period for user recharging, and provides a technical basis for the electricity recharging management of a prepaid electric power system.
The above embodiments are provided to further explain the objects, technical solutions and advantages of the present invention in detail, and it should be understood that the above embodiments are only examples of the present invention and are not intended to limit the scope of the present invention. It should be understood that any modifications, equivalents, improvements and the like, which come within the spirit and principle of the invention, may occur to those skilled in the art and are intended to be included within the scope of the invention.