Python QSYS QRC包装器
qsys的Python项目详细描述
Python QSYS QRC包装器
- 用python控制QSC-QSYS核心设备
托多
- 弗莱斯基。。。在
- 文件,文件,文件
使用
- 为网络上的每个QSC核心实例化一个“Core”类
- 当添加控件对象时,它们将自己“强制转换”到父核心类
- 创建控件对象时,父核心类实例需要作为关键字arg“parent”
#!/usr/bin/python3importtimefromqsys.classesimportCore,Control,ChangeGroup#returns epoch timefromqsys.helpersimportepochdefmain():#See qsys.py for parameters in Core class#The initiail EngineStatus response parameters from the device will get added to Core.__dict__#You can pass "port" as well, but it defaults to 1710myCore=Core(Name='myCore',User='',Password='',ip='192.168.61.2')#Open the socket,creates "listen" and "keepalive" threadsmyCore.start()#ValueType can be a list of potential value types [int,float] or a single type "str" etc#This object is assumed to be a "gain" control object, so we can pass [int,float]gainControlObject=Control(parent=myCore,Name='namedControlInQsysDesigner',ValueType=[int,float])#To constantly monitor the state of your object use a ChangeGroup#You need to a ChangeGroup instance to add control objects and set polling rates#Parameters that are capitalize are that way because of the QRC parameter protocol#Id in this case is just the name of the ChangeGroupmyChangeGroup=ChangeGroup(parent=myCore,Id='myChangeGroup')myChangeGroup.AddControl(gainControlObject)#Allow the socket time to connect and parse the initial responsestime.sleep(2)#Set the change group auto poll rate#This rate is fast, your mileage may varymyChangeGroup.AutoPoll(Rate=0.1)#Value = value to set object to#TransId = QRC id parameter for transaction IDgainControlObject.set(Value=10,TransId=epoch())whileTrue:print(gainControlObject.state)time.sleep(1)if__name__=='__main__':main()
注释
- 在开发过程中,版本会迅速变化。这个版本还没什么用。。待命
参考文献
- 项目
标签: