コード例 #1
0
ファイル: piserver.py プロジェクト: HouseYin/smartlock
def handle():
    try:
        while True:
            msg = s.recv(1024)
            match = msgTemplate.match(msg)
            if match:
                order = match.group(1)
                identity = match.group(2)
                if order == 'opendoor':
                    log('%s open and close the door' % identity)
                    hardware.openThenClose()
                elif order == 'justopen':
                    log('%s open the door' % identity)
                    hardware.openDoor()
                elif order == 'closedoor':
                    log('%s close the door' % identity)
                    hardware.closeDoor()
                elif order == 'adjustdoor':
                    log('%s adjust the door' % identity)
                    hardware.adjustDoor()
                elif order == 'exit':
                    break
        s.close()
    except socket.error:
        print 'lost remote server(%s, %s)' % server
        log('ERROR: lost remote server(%s, %s)' % server)
コード例 #2
0
ファイル: piserver.py プロジェクト: mcxr4299/smartlock
def handle():
    try:
        while True:
            msg = s.recv(1024)
            match = msgTemplate.match(msg)
            if match:
                order = match.group(1)
                identity = match.group(2)
                if order == 'opendoor':
                    log('%s open and close the door' % identity)
                    hardware.openThenClose()
                elif order == 'justopen':
                    log('%s open the door' % identity)
                    hardware.openDoor()
                elif order == 'closedoor':
                    log('%s close the door' % identity)
                    hardware.closeDoor()
                elif order == 'adjustdoor':
                    log('%s adjust the door' % identity)
                    hardware.adjustDoor()
                elif order == 'exit':
                    break
        s.close()
    except socket.error:
        print 'lost remote server(%s, %s)' % server
        log('ERROR: lost remote server(%s, %s)' % server)
コード例 #3
0
ファイル: server.py プロジェクト: HouseYin/smartlock
    def doorOperate(self, order, identity):
        # 正在开/关门
        self.setOperatingDoor(True)

        sound = soundRe.match(order)
        if order == 'opendoor':
            self.log('%s open and close the door' % identity)
            hardware.openThenClose()
        elif order == 'justopen':
            self.log('%s open the door' % identity)
            hardware.openDoor()
        elif order == 'closedoor':
            self.log('%s close the door' % identity)
            hardware.closeDoor()
        elif order == 'adjustdoor':
            self.log('%s adjust the door' % identity)
            hardware.rotateMotor(20, True)
        elif sound:
            self.log('%s palyed %s' % (identity, sound.group(1)))
            music.play(sound.group(1))

        # 开/关门完毕
        self.setOperatingDoor(False)
コード例 #4
0
ファイル: server.py プロジェクト: mcxr4299/smartlock
    def doorOperate(self, order, identity):
        # 正在开/关门
        self.setOperatingDoor(True)

        sound = soundRe.match(order)
        if order == 'opendoor':
            self.log('%s open and close the door' % identity)
            hardware.openThenClose()
        elif order == 'justopen':
            self.log('%s open the door' % identity)
            hardware.openDoor()
        elif order == 'closedoor':
            self.log('%s close the door' % identity)
            hardware.closeDoor()
        elif order == 'adjustdoor':
            self.log('%s adjust the door' % identity)
            hardware.rotateMotor(20, True)
        elif sound:
            self.log('%s palyed %s' % (identity, sound.group(1)))
            music.play(sound.group(1))

        # 开/关门完毕
        self.setOperatingDoor(False)