EE308FZ_Lab1_2: Development Blog
Development Blog
To see the whole version, go to the End and see HTML version on Github.com.
Contents
目录
- Development Blog
- Contents
- PSP Form
- Ideas of Problem-solving
- Design and Implement Processes
- Code Description
- main.py
- common.py
- specific_c.py
- Unit Test
- Screenshots and Description
- Test Data
- Result
- Coverage Optimization
- Performance Testing
- Summary
- End
PSP Form
| Process Stages | Estimated Time(min) | Actual Time(min) |
|---|---|---|
| Analyze Problem | 10 | 5 |
| Planning Development | 10 | 5 |
| Modelling Project | 30 | 15 |
| Design Basic Framework | 20 | 20 |
| Design & Develop Assistant Tools | 30 | 120 |
| Review Assistant Tools | 10 | 30 |
| Develop Prototype working on 1st Level | 30 | 40 |
| Review & Fortify Program | 10 | 30 |
| Design 2nd Level Program | 30 | 40 |
| Develop & Review 2nd Level Program | 30 | 200 |
| Design 3rd Level Program | 30 | 20 |
| Design 4th Level Program | 40 | 80 |
| Develop & Review 3rd & 4th Level Program | 80 | 200 |
| Refine Details | 20 | 5 |
| Final Test | 20 | 10 |
| Reporting | 40 | 70 |
| Summarizing | 30 | 10 |
| Total Time | 470 | 900 |
Ideas of Problem-solving
Problem is given in four level and that's good for Incremental model.
Idea of develop solution:
- Break problem into parts of tasks and queue them.
- Think sub solutions for tasks.
- Code and implement the solutions.
- Test
Design and Implement Processes
Solution steps:
- Determine file type and check
- Read corresponding keywords of the language
- Read the file content
- Solve for 1st level
- Solve for 2nd level
- Solve for 3rd&4th level
graph TD
File_Validation --> Read_Keywords --> Read_File_Content
Read_File_Content --beginning_of_running_any_solution--> sol.1
Read_File_Content -.-> 1st_Level
Read_File_Content -.-> 2nd_Level
Read_File_Content -.-> 3rd_Level
Read_File_Content -.-> 4th_Level
1st_Level --> sol.1
2nd_Level --> sol.2
3rd_Level --> sol.3
4th_Level --> sol.3
sol.1 --> Count_Keywords
Count_Keywords -- generate info--> sol.1
Count_Keywords --> Give_Answer_of_1st_Level
sol.1 --give info--> sol.2
sol.1 --give info--> sol.3
sol.2 --> Iterate_and_Calculate_for_sol.2
sol.3 --> Iterate_and_Calculate_for_sol.3
Iterate_and_Calculate_for_sol.2 -.-> Give_Answers_of_2nd_Level
Iterate_and_Calculate_for_sol.3 -.-> Give_Answers_of_3rd&4th_Level
Iterate_and_Calculate_for_sol.2 --> Function2
Function2 --find 'switch', iterate--> Function2
Function2 --> Count_'case'
Count_'case' --> Give_Answers_of_2nd_Level
Iterate_and_Calculate_for_sol.3 --> Function3
Function3 --find 'if/else', iterate--> Function3
Function3 --> Count_'else_if/else'
Count_'else_if/else' --> Give_Answers_of_3rd&4th_Level
Give_Answer_of_1st_Level --collect--> Completed_Answer
Give_Answers_of_2nd_Level --collect--> Completed_Answer
Give_Answers_of_3rd&4th_Level --collect--> Completed_Answer
Code Description
My project used many to assist the development process. But those do nothing with problem-solving, so I will not explain them here.
Here is key codes and their explanation:
main.py
This is the entrance of whole program. This file contains $sol.1$ and leads to the rest.
# Open File Preparation
f = None
try:
# get the file name
fileName = sys.argv[1]
except IndexError as ie:
estr = OINFOHEADER + f'No file input, no first parameter given. {ie}'
raise IndexError(estr)
# get the program directory
programDir = osp.dirname(sys.argv[0])
# Check ext
fileExt: common.ExtClass = common.ExtClass()
# determine ext
fileExt.extSelect(fileName)
# open file
try:
f = open(fileName)
except FileNotFoundError as fe:
estr = OINFOHEADER + f'{fe}'
raise FileNotFoundError(estr)
# read keywords
keys = []
try:
with open(osp.join(programDir, f'keywords_{fileExt.ext}.txt')) as fkey:
# with open(programDir + dirsep + f'keywords_{fileExt.ext}.txt') as fkey:
t = fkey.read()
keys = t.split()
except FileNotFoundError as fe:
estr = OINFOHEADER + f'{fe}'
raise FileNotFoundError(estr)
# read file data
strs = f.readlines()
# work of 1st level
keycnt, moreinfo = common.countKw(keys, strs)
print('total num: ', keycnt)
# language-specific part of solution's entrance (of .c file)
speMDic = {
'c': specific_c,
'cpp': specific_cpp
}
speMDic[fileExt.ext].entrance(keys, strs, moreinfo)
common.py
This file contains the common parts of codes, i.e. the public codes for all modules.
# Class and method for storing and determining ext
class ExtClass():
ext = None
exti = 0
mode: DevMode = sampleModeCommon
def __init__(self, mode: DevMode=None):
...
def extSelect(self, fileName:str=''):
# debug code
...
# set ext
t1 = fileName.rsplit(sep='.', maxsplit=3)
self.ext = t1[-1]
...
# This function count keywords in strings from the file.
def countKw(keys, strs:list):
...
for i in strs:
cnt1 = 0
for j in keys:
i: str
a = k = 0
while True:
a = i.find(j,a)
if a == -1:
break
a += keylength[j]
if i[a].isalpha() is False:
# found a keyword here
k += 1
# pairs of location prepared for more operation
p = [idi, a - keylength[j], j]
locations.append(p)
cnt1 += k
cnt2 += cnt1
idi += 1
return cnt2, locations
specific_c.py
Contains part of solutions for c language.
# addon entrance
def entrance(pkeys, pstrs, pmoreinfo=None):
...
locations = extractWordsBraces(strs, wordLocation)
# process switch-case
locations_SwCsBraces = extractSwCsBraces(locations)
SwCnt_Group = countSwCs(locations_SwCsBraces)
# output SwCs
print(f'switch num: ', SwCnt_Group.__len__())
print('case num: ', end='')
for i in SwCnt_Group:
print(i, end=' ')
print('')
# process if-else, if-elseif-else
# these codes are only designed for cases with entire braces attached to keywords.
locations_IfEsBraces = extractIfEsBraces(locations)
cnt_IfEs, cnt_IfEsifEs = countIfEs(locations_IfEsBraces)
cntIFES = [cnt_IfEs, cnt_IfEsifEs]
# output IFES
print(f'if-else num: ', cnt_IfEs)
print(f'if-elseif-else num: ', cnt_IfEsifEs)
# This function count 'switch's and each group's 'case's. Support nested structure.
def countSwCs(plocations_SwCsBraces):
...
i = 0
while i < length:
# find a 'switch', do iteration
if plocations_SwCsBraces[i][2]=='switch':
...
interval = [i, endBrace+1]
intervals.append(interval)
# iterate
CsCntItr = countSwCs(plocations_SwCsBraces[i+1:endBrace+1])
SwCnt_Group.extend(CsCntItr)
# print(SwCnt_Group)
i = endBrace
i += 1
...
# count 'case's of given strings
i = 0
while i < length:
...
if plocations_SwCsBraces[i][2]=='case':
CsCnt += 1
i += 1
if CsCnt!=0:
SwCnt_Group.append(CsCnt)
return SwCnt_Group
# This function figures the answers of sol.3. Support nested structure.
def countIfEs(plocations_IfEsBraces):
...
while i < length:
# find a/an 'if'/'else', do iteration
if plocations_IfEsBraces[i][2] == 'if' or \
(plocations_IfEsBraces[i][2] == 'else' and plocations_IfEsBraces[i+1 if i+1 <length else i][2] != 'if'):
...
interval = [i + 2, endBrace]
intervals.append(interval)
# iterate
retv = countIfEs(plocations_IfEsBraces[i + 1:endBrace + 1])
...
cnt_IfEs += retv[0]
cnt_IfEsifEs += retv[1]
i = endBrace
i += 1
...
# count cases of 'if-else' and 'if-elseif-else' of given strings
i = 0
tlength = tpifesloclist.__len__()
while i < tlength:
if tpifesloclist[i][2] == 'else':
if tpifesloclist[i+1 if i+1<tlength else i][2] == 'if':
cnt_IfEsifEs += 1
while i < tlength:
if tpifesloclist[i][2] == 'else' and tpifesloclist[i+1 if i+1<tlength else i][2] != 'if':
break
i += 1
elif tpifesloclist[i+1 if i+1<tlength else i][2] == '{':
cnt_IfEs += 1
i += 1
cntIFES = [cnt_IfEs, cnt_IfEsifEs]
return cntIFES
Unit Test
my_unit_test.py
Screenshots and Description
Test Data
Test file, $testfile.c$, is copied from website. See the website at the End.
Result
Picture shown below tells that of 4th level, i.e. the ultimate requirement. It goes to expectation.


Coverage Optimization
Comment useless codes.

$81$% ->$82$%
Performance Testing

Summary
In this program, I used lots of new knowledge. Software Engineering is truly a systematic engineering. Methodology is really important.
End
| The Link Your Class | https://bbs.csdn.net/forums/MUEE308FZU202201 |
|---|---|
| The Link of Requirement of This Assignment | https://bbs.csdn.net/topics/608734907 |
| The Aim of This Assignment | Note the development processes. |
| MU STU ID and FZU STU ID | 20123850_832001217 |
Project on Github.com: https://github.com/LiuJiewenTT/ee308fz_lab1
URL on github.com of this passage(download): https://liujiewentt.github.io/ee308fz_lab1/development%20blog.md
URL on github.com of this passage(view with Github md): https://github.com/LiuJiewenTT/ee308fz_lab1/tree/main/development%20blog.md
URL on github.com of this passage(view as html): https://liujiewentt.github.io/ee308fz_lab1/development%20blog.html
URL on csdn.net of this passage(view as html): https://bbs.csdn.net/topics/608838406
相关推荐
基于混合储能协调控制的三相并网逆变系统设计【附说明文档】
内容概要:本文围绕“基于混合储能协调控制的三相并网逆变系统设计”展开,系统阐述了蓄电池与飞轮储能等混合储能系统在微电网中的协同控制策略。研究涵盖三相并网逆变器的能量管理、SOC(荷电状态)恒压恒流充放电控制、PQ控制与双闭环控制等核心技术,并基于Matlab/Simulink仿真平台实现了系统建模与动态仿真验证。文中深入探讨了飞轮储能系统的机侧PQ控制与网侧变流器的恒压双闭环控制,分析了微电网在调频调峰、功率协同分配等方面的运行特性,强调多能源间的协调优化与系统的快速动态响应能力,旨在提升微电网的运行稳定性、电能质量及能源利用效率。; 适合人群:具备电力电子、自动化或电气工程等相关专业背景,从事新能源发电、微电网控制、储能系统集成与优化等领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①深入研究混合储能系统在微电网中的协调控制机制与能量管理策略;②掌握三相并网逆变器的建模、控制算法设计及Matlab/Simulink仿真方法;③实现储能系统的高效充放电管理与并网功率精确控制;④为学术论文撰写、科研课题申报、工程项目开发或实验复现提供完整的技术方案与参考实例。; 阅读建议:建议结合所提供的仿真模型、说明文档及参考文献,按照系统架构从单元控制到整体协调的顺序分模块学习,重点关注各控制策略的设计原理、参数整定方法与协同逻辑。推荐在Matlab环境中动手复现仿真,通过调整参数和工况来观察系统响应,以深化对理论知识的理解和工程应用能力的掌握。
科技中介服务机构在服务企业时,如何通过平台降低服务门槛和操作复杂度?.docx
科技中介服务机构在服务企业时,如何通过平台降低服务门槛和操作复杂度?
运维管理基于Hyperfilelens的Docker Compose业务系统备份恢复:机房设备更换场景下的数据迁移与验证方案设计
内容概要:本文介绍了在机房存储设备更换及固件升级背景下,通过 Hyperfilelens 实现多套 Docker Compose 部署的业务系统备份与恢复的全过程。文章围绕备份迁移的实际操作,详细阐述了从主机接入、备份路径选择、策略配置、恢复执行到业务验证的七个关键步骤,并结合截图说明各环节的操作要点。特别强调了不仅要完成数据备份与恢复,还需核对目录结构、服务启动状态和业务功能可用性,确保迁移后系统完整可用。最终总结了 Hyperfilelens 在集中管理保护对象、制定备份策略、明确恢复目标和提供可核查记录方面的核心价值,倡导将备份作为常态化运维机制而非临时应急措施。; 适合人群:从事运维、系统管理及相关技术岗位,具备一定 Docker 和服务器管理经验的技术人员,尤其是面临机房设备更新或系统迁移任务的团队成员。; 使用场景及目标:①解决老旧存储设备更换过程中的业务系统平滑迁移问题;②实现基于 Docker Compose 架构的应用数据可靠备份与异机恢复;③建立可复用的备份恢复流程,提升运维自动化与可靠性。; 阅读建议:建议结合文中提到的平台界面和操作命令逐步实践,重点关注备份范围确认、一致性保护、恢复路径核对及业务端到端验证,避免仅依赖工具状态而忽视实际业务可用性。
chromedriver-mac-arm64-158.0.8127.18(Beta).zip
chromedriver-mac-arm64-158.0.8127.18(Beta).zip
政府科技管理者在推动区域科技成果转化时,如何实现科技成果与产业需求的精准对接?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。


