Plant#plant_stage

pull/697/head
Rick Carlino 2018-03-05 11:15:56 -06:00
parent d90c29af8a
commit 661430298c
12 changed files with 32 additions and 13 deletions

View File

@ -7,6 +7,7 @@
module CeleryScriptSettingsBag module CeleryScriptSettingsBag
# List of all celery script nodes that can be used as a varaible... # List of all celery script nodes that can be used as a varaible...
ANY_VARIABLE = [:tool, :coordinate, :point, :identifier] ANY_VARIABLE = [:tool, :coordinate, :point, :identifier]
PLANT_STAGES = %w(planned planted harvested)
ALLOWED_PIN_MODES = [DIGITAL = 0, ANALOG = 1] ALLOWED_PIN_MODES = [DIGITAL = 0, ANALOG = 1]
ALLOWED_PIN_TYPES = [Peripheral, Sensor].map(&:name) ALLOWED_PIN_TYPES = [Peripheral, Sensor].map(&:name)
ALLOWED_RPC_NODES = %w(home emergency_lock emergency_unlock read_status ALLOWED_RPC_NODES = %w(home emergency_lock emergency_unlock read_status

View File

@ -1,8 +1,10 @@
class PointSerializer < ActiveModel::Serializer class PointSerializer < ActiveModel::Serializer
attributes :id, :created_at, :updated_at, :device_id, :meta, :name, attributes :id, :created_at, :updated_at, :device_id, :meta, :name,
:pointer_type, :radius, :x, :y, :z :pointer_type, :radius, :x, :y, :z
attribute :openfarm_slug, if: :plant? attribute :openfarm_slug, if: :plant?
attribute :planted_at, if: :plant? attribute :planted_at, if: :plant?
attribute :plant_stage, if: :plant?
attribute :tool_id, if: :tool_slot? attribute :tool_id, if: :tool_slot?
attribute :pullout_direction, if: :tool_slot? attribute :pullout_direction, if: :tool_slot?
@ -26,6 +28,10 @@ class PointSerializer < ActiveModel::Serializer
object.pointer.planted_at object.pointer.planted_at
end end
def plant_stage
object.pointer.plant_stage
end
def pullout_direction def pullout_direction
object.pointer.pullout_direction object.pointer.pullout_direction
end end

View File

@ -0,0 +1,6 @@
class AddPlantStageToPlants < ActiveRecord::Migration[5.1]
def change
add_column :plants, :plant_stage, :string, limit: 10, default: "planned",
presence: true
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180301222052) do ActiveRecord::Schema.define(version: 20180305170608) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -260,6 +260,7 @@ ActiveRecord::Schema.define(version: 20180301222052) do
t.string "openfarm_slug", limit: 280, default: "50", null: false t.string "openfarm_slug", limit: 280, default: "50", null: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "planted_at" t.datetime "planted_at"
t.string "plant_stage", limit: 10, default: "planned"
t.index ["created_at"], name: "index_plants_on_created_at" t.index ["created_at"], name: "index_plants_on_created_at"
end end

View File

@ -131,6 +131,7 @@ class CorpusEmitter
result.push(enum_type :DataChangeType, CeleryScriptSettingsBag::ALLOWED_CHAGES) result.push(enum_type :DataChangeType, CeleryScriptSettingsBag::ALLOWED_CHAGES)
result.push(enum_type :PointType, CeleryScriptSettingsBag::ALLOWED_POINTER_TYPE) result.push(enum_type :PointType, CeleryScriptSettingsBag::ALLOWED_POINTER_TYPE)
result.push(enum_type :AllowedPinTypes, CeleryScriptSettingsBag::ALLOWED_PIN_TYPES) result.push(enum_type :AllowedPinTypes, CeleryScriptSettingsBag::ALLOWED_PIN_TYPES)
result.push(enum_type :PlantStage, CeleryScriptSettingsBag::PLANT_STAGES)
File.open("latest_corpus.ts", "w") do |f| File.open("latest_corpus.ts", "w") do |f|
f.write(result.join.gsub("\n\n\n", "\n").gsub("\n\n", "\n").strip) f.write(result.join.gsub("\n\n\n", "\n").gsub("\n\n", "\n").strip)

View File

@ -53,7 +53,7 @@
"enzyme": "^3.1.0", "enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.1.0", "enzyme-adapter-react-16": "^1.1.0",
"extract-text-webpack-plugin": "^3.0.1", "extract-text-webpack-plugin": "^3.0.1",
"farmbot": "5.4.0-rc3", "farmbot": "5.4.0-rc4",
"farmbot-toastr": "^1.0.3", "farmbot-toastr": "^1.0.3",
"fastclick": "^1.0.6", "fastclick": "^1.0.6",
"file-loader": "^1.1.5", "file-loader": "^1.1.5",

View File

@ -98,6 +98,7 @@ export function fakePlant(): TaggedPlantPointer {
id: idCounter++, id: idCounter++,
name: "Strawberry Plant 1", name: "Strawberry Plant 1",
pointer_type: "Plant", pointer_type: "Plant",
plant_stage: "planned",
x: 100, x: 100,
y: 200, y: 200,
z: 0, z: 0,

View File

@ -128,7 +128,6 @@ const tr7: TaggedPoint = {
"id": 1392, "id": 1392,
"created_at": "2017-05-24T20:41:19.804Z", "created_at": "2017-05-24T20:41:19.804Z",
"updated_at": "2017-05-24T20:41:19.804Z", "updated_at": "2017-05-24T20:41:19.804Z",
// "device_id": 415,
"meta": { "meta": {
}, },
@ -138,7 +137,8 @@ const tr7: TaggedPoint = {
"x": 347, "x": 347,
"y": 385, "y": 385,
"z": 0, "z": 0,
"openfarm_slug": "radish" "openfarm_slug": "radish",
"plant_stage": "planned"
}, },
"uuid": "Point.1392.6" "uuid": "Point.1392.6"
}; };
@ -159,7 +159,8 @@ const tr8: TaggedPoint = {
"x": 727, "x": 727,
"y": 376, "y": 376,
"z": 0, "z": 0,
"openfarm_slug": "garlic" "openfarm_slug": "garlic",
"plant_stage": "planned"
}, },
"uuid": "Point.1393.7" "uuid": "Point.1393.7"
}; };
@ -331,7 +332,7 @@ export let FAKE_RESOURCES: TaggedResource[] = [tr1, fakeDevice(), tr2, tr3, tr4,
export export
function buildResourceIndex(resources: TaggedResource[] = FAKE_RESOURCES, function buildResourceIndex(resources: TaggedResource[] = FAKE_RESOURCES,
state = emptyState()) { state = emptyState()) {
const KIND: keyof TaggedResource = "kind"; // Safety first, kids. const KIND: keyof TaggedResource = "kind"; // Safety first, kids.
return _(resources) return _(resources)
.groupBy(KIND) .groupBy(KIND)

View File

@ -16,6 +16,7 @@ export function Plant(options: PlantOptions): PlantPointer {
y: (options.y || 0), y: (options.y || 0),
z: 0, z: 0,
radius: (options.radius || DEFAULT_PLANT_RADIUS), radius: (options.radius || DEFAULT_PLANT_RADIUS),
openfarm_slug openfarm_slug,
plant_stage: "planned"
}; };
} }

View File

@ -1,7 +1,7 @@
import { AuthState } from "./auth/interfaces"; import { AuthState } from "./auth/interfaces";
import { ConfigState } from "./config/interfaces"; import { ConfigState } from "./config/interfaces";
import { BotState } from "./devices/interfaces"; import { BotState } from "./devices/interfaces";
import { Color as FarmBotJsColor, ALLOWED_MESSAGE_TYPES } from "farmbot"; import { Color as FarmBotJsColor, ALLOWED_MESSAGE_TYPES, PlantStage } from "farmbot";
import { DraggableState } from "./draggable/interfaces"; import { DraggableState } from "./draggable/interfaces";
import { PeripheralState } from "./controls/peripherals/interfaces"; import { PeripheralState } from "./controls/peripherals/interfaces";
import { RestResources } from "./resources/interfaces"; import { RestResources } from "./resources/interfaces";
@ -108,7 +108,6 @@ interface BasePoint {
x: number; x: number;
y: number; y: number;
z: number; z: number;
// device_id: number;
pointer_id?: number | undefined; pointer_id?: number | undefined;
meta: { [key: string]: (string | undefined) }; meta: { [key: string]: (string | undefined) };
name: string; name: string;
@ -118,6 +117,7 @@ export interface PlantPointer extends BasePoint {
openfarm_slug: string; openfarm_slug: string;
pointer_type: "Plant"; pointer_type: "Plant";
planted_at?: string; planted_at?: string;
plant_stage: PlantStage;
} }
export enum ToolPulloutDirection { export enum ToolPulloutDirection {

View File

@ -16,7 +16,8 @@ export function fakeResourceIndex(): ResourceIndex {
"x": 1, "x": 1,
"y": 2, "y": 2,
"z": 3, "z": 3,
"openfarm_slug": "garlic" "openfarm_slug": "garlic",
"plant_stage": "planned"
}, },
"uuid": "plant" "uuid": "plant"
}, },

View File

@ -2258,9 +2258,9 @@ farmbot-toastr@^1.0.0, farmbot-toastr@^1.0.3:
farmbot-toastr "^1.0.0" farmbot-toastr "^1.0.0"
typescript "^2.3.4" typescript "^2.3.4"
farmbot@5.4.0-rc3: farmbot@5.4.0-rc4:
version "5.4.0-rc3" version "5.4.0-rc4"
resolved "https://registry.yarnpkg.com/farmbot/-/farmbot-5.4.0-rc3.tgz#5d3024f5234d7b22ebe77867cd1edb0e7e1d577e" resolved "https://registry.yarnpkg.com/farmbot/-/farmbot-5.4.0-rc4.tgz#478275c12875afcbb8e88a970c449f8c911dce0a"
dependencies: dependencies:
mqtt "2.15.0" mqtt "2.15.0"
typescript "^2.4.2" typescript "^2.4.2"