From 1102a7c23a86117a19ab8f8367a835796b3a6a88 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 24 May 2023 17:45:28 +0200 Subject: [PATCH] =?UTF-8?q?-aggiunta=20possibilit=C3=A0=20di=20scegliere?= =?UTF-8?q?=20l'ordine=20del=20sorting=20crescente=20o=20decrescente=20-ma?= =?UTF-8?q?nca=20costante=20da=20WD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/WallExec.lua | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) 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)