python三菱_三菱机器人melfarxm.ocx控件的Python使用,MelfaRxMOCX,python,用法
1.? ?安裝控件? \MelfaRXM\MelfaRXM_Dev\Redist\Installer
2. 在WINDOWS/System32里找到MelfaRxM.ocx
3.把OCX控件轉(zhuǎn)成C#的DLL
a.打vs的開發(fā)人員命令行
b.把剛剛的OCX放到命令行顯示的目錄
c.在命令輸入 :? ?aximp MelfaRxM.ocx
生成的DLL就是pythonnet可用調(diào)用的DLL的
4.pythonnet的調(diào)用
# -*- coding: utf-8 -*-
"""
Created on Wed May ?6 23:24:19 2020
@author: Martin
"""
import time
import clr
import sys
sys.path.append(r"./MISB_ReferencedAssemblies")
clr.AddReference('AxMELFARXMLib')
clr.AddReference('MELFARXMLib')
import AxMELFARXMLib
import System
class robot(System.Windows.Forms.Form):
#---初始化
def __init__(self,robot):
self.robot = robot
print(self.robot)
self.InitializeComponent()
def InitializeComponent(self):
self.ctrMelfaRxM=AxMELFARXMLib.AxMelfaRxM()
((System.ComponentModel.ISupportInitialize)(self.ctrMelfaRxM)).BeginInit()
self.Controls.Add(self.ctrMelfaRxM)
((System.ComponentModel.ISupportInitialize)(self.ctrMelfaRxM)).EndInit()
if self.ctrMelfaRxM.ServerLive()==False:
self.ctrMelfaRxM.ServerStart()
def sv_off(self):
sSendDataOFF = "1" + "\n" +"0"
lStatus = self.ctrMelfaRxM.RequestServiceM(self.robot, 403, len(sSendDataOFF), sSendDataOFF, 0, 0, 0)
return lStatus
def sv_on(self):
sSendDataON = "1" + "\n" +"1"
lStatus = self.ctrMelfaRxM.RequestServiceM(self.robot, 403, len(sSendDataON), sSendDataON, 0, 0, 0)
return lStatus
def read_program_list(self):
lStatus = self.ctrMelfaRxM.RequestServiceM(self.robot, 106, 0, "", 0, 0, 0)
return lStatus
def runApp():
global robot1
thread=System.Threading.Thread(System.Threading.ThreadStart(runthread))
thread.SetApartmentState(0)
thread.Start()
time.sleep(1)
# ? ?robot1.Hide()
def runthread():
global robot1
robot1 = robot(1)
System.Windows.Forms.Application.Run(robot1)
pass
global robot1
if __name__ == "__main__":
runApp()
pass
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的python三菱_三菱机器人melfarxm.ocx控件的Python使用,MelfaRxMOCX,python,用法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 日期和时间函数_介绍一下my
- 下一篇: python time sleep和wa