コード例 #1
0
ファイル: Pilot.py プロジェクト: mateuszolszowy1991/CarSystem
class Pilot:
    
    def __init__(self, id):
        self.loadData(id)
        if self.checkIsRegistered(id):
            self.subscribeToDoor()
            print __name__ + "[INFO]: Pilot is reistered for: " + self.content.split(":")[1]

    def subscribeToDoor(self):
        self.doorDevMan = DeviceManager()


    def checkIsRegistered(self, id):
        if len(self.content.split(":")) > 0:
            return True

    def loadData(self, id):
        f = open("Pilot/userID.txt", "r")
        content = f.readlines()
        f.close()
        for user in content:
            if id in user:
                self.content = user


    def getUserInfo(self):
        self.content

    def clickOpenDoorButton(self):
        self.doorDevMan.openEachDoor()

    def clickCloseDoorButton(self):
        self.doorDevMan.closeEachDoor()

    def clickSwitchTrunkButton(self):
        trunk = self.doorDevMan.getObjectInstance("trunk")
        if trunk.isOpened:
            trunk.isOpened = False
        else:
            trunk.isOpened = True
コード例 #2
0
ファイル: main.py プロジェクト: mateuszolszowy1991/CarSystem
# from Test import *
from Body.DeviceManager import *
from Pilot.Pilot import *

# doorTest()
Body = DeviceManager()
Body.createObjects()
print Body.getBodyObjectModel()
print Body.getObjectInstance("door", "FRONT_LEFT")
print Body.getObjectInstance("trunk").isOpened

rc = Pilot("0x0001")
rc.clickOpenDoorButton()
for door in Body.getBodyObjectModel():
    door.isOpened

rc.clickCloseDoorButton()
for door in Body.getBodyObjectModel():
    door.isOpened

rc.clickSwitchTrunkButton()
print Body.getObjectInstance("trunk").isOpened

rc.clickSwitchTrunkButton()
print Body.getObjectInstance("trunk").isOpened