Commit c434252f authored by Bernardo Quaresma Dias's avatar Bernardo Quaresma Dias
Browse files

Inclusão de versão 3_0 de lib-reconnect

INSTMPA-1027
parent 0dc09a03
-- =============================================================================
-- Copyright (C) 2003-2021 Tecgraf/PUC-Rio, PETROBRAS S/A
-- Instituto Tecgraf <mpa@tecgraf.puc-rio.br>
-- Arquivo gerado pelo programa MPA
-- Verso: 6.5
-- Arquivo: lib-reconnect.mpad
-- Data: 28/04/2021 15:01:59
-- =============================================================================
MPA_5_0 = true
EXPANDED = {
true,
}
DisabledDiagrams = {
}
Diagrams = {
{
id = "{{RECONNECT}}",
name = "{{RECONNECT}}",
kind = "Flow",
description = "Monitora a execuo de diagrama e, caso interrompida,\nexecuta a reconexo de ponte associada a um nome de\nponto informado.\n\nOpcionalmente, um intervalo pode ser informado para\n",
isApplication = false,
globals = {
{
name = "diagname",
type = "STRING",
list = false,
value = nil,
comment = "Nome de Diagrama",
is_arg = true,
is_ret = false,
},
{
name = "pointname",
type = "STRING",
list = false,
value = nil,
comment = "Nome de Ponto",
is_arg = true,
is_ret = false,
},
{
name = "reg",
type = "registro",
list = false,
value = nil,
comment = nil,
is_arg = true,
is_ret = false,
},
{
name = "interval",
type = "REAL",
list = false,
value = nil,
comment = "Intervalo para Reconexo",
is_arg = true,
is_ret = false,
},
},
errorFunction = nil,
haltDiagram = nil,
Nodes = {
{
type = "Command",
description = "$Name\n$parameters",
action = {
_switch = "FUNCTIONCALL",
beforemsg = nil,
aftermsg = nil,
expressions = {
"diagname",
},
variables = {},
functionid = "app_start_diagram",
},
xmin = 5200,
ymin = 4500,
xmax = 5680,
ymax = 4620,
},
{
type = "Command",
description = "$result =\n$Name\npara\n$parameters",
action = {
_switch = "FUNCTIONCALL",
beforemsg = "string.format(\"Tentando Reconectar ponte de '%s'...\", pointname)",
aftermsg = nil,
expressions = {
"pointname",
},
variables = {
"pointbridge",
},
functionid = "reconnect_bridge",
},
xmin = 6320,
ymin = 4499.7071112817,
xmax = 6800,
ymax = 4620,
},
{
type = "Choice",
description = "$Name\n$parameter_1",
action = {
_switch = "FUNCTIONCALL",
beforemsg = nil,
aftermsg = nil,
expressions = {
"diagname",
},
variables = {},
functionid = "app_eval_diagram_exec",
},
xmin = 5760,
ymin = 4500,
xmax = 6240.6212954384,
ymax = 4618.6283016624,
},
{
type = "Command",
description = "$name\n$parameters s",
action = {
_switch = "FUNCTIONCALL",
beforemsg = nil,
aftermsg = nil,
expressions = {
"10",
},
variables = {},
functionid = "esperar",
},
xmin = 5760,
ymin = 4700,
xmax = 6240,
ymax = 4820,
},
{
type = "Command",
description = "$result =\n$name\n$parameter_1",
action = {
_switch = "FUNCTIONCALL",
beforemsg = "string.format(\"Interrupo identificada em '%s'...\", diagname)",
aftermsg = nil,
expressions = {
"{diagname;'reconnect-diag_fail';pointname}",
"';'",
},
variables = {
"reg_msg",
},
functionid = "list_concat",
},
xmin = 5760.6212954384,
ymin = 4300,
xmax = 6240.6212954384,
ymax = 4420,
},
{
type = "Command",
description = "$name\n$parameters\n[$object]",
action = {
_switch = "OBJECTCALL",
beforemsg = nil,
aftermsg = nil,
expressions = {
"reg_msg",
},
variables = {},
classid = "registro",
objname = "reg",
member = "registrar",
operation = "call",
},
xmin = 5760,
ymin = 4100,
xmax = 6240,
ymax = 4220,
},
{
type = "Command",
description = "$result =\n$name\n$parameter_1",
action = {
_switch = "FUNCTIONCALL",
beforemsg = nil,
aftermsg = nil,
expressions = {
"{diagname;'reconnect-exec';pointname;pointbridge}",
"';'",
},
variables = {
"reg_msg",
},
functionid = "list_concat",
},
xmin = 6320,
ymin = 4299.7071112817,
xmax = 6800,
ymax = 4419.7071112817,
},
{
type = "Command",
description = "$name\n$parameters\n[$object]",
action = {
_switch = "OBJECTCALL",
beforemsg = nil,
aftermsg = nil,
expressions = {
"reg_msg",
},
variables = {},
classid = "registro",
objname = "reg",
member = "registrar",
operation = "call",
},
xmin = 6320,
ymin = 4099.7071112817,
xmax = 6800,
ymax = 4219.7071112817,
},
{
type = "Command",
description = "$name\n$parameters",
action = {
_switch = "FUNCTIONCALL",
beforemsg = nil,
aftermsg = nil,
expressions = {
"interval or 20",
},
variables = {},
functionid = "esperar",
},
xmin = 6320,
ymin = 4700,
xmax = 6800,
ymax = 4820,
},
{
type = "Jump",
description = "start",
x = 6560,
y = 3980,
r = 40,
},
{
type = "Jump",
description = "start",
x = 5440,
y = 4760,
r = 40,
},
},
Links = {
{
type = "Link",
description = "V",
from = 3,
to = 4,
x = {
6000.3106477192,
5999.7194460472,
},
y = {
4559.3141508312,
4759.8756136758,
},
},
{
type = "Link",
description = "F",
from = 3,
to = 5,
x = {
6000.3106477192,
6000.6212954384,
},
y = {
4559.3141508312,
4360,
},
},
{
type = "Link",
description = nil,
from = 1,
to = 3,
x = {
5440,
6000.3106477192,
},
y = {
4560,
4559.3141508312,
},
},
{
type = "Link",
description = nil,
from = 8,
to = 10,
x = {
6560,
6560,
},
y = {
4159.7071112817,
3980,
},
},
{
type = "Link",
description = nil,
from = 4,
to = 3,
x = {
5999.7194460472,
5720,
5720,
6000.3106477192,
},
y = {
4759.8756136758,
4760,
4660,
4559.3141508312,
},
},
{
type = "Link",
description = nil,
from = nil,
to = 1,
x = {
5100,
5440,
},
y = {
4560,
4560,
},
},
{
type = "Link",
description = nil,
from = 5,
to = 6,
x = {
6000.6212954384,
6000,
},
y = {
4360,
4160,
},
},
{
type = "Link",
description = nil,
from = 6,
to = 9,
x = {
6000,
6280,
6280,
6560,
},
y = {
4160,
4260,
4660,
4760,
},
},
{
type = "Link",
description = nil,
from = 7,
to = 8,
x = {
6560,
6560,
},
y = {
4359.7071112817,
4159.7071112817,
},
},
{
type = "Link",
description = nil,
from = 2,
to = 7,
x = {
6560,
6560,
},
y = {
4559.8535556408,
4359.7071112817,
},
},
{
type = "Link",
description = nil,
from = 9,
to = 2,
x = {
6560,
6560,
},
y = {
4760,
4559.8535556408,
},
},
{
type = "Link",
description = nil,
from = 11,
to = 1,
x = {
5440,
5440,
},
y = {
4760,
4560,
},
},
},
Areas = {
{
description = "check/diag_fail",
documentation = nil,
bgcolor = "255 255 200",
alignment = 0,
x = {
5740,
5740,
6260,
6260,
},
y = {
4860,
4080,
4080,
4860,
},
},
{
description = "exec",
documentation = nil,
bgcolor = "255 255 200",
alignment = 0,
x = {
6300,
6300,
6820,
6820,
},
y = {
4860,
4080,
4080,
4860,
},
},
},
Hidden = {
},
},
}
Dependencies = {
"lib-app-1_0.mpam",
"lib-log-2_3.mpam",
"lib-time-1_2.mpam",
}
include 'lib-app-1_0.mpam'
func{ id = "reconnect_bridge", name = "Reconectar Ponte",
description = [[
Tenta identificar a ponte carregada para o nome de ponto informado
e criar um nova conexo para esse ponte caso positivo.
A ponte identificada convertida para texto retornada.
Se um ponto no for informado ou no for encontrando na configuraao da planta,
a ponte padro ser considerada.
Observao: A reconexo realizada apenas para pontes VXL.
]],
parameters = {
{name="Nome de Ponto", type="STRING"},
},
results = {
{name="Ponte Encontrada", type="STRING"},
},
code = [=[ function (pointname)
local pt_bridge = getbridge(pointname)
local ok, ret
if pt_bridge ~= nil then
ok, ret = pcall(require,"mpa.bridge.vxl")
if ok then
local vxl = ret
local oldbridge = pt_bridge.bridge
ok, ret = pcall(oldbridge.close, oldbridge)
if not ok then return ret end
ok, ret = pcall(vxl.open)
if ok then
local newbridge = ret
newbridge.getblock = oldbridge.getblock
newbridge.setblock = oldbridge.setblock
pt_bridge.bridge = newbridge
else
return ret
end
else
local restart = pt_bridge.bridge.restart
if restart then
ok, ret = pcall(restart, pt_bridge.bridge)
if not ok then return ret end
end
end
end
return tostring(pt_bridge.bridge)
end]=],
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment