コード例 #1
0
ファイル: mDraw.py プロジェクト: wanderingnoah/mDrawBot
 def refreshCom(self):
     self.commList = {}
     self.ui.portCombo.clear()
     serPorts = SerialCom.serialList()
     for s in serPorts:
         self.commList[s] = "COM"
         self.ui.portCombo.addItem(s)
コード例 #2
0
ファイル: robot_gui.py プロジェクト: andrewmk/mDrawBot
 def refreshCom(self):
     self.commList = {}
     self.ui.portCombo.clear()
     serPorts = SerialCom.serialList()
     for s in serPorts:
         self.commList[s]="COM"
         self.ui.portCombo.addItem(s)
コード例 #3
0
def laser_task():
    mylaser = sc.Revlaser()

    while True:
        dis_temp = mylaser.readlaser()
        if (dis_temp == 0):
            # print("err")
            pass
        else:
            info.Laser.disdata = dis_temp
コード例 #4
0
def sendcmd_task():
    global tx_data
    mysend = sc.H7com()

    while True:
        try:
            pack()
            mysend.sendcmd(tx_data)
            # print("sended", tx_data)
            time.sleep(0.01)
        except:
            # pass
            print("err err err!!!")
            time.sleep(0.05)
コード例 #5
0
def readMotorPosition():
    m1Pos = -1
    m2Pos = -1
    SerialCom.send2IntToArduino(Constant.MOTOR_1_READ_POS, 0)
    m1Pos = SerialCom.readIntFromArduino()

    SerialCom.send2IntToArduino(Constant.MOTOR_2_READ_POS, 0)
    m2Pos = SerialCom.readIntFromArduino()

    return (m1Pos, m2Pos)
コード例 #6
0
def rev_task():
    global rx_data
    myrev = sc.H7com()

    while True:
        temp = myrev.readh7()
        # print("hello", temp)
        if (temp != 0):
            for i in range(6):
                rx_data[i] = temp[i]
            unpack()
        #     print(rx_data)

        else:
            #     print("fxxk")
            pass
コード例 #7
0
    def initUI(self):
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        self.setWindowTitle("DLP Printer")
        self.show()

        self.ui.progressBar.setValue(0)
        # init serial
        self.comm = None
        self.serial = SerialCom.serialCom(self.commRx)
        self.refreshCom()
        self.initProjectorWindow()
        # connect buttons
        self.ui.pushButton.clicked.connect(self.loadImages)

        self.ui.btnRefresh.clicked.connect(self.refreshCom)
        self.ui.btnConnect.clicked.connect(self.connectPort)
        self.ui.btnPrint.clicked.connect(self.startPrint)

        self.ui.btnHomeZ.clicked.connect(self.G28)
        #self.ui.btnUp10mm.clicked.connect(self.UP10mm)
        self.ui.btnUp1mm.clicked.connect(self.UP1mm)
        self.ui.btnDown1mm.clicked.connect(self.DOWN1mm)
        self.ui.btnUp10mm.clicked.connect(self.UP10mm)
        self.ui.btnDown10mm.clicked.connect(self.DOWN10mm)

        self.ui.btnShowCalibration.clicked.connect(
            self.projWidget.showCalibration)
        self.ui.btnShowBlank.clicked.connect(self.projWidget.showBlank)

        self.ui.lineHeight.editingFinished.connect(self.calcExptime)
        self.ui.lineFeedrate.editingFinished.connect(self.calcExptime)

        self.ui.sliderLayer.valueChanged.connect(self.layerChanged)

        self.q = queue.Queue()
        self.robotSig.connect(self.parseSig)
コード例 #8
0
ファイル: mDraw.py プロジェクト: wanderingnoah/mDrawBot
    def initUI(self):
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        # get sys serial port and update combo box
        self.comm = None
        self.serial = SerialCom.serialCom(self.commRx)
        self.refreshCom()
        # link button
        self.ui.btnConnect.clicked.connect(self.connectPort)
        self.ui.btnLoadPic.clicked.connect(self.loadPic)
        self.ui.btnClearPic.clicked.connect(self.clearPic)
        self.ui.btnSend.clicked.connect(self.sendCmd)
        self.ui.btnPrintPic.clicked.connect(self.robotPrint)
        self.ui.btnStop.clicked.connect(self.robotStop)
        self.ui.btnSetRobot.clicked.connect(self.showRobotSetup)
        self.ui.portCombo.mousePressEvent = self.portComboPressed
        self.ui.labelXpos.returnPressed.connect(self.userSetPos)
        self.ui.labelYpos.returnPressed.connect(self.userSetPos)
        self.ui.lineSvgHeight.returnPressed.connect(self.userSetSvgRect)
        self.ui.lineSvgWidth.returnPressed.connect(self.userSetSvgRect)
        self.ui.lineSend.returnPressed.connect(self.sendCmd)
        self.ui.btnUpdateFirmware.clicked.connect(self.uploadFirmware)
        self.ui.btnHome.clicked.connect(self.robotGoHome)
        self.ui.btnSavePos.clicked.connect(self.savePenPos)
        self.ui.btnHelp.clicked.connect(self.linkToFAQ)

        self.ui.btnHFlip.clicked.connect(self.xReflect)
        self.ui.btnVFlip.clicked.connect(self.yReflect)
        self.ui.btnRollC.clicked.connect(self.rollClockwise)
        self.ui.btnRollAC.clicked.connect(self.rollAntiClockwise)

        self.ui.btnWiring.clicked.connect(self.showWire)

        # connect pen widget
        self.ui.btnPenUp.clicked.connect(self.plotPenUp)
        self.ui.btnPenDown.clicked.connect(self.plotPenDown)

        # connect laser widget
        self.ui.slideLaserPower.valueChanged.connect(self.laserValue)
        self.ui.slideLaserDelay.valueChanged.connect(self.laserDelay)
        self.ui.radioLaserMode.toggled.connect(self.laserMode)

        self.ui.tabWidget.currentChanged.connect(self.tabWidgetChanged)
        self.ui.robotCombo.currentIndexChanged.connect(self.tabChanged)

        # init scene
        rect = QRectF(self.ui.graphicsView.rect())
        self.scene = QGraphicsScene(rect)
        item = QGraphicsEllipseItem(75, 10, 60, 40)
        self.ui.graphicsView.setScene(self.scene)
        self.ui.labelEstTime.setVisible(False)
        self.ui.progressBar.setVisible(False)
        self.ui.labelPic.setVisible(False)
        self.ui.pushButton.clicked.connect(self.linkToFAQ)
        #fix the 1 pix margin of graphic view
        rcontent = self.ui.graphicsView.contentsRect()
        self.ui.graphicsView.setSceneRect(0, 0, rcontent.width(),
                                          rcontent.height())

        # mouse movement
        self.ui.graphicsView.mousePressEvent = self.graphMouseClick
        self.ui.graphicsView.mouseMoveEvent = self.graphMouseMove
        self.ui.graphicsView.mouseReleaseEvent = self.graphMouseRelease

        # path from user paint
        self.userPaint = None
        # init robot parts (default to scara robot)
        self.robot = ScaraRobot.Scara(self.scene, self.ui)
        self.robot.sendCmd = self.sendCmd
        self.robot.robotSig = self.robotSig

        self.sceneUpdateSig.connect(self.scene.update)
        self.robotSig.connect(self.parseRobotSig)
        self.robotSig.emit("pg 0")

        self.initGraphView()
        self.robot.initRobotCanvas()
        self.setWindowTitle('mDraw')
        self.setWindowIcon(QtGui.QIcon('mDrawIcon.png'))
        self.show()
        # start refresh thread
        self.refreshThread = WorkInThread(self.sceneRefresh)
        self.refreshThread.setDaemon(True)
        self.refreshThread.start()

        self.ui.slideLaserDelay.setValue(25)
コード例 #9
0
def submerge(depth):
    print("submerging to: " + depth)
    SerialCom.send(depth)
コード例 #10
0
def surface(depth):
    print("going up: " + depth + " feet")
    SerialCom.send(depth)
コード例 #11
0
 def InitSerial(self):
     self.SerialObj = SerialCom.SerialCom()
     self.arduinoOut = self.SerialObj.getConn('COM9', 9600)
コード例 #12
0
def turnToPos(commandNb, position):
    #if position >= Constant.POS_MIN:
    SerialCom.send2IntToArduino(commandNb, position)
コード例 #13
0
def rotateStop(commandNb):
    SerialCom.send2IntToArduino(commandNb, Constant.STOP)
コード例 #14
0
def rotateCounterClockWise(commandNb):
    SerialCom.send2IntToArduino(commandNb, Constant.COUNTERCLOCKWISE)
コード例 #15
0
def openGripper():
    SerialCom.send2IntToArduino(Constant.GRIPPER, Constant.GRIPPER_OPEN)
コード例 #16
0
def closeGripper():
    SerialCom.send2IntToArduino(Constant.GRIPPER, Constant.GRIPPER_CLOSE)
コード例 #17
0
ファイル: robot_gui.py プロジェクト: andrewmk/mDrawBot
    def initUI(self):
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        # get sys serial port and update combo box
        self.comm = None
        self.serial = SerialCom.serialCom(self.commRx)
        self.socket = SocketCom.SocketCom(self.refreshDone,self.commRx,self.disconnectPort)
        self.refreshCom()
        # link button
        self.ui.btnConnect.clicked.connect(self.connectPort)
        self.ui.btnLoadPic.clicked.connect(self.loadPic)
        self.ui.btnClearPic.clicked.connect(self.clearPic)
        self.ui.btnSend.clicked.connect(self.sendCmd)
        self.ui.btnPrintPic.clicked.connect(self.robotPrint)
        self.ui.btnStop.clicked.connect(self.robotStop)
        self.ui.btnSetRobot.clicked.connect(self.showRobotSetup)
        self.ui.portCombo.mousePressEvent = self.portComboPressed
        self.ui.labelXpos.returnPressed.connect(self.userSetPos)
        self.ui.labelYpos.returnPressed.connect(self.userSetPos)
        self.ui.lineSvgHeight.returnPressed.connect(self.userSetSvgRect)
        self.ui.lineSvgWidth.returnPressed.connect(self.userSetSvgRect)
        self.ui.lineSend.returnPressed.connect(self.sendCmd)
        self.ui.btnUpdateFirmware.clicked.connect(self.uploadFirmware)
        self.ui.linePenUp.returnPressed.connect(self.updateSetting)
        self.ui.linePenDown.returnPressed.connect(self.updateSetting)
        
        # init scene
        rect = QRectF( self.ui.graphicsView.rect())
        self.scene = QtGui.QGraphicsScene(rect)
        item = QtGui.QGraphicsEllipseItem(75, 10, 60, 40)
        self.ui.graphicsView.setScene(self.scene)
        self.ui.progressBar.setVisible(False)
        self.ui.labelPic.setVisible(False)
        self.ui.pushButton.clicked.connect(self.linkToFAQ)
        #fix the 1 pix margin of graphic view
        rcontent = self.ui.graphicsView.contentsRect();
        self.ui.graphicsView.setSceneRect(0, 0, rcontent.width(), rcontent.height());
        
        # mouse movement
        self.ui.graphicsView.mousePressEvent = self.graphMouseClick
        self.ui.graphicsView.mouseMoveEvent = self.graphMouseMove
        self.ui.graphicsView.mouseReleaseEvent = self.graphMouseRelease
        # path from user paint
        self.userPaint = None
        # init robot parts (default to scara robot)
        self.robot = ScaraRobot.Scara(self.scene, self.ui)
        self.robot.sendCmd = self.sendCmd
        self.robot.robotSig = self.robotSig
        # connect robot delegate
        self.ui.btnHome.clicked.connect(self.robotGoHome)
        # connect pen widget
        self.ui.btnPenUp.clicked.connect(self.plotPenUp)
        self.ui.btnPenDown.clicked.connect(self.plotPenDown)
        # connect laser widget
        self.ui.slideLaserPower.setEnabled(False)
        self.ui.slideLaserDelay.setEnabled(False)
        self.ui.slideLaserPower.valueChanged.connect(self.laserValue)
        self.ui.slideLaserDelay.valueChanged.connect(self.laserDelay)
        self.ui.btnLaserStart.clicked.connect(self.laserMode)
        
        self.ui.tabWidget.currentChanged.connect(self.tabWidgetChanged)
        
        self.ui.robotCombo.currentIndexChanged.connect(self.tabChanged)

        self.sceneUpdateSig.connect(self.scene.update)
        self.robotSig.connect(self.parseRobotSig)
        self.robotSig.emit("pg 0")
        
        self.initGraphView()
        self.robot.initRobotCanvas()
        self.setWindowTitle('mDraw')
        self.show()
        # start refresh thread
        self.refreshThread = WorkInThread(self.sceneRefresh)
        self.refreshThread.setDaemon(True)
        self.refreshThread.start()
        # get update info
        self.htmlThread = WorkInThread(self.getUpdateInfo)
        self.htmlThread.setDaemon(True)
        self.htmlThread.start()
コード例 #18
0
import SerialCom

print("Starting com test:")
print("Talking to 1: ")
SerialCom.send1("g")
SerialCom.read1()
print("Talking to 2: ")
SerialCom.send2("g")
SerialCom.read2()
print("Talking to 1: ")
SerialCom.send1("g")
SerialCom.read1()
print("Talking to 2: ")
SerialCom.send2("g")
SerialCom.read2()
print("Talking to 1: ")
SerialCom.send1("g")
SerialCom.read1()
print("Talking to 2: ")
SerialCom.send2("g")
SerialCom.read2()
print("Talking to 1: ")
SerialCom.send1("g")
SerialCom.read1()
print("Talking to 2: ")
SerialCom.send2("g")
SerialCom.read2()
print("Test Done")