Modifica nomi variabili secondo nuovo standard

This commit is contained in:
andrea.villa
2024-05-14 11:47:53 +02:00
parent 59bbf159e4
commit 30fa7c8cbd
11 changed files with 499 additions and 389 deletions
+176 -176
View File
@@ -63,13 +63,13 @@ end
-------------------------------------------------------------------------------------------------------------
local function IsToolOk( Tool)
-- controllo che i dati necessari siano impostati
if Tool.MaxMaterial and Tool.Diameter and Tool.Length and Tool.Head and Tool.UUID then
if Tool.dMaxMaterial and Tool.dDiameter and Tool.dLength and Tool.sHead and Tool.sUUID then
-- se DRILLBIT non ho altri dati
if Tool.Family == 'DRILLBIT' then
if Tool.sFamily == 'DRILLBIT' then
return true
-- altrimenti controllo dati aggiuntivi altre famiglie di utensili
else
if Tool.Thick then
if Tool.dThick then
return true
end
end
@@ -86,13 +86,13 @@ function BeamExec.GetToolsFromDB()
local Tool = {}
-- recupero tutti gli utensili : punte a forare, lame, frese e motoseghe
Tool.Name = EgtTdbGetFirstTool( MCH_TF.DRILLBIT + MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE)
while Tool.Name ~= '' do
Tool.sName = EgtTdbGetFirstTool( MCH_TF.DRILLBIT + MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE)
while Tool.sName ~= '' do
-- imposto utensile come corrente per recuperarne i dati
EgtTdbSetCurrTool( Tool.Name)
EgtTdbSetCurrTool( Tool.sName)
-- verifico se utensile disponibile in attrezzaggio attuale e che abbia un tipo ben definito
local bToolLoadedOnSetup, sToolTCPos = EgtFindToolInCurrSetup( Tool.Name)
local bToolLoadedOnSetup, sToolTCPos = EgtFindToolInCurrSetup( Tool.sName)
local dToolTypeID = EgtTdbGetCurrToolParam( MCH_TP.TYPE)
local sToolType, sToolFamily = GetToolTypeNameFromToolTypeID( dToolTypeID)
@@ -100,60 +100,60 @@ function BeamExec.GetToolsFromDB()
if bToolLoadedOnSetup and sToolType then
-- TODO Tool.AName -> da rimuovere perchè non serve. Per il momento lo manteniamo solo perchè è più facile vedere e interpretare la lista utensili nella watch di zerobrane
-- Nell'utilizzo, si legge sempre il Tool.Name
Tool.AName = Tool.Name
Tool.TcPos = sToolTCPos
Tool.Family = sToolFamily
Tool.Type = sToolType
Tool.TypeID = dToolTypeID
Tool.MaxMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
Tool.Diameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
Tool.Length = EgtTdbGetCurrToolParam( MCH_TP.LEN)
Tool.Speed = EgtTdbGetCurrToolParam( MCH_TP.SPEED)
Tool.IsCCW = Tool.Speed < 0
Tool.AName = Tool.sName
Tool.sTcPos = sToolTCPos
Tool.sFamily = sToolFamily
Tool.sType = sToolType
Tool.dTypeID = dToolTypeID
Tool.dMaxMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
Tool.dDiameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
Tool.dLength = EgtTdbGetCurrToolParam( MCH_TP.LEN)
Tool.dSpeed = EgtTdbGetCurrToolParam( MCH_TP.SPEED)
Tool.bIsCCW = Tool.dSpeed < 0
Tool.Feeds = {}
Tool.Feeds.Feed = EgtTdbGetCurrToolParam( MCH_TP.FEED)
Tool.Feeds.StartFeed = EgtTdbGetCurrToolParam( MCH_TP.STARTFEED)
Tool.Feeds.EndFeed = EgtTdbGetCurrToolParam( MCH_TP.ENDFEED)
Tool.Feeds.TipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED)
Tool.Feeds.dFeed = EgtTdbGetCurrToolParam( MCH_TP.FEED)
Tool.Feeds.dStartFeed = EgtTdbGetCurrToolParam( MCH_TP.STARTFEED)
Tool.Feeds.dEndFeed = EgtTdbGetCurrToolParam( MCH_TP.ENDFEED)
Tool.Feeds.dTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED)
-- TODO serve funzione in BeamData che data la posizione dell'utensile e della testa, capisca il montaggio (testa sopra - testa sotto - aggregato - ecc...)
Tool.Head = EgtTdbGetCurrToolParam( MCH_TP.HEAD)
Tool.UUID = EgtTdbGetCurrToolParam( MCH_TP.UUID)
Tool.UserNotes = EgtTdbGetCurrToolParam( MCH_TP.USERNOTES)
Tool.MaxDepth = EgtTdbGetCurrToolMaxDepth() or Tool.MaxMaterial
Tool.sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD)
Tool.sUUID = EgtTdbGetCurrToolParam( MCH_TP.UUID)
Tool.sUserNotes = EgtTdbGetCurrToolParam( MCH_TP.USERNOTES)
Tool.dMaxDepth = EgtTdbGetCurrToolMaxDepth() or Tool.dMaxMaterial
Tool.ToolHolder = {}
Tool.ToolHolder.Diameter = EgtTdbGetCurrToolThDiam() or TH_DIAMETER_HSK63 -- diametro standard HSK63
Tool.ToolHolder.Length = EgtTdbGetCurrToolThLength() or TH_LENGTH_HSK63 -- lunghezza standard HSK63
Tool.ToolHolder.dDiameter = EgtTdbGetCurrToolThDiam() or TH_DIAMETER_HSK63 -- diametro standard HSK63
Tool.ToolHolder.dLength = EgtTdbGetCurrToolThLength() or TH_LENGTH_HSK63 -- lunghezza standard HSK63
-- parametri scritti nelle note
Tool.Double = EgtGetValInNotes( Tool.UserNotes, 'DOUBLE')
Tool.nDouble = EgtGetValInNotes( Tool.sUserNotes, 'DOUBLE')
-- lettura parametri non comuni ( famiglia DRILLBIT non ha parametri specifici)
if sToolFamily ~= 'DRILLBIT' then
Tool.Thick = EgtTdbGetCurrToolParam( MCH_TP.THICK)
Tool.LongitudinalOffset = EgtTdbGetCurrToolParam( MCH_TP.LONOFFSET)
Tool.RadialOffset = EgtTdbGetCurrToolParam( MCH_TP.RADOFFSET)
Tool.dThick = EgtTdbGetCurrToolParam( MCH_TP.THICK)
Tool.dLongitudinalOffset = EgtTdbGetCurrToolParam( MCH_TP.LONOFFSET)
Tool.dRadialOffset = EgtTdbGetCurrToolParam( MCH_TP.RADOFFSET)
-- recupero parametri propri delle frese
if sToolFamily == 'MILL' then
Tool.StemDiameter = EgtTdbGetCurrToolParam( MCH_TP.STEMDIAM) or Tool.ThDiameter -- se non settato, considero diametro come ToolHolder
Tool.SideAngle = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or 0
Tool.dStemDiameter = EgtTdbGetCurrToolParam( MCH_TP.STEMDIAM) or Tool.ToolHolder.dDiameter -- se non settato, considero diametro come ToolHolder
Tool.dSideAngle = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or 0
-- verifico che parametri siano compatibili con una fresa a coda di rondine ( angolo di fianco standard Coda di rondine -> 15°)
Tool.IsDoveTail = Tool.Type == 'MILL_NOTIP' and abs( abs( Tool.SideAngle) - SIDEANGLE_DOVETAIL) < 1
Tool.bIsDoveTail = Tool.Type == 'MILL_NOTIP' and abs( abs( Tool.dSideAngle) - SIDEANGLE_DOVETAIL) < 1
-- verifico che sia una fresa tipo T-Mill o BlockHaus
Tool.SideDepth = EgtGetValInNotes( Tool.UserNotes, 'SIDEDEPTH') or 0 -- se non settato nell'utensile, dico che non ha massimo affondamento laterale
Tool.IsTMill = Tool.SideDepth > 0
Tool.Step = EgtGetValInNotes( Tool.UserNotes, 'STEP') or ( Tool.MaxMaterial / 2) -- se non settato nell'utensile, considero metà del tagliente
Tool.SideStep = EgtGetValInNotes( Tool.UserNotes, 'SIDESTEP') or floor( Tool.Diameter / 2) -- se non settato nell'utensile, considero metà del diametro
Tool.dSideDepth = EgtGetValInNotes( Tool.sUserNotes, 'SIDEDEPTH') or 0 -- se non settato nell'utensile, dico che non ha massimo affondamento laterale
Tool.bIsTMill = Tool.dSideDepth > 0
Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or ( Tool.dMaxMaterial / 2) -- se non settato nell'utensile, considero metà del tagliente
Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or floor( Tool.dDiameter / 2) -- se non settato nell'utensile, considero metà del diametro
-- recupero parametri propri delle lame
elseif sToolFamily == 'SAWBLADE' then
Tool.IsUsedForLongCut = EgtGetValInNotes( Tool.UserNotes, 'LONGCUT') == 1 or false -- false coem valore di default
Tool.Step = EgtGetValInNotes( Tool.UserNotes, 'STEP') or Tool.Thick -- se non settato nell'utensile, considero lo spessore lama
Tool.SideStep = EgtGetValInNotes( Tool.UserNotes, 'SIDESTEP') or floor( Tool.Diameter / 4) -- se non settato nell'utensile, considero un quarto del diametro
Tool.bIsUsedForLongCut = EgtGetValInNotes( Tool.sUserNotes, 'LONGCUT') == 1 or false -- false coem valore di default
Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or Tool.dThick -- se non settato nell'utensile, considero lo spessore lama
Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or floor( Tool.dDiameter / 4) -- se non settato nell'utensile, considero un quarto del diametro
-- recupero parametri propri delle motoseghe
elseif sToolFamily == 'MORTISE' then
Tool.Distance = EgtTdbGetCurrToolParam( MCH_TP.DIST) or 90 -- 90mm dimensione standard aggregato catena
Tool.IsMortise = EgtGetValInNotes( Tool.UserNotes, 'MORTISE') == 1
Tool.IsChainSaw = not Tool.IsMortise
Tool.Step = EgtGetValInNotes( Tool.UserNotes, 'STEP') or ( Tool.Thick - 1) -- se non settato nell'utensile, considero spessore catena meno 1mm di sicurezza
Tool.SideStep = EgtGetValInNotes( Tool.UserNotes, 'SIDESTEP') or floor( Tool.MaxMaterial / 3) -- se non settato nell'utensile, considero un terzo della lunghezza
Tool.dDistance = EgtTdbGetCurrToolParam( MCH_TP.DIST) or 90 -- 90mm dimensione standard aggregato catena
Tool.bIsMortise = EgtGetValInNotes( Tool.sUserNotes, 'MORTISE') == 1
Tool.bIsChainSaw = not Tool.bIsMortise
Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or ( Tool.dThick - 1) -- se non settato nell'utensile, considero spessore catena meno 1mm di sicurezza
Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or floor( Tool.dMaxMaterial / 3) -- se non settato nell'utensile, considero un terzo della lunghezza
end
end
@@ -162,7 +162,7 @@ function BeamExec.GetToolsFromDB()
table.insert( TOOLS, Tool)
-- altrimenti scrivo nel log che l'utensile non è conforme
else
EgtOutLog( '*** ' .. Tool.Name .. ' : NOT-COMPLIANT ***', 1)
EgtOutLog( '*** ' .. Tool.sName .. ' : NOT-COMPLIANT ***', 1)
end
-- reset dati
@@ -170,7 +170,7 @@ function BeamExec.GetToolsFromDB()
end
-- recupero utensile successivo ( punte a forare, lame, frese e motoseghe)
Tool.Name = EgtTdbGetNextTool( MCH_TF.DRILLBIT + MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE)
Tool.sName = EgtTdbGetNextTool( MCH_TF.DRILLBIT + MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE)
end
end
@@ -228,8 +228,8 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b
-- Creazione nuovo gruppo di lavoro
if not bMachGroupOk then
local sMgName = EgtGetMachGroupNewName( 'Mach_1')
local NewMgId = EgtAddMachGroup( sMgName)
if not NewMgId then
local idNewMg = EgtAddMachGroup( sMgName)
if not idNewMg then
local sOut = 'Errore nella creazione del gruppo di lavoro ' .. sMgName
return false, sOut
end
@@ -251,110 +251,110 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b
local b3Tab = EgtGetTableArea()
-- Calcolo posizione estremo TR/BR della tavola rispetto a sua origine in BL
local dPosY = EgtIf( BeamData.CENTER_BEAM, ( b3Tab:getDimY() + dRawW * EgtIf( BeamData.RIGHT_LOAD, -1, 1)) / 2, EgtIf( BeamData.RIGHT_LOAD, 0, b3Tab:getDimY()))
BeamData.OriXR = Point3d( b3Tab:getDimX(), dPosY, 0)
BeamData.PosXR = EgtIf( BeamData.RIGHT_LOAD, MCH_CR.BR, MCH_CR.TR)
BeamData.ptOriXR = Point3d( b3Tab:getDimX(), dPosY, 0)
BeamData.dPosXR = EgtIf( BeamData.RIGHT_LOAD, MCH_CR.BR, MCH_CR.TR)
-- Impostazione dell'attrezzaggio di default
EgtImportSetup()
-- Inserimento dei pezzi con il loro grezzo
local Cnt = 0
local Len = dRawL
local nPrevRaw, dPrevDelta
local DeltaS = dOvmHead
local DeltaSMin = 0
local DeltaE = BeamData.OVM_MID
local nCnt = 0
local dLen = dRawL
local idPrevRaw, dPrevDelta
local dDeltaS = dOvmHead
local dDeltaSMin = 0
local dDeltaE = BeamData.OVM_MID
for i = 1, #vBeam do
-- assegno identificativo pezzo
local Pz = vBeam[i].Id
local idPz = vBeam[i].Id
-- dati del pezzo
local b3Part = EgtGetBBoxGlob( Pz or GDB_ID.NULL, GDB_BB.EXACT)
local b3Solid = vBeam[i].Box
local b3Part = EgtGetBBoxGlob( idPz or GDB_ID.NULL, GDB_BB.EXACT)
local b3Solid = vBeam[i].b3Box
if b3Part:isEmpty() or b3Solid:isEmpty() then break end
EgtOutLog( 'PartSez=' .. EgtNumToString( b3Part:getDimY(), 1) .. 'x' .. EgtNumToString( b3Part:getDimZ(), 1), 3)
-- se sezione compatibile e lunghezza disponibile sufficiente
local PartLen = b3Solid:getDimX()
local PartWidth = b3Solid:getDimY()
local PartHeight = b3Solid:getDimZ()
local NextLen = Len - DeltaS - PartLen - DeltaE
if (( abs( PartWidth - dRawW) < 100 * GEO.EPS_SMALL and abs( PartHeight - dRawH) < 100 * GEO.EPS_SMALL) or
( abs( PartHeight - dRawW) < 100 * GEO.EPS_SMALL and abs( PartWidth - dRawH) < 100 * GEO.EPS_SMALL)) and
NextLen + DeltaE >= 0 then
local dPartLen = b3Solid:getDimX()
local dPartWidth = b3Solid:getDimY()
local dPartHeight = b3Solid:getDimZ()
local dNextLen = dLen - dDeltaS - dPartLen - dDeltaE
if (( abs( dPartWidth - dRawW) < 100 * GEO.EPS_SMALL and abs( dPartHeight - dRawH) < 100 * GEO.EPS_SMALL) or
( abs( dPartHeight - dRawW) < 100 * GEO.EPS_SMALL and abs( dPartWidth - dRawH) < 100 * GEO.EPS_SMALL)) and
dNextLen + dDeltaE >= 0 then
-- eventuale sovramateriale di testa
if i > 1 then
if vBeam[i].PosX then
DeltaS = max( vBeam[i].PosX - ( dRawL - Len), DeltaSMin)
if vBeam[i].dPosX then
dDeltaS = max( vBeam[i].dPosX - ( dRawL - dLen), dDeltaSMin)
else
DeltaS = max( dOvmMid - DeltaE, 0)
dDeltaS = max( dOvmMid - dDeltaE, 0)
end
end
-- dimensioni del grezzo
local CrawLen = min( PartLen + DeltaS + DeltaE, Len)
local Delta = CrawLen - PartLen - DeltaS
local dCrawLen = min( dPartLen + dDeltaS + dDeltaE, dLen)
local dDelta = dCrawLen - dPartLen - dDeltaS
-- creo e posiziono il grezzo
local nRaw = EgtAddRawPart( Point3d(0,0,0), CrawLen, dRawW, dRawH, BeamData.RAWCOL)
EgtMoveToCornerRawPart( nRaw, BeamData.OriXR, BeamData.PosXR)
EgtMoveRawPart( nRaw, Vector3d( Len - dRawL, 0, 0))
local idRaw = EgtAddRawPart( Point3d(0,0,0), dCrawLen, dRawW, dRawH, BeamData.RAWCOL)
EgtMoveToCornerRawPart( idRaw, BeamData.ptOriXR, BeamData.dPosXR)
EgtMoveRawPart( idRaw, Vector3d( dLen - dRawL, 0, 0))
-- assegno ordine in lavorazione
Cnt = Cnt + 1
EgtSetInfo( nRaw, 'ORD', Cnt)
nCnt = nCnt + 1
EgtSetInfo( idRaw, 'ORD', nCnt)
-- creo o pulisco gruppo geometrie aggiuntive
if not BeamLib.CreateOrEmptyAddGroup( Pz) then
local sOut = 'Error creating Additional Group in Part ' .. tostring( Pz)
if not BeamLib.CreateOrEmptyAddGroup( idPz) then
local sOut = 'Error creating Additional Group in Part ' .. tostring( idPz)
return false, sOut
end
-- aggiungo faccia per taglio iniziale al pezzo
BeamLib.AddPartStartFace( Pz, b3Solid)
BeamLib.AddPartStartFace( idPz, b3Solid)
-- se sovramateriale di testa, lo notifico
if DeltaS > 0.09 then
EgtSetInfo( nRaw, 'HOVM', DeltaS)
if nPrevRaw then
EgtSetInfo( nPrevRaw, 'BDST', DeltaS + dPrevDelta)
if dDeltaS > 0.09 then
EgtSetInfo( idRaw, 'HOVM', dDeltaS)
if idPrevRaw then
EgtSetInfo( idPrevRaw, 'BDST', dDeltaS + dPrevDelta)
end
end
if DeltaE > 0.09 then
EgtSetInfo( nRaw, 'TOVM', DeltaE)
if dDeltaE > 0.09 then
EgtSetInfo( idRaw, 'TOVM', dDeltaE)
end
-- aggiungo faccia per taglio finale al pezzo
BeamLib.AddPartEndFace( Pz, b3Solid)
BeamLib.AddPartEndFace( idPz, b3Solid)
-- inserisco il pezzo nel grezzo
EgtDeselectPartObjs( Pz)
local ptPos = b3Part:getMin() - b3Solid:getMin() + Vector3d( Delta, ( dRawW - PartWidth) / 2, ( dRawH - PartHeight) / 2)
EgtAddPartToRawPart( Pz, ptPos, nRaw)
if abs( PartWidth - dRawW) > 100 * GEO.EPS_SMALL then
EgtDeselectPartObjs( idPz)
local ptPos = b3Part:getMin() - b3Solid:getMin() + Vector3d( dDelta, ( dRawW - dPartWidth) / 2, ( dRawH - dPartHeight) / 2)
EgtAddPartToRawPart( idPz, ptPos, idRaw)
if abs( dPartWidth - dRawW) > 100 * GEO.EPS_SMALL then
-- rotazione attorno a centro geometria complessiva del pezzo
EgtRotatePartInRawPart( Pz, X_AX(), 90)
EgtRotatePartInRawPart( idPz, X_AX(), 90)
-- correggo per eccentricità solido rispetto a geometria complessiva del pezzo
local vtEccOri = b3Solid:getCenter() - b3Part:getCenter()
local vtEccRot = Vector3d( vtEccOri)
vtEccRot:rotate( X_AX(), 90)
EgtMovePartInRawPart( Pz, ( vtEccOri - vtEccRot))
EgtMovePartInRawPart( idPz, ( vtEccOri - vtEccRot))
end
-- aggiorno la lunghezza residua della barra
Len = Len - CrawLen
dLen = dLen - dCrawLen
-- aggiorno grezzo precedente
nPrevRaw = nRaw
dPrevDelta = Delta
idPrevRaw = idRaw
dPrevDelta = dDelta
else
local sOut = 'Error: part L(' .. EgtNumToString( PartLen, 1) .. ') too big for raw part L(' .. EgtNumToString( Len - 0.1, 1) .. ')'
local sOut = 'Error: part L(' .. EgtNumToString( dPartLen, 1) .. ') too big for raw part L(' .. EgtNumToString( dLen - 0.1, 1) .. ')'
return false, sOut
end
-- se rimasto troppo poco grezzo, esco
--if Len < BeamData.MinRaw then break end
DeltaS = 0
end
if nPrevRaw then
EgtSetInfo( nPrevRaw, 'BDST', 10000)
if idPrevRaw then
EgtSetInfo( idPrevRaw, 'BDST', 10000)
end
-- Se rimasto materiale aggiungo grezzo dell'avanzo
if Len > 10 then
local nRaw = EgtAddRawPart( Point3d(0,0,0), Len, dRawW, dRawH, BeamData.RAWCOL)
EgtMoveToCornerRawPart( nRaw, BeamData.OriXR, BeamData.PosXR)
EgtMoveRawPart( nRaw, Vector3d( Len - dRawL, 0, 0))
if dLen > 10 then
local idRaw = EgtAddRawPart( Point3d(0,0,0), dLen, dRawW, dRawH, BeamData.RAWCOL)
EgtMoveToCornerRawPart( idRaw, BeamData.ptOriXR, BeamData.dPosXR)
EgtMoveRawPart( idRaw, Vector3d( dLen - dRawL, 0, 0))
-- assegno ordine in lavorazione
Cnt = Cnt + 1
EgtSetInfo( nRaw, 'ORD', Cnt)
nCnt = nCnt + 1
EgtSetInfo( idRaw, 'ORD', nCnt)
end
return true
@@ -363,18 +363,18 @@ end
-------------------------------------------------------------------------------------------------------------
function BeamExec.CalcMinUnloadableRaw( dRawW, dRawH)
if BeamData.GetMinUnloadableRaw then
BeamData.MinRaw = BeamData.GetMinUnloadableRaw( dRawW, dRawH)
BeamData.dMinRaw = BeamData.GetMinUnloadableRaw( dRawW, dRawH)
else
local H_S = 200
local H_L = 400
-- Determinazione minimo grezzo scaricabile
if dRawH <= H_S then
BeamData.MinRaw = BeamData.MINRAW_S
BeamData.dMinRaw = BeamData.MINRAW_S
elseif dRawH <= H_L then
local Coeff = ( dRawH - H_S) / ( H_L - H_S)
BeamData.MinRaw = ( 1 - Coeff) * BeamData.MINRAW_S + Coeff * BeamData.MINRAW_L
BeamData.dMinRaw = ( 1 - Coeff) * BeamData.MINRAW_S + Coeff * BeamData.MINRAW_L
else
BeamData.MinRaw = BeamData.MINRAW_L
BeamData.dMinRaw = BeamData.MINRAW_L
end
end
end
@@ -387,11 +387,11 @@ local function GetStrategiesFromGlobalList( Proc)
-- cerco tra le feature
for i = 1, #STRATEGIES.Features do
-- se trovo la feature
if Proc.Prc == STRATEGIES.Features[i].Prc and Proc.Grp == STRATEGIES.Features[i].Grp then
if Proc.nPrc == STRATEGIES.Features[i].nPrc and Proc.nGrp == STRATEGIES.Features[i].nGrp then
-- cerco tra le topologie
for j = 1, #STRATEGIES.Features[i].Topologies do
-- se trovo la topologia
if Proc.Topology.Name == STRATEGIES.Features[i].Topologies[j].Name then
if Proc.Topology.sName == STRATEGIES.Features[i].Topologies[j].sName then
-- ritorno le strategie disponibili per la feature che sto analizzando
return STRATEGIES.Features[i].Topologies[j].Strategies
end
@@ -426,21 +426,21 @@ local function GetFeatureForcedStrategy( Proc)
local StrategyData = require( sStrategyId .. '\\' .. sStrategyId .. 'Config')
-- se ID strategia non esiste oppure ID letto in NGE è differente da quello letto nella strategia, esco subito
if not StrategyData or StrategyData.StrategyId ~= sStrategyId then
if not StrategyData or StrategyData.sStrategyId ~= sStrategyId then
return nil
end
-- salvo che questa strategia è stata forzata, e che quindi ho già letto il file config con i parametri di default
-- quando si calcolerà la lavorazione non servirà leggere/riverificare i parametri di default
StrategyData.ForcedStrategy = true
StrategyData.bForcedStrategy = true
-- cerco e aggiorno i parametri come sono settati nel processing
for i = 1, #StrategyData.Parameters do
local sParameterToRead = StrategyData.StrategyId .. '_' .. StrategyData.Parameters[i].Name
local sParameterToRead = StrategyData.sStrategyId .. '_' .. StrategyData.Parameters[i].sName
ForcedParameterForProc = EgtGetInfo( Proc.Id, sParameterToRead, 's')
-- se ho trovato il valore, lo sovrascrivo al default
if ForcedParameterForProc then
StrategyData.Parameters[i].Value = ForcedParameterForProc
StrategyData.Parameters[i].sValue = ForcedParameterForProc
end
end
@@ -470,25 +470,25 @@ local function CollectFeatures( PartId, Part)
local nDo = EgtGetInfo( ProcId, 'DO', 'i') or 1
if nGrp and nPrc and nDo == 1 then
local Proc = {}
Proc.PartId = PartId
Proc.idPart = PartId
Proc.Id = ProcId
-- id della feature btl ( se non presente info, si prende id dell'entità geometrica)
Proc.FeatureId = EgtGetInfo( Proc.Id, 'PRID', 's') or Proc.Id
Proc.Grp = nGrp
Proc.Prc = nPrc
Proc.Flg = 1
Proc.Fct = EgtSurfTmFacetCount( ProcId) or 0
Proc.CutId = EgtGetInfo( EgtGetParent( EgtGetParent( ProcId)), 'CUTID', 'i') or 0
Proc.TaskId = EgtGetInfo( ProcId, 'TASKID', 'i') or 0
Proc.Box = EgtGetBBoxGlob( ProcId, GDB_BB.STANDARD)
EgtOutLog( '------Feature ' .. Proc.FeatureId .. '------')
Proc.idFeature = EgtGetInfo( Proc.Id, 'PRID', 's') or Proc.Id
Proc.nGrp = nGrp
Proc.nPrc = nPrc
Proc.nFlg = 1
Proc.nFct = EgtSurfTmFacetCount( ProcId) or 0
Proc.idCut = EgtGetInfo( EgtGetParent( EgtGetParent( ProcId)), 'CUTID', 'i') or 0
Proc.idTask = EgtGetInfo( ProcId, 'TASKID', 'i') or 0
Proc.b3Box = EgtGetBBoxGlob( ProcId, GDB_BB.STANDARD)
EgtOutLog( '------Feature ' .. Proc.idFeature .. '------')
-- se esiste la geometria
if Proc.Box and not Proc.Box:isEmpty() then
if Proc.b3Box and not Proc.b3Box:isEmpty() then
-- TODO fare una funzione per recuperare i dati delle feature che non passano dal calcolo della topologia?
-- se foro calcolo altri dati
if ID.IsDrilling( Proc) then
-- assegno diametro e facce di ingresso e uscita (dati tabelle sempre per riferimento)
Proc.Diam, Proc.Len, Proc.Fcs, Proc.Fce = FeatureData.GetDrillingData( Proc)
Proc.dDiam, Proc.dLen, Proc.nFcs, Proc.nFce = FeatureData.GetDrillingData( Proc)
end
-- informazioni facce e topologia
Proc.AffectedFaces = BeamLib.GetAffectedFaces( Proc)
@@ -499,11 +499,11 @@ local function CollectFeatures( PartId, Part)
Proc.Faces = FaceData.GetFacesInfo( Proc, Part)
Proc.Topology = FeatureData.ClassifyTopology( Proc, Part)
else
Proc.Topology.Family = 'FEATURE'
Proc.Topology.Name = 'FEATURE'
Proc.Topology.sFamily = 'FEATURE'
Proc.Topology.sName = 'FEATURE'
end
-- se topologia feature riconosciuta, oppure da non calcolare perchè il riconoscimento topologico è basato sulla feature stessa
if Proc.Topology.Name ~= 'NOT_IMPLEMENTED' then
if Proc.Topology.sName ~= 'NOT_IMPLEMENTED' then
-- TODO Funzione 'GetMainFaces' da scrivere
Proc.MainFaces = FaceData.GetMainFaces( Proc)
-- se la processing ha una strategia forzata, riporto tutto nella proc
@@ -519,16 +519,16 @@ local function CollectFeatures( PartId, Part)
table.insert( vProc, Proc)
-- altrimenti errore (non ci sono strategie per lavorare la topologia riconosciuta)
else
EgtOutLog( ' Feature ' .. tostring( Proc.FeatureId) .. ' : NO available strategies')
EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' : NO available strategies')
end
-- altrimenti errore (serviva riconoscimento topologico, ma non è stato possibile farlo)
else
EgtOutLog( ' Feature ' .. tostring( Proc.FeatureId) .. ' : NO available strategies')
EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' : NO available strategies')
end
else
Proc.Flg = 0
table.insert( vProc, Proc)
EgtOutLog( ' Feature ' .. tostring( Proc.FeatureId) .. ' is empty (no geometry)')
EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' is empty (no geometry)')
end
end
end
@@ -577,16 +577,16 @@ local function AreDrillingsMirrored( Proc, ProcMirror, Part)
-- centri allineati, equidistanti dalla mezzeria trave, non troppo vicini
local vtDisplacement = ptBC - ptBCMirror
local ptCenRaw = Part.RawBox:getCenter()
local ptCenRaw = Part.b3RawBox:getCenter()
if nDouble == 2 then
local dYMinDistance = max( Proc.Box:getMin():getY(), ProcMirror.Box:getMin():getY()) - min( Proc.Box:getMax():getY(), ProcMirror.Box:getMax():getY())
local dYMinDistance = max( Proc.b3Box:getMin():getY(), ProcMirror.b3Box:getMin():getY()) - min( Proc.b3Box:getMax():getY(), ProcMirror.b3Box:getMax():getY())
if not ( abs( vtDisplacement:getX()) < 100 * GEO.EPS_SMALL and abs( vtDisplacement:getZ()) < 100 * GEO.EPS_SMALL and
( abs( ptBC:getY() - ptCenRaw:getY()) - abs( ptBCMirror:getY() - ptCenRaw:getY())) < 100 * GEO.EPS_SMALL and
dYMinDistance > MIRROR_DRILLINGS_MIN_DISTANCE + 10 * GEO.EPS_SMALL) then
return false
end
else
local dZMinDistance = max( Proc.Box:getMin():getZ(), ProcMirror.Box:getMin():getZ()) - min( Proc.Box:getMax():getZ(), ProcMirror.Box:getMax():getZ())
local dZMinDistance = max( Proc.b3Box:getMin():getZ(), ProcMirror.b3Box:getMin():getZ()) - min( Proc.b3Box:getMax():getZ(), ProcMirror.b3Box:getMax():getZ())
if not ( abs( vtDisplacement:getX()) < 100 * GEO.EPS_SMALL and abs( vtDisplacement:getY()) < 100 * GEO.EPS_SMALL and
( abs( ptBC:getZ() - ptCenRaw:getZ()) - abs( ptBCMirror:getZ() - ptCenRaw:getZ())) < 100 * GEO.EPS_SMALL and
dZMinDistance > MIRROR_DRILLINGS_MIN_DISTANCE + 10 * GEO.EPS_SMALL) then
@@ -595,7 +595,7 @@ local function AreDrillingsMirrored( Proc, ProcMirror, Part)
end
-- fori della stessa profondità
if abs( Proc.Len - ProcMirror.Len) > 10 * GEO.EPS_SMALL then
if abs( Proc.dLen - ProcMirror.dLen) > 10 * GEO.EPS_SMALL then
return false
end
@@ -613,9 +613,9 @@ local function GetFeatureInfoAndDependency( vProcSingleRot, Part)
if i ~= j then
local ProcB = vProcSingleRot[j]
-- verifico se feature tipo LapJoint è attraversata da almeno un foro
if ( Proc.Topology.Family == 'Pocket' or Proc.Topology.Family == 'Tunnel' or Proc.Topology.Family == 'Groove' or ID.IsMortise( Proc)) and
ID.IsDrilling( ProcB) and Overlaps( Proc.Box, ProcB.Box) then
Proc.PassedByHole = true
if ( Proc.Topology.sFamily == 'Pocket' or Proc.Topology.sFamily == 'Tunnel' or Proc.Topology.sFamily == 'Groove' or ID.IsMortise( Proc)) and
ID.IsDrilling( ProcB) and Overlaps( Proc.b3Box, ProcB.b3Box) then
Proc.bPassedByHole = true
end
-- verifiche per specchiature
if BeamData.DOWN_HEAD or BeamData.TWO_EQUAL_HEADS then
@@ -658,28 +658,28 @@ local function GetIndexBestStrategyFromComparison( AvailableStrategies, nIndex1,
dChosenIndex = 0
elseif nIndex1 == 0 then
-- basta che sia applicabile
if AvailableStrategies[nIndex2].RatingResult and ( AvailableStrategies[nIndex2].RatingResult.Status == 'Completed' or AvailableStrategies[nIndex2].RatingResult.Status == 'Not-Completed') then
if AvailableStrategies[nIndex2].RatingResult and ( AvailableStrategies[nIndex2].RatingResult.sStatus == 'Completed' or AvailableStrategies[nIndex2].RatingResult.sStatus == 'Not-Completed') then
dChosenIndex = nIndex2
end
elseif nIndex2 == 0 then
-- basta che sia applicabile
if AvailableStrategies[nIndex1].RatingResult and ( AvailableStrategies[nIndex1].RatingResult.Status == 'Completed' or AvailableStrategies[nIndex1].RatingResult.Status == 'Not-Completed') then
if AvailableStrategies[nIndex1].RatingResult and ( AvailableStrategies[nIndex1].RatingResult.sStatus == 'Completed' or AvailableStrategies[nIndex1].RatingResult.sStatus == 'Not-Completed') then
dChosenIndex = nIndex1
end
elseif not AvailableStrategies[nIndex1].RatingResult or not AvailableStrategies[nIndex2].RatingResult then
dChosenIndex = 0
elseif ( AvailableStrategies[nIndex1].RatingResult.Status == 'Completed' and AvailableStrategies[nIndex2].RatingResult.Status ~= 'Completed') or
( AvailableStrategies[nIndex1].RatingResult.Status == 'Not-Completed' and AvailableStrategies[nIndex2].RatingResult.Status == 'Not-Applicable') then
elseif ( AvailableStrategies[nIndex1].RatingResult.sStatus == 'Completed' and AvailableStrategies[nIndex2].RatingResult.sStatus ~= 'Completed') or
( AvailableStrategies[nIndex1].RatingResult.sStatus == 'Not-Completed' and AvailableStrategies[nIndex2].RatingResult.sStatus == 'Not-Applicable') then
dChosenIndex = nIndex1
elseif ( AvailableStrategies[nIndex2].RatingResult.Status == 'Completed' and AvailableStrategies[nIndex1].RatingResult.Status ~= 'Completed') or
( AvailableStrategies[nIndex2].RatingResult.Status == 'Not-Completed' and AvailableStrategies[nIndex1].RatingResult.Status == 'Not-Applicable') then
elseif ( AvailableStrategies[nIndex2].RatingResult.sStatus == 'Completed' and AvailableStrategies[nIndex1].RatingResult.sStatus ~= 'Completed') or
( AvailableStrategies[nIndex2].RatingResult.sStatus == 'Not-Completed' and AvailableStrategies[nIndex1].RatingResult.sStatus == 'Not-Applicable') then
dChosenIndex = nIndex2
else
-- se le due strategie hanno stesso stato e sono entrambe applicabili (quindi entrambe complete o entrambe non-complete)
if AvailableStrategies[nIndex1].RatingResult.Status ~= 'Not-Applicable' and AvailableStrategies[nIndex2].RatingResult.Status ~= 'Not-Applicable' and
AvailableStrategies[nIndex1].RatingResult.Status == AvailableStrategies[nIndex2].RatingResult.Status then
local dCompositeRatingStrategy1 = AvailableStrategies[nIndex1].RatingResult.Rating + AvailableStrategies[nIndex1].RatingResult.CompletionIndex
local dCompositeRatingStrategy2 = AvailableStrategies[nIndex2].RatingResult.Rating + AvailableStrategies[nIndex2].RatingResult.CompletionIndex
if AvailableStrategies[nIndex1].RatingResult.sStatus ~= 'Not-Applicable' and AvailableStrategies[nIndex2].RatingResult.sStatus ~= 'Not-Applicable' and
AvailableStrategies[nIndex1].RatingResult.sStatus == AvailableStrategies[nIndex2].RatingResult.sStatus then
local dCompositeRatingStrategy1 = AvailableStrategies[nIndex1].RatingResult.dRating + AvailableStrategies[nIndex1].RatingResult.dCompletionIndex
local dCompositeRatingStrategy2 = AvailableStrategies[nIndex2].RatingResult.dRating + AvailableStrategies[nIndex2].RatingResult.dCompletionIndex
-- si predilige strategia con rating composito più alto
if dCompositeRatingStrategy1 > dCompositeRatingStrategy2 then
dChosenIndex = nIndex1
@@ -701,7 +701,7 @@ local function GetBestStrategy( vProcSingleRot, Part)
for i = 1, #vProcSingleRot do
-- processo tutte le feature attive
local Proc = vProcSingleRot[i]
if Proc.Flg ~= 0 then
if Proc.nFlg ~= 0 then
-- controllo se ci sono strategie disponibili
if Proc.AvailableStrategies and #Proc.AvailableStrategies > 0 then
local nIndexBestStrategy = 0
@@ -709,7 +709,7 @@ local function GetBestStrategy( vProcSingleRot, Part)
for nIndexCurrentStrategy = 1, #Proc.AvailableStrategies do
-- eseguo file config con i parametri di default
local CurrentStrategy = {}
CurrentStrategy = RunStrategyLibraries( Proc.AvailableStrategies[nIndexCurrentStrategy].StrategyId)
CurrentStrategy = RunStrategyLibraries( Proc.AvailableStrategies[nIndexCurrentStrategy].sStrategyId)
-- controllo che le librerie siano state effettivamente caricate
if CurrentStrategy.Config and CurrentStrategy.Script then
-- eseguo la strategia solo come calcolo fattibilità e voto. Non si applicano le lavorazioni. Si passa la Proc e i parametri personalizzati
@@ -721,7 +721,7 @@ local function GetBestStrategy( vProcSingleRot, Part)
-- se scelta strategia standard, esco subito alla prima che trovo completa
-- TODO serve paraemtro da Beam&Wall ( oppure da confirgurazione) !!!!!!!!
if BEAM.GetFirstCompletedStrategy and nIndexBestStrategy > 0 then
if Proc.AvailableStrategies[nIndexBestStrategy].RatingResult.Status == 'Complete' then
if Proc.AvailableStrategies[nIndexBestStrategy].RatingResult.sStatus == 'Complete' then
break
end
end
@@ -729,7 +729,7 @@ local function GetBestStrategy( vProcSingleRot, Part)
-- se non trovo i file della strategia, scrivo che non è più disponibile
else
Proc.AvailableStrategies[nIndexCurrentStrategy].RatingResult = {}
Proc.AvailableStrategies[nIndexCurrentStrategy].RatingResult.Info = 'Strategy not found'
Proc.AvailableStrategies[nIndexCurrentStrategy].RatingResult.sInfo = 'Strategy not found'
end
end
-- salvo sulla proc la migliore strategia
@@ -749,9 +749,9 @@ local function ExecPieceFeatures( vProc, Part)
for i = 1, #vProc do
-- processo tutte le feature attive applicando le lavorazioni
local Proc = vProc[i]
if Proc.Flg ~= 0 and Proc.ChosenStrategy then
if Proc.nFlg ~= 0 and Proc.ChosenStrategy then
-- carico file script strategia (non serve verificare presenza del file perchè già fatto durante scelta strategia)
local StrategyScriptName = Proc.ChosenStrategy.StrategyId .. '\\' .. Proc.ChosenStrategy.StrategyId
local StrategyScriptName = Proc.ChosenStrategy.sStrategyId .. '\\' .. Proc.ChosenStrategy.sStrategyId
local StrategyScript = require( StrategyScriptName)
-- eseguo la strategia e si applicano le lavorazioni. Si passa la Proc e i parametri personalizzati
Proc = StrategyScript.Make( true, Proc, Part, Proc.ChosenStrategy.Parameters)
@@ -766,13 +766,13 @@ local function PrintFeatures( vProc, Part)
for i = 1, #vProc do
local Proc = vProc[i]
local sOut = string.format( ' Id=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Down=%s Side=%s Head=%s Tail=%s Fcse=%1d,%1d Diam=%.2f Fct=%2d Box=%s TopoName=%s',
Proc.Id, Proc.Grp, Proc.Prc, Proc.TaskId, Proc.CutId,
Proc.Flg, EgtIf( Proc.Down, 'T', 'F'), EgtIf( Proc.Side, 'T', 'F'),
EgtIf( Proc.Head, 'T', 'F'), EgtIf( Proc.Tail, 'T', EgtIf( Proc.AdvTail, 'A', 'F')),
Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, tostring( Proc.Box), Proc.Topology.Name or '')
Proc.Id, Proc.nGrp, Proc.nPrc, Proc.idTask, Proc.idCut,
Proc.nFlg, EgtIf( Proc.bDown, 'T', 'F'), EgtIf( Proc.bSide, 'T', 'F'),
EgtIf( Proc.bHead, 'T', 'F'), EgtIf( Proc.bTail, 'T', EgtIf( Proc.bAdvTail, 'A', 'F')),
Proc.nFcs, Proc.nFce, Proc.dDiam, Proc.nFct, tostring( Proc.b3Box), Proc.Topology.sName or '')
-- info speciali per Block Haus Half Lap
if Proc.Prc == 37 then
local sSpec = string.format( ' N=%s Hd=%s', tostring( Proc.vtN or V_NULL()), EgtIf( Proc.HeadDir, 'T', 'F'))
if Proc.nPrc == 37 then
local sSpec = string.format( ' N=%s Hd=%s', tostring( Proc.vtN or V_NULL()), EgtIf( Proc.bHeadDir, 'T', 'F'))
sOut = sOut .. sSpec
end
EgtOutLog( sOut)
@@ -786,12 +786,12 @@ function BeamExec.ProcessFeatures()
local Stats = {}
local nOrd = 1
local Part = {}
Part.IdRaw = EgtGetFirstRawPart()
while Part.IdRaw do
Part.idRaw = EgtGetFirstRawPart()
while Part.idRaw do
-- verifico che il grezzo contenga pezzi oppure sia abbastanza lungo da essere scaricato coi carrelli
local nPartId = EgtGetFirstPartInRawPart( Part.IdRaw)
Part.RawBox = EgtGetRawPartBBox( Part.IdRaw)
if not nPartId and Part.RawBox:getDimX() < BeamData.MinRaw then break end
local nPartId = EgtGetFirstPartInRawPart( Part.idRaw)
Part.b3RawBox = EgtGetRawPartBBox( Part.idRaw)
if not nPartId and Part.b3RawBox:getDimX() < BeamData.dMinRaw then break end
-- per ogni rotazione, calcolo come lavorare le feature per decidere posizionamento iniziale e in che rotazione verranno lavorate le singole feature
local vProcRot = {}
@@ -816,19 +816,19 @@ function BeamExec.ProcessFeatures()
-- ruoto il grezzo per calcolare la fattibilità delle lavorazioni nella prossima rotazione
-- vettore movimento grezzi per rotazione di 90deg ogni step
local dDeltaYZ = Part.RawBox:getDimY() - Part.RawBox:getDimZ()
local dDeltaYZ = Part.b3RawBox:getDimY() - Part.b3RawBox:getDimZ()
local vtMove = Vector3d( 0, dDeltaYZ / 2 * EgtIf( BeamData.RIGHT_LOAD, -1, 1), dDeltaYZ / 2)
local bPreMove = ( dDeltaYZ < 0)
-- ruoto le travi della fase corrente
if bPreMove then
EgtMoveRawPart( Part.IdRaw, vtMove)
EgtMoveRawPart( Part.idRaw, vtMove)
end
EgtRotateRawPart( Part.IdRaw, X_AX(), EgtIf( BeamData.RIGHT_LOAD, -90, 90))
EgtRotateRawPart( Part.idRaw, X_AX(), EgtIf( BeamData.RIGHT_LOAD, -90, 90))
if not bPreMove then
EgtMoveRawPart( Part.IdRaw, vtMove)
EgtMoveRawPart( Part.idRaw, vtMove)
end
-- aggiorno info pezzo
Part.RawBox = EgtGetRawPartBBox( Part.IdRaw)
Part.b3RawBox = EgtGetRawPartBBox( Part.idRaw)
end
-- TODO da rimuovere o lasciare solo per debug
@@ -844,13 +844,13 @@ function BeamExec.ProcessFeatures()
if nOrd == 1 then
EgtSetCurrPhase( 1)
else
BeamLib.AddPhaseWithRawParts( Part, BeamData.OriXR, BeamData.PosXR, 0)
BeamLib.AddPhaseWithRawParts( Part, BeamData.ptOriXR, BeamData.dPosXR, 0)
end
local nPhase = EgtGetCurrPhase()
local nDispId = EgtGetPhaseDisposition( nPhase)
EgtSetInfo( nDispId, 'TYPE', EgtIf( nPartId, 'START', 'REST'))
EgtSetInfo( nDispId, 'ORD', nOrd)
EgtOutLog( ' *** Phase=' .. tostring( nPhase) .. ' Raw=' .. tostring( Part.IdRaw) .. ' Part=' .. tostring( nPartId) .. ' ***', 1)
EgtOutLog( ' *** Phase=' .. tostring( nPhase) .. ' Raw=' .. tostring( Part.idRaw) .. ' Part=' .. tostring( nPartId) .. ' ***', 1)
-- debug
if EgtGetDebugLevel() >= 1 then
@@ -878,7 +878,7 @@ function BeamExec.ProcessFeatures()
EgtOutLog( ' *** End AddMachinings ***', 1)
-- passo al grezzo successivo
nOrd = nOrd + 1
Part.IdRaw = EgtGetNextRawPart( Part.IdRaw)
Part.idRaw = EgtGetNextRawPart( Part.idRaw)
end
return ( nTotErr == 0), Stats