Accept Merge Request #85: (api -> master)
Merge Request: Parse more sections Created By: @王琼钰 Accepted By: @王琼钰 URL: https://tjwater.coding.net/p/tjwatercloud/d/TJWaterServer/git/merge/85
This commit is contained in:
@@ -99,7 +99,7 @@ def inp_in_status(section: list[str]) -> ChangeSet:
|
||||
|
||||
cs = ChangeSet()
|
||||
for link, values in objs.items():
|
||||
obj_cs = {'operation': API_UPDATE, 'type': 'status', 'link' : link, 'status': None, 'setting': None}
|
||||
obj_cs : dict[str, Any] = g_update_prefix | {'type': 'status', 'link' : link, 'status': None, 'setting': None}
|
||||
for obj in values:
|
||||
if obj.is_status:
|
||||
obj_cs['status'] = obj.status
|
||||
|
||||
@@ -115,7 +115,7 @@ def inp_in_pattern(section: list[str]) -> ChangeSet:
|
||||
|
||||
cs = ChangeSet()
|
||||
for id, factors in patterns.items():
|
||||
cs.append({'operation': API_ADD, 'type': 'pattern', 'id' : id, 'factors' : factors})
|
||||
cs.append(g_add_prefix | {'type': 'pattern', 'id' : id, 'factors' : factors})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ def inp_in_curve(section: list[str]) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
for id, coords in curves.items():
|
||||
c_type = types[id] if id in types else CURVE_TYPE_PUMP
|
||||
cs.append({'operation': API_ADD, 'type': 'curve', 'id' : id, 'c_type': c_type, 'coords' : coords})
|
||||
cs.append(g_add_prefix | {'type': 'curve', 'id' : id, 'c_type': c_type, 'coords' : coords})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class InpControl:
|
||||
|
||||
def inp_in_control(section: list[str]) -> ChangeSet:
|
||||
obj = InpControl(section)
|
||||
cs = ChangeSet({'operation' : API_UPDATE, 'type': 'control', 'control' : obj.control})
|
||||
cs = ChangeSet(g_update_prefix | {'type': 'control', 'control' : obj.control})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class InpRule:
|
||||
|
||||
def inp_in_rule(section: list[str]) -> ChangeSet:
|
||||
obj = InpRule(section)
|
||||
cs = ChangeSet({'operation' : API_UPDATE, 'type': 'rule', 'rule' : obj.rule})
|
||||
cs = ChangeSet(g_update_prefix | {'type': 'rule', 'rule' : obj.rule})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -57,27 +57,6 @@ def set_energy(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_energy_cache(name, cs))
|
||||
|
||||
|
||||
def inp_in_energy(section: list[str]) -> ChangeSet:
|
||||
cs = g_update_prefix | { 'type' : 'energy' }
|
||||
for s in section:
|
||||
line = s.upper().strip()
|
||||
for key in get_energy_schema('').keys():
|
||||
if line.startswith(key):
|
||||
value = line.removeprefix(key).strip()
|
||||
cs |= { key : value }
|
||||
return ChangeSet(cs)
|
||||
|
||||
|
||||
def inp_out_energy(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, f"select * from energy")
|
||||
for obj in objs:
|
||||
key = obj['key']
|
||||
value = obj['value']
|
||||
lines.append(f'{key} {value}')
|
||||
return lines
|
||||
|
||||
|
||||
def get_pump_energy_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
return { 'pump' : {'type': 'str' , 'optional': False , 'readonly': True },
|
||||
'price' : {'type': 'float' , 'optional': True , 'readonly': False},
|
||||
@@ -150,3 +129,57 @@ def set_pump_energy_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
|
||||
def set_pump_energy(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_pump_energy_cache(name, cs))
|
||||
|
||||
|
||||
def inp_in_energy(section: list[str]) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
|
||||
for s in section:
|
||||
tokens = s.strip().split()
|
||||
|
||||
if tokens[0].upper() == 'PUMP':
|
||||
pump = tokens[1]
|
||||
key = tokens[2].lower()
|
||||
value = tokens[3]
|
||||
if key == 'price':
|
||||
value = float(value)
|
||||
cs.append(g_update_prefix | { 'type' : 'pump_energy', 'pump' : pump, key: value })
|
||||
|
||||
else:
|
||||
line = s.upper().strip()
|
||||
for key in get_energy_schema('').keys():
|
||||
if line.startswith(key):
|
||||
value = line.removeprefix(key).strip()
|
||||
cs.append(g_update_prefix | { 'type' : 'energy', key : value })
|
||||
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_energy(name: str) -> list[str]:
|
||||
lines = []
|
||||
|
||||
objs = read_all(name, f"select * from energy")
|
||||
for obj in objs:
|
||||
key = obj['key']
|
||||
value = obj['value']
|
||||
lines.append(f'{key} {value}')
|
||||
|
||||
objs = read_all(name, f"select * from energy_pump_price")
|
||||
for obj in objs:
|
||||
pump = obj['pump']
|
||||
value = obj['price']
|
||||
lines.append(f'PUMP {pump} PRICE {value}')
|
||||
|
||||
objs = read_all(name, f"select * from energy_pump_pattern")
|
||||
for obj in objs:
|
||||
pump = obj['pump']
|
||||
value = obj['pattern']
|
||||
lines.append(f'PUMP {pump} PATTERN {value}')
|
||||
|
||||
objs = read_all(name, f"select * from energy_pump_effic")
|
||||
for obj in objs:
|
||||
pump = obj['pump']
|
||||
value = obj['effic']
|
||||
lines.append(f'PUMP {pump} EFFIC {value}')
|
||||
|
||||
return lines
|
||||
|
||||
@@ -57,3 +57,36 @@ def set_emitter_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
|
||||
def set_emitter(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_emitter_cache(name, cs))
|
||||
|
||||
|
||||
class InpEmitter:
|
||||
def __init__(self, line: str) -> None:
|
||||
tokens = line.split()
|
||||
|
||||
num = len(tokens)
|
||||
has_desc = tokens[-1].startswith(';')
|
||||
num_without_desc = (num - 1) if has_desc else num
|
||||
|
||||
self.junction = str(tokens[0])
|
||||
self.coefficient = float(tokens[1])
|
||||
|
||||
|
||||
def inp_in_emitter(section: list[str]) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
for s in section:
|
||||
# skip comment
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpEmitter(s)
|
||||
cs.append(g_update_prefix | {'type': 'emitter', 'junction': obj.junction, 'coefficient': obj.coefficient})
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_emitter(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, 'select * from emitters')
|
||||
for obj in objs:
|
||||
junction = obj['junction']
|
||||
coefficient = obj['coefficient']
|
||||
lines.append(f'{junction} {coefficient}')
|
||||
return lines
|
||||
|
||||
@@ -57,3 +57,36 @@ def set_quality_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
|
||||
def set_quality(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_quality_cache(name, cs))
|
||||
|
||||
|
||||
class InpQuality:
|
||||
def __init__(self, line: str) -> None:
|
||||
tokens = line.split()
|
||||
|
||||
num = len(tokens)
|
||||
has_desc = tokens[-1].startswith(';')
|
||||
num_without_desc = (num - 1) if has_desc else num
|
||||
|
||||
self.node = str(tokens[0])
|
||||
self.quality = float(tokens[1])
|
||||
|
||||
|
||||
def inp_in_quality(section: list[str]) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
for s in section:
|
||||
# skip comment
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpQuality(s)
|
||||
cs.append(g_update_prefix | {'type': 'quality', 'node': obj.node, 'quality': obj.quality})
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_quality(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, 'select * from quality')
|
||||
for obj in objs:
|
||||
node = obj['node']
|
||||
quality = obj['quality']
|
||||
lines.append(f'{node} {quality}')
|
||||
return lines
|
||||
|
||||
@@ -98,3 +98,40 @@ def delete_source_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
|
||||
def delete_source(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, delete_source_cache(name, cs))
|
||||
|
||||
|
||||
class InpSource:
|
||||
def __init__(self, line: str) -> None:
|
||||
tokens = line.split()
|
||||
|
||||
num = len(tokens)
|
||||
has_desc = tokens[-1].startswith(';')
|
||||
num_without_desc = (num - 1) if has_desc else num
|
||||
|
||||
self.node = str(tokens[0])
|
||||
self.s_type = str(tokens[1])
|
||||
self.strength = float(tokens[2])
|
||||
self.pattern = str(tokens[3]) if num_without_desc >= 4 else None
|
||||
|
||||
|
||||
def inp_in_source(section: list[str]) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
for s in section:
|
||||
# skip comment
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpSource(s)
|
||||
cs.append(g_add_prefix | {'type': 'source', 'node': obj.node, 's_type': obj.s_type, 'strength': obj.strength, 'pattern': obj.pattern})
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_source(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, 'select * from sources')
|
||||
for obj in objs:
|
||||
node = obj['node']
|
||||
s_type = obj['s_type']
|
||||
strength = obj['strength']
|
||||
pattern = obj['pattern'] if obj['pattern'] != None else ''
|
||||
lines.append(f'{node} {s_type} {strength} {pattern}')
|
||||
return lines
|
||||
|
||||
@@ -60,27 +60,6 @@ def set_reaction(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_reaction_cache(name, cs))
|
||||
|
||||
|
||||
def inp_in_reaction(section: list[str]) -> ChangeSet:
|
||||
cs = g_update_prefix | { 'type' : 'reaction' }
|
||||
for s in section:
|
||||
line = s.upper().strip()
|
||||
for key in get_reaction_schema('').keys():
|
||||
if line.startswith(key):
|
||||
value = line.removeprefix(key).strip()
|
||||
cs |= { key : value }
|
||||
return ChangeSet(cs)
|
||||
|
||||
|
||||
def inp_out_reaction(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, f"select * from reactions")
|
||||
for obj in objs:
|
||||
key = obj['key']
|
||||
value = obj['value']
|
||||
lines.append(f'{key} {value}')
|
||||
return lines
|
||||
|
||||
|
||||
def get_pipe_reaction_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
return { 'pipe' : {'type': 'str' , 'optional': False , 'readonly': True },
|
||||
'bulk' : {'type': 'float' , 'optional': True , 'readonly': False},
|
||||
@@ -200,3 +179,60 @@ def set_tank_reaction_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
|
||||
def set_tank_reaction(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_tank_reaction_cache(name, cs))
|
||||
|
||||
|
||||
def inp_in_reaction(section: list[str]) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
|
||||
for s in section:
|
||||
tokens = s.strip().split()
|
||||
token0 = tokens[0].upper()
|
||||
if token0 == 'BULK' or token0 == 'WALL':
|
||||
pipe = tokens[1]
|
||||
key = token0.lower()
|
||||
value = tokens[2]
|
||||
cs.append(g_update_prefix | { 'type' : 'pipe_reaction', 'pipe' : pipe, key: value })
|
||||
|
||||
elif token0 == 'TANK':
|
||||
tank = tokens[1]
|
||||
value = tokens[2]
|
||||
cs.append(g_update_prefix | { 'type' : 'pipe_reaction', 'tank' : tank, 'value': value })
|
||||
|
||||
else:
|
||||
line = s.upper().strip()
|
||||
for key in get_reaction_schema('').keys():
|
||||
if line.startswith(key):
|
||||
value = line.removeprefix(key).strip()
|
||||
cs.append(g_update_prefix | { 'type' : 'reaction', key : value })
|
||||
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_reaction(name: str) -> list[str]:
|
||||
lines = []
|
||||
|
||||
objs = read_all(name, f"select * from reactions")
|
||||
for obj in objs:
|
||||
key = obj['key']
|
||||
value = obj['value']
|
||||
lines.append(f'{key} {value}')
|
||||
|
||||
objs = read_all(name, f"select * from reactions_pipe_bulk")
|
||||
for obj in objs:
|
||||
pipe = obj['pipe']
|
||||
bulk = obj['bulk']
|
||||
lines.append(f'BULK {pipe} {bulk}')
|
||||
|
||||
objs = read_all(name, f"select * from reactions_pipe_wall")
|
||||
for obj in objs:
|
||||
pipe = obj['pipe']
|
||||
wall = obj['wall']
|
||||
lines.append(f'WALL {pipe} {wall}')
|
||||
|
||||
objs = read_all(name, f"select * from reactions_tank")
|
||||
for obj in objs:
|
||||
tank = obj['tank']
|
||||
value = obj['value']
|
||||
lines.append(f'TANK {tank} {value}')
|
||||
|
||||
return lines
|
||||
@@ -34,7 +34,7 @@ class InpTitle:
|
||||
|
||||
def inp_in_title(section: list[str]) -> ChangeSet:
|
||||
obj = InpTitle(section)
|
||||
cs = ChangeSet({'operation' : API_ADD, 'type': 'title', 'value' : obj.value})
|
||||
cs = ChangeSet(g_update_prefix | {'type': 'title', 'value' : obj.value})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -94,3 +94,38 @@ def delete_mixing_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
|
||||
def delete_mixing(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, delete_mixing_cache(name, cs))
|
||||
|
||||
|
||||
class InpMixing:
|
||||
def __init__(self, line: str) -> None:
|
||||
tokens = line.split()
|
||||
|
||||
num = len(tokens)
|
||||
has_desc = tokens[-1].startswith(';')
|
||||
num_without_desc = (num - 1) if has_desc else num
|
||||
|
||||
self.tank = str(tokens[0])
|
||||
self.model = str(tokens[1])
|
||||
self.value = float(tokens[3]) if num_without_desc >= 4 else None
|
||||
|
||||
|
||||
def inp_in_mixing(section: list[str]) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
for s in section:
|
||||
# skip comment
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpMixing(s)
|
||||
cs.append(g_add_prefix | {'type': 'mixing', 'tank': obj.tank, 'model': obj.model, 'value': obj.value})
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_mixing(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, 'select * from mixing')
|
||||
for obj in objs:
|
||||
tank = obj['tank']
|
||||
model = obj['model']
|
||||
value = obj['value'] if obj['value'] != None else ''
|
||||
lines.append(f'{tank} {model} {value}')
|
||||
return lines
|
||||
|
||||
@@ -22,7 +22,7 @@ def inp_in_coord(section: list[str]) -> dict[str, dict[str, float]]:
|
||||
return coords
|
||||
|
||||
|
||||
def inp_out_junction(name: str) -> list[str]:
|
||||
def inp_out_coord(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, 'select * from coordinates')
|
||||
for obj in objs:
|
||||
|
||||
@@ -78,3 +78,29 @@ def delete_vertex(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
result.redo_cs |= g_delete_prefix
|
||||
result.undo_cs |= g_add_prefix
|
||||
return execute_command(name, result)
|
||||
|
||||
|
||||
def inp_in_vertex(section: list[str]) -> ChangeSet:
|
||||
vertices: dict[str, list[dict[str, float]]] = {}
|
||||
|
||||
for s in section:
|
||||
tokens = s.split()
|
||||
if tokens[0] not in vertices:
|
||||
vertices[tokens[0]] = []
|
||||
vertices[tokens[0]].append({'x': float(tokens[1]), 'y': float(tokens[2])})
|
||||
|
||||
cs = ChangeSet()
|
||||
for link, coords in vertices.items():
|
||||
cs.append(g_add_prefix | {'type': 'vertex', 'link' : link, 'coords' : coords})
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_vertex(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, f"select * from vertices order by _order")
|
||||
for obj in objs:
|
||||
link = obj['link']
|
||||
x = obj['x']
|
||||
y = obj['y']
|
||||
lines.append(f"{link} {x} {y}")
|
||||
return lines
|
||||
|
||||
@@ -95,5 +95,38 @@ def delete_label_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
|
||||
|
||||
|
||||
def delete_label(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, delete_label_cache(name, cs))
|
||||
class InpLabel:
|
||||
def __init__(self, line: str) -> None:
|
||||
tokens = line.split()
|
||||
|
||||
num = len(tokens)
|
||||
has_desc = tokens[-1].startswith(';')
|
||||
num_without_desc = (num - 1) if has_desc else num
|
||||
|
||||
self.x = float(tokens[0])
|
||||
self.y = float(tokens[1])
|
||||
self.label = str(tokens[2])
|
||||
self.node = str(tokens[3]) if num >= 4 else None
|
||||
|
||||
|
||||
def inp_in_label(section: list[str]) -> ChangeSet:
|
||||
cs = ChangeSet()
|
||||
for s in section:
|
||||
# skip comment
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpLabel(s)
|
||||
cs.append(g_add_prefix | {'type': 'label', 'x': obj.x, 'y': obj.y, 'label': obj.label, 'node': obj.node})
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_label(name: str) -> list[str]:
|
||||
lines = []
|
||||
objs = read_all(name, 'select * from labels')
|
||||
for obj in objs:
|
||||
x = obj['x']
|
||||
y = obj['y']
|
||||
label = obj['label']
|
||||
node = obj['node'] if obj['node'] != None else ''
|
||||
lines.append(f'{x} {y} {label} {node}')
|
||||
return lines
|
||||
|
||||
@@ -24,3 +24,19 @@ def set_backdrop_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
|
||||
def set_backdrop(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_backdrop_cache(name, cs))
|
||||
|
||||
|
||||
class InpBackdrop:
|
||||
def __init__(self, section) -> None:
|
||||
self.value = '\n'.join(section)
|
||||
|
||||
|
||||
def inp_in_backdrop(section: list[str]) -> ChangeSet:
|
||||
obj = InpBackdrop(section)
|
||||
cs = ChangeSet(g_update_prefix | {'type': 'backdrop', 'content' : obj.value})
|
||||
return cs
|
||||
|
||||
|
||||
def inp_out_backdrop(name: str) -> list[str]:
|
||||
obj = str(get_backdrop(name)['content'])
|
||||
return obj.split('\n')
|
||||
@@ -142,7 +142,7 @@ def inp_in_junction(section: list[str]) -> ChangeSet:
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpJunction(s)
|
||||
cs.append({'operation': API_ADD, 'type': 'junction', 'id': obj.id, 'elevation': obj.elevation, 'demand': obj.demand, 'pattern': obj.pattern})
|
||||
cs.append(g_add_prefix | {'type': 'junction', 'id': obj.id, 'elevation': obj.elevation, 'demand': obj.demand, 'pattern': obj.pattern})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ def inp_in_reservoir(section: list[str]) -> ChangeSet:
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpReservoir(s)
|
||||
cs.append({'operation': API_ADD, 'type': 'reservoir', 'id': obj.id, 'head': obj.head, 'pattern': obj.pattern})
|
||||
cs.append(g_add_prefix | {'type': 'reservoir', 'id': obj.id, 'head': obj.head, 'pattern': obj.pattern})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ def inp_in_tank(section: list[str]) -> ChangeSet:
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpTank(s)
|
||||
cs.append({'operation': API_ADD, 'type': 'tank', 'id': obj.id, 'elevation': obj.elevation, 'init_level': obj.init_level, 'min_level': obj.min_level, 'max_level': obj.max_level, 'diameter': obj.diameter, 'min_vol': obj.min_vol, 'vol_curve': obj.vol_curve, 'overflow': obj.overflow})
|
||||
cs.append(g_add_prefix | {'type': 'tank', 'id': obj.id, 'elevation': obj.elevation, 'init_level': obj.init_level, 'min_level': obj.min_level, 'max_level': obj.max_level, 'diameter': obj.diameter, 'min_vol': obj.min_vol, 'vol_curve': obj.vol_curve, 'overflow': obj.overflow})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ def inp_in_pipe(section: list[str]) -> ChangeSet:
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpPipe(s)
|
||||
cs.append({'operation': API_ADD, 'type': 'pipe', 'id': obj.id, 'node1': obj.node1, 'node2': obj.node2, 'length': obj.length, 'diameter': obj.diameter, 'roughness': obj.roughness, 'minor_loss': obj.minor_loss, 'status': obj.status})
|
||||
cs.append(g_add_prefix | {'type': 'pipe', 'id': obj.id, 'node1': obj.node1, 'node2': obj.node2, 'length': obj.length, 'diameter': obj.diameter, 'roughness': obj.roughness, 'minor_loss': obj.minor_loss, 'status': obj.status})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ def inp_in_pump(section: list[str]) -> ChangeSet:
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpPump(s)
|
||||
cs.append({'operation': API_ADD, 'type': 'pump', 'id': obj.id, 'node1': obj.node1, 'node2': obj.node2, 'power': obj.power, 'head': obj.head, 'speed': obj.speed, 'pattern': obj.pattern})
|
||||
cs.append(g_add_prefix | {'type': 'pump', 'id': obj.id, 'node1': obj.node1, 'node2': obj.node2, 'power': obj.power, 'head': obj.head, 'speed': obj.speed, 'pattern': obj.pattern})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ def inp_in_valve(section: list[str]) -> ChangeSet:
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpValve(s)
|
||||
cs.append({'operation': API_ADD, 'type': 'valve', 'id': obj.id, 'node1': obj.node1, 'node2': obj.node2, 'diameter': obj.diameter, 'v_type': obj.v_type, 'setting': obj.setting, 'minor_loss': obj.minor_loss})
|
||||
cs.append(g_add_prefix | {'type': 'valve', 'id': obj.id, 'node1': obj.node1, 'node2': obj.node2, 'diameter': obj.diameter, 'v_type': obj.v_type, 'setting': obj.setting, 'minor_loss': obj.minor_loss})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ def inp_in_tag(section: list[str]) -> ChangeSet:
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
obj = InpTag(s)
|
||||
cs.append({'operation': API_UPDATE, 'type': 'tag', 't_type': obj.t_type, 'id': obj.id, 'tag': obj.tag})
|
||||
cs.append(g_update_prefix | {'type': 'tag', 't_type': obj.t_type, 'id': obj.id, 'tag': obj.tag})
|
||||
return cs
|
||||
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ def inp_in_demand(section: list[str]) -> ChangeSet:
|
||||
|
||||
cs = ChangeSet()
|
||||
for junction, demands in objs.items():
|
||||
obj_cs = {'operation': API_UPDATE, 'type': 'demand', 'junction' : junction, 'demands' : []}
|
||||
obj_cs : dict[str, Any] = g_update_prefix | {'type': 'demand', 'junction' : junction, 'demands' : []}
|
||||
for obj in demands:
|
||||
obj_cs['demands'].append({'demand': obj.demand, 'pattern' : obj.pattern, 'category': obj.category})
|
||||
cs.append(obj_cs)
|
||||
|
||||
Reference in New Issue
Block a user