|
|
import matlab.engine
|
|
|
import os
|
|
|
|
|
|
eng = matlab.engine.start_matlab()
|
|
|
|
|
|
modelName = 'sat9_new'
|
|
|
objectName = 'Solar panel1'
|
|
|
|
|
|
# 参数初始化
|
|
|
eng.eval("initial_data_new()", nargout=0)
|
|
|
|
|
|
# 从input.txt中读取参数
|
|
|
with open('input.txt', 'r') as file:
|
|
|
lines = file.readlines()
|
|
|
work_mode_param, maneuverYN_param = lines[1].strip().split(' ')
|
|
|
work_mode_param = int(work_mode_param)
|
|
|
maneuverYN_param = int(maneuverYN_param)
|
|
|
|
|
|
# 帆板工作模式
|
|
|
work_mode_list = ["1:帆板锁定模式", "2:正常跟踪模式", "3:快速捕获模式", "4:仅+Y帆板驱动", "5:仅-Y帆板驱动"]
|
|
|
work_mode = work_mode_list[work_mode_param]
|
|
|
maneuverYNList = ['on', 'off']
|
|
|
maneuverYN = maneuverYNList[maneuverYN_param]
|
|
|
|
|
|
# 加载初始化变量
|
|
|
eng.eval("load initial_data.mat", nargout=0)
|
|
|
|
|
|
# 加载模型
|
|
|
eng.eval("model = '{}'".format(modelName), nargout=0)
|
|
|
eng.eval("load_system(model)", nargout=0)
|
|
|
|
|
|
# 设置模型参数
|
|
|
eng.eval("set_param('sat9_new/Solar panel1', 'work_mode', '{}')".format(work_mode), nargout=0)
|
|
|
eng.eval("set_param('sat9_new/Solar panel1', 'maneuverYN', '{}')".format(maneuverYN), nargout=0)
|
|
|
# eng.set_param(modelName + '/' + objectName + '/work_mode', 'Value', '1:帆板锁定模式', nargout=0)
|
|
|
# eng.set_param(modelName + '/' + objectName, 'maneuverYN', 'on')
|
|
|
|
|
|
# 执行模型
|
|
|
eng.sim(modelName)
|
|
|
|
|
|
# 保存结果
|
|
|
eng.saveResult(nargout=0)
|
|
|
|
|
|
# 结束
|
|
|
eng.quit()
|