本文整理汇总了Python中DataManager.DataManager.getLatestRainfall方法的典型用法代码示例。如果您正苦于以下问题:Python DataManager.getLatestRainfall方法的具体用法?Python DataManager.getLatestRainfall怎么用?Python DataManager.getLatestRainfall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataManager.DataManager
的用法示例。
在下文中一共展示了DataManager.getLatestRainfall方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calculateNeededGallons
# 需要导入模块: from DataManager import DataManager [as 别名]
# 或者: from DataManager.DataManager import getLatestRainfall [as 别名]
def calculateNeededGallons():
result = []
recentWateringGallons = DataManager.getPreviousWateringAmounts(pymysql.connect(host='localhost',
user='root',
password='',
db='Garden',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor))
sectorTargets = DataManager.getTargetCapacity(pymysql.connect(host='localhost',
user='root',
password='',
db='Garden',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor))
previousRain = DataManager.getLatestRainfall(pymysql.connect(host='localhost',
user='root',
password='',
db='Garden',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor))
predictedRain = DataManager.getPredictedRainfall(pymysql.connect(host='localhost',
user='root',
password='',
db='Garden',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor))
currentMoistures = DataManager.getLatestMoisture(pymysql.connect(host='localhost',
user='root',
password='',
db='Garden',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor))
for x in range(0, 4):
currentGallons = (previousRain * 280) + recentWateringGallons[x + 1]
if currentMoistures[x] > sectorTargets[x]:
result.insert(x, 0)
elif currentGallons > 280:
result.insert(x, 0)
else:
if (predictedRain[1] * 280) * (predictedRain[0]/Decimal(100)) + currentGallons > 280:
result.insert(x, 0)
else:
result.insert(x, 280 - ((predictedRain[1] * 280) * (predictedRain[0]/Decimal(100)) + currentGallons))
print((predictedRain[1] * 280) * (predictedRain[0]/Decimal(100)) + currentGallons)
return result