Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MyEMS
MyEMS能源管理系统
提交
ef49efe0
M
MyEMS能源管理系统
项目概览
MyEMS
/
MyEMS能源管理系统
通知
46
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
MyEMS能源管理系统
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ef49efe0
编写于
5月 05, 2024
作者:
nengyuangzhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added charge and discharge functions for energy storage power station in myems-aggregation
上级
c61f474b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
1713 addition
and
0 deletion
+1713
-0
myems-aggregation/energy_storage_power_station_billing_charge.py
...ggregation/energy_storage_power_station_billing_charge.py
+252
-0
myems-aggregation/energy_storage_power_station_billing_discharge.py
...egation/energy_storage_power_station_billing_discharge.py
+252
-0
myems-aggregation/energy_storage_power_station_carbon_charge.py
...aggregation/energy_storage_power_station_carbon_charge.py
+253
-0
myems-aggregation/energy_storage_power_station_carbon_discharge.py
...regation/energy_storage_power_station_carbon_discharge.py
+253
-0
myems-aggregation/energy_storage_power_station_energy_charge.py
...aggregation/energy_storage_power_station_energy_charge.py
+342
-0
myems-aggregation/energy_storage_power_station_energy_discharge.py
...regation/energy_storage_power_station_energy_discharge.py
+342
-0
myems-aggregation/main.py
myems-aggregation/main.py
+19
-0
未找到文件。
myems-aggregation/energy_storage_power_station_billing_charge.py
0 → 100644
浏览文件 @
ef49efe0
import
time
from
datetime
import
datetime
,
timedelta
from
decimal
import
Decimal
import
mysql.connector
import
config
import
tariff
########################################################################################################################
# PROCEDURES
# Step 1: get all energy storage power stations
# for each energy storage power station in list:
# Step 2: get the latest start_datetime_utc
# Step 3: get all charge energy data since the latest start_datetime_utc
# Step 4: get tariffs
# Step 5: calculate charge billing by multiplying energy with tariff
# Step 6: save charge billing data to database
########################################################################################################################
def
main
(
logger
):
while
True
:
# the outermost while loop
################################################################################################################
# Step 1: get all energy storage power stations
################################################################################################################
cnx_system_db
=
None
cursor_system_db
=
None
try
:
cnx_system_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_system_db
)
cursor_system_db
=
cnx_system_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.1 of energy_storage_power_station_billing_charge "
+
str
(
e
))
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS System Database"
)
energy_storage_power_station_list
=
list
()
try
:
cursor_system_db
.
execute
(
" SELECT id, name, cost_center_id "
" FROM tbl_energy_storage_power_stations "
" ORDER BY id "
)
rows_energy_storage_power_stations
=
cursor_system_db
.
fetchall
()
if
rows_energy_storage_power_stations
is
None
or
len
(
rows_energy_storage_power_stations
)
==
0
:
print
(
"Step 1.2: There isn't any energy storage power stations. "
)
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
for
row
in
rows_energy_storage_power_stations
:
energy_storage_power_station_list
.
append
({
"id"
:
row
[
0
],
"name"
:
row
[
1
],
"cost_center_id"
:
row
[
2
]})
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.2 of energy_storage_power_station_billing_charge "
+
str
(
e
))
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Step 1.2: Got all energy storage power stations from MyEMS System Database"
)
cnx_energy_db
=
None
cursor_energy_db
=
None
try
:
cnx_energy_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_energy_db
)
cursor_energy_db
=
cnx_energy_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.3 of energy_storage_power_station_billing_charge "
+
str
(
e
))
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS Energy Database"
)
cnx_billing_db
=
None
cursor_billing_db
=
None
try
:
cnx_billing_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_billing_db
)
cursor_billing_db
=
cnx_billing_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.4 of energy_storage_power_station_billing_charge "
+
str
(
e
))
if
cursor_billing_db
:
cursor_billing_db
.
close
()
if
cnx_billing_db
:
cnx_billing_db
.
close
()
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS Billing Database"
)
for
energy_storage_power_station
in
energy_storage_power_station_list
:
############################################################################################################
# Step 2: get the latest start_datetime_utc
############################################################################################################
print
(
"Step 2: get the latest start_datetime_utc from billing database for "
+
energy_storage_power_station
[
'name'
])
try
:
cursor_billing_db
.
execute
(
" SELECT MAX(start_datetime_utc) "
" FROM tbl_energy_storage_power_station_charge_hourly "
" WHERE energy_storage_power_station_id = %s "
,
(
energy_storage_power_station
[
'id'
],
))
row_datetime
=
cursor_billing_db
.
fetchone
()
start_datetime_utc
=
datetime
.
strptime
(
config
.
start_datetime_utc
,
'%Y-%m-%d %H:%M:%S'
)
start_datetime_utc
=
start_datetime_utc
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
if
row_datetime
is
not
None
and
len
(
row_datetime
)
>
0
and
isinstance
(
row_datetime
[
0
],
datetime
):
# replace second and microsecond with 0
# note: do not replace minute in case of calculating in half hourly
start_datetime_utc
=
row_datetime
[
0
].
replace
(
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
# start from the next time slot
start_datetime_utc
+=
timedelta
(
minutes
=
config
.
minutes_to_count
)
print
(
"start_datetime_utc: "
+
start_datetime_utc
.
isoformat
()[
0
:
19
])
except
Exception
as
e
:
logger
.
error
(
"Error in step 2 of energy_storage_power_station_billing_charge "
+
str
(
e
))
# break the for energy storage power station loop
break
############################################################################################################
# Step 3: get all charge energy data since the latest start_datetime_utc
############################################################################################################
print
(
"Step 3: get all charge energy data since the latest start_datetime_utc"
)
query
=
(
" SELECT start_datetime_utc, actual_value "
" FROM tbl_energy_storage_power_station_charge_hourly "
" WHERE energy_storage_power_station_id = %s AND start_datetime_utc >= %s "
" ORDER BY id "
)
cursor_energy_db
.
execute
(
query
,
(
energy_storage_power_station
[
'id'
],
start_datetime_utc
,
))
rows_hourly
=
cursor_energy_db
.
fetchall
()
if
rows_hourly
is
None
or
len
(
rows_hourly
)
==
0
:
print
(
"Step 3: There isn't any energy input data to calculate. "
)
# continue the for energy storage power station loop
continue
energy_dict
=
dict
()
end_datetime_utc
=
start_datetime_utc
for
row_hourly
in
rows_hourly
:
current_datetime_utc
=
row_hourly
[
0
]
actual_value
=
row_hourly
[
1
]
energy_dict
[
current_datetime_utc
]
=
actual_value
if
current_datetime_utc
>
end_datetime_utc
:
end_datetime_utc
=
current_datetime_utc
############################################################################################################
# Step 4: get tariffs
############################################################################################################
print
(
"Step 4: get tariffs"
)
tariff_dict
=
dict
()
tariff_dict
[
1
]
=
tariff
.
get_energy_category_tariffs
(
energy_storage_power_station
[
'cost_center_id'
],
1
,
start_datetime_utc
,
end_datetime_utc
)
############################################################################################################
# Step 5: calculate charge billing by multiplying energy with tariff
############################################################################################################
print
(
"Step 5: calculate charge billing by multiplying energy with tariff"
)
billing_dict
=
dict
()
if
len
(
energy_dict
)
>
0
:
for
current_datetime_utc
in
energy_dict
.
keys
():
current_tariff
=
tariff_dict
[
1
].
get
(
current_datetime_utc
)
current_energy
=
energy_dict
[
current_datetime_utc
]
if
current_tariff
is
not
None
\
and
isinstance
(
current_tariff
,
Decimal
)
\
and
current_energy
is
not
None
\
and
isinstance
(
current_energy
,
Decimal
):
billing_dict
[
current_datetime_utc
]
=
current_energy
*
current_tariff
############################################################################################################
# Step 6: save charge billing data to billing database
############################################################################################################
print
(
"Step 6: save charge billing data to billing database"
)
if
len
(
billing_dict
)
>
0
:
try
:
add_values
=
(
" INSERT INTO tbl_energy_storage_power_station_charge_hourly "
" (energy_storage_power_station_id, "
" start_datetime_utc, "
" actual_value) "
" VALUES "
)
for
current_datetime_utc
in
billing_dict
:
current_billing
=
billing_dict
[
current_datetime_utc
]
if
current_billing
is
not
None
and
isinstance
(
current_billing
,
Decimal
):
add_values
+=
" ("
+
str
(
energy_storage_power_station
[
'id'
])
+
","
add_values
+=
"'"
+
current_datetime_utc
.
isoformat
()[
0
:
19
]
+
"',"
add_values
+=
str
(
current_billing
)
+
"), "
print
(
"add_values:"
+
add_values
)
# trim ", " at the end of string and then execute
cursor_billing_db
.
execute
(
add_values
[:
-
2
])
cnx_billing_db
.
commit
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 6 of energy_storage_power_station_billing_charge "
+
str
(
e
))
# break the for energy storage power station loop
break
# end of for energy storage power station loop
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_billing_db
:
cursor_billing_db
.
close
()
if
cnx_billing_db
:
cnx_billing_db
.
close
()
print
(
"go to sleep 300 seconds..."
)
time
.
sleep
(
300
)
print
(
"wake from sleep, and continue to work..."
)
# end of the outermost while loop
myems-aggregation/energy_storage_power_station_billing_discharge.py
0 → 100644
浏览文件 @
ef49efe0
import
time
from
datetime
import
datetime
,
timedelta
from
decimal
import
Decimal
import
mysql.connector
import
config
import
tariff
########################################################################################################################
# PROCEDURES
# Step 1: get all energy storage power stations
# for each energy storage power station in list:
# Step 2: get the latest start_datetime_utc
# Step 3: get all discharge energy data since the latest start_datetime_utc
# Step 4: get tariffs
# Step 5: calculate discharge billing by multiplying energy with tariff
# Step 6: save discharge billing data to database
########################################################################################################################
def
main
(
logger
):
while
True
:
# the outermost while loop
################################################################################################################
# Step 1: get all energy storage power stations
################################################################################################################
cnx_system_db
=
None
cursor_system_db
=
None
try
:
cnx_system_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_system_db
)
cursor_system_db
=
cnx_system_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.1 of energy_storage_power_station_billing_discharge "
+
str
(
e
))
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS System Database"
)
energy_storage_power_station_list
=
list
()
try
:
cursor_system_db
.
execute
(
" SELECT id, name, cost_center_id "
" FROM tbl_energy_storage_power_stations "
" ORDER BY id "
)
rows_energy_storage_power_stations
=
cursor_system_db
.
fetchall
()
if
rows_energy_storage_power_stations
is
None
or
len
(
rows_energy_storage_power_stations
)
==
0
:
print
(
"Step 1.2: There isn't any energy storage power stations. "
)
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
for
row
in
rows_energy_storage_power_stations
:
energy_storage_power_station_list
.
append
({
"id"
:
row
[
0
],
"name"
:
row
[
1
],
"cost_center_id"
:
row
[
2
]})
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.2 of energy_storage_power_station_billing_discharge "
+
str
(
e
))
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Step 1.2: Got all energy storage power stations from MyEMS System Database"
)
cnx_energy_db
=
None
cursor_energy_db
=
None
try
:
cnx_energy_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_energy_db
)
cursor_energy_db
=
cnx_energy_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.3 of energy_storage_power_station_billing_discharge "
+
str
(
e
))
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS Energy Database"
)
cnx_billing_db
=
None
cursor_billing_db
=
None
try
:
cnx_billing_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_billing_db
)
cursor_billing_db
=
cnx_billing_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.4 of energy_storage_power_station_billing_discharge "
+
str
(
e
))
if
cursor_billing_db
:
cursor_billing_db
.
close
()
if
cnx_billing_db
:
cnx_billing_db
.
close
()
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS Billing Database"
)
for
energy_storage_power_station
in
energy_storage_power_station_list
:
############################################################################################################
# Step 2: get the latest start_datetime_utc
############################################################################################################
print
(
"Step 2: get the latest start_datetime_utc from billing database for "
+
energy_storage_power_station
[
'name'
])
try
:
cursor_billing_db
.
execute
(
" SELECT MAX(start_datetime_utc) "
" FROM tbl_energy_storage_power_station_discharge_hourly "
" WHERE energy_storage_power_station_id = %s "
,
(
energy_storage_power_station
[
'id'
],
))
row_datetime
=
cursor_billing_db
.
fetchone
()
start_datetime_utc
=
datetime
.
strptime
(
config
.
start_datetime_utc
,
'%Y-%m-%d %H:%M:%S'
)
start_datetime_utc
=
start_datetime_utc
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
if
row_datetime
is
not
None
and
len
(
row_datetime
)
>
0
and
isinstance
(
row_datetime
[
0
],
datetime
):
# replace second and microsecond with 0
# note: do not replace minute in case of calculating in half hourly
start_datetime_utc
=
row_datetime
[
0
].
replace
(
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
# start from the next time slot
start_datetime_utc
+=
timedelta
(
minutes
=
config
.
minutes_to_count
)
print
(
"start_datetime_utc: "
+
start_datetime_utc
.
isoformat
()[
0
:
19
])
except
Exception
as
e
:
logger
.
error
(
"Error in step 2 of energy_storage_power_station_billing_discharge "
+
str
(
e
))
# break the for energy storage power station loop
break
############################################################################################################
# Step 3: get all discharge energy data since the latest start_datetime_utc
############################################################################################################
print
(
"Step 3: get all discharge energy data since the latest start_datetime_utc"
)
query
=
(
" SELECT start_datetime_utc, actual_value "
" FROM tbl_energy_storage_power_station_discharge_hourly "
" WHERE energy_storage_power_station_id = %s AND start_datetime_utc >= %s "
" ORDER BY id "
)
cursor_energy_db
.
execute
(
query
,
(
energy_storage_power_station
[
'id'
],
start_datetime_utc
,
))
rows_hourly
=
cursor_energy_db
.
fetchall
()
if
rows_hourly
is
None
or
len
(
rows_hourly
)
==
0
:
print
(
"Step 3: There isn't any energy input data to calculate. "
)
# continue the for energy storage power station loop
continue
energy_dict
=
dict
()
end_datetime_utc
=
start_datetime_utc
for
row_hourly
in
rows_hourly
:
current_datetime_utc
=
row_hourly
[
0
]
actual_value
=
row_hourly
[
1
]
energy_dict
[
current_datetime_utc
]
=
actual_value
if
current_datetime_utc
>
end_datetime_utc
:
end_datetime_utc
=
current_datetime_utc
############################################################################################################
# Step 4: get tariffs
############################################################################################################
print
(
"Step 4: get tariffs"
)
tariff_dict
=
dict
()
tariff_dict
[
1
]
=
tariff
.
get_energy_category_tariffs
(
energy_storage_power_station
[
'cost_center_id'
],
1
,
start_datetime_utc
,
end_datetime_utc
)
############################################################################################################
# Step 5: calculate discharge billing by multiplying energy with tariff
############################################################################################################
print
(
"Step 5: calculate discharge billing by multiplying energy with tariff"
)
billing_dict
=
dict
()
if
len
(
energy_dict
)
>
0
:
for
current_datetime_utc
in
energy_dict
.
keys
():
current_tariff
=
tariff_dict
[
1
].
get
(
current_datetime_utc
)
current_energy
=
energy_dict
[
current_datetime_utc
]
if
current_tariff
is
not
None
\
and
isinstance
(
current_tariff
,
Decimal
)
\
and
current_energy
is
not
None
\
and
isinstance
(
current_energy
,
Decimal
):
billing_dict
[
current_datetime_utc
]
=
current_energy
*
current_tariff
############################################################################################################
# Step 6: save discharge billing data to billing database
############################################################################################################
print
(
"Step 6: save discharge billing data to billing database"
)
if
len
(
billing_dict
)
>
0
:
try
:
add_values
=
(
" INSERT INTO tbl_energy_storage_power_station_discharge_hourly "
" (energy_storage_power_station_id, "
" start_datetime_utc, "
" actual_value) "
" VALUES "
)
for
current_datetime_utc
in
billing_dict
:
current_billing
=
billing_dict
[
current_datetime_utc
]
if
current_billing
is
not
None
and
isinstance
(
current_billing
,
Decimal
):
add_values
+=
" ("
+
str
(
energy_storage_power_station
[
'id'
])
+
","
add_values
+=
"'"
+
current_datetime_utc
.
isoformat
()[
0
:
19
]
+
"',"
add_values
+=
str
(
current_billing
)
+
"), "
print
(
"add_values:"
+
add_values
)
# trim ", " at the end of string and then execute
cursor_billing_db
.
execute
(
add_values
[:
-
2
])
cnx_billing_db
.
commit
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 6 of energy_storage_power_station_billing_discharge "
+
str
(
e
))
# break the for energy storage power station loop
break
# end of for energy storage power station loop
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_billing_db
:
cursor_billing_db
.
close
()
if
cnx_billing_db
:
cnx_billing_db
.
close
()
print
(
"go to sleep 300 seconds..."
)
time
.
sleep
(
300
)
print
(
"wake from sleep, and continue to work..."
)
# end of the outermost while loop
myems-aggregation/energy_storage_power_station_carbon_charge.py
0 → 100644
浏览文件 @
ef49efe0
import
time
from
datetime
import
datetime
,
timedelta
from
decimal
import
Decimal
import
mysql.connector
import
carbon_dioxide_emmision_factor
import
config
########################################################################################################################
# PROCEDURES
# Step 1: get all energy storage power stations
# for each energy storage power station in list:
# Step 2: get the latest start_datetime_utc
# Step 3: get all charge energy data since the latest start_datetime_utc
# Step 4: get carbon dioxide emissions factor
# Step 5: calculate charge carbon dioxide emissions by multiplying energy with factor
# Step 6: save charge carbon dioxide emissions data to database
########################################################################################################################
def
main
(
logger
):
while
True
:
# the outermost while loop
################################################################################################################
# Step 1: get all energy storage power stations
################################################################################################################
cnx_system_db
=
None
cursor_system_db
=
None
try
:
cnx_system_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_system_db
)
cursor_system_db
=
cnx_system_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.1 of energy_storage_power_station_carbon_charge "
+
str
(
e
))
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS System Database"
)
energy_storage_power_station_list
=
list
()
try
:
cursor_system_db
.
execute
(
" SELECT id, name, cost_center_id "
" FROM tbl_energy_storage_power_stations "
" ORDER BY id "
)
rows_energy_storage_power_stations
=
cursor_system_db
.
fetchall
()
if
rows_energy_storage_power_stations
is
None
or
len
(
rows_energy_storage_power_stations
)
==
0
:
print
(
"Step 1.2: There isn't any energy storage power stations. "
)
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
for
row
in
rows_energy_storage_power_stations
:
energy_storage_power_station_list
.
append
({
"id"
:
row
[
0
],
"name"
:
row
[
1
],
"cost_center_id"
:
row
[
2
]})
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.2 of energy_storage_power_station_carbon_charge "
+
str
(
e
))
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Step 1.2: Got all energy storage power stations from MyEMS System Database"
)
cnx_energy_db
=
None
cursor_energy_db
=
None
try
:
cnx_energy_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_energy_db
)
cursor_energy_db
=
cnx_energy_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.3 of energy_storage_power_station_carbon_charge "
+
str
(
e
))
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS Energy Database"
)
cnx_carbon_db
=
None
cursor_carbon_db
=
None
try
:
cnx_carbon_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_carbon_db
)
cursor_carbon_db
=
cnx_carbon_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.4 of energy_storage_power_station_carbon_charge "
+
str
(
e
))
if
cursor_carbon_db
:
cursor_carbon_db
.
close
()
if
cnx_carbon_db
:
cnx_carbon_db
.
close
()
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS Carbon Database"
)
for
energy_storage_power_station
in
energy_storage_power_station_list
:
############################################################################################################
# Step 2: get the latest start_datetime_utc
############################################################################################################
print
(
"Step 2: get the latest start_datetime_utc from carbon database for "
+
energy_storage_power_station
[
'name'
])
try
:
cursor_carbon_db
.
execute
(
" SELECT MAX(start_datetime_utc) "
" FROM tbl_energy_storage_power_station_charge_hourly "
" WHERE energy_storage_power_station_id = %s "
,
(
energy_storage_power_station
[
'id'
],
))
row_datetime
=
cursor_carbon_db
.
fetchone
()
start_datetime_utc
=
datetime
.
strptime
(
config
.
start_datetime_utc
,
'%Y-%m-%d %H:%M:%S'
)
start_datetime_utc
=
start_datetime_utc
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
if
row_datetime
is
not
None
and
len
(
row_datetime
)
>
0
and
isinstance
(
row_datetime
[
0
],
datetime
):
# replace second and microsecond with 0
# note: do not replace minute in case of calculating in half hourly
start_datetime_utc
=
row_datetime
[
0
].
replace
(
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
# start from the next time slot
start_datetime_utc
+=
timedelta
(
minutes
=
config
.
minutes_to_count
)
print
(
"start_datetime_utc: "
+
start_datetime_utc
.
isoformat
()[
0
:
19
])
except
Exception
as
e
:
logger
.
error
(
"Error in step 2 of energy_storage_power_station_carbon_charge "
+
str
(
e
))
# break the for energy storage power station loop
break
############################################################################################################
# Step 3: get all charge energy data since the latest start_datetime_utc
############################################################################################################
print
(
"Step 3: get all charge energy data since the latest start_datetime_utc"
)
query
=
(
" SELECT start_datetime_utc, actual_value "
" FROM tbl_energy_storage_power_station_charge_hourly "
" WHERE energy_storage_power_station_id = %s AND start_datetime_utc >= %s "
" ORDER BY id "
)
cursor_energy_db
.
execute
(
query
,
(
energy_storage_power_station
[
'id'
],
start_datetime_utc
,
))
rows_hourly
=
cursor_energy_db
.
fetchall
()
if
rows_hourly
is
None
or
len
(
rows_hourly
)
==
0
:
print
(
"Step 3: There isn't any charge energy data to calculate. "
)
# continue the for energy storage power station loop
continue
energy_dict
=
dict
()
end_datetime_utc
=
start_datetime_utc
for
row_hourly
in
rows_hourly
:
current_datetime_utc
=
row_hourly
[
0
]
actual_value
=
row_hourly
[
1
]
energy_dict
[
current_datetime_utc
]
=
actual_value
if
current_datetime_utc
>
end_datetime_utc
:
end_datetime_utc
=
current_datetime_utc
############################################################################################################
# Step 4: get carbon dioxide emissions factor
############################################################################################################
print
(
"Step 4: get carbon dioxide emissions factor"
)
factor_dict
=
dict
()
factor_dict
[
1
]
=
\
carbon_dioxide_emmision_factor
.
get_energy_category_factor
(
1
,
start_datetime_utc
,
end_datetime_utc
)
############################################################################################################
# Step 5: calculate carbon dioxide emissions by multiplying energy with factor
############################################################################################################
print
(
"Step 5: calculate carbon dioxide emissions by multiplying energy with factor"
)
carbon_dict
=
dict
()
if
len
(
energy_dict
)
>
0
:
for
current_datetime_utc
in
energy_dict
.
keys
():
current_factor
=
factor_dict
[
1
]
current_energy
=
energy_dict
[
current_datetime_utc
]
if
current_factor
is
not
None
\
and
isinstance
(
current_factor
,
Decimal
)
\
and
current_energy
is
not
None
\
and
isinstance
(
current_energy
,
Decimal
):
carbon_dict
[
current_datetime_utc
]
=
current_energy
*
current_factor
############################################################################################################
# Step 6: save carbon dioxide emissions data to database
############################################################################################################
print
(
"Step 6: save carbon dioxide emissions data to database"
)
if
len
(
carbon_dict
)
>
0
:
try
:
add_values
=
(
" INSERT INTO tbl_energy_storage_power_station_charge_hourly "
" (energy_storage_power_station_id, "
" start_datetime_utc, "
" actual_value) "
" VALUES "
)
for
current_datetime_utc
in
carbon_dict
:
current_carbon
=
carbon_dict
[
current_datetime_utc
]
if
current_carbon
is
not
None
and
isinstance
(
current_carbon
,
Decimal
):
add_values
+=
" ("
+
str
(
energy_storage_power_station
[
'id'
])
+
","
add_values
+=
"'"
+
current_datetime_utc
.
isoformat
()[
0
:
19
]
+
"',"
add_values
+=
str
(
current_carbon
)
+
"), "
print
(
"add_values:"
+
add_values
)
# trim ", " at the end of string and then execute
cursor_carbon_db
.
execute
(
add_values
[:
-
2
])
cnx_carbon_db
.
commit
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 6 of energy_storage_power_station_carbon_charge "
+
str
(
e
))
# break the for energy storage power station loop
break
# end of for energy storage power station loop
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_carbon_db
:
cursor_carbon_db
.
close
()
if
cnx_carbon_db
:
cnx_carbon_db
.
close
()
print
(
"go to sleep 300 seconds..."
)
time
.
sleep
(
300
)
print
(
"wake from sleep, and continue to work..."
)
# end of the outermost while loop
myems-aggregation/energy_storage_power_station_carbon_discharge.py
0 → 100644
浏览文件 @
ef49efe0
import
time
from
datetime
import
datetime
,
timedelta
from
decimal
import
Decimal
import
mysql.connector
import
carbon_dioxide_emmision_factor
import
config
########################################################################################################################
# PROCEDURES
# Step 1: get all energy storage power stations
# for each energy storage power station in list:
# Step 2: get the latest start_datetime_utc
# Step 3: get all discharge energy data since the latest start_datetime_utc
# Step 4: get carbon dioxide emissions factor
# Step 5: calculate discharge carbon dioxide emissions by multiplying energy with factor
# Step 6: save discharge carbon dioxide emissions data to database
########################################################################################################################
def
main
(
logger
):
while
True
:
# the outermost while loop
################################################################################################################
# Step 1: get all energy storage power stations
################################################################################################################
cnx_system_db
=
None
cursor_system_db
=
None
try
:
cnx_system_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_system_db
)
cursor_system_db
=
cnx_system_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.1 of energy_storage_power_station_carbon_discharge "
+
str
(
e
))
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS System Database"
)
energy_storage_power_station_list
=
list
()
try
:
cursor_system_db
.
execute
(
" SELECT id, name, cost_center_id "
" FROM tbl_energy_storage_power_stations "
" ORDER BY id "
)
rows_energy_storage_power_stations
=
cursor_system_db
.
fetchall
()
if
rows_energy_storage_power_stations
is
None
or
len
(
rows_energy_storage_power_stations
)
==
0
:
print
(
"Step 1.2: There isn't any energy storage power stations. "
)
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
for
row
in
rows_energy_storage_power_stations
:
energy_storage_power_station_list
.
append
({
"id"
:
row
[
0
],
"name"
:
row
[
1
],
"cost_center_id"
:
row
[
2
]})
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.2 of energy_storage_power_station_carbon_discharge "
+
str
(
e
))
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Step 1.2: Got all energy storage power stations from MyEMS System Database"
)
cnx_energy_db
=
None
cursor_energy_db
=
None
try
:
cnx_energy_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_energy_db
)
cursor_energy_db
=
cnx_energy_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.3 of energy_storage_power_station_carbon_discharge "
+
str
(
e
))
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS Energy Database"
)
cnx_carbon_db
=
None
cursor_carbon_db
=
None
try
:
cnx_carbon_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_carbon_db
)
cursor_carbon_db
=
cnx_carbon_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.4 of energy_storage_power_station_carbon_discharge "
+
str
(
e
))
if
cursor_carbon_db
:
cursor_carbon_db
.
close
()
if
cnx_carbon_db
:
cnx_carbon_db
.
close
()
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outermost while loop
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS Carbon Database"
)
for
energy_storage_power_station
in
energy_storage_power_station_list
:
############################################################################################################
# Step 2: get the latest start_datetime_utc
############################################################################################################
print
(
"Step 2: get the latest start_datetime_utc from carbon database for "
+
energy_storage_power_station
[
'name'
])
try
:
cursor_carbon_db
.
execute
(
" SELECT MAX(start_datetime_utc) "
" FROM tbl_energy_storage_power_station_discharge_hourly "
" WHERE energy_storage_power_station_id = %s "
,
(
energy_storage_power_station
[
'id'
],
))
row_datetime
=
cursor_carbon_db
.
fetchone
()
start_datetime_utc
=
datetime
.
strptime
(
config
.
start_datetime_utc
,
'%Y-%m-%d %H:%M:%S'
)
start_datetime_utc
=
start_datetime_utc
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
if
row_datetime
is
not
None
and
len
(
row_datetime
)
>
0
and
isinstance
(
row_datetime
[
0
],
datetime
):
# replace second and microsecond with 0
# note: do not replace minute in case of calculating in half hourly
start_datetime_utc
=
row_datetime
[
0
].
replace
(
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
# start from the next time slot
start_datetime_utc
+=
timedelta
(
minutes
=
config
.
minutes_to_count
)
print
(
"start_datetime_utc: "
+
start_datetime_utc
.
isoformat
()[
0
:
19
])
except
Exception
as
e
:
logger
.
error
(
"Error in step 2 of energy_storage_power_station_carbon_discharge "
+
str
(
e
))
# break the for energy storage power station loop
break
############################################################################################################
# Step 3: get all discharge energy data since the latest start_datetime_utc
############################################################################################################
print
(
"Step 3: get all discharge energy data since the latest start_datetime_utc"
)
query
=
(
" SELECT start_datetime_utc, actual_value "
" FROM tbl_energy_storage_power_station_discharge_hourly "
" WHERE energy_storage_power_station_id = %s AND start_datetime_utc >= %s "
" ORDER BY id "
)
cursor_energy_db
.
execute
(
query
,
(
energy_storage_power_station
[
'id'
],
start_datetime_utc
,
))
rows_hourly
=
cursor_energy_db
.
fetchall
()
if
rows_hourly
is
None
or
len
(
rows_hourly
)
==
0
:
print
(
"Step 3: There isn't any discharge energy data to calculate. "
)
# continue the for energy storage power station loop
continue
energy_dict
=
dict
()
end_datetime_utc
=
start_datetime_utc
for
row_hourly
in
rows_hourly
:
current_datetime_utc
=
row_hourly
[
0
]
actual_value
=
row_hourly
[
1
]
energy_dict
[
current_datetime_utc
]
=
actual_value
if
current_datetime_utc
>
end_datetime_utc
:
end_datetime_utc
=
current_datetime_utc
############################################################################################################
# Step 4: get carbon dioxide emissions factor
############################################################################################################
print
(
"Step 4: get carbon dioxide emissions factor"
)
factor_dict
=
dict
()
factor_dict
[
1
]
=
\
carbon_dioxide_emmision_factor
.
get_energy_category_factor
(
1
,
start_datetime_utc
,
end_datetime_utc
)
############################################################################################################
# Step 5: calculate carbon dioxide emissions by multiplying energy with factor
############################################################################################################
print
(
"Step 5: calculate carbon dioxide emissions by multiplying energy with factor"
)
carbon_dict
=
dict
()
if
len
(
energy_dict
)
>
0
:
for
current_datetime_utc
in
energy_dict
.
keys
():
current_factor
=
factor_dict
[
1
]
current_energy
=
energy_dict
[
current_datetime_utc
]
if
current_factor
is
not
None
\
and
isinstance
(
current_factor
,
Decimal
)
\
and
current_energy
is
not
None
\
and
isinstance
(
current_energy
,
Decimal
):
carbon_dict
[
current_datetime_utc
]
=
current_energy
*
current_factor
############################################################################################################
# Step 6: save carbon dioxide emissions data to database
############################################################################################################
print
(
"Step 6: save carbon dioxide emissions data to database"
)
if
len
(
carbon_dict
)
>
0
:
try
:
add_values
=
(
" INSERT INTO tbl_energy_storage_power_station_discharge_hourly "
" (energy_storage_power_station_id, "
" start_datetime_utc, "
" actual_value) "
" VALUES "
)
for
current_datetime_utc
in
carbon_dict
:
current_carbon
=
carbon_dict
[
current_datetime_utc
]
if
current_carbon
is
not
None
and
isinstance
(
current_carbon
,
Decimal
):
add_values
+=
" ("
+
str
(
energy_storage_power_station
[
'id'
])
+
","
add_values
+=
"'"
+
current_datetime_utc
.
isoformat
()[
0
:
19
]
+
"',"
add_values
+=
str
(
current_carbon
)
+
"), "
print
(
"add_values:"
+
add_values
)
# trim ", " at the end of string and then execute
cursor_carbon_db
.
execute
(
add_values
[:
-
2
])
cnx_carbon_db
.
commit
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 6 of energy_storage_power_station_carbon_discharge "
+
str
(
e
))
# break the for energy storage power station loop
break
# end of for energy storage power station loop
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
if
cursor_carbon_db
:
cursor_carbon_db
.
close
()
if
cnx_carbon_db
:
cnx_carbon_db
.
close
()
print
(
"go to sleep 300 seconds..."
)
time
.
sleep
(
300
)
print
(
"wake from sleep, and continue to work..."
)
# end of the outermost while loop
myems-aggregation/energy_storage_power_station_energy_charge.py
0 → 100644
浏览文件 @
ef49efe0
import
random
import
time
from
datetime
import
datetime
,
timedelta
from
decimal
import
Decimal
from
multiprocessing
import
Pool
import
mysql.connector
import
config
########################################################################################################################
# PROCEDURES
# Step 1: get all energy storage power stations
# Step 2: Create multiprocessing pool to call worker in parallel
########################################################################################################################
def
main
(
logger
):
while
True
:
# the outermost while loop
################################################################################################################
# Step 1: get all energy storage power stations
################################################################################################################
cnx_system_db
=
None
cursor_system_db
=
None
try
:
cnx_system_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_system_db
)
cursor_system_db
=
cnx_system_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.1 of energy_storage_power_station_energy_charge.main "
+
str
(
e
))
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outer loop to reconnect the database
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS System Database"
)
energy_storage_power_station_list
=
list
()
try
:
cursor_system_db
.
execute
(
" SELECT id, name "
" FROM tbl_energy_storage_power_stations "
" ORDER BY id "
)
rows_energy_storage_power_stations
=
cursor_system_db
.
fetchall
()
if
rows_energy_storage_power_stations
is
None
or
len
(
rows_energy_storage_power_stations
)
==
0
:
print
(
"There isn't any energy storage power stations "
)
# sleep and continue the outer loop to reconnect the database
time
.
sleep
(
60
)
continue
for
row
in
rows_energy_storage_power_stations
:
energy_storage_power_station_list
.
append
({
"id"
:
row
[
0
],
"name"
:
row
[
1
]})
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.2 of energy_storage_power_station_energy_charge.main "
+
str
(
e
))
# sleep and continue the outer loop to reconnect the database
time
.
sleep
(
60
)
continue
finally
:
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
print
(
"Got all energy storage power stations in MyEMS System Database"
)
# shuffle the energy storage power station list for randomly calculating the meter hourly value
random
.
shuffle
(
energy_storage_power_station_list
)
################################################################################################################
# Step 2: Create multiprocessing pool to call worker in parallel
################################################################################################################
p
=
Pool
(
processes
=
config
.
pool_size
)
error_list
=
p
.
map
(
worker
,
energy_storage_power_station_list
)
p
.
close
()
p
.
join
()
for
error
in
error_list
:
if
error
is
not
None
and
len
(
error
)
>
0
:
logger
.
error
(
error
)
print
(
"go to sleep 300 seconds..."
)
time
.
sleep
(
300
)
print
(
"wake from sleep, and continue to work..."
)
# end of outer while
########################################################################################################################
# PROCEDURES:
# Step 1: get all energy storage containers associated with the energy storage power station
# Step 2: determine start datetime and end datetime to aggregate
# Step 3: for each energy storage container in list, get energy charge data from energy database
# Step 4: determine common time slot to aggregate
# Step 5: aggregate energy data in the common time slot by energy categories and hourly
# Step 6: save energy data to energy database
#
# NOTE: returns None or the error string because that the logger object cannot be passed in as parameter
########################################################################################################################
def
worker
(
energy_storage_power_station
):
cnx_system_db
=
None
cursor_system_db
=
None
try
:
cnx_system_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_system_db
)
cursor_system_db
=
cnx_system_db
.
cursor
()
except
Exception
as
e
:
error_string
=
"Error in step 1.1 of energy_storage_power_station_energy_charge.worker "
+
str
(
e
)
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
print
(
error_string
)
return
error_string
####################################################################################################################
# Step 1: get all energy storage containers associated with the energy storage power station
####################################################################################################################
print
(
"Step 1: get all energy storage containers associated with the energy storage power station"
)
energy_storage_container_list
=
list
()
try
:
cursor_system_db
.
execute
(
" SELECT e.id, e.name "
" FROM tbl_energy_storage_containers e, "
" tbl_energy_storage_power_stations_containers ec "
" WHERE e.id = ec.energy_storage_container_id "
" AND ec.energy_storage_power_station_id = %s "
,
(
energy_storage_power_station
[
'id'
],))
rows_energy_storage_containers
=
cursor_system_db
.
fetchall
()
if
rows_energy_storage_containers
is
not
None
and
len
(
rows_energy_storage_containers
)
>
0
:
for
row
in
rows_energy_storage_containers
:
energy_storage_container_list
.
append
({
"id"
:
row
[
0
],
"name"
:
row
[
1
]})
except
Exception
as
e
:
error_string
=
"Error in step 1 of energy_storage_power_station_energy_charge.worker "
+
str
(
e
)
print
(
error_string
)
return
error_string
finally
:
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
####################################################################################################################
# stop to the next energy storage power station if this energy storage power station is empty
####################################################################################################################
if
energy_storage_container_list
is
None
or
len
(
energy_storage_container_list
)
==
0
:
print
(
"This is an empty energy storage power station "
)
return
None
####################################################################################################################
# Step 2: determine start datetime and end datetime to aggregate
####################################################################################################################
print
(
"Step 2: determine start datetime and end datetime to aggregate"
)
cnx_energy_db
=
None
cursor_energy_db
=
None
try
:
cnx_energy_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_energy_db
)
cursor_energy_db
=
cnx_energy_db
.
cursor
()
except
Exception
as
e
:
error_string
=
"Error in step 2.1 of energy_storage_power_station_energy_charge.worker "
+
str
(
e
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
print
(
error_string
)
return
error_string
try
:
query
=
(
" SELECT MAX(start_datetime_utc) "
" FROM tbl_energy_storage_power_station_charge_hourly "
" WHERE energy_storage_power_station_id = %s "
)
cursor_energy_db
.
execute
(
query
,
(
energy_storage_power_station
[
'id'
],))
row_datetime
=
cursor_energy_db
.
fetchone
()
start_datetime_utc
=
datetime
.
strptime
(
config
.
start_datetime_utc
,
'%Y-%m-%d %H:%M:%S'
)
start_datetime_utc
=
start_datetime_utc
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
if
row_datetime
is
not
None
and
len
(
row_datetime
)
>
0
and
isinstance
(
row_datetime
[
0
],
datetime
):
# replace second and microsecond with 0
# note: do not replace minute in case of calculating in half hourly
start_datetime_utc
=
row_datetime
[
0
].
replace
(
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
# start from the next time slot
start_datetime_utc
+=
timedelta
(
minutes
=
config
.
minutes_to_count
)
end_datetime_utc
=
datetime
.
utcnow
().
replace
(
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
print
(
"start_datetime_utc: "
+
start_datetime_utc
.
isoformat
()[
0
:
19
]
+
"end_datetime_utc: "
+
end_datetime_utc
.
isoformat
()[
0
:
19
])
except
Exception
as
e
:
error_string
=
"Error in step 2.2 of energy_storage_power_station_energy_charge.worker "
+
str
(
e
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
print
(
error_string
)
return
error_string
####################################################################################################################
# Step 3: for each energy storage container in list, get energy charge data from energy database
####################################################################################################################
energy_energy_storage_container_hourly
=
dict
()
if
energy_storage_container_list
is
not
None
and
len
(
energy_storage_container_list
)
>
0
:
try
:
for
energy_storage_container
in
energy_storage_container_list
:
energy_storage_container_id
=
str
(
energy_storage_container
[
'id'
])
query
=
(
" SELECT start_datetime_utc, actual_value "
" FROM tbl_energy_storage_container_charge_hourly "
" WHERE energy_storage_container_id = %s "
" AND start_datetime_utc >= %s "
" AND start_datetime_utc < %s "
" ORDER BY start_datetime_utc "
)
cursor_energy_db
.
execute
(
query
,
(
energy_storage_container_id
,
start_datetime_utc
,
end_datetime_utc
,))
rows_energy_values
=
cursor_energy_db
.
fetchall
()
if
rows_energy_values
is
None
or
len
(
rows_energy_values
)
==
0
:
energy_energy_storage_container_hourly
[
energy_storage_container_id
]
=
None
else
:
energy_energy_storage_container_hourly
[
energy_storage_container_id
]
=
dict
()
for
row_value
in
rows_energy_values
:
current_datetime_utc
=
row_value
[
0
]
actual_value
=
row_value
[
1
]
energy_energy_storage_container_hourly
[
energy_storage_container_id
][
current_datetime_utc
]
=
\
actual_value
except
Exception
as
e
:
error_string
=
"Error in step 3 of energy_storage_power_station_energy_charge.worker "
+
str
(
e
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
print
(
error_string
)
return
error_string
####################################################################################################################
# Step 4: determine common time slot to aggregate
####################################################################################################################
common_start_datetime_utc
=
start_datetime_utc
common_end_datetime_utc
=
end_datetime_utc
print
(
"Getting common time slot of energy values for all energy storage containers..."
)
if
common_start_datetime_utc
is
not
None
and
common_end_datetime_utc
is
not
None
:
if
energy_energy_storage_container_hourly
is
not
None
and
len
(
energy_energy_storage_container_hourly
)
>
0
:
for
energy_storage_container_id
,
energy_hourly
in
energy_energy_storage_container_hourly
.
items
():
if
energy_hourly
is
None
or
len
(
energy_hourly
)
==
0
:
common_start_datetime_utc
=
None
common_end_datetime_utc
=
None
break
else
:
if
common_start_datetime_utc
<
min
(
energy_hourly
.
keys
()):
common_start_datetime_utc
=
min
(
energy_hourly
.
keys
())
if
common_end_datetime_utc
>
max
(
energy_hourly
.
keys
()):
common_end_datetime_utc
=
max
(
energy_hourly
.
keys
())
if
energy_energy_storage_container_hourly
is
None
or
len
(
energy_energy_storage_container_hourly
)
==
0
:
# There isn't any energy data
print
(
"There isn't any energy data"
)
# continue the for energy storage power station loop to the next energy storage power station
print
(
"continue the for energy storage power station loop to the next energy storage power station"
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
return
None
print
(
"common_start_datetime_utc: "
+
str
(
common_start_datetime_utc
))
print
(
"common_end_datetime_utc: "
+
str
(
common_end_datetime_utc
))
####################################################################################################################
# Step 5: aggregate energy data in the common time slot by energy categories and hourly
####################################################################################################################
print
(
"Step 5: aggregate energy data in the common time slot by energy categories and hourly"
)
aggregated_values
=
list
()
try
:
current_datetime_utc
=
common_start_datetime_utc
while
common_start_datetime_utc
is
not
None
\
and
common_end_datetime_utc
is
not
None
\
and
current_datetime_utc
<=
common_end_datetime_utc
:
aggregated_value
=
dict
()
aggregated_value
[
'start_datetime_utc'
]
=
current_datetime_utc
aggregated_value
[
'actual_value'
]
=
Decimal
(
0.0
)
if
energy_storage_container_list
is
not
None
and
len
(
energy_storage_container_list
)
>
0
:
for
energy_storage_container
in
energy_storage_container_list
:
energy_storage_container_id
=
str
(
energy_storage_container
[
'id'
])
aggregated_value
[
'actual_value'
]
+=
\
energy_energy_storage_container_hourly
[
energy_storage_container_id
][
current_datetime_utc
]
aggregated_values
.
append
(
aggregated_value
)
current_datetime_utc
+=
timedelta
(
minutes
=
config
.
minutes_to_count
)
except
Exception
as
e
:
error_string
=
"Error in step 5 of energy_storage_power_station_energy_charge.worker "
+
str
(
e
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
print
(
error_string
)
return
error_string
####################################################################################################################
# Step 6: save energy data to energy database
####################################################################################################################
print
(
"Step 6: save energy data to energy database"
)
while
len
(
aggregated_values
)
>
0
:
insert_100
=
aggregated_values
[:
100
]
aggregated_values
=
aggregated_values
[
100
:]
try
:
add_values
=
(
" INSERT INTO tbl_energy_storage_power_station_charge_hourly "
" (energy_storage_power_station_id, "
" start_datetime_utc, "
" actual_value) "
" VALUES "
)
for
aggregated_value
in
insert_100
:
add_values
+=
" ("
+
str
(
energy_storage_power_station
[
'id'
])
+
","
add_values
+=
"'"
+
aggregated_value
[
'start_datetime_utc'
].
isoformat
()[
0
:
19
]
+
"',"
add_values
+=
str
(
aggregated_value
[
'actual_value'
])
+
"), "
print
(
"add_values:"
+
add_values
)
# trim ", " at the end of string and then execute
cursor_energy_db
.
execute
(
add_values
[:
-
2
])
cnx_energy_db
.
commit
()
except
Exception
as
e
:
error_string
=
"Error in step 6.1 of energy_storage_power_station_energy_charge.worker "
+
str
(
e
)
print
(
error_string
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
return
error_string
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
return
None
myems-aggregation/energy_storage_power_station_energy_discharge.py
0 → 100644
浏览文件 @
ef49efe0
import
random
import
time
from
datetime
import
datetime
,
timedelta
from
decimal
import
Decimal
from
multiprocessing
import
Pool
import
mysql.connector
import
config
########################################################################################################################
# PROCEDURES
# Step 1: get all energy storage power stations
# Step 2: Create multiprocessing pool to call worker in parallel
########################################################################################################################
def
main
(
logger
):
while
True
:
# the outermost while loop
################################################################################################################
# Step 1: get all energy storage power stations
################################################################################################################
cnx_system_db
=
None
cursor_system_db
=
None
try
:
cnx_system_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_system_db
)
cursor_system_db
=
cnx_system_db
.
cursor
()
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.1 of energy_storage_power_station_energy_discharge.main "
+
str
(
e
))
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
# sleep and continue the outer loop to reconnect the database
time
.
sleep
(
60
)
continue
print
(
"Connected to MyEMS System Database"
)
energy_storage_power_station_list
=
list
()
try
:
cursor_system_db
.
execute
(
" SELECT id, name "
" FROM tbl_energy_storage_power_stations "
" ORDER BY id "
)
rows_energy_storage_power_stations
=
cursor_system_db
.
fetchall
()
if
rows_energy_storage_power_stations
is
None
or
len
(
rows_energy_storage_power_stations
)
==
0
:
print
(
"There isn't any energy storage power stations "
)
# sleep and continue the outer loop to reconnect the database
time
.
sleep
(
60
)
continue
for
row
in
rows_energy_storage_power_stations
:
energy_storage_power_station_list
.
append
({
"id"
:
row
[
0
],
"name"
:
row
[
1
]})
except
Exception
as
e
:
logger
.
error
(
"Error in step 1.2 of energy_storage_power_station_energy_discharge.main "
+
str
(
e
))
# sleep and continue the outer loop to reconnect the database
time
.
sleep
(
60
)
continue
finally
:
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
print
(
"Got all energy storage power stations in MyEMS System Database"
)
# shuffle the energy storage power station list for randomly calculating the meter hourly value
random
.
shuffle
(
energy_storage_power_station_list
)
################################################################################################################
# Step 2: Create multiprocessing pool to call worker in parallel
################################################################################################################
p
=
Pool
(
processes
=
config
.
pool_size
)
error_list
=
p
.
map
(
worker
,
energy_storage_power_station_list
)
p
.
close
()
p
.
join
()
for
error
in
error_list
:
if
error
is
not
None
and
len
(
error
)
>
0
:
logger
.
error
(
error
)
print
(
"go to sleep 300 seconds..."
)
time
.
sleep
(
300
)
print
(
"wake from sleep, and continue to work..."
)
# end of outer while
########################################################################################################################
# PROCEDURES:
# Step 1: get all energy storage containers associated with the energy storage power station
# Step 2: determine start datetime and end datetime to aggregate
# Step 3: for each energy storage container in list, get energy discharge data from energy database
# Step 4: determine common time slot to aggregate
# Step 5: aggregate energy data in the common time slot by energy categories and hourly
# Step 6: save energy data to energy database
#
# NOTE: returns None or the error string because that the logger object cannot be passed in as parameter
########################################################################################################################
def
worker
(
energy_storage_power_station
):
cnx_system_db
=
None
cursor_system_db
=
None
try
:
cnx_system_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_system_db
)
cursor_system_db
=
cnx_system_db
.
cursor
()
except
Exception
as
e
:
error_string
=
"Error in step 1.1 of energy_storage_power_station_energy_discharge.worker "
+
str
(
e
)
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
print
(
error_string
)
return
error_string
####################################################################################################################
# Step 1: get all energy storage containers associated with the energy storage power station
####################################################################################################################
print
(
"Step 1: get all energy storage containers associated with the energy storage power station"
)
energy_storage_container_list
=
list
()
try
:
cursor_system_db
.
execute
(
" SELECT e.id, e.name "
" FROM tbl_energy_storage_containers e, "
" tbl_energy_storage_power_stations_containers ec "
" WHERE e.id = ec.energy_storage_container_id "
" AND ec.energy_storage_power_station_id = %s "
,
(
energy_storage_power_station
[
'id'
],))
rows_energy_storage_containers
=
cursor_system_db
.
fetchall
()
if
rows_energy_storage_containers
is
not
None
and
len
(
rows_energy_storage_containers
)
>
0
:
for
row
in
rows_energy_storage_containers
:
energy_storage_container_list
.
append
({
"id"
:
row
[
0
],
"name"
:
row
[
1
]})
except
Exception
as
e
:
error_string
=
"Error in step 1 of energy_storage_power_station_energy_discharge.worker "
+
str
(
e
)
print
(
error_string
)
return
error_string
finally
:
if
cursor_system_db
:
cursor_system_db
.
close
()
if
cnx_system_db
:
cnx_system_db
.
close
()
####################################################################################################################
# stop to the next energy storage power station if this energy storage power station is empty
####################################################################################################################
if
energy_storage_container_list
is
None
or
len
(
energy_storage_container_list
)
==
0
:
print
(
"This is an empty energy storage power station "
)
return
None
####################################################################################################################
# Step 2: determine start datetime and end datetime to aggregate
####################################################################################################################
print
(
"Step 2: determine start datetime and end datetime to aggregate"
)
cnx_energy_db
=
None
cursor_energy_db
=
None
try
:
cnx_energy_db
=
mysql
.
connector
.
connect
(
**
config
.
myems_energy_db
)
cursor_energy_db
=
cnx_energy_db
.
cursor
()
except
Exception
as
e
:
error_string
=
"Error in step 2.1 of energy_storage_power_station_energy_discharge.worker "
+
str
(
e
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
print
(
error_string
)
return
error_string
try
:
query
=
(
" SELECT MAX(start_datetime_utc) "
" FROM tbl_energy_storage_power_station_discharge_hourly "
" WHERE energy_storage_power_station_id = %s "
)
cursor_energy_db
.
execute
(
query
,
(
energy_storage_power_station
[
'id'
],))
row_datetime
=
cursor_energy_db
.
fetchone
()
start_datetime_utc
=
datetime
.
strptime
(
config
.
start_datetime_utc
,
'%Y-%m-%d %H:%M:%S'
)
start_datetime_utc
=
start_datetime_utc
.
replace
(
minute
=
0
,
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
if
row_datetime
is
not
None
and
len
(
row_datetime
)
>
0
and
isinstance
(
row_datetime
[
0
],
datetime
):
# replace second and microsecond with 0
# note: do not replace minute in case of calculating in half hourly
start_datetime_utc
=
row_datetime
[
0
].
replace
(
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
# start from the next time slot
start_datetime_utc
+=
timedelta
(
minutes
=
config
.
minutes_to_count
)
end_datetime_utc
=
datetime
.
utcnow
().
replace
(
second
=
0
,
microsecond
=
0
,
tzinfo
=
None
)
print
(
"start_datetime_utc: "
+
start_datetime_utc
.
isoformat
()[
0
:
19
]
+
"end_datetime_utc: "
+
end_datetime_utc
.
isoformat
()[
0
:
19
])
except
Exception
as
e
:
error_string
=
"Error in step 2.2 of energy_storage_power_station_energy_discharge.worker "
+
str
(
e
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
print
(
error_string
)
return
error_string
####################################################################################################################
# Step 3: for each energy storage container in list, get energy discharge data from energy database
####################################################################################################################
energy_energy_storage_container_hourly
=
dict
()
if
energy_storage_container_list
is
not
None
and
len
(
energy_storage_container_list
)
>
0
:
try
:
for
energy_storage_container
in
energy_storage_container_list
:
energy_storage_container_id
=
str
(
energy_storage_container
[
'id'
])
query
=
(
" SELECT start_datetime_utc, actual_value "
" FROM tbl_energy_storage_container_discharge_hourly "
" WHERE energy_storage_container_id = %s "
" AND start_datetime_utc >= %s "
" AND start_datetime_utc < %s "
" ORDER BY start_datetime_utc "
)
cursor_energy_db
.
execute
(
query
,
(
energy_storage_container_id
,
start_datetime_utc
,
end_datetime_utc
,))
rows_energy_values
=
cursor_energy_db
.
fetchall
()
if
rows_energy_values
is
None
or
len
(
rows_energy_values
)
==
0
:
energy_energy_storage_container_hourly
[
energy_storage_container_id
]
=
None
else
:
energy_energy_storage_container_hourly
[
energy_storage_container_id
]
=
dict
()
for
row_value
in
rows_energy_values
:
current_datetime_utc
=
row_value
[
0
]
actual_value
=
row_value
[
1
]
energy_energy_storage_container_hourly
[
energy_storage_container_id
][
current_datetime_utc
]
=
\
actual_value
except
Exception
as
e
:
error_string
=
"Error in step 3 of energy_storage_power_station_energy_discharge.worker "
+
str
(
e
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
print
(
error_string
)
return
error_string
####################################################################################################################
# Step 4: determine common time slot to aggregate
####################################################################################################################
common_start_datetime_utc
=
start_datetime_utc
common_end_datetime_utc
=
end_datetime_utc
print
(
"Getting common time slot of energy values for all energy storage containers..."
)
if
common_start_datetime_utc
is
not
None
and
common_end_datetime_utc
is
not
None
:
if
energy_energy_storage_container_hourly
is
not
None
and
len
(
energy_energy_storage_container_hourly
)
>
0
:
for
energy_storage_container_id
,
energy_hourly
in
energy_energy_storage_container_hourly
.
items
():
if
energy_hourly
is
None
or
len
(
energy_hourly
)
==
0
:
common_start_datetime_utc
=
None
common_end_datetime_utc
=
None
break
else
:
if
common_start_datetime_utc
<
min
(
energy_hourly
.
keys
()):
common_start_datetime_utc
=
min
(
energy_hourly
.
keys
())
if
common_end_datetime_utc
>
max
(
energy_hourly
.
keys
()):
common_end_datetime_utc
=
max
(
energy_hourly
.
keys
())
if
energy_energy_storage_container_hourly
is
None
or
len
(
energy_energy_storage_container_hourly
)
==
0
:
# There isn't any energy data
print
(
"There isn't any energy data"
)
# continue the for energy storage power station loop to the next energy storage power station
print
(
"continue the for energy storage power station loop to the next energy storage power station"
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
return
None
print
(
"common_start_datetime_utc: "
+
str
(
common_start_datetime_utc
))
print
(
"common_end_datetime_utc: "
+
str
(
common_end_datetime_utc
))
####################################################################################################################
# Step 5: aggregate energy data in the common time slot by energy categories and hourly
####################################################################################################################
print
(
"Step 5: aggregate energy data in the common time slot by energy categories and hourly"
)
aggregated_values
=
list
()
try
:
current_datetime_utc
=
common_start_datetime_utc
while
common_start_datetime_utc
is
not
None
\
and
common_end_datetime_utc
is
not
None
\
and
current_datetime_utc
<=
common_end_datetime_utc
:
aggregated_value
=
dict
()
aggregated_value
[
'start_datetime_utc'
]
=
current_datetime_utc
aggregated_value
[
'actual_value'
]
=
Decimal
(
0.0
)
if
energy_storage_container_list
is
not
None
and
len
(
energy_storage_container_list
)
>
0
:
for
energy_storage_container
in
energy_storage_container_list
:
energy_storage_container_id
=
str
(
energy_storage_container
[
'id'
])
aggregated_value
[
'actual_value'
]
+=
\
energy_energy_storage_container_hourly
[
energy_storage_container_id
][
current_datetime_utc
]
aggregated_values
.
append
(
aggregated_value
)
current_datetime_utc
+=
timedelta
(
minutes
=
config
.
minutes_to_count
)
except
Exception
as
e
:
error_string
=
"Error in step 5 of energy_storage_power_station_energy_discharge.worker "
+
str
(
e
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
print
(
error_string
)
return
error_string
####################################################################################################################
# Step 6: save energy data to energy database
####################################################################################################################
print
(
"Step 6: save energy data to energy database"
)
while
len
(
aggregated_values
)
>
0
:
insert_100
=
aggregated_values
[:
100
]
aggregated_values
=
aggregated_values
[
100
:]
try
:
add_values
=
(
" INSERT INTO tbl_energy_storage_power_station_discharge_hourly "
" (energy_storage_power_station_id, "
" start_datetime_utc, "
" actual_value) "
" VALUES "
)
for
aggregated_value
in
insert_100
:
add_values
+=
" ("
+
str
(
energy_storage_power_station
[
'id'
])
+
","
add_values
+=
"'"
+
aggregated_value
[
'start_datetime_utc'
].
isoformat
()[
0
:
19
]
+
"',"
add_values
+=
str
(
aggregated_value
[
'actual_value'
])
+
"), "
print
(
"add_values:"
+
add_values
)
# trim ", " at the end of string and then execute
cursor_energy_db
.
execute
(
add_values
[:
-
2
])
cnx_energy_db
.
commit
()
except
Exception
as
e
:
error_string
=
"Error in step 6.1 of energy_storage_power_station_energy_discharge.worker "
+
str
(
e
)
print
(
error_string
)
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
return
error_string
if
cursor_energy_db
:
cursor_energy_db
.
close
()
if
cnx_energy_db
:
cnx_energy_db
.
close
()
return
None
myems-aggregation/main.py
浏览文件 @
ef49efe0
...
...
@@ -15,6 +15,12 @@ import energy_storage_container_carbon_charge
import
energy_storage_container_billing_discharge
import
energy_storage_container_energy_discharge
import
energy_storage_container_carbon_discharge
import
energy_storage_power_station_billing_charge
import
energy_storage_power_station_energy_charge
import
energy_storage_power_station_carbon_charge
import
energy_storage_power_station_billing_discharge
import
energy_storage_power_station_energy_discharge
import
energy_storage_power_station_carbon_discharge
import
equipment_billing_input_category
import
equipment_billing_input_item
import
equipment_billing_output_category
...
...
@@ -105,6 +111,19 @@ def main():
# energy storage container carbon discharge
Process
(
target
=
energy_storage_container_carbon_discharge
.
main
,
args
=
(
logger
,)).
start
()
# energy storage power station energy charge
Process
(
target
=
energy_storage_power_station_energy_charge
.
main
,
args
=
(
logger
,)).
start
()
# energy storage power station energy discharge
Process
(
target
=
energy_storage_power_station_energy_discharge
.
main
,
args
=
(
logger
,)).
start
()
# energy storage power station billing charge
Process
(
target
=
energy_storage_power_station_billing_charge
.
main
,
args
=
(
logger
,)).
start
()
# energy storage power station billing discharge
Process
(
target
=
energy_storage_power_station_billing_discharge
.
main
,
args
=
(
logger
,)).
start
()
# energy storage power station carbon charge
Process
(
target
=
energy_storage_power_station_carbon_charge
.
main
,
args
=
(
logger
,)).
start
()
# energy storage power station carbon discharge
Process
(
target
=
energy_storage_power_station_carbon_discharge
.
main
,
args
=
(
logger
,)).
start
()
# equipment billing input by energy categories
Process
(
target
=
equipment_billing_input_category
.
main
,
args
=
(
logger
,)).
start
()
# equipment billing input by energy items
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录