Ejemplo n.º 1
0
 def __init__(self, verbose, processType):
     '''Processing specific text files'''
     self.verbose = verbose
     self.processType = processType
     self.dashboardDir = '/Volume/Dashboard'
     self.dataDir = 'Volume/Data'
     self.processDir = '%s/PROCESSING/%s' % (self.dashboardDir,
                                             self.processType)
     self.processingLog = '%s/Processing.log' % self.processDir
     self.currentlyProcessingFP = '%s/CURRENTLY_PROCESSING.txt' % self.processDir
     self.exceptionsFP = '%s/EXCEPTIONS.txt' % self.processDir
     self.failedFP = '%s/FAILED.txt' % self.processDir
     self.processedFP = '%s/PROCESSED.txt' % self.processDir
     self.toProcessFP = '%s/TO_PROCESS.txt' % self.processDir
     self.exceptionFileList = [
         self.currentlyProcessingFP, self.exceptionsFP, self.failedFP,
         self.processedFP
     ]
     self.projectReportFile = '%s/Project_Reports.txt' % self.dashboardDir
     self.projectsOutputDir = '%s/Project_outputs' % self.dashboardDir
     '''Initialising lists & dicts'''
     self.projectReportFile = Dashboard.CreateProjectDict(
         self.projectReportFile).keys()
     if self.processType == 'MRtrix':
         self.MRtrixProcessFile = '%s/Projects.txt' % self.processDir
         self.mrtrixDict = Dashboard.CreateProjectDict(
             self.MRtrixProcessFile)
     self.exceptionIDList = []
     self.IDtoProcess = None
     self.IDList = []
     self.IDProcessingType = None
Ejemplo n.º 2
0
def main():
    print('Welcome!')
    entry=None
    while entry!='2':
        entry = input('\n1. Current Student\n2. New Student\n3. Quit\nPlease, enter 1, 2 or 3: ')

        if entry=='1':
            student_dashboard = Dashboard.StudentDashboard()
            email = input('\nEnter Your Email: ')
            pw = input('Enter Your Password: '******'\nWhat Would You Like To Do?')

                while entry!='2':
                    entry = input('\n1. Register To Course\n2. Logout\nPlease, enter 1 or 2: ')

                    if entry=='1':
                        show_all_courses(course_list)
                        course_id = input('\nSelect Course By ID Number: ')
                        print("\nAttempting to Register...")
                        if attending_dashboard.register_student_to_course(email, course_id, course_list):
                            show_my_courses(student, course_list)
                    elif entry=='2':
                        print('\nYou Have Been Logged Out.')
                    else:
                        print('\nInvalid Option...')


            else:
                print('\nWrong Credentials!')
        elif entry=='2':
            print("Welcome to the school!")
            student_dashboard = Dashboard.StudentDashboard()
            email = input('Please provide your email : ')
            if not student_dashboard.get_student_by_email(email):
                name     = input("What is your full name? : ")
                password = input("What would you like your password to be? : ")
                student_dashboard.add_new_student(email, name, password)
                entry = '-1'
                continue;
            else:
                print("That email is already taken")

        elif entry=='3':
            print("Programming is closing, ")
            break;
        else:
            print('Invalid Option...')
    print('\nClosing Program. Goodbye.')
Ejemplo n.º 3
0
    def Login():

        id1 = text1.get("1.0", "end-1c")
        pw = text2.get("1.0", "end-1c")
        print(pw)
        info = []
        q = '''match(m:Member) where Id(m)={i} and m.password={pwd} return m'''  #.libraryID'''
        data2 = graph.run(q, i=int(id1), pwd=pw)
        for i in data2:
            info.append(i)
        if not info:
            messagebox.showinfo("Warning", "Invalid Id or Password")
        else:
            Dashboard.main(id1)
    def initializeGameWorld(self):

        base.setFrameRateMeter(True)
        self.setupLights()
        self.accept('escape', self.doExit)
        self.keyMap = {"reset": 0}
        # input states
        self.accept('f1', self.toggleWireframe)
        self.accept('f2', self.toggleTexture)
        self.accept('f3', self.toggleDebug)
        self.accept('f5', self.doScreenshot)
        self.accept("r", self.resetCar)
        self.accept('1', self.activateBoost)
        # Network Setup
        #self.cManager.startConnection()
        # Create Audio Manager
        self.audioManager = Audio(self)
        self.audioManager.startAudioManager()
        #taskMgr.add(self.enterGame, "EnterGame")

        #taskMgr.add(self.usePowerup, "usePowerUp")
        self.accept('bullet-contact-added', self.onContactAdded)
        #Physics -- Terrain
        self.setup()  # Create Players
        self.createPlayers()

        # Camera
        self.setupCamera()
        # Create Powerups
        self.createPowerups()
        taskMgr.add(self.powerups.checkPowerPickup, "checkPowerupTask")
        self.dashboard = Dashboard(self, taskMgr)
Ejemplo n.º 5
0
def show_my_courses(student, course_list):
    print('\nMy Courses:')
    print('#\tCOURSE NAME\tINSTRUCTOR NAME')
    attending_dashboard = Dashboard.AttendingDashboard()
    my_courses = attending_dashboard.get_student_courses(course_list, student.get_email())
    i = 1
    for course in my_courses:
        print(f'{i}\t{course.get_name()}\t{course.get_instructor()}')
        i+=1
def validate(window,w,namevar,passvar):
    print("here")
    if namevar=='admin' and passvar=='root':
        print("logged in")
        w.destroy()
        Dashboard.Dashboard()
    else:
        messagebox.showerror("Warning","Incorrect Username or Password")
        window.destroy()
        login(w)
Ejemplo n.º 7
0
def main():
    '''
    print('Testing car class ...')
    make = 'Chevy'
    model = 'Malibu'
    year = '2005'
    port_number = 283944390
    
    my_car = Car.Car(make, model, port_number, year)
    my_car.getSpeed()
    my_car.read_dtc_trace()
    '''
    Dashboard.Dashboard()
Ejemplo n.º 8
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.timer = QTimer(self)
        self.interval = 200

        self.setupUi(self)
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.dashboard = Dashboard.Dashboard(self)
        self.setCentralWidget(self.dashboard)

        self.startButton.clicked.connect(self.startTimer)
        self.stopButton.clicked.connect(self.stopTimer)
        self.timer.timeout.connect(self.marquee)
Ejemplo n.º 9
0
 def create_new_project(self, data, file_name=''):
     try:
         try:
             self.dboard_window.close()
         except AttributeError:
             pass
         self.dboard_window = QtWidgets.QMainWindow(self.centralwidget)
         # self.dboard_window.setWindowModality(QtCore.Qt.ApplicationModal)
         self.dboard_widget = Dashboard.Ui_MainWindow()
         self.dboard_widget.setupUi(self.dboard_window, data, file_name)
         self.dboard_window.show()
         self.dboard_widget.close.connect(self.close)
         self.main_window.setVisible(False)
     except Exception as e:
         print('Error Creating New Project -->>', type(e), str(e))
class World(DirectObject):
    gameStateDict = {"Login": 0, "CreateLobby": 4, "EnterGame": 1, "BeginGame": 2, "InitializeGame": 3}
    gameState = -1
    # Login , EnterGame , BeginGame
    responseValue = -1
    currentTime = 0
    idleTime = 0
    mySequence = None
    pandaPace = None
    jumpState = False
    isWalk = False
    previousPos = None  # used to store the mainChar pos from one frame to another
    host = ""
    port = 0
    characters = []

    def __init__(self, manager):
        # Stores the list of all the others players characters
        self.cleanParticle = False
        self.vehiclelist = {}
        self.isActive = False
        self.nodeFilterList = []
        self.collisionThreadSet = []
        self.otherPlayer = None
        self.deadCounter = 0
        self.manager = manager
        self.lobby = manager.lobby
        self.login = self.lobby.World.username
        #self.cManager = self.manager.cManager
        self.isDebug = False
        self.enemyHealthList = {}

    def initializeGameWorld(self):

        base.setFrameRateMeter(True)
        self.setupLights()
        self.accept('escape', self.doExit)
        self.keyMap = {"reset": 0}
        # input states
        self.accept('f1', self.toggleWireframe)
        self.accept('f2', self.toggleTexture)
        self.accept('f3', self.toggleDebug)
        self.accept('f5', self.doScreenshot)
        self.accept("r", self.resetCar)
        self.accept('1', self.activateBoost)
        # Network Setup
        #self.cManager.startConnection()
        # Create Audio Manager
        self.audioManager = Audio(self)
        self.audioManager.startAudioManager()
        #taskMgr.add(self.enterGame, "EnterGame")

        #taskMgr.add(self.usePowerup, "usePowerUp")
        self.accept('bullet-contact-added', self.onContactAdded)
        #Physics -- Terrain
        self.setup()  # Create Players
        self.createPlayers()

        # Camera
        self.setupCamera()
        # Create Powerups
        self.createPowerups()
        taskMgr.add(self.powerups.checkPowerPickup, "checkPowerupTask")
        self.dashboard = Dashboard(self, taskMgr)


    def activateKeys(self):
        inputState.watchWithModifiers('boostUp', '1-up')
        inputState.watchWithModifiers('forward', 'w')
        inputState.watchWithModifiers('left', 'a')
        inputState.watchWithModifiers('brake', 's')
        inputState.watchWithModifiers('right', 'd')
        inputState.watchWithModifiers('turnLeft', 'q')
        inputState.watchWithModifiers('turnRight', 'e')

        self.world.setGravity(Vec3(0, 0, -9.81))
    def activateBoost(self):
        self.vehicleContainer.addBoost()

    def resetCar(self):
        self.vehicleContainer.reset()

    def createPowerups(self):
        self.powerups = PowerupManager(self, self.vehicleContainer)

    def setTime(self):
        self.cManager.sendRequest(Constants.CMSG_TIME)

    def doExit(self):
        self.cleanup()
        sys.exit(1)

    def cleanup(self):
        self.cManager.sendRequest(Constants.CMSG_DISCONNECT)
        self.cManager.closeConnection()
        self.world = None
        self.outsideWorldRender.removeNode()


    def doReset(self):
        self.mainCharRef.reset()

    def doRanking(self):
        #print "doRanking called"
        self.cManager.sendRequest(Constants.CMSG_RANKINGS)


    def enterGame(self, task):
        self.startGameNow()
        return task.done
        if self.gameState == self.gameStateDict["Login"]:
            #responseValue = 1 indicates that this state has been finished
            if self.responseValue == 1:
                print "Authentication succeeded"
                # Authentication succeeded
                self.cManager.sendRequest(Constants.CMSG_CREATE_LOBBY, ["raceroyal", "0", "1"])
                self.gameState = self.gameStateDict["CreateLobby"]
                self.responseValue = -1
        elif self.gameState == self.gameStateDict["CreateLobby"]:
            if self.responseValue == 1:
                # Lobby Created and we are already in
                print "Lobby Created and we are already in"
                self.gameState = self.gameStateDict["EnterGame"]
                self.responseValue = -1
                self.cManager.sendRequest(Constants.CMSG_READY)

            elif self.responseValue == 0:
                #Game already created, let's join it
                print "Game already created, let's join it"
                self.cManager.sendRequest(Constants.CMSG_ENTER_GAME_NAME, "raceroyal")
                #self.gameState = self.gameStateDict["EnterGame"]
                #self.responseValue = -1
                self.responseValue = -1
                self.gameState = self.gameStateDict["InitializeGame"]
                #               Everyone is in the game, we send ReqReady, and the server will send positions when every client did
                self.cManager.sendRequest(Constants.CMSG_READY)

        elif self.gameState == self.gameStateDict["EnterGame"]:
            if self.responseValue == 1:
                #                 When the positions are sent, an acknowledgment is sent and we begin the InitializeGame
                print "When the positions are sent, an acknowledgment is sent and we begin the InitializeGame"
                self.responseValue = -1
                self.gameState = self.gameStateDict["InitializeGame"]
                #               Everyone is in the game, we send ReqReady, and the server will send positions when every client did
                self.cManager.sendRequest(Constants.CMSG_READY)

        elif self.gameState == self.gameStateDict["InitializeGame"]:
            if self.responseValue == 1:
                print "Set up the camera"
                # Set up the camera
                self.camera = Camera(self.mainChar)
                self.gameState = self.gameStateDict["BeginGame"]
                self.cManager.sendRequest(Constants.CMSG_READY)
                self.responseValue = -1

        elif self.gameState == self.gameStateDict["BeginGame"]:
            if self.responseValue == 1:
                print "Begin Game"
                #taskMgr.doMethodLater(.1, self.updateMove, 'updateMove')
                taskMgr.add(self.update, "moveTask")
                return task.done

        return task.cont


    def startGameNow(self):
        #self.camera = Camera(self.mainChar)
        #taskMgr.doMethodLater(.1, self.updateMove, 'updateMove')
        taskMgr.add(self.update, "moveTask")


    def createEnvironment(self):
        self.environ = loader.loadModel("models/square")
        self.environ.reparentTo(render)
        self.environ.setPos(0, 0, 0)
        self.environ.setScale(500, 500, 1)
        self.moon_tex = loader.loadTexture("models/moon_1k_tex.jpg")
        self.environ.setTexture(self.moon_tex, 1)

        shape = BulletPlaneShape(Vec3(0, 0, 1), 0)
        node = BulletRigidBodyNode('Ground')
        node.addShape(shape)
        np = render.attachNewNode(node)
        np.setPos(0, 0, 0)

        self.bulletWorld.attachRigidBody(node)

        self.visNP = loader.loadModel('models/track.egg')
        self.tex = loader.loadTexture("models/tex/Main.png")
        self.visNP.setTexture(self.tex)

        geom = self.visNP.findAllMatches('**/+GeomNode').getPath(0).node().getGeom(0)
        mesh = BulletTriangleMesh()
        mesh.addGeom(geom)
        trackShape = BulletTriangleMeshShape(mesh, dynamic=False)

        body = BulletRigidBodyNode('Bowl')
        self.visNP.node().getChild(0).addChild(body)
        bodyNP = render.anyPath(body)
        bodyNP.node().addShape(trackShape)
        bodyNP.node().setMass(0.0)
        bodyNP.setTexture(self.tex)

        self.bulletWorld.attachRigidBody(bodyNP.node())

        self.visNP.reparentTo(render)

        self.bowlNP = bodyNP
        self.visNP.setScale(70)

    def makeCollisionNodePath(self, nodepath, solid):
        '''
        Creates a collision node and attaches the collision solid to the
        supplied NodePath. Returns the nodepath of the collision node.
        '''
        # Creates a collision node named after the name of the NodePath.
        collNode = CollisionNode("%s c_node" % nodepath.getName())
        collNode.addSolid(solid)
        collisionNodepath = nodepath.attachNewNode(collNode)

        return collisionNodepath


    # Records the state of the arrow keys
    def setKey(self, key, value):
        self.keyMap[key] = value


    # Accepts arrow keys to move either the player or the menu cursor,
    # Also deals with grid checking and collision detection
    def getDist(self):
        mainCharX = self.mainChar.getPos().x
        mainCharY = self.mainChar.getPos().y
        pandaX = self.pandaActor2.getPos().x
        pandaY = self.pandaActor2.getPos().y
        dist = math.sqrt(abs(mainCharX - pandaX) ** 2 + abs(mainCharY - pandaY) ** 2)
        return dist


    def removeCollisionSet(self, arg):
        sleep(2)
        self.nodeFilterList.pop(0)


    # _____HANDLER_____
    def onContactAdded(self, node1, node2):
        isMyCarColliding = False
        if node1.notifiesCollisions() and node2.notifiesCollisions():
            self.audioManager.play_collision()
            isEnable = True
            list2 = [node1.getName(), node2.getName()]
            for nodeSet in self.nodeFilterList:
                if (list2[0] == nodeSet[0]) or (list2[0] == nodeSet[1]):
                    if (list2[1] == nodeSet[0]) or (list2[1] == nodeSet[1]):
                        isEnable = False

            if isEnable:
                isMyCarColliding = False
                if node1.getName() == self.login:
                    isMyCarColliding = True
                    if node2.getName() == 'UniverseNode':
                        self.killMe()
                        return
                elif node2.getName() == self.login:
                    isMyCarColliding = True
                    if node1.getName() == 'UniverseNode':
                        self.killMe()
                        return

                if isMyCarColliding:
                    name1 = node1.getName()
                    vehicle1 = self.vehiclelist[name1]
                    vehicle1.props.setVelocity(node1.getLinearVelocity().length())
                    name2 = node2.getName()
                    vehicle2 = self.vehiclelist[name2]
                    vehicle2.props.setVelocity(node2.getLinearVelocity().length())
                    self.calculateDamage(vehicle1, vehicle2)

                self.nodeFilterList.append((node1.getName(), node2.getName()))
                thread = Thread(target=self.removeCollisionSet, args=(1, ))
                self.collisionThreadSet.append(thread)
                thread.start()

    def killMe(self):
        self.vehicleContainer.props.health = self.vehicleContainer.props.armor = 0
        self.cManager.sendRequest(Constants.CMSG_HEALTH, 0)
        #self.vehicleContainer.chassisNP.removeNode()
        self.cManager.sendRequest(Constants.CMSG_DEAD)
        self.gameEnd(True)

    def gameEnd(self, isDead=False):
        self.dashboard.gameResult(isDead)
        self.audioManager.StopAudioManager()
        self.cleanup()


    def callLobby(self):

        self.cleanup()
        # self.lobby.createSocialization()
        self.lobby.World.startMusic()
        self.lobby.World.doMenu()

    def doExit(self):
        self.cleanup()
        sys.exit(1)

    def doReset(self):
        self.cleanup()
        self.setup()

    def toggleWireframe(self):
        base.toggleWireframe()

    def toggleTexture(self):

        base.toggleTexture()


    def toggleDebug(self):
        if self.debugNP.isHidden() and self.isDebug:
            self.debugNP.show()
        else:
            self.debugNP.hide()


    def calculateDamage(self, fromCar, toCar, fromCollisionSection=2, toCollisionSection=2):
        # toCar takes more damage than fromCar
        fromWeight = fromCar.props.weight
        toWeight = toCar.props.weight
        fromSpeed = fromCar.props.velocity
        toSpeed = toCar.props.velocity

        #Speed Max = 100
        #Weights Max = 10
        #Front collisionSection = 3, mid = 2, back = 1
        damageFactor = (((fromWeight + toWeight) * (fromSpeed + toSpeed)) / 100)

        damage = .5 * damageFactor / fromCollisionSection
        #toDamage = .5 * damageFactor / toCollisionSection
        damage = int(damage)
        print "Damage: ", damage
        #print "To Damage: ", toDamage
        if fromCar.username == self.login:
            if not fromCar.props.setDamage(damage):
                self.killMe()
            else:
                self.cManager.sendRequest(Constants.CMSG_HEALTH, fromCar.props.getHitPoint())

        else:
            if not toCar.props.setDamage(damage):
                self.killMe()
            else:
                self.cManager.sendRequest(Constants.CMSG_HEALTH, toCar.props.getHitPoint())

        print "My health: ", self.vehicleContainer.props.health
        if self.vehicleContainer.props.health < 50 and not self.cleanParticle:
            #self.vehicleContainer.loadParticleConfig('steam.ptf')
            self.cleanParticle = True
        else:
            if self.cleanParticle:
                #self.vehicleContainer.p.cleanup()
                self.cleanParticle = False

    def doScreenshot(self):

        base.screenshot('Bullet')

    def toggleHeightfield(self):

        self.terrainContainer.setDebugEnabled()
    # ____TASK___
    def update(self, task):
        dt = globalClock.getDt()
        self.audioManager.updateSound(self.vehicleContainer)
        #print "Type: ", type(self.vehicleContainer)
        forces = self.vehicleContainer.processInput(inputState, dt)
        moving = self.vehicleContainer.chassisNP.getPos()
        if forces!= None and forces[0] != None and forces[1] != None and forces[2] != None:
            #fake move for other playera
                # self.otherPlayer.move(forces[0], forces[1], forces[2], moving.getX()+10, moving.getY(), moving.getZ(),
                #                            self.vehicleContainer.chassisNP.getH(), self.vehicleContainer.chassisNP.getP(), self.vehicleContainer.chassisNP.getR())
            #print"sending move: ", self.login, forces[0], forces[1], forces[2], moving.getX(), moving.getY(), moving.getZ(), self.vehicleContainer.chassisNP.getH(), self.vehicleContainer.chassisNP.getP(), self.vehicleContainer.chassisNP.getR()
            self.cManager.sendRequest(Constants.CMSG_MOVE,
                                      [forces[0], forces[1], forces[2], moving.getX(), moving.getY(), moving.getZ(),
                                       self.vehicleContainer.chassisNP.getH(), self.vehicleContainer.chassisNP.getP(), self.vehicleContainer.chassisNP.getR()])

        #self.moveCrazyCar(dt)
        if self.world != None:
            self.world.doPhysics(dt, 10, 0.008)

        # if inputState.isSet('step'):
        #     self.vehicleContainer.processInput(inputState, dt)
        #     self.moveCrazyCar(dt)
        #     self.stepPhysicsWorld()

        self.updateCamera(self.vehicleContainer.speed)
        return task.cont


    def updateCamera(self, speed=0.0, initial=False):
        #"""Reposition camera depending on the vehicle speed"""
        minDistance = 8.0
        maxDistance = 13.0
        minHeight = 1.5
        maxHeight = 3.0
        maxSpeed = 30.0  # m/s

        distance = (minDistance + (maxDistance - minDistance) * speed / maxSpeed)
        distance = min(maxDistance, distance)
        height = minHeight + (maxHeight - minHeight) * speed / maxSpeed
        height = min(maxHeight, height)

        vPos = self.vehicleContainer.chassisNP.getPos()
        headingRad = self.vehicleContainer.chassisNP.getH() * math.pi / 180.0

        targetPos = vPos + Vec3(distance * math.sin(headingRad), -distance * math.cos(headingRad), height)
        cameraPos = base.camera.getPos()

        base.camera.setPos(cameraPos + (targetPos - cameraPos) * 0.1)
        # Look slightly ahead of the car
        base.camera.lookAt(*vPos)
        base.camera.setP(base.camera.getP() + 7)

    def cleanup(self):
        self.world = None
        self.worldNP.removeNode()
        self.cManager.closeConnection()

    def setupCamera(self):
        base.disableMouse()
        base.camera.setPos(self.vehicleContainer.chassisNP.getX(), self.vehicleContainer.chassisNP.getY() + 10, 2)
        # Create a floater object.  We use the "floater" as a temporary
        # variable in a variety of calculations.
        self.floater = NodePath(PandaNode("floater"))
        self.floater.reparentTo(render)

    def setupLights(self):
        base.setBackgroundColor(0.0, 0.0, 0.0, 1)
        base.setFrameRateMeter(True)
        # Add a light to the scene.
        self.lightpivot = render.attachNewNode("lightpivot")
        self.lightpivot.setPos(0, 0, 5)
        self.lightpivot.hprInterval(10, Point3(360, 0, 0)).loop()
        plight = PointLight('plight')
        plight.setColor(Vec4(1, 0, 0, 1))
        plight.setAttenuation(Vec3(0.37, 0.025, 0))
        plnp = self.lightpivot.attachNewNode(plight)
        plnp.setPos(45, 0, 0)
        plnp.lookAt(*Vec3(0, 0, 0, ))

        # Light
        alight = AmbientLight('ambientLight')
        alight.setColor(Vec4(0.2, 0.2, 0.2, 1))
        alightNP = render.attachNewNode(alight)

        #   dlight = DirectionalLight('directionalLight')
        #   dlight.setDirection(Vec3(1, 1, -1))
        #   dlight.setColor(Vec4(0.7, 0.7, 0.7, 1))
        #   dlightNP = render.attachNewNode(dlight)

        render.clearLight()
        render.setLight(alightNP)
        #   render.setLight(dlightNP)
        render.setLight(plnp)

        # create a sphere to denote the light
        sphere = loader.loadModel("models/sphere")
        sphere.reparentTo(plnp)
        sun_tex = loader.loadTexture("models/tex/sun.jpg")
        sphere.setTexture(sun_tex, 1)

        render.setShaderAuto()


    def stepPhysicsWorld(self):
        dt = globalClock.getDt()
        self.world.doPhysics(dt, 10, 0.008)


    def setup(self):
        self.worldNP = render.attachNewNode('World')
        # World
        self.debugNP = self.worldNP.attachNewNode(BulletDebugNode('Debug'))
        #self.debugNP.show()
        #self.debugNP.node().showNormals(True)

        self.world = BulletWorld()
        self.world.setDebugNode(self.debugNP.node())

        # Obstruction
        # self.obstruction = Obstruction(self)

        # Heightfield (static)
        self.terrainContainer = Terrain(self, base, render)


    def createPlayers(self):
        # Dynamic - moving bodies
        # Car
        for createPlayerUsername in self.manager.playerList.keys():
            if createPlayerUsername in self.vehiclelist.keys():
                print "Player Already rendered"
            else:
                #print "Creating main other player @ 100"
                vehicleAttributes = self.manager.playerList[createPlayerUsername]
                isCurrentPlayer=False
                if self.login == createPlayerUsername:
                    isCurrentPlayer = True
                playerVehicle = Vehicle(self, createPlayerUsername, pos=LVecBase3(vehicleAttributes.x, vehicleAttributes.y, vehicleAttributes.z),isCurrentPlayer=isCurrentPlayer, carId=vehicleAttributes.carId)
                if self.login != createPlayerUsername:
                    self.enemyHealth = OtherPlayersHealth(self,playerVehicle)
                    self.enemyHealthList[createPlayerUsername] = self.enemyHealth
                    #taskMgr.add(self.updateStatusBars,"healthchange")
                #Send Health
                # CMSG_HEALTH
                self.cManager.sendRequest(Constants.CMSG_HEALTH, playerVehicle.props.getHitPoint())
                if self.login == createPlayerUsername:
                    self.vehicleContainer = playerVehicle
                    # self.audioManager.play_music_dd()
                    self.audioManager.initialiseSound(self.vehicleContainer)
                    print "I AM: ", createPlayerUsername
                #print "Creating other players: ", createPlayerUsername, "@ ", vehicleAttributes.x, vehicleAttributes.y, vehicleAttributes.z
                self.vehiclelist[createPlayerUsername] = playerVehicle

    def updateStatusBars(self, username, health):
        if username in self.enemyHealthList.keys():
            enemyHealth = self.enemyHealthList[username]
            print "self.vehicleContainer.props.health", self.vehicleContainer.props.health
            enemyHealth.HealthBar['value'] = health
        else:
            print "updateStatusBars: Enemy entry not found"

    def startConnection(self):
        """Create a connection to the remote host.

        If a connection cannot be created, it will ask the user to perform
        additional retries.

        """
        if self.cManager.connection == None:
            if not self.cManager.startConnection():
                return False

        return True


    def listFromInputState(self, inputState):
        # index 0 == forward
        # index 1 == brake
        # index 2 == right
        # index 3 == left
        result = [0, 0, 0, 0]
        if inputState.isSet('forward'):
            result[0] = 1
        if inputState.isSet('brake'):
            result[1] = 1
        if inputState.isSet('right'):
            result[2] = 1
        if inputState.isSet('left'):
            result[3] = 1

        return result
Ejemplo n.º 11
0
import Dashboard
import dashdraw
# stup pygame
pygame.init()

# window
ws = pygame.display.set_mode((800, 600))

# backgournd
background = (33, 33, 33)

#Loop until the user clicks the close button.
done = False
clock = pygame.time.Clock()

lamp1 = Dashboard.Lamp(ws, (300, 300), name="Nandin")


def teste(obj):
    lamp1.set_state(obj)


bt = Dashboard.ButtonONOFF(ws, (100, 300), callback=teste)
raio = 60
x = 2 * raio + 5
g1 = Dashboard.Gauge(ws, (x, 100), raio)
g2 = Dashboard.Gauge(ws, (2 * x, 100), raio, display=Dashboard.Gauge.ARROW)
g2.set_max(300)

g3 = Dashboard.Gauge(ws, (3 * x, 100),
                     raio,
Ejemplo n.º 12
0
 def openResultsWindow(self, data):
     self.window = QtWidgets.QMainWindow()
     self.ui = Dashboard.Ui_DashboardWindow(self.window, data)
     self.ui.setupUi(self.window)
     self.wind.close()
     self.window.show()
Ejemplo n.º 13
0
    def __init__(self):
        self.login = "******"
        base.setFrameRateMeter(True)
        #input states
        inputState.watchWithModifiers('forward', 'w')
        inputState.watchWithModifiers('left', 'a')
        inputState.watchWithModifiers('brake', 's')
        inputState.watchWithModifiers('right', 'd')
        inputState.watchWithModifiers('turnLeft', 'q')
        inputState.watchWithModifiers('turnRight', 'e')

        self.keyMap = {
            "hello": 0,
            "left": 0,
            "right": 0,
            "forward": 0,
            "backward": 0,
            "cam-left": 0,
            "cam-right": 0,
            "chat0": 0,
            "powerup": 0,
            "reset": 0
        }
        base.win.setClearColor(Vec4(0, 0, 0, 1))

        # Network Setup
        self.cManager = ConnectionManager(self)
        self.startConnection()
        #self.cManager.sendRequest(Constants.CMSG_LOGIN, ["username", "password"])
        # chat box
        # self.chatbox = Chat(self.cManager, self)

        # Set up the environment
        #
        self.initializeBulletWorld(False)

        #self.createEnvironment()
        Track(self.bulletWorld)

        # Create the main character, Ralph

        self.mainCharRef = Vehicle(self.bulletWorld, (100, 10, 5, 0, 0, 0),
                                   self.login)
        #self.mainCharRef = Character(self, self.bulletWorld, 0, "Me")
        self.mainChar = self.mainCharRef.chassisNP
        #self.mainChar.setPos(0, 25, 16)

        #         self.characters.append(self.mainCharRef)

        #         self.TestChar = Character(self, self.bulletWorld, 0, "test")
        #         self.TestChar.actor.setPos(0, 0, 0)

        self.previousPos = self.mainChar.getPos()
        taskMgr.doMethodLater(.1, self.updateMove, 'updateMove')

        # Set Dashboard
        self.dashboard = Dashboard(self.mainCharRef, taskMgr)

        self.floater = NodePath(PandaNode("floater"))
        self.floater.reparentTo(render)

        # Accept the control keys for movement and rotation
        self.accept("escape", self.doExit)
        self.accept("a", self.setKey, ["left", 1])
        self.accept("d", self.setKey, ["right", 1])
        self.accept("w", self.setKey, ["forward", 1])
        self.accept("s", self.setKey, ["backward", 1])
        self.accept("arrow_left", self.setKey, ["cam-left", 1])
        self.accept("arrow_right", self.setKey, ["cam-right", 1])
        self.accept("a-up", self.setKey, ["left", 0])
        self.accept("d-up", self.setKey, ["right", 0])
        self.accept("w-up", self.setKey, ["forward", 0])
        self.accept("s-up", self.setKey, ["backward", 0])
        self.accept("arrow_left-up", self.setKey, ["cam-left", 0])
        self.accept("arrow_right-up", self.setKey, ["cam-right", 0])
        self.accept("h", self.setKey, ["hello", 1])
        self.accept("h-up", self.setKey, ["hello", 0])
        self.accept("0", self.setKey, ["chat0", 1])
        self.accept("0-up", self.setKey, ["chat0", 0])
        self.accept("1", self.setKey, ["powerup", 1])
        self.accept("1-up", self.setKey, ["powerup", 0])
        self.accept("2", self.setKey, ["powerup", 2])
        self.accept("2-up", self.setKey, ["powerup", 0])
        self.accept("3", self.setKey, ["powerup", 3])
        self.accept("3-up", self.setKey, ["powerup", 0])
        self.accept("r", self.doReset)
        self.accept("p", self.setTime)

        #taskMgr.add(self.move, "moveTask")

        # Game state variables
        self.isMoving = False

        # Sky Dome
        self.sky = SkyDome()

        # Set up the camera
        self.camera = Camera(self.mainChar)
        #base.disableMouse()
        #base.camera.setPos(self.mainChar.getX(), self.mainChar.getY() + 10, self.mainChar.getZ() + 2)

        # Create some lighting
        ambientLight = AmbientLight("ambientLight")
        ambientLight.setColor(Vec4(.3, .3, .3, 1))
        directionalLight = DirectionalLight("directionalLight")
        directionalLight.setDirection(Vec3(-5, -5, -5))
        directionalLight.setColor(Vec4(1, 1, 1, 1))
        directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
        directionalLight2 = DirectionalLight("directionalLight2")
        directionalLight2.setDirection(Vec3(5, 5, -5))
        directionalLight2.setColor(Vec4(1, 1, 1, 1))
        directionalLight2.setSpecularColor(Vec4(1, 1, 1, 1))
        render.setLight(render.attachNewNode(ambientLight))
        render.setLight(render.attachNewNode(directionalLight))
        render.setLight(render.attachNewNode(directionalLight2))

        # Game initialisation
        self.gameState = self.gameStateDict["Login"]
        self.responseValue = -1

        self.cManager.sendRequest(Constants.CMSG_LOGIN, [self.login, "1234"])
        taskMgr.add(self.enterGame, "EnterGame")

        # Create Powerups
        self.createPowerups()
        taskMgr.add(self.powerups.checkPowerPickup, "checkPowerupTask")
        taskMgr.add(self.usePowerup, "usePowerUp")
Ejemplo n.º 14
0
def dashboard():
    return Dashboard.home(mysql)
Ejemplo n.º 15
0
 def back(self):
     self.window = QtWidgets.QMainWindow()
     self.ui = Dashboard.Ui_DashboardWindow(self.window, self.rawData)
     self.ui.setupUi(self.window)
     self.wind.close()
     self.window.show()
    for item in AllArticles:
        try:
            wr.writerow(item)
        except:
            continue

#Relevancy
df_unique = Relevancy.RemoveDuplicates(stocks, df_articles)
endtime = datetime.now()
print('EndTime After Relevancy : ')
print(endtime)

# sentiment scoring
df_unique = SentimentScoring.ScoreArticles(df_unique)
endtime = datetime.now()
print('EndTime after Sentiment scoring: ')
print(endtime)

# tweet sentiment scoring
tweet_df = StockTwits.GetTweetSentiment(stocks)
endtime = datetime.now()
print('EndTime after Sentiment scoring: ')
print(endtime)

#Dashboard
df_unique['Score'] = df_unique['Score'].apply(lambda x: round(x, 2))
Dashboard.CreateDashboardWithTweets(stocks, df_unique, tweet_df)
endtime = datetime.now()
print('EndTime after creating Dashboard: ')
print(endtime)
Ejemplo n.º 17
0
from tkinter import *
from Constants import *
from Dashboard import *
from Window import *

root = Tk()
window = Dashboard(root)
root.title(APP_TITLE)

root.resizable(False, False)  #disabling window resize
root.configure(background=PRIMARY)

root.geometry('{}x{}'.format(WINDOW_WIDTH, WINDOW_HEIGHT))
root.grid_rowconfigure(1, weight=1)
root.grid_columnconfigure(0, weight=1)
root.mainloop()
Ejemplo n.º 18
0
from ControllerLibrary import LoadHardwareConfiguration
from DatabaseTools import DatabaseInterface
from multiprocessing import Process, Manager

if __name__ == '__main__':
    #ControllerFrontend = FrontEnd.initialize_frontend()
    #ControllerFrontend.run_server(debug=True)
    #LoadHardwareConfiguration()
    hardware_configuration = LoadHardwareConfiguration()
    Controllers.registerProxy('DBConnection', DatabaseInterface,
                              Controllers.DatabaseInterfaceProxy,
                              Controllers.TankControllerManager)
    # Controllers.registerProxy('Synchronizer', Controllers.Synchronizer, Controllers.SynchronizerProxy,
    #                           Controllers.TankControllerManager)

    SystemManager = Controllers.TankControllerManager()
    SystemManager.start()

    #DatabaseConnector = SystemManager.DBConnection()
    ProcessSynchronizer = Controllers.Synchronizer(SystemManager)
    ProcessSynchronizer.database_connector = SystemManager.DBConnection()

    SystemController = Controllers.TankController(ProcessSynchronizer,
                                                  hardware_configuration)
    #SystemController.start()

    TankControllerFrontEnd, TankControllerSharedMemory = Dashboard.InitializeFrontend(
        hardware_configuration=hardware_configuration,
        system_manager=SystemManager,
        synchronizer=ProcessSynchronizer)
    TankControllerFrontEnd.run_server(debug=True, port=8080, host='0.0.0.0')