Esempio n. 1
0
def harvest_ready(new_plants_status: dict):
    for ring_colour in new_plants_status:
        plant = Plant.parse_obj(new_plants_status[ring_colour])
        if plant.growthStage ==  GrowthStage.harvest:
            # As long as there is harvest stage for any plant inform
            return True
    return False
Esempio n. 2
0
async def cv_inference(pot_id, encoded_img_data):
    if CV_SERVER_URL_PREFIX == None:
        raise Exception("CV_SERVER_URL_PREFIX not set")
    data = { "potId": pot_id, "encoded_data": encoded_img_data }
    async with aiohttp.request(method='GET', url=CV_SERVER_URL_PREFIX, json=data) as resp:
        if resp.status == 200:
            response = await resp.json()
            
            for ring_colour in response:
                try:
                    Plant.parse_obj(response[ring_colour]) # Validate data with model
                except Exception as e:
                    raise Exception("CV server's response validation error")
            return response
        else:
            response = await resp.json()
            logger.error("Respose status={}, response={}".format(resp.status, response))
            raise Exception("Something went wrong in CV Server")
Esempio n. 3
0
def to_show_trim(new_plants_status):
    after_check_trim_status = {}
    for ring_colour in new_plants_status:
        if new_plants_status[ring_colour] == None:
            plant = None
        else:
            plant = Plant.parse_obj(new_plants_status[ring_colour])
            if plant.yellowness.value > 0.3:
                plant.yellowness.toShowTrim = True
        after_check_trim_status[ring_colour] = plant.dict() if plant != None else plant
            
    return after_check_trim_status