-- Table: public.syncmotor_bay

-- DROP
DROP TABLE IF EXISTS public.syncmotor_bay;
DROP SEQUENCE IF EXISTS public.syncmotor_bay_id_seq;
DROP TYPE IF EXISTS public.varible;

-- CREATE

CREATE TYPE public.varible AS
(
	device character varying(64),
	terminal_idx integer,
	value double precision
);
ALTER TYPE public.varible
    OWNER TO postgres;

CREATE SEQUENCE IF NOT EXISTS public.syncmotor_bay_id_seq;

CREATE TABLE IF NOT EXISTS public.syncmotor_bay
(
    id integer NOT NULL DEFAULT nextval('syncmotor_bay_id_seq'::regclass),
    component_id integer NOT NULL,

    dev_protect jsonb NOT NULL DEFAULT '{}'::jsonb,
    dev_scada jsonb NOT NULL DEFAULT '{}'::jsonb,
    dev_intelligent jsonb NOT NULL DEFAULT '{}'::jsonb,
    dev_recording jsonb NOT NULL DEFAULT '{}'::jsonb,
    dev_status jsonb NOT NULL DEFAULT '{}'::jsonb,
    dev_etc jsonb NOT NULL DEFAULT '{}'::jsonb,

    "v_Ia" varible NOT NULL,
    "v_Ib" varible NOT NULL,
    "v_Ic" varible NOT NULL, 
    "v_I0" varible NOT NULL,
    "v_I1" varible NOT NULL,
    "v_I2" varible NOT NULL, 

    "v_Ua" varible NOT NULL,
    "v_Ub" varible NOT NULL, 
    "v_Uc" varible NOT NULL,
    "v_U0" varible NOT NULL,
    "v_U1" varible NOT NULL,
    "v_U2" varible NOT NULL,
    "v_Uab" varible NOT NULL,
    "v_Ubc" varible NOT NULL,
    "v_Uca" varible NOT NULL,  
    "v_Uarrow" varible NOT NULL,    

    "v_IA" varible NOT NULL,
    "v_IB" varible NOT NULL,
    "v_IC" varible NOT NULL, 
    "v_I0p" varible NOT NULL,
    "v_I1p" varible NOT NULL,
    "v_I2p" varible NOT NULL, 
    "v_In" varible NOT NULL, 

    "v_IpA" varible NOT NULL,
    "v_IpB" varible NOT NULL,
    "v_IpC" varible NOT NULL, 

    "v_UA" varible NOT NULL,
    "v_UB" varible NOT NULL,
    "v_UC" varible NOT NULL,
    "v_U0p" varible NOT NULL,
    "v_U1p" varible NOT NULL,
    "v_U2p" varible NOT NULL,
    "v_UAB" varible NOT NULL,
    "v_UBC" varible NOT NULL,
    "v_UCA" varible NOT NULL,
    "v_Uarrowp" varible NOT NULL,

    "v_P" varible NOT NULL,
    "v_Q" varible NOT NULL,
    "v_S" varible NOT NULL,
    "v_PF" varible NOT NULL,

    "v_f" varible NOT NULL,
    "v_df_per_dt" varible NOT NULL,

    "v_Temp" varible NOT NULL,
    "v_PD" varible NOT NULL,
    "v_Vsp" varible NOT NULL,

    "v_TL" varible NOT NULL,
    "v_n" varible NOT NULL,
    "v_s" varible NOT NULL,

    op integer NOT NULL DEFAULT '-1'::integer,
    ts timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,

    CONSTRAINT syncmotor_bay_id_PrimaryKey PRIMARY KEY (id),
    CONSTRAINT syncmotor_bay_ForeignKey_component_id FOREIGN KEY (component_id)
        REFERENCES public.component (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.syncmotor_bay
    OWNER to postgres;

COMMENT ON TABLE public.syncmotor_bay
    IS '存储异步电动机的间隔信息';

