コード例 #1
0
ファイル: DB.py プロジェクト: DarkCarlos/Farmwares_FB
 def upload_plants(self):
     """Add plants to FarmBot Web App Farm Designer."""
     point_ids = []
     for plant in self.plants['remove']:
         point_ids = self.upload_point(plant, 'Weed', point_ids)
     for plant in self.plants['save']:
         point_ids = self.upload_point(plant, 'Detected Plant', point_ids)
     # for plant in self.plants['known']:
     #     point_ids = self.upload_point(plant, 'Known Plant', point_ids)
     for plant in self.plants['safe_remove']:
         point_ids = self.upload_point(plant, 'Safe-Remove Weed', point_ids)
     self.api_response_error_printer()
     if point_ids:
         # Points have been added to the web app
         # Indicate that a sync is required for the points
         CeleryPy.data_update('points', point_ids)
コード例 #2
0
 def setUp(self):
     # add_point
     self.add_point = CeleryPy.add_point(
         point_x=1, point_y=2, point_z=3, point_r=4)
     self.add_point_static = {
         "kind": "add_point",
         "args": {
             "radius": 4,
             "location": {
                 "kind": "coordinate",
                 "args": {
                     "x": 1,
                     "y": 2,
                     "z": 3
                 }
             }
         },
         "body": [
             {
                 "kind": "pair",
                 "args": {
                     "label": "created_by",
                     "value": "plant-detection"
                 }
             }
         ]
     }
     # set_user_env
     self.set_env_var = CeleryPy.set_user_env(
         label='PLANT_DETECTION_options', value=json.dumps({"in": "puts"}))
     self.set_env_var_static = {
         "kind": "set_user_env",
         "args": {},
         "body": [
             {
                 "kind": "pair",
                 "args": {
                     "label": "PLANT_DETECTION_options",
                     "value": "{\"in\": \"puts\"}"
                 }
             }
         ]
     }
     # move_absolute: coordinate
     self.move_absolute_coordinate = CeleryPy.move_absolute(
         location=[10, 20, 30],
         offset=[40, 50, 60],
         speed=800)
     self.move_absolute_coordinate_static = {
         "kind": "move_absolute",
         "args": {
             "location": {
                 "kind": "coordinate",
                 "args": {
                     "x": 10,
                     "y": 20,
                     "z": 30
                 }
             },
             "offset": {
                 "kind": "coordinate",
                 "args": {
                     "x": 40,
                     "y": 50,
                     "z": 60
                 }
             },
             "speed": 800
         }
     }
     # move_absolute: tool
     self.move_absolute_tool = CeleryPy.move_absolute(
         location=['tool', 1],
         offset=[40, 50, 60],
         speed=800)
     self.move_absolute_tool_static = {
         "kind": "move_absolute",
         "args": {
             "location": {
                 "kind": "tool",
                 "args": {
                     "tool_id": 1
                 }
             },
             "offset": {
                 "kind": "coordinate",
                 "args": {
                     "x": 40,
                     "y": 50,
                     "z": 60
                 }
             },
             "speed": 800
         }
     }
     # move_absolute: plant
     self.move_absolute_plant = CeleryPy.move_absolute(
         location=['Plant', 1],
         offset=[40, 50, 60],
         speed=800)
     self.move_absolute_plant_static = {
         "kind": "move_absolute",
         "args": {
             "location": {
                 "kind": "point",
                 "args": {
                     "pointer_type": "Plant",
                     "pointer_id": 1
                 }
             },
             "offset": {
                 "kind": "coordinate",
                 "args": {
                     "x": 40,
                     "y": 50,
                     "z": 60
                 }
             },
             "speed": 800
         }
     }
     # move_absolute: point
     self.move_absolute_point = CeleryPy.move_absolute(
         location=['GenericPointer', 1],
         offset=[40, 50, 60],
         speed=800)
     self.move_absolute_point_static = {
         "kind": "move_absolute",
         "args": {
             "location": {
                 "kind": "point",
                 "args": {
                     "pointer_type": "GenericPointer",
                     "pointer_id": 1
                 }
             },
             "offset": {
                 "kind": "coordinate",
                 "args": {
                     "x": 40,
                     "y": 50,
                     "z": 60
                 }
             },
             "speed": 800
         }
     }
     # move_relative
     self.move_relative = CeleryPy.move_relative(
         distance=(100, 200, 300), speed=800)
     self.move_relative_static = {
         "kind": "move_relative",
         "args": {
             "x": 100,
             "y": 200,
             "z": 300,
             "speed": 800
         }
     }
     # data_update: all
     self.data_update = CeleryPy.data_update(endpoint='points')
     self.data_update_static = {
         "kind": "data_update",
         "args": {
             "value": "update"
         },
         "body": [
             {
                 "kind": "pair",
                 "args": {
                     "label": "points",
                     "value": "*"
                 }
             }
         ]
     }
     # data_update: one
     self.data_update_id = CeleryPy.data_update(endpoint='points', ids_=101)
     self.data_update_id_static = {
         "kind": "data_update",
         "args": {
             "value": "update"
         },
         "body": [
             {
                 "kind": "pair",
                 "args": {
                     "label": "points",
                     "value": "101"
                 }
             }
         ]
     }
     # data_update: ids
     self.data_update_list = CeleryPy.data_update(
         endpoint='points', ids_=[123, 456, 789])
     self.data_update_list_static = {
         "kind": "data_update",
         "args": {
             "value": "update"
         },
         "body": [
             {
                 "kind": "pair",
                 "args": {
                     "label": "points",
                     "value": "123"
                 }
             },
             {
                 "kind": "pair",
                 "args": {
                     "label": "points",
                     "value": "456"
                 }
             },
             {
                 "kind": "pair",
                 "args": {
                     "label": "points",
                     "value": "789"
                 }
             }
         ]
     }
     # send_message: logs
     self.send_message = CeleryPy.send_message(
         message='Hello', message_type='fun')
     self.send_message_static = {
         "kind": "send_message",
         "args": {
             "message": "Hello",
             "message_type": "fun"
         }
     }
     # send_message: toast
     self.send_message_toast = CeleryPy.send_message(
         message='Hello', message_type='fun', channel='toast')
     self.send_message_toast_static = {
         "kind": "send_message",
         "args": {
             "message": "Hello",
             "message_type": "fun"
         },
         "body": [
             {
                 "kind": "channel",
                 "args": {
                     "channel_name": "toast"
                 }
             }
         ]
     }
     # send_message: channels
     self.send_message_channels = CeleryPy.send_message(
         message='Hello', message_type='fun', channel=['toast', 'email'])
     self.send_message_channels_static = {
         "kind": "send_message",
         "args": {
             "message": "Hello",
             "message_type": "fun"
         },
         "body": [
             {
                 "kind": "channel",
                 "args": {
                     "channel_name": "toast"
                 }
             },
             {
                 "kind": "channel",
                 "args": {
                     "channel_name": "email"
                 }
             }
         ]
     }
     # find_home
     self.find_home = CeleryPy.find_home(axis='all', speed=100)
     self.find_home_static = {
         "kind": "find_home",
         "args": {
             "axis": "all",
             "speed": 100
         }
     }
     # _if: execute
     self.if_statement = CeleryPy.if_statement(
         lhs='x', op='is', rhs=0, _then=1, _else=2)
     self.if_statement_static = {
         "kind": "_if",
         "args": {
             "lhs": "x",
             "op": "is",
             "rhs": 0,
             "_then": {
                 "kind": "execute",
                 "args": {
                     "sequence_id": 1
                 }
             },
             "_else": {
                 "kind": "execute",
                 "args": {
                     "sequence_id": 2
                 }
             }
         }
     }
     # _if: nothing
     self.if_statement_nothing = CeleryPy.if_statement(
         lhs='x', op='is', rhs=0)
     self.if_statement_nothing_static = {
         "kind": "_if",
         "args": {
             "lhs": "x",
             "op": "is",
             "rhs": 0,
             "_then": {
                 "kind": "nothing",
                 "args": {}
             },
             "_else": {
                 "kind": "nothing",
                 "args": {}
             }
         }
     }
     # write_pin
     self.write_pin = CeleryPy.write_pin(number=0, value=1)
     self.write_pin_static = {
         "kind": "write_pin",
         "args": {
             "pin_number": 0,
             "pin_value": 1,
             "pin_mode": 0
         }
     }
     # read_pin
     self.read_pin = CeleryPy.read_pin(number=0, mode=0, label='pin')
     self.read_pin_static = {
         "kind": "read_pin",
         "args": {
             "pin_number": 0,
             "pin_mode": 0,
             "label": "pin"
         }
     }
     # execute_sequence
     self.execute_sequence = CeleryPy.execute_sequence(sequence_id=1)
     self.execute_sequence_static = {
         "kind": "execute",
         "args": {
             "sequence_id": 1
         }
     }
     # execute_script
     self.execute_script = CeleryPy.execute_script(label='plant-detection')
     self.execute_script_static = {
         "kind": "execute_script",
         "args": {
             "label": "plant-detection"
         }
     }
     # take_photo
     self.take_photo = CeleryPy.take_photo()
     self.take_photo_static = {
         "kind": "take_photo",
         "args": {}
     }
     # wait
     self.wait = CeleryPy.wait(milliseconds=100)
     self.wait_static = {
         "kind": "wait",
         "args": {
             "milliseconds": 100
         }
     }