Merge branch 'NewMachiningOrder' into develop
This commit is contained in:
+145
-149
@@ -968,7 +968,7 @@ local function AddNewMachining( ProcToAdd, MachiningToAdd, AuxiliaryDataToAdd)
|
||||
nHeadCutRotation = 3
|
||||
elseif ProcToAdd.bSide then
|
||||
nHeadCutRotation = 2
|
||||
else
|
||||
else -- ProcToAdd.bStd
|
||||
nHeadCutRotation = 1
|
||||
end
|
||||
MACHININGS.Info.nHeadCutRotation = max( MACHININGS.Info.nHeadCutRotation or 0, nHeadCutRotation)
|
||||
@@ -978,7 +978,7 @@ local function AddNewMachining( ProcToAdd, MachiningToAdd, AuxiliaryDataToAdd)
|
||||
nSplitCutRotation = 3
|
||||
elseif ProcToAdd.bSide and MachiningToAdd.sStage == 'AfterTail' then
|
||||
nSplitCutRotation = 2
|
||||
else
|
||||
else -- ProcToAdd.bStd
|
||||
nSplitCutRotation = 1
|
||||
end
|
||||
MACHININGS.Info.nSplitCutRotation = max( MACHININGS.Info.nSplitCutRotation or 0, nSplitCutRotation)
|
||||
@@ -1108,17 +1108,20 @@ function MachiningLib.AddOperations( vProc, Part, sRotation)
|
||||
|
||||
for i = 1, #MACHININGS do
|
||||
-- si aggiungono solo quelle della fase richiesta
|
||||
if ( sRotation == 'STD' and not MACHININGS[i].Proc.bDown and not MACHININGS[i].Proc.bSide) or
|
||||
if ( MACHININGS[i].Proc.bStd and sRotation == 'STD') or
|
||||
( MACHININGS[i].Proc.bDown and sRotation == 'DOWN') or
|
||||
( MACHININGS[i].Proc.bSide and sRotation == 'SIDE') then
|
||||
local nClonesToAdd = 1
|
||||
if MACHININGS[i].AuxiliaryData.Clones then
|
||||
nClonesToAdd = #MACHININGS[i].AuxiliaryData.Clones
|
||||
end
|
||||
-- dati da salvare dopo applicazione della lavorazione
|
||||
MACHININGS[i].Machining.MachStartAxesPos = {}
|
||||
MACHININGS[i].Machining.MachEndAxesPos = {}
|
||||
MACHININGS[i].Machining.nOperationId = {}
|
||||
for j = 1, nClonesToAdd do
|
||||
-- creazione lavorazione
|
||||
local nOperationId = EgtCreateMachining( MACHININGS[i].Machining.sOperationName, MACHININGS[i].Machining.nType, MACHININGS[i].Machining.sToolName)
|
||||
|
||||
if nOperationId then
|
||||
-- impostazione geometria
|
||||
local Geometry
|
||||
@@ -1216,6 +1219,16 @@ function MachiningLib.AddOperations( vProc, Part, sRotation)
|
||||
end
|
||||
|
||||
local bIsApplyOk = MachiningLib.ApplyMachining( true, false)
|
||||
|
||||
-- si salva sulla lista info lavorazione applicata
|
||||
local MachExtraInfo = { sType = 'MACH',
|
||||
nIndexInMachinings = i,
|
||||
nOperationId = nOperationId,
|
||||
MachStartAxesPos = EgtGetMachiningStartAxes(),
|
||||
MachEndAxesPos = EgtGetMachiningEndAxes()}
|
||||
table.insert( DB_MACH_APPLIED, MachExtraInfo)
|
||||
|
||||
-- se errore in applicazione
|
||||
if not bIsApplyOk then
|
||||
bAreAllMachiningApplyOk = false
|
||||
nErr, sErr = EgtGetLastMachMgrError()
|
||||
@@ -1225,36 +1238,40 @@ function MachiningLib.AddOperations( vProc, Part, sRotation)
|
||||
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
|
||||
-- se non deve essere igniorato, si salva ingombro lavorazione attuale e fasi successive
|
||||
elseif not MACHININGS[i].AuxiliaryData.bIgnoreNotClampableLength then
|
||||
-- salvo ingombro non pinzabile testa/coda
|
||||
local nCurrRotation = MACHININGS[i].Proc.nIndexRotation
|
||||
local dNotClampHead, dNotClampTail = FeatureLib.GetFeatureRotationNotClampableLengths( MACHININGS[i].Proc, Part, nCurrRotation)
|
||||
Part.NotClampableLength[sRotation].dHead = max( Part.NotClampableLength[sRotation].dHead, dNotClampHead)
|
||||
Part.NotClampableLength[sRotation].dTail = max( Part.NotClampableLength[sRotation].dTail, dNotClampTail)
|
||||
-- se applicazione andata a buon fine
|
||||
else
|
||||
|
||||
if sRotation == 'DOWN' then
|
||||
-- se non deve essere igniorato, si salva ingombro lavorazione attuale e fasi successive
|
||||
if not MACHININGS[i].AuxiliaryData.bIgnoreNotClampableLength then
|
||||
-- salvo ingombro non pinzabile testa/coda
|
||||
local nCurrRotation = MACHININGS[i].Proc.nIndexRotation
|
||||
local dNotClampHead, dNotClampTail = FeatureLib.GetFeatureRotationNotClampableLengths( MACHININGS[i].Proc, Part, nCurrRotation)
|
||||
Part.NotClampableLength[sRotation].dHead = max( Part.NotClampableLength[sRotation].dHead, dNotClampHead)
|
||||
Part.NotClampableLength[sRotation].dTail = max( Part.NotClampableLength[sRotation].dTail, dNotClampTail)
|
||||
|
||||
if sRotation == 'DOWN' then
|
||||
local nNextRotation = EgtIf( nCurrRotation - 1 < 1, nCurrRotation - 1 + 4, nCurrRotation - 1)
|
||||
-- se rotazione attiva (SIDE)
|
||||
if string.sub( Part.ChosenCombination, nNextRotation, nNextRotation) == '1' then
|
||||
dNotClampHead, dNotClampTail = FeatureLib.GetFeatureRotationNotClampableLengths( MACHININGS[i].Proc, Part, nNextRotation)
|
||||
Part.NotClampableLength['SIDE'].dHead = max( Part.NotClampableLength['SIDE'].dHead, dNotClampHead)
|
||||
Part.NotClampableLength['SIDE'].dTail = max( Part.NotClampableLength['SIDE'].dTail, dNotClampTail)
|
||||
end
|
||||
nNextRotation = EgtIf( nNextRotation - 1 < 1, nNextRotation - 1 + 4, nNextRotation - 1)
|
||||
-- se rotazione attiva (STD)
|
||||
if string.sub( Part.ChosenCombination, nNextRotation, nNextRotation) == '1' then
|
||||
dNotClampHead, dNotClampTail = FeatureLib.GetFeatureRotationNotClampableLengths( MACHININGS[i].Proc, Part, nNextRotation)
|
||||
Part.NotClampableLength['STD'].dHead = max( Part.NotClampableLength['STD'].dHead, dNotClampHead)
|
||||
Part.NotClampableLength['STD'].dTail = max( Part.NotClampableLength['STD'].dTail, dNotClampTail)
|
||||
end
|
||||
elseif sRotation == 'SIDE' then
|
||||
local nNextRotation = EgtIf( nCurrRotation - 1 < 1, nCurrRotation - 1 + 4, nCurrRotation - 1)
|
||||
-- se rotazione attiva (SIDE)
|
||||
if string.sub( Part.ChosenCombination, nNextRotation, nNextRotation) == '1' then
|
||||
dNotClampHead, dNotClampTail = FeatureLib.GetFeatureRotationNotClampableLengths( MACHININGS[i].Proc, Part, nNextRotation)
|
||||
Part.NotClampableLength['SIDE'].dHead = max( Part.NotClampableLength['SIDE'].dHead, dNotClampHead)
|
||||
Part.NotClampableLength['SIDE'].dTail = max( Part.NotClampableLength['SIDE'].dTail, dNotClampTail)
|
||||
end
|
||||
nNextRotation = EgtIf( nNextRotation - 1 < 1, nNextRotation - 1 + 4, nNextRotation - 1)
|
||||
-- se rotazione attiva (STD)
|
||||
if string.sub( Part.ChosenCombination, nNextRotation, nNextRotation) == '1' then
|
||||
dNotClampHead, dNotClampTail = FeatureLib.GetFeatureRotationNotClampableLengths( MACHININGS[i].Proc, Part, nNextRotation)
|
||||
Part.NotClampableLength['STD'].dHead = max( Part.NotClampableLength['STD'].dHead, dNotClampHead)
|
||||
Part.NotClampableLength['STD'].dTail = max( Part.NotClampableLength['STD'].dTail, dNotClampTail)
|
||||
end
|
||||
elseif sRotation == 'SIDE' then
|
||||
local nNextRotation = EgtIf( nCurrRotation - 1 < 1, nCurrRotation - 1 + 4, nCurrRotation - 1)
|
||||
-- se rotazione attiva (STD)
|
||||
if string.sub( Part.ChosenCombination, nNextRotation, nNextRotation) == '1' then
|
||||
dNotClampHead, dNotClampTail = FeatureLib.GetFeatureRotationNotClampableLengths( MACHININGS[i].Proc, Part, nNextRotation)
|
||||
Part.NotClampableLength['STD'].dHead = max( Part.NotClampableLength['STD'].dHead, dNotClampHead)
|
||||
Part.NotClampableLength['STD'].dTail = max( Part.NotClampableLength['STD'].dTail, dNotClampTail)
|
||||
-- se rotazione attiva (STD)
|
||||
if string.sub( Part.ChosenCombination, nNextRotation, nNextRotation) == '1' then
|
||||
dNotClampHead, dNotClampTail = FeatureLib.GetFeatureRotationNotClampableLengths( MACHININGS[i].Proc, Part, nNextRotation)
|
||||
Part.NotClampableLength['STD'].dHead = max( Part.NotClampableLength['STD'].dHead, dNotClampHead)
|
||||
Part.NotClampableLength['STD'].dTail = max( Part.NotClampableLength['STD'].dTail, dNotClampTail)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1550,19 +1567,6 @@ end
|
||||
-- TODO libreria Sorting??
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local SortingComparisonRules = {
|
||||
-- ordine interno alla feature
|
||||
function( MachiningA, MachiningB)
|
||||
if MachiningA.Proc.id == MachiningB.Proc.id then
|
||||
if MachiningA.Machining.nFeatureInternalIndex < MachiningB.Machining.nFeatureInternalIndex then
|
||||
return 1
|
||||
elseif MachiningA.Machining.nFeatureInternalIndex > MachiningB.Machining.nFeatureInternalIndex then
|
||||
return -1
|
||||
end
|
||||
end
|
||||
|
||||
return 0
|
||||
end,
|
||||
|
||||
-- dipendenze solo spostamento stage 2->4
|
||||
-- TODO da fare
|
||||
|
||||
@@ -1576,110 +1580,6 @@ local SortingComparisonRules = {
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
|
||||
-- dipendenze
|
||||
-- TODO da fare
|
||||
|
||||
-- segment
|
||||
function ( MachiningA, MachiningB)
|
||||
if MachiningA.Machining.nPartSegment < MachiningB.Machining.nPartSegment then
|
||||
return 1
|
||||
elseif MachiningA.Machining.nPartSegment > MachiningB.Machining.nPartSegment then
|
||||
return -1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
|
||||
-- testa
|
||||
-- TODO da fare
|
||||
|
||||
-- famiglia utensile
|
||||
function ( MachiningA, MachiningB)
|
||||
-- TODO tirare fuori da qua??
|
||||
local ToolFamilyOrder = {
|
||||
SAWBLADE = 1,
|
||||
DRILLBIT = 2,
|
||||
MILL = 3,
|
||||
MORTISE = 4
|
||||
}
|
||||
local nToolFamilyOrderA = ToolFamilyOrder[ TOOLS[ MachiningA.Machining.nToolIndex].sFamily]
|
||||
local nToolFamilyOrderB = ToolFamilyOrder[ TOOLS[ MachiningB.Machining.nToolIndex].sFamily]
|
||||
|
||||
if nToolFamilyOrderA < nToolFamilyOrderB then
|
||||
return 1
|
||||
elseif nToolFamilyOrderA > nToolFamilyOrderB then
|
||||
return -1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
|
||||
-- performance utensile
|
||||
function( MachiningA, MachiningB)
|
||||
local dToolPerformanceIndexA = TOOLS[MachiningA.Machining.nToolIndex].dPerformanceIndex
|
||||
local dToolPerformanceIndexB = TOOLS[MachiningB.Machining.nToolIndex].dPerformanceIndex
|
||||
|
||||
if dToolPerformanceIndexA > dToolPerformanceIndexB then
|
||||
return 1
|
||||
elseif dToolPerformanceIndexA < dToolPerformanceIndexB then
|
||||
return -1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
|
||||
-- probabilmente arrivati qui significa che gli utensili A e B sono gli stessi
|
||||
-- se così non fosse e tutte le caratteristiche sopra sono uguali, ordine alfabetico
|
||||
function( MachiningA, MachiningB)
|
||||
local sToolNameA = TOOLS[MachiningA.Machining.nToolIndex].sName
|
||||
local sToolNameB = TOOLS[MachiningB.Machining.nToolIndex].sName
|
||||
|
||||
if sToolNameA < sToolNameB then
|
||||
return 1
|
||||
elseif sToolNameA > sToolNameB then
|
||||
return -1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
|
||||
-- lato di lavoro
|
||||
-- TODO questo, insieme all'ordinamento X, andrà sostituito dallo shortest path pesato sulla quantità di rotazione della testa
|
||||
function( MachiningA, MachiningB)
|
||||
if MachiningA.Machining.vtToolDirection:getY() < -0.174 and MachiningB.Machining.vtToolDirection:getY() >= 0.174 then
|
||||
return 1
|
||||
elseif MachiningA.Machining.vtToolDirection:getY() >= 0.174 and MachiningB.Machining.vtToolDirection:getY() < -0.174 then
|
||||
return -1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
|
||||
-- ordinamento X
|
||||
-- TODO questo andrà sostituito dallo shortest path pesato sulla quantità di rotazione della testa
|
||||
function( MachiningA, MachiningB)
|
||||
local bIsMachiningOnFront = MachiningA.Machining.vtToolDirection:getY() < 10 * GEO.EPS_SMALL
|
||||
local nResult = 0
|
||||
|
||||
-- se lavorazione davanti ordine testa->coda
|
||||
if bIsMachiningOnFront then
|
||||
if MachiningA.Machining.ptCenter:getX() > MachiningB.Machining.ptCenter:getX() + 10 * GEO.EPS_SMALL then
|
||||
nResult = 1
|
||||
elseif MachiningA.Machining.ptCenter:getX() < MachiningB.Machining.ptCenter:getX() - 10 * GEO.EPS_SMALL then
|
||||
nResult = -1
|
||||
end
|
||||
-- se lavorazione dietro ordine coda->testa
|
||||
else
|
||||
if MachiningA.Machining.ptCenter:getX() < MachiningB.Machining.ptCenter:getX() - 10 * GEO.EPS_SMALL then
|
||||
nResult = 1
|
||||
elseif MachiningA.Machining.ptCenter:getX() > MachiningB.Machining.ptCenter:getX() + 10 * GEO.EPS_SMALL then
|
||||
nResult = -1
|
||||
end
|
||||
end
|
||||
|
||||
return nResult
|
||||
end
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
@@ -1696,5 +1596,101 @@ function MachiningLib.CompareMachinings( MachiningA, MachiningB)
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function OrderMachining( MachiningOptList)
|
||||
-- Recupero l'identificativo del gruppo di lavoro corrente
|
||||
for i = 1, #MachiningOptList - 1 do
|
||||
local idSource = DB_MACH_APPLIED[MachiningOptList[i+1]].nOperationId
|
||||
local idRef = DB_MACH_APPLIED[MachiningOptList[i]].nOperationId
|
||||
EgtRelocateGlob( idSource, idRef, GDB_IN.AFTER)
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function MachiningLib.ShortestPathSorting()
|
||||
-- verificare se serve settare prima e ultima lavorazione
|
||||
-- EgtOptMachSetFirstMachining( int nId)
|
||||
-- EgtOptMachSetLastMachining( int nId)
|
||||
|
||||
local nStartIndex
|
||||
local i = 1
|
||||
while i <= #DB_MACH_APPLIED do
|
||||
local nMachInDisp = 0
|
||||
local MachiningOptList = {}
|
||||
|
||||
-- se è una lavorazione
|
||||
if DB_MACH_APPLIED[i].sType ~= 'DISP' then
|
||||
-- inizio
|
||||
nStartIndex = i
|
||||
EgtOptMachInit()
|
||||
|
||||
-- leggere feed dalla macchina
|
||||
EgtOptMachSetFeeds( 10000, 2000)
|
||||
|
||||
-- tra gruppi (stage) non si può ottimizzare
|
||||
EgtOptMachSetAllGroupsDependencesAsMandatory( true)
|
||||
|
||||
-- se è una lavorazione
|
||||
while DB_MACH_APPLIED[i] and DB_MACH_APPLIED[i].sType ~= 'DISP' do
|
||||
-- aggiungo lavorazioni
|
||||
local nToolIndex = MACHININGS[DB_MACH_APPLIED[i].nIndexInMachinings].Machining.nToolIndex
|
||||
EgtOptMachAddTool( nToolIndex, 2, 2) -- , [ num dTC_X, num dTC_Y, num dTC_Z, num dTC_A, num dTC_B, num dTC_C])
|
||||
-- viene eseguito prima il gruppo con indice più alto, quindi si inverte indice dato che lo stage è dal più piccolo al più grande
|
||||
local nOperationId = DB_MACH_APPLIED[i].nOperationId
|
||||
local nGroup = 10 - MACHININGS[DB_MACH_APPLIED[i].nIndexInMachinings].Machining.nStage
|
||||
local MachStartAxesPos = DB_MACH_APPLIED[i].MachStartAxesPos
|
||||
local MachEndAxesPos = DB_MACH_APPLIED[i].MachEndAxesPos
|
||||
EgtOptMachAddMachining( i, nToolIndex, nGroup, MachStartAxesPos, MachEndAxesPos)
|
||||
table.insert( MachiningOptList, i)
|
||||
|
||||
nMachInDisp = nMachInDisp + 1
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
local nStopIndex = nStartIndex + nMachInDisp - 1
|
||||
-- cliclo su tutte le lavorazioni
|
||||
for k = nStartIndex, nStopIndex do
|
||||
for j = nStartIndex, nStopIndex do
|
||||
-- se non è stessa lavorazione, imposto dati e dipendenze
|
||||
if k ~= j then
|
||||
-- se stessa Proc
|
||||
if MACHININGS[DB_MACH_APPLIED[k].nIndexInMachinings].Proc.id == MACHININGS[DB_MACH_APPLIED[j].nIndexInMachinings].Proc.id then
|
||||
-- se lavorazioni della stessa feature, obbligatorio rispettare ordine
|
||||
if MACHININGS[DB_MACH_APPLIED[k].nIndexInMachinings].Machining.nFeatureInternalIndex < MACHININGS[DB_MACH_APPLIED[j].nIndexInMachinings].Machining.nFeatureInternalIndex then
|
||||
EgtOptMachAddDependence( k, j)
|
||||
end
|
||||
-- se tra due Proc diverse
|
||||
else
|
||||
-- TODO :
|
||||
-- se ci sono dipendenze tra due feature diverse, la dipendenza è obbligatoria! ATTENZIONE A DIPENDENZE INCROCIATE A->B, B->C, C->A
|
||||
|
||||
-- se in diversa rotazione dipendenza obbligatoria
|
||||
if MACHININGS[DB_MACH_APPLIED[k].nIndexInMachinings].Proc.bDown and ( MACHININGS[DB_MACH_APPLIED[j].nIndexInMachinings].Proc.bStd or MACHININGS[DB_MACH_APPLIED[j].nIndexInMachinings].Proc.bSide) then
|
||||
EgtOptMachAddDependence( k, j)
|
||||
elseif MACHININGS[DB_MACH_APPLIED[k].nIndexInMachinings].Proc.bSide and MACHININGS[DB_MACH_APPLIED[j].nIndexInMachinings].Proc.bStd then
|
||||
EgtOptMachAddDependence( k, j)
|
||||
-- dipendenza suggerita se sono su segmenti diversi (non sempre il segmento è settato)
|
||||
elseif MACHININGS[DB_MACH_APPLIED[k].nIndexInMachinings].Machining.nPartSegment < MACHININGS[DB_MACH_APPLIED[j].nIndexInMachinings].Machining.nPartSegment then
|
||||
EgtOptMachAddSuggestedDependence( k, j)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- calcolo ordine lavorazioni
|
||||
MachiningOptList = EgtOptMachGetResult( MachiningOptList)
|
||||
|
||||
OrderMachining( MachiningOptList)
|
||||
|
||||
-- fine
|
||||
EgtOptMachTerminate()
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
return MachiningLib
|
||||
|
||||
Reference in New Issue
Block a user