diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index a287c60..8a2c12e 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -105,11 +105,6 @@ local dRawH local function GetDataConfig() -- recupero utensili dal magazzino BeamExec.GetToolsFromDB() - -- se si utilizza interfaccia B&W, si carica il file JSON - local bIsBeamWall = BEAM.BW - if bIsBeamWall then - BeamExec.GetStrategiesFromJSONinBD() - end -- TODO da gestire eventuali errori bloccanti return true end @@ -421,6 +416,9 @@ if bToProcess then end end + -- recupero parametri generali da progetto + BeamExec.GetGeneralParameters() + -- Se devo creare la barra if bCreateBar then if #PARTS == 0 then @@ -576,13 +574,24 @@ if bToProcess then PARTS[i].dHeight = PARTS[i].b3Part:getDimZ() PARTS[i].bSquareSection = abs( PARTS[i].dWidth - PARTS[i].dHeight) < 100 * GEO.EPS_SMALL PARTS[i].nIndexInParts = i - PARTS[i].CombinationList = BeamExec.GetAvailableCombinations( PARTS[i], bCalcBestPieceUnloadPosition) PARTS[i].SplittingPoints = BeamLib.GetPartSplittingPoints( PARTS[i]) PARTS[i].NotClampableLength = { STD = { dHead = 0, dTail = 0}, SIDE = { dHead = 0, dTail = 0}, DOWN = { dHead = 0, dTail = 0}} + PARTS[i].sBTLInfo = EgtGetInfo( PARTS[i].id, 'PROJ', 's') or nil + + -- TODO LE INFO BTL ci devono sempre essere!! ripristinare dopo aver sistemato lettura da BtlInfo + --PARTS[i].sAISetupConfig = EgtGetInfo( PARTS[i].id, 'AISETUP', 's') or GENERAL_PARAMETERS.BTL[PARTS[i].sBTLInfo].sAISetupConfig or GENERAL_PARAMETERS.PROJECT.sAISetupConfig or nil + PARTS[i].sAISetupConfig = EgtGetInfo( PARTS[i].id, 'AISETUP', 's') or GENERAL_PARAMETERS.PROJECT.sAISetupConfig or nil + + + -- si carica configurazione lavorazioni + BeamExec.GetStrategiesFromJSONinBD( PARTS[i].sAISetupConfig) + PARTS[i].GeneralParameters = BeamLib.GetPieceGeneralParameters( PARTS[i], GENERAL_PARAMETERS_JSON) + PARTS[i].CombinationList = BeamExec.GetAvailableCombinations( PARTS[i], bCalcBestPieceUnloadPosition) -- sovramateriale in testa al pezzo local dDeltaS = max( PARTS[i].dPosX - ( dBarLen - dLen), 0) PARTS[i].dHeadOverMaterial = dDeltaS + -- lunghezza grezzo (comprende sovramateriale di testa e mm tagliati in coda dalla lavorazione, tipicamente 5.4mm dello spessore lama) local dCrawLen = PARTS[i].dRawLength -- materiale tolto in coda dalla lavorazione di separazione diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index 6331f6b..debcff6 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -50,7 +50,7 @@ local function GetStrategies_Egalware( Proc) end local CompleteList = {} - CompleteList.FeatureList = BeamLib.ImportFileJSON( sFile) + CompleteList.FEATURE = BeamLib.ImportFileJSON( sFile) Strategies = BeamLib.GetStrategiesFromList( Proc, CompleteList) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index cec9362..0c91f9f 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -29,12 +29,14 @@ EgtMdbSave() -- *** variabili globali *** ------------------------------------------------------------------------------------------------------------- TOOLS = {} -- tabella contenente tutti gli utensili -STRATEGIES = nil -- tabella contenente le strategie disponibili per ogni feature +STRATEGIES = {} -- tabella contenente le strategie disponibili per ogni feature STRATEGIES_CONFIG = {} -- tabella contenente i parametri di default delle strategie disponibili MACHININGS = {} -- tabella contenente le lavorazioni da applicare MACHININGS.Info = {} PROCESSINGS = {} -- tabella contenente tutte le informazioni di ogni feature, processate per ogni rotazione RESULT = {} -- tabella contenente il risultato, feature per feature, dell'applicazione della strategia scelta e il resoconto dell'analisi fatta +GENERAL_PARAMETERS = {} -- tabella contenente i parametri generali già letti e importati +GENERAL_PARAMETERS_JSON = {} -- tabella contenente i parametri generali di default ------------------------------------------------------------------------------------------------------------- -- *** COSTANTI *** TODO -> DA SPOSTARE IN BEAMDATA??? @@ -206,55 +208,47 @@ function BeamExec.GetToolsFromDB() end ------------------------------------------------------------------------------------------------------------- -function BeamExec.GetStrategiesFromJSONinBD() - -- si legge il JSON contenente la configurazione da utilizzare (nome del file salvato nel BeamData) - local sMachDir = EgtGetCurrMachineDir() - if BeamData.STRATEGIES_CONFIG_FILE then - local sFile = sMachDir .. '\\Beam\\AISetup\\' .. BeamData.STRATEGIES_CONFIG_FILE +function BeamExec.GetGeneralParameters() + local CompleteList = {} + local sFile = BEAM.BASEDIR .. '\\Strategies\\GeneralParameters.json' + -- se non esiste file JSON, esco subito + if not EgtExistsFile( sFile) then + return + end + + GENERAL_PARAMETERS_JSON = BeamLib.ImportFileJSON( sFile) + + -- all'inizio si legge solo PROJECT e BTL. I parametri PIECE vengono letti direttamente dalle strategie + GENERAL_PARAMETERS = BeamLib.LoadGeneralParametersInList( GENERAL_PARAMETERS_JSON) +end + +------------------------------------------------------------------------------------------------------------- +function BeamExec.GetStrategiesFromJSONinBD( sAISetupConfigName) + -- si legge il JSON contenente la configurazione da utilizzare solo se non è già stato importato + if sAISetupConfigName and not STRATEGIES[sAISetupConfigName] then + local sMachDir = EgtGetCurrMachineDir() + local sFile = sMachDir .. '\\Beam\\AISetup\\' .. sAISetupConfigName .. '.json' -- se non esiste file JSON, annullo la lista contenente le strategie if not EgtExistsFile( sFile) then - STRATEGIES = nil + STRATEGIES[sAISetupConfigName] = nil return end - + local FeatureList = {} FeatureList = BeamLib.ImportFileJSON( sFile) -- metto la tabella letta nella lista globale STRATEGIES - STRATEGIES = {} - STRATEGIES.FeatureList = FeatureList + STRATEGIES[sAISetupConfigName] = {} + STRATEGIES[sAISetupConfigName].GENERAL = FeatureList.GENERAL + STRATEGIES[sAISetupConfigName].FEATURE = FeatureList.FEATURE end end ------------------------------------------------------------------------------------------------------------- -- funzione che controlla validità delle combinazioni proposte -local function IsCombinationAvailable( sCombination, nUnloadPos, bSquareSection, bCalcBestPieceUnloadPosition) - -- STANDARD : posizione di scarico come posizionamento iniziale - if not bCalcBestPieceUnloadPosition then - local ExtraRotation = nUnloadPos + 3 - if nUnloadPos ~= 1 then - return false - elseif string.sub( sCombination, nUnloadPos, nUnloadPos) == '1' and string.sub( sCombination, ExtraRotation, ExtraRotation) == '0' then - if not BeamData.ROT90 and string.sub( sCombination, nUnloadPos+1, nUnloadPos+1) == '1' then - return false - elseif not BeamData.ROT180 and string.sub( sCombination, nUnloadPos+2, nUnloadPos+2) == '1' then - return false - else - return true - end - else - return false - end - -- TODO capire come passare info che il pezzo non ha bisogno di rotazioni per velocizzare il caclolo. Magari non serve neanche entrare in questa funzione - -- NO ROTATION : solo posizione di partenza - elseif BEAM.Rotation and BEAM.Rotation.bNoRotation then - if sCombination == '1000' and nUnloadPos == 1 then - return true - else - return false - end - -- PREROTATION : ammesse anche le prerotazioni e le inversioni (serve per preparare il pezzo nella posizione migliore prima di metterlo nella barra) - elseif bCalcBestPieceUnloadPosition then +local function IsCombinationAvailable( sCombination, nUnloadPos, bSquareSection, GeneralParameters, bCalcBestPieceUnloadPosition) + -- PREROTATION : flip-rot, si considerano tutte le posizioni possibili, a meno che non si voglia come da BTL + if bCalcBestPieceUnloadPosition and GeneralParameters.GEN_sPiecesLoadingPosition ~= 'BTL_POSITION' then local nRotation90 = EgtIf( nUnloadPos + 1 > 4, nUnloadPos + 1 - 4, nUnloadPos + 1) local nRotation180 = EgtIf( nUnloadPos + 2 > 4, nUnloadPos + 2 - 4, nUnloadPos + 2) local nExtraRotation = EgtIf( nUnloadPos + 3 > 4, nUnloadPos + 3 - 4, nUnloadPos + 3) @@ -274,6 +268,32 @@ local function IsCombinationAvailable( sCombination, nUnloadPos, bSquareSection, end end end + -- se invece si è nel caso standard di calcolo + else + -- NO ROTATION : solo posizione di partenza e non sono ammesse rotazioni + if GeneralParameters.GEN_sPieceRotation == 'NOT_ALLOWED' then + if sCombination == '1000' and nUnloadPos == 1 then + return true + else + return false + end + -- STANDARD : posizione di scarico come posizionamento iniziale + else + local ExtraRotation = nUnloadPos + 3 + if nUnloadPos ~= 1 then + return false + elseif string.sub( sCombination, nUnloadPos, nUnloadPos) == '1' and string.sub( sCombination, ExtraRotation, ExtraRotation) == '0' then + if not BeamData.ROT90 and string.sub( sCombination, nUnloadPos+1, nUnloadPos+1) == '1' then + return false + elseif not BeamData.ROT180 and string.sub( sCombination, nUnloadPos+2, nUnloadPos+2) == '1' then + return false + else + return true + end + else + return false + end + end end end @@ -282,8 +302,8 @@ function BeamExec.GetAvailableCombinations( PartInfo, bCalcBestPieceUnloadPositi local CombinationList = {} CombinationList.Rotations = {0, 0, 0, 0} -- indice rotazione attiva, per calcolo collect feature - -- se sto effettivamente calcolando, il pezzo è già in posizione e non può essere invertito. Se sono in preverifica, allora devo consoderare anche eventuali inversioni del pezzo - local nCycles = EgtIf( bCalcBestPieceUnloadPosition, 2, 1) + -- se sto effettivamente calcolando, il pezzo è già in posizione e non può essere invertito. Se sono in preverifica, allora devo considerare anche eventuali inversioni del pezzo + local nCycles = EgtIf( bCalcBestPieceUnloadPosition and PartInfo.GeneralParameters.GEN_sPiecesLoadingPosition == 'BEST_POSITION', 2, 1) -- verifico tutte le combinazioni che possono essere considerate for nInvertIndex = 1, nCycles do for nUnloadPos = 1, 4 do @@ -291,7 +311,7 @@ function BeamExec.GetAvailableCombinations( PartInfo, bCalcBestPieceUnloadPositi local nBitIndexCombination = BeamLib.DecimalToBinary( i) local sBitIndexCombination = BeamLib.CalculateStringBinaryFormat( nBitIndexCombination, 4) -- si calcolano le combinazioni all'inizio, ottimizzando calcolo della collect solo nelle rotazioni che possono essere considerate - if IsCombinationAvailable( sBitIndexCombination, nUnloadPos, PartInfo.bSquareSection, bCalcBestPieceUnloadPosition) then + if IsCombinationAvailable( sBitIndexCombination, nUnloadPos, PartInfo.bSquareSection, PartInfo.GeneralParameters, bCalcBestPieceUnloadPosition) then local Combination = {} Combination.sBitIndexCombination = sBitIndexCombination Combination.nUnloadPos = nUnloadPos @@ -459,10 +479,21 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, b PARTS[i].bSquareSection = abs( PARTS[i].dWidth - PARTS[i].dHeight) < 100 * GEO.EPS_SMALL PARTS[i].b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) PARTS[i].nIndexInParts = i - PARTS[i].CombinationList = BeamExec.GetAvailableCombinations( PARTS[i], bCalcBestPieceUnloadPosition) PARTS[i].SplittingPoints = BeamLib.GetPartSplittingPoints( PARTS[i]) PARTS[i].NotClampableLength = { STD = { dHead = 0, dTail = 0}, SIDE = { dHead = 0, dTail = 0}, DOWN = { dHead = 0, dTail = 0}} PARTS[i].dHeadOverMaterial = dDeltaS + PARTS[i].sBTLInfo = EgtGetInfo( PARTS[i].id, 'PROJECT', 's') or nil + + -- TODO LE INFO BTL ci devono sempre essere!! ripristinare dopo aver sistemato lettura da BtlInfo + --PARTS[i].sAISetupConfig = EgtGetInfo( PARTS[i].id, 'AISETUP', 's') or GENERAL_PARAMETERS.BTL[PARTS[i].sBTLInfo].sAISetupConfig or GENERAL_PARAMETERS.PROJECT.sAISetupConfig or nil + PARTS[i].sAISetupConfig = EgtGetInfo( PARTS[i].id, 'AISETUP', 's') or GENERAL_PARAMETERS.PROJECT.sAISetupConfig or nil + + + -- si carica configurazione lavorazioni + BeamExec.GetStrategiesFromJSONinBD( PARTS[i].sAISetupConfig) + PARTS[i].GeneralParameters = BeamLib.GetPieceGeneralParameters( PARTS[i], GENERAL_PARAMETERS_JSON) + PARTS[i].CombinationList = BeamExec.GetAvailableCombinations( PARTS[i], bCalcBestPieceUnloadPosition) + else local sOut = 'Error: part L(' .. EgtNumToString( dPartLen, 1) .. ') too big for raw part L(' .. EgtNumToString( dLen - 0.1, 1) .. ')' return false, sOut @@ -522,11 +553,11 @@ end ------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------- -local function GetStrategies( Proc) +local function GetStrategies( Proc, sAISetupConfigName) local AvailableStrategiesForProc = nil -- se la lista STRATEGIES è stata letta da JSON (quindi non è vuota), ritorno le strategie possibili - if STRATEGIES and #STRATEGIES.FeatureList > 0 then - AvailableStrategiesForProc = BeamLib.GetStrategiesFromList( Proc, STRATEGIES) + if STRATEGIES and sAISetupConfigName and STRATEGIES[sAISetupConfigName] and #STRATEGIES[sAISetupConfigName].FEATURE > 0 then + AvailableStrategiesForProc = BeamLib.GetStrategiesFromList( Proc, STRATEGIES[sAISetupConfigName]) end -- se non ho trovato strategie disponibili nel JSON, o se JSON non presente, lancio script che setta le strategie in modo statico, come definito con cliente if not AvailableStrategiesForProc then @@ -638,7 +669,7 @@ local function CollectFeatures( Part, dRotIndex) Proc.AvailableStrategies = vForcedStrategy -- altrimenti cerco tra le strategie disponibili else - Proc.AvailableStrategies = GetStrategies( Proc) + Proc.AvailableStrategies = GetStrategies( Proc, Part.sAISetupConfig) end -- se ci sono strategie disponibili, aggiungo a lista delle feature da lavorare if Proc.AvailableStrategies and #Proc.AvailableStrategies > 0 then @@ -831,7 +862,7 @@ end ------------------------------------------------------------------------------------------------------------- -- ritorna l'indice della strategia migliore, tra le due passate -local function GetIndexBestStrategyFromComparison( AvailableStrategies, nIndex1, nIndex2) +local function GetIndexBestStrategyFromComparison( AvailableStrategies, Part, nIndex1, nIndex2) local dChosenIndex = 0 -- controllo indici if nIndex1 == 0 and nIndex2 == 0 then @@ -857,16 +888,21 @@ local function GetIndexBestStrategyFromComparison( AvailableStrategies, nIndex1, ( AvailableStrategies[nIndex2].Result.sStatus == 'Not-Completed' and AvailableStrategies[nIndex1].Result.sStatus == 'Not-Applicable') then dChosenIndex = nIndex2 else - -- TODO gestire parametri scelta strategia - -- 1) tempo - -- 2) qualità - -- 3) prima strategia nell'ordine tra quelle disponibili - -- se le due strategie hanno stesso stato e sono entrambe applicabili (quindi entrambe complete o entrambe non-complete) if AvailableStrategies[nIndex1].Result.sStatus ~= 'Not-Applicable' and AvailableStrategies[nIndex2].Result.sStatus ~= 'Not-Applicable' and - AvailableStrategies[nIndex1].Result.sStatus == AvailableStrategies[nIndex2].Result.sStatus then + AvailableStrategies[nIndex1].Result.sStatus == AvailableStrategies[nIndex2].Result.sStatus then local dCompositeRatingStrategy1 = AvailableStrategies[nIndex1].Result.dCompositeRating local dCompositeRatingStrategy2 = AvailableStrategies[nIndex2].Result.dCompositeRating + if Part.GeneralParameters.GEN_sMachiningStrategy == 'BALANCED' then + dCompositeRatingStrategy1 = dCompositeRatingStrategy1 * ( 1 / AvailableStrategies[nIndex1].Result.dTimeToMachine) + dCompositeRatingStrategy2 = dCompositeRatingStrategy2 * ( 1 / AvailableStrategies[nIndex2].Result.dTimeToMachine) + elseif Part.GeneralParameters.GEN_sMachiningStrategy == 'FASTEST' then + dCompositeRatingStrategy1 = ( dCompositeRatingStrategy1 * 0.25) * ( 1 / ( AvailableStrategies[nIndex1].Result.dTimeToMachine * 0.75)) + dCompositeRatingStrategy2 = ( dCompositeRatingStrategy2 * 0.25) * ( 1 / ( AvailableStrategies[nIndex2].Result.dTimeToMachine * 0.75)) + elseif Part.GeneralParameters.GEN_sMachiningStrategy == 'HIGH_QUALITY' then + dCompositeRatingStrategy1 = ( dCompositeRatingStrategy1 * 0.75) * ( 1 / ( AvailableStrategies[nIndex1].Result.dTimeToMachine * 0.25)) + dCompositeRatingStrategy2 = ( dCompositeRatingStrategy2 * 0.75) * ( 1 / ( AvailableStrategies[nIndex2].Result.dTimeToMachine * 0.25)) + end -- si predilige strategia con rating composito più alto if dCompositeRatingStrategy1 > dCompositeRatingStrategy2 then dChosenIndex = nIndex1 @@ -883,7 +919,7 @@ end ------------------------------------------------------------------------------------------------------------- -- funzione che trova la strategia migliore tra quelle disponibili -local function GetBestStrategy( vProcSingleRot) +local function GetBestStrategy( vProcSingleRot, Part) for i = 1, #vProcSingleRot do -- processo tutte le feature attive local Proc = vProcSingleRot[i] @@ -894,7 +930,7 @@ local function GetBestStrategy( vProcSingleRot) -- ciclo tutte le strategie della feature for nIndexCurrentStrategy = 1, #Proc.AvailableStrategies do -- scelgo la migliore strategia tra le due - nIndexBestStrategy = GetIndexBestStrategyFromComparison( Proc.AvailableStrategies, nIndexCurrentStrategy, nIndexBestStrategy) + nIndexBestStrategy = GetIndexBestStrategyFromComparison( Proc.AvailableStrategies, Part, nIndexCurrentStrategy, nIndexBestStrategy) -- salvo sulla proc la migliore strategia end if nIndexBestStrategy ~= 0 then @@ -944,8 +980,7 @@ local function CalculateStrategies( vProcSingleRot, Part) Proc.AvailableStrategies[nIndexCurrentStrategy].Result = FeatureLib.CalculateCompositeRating( Proc.AvailableStrategies[nIndexCurrentStrategy].Result) -- se scelta strategia in modalità base o standard, esco subito alla prima che trovo completa - -- TODO serve parametro da Beam&Wall ( oppure da confirgurazione) !!!!!!!! - if BEAM.GetFirstCompletedStrategy and Proc.AvailableStrategies[nIndexCurrentStrategy].Result.sStatus == 'Complete' then + if Part.GeneralParameters.GEN_sMachiningStrategy == 'FIRST_IN_LIST' and Proc.AvailableStrategies[nIndexCurrentStrategy].Result.sStatus == 'Complete' then break end @@ -1244,44 +1279,81 @@ end ------------------------------------------------------------------------------------------------------------- -- funzione che decide la migliore tra le combinazioni di rotazione disponibili -local function GetBestCombination( ListToCompare) - -- TODO da completare +local function GetBestCombination( ListToCompare, Part) local nIndexBestCombination = 1 if #ListToCompare == 1 then nIndexBestCombination = 1 else for ListIndex = 2, #ListToCompare do - local bBestComplete = ListToCompare[nIndexBestCombination].nNotComplete == 0 and ListToCompare[nIndexBestCombination].nNotExecute == 0 - local bOtherComplete = ListToCompare[ListIndex].nNotComplete == 0 and ListToCompare[ListIndex].nNotExecute == 0 - - -- prediligo combinazione completa - if bBestComplete and not bOtherComplete then - ; -- la migliore resta la stessa - elseif not bBestComplete and bOtherComplete then - nIndexBestCombination = ListIndex - -- altrimenti guardo il voto + -- se rotazione non ammessa, si sceglie la migliore soluzione SENZA rotazioni + if Part.GeneralParameters.GEN_sPieceRotation == 'NOT_ALLOWED' then + -- scelgo soluzione senza rotazioni + if ListToCompare[ListIndex].nRotations == 0 then + -- scelgo soluzione con voto più alto + if ListToCompare[nIndexBestCombination].dTotalRating < ListToCompare[ListIndex].dTotalRating then + nIndexBestCombination = ListIndex + end + end + -- se rotazioni ammesse, si sceglie in base a peso singola rotazione else - -- si sceglie soluzione con più feature complete - if ListToCompare[ListIndex].nComplete > ListToCompare[nIndexBestCombination].nComplete then + local bBestComplete = ListToCompare[nIndexBestCombination].nNotComplete == 0 and ListToCompare[nIndexBestCombination].nNotExecute == 0 + local bOtherComplete = ListToCompare[ListIndex].nNotComplete == 0 and ListToCompare[ListIndex].nNotExecute == 0 + + -- prediligo combinazione completa + if bBestComplete and not bOtherComplete then + ; -- la migliore resta la stessa + elseif not bBestComplete and bOtherComplete then nIndexBestCombination = ListIndex - elseif ListToCompare[ListIndex].nComplete == ListToCompare[nIndexBestCombination].nComplete then - -- se stesso voto - if ListToCompare[nIndexBestCombination].dTotalRating == ListToCompare[ListIndex].dTotalRating then - -- TODO il voto dovrebbe essere considerato già pesando le rotazioni, con un coefficiente o un peso fisso aggiuntivo - -- scelgo soluzione con meno rotazioni + -- altrimenti guardo il voto + else + -- se rotazione ha un grande impatto + if Part.GeneralParameters.GEN_sPieceRotation == 'IF_NECESSARY' then + -- scelgo soluzione con meno rotazioni indipendentemente dal voto if ListToCompare[nIndexBestCombination].nRotations > ListToCompare[ListIndex].nRotations then nIndexBestCombination = ListIndex - -- se anche le rotazioni sono le stesse, prendo la soluzione con più lavorazioni alla fine - elseif #ListToCompare[nIndexBestCombination].Rot0 < #ListToCompare[ListIndex].Rot0 then - nIndexBestCombination = ListIndex + -- se stesso numero di rotazioni + elseif ListToCompare[nIndexBestCombination].nRotations == ListToCompare[ListIndex].nRotations then + -- si sceglie soluzione con più feature complete + if ListToCompare[ListIndex].nComplete > ListToCompare[nIndexBestCombination].nComplete then + nIndexBestCombination = ListIndex + elseif ListToCompare[ListIndex].nComplete == ListToCompare[nIndexBestCombination].nComplete then + -- scelgo soluzione con voto più alto + if ListToCompare[nIndexBestCombination].dTotalRating < ListToCompare[ListIndex].dTotalRating then + nIndexBestCombination = ListIndex + end + end end - -- se voto diverso + -- GEN_sPieceRotation = 'MODERATE_IMPACT' oppure 'NO_CONSTRAINT' else - -- scelgo soluzione con voto più alto - if ListToCompare[nIndexBestCombination].dTotalRating < ListToCompare[ListIndex].dTotalRating then + -- si sceglie soluzione con più feature complete + if ListToCompare[ListIndex].nComplete > ListToCompare[nIndexBestCombination].nComplete then nIndexBestCombination = ListIndex + elseif ListToCompare[ListIndex].nComplete == ListToCompare[nIndexBestCombination].nComplete then + local dBestTotalRating = ListToCompare[nIndexBestCombination].dTotalRating + local dOtherTotalRating = ListToCompare[ListIndex].dTotalRating + -- se la rotazione ha un moderato impatto, si calcola che ogni rotazione aumenta il dTotalRating del 10% + if Part.GeneralParameters.GEN_sPieceRotation == 'MODERATE_IMPACT' then + -- TODO IMPROVEMENT: si potrebbe avere un tempo di rotazione e aggiungere quello alla somma dei tempi delle lavorazioni delle feature + dBestTotalRating = dBestTotalRating * ( 1 + ( ListToCompare[nIndexBestCombination].nRotations / 10)) + dOtherTotalRating = dOtherTotalRating * ( 1 + ( ListToCompare[ListIndex].nRotations / 10)) + end + + -- scelgo soluzione con voto più alto + if dBestTotalRating < dOtherTotalRating then + nIndexBestCombination = ListIndex + -- se stesso voto + elseif dBestTotalRating == dOtherTotalRating then + -- scelgo soluzione con meno rotazioni + if ListToCompare[nIndexBestCombination].nRotations > ListToCompare[ListIndex].nRotations then + nIndexBestCombination = ListIndex + -- se anche le rotazioni sono le stesse, prendo la soluzione con più lavorazioni alla fine + elseif #ListToCompare[nIndexBestCombination].Rot0 < #ListToCompare[ListIndex].Rot0 then + nIndexBestCombination = ListIndex + end + end end end + end end end @@ -1334,7 +1406,7 @@ end ------------------------------------------------------------------------------------------------------------- -- funzione che ritorna la Proc nella rotazione scelta -local function GetProcBestMachRotationFromList( ListToCompare) +local function GetProcBestMachRotationFromList( ListToCompare, Part) local Data = {} local Proc = {} local nIndexChosenProcInRot = 1 @@ -1348,7 +1420,7 @@ local function GetProcBestMachRotationFromList( ListToCompare) end for nIndexCurrentStrategy = 1, #AvailableStrategiesInRot do -- la scelta tra le differenti strategie tra le rotazioni utilizza gli stessi criteri della scelta strategie all'interno della feature stessa - nIndexChosenProcInRot = GetIndexBestStrategyFromComparison( AvailableStrategiesInRot, nIndexCurrentStrategy, nIndexChosenProcInRot) + nIndexChosenProcInRot = GetIndexBestStrategyFromComparison( AvailableStrategiesInRot, Part, nIndexCurrentStrategy, nIndexChosenProcInRot) end -- altrimenti prendo la prima else @@ -1429,7 +1501,7 @@ local function GetCombinationListFromMatrix( ProcessingsOnPart, PartInfo) -- se la feature può essere lavorata in almeno una rotazione if #ResultsList > 0 then - local Proc, Data = GetProcBestMachRotationFromList( ResultsList) + local Proc, Data = GetProcBestMachRotationFromList( ResultsList, PartInfo) Proc.nIndexRotation = Data.nIndexRotation -- inserisco la Proc nell'apposita lista if Data.nIndexRotation == nUnloadPos then @@ -1486,7 +1558,7 @@ function BeamExec.GetCombinationMatrix( PARTS, bCalcBestPieceUnloadPosition) -- calcola le strategie applicabili PROCESSINGS[nPart].Rotation[nIndex] = CalculateStrategies( PROCESSINGS[nPart].Rotation[nIndex], PARTS[nPart]) -- tra le calcolate, sceglie la migliore - PROCESSINGS[nPart].Rotation[nIndex] = GetBestStrategy( PROCESSINGS[nPart].Rotation[nIndex]) + PROCESSINGS[nPart].Rotation[nIndex] = GetBestStrategy( PROCESSINGS[nPart].Rotation[nIndex], PARTS[nPart]) -- rotazione pezzo di 90° per volta BeamLib.RotateRawPart( PARTS[nPart], 1) -- aggiorno info pezzo @@ -1548,7 +1620,7 @@ function BeamExec.ProcessMachinings( PARTS) end -- scelta delal migliore combinazione - local BestCombination = GetBestCombination( CombinationListFromMatrix) + local BestCombination = GetBestCombination( CombinationListFromMatrix, PARTS[nPart]) PARTS[nPart].ChosenCombination = BestCombination.sBitIndexCombination PARTS[nPart].bPartInCombiIsInverted = BestCombination.bPartInCombiIsInverted diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 0957578..f3686ba 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -118,7 +118,7 @@ function BeamLib.AddPhaseWithRawParts( idRaw, OriXR, PosXR, dDeltaSucc) end end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.IsPointOnBoxLimit( ptPointToCheck, b3Solid) local bOnBoxLimit = false if abs( ptPointToCheck:getX() - b3Solid:getMax():getX()) < 100 * GEO.EPS_SMALL or @@ -131,7 +131,7 @@ function BeamLib.IsPointOnBoxLimit( ptPointToCheck, b3Solid) end return bOnBoxLimit end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.SetOpenSide( nPathInt, b3Solid) -- fondo tra loro le curve compatibili EgtMergeCurvesInCurveCompo( nPathInt) @@ -337,7 +337,7 @@ function BeamLib.GetAffectedFaces( Proc, Part) return vtFacesAffected end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.GetNearestOrthoOpposite( vtRef, vtNorm) -- se definita anche la normale alla faccia, elimino la parte di vtRef parallela a questa local vtMyRef = Vector3d( vtRef) @@ -372,7 +372,7 @@ function BeamLib.GetNearestOrthoOpposite( vtRef, vtNorm) return nil end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.GetNearestParalOpposite( vtRef, vtNorm) -- se definita anche la normale alla faccia, elimino la parte di vtRef parallela a questa local vtMyRef = Vector3d( vtRef) @@ -406,7 +406,7 @@ function BeamLib.GetNearestParalOpposite( vtRef, vtNorm) return nil end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- -- Funzione per determinare se la faccia ha lati molto corti (trascurabili) ed è quindi approssimabile ad una 3 facce function BeamLib.Is3EdgesApprox( Proc, idFace, nAddGrpId) nAddGrpId = nAddGrpId or BeamLib.GetAddGroup( Proc.idPart) @@ -458,14 +458,64 @@ function BeamLib.GetMaxNzDefault( vtNFace, Tool) return 0 end +-- TODO bisogna recuperare il nome del parametro NGE, perchè in questo caso è forzato +------------------------------------------------------------------------------------------------------------- +function BeamLib.GetPieceGeneralParameters( Part, DefaultGeneralParamList) + local GeneralParameters = {} + + -- si salvano sul pezzo le note forzate, altrimenti si leggeranno dopo, quando si prendono i dati della strategia + for i = 1, #DefaultGeneralParamList do + local sParamNameNGE = DefaultGeneralParamList[i].sNameNge + local xParameterValue = EgtGetInfo( Part.id, sParamNameNGE, 's') or nil + -- se il paraemtro esiste, salvataggio dato su lista con accesso diretto + if xParameterValue then + if DefaultGeneralParamList[i].sType == 'b' then + GeneralParameters[DefaultGeneralParamList[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true + elseif DefaultGeneralParamList[i].sType == 'd' then + if #DefaultGeneralParamList[i].sValue > 0 then + GeneralParameters[DefaultGeneralParamList[i].sName] = tonumber( xParameterValue) + -- stringa vuota equivale a non passare alcun valore (deciderà la strategia) + else + GeneralParameters[DefaultGeneralParamList[i].sName] = nil + end + else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' + GeneralParameters[DefaultGeneralParamList[i].sName] = xParameterValue + end + else + if GENERAL_PARAMETERS.BTL and GENERAL_PARAMETERS.BTL[Part.sBTLInfo] and GENERAL_PARAMETERS.BTL[Part.sBTLInfo][DefaultGeneralParamList[i].sName] then + GeneralParameters[DefaultGeneralParamList[i].sName] = GENERAL_PARAMETERS.BTL[Part.sBTLInfo][DefaultGeneralParamList[i].sName] + elseif GENERAL_PARAMETERS.PROJECT[DefaultGeneralParamList[i].sName] then + GeneralParameters[DefaultGeneralParamList[i].sName] = GENERAL_PARAMETERS.PROJECT[DefaultGeneralParamList[i].sName] + end + end + end + + return GeneralParameters +end + +------------------------------------------------------------------------------------------------------------- +local function GetInheritedParameter( Part, sSourceParamName) + local sValue = nil + if sSourceParamName and #sSourceParamName > 0 then + if Part.GeneralParameters[sSourceParamName] then + sValue = Part.GeneralParameters[sSourceParamName] + elseif GENERAL_PARAMETERS.BTL and GENERAL_PARAMETERS.BTL[Part.sBTLInfo] and GENERAL_PARAMETERS.BTL[Part.sBTLInfo][sSourceParamName] then + sValue = GENERAL_PARAMETERS.BTL[Part.sBTLInfo][sSourceParamName] + elseif GENERAL_PARAMETERS.PROJECT[sSourceParamName] then + sValue = GENERAL_PARAMETERS.PROJECT[sSourceParamName] + end + end + return sValue +end + ------------------------------------------------------------------------------------------------------------- -- si traduce la tabella dei parametri con tutte le informazioni in una lista contenente i parametri utilizzabili con accesso diretto -function BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, DefaultStrategyParamList) +function BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, DefaultStrategyParamList) local UpdatedParameters = {} -- TODO serve controllare se campo 'sStrategyId' congruente tra il Config (DefaultStrategyParamList) e i parametri custom (CustomParameters)? if DefaultStrategyParamList and DefaultStrategyParamList.ParameterList and #DefaultStrategyParamList.ParameterList > 0 then -- lettura e settaggio parametri finali per la strategia (customizzati o default) - for i=1, #DefaultStrategyParamList.ParameterList do + for i = 1, #DefaultStrategyParamList.ParameterList do local xParameterValue = nil -- se strategia forzata, leggo eventuali parametri nelle info if CustomParameters and CustomParameters.bForcedStrategy then @@ -477,7 +527,7 @@ function BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, Default end -- altrimenti i parametri custom si trovano già su questa lista elseif CustomParameters and CustomParameters.ParameterList then - for j=1, #CustomParameters.ParameterList do + for j = 1, #CustomParameters.ParameterList do if CustomParameters.ParameterList[j].sName == DefaultStrategyParamList.ParameterList[i].sName or CustomParameters.ParameterList[j].sName == DefaultStrategyParamList.ParameterList[i].sNameNge then xParameterValue = CustomParameters.ParameterList[j].sValue @@ -488,7 +538,12 @@ function BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, Default -- se non arriva forzato da strategia, oppure se non è stato configurato da cliente, si prende default if xParameterValue == nil then - xParameterValue = DefaultStrategyParamList.ParameterList[i].sValue + -- se il parametro strategia è da ereditare da un parametro globale + if DefaultStrategyParamList.ParameterList[i].sSource and #DefaultStrategyParamList.ParameterList[i].sSource > 0 then + xParameterValue = GetInheritedParameter( Part, DefaultStrategyParamList.ParameterList[i].sSource) + else + xParameterValue = DefaultStrategyParamList.ParameterList[i].sValue + end end if DefaultStrategyParamList.ParameterList[i].sType == 'b' then @@ -503,14 +558,69 @@ function BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, Default else --DefaultStrategyParamList[i].sType == 's' or DefaultStrategyParamList[i].sType == 'combo' UpdatedParameters[DefaultStrategyParamList.ParameterList[i].sName] = xParameterValue end - end end return UpdatedParameters end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- +-- si traduce la tabella dei parametri con tutte le informazioni in una lista contenente i parametri utilizzabili con accesso diretto +function BeamLib.LoadGeneralParametersInList( DefaultGeneralParamList) + local UpdatedParameters = { PROJECT = {}, BTL = {}} + -- aggiornamento parametri PROJECT + if DefaultGeneralParamList then + local idProjectInfo = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'ProjectInfo') or GDB_ID.NULL + UpdatedParameters.PROJECT.sAISetupConfig = EgtGetInfo( idProjectInfo, 'AISETUP', 's') or nil + for i = 1, #DefaultGeneralParamList do + local sParamNameNGE = DefaultGeneralParamList[i].sNameNge + local xParameterValue = EgtGetInfo( idProjectInfo, sParamNameNGE, 's') or DefaultGeneralParamList[i].sValue + -- salvataggio dato su lista con accesso diretto + if DefaultGeneralParamList[i].sType == 'b' then + UpdatedParameters.PROJECT[DefaultGeneralParamList[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true + elseif DefaultGeneralParamList[i].sType == 'd' then + if #DefaultGeneralParamList[i].sValue > 0 then + UpdatedParameters.PROJECT[DefaultGeneralParamList[i].sName] = tonumber( xParameterValue) + -- stringa vuota equivale a non passare alcun valore (deciderà la strategia) + else + UpdatedParameters.PROJECT[DefaultGeneralParamList[i].sName] = nil + end + else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' + UpdatedParameters.PROJECT[DefaultGeneralParamList[i].sName] = xParameterValue + end + end + + -- aggiornamento parametri BTL + local BTLInfo = EgtGetNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL + for j = 1, #BTLInfo do + local BTLName = EgtGetInfo( BTLInfo[j], 'PROJECT', 's') + if BTLName then + UpdatedParameters.BTL[BTLName] = {} + UpdatedParameters.BTL[BTLName].sAISetupConfig = EgtGetInfo( BTLInfo[j], 'AISETUP', 's') or nil + for i = 1, #DefaultGeneralParamList do + local sParamNameNGE = DefaultGeneralParamList[i].sNameNge + local xParameterValue = EgtGetInfo( BTLInfo[j], sParamNameNGE, 's') or DefaultGeneralParamList[i].sValue + -- salvataggio dato su lista con accesso diretto + if DefaultGeneralParamList[i].sType == 'b' then + UpdatedParameters.BTL[BTLName][DefaultGeneralParamList[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true + elseif DefaultGeneralParamList[i].sType == 'd' then + if #DefaultGeneralParamList[i].sValue > 0 then + UpdatedParameters.BTL[BTLName][DefaultGeneralParamList[i].sName] = tonumber( xParameterValue) + -- stringa vuota equivale a non passare alcun valore (deciderà la strategia) + else + UpdatedParameters.BTL[BTLName][DefaultGeneralParamList[i].sName] = nil + end + else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' + UpdatedParameters.BTL[BTLName][DefaultGeneralParamList[i].sName] = xParameterValue + end + end + end + end + end + + return UpdatedParameters +end +------------------------------------------------------------------------------------------------------------- function BeamLib.GetChainSawInitAngs( vtN, vtO, nInd) if BeamData.GetChainSawInitAngs then return BeamData.GetChainSawInitAngs( vtN, vtO, nInd) @@ -527,7 +637,7 @@ function BeamLib.GetChainSawInitAngs( vtN, vtO, nInd) end end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.GetBlockedAxis( nToolIndex, sBlockedAxis, b3Raw, vtTool, vtOut) -- se presente funzione specifica nella macchina, la richiamo if BeamData.GetBlockedAxis then @@ -549,7 +659,7 @@ function BeamLib.GetBlockedAxis( nToolIndex, sBlockedAxis, b3Raw, vtTool, vtOut) return '' end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.BinaryToDecimal( dNumber) local sNumberToConvert = tostring( dNumber) local dResult = 0 @@ -564,7 +674,7 @@ function BeamLib.BinaryToDecimal( dNumber) return dResult end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.DecimalToBinary( dNumber) local sNumberToConvert = tostring( dNumber) local n = sNumberToConvert @@ -589,7 +699,7 @@ function BeamLib.DecimalToBinary( dNumber) return tonumber( sResult) end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.CalculateStringBinaryFormat( dNumber, CharNumber) local NumberString = tostring( dNumber) while #NumberString < CharNumber do @@ -599,7 +709,7 @@ function BeamLib.CalculateStringBinaryFormat( dNumber, CharNumber) return NumberString end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- --- copia una tabella lua in modo ricorsivo, ossia mantiene indipendenti anche tutte le sottotabelle --- ATTENZIONE: in caso di modifiche vanno gestiti anche i tipi custom; sarebbe meglio metterla nel LuaLibs function BeamLib.TableCopyDeep( OriginalTable) @@ -633,7 +743,7 @@ function BeamLib.TableCopyDeep( OriginalTable) return CopiedTable end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.MergeTables( OriginalTable, InputTable) local result = {} for k, v in pairs( OriginalTable) do result[k] = v end @@ -641,7 +751,7 @@ function BeamLib.MergeTables( OriginalTable, InputTable) return result end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.FindEdgeBestOrientedAsDirection( Edges, vtDirection) local BestEdge = {} @@ -725,16 +835,16 @@ end ------------------------------------------------------------------------------------------------------------- function BeamLib.GetStrategiesFromList( Proc, StrategyList) -- cerco tra le feature - for i = 1, #StrategyList.FeatureList do + for i = 1, #StrategyList.FEATURE do -- se trovo la feature - if Proc.nPrc == StrategyList.FeatureList[i].nPrc then + if Proc.nPrc == StrategyList.FEATURE[i].nPrc then local bGroupIsCompatible = false -- nel JSON il gruppo è sempre 0/1, mente da BTL possono arrivare altri valori. - if StrategyList.FeatureList[i].nGrp == 0 then + if StrategyList.FEATURE[i].nGrp == 0 then if Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4 then bGroupIsCompatible = true end - elseif StrategyList.FeatureList[i].nGrp == 1 then + elseif StrategyList.FEATURE[i].nGrp == 1 then if Proc.nGrp == 1 or Proc.nGrp == 2 then bGroupIsCompatible = true end @@ -742,15 +852,15 @@ function BeamLib.GetStrategiesFromList( Proc, StrategyList) -- si controlla gruppo if bGroupIsCompatible then - if #StrategyList.FeatureList[i].TopologyList == 1 and StrategyList.FeatureList[i].TopologyList[1].sName == 'Feature' then - return BeamLib.TableCopyDeep( StrategyList.FeatureList[i].TopologyList[1].StrategyList) + if #StrategyList.FEATURE[i].TopologyList == 1 and StrategyList.FEATURE[i].TopologyList[1].sName == 'Feature' then + return BeamLib.TableCopyDeep( StrategyList.FEATURE[i].TopologyList[1].StrategyList) else -- cerco tra le topologie - for j = 1, #StrategyList.FeatureList[i].TopologyList do + for j = 1, #StrategyList.FEATURE[i].TopologyList do -- se trovo la topologia - if Proc.Topology.sName == StrategyList.FeatureList[i].TopologyList[j].sName then + if Proc.Topology.sName == StrategyList.FEATURE[i].TopologyList[j].sName then -- ritorno le strategie disponibili per la feature che sto analizzando - return BeamLib.TableCopyDeep( StrategyList.FeatureList[i].TopologyList[j].StrategyList) + return BeamLib.TableCopyDeep( StrategyList.FEATURE[i].TopologyList[j].StrategyList) end end end @@ -760,7 +870,7 @@ function BeamLib.GetStrategiesFromList( Proc, StrategyList) return nil end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- -- Merge sorting - algoritmo di sorting stabile, ossia che mantiene l'ordine relativo se gli elementi sono equivalenti -- TODO vedere come riordinare (tutto in tabella MergeSort??) -- TODO libreria Sorting?? diff --git a/LuaLibs/FeatureLib.lua b/LuaLibs/FeatureLib.lua index 440f8d1..9d53ade 100644 --- a/LuaLibs/FeatureLib.lua +++ b/LuaLibs/FeatureLib.lua @@ -669,11 +669,12 @@ end function FeatureLib.CalculateCompositeRating( StrategyResult) -- se ho tutti i dati che mi servono calcolo il rating della strategia applicato alla feature if StrategyResult and StrategyResult.nQuality and StrategyResult.nCompletionIndex and StrategyResult.dMRR then + -- TODO serve funzione generale? -- indice bonta lavorazione feature in rotazione è opzionale, se non settato viene messo a 3 if not StrategyResult.nFeatureRotationIndex then StrategyResult.nFeatureRotationIndex = 3 end - StrategyResult.dCompositeRating = ceil( StrategyResult.nQuality * StrategyResult.nCompletionIndex * StrategyResult.dMRR * StrategyResult.nFeatureRotationIndex) + StrategyResult.dCompositeRating = ceil( StrategyResult.nQuality * StrategyResult.nCompletionIndex * ( 1 + ( StrategyResult.nFeatureRotationIndex / 10))) else StrategyResult.dCompositeRating = 0 end diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index fee9b88..0f44849 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -1386,6 +1386,8 @@ function MachiningLib.PrepareMachiningsForSorting( Part) end if MachiningCurrent.ptCenter:getX() > dNextSplitX - 10 * GEO.EPS_SMALL and MachiningCurrent.ptCenter:getX() < dPreviousSplitX + 10 * GEO.EPS_SMALL then MachiningCurrent.nPartSegment = j + else + MachiningCurrent.nPartSegment = -1 end end else diff --git a/Process.lua b/Process.lua index 79fad63..1206728 100644 --- a/Process.lua +++ b/Process.lua @@ -163,11 +163,6 @@ end local function GetDataConfig() -- recupero utensili dal magazzino BeamExec.GetToolsFromDB() - -- se si utilizza interfaccia B&W, si carica il file JSON - local bIsBeamWall = true -- TODO serve parametro per capire se stiamo utilizzando B&W - if bIsBeamWall then - BeamExec.GetStrategiesFromJSONinBD() - end -- TODO da gestire eventuali errori bloccanti return true end @@ -364,6 +359,9 @@ end ------------------------------------------------------------------------------------------------------------- if not MyProcessInputData() then return end +-- recupero parametri generali da progetto +BeamExec.GetGeneralParameters() + if not MyProcessBeams() then return end if not GetDataConfig() then return end diff --git a/Strategies/GeneralParameters.json b/Strategies/GeneralParameters.json new file mode 100644 index 0000000..fca82fb --- /dev/null +++ b/Strategies/GeneralParameters.json @@ -0,0 +1,127 @@ + +[ + { + "nGroup": "1", + "sName": "GEN_sPiecesLoadingPosition", + "sNameNge": "GEN_PIECES_LOADING", + "sValue": "BTL_POSITION", + "sDescriptionShort": "Part loading position", + "sDescriptionLong": "", + "sType": "combo", + "sMinUserLevel": "1", + "Choices": [ + { + "sValue": "BTL_POSITION", + "sDescriptionShort": "Last piece position as BTL", + "sDescriptionLong": "", + "sMessageId": "" + }, + { + "sValue": "BEST_ROTATION", + "sDescriptionShort": "Allow piece rotations", + "sDescriptionLong": "", + "sMessageId": "" + }, + { + "sValue": "BEST_POSITION", + "sDescriptionShort": "Allow piece rotation and inversion", + "sDescriptionLong": "", + "sMessageId": "" + } + ] + }, + { + "nGroup": "1", + "sName": "GEN_sPieceRotation", + "sNameNge": "GEN_PIECE_ROTATION", + "sValue": "IF_NECESSARY", + "sDescriptionShort": "Part rotating acceptability", + "sDescriptionLong": "Acceptability of rotating the part between machining steps", + "sType": "combo", + "sMinUserLevel": "1", + "Choices": [ + { + "sValue": "NOT_ALLOWED", + "sDescriptionShort": "Rotation not allowed", + "sDescriptionLong": "", + "sMessageId": "" + }, + { + "sValue": "IF_NECESSARY", + "sDescriptionShort": "Rotation allowed only if strictly necessary", + "sDescriptionLong": "", + "sMessageId": "" + }, + { + "sValue": "MODERATE_IMPACT", + "sDescriptionShort": "Rotation acceptable with moderate impact", + "sDescriptionLong": "", + "sMessageId": "" + }, + { + "sValue": "NO_CONSTRAINT", + "sDescriptionShort": "Rotation easily acceptable / no constraint", + "sDescriptionLong": "", + "sMessageId": "" + } + ] + }, + { + "nGroup": "1", + "sName": "GEN_sMachiningStrategy", + "sNameNge": "GEN_MACHINING_STRATEGY", + "sValue": "BALANCED", + "sDescriptionShort": "Machining Strategy", + "sDescriptionLong": "", + "sType": "combo", + "sMinUserLevel": "1", + "Choices": [ + { + "sValue": "FIRST_IN_LIST", + "sDescriptionShort": "Prefer first strategy in list", + "sDescriptionLong": "", + "sMessageId": "" + }, + { + "sValue": "BALANCED", + "sDescriptionShort": "Balanced", + "sDescriptionLong": "", + "sMessageId": "" + }, + { + "sValue": "FASTEST", + "sDescriptionShort": "Fastest", + "sDescriptionLong": "Prefer fastest strategies", + "sMessageId": "" + }, + { + "sValue": "HIGH_QUALITY", + "sDescriptionShort": "High quality", + "sDescriptionLong": "Prefer strategies with an high-quality", + "sMessageId": "" + } + ] + }, + { + "nGroup": "2", + "sName": "GEN_dMaxWasteLength", + "sNameNge": "GEN_MAX_WASTE_LENGTH", + "sValue": "300", + "sDescriptionShort": "Maximum Waste Length for Dice-cut", + "sDescriptionLong": "", + "sType": "d", + "sMessageId": " ", + "sMinUserLevel": "5" + }, + { + "nGroup": "2", + "sName": "GEN_dMaxWasteVolume", + "sNameNge": "GEN_MAX_WASTE_VOLUME", + "sValue": "6000000", + "sDescriptionShort": "Maximum Waste Volume for Dice-cut", + "sDescriptionLong": "", + "sType": "d", + "sMessageId": " ", + "sMinUserLevel": "5" + } +] diff --git a/Strategies/Standard/HEADCUT/HEADCUT.json b/Strategies/Standard/HEADCUT/HEADCUT.json index 8ac0cd5..ba26a06 100644 --- a/Strategies/Standard/HEADCUT/HEADCUT.json +++ b/Strategies/Standard/HEADCUT/HEADCUT.json @@ -22,26 +22,6 @@ "sMessageId": " ", "sMinUserLevel": "1" }, - { - "sName": "dMaxWasteLength", - "sNameNge": "MAX_WASTE_LENGTH", - "sValue": "300", - "sDescriptionShort": "Maximum Waste Length", - "sDescriptionLong": "", - "sType": "d", - "sMessageId": " ", - "sMinUserLevel": "1" - }, - { - "sName": "dMaxWasteVolume", - "sNameNge": "MAX_WASTE_VOLUME", - "sValue": "6000000", - "sDescriptionShort": "Maximum Waste Volume", - "sDescriptionLong": "", - "sType": "d", - "sMessageId": " ", - "sMinUserLevel": "1" - }, { "sName": "bReduceBladePath", "sNameNge": "REDUCE_BLADE_PATH", @@ -71,6 +51,16 @@ "sType": "b", "sMessageId": " ", "sMinUserLevel": "1" + }, + { + "sName": "dMaxWasteLength", + "sSource": "GEN_dMaxWasteLength", + "sMinUserLevel": "5" + }, + { + "sName": "dMaxWasteVolume", + "sSource": "GEN_dMaxWasteVolume", + "sMinUserLevel": "5" } ] } diff --git a/Strategies/Standard/HEADCUT/HEADCUT.lua b/Strategies/Standard/HEADCUT/HEADCUT.lua index b5b314c..70b41cd 100644 --- a/Strategies/Standard/HEADCUT/HEADCUT.lua +++ b/Strategies/Standard/HEADCUT/HEADCUT.lua @@ -27,7 +27,7 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.SplitStrategy = {} Strategy.Result = {} Strategy.Machining = {} diff --git a/Strategies/Standard/STR0001/STR0001.json b/Strategies/Standard/STR0001/STR0001.json index b753b80..961d191 100644 --- a/Strategies/Standard/STR0001/STR0001.json +++ b/Strategies/Standard/STR0001/STR0001.json @@ -42,26 +42,6 @@ "sMessageId": " ", "sMinUserLevel": "1" }, - { - "sName": "dMaxWasteLength", - "sNameNge": "MAX_WASTE_LENGTH", - "sValue": "300", - "sDescriptionShort": "Maximum Waste Length", - "sDescriptionLong": "", - "sType": "d", - "sMessageId": " ", - "sMinUserLevel": "1" - }, - { - "sName": "dMaxWasteVolume", - "sNameNge": "MAX_WASTE_VOLUME", - "sValue": "6000000", - "sDescriptionShort": "Maximum Waste Volume", - "sDescriptionLong": "", - "sType": "d", - "sMessageId": " ", - "sMinUserLevel": "1" - }, { "sName": "bReduceBladePath", "sNameNge": "REDUCE_BLADE_PATH", @@ -128,6 +108,16 @@ "sSubType": "MCH_TF.MILL", "sMessageId": " ", "sMinUserLevel": "1" + }, + { + "sName": "dMaxWasteLength", + "sSource": "GEN_dMaxWasteLength", + "sMinUserLevel": "5" + }, + { + "sName": "dMaxWasteVolume", + "sSource": "GEN_dMaxWasteVolume", + "sMinUserLevel": "5" } ] } \ No newline at end of file diff --git a/Strategies/Standard/STR0001/STR0001.lua b/Strategies/Standard/STR0001/STR0001.lua index 119472e..56e2f54 100644 --- a/Strategies/Standard/STR0001/STR0001.lua +++ b/Strategies/Standard/STR0001/STR0001.lua @@ -297,7 +297,7 @@ function STR0001.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Machining = {} Strategy.Result = {} Strategy.Result.dTimeToMachine = 0 diff --git a/Strategies/Standard/STR0002/STR0002.lua b/Strategies/Standard/STR0002/STR0002.lua index b955df0..5c06932 100644 --- a/Strategies/Standard/STR0002/STR0002.lua +++ b/Strategies/Standard/STR0002/STR0002.lua @@ -486,7 +486,7 @@ function STR0002.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Machining = {} Strategy.Result = {} Strategy.Result.dTimeToMachine = 0 diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index 134850b..b7f7afe 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -182,7 +182,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Result = {} Strategy.Result.sInfo = '' Blade.Result = {} diff --git a/Strategies/Standard/STR0004/STR0004.lua b/Strategies/Standard/STR0004/STR0004.lua index eb7c6af..8deeec0 100644 --- a/Strategies/Standard/STR0004/STR0004.lua +++ b/Strategies/Standard/STR0004/STR0004.lua @@ -106,7 +106,7 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Result = {} Strategy.Result.sInfo = '' Chainsaw.Result = {} diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 35853ac..134d9ad 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -52,7 +52,7 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Result = {} Strategy.Result.sInfo = '' Blade.Result = {} diff --git a/Strategies/Standard/STR0006/STR0006.lua b/Strategies/Standard/STR0006/STR0006.lua index 017540f..6225794 100644 --- a/Strategies/Standard/STR0006/STR0006.lua +++ b/Strategies/Standard/STR0006/STR0006.lua @@ -252,7 +252,7 @@ function STR0006.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Machining = {} Strategy.Result = {} local Results = {} diff --git a/Strategies/Standard/STR0007/STR0007.lua b/Strategies/Standard/STR0007/STR0007.lua index ad8d50e..c1f01bd 100644 --- a/Strategies/Standard/STR0007/STR0007.lua +++ b/Strategies/Standard/STR0007/STR0007.lua @@ -326,7 +326,7 @@ function STR0007.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Machining = {} Strategy.Result = {} diff --git a/Strategies/Standard/STR0008/STR0008.lua b/Strategies/Standard/STR0008/STR0008.lua index ccd0fe5..b666391 100644 --- a/Strategies/Standard/STR0008/STR0008.lua +++ b/Strategies/Standard/STR0008/STR0008.lua @@ -230,7 +230,7 @@ function STR0008.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Machining = {} Strategy.Result = {} diff --git a/Strategies/Standard/STR0009/STR0009.lua b/Strategies/Standard/STR0009/STR0009.lua index af49681..1b88a17 100644 --- a/Strategies/Standard/STR0009/STR0009.lua +++ b/Strategies/Standard/STR0009/STR0009.lua @@ -168,7 +168,7 @@ function STR0009.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Machinings = {} Strategy.Result = {} diff --git a/Strategies/Standard/STR0010/STR0010.lua b/Strategies/Standard/STR0010/STR0010.lua index f89a277..18a153e 100644 --- a/Strategies/Standard/STR0010/STR0010.lua +++ b/Strategies/Standard/STR0010/STR0010.lua @@ -168,7 +168,7 @@ function STR0010.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Machinings = {} Strategy.Result = {} diff --git a/Strategies/Standard/STR0011/STR0011.lua b/Strategies/Standard/STR0011/STR0011.lua index df14470..1ccb65f 100644 --- a/Strategies/Standard/STR0011/STR0011.lua +++ b/Strategies/Standard/STR0011/STR0011.lua @@ -244,7 +244,7 @@ function STR0011.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Machinings = {} Strategy.Result = {} diff --git a/Strategies/Standard/STR0012/STR0012.lua b/Strategies/Standard/STR0012/STR0012.lua index 1ae5b25..a349639 100644 --- a/Strategies/Standard/STR0012/STR0012.lua +++ b/Strategies/Standard/STR0012/STR0012.lua @@ -26,7 +26,7 @@ function STR0012.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Result = {} Strategy.Result.sInfo = '' RidgeLap.Result = {} diff --git a/Strategies/Standard/STR0013/STR0013.lua b/Strategies/Standard/STR0013/STR0013.lua index 37d9971..532669e 100644 --- a/Strategies/Standard/STR0013/STR0013.lua +++ b/Strategies/Standard/STR0013/STR0013.lua @@ -154,7 +154,7 @@ function STR0013.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Machinings = {} Strategy.Result = {} diff --git a/Strategies/Standard/STR0014/STR0014.lua b/Strategies/Standard/STR0014/STR0014.lua index e50dcaf..00863c0 100644 --- a/Strategies/Standard/STR0014/STR0014.lua +++ b/Strategies/Standard/STR0014/STR0014.lua @@ -40,7 +40,7 @@ function STR0014.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Machining = MachiningLib.InitMachiningParameters( MCH_MY.MILLING) Strategy.Result = {} Strategy.Result.dTimeToMachine = 0 diff --git a/Strategies/Standard/STR0015/STR0015.lua b/Strategies/Standard/STR0015/STR0015.lua index 8bebfad..9521a68 100644 --- a/Strategies/Standard/STR0015/STR0015.lua +++ b/Strategies/Standard/STR0015/STR0015.lua @@ -690,7 +690,7 @@ function STR0015.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.Chamfer = {} Strategy.Chamfer.Machinings = {} Strategy.Chamfer.Result = {} diff --git a/Strategies/Standard/TAILCUT/TAILCUT.lua b/Strategies/Standard/TAILCUT/TAILCUT.lua index 72dcec3..61fc28f 100644 --- a/Strategies/Standard/TAILCUT/TAILCUT.lua +++ b/Strategies/Standard/TAILCUT/TAILCUT.lua @@ -27,7 +27,7 @@ function TAILCUT.Make( bAddMachining, Proc, Part, CustomParameters) local StrategyLib = {} StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId] Strategy.sName = StrategyLib.Config.sStrategyId - Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, StrategyLib.Config) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config) Strategy.SplitStrategy = {} Strategy.Result = {} Strategy.Machining = {}