2136 lines
86 KiB
Lua
2136 lines
86 KiB
Lua
-- 20/01/2021
|
|
-- in questa versione (per la macchina FAST) è stata disabilitata la possibilità di muovere la testa
|
|
-- 13/04/2021
|
|
-- PosizioniAttuali: in posizione [6] viene restituita la tabella delle posizioni dell'intervallo 3
|
|
-- AggiornaQuotaIntervallo: Trave/QuoteIntervallo3 deve essere disegnato
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
EgtOutLog( ' Simulazione Carrelli FAST', 1)
|
|
local M = {}
|
|
|
|
local MyDirectory = EgtGetSourceDir()
|
|
M.NomeFileCarrelli = MyDirectory.. "Essetre-FAST_r10.lua"
|
|
M.NomeFileDati = MyDirectory.. "DatiTest.csv"
|
|
M.NomeFileComandi = MyDirectory.. "Comandi.lua"
|
|
M.NomeFileEseguiComandi = MyDirectory.. "EseguiComandi.lua"
|
|
--
|
|
M.NomeDirettorioBatch = MyDirectory.. "BatchComandi1" -- vedi 'AvviaSimulazione.lua'
|
|
M.NomeFunzione = "da definire" -- viene sovrascritta da DialogBox o da file dati
|
|
M.UltimoTest = "nulla"
|
|
M.EseguiSimulazione = false
|
|
|
|
local AbilitaQuotaExtra = true
|
|
local bPosizionamentoPezzi = false
|
|
local UltimaSelezionePiccoloSpostamento = "Morsa1"
|
|
local UltimaDistanzaPiccoloSpostamento = 5
|
|
local AbilitaPosizioniMandrino = false
|
|
|
|
local Morsa1
|
|
local Morsa2
|
|
local Rulli1, Rulli2, Trave, CorseCarrelli, CentroLavoro
|
|
local SistemaRiferimento = -1
|
|
local AllargaMorse = Vector3d(0,-1,0)
|
|
local AllargaRulli = Vector3d(0,-1,0)
|
|
local AlzaRulli = Vector3d(0,0,1)
|
|
local TraslaMorse = Vector3d( SistemaRiferimento,0,0)
|
|
local TraslaAsseZ = Vector3d(0,0,1)
|
|
local TraslaAsseX = Vector3d(0,1,0)
|
|
local RuotaAttornoAsseZ = Vector3d(0,0,1)
|
|
local RuotaAttornoAsseY = Vector3d(1,0,0)
|
|
local ApertureMassimaMorse = 300
|
|
local AlzataMassimaRulli = 400
|
|
local AperturaMassimaRulli = 200
|
|
local Velocit = 100
|
|
local TempoPausa = 1000
|
|
|
|
local LunghezzaTrave = 12000
|
|
local AltezzaTrave = 100
|
|
local LarghezzaTrave = 100
|
|
local PuntoRiferimentoTrave = Point3d(0,0,0)
|
|
|
|
local TripMorsa1 = 0
|
|
local TripMorsa2 = 0
|
|
local PrecPosizioneMorsa1 = nil
|
|
local PrecPosizioneMorsa2 = nil
|
|
local PosizioneInizialeMorsa1 = 0
|
|
local PosizioneInizialeMorsa2 = 0
|
|
local PosizioneInizialeTrave = 0
|
|
|
|
local CentroMandrinoAsseZ
|
|
local CentroMandrinoAsseY
|
|
local PosizioneInizialeAsseC = 0
|
|
local PosizioneInizialeAsseB = 0
|
|
|
|
local PosizioneInizialeRullo1 = 0
|
|
local PosizioneInizialeRullo2 = 0
|
|
local PosizioneInizialeFineCorsa1 = 0
|
|
local PosizioneInizialeFineCorsa2 = 0
|
|
local PosizioneInizialeIntervallo1 = 0
|
|
local PosizioneInizialeIntervallo2 = 0
|
|
local PosizioneInizialeIntervallo3 = 0
|
|
|
|
local LunghezzaIntervallo1 = 0
|
|
local LunghezzaIntervallo2 = 0
|
|
local LunghezzaIntervallo3 = 0
|
|
local PuntoIntervallo1 = {0,0,0}
|
|
local PuntoIntervallo2 = {0,0,0}
|
|
local PuntoIntervallo3 = {0,0,0}
|
|
|
|
local QuotaMorsa1
|
|
local LineaQuotaMorsa1
|
|
local QuotaMorsa2
|
|
local LineaQuotaMorsa2
|
|
local TestoPosizioneMorsa1
|
|
local TestoPosizioneMorsa2
|
|
local TestoPosizioneTrave
|
|
local TestoPosizioneIntervallo1
|
|
local TestoPosizioneIntervallo2
|
|
local TestoTripMorsa1
|
|
local TestoTripMorsa2
|
|
local TestoPosizioneRelativaIntervallo1 = 1832
|
|
local TestoPosizioneRelativaIntervallo2 = 1833
|
|
local TestoPosizioneRelativaIntervallo3 = 0000 -- ancora non è stato definito nel codice
|
|
local IdPuntoMandrinoZ
|
|
|
|
local NewTab = {}
|
|
|
|
-- carico i Part
|
|
function M.CaricaParent()
|
|
local CurrPart = EgtGetFirstPart()
|
|
while CurrPart do
|
|
local NomeCurrPart = EgtGetName( CurrPart)
|
|
if NomeCurrPart == "Morsa1" then
|
|
Morsa1 = CurrPart
|
|
elseif NomeCurrPart == "Morsa2" then
|
|
Morsa2 = CurrPart
|
|
elseif NomeCurrPart == "Rulli1" then
|
|
Rulli1 = CurrPart
|
|
elseif NomeCurrPart == "Rulli2" then
|
|
Rulli2 = CurrPart
|
|
elseif NomeCurrPart == "Trave" then
|
|
Trave = CurrPart
|
|
elseif NomeCurrPart == "Cartiglio Posizioni" then
|
|
Cartiglio = CurrPart
|
|
elseif NomeCurrPart == "CorseCarrelli" then
|
|
CorseCarrelli = CurrPart
|
|
elseif NomeCurrPart == "CentroLavoro" then
|
|
CentroLavoro = CurrPart
|
|
end
|
|
CurrPart = EgtGetNextPart( CurrPart)
|
|
end
|
|
end
|
|
--
|
|
|
|
-- restituisce tutti gli oggetti (layer) del Part indicato [GENERICA]
|
|
local function SelezionaLayerPart( CurrPart)
|
|
local CurrLayer = EgtGetFirstLayer( CurrPart)
|
|
local TabellaOggetti = {}
|
|
while CurrLayer do
|
|
table.insert( TabellaOggetti, CurrLayer)
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
return TabellaOggetti
|
|
end
|
|
--
|
|
|
|
-- restituisce il primo Id dell'oggetto cercato per nome tra tutti i layer dello stesso part [GENERICA]
|
|
local function RicercaOggettoPerNomeInPart( CurrPart, NomeOggetto)
|
|
local TabellaLayer = SelezionaLayerPart( CurrPart)
|
|
local TabellaOggetti = {}
|
|
for i = 1 , #TabellaLayer , 1 do
|
|
TabellaOggetti = EgtGetNameInGroup( TabellaLayer[i], NomeOggetto)
|
|
if TabellaOggetti then
|
|
return TabellaOggetti[1]
|
|
end
|
|
end
|
|
end
|
|
--
|
|
|
|
-- carico localmente l'Id degli oggetti indicati
|
|
local function CaricaOggetti()
|
|
QuotaMorsa1 = RicercaOggettoPerNomeInPart( Morsa1, "Quota")
|
|
LineaQuotaMorsa1 = RicercaOggettoPerNomeInPart( Morsa1, "LineaQuota")
|
|
QuotaMorsa2 = RicercaOggettoPerNomeInPart( Morsa2, "Quota")
|
|
LineaQuotaMorsa2 = RicercaOggettoPerNomeInPart( Morsa2, "LineaQuota")
|
|
TestoPosizioneMorsa1 = RicercaOggettoPerNomeInPart( Cartiglio, "Morsa1")
|
|
TestoPosizioneMorsa2 = RicercaOggettoPerNomeInPart( Cartiglio, "Morsa2")
|
|
TestoPosizioneTrave = RicercaOggettoPerNomeInPart( Cartiglio, "Trave")
|
|
TestoPosizioneIntervallo1 = RicercaOggettoPerNomeInPart( Cartiglio, "Intervallo1")
|
|
TestoPosizioneIntervallo2 = RicercaOggettoPerNomeInPart( Cartiglio, "Intervallo2")
|
|
-- TestoPosizioneRelativaIntervallo3 = RicercaOggettoPerNomeInPart( Cartiglio, "Intervallo2") -- manca la definizione nel progetto
|
|
TestoTripMorsa1 = RicercaOggettoPerNomeInPart( Cartiglio, "Trip Morsa 1")
|
|
TestoTripMorsa2 = RicercaOggettoPerNomeInPart( Cartiglio, "Trip Morsa 2")
|
|
if AbilitaPosizioniMandrino then
|
|
IdPuntoMandrinoZ = RicercaOggettoPerNomeInPart( CentroLavoro, "CentroMandrinoZ")
|
|
CentroMandrinoAsseZ = EgtSP( IdPuntoMandrinoZ, GDB_RT.GLOB)
|
|
IdPuntoMandrinoY = RicercaOggettoPerNomeInPart( CentroLavoro, "CentroMandrinoY")
|
|
CentroMandrinoAsseY = EgtSP( IdPuntoMandrinoY, GDB_RT.GLOB)
|
|
end
|
|
end
|
|
--
|
|
|
|
-- restituice l'indice del part e il primo layer
|
|
local function MorsaCorrente( NumeroMorsa)
|
|
if NumeroMorsa == "1" then
|
|
return Morsa1, EgtGetFirstLayer( Morsa1)
|
|
elseif NumeroMorsa == "2" then
|
|
return Morsa2, EgtGetFirstLayer( Morsa2)
|
|
end
|
|
end
|
|
--
|
|
|
|
-- restituice l'indice del part e il primo layer
|
|
local function RulloCorrente( NumeroRullo)
|
|
if NumeroRullo == "1" then
|
|
return Rulli1, EgtGetFirstLayer( Rulli1)
|
|
elseif NumeroRullo == "2" then
|
|
return Rulli2, EgtGetFirstLayer( Rulli2)
|
|
end
|
|
end
|
|
--
|
|
|
|
-- verifica lo stato di apertura della morsa
|
|
local function MorsaAperta( CurrPart)
|
|
local Stato = EgtGetInfo( CurrPart, "StatoApertura", 'i')
|
|
if ( not Stato or Stato == 0) then
|
|
if CurrPart == Morsa1 then
|
|
M.StatoMorsa1="CH"
|
|
else
|
|
M.StatoMorsa2="CH"
|
|
end
|
|
return false
|
|
else
|
|
if CurrPart == Morsa1 then
|
|
M.StatoMorsa1="AP"
|
|
else
|
|
M.StatoMorsa2="AP"
|
|
end
|
|
return true
|
|
end
|
|
end
|
|
--
|
|
|
|
-- restituisce le dimensioni x,y del box e il punto Maggiore/Minore
|
|
local function EstremiBOX( BOX, MAX)
|
|
local PuntoMin = BOX:getMin() PuntoMin:toGlob( Frame3d())
|
|
local PuntoMax = BOX:getMax() PuntoMax:toGlob( Frame3d())
|
|
local Distx = PuntoMax:getX() - PuntoMin:getX()
|
|
local Disty = PuntoMax:getY() - PuntoMin:getY()
|
|
if MAX then
|
|
return { Distx, Disty, PuntoMax}
|
|
else
|
|
return { Distx, Disty, PuntoMin}
|
|
end
|
|
end
|
|
--
|
|
|
|
-- restituisce le pozioni assolute delle morse e della trave e degli intervalli
|
|
function M.PosizioniAttuali()
|
|
local NumeroMorsa = "1"
|
|
local Morsa, CurrLayer = MorsaCorrente( NumeroMorsa)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Morsa"..NumeroMorsa.."SurfFront" then
|
|
break
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local BOXMorsa1 = EgtGetBBoxGlob( CurrLayer, GDB_BB.STANDARD)
|
|
local TabellaMorsa1 = EstremiBOX( BOXMorsa1, true)
|
|
|
|
NumeroMorsa = "2"
|
|
Morsa, CurrLayer = MorsaCorrente( NumeroMorsa)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Morsa"..NumeroMorsa.."SurfFront" then
|
|
break
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local BOXMorsa2 = EgtGetBBoxGlob( CurrLayer, GDB_BB.STANDARD)
|
|
local TabellaMorsa2 = EstremiBOX( BOXMorsa2, false)
|
|
|
|
local NumeroRullo = "1"
|
|
local Rullo
|
|
Rullo, CurrLayer = RulloCorrente( NumeroRullo)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Rullo"..NumeroRullo.."SurfSup" then
|
|
break
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local BOXRullo1 = EgtGetBBoxGlob( CurrLayer, GDB_BB.STANDARD)
|
|
local TabellaRullo1 = EstremiBOX( BOXRullo1, false)
|
|
|
|
NumeroRullo = "2"
|
|
Rullo, CurrLayer = RulloCorrente( NumeroRullo)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Rullo"..NumeroRullo.."SurfSup" then
|
|
break
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local BOXRullo2 = EgtGetBBoxGlob( CurrLayer, GDB_BB.STANDARD)
|
|
local TabellaRullo2 = EstremiBOX( BOXRullo2, true)
|
|
|
|
local NumeroFineCorsa = "1"
|
|
CurrLayer = EgtGetFirstLayer( CorseCarrelli)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "FineCorsaMorsa"..NumeroFineCorsa.."Surf" then
|
|
break
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local BOXFineCorsaMorsa1 = EgtGetBBoxGlob( CurrLayer, GDB_BB.STANDARD)
|
|
local TabellaFineCorsaMorsa1 = EstremiBOX( BOXFineCorsaMorsa1, true)
|
|
|
|
NumeroFineCorsa = "2"
|
|
CurrLayer = EgtGetFirstLayer( CorseCarrelli)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "FineCorsaMorsa"..NumeroFineCorsa.."Surf" then
|
|
break
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local BOXFineCorsaMorsa2 = EgtGetBBoxGlob( CurrLayer, GDB_BB.STANDARD)
|
|
local TabellaFineCorsaMorsa2 = EstremiBOX( BOXFineCorsaMorsa2, false)
|
|
|
|
CurrLayer = EgtGetFirstLayer( Trave)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "TraveSurf" then
|
|
break
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local BOXTrave = EgtGetBBoxGlob( CurrLayer, GDB_BB.STANDARD)
|
|
local TabellaTrave = EstremiBOX( BOXTrave, true)
|
|
|
|
CurrLayer = EgtGetFirstLayer( Trave)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Intervallo1Surf" then
|
|
break
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local BOXIntervallo1 = EgtGetBBoxGlob( CurrLayer, GDB_BB.STANDARD)
|
|
local TabellaIntervallo1 = EstremiBOX( BOXIntervallo1, false)
|
|
|
|
CurrLayer = EgtGetFirstLayer( Trave)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Intervallo2Surf" then
|
|
break
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local BOXIntervallo2 = EgtGetBBoxGlob( CurrLayer, GDB_BB.STANDARD)
|
|
local TabellaIntervallo2 = EstremiBOX( BOXIntervallo2, false)
|
|
|
|
CurrLayer = EgtGetFirstLayer( Trave)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Intervallo3Surf" then
|
|
break
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local BOXIntervallo3 = EgtGetBBoxGlob( CurrLayer, GDB_BB.STANDARD)
|
|
local TabellaIntervallo3 = EstremiBOX( BOXIntervallo3, false)
|
|
|
|
return TabellaMorsa1[3]:getX() * SistemaRiferimento, TabellaMorsa2[3]:getX() * SistemaRiferimento, TabellaTrave[3]:getX() * SistemaRiferimento,
|
|
TabellaIntervallo1, TabellaIntervallo2, TabellaIntervallo3, TabellaRullo1[3]:getX() * SistemaRiferimento, TabellaRullo2[3]:getX() * SistemaRiferimento,
|
|
TabellaFineCorsaMorsa1[3]:getX() * SistemaRiferimento, TabellaFineCorsaMorsa2[3]:getX() * SistemaRiferimento
|
|
end
|
|
--
|
|
|
|
-- converte un numero decimale in stringa
|
|
local function StampaQuota( ValoreNumerico, NumeroDecimali)
|
|
if not NumeroDecimali then
|
|
NumeroDecimali = 100
|
|
end
|
|
return tostring( floor( ValoreNumerico *NumeroDecimali) /NumeroDecimali)
|
|
end
|
|
|
|
-- calcola le distaze relative tra trave e morse
|
|
local function AggiornaQuota( NumeroMorsa)
|
|
PosizioneInizialeMorsa1, PosizioneInizialeMorsa2, PosizioneInizialeTrave = M.PosizioniAttuali()
|
|
local QuotaAsseX
|
|
local PuntoTestaTrave = RicercaOggettoPerNomeInPart( Trave, "PuntoTestaTrave")
|
|
if NumeroMorsa == "1" then
|
|
QuotaAsseX = PosizioneInizialeTrave - PosizioneInizialeMorsa1
|
|
local NuovePuntoFinle = Point3d( EgtSP( PuntoTestaTrave, GDB_RT.GLOB):getX(), EgtEP( LineaQuotaMorsa1, GDB_RT.GLOB):getY(), EgtEP( LineaQuotaMorsa1, GDB_RT.GLOB):getZ())
|
|
EgtModifyCurveEndPoint( LineaQuotaMorsa1, NuovePuntoFinle, GDB_RT.GLOB)
|
|
else
|
|
QuotaAsseX = PosizioneInizialeTrave - PosizioneInizialeMorsa2
|
|
local NuovePuntoFinle = Point3d( EgtSP( PuntoTestaTrave, GDB_RT.GLOB):getX(), EgtEP( LineaQuotaMorsa2, GDB_RT.GLOB):getY(), EgtEP( LineaQuotaMorsa2, GDB_RT.GLOB):getZ())
|
|
EgtModifyCurveEndPoint( LineaQuotaMorsa2, NuovePuntoFinle, GDB_RT.GLOB)
|
|
end
|
|
return StampaQuota( SistemaRiferimento *QuotaAsseX)
|
|
end
|
|
--
|
|
|
|
-- aggiorna quote intervallo
|
|
local function AggiornaQuotaIntervallo( NumeroIntervallo)
|
|
local _, _, _, TabellaIntervallo1, TabellaIntervallo2, TabellaIntervallo3 = M.PosizioniAttuali()
|
|
local QuotaMin, QuotaMax1
|
|
local Status1Min, Status1Max, Status2Min, Status2Max
|
|
if NumeroIntervallo == "1" then
|
|
QuotaMin = TabellaIntervallo1[3]:getX() - PosizioneInizialeRullo1 * SistemaRiferimento
|
|
QuotaMax = PosizioneInizialeFineCorsa1 * SistemaRiferimento - ( TabellaIntervallo1[3]:getX() + TabellaIntervallo1[1])
|
|
else
|
|
QuotaMin= TabellaIntervallo2[3]:getX() - PosizioneInizialeFineCorsa2 * SistemaRiferimento
|
|
QuotaMax = PosizioneInizialeRullo2 * SistemaRiferimento - ( TabellaIntervallo2[3]:getX() + TabellaIntervallo2[1])
|
|
end
|
|
|
|
if not AbilitaQuotaExtra then
|
|
QuotaMin = -1
|
|
QuotaMax = -1
|
|
end
|
|
|
|
local Linea1IntSX = RicercaOggettoPerNomeInPart( Trave, "Linea1IntSX")
|
|
local Linea1QuotaSX = RicercaOggettoPerNomeInPart( Trave, "Linea1QuotaSX")
|
|
local Linea1QuotaMin = RicercaOggettoPerNomeInPart( Trave, "Linea1QuotaMin")
|
|
local SpostamentoX = -EgtSP(Linea1IntSX, GDB_RT.GLOB):getX() + TabellaIntervallo1[3]:getX()
|
|
local Linea1Rullo = RicercaOggettoPerNomeInPart( Rulli1, "Linea1IntSX")
|
|
local Quota1Min = RicercaOggettoPerNomeInPart( Trave, "Quota1Min")
|
|
EgtMove( {Linea1IntSX, Linea1QuotaSX, Linea1QuotaMin, Quota1Min}, Vector3d(SpostamentoX,0,0), GDB_RT.G)
|
|
EgtModifyCurveEndPoint( Linea1QuotaMin, EgtEP( Linea1Rullo, GDB_RT.GLOB), GDB_RT.GLOB)
|
|
|
|
local Linea1QuotaDX = RicercaOggettoPerNomeInPart( Trave, "Linea1QuotaDX")
|
|
local Linea1IntDX = RicercaOggettoPerNomeInPart( Trave, "Linea1IntDX")
|
|
local Linea1QuotaMax = RicercaOggettoPerNomeInPart( Trave, "Linea1QuotaMax")
|
|
SpostamentoX = -EgtSP(Linea1IntDX, GDB_RT.GLOB):getX() +(TabellaIntervallo1[3]:getX() + TabellaIntervallo1[1])
|
|
local Linea1FineCorsa = RicercaOggettoPerNomeInPart( CorseCarrelli, "Linea1IntDX")
|
|
local Quota1Max = RicercaOggettoPerNomeInPart( Trave, "Quota1Max")
|
|
EgtMove( {Linea1QuotaDX, Linea1IntDX, Linea1QuotaMax, Quota1Max}, Vector3d( SpostamentoX,0,0), GDB_RT.G)
|
|
EgtModifyCurveEndPoint( Linea1QuotaMax, EgtEP( Linea1FineCorsa, GDB_RT.GLOB), GDB_RT.GLOB)
|
|
|
|
local Linea2IntSX = RicercaOggettoPerNomeInPart( Trave, "Linea2IntSX")
|
|
local Linea2QuotaSX = RicercaOggettoPerNomeInPart( Trave, "Linea2QuotaSX")
|
|
local Linea2QuotaMax = RicercaOggettoPerNomeInPart( Trave, "Linea2QuotaMax")
|
|
SpostamentoX = -EgtSP(Linea2IntSX, GDB_RT.GLOB):getX() + TabellaIntervallo2[3]:getX()
|
|
local Linea2FineCorsa = RicercaOggettoPerNomeInPart( CorseCarrelli, "Linea2IntSX")
|
|
local Quota2Min = RicercaOggettoPerNomeInPart( Trave, "Quota2Min")
|
|
EgtMove( {Linea2IntSX, Linea2QuotaSX, Linea2QuotaMax, Quota2Min}, Vector3d(SpostamentoX,0,0), GDB_RT.G)
|
|
EgtModifyCurveEndPoint( Linea2QuotaMax, EgtEP( Linea2FineCorsa, GDB_RT.GLOB), GDB_RT.GLOB)
|
|
|
|
local Linea2QuotaDX = RicercaOggettoPerNomeInPart( Trave, "Linea2QuotaDX")
|
|
local Linea2IntDX = RicercaOggettoPerNomeInPart( Trave, "Linea2IntDX")
|
|
local Linea2QuotaMin = RicercaOggettoPerNomeInPart( Trave, "Linea2QuotaMin")
|
|
SpostamentoX = -EgtSP(Linea2IntDX, GDB_RT.GLOB):getX() +( TabellaIntervallo2[3]:getX() + TabellaIntervallo2[1])
|
|
local Linea2Rullo = RicercaOggettoPerNomeInPart( Rulli2, "Linea2IntDX")
|
|
local Quota2Max = RicercaOggettoPerNomeInPart( Trave, "Quota2Max")
|
|
EgtMove( {Linea2QuotaDX, Linea2IntDX, Linea2QuotaMin, Quota2Max}, Vector3d(SpostamentoX,0,0), GDB_RT.G)
|
|
EgtModifyCurveEndPoint( Linea2QuotaMin, EgtEP( Linea2Rullo, GDB_RT.GLOB), GDB_RT.GLOB)
|
|
|
|
if QuotaMin >0 then
|
|
if NumeroIntervallo == "1" then
|
|
Status1Min = GDB_ST.ON
|
|
Status1Max = GDB_ST.OFF
|
|
EgtModifyText( Quota1Min, StampaQuota( QuotaMin, 2))
|
|
else
|
|
Status2Min = GDB_ST.OFF
|
|
Status2Max = GDB_ST.ON
|
|
EgtModifyText( Quota2Max, StampaQuota( QuotaMin, 2))
|
|
end
|
|
elseif QuotaMax > 0 then
|
|
if NumeroIntervallo == "1" then
|
|
Status1Min = GDB_ST.OFF
|
|
Status1Max = GDB_ST.ON
|
|
EgtModifyText( Quota1Max, StampaQuota( QuotaMax, 2))
|
|
else
|
|
Status2Min = GDB_ST.ON
|
|
Status2Max = GDB_ST.OFF
|
|
EgtModifyText( Quota2Min, StampaQuota( QuotaMax, 2))
|
|
end
|
|
else
|
|
if NumeroIntervallo == "1" then
|
|
Status1Min = GDB_ST.OFF
|
|
Status1Max = GDB_ST.OFF
|
|
else
|
|
Status2Min = GDB_ST.OFF
|
|
Status2Max = GDB_ST.OFF
|
|
end
|
|
end
|
|
|
|
if NumeroIntervallo == "1" then
|
|
EgtSetStatus( Linea1QuotaMin, Status1Min)
|
|
EgtSetStatus( Linea1QuotaSX, Status1Min)
|
|
EgtSetStatus( Linea1IntSX, Status1Min)
|
|
EgtSetStatus( Linea1Rullo,Status1Min)
|
|
EgtSetStatus( RicercaOggettoPerNomeInPart( Rulli1, "Linea1QuotaSX"), Status1Min)
|
|
EgtSetStatus( Quota1Min, Status1Min)
|
|
|
|
EgtSetStatus( Linea1QuotaMax, Status1Max)
|
|
EgtSetStatus( Linea1QuotaDX, Status1Max)
|
|
EgtSetStatus( Linea1IntDX, Status1Max)
|
|
EgtSetStatus( Linea1FineCorsa, Status1Max)
|
|
EgtSetStatus( RicercaOggettoPerNomeInPart( CorseCarrelli, "Linea1QuotaDX"), Status1Max)
|
|
EgtSetStatus( Quota1Max, Status1Max)
|
|
else
|
|
EgtSetStatus( Linea2QuotaMin, Status2Min)
|
|
EgtSetStatus( Linea2QuotaDX, Status2Min)
|
|
EgtSetStatus( Linea2IntDX, Status2Min)
|
|
EgtSetStatus( Linea2Rullo, Status2Min)
|
|
EgtSetStatus( RicercaOggettoPerNomeInPart( Rulli2, "Linea2QuotaDX"),Status2Min)
|
|
EgtSetStatus( Quota2Min, Status2Min)
|
|
|
|
EgtSetStatus( Linea2QuotaMax, Status2Max)
|
|
EgtSetStatus( Linea2QuotaSX, Status2Max)
|
|
EgtSetStatus( Linea2IntSX, Status2Max)
|
|
EgtSetStatus( Linea2FineCorsa,Status2Max)
|
|
EgtSetStatus( RicercaOggettoPerNomeInPart( CorseCarrelli, "Linea2QuotaSX"), Status2Max)
|
|
EgtSetStatus( Quota2Max, Status2Max)
|
|
end
|
|
|
|
end
|
|
|
|
-- aggiorna il valore delle posizioni degli oggetti indicati
|
|
local function AggiornaPosizioniInCartiglio()
|
|
local PosizioneMorsa1, PosizioneMorsa2, PosizioneTrave, TabellaIntervallo1, TabellaIntervallo2, TabellaIntervallo3, TabellaTesta = M.PosizioniAttuali()
|
|
if PrecPosizioneMorsa1 == nil then
|
|
PrecPosizioneMorsa1 = PosizioneMorsa1
|
|
end
|
|
if PrecPosizioneMorsa2 == nil then
|
|
PrecPosizioneMorsa2 = PosizioneMorsa2
|
|
end
|
|
TripMorsa1 = math.abs(PrecPosizioneMorsa1 - PosizioneMorsa1) + TripMorsa1
|
|
PrecPosizioneMorsa1 = PosizioneMorsa1
|
|
TripMorsa2 = math.abs(PrecPosizioneMorsa2 - PosizioneMorsa2) + TripMorsa2
|
|
PrecPosizioneMorsa2 = PosizioneMorsa2
|
|
EgtModifyText( TestoPosizioneMorsa1, "Posizione Morsa 1 = "..StampaQuota( PosizioneMorsa1, 100))
|
|
EgtModifyText( TestoPosizioneMorsa2, "Posizione Morsa 2 = "..StampaQuota( PosizioneMorsa2, 100))
|
|
EgtModifyText( TestoPosizioneTrave, "Posizione Trave = "..StampaQuota( PosizioneTrave, 100))
|
|
EgtModifyText( TestoTripMorsa1, "Trip Morsa 1 = "..StampaQuota( TripMorsa1, 100))
|
|
EgtModifyText( TestoTripMorsa2, "Trip Morsa 2 = "..StampaQuota( TripMorsa2, 100))
|
|
local PuntoMedioIntervallo1 = TabellaIntervallo1[3]:getX() + TabellaIntervallo1[1]/2
|
|
PosizioneInizialeIntervallo1 = PuntoMedioIntervallo1
|
|
PuntoIntervallo1 = TabellaIntervallo1[3]
|
|
LunghezzaIntervallo1 = TabellaIntervallo1[1]
|
|
local PuntoMedioIntervallo2 = TabellaIntervallo2[3]:getX() + TabellaIntervallo2[1]/2
|
|
PosizioneInizialeIntervallo2 = PuntoMedioIntervallo2
|
|
PuntoIntervallo2 = TabellaIntervallo2[3]
|
|
LunghezzaIntervallo2 = TabellaIntervallo2[1]
|
|
local PuntoMedioIntervallo3 = TabellaIntervallo3[3]:getX() + TabellaIntervallo3[1]/2
|
|
PosizioneInizialeIntervallo3 = PuntoMedioIntervallo3
|
|
PuntoIntervallo3 = TabellaIntervallo3[3]
|
|
LunghezzaIntervallo3 = TabellaIntervallo3[1]
|
|
EgtModifyText( TestoPosizioneIntervallo1, "Posizione Intervallo 1 = "..StampaQuota( SistemaRiferimento *PuntoMedioIntervallo1, 100))
|
|
EgtModifyText( TestoPosizioneIntervallo2, "Posizione Intervallo 2 = "..StampaQuota( SistemaRiferimento *PuntoMedioIntervallo2, 100))
|
|
EgtModifyText( TestoPosizioneRelativaIntervallo1, "Posizione Relativa Intervallo 1 = "..StampaQuota( SistemaRiferimento *PuntoMedioIntervallo1 - PosizioneTrave), 100)
|
|
EgtModifyText( TestoPosizioneRelativaIntervallo2, "Posizione Relativa Intervallo 2 = "..StampaQuota( SistemaRiferimento *PuntoMedioIntervallo2 - PosizioneTrave))
|
|
-- EgtModifyText( TestoPosizioneRelativaIntervallo3, "Posizione Relativa Intervallo 3 = "..StampaQuota( SistemaRiferimento *PuntoMedioIntervallo3 - PosizioneTrave))
|
|
end
|
|
--
|
|
|
|
-- modifica le dimensioni degli intervalli
|
|
local function ModificaDimensioniIntervallo( NumeroIntervallo, NuovoEstremoSinistro, NuovoEstremoDestro, AmpiezzaAttuale, PuntoEstremoSinistroAttuale)
|
|
local TabellaOggetti = {}
|
|
local CurrLayer = EgtGetFirstLayer( Trave)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Intervallo"..NumeroIntervallo.."Surf" then
|
|
table.insert( TabellaOggetti, CurrLayer)
|
|
elseif NomeLayer == "Intervallo"..NumeroIntervallo.."Linee" then
|
|
table.insert( TabellaOggetti, CurrLayer)
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local Scala = ( NuovoEstremoSinistro - NuovoEstremoDestro) / AmpiezzaAttuale
|
|
local PuntoMedio = Point3d{ PuntoEstremoSinistroAttuale:getX() + AmpiezzaAttuale/2 , PuntoEstremoSinistroAttuale:getY() , PuntoEstremoSinistroAttuale:getZ()}
|
|
EgtScale( TabellaOggetti,{ PuntoMedio, {1,0,0},{0,1,0},{0,0,1} } , Scala , 1, 1, GDB_RT.GLOB)
|
|
local MuoviBaricentro = Vector3d{ (NuovoEstremoSinistro + NuovoEstremoDestro) / 2 - (PuntoEstremoSinistroAttuale:getX() + AmpiezzaAttuale/2) , 0, 0}
|
|
EgtMove( TabellaOggetti, MuoviBaricentro, GDB_RT.GLOB)
|
|
AggiornaQuotaIntervallo( "1")
|
|
AggiornaQuotaIntervallo( "2")
|
|
EgtDraw()
|
|
EgtPause( TempoPausa/10)
|
|
end
|
|
--
|
|
|
|
-- restituisce le dimensioni della trave corrente e definisce il delta apertura morse
|
|
local function DimensioniTrave()
|
|
local CurrLayer = EgtGetFirstLayer( Trave)
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "TraveSurf" then
|
|
break
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
local BOXTrave = EgtGetBBoxGlob( CurrLayer, GDB_BB.STANDARD)
|
|
local TabellaTraveMassimo = EstremiBOX( BOXTrave, true)
|
|
local TabellaTraveMinimo = EstremiBOX( BOXTrave, false)
|
|
LunghezzaTrave = TabellaTraveMassimo[1]
|
|
LarghezzaTrave = TabellaTraveMassimo[2]
|
|
AltezzaTrave = abs( TabellaTraveMassimo[3]:getZ() - TabellaTraveMinimo[3]:getZ())
|
|
PuntoRiferimentoTrave = Point3d{ TabellaTraveMassimo[3]:getX(), TabellaTraveMassimo[3]:getY(), TabellaTraveMinimo[3]:getZ()}
|
|
return LunghezzaTrave, LarghezzaTrave, AltezzaTrave, PuntoRiferimentoTrave
|
|
end
|
|
--
|
|
|
|
-- aggiorna la quota di aèertura delle morse in funzione della dimensione della trave
|
|
local function AggiornaAperturaMassimaMorse()
|
|
if LarghezzaTrave then
|
|
return ( ApertureMassimaMorse - LarghezzaTrave)
|
|
else
|
|
return ApertureMassimaMorse
|
|
end
|
|
end
|
|
--
|
|
|
|
-- aggiorna la quota di aèertura dei rulli in funzione della dimensione della trave
|
|
local function AggiornaAperturaMassimaRulli()
|
|
if LarghezzaTrave then
|
|
AperturaMassimaRulli = AperturaMassimaRulli - LarghezzaTrave
|
|
end
|
|
end
|
|
--
|
|
|
|
-- aggiorna la quota di aèertura dei rulli in funzione della dimensione della trave
|
|
local function AggiornaAlzataMassimaRulli()
|
|
if AltezzaTrave then
|
|
AlzataMassimaRulli = AlzataMassimaRulli - AltezzaTrave
|
|
end
|
|
end
|
|
|
|
-- restituisce il layer dell'intervallo e il layer associato alla quota dell'intervallo
|
|
local function SelezioneLayerIntervallo( NumeroIntervallo)
|
|
local CurrLayer = EgtGetFirstLayer( Trave)
|
|
local TabellaIdLayerIntervallo = {}
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Intervallo"..NumeroIntervallo.."Surf" then
|
|
table.insert( TabellaIdLayerIntervallo, CurrLayer)
|
|
elseif NomeLayer == "Intervallo"..NumeroIntervallo.."Linee" then
|
|
table.insert( TabellaIdLayerIntervallo, CurrLayer)
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
if NumeroIntervallo == 1 then
|
|
table.insert( TabellaIdLayerIntervallo, TestoPosizioneIntervallo1)
|
|
table.insert( TabellaIdLayerIntervallo, TestoPosizioneRelativaIntervallo1)
|
|
elseif NumeroIntervallo == 2 then
|
|
table.insert( TabellaIdLayerIntervallo, TestoPosizioneIntervallo2)
|
|
table.insert( TabellaIdLayerIntervallo, TestoPosizioneRelativaIntervallo2)
|
|
else
|
|
table.insert( TabellaIdLayerIntervallo, TestoPosizioneIntervallo3)
|
|
table.insert( TabellaIdLayerIntervallo, TestoPosizioneRelativaIntervallo3)
|
|
end
|
|
return TabellaIdLayerIntervallo
|
|
end
|
|
--
|
|
|
|
-- restituisce il valore corrente della lunghezza della trave
|
|
function M.RestituisciDimensioniTrave()
|
|
return LunghezzaTrave, LarghezzaTrave, AltezzaTrave
|
|
end
|
|
--
|
|
|
|
-- restituisce i valori delle corse dei carrelli
|
|
function M.RestituisciFineCorsa()
|
|
return PosizioneInizialeRullo1, PosizioneInizialeRullo2, PosizioneInizialeFineCorsa1, PosizioneInizialeFineCorsa2
|
|
end
|
|
--
|
|
|
|
local function ModificaDimensionitrave( NuovaLunghezza, NuovaLarghezza, NuovaAltezza, LunghezzaAttuale, LargezzaAttuale, AltezzaAttuale, PuntoEstremoSinistroAttuale)
|
|
local TabellaLayer = {}
|
|
local CurrLayer = EgtGetFirstLayer( Trave)
|
|
local LayerPuntoRiferiento
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer ~= "PuntoRiferimento" then
|
|
table.insert( TabellaLayer, CurrLayer)
|
|
else
|
|
LayerPuntoRiferiento = CurrLayer
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
|
|
local ScalaX = NuovaLunghezza/ LunghezzaAttuale
|
|
local ScalaY = NuovaLarghezza/ LargezzaAttuale
|
|
local ScalaZ = NuovaAltezza/ AltezzaAttuale
|
|
EgtScale( TabellaLayer,{ PuntoEstremoSinistroAttuale, {1,0,0},{0,1,0},{0,0,1} } , ScalaX , ScalaY, ScalaZ, GDB_RT.GLOB)
|
|
EgtScale( LayerPuntoRiferiento,{ PuntoEstremoSinistroAttuale, {1,0,0},{0,1,0},{0,0,1} } , ScalaX , 1, 1, GDB_RT.GLOB)
|
|
LunghezzaTrave = NuovaLunghezza
|
|
LarghezzaTrave = NuovaLarghezza
|
|
AltezzaTrave = NuovaAltezza
|
|
AggiornaQuotaIntervallo( "1")
|
|
AggiornaQuotaIntervallo( "2")
|
|
EgtDraw()
|
|
AggiornaPosizioniInCartiglio()
|
|
--AggiornaAperturaMassimaMorse()
|
|
--AggiornaAperturaMassimaRulli()
|
|
--AggiornaAlzataMassimaRulli()
|
|
end
|
|
--
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
-- INIZIO ANIMAZIONI E MOVIMENTI
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
-- restituisce la teballa degli oggetti che si muvono assieme con la stessa direzione e velocità
|
|
local function Animazione( Muovi, TabellaOggettiLayer, VersoreDirezione, Ruota)
|
|
if Ruota == nil then
|
|
Ruota = false
|
|
end
|
|
local Direzione = 1
|
|
if Muovi < 0 then
|
|
Direzione = -1
|
|
end
|
|
local TabellaOggetti = {}
|
|
for i = 1, #TabellaOggettiLayer, 1 do
|
|
for j = 1, #TabellaOggettiLayer[i], 1 do
|
|
table.insert( TabellaOggetti, TabellaOggettiLayer[i][j])
|
|
end
|
|
end
|
|
return { Muovi, TabellaOggetti, VersoreDirezione, Direzione, Ruota}
|
|
end
|
|
--
|
|
|
|
-- muove gli oggetti a velocità differenti
|
|
local function AnimazioneSincrona( TabellaMovimenti)
|
|
local ContinuaMovimento = {}
|
|
local SpostamentoMassimo = 1
|
|
|
|
if #TabellaMovimenti == 1 then
|
|
SpostamentoMassimo = abs ( TabellaMovimenti[1][1])
|
|
elseif #TabellaMovimenti == 2 then
|
|
SpostamentoMassimo = max( abs( TabellaMovimenti[1][1]), abs( TabellaMovimenti[2][1]))
|
|
elseif #TabellaMovimenti > 2 then
|
|
for i = 1, #TabellaMovimenti, 1 do
|
|
SpostamentoMassimo = max( abs( TabellaMovimenti[i][1]), abs( SpostamentoMassimo))
|
|
end
|
|
end
|
|
if SpostamentoMassimo <= 0.009 then
|
|
return
|
|
end
|
|
for j = 1, #TabellaMovimenti, 1 do
|
|
if TabellaMovimenti[j] ~= 0 then
|
|
table.insert( ContinuaMovimento, true)
|
|
else
|
|
table.insert( ContinuaMovimento, false)
|
|
end
|
|
end
|
|
|
|
local TempoTotaleMovimento = floor( SpostamentoMassimo / Velocit)
|
|
if TempoTotaleMovimento == 0 then
|
|
TempoTotaleMovimento = 1
|
|
end
|
|
|
|
for Tempo = 1 , TempoTotaleMovimento, 1 do
|
|
for i = 1, #TabellaMovimenti, 1 do
|
|
if ContinuaMovimento[i] then
|
|
local DeltaSpostamento = abs( TabellaMovimenti[i][1] / SpostamentoMassimo)
|
|
if not TabellaMovimenti[i][5] then
|
|
EgtMove( TabellaMovimenti[i][2], TabellaMovimenti[i][3] * TabellaMovimenti[i][4] * DeltaSpostamento * Velocit, GDB_RT.GLOB)
|
|
else
|
|
EgtRotate( TabellaMovimenti[i][2], EgtSP( EgtIf( RuotaAttornoAsseZ == TabellaMovimenti[i][3], IdPuntoMandrinoZ, IdPuntoMandrinoY), GDB_RT.GLOB), TabellaMovimenti[i][3], DeltaSpostamento * Velocit)
|
|
end
|
|
EgtModifyText( QuotaMorsa1, AggiornaQuota( "1"))
|
|
EgtModifyText( QuotaMorsa2, AggiornaQuota( "2"))
|
|
AggiornaQuotaIntervallo( "1")
|
|
AggiornaQuotaIntervallo( "2")
|
|
AggiornaPosizioniInCartiglio()
|
|
EgtDraw()
|
|
--EgtTestBreak( 0,0)
|
|
end
|
|
end
|
|
end
|
|
for i = 1, #TabellaMovimenti, 1 do
|
|
if ContinuaMovimento[i] then
|
|
local DeltaSpostamento = abs( TabellaMovimenti[i][1]) - abs( TabellaMovimenti[i][1] / SpostamentoMassimo) * TempoTotaleMovimento * Velocit
|
|
if not TabellaMovimenti[i][5] then
|
|
EgtMove( TabellaMovimenti[i][2], TabellaMovimenti[i][3] * TabellaMovimenti[i][4] * DeltaSpostamento, GDB_RT.GLOB)
|
|
else
|
|
EgtRotate( TabellaMovimenti[i][2], EgtSP( EgtIf( RuotaAttornoAsseZ == TabellaMovimenti[i][3], IdPuntoMandrinoZ, IdPuntoMandrinoY), GDB_RT.GLOB), TabellaMovimenti[i][3], DeltaSpostamento)
|
|
end
|
|
EgtModifyText( QuotaMorsa1, AggiornaQuota( "1"))
|
|
EgtModifyText( QuotaMorsa2, AggiornaQuota( "2"))
|
|
AggiornaQuotaIntervallo( "1")
|
|
AggiornaQuotaIntervallo( "2")
|
|
AggiornaPosizioniInCartiglio()
|
|
EgtDraw()
|
|
--EgtTestBreak( 0,0)
|
|
end
|
|
end
|
|
end
|
|
--
|
|
|
|
-- muove più oggetti contemporaneamente a velocità costante
|
|
local function AnimazioneNonSincrona( TabellaMovimenti)
|
|
local Tempo = 1
|
|
local ContinuaMovimento = {}
|
|
local Continua = true
|
|
for j = 1, #TabellaMovimenti, 1 do
|
|
table.insert( ContinuaMovimento, true)
|
|
end
|
|
while Continua do
|
|
local i = 1
|
|
while i <= #TabellaMovimenti do
|
|
ContinuaMovimento[i] = false
|
|
if math.abs(TabellaMovimenti[i][1]) >= Tempo * Velocit then
|
|
EgtMove( TabellaMovimenti[i][2], TabellaMovimenti[i][3] * TabellaMovimenti[i][4] * Velocit, GDB_RT.GLOB)
|
|
EgtModifyText( QuotaMorsa1, AggiornaQuota( "1"))
|
|
EgtModifyText( QuotaMorsa2, AggiornaQuota( "2"))
|
|
ContinuaMovimento[i] = true
|
|
end
|
|
i = i + 1
|
|
end
|
|
Continua = false
|
|
for j = 1, #ContinuaMovimento, 1 do
|
|
Continua = Continua or ContinuaMovimento[j]
|
|
end
|
|
Tempo = Tempo + 1
|
|
EgtDraw()
|
|
--EgtTestBreak( 0,0)
|
|
EgtPause( TempoPausa/10)
|
|
end
|
|
end
|
|
--
|
|
|
|
-- mostra direttamente le posizioni finali degli oggetti
|
|
local function AnimazioneSincrona1( TabellaMovimenti)
|
|
local Tempo = 1
|
|
local i = 1
|
|
while i <= #TabellaMovimenti do
|
|
if math.abs(TabellaMovimenti[i][1]) >= 0 then
|
|
EgtMove( TabellaMovimenti[i][2], TabellaMovimenti[i][1] * TabellaMovimenti[i][3] , GDB_RT.GLOB)
|
|
EgtModifyText( QuotaMorsa1, AggiornaQuota( "1"))
|
|
EgtModifyText( QuotaMorsa2, AggiornaQuota( "2"))
|
|
end
|
|
i = i + 1
|
|
end
|
|
EgtDraw()
|
|
--EgtTestBreak( 0,0)
|
|
end
|
|
--
|
|
|
|
-- Getsisce l'apertura/chiusura delle morse
|
|
local function Apri_Chiudi_Morsa( NumeroMorsa, Muovi)
|
|
local TabellaOggettiLayer = {}
|
|
local CurrPart, CurrLayer = MorsaCorrente( NumeroMorsa)
|
|
local Stato = EgtGetInfo( CurrPart, "StatoApertura", 'i')
|
|
local Color
|
|
-- verifico che lo stato della morsa assieme alla condizione di movimento
|
|
if not MorsaAperta( CurrPart) and Muovi > 0 then
|
|
EgtSetInfo( CurrPart, "StatoApertura", 1)
|
|
Colore = "GREEN"
|
|
elseif MorsaAperta( CurrPart) and Muovi < 0 then
|
|
EgtSetInfo( CurrPart, "StatoApertura", 0)
|
|
Colore = "RED"
|
|
else
|
|
return
|
|
end
|
|
-- ricerco il lato morsa da allargare
|
|
local TabellaOggetti = {}
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Morsa"..NumeroMorsa.."LineeFront" then
|
|
table.insert( TabellaOggetti, CurrLayer)
|
|
elseif NomeLayer == "Morsa"..NumeroMorsa.."SurfFront" then
|
|
table.insert( TabellaOggetti, CurrLayer)
|
|
EgtSetColor( CurrLayer, Colore)
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
-- calcolo il movimento di apertura morse in funzione della dimensione della trave
|
|
table.insert( TabellaOggettiLayer, TabellaOggetti)
|
|
local TabellaMovimenti = {}
|
|
table.insert( TabellaMovimenti, Animazione( Muovi, TabellaOggettiLayer, AllargaMorse))
|
|
AnimazioneSincrona( TabellaMovimenti)
|
|
end
|
|
--
|
|
|
|
-- Gestiscel l'apertura/chiusura dei rulli orizzontali
|
|
local function Alza_Abbassa_Rullo( NumeroRullo, Muovi)
|
|
local TabellaOggettiLayer = {}
|
|
local CurrPart, CurrLayer = RulloCorrente( NumeroRullo)
|
|
-- ricerco il lato rullo da muovere
|
|
local TabellaOggetti = {}
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Rullo"..NumeroRullo.."LineeSup" then
|
|
table.insert( TabellaOggetti, CurrLayer)
|
|
elseif NomeLayer == "Rullo"..NumeroRullo.."SurfSup" then
|
|
table.insert( TabellaOggetti, CurrLayer)
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
table.insert( TabellaOggettiLayer, TabellaOggetti)
|
|
return Animazione( Muovi, TabellaOggettiLayer, AlzaRulli)
|
|
--local TabellaMovimenti = {}
|
|
--table.insert( TabellaMovimenti, Animazione( Muovi, TabellaOggettiLayer, AlzaRulli))
|
|
--AnimazioneSincrona( TabellaMovimenti)
|
|
end
|
|
--
|
|
|
|
-- Gestiscel l'apertura/chiusura dei rulli verticali
|
|
local function Apri_Chiudi_Rullo( NumeroRullo, Muovi)
|
|
local TabellaOggettiLayer = {}
|
|
local CurrPart, CurrLayer = RulloCorrente( NumeroRullo)
|
|
-- ricerco il lato rullo da muovere
|
|
local TabellaOggetti = {}
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Rullo"..NumeroRullo.."LineeFront" then
|
|
table.insert( TabellaOggetti, CurrLayer)
|
|
elseif NomeLayer == "Rullo"..NumeroRullo.."SurfFront" then
|
|
table.insert( TabellaOggetti, CurrLayer)
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
table.insert( TabellaOggettiLayer, TabellaOggetti)
|
|
return Animazione( Muovi, TabellaOggettiLayer, AllargaRulli)
|
|
--local TabellaMovimenti = {}
|
|
--table.insert( TabellaMovimenti, Animazione( Muovi, TabellaOggettiLayer, AllargaRulli))
|
|
--AnimazioneSincrona( TabellaMovimenti)
|
|
end
|
|
--
|
|
|
|
function M.Trasla_Rullo( NumeroRullo, Muovi)
|
|
local TabellaOggettiLayer = {}
|
|
local Spostamento = 0
|
|
local CurrPart, CurrLayer = RulloCorrente( NumeroRullo)
|
|
table.insert( TabellaOggettiLayer, SelezionaLayerPart( CurrPart))
|
|
if NumeroRullo == "1" then
|
|
Spostamento = Muovi - PosizioneInizialeRullo1
|
|
PosizioneInizialeRullo1 = Muovi
|
|
else
|
|
Spostamento = Muovi - PosizioneInizialeRullo2
|
|
PosizioneInizialeRullo2 = Muovi
|
|
end
|
|
return Animazione( Spostamento, TabellaOggettiLayer, TraslaMorse)
|
|
end
|
|
--
|
|
|
|
-- calcola spostamento morsa
|
|
function M.Trasla_Morsa( NumeroMorsa, Muovi)
|
|
local TabellaOggettiLayer = {}
|
|
local Spostamento = 0
|
|
local CurrPart, CurrLayer = MorsaCorrente( NumeroMorsa)
|
|
table.insert( TabellaOggettiLayer, SelezionaLayerPart( CurrPart))
|
|
if NumeroMorsa == "1" then
|
|
Spostamento = Muovi - PosizioneInizialeMorsa1
|
|
PosizioneInizialeMorsa1 = Muovi
|
|
else
|
|
Spostamento = Muovi - PosizioneInizialeMorsa2
|
|
PosizioneInizialeMorsa2 = Muovi
|
|
end
|
|
return Animazione( Spostamento, TabellaOggettiLayer, TraslaMorse)
|
|
end
|
|
--
|
|
|
|
-- calcola spostamento trave
|
|
function M.Trasla_Trave( Muovi)
|
|
local TabellaOggettiLayer = {}
|
|
table.insert( TabellaOggettiLayer, SelezionaLayerPart( Trave))
|
|
local Spostamento = Muovi - PosizioneInizialeTrave
|
|
PosizioneInizialeTrave = Muovi
|
|
return Animazione( Spostamento, TabellaOggettiLayer, TraslaMorse)
|
|
end
|
|
--
|
|
|
|
-- calcola spostamento mandrino assi x,z
|
|
function M.TraslaMandrino( Asse, Muovi)
|
|
local TabellaOggettiLayer = {}
|
|
local Spostamento = 0
|
|
if Asse == "AsseZ" then
|
|
Spostamento = Muovi - CentroMandrinoAsseZ:getZ()
|
|
else
|
|
Spostamento = Muovi - CentroMandrinoAsseY:getY()
|
|
end
|
|
local CurrLayer = EgtGetFirstLayer( CentroLavoro)
|
|
local TabellaLocaleAsseZ = {}
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer ==Asse .."Linee" then
|
|
table.insert( TabellaLocaleAsseZ, CurrLayer)
|
|
elseif NomeLayer == Asse .."Surf" then
|
|
table.insert( TabellaLocaleAsseZ, CurrLayer)
|
|
elseif NomeLayer == "AsseZLinee" then
|
|
table.insert( TabellaLocaleAsseZ, CurrLayer)
|
|
elseif NomeLayer == "AsseZSurf" then
|
|
table.insert( TabellaLocaleAsseZ, CurrLayer)
|
|
elseif NomeLayer == "AsseCLinee" then
|
|
table.insert( TabellaLocaleAsseZ, CurrLayer)
|
|
elseif NomeLayer == "AsseCSurf" then
|
|
table.insert( TabellaLocaleAsseZ, CurrLayer)
|
|
elseif NomeLayer == "AsseBLinee" then
|
|
table.insert( TabellaLocaleAsseZ, CurrLayer)
|
|
elseif NomeLayer == "AsseBSurf" then
|
|
table.insert( TabellaLocaleAsseZ, CurrLayer)
|
|
elseif NomeLayer == "PuntoRiferimento" then
|
|
table.insert( TabellaLocaleAsseZ, CurrLayer)
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
table.insert( TabellaOggettiLayer, TabellaLocaleAsseZ)
|
|
return Animazione( Spostamento, TabellaOggettiLayer, EgtIf( Asse == "AsseZ", TraslaAsseZ, TraslaAsseX))
|
|
end
|
|
--
|
|
|
|
-- calcola rotazioni mandrino assi C,B
|
|
function M.RuotaMandrino( Asse, Muovi)
|
|
local TabellaOggettiLayer = {}
|
|
local Spostamento = 0
|
|
if Asse == "AsseC" then
|
|
Spostamento = Muovi - PosizioneInizialeAsseC
|
|
PosizioneInizialeAsseC = Muovi
|
|
else
|
|
Spostamento = Muovi - PosizioneInizialeAsseB
|
|
PosizioneInizialeAsseB = Muovi
|
|
end
|
|
local CurrLayer = EgtGetFirstLayer( CentroLavoro)
|
|
local TabellaLocaleAsseC = {}
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer ==Asse .."Linee" then
|
|
table.insert( TabellaLocaleAsseC, CurrLayer)
|
|
elseif NomeLayer == Asse .."Surf" then
|
|
table.insert( TabellaLocaleAsseC, CurrLayer)
|
|
elseif NomeLayer == "AsseBLinee" then
|
|
table.insert( TabellaLocaleAsseC, CurrLayer)
|
|
elseif NomeLayer == "AsseBSurf" then
|
|
table.insert( TabellaLocaleAsseC, CurrLayer)
|
|
elseif NomeLayer == "PuntoRiferimento" then
|
|
table.insert( TabellaLocaleAsseC, CurrLayer)
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
table.insert( TabellaOggettiLayer, TabellaLocaleAsseC)
|
|
return Animazione( Spostamento, TabellaOggettiLayer, EgtIf( Asse == "AsseC", RuotaAttornoAsseZ, RuotaAttornoAsseY), true)
|
|
end
|
|
--
|
|
|
|
-- calcola posizione fine corsa
|
|
function M.Trasla_FineCorsa( NumeroFineCorsa, Muovi)
|
|
local TabellaOggettiLayer = {}
|
|
local Spostamento = 0
|
|
if NumeroFineCorsa == "1" then
|
|
Spostamento = Muovi - PosizioneInizialeFineCorsa1
|
|
PosizioneInizialeFineCorsa1 = Muovi
|
|
else
|
|
Spostamento = Muovi - PosizioneInizialeFineCorsa2
|
|
PosizioneInizialeFineCorsa2 = Muovi
|
|
end
|
|
local CurrLayer = EgtGetFirstLayer( CorseCarrelli)
|
|
local TabellaLocaleFineCorsa = {}
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "FineCorsaMorsa"..NumeroFineCorsa .."Surf" then
|
|
table.insert( TabellaLocaleFineCorsa, CurrLayer)
|
|
end
|
|
if NomeLayer == "FineCorsaMorsa"..NumeroFineCorsa .."Linee" then
|
|
table.insert( TabellaLocaleFineCorsa, CurrLayer)
|
|
end
|
|
if NomeLayer == "PuntoRiferimento"..NumeroFineCorsa then
|
|
table.insert( TabellaLocaleFineCorsa, CurrLayer)
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
table.insert( TabellaOggettiLayer, TabellaLocaleFineCorsa)
|
|
return Animazione( Spostamento, TabellaOggettiLayer, TraslaMorse)
|
|
end
|
|
--
|
|
|
|
-- calcola posizioni intervalli
|
|
function M.Trasla_Intervallo( NumeroIntervallo, Muovi)
|
|
local TabellaOggettiLayer = {}
|
|
local Spostamento = 0
|
|
if NumeroIntervallo == "1" then
|
|
Spostamento = Muovi - PosizioneInizialeIntervallo1
|
|
PosizioneInizialeIntervallo1 = Muovi
|
|
elseif NumeroIntervallo == "2" then
|
|
Spostamento = Muovi - PosizioneInizialeIntervallo2
|
|
PosizioneInizialeIntervallo2 = Muovi
|
|
else
|
|
Spostamento = Muovi - PosizioneInizialeIntervallo3
|
|
PosizioneInizialeIntervallo3 = Muovi
|
|
end
|
|
local CurrLayer = EgtGetFirstLayer( Trave)
|
|
local TabellaLocaleIntervallo = {}
|
|
while CurrLayer do
|
|
local NomeLayer = EgtGetName( CurrLayer)
|
|
if NomeLayer == "Intervallo"..NumeroIntervallo .."Surf" then
|
|
table.insert( TabellaLocaleIntervallo, CurrLayer)
|
|
end
|
|
if NomeLayer == "Intervallo"..NumeroIntervallo .."Linee" then
|
|
table.insert( TabellaLocaleIntervallo, CurrLayer)
|
|
end
|
|
CurrLayer = EgtGetNextLayer( CurrLayer)
|
|
end
|
|
table.insert( TabellaOggettiLayer, TabellaLocaleIntervallo)
|
|
return Animazione( Spostamento, TabellaOggettiLayer, TraslaMorse)
|
|
end
|
|
--
|
|
|
|
---------------------------------------------------------------------------------------------
|
|
-- COMANDI PER LA GESTIONE DEI MOVIMENTI
|
|
---------------------------------------------------------------------------------------------
|
|
|
|
-- Apri
|
|
function M.Apri_Morsa( sNumeroMorsa)
|
|
Apri_Chiudi_Morsa( sNumeroMorsa, AggiornaAperturaMassimaMorse())
|
|
if sNumeroMorsa == "1" then
|
|
M.StatoMorsa1="AP"
|
|
else
|
|
M.StatoMorsa2="AP"
|
|
end
|
|
EgtPause( TempoPausa)
|
|
end
|
|
--
|
|
|
|
-- Chiudi
|
|
function M.Chiudi_Morsa( sNumeroMorsa)
|
|
Apri_Chiudi_Morsa( sNumeroMorsa, -AggiornaAperturaMassimaMorse())
|
|
if sNumeroMorsa == "1" then
|
|
M.StatoMorsa1="CH"
|
|
else
|
|
M.StatoMorsa2="CH"
|
|
end
|
|
EgtPause( TempoPausa)
|
|
end
|
|
--
|
|
|
|
-- Alza
|
|
function M.Alza_Rullo ( sNumeroRullo)
|
|
Alza_Abbassa_Rullo( sNumeroRullo, AlzataMassimaRulli)
|
|
EgtPause( TempoPausa)
|
|
end
|
|
--
|
|
|
|
-- Abbassa
|
|
function M.Abbassa_Rullo ( sNumeroRullo)
|
|
Alza_Abbassa_Rullo( sNumeroRullo, -AlzataMassimaRulli)
|
|
EgtPause( TempoPausa)
|
|
end
|
|
--
|
|
|
|
-- Apri
|
|
function M.Apri_Rullo ( sNumeroRullo)
|
|
local TabellaMovimenti = {}
|
|
table.insert( TabellaMovimenti, Apri_Chiudi_Rullo( sNumeroRullo, AperturaMassimaRulli))
|
|
table.insert( TabellaMovimenti, Alza_Abbassa_Rullo( sNumeroRullo, AlzataMassimaRulli))
|
|
AnimazioneSincrona( TabellaMovimenti)
|
|
EgtPause( TempoPausa)
|
|
end
|
|
--
|
|
|
|
-- Chiudi
|
|
function M.Chiudi_Rullo ( sNumeroRullo)
|
|
local TabellaMovimenti = {}
|
|
table.insert( TabellaMovimenti, Apri_Chiudi_Rullo( sNumeroRullo, -AperturaMassimaRulli))
|
|
table.insert( TabellaMovimenti, Alza_Abbassa_Rullo( sNumeroRullo, -AlzataMassimaRulli))
|
|
AnimazioneSincrona( TabellaMovimenti)
|
|
EgtPause( TempoPausa)
|
|
end
|
|
--
|
|
|
|
-- Costruisce la tabella degli spostamenti
|
|
function M.Trasla_Morse_Trave( NumeroMorsa1, MuoviMorsa1, NumeroMorsa2, MuoviMorsa2, MuoviTrave)
|
|
if not bPosizionamentoPezzi then
|
|
if not MorsaAperta( Morsa1) and not MorsaAperta( Morsa2) then
|
|
EgtOutBox( "Entrambe le morse chiuse, scivolamento trave", "Warning", 'WARNING')
|
|
elseif not MorsaAperta( Morsa1) and MuoviTrave ~= nil then
|
|
if MuoviMorsa1 ~= nil and MuoviTrave ~= nil then
|
|
if abs( MuoviMorsa1 - MuoviTrave - (PosizioneInizialeMorsa1 - PosizioneInizialeTrave)) > GEO.EPS_SMALL then
|
|
EgtOutBox( "Scivolamento trave da morsa 1", "Errore", 'ERROR')
|
|
elseif ( PosizioneInizialeTrave + LunghezzaTrave) - PosizioneInizialeMorsa1 < GEO.EPS_SMALL then
|
|
EgtOutBox( "Mancato aggancio trave da morsa1", "Errore", 'ERROR')
|
|
end
|
|
end
|
|
elseif not MorsaAperta( Morsa2) and MuoviTrave ~= nil then
|
|
if MuoviMorsa2 ~= nil and MuoviTrave ~= nil then
|
|
if abs( MuoviMorsa2 - MuoviTrave - (PosizioneInizialeMorsa2 - PosizioneInizialeTrave)) > GEO.EPS_SMALL then
|
|
EgtOutBox( "Scivolamento trave da morsa 2", "Errore", 'ERROR')
|
|
elseif PosizioneInizialeMorsa2 - PosizioneInizialeTrave < GEO.EPS_SMALL then
|
|
EgtOutBox( "Mancato aggancio trave da morsa2", "Errore", 'ERROR')
|
|
end
|
|
end
|
|
end
|
|
if MuoviMorsa1 ~= nil then
|
|
if abs( MuoviMorsa1) < abs( PosizioneInizialeRullo1) or abs( MuoviMorsa1) > abs( PosizioneInizialeFineCorsa1) then
|
|
EgtOutBox( "Collisione morsa 1", "Errore", 'ERROR')
|
|
end
|
|
end
|
|
if MuoviMorsa2 ~= nil then
|
|
if abs( MuoviMorsa2) < abs( PosizioneInizialeRullo2) or abs( MuoviMorsa2) > abs( PosizioneInizialeFineCorsa2) then
|
|
EgtOutBox( "Collisione morsa 2", "Errore", 'ERROR')
|
|
end
|
|
end
|
|
end
|
|
local TabellaMovimenti = {}
|
|
if NumeroMorsa1 and MuoviMorsa1 then
|
|
table.insert( TabellaMovimenti, M.Trasla_Morsa( "1", MuoviMorsa1))
|
|
end
|
|
if NumeroMorsa2 and MuoviMorsa2 then
|
|
table.insert( TabellaMovimenti, M.Trasla_Morsa( "2", MuoviMorsa2))
|
|
end
|
|
if MuoviTrave then
|
|
table.insert( TabellaMovimenti, M.Trasla_Trave( MuoviTrave))
|
|
end
|
|
AnimazioneSincrona( TabellaMovimenti)
|
|
EgtPause( TempoPausa)
|
|
end
|
|
--
|
|
|
|
-- Costruisco la tabella degli spostamenti della testa
|
|
function M.Trasla_Mandrino( AsseZ, MuoviAsseZ, AsseX, MuoviAsseX, AsseC, MuoviAsseC, AsseB, MuoviAsseB)
|
|
CentroMandrinoAsseZ = EgtSP( IdPuntoMandrinoZ, GDB_RT.GLOB)
|
|
CentroMandrinoAsseY = EgtSP( IdPuntoMandrinoY, GDB_RT.GLOB)
|
|
local TabellaMovimenti = {}
|
|
if AsseZ and MuoviAsseZ then
|
|
table.insert( TabellaMovimenti, M.TraslaMandrino( "AsseZ", MuoviAsseZ))
|
|
end
|
|
if AsseX and MuoviAsseX then
|
|
table.insert( TabellaMovimenti, M.TraslaMandrino( "AsseX", MuoviAsseX))
|
|
end
|
|
if AsseC and MuoviAsseC then
|
|
table.insert( TabellaMovimenti, M.RuotaMandrino( "AsseC", MuoviAsseC))
|
|
end
|
|
if AsseB and MuoviAsseB then
|
|
table.insert( TabellaMovimenti, M.RuotaMandrino( "AsseB", MuoviAsseB))
|
|
end
|
|
AnimazioneSincrona( TabellaMovimenti)
|
|
end
|
|
--
|
|
|
|
-- Costruisce la tabella degli spostamenti dei rulli
|
|
function M.Trasla_Fine_Corsa( NumeroRullo1, MuoviRullo1, NumeroRullo2, MuoviRullo2, NumeroFineCorsa1, MuoviFineCorsa1, NumeroFineCorsa2, MuoviFineCorsa2)
|
|
local TabellaMovimenti = {}
|
|
if NumeroRullo1 and MuoviRullo1 then
|
|
table.insert( TabellaMovimenti, M.Trasla_Rullo( "1", MuoviRullo1))
|
|
end
|
|
if NumeroRullo2 and MuoviRullo2 then
|
|
table.insert( TabellaMovimenti, M.Trasla_Rullo( "2", MuoviRullo2))
|
|
end
|
|
if NumeroFineCorsa1 and MuoviFineCorsa1 then
|
|
table.insert( TabellaMovimenti, M.Trasla_FineCorsa( "1", MuoviFineCorsa1))
|
|
end
|
|
if NumeroFineCorsa2 and MuoviFineCorsa2 then
|
|
table.insert( TabellaMovimenti, M.Trasla_FineCorsa( "2", MuoviFineCorsa2))
|
|
end
|
|
AnimazioneSincrona( TabellaMovimenti)
|
|
EgtPause( TempoPausa)
|
|
end
|
|
--
|
|
|
|
-- Costruisce la teballe degli spostamenti degli intervalli e l'intervallo di lavorazione
|
|
function M.Trasla_Intervalli (NumeroIntervallo1, MuoviIntervallo1, NumeroIntervallo2, MuoviIntervallo2)
|
|
local TabellaMovimenti = {}
|
|
if NumeroIntervallo1 then
|
|
if NumeroIntervallo1 == "3" then
|
|
table.insert( TabellaMovimenti, M.Trasla_Intervallo( "3", MuoviIntervallo1))
|
|
end
|
|
if NumeroIntervallo1 == "1" and MuoviIntervallo1 then
|
|
table.insert( TabellaMovimenti, M.Trasla_Intervallo( "1", MuoviIntervallo1))
|
|
end
|
|
end
|
|
if NumeroIntervallo2 and MuoviIntervallo2 then
|
|
table.insert( TabellaMovimenti, M.Trasla_Intervallo( "2", MuoviIntervallo2))
|
|
end
|
|
AnimazioneSincrona( TabellaMovimenti)
|
|
EgtPause( TempoPausa)
|
|
end
|
|
--
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
-- FINE ANIMAZIONI E MOVIMENTI
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
-- Ricerca all'interno del file Comandi l'ultima funzione eseguita
|
|
local function UltimaFunzioneEseguita()
|
|
local NomeFileComandi = M.NomeFileComandi
|
|
if not EgtExistsFile( NomeFileComandi) then
|
|
return
|
|
end
|
|
lines = {}
|
|
for line in io.lines( NomeFileComandi) do
|
|
lines[#lines + 1] = line
|
|
if string.find( line, "-- Funzione Test:") then
|
|
local TabellaSplit = EgtSplitString( line, ':')
|
|
if TabellaSplit[2] then
|
|
local SplitDati = EgtSplitString( TabellaSplit[2], ',')
|
|
M.NomeFunzione = EgtTrim( SplitDati[1])
|
|
if SplitDati[2] then
|
|
M.UltimoTest = EgtTrim( SplitDati[2])
|
|
end
|
|
end
|
|
break
|
|
end
|
|
end
|
|
end
|
|
--
|
|
|
|
M.CaricaParent()
|
|
CaricaOggetti()
|
|
PosizioneInizialeMorsa1, PosizioneInizialeMorsa2, PosizioneInizialeTrave,_, _, _, PosizioneInizialeRullo1, PosizioneInizialeRullo2, PosizioneInizialeFineCorsa1, PosizioneInizialeFineCorsa2 = M.PosizioniAttuali()
|
|
_ = nil
|
|
AggiornaQuota( "1")
|
|
AggiornaQuota( "2")
|
|
AggiornaPosizioniInCartiglio()
|
|
DimensioniTrave()
|
|
UltimaFunzioneEseguita()
|
|
|
|
---------------------------------------------------------------------------------------------------------------------------------------------------
|
|
--LETTURA DATI DA TABELLA
|
|
---------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
-- Verifico che il file esista
|
|
local function file_exists(file)
|
|
local f = io.open(file, "r")
|
|
if f then
|
|
f:close()
|
|
end
|
|
return f ~= nil
|
|
end
|
|
--
|
|
|
|
-- Recupero tutte le righe del file
|
|
local function lines_from(file)
|
|
if not file_exists(file) then
|
|
return {}
|
|
end
|
|
lines = {}
|
|
for line in io.lines(file) do
|
|
lines[#lines + 1] = line
|
|
end
|
|
return lines
|
|
end
|
|
--
|
|
|
|
-- salva la riga di dati
|
|
local function StampaTabellaDati( file, NuovaRiga)
|
|
local f = io.open(file, "a")
|
|
if f then
|
|
f:write( NuovaRiga .."\n")
|
|
f:close()
|
|
end
|
|
return f ~= nil
|
|
end
|
|
--
|
|
|
|
local function CaricaTabellaDati( )
|
|
local RigheDati = {}
|
|
if file_exists(M.NomeFileDati) then
|
|
RigheDati = lines_from(M.NomeFileDati)
|
|
else
|
|
EgtOutBox("File '"..M.NomeFileDati.."' non trovato.","Interrota simulazione")
|
|
end
|
|
local ElencoTest = {}
|
|
local DatiTest = {}
|
|
for i = 1, #RigheDati, 1 do
|
|
DatiTest = EgtSplitString(RigheDati[i], ";")
|
|
if #DatiTest > 35 and DatiTest[1] ~= "" then
|
|
table.insert(ElencoTest, DatiTest)
|
|
end
|
|
end
|
|
return ElencoTest
|
|
end
|
|
--
|
|
|
|
-- carica i dati letti dal file csv
|
|
local function PosizionamentoInizialeDaFile( NumeroTest)
|
|
local VelocitSimulazione = Velocit
|
|
Velocit = 1000
|
|
bPosizionamentoPezzi = true
|
|
local ElencoTabellaDati = CaricaTabellaDati()
|
|
local ElencoCampi = ElencoTabellaDati[1]
|
|
local TabellaDati = ElencoTabellaDati[NumeroTest]
|
|
|
|
local LunghezzaTraveTest = 14000
|
|
local PosizioneTraveTest = -6000
|
|
|
|
local PosizioneMorsa1Test = 2000
|
|
local PosizioneMorsa2Test = -2000
|
|
|
|
local MaxIntervallo1Test = 1000
|
|
local MinIntervallo1Test = 800
|
|
local MaxIntervallo2Test = -800
|
|
local MinIntervallo2Test = -1000
|
|
|
|
local MaxFineCorsa1Test = 3000
|
|
local MinFineCorsa1Test = 300
|
|
local MaxFineCorsa2Test = -300
|
|
local MinFIneCorsa2Test = -3000
|
|
|
|
local StatoMorsa1Test = "AP"
|
|
local StatoMorsa2Test = "CH"
|
|
|
|
local PosDistFront = 2500
|
|
local PosDistBack = 2000
|
|
local DistFront = 1000
|
|
local DistBack = -12800
|
|
|
|
for i = 1, #ElencoCampi, 1 do
|
|
if EgtTrim(ElencoCampi[i]) == "LB" then
|
|
LunghezzaTraveTest = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "TiPos" then
|
|
PosizioneTraveTest = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "Y1iPos" then
|
|
PosizioneMorsa1Test = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "Y2iPos" then
|
|
PosizioneMorsa2Test = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "MaxPos Int_val1" then
|
|
MaxIntervallo1Test = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "MinPos Int_val1" then
|
|
MinIntervallo1Test = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "MaxPos Int_val2" then
|
|
MaxIntervallo2Test = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "MinPos Int_val2" then
|
|
MinIntervallo2Test = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "MaxY1" then
|
|
MaxFineCorsa1Test = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "MinY1" then
|
|
MinFineCorsa1Test = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "MaxY2" then
|
|
MaxFineCorsa2Test = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "MinY2" then
|
|
MinFIneCorsa2Test = TabellaDati[i]
|
|
elseif EgtTrim(ElencoCampi[i]) == "st Y1" then
|
|
StatoMorsa1Test = EgtTrim( TabellaDati[i])
|
|
elseif EgtTrim(ElencoCampi[i]) == "st Y2" then
|
|
StatoMorsa2Test = EgtTrim( TabellaDati[i])
|
|
elseif EgtTrim(ElencoCampi[i]) == "Pos Dist Front" then
|
|
PosDistFront = EgtTrim( TabellaDati[i])
|
|
elseif EgtTrim(ElencoCampi[i]) == "Pos Dist Back" then
|
|
PosDistBack = EgtTrim( TabellaDati[i])
|
|
end
|
|
end
|
|
|
|
DistFront = PosDistFront - PosizioneTraveTest
|
|
DistBack = LunghezzaTraveTest - ( PosDistBack - PosizioneTraveTest)
|
|
|
|
NewTab.dDistFront = DistFront
|
|
NewTab.dDistBack = DistBack
|
|
NewTab.bFixedDelta = false
|
|
NewTab.bFixedPos = false
|
|
|
|
M.PosizioniAttuali()
|
|
AggiornaQuota( "1")
|
|
AggiornaQuota( "2")
|
|
AggiornaQuotaIntervallo( "1")
|
|
AggiornaQuotaIntervallo( "2")
|
|
AggiornaPosizioniInCartiglio()
|
|
DimensioniTrave()
|
|
|
|
M.StatoMorsa1 = StatoMorsa1Test
|
|
if StatoMorsa1Test == "AP" and not MorsaAperta( Morsa1) then
|
|
M.Apri_Morsa( "1")
|
|
elseif StatoMorsa1Test == "CH" and MorsaAperta( Morsa1) then
|
|
M.Chiudi_Morsa( "1")
|
|
end
|
|
|
|
M.StatoMorsa2 = StatoMorsa2Test
|
|
if StatoMorsa2Test == "AP" and not MorsaAperta( Morsa2) then
|
|
M.Apri_Morsa( "2")
|
|
elseif StatoMorsa2Test == "CH" and MorsaAperta( Morsa2) then
|
|
M.Chiudi_Morsa( "2")
|
|
end
|
|
|
|
ModificaDimensionitrave( tonumber ( LunghezzaTraveTest), LarghezzaTrave, AltezzaTrave, LunghezzaTrave, LarghezzaTrave, AltezzaTrave, PuntoRiferimentoTrave)
|
|
M.Trasla_Morse_Trave("1",tonumber( PosizioneMorsa1Test),"2", tonumber( PosizioneMorsa2Test), tonumber( PosizioneTraveTest))
|
|
|
|
local TabellaIdLayerIntervallo1 = SelezioneLayerIntervallo( "1")
|
|
if MaxIntervallo1Test ~= "" and MinIntervallo1Test ~= "" then
|
|
EgtSetStatus( TabellaIdLayerIntervallo1, GDB_ST.ON)
|
|
ModificaDimensioniIntervallo( "1", tonumber( MaxIntervallo1Test)* SistemaRiferimento, tonumber( MinIntervallo1Test)* SistemaRiferimento, LunghezzaIntervallo1, PuntoIntervallo1)
|
|
else
|
|
EgtSetStatus( TabellaIdLayerIntervallo1, GDB_ST.OFF)
|
|
end
|
|
|
|
local TabellaIdLayerIntervallo2 = SelezioneLayerIntervallo( "2")
|
|
if MaxIntervallo2Test ~= "" and MinIntervallo2Test ~="" then
|
|
EgtSetStatus( TabellaIdLayerIntervallo2, GDB_ST.ON)
|
|
ModificaDimensioniIntervallo( "2", tonumber( MaxIntervallo2Test)* SistemaRiferimento, tonumber( MinIntervallo2Test)* SistemaRiferimento, LunghezzaIntervallo2, PuntoIntervallo2)
|
|
else
|
|
EgtSetStatus( TabellaIdLayerIntervallo2, GDB_ST.OFF)
|
|
end
|
|
|
|
local TabellaIdLayerIntervallo3 = SelezioneLayerIntervallo( "3")
|
|
if DistFront ~= "" and DistBack ~="" then
|
|
EgtSetStatus( TabellaIdLayerIntervallo3, GDB_ST.ON)
|
|
ModificaDimensioniIntervallo( "3", tonumber( PosizioneTraveTest + LunghezzaTraveTest - DistBack)* SistemaRiferimento, tonumber( PosizioneTraveTest + DistFront)* SistemaRiferimento, LunghezzaIntervallo3, PuntoIntervallo3)
|
|
else
|
|
EgtSetStatus( TabellaIdLayerIntervallo3, GDB_ST.OFF)
|
|
end
|
|
|
|
|
|
M.Trasla_Fine_Corsa( "1", tonumber( MinFineCorsa1Test), "2", tonumber( MaxFineCorsa2Test), "1", tonumber( MaxFineCorsa1Test), "2", tonumber( MinFIneCorsa2Test))
|
|
Velocit = VelocitSimulazione
|
|
bPosizionamentoPezzi = false
|
|
AggiornaPosizioniInCartiglio()
|
|
end
|
|
--
|
|
|
|
|
|
-- salva i dati utilizzati per eseguire un test nel file csv
|
|
function M.SalvaTest( NomeFunzione, WorkTab, EMC, MaxY1, MinY2, MinY1, MaxY2)
|
|
local ElencoTabellaDati = CaricaTabellaDati()
|
|
local ElencoCampi = ElencoTabellaDati[1]
|
|
|
|
local Indice = 1
|
|
for j = 1, #ElencoTabellaDati, 1 do
|
|
if ElencoTabellaDati[j][1] then
|
|
if ElencoTabellaDati[j][1] ~= "" then
|
|
if EgtTrim(ElencoTabellaDati[j][1]) == EgtTrim(NomeFunzione .."." ..Indice) then
|
|
Indice = Indice + 1
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
local NuovaRiga = NomeFunzione .."." ..Indice
|
|
|
|
for i = 1, #ElencoCampi, 1 do
|
|
if EgtTrim(ElencoCampi[i]) == "LB" then
|
|
NuovaRiga = NuovaRiga ..EMC.LB ..";"
|
|
elseif EgtTrim(ElencoCampi[i]) == "TiPos" then
|
|
NuovaRiga = NuovaRiga ..WorkTab.dTPosI ..";"
|
|
elseif EgtTrim(ElencoCampi[i]) == "Y1iPos" then
|
|
NuovaRiga = NuovaRiga ..( WorkTab.dY1DeltaI + WorkTab.dTPosI) ..";"
|
|
elseif EgtTrim(ElencoCampi[i]) == "Y2iPos" then
|
|
NuovaRiga = NuovaRiga ..( WorkTab.dY2DeltaI + WorkTab.dTPosI) ..";"
|
|
|
|
elseif EgtTrim(ElencoCampi[i]) == "MaxY1" then
|
|
NuovaRiga = NuovaRiga ..MaxY1 ..";"
|
|
elseif EgtTrim(ElencoCampi[i]) == "MinY1" then
|
|
NuovaRiga = NuovaRiga ..MinY1 ..";"
|
|
elseif EgtTrim(ElencoCampi[i]) == "MaxY2" then
|
|
NuovaRiga = NuovaRiga ..MaxY2 ..";"
|
|
elseif EgtTrim(ElencoCampi[i]) == "MinY2" then
|
|
NuovaRiga = NuovaRiga ..MinY2 ..";"
|
|
|
|
elseif EgtTrim(ElencoCampi[i]) == "st Y1" then
|
|
if EMC.YDELTA then
|
|
NuovaRiga = NuovaRiga .."CH;"
|
|
else
|
|
NuovaRiga = NuovaRiga .."AP;"
|
|
end
|
|
elseif EgtTrim(ElencoCampi[i]) == "st Y2" then
|
|
if EMC.VDELTA then
|
|
NuovaRiga = NuovaRiga .."CH;"
|
|
else
|
|
NuovaRiga = NuovaRiga .."AP;"
|
|
end
|
|
|
|
elseif EgtTrim(ElencoCampi[i]) == "Pos Dist Front" then
|
|
NuovaRiga = NuovaRiga ..( NewTab.dDistFront + WorkTab.dTPosI) ..";"
|
|
elseif EgtTrim(ElencoCampi[i]) == "Pos Dist Back" then
|
|
NuovaRiga = NuovaRiga ..( EMC.LB - NewTab.dDistBack + WorkTab.dTPosI) ..";"
|
|
|
|
else
|
|
NuovaRiga = NuovaRiga ..";"
|
|
end
|
|
end
|
|
|
|
StampaTabellaDati( M.NomeFileDati, NuovaRiga)
|
|
|
|
end
|
|
--
|
|
|
|
---------------------------------------------------------------------------------------------------------------------------------------------------
|
|
--INIZIO CONFIGURATORE
|
|
---------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
-- definizione delle posizioni iniziali
|
|
local function FinestraMorse()
|
|
local PosizioneMorsa1Attuale, PosizioneMorsa2Attuale, PosizioneTraveAttuale = M.PosizioniAttuali()
|
|
local ComboBoxMorsa1 = "CB: Chiusa, Aperta"
|
|
if MorsaAperta( Morsa1) then
|
|
ComboBoxMorsa1 = "CB: Aperta, Chiusa"
|
|
end
|
|
local ComboBoxMorsa2 = "CB: Chiusa, Aperta"
|
|
if MorsaAperta( Morsa2) then
|
|
ComboBoxMorsa2 = "CB: Aperta, Chiusa"
|
|
end
|
|
local PosizioniDiPartenza = EgtDialogBox( "Posizioni di partenza",
|
|
{ "Posizione Morsa 1", StampaQuota( PosizioneMorsa1Attuale, 100)},
|
|
{ "Posizione Morsa 2", StampaQuota( PosizioneMorsa2Attuale, 100)},
|
|
{ "Posizione Trave", StampaQuota( PosizioneTraveAttuale, 100)},
|
|
{ "Stato Morsa 1", ComboBoxMorsa1},
|
|
{ "Stato Morsa 2", ComboBoxMorsa2},
|
|
{ "Posizione Morsa chiusa", "CB: No, Si"})
|
|
if not PosizioniDiPartenza then
|
|
return false
|
|
end
|
|
if string.find( PosizioniDiPartenza[4], "Chiusa") then
|
|
M.Chiudi_Morsa( "1")
|
|
else
|
|
M.Apri_Morsa( "1")
|
|
end
|
|
if string.find(PosizioniDiPartenza[5], "Chiusa") then
|
|
M.Chiudi_Morsa( "2")
|
|
else
|
|
M.Apri_Morsa( "2")
|
|
end
|
|
if string.find(PosizioniDiPartenza[6], "Si") then
|
|
if not MorsaAperta( Morsa1) and MorsaAperta( Morsa2) then
|
|
local PosizioneFinaleTrave = PosizioneTraveAttuale + ( tonumber( PosizioniDiPartenza[1]) - PosizioneMorsa1Attuale)
|
|
M.Trasla_Morse_Trave( "1", tonumber( PosizioniDiPartenza[1]), "2", tonumber( PosizioniDiPartenza[2]), PosizioneFinaleTrave)
|
|
elseif not MorsaAperta( Morsa2) and MorsaAperta( Morsa1) then
|
|
local PosizioneFinaleTrave = PosizioneTraveAttuale + ( tonumber( PosizioniDiPartenza[2]) - PosizioneMorsa2Attuale)
|
|
M.Trasla_Morse_Trave("1", tonumber( PosizioniDiPartenza[1]), "2", tonumber( PosizioniDiPartenza[2]), PosizioneFinaleTrave)
|
|
end
|
|
else
|
|
M.Trasla_Morse_Trave("1",tonumber( PosizioniDiPartenza[1]),"2", tonumber( PosizioniDiPartenza[2]), tonumber( PosizioniDiPartenza[3]))
|
|
end
|
|
return true
|
|
end
|
|
--
|
|
|
|
-- definizione della dimensione dell'intervallo di lavoro
|
|
local function FinestraLavorazione()
|
|
local _, _, _, _, _, TabellaIntervallo3 = M.PosizioniAttuali()
|
|
local PosizioniDiPartenza = EgtDialogBox( "Posizioni lavorazione",
|
|
{ "Posizione Back", StampaQuota( TabellaIntervallo3[3]:getX() * SistemaRiferimento, 100)},
|
|
{ "Posizione Front", StampaQuota( ( TabellaIntervallo3[3]:getX() + TabellaIntervallo3[1])* SistemaRiferimento, 100)})
|
|
if not PosizioniDiPartenza then
|
|
return false
|
|
end
|
|
|
|
local TabellaIdLayerIntervallo3 = SelezioneLayerIntervallo( "3")
|
|
if PosizioniDiPartenza[1] ~= "" and PosizioniDiPartenza[2] ~="" then
|
|
EgtSetStatus( TabellaIdLayerIntervallo3, GDB_ST.ON)
|
|
ModificaDimensioniIntervallo( "3", tonumber( PosizioniDiPartenza[1])* SistemaRiferimento, tonumber( PosizioniDiPartenza[2])* SistemaRiferimento, TabellaIntervallo3[1], TabellaIntervallo3[3])
|
|
else
|
|
EgtSetStatus( TabellaIdLayerIntervallo3, GDB_ST.OFF)
|
|
end
|
|
return true
|
|
end
|
|
--
|
|
|
|
-- definizione delle dimensioni della trave
|
|
local function FinestraTrave()
|
|
--local LunghezzaTrave, LarghezzaTrave, AltezzaTrave, PuntoRiferimentoScala = DimensioniTrave()
|
|
local DimensionamentoTrave = EgtDialogBox( "Dimensioni Trave",
|
|
{ "Lunghezza", StampaQuota( LunghezzaTrave, 100)},
|
|
{ "Larghezza", StampaQuota( LarghezzaTrave, 100)},
|
|
{ "Altezzza", StampaQuota( AltezzaTrave, 100)})
|
|
|
|
if not DimensionamentoTrave then
|
|
return false
|
|
end
|
|
--Alza_Abbassa_Rullo( NumeroRullo, Muovi)
|
|
M.Apri_Rullo ( "1")
|
|
M.Apri_Rullo ( "2")
|
|
AperturaMassimaRulli = AperturaMassimaRulli + LarghezzaTrave - tonumber(DimensionamentoTrave[2])
|
|
AlzataMassimaRulli = AlzataMassimaRulli + AltezzaTrave - tonumber(DimensionamentoTrave[3])
|
|
local StatoMorsa1Aperta = MorsaAperta( Morsa1)
|
|
local StatoMorsa2Aperta = MorsaAperta( Morsa2)
|
|
M.Apri_Morsa( "1")
|
|
M.Apri_Morsa( "2")
|
|
ApertureMassimaMorse = ApertureMassimaMorse + LarghezzaTrave - tonumber(DimensionamentoTrave[2])
|
|
ModificaDimensionitrave( DimensionamentoTrave[1], DimensionamentoTrave[2], DimensionamentoTrave[3], LunghezzaTrave, LarghezzaTrave, AltezzaTrave, PuntoRiferimentoTrave)
|
|
M.Chiudi_Rullo( "1")
|
|
M.Chiudi_Rullo( "2")
|
|
if StatoMorsa1Aperta then
|
|
M.Chiudi_Morsa( "1")
|
|
end
|
|
if StatoMorsa2Aperta then
|
|
M.Chiudi_Morsa( "2")
|
|
end
|
|
LunghezzaTrave = DimensionamentoTrave[1]
|
|
LarghezzaTrave = DimensionamentoTrave[2]
|
|
AltezzaTrave = DimensionamentoTrave[3]
|
|
return true
|
|
end
|
|
--
|
|
|
|
-- utilizzata per disegare l'intervallo complementare (nelle funzioni A, C)
|
|
function M.MostraIntervalloComplementare( NumeroIntervallo, MaxIntervallo, MinIntervallo)
|
|
local _, _, _, TabellaIntervallo1, TabellaIntervallo2, TabellaIntervallo3 = M.PosizioniAttuali()
|
|
if EgtTrim( NumeroIntervallo) == "1" then
|
|
ModificaDimensioniIntervallo( "1", tonumber( MaxIntervallo)* SistemaRiferimento, tonumber( MinIntervallo)* SistemaRiferimento, TabellaIntervallo1[1], TabellaIntervallo1[3])
|
|
EgtSetStatus( SelezioneLayerIntervallo( "1") , GDB_ST.ON)
|
|
else
|
|
ModificaDimensioniIntervallo( "2", tonumber( MaxIntervallo)* SistemaRiferimento, tonumber( MinIntervallo)* SistemaRiferimento, TabellaIntervallo2[1], TabellaIntervallo2[3])
|
|
EgtSetStatus( SelezioneLayerIntervallo( "2") , GDB_ST.ON)
|
|
end
|
|
AggiornaQuotaIntervallo( "1")
|
|
AggiornaQuotaIntervallo( "2")
|
|
EgtDraw()
|
|
end
|
|
--
|
|
|
|
-- definizione delle posizioni degli intervalli
|
|
local function FinestraIntervalli()
|
|
local _, _, _, TabellaIntervallo1, TabellaIntervallo2, TabellaIntervallo3 = M.PosizioniAttuali()
|
|
|
|
local TabellaIdLayerIntervallo1 = SelezioneLayerIntervallo( "1")
|
|
local Intervallo1Visibilita = "CB: Nascondi, Mostra"
|
|
if EgtGetStatus( TabellaIdLayerIntervallo1[1]) ~= 0 then
|
|
Intervallo1Visibilita = "CB: Mostra, Nascondi"
|
|
end
|
|
|
|
local TabellaIdLayerIntervallo2 = SelezioneLayerIntervallo( "2")
|
|
local Intervallo2Visibilita = "CB: Nascondi, Mostra"
|
|
if EgtGetStatus( TabellaIdLayerIntervallo2[1]) ~= 0 then
|
|
Intervallo2Visibilita = "CB: Mostra, Nascondi"
|
|
end
|
|
|
|
local PosizioniDiPartenza = EgtDialogBox( "Posizioni di partenza",
|
|
{ "Visibilità Intervallo 1", Intervallo1Visibilita},
|
|
{ "Posizione sx Intervallo 1", StampaQuota( TabellaIntervallo1[3]:getX() * SistemaRiferimento, 100)},
|
|
{ "Posizione dx Intervallo 1", StampaQuota( ( TabellaIntervallo1[3]:getX() + TabellaIntervallo1[1])* SistemaRiferimento, 100)},
|
|
{ "Visibilità Intervallo 2", Intervallo2Visibilita},
|
|
{ "Posizione sx Intervallo 2",StampaQuota( TabellaIntervallo2[3]:getX() * SistemaRiferimento, 100)},
|
|
{ "Posizione dx Intervallo 2",StampaQuota( ( TabellaIntervallo2[3]:getX() + TabellaIntervallo2[1])* SistemaRiferimento, 100)})
|
|
if not PosizioniDiPartenza then
|
|
return false
|
|
end
|
|
PosizioneInizialeIntervallo1 = (PosizioniDiPartenza[2] + PosizioniDiPartenza[3]) / 2
|
|
PosizioneInizialeIntervallo2 = (PosizioniDiPartenza[5] + PosizioniDiPartenza[6]) / 2
|
|
if EgtTrim( PosizioniDiPartenza[1]) == "Mostra" then
|
|
EgtSetStatus( TabellaIdLayerIntervallo1, GDB_ST.ON)
|
|
ModificaDimensioniIntervallo( "1", tonumber( PosizioniDiPartenza[2])* SistemaRiferimento, tonumber( PosizioniDiPartenza[3])* SistemaRiferimento, TabellaIntervallo1[1], TabellaIntervallo1[3])
|
|
else
|
|
EgtSetStatus( TabellaIdLayerIntervallo1, GDB_ST.OFF)
|
|
end
|
|
if EgtTrim( PosizioniDiPartenza[4]) == "Mostra" then
|
|
EgtSetStatus( TabellaIdLayerIntervallo2, GDB_ST.ON)
|
|
ModificaDimensioniIntervallo( "2", tonumber( PosizioniDiPartenza[5])* SistemaRiferimento, tonumber( PosizioniDiPartenza[6])* SistemaRiferimento, TabellaIntervallo2[1], TabellaIntervallo2[3])
|
|
else
|
|
EgtSetStatus( TabellaIdLayerIntervallo1, GDB_ST.OFF)
|
|
end
|
|
AggiornaPosizioniInCartiglio()
|
|
return true
|
|
end
|
|
--
|
|
|
|
-- definizione dei piccoli movimenti
|
|
local function FinestraMovimentiStep()
|
|
local PosizioneMorsa1, PosizioneMorsa2, PosizioneTrave, TabellaIntervallo1, TabellaIntervallo2, TabellaIntervallo3 = M.PosizioniAttuali()
|
|
local ListaOggeti = {"Morsa1", "Morsa2", "Trave", "Intervallo1", "Intervallo2", "Lavorazione", "Morsa chiusa"}
|
|
local ComboBoxOggetti
|
|
if UltimaSelezionePiccoloSpostamento then
|
|
ComboBoxOggetti = EgtTrim( UltimaSelezionePiccoloSpostamento)
|
|
for i = 1, #ListaOggeti, 1 do
|
|
if EgtTrim( UltimaSelezionePiccoloSpostamento) ~= ListaOggeti[i] then
|
|
ComboBoxOggetti = ComboBoxOggetti .."," ..ListaOggeti[i]
|
|
end
|
|
end
|
|
else
|
|
ComboBoxOggetti = ListaOggeti[1]
|
|
for i = 1, #ListaOggeti, 1 do
|
|
ComboBoxOggetti = ComboBoxOggetti .."," ..ListaOggeti[i]
|
|
end
|
|
end
|
|
|
|
local Movimenti = EgtDialogBox( "Piccoli Movimenti",
|
|
{ "Step Movimento", tostring( UltimaDistanzaPiccoloSpostamento)},
|
|
{ "Seleziona elemento", "CB: " ..ComboBoxOggetti})
|
|
if not Movimenti then
|
|
return false
|
|
end
|
|
UltimaDistanzaPiccoloSpostamento = tonumber( Movimenti[1])
|
|
UltimaSelezionePiccoloSpostamento = Movimenti[2]
|
|
if string.find( Movimenti[2], "Morsa1") then
|
|
M.Trasla_Morse_Trave( "1", PosizioneMorsa1 + tonumber( Movimenti[1]) , nil, nil, nil)
|
|
elseif string.find( Movimenti[2], "Morsa2") then
|
|
M.Trasla_Morse_Trave( nil, nil, "2", PosizioneMorsa2 + tonumber( Movimenti[1]), nil)
|
|
elseif string.find( Movimenti[2], "Trave") then
|
|
M.Trasla_Morse_Trave( nil, nil, nil, nil, PosizioneTrave + tonumber( Movimenti[1]))
|
|
elseif string.find( Movimenti[2], "Intervallo1") then
|
|
M.Trasla_Intervalli ( "1", PosizioneInizialeIntervallo1 + tonumber( Movimenti[1]), nil, nil)
|
|
elseif string.find( Movimenti[2], "Intervallo2") then
|
|
M.Trasla_Intervalli ( nil, nil, "2", PosizioneInizialeIntervallo2 + tonumber( Movimenti[1]))
|
|
elseif string.find( Movimenti[2], "Lavorazione") then
|
|
M.Trasla_Intervalli ( "3", PosizioneInizialeIntervallo3 + tonumber( Movimenti[1]), nil, nil)
|
|
elseif string.find( Movimenti[2], "Morsa chiusa") then
|
|
if not MorsaAperta( Morsa1) and MorsaAperta( Morsa2) then
|
|
M.Trasla_Morse_Trave( "1", PosizioneMorsa1 + tonumber( Movimenti[1]), nil, nil, PosizioneTrave + tonumber( Movimenti[1]))
|
|
elseif not MorsaAperta( Morsa2) and MorsaAperta( Morsa1) then
|
|
M.Trasla_Morse_Trave( nil, nil, "2", PosizioneMorsa2 + tonumber( Movimenti[1]), PosizioneTrave + tonumber( Movimenti[1]))
|
|
end
|
|
end
|
|
return true
|
|
end
|
|
--
|
|
|
|
-- definsce l'elenco delle funzioni test
|
|
local function ComboBoxFunzioni()
|
|
local RigheDati = {}
|
|
local ElencoFunzioni = {}
|
|
if file_exists(M.NomeFileCarrelli) then
|
|
RigheDati = lines_from(M.NomeFileCarrelli)
|
|
end
|
|
for i = 1, #RigheDati, 1 do
|
|
if string.find( RigheDati[i], 'if sFunction == ') then
|
|
string.gsub( RigheDati[i], '"(.-)"', function (w) table.insert( ElencoFunzioni, EgtTrim( w)) end)
|
|
end
|
|
end
|
|
|
|
local IndiceFunzione = 1
|
|
for i = 1, #ElencoFunzioni, 1 do
|
|
if EgtTrim( M.NomeFunzione) == ElencoFunzioni[i] then
|
|
IndiceFunzione = i
|
|
break
|
|
end
|
|
end
|
|
|
|
local ComboBoxFunzioniTest = "CB: "..ElencoFunzioni[IndiceFunzione]
|
|
for i = 1, #ElencoFunzioni, 1 do
|
|
if i ~= IndiceFunzione then
|
|
ComboBoxFunzioniTest = ComboBoxFunzioniTest.. ", "..ElencoFunzioni[i]
|
|
end
|
|
end
|
|
return ElencoFunzioni, ComboBoxFunzioniTest
|
|
end
|
|
--
|
|
|
|
-- scelta della funzione da verificare
|
|
local function FinestraFunzioni()
|
|
local ElencoFunzioni, ComboBoxFunzioniTest = ComboBoxFunzioni()
|
|
local FunzioneTset = EgtDialogBox( "Elenco funzioni",
|
|
{ "Funzione Test", ComboBoxFunzioniTest})
|
|
if not FunzioneTset then
|
|
return false
|
|
end
|
|
|
|
for i = 1, #ElencoFunzioni, 1 do
|
|
if EgtTrim( FunzioneTset[1]) == ElencoFunzioni[i] then
|
|
M.NomeFunzione = ElencoFunzioni[i]
|
|
break
|
|
end
|
|
end
|
|
return true
|
|
end
|
|
--
|
|
|
|
-- definizione delle posizioni degli intervalli
|
|
local function FinestraFineCorsa()
|
|
local _, _, _, _, _, _, PosizioneRullo1, PosizioneRullo2, PosizioneFineCorsa1, PosizioneFineCorsa2 = M.PosizioniAttuali()
|
|
PosizioneInizialeRullo1 = PosizioneRullo1
|
|
PosizioneInizialeRullo2 = PosizioneRullo2
|
|
PosizioneInizialeFineCorsa1 = PosizioneFineCorsa1
|
|
PosizioneInizialeFineCorsa2 = PosizioneFineCorsa2
|
|
local Posizionamento = EgtDialogBox( "Posizioni di partenza",
|
|
{ "Posizione rullo 1", StampaQuota( PosizioneRullo1, 100)},
|
|
{ "Posizione rullo 2", StampaQuota( PosizioneRullo2, 100)},
|
|
{ "Fine Corsa 1", StampaQuota( PosizioneFineCorsa1, 100)},
|
|
{ "Fine Corsa 2", StampaQuota( PosizioneFineCorsa2, 100)})
|
|
if not Posizionamento then
|
|
return false
|
|
end
|
|
M.Trasla_Fine_Corsa( "1", Posizionamento[1], "2", Posizionamento[2], "1", Posizionamento[3], "2", Posizionamento[4])
|
|
return true
|
|
end
|
|
--
|
|
|
|
-- esegue in sequenza tutti i test cotrassegnati nel campo "Test" con "*" (da file csv)
|
|
function M.EseguiTuttiTest()
|
|
local ElencoFunzioni, _ = ComboBoxFunzioni()
|
|
local ElencoTabellaDati = CaricaTabellaDati()
|
|
local ElencoCampi = ElencoTabellaDati[1]
|
|
local CampoNomeTest = 1
|
|
local CampoTest = 1
|
|
local CampoFunzioni = 1
|
|
for i = 1, #ElencoCampi, 1 do
|
|
if EgtTrim( ElencoCampi[i]) == "Test" then
|
|
CampoTest = i
|
|
end
|
|
if EgtTrim( ElencoCampi[i]) == "Funzione" then
|
|
CampoFunzioni = i
|
|
end
|
|
end
|
|
|
|
for i = 2, #ElencoTabellaDati, 1 do
|
|
if CampoTest ~= CampoFunzioni and EgtTrim( ElencoTabellaDati[i][CampoTest]) == "*" and ElencoTabellaDati[i][CampoFunzioni] ~= "" then
|
|
PosizionamentoInizialeDaFile( i)
|
|
for j = 1, #ElencoFunzioni, 1 do
|
|
if EgtTrim( ElencoFunzioni[j]) == EgtTrim( ElencoTabellaDati[i][CampoFunzioni]) then
|
|
M.NomeFunzione = ElencoFunzioni[j]
|
|
M.UltimoTest = ElencoTabellaDati[i][CampoNomeTest]
|
|
local A = dofile( M.NomeFileCarrelli)
|
|
M.VerificaPoiszionamentoMorse()
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
--
|
|
|
|
-- scelgo se lanciare l'ultimo test oppure il batch oppure procedere con la selezione di un test
|
|
local function FinestraEseguiComandi()
|
|
local ComboBoxSelezione = "CB: Seleziona Test, Esegui Batch, Riesegui Test, Carica Disegno"
|
|
local SelezioneAvvio = EgtDialogBox( "Configurazione Avvio",
|
|
{ "Selezione avvio", ComboBoxSelezione})
|
|
if not SelezioneAvvio then
|
|
return false
|
|
end
|
|
if EgtTrim( SelezioneAvvio[1]) == "Esegui Batch" then
|
|
M.EseguiSimulazione = true
|
|
local A = dofile( M.NomeFileEseguiComandi)
|
|
return false, false
|
|
elseif EgtTrim( SelezioneAvvio[1]) == "Riesegui Test" then
|
|
M.EseguiSimulazione = false
|
|
local A = dofile( M.NomeFileEseguiComandi)
|
|
return false, false
|
|
elseif EgtTrim( SelezioneAvvio[1]) == "Carica Disegno" then
|
|
return true, false
|
|
else
|
|
M.EseguiSimulazione = false
|
|
return true, true
|
|
end
|
|
end
|
|
--
|
|
|
|
-- scelta del test
|
|
local function FinestraSelezioneTest()
|
|
local ElencoFunzioni, ComboBoxFunzioniTest = ComboBoxFunzioni()
|
|
local ElencoTest = CaricaTabellaDati()
|
|
local ComboBoxTest
|
|
if M.UltimoTest == "nulla" then
|
|
ComboBoxTest = "CB: " ..M.UltimoTest
|
|
else
|
|
ComboBoxTest = "CB: " ..M.UltimoTest ..", nulla"
|
|
end
|
|
for i = 1, #ElencoTest, 1 do
|
|
if EgtTrim( ElencoTest[i][1]) ~= "Campi" and EgtTrim( ElencoTest[i][1]) ~= M.UltimoTest then
|
|
ComboBoxTest = ComboBoxTest.."," ..ElencoTest[i][1]
|
|
end
|
|
end
|
|
local Test = EgtDialogBox( "Configurazione test",
|
|
{ "Seleziona test", ComboBoxTest},
|
|
{ "Funzione Test", ComboBoxFunzioniTest})
|
|
|
|
if not Test then
|
|
return false
|
|
end
|
|
M.UltimoTest = Test[1]
|
|
|
|
for i = 1, #ElencoTest, 1 do
|
|
if EgtTrim( ElencoTest[i][1]) == EgtTrim( Test[1]) then
|
|
PosizionamentoInizialeDaFile( i)
|
|
break
|
|
end
|
|
end
|
|
|
|
for i = 1, #ElencoFunzioni, 1 do
|
|
if EgtTrim( ElencoFunzioni[i]) == EgtTrim( Test[2]) then
|
|
M.NomeFunzione = ElencoFunzioni[i]
|
|
break
|
|
end
|
|
end
|
|
return true
|
|
end
|
|
--
|
|
|
|
-- Menu principale
|
|
function M.PreparaSimulazione()
|
|
bPosizionamentoPezzi = true
|
|
local EsitoEseguiComandi, SaltaAdAvvio = FinestraEseguiComandi()
|
|
if not EsitoEseguiComandi then
|
|
return false
|
|
end
|
|
M.PosizioniAttuali()
|
|
AggiornaQuota( "1")
|
|
AggiornaQuota( "2")
|
|
AggiornaQuotaIntervallo( "1")
|
|
AggiornaQuotaIntervallo( "2")
|
|
AggiornaPosizioniInCartiglio()
|
|
DimensioniTrave()
|
|
UltimaFunzioneEseguita()
|
|
local VelocitSimulazione = Velocit
|
|
Velocit = 1000
|
|
EgtDraw()
|
|
if SaltaAdAvvio then
|
|
if not FinestraSelezioneTest() then
|
|
return false
|
|
end
|
|
end
|
|
local ContinuaSimulazione = false
|
|
while not ContinuaSimulazione do
|
|
local ComboBoxSceltaFinestra = "CB: Avvia Simulazione, Posizionamento, Trave, Intervalli, Lavorazione, Piccoli Spostamenti, Fine Corsa, Dati Test, Funzione Test"
|
|
local SceltaFinestra = EgtDialogBox( "Scelta Finestra", { "Seleziona finestra", ComboBoxSceltaFinestra})
|
|
if not SceltaFinestra then
|
|
bPosizionamentoPezzi = false
|
|
Velocit = VelocitSimulazione
|
|
return false
|
|
end
|
|
local RimaniNellaFinestra = false
|
|
|
|
if string.find( SceltaFinestra[1], "Avvia Simulazione") then
|
|
bPosizionamentoPezzi = false
|
|
Velocit = VelocitSimulazione
|
|
ContinuaSimulazione = true
|
|
elseif string.find( SceltaFinestra[1], "Posizionamento") then
|
|
RimaniNellaFinestra = FinestraMorse()
|
|
while RimaniNellaFinestra do
|
|
RimaniNellaFinestra = FinestraMorse()
|
|
end
|
|
elseif string.find( SceltaFinestra[1], "Trave") then
|
|
RimaniNellaFinestra = FinestraTrave()
|
|
while RimaniNellaFinestra do
|
|
RimaniNellaFinestra = FinestraTrave()
|
|
end
|
|
elseif string.find( SceltaFinestra[1], "Intervalli") then
|
|
RimaniNellaFinestra = FinestraIntervalli()
|
|
while RimaniNellaFinestra do
|
|
RimaniNellaFinestra = FinestraIntervalli()
|
|
end
|
|
elseif string.find( SceltaFinestra[1], "Lavorazione") then
|
|
RimaniNellaFinestra = FinestraLavorazione()
|
|
while RimaniNellaFinestra do
|
|
RimaniNellaFinestra = FinestraLavorazione()
|
|
end
|
|
elseif string.find( SceltaFinestra[1], "Piccoli Spostamenti") then
|
|
RimaniNellaFinestra = FinestraMovimentiStep()
|
|
while RimaniNellaFinestra do
|
|
RimaniNellaFinestra = FinestraMovimentiStep()
|
|
end
|
|
elseif string.find( SceltaFinestra[1], "Funzione Test") then
|
|
FinestraFunzioni()
|
|
elseif string.find( SceltaFinestra[1], "Dati Test") then
|
|
RimaniNellaFinestra = FinestraSelezioneTest()
|
|
while RimaniNellaFinestra do
|
|
RimaniNellaFinestra = FinestraSelezioneTest()
|
|
end
|
|
elseif string.find( SceltaFinestra[1], "Fine Corsa") then
|
|
RimaniNellaFinestra = FinestraFineCorsa()
|
|
while RimaniNellaFinestra do
|
|
RimaniNellaFinestra = FinestraFineCorsa()
|
|
end
|
|
end
|
|
end
|
|
return true
|
|
end
|
|
--
|
|
|
|
function M.VerificaPoiszionamentoMorse()
|
|
local PosizioneMorsa1, PosizioneMorsa2, PosizioneTrave, TabellaIntervallo1, TabellaIntervallo2, TabellaIntervallo3 = M.PosizioniAttuali()
|
|
if MorsaAperta( Morsa1) and MorsaAperta( Morsa2) then
|
|
EgtOutBox( "Entrambe le morse aperte, scivolamento trave", "Warning", 'WARNING')
|
|
end
|
|
if not MorsaAperta( Morsa1) then
|
|
if PosizioneMorsa1 * SistemaRiferimento < TabellaIntervallo1[3]:getX() and PosizioneMorsa1 * SistemaRiferimento > TabellaIntervallo1[3]:getX() + TabellaIntervallo1[1] then
|
|
EgtOutBox( "Mancato intervallo morsa 1", "Errore", 'ERROR')
|
|
end
|
|
end
|
|
if not MorsaAperta( Morsa2) then
|
|
if PosizioneMorsa2 * SistemaRiferimento < TabellaIntervallo2[3]:getX() and PosizioneMorsa2 * SistemaRiferimento > TabellaIntervallo2[3]:getX() + TabellaIntervallo2[1] then
|
|
EgtOutBox( "Mancato intervallo morsa 2", "Errore", 'ERROR')
|
|
end
|
|
end
|
|
end
|
|
--
|
|
|
|
-- Usata nell'EseguiComandi: mostra il nome del test e la funzione associata al file
|
|
function M.PosizionaEseguiComandi()
|
|
-- stampo l'elenco dei file presenti nella cartella selezionata
|
|
local TabFileBatch = {}
|
|
local p = io.popen('dir "'..M.NomeDirettorioBatch ..'"')
|
|
-- ricavo l'elenco dei direttori
|
|
local ComboBoxDirettori = "CB: "
|
|
local Index = 1
|
|
for Direttorio in p:lines() do
|
|
m, d, y = string.match(Direttorio, "(%d+)/(%d+)/(%d+)")
|
|
if m and d and y and string.find(Direttorio,"<DIR>") then
|
|
Direttorio = string.gsub(Direttorio,"<DIR>", "")
|
|
Direttorio = string.gsub(Direttorio,"(%d+)/(%d+)/(%d+)%s*(%d+):(%d+)%s*(%d+)%s*", "")
|
|
if Direttorio ~= "." and Direttorio ~= ".." then
|
|
ComboBoxDirettori = ComboBoxDirettori.. EgtIf( Index == 1, "", ", ").. Direttorio
|
|
Index = Index + 1
|
|
end
|
|
end
|
|
end
|
|
-- finsetra per la selezione del direttorio
|
|
local SceltaDirettorioBatch = EgtDialogBox( "Seleziona Direttorio Batch", { "Seleziona Direttorio", ComboBoxDirettori})
|
|
if not SceltaDirettorioBatch then
|
|
return false
|
|
end
|
|
-- elenco dei file presenti nella cartella selezionata
|
|
for file in io.popen('dir "'..M.NomeDirettorioBatch.. EgtTrim(SceltaDirettorioBatch[1]).. "\\"..'"'):lines() do
|
|
m, d, y = string.match(file, "(%d+)/(%d+)/(%d+)")
|
|
if m and d and y and not string.find( file, "<DIR>")then
|
|
file = string.gsub(file,"(%d+)/(%d+)/(%d+)%s*(%d+):(%d+)%s*(%d+)%s*", "")
|
|
table.insert(TabFileBatch, file)
|
|
end
|
|
end
|
|
|
|
UltimaFunzioneEseguita()
|
|
local ComboBoxFunzioniBatch = "CB: "
|
|
if M.NomeFunzione and M.UltimoTest then
|
|
ComboBoxFunzioniBatch = "CB: Cmd_" ..EgtTrim( M.NomeFunzione) ..'_'.. EgtTrim( M.UltimoTest)
|
|
end
|
|
for i = 1, #TabFileBatch, 1 do
|
|
if TabFileBatch[i] ~= "Cmd_" ..EgtTrim( M.NomeFunzione) ..'_'.. EgtTrim( M.UltimoTest).. ".lua" then
|
|
ComboBoxFunzioniBatch = ComboBoxFunzioniBatch.. ", ".. string.gsub(TabFileBatch[i], ".lua", "")
|
|
end
|
|
end
|
|
local SceltaFileBatch = EgtDialogBox( "Seleziona File Batch", { "Seleziona file", ComboBoxFunzioniBatch})
|
|
if not SceltaFileBatch then
|
|
return false
|
|
end
|
|
EgtCopyFile( M.NomeDirettorioBatch.. EgtTrim(SceltaDirettorioBatch[1]).. "\\".. EgtTrim( SceltaFileBatch[1]).. ".lua", M.NomeFileComandi)
|
|
UltimaFunzioneEseguita()
|
|
return FinestraSelezioneTest()
|
|
end
|
|
--
|
|
|
|
-- azzera i valori dei movimenti
|
|
function M.ResetTrip()
|
|
TripMorsa1 = 0
|
|
TripMorsa2 = 0
|
|
PrecPosizioneMorsa1 = nil
|
|
PrecPosizioneMorsa2 = nil
|
|
end
|
|
--
|
|
|
|
-- carica i dati letti dalla WorkTab
|
|
function M.PosizionemantoDaWorkTab( WorkTab)
|
|
|
|
local MaxIntervallo1Test = WorkTab.dY1DeltaMinF + WorkTab.dTPosI
|
|
local MinIntervallo1Test = WorkTab.dY1DeltaMaxF + WorkTab.dTPosI
|
|
local MaxIntervallo2Test = WorkTab.dY2DeltaMinF + WorkTab.dTPosI
|
|
local MinIntervallo2Test = WorkTab.dY2DeltaMaxF + WorkTab.dTPosI
|
|
local MaxIntervallo3Test = LunghezzaTrave - NewTab.dDistBack + WorkTab.dTPosI
|
|
local MinIntervallo3Test = NewTab.dDistFront + WorkTab.dTPosI
|
|
|
|
M.PosizioniAttuali()
|
|
AggiornaQuota( "1")
|
|
AggiornaQuota( "2")
|
|
AggiornaQuotaIntervallo( "1")
|
|
AggiornaQuotaIntervallo( "2")
|
|
|
|
local TabellaIdLayerIntervallo1 = SelezioneLayerIntervallo( "1")
|
|
if MaxIntervallo1Test ~= "" and MinIntervallo1Test ~= "" then
|
|
EgtSetStatus( TabellaIdLayerIntervallo1, GDB_ST.ON)
|
|
ModificaDimensioniIntervallo( "1", tonumber( MaxIntervallo1Test)* SistemaRiferimento, tonumber( MinIntervallo1Test)* SistemaRiferimento, LunghezzaIntervallo1, PuntoIntervallo1)
|
|
else
|
|
EgtSetStatus( TabellaIdLayerIntervallo1, GDB_ST.OFF)
|
|
end
|
|
|
|
local TabellaIdLayerIntervallo2 = SelezioneLayerIntervallo( "2")
|
|
if MaxIntervallo2Test ~= "" and MinIntervallo2Test ~="" then
|
|
EgtSetStatus( TabellaIdLayerIntervallo2, GDB_ST.ON)
|
|
ModificaDimensioniIntervallo( "2", tonumber( MaxIntervallo2Test)* SistemaRiferimento, tonumber( MinIntervallo2Test)* SistemaRiferimento, LunghezzaIntervallo2, PuntoIntervallo2)
|
|
else
|
|
EgtSetStatus( TabellaIdLayerIntervallo2, GDB_ST.OFF)
|
|
end
|
|
AggiornaPosizioniInCartiglio()
|
|
end
|
|
--
|
|
|
|
-- restiuisce il valore delle nuove colonne (DistBack e DistFront) lette da csv
|
|
function M.PosizioniPerCalcoloIntervallo()
|
|
local PosizioneMorsa1, PosizioneMorsa2, PosizioneTrave, TabellaIntervallo1, TabellaIntervallo2, TabellaIntervallo3 = M.PosizioniAttuali()
|
|
NewTab.dDistFront = ( TabellaIntervallo3[3]:getX() * SistemaRiferimento - TabellaIntervallo3[1]) - PosizioneTrave
|
|
NewTab.dDistBack = LunghezzaTrave - ( NewTab.dDistFront + TabellaIntervallo3[1])
|
|
return NewTab
|
|
end
|
|
--
|
|
---------------------------------------------------------------------------------------------------------------------------------------------------
|
|
-- FINE CONFIGURATORE
|
|
---------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
return M
|