コード例 #1
0
ファイル: Adversario.py プロジェクト: felipeap/iCruzeiro
 def adversarioExiste(self, jogo):
     jsonQuery = {'nome': jogo.adversario}
     cursor = Database().getdata(jsonQuery, 0, "Adversarios")
     if cursor.count() > 0:
         return cursor.next()
     self.cadastraNovoAdversario(jogo)
     return self.__dict__
コード例 #2
0
	def leitura(self):
		print "blaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
		json_query = {}
		sortby =[['proprietario', pymongo.ASCENDING]]
		cursor = Database().getdata(json_query, sortby, collection="Rastreadores")
		print cursor.count()
		listaProdutos = list(cursor)
		return listaProdutos
コード例 #3
0
 def jogoExiste(self):
     query = {'ident': self.ident}
     col = "Jogos"
     cursor = Database().getdata(query=query, sortby=0, collection=col)
     if cursor.count() == 0:
         return True
     else:
         return False
コード例 #4
0
 def proxIdent(self, col):
     jsonQuery = {}
     sortby = [("ident", pymongo.DESCENDING)]
     cursor = Database().getdata(jsonQuery, sortby, col)
     if cursor.count() == 0:
         return 1
     else:
         for pos in cursor:
             return pos["ident"] + 1
コード例 #5
0
    def leitura(self):
        StartDateInt = int(Utils().set_DatetimeToInt(self.dtinf))
        EndDateInt = int(Utils().set_DatetimeToInt(self.dtsup))

        json_query = {
            'deviceID': int(self.serial),
            'dateTime': {
                '$gte': StartDateInt,
                '$lte': EndDateInt
            }
        }
        sortby = [['dateTime', pymongo.DESCENDING]]
        cursor = Database().getdata(json_query, sortby, collection="DataMaxPB")

        print cursor.count()
        lines = []
        if cursor.count() > 0:
            for doc in cursor:
                pacoteData = Pacote_Data()

                pacoteData.deviceID = int(self.serial)
                pacoteData.seqNumber = Utils().get_memoryindex(doc)
                pacoteData.reason = Utils().get_event(doc)
                pacoteData.datetime = Utils().get_devdate(doc)
                pacoteData.unixTime = doc["dateTime"]
                pacoteData.gtwDate = Utils().get_gtwdate(doc)
                pacoteData.ignition = Utils().get_ignition(doc)
                pacoteData.gpsFix = Utils().get_gpsfix(doc)
                pacoteData.gprsFix = Utils().get_gprsfix(doc)
                pacoteData.lat = float(
                    float(doc["positionInfo"][0]["latitude"]) / 10000000)
                pacoteData.long = float(
                    float(doc["positionInfo"][0]["longitude"]) / 10000000)
                pacoteData.moving = Utils().get_gsensor(doc)
                pacoteData.speed = Utils().get_speed(doc)
                pacoteData.csq = Utils().get_csq(doc)
                pacoteData.extPower = Utils().get_extpower(doc)
                pacoteData.battery = Utils().get_battery(doc)
                pacoteData.batteryState = Utils().get_batteryState(doc)
                pacoteData.uptime = Utils().get_uptime(doc)
                pacoteData.hdop = Utils().get_hdop(doc)
                pacoteData.snr = Utils().get_snr(doc)
                pacoteData.svn = Utils().get_svn(doc)
                lines.append(pacoteData.__dict__)

        return lines
コード例 #6
0
ファイル: Adversario.py プロジェクト: felipeap/iCruzeiro
    def atualizaEstatisticas(self, jogo, adversario):
        adversario["jogos"] = adversario["jogos"] + 1
        adversario["golsFeitos"] = adversario["golsFeitos"] + int(
            jogo.placarCruzeiro)
        adversario["golsSofridos"] = adversario["golsSofridos"] + int(
            jogo.placarAdv)

        if jogo.placarCruzeiro > jogo.placarAdv:
            adversario["vitorias"] = adversario["vitorias"] + 1
        elif jogo.placarCruzeiro == jogo.placarAdv:
            adversario["empates"] = adversario["empates"] + 1
        else:
            adversario["derrotas"] = adversario["derrotas"] + 1
        Database().updatedata({"ident": adversario["ident"]}, adversario,
                              "Adversarios")
コード例 #7
0
 def toMongo(self):
     Database().add(self, "Jogos")
コード例 #8
0
    def leitura(self):
        StartDateInt = int(Utils().set_DatetimeToInt(self.dtinf))
        EndDateInt = int(Utils().set_DatetimeToInt(self.dtsup))

        json_query = {
            'dev_id': int(self.serial),
            'date_dev': {
                '$gte': self.dtinf,
                '$lte': self.dtsup
            }
        }
        sortby = [['date_dev', pymongo.ASCENDING]]
        print "pre db"
        cursor = Database().getdata(json_query, sortby, collection="Pontos")
        print cursor.count()
        lines = []
        first = True
        if cursor.count() > 0:
            for doc in cursor:
                gprs = Utils().get_gprsfix(doc)
                ignition = Utils().get_ignition(doc)
                evento = Utils().get_event(doc)
                pos = Utils().get_memoryindex(doc)

                if first or lastPos != pos:
                    first = False
                    lastPos = pos

                    speed = Utils().get_speed(doc)
                    gps = Utils().get_gpsfix(doc)
                    date = Utils().get_devdate(doc)
                    # extPwr = Utils().get_extpower(doc)
                    # battery = Utils().get_battery(doc)
                    latitude = float(float(doc["lat"]) / 1000000)
                    longitude = float(float(doc["long"]) / 1000000)
                    stringInfo = "<b>Position</b>: " + str(pos) \
                               + "<br><b>Event:</b> "    + str(evento)  \
                               + "<br><b>Date:</b> "     + str(date) \
                               + "<br><b>Ignition: </b> "  + str(ignition) \
                               + "<br><b>Speed:</b> "  + str(speed) \
                               + "<br><b>GPS Fix:</b> "  + str(gps) \
                               + "<br><b>GPRS Fix:</b> "  + str(gprs)
                    # + "<br><b>Battery:</b> "  + str(battery) \
                    # + "<br><b>Ext Power:</b> "  + str(extPwr)
                    type = self.getType(doc)
                    mapdata = Map_Data(type, latitude, longitude, stringInfo)

                    route_reconstruct = doc["route_rec"]
                    if route_reconstruct.__len__() > 0:
                        for rec_cursor in route_reconstruct:
                            lat_rec = float(float(rec_cursor["lat"]) / 1000000)
                            long_rec = float(
                                float(rec_cursor["long"]) / 1000000)
                            string_info_rec = "<b>Position : </b> "  + str(pos) \
                                            + "<br><b>Date : </b> "  + str(rec_cursor["date"]) \
                                            + "<br><b>Speed: </b> "  + str(rec_cursor["speed"])
                            point_reconstruct = Map_Data(
                                0, lat_rec, long_rec, string_info_rec)
                            lines.append(point_reconstruct)
                    lines.append(mapdata.__dict__)

        return lines
コード例 #9
0
ファイル: Adversario.py プロジェクト: felipeap/iCruzeiro
 def toMongo(self):
     Database().add(self, "Adversarios")