找回密码
 会员注册
查看: 38|回复: 0

Python调用Canoe获取启动Canoe,停止Canoe,获取系统变量,更改系统变量,获取信号值

[复制链接]

2万

主题

0

回帖

7万

积分

超级版主

积分
71086
发表于 2024-9-9 21:45:07 | 显示全部楼层 |阅读模式
1、Canoe获取启动Canoe,停止Canoe,获取系统变量,更改系统变量,获取信号值Canoe工程如下2、Python_canoe_start_and_stop_variables_and_signals_read_and_write.py代码如下#--------------------------------------------------------------------------#Standardlibraryimportsimportosimportsysimportsubprocessimporttimeimportmsvcrtfromwin32com.clientimport*fromwin32com.client.connectimport*#VectorCanoeClassclassCANoe:def__init__(self,visible=True):self.application=Noneself.application=DispatchEx("CANoe.Application")#self.application.Versible=visibleself.ver=self.application.Versionprint('LoadedCANoeversion',self.ver.major,'.',self.ver.minor,'.',self.ver.Build,'...')#,sep,''self.Measurement=self.application.Measurement.Runningdefopen_cfg(self,cfgname):#openCANoesimulationcfgname=os.path.abspath(cfgname)if(self.application!=None):#checkforvalidfileanditis*.cfgfileifos.path.isfile(cfgname)and(os.path.splitext(cfgname)[1]==".cfg"):self.application.Open(cfgname)print("opening..."+cfgname)else:raiseRuntimeError("Can'tfindCANoecfgfile")else:raiseRuntimeError("CANoeApplicationismissing,unabletoopensimulation")defclose_cfg(self):#closeCANoesimulationif(self.application!=None):print("closecfg...")#self.stop_Measurement()self.application.Quit()self.application=Nonedefstart_Measurement(self):retry=0retry_counter=5#trytoestablishmeasurementwithin5stimeoutwhilenotself.application.Measurement.Runningand(retry")defOnStop(self,reason):self.started=Falseself.stopped=Trueprint("")classCanoeMeasurementEvents(object):"""HandlerforCANoemeasurementevents"""defOnStart(self):CanoeSync.Started=TrueCanoeSync.Stopped=Falseprint("")defOnStop(self):CanoeSync.Started=FalseCanoeSync.Stopped=Trueprint("")defmain():Tester=CanoeSync()Tester.Load(r'../Pressure_measurement_collection/Pressure_measurement_collection/CANoecfg/Pressure_measurement_collection.cfg')Tester.LoadTestSetup("Pressure_measurement_collection.tse")Tester.Start()Tester.RunTestModules()Tester.Stop()if__name__=="__main__":main()文章借鉴:Python调用CANoe(1)(启动与停止,变量和信号读写)-CSDN博客
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

QQ|手机版|心飞设计-版权所有:微度网络信息技术服务中心 ( 鲁ICP备17032091号-12 )|网站地图

GMT+8, 2025-1-9 05:59 , Processed in 0.813926 second(s), 25 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表