diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index c96a022..7fa059a 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -645,17 +645,35 @@ function WallExec.ProcessFeatures() local nPhase = 1 local PrevMch = EgtGetPhaseDisposition( nPhase) - local vPriority = {} - local nOperId = EgtGetNextOperation( PrevMch) - local nCurrentPriorityId = 1 - while nOperId do - local nPriority = EgtGetInfo( nOperId or GDB_ID.NULL, 'PRIORITY', 'i') - if nPriority and nPriority ~= 0 then vPriority[nCurrentPriorityId] = nPriority end - nCurrentPriorityId = nCurrentPriorityId + 1 - nOperId = EgtGetNextOperation( nOperId) - end - for i = 1, #vPriority do - PrevMch = SortMachinings( nPhase, PrevMch, nil, vPriority[i]) + -- abilitazione ordinamento con priorità da btl: 0 = no, 1 = ordine crescente, 2 = ordine decrescente + -- le lavorazioni con priorità 0 o senza priorità saranno lasciate per ultime + local nGetPriorityFromBtl = 2 -- TEMP qua costante da WallData!! + if nGetPriorityFromBtl > 0 then + local vPriority = {} + local nOperId = EgtGetNextOperation( PrevMch) + local nCurrentPriorityId = 1 + while nOperId do + local nPriority = EgtGetInfo( nOperId or GDB_ID.NULL, 'PRIORITY', 'i') + if nPriority and nPriority ~= 0 then + vPriority[nCurrentPriorityId] = nPriority + nCurrentPriorityId = nCurrentPriorityId + 1 + end + nOperId = EgtGetNextOperation( nOperId) + end + -- sorting delle priorità + -- ordine crescente + if nGetPriorityFromBtl == 1 then + table.sort( vPriority) + -- ordine decrescente + else + table.sort( vPriority, function( a, b) return a > b end) + end + -- riordino le lavorazioni per priorità + for i = 1, #vPriority do + -- if i == 1 or ( vPriority[i] ~= vPriority[i - 1]) then + PrevMch = SortMachinings( nPhase, PrevMch, nil, vPriority[i]) + -- end + end end SortMachinings( nPhase, PrevMch)