Exemple #1
0
    def RecordData():
        cookId = CookDL.getCurrentCookId()
        
        # if DEBUG:
        #     print("CookId: {0}".format(cookId))

        if cookId > 0:
            
            # Number of samplet to take
            numOfSamples = 3

            tempSamples = []
            tempFinal = []

            for i in range(numOfSamples):
                tempSamples.append(HWTempDL.getTemps())
                tempFinal.append(0.0)

            for tempSample in tempSamples:
                tempSampleCount = 0
                for temp in tempSample:
                    tempFinal[tempSampleCount] = tempFinal[tempSampleCount] + temp
                    tempSampleCount = tempSampleCount + 1

            tempSampleCount = 0
            for temp in tempFinal:
                tempFinal[tempSampleCount] = tempFinal[tempSampleCount] / numOfSamples
                tempSampleCount = tempSampleCount + 1

            TempDL.logTemps(tempFinal, cookId)
        
        return jsonify('OK')
Exemple #2
0
def SetCookData():
    temps = json.loads(request.json)
    cookId = CookDL.getCurrentCookId()
    print(cookId)
    print(temps)

    if (cookId > 0):
        TempDL.logTemps(temps, cookId)

    return jsonify({"Status": "OK"})
Exemple #3
0
def editcook():
    currentCookId = CookDL.getCurrentCookId()

    if request.method == "POST":
        if currentCookId == 0:
            title = request.form["title"]
            smokerTarget = request.form["smokerTarget"]
            target = request.form["target"]
            CookDL.startCook(title, smokerTarget, target)
            cookId = CookDL.getCurrentCookId()
            SMSession.setCookId(cookId)
        else:
            CookDL.endCurrentCook()

        return redirect(url_for('smomo.index'))

    else:
        cook = CookDL.getCook(currentCookId)
        subs = SubscriptionDL.getSubscriptionsForCook(currentCookId)
        title = cook.Title
        return render_template('smomo/editcook.html', cook=cook, subs=subs)
Exemple #4
0
def index():
    cookId = SMSession.getCookId()

    if cookId == 0:
        cookId = CookDL.getCurrentCookId()
        SMSession.setCookId(cookId)

    currentCook = CookDL.getCook(cookId)

    return render_template('smomo/index.html',
                           cook=currentCook,
                           currentDT=datetime.now())
Exemple #5
0
    def startcook():
        currentCookId = CookDL.getCurrentCookId()

        if request.method == "POST":
            if currentCookId == 0:
                title = request.form["title"]
                smokerTarget =  request.form["smokerTarget"]
                target =  request.form["target"]
                CookDL.startCook(title, smokerTarget, target)
                cookId = CookDL.getCurrentCookId()
                SMSession.setCookId(cookId)
                
            else:
                CookDL.endCurrentCook()    
            return redirect(url_for('index'))

        else:
            if currentCookId == 0:
                return render_template('startcook.html')
            else:
                cook = CookDL.getCook(currentCookId)
                title = cook.Title
                return render_template('endcook.html', title=title)
Exemple #6
0
    def index():
        cookId = SMSession.getCookId()
        
        if cookId == 0:
            cookId = CookDL.getCurrentCookId()
            SMSession.setCookId(cookId)
        
        currentCook = CookDL.getCook(cookId)

        latestTime = datetime(2019,1,1)
        latestTemp = [0, 0, 0]
        minTemp = [9999, 9999, 9999]
        maxTemp = [0, 0, 0]
        temps = []

        if currentCook.CookId > 0:
            temps = TempDL.getTempsForCook(currentCook.CookId)

            for x in temps:
                if x.EventDate > latestTime:
                    latestTime = x.EventDate
                    latestTemp[0] = x.Temp1
                    latestTemp[1] = x.Temp2
                    latestTemp[2] = x.Temp3
                """
                if x.Temp < minTemp[x.SensorNum]:
                    minTemp[x.SensorNum] = x.Temp
                
                if x.Temp > maxTemp[x.SensorNum]:
                    maxTemp[x.SensorNum] = x.Temp
                """
                
        return render_template('index.html', cook = currentCook, 
                                                latestTime = latestTime,
                                                latestTemp = latestTemp,
                                                minTemp = minTemp,
                                                maxTemp = maxTemp,
                                                temps = temps,
                                                values=temps,
                                                currentDT=datetime.now())