First pass scan
This commit is contained in:
@@ -126,6 +126,28 @@ def inp_in_pattern(section: list[str]) -> ChangeSet:
|
|||||||
return cs
|
return cs
|
||||||
|
|
||||||
|
|
||||||
|
def inp_in_pattern_new(name: str, section: list[str]) -> None:
|
||||||
|
descs = {}
|
||||||
|
patterns: list[str] = []
|
||||||
|
|
||||||
|
count = len(section)
|
||||||
|
for i in range(0, count):
|
||||||
|
if section[i].startswith(';'):
|
||||||
|
# this is description
|
||||||
|
next = i + 1
|
||||||
|
if next < count and section[next].startswith(';') == False:
|
||||||
|
next_tokens = section[next].split()
|
||||||
|
descs[next_tokens[0]] = section[i].removeprefix(';')
|
||||||
|
continue
|
||||||
|
|
||||||
|
tokens = section[i].split()
|
||||||
|
if tokens[0] not in patterns:
|
||||||
|
patterns.append(tokens[0])
|
||||||
|
write(name, f"insert into _pattern (id) values ('{tokens[0]}');")
|
||||||
|
for token in tokens[1:]:
|
||||||
|
write(name, f"insert into patterns (id, factor) values ('{tokens[0]}', {float(token)});")
|
||||||
|
|
||||||
|
|
||||||
def inp_out_pattern(name: str) -> list[str]:
|
def inp_out_pattern(name: str) -> list[str]:
|
||||||
lines = []
|
lines = []
|
||||||
objs = read_all(name, f"select * from patterns order by _order")
|
objs = read_all(name, f"select * from patterns order by _order")
|
||||||
|
|||||||
@@ -159,6 +159,32 @@ def inp_in_curve(section: list[str]) -> ChangeSet:
|
|||||||
return cs
|
return cs
|
||||||
|
|
||||||
|
|
||||||
|
def inp_in_curve_new(name: str, section: list[str]) -> None:
|
||||||
|
types = {}
|
||||||
|
descs = {}
|
||||||
|
curves: list[str] = []
|
||||||
|
|
||||||
|
count = len(section)
|
||||||
|
for i in range(0, count):
|
||||||
|
if section[i].startswith(';'):
|
||||||
|
# ;type: desc
|
||||||
|
type_plus_desc = section[i].removeprefix(';')
|
||||||
|
type_plus_desc_tokens = type_plus_desc.split(':')
|
||||||
|
next = i + 1
|
||||||
|
if next < count and section[next].startswith(';') == False:
|
||||||
|
next_tokens = section[next].split()
|
||||||
|
types[next_tokens[0]] = type_plus_desc_tokens[0].strip().upper()
|
||||||
|
if len(type_plus_desc_tokens) > 1:
|
||||||
|
descs[next_tokens[0]] = type_plus_desc_tokens[1].strip()
|
||||||
|
continue
|
||||||
|
|
||||||
|
tokens = section[i].split()
|
||||||
|
if tokens[0] not in curves:
|
||||||
|
curves.append(tokens[0])
|
||||||
|
write(name, f"insert into _curve (id, type) values ('{tokens[0]}', '{types[tokens[0]]}');")
|
||||||
|
write(name, f"insert into curves (id, x, y) values ('{tokens[0]}', {float(tokens[1])}, {float(tokens[2])});")
|
||||||
|
|
||||||
|
|
||||||
def inp_out_curve(name: str) -> list[str]:
|
def inp_out_curve(name: str) -> list[str]:
|
||||||
lines = []
|
lines = []
|
||||||
types = read_all(name, f"select * from _curve")
|
types = read_all(name, f"select * from _curve")
|
||||||
|
|||||||
@@ -48,5 +48,10 @@ def inp_in_control(section: list[str]) -> ChangeSet:
|
|||||||
return ChangeSet()
|
return ChangeSet()
|
||||||
|
|
||||||
|
|
||||||
|
def inp_in_control_new(name: str, section: list[str]) -> None:
|
||||||
|
for line in section:
|
||||||
|
write(name, f"\ninsert into controls (line) values ('{line}');")
|
||||||
|
|
||||||
|
|
||||||
def inp_out_control(name: str) -> list[str]:
|
def inp_out_control(name: str) -> list[str]:
|
||||||
return get_control(name)['controls']
|
return get_control(name)['controls']
|
||||||
|
|||||||
@@ -44,5 +44,10 @@ def inp_in_rule(section: list[str]) -> ChangeSet:
|
|||||||
return ChangeSet()
|
return ChangeSet()
|
||||||
|
|
||||||
|
|
||||||
|
def inp_in_rule_new(name: str, section: list[str]) -> None:
|
||||||
|
for line in section:
|
||||||
|
write(name, f"\ninsert into rules (line) values ('{line}');")
|
||||||
|
|
||||||
|
|
||||||
def inp_out_rule(name: str) -> list[str]:
|
def inp_out_rule(name: str) -> list[str]:
|
||||||
return get_rule(name)['rules']
|
return get_rule(name)['rules']
|
||||||
@@ -40,6 +40,15 @@ def inp_in_title(section: list[str]) -> ChangeSet:
|
|||||||
return ChangeSet(g_update_prefix | {'type': 'title', 'value' : obj.value})
|
return ChangeSet(g_update_prefix | {'type': 'title', 'value' : obj.value})
|
||||||
|
|
||||||
|
|
||||||
|
def inp_in_title_new(name: str, section: list[str]) -> None:
|
||||||
|
if section == []:
|
||||||
|
return
|
||||||
|
|
||||||
|
title = '\n'.join(section)
|
||||||
|
sql = f"update title set value = '{title}';"
|
||||||
|
write(name, sql)
|
||||||
|
|
||||||
|
|
||||||
def inp_out_title(name: str) -> list[str]:
|
def inp_out_title(name: str) -> list[str]:
|
||||||
obj = str(get_title(name)['value'])
|
obj = str(get_title(name)['value'])
|
||||||
return obj.split('\n')
|
return obj.split('\n')
|
||||||
|
|||||||
@@ -97,6 +97,18 @@ def inp_in_time(section: list[str]) -> ChangeSet:
|
|||||||
return ChangeSet()
|
return ChangeSet()
|
||||||
|
|
||||||
|
|
||||||
|
def inp_in_time_new(name: str, section: list[str]) -> None:
|
||||||
|
for s in section:
|
||||||
|
if s.startswith(';'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
line = s.upper().strip()
|
||||||
|
for key in get_time_schema('').keys():
|
||||||
|
if line.startswith(key):
|
||||||
|
value = line.removeprefix(key).strip()
|
||||||
|
write(name, f"update times set value = '{value}' where key = '{key}';")
|
||||||
|
|
||||||
|
|
||||||
def inp_out_time(name: str) -> list[str]:
|
def inp_out_time(name: str) -> list[str]:
|
||||||
lines = []
|
lines = []
|
||||||
objs = read_all(name, f"select * from times")
|
objs = read_all(name, f"select * from times")
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ def inp_in_report(section: list[str]) -> ChangeSet:
|
|||||||
return ChangeSet()
|
return ChangeSet()
|
||||||
|
|
||||||
|
|
||||||
|
def inp_in_report_new(name: str, section: list[str]) -> None:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def inp_out_report(name: str) -> list[str]:
|
def inp_out_report(name: str) -> list[str]:
|
||||||
lines = []
|
lines = []
|
||||||
objs = read_all(name, f"select * from report")
|
objs = read_all(name, f"select * from report")
|
||||||
|
|||||||
@@ -40,6 +40,18 @@ def inp_in_option(section: list[str]) -> ChangeSet:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def inp_in_option_new(name: str, section: list[str]) -> None:
|
||||||
|
result = inp_in_option(section)
|
||||||
|
for op in result.operations:
|
||||||
|
for key in op.keys():
|
||||||
|
if key == 'operation' or key == 'type':
|
||||||
|
continue
|
||||||
|
if op['type'] == 'option':
|
||||||
|
write(name, f"update options set value = '{op[key]}' where key = '{key}';")
|
||||||
|
else:
|
||||||
|
write(name, f"update options_v3 set value = '{op[key]}' where key = '{key}';")
|
||||||
|
|
||||||
|
|
||||||
def inp_out_option(name: str) -> list[str]:
|
def inp_out_option(name: str) -> list[str]:
|
||||||
lines = []
|
lines = []
|
||||||
objs = read_all(name, f"select * from options")
|
objs = read_all(name, f"select * from options")
|
||||||
|
|||||||
@@ -44,7 +44,11 @@ def inp_in_option_v3(section: list[str]) -> ChangeSet:
|
|||||||
tokens = s.strip().split()
|
tokens = s.strip().split()
|
||||||
key = tokens[0]
|
key = tokens[0]
|
||||||
if key in get_option_v3_schema('').keys():
|
if key in get_option_v3_schema('').keys():
|
||||||
value = tokens[1] if len(tokens) >= 2 else ''
|
value = ''
|
||||||
|
if len(tokens) == 2:
|
||||||
|
value = tokens[1]
|
||||||
|
elif len(tokens) > 2:
|
||||||
|
value = ' '.join(tokens[1:])
|
||||||
cs_v3 |= { key : value }
|
cs_v3 |= { key : value }
|
||||||
else:
|
else:
|
||||||
v2_lines.append(s.strip())
|
v2_lines.append(s.strip())
|
||||||
@@ -58,6 +62,18 @@ def inp_in_option_v3(section: list[str]) -> ChangeSet:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def inp_in_option_v3_new(name: str, section: list[str]) -> None:
|
||||||
|
result = inp_in_option_v3(section)
|
||||||
|
for op in result.operations:
|
||||||
|
for key in op.keys():
|
||||||
|
if key == 'operation' or key == 'type':
|
||||||
|
continue
|
||||||
|
if op['type'] == 'option_v3':
|
||||||
|
write(name, f"update options_v3 set value = '{op[key]}' where key = '{key}';")
|
||||||
|
else:
|
||||||
|
write(name, f"update options set value = '{op[key]}' where key = '{key}';")
|
||||||
|
|
||||||
|
|
||||||
def inp_out_option_v3(name: str) -> list[str]:
|
def inp_out_option_v3(name: str) -> list[str]:
|
||||||
lines = []
|
lines = []
|
||||||
objs = read_all(name, f"select * from options_v3")
|
objs = read_all(name, f"select * from options_v3")
|
||||||
|
|||||||
@@ -38,6 +38,15 @@ def inp_in_backdrop(section: list[str]) -> ChangeSet:
|
|||||||
return ChangeSet()
|
return ChangeSet()
|
||||||
|
|
||||||
|
|
||||||
|
def inp_in_backdrop_new(name: str, section: list[str]) -> None:
|
||||||
|
if section == []:
|
||||||
|
return
|
||||||
|
|
||||||
|
content = '\n'.join(section)
|
||||||
|
sql = f"update backdrop set content = '{content}';"
|
||||||
|
write(name, sql)
|
||||||
|
|
||||||
|
|
||||||
def inp_out_backdrop(name: str) -> list[str]:
|
def inp_out_backdrop(name: str) -> list[str]:
|
||||||
obj = str(get_backdrop(name)['content'])
|
obj = str(get_backdrop(name)['content'])
|
||||||
return obj.split('\n')
|
return obj.split('\n')
|
||||||
@@ -34,9 +34,38 @@ s29_scada_device = 'scada_device'
|
|||||||
s30_scada_device_data = 'scada_device_data'
|
s30_scada_device_data = 'scada_device_data'
|
||||||
s31_scada_element = 'scada_element'
|
s31_scada_element = 'scada_element'
|
||||||
|
|
||||||
section_name = ['TITLE', 'JUNCTIONS', 'RESERVOIRS', 'TANKS', 'PIPES',
|
TITLE = 'TITLE'
|
||||||
'PUMPS', 'VALVES', 'TAGS', 'DEMANDS', 'STATUS',
|
JUNCTIONS = 'JUNCTIONS'
|
||||||
'PATTERNS', 'CURVES', 'CONTROLS', 'RULES', 'ENERGY',
|
RESERVOIRS = 'RESERVOIRS'
|
||||||
'EMITTERS', 'QUALITY', 'SOURCES', 'REACTIONS', 'MIXING',
|
TANKS = 'TANKS'
|
||||||
'TIMES', 'REPORT', 'OPTIONS', 'COORDINATES', 'VERTICES',
|
PIPES = 'PIPES'
|
||||||
'LABELS', 'BACKDROP', 'END']
|
PUMPS = 'PUMPS'
|
||||||
|
VALVES = 'VALVES'
|
||||||
|
TAGS = 'TAGS'
|
||||||
|
DEMANDS = 'DEMANDS'
|
||||||
|
STATUS = 'STATUS'
|
||||||
|
PATTERNS = 'PATTERNS'
|
||||||
|
CURVES = 'CURVES'
|
||||||
|
CONTROLS = 'CONTROLS'
|
||||||
|
RULES = 'RULES'
|
||||||
|
ENERGY = 'ENERGY'
|
||||||
|
EMITTERS = 'EMITTERS'
|
||||||
|
QUALITY = 'QUALITY'
|
||||||
|
SOURCES = 'SOURCES'
|
||||||
|
REACTIONS = 'REACTIONS'
|
||||||
|
MIXING = 'MIXING'
|
||||||
|
TIMES = 'TIMES'
|
||||||
|
REPORT = 'REPORT'
|
||||||
|
OPTIONS = 'OPTIONS'
|
||||||
|
COORDINATES = 'COORDINATES'
|
||||||
|
VERTICES = 'VERTICES'
|
||||||
|
LABELS = 'LABELS'
|
||||||
|
BACKDROP = 'BACKDROP'
|
||||||
|
END = 'END'
|
||||||
|
|
||||||
|
section_name = [TITLE, JUNCTIONS, RESERVOIRS, TANKS, PIPES,
|
||||||
|
PUMPS, VALVES, TAGS, DEMANDS, STATUS,
|
||||||
|
PATTERNS, CURVES, CONTROLS, RULES, ENERGY,
|
||||||
|
EMITTERS, QUALITY, SOURCES, REACTIONS, MIXING,
|
||||||
|
TIMES, REPORT, OPTIONS, COORDINATES, VERTICES,
|
||||||
|
LABELS, BACKDROP, END]
|
||||||
|
|||||||
Reference in New Issue
Block a user