Add energy api and test

This commit is contained in:
WQY\qiong
2022-11-04 13:10:31 +08:00
parent e8abbef5a6
commit 47e029e118
6 changed files with 791 additions and 167 deletions

View File

@@ -1,33 +1,31 @@
-- [ENERGY]
create type energy_param as enum ('PRICE', 'PATTERN', 'EFFIC');
-- GLOBAL PRICE / PATTERN / EFFIC value
create table energy_global
(
param energy_param not null
, value numeric not null
_no integer primary key
, price numeric not null
, pattern varchar(32) references _pattern(id)
, effic numeric not null
, demand_charge numeric not null
);
-- PUMP pumpID PRICE / PATTERN / EFFIC value
create table energy_pump
insert into energy_global (_no, price, pattern, effic, demand_charge)
values (0, 0.0, null, 75, 0.0);
create table energy_pump_price
(
id varchar(32) references pumps(id) not null
, param energy_param not null
, value numeric not null
id varchar(32) primary key references pumps(id) not null
, price numeric not null
);
-- DEMAND CHARGE value
create table energy_demand_charge
create table energy_pump_pattern
(
value numeric not null
id varchar(32) primary key references pumps(id) not null
, pattern varchar(32) references _pattern(id) not null
);
insert into energy_global (param, value) values
('PRICE', 0.0)
, ('EFFIC', 75)
;
insert into energy_demand_charge values
(0.0)
;
create table energy_pump_effic
(
id varchar(32) primary key references pumps(id) not null
, effic varchar(32) references _curve(id) not null
);

View File

@@ -1,9 +1,7 @@
-- [ENERGY]
drop table if exists energy_demand_charge;
drop table if exists energy_pump;
drop table if exists energy_pump_effic;
drop table if exists energy_pump_pattern;
drop table if exists energy_pump_price;
drop table if exists energy_global;
drop type if exists energy_param;