Program modification and upgrade trilogy: requirements, design, and implementation

Source: Internet
Author: User
Document directory
  • Scope of design changes caused by demand changes:
  • Implementation changes caused by design changes:
  • Implementation ideas:
  • 1. Read the code, understand the original implementation method, and record the points to be modified:
  • 2. implement initialization sequence changes:
  • 3. Access to parameters of pre-loaded stalls:
  • 4. Implement preload parameter reference:
  • 5. Implement new signals and slots:
  • 6. Implement shift status record:
You need to modify and upgrade the original program in the near future:

1. A group of data is sent to the serial port by pressing a button. The data received by the serial port is read, calculated, and displayed.

Now, when you press the next button, first send a group of data to the serial port, and then send a group of data after a period of time, then read the data received by the serial port and calculate and display it.

2. The original initialization sequence needs to be enriched and changed now. The new sequence has been preliminarily finalized, but there may be adjustment requirements later.

After a long term of thinking and writing, we have three ideas: the scope of design changes caused by demand changes:

1. parameters need to be added to the change of the transmission process, the parameter design framework needs to be added, and the business process is bound to be modified.

2. the initialization sequence is a small change and does not affect the main business logic framework. However, it is better if it can be configured externally. Let's talk about it later.

Implementation changes caused by design changes:

It is mainly about the implementation of business processes, and some variables need to be added for control parameters. Of course, it also involves accessing and referencing new parameters.

Considering the time urgency, implementation is the benchmark.

Implementation ideas:

1. First, the initialization sequence is adjusted and built-in. Parameter Extraction will be considered when adjustments are required in the future.

2. Add the parameters for gear stock preparation. XML

3. Implementation of parameter access for gear stock preparation.

4. Whether the parameter configuration of the backup gear is available.

5. Business process changes involve a. startup process; B. display data; C. timer switch; D. Timer count; E. transmission gear.

Implementation: 1. Read the code, understand the original implementation method, and record the places to be modified:

A. the initialization sequence needs to be changed. As it is not the main requirement, hard encoding is used for the time being. Initdevice ()

B. design the storage structure of pre-loaded parameters in XML format. Levelpre. XML, levelpreinverse. XML (levelprenormal. xml may be available in the future)

C. Implement the access function of the pre-loaded parameters. Cxmllevelpre, cxmllevelpreinverse, cleverpre, clevelinverse

D. Added pre-loaded slot signals and slots. Sendlevel (nlevel), sendlevelpre (nlevel)

E. Record the status phase of the position: ws_none in non-working phase, ws_pre in pre-loading phase, and ws_work in formal working phase

F. Data returned by the serial port during pre-loading is only displayed and is not involved in calculation. Disp ()

G. Change the switch logic. Timeout (), start (), sendleveldata (), sendlevelpredata (), and constructor.

2. implement initialization sequence changes:

Initialization is only performed once. Follow the steps to modify and add the original one by one.

3. Access to parameters of pre-loaded stalls:

Parameter Structure Design level_pre.xml :( 1 indicates that pre-loading is required, and 0 indicates no pre-loading is required: Some stalls are required, and some stalls are not required)

<? XML version = '1. 0' encoding = 'unicode '?>
<XML>
<Levels_normal>
<Level1 inverse = "1"/>
<Level2 inverse = "1"/>
<Level3 inverse = "1"/>
<Level4 inverse = "1"/>
<Level5 inverse = "1"/>
<Level6 inverse = "1"/>
<Level7 inverse = "1"/>
<Level8 inverse = "1"/>
<Level9 inverse = "1"/>
<Level10 inverse = "1"/>
<Level11 inverse = "1"/>
<Level12 inverse = "1"/>
<Level13 inverse = "1"/>
<Level14 inverse = "1"/>
<Level15 inverse = "1"/>
<Level16 inverse = "1"/>
<Level17 inverse = "1"/>
<Level18 inverse = "1"/>
<Level19 inverse = "1"/>
<Level20 inverse = "1"/>
</Levels_normal>
</XML>

Parameter Structure Design level_pre_inverse.xml:

<? XML version = '1. 0' encoding = 'unicode '?>
<XML>
<Levels_normal>
<Level1 currentvalue = "355" interval = "8000"/>
<Level2 currentvalue = "368" interval = "8000"/>
<Level3 currentvalue = "380" interval = "8000"/>
<Level4 currentvalue = "393" interval = "8000"/>
<Level5 currentvalue = "405" interval = "8000"/>
<Level6 currentvalue = "418" interval = "8000"/>
<Level7 currentvalue = "431" interval = "8000"/>
<Level8 currentvalue = "443" interval = "8000"/>
<Level9 currentvalue = "456" interval = "8000"/>
<Level10 currentvalue = "469" interval = "8000"/>
<Level11 currentvalue = "481" interval = "8000"/>
<Level12 currentvalue = "494" interval = "8000"/>
<Level13 currentvalue = "507" interval = "8000"/>
<Level14 currentvalue = "519" interval = "8000"/>
<Level15 currentvalue = "532" interval = "8000"/>
<Level16 currentvalue = "544" interval = "8000"/>
<Level17 currentvalue = "557" interval = "8000"/>
<Level18 currentvalue = "570" interval = "8000"/>
<Level19 currentvalue = "582" interval = "8000"/>
<Level20 currentvalue = "595" interval = "8000"/>
</Levels_normal>
<Param_memo>
<Currentvalue unit = "Ma" Memo = ""/>
<Interval unit = "Ms" Memo = ""/>
</Param_memo>
</XML>
The implementation is roughly as follows:
Cxmllevelpre

Cxmllevelpreinverse

Clevelpre

4. Implement preload parameter reference:

Clevelpre levelpres [level_count];

Clevel levepreinverses [level_count];
5. Implement new signals and slots:

Signals:

Void sendlevelpre (const int nlevel );
Slots:
Void sendlevelpredata (const int nlevel );

6. Implement shift status record:

Enum workstate {
Ws_none,
Ws_pre,
Ws_work,
};

Workstate m_wslevelstate;

7. Implement shift switching and shift status switching:

A. Switch to level 1 after running;

B. check whether there are pre-loaded files in the gear position;

C. If yes, send the sendlevelpre signal; otherwise, send the sendlevel signal;

D. If the duration of the gear is reached, determine whether the gear status is pre;

E. If yes, switch to the Work status. Otherwise, switch to the next position and continue step B until the next round is completed.

F. Determine whether another test is required;

G. If necessary, switch to step a. Otherwise, exit.

Note: The original switch position is not used as a separate function and needs to be extracted now.

8. Waiting for online debugging:

Wait.

Conclusion:

1. I hope to improve my skills on this basis.

2. You also need to consider how to synchronize files.

3. The record is simple and fragmented, just record it.

4. The upgrade route leads to the following: I have always drawn no height. I need to pay more attention to other people's discussions in the future.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.