本文整理汇总了Python中JSBSim_utils.CreateFDM.get_property_manager方法的典型用法代码示例。如果您正苦于以下问题:Python CreateFDM.get_property_manager方法的具体用法?Python CreateFDM.get_property_manager怎么用?Python CreateFDM.get_property_manager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSBSim_utils.CreateFDM
的用法示例。
在下文中一共展示了CreateFDM.get_property_manager方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testFunctionWithIndexedProps
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import get_property_manager [as 别名]
def testFunctionWithIndexedProps(self):
tree = et.parse(self.sandbox.path_to_jsbsim_file('engine',
'eng_PegasusXc.xml'))
# Define the function starter-max-power-W as a 'post' function
root = tree.getroot()
startPowFunc_tag = root.find("function/[@name='propulsion/engine[#]/starter-max-power-W']")
startPowFunc_tag.attrib['type']='post'
tree.write('eng_PegasusXc.xml')
# Copy the propeller file.
shutil.copy(self.sandbox.path_to_jsbsim_file('engine', 'prop_deHavilland5000.xml'),
'.')
fdm = CreateFDM(self.sandbox)
fdm.set_engine_path('.')
fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts',
'Short_S23_1.xml'))
fdm.run_ic()
pm = fdm.get_property_manager()
self.assertTrue(pm.hasNode('propulsion/engine[0]/starter-max-power-W'))
self.assertTrue(pm.hasNode('propulsion/engine[1]/starter-max-power-W'))
self.assertTrue(pm.hasNode('propulsion/engine[2]/starter-max-power-W'))
self.assertTrue(pm.hasNode('propulsion/engine[3]/starter-max-power-W'))
while fdm.run():
rpm = [fdm['propulsion/engine[0]/engine-rpm'],
fdm['propulsion/engine[1]/engine-rpm'],
fdm['propulsion/engine[2]/engine-rpm'],
fdm['propulsion/engine[3]/engine-rpm']]
for i in range(4):
maxPower = max(0.0, 1.0-rpm[i]/400)*498.941*0.10471976*rpm[i]
self.assertAlmostEqual(fdm['propulsion/engine[%d]/starter-max-power-W' % (i,)],
maxPower)
示例2: testEnginePowerVC
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import get_property_manager [as 别名]
def testEnginePowerVC(self):
fdm = CreateFDM(self.sandbox)
fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts',
'L4102.xml'))
fdm.run_ic()
pm = fdm.get_property_manager()
self.assertTrue(pm.hasNode('propulsion/engine[0]/EnginePowerVC'))
self.assertTrue(pm.hasNode('propulsion/engine[1]/EnginePowerVC'))
while fdm.run():
self.assertAlmostEqual(fdm['propulsion/engine[0]/EnginePowerVC'],
fdm['propulsion/engine[1]/EnginePowerVC'])
示例3: steerType
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import get_property_manager [as 别名]
def steerType(self, hasSteerPosDeg, hasSteeringAngle, hasCastered):
self.tree.write(self.sandbox('aircraft', self.aircraft_name,
self.aircraft_name+'.xml'))
fdm = CreateFDM(self.sandbox)
fdm.set_aircraft_path('aircraft')
fdm.load_script(self.script_path)
fdm.run_ic()
pm = fdm.get_property_manager()
self.assertTrue(pm.hasNode('fcs/steer-pos-deg') == hasSteerPosDeg)
self.assertTrue(pm.hasNode('gear/unit/steering-angle-deg')
== hasSteeringAngle)
self.assertTrue(pm.hasNode('gear/unit/castered') == hasCastered)
return fdm
示例4: testTableWithIndexedVars
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import get_property_manager [as 别名]
def testTableWithIndexedVars(self):
tree = et.parse(self.sandbox.path_to_jsbsim_file('engine',
'eng_PegasusXc.xml'))
# Define the function starter-max-power-W as a 'post' function
root = tree.getroot()
startPowFunc_tag = root.find("function/[@name='propulsion/engine[#]/starter-max-power-W']")
startPowFunc_tag.attrib['type']='post'
max_tag = startPowFunc_tag.find('product/max')
diff_tag = max_tag.find('difference')
max_tag.remove(diff_tag)
table_tag = et.SubElement(max_tag,'table')
table_tag.attrib['name']='propulsion/engine[#]/starter-tabular-data'
indepVar_tag = et.SubElement(table_tag, 'independentVar')
indepVar_tag.attrib['lookup']='row'
indepVar_tag.text = 'propulsion/engine[#]/engine-rpm'
tData_tag = et.SubElement(table_tag, 'tableData')
tData_tag.text ='0.0 1.0\n400.0 0.0'
tree.write('eng_PegasusXc.xml')
# Copy the propeller file.
shutil.copy(self.sandbox.path_to_jsbsim_file('engine', 'prop_deHavilland5000.xml'),
'.')
fdm = CreateFDM(self.sandbox)
fdm.set_engine_path('.')
fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts',
'Short_S23_1.xml'))
fdm.run_ic()
pm = fdm.get_property_manager()
self.assertTrue(pm.hasNode('propulsion/engine[0]/starter-max-power-W'))
self.assertTrue(pm.hasNode('propulsion/engine[1]/starter-max-power-W'))
self.assertTrue(pm.hasNode('propulsion/engine[2]/starter-max-power-W'))
self.assertTrue(pm.hasNode('propulsion/engine[3]/starter-max-power-W'))
while fdm.run():
rpm = [fdm['propulsion/engine[0]/engine-rpm'],
fdm['propulsion/engine[1]/engine-rpm'],
fdm['propulsion/engine[2]/engine-rpm'],
fdm['propulsion/engine[3]/engine-rpm']]
for i in range(4):
tabularData = max(0.0, 1.0-rpm[i]/400)
maxPower = tabularData*498.941*0.10471976*rpm[i]
self.assertAlmostEqual(fdm['propulsion/engine[%d]/starter-max-power-W' % (i,)],
maxPower)
self.assertAlmostEqual(fdm['propulsion/engine[%d]/starter-tabular-data' % (i,)],
tabularData)
示例5: test_property_access
# 需要导入模块: from JSBSim_utils import CreateFDM [as 别名]
# 或者: from JSBSim_utils.CreateFDM import get_property_manager [as 别名]
def test_property_access(self):
fdm = CreateFDM(self.sandbox)
fdm.load_model('ball')
fdm.run_ic()
# Check that the node 'qwerty' does not exist
pm = fdm.get_property_manager()
self.assertFalse(pm.hasNode('qwerty'))
# Check the default behavior of get_property_value. Non existing
# properties return 0.0
self.assertEqual(fdm.get_property_value('qwerty'), 0.0)
# Verify that __getitem__ checks the existence and raises KeyError if
# the property does not exist.
with self.assertRaises(KeyError):
x = fdm['qwerty']
# Check that we can initialize a non existing property
fdm['qwerty'] = 42.0
self.assertAlmostEqual(fdm.get_property_value('qwerty'), 42.0)
self.assertAlmostEqual(fdm['qwerty'], 42.0)
del fdm