Compare commits
12 Commits
f805788152
..
exp
| Author | SHA1 | Date | |
|---|---|---|---|
| b3e0054c23 | |||
| 7266540371 | |||
| 483c4799e0 | |||
| b6cd0994ea | |||
| 3c9b4e3161 | |||
| 4a9ea7db6d | |||
| 88f9a05fc1 | |||
| 57507598cc | |||
| 8e3115386b | |||
| caa698ffe4 | |||
| cbb37b4303 | |||
| 47f7147e12 |
@@ -1 +1,2 @@
|
|||||||
from autodoc.autodoc import *
|
from autodoc.autodoc import *
|
||||||
|
from autodoc.configdb import *
|
||||||
|
|||||||
+8
-1
@@ -11,6 +11,7 @@ import sys
|
|||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
import autodoc
|
import autodoc
|
||||||
|
from configdb import ConfigDB
|
||||||
|
|
||||||
__version__ = "0.0.0"
|
__version__ = "0.0.0"
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ def __args__():
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-d", "--destination", help="Destination folder", type=str, default="."
|
"-d", "--destination", help="Destination folder", type=str, default="."
|
||||||
)
|
)
|
||||||
|
parser.add_argument("-o", "--output", help="Output name", type=str, default="")
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@@ -73,8 +75,13 @@ def main():
|
|||||||
if not config:
|
if not config:
|
||||||
logging.error(f"Impossible to load configuration `{args.filename}`")
|
logging.error(f"Impossible to load configuration `{args.filename}`")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
if args.output:
|
||||||
|
filename = args.output
|
||||||
|
else:
|
||||||
filename = os.path.splitext(os.path.basename(args.filename))[0]
|
filename = os.path.splitext(os.path.basename(args.filename))[0]
|
||||||
autodoc.document(filename, args, config)
|
# autodoc.document(filename, args, config)
|
||||||
|
|
||||||
|
cfgdb = ConfigDB()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
"""
|
||||||
|
Autodoc functions
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import common as doc
|
||||||
|
from doc_state import *
|
||||||
|
from doc_state_machine import doc_state_machine
|
||||||
|
|
||||||
|
|
||||||
|
def __doc_app_state__(state, tab=" │ "):
|
||||||
|
res = ""
|
||||||
|
if "+Threads" in state:
|
||||||
|
for i, tname in enumerate(state["+Threads"]):
|
||||||
|
if tname[0] == "+":
|
||||||
|
ch = "├─●" if i < len(state["+Threads"]) - 1 else "╰─●"
|
||||||
|
res += f"{tab} {ch} {tname[1:]}\n"
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def __doc_application__(label, app):
|
||||||
|
logging.info(f"Documenting real time application {label}")
|
||||||
|
mdapp = f'\n## Real-time application: "{label[1:]}"\n\n'
|
||||||
|
mdapp += f"Below are descrbed the states and threads of the real-time application {label[1:]}.\n"
|
||||||
|
|
||||||
|
mdapp += "\n"
|
||||||
|
mdapp += "```\n"
|
||||||
|
# mdapp += f'╭{"─"*(len(label)-1)}╮\n'
|
||||||
|
# mdapp += f"│{label[1:]}│\n"
|
||||||
|
# mdapp += f'╰┬{"─"*(len(label)-2)}╯\n'
|
||||||
|
states = app["+States"]
|
||||||
|
|
||||||
|
for i, (state, obj) in enumerate(states.items()):
|
||||||
|
if state[0] == "+":
|
||||||
|
mdapp += f" - {state[1:]}\n"
|
||||||
|
for thread in obj["+Threads"]:
|
||||||
|
if thread[0] == "+":
|
||||||
|
mdapp += f" - {thread[1:]}\n"
|
||||||
|
ch = "├─▷" if i < len(states) - 1 else "╰─▷"
|
||||||
|
tab = " │ " if i < len(states) - 1 else " "
|
||||||
|
if label[0] == "+":
|
||||||
|
mdapp += f" {ch} {label[1:]}\n"
|
||||||
|
mdapp += __doc_app_state__(obj, tab)
|
||||||
|
mdapp += "```\n"
|
||||||
|
for label, obj in states.items():
|
||||||
|
if label[0] == "+":
|
||||||
|
mdapp += f'\n### State: "{label[1:]}"\n'
|
||||||
|
mdapp += doc_state(label, obj, app)
|
||||||
|
return mdapp
|
||||||
|
|
||||||
|
|
||||||
|
def document(fname, args, config):
|
||||||
|
"""Document MARTe object."""
|
||||||
|
doc.set_path(os.path.join(args.destination, fname))
|
||||||
|
doc.set_config(args)
|
||||||
|
if not os.path.isdir(doc.path()):
|
||||||
|
os.mkdir(doc.path())
|
||||||
|
now = datetime.now() # current date and time
|
||||||
|
today = now.strftime("%d/%m/%Y")
|
||||||
|
mddoc = "---\n"
|
||||||
|
mddoc += "toc: true\n"
|
||||||
|
mddoc += f"title: {fname} Documentation\n"
|
||||||
|
mddoc += "author: MARTe AutoDOC\n"
|
||||||
|
mddoc += "titlepage: true\n"
|
||||||
|
mddoc += f"date: {today}\n"
|
||||||
|
mddoc += "geometry: margin=2cm\n"
|
||||||
|
mddoc += "---\n\n"
|
||||||
|
|
||||||
|
mddoc += f"# {fname}\n"
|
||||||
|
for label, obj in config.items():
|
||||||
|
if "Class" in obj:
|
||||||
|
if obj["Class"] == "RealTimeApplication":
|
||||||
|
mddoc += __doc_application__(label, obj)
|
||||||
|
if obj["Class"] == "StateMachine":
|
||||||
|
mddoc += f'\n## State-Machine: "{label[1:]}"\n'
|
||||||
|
mddoc += doc_state_machine(label[1:], obj)
|
||||||
|
fpath = os.path.join(doc.path(), f"{fname}.md")
|
||||||
|
outpath = os.path.join(doc.path(), fname)
|
||||||
|
logging.info(f"Saving markdown: {fpath}")
|
||||||
|
with open(fpath, "w") as file:
|
||||||
|
file.write(mddoc)
|
||||||
|
if doc.build():
|
||||||
|
logging.info(f"Generating html: {outpath}.html")
|
||||||
|
os.system(
|
||||||
|
f"pandoc --css pandoc/styling.css --resource-path={doc.path()} --embed-resource --to html5 -s {fpath} -o {outpath}.html"
|
||||||
|
)
|
||||||
|
logging.info(f"Generating pdf: {outpath}.pdf")
|
||||||
|
os.system(
|
||||||
|
f"pandoc -H pandoc/disable_float.tex --resource-path={doc.path()} -s {fpath} -o {outpath}.pdf"
|
||||||
|
)
|
||||||
+12
-2
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
__PATH__ = "."
|
__PATH__ = "."
|
||||||
__CONFIG__ = None
|
__CONFIG__ = None
|
||||||
@@ -29,13 +30,19 @@ def type_bytes_count(mtype):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
def signal_byte_size(sig):
|
def signal_byte_size(parent_id, sig_id, sig):
|
||||||
noe = 1 if "NumberOfElements" not in sig else int(sig["NumberOfElements"])
|
noe = 1 if "NumberOfElements" not in sig else int(sig["NumberOfElements"])
|
||||||
nod = 1 if "NumberOfDimensions" not in sig else int(sig["NumberOfDimensions"])
|
nod = 1 if "NumberOfDimensions" not in sig else int(sig["NumberOfDimensions"])
|
||||||
nod = nod if nod > 0 else 1
|
nod = nod if nod > 0 else 1
|
||||||
noe = noe if noe > 0 else 1
|
noe = noe if noe > 0 else 1
|
||||||
|
nos = 1 if "Samples" not in sig else int(sig["Samples"])
|
||||||
|
if "Type" not in sig:
|
||||||
|
logging.warning(f"no type defined for signal {parent_id}.{sig_id}")
|
||||||
|
if "Type" in sig:
|
||||||
bytes = type_bytes_count(sig["Type"])
|
bytes = type_bytes_count(sig["Type"])
|
||||||
tot = noe * nod
|
else:
|
||||||
|
bytes = type_bytes_count(signal_type(sig)[0])
|
||||||
|
tot = noe * nod * nos
|
||||||
|
|
||||||
if "Ranges" in sig:
|
if "Ranges" in sig:
|
||||||
tot = 0
|
tot = 0
|
||||||
@@ -46,7 +53,10 @@ def signal_byte_size(sig):
|
|||||||
|
|
||||||
|
|
||||||
def signal_type(sig):
|
def signal_type(sig):
|
||||||
|
if "Type" in sig:
|
||||||
type_name = sig["Type"]
|
type_name = sig["Type"]
|
||||||
|
else:
|
||||||
|
type_name = "uint32"
|
||||||
noe = int(sig["NumberOfElements"]) if "NumberOfElements" in sig else 1
|
noe = int(sig["NumberOfElements"]) if "NumberOfElements" in sig else 1
|
||||||
nod = int(sig["NumberOfDimensions"]) if "NumberOfDimensions" in sig else 1
|
nod = int(sig["NumberOfDimensions"]) if "NumberOfDimensions" in sig else 1
|
||||||
nod = nod if nod > 0 else 1
|
nod = nod if nod > 0 else 1
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
from re import search
|
||||||
|
|
||||||
|
from MARTe.StandardParser import logging
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigDB:
|
||||||
|
def __new__(cls):
|
||||||
|
if not hasattr(cls, "instance"):
|
||||||
|
cls.instance = super(ConfigDB, cls).__new__(cls)
|
||||||
|
return cls.instance
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
ConfigDB.__INST__ = self
|
||||||
|
self.__db__ = {}
|
||||||
|
|
||||||
|
def get(self, path: str):
|
||||||
|
ipath = path.split(".")
|
||||||
|
obj = self.__db__
|
||||||
|
for p in ipath:
|
||||||
|
if p in obj:
|
||||||
|
obj = obj[p]
|
||||||
|
else:
|
||||||
|
logging.error(f"no key {p} found for {path}")
|
||||||
|
return None
|
||||||
|
return obj
|
||||||
|
|
||||||
|
def insert(self, key: dict, obj):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MARTeOBJ:
|
||||||
|
def __init__(self, fname, id, cfg):
|
||||||
|
self.__name__ = id
|
||||||
|
self.__mcls__ = cfg["Class"]
|
||||||
|
self.__struct__ = {}
|
||||||
|
for key, itm in cfg.items():
|
||||||
|
if key != "Class":
|
||||||
|
if isinstance(itm, dict) and "Class" in itm:
|
||||||
|
self.__struct__[key] = MARTeOBJ(fname, key, itm)
|
||||||
|
else:
|
||||||
|
self.__struct__[key] = itm
|
||||||
|
|
||||||
|
def pretty_print(self, spacing=""):
|
||||||
|
str = f"{spacing}{self.__name__}[{self.__mcls__}]:\n"
|
||||||
|
for key, itm in self.__struct__.items():
|
||||||
|
if isinstance(itm, MARTeOBJ):
|
||||||
|
str += itm.pretty_print(spacing + " ")
|
||||||
|
else:
|
||||||
|
str += f"{spacing} {key}: {itm}\n"
|
||||||
|
return str
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
str = f"{self.__name__}[{self.__mcls__}]:\n"
|
||||||
|
for key, itm in self.__struct__.items():
|
||||||
|
str += f" {key}: {itm}\n"
|
||||||
|
return str
|
||||||
|
|
||||||
|
|
||||||
|
def parse_config(fname: str, config: dict):
|
||||||
|
for key, obj in config.items():
|
||||||
|
ConfigDB().insert(key, obj)
|
||||||
+132
-94
@@ -1,5 +1,7 @@
|
|||||||
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
import common as doc
|
import common as doc
|
||||||
|
|
||||||
@@ -10,9 +12,9 @@ def __doc_obj__(label, obj, id):
|
|||||||
|
|
||||||
|
|
||||||
def __doc_common_gam__(name, obj, edges, thread):
|
def __doc_common_gam__(name, obj, edges, thread):
|
||||||
inputs = ""
|
inputs = "<table cellborder='0' border='0'>"
|
||||||
outputs = ""
|
outputs = "<table cellborder='0' border='0'>"
|
||||||
if "InputSignals" in obj:
|
if "InputSignals" in obj and len(obj["InputSignals"]):
|
||||||
for i, (l, sig) in enumerate(obj["InputSignals"].items()):
|
for i, (l, sig) in enumerate(obj["InputSignals"].items()):
|
||||||
alias = doc.signal_alias(l, sig)
|
alias = doc.signal_alias(l, sig)
|
||||||
mtype = doc.signal_type(sig)
|
mtype = doc.signal_type(sig)
|
||||||
@@ -25,50 +27,11 @@ def __doc_common_gam__(name, obj, edges, thread):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
if i != 0:
|
if i != 0:
|
||||||
inputs += " | "
|
inputs += "<hr/>"
|
||||||
inputs += f"<in_{doc.format_name(l)}> {l}"
|
inputs += f"<tr><td port='in_{doc.format_name(l)}'>{l}</td></tr>"
|
||||||
if "OutputSignals" in obj:
|
|
||||||
for i, (l, sig) in enumerate(obj["OutputSignals"].items()):
|
|
||||||
alias = doc.signal_alias(l, sig)
|
|
||||||
mtype = doc.signal_type(sig)
|
|
||||||
datasrc = sig["DataSource"]
|
|
||||||
edges.append(
|
|
||||||
doc.edge(
|
|
||||||
doc.signal(name, l, mtype),
|
|
||||||
doc.signal(datasrc, alias, mtype),
|
|
||||||
thread,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if i != 0:
|
|
||||||
outputs += " | "
|
|
||||||
outputs += f"<out_{doc.format_name(l)}> {l}"
|
|
||||||
return "{ {" + inputs + " } | { " + outputs + "} }", edges
|
|
||||||
|
|
||||||
|
|
||||||
def __doc_triggered_iogam__(name, obj, edges, thread):
|
|
||||||
signals = ""
|
|
||||||
if "InputSignals" in obj:
|
|
||||||
for i, (l, sig) in enumerate(obj["InputSignals"].items()):
|
|
||||||
alias = doc.signal_alias(l, sig)
|
|
||||||
mtype = doc.signal_type(sig)
|
|
||||||
datasrc = sig["DataSource"]
|
|
||||||
edges.append(
|
|
||||||
doc.edge(
|
|
||||||
doc.signal(datasrc, alias, mtype),
|
|
||||||
doc.signal(name, l, mtype),
|
|
||||||
thread,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if i > 1:
|
|
||||||
signals += " | "
|
|
||||||
signals += f"<in_{doc.format_name(l)}> "
|
|
||||||
|
|
||||||
if i == 0:
|
|
||||||
signals += "Trigger | { { "
|
|
||||||
else:
|
else:
|
||||||
signals += f"{l}"
|
inputs += "<tr><td></td></tr>"
|
||||||
signals += " } | { "
|
if "OutputSignals" in obj and len(obj["OutputSignals"]):
|
||||||
if "OutputSignals" in obj:
|
|
||||||
for i, (l, sig) in enumerate(obj["OutputSignals"].items()):
|
for i, (l, sig) in enumerate(obj["OutputSignals"].items()):
|
||||||
alias = doc.signal_alias(l, sig)
|
alias = doc.signal_alias(l, sig)
|
||||||
mtype = doc.signal_type(sig)
|
mtype = doc.signal_type(sig)
|
||||||
@@ -81,10 +44,41 @@ def __doc_triggered_iogam__(name, obj, edges, thread):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
if i != 0:
|
if i != 0:
|
||||||
signals += " | "
|
outputs += "<hr/>"
|
||||||
signals += f"<out_{doc.format_name(l)}> {l} "
|
outputs += f"<tr><td port='out_{doc.format_name(l)}'>{l}</td></tr>"
|
||||||
signals += " } }"
|
else:
|
||||||
node = f'{name} [tooltip=" TriggeredIOGAM::{name} ", label="{name}\nTriggeredIOGAM | {signals}", style=filled, fillcolor="#eee"];\n'
|
outputs += "<tr><td></td></tr>"
|
||||||
|
return (
|
||||||
|
"<tr><td>" + inputs + "</table></td><vr/><td>" + outputs + "</table></td></tr>",
|
||||||
|
edges,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def __doc_triggered_iogam__(id, obj, edges, thread):
|
||||||
|
node = ""
|
||||||
|
|
||||||
|
if len(obj["InputSignals"]) > 0:
|
||||||
|
name = id[2:]
|
||||||
|
node = __gam__(id, name, "TriggeredIOGAM")
|
||||||
|
|
||||||
|
recl = copy.deepcopy(obj)
|
||||||
|
trg = list(obj["InputSignals"].keys())[0]
|
||||||
|
sig = obj["InputSignals"][trg]
|
||||||
|
alias = doc.signal_alias(trg, sig)
|
||||||
|
mtype = doc.signal_type(sig)
|
||||||
|
datasrc = sig["DataSource"]
|
||||||
|
edges.append(
|
||||||
|
doc.edge(
|
||||||
|
doc.signal(datasrc, alias, mtype),
|
||||||
|
doc.signal(id, trg, mtype),
|
||||||
|
thread,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
node += f"<tr><td port='in_{doc.format_name(trg)}' colspan='2'><b>Trigger</b></td></tr><hr/>"
|
||||||
|
del recl["InputSignals"][trg]
|
||||||
|
sigs, edges = __doc_common_gam__(id, recl, edges, thread)
|
||||||
|
node += sigs
|
||||||
|
node += "</table>>];"
|
||||||
return node, edges
|
return node, edges
|
||||||
|
|
||||||
|
|
||||||
@@ -92,6 +86,7 @@ __set_keys__ = (
|
|||||||
"Alias",
|
"Alias",
|
||||||
"Type",
|
"Type",
|
||||||
"DataSource",
|
"DataSource",
|
||||||
|
"Samples",
|
||||||
"NumberOfElements",
|
"NumberOfElements",
|
||||||
"NumberOfDimensions",
|
"NumberOfDimensions",
|
||||||
"Ranges",
|
"Ranges",
|
||||||
@@ -116,7 +111,7 @@ def __doc_iogam__(id, obj, edges, thread):
|
|||||||
while input_size <= output_size and in_i < len(inputs):
|
while input_size <= output_size and in_i < len(inputs):
|
||||||
in_label = input_names[in_i]
|
in_label = input_names[in_i]
|
||||||
input = inputs[in_label]
|
input = inputs[in_label]
|
||||||
input_size += doc.signal_byte_size(input)
|
input_size += doc.signal_byte_size(id, in_label, input)
|
||||||
in_i += 1
|
in_i += 1
|
||||||
alias = doc.signal_alias(in_label, input)
|
alias = doc.signal_alias(in_label, input)
|
||||||
mtype = doc.signal_type(input)
|
mtype = doc.signal_type(input)
|
||||||
@@ -139,7 +134,7 @@ def __doc_iogam__(id, obj, edges, thread):
|
|||||||
while output_size < input_size and out_i < len(outputs):
|
while output_size < input_size and out_i < len(outputs):
|
||||||
out_label = output_names[out_i]
|
out_label = output_names[out_i]
|
||||||
output = outputs[out_label]
|
output = outputs[out_label]
|
||||||
output_size += doc.signal_byte_size(output)
|
output_size += doc.signal_byte_size(id, out_label, output)
|
||||||
out_i += 1
|
out_i += 1
|
||||||
alias = doc.signal_alias(out_label, output)
|
alias = doc.signal_alias(out_label, output)
|
||||||
mtype = doc.signal_type(output)
|
mtype = doc.signal_type(output)
|
||||||
@@ -159,42 +154,43 @@ def __doc_iogam__(id, obj, edges, thread):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
orows.append(orow)
|
orows.append(orow)
|
||||||
fill = "#fff"
|
fill = "#eee"
|
||||||
|
fcolor = "#000"
|
||||||
total = max(len(orows), len(irows))
|
total = max(len(orows), len(irows))
|
||||||
if bold or total > 1:
|
if bold or total > 1:
|
||||||
fill = "#333"
|
fill = "#eee"
|
||||||
bold = True
|
bold = True
|
||||||
else:
|
else:
|
||||||
fill = "#666"
|
fill = "#eee"
|
||||||
|
|
||||||
inode = f"{id}_{counter} [shape=plaintext,"
|
inode = f"{id}_{counter} [shape=plaintext,"
|
||||||
inode += f'tooltip=" IOGAM::{id} ", label=<'
|
inode += f'tooltip=" IOGAM::{id} ", label=<'
|
||||||
inode += "<table cellspacing='0' cellborder='1'"
|
inode += "<table cellspacing='0' cellborder='0' style='rounded'"
|
||||||
inode += f" cellpadding='4' border='0' bgcolor='{fill}'>"
|
inode += f" cellpadding='4' border='1' bgcolor='{fill}'>"
|
||||||
|
|
||||||
if bold:
|
if bold:
|
||||||
for i in range(total):
|
for i in range(total):
|
||||||
inode += "<tr>"
|
inode += "<tr>"
|
||||||
if i < len(irows):
|
if i < len(irows):
|
||||||
inode += f'<td port="in_{i}" bgcolor="{fill}"'
|
inode += f'<td port="in_{i}"'
|
||||||
if len(orows) > len(irows):
|
if len(orows) > len(irows):
|
||||||
inode += f' rowspan="{len(orows)}"'
|
inode += f' rowspan="{len(orows)}"'
|
||||||
inode += ">"
|
inode += ">"
|
||||||
inode += '<font color="#fff">'
|
inode += f'<font color="{fcolor}">'
|
||||||
inode += irows[i]
|
inode += irows[i]
|
||||||
inode += "</font></td>"
|
inode += "</font></td><vr/>"
|
||||||
if i < len(orows):
|
if i < len(orows):
|
||||||
inode += f'<td port="out_{i}" bgcolor="{fill}"'
|
inode += f'<td port="out_{i}"'
|
||||||
if len(orows) < len(irows):
|
if len(orows) < len(irows):
|
||||||
inode += f' rowspan="{len(irows)}"'
|
inode += f' rowspan="{len(irows)}"'
|
||||||
inode += ">"
|
inode += ">"
|
||||||
inode += '<font color="#fff">'
|
inode += f'<font color="{fcolor}">'
|
||||||
inode += orows[i]
|
inode += orows[i]
|
||||||
inode += "</font></td>"
|
inode += "</font></td>"
|
||||||
inode += "</tr>"
|
inode += "</tr>"
|
||||||
else:
|
if i < total - 1:
|
||||||
inode += "<tr><td port='in_0'></td>"
|
inode += "<hr/>"
|
||||||
inode += "<td port='out_0'></td></tr>"
|
|
||||||
inode += "</table>>"
|
inode += "</table>>"
|
||||||
inode += "];\n"
|
inode += "];\n"
|
||||||
if not bold:
|
if not bold:
|
||||||
@@ -210,7 +206,7 @@ def __doc_iogam__(id, obj, edges, thread):
|
|||||||
|
|
||||||
|
|
||||||
def __doc_constgam__(id, obj, edges, thread):
|
def __doc_constgam__(id, obj, edges, thread):
|
||||||
node = f" {id} [shape=plaintext, label=<<table cellspacing='0' cellborder='1' cellpadding='4' border='0'>"
|
node = f" {id} [shape=plaintext, label=<<table cellspacing='0' cellborder='0' cellpadding='4' border='1' style='rounded'>"
|
||||||
node += f"<tr><td colspan='2'><b>{id[2:]}</b><br/>{obj['Class']}</td></tr>"
|
node += f"<tr><td colspan='2'><b>{id[2:]}</b><br/>{obj['Class']}</td></tr>"
|
||||||
|
|
||||||
if "OutputSignals" in obj:
|
if "OutputSignals" in obj:
|
||||||
@@ -225,8 +221,9 @@ def __doc_constgam__(id, obj, edges, thread):
|
|||||||
thread,
|
thread,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
node += f'<tr><td bgcolor="#eee">{doc.type_to_string(mtype)}<br/><font point-size="8">{l}</font></td>'
|
node += "<hr/>"
|
||||||
node += f'<td port="out_{doc.format_name(l)}">'
|
node += f'<tr><td>{doc.type_to_string(mtype)}<br/><font point-size="8">{l}</font></td>'
|
||||||
|
node += f'<vr/><td port="out_{doc.format_name(l)}">'
|
||||||
node += f'{sig["Default"]}</td></tr>'
|
node += f'{sig["Default"]}</td></tr>'
|
||||||
node += "</table>>];\n"
|
node += "</table>>];\n"
|
||||||
return node, edges
|
return node, edges
|
||||||
@@ -252,7 +249,7 @@ def __doc_message_gam__(id, obj, edges, thread):
|
|||||||
inputs += " | "
|
inputs += " | "
|
||||||
inputs += f"<in_{doc.format_name(l)}> {l}"
|
inputs += f"<in_{doc.format_name(l)}> {l}"
|
||||||
if inputs:
|
if inputs:
|
||||||
node += inputs + '"];'
|
node += inputs + '", style=filled, fillcolor=lightyellow];'
|
||||||
else:
|
else:
|
||||||
node = ""
|
node = ""
|
||||||
|
|
||||||
@@ -264,6 +261,7 @@ def __doc_message_gam__(id, obj, edges, thread):
|
|||||||
|
|
||||||
def __doc_events__(id, obj, edges, thread):
|
def __doc_events__(id, obj, edges, thread):
|
||||||
nodes = ""
|
nodes = ""
|
||||||
|
bgcolor = "lightyellow"
|
||||||
for event_id, event in obj["+Events"].items():
|
for event_id, event in obj["+Events"].items():
|
||||||
if event_id[0] == "+":
|
if event_id[0] == "+":
|
||||||
event_id = event_id[1:]
|
event_id = event_id[1:]
|
||||||
@@ -272,22 +270,20 @@ def __doc_events__(id, obj, edges, thread):
|
|||||||
for msg_id in message_ids:
|
for msg_id in message_ids:
|
||||||
nodes += f" {id}_{event_id}_{msg_id} [shape=plaintext, label=<"
|
nodes += f" {id}_{event_id}_{msg_id} [shape=plaintext, label=<"
|
||||||
nodes += '<table cellspacing="0" cellborder="1" border="0" cellpadding="4"><tr>'
|
nodes += '<table cellspacing="0" cellborder="1" border="0" cellpadding="4"><tr>'
|
||||||
nodes += (
|
nodes += f"<td bgcolor='{bgcolor}' align='left'><b>When</b></td><td balign='left'>"
|
||||||
"<td bgcolor='#ccc' align='left'><b>When</b></td><td balign='left'>"
|
|
||||||
)
|
|
||||||
for i, (sig, val) in enumerate(trigger.items()):
|
for i, (sig, val) in enumerate(trigger.items()):
|
||||||
if i > 0:
|
if i > 0:
|
||||||
nodes += "<br/>"
|
nodes += "<br/>"
|
||||||
nodes += f"{sig} == {val}"
|
nodes += f"{sig} == {val}"
|
||||||
|
|
||||||
nodes += "</td></tr><tr><td bgcolor='#ccc' align='left'><b>Destination</b></td>"
|
nodes += f"</td></tr><tr><td bgcolor='{bgcolor}' align='left'><b>Destination</b></td>"
|
||||||
msg = event[f"+{msg_id}"]
|
msg = event[f"+{msg_id}"]
|
||||||
fn = msg["Function"]
|
fn = msg["Function"]
|
||||||
nodes += f"<td align='left'>{msg['Destination']}</td></tr>"
|
nodes += f"<td align='left'>{msg['Destination']}</td></tr>"
|
||||||
nodes += "<tr><td bgcolor='#ccc' align='left'><b>Function</b></td><td align='left'>"
|
nodes += f"<tr><td bgcolor='{bgcolor}' align='left'><b>Message</b></td><td align='left'>"
|
||||||
if fn == "SetOutput":
|
if fn == "SetOutput":
|
||||||
params = msg["+Parameters"]
|
params = msg["+Parameters"]
|
||||||
nodes += f"{params['SignalName']} = {params['SignalValue']}"
|
nodes += f"<i>set</i> {params['SignalName']} <i>to</i> {params['SignalValue']}"
|
||||||
else:
|
else:
|
||||||
nodes += f"{fn} "
|
nodes += f"{fn} "
|
||||||
nodes += "</td></tr></table>>];\n"
|
nodes += "</td></tr></table>>];\n"
|
||||||
@@ -297,18 +293,42 @@ def __doc_events__(id, obj, edges, thread):
|
|||||||
|
|
||||||
|
|
||||||
def __sanitize__(expression):
|
def __sanitize__(expression):
|
||||||
|
expression = expression.strip()
|
||||||
|
expression = re.sub(" +", " ", expression)
|
||||||
if expression[0] == "\n":
|
if expression[0] == "\n":
|
||||||
expression = expression[1:]
|
expression = expression[1:]
|
||||||
return expression.replace(">", ">").replace("<", "<").replace("\n", "\n")
|
if expression[-1] == "\n":
|
||||||
|
expression = expression[:-1]
|
||||||
|
|
||||||
|
expression = (
|
||||||
|
expression.replace("&", "&")
|
||||||
|
.replace(">", ">")
|
||||||
|
.replace("<", "<")
|
||||||
|
.replace("\n", "<br/>")
|
||||||
|
)
|
||||||
|
return expression
|
||||||
|
|
||||||
|
|
||||||
|
def __gam__(id, label, cls):
|
||||||
|
node = f" {id} [shape=plaintext, label=<<table border='1' cellborder='0' cellpadding='0' style='rounded'>"
|
||||||
|
node += f"<tr><td colspan='2'><b>{label}</b><br/>{cls}</td></tr><hr/>"
|
||||||
|
return node
|
||||||
|
|
||||||
|
|
||||||
def __doc_mathgam__(id, obj, edges, thread):
|
def __doc_mathgam__(id, obj, edges, thread):
|
||||||
label = id[2:]
|
label = id[2:]
|
||||||
node = f' {id} [label="{label}\n{obj["Class"]} | '
|
import sys
|
||||||
node += __sanitize__(obj["Expression"]) + " | "
|
|
||||||
|
node = __gam__(id, label, obj["Class"])
|
||||||
|
node += (
|
||||||
|
"<tr><td colspan='2' align='left' balign='left' bgcolor='#fef'><font face='mono' point-size='9'>"
|
||||||
|
+ __sanitize__(obj["Expression"])
|
||||||
|
+ "</font></td></tr><hr/> "
|
||||||
|
)
|
||||||
|
|
||||||
sigs, edges = __doc_common_gam__(id, obj, edges, thread)
|
sigs, edges = __doc_common_gam__(id, obj, edges, thread)
|
||||||
if sigs:
|
if sigs:
|
||||||
node += sigs + '"];'
|
node += sigs + "</table>>];"
|
||||||
else:
|
else:
|
||||||
node = ""
|
node = ""
|
||||||
return node, edges
|
return node, edges
|
||||||
@@ -328,10 +348,10 @@ def __doc_gam__(label, obj, edges, thread, classfilter=True):
|
|||||||
cls = obj["Class"]
|
cls = obj["Class"]
|
||||||
if classfilter and cls in __gams_fns__:
|
if classfilter and cls in __gams_fns__:
|
||||||
return __gams_fns__[cls](id, obj, edges, thread)
|
return __gams_fns__[cls](id, obj, edges, thread)
|
||||||
node = f' {id} [label="{label}\n{obj["Class"]} | '
|
node = __gam__(id, label, cls)
|
||||||
sigs, edges = __doc_common_gam__(id, obj, edges, thread)
|
sigs, edges = __doc_common_gam__(id, obj, edges, thread)
|
||||||
if sigs:
|
if sigs:
|
||||||
node += sigs + '"];'
|
node += sigs + "</table>>];"
|
||||||
else:
|
else:
|
||||||
node = ""
|
node = ""
|
||||||
return node, edges
|
return node, edges
|
||||||
@@ -388,10 +408,17 @@ def __process_gamds__(name, cls, signals, edges):
|
|||||||
node += " | "
|
node += " | "
|
||||||
sig_type = signals[sig_name]
|
sig_type = signals[sig_name]
|
||||||
node += (
|
node += (
|
||||||
f"<{doc.format_name(sig_name)}> {sig_name} ({doc.type_to_string(sig_type)})"
|
f'<tr><td port="{doc.format_name(sig_name)}">'
|
||||||
|
f"{sig_name} ({doc.type_to_string(sig_type)})"
|
||||||
|
"</td></tr>"
|
||||||
)
|
)
|
||||||
if node:
|
if node:
|
||||||
node = f'{name} [label="{name}\n{cls} | {node}", color=blue, style=filled, fillcolor=lightyellow];\n'
|
label = f"""<table border="0" cellpadding="4" cellborder="1" cellspacing="0" bgcolor="#eee">
|
||||||
|
<tr><td><b>{name}</b><br/>{cls}</td></tr>
|
||||||
|
{node}
|
||||||
|
</table>
|
||||||
|
"""
|
||||||
|
node = f'{name} [shape=plaintext, label=<{label}>, color="#0af"];\n'
|
||||||
return node, edges
|
return node, edges
|
||||||
|
|
||||||
|
|
||||||
@@ -430,9 +457,7 @@ def __process_ds__(name, obj, edges):
|
|||||||
if sig not in order:
|
if sig not in order:
|
||||||
lost.append(sig)
|
lost.append(sig)
|
||||||
node = f"{name} [shape=plaintext; label=<"
|
node = f"{name} [shape=plaintext; label=<"
|
||||||
node += (
|
node += '<table border="0" cellpadding="4" cellborder="1" cellspacing="0" bgcolor="lightblue">\n'
|
||||||
'<table border="0" cellpadding="4" cellborder="1" cellspacing="0">\n'
|
|
||||||
)
|
|
||||||
node += f"<tr><td><b>{name}</b><br/>{cls}</td></tr>\n"
|
node += f"<tr><td><b>{name}</b><br/>{cls}</td></tr>\n"
|
||||||
for i, sig_name in enumerate(order):
|
for i, sig_name in enumerate(order):
|
||||||
node += f'<tr><td port="{doc.format_name(sig_name)}">'
|
node += f'<tr><td port="{doc.format_name(sig_name)}">'
|
||||||
@@ -445,7 +470,7 @@ def __process_ds__(name, obj, edges):
|
|||||||
sig_type = sigs[sig_name]
|
sig_type = sigs[sig_name]
|
||||||
node += f"{sig_name} ({doc.type_to_string(sig_type)})"
|
node += f"{sig_name} ({doc.type_to_string(sig_type)})"
|
||||||
node += "</td></tr>\n"
|
node += "</td></tr>\n"
|
||||||
node += "</table>>, color=blue];\n"
|
node += '</table>>, color="#0af"];\n'
|
||||||
if not multi_thread and node:
|
if not multi_thread and node:
|
||||||
node = f"subgraph cluster_{thread}" + "{\n" + node + "};\n"
|
node = f"subgraph cluster_{thread}" + "{\n" + node + "};\n"
|
||||||
return node, edges
|
return node, edges
|
||||||
@@ -489,8 +514,10 @@ def __state_full_graph__(label, state, app):
|
|||||||
graph = f"digraph {label[1:]}" + "{\n"
|
graph = f"digraph {label[1:]}" + "{\n"
|
||||||
graph += "ranksep = 2;\n"
|
graph += "ranksep = 2;\n"
|
||||||
graph += "nodesep = 0.05;\n"
|
graph += "nodesep = 0.05;\n"
|
||||||
|
graph += 'fontname="monospace";\n'
|
||||||
graph += "rankdir = LR;\n"
|
graph += "rankdir = LR;\n"
|
||||||
graph += "node [shape=Mrecord];\n"
|
graph += 'edge [fontname="monospace"];\n'
|
||||||
|
graph += 'node [shape=Mrecord, fontname="monospace"];\n'
|
||||||
graph += f"label=<State: <B>{label[1:]}</B>>;\n"
|
graph += f"label=<State: <B>{label[1:]}</B>>;\n"
|
||||||
graph += "fontsize=40;\n"
|
graph += "fontsize=40;\n"
|
||||||
graph += "\n"
|
graph += "\n"
|
||||||
@@ -532,18 +559,18 @@ def __state_full_graph__(label, state, app):
|
|||||||
def __simple_gam__(label, obj):
|
def __simple_gam__(label, obj):
|
||||||
cls = obj["Class"]
|
cls = obj["Class"]
|
||||||
id = f"fn{doc.format_name(label)}"
|
id = f"fn{doc.format_name(label)}"
|
||||||
style = ""
|
style = "style=rounded"
|
||||||
if cls == "IOGAM":
|
if cls == "IOGAM":
|
||||||
style = ", style=filled, fillcolor=lightgray"
|
style = 'style="rounded,filled", fillcolor="#eee"'
|
||||||
elif cls == "MessageGAM":
|
elif cls == "MessageGAM":
|
||||||
style = ", style=filled, fillcolor=yellow"
|
style = 'style="rounded,filled", fillcolor=lightyellow'
|
||||||
if "InputSignals" in obj:
|
if "InputSignals" in obj:
|
||||||
for _, signal in obj["InputSignals"].items():
|
for _, signal in obj["InputSignals"].items():
|
||||||
ds = f'ds{doc.format_name(signal["DataSource"])}'
|
ds = f'ds{doc.format_name(signal["DataSource"])}'
|
||||||
if "OutputSignals" in obj:
|
if "OutputSignals" in obj:
|
||||||
for _, signal in obj["OutputSignals"].items():
|
for _, signal in obj["OutputSignals"].items():
|
||||||
ds = f'ds{doc.format_name(signal["DataSource"])}'
|
ds = f'ds{doc.format_name(signal["DataSource"])}'
|
||||||
return f"{id}[label=<<B>{label}</B><BR/>{cls}> {style}]\n"
|
return f"{id}[label=<<B>{label}</B><BR/>{cls}>, {style}]\n"
|
||||||
|
|
||||||
|
|
||||||
def __simple_ds__(label, obj, edges):
|
def __simple_ds__(label, obj, edges):
|
||||||
@@ -564,7 +591,14 @@ def __simple_ds__(label, obj, edges):
|
|||||||
thread = edge[-1]
|
thread = edge[-1]
|
||||||
elif thread != edge[-1]:
|
elif thread != edge[-1]:
|
||||||
multi_thread = True
|
multi_thread = True
|
||||||
node = f"{id}[label=<<B>{label}</B><BR/>{cls}>, fillcolor=lightblue]\n"
|
|
||||||
|
fillcolor = "lightblue"
|
||||||
|
bordercolor = "#0af"
|
||||||
|
style = "penwidth=2"
|
||||||
|
if cls == "GAMDataSource":
|
||||||
|
fillcolor = "#eee"
|
||||||
|
node = f"{id}[label=<<B>{label}</B><BR/>{cls}>, "
|
||||||
|
node += f'{style}, fillcolor="{fillcolor}", color="{bordercolor}"]\n'
|
||||||
if thread and not multi_thread:
|
if thread and not multi_thread:
|
||||||
node = f"subgraph cluster_{thread}" + "{\n " + node + "}"
|
node = f"subgraph cluster_{thread}" + "{\n " + node + "}"
|
||||||
return node
|
return node
|
||||||
@@ -592,8 +626,12 @@ def __simple_edges__(edges, datasources):
|
|||||||
def __state_simple_graph__(label, state, app):
|
def __state_simple_graph__(label, state, app):
|
||||||
graph = f"digraph {label[1:]}" + "{\n"
|
graph = f"digraph {label[1:]}" + "{\n"
|
||||||
graph += "rankdir = LR;\n"
|
graph += "rankdir = LR;\n"
|
||||||
graph += 'node [shape=rect, style="filled", fillcolor=white];\n'
|
graph += (
|
||||||
|
'node [shape=rect, style="filled", fillcolor=white, fontname="monospace"];\n'
|
||||||
|
)
|
||||||
|
graph += 'edge [fontname="monospace"];\n'
|
||||||
graph += f"label=<State: <B>{label[1:]}</B>>;\n"
|
graph += f"label=<State: <B>{label[1:]}</B>>;\n"
|
||||||
|
graph += 'fontname="monospace";\n'
|
||||||
graph += "fontsize=40;\n"
|
graph += "fontsize=40;\n"
|
||||||
graph += "\n"
|
graph += "\n"
|
||||||
arrows = ""
|
arrows = ""
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ def doc_state_machine(name, obj):
|
|||||||
graph = f"digraph {name}" + "{\n"
|
graph = f"digraph {name}" + "{\n"
|
||||||
graph += "rankdir = LR;\n"
|
graph += "rankdir = LR;\n"
|
||||||
# graph += "layout = circo;\n"
|
# graph += "layout = circo;\n"
|
||||||
graph += 'node [shape=egg, style="filled"];\n'
|
graph += 'fontname="monospace";\n'
|
||||||
|
graph += 'node [shape=egg, style="filled", fontname="monospace"];\n'
|
||||||
|
graph += 'edge [fontname="monospace"];\n'
|
||||||
first = True
|
first = True
|
||||||
for key in obj:
|
for key in obj:
|
||||||
if key[0] == "+":
|
if key[0] == "+":
|
||||||
|
|||||||
@@ -0,0 +1,186 @@
|
|||||||
|
{
|
||||||
|
"$App": {
|
||||||
|
"Class": "RealTimeApplication",
|
||||||
|
"+Data": {
|
||||||
|
"Class": "ReferenceContainer",
|
||||||
|
"+RTTimer": {
|
||||||
|
"Class": "LinuxTimer",
|
||||||
|
"SleepNature": "Busy",
|
||||||
|
"CPUMask": 2,
|
||||||
|
"Locked": 1,
|
||||||
|
"Signals": {
|
||||||
|
"Counter": {
|
||||||
|
"Type": "uint32"
|
||||||
|
},
|
||||||
|
"Time": {
|
||||||
|
"Type": "uint32"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"+Timing": {
|
||||||
|
"Class": "TimingDataSource",
|
||||||
|
"Locked": 1
|
||||||
|
},
|
||||||
|
"+DDB0": {
|
||||||
|
"Class": "GAMDataSource",
|
||||||
|
"Locked": 1,
|
||||||
|
"Signals": {
|
||||||
|
"Time": {
|
||||||
|
"Type": "uint32"
|
||||||
|
},
|
||||||
|
"Times": {
|
||||||
|
"Type": "uint32",
|
||||||
|
"NumberOfDimensions": 1,
|
||||||
|
"NumberOfElements": 3
|
||||||
|
},
|
||||||
|
"Amplitudes": {
|
||||||
|
"Type": "float32",
|
||||||
|
"NumberOfDimensions": 1,
|
||||||
|
"NumberOfElements": 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"+EpicsIn": {
|
||||||
|
"Class": "EPICSCA::EPICSCAInput",
|
||||||
|
"Locked": 1,
|
||||||
|
"Signals": {
|
||||||
|
"Amplitude": {
|
||||||
|
"Type": "float32",
|
||||||
|
"PVName": "Amplitude"
|
||||||
|
},
|
||||||
|
"Frequency": {
|
||||||
|
"Type": "float32",
|
||||||
|
"PVName": "Frequency"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"DefaultDataSource": "DDB0",
|
||||||
|
"+Logger": {
|
||||||
|
"Class": "OnChangeLoggerDataSource",
|
||||||
|
"Locked": 1,
|
||||||
|
"Signals": {
|
||||||
|
"Times": {
|
||||||
|
"Type": "uint32",
|
||||||
|
"NumberOfDimensions": 1,
|
||||||
|
"NumberOfElements": 3
|
||||||
|
},
|
||||||
|
"Amplitudes": {
|
||||||
|
"Type": "float32",
|
||||||
|
"NumberOfDimensions": 1,
|
||||||
|
"NumberOfElements": 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"+Functions": {
|
||||||
|
"+TimerGAM": {
|
||||||
|
"Class": "IOGAM",
|
||||||
|
"InputSignals": {
|
||||||
|
"Time": {
|
||||||
|
"Frequency": 100,
|
||||||
|
"DataSource": "RTTimer",
|
||||||
|
"Type": "uint32",
|
||||||
|
"Alias": "Time"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"OutputSignals": {
|
||||||
|
"Time": {
|
||||||
|
"DataSource": "DDB0",
|
||||||
|
"Type": "uint32",
|
||||||
|
"Alias": "Time"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"+Chai": {
|
||||||
|
"Class": "ChaiGAM",
|
||||||
|
"Code": "global g = 4;\nfun() {\n\tg = g + 1;\n\ty[0] = -A;\n \ty[1] = A;\n\ty[2] = -A;\n\tt[0] = g;\n\tif (freq <= 0) {\n\t\tt[1] = 0;\n\t\tt[2] = 0;\n\t} else {\n\t\tt[1] = int(5e5 / freq);\n\t\tt[2] = int(1e6 / freq);\n\t}\n}",
|
||||||
|
"InputSignals": {
|
||||||
|
"A": {
|
||||||
|
"DataSource": "EpicsIn",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "Amplitude"
|
||||||
|
},
|
||||||
|
"freq": {
|
||||||
|
"DataSource": "EpicsIn",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "Frequency"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"OutputSignals": {
|
||||||
|
"t": {
|
||||||
|
"NumberOfElements": 3,
|
||||||
|
"NumberOfDimensions": 1,
|
||||||
|
"DataSource": "DDB0",
|
||||||
|
"Type": "uint32",
|
||||||
|
"Alias": "Times"
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"NumberOfElements": 3,
|
||||||
|
"NumberOfDimensions": 1,
|
||||||
|
"DataSource": "DDB0",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "Amplitudes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Class": "ReferenceContainer",
|
||||||
|
"+LogGAM": {
|
||||||
|
"Class": "IOGAM",
|
||||||
|
"InputSignals": {
|
||||||
|
"t": {
|
||||||
|
"NumberOfElements": 3,
|
||||||
|
"NumberOfDimensions": 1,
|
||||||
|
"DataSource": "DDB0",
|
||||||
|
"Type": "uint32",
|
||||||
|
"Alias": "Times"
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"NumberOfElements": 3,
|
||||||
|
"NumberOfDimensions": 1,
|
||||||
|
"DataSource": "DDB0",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "Amplitudes"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"OutputSignals": {
|
||||||
|
"times": {
|
||||||
|
"NumberOfElements": 3,
|
||||||
|
"NumberOfDimensions": 1,
|
||||||
|
"DataSource": "Logger",
|
||||||
|
"Type": "uint32",
|
||||||
|
"Alias": "Times"
|
||||||
|
},
|
||||||
|
"amplitudes": {
|
||||||
|
"NumberOfElements": 3,
|
||||||
|
"NumberOfDimensions": 1,
|
||||||
|
"DataSource": "Logger",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "Amplitudes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"+States": {
|
||||||
|
"Class": "ReferenceContainer",
|
||||||
|
"+Exec": {
|
||||||
|
"Class": "RealTimeState",
|
||||||
|
"+Threads": {
|
||||||
|
"+Comm": {
|
||||||
|
"Class": "RealTimeThread",
|
||||||
|
"CPUs": 1,
|
||||||
|
"Functions": [
|
||||||
|
"TimerGAM",
|
||||||
|
"Chai",
|
||||||
|
"LogGAM"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Class": "ReferenceContainer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"+Scheduler": {
|
||||||
|
"Class": "GAMScheduler",
|
||||||
|
"TimingDataSource": "Timing"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -989,16 +989,16 @@
|
|||||||
"GB_GCPS_Amplitude_Max_Delta_Read": {
|
"GB_GCPS_Amplitude_Max_Delta_Read": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_BPS_Voltage_SP_Read": {
|
"GA_ABPS_BPS_Voltage_SP_Read": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_APS_Voltage_SP_Read": {
|
"GA_ABPS_APS_Voltage_SP_Read": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_BPS_Voltage_SP_Read": {
|
"GB_ABPS_BPS_Voltage_SP_Read": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_APS_Voltage_SP_Read": {
|
"GB_ABPS_APS_Voltage_SP_Read": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"ACK_GCOM_FCT_ABORT_CMD": {
|
"ACK_GCOM_FCT_ABORT_CMD": {
|
||||||
@@ -1459,16 +1459,16 @@
|
|||||||
"GB_GCPS_Amplitude_Max_Delta": {
|
"GB_GCPS_Amplitude_Max_Delta": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_BPS_Voltage_SP": {
|
"GA_ABPS_BPS_Voltage_SP": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_APS_Voltage_SP": {
|
"GA_ABPS_APS_Voltage_SP": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_BPS_Voltage_SP": {
|
"GB_ABPS_BPS_Voltage_SP": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_APS_Voltage_SP": {
|
"GB_ABPS_APS_Voltage_SP": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GCOM_HVPS_Voltage_SP": {
|
"GCOM_HVPS_Voltage_SP": {
|
||||||
@@ -1875,6 +1875,9 @@
|
|||||||
"MHVPS_OC": {
|
"MHVPS_OC": {
|
||||||
"Type": "uint8"
|
"Type": "uint8"
|
||||||
},
|
},
|
||||||
|
"SDNAbsTime": {
|
||||||
|
"Type": "uint64"
|
||||||
|
},
|
||||||
"OSMState": {
|
"OSMState": {
|
||||||
"Type": "uint8"
|
"Type": "uint8"
|
||||||
},
|
},
|
||||||
@@ -1917,6 +1920,9 @@
|
|||||||
"PendingSegChange": {
|
"PendingSegChange": {
|
||||||
"Type": "uint32"
|
"Type": "uint32"
|
||||||
},
|
},
|
||||||
|
"LOAD_DONE": {
|
||||||
|
"Type": "uint8"
|
||||||
|
},
|
||||||
"GA_CCPS_Config_Status": {
|
"GA_CCPS_Config_Status": {
|
||||||
"Type": "uint8"
|
"Type": "uint8"
|
||||||
},
|
},
|
||||||
@@ -1952,7 +1958,10 @@
|
|||||||
"Type": "uint8",
|
"Type": "uint8",
|
||||||
"NumberOfElements": 6
|
"NumberOfElements": 6
|
||||||
},
|
},
|
||||||
"LOAD_DONE": {
|
"SimTime": {
|
||||||
|
"Type": "float32"
|
||||||
|
},
|
||||||
|
"ACK_GA_FHPS_CONFIG_SEQ_CMD": {
|
||||||
"Type": "uint8"
|
"Type": "uint8"
|
||||||
},
|
},
|
||||||
"GB_CCPS_Operation_Pending": {
|
"GB_CCPS_Operation_Pending": {
|
||||||
@@ -2251,16 +2260,16 @@
|
|||||||
"GB_GCPS_Sweep_Rate": {
|
"GB_GCPS_Sweep_Rate": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_BPS_Voltage_SP": {
|
"GA_ABPS_BPS_Voltage_SP": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_APS_Voltage_SP": {
|
"GA_ABPS_APS_Voltage_SP": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_BPS_Voltage_SP": {
|
"GB_ABPS_BPS_Voltage_SP": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_APS_Voltage_SP": {
|
"GB_ABPS_APS_Voltage_SP": {
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GCOM_HVPS_Voltage_SP": {
|
"GCOM_HVPS_Voltage_SP": {
|
||||||
@@ -2368,6 +2377,24 @@
|
|||||||
"GA_CCPS_CONFIG_SEQ_STAT": {
|
"GA_CCPS_CONFIG_SEQ_STAT": {
|
||||||
"Type": "uint8"
|
"Type": "uint8"
|
||||||
},
|
},
|
||||||
|
"GA_FHPS_CONF_CMD": {
|
||||||
|
"Type": "uint8"
|
||||||
|
},
|
||||||
|
"GA_FHPS_CONF_STAT": {
|
||||||
|
"Type": "uint8"
|
||||||
|
},
|
||||||
|
"GA_FHPS_AC_V_IN": {
|
||||||
|
"Type": "float32"
|
||||||
|
},
|
||||||
|
"GA_FHPS_AC_V_INT": {
|
||||||
|
"Type": "float32"
|
||||||
|
},
|
||||||
|
"GA_FHPS_AC_V_OUT": {
|
||||||
|
"Type": "float32"
|
||||||
|
},
|
||||||
|
"GA_FHPS_ACK": {
|
||||||
|
"Type": "uint8"
|
||||||
|
},
|
||||||
"ShotTime": {
|
"ShotTime": {
|
||||||
"Type": "uint32",
|
"Type": "uint32",
|
||||||
"Ignore": 1
|
"Ignore": 1
|
||||||
@@ -3481,19 +3508,19 @@
|
|||||||
"DataSource": "PLCSDNSub",
|
"DataSource": "PLCSDNSub",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_BPS_Voltage_SP": {
|
"GA_ABPS_BPS_Voltage_SP": {
|
||||||
"DataSource": "PLCSDNSub",
|
"DataSource": "PLCSDNSub",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_APS_Voltage_SP": {
|
"GA_ABPS_APS_Voltage_SP": {
|
||||||
"DataSource": "PLCSDNSub",
|
"DataSource": "PLCSDNSub",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_BPS_Voltage_SP": {
|
"GB_ABPS_BPS_Voltage_SP": {
|
||||||
"DataSource": "PLCSDNSub",
|
"DataSource": "PLCSDNSub",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_APS_Voltage_SP": {
|
"GB_ABPS_APS_Voltage_SP": {
|
||||||
"DataSource": "PLCSDNSub",
|
"DataSource": "PLCSDNSub",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
@@ -3831,19 +3858,19 @@
|
|||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_BPS_Voltage_SP": {
|
"GA_ABPS_BPS_Voltage_SP": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_APS_Voltage_SP": {
|
"GA_ABPS_APS_Voltage_SP": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_BPS_Voltage_SP": {
|
"GB_ABPS_BPS_Voltage_SP": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_APS_Voltage_SP": {
|
"GB_ABPS_APS_Voltage_SP": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
@@ -4580,44 +4607,44 @@
|
|||||||
"Alias": "GB_GCPS_Sweep_Rate",
|
"Alias": "GB_GCPS_Sweep_Rate",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_BPS_Voltage_SP_a": {
|
"GA_ABPS_BPS_Voltage_SP_a": {
|
||||||
"Alias": "GA_BPS_Voltage_SP",
|
"Alias": "GA_ABPS_BPS_Voltage_SP",
|
||||||
"DataSource": "PLCSDNSub",
|
"DataSource": "PLCSDNSub",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_BPS_Voltage_SP_b": {
|
"GA_ABPS_BPS_Voltage_SP_b": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Alias": "GA_BPS_Voltage_SP",
|
"Alias": "GA_ABPS_BPS_Voltage_SP",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_APS_Voltage_SP_a": {
|
"GA_ABPS_APS_Voltage_SP_a": {
|
||||||
"Alias": "GA_APS_Voltage_SP",
|
"Alias": "GA_ABPS_APS_Voltage_SP",
|
||||||
"DataSource": "PLCSDNSub",
|
"DataSource": "PLCSDNSub",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GA_APS_Voltage_SP_b": {
|
"GA_ABPS_APS_Voltage_SP_b": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Alias": "GA_APS_Voltage_SP",
|
"Alias": "GA_ABPS_APS_Voltage_SP",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_BPS_Voltage_SP_a": {
|
"GB_ABPS_BPS_Voltage_SP_a": {
|
||||||
"Alias": "GB_BPS_Voltage_SP",
|
"Alias": "GB_ABPS_BPS_Voltage_SP",
|
||||||
"DataSource": "PLCSDNSub",
|
"DataSource": "PLCSDNSub",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_BPS_Voltage_SP_b": {
|
"GB_ABPS_BPS_Voltage_SP_b": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Alias": "GB_BPS_Voltage_SP",
|
"Alias": "GB_ABPS_BPS_Voltage_SP",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_APS_Voltage_SP_a": {
|
"GB_ABPS_APS_Voltage_SP_a": {
|
||||||
"Alias": "GB_APS_Voltage_SP",
|
"Alias": "GB_ABPS_APS_Voltage_SP",
|
||||||
"DataSource": "PLCSDNSub",
|
"DataSource": "PLCSDNSub",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GB_APS_Voltage_SP_b": {
|
"GB_ABPS_APS_Voltage_SP_b": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Alias": "GB_APS_Voltage_SP",
|
"Alias": "GB_ABPS_APS_Voltage_SP",
|
||||||
"Type": "float32"
|
"Type": "float32"
|
||||||
},
|
},
|
||||||
"GCOM_HVPS_Voltage_SP_a": {
|
"GCOM_HVPS_Voltage_SP_a": {
|
||||||
@@ -5561,7 +5588,7 @@
|
|||||||
"Alias": "ACK_GA_FHPS_RAMP_CMD"
|
"Alias": "ACK_GA_FHPS_RAMP_CMD"
|
||||||
},
|
},
|
||||||
"ACK_GA_FHPS_CONFIG_SEQ_CMD": {
|
"ACK_GA_FHPS_CONFIG_SEQ_CMD": {
|
||||||
"DataSource": "PLCSDNPub",
|
"DataSource": "DDB1",
|
||||||
"Type": "uint8",
|
"Type": "uint8",
|
||||||
"Alias": "ACK_GA_FHPS_CONFIG_SEQ_CMD"
|
"Alias": "ACK_GA_FHPS_CONFIG_SEQ_CMD"
|
||||||
},
|
},
|
||||||
@@ -6064,6 +6091,48 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"+SDNTimeGAM": {
|
||||||
|
"Class": "IOGAM",
|
||||||
|
"InputSignals": {
|
||||||
|
"Time": {
|
||||||
|
"NumberOfElements": 48,
|
||||||
|
"Range": [
|
||||||
|
[
|
||||||
|
32,
|
||||||
|
39
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"DataSource": "PLCSDNSub",
|
||||||
|
"Type": "uint8",
|
||||||
|
"Alias": "Header"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"OutputSignals": {
|
||||||
|
"Time": {
|
||||||
|
"DataSource": "DDB1",
|
||||||
|
"Type": "uint64",
|
||||||
|
"Alias": "SDNAbsTime"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"+SimTimeGAM": {
|
||||||
|
"Class": "ConversionGAM",
|
||||||
|
"InputSignals": {
|
||||||
|
"Time": {
|
||||||
|
"DataSource": "DDB1",
|
||||||
|
"Type": "uint64",
|
||||||
|
"Alias": "SDNAbsTime"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"OutputSignals": {
|
||||||
|
"Time": {
|
||||||
|
"Gain": 1e-06,
|
||||||
|
"DataSource": "DDB1",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "SimTime"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"+ReferenceGAM": {
|
"+ReferenceGAM": {
|
||||||
"Class": "ConstantGAM",
|
"Class": "ConstantGAM",
|
||||||
"OutputSignals": {
|
"OutputSignals": {
|
||||||
@@ -6447,8 +6516,8 @@
|
|||||||
"Expression": "cpsA_On = (uint8)((Mode == (uint8)1) || (Mode == (uint8)3));\ncpsB_On = (uint8)((Mode == (uint8)2) || (Mode == (uint8)3));"
|
"Expression": "cpsA_On = (uint8)((Mode == (uint8)1) || (Mode == (uint8)3));\ncpsB_On = (uint8)((Mode == (uint8)2) || (Mode == (uint8)3));"
|
||||||
},
|
},
|
||||||
"+FHPSAOnGAM": {
|
"+FHPSAOnGAM": {
|
||||||
"Class": "ChaiGAM",
|
"Class": "LuaGAM",
|
||||||
"Code": "fun() {\n\tif (State == 105) { \n\t\tCommand = 3; \n\t} else if (APSSwitch == 3){ \n\t\tCommand = 1; \n\t} else { \n\t\tCommand = 0; \n\t} \n}",
|
"Code": "function gam() \n\tif (State == 105) then \n\t\tCommand = 3 \n\telseif (APSSwitch == 3) then \n\t\tCommand = 1 \n\telse \n\t\tCommand = 0 \n\tend \nend",
|
||||||
"InputSignals": {
|
"InputSignals": {
|
||||||
"State": {
|
"State": {
|
||||||
"Type": "uint8",
|
"Type": "uint8",
|
||||||
@@ -6470,8 +6539,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"+FHPSBOnGAM": {
|
"+FHPSBOnGAM": {
|
||||||
"Class": "ChaiGAM",
|
"Class": "LuaGAM",
|
||||||
"Code": "fun() {\n\tif (State == 105) { \n\t\tCommand = 3; \n\t} else if (APSSwitch == 3){ \n\t\tCommand = 1; \n\t} else { \n\t\tCommand = 0; \n\t} \n}",
|
"Code": "function gam() \n\tif (State == 105) then \n\t\tCommand = 3 \n\telseif (APSSwitch == 3) then \n\t\tCommand = 1 \n\telse \n\t\tCommand = 0 \n\tend \nend",
|
||||||
"InputSignals": {
|
"InputSignals": {
|
||||||
"State": {
|
"State": {
|
||||||
"Type": "uint8",
|
"Type": "uint8",
|
||||||
@@ -6575,10 +6644,40 @@
|
|||||||
"Type": "uint8",
|
"Type": "uint8",
|
||||||
"Alias": "GA_CCPS_Config_Status"
|
"Alias": "GA_CCPS_Config_Status"
|
||||||
},
|
},
|
||||||
|
"GA_FHPS_CONF_CMD": {
|
||||||
|
"DataSource": "PLCSDNSub",
|
||||||
|
"Type": "uint8",
|
||||||
|
"Alias": "GA_FHPS_CONFIG_SEQ_CMD"
|
||||||
|
},
|
||||||
|
"GA_FHPS_V_IN": {
|
||||||
|
"DataSource": "PLCSDNSub",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "GA_FHPS_AC_Voltage"
|
||||||
|
},
|
||||||
|
"GA_FHPS_V_INT": {
|
||||||
|
"DataSource": "ConfActualDB",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "GA_FHPS_AC_Voltage"
|
||||||
|
},
|
||||||
|
"GA_FHPS_V_OUT": {
|
||||||
|
"DataSource": "GA_FHPS",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "AC_Voltage_Read"
|
||||||
|
},
|
||||||
|
"GA_FHPS_ACK": {
|
||||||
|
"DataSource": "DDB1",
|
||||||
|
"Type": "uint8",
|
||||||
|
"Alias": "ACK_GA_FHPS_CONFIG_SEQ_CMD"
|
||||||
|
},
|
||||||
"ShotTime": {
|
"ShotTime": {
|
||||||
"DataSource": "ABDB",
|
"DataSource": "ABDB",
|
||||||
"Type": "uint32",
|
"Type": "uint32",
|
||||||
"Alias": "ShotTime"
|
"Alias": "ShotTime"
|
||||||
|
},
|
||||||
|
"ACK": {
|
||||||
|
"DataSource": "DDB1",
|
||||||
|
"Type": "uint8",
|
||||||
|
"Alias": "ACK_GA_FHPS_CONFIG_SEQ_CMD"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"OutputSignals": {
|
"OutputSignals": {
|
||||||
@@ -6662,10 +6761,40 @@
|
|||||||
"Type": "uint8",
|
"Type": "uint8",
|
||||||
"Alias": "GA_CCPS_CONFIG_SEQ_STAT"
|
"Alias": "GA_CCPS_CONFIG_SEQ_STAT"
|
||||||
},
|
},
|
||||||
|
"GA_FHPS_CONF_CMD": {
|
||||||
|
"DataSource": "Logger",
|
||||||
|
"Type": "uint8",
|
||||||
|
"Alias": "GA_FHPS_CONF_CMD"
|
||||||
|
},
|
||||||
|
"GA_FHPS_V_IN": {
|
||||||
|
"DataSource": "Logger",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "GA_FHPS_AC_V_IN"
|
||||||
|
},
|
||||||
|
"GA_FHPS_V_INT": {
|
||||||
|
"DataSource": "Logger",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "GA_FHPS_AC_V_INT"
|
||||||
|
},
|
||||||
|
"GA_FHPS_V_OUT": {
|
||||||
|
"DataSource": "Logger",
|
||||||
|
"Type": "float32",
|
||||||
|
"Alias": "GA_FHPS_AC_V_OUT"
|
||||||
|
},
|
||||||
|
"GA_FHPS_ACK": {
|
||||||
|
"DataSource": "Logger",
|
||||||
|
"Type": "uint8",
|
||||||
|
"Alias": "GA_FHPS_ACK"
|
||||||
|
},
|
||||||
"ShotTime": {
|
"ShotTime": {
|
||||||
"DataSource": "Logger",
|
"DataSource": "Logger",
|
||||||
"Type": "uint32",
|
"Type": "uint32",
|
||||||
"Alias": "ShotTime"
|
"Alias": "ShotTime"
|
||||||
|
},
|
||||||
|
"ACK": {
|
||||||
|
"DataSource": "PLCSDNPub",
|
||||||
|
"Type": "uint8",
|
||||||
|
"Alias": "ACK_GA_FHPS_CONFIG_SEQ_CMD"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -8374,25 +8503,25 @@
|
|||||||
"Type": "float32",
|
"Type": "float32",
|
||||||
"Alias": "GB_GCPS_Amplitude_Max_Delta"
|
"Alias": "GB_GCPS_Amplitude_Max_Delta"
|
||||||
},
|
},
|
||||||
"GA_APS_Voltage_SP": {
|
"GA_ABPS_APS_Voltage_SP": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Type": "float32",
|
"Type": "float32",
|
||||||
"Alias": "GA_APS_Voltage_SP"
|
"Alias": "GA_ABPS_APS_Voltage_SP"
|
||||||
},
|
},
|
||||||
"GB_APS_Voltage_SP": {
|
"GB_ABPS_APS_Voltage_SP": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Type": "float32",
|
"Type": "float32",
|
||||||
"Alias": "GB_APS_Voltage_SP"
|
"Alias": "GB_ABPS_APS_Voltage_SP"
|
||||||
},
|
},
|
||||||
"GA_BPS_Voltage_SP": {
|
"GA_ABPS_BPS_Voltage_SP": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Type": "float32",
|
"Type": "float32",
|
||||||
"Alias": "GA_BPS_Voltage_SP"
|
"Alias": "GA_ABPS_BPS_Voltage_SP"
|
||||||
},
|
},
|
||||||
"GB_BPS_Voltage_SP": {
|
"GB_ABPS_BPS_Voltage_SP": {
|
||||||
"DataSource": "ConfActualDB",
|
"DataSource": "ConfActualDB",
|
||||||
"Type": "float32",
|
"Type": "float32",
|
||||||
"Alias": "GB_BPS_Voltage_SP"
|
"Alias": "GB_ABPS_BPS_Voltage_SP"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"OutputSignals": {
|
"OutputSignals": {
|
||||||
@@ -8456,25 +8585,25 @@
|
|||||||
"Type": "float32",
|
"Type": "float32",
|
||||||
"Alias": "GB_GCPS_Amplitude_Max_Delta_Read"
|
"Alias": "GB_GCPS_Amplitude_Max_Delta_Read"
|
||||||
},
|
},
|
||||||
"GA_APS_Voltage_SP_Read": {
|
"GA_ABPS_APS_Voltage_SP_Read": {
|
||||||
"DataSource": "PLCSDNPub",
|
"DataSource": "PLCSDNPub",
|
||||||
"Type": "float32",
|
"Type": "float32",
|
||||||
"Alias": "GA_APS_Voltage_SP_Read"
|
"Alias": "GA_ABPS_APS_Voltage_SP_Read"
|
||||||
},
|
},
|
||||||
"GB_APS_Voltage_SP_Read": {
|
"GB_ABPS_APS_Voltage_SP_Read": {
|
||||||
"DataSource": "PLCSDNPub",
|
"DataSource": "PLCSDNPub",
|
||||||
"Type": "float32",
|
"Type": "float32",
|
||||||
"Alias": "GB_APS_Voltage_SP_Read"
|
"Alias": "GB_ABPS_APS_Voltage_SP_Read"
|
||||||
},
|
},
|
||||||
"GA_BPS_Voltage_SP_Read": {
|
"GA_ABPS_BPS_Voltage_SP_Read": {
|
||||||
"DataSource": "PLCSDNPub",
|
"DataSource": "PLCSDNPub",
|
||||||
"Type": "float32",
|
"Type": "float32",
|
||||||
"Alias": "GA_BPS_Voltage_SP_Read"
|
"Alias": "GA_ABPS_BPS_Voltage_SP_Read"
|
||||||
},
|
},
|
||||||
"GB_BPS_Voltage_SP_Read": {
|
"GB_ABPS_BPS_Voltage_SP_Read": {
|
||||||
"DataSource": "PLCSDNPub",
|
"DataSource": "PLCSDNPub",
|
||||||
"Type": "float32",
|
"Type": "float32",
|
||||||
"Alias": "GB_BPS_Voltage_SP_Read"
|
"Alias": "GB_ABPS_BPS_Voltage_SP_Read"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -8807,6 +8936,54 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"+SimMCPS_A_GAM": {
|
||||||
|
"Class": "LuaGAM",
|
||||||
|
"Code": "last_time = 0\nfunction gam() \n\tif hold_cmd == 1 then \n\t\tramp_done = 0\n\t\tstate = 0\n\tif ramp_cmd == 1 then\n\t\tlast_time = time\n\t\tramp_done = 0\n\t\tstate = 1\n\telif ramp_cmd == 2 then\n\t\tlast_time = time\n\t\tramp_done = 0 \n\t\tstate = 2\n\tend\n\tif state == 2 then\n\t\tlocal dt = time - last_time -- ms?\n\t\tcurrent = current - (sweep_rate/60000.0) * dt\n\t\tif current_rb <= current_sp then\n\t\t\t-- current = current_sp\n\t\t\tstate = 4\n\t\t\tramp_done = 2\n\t\tend \n\telseif state == 1 then\n\t\tlocal dt = time - last_time -- ms?\n\t\tcurrent = current + (sweep_rate/60000.0) * dt\n\t\tif current >= current_sp then\n\t\t\t-- current_rb = current_sp\n\t\t\tstate = 3\n\t\t\tramp_done = 1\n\t\tend \n\tend\n\tlast_time = time\nend",
|
||||||
|
"InputSignals": {
|
||||||
|
"ramp_cmd": {
|
||||||
|
"Type": "uint8",
|
||||||
|
"DataSource": "PLCSDNSub",
|
||||||
|
"Alias": "GA_MCPS_RAMP_CMD"
|
||||||
|
},
|
||||||
|
"hold_cmd": {
|
||||||
|
"Type": "uint8",
|
||||||
|
"DataSource": "PLCSDNSub",
|
||||||
|
"Alias": "GA_MCPS_HOLD_CMD"
|
||||||
|
},
|
||||||
|
"current_sp": {
|
||||||
|
"Type": "float32",
|
||||||
|
"DataSource": "ConfActualDB",
|
||||||
|
"Alias": "GA_MCPS_Current"
|
||||||
|
},
|
||||||
|
"sweep_rate": {
|
||||||
|
"Type": "float32",
|
||||||
|
"DataSource": "ConfActualDB",
|
||||||
|
"Alias": "GA_MCPS_Sweep_Rate"
|
||||||
|
},
|
||||||
|
"time_ms": {
|
||||||
|
"Type": "float32",
|
||||||
|
"DataSource": "DDB1",
|
||||||
|
"Alias": "SimTime"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"OutputSignals": {
|
||||||
|
"state": {
|
||||||
|
"Type": "uint8",
|
||||||
|
"DataSource": "PLCSDNPub",
|
||||||
|
"Alias": "GA_MCPS_STAT"
|
||||||
|
},
|
||||||
|
"ramp_done": {
|
||||||
|
"Type": "uint8",
|
||||||
|
"DataSource": "PLCSDNPub",
|
||||||
|
"Alias": "GA_MCPS_RAMP_DONE"
|
||||||
|
},
|
||||||
|
"current": {
|
||||||
|
"Type": "float32",
|
||||||
|
"DataSource": "PLCSDNPub",
|
||||||
|
"Alias": "GA_MCPS_Current"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"+LogWFGAM": {
|
"+LogWFGAM": {
|
||||||
"Class": "IOGAM",
|
"Class": "IOGAM",
|
||||||
"InputSignals": {
|
"InputSignals": {
|
||||||
@@ -9072,6 +9249,9 @@
|
|||||||
"StatePublisherGAM",
|
"StatePublisherGAM",
|
||||||
"SegMessageGAM",
|
"SegMessageGAM",
|
||||||
"SegStateGAM",
|
"SegStateGAM",
|
||||||
|
"SDNTimeGAM",
|
||||||
|
"SimTimeGAM",
|
||||||
|
"SimMCPS_A_GAM",
|
||||||
"EpicsLogGAM",
|
"EpicsLogGAM",
|
||||||
"LoggerGAM"
|
"LoggerGAM"
|
||||||
]
|
]
|
||||||
@@ -9157,6 +9337,9 @@
|
|||||||
"PLCReadBackPubGAM",
|
"PLCReadBackPubGAM",
|
||||||
"StatePublisherGAM",
|
"StatePublisherGAM",
|
||||||
"SegStateGAM",
|
"SegStateGAM",
|
||||||
|
"SDNTimeGAM",
|
||||||
|
"SimTimeGAM",
|
||||||
|
"SimMCPS_A_GAM",
|
||||||
"EpicsLogGAM",
|
"EpicsLogGAM",
|
||||||
"LoggerGAM"
|
"LoggerGAM"
|
||||||
]
|
]
|
||||||
@@ -9267,6 +9450,9 @@
|
|||||||
"PLCReadBackPubGAM",
|
"PLCReadBackPubGAM",
|
||||||
"StatePublisherGAM",
|
"StatePublisherGAM",
|
||||||
"SegStateGAM",
|
"SegStateGAM",
|
||||||
|
"SDNTimeGAM",
|
||||||
|
"SimTimeGAM",
|
||||||
|
"SimMCPS_A_GAM",
|
||||||
"EpicsLogGAM",
|
"EpicsLogGAM",
|
||||||
"LoggerGAM"
|
"LoggerGAM"
|
||||||
]
|
]
|
||||||
@@ -9374,6 +9560,9 @@
|
|||||||
"PLCReadBackPubGAM",
|
"PLCReadBackPubGAM",
|
||||||
"StatePublisherGAM",
|
"StatePublisherGAM",
|
||||||
"SegStateGAM",
|
"SegStateGAM",
|
||||||
|
"SDNTimeGAM",
|
||||||
|
"SimTimeGAM",
|
||||||
|
"SimMCPS_A_GAM",
|
||||||
"EpicsLogGAM",
|
"EpicsLogGAM",
|
||||||
"LoggerGAM"
|
"LoggerGAM"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
packages:
|
||||||
|
core:
|
||||||
|
description: "MARTe2 Core Package"
|
||||||
|
namespace: ""
|
||||||
|
url: "https://vcis-gitlab.f4e.europa.eu/aneto/MARTe2"
|
||||||
|
datasources:
|
||||||
|
GAMDataSource:
|
||||||
|
brief: "DataSource implementation for the exchange of signals between GAM components."
|
||||||
|
prameters:
|
||||||
|
HeapName:
|
||||||
|
type: "string"
|
||||||
|
comment: "GetStandardHeap() if not defined"
|
||||||
|
default: ""
|
||||||
|
AllowNoProducer:
|
||||||
|
type: "bool"
|
||||||
|
mandatory: false
|
||||||
|
default: 0
|
||||||
|
ResetUnusedVariableAtStateChange:
|
||||||
|
type: "bool"
|
||||||
|
mandatory: false
|
||||||
|
default: 1
|
||||||
|
Signals:
|
||||||
|
mode: "any"
|
||||||
|
components:
|
||||||
|
description: "MARTe2 Components"
|
||||||
|
url: "https://vcis-gitlab.f4e.europa.eu/aneto/MARTe2-components"
|
||||||
|
namespace: ""
|
||||||
@@ -0,0 +1,177 @@
|
|||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
gi.require_version("Gdk", "3.0")
|
||||||
|
|
||||||
|
from gi.repository import Gdk, Gtk
|
||||||
|
|
||||||
|
|
||||||
|
class ControlPanel(Gtk.Box):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(orientation=Gtk.Orientation.VERTICAL, spacing=5)
|
||||||
|
# Place the control panel in the top right
|
||||||
|
self.set_halign(Gtk.Align.END)
|
||||||
|
self.set_valign(Gtk.Align.START)
|
||||||
|
|
||||||
|
# Add the .control-panel CSS class to this widget
|
||||||
|
context = self.get_style_context()
|
||||||
|
context.add_class("control-panel")
|
||||||
|
|
||||||
|
def add_group(self, group):
|
||||||
|
self.pack_start(group, False, False, 0)
|
||||||
|
|
||||||
|
|
||||||
|
class ControlPanelGroup(Gtk.Expander):
|
||||||
|
def __init__(self, title: str):
|
||||||
|
Gtk.Expander.__init__(self, label=title)
|
||||||
|
self._inner = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
|
||||||
|
|
||||||
|
# Set the size request to 200 pixels wide
|
||||||
|
self.set_size_request(200, -1)
|
||||||
|
|
||||||
|
# Add a bit of margin after the header
|
||||||
|
self._inner.set_margin_top(5)
|
||||||
|
|
||||||
|
self.add(self._inner)
|
||||||
|
|
||||||
|
def add_row(self, widget):
|
||||||
|
self._inner.pack_start(widget, False, False, 0)
|
||||||
|
|
||||||
|
|
||||||
|
class MyControlPanel(ControlPanel):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self._first_panel = ControlPanelGroup("Some Buttons")
|
||||||
|
self._first_panel.add_row(Gtk.Button(label="Button 1"))
|
||||||
|
self._first_panel.add_row(Gtk.Button(label="Button 2"))
|
||||||
|
self.add_group(self._first_panel)
|
||||||
|
|
||||||
|
self._second_panel = ControlPanelGroup("Extra Settings")
|
||||||
|
self._second_panel.add_row(Gtk.Button(label="Button 3"))
|
||||||
|
self._second_panel.add_row(Gtk.Button(label="Button 4"))
|
||||||
|
self._second_panel.add_row(Gtk.CheckButton.new_with_label("First checkbox"))
|
||||||
|
self._second_panel.add_row(Gtk.CheckButton.new_with_label("Second checkbox"))
|
||||||
|
|
||||||
|
combo = Gtk.ComboBoxText()
|
||||||
|
combo.append("first", "First Choice")
|
||||||
|
combo.append("second", "Second Choice")
|
||||||
|
combo.append("third", "Third Choice")
|
||||||
|
combo.append("forth", "This one is quite long")
|
||||||
|
combo.set_active_id("first")
|
||||||
|
self._second_panel.add_row(combo)
|
||||||
|
|
||||||
|
self.add_group(self._second_panel)
|
||||||
|
|
||||||
|
|
||||||
|
class MapEditor(Gtk.DrawingArea):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.set_events(
|
||||||
|
Gdk.EventMask.BUTTON_PRESS_MASK
|
||||||
|
| Gdk.EventMask.BUTTON_RELEASE_MASK
|
||||||
|
| Gdk.EventMask.POINTER_MOTION_MASK
|
||||||
|
)
|
||||||
|
|
||||||
|
self._camera_x = 0 # The X coordinate of the camera
|
||||||
|
self._camera_y = 0 # The Y coordinate of the camera
|
||||||
|
self._mouse_x = 0 # The X coordinate of the pointer
|
||||||
|
self._mouse_y = 0 # The Y coordinate of the pointer
|
||||||
|
self._button = None # The currently held mouse button
|
||||||
|
|
||||||
|
# Connect to the draw and mouse events
|
||||||
|
self.connect("draw", self.on_draw)
|
||||||
|
self.connect("button-press-event", self.on_button_press_event)
|
||||||
|
self.connect("button-release-event", self.on_button_release_event)
|
||||||
|
self.connect("motion-notify-event", self.on_motion_notify_event)
|
||||||
|
|
||||||
|
def on_button_press_event(self, widget, event):
|
||||||
|
self._mouse_x = event.x
|
||||||
|
self._mouse_y = event.y
|
||||||
|
self._button = event.button
|
||||||
|
|
||||||
|
def on_button_release_event(self, widget, event):
|
||||||
|
self._mouse_x = 0
|
||||||
|
self._mouse_y = 0
|
||||||
|
self._button = None
|
||||||
|
|
||||||
|
def on_motion_notify_event(self, widget, event):
|
||||||
|
if self._button == Gdk.BUTTON_SECONDARY:
|
||||||
|
self._camera_x += event.x - self._mouse_x
|
||||||
|
self._camera_y += event.y - self._mouse_y
|
||||||
|
self._mouse_x = event.x
|
||||||
|
self._mouse_y = event.y
|
||||||
|
self.queue_draw()
|
||||||
|
|
||||||
|
def on_draw(self, widget, context):
|
||||||
|
# Get the width and height of the widget
|
||||||
|
width = self.get_allocated_width()
|
||||||
|
height = self.get_allocated_height()
|
||||||
|
|
||||||
|
# Render a rectangle for the background of the editor
|
||||||
|
context.set_source_rgb(0.11, 0.11, 0.11)
|
||||||
|
context.rectangle(0, 0, width, height)
|
||||||
|
context.fill()
|
||||||
|
|
||||||
|
# Render our grids
|
||||||
|
context.set_line_width(1)
|
||||||
|
for color, step in [(0.2, 10), (0.3, 100)]:
|
||||||
|
context.set_source_rgb(color, color, color)
|
||||||
|
y = int(self._camera_y % step) + 0.5
|
||||||
|
while y < height:
|
||||||
|
context.move_to(0, y)
|
||||||
|
context.line_to(width, y)
|
||||||
|
y += step
|
||||||
|
x = int(self._camera_x % step) + 0.5
|
||||||
|
while x < width:
|
||||||
|
context.move_to(x, 0)
|
||||||
|
context.line_to(x, height)
|
||||||
|
x += step
|
||||||
|
context.stroke()
|
||||||
|
|
||||||
|
|
||||||
|
class MainWindow(Gtk.Window):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.set_title("Collapsible Controls Overlay Demo")
|
||||||
|
|
||||||
|
# Set the default window size to 800x800
|
||||||
|
self.set_default_size(800, 800)
|
||||||
|
# When our window is destroyed, exit the main event loop
|
||||||
|
self.connect("destroy", Gtk.main_quit)
|
||||||
|
|
||||||
|
# Create our map editor and control panel instances
|
||||||
|
self._editor = MapEditor()
|
||||||
|
self._controls = MyControlPanel()
|
||||||
|
|
||||||
|
# Create the overlay widget
|
||||||
|
self._overlay = Gtk.Overlay()
|
||||||
|
|
||||||
|
# Add our editor and control panel as overlays
|
||||||
|
self._overlay.add_overlay(self._editor)
|
||||||
|
self._overlay.add_overlay(self._controls)
|
||||||
|
|
||||||
|
# Add the overlay as the immediate child of the window
|
||||||
|
self.add(self._overlay)
|
||||||
|
|
||||||
|
|
||||||
|
def install_css():
|
||||||
|
screen = Gdk.Screen.get_default()
|
||||||
|
provider = Gtk.CssProvider()
|
||||||
|
provider.load_from_data(
|
||||||
|
b"""
|
||||||
|
.control-panel {
|
||||||
|
background-color: rgba(255,255,255,0.8);
|
||||||
|
padding: 4px;
|
||||||
|
border-bottom-left-radius: 4px;
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Gtk.StyleContext.add_provider_for_screen(screen, provider, 600)
|
||||||
|
|
||||||
|
|
||||||
|
install_css()
|
||||||
|
window = MainWindow()
|
||||||
|
window.show_all()
|
||||||
|
Gtk.main()
|
||||||
|
|
||||||
@@ -0,0 +1,269 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# Copyright 2008 Jose Fonseca
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
import operator
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
|
||||||
|
import xdot.ui
|
||||||
|
from gi.repository import Gdk, Gio, GObject, Gtk
|
||||||
|
|
||||||
|
|
||||||
|
class ControlPanel(Gtk.Box):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(orientation=Gtk.Orientation.VERTICAL, spacing=5)
|
||||||
|
# Place the control panel in the top right
|
||||||
|
self.set_halign(Gtk.Align.END)
|
||||||
|
self.set_valign(Gtk.Align.START)
|
||||||
|
|
||||||
|
# Add the .control-panel CSS class to this widget
|
||||||
|
context = self.get_style_context()
|
||||||
|
context.add_class("control-panel")
|
||||||
|
|
||||||
|
def add_group(self, group):
|
||||||
|
self.pack_start(group, False, False, 0)
|
||||||
|
|
||||||
|
|
||||||
|
class ControlPanelGroup(Gtk.Expander):
|
||||||
|
def __init__(self, title: str):
|
||||||
|
Gtk.Expander.__init__(self, label=title)
|
||||||
|
self._inner = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
|
||||||
|
|
||||||
|
# Set the size request to 200 pixels wide
|
||||||
|
self.set_size_request(200, -1)
|
||||||
|
|
||||||
|
# Add a bit of margin after the header
|
||||||
|
self._inner.set_margin_top(5)
|
||||||
|
|
||||||
|
self.add(self._inner)
|
||||||
|
|
||||||
|
def add_row(self, widget):
|
||||||
|
self._inner.pack_start(widget, False, False, 0)
|
||||||
|
|
||||||
|
|
||||||
|
class MyControlPanel(ControlPanel):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self._first_panel = ControlPanelGroup("Some Buttons")
|
||||||
|
self._first_panel.add_row(Gtk.Button(label="Button 1"))
|
||||||
|
self._first_panel.add_row(Gtk.Button(label="Button 2"))
|
||||||
|
self.add_group(self._first_panel)
|
||||||
|
|
||||||
|
self._second_panel = ControlPanelGroup("Extra Settings")
|
||||||
|
self._second_panel.add_row(Gtk.Button(label="Button 3"))
|
||||||
|
self._second_panel.add_row(Gtk.Button(label="Button 4"))
|
||||||
|
self._second_panel.add_row(Gtk.CheckButton.new_with_label("First checkbox"))
|
||||||
|
self._second_panel.add_row(Gtk.CheckButton.new_with_label("Second checkbox"))
|
||||||
|
|
||||||
|
combo = Gtk.ComboBoxText()
|
||||||
|
combo.append("first", "First Choice")
|
||||||
|
combo.append("second", "Second Choice")
|
||||||
|
combo.append("third", "Third Choice")
|
||||||
|
combo.append("forth", "This one is quite long")
|
||||||
|
combo.set_active_id("first")
|
||||||
|
self._second_panel.add_row(combo)
|
||||||
|
|
||||||
|
self.add_group(self._second_panel)
|
||||||
|
|
||||||
|
|
||||||
|
def __icon_button__(icon_name: str) -> Gtk.Button:
|
||||||
|
icon = Gio.ThemedIcon(name=icon_name)
|
||||||
|
image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
|
||||||
|
button = Gtk.Button()
|
||||||
|
button.add(image)
|
||||||
|
return button
|
||||||
|
|
||||||
|
|
||||||
|
def get_handler_id(obj, signal_name):
|
||||||
|
signal_id, detail = GObject.signal_parse_name(signal_name, obj, True)
|
||||||
|
return GObject.signal_handler_find(
|
||||||
|
obj, GObject.SignalMatchType.ID, signal_id, detail, None, None, None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class MainView(Gtk.Grid):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.searchbar = Gtk.SearchBar()
|
||||||
|
self.dot = xdot.ui.DotWidget()
|
||||||
|
self.searchentry = Gtk.SearchEntry()
|
||||||
|
self.searchbar.connect_entry(self.searchentry)
|
||||||
|
self.searchbar.add(self.searchentry)
|
||||||
|
|
||||||
|
self.searchentry.connect("search-changed", self.search)
|
||||||
|
self.searchentry.connect("stop-search", self.search_close)
|
||||||
|
|
||||||
|
# Create the overlay widget
|
||||||
|
self._overlay = Gtk.Overlay()
|
||||||
|
|
||||||
|
# Add our editor and control panel as overlays
|
||||||
|
self._overlay.add_overlay(self.dot)
|
||||||
|
self._overlay.add_overlay(MyControlPanel())
|
||||||
|
|
||||||
|
self.attach(self.searchbar, 0, 1, 1, 1)
|
||||||
|
self.attach(self._overlay, 0, 0, 1, 1)
|
||||||
|
self.dot.set_hexpand(True)
|
||||||
|
self.dot.set_vexpand(True)
|
||||||
|
|
||||||
|
self.dot.grab_focus()
|
||||||
|
self.dot.connect("clicked", self.on_click)
|
||||||
|
self.dot.disconnect(get_handler_id(self.dot, "key-press-event"))
|
||||||
|
self.dot.connect("key-press-event", self.on_key_pressed)
|
||||||
|
self.dot.connect("button-press-event", self.on_focus)
|
||||||
|
|
||||||
|
def open_dotcode(self, path):
|
||||||
|
fp = open(path, "rb")
|
||||||
|
self.dot.set_dotcode(fp.read(), path)
|
||||||
|
|
||||||
|
def set_dotcode(self, code):
|
||||||
|
try:
|
||||||
|
self.dot.set_dotcode(code)
|
||||||
|
except AssertionError as e:
|
||||||
|
print("something wrong:", e)
|
||||||
|
|
||||||
|
def find_text(self, entry_text):
|
||||||
|
found_items = []
|
||||||
|
dot_widget = self.dot
|
||||||
|
try:
|
||||||
|
regexp = re.compile(entry_text)
|
||||||
|
except re.error as err:
|
||||||
|
sys.stderr.write('warning: re.compile() failed with error "%s"\n' % err)
|
||||||
|
return []
|
||||||
|
for element in (
|
||||||
|
dot_widget.graph.nodes + dot_widget.graph.edges + dot_widget.graph.shapes
|
||||||
|
):
|
||||||
|
if element.search_text(regexp):
|
||||||
|
found_items.append(element)
|
||||||
|
return sorted(found_items, key=operator.methodcaller("get_text"))
|
||||||
|
|
||||||
|
def search(self, _):
|
||||||
|
txt = self.searchentry.get_text()
|
||||||
|
if txt:
|
||||||
|
items = self.find_text(txt)
|
||||||
|
self.dot.set_highlight(items, search=True)
|
||||||
|
else:
|
||||||
|
self.dot.set_highlight(None, search=True)
|
||||||
|
|
||||||
|
def search_close(
|
||||||
|
self,
|
||||||
|
_,
|
||||||
|
):
|
||||||
|
self.dot.grab_focus()
|
||||||
|
|
||||||
|
def on_click(self, _, url, event):
|
||||||
|
print(url, event)
|
||||||
|
# center element
|
||||||
|
x, y = int(event.x), int(event.y)
|
||||||
|
jump = self.dot.get_jump(x, y)
|
||||||
|
if jump is not None:
|
||||||
|
self.dot.animate_to(jump.x, jump.y)
|
||||||
|
|
||||||
|
def on_focus(self, widget, _):
|
||||||
|
self.dot.grab_focus()
|
||||||
|
|
||||||
|
def on_key_pressed(self, _, event):
|
||||||
|
if event.keyval in (Gdk.KEY_f, Gdk.KEY_slash):
|
||||||
|
if self.searchbar.get_search_mode():
|
||||||
|
self.searchentry.grab_focus()
|
||||||
|
else:
|
||||||
|
self.searchbar.set_search_mode(True)
|
||||||
|
return True
|
||||||
|
if event.keyval == Gdk.KEY_w:
|
||||||
|
self.dot.zoom_to_fit()
|
||||||
|
return True
|
||||||
|
if event.keyval == Gdk.KEY_plus:
|
||||||
|
self.dot.zoom_image(self.dot.zoom_ratio * 1.1)
|
||||||
|
return True
|
||||||
|
if event.keyval == Gdk.KEY_minus:
|
||||||
|
self.dot.zoom_image(self.dot.zoom_ratio / 1.1)
|
||||||
|
return True
|
||||||
|
if event.keyval == Gdk.KEY_equal:
|
||||||
|
self.dot.zoom_image(1.0)
|
||||||
|
return True
|
||||||
|
if event.keyval == Gdk.KEY_Left:
|
||||||
|
self.dot.x -= self.dot.POS_INCREMENT / self.dot.zoom_ratio
|
||||||
|
self.dot.queue_draw()
|
||||||
|
return True
|
||||||
|
if event.keyval == Gdk.KEY_Right:
|
||||||
|
self.dot.x += self.dot.POS_INCREMENT / self.dot.zoom_ratio
|
||||||
|
self.dot.queue_draw()
|
||||||
|
return True
|
||||||
|
if event.keyval == Gdk.KEY_Up:
|
||||||
|
self.dot.y -= self.dot.POS_INCREMENT / self.dot.zoom_ratio
|
||||||
|
self.dot.queue_draw()
|
||||||
|
return True
|
||||||
|
if event.keyval == Gdk.KEY_Down:
|
||||||
|
self.dot.y += self.dot.POS_INCREMENT / self.dot.zoom_ratio
|
||||||
|
self.dot.queue_draw()
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class MyDotWindow(Gtk.Window):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(title="Test")
|
||||||
|
self.set_default_size(400, 200)
|
||||||
|
self._main_view = MainView()
|
||||||
|
box = Gtk.VBox()
|
||||||
|
paned1 = Gtk.Paned()
|
||||||
|
paned2 = Gtk.Paned()
|
||||||
|
button1 = Gtk.Button(label="Button1")
|
||||||
|
button2 = Gtk.Button(label="Button2")
|
||||||
|
paned1.add1(button1)
|
||||||
|
paned1.add2(paned2)
|
||||||
|
paned2.pack1(self._main_view, True, False)
|
||||||
|
paned2.pack2(button2, False, True)
|
||||||
|
box.pack_start(paned1, True, True, 0)
|
||||||
|
|
||||||
|
self.add(box)
|
||||||
|
self.show_all()
|
||||||
|
|
||||||
|
def open_dotcode(self, path):
|
||||||
|
self._main_view.open_dotcode(path)
|
||||||
|
|
||||||
|
|
||||||
|
def install_css():
|
||||||
|
screen = Gdk.Screen.get_default()
|
||||||
|
provider = Gtk.CssProvider()
|
||||||
|
provider.load_from_data(
|
||||||
|
b"""
|
||||||
|
.control-panel {
|
||||||
|
background-color: rgba(255,255,255, 0.8);
|
||||||
|
padding: 4px;
|
||||||
|
border-bottom-left-radius: 4px;
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
Gtk.StyleContext.add_provider_for_screen(screen, provider, 600)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
install_css()
|
||||||
|
window = MyDotWindow()
|
||||||
|
window.open_dotcode("../output/Test.dot")
|
||||||
|
window.connect("delete-event", Gtk.main_quit)
|
||||||
|
window.show_all()
|
||||||
|
Gtk.main()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user