Files
essetre-wall_xs0018/Scripts/SetUp.lua
T
andrea.villa 6aae90fd73 - Configurazione macchina in GIT
- Gestione sottopezzo per parete layer. Serve Wall 2.6i1
2024-08-30 09:01:10 +02:00

210 lines
5.4 KiB
Lua

-- 2023/09/07
-- Gestione attrezzaggio per Essetre-WallXS0018
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Tavola di passaggio valori
local STU = {}
STU.TUUID = ""
STU.TCPOS = ""
STU.HEAD = ""
STU.GROUP = ""
STU.POS = ""
STU.EXIT = 0
STU.INDEX = 0
STU.HEAD1 = ""
STU.HEAD2 = ""
STU.ISVALID = false
STU.ERR = 0
_G.STU = STU
local INVALIDPOS = ""
local POS = "Pos"
-- Geom Set
local GS = {}
-- Configurazione posizioni
local PositionTable={{Pos = "Pos1", TcPos = "T9", Head = "H2", Group = "G1"},
{Pos = "Pos2", TcPos = "T1", Head = "H1", Group = "G2"},
{Pos = "Pos3", TcPos = "T2", Head = "H1", Group = "G2"},
{Pos = "Pos4", TcPos = "T3", Head = "H1", Group = "G2"},
{Pos = "Pos5", TcPos = "T4", Head = "H1", Group = "G2"},
{Pos = "Pos6", TcPos = "T5", Head = "H1", Group = "G2"},
{Pos = "Pos7", TcPos = "T6", Head = "H1", Group = "G2"},
{Pos = "Pos8", TcPos = "T7", Head = "H1", Group = "G2"},
{Pos = "Pos9", TcPos = "T8", Head = "H1", Group = "G2"}}
local bNail11 = ( EgtGetHeadId( 'H11') ~= nil)
local bNail12 = ( EgtGetHeadId( 'H12') ~= nil)
if bNail11 then
table.insert( PositionTable, {Pos = "Pos10", TcPos = "T11", Head = "H11", Group = "G3"})
end
if bNail12 then
if bNail11 then
table.insert( PositionTable, {Pos = "Pos11", TcPos = "T12", Head = "H12", Group = "G3"})
else
table.insert( PositionTable, {Pos = "Pos10", TcPos = "T12", Head = "H12", Group = "G3"})
end
end
local UsePositionHead = true
local function IsInGeomSet( ToolHead, PosHead)
for GsIndex = 1, #GS do
local bToolHead = false
local bPosHead = false
for HIndex = 1, #GS[GsIndex] do
if GS[GsIndex][HIndex] == ToolHead then
bToolHead = true
elseif GS[GsIndex][HIndex] == PosHead then
bPosHead = true
end
if bToolHead and bPosHead then
return true
end
end
if bToolHead and bPosHead then
return true
end
end
return false
end
function STU.IsCompatibleHeads()
STU.ISVALID = false
if IsInGeomSet(STU.HEAD1, STU.HEAD2) then
STU.ISVALID = true
else
STU.ISVALID = false
end
end
function STU.GetValidHeadExitForPos()
-- se TUUID non valido restituisco errore
local ToolName = EgtTdbGetToolFromUUID( STU.TUUID)
if ToolName == nill then
STU.ERR = 1
return
end
EgtTdbSetCurrTool( ToolName)
local CurrToolHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD)
STU.EXIT = EgtTdbGetCurrToolParam( MCH_TP.EXIT)
-- recupero testa predefinita per la posizione corrente
local CurrPosHead
for i = 1, #PositionTable do
if PositionTable[i].TcPos == STU.TCPOS then
CurrPosHead = PositionTable[i].Head
break
end
end
-- verifico se la testa è quella della posizione predefinita
if CurrPosHead == CurrToolHead then
STU.HEAD = CurrToolHead
STU.ERR = 0
return
-- verifico se la testa è compatibile con quella della posizione predefinita
elseif IsInGeomSet( CurrToolHead, CurrPosHead) then
if UsePositionHead then
STU.HEAD = CurrPosHead
STU.ERR = 0
return
else
STU.HEAD = CurrToolHead
STU.ERR = 0
return
end
-- la testa non è compatibile con quella della posizione predefinita
else
STU.HEAD = INVALIDPOS
STU.ERR = 0
return
end
end
function STU.IsValidTcPosFromHead()
STU.ISVALID = false
for i = 1, #PositionTable do
if PositionTable[i].TcPos == STU.TCPOS then
if PositionTable[i].Head == STU.HEAD then
STU.ISVALID = true
STU.ERR = 0
return
elseif IsInGeomSet(PositionTable[i].Head, STU.HEAD) then
STU.ISVALID = true
STU.ERR = 0
return
end
STU.ISVALID = false
STU.ERR = 0
return
end
end
end
function STU.GetTcPosHeadGroupFromPos()
for i = 1, #PositionTable do
if PositionTable[i].Pos == (POS .. tostring(STU.INDEX)) then
STU.TCPOS = PositionTable[i].TcPos
STU.HEAD = PositionTable[i].Head
STU.GROUP = PositionTable[i].Group
STU.ERR = 0
return
end
end
STU.TCPOS = INVALIDPOS
STU.HEAD = INVALIDPOS
STU.GROUP = INVALIDPOS
STU.ERR = 1
end
function STU.GetPosFromTcPos()
for i = 1, #PositionTable do
if PositionTable[i].TcPos == STU.TCPOS then
STU.POS = PositionTable[i].Pos
STU.ERR = 0
return
end
end
STU.POS = INVALIDPOS
STU.ERR = 1
end
function STU.GetGroupFromTcPos()
for i = 1, #PositionTable do
if PositionTable[i].TcPos == STU.TCPOS then
STU.GROUP = PositionTable[i].Group
STU.ERR = 0
return
end
end
STU.GROUP = INVALIDPOS
STU.ERR = 1
end
function STU.GetHeadFromPos()
for i = 1, #PositionTable do
if PositionTable[i].Pos == (POS .. tostring(STU.INDEX)) then
STU.HEAD = PositionTable[i].Head
STU.ERR = 0
return
end
end
STU.HEAD = INVALIDPOS
STU.ERR = 1
end
function STU.GetTcPosFromPos()
for i = 1, #PositionTable do
if PositionTable[i].Pos == (POS .. tostring(STU.INDEX)) then
STU.TCPOS = PositionTable[i].TcPos
STU.ERR = 0
return
end
end
STU.TCPOS = INVALIDPOS
STU.ERR = 1
end