Merge branch 'STR0002_TimeEstimation' into develop

This commit is contained in:
luca.mazzoleni
2025-05-08 19:01:34 +02:00
5 changed files with 59 additions and 13 deletions
+19 -4
View File
@@ -190,7 +190,7 @@ function MachiningLib.GetSplitMachinings( Machinings, SplittingPoints, Part)
end
Machinings[nCurrentMachiningIndex].nFeatureSegment = j
Machinings[nCurrentMachiningIndex].dLengthToMachine = Machinings[nCurrentMachiningIndex].dEdgeLength + Machinings[nCurrentMachiningIndex].LeadIn.dStartAddLength + Machinings[nCurrentMachiningIndex].LeadOut.dEndAddLength
Machinings[nCurrentMachiningIndex].dTimeToMachine = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Machinings[nCurrentMachiningIndex])
Machinings[nCurrentMachiningIndex].dTimeToMachine = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Machinings[nCurrentMachiningIndex], Part)
end
-- anche le lavorazioni non splittate necessitano del segmento assegnato
else
@@ -220,7 +220,7 @@ function MachiningLib.GetSplitMachinings( Machinings, SplittingPoints, Part)
end
end
Machinings[i].dLengthToMachine = Machinings[i].dEdgeLength + Machinings[i].LeadIn.dStartAddLength + Machinings[i].LeadOut.dEndAddLength
Machinings[i].dTimeToMachine = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Machinings[i])
Machinings[i].dTimeToMachine = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Machinings[i], Part)
end
end
@@ -871,7 +871,7 @@ function MachiningLib.AddOperations( vProc, Part, sRotation)
nErr, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nOperationId, false)
-- update risultati
-- TODO è corretto mettere non applicabile?????
-- TODO è corretto mettere non applicabile????? disattivare e dare un'incompleta gialla?
RESULT[MACHININGS[i].Proc.nIndexInResult].ChosenStrategy.sStatus = 'Not-Applicable'
RESULT[MACHININGS[i].Proc.nIndexInResult].ChosenStrategy.sApplyInfo = sErr
RESULT[MACHININGS[i].Proc.nIndexInResult].ChosenStrategy.nApplyError = nErr
@@ -947,7 +947,7 @@ function MachiningLib.GetToolMRR( Parameters)
end
-------------------------------------------------------------------------------------------------------------
function MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Machining)
function MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Machining, Part)
local dLengthToMachineAllStepsWithLeadInOut = 0
local dTimeToMachineTotal = 0
local dToolStartFeed = TOOLS[Machining.nToolIndex].Feeds.dStartFeed
@@ -996,6 +996,21 @@ function MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Machining)
dLengthToMachineAllStepsWithLeadInOut = Machining.CloneStepsLongitudinal.nCount * ( ( 2 * Machining.Steps.nCount - 1) * Machining.dLengthToMachine + 2 * 10 * ( Machining.Steps.nCount - 1) + 2 * ( Machining.dDepthToMachine + ( TOOLS[Machining.nToolIndex].SetupInfo.dZSafeDelta or 60) + EgtMdbGetGeneralParam( MCH_GP.SAFEZ)))
dTimeToMachineTotal = Machining.CloneStepsLongitudinal.nCount * ( ( 2 * Machining.Steps.nCount - 1) * dTimeToMachineEdge + 2 * 10 / dToolFeed * ( Machining.Steps.nCount - 1) + dTimeToMachineLeadIn + dTimeToMachineLeadOut)
end
elseif Machining.nType == MCH_MY.POCKETING then
-- TODO le chiamate alla pocketing vanno unificate e uniformate
local dFaceElevation = EgtSurfTmFacetElevationInBBox( Machining.Geometry[1][1], Machining.Geometry[1][2], Part.b3Part, true, GDB_ID.ROOT)
local dDepthToMachine = min( dFaceElevation, ( Machining.dMaxElev or dFaceElevation)) - ( max( 0, Machining.dResidualDepth or 0))
local nSteps = ceil( ( dDepthToMachine - 50 * GEO.EPS_SMALL) / TOOLS[Machining.nToolIndex].dStep)
local _, dLongEdgeDimension, dShortEdgeDimension = EgtSurfTmFacetMinAreaRectangle( Machining.Geometry[1][1], Machining.Geometry[1][2], GDB_ID.ROOT)
-- TODO bisogna calcolare correttamente per lati aperti e chiusi (aperti: aggiungi D/2 - Sidestep, chiusi: sottrai - D/2)
local nOffsets = ceil ( ( dShortEdgeDimension - TOOLS[Machining.nToolIndex].dSideStep) / TOOLS[Machining.nToolIndex].dSideStep) + 1
for i = 1, floor( nOffsets / 2) do
dLengthToMachineAllStepsWithLeadInOut = dLengthToMachineAllStepsWithLeadInOut
+ 2 * ( dShortEdgeDimension - 2 * ( i - 1) * TOOLS[Machining.nToolIndex].dSideStep)
+ 2 * ( dLongEdgeDimension - 2 * ( i - 1) * TOOLS[Machining.nToolIndex].dSideStep)
end
dLengthToMachineAllStepsWithLeadInOut = dLengthToMachineAllStepsWithLeadInOut * nSteps
dTimeToMachineTotal = dLengthToMachineAllStepsWithLeadInOut / dToolFeed
else
error( 'GetTimeToMachineAllStepsWithLeadInOut : unknown machining type')
end
+35 -5
View File
@@ -363,7 +363,7 @@ local function GetBestPocketingStrategy( Proc)
end
-------------------------------------------------------------------------------------------------------------
local function GetSplitSurfaces( Proc, Part)
local function GetSplitSurfaces( Proc, Part, bAddMachining)
local vAddId = {}
local vAddIdTunnel = {}
local nAddGrpId = BeamLib.GetAddGroup( Part.id)
@@ -378,6 +378,10 @@ local function GetSplitSurfaces( Proc, Part)
if #FeatureSplittingPoints == 0 then
local nAddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL
local nAddIdTunnel = EgtCopyGlob( nOriginalTmIdTunnel, nAddGrpId) or GDB_ID.NULL
if not bAddMachining then
EgtSetLevel( nAddId, GDB_LV.TEMP)
EgtSetLevel( nAddIdTunnel, GDB_LV.TEMP)
end
table.insert( vAddId, nAddId)
table.insert( vAddIdTunnel, nAddIdTunnel)
else
@@ -399,6 +403,10 @@ local function GetSplitSurfaces( Proc, Part)
EgtCutSurfTmPlane( nAddId, ptSplit, X_AX(), true, GDB_RT.GLOB)
EgtCutSurfTmPlane( nAddIdTunnel, ptSplit, X_AX(), true, GDB_RT.GLOB)
end
if not bAddMachining then
EgtSetLevel( nAddId, GDB_LV.TEMP)
EgtSetLevel( nAddIdTunnel, GDB_LV.TEMP)
end
table.insert( vAddId, nAddId)
table.insert( vAddIdTunnel, nAddIdTunnel)
end
@@ -408,6 +416,10 @@ local function GetSplitSurfaces( Proc, Part)
local ptSplit = FeatureSplittingPoints[#FeatureSplittingPoints] + Vector3d( BeamData.MILL_OVERLAP / 2, 0, 0)
EgtCutSurfTmPlane( nAddId, ptSplit, X_AX(), true, GDB_RT.GLOB)
EgtCutSurfTmPlane( nAddIdTunnel, ptSplit, X_AX(), true, GDB_RT.GLOB)
if not bAddMachining then
EgtSetLevel( nAddId, GDB_LV.TEMP)
EgtSetLevel( nAddIdTunnel, GDB_LV.TEMP)
end
table.insert( vAddId, nAddId)
table.insert( vAddIdTunnel, nAddIdTunnel)
end
@@ -416,6 +428,7 @@ local function GetSplitSurfaces( Proc, Part)
end
-------------------------------------------------------------------------------------------------------------
-- TODO rimuovere il calcolo MRR dove non serve, è fatto tutto alla fine.
function STR0002.Make( bAddMachining, Proc, Part, CustomParameters)
-- carico parametri de default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti)
local StrategyLib = {}
@@ -424,6 +437,7 @@ function STR0002.Make( bAddMachining, Proc, Part, CustomParameters)
Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config)
Strategy.Machining = {}
Strategy.Result = {}
Strategy.Result.dTimeToMachine = 0
if not IsTopologyOk( Proc) then
local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. StrategyLib.Config.sStrategyId .. ' not implemented'
@@ -433,17 +447,18 @@ function STR0002.Make( bAddMachining, Proc, Part, CustomParameters)
end
local bAreAllMachiningsAdded = true
local dFeatureVolume = FeatureLib.GetFeatureVolume( Proc, Part)
local ToolInfo = {}
local Pocketing = {}
Strategy.Machining = GetBestPocketingStrategy( Proc)
if bAddMachining and Strategy.Result.sStatus ~= 'Not-Applicable' then
if Strategy.Result.sStatus ~= 'Not-Applicable' then
local vAddId = {}
local vAddIdTunnel = {}
-- recupero superficie, se necessario trimmata sugli spezzoni
vAddId, vAddIdTunnel = GetSplitSurfaces( Proc, Part)
vAddId, vAddIdTunnel = GetSplitSurfaces( Proc, Part, bAddMachining)
-- si applicano le lavorazioni
for i = 1, #vAddId do
@@ -461,6 +476,7 @@ function STR0002.Make( bAddMachining, Proc, Part, CustomParameters)
Pocketing.LeadIn.dTangentDistance = TOOLS[Strategy.Machining[j].ToolInfo.nToolIndex].dDiameter/2
Pocketing.LeadIn.dElevation = TOOLS[Strategy.Machining[j].ToolInfo.nToolIndex].dDiameter/2
Pocketing.sDepth = -Strategy.Machining[j].ToolInfo.dResidualDepth
Pocketing.dResidualDepth = Strategy.Machining[j].ToolInfo.dResidualDepth
-- il quarto ciclo è la lavorazione opposta sulla faccia Tunnel
if Strategy.Machining[j].bToolInvert then
Pocketing.bToolInvert = true
@@ -477,7 +493,13 @@ function STR0002.Make( bAddMachining, Proc, Part, CustomParameters)
if Proc.AffectedFaces.bLeft then
Pocketing.sStage = 'AfterTail'
end
bAreAllMachiningsAdded = MachiningLib.AddMachinings( Proc, Pocketing)
Pocketing.dTimeToMachine = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Pocketing, Part)
Strategy.Result.dTimeToMachine = Strategy.Result.dTimeToMachine + Pocketing.dTimeToMachine
if bAddMachining then
bAreAllMachiningsAdded = MachiningLib.AddMachinings( Proc, Pocketing)
end
else
-- TODO controllare parametro danneggiamento ammesso per decidere se spostare dopo taglio seprazione
-- se è aperta sulla coda, dico che deve essere fatta dopo la separazione
@@ -494,7 +516,13 @@ function STR0002.Make( bAddMachining, Proc, Part, CustomParameters)
end
if vtNSplitFace and AreSameVectorApprox( vtNSplitFace * EgtIf( Pocketing.bToolInvert, -1, 1), Strategy.Machining[j].vtFaceNormal) then
Pocketing.Geometry = {{ nIdTm, k - 1}}
bAreAllMachiningsAdded = bAreAllMachiningsAdded and MachiningLib.AddMachinings( Proc, Pocketing)
Pocketing.dTimeToMachine = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Pocketing, Part)
Strategy.Result.dTimeToMachine = Strategy.Result.dTimeToMachine + Pocketing.dTimeToMachine
if bAddMachining then
bAreAllMachiningsAdded = bAreAllMachiningsAdded and MachiningLib.AddMachinings( Proc, Pocketing)
end
break
end
end
@@ -502,6 +530,8 @@ function STR0002.Make( bAddMachining, Proc, Part, CustomParameters)
end
end
end
-- TODO se incompleta il volume non è corretto, ma conta? L'MRR ha senso nelle incomplete??
Strategy.Result.dMRR = ( dFeatureVolume / Strategy.Result.dTimeToMachine) / pow( 10, 6)
else
bAreAllMachiningsAdded = false
end
+3 -2
View File
@@ -80,7 +80,8 @@ local function CalculateLeadInOut( Machining, EdgeToMachine, Part)
LeadOut.dTangentDistance = 0
if Machining.bIsStartClosed
or Machining.bIsEndClosed
or Machining.CloneStepsRadial.nCount > 1 then
or Machining.CloneStepsRadial.nCount > 1
or Machining.Steps.nCount > 1 then
Machining.sLeadInOutType = 'Perpendicular'
if AreSameVectorApprox( Machining.vtToolDirection, EdgeToMachine.vtN) then
@@ -378,7 +379,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar
Cutting.dLengthToMachine = EdgeToMachine.dLength + Cutting.LeadIn.dStartAddLength + Cutting.LeadOut.dEndAddLength
local b3BoxEdge = BBox3d( Cutting.ptEdge1, Cutting.ptEdge2)
Cutting.dLengthOnX = b3BoxEdge:getDimX()
Cutting.dTimeToMachine, Cutting.dLengthToMachineAllStepsWithLeadInOut = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Cutting)
Cutting.dTimeToMachine, Cutting.dLengthToMachineAllStepsWithLeadInOut = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Cutting, Part)
-- lunghezza impronta lama
if Cutting.bIsStartClosed and Cutting.bIsEndClosed then
Cutting.dToolMarkLength = abs( min( Cutting.LeadIn.dStartAddLength, Cutting.LeadOut.dEndAddLength))
+1 -1
View File
@@ -215,7 +215,7 @@ function FACEBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional
-- TODO fare funzione EstimatePathLength o simile
Mortising.dLengthToMachine = Mortising.dEdgeLength + Mortising.LeadIn.dStartAddLength + Mortising.LeadOut.dEndAddLength
Mortising.dLengthOnX = abs( dLengthToMachine * EdgeToMachine.vtN:getY())
Mortising.dTimeToMachine, Mortising.dLengthToMachineAllStepsWithLeadInOut = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Mortising)
Mortising.dTimeToMachine, Mortising.dLengthToMachineAllStepsWithLeadInOut = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Mortising, Part)
-- area lavorata
Mortising.dAreaToMachine = min( EdgeToMachine.dElevation, Mortising.dDepthToMachine) * ( min( Mortising.dEdgeLength, Mortising.dLengthToMachine + TOOLS[Mortising.nToolIndex].dDiameter))
-- geometria
+1 -1
View File
@@ -379,7 +379,7 @@ function FACEBYMILL.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPara
Milling.dLengthToMachine = EdgeToMachine.dLength + Milling.LeadIn.dStartAddLength + Milling.LeadOut.dEndAddLength
local b3BoxEdge = BBox3d( Milling.ptEdge1, Milling.ptEdge2)
Milling.dLengthOnX = b3BoxEdge:getDimX()
Milling.dTimeToMachine, Milling.dLengthToMachineAllStepsWithLeadInOut = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Milling)
Milling.dTimeToMachine, Milling.dLengthToMachineAllStepsWithLeadInOut = MachiningLib.GetTimeToMachineAllStepsWithLeadInOut( Milling, Part)
-- lunghezza impronta lama
if Milling.bIsStartClosed and Milling.bIsEndClosed then
Milling.dToolMarkLength = abs( min( Milling.LeadIn.dStartAddLength, Milling.LeadOut.dEndAddLength))