start real time simulation api
This commit is contained in:
54
get_current_status.py
Normal file
54
get_current_status.py
Normal file
@@ -0,0 +1,54 @@
|
||||
from tjnetwork import *
|
||||
from get_realValue import *
|
||||
import datetime
|
||||
|
||||
|
||||
ids=['3489','3854','3853','2510','2514','4780','4854']
|
||||
cur_data=None
|
||||
|
||||
def get_latest_cal_time()->datetime:
|
||||
current_time=datetime.datetime.now()
|
||||
return current_time
|
||||
|
||||
|
||||
def get_current_data()->bool:
|
||||
global cur_data
|
||||
cur_data=get_realValue(ids)
|
||||
if cur_data ==None:
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_current_total_Q(str_dt:str='')->float:
|
||||
q_ids=['3489','3854','3853']
|
||||
q_dn900=cur_data[q_ids[0]]
|
||||
q_dn500=cur_data[q_ids[1]]
|
||||
q_dn1000=cur_data[q_ids[2]]
|
||||
total_q=q_dn1000+q_dn500+q_dn900
|
||||
return total_q
|
||||
|
||||
def get_h_pressure()->float:
|
||||
head_id='2510'
|
||||
h_pressure=cur_data[head_id]
|
||||
return h_pressure
|
||||
|
||||
def get_l_pressure()->float:
|
||||
head_id='2514'
|
||||
l_pressure=cur_data[head_id]
|
||||
return l_pressure
|
||||
|
||||
def get_h_tank_leve()->float:
|
||||
h_tank_id='4780'
|
||||
h_tank_level=cur_data[h_tank_id]
|
||||
return h_tank_level
|
||||
|
||||
def get_l_tank_leve()->float:
|
||||
l_tank_id='4854'
|
||||
l_tank_level=cur_data[l_tank_id]
|
||||
return l_tank_level
|
||||
|
||||
|
||||
# test interface
|
||||
if __name__ == '__main__':
|
||||
if get_current_data()==True:
|
||||
tQ=get_current_total_Q()
|
||||
print(f"the current tQ is {tQ}\n")
|
||||
Reference in New Issue
Block a user