From a508b4bb94439f60a6c5bd42c3d9942d41cb3b95 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 3 Oct 2025 11:15:17 +0200 Subject: [PATCH 1/5] =?UTF-8?q?-=20Prima=20versione=20con=20gestione=20par?= =?UTF-8?q?ametri=20generali=20-=20Possibilit=C3=A0=20di=20aprire=20pi?= =?UTF-8?q?=C3=B9=20configurazioni=20delle=20strategie=20-=20Gestione=20pa?= =?UTF-8?q?rametri=20ereditati=20-=20Nuovo=20JSON=20parametri=20generali?= =?UTF-8?q?=20-=20Adeguamento=20strategie=20per=20gestione=20parametri=20g?= =?UTF-8?q?enerali?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BatchProcessNew.lua | 13 +- LuaLibs/BeamExec.lua | 49 +++++--- LuaLibs/BeamLib.lua | 120 +++++++++++++++++- LuaLibs/MachiningLib.lua | 2 + Process.lua | 7 +- Strategies/GeneralParameters.json | 147 +++++++++++++++++++++++ Strategies/Standard/HEADCUT/HEADCUT.json | 30 ++--- Strategies/Standard/HEADCUT/HEADCUT.lua | 2 +- Strategies/Standard/STR0001/STR0001.json | 30 ++--- Strategies/Standard/STR0001/STR0001.lua | 2 +- Strategies/Standard/STR0002/STR0002.lua | 2 +- Strategies/Standard/STR0003/STR0003.lua | 2 +- Strategies/Standard/STR0004/STR0004.lua | 2 +- Strategies/Standard/STR0005/STR0005.lua | 2 +- Strategies/Standard/STR0006/STR0006.lua | 2 +- Strategies/Standard/STR0007/STR0007.lua | 2 +- Strategies/Standard/STR0008/STR0008.lua | 2 +- Strategies/Standard/STR0009/STR0009.lua | 2 +- Strategies/Standard/STR0010/STR0010.lua | 2 +- Strategies/Standard/STR0011/STR0011.lua | 2 +- Strategies/Standard/STR0012/STR0012.lua | 2 +- Strategies/Standard/STR0013/STR0013.lua | 2 +- Strategies/Standard/STR0014/STR0014.lua | 2 +- Strategies/Standard/STR0015/STR0015.lua | 2 +- Strategies/Standard/TAILCUT/TAILCUT.lua | 2 +- 25 files changed, 346 insertions(+), 86 deletions(-) create mode 100644 Strategies/GeneralParameters.json diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index a287c60..1d8b171 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -105,11 +105,8 @@ 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 + -- recupero parametri generali da progetto + BeamExec.GetGeneralParameters() -- TODO da gestire eventuali errori bloccanti return true end @@ -579,10 +576,16 @@ if bToProcess then 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].sAISetupConfig = EgtGetInfo( PARTS[i].id, 'AISETUP', 's') or nil + PARTS[i].GeneralParameters = {} + -- si carica configurazione lavorazioni + BeamExec.GetStrategiesFromJSONinBD( PARTS[i].sAISetupConfig) + -- TODO leggere qui i parametri generali pezzo? -- 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/BeamExec.lua b/LuaLibs/BeamExec.lua index cec9362..70f3654 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -29,12 +29,13 @@ 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 ------------------------------------------------------------------------------------------------------------- -- *** COSTANTI *** TODO -> DA SPOSTARE IN BEAMDATA??? @@ -206,23 +207,38 @@ 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 + + CompleteList = BeamLib.ImportFileJSON( sFile) + + GENERAL_PARAMETERS = BeamLib.LoadGeneralParametersInList( CompleteList) +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].FeatureList = FeatureList.FEATURE + STRATEGIES[sAISetupConfigName].sAISetupConfigName = sAISetupConfigName end end @@ -463,6 +479,11 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, b 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].sAISetupConfig = EgtGetInfo( PARTS[i].id, 'AISETUP', 's') or nil + PARTS[i].GeneralParameters = {} + -- si carica configurazione lavorazioni + BeamExec.GetStrategiesFromJSONinBD( PARTS[i].sAISetupConfig) + -- TODO leggere qui i parametri generali pezzo? 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 +543,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].FeatureList > 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 +659,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 diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 0957578..340e656 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -458,14 +458,40 @@ 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, sParameterName) + local sValue = nil + -- si caricano i parametri generali riferiti al pezzo + sValue = EgtGetInfo( Part.id, sParameterName, 's') + return sValue +end + +------------------------------------------------------------------------------------------------------------- +local function GetInheritedParameter( Part, sSourceParamName) + local sValue = nil + if sSourceParamName and #sSourceParamName > 0 then + -- se il parametro è già stato letto + if Part.GeneralParameters[sSourceParamName] then + sValue = Part.GeneralParameters[sSourceParamName] + -- altrimenti lo recupero + else + Part.GeneralParameters[sSourceParamName] = BeamLib.GetPieceGeneralParameters( Part, sSourceParamName) + sValue = Part.GeneralParameters[sSourceParamName] or + GENERAL_PARAMETERS.PIECE[sSourceParamName] or GENERAL_PARAMETERS.BTL[sSourceParamName] or GENERAL_PARAMETERS.PROJECT[sSourceParamName] or nil + 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 +503,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 +514,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,13 +534,92 @@ 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 = {}, PIECE = {}} + -- aggiornamento parametri PROJECT + if DefaultGeneralParamList and DefaultGeneralParamList.PROJECT then + local idProjectInfo = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'ProjectInfo') or GDB_ID.NULL + for i = 1, #DefaultGeneralParamList.PROJECT do + local sParamNameNGE = DefaultGeneralParamList.PROJECT[i].sNameNge + local xParameterValue = EgtGetInfo( idProjectInfo, sParamNameNGE, 's') or DefaultGeneralParamList.PROJECT[i].sValue + -- salvataggio dato su lista con accesso diretto + if DefaultGeneralParamList.PROJECT[i].sType == 'b' then + UpdatedParameters.PROJECT[DefaultGeneralParamList.PROJECT[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true + elseif DefaultGeneralParamList.PROJECT[i].sType == 'd' then + if #DefaultGeneralParamList.PROJECT[i].sValue > 0 then + UpdatedParameters.PROJECT[DefaultGeneralParamList.PROJECT[i].sName] = tonumber( xParameterValue) + -- stringa vuota equivale a non passare alcun valore (deciderà la strategia) + else + UpdatedParameters.PROJECT[DefaultGeneralParamList.PROJECT[i].sName] = nil + end + else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' + UpdatedParameters.PROJECT[DefaultGeneralParamList.PROJECT[i].sName] = xParameterValue + end + end + end + + -- TODO GESTIRE IL CASO IN CUI IN UN PROGETTO CI SIANO PIU' DI UN BTL + -- aggiornamento parametri BTL + if DefaultGeneralParamList and DefaultGeneralParamList.BTL then + local idBTLInfo = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL + for i = 1, #DefaultGeneralParamList.BTL do + if DefaultGeneralParamList.BTL[i].sType == 'inherited' then + UpdatedParameters.BTL[DefaultGeneralParamList.BTL[i].sName] = UpdatedParameters.PROJECT[DefaultGeneralParamList.BTL[i].sName] + else + local sParamNameNGE = DefaultGeneralParamList.BTL[i].sNameNge + + local xParameterValue = EgtGetInfo( idBTLInfo, sParamNameNGE, 's') or DefaultGeneralParamList.BTL[i].sValue + -- salvataggio dato su lista con accesso diretto + if DefaultGeneralParamList.BTL[i].sType == 'b' then + UpdatedParameters.BTL[DefaultGeneralParamList.BTL[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true + elseif DefaultGeneralParamList.BTL[i].sType == 'd' then + if #DefaultGeneralParamList.BTL[i].sValue > 0 then + UpdatedParameters.BTL[DefaultGeneralParamList.BTL[i].sName] = tonumber( xParameterValue) + -- stringa vuota equivale a non passare alcun valore (deciderà la strategia) + else + UpdatedParameters.BTL[DefaultGeneralParamList.BTL[i].sName] = nil + end + else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' + UpdatedParameters.BTL[DefaultGeneralParamList.BTL[i].sName] = xParameterValue + end + end + end + end + + -- aggiornamento parametri PIECE (in questo momento si salva solo il default, poi lo si aggiorna pezzo per pezzo) + if DefaultGeneralParamList and DefaultGeneralParamList.PIECE then + for i = 1, #DefaultGeneralParamList.PIECE do + if DefaultGeneralParamList.PIECE[i].sType == 'inherited' then + UpdatedParameters.PIECE[DefaultGeneralParamList.PIECE[i].sName] = UpdatedParameters.BTL[DefaultGeneralParamList.PIECE[i].sName] or UpdatedParameters.PROJECT[DefaultGeneralParamList.PIECE[i].sName] + else + local xParameterValue = DefaultGeneralParamList.PIECE[i].sValue or nil + -- salvataggio dato su lista con accesso diretto + if DefaultGeneralParamList.PIECE[i].sType == 'b' then + UpdatedParameters.PIECE[DefaultGeneralParamList.PIECE[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true + elseif DefaultGeneralParamList.PIECE[i].sType == 'd' then + if #DefaultGeneralParamList.PIECE[i].sValue > 0 then + UpdatedParameters.PIECE[DefaultGeneralParamList.PIECE[i].sName] = tonumber( xParameterValue) + -- stringa vuota equivale a non passare alcun valore (deciderà la strategia) + else + UpdatedParameters.PIECE[DefaultGeneralParamList.PIECE[i].sName] = nil + end + else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' + UpdatedParameters.PIECE[DefaultGeneralParamList.PIECE[i].sName] = xParameterValue + end + end + end + end + + return UpdatedParameters +end --------------------------------------------------------------------- function BeamLib.GetChainSawInitAngs( vtN, vtO, nInd) if BeamData.GetChainSawInitAngs then 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..de88d5c 100644 --- a/Process.lua +++ b/Process.lua @@ -163,11 +163,8 @@ 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 + -- recupero parametri generali da progetto + BeamExec.GetGeneralParameters() -- TODO da gestire eventuali errori bloccanti return true end diff --git a/Strategies/GeneralParameters.json b/Strategies/GeneralParameters.json new file mode 100644 index 0000000..fcaf605 --- /dev/null +++ b/Strategies/GeneralParameters.json @@ -0,0 +1,147 @@ + +{ + "PROJECT" : [ + { + "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": "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" + } + ], + "BTL" : [ + { + "sName": "GEN_sPieceRotation", + "sType": "inherited", + "sMinUserLevel": "1" + }, + { + "sName": "GEN_sMachiningStrategy", + "sType": "inherited", + "sMinUserLevel": "1" + } + ], + "PIECE" : [ + { + "sName": "GEN_sPieceRotation", + "sType": "inherited", + "sMinUserLevel": "1" + }, + { + "sName": "GEN_sMachiningStrategy", + "sType": "inherited", + "sMinUserLevel": "1" + } + ] +} \ No newline at end of file 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 = {} From ddbbc894fdc1b57f3bdd1a31e30ee4ea63d1c61e Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 3 Oct 2025 17:14:10 +0200 Subject: [PATCH 2/5] =?UTF-8?q?-=20Lettura=20parametri=20globali=20PROJECT?= =?UTF-8?q?=20e=20BTL=20-=20Possibilit=C3=A0=20di=20leggere=20pi=C3=B9=20f?= =?UTF-8?q?ile=20BTLInfo=20-=20Creata=20funzione=20GetPieceGeneralParamete?= =?UTF-8?q?rs=20(DA=20FARE)=20per=20aggiornamento=20parametri=20su=20pezzo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BatchProcessNew.lua | 9 ++- LuaLibs/BasicCustomerStrategies.lua | 2 +- LuaLibs/BeamExec.lua | 19 +++-- LuaLibs/BeamLib.lua | 112 ++++++++++++---------------- Process.lua | 5 +- 5 files changed, 68 insertions(+), 79 deletions(-) diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 1d8b171..1457ea4 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -105,8 +105,6 @@ local dRawH local function GetDataConfig() -- recupero utensili dal magazzino BeamExec.GetToolsFromDB() - -- recupero parametri generali da progetto - BeamExec.GetGeneralParameters() -- TODO da gestire eventuali errori bloccanti return true end @@ -418,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 @@ -577,10 +578,10 @@ if bToProcess then 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].sAISetupConfig = EgtGetInfo( PARTS[i].id, 'AISETUP', 's') or nil - PARTS[i].GeneralParameters = {} + PARTS[i].sBTLInfo = EgtGetInfo( PARTS[i].id, 'PROJ', 's') or nil -- si carica configurazione lavorazioni BeamExec.GetStrategiesFromJSONinBD( PARTS[i].sAISetupConfig) - -- TODO leggere qui i parametri generali pezzo? + PARTS[i].GeneralParameters = BeamLib.GetPieceGeneralParameters( PARTS[i].id, PARTS[i].sBTLInfo, STRATEGIES[PARTS[i].sAISetupConfig], GENERAL_PARAMETERS_JSON) -- si carica configurazione lavorazioni -- sovramateriale in testa al pezzo local dDeltaS = max( PARTS[i].dPosX - ( dBarLen - dLen), 0) 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 70f3654..359ad32 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -35,7 +35,8 @@ 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 +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??? @@ -215,9 +216,10 @@ function BeamExec.GetGeneralParameters() return end - CompleteList = BeamLib.ImportFileJSON( sFile) + GENERAL_PARAMETERS_JSON = BeamLib.ImportFileJSON( sFile) - GENERAL_PARAMETERS = BeamLib.LoadGeneralParametersInList( CompleteList) + -- all'inizio si legge solo PROJECT e BTL. I parametri PIECE vengono letti direttamente dalle strategie + GENERAL_PARAMETERS = BeamLib.LoadGeneralParametersInList( GENERAL_PARAMETERS_JSON) end ------------------------------------------------------------------------------------------------------------- @@ -237,7 +239,10 @@ function BeamExec.GetStrategiesFromJSONinBD( sAISetupConfigName) -- metto la tabella letta nella lista globale STRATEGIES STRATEGIES[sAISetupConfigName] = {} - STRATEGIES[sAISetupConfigName].FeatureList = FeatureList.FEATURE + STRATEGIES[sAISetupConfigName].PROJECT = FeatureList.PROJECT + STRATEGIES[sAISetupConfigName].BTL = FeatureList.BTL + STRATEGIES[sAISetupConfigName].PIECE = FeatureList.PIECE + STRATEGIES[sAISetupConfigName].FEATURE = FeatureList.FEATURE STRATEGIES[sAISetupConfigName].sAISetupConfigName = sAISetupConfigName end end @@ -480,10 +485,10 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, b PARTS[i].NotClampableLength = { STD = { dHead = 0, dTail = 0}, SIDE = { dHead = 0, dTail = 0}, DOWN = { dHead = 0, dTail = 0}} PARTS[i].dHeadOverMaterial = dDeltaS PARTS[i].sAISetupConfig = EgtGetInfo( PARTS[i].id, 'AISETUP', 's') or nil - PARTS[i].GeneralParameters = {} + PARTS[i].sBTLInfo = EgtGetInfo( PARTS[i].id, 'PROJ', 's') or nil -- si carica configurazione lavorazioni BeamExec.GetStrategiesFromJSONinBD( PARTS[i].sAISetupConfig) - -- TODO leggere qui i parametri generali pezzo? + PARTS[i].GeneralParameters = BeamLib.GetPieceGeneralParameters( PARTS[i].id, PARTS[i].sBTLInfo, STRATEGIES[PARTS[i].sAISetupConfig], GENERAL_PARAMETERS_JSON) else local sOut = 'Error: part L(' .. EgtNumToString( dPartLen, 1) .. ') too big for raw part L(' .. EgtNumToString( dLen - 0.1, 1) .. ')' return false, sOut @@ -546,7 +551,7 @@ end 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 sAISetupConfigName and STRATEGIES[sAISetupConfigName] and #STRATEGIES[sAISetupConfigName].FeatureList > 0 then + 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 diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 340e656..73d2e0f 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -460,25 +460,28 @@ end -- TODO bisogna recuperare il nome del parametro NGE, perchè in questo caso è forzato ------------------------------------------------------------------------------------------------------------- -function BeamLib.GetPieceGeneralParameters( Part, sParameterName) - local sValue = nil - -- si caricano i parametri generali riferiti al pezzo - sValue = EgtGetInfo( Part.id, sParameterName, 's') - return sValue +function BeamLib.GetPieceGeneralParameters( idPart, idBTLInfo, StrategiesParameterList, DefaultGeneralParamList) + local GeneralParameters = {} + + -- TODO DA FARE!!! + -- da JSON leggere i parametri di default + -- vedere se sono settati ome nota su pezzo + -- vedere se sono settate nel BTLInfo del pezzo + -- vedere se sono settate nel PROJECT + + return GeneralParameters end ------------------------------------------------------------------------------------------------------------- local function GetInheritedParameter( Part, sSourceParamName) local sValue = nil if sSourceParamName and #sSourceParamName > 0 then - -- se il parametro è già stato letto if Part.GeneralParameters[sSourceParamName] then sValue = Part.GeneralParameters[sSourceParamName] - -- altrimenti lo recupero - else - Part.GeneralParameters[sSourceParamName] = BeamLib.GetPieceGeneralParameters( Part, sSourceParamName) - sValue = Part.GeneralParameters[sSourceParamName] or - GENERAL_PARAMETERS.PIECE[sSourceParamName] or GENERAL_PARAMETERS.BTL[sSourceParamName] or GENERAL_PARAMETERS.PROJECT[sSourceParamName] or nil + 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 @@ -543,7 +546,7 @@ 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 = {}, PIECE = {}} + local UpdatedParameters = { PROJECT = {}, BTL = {}} -- aggiornamento parametri PROJECT if DefaultGeneralParamList and DefaultGeneralParamList.PROJECT then local idProjectInfo = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'ProjectInfo') or GDB_ID.NULL @@ -566,53 +569,32 @@ function BeamLib.LoadGeneralParametersInList( DefaultGeneralParamList) end end - -- TODO GESTIRE IL CASO IN CUI IN UN PROGETTO CI SIANO PIU' DI UN BTL -- aggiornamento parametri BTL if DefaultGeneralParamList and DefaultGeneralParamList.BTL then - local idBTLInfo = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL - for i = 1, #DefaultGeneralParamList.BTL do - if DefaultGeneralParamList.BTL[i].sType == 'inherited' then - UpdatedParameters.BTL[DefaultGeneralParamList.BTL[i].sName] = UpdatedParameters.PROJECT[DefaultGeneralParamList.BTL[i].sName] - else - local sParamNameNGE = DefaultGeneralParamList.BTL[i].sNameNge - - local xParameterValue = EgtGetInfo( idBTLInfo, sParamNameNGE, 's') or DefaultGeneralParamList.BTL[i].sValue - -- salvataggio dato su lista con accesso diretto - if DefaultGeneralParamList.BTL[i].sType == 'b' then - UpdatedParameters.BTL[DefaultGeneralParamList.BTL[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true - elseif DefaultGeneralParamList.BTL[i].sType == 'd' then - if #DefaultGeneralParamList.BTL[i].sValue > 0 then - UpdatedParameters.BTL[DefaultGeneralParamList.BTL[i].sName] = tonumber( xParameterValue) - -- stringa vuota equivale a non passare alcun valore (deciderà la strategia) - else - UpdatedParameters.BTL[DefaultGeneralParamList.BTL[i].sName] = nil + -- TODO verificare perchè sembra non funzionare, mentre la EgtGetFirstNameInGroup restituiva l'ID + local BTLInfo = EgtGetNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL + for j = 1, #BTLInfo do + local BTLName = EgtGetInfo( BTLInfo[j], 'PROJ', 's') + for i = 1, #DefaultGeneralParamList.BTL do + if DefaultGeneralParamList.BTL[i].sType == 'inherited' then + UpdatedParameters.BTL[BTLName][DefaultGeneralParamList.BTL[i].sName] = UpdatedParameters.PROJECT[DefaultGeneralParamList.BTL[i].sName] + else + local sParamNameNGE = DefaultGeneralParamList.BTL[i].sNameNge + + local xParameterValue = EgtGetInfo( BTLInfo[j], sParamNameNGE, 's') or DefaultGeneralParamList.BTL[i].sValue + -- salvataggio dato su lista con accesso diretto + if DefaultGeneralParamList.BTL[i].sType == 'b' then + UpdatedParameters.BTL[BTLName][DefaultGeneralParamList.BTL[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true + elseif DefaultGeneralParamList.BTL[i].sType == 'd' then + if #DefaultGeneralParamList.BTL[i].sValue > 0 then + UpdatedParameters.BTL[BTLName][DefaultGeneralParamList.BTL[i].sName] = tonumber( xParameterValue) + -- stringa vuota equivale a non passare alcun valore (deciderà la strategia) + else + UpdatedParameters.BTL[BTLName][DefaultGeneralParamList.BTL[i].sName] = nil + end + else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' + UpdatedParameters.BTL[BTLName][DefaultGeneralParamList.BTL[i].sName] = xParameterValue end - else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' - UpdatedParameters.BTL[DefaultGeneralParamList.BTL[i].sName] = xParameterValue - end - end - end - end - - -- aggiornamento parametri PIECE (in questo momento si salva solo il default, poi lo si aggiorna pezzo per pezzo) - if DefaultGeneralParamList and DefaultGeneralParamList.PIECE then - for i = 1, #DefaultGeneralParamList.PIECE do - if DefaultGeneralParamList.PIECE[i].sType == 'inherited' then - UpdatedParameters.PIECE[DefaultGeneralParamList.PIECE[i].sName] = UpdatedParameters.BTL[DefaultGeneralParamList.PIECE[i].sName] or UpdatedParameters.PROJECT[DefaultGeneralParamList.PIECE[i].sName] - else - local xParameterValue = DefaultGeneralParamList.PIECE[i].sValue or nil - -- salvataggio dato su lista con accesso diretto - if DefaultGeneralParamList.PIECE[i].sType == 'b' then - UpdatedParameters.PIECE[DefaultGeneralParamList.PIECE[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true - elseif DefaultGeneralParamList.PIECE[i].sType == 'd' then - if #DefaultGeneralParamList.PIECE[i].sValue > 0 then - UpdatedParameters.PIECE[DefaultGeneralParamList.PIECE[i].sName] = tonumber( xParameterValue) - -- stringa vuota equivale a non passare alcun valore (deciderà la strategia) - else - UpdatedParameters.PIECE[DefaultGeneralParamList.PIECE[i].sName] = nil - end - else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' - UpdatedParameters.PIECE[DefaultGeneralParamList.PIECE[i].sName] = xParameterValue end end end @@ -835,16 +817,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 @@ -852,15 +834,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 diff --git a/Process.lua b/Process.lua index de88d5c..1206728 100644 --- a/Process.lua +++ b/Process.lua @@ -163,8 +163,6 @@ end local function GetDataConfig() -- recupero utensili dal magazzino BeamExec.GetToolsFromDB() - -- recupero parametri generali da progetto - BeamExec.GetGeneralParameters() -- TODO da gestire eventuali errori bloccanti return true end @@ -361,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 From 0f4f2458279138358e992243dc34dec4810ca41a Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Mon, 6 Oct 2025 10:43:53 +0200 Subject: [PATCH 3/5] In GetPieceGeneralParameters si leggono parametri forzati su pezzo --- BatchProcessNew.lua | 9 +++++++-- LuaLibs/BeamExec.lua | 9 +++++++-- LuaLibs/BeamLib.lua | 30 ++++++++++++++++++++++++------ 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 1457ea4..2bd6e7c 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -577,11 +577,16 @@ if bToProcess then 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].sAISetupConfig = EgtGetInfo( PARTS[i].id, 'AISETUP', 's') or nil 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].id, PARTS[i].sBTLInfo, STRATEGIES[PARTS[i].sAISetupConfig], GENERAL_PARAMETERS_JSON) -- si carica configurazione lavorazioni + PARTS[i].GeneralParameters = BeamLib.GetPieceGeneralParameters( PARTS[i].id, GENERAL_PARAMETERS_JSON) -- sovramateriale in testa al pezzo local dDeltaS = max( PARTS[i].dPosX - ( dBarLen - dLen), 0) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 359ad32..5f39cc7 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -484,11 +484,16 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, b 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].sAISetupConfig = EgtGetInfo( PARTS[i].id, 'AISETUP', 's') or nil 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].id, PARTS[i].sBTLInfo, STRATEGIES[PARTS[i].sAISetupConfig], GENERAL_PARAMETERS_JSON) + PARTS[i].GeneralParameters = BeamLib.GetPieceGeneralParameters( PARTS[i].id, GENERAL_PARAMETERS_JSON) else local sOut = 'Error: part L(' .. EgtNumToString( dPartLen, 1) .. ') too big for raw part L(' .. EgtNumToString( dLen - 0.1, 1) .. ')' return false, sOut diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 73d2e0f..309a7dc 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -460,14 +460,30 @@ end -- TODO bisogna recuperare il nome del parametro NGE, perchè in questo caso è forzato ------------------------------------------------------------------------------------------------------------- -function BeamLib.GetPieceGeneralParameters( idPart, idBTLInfo, StrategiesParameterList, DefaultGeneralParamList) +function BeamLib.GetPieceGeneralParameters( idPart, DefaultGeneralParamList) local GeneralParameters = {} - -- TODO DA FARE!!! - -- da JSON leggere i parametri di default - -- vedere se sono settati ome nota su pezzo - -- vedere se sono settate nel BTLInfo del pezzo - -- vedere se sono settate nel PROJECT + -- si salvano sul pezzo le note forzate, altrimenti si leggeranno dopo, quando si prendono i dati della strategia + for i = 1, #DefaultGeneralParamList.PIECE do + if DefaultGeneralParamList.PIECE[i].sType ~= 'inherited' then + + local sParamNameNGE = DefaultGeneralParamList.PIECE[i].sNameNge + local xParameterValue = EgtGetInfo( idPart, sParamNameNGE, 's') or DefaultGeneralParamList.PIECE[i].sValue + -- salvataggio dato su lista con accesso diretto + if DefaultGeneralParamList.PIECE[i].sType == 'b' then + GeneralParameters[DefaultGeneralParamList.PIECE[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true + elseif DefaultGeneralParamList.PIECE[i].sType == 'd' then + if #DefaultGeneralParamList.PIECE[i].sValue > 0 then + GeneralParameters[DefaultGeneralParamList.PIECE[i].sName] = tonumber( xParameterValue) + -- stringa vuota equivale a non passare alcun valore (deciderà la strategia) + else + GeneralParameters[DefaultGeneralParamList.PIECE[i].sName] = nil + end + else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' + GeneralParameters[DefaultGeneralParamList.PIECE[i].sName] = xParameterValue + end + end + end return GeneralParameters end @@ -550,6 +566,7 @@ function BeamLib.LoadGeneralParametersInList( DefaultGeneralParamList) -- aggiornamento parametri PROJECT if DefaultGeneralParamList and DefaultGeneralParamList.PROJECT 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.PROJECT do local sParamNameNGE = DefaultGeneralParamList.PROJECT[i].sNameNge local xParameterValue = EgtGetInfo( idProjectInfo, sParamNameNGE, 's') or DefaultGeneralParamList.PROJECT[i].sValue @@ -575,6 +592,7 @@ function BeamLib.LoadGeneralParametersInList( DefaultGeneralParamList) local BTLInfo = EgtGetNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL for j = 1, #BTLInfo do local BTLName = EgtGetInfo( BTLInfo[j], 'PROJ', 's') + UpdatedParameters.BTL[BTLName].sAISetupConfig = EgtGetInfo( BTLName, 'AISETUP', 's') or nil for i = 1, #DefaultGeneralParamList.BTL do if DefaultGeneralParamList.BTL[i].sType == 'inherited' then UpdatedParameters.BTL[BTLName][DefaultGeneralParamList.BTL[i].sName] = UpdatedParameters.PROJECT[DefaultGeneralParamList.BTL[i].sName] From 738b2af5027ed72261d8db2da6d30dabcd19b826 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Wed, 8 Oct 2025 11:53:01 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Nuova=20JSON=20=20dei=20parametri=20general?= =?UTF-8?q?i=20(FUNZIONI=20DA=20FARE),=20non=20esiste=20pi=C3=B9=20distinz?= =?UTF-8?q?ione=20PROJECT/BTL/PIECE,=20ma=20tutti=20i=20parametri=20sono?= =?UTF-8?q?=20settabili=20a=20tutti=20i=20livelli?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Strategies/GeneralParameters.json | 272 ++++++++++++++---------------- 1 file changed, 126 insertions(+), 146 deletions(-) diff --git a/Strategies/GeneralParameters.json b/Strategies/GeneralParameters.json index fcaf605..fca82fb 100644 --- a/Strategies/GeneralParameters.json +++ b/Strategies/GeneralParameters.json @@ -1,147 +1,127 @@ -{ - "PROJECT" : [ - { - "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": "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" - } - ], - "BTL" : [ - { - "sName": "GEN_sPieceRotation", - "sType": "inherited", - "sMinUserLevel": "1" - }, - { - "sName": "GEN_sMachiningStrategy", - "sType": "inherited", - "sMinUserLevel": "1" - } - ], - "PIECE" : [ - { - "sName": "GEN_sPieceRotation", - "sType": "inherited", - "sMinUserLevel": "1" - }, - { - "sName": "GEN_sMachiningStrategy", - "sType": "inherited", - "sMinUserLevel": "1" - } - ] -} \ No newline at end of file +[ + { + "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" + } +] From 810bf4f7abde9aa22fa3414ed9224c1496d57c3d Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Thu, 9 Oct 2025 08:33:52 +0200 Subject: [PATCH 5/5] Modificate funzioni per lettura e gestione parametri generali --- BatchProcessNew.lua | 4 +- LuaLibs/BeamExec.lua | 195 +++++++++++++++++++++++++---------------- LuaLibs/BeamLib.lua | 118 ++++++++++++------------- LuaLibs/FeatureLib.lua | 3 +- 4 files changed, 181 insertions(+), 139 deletions(-) diff --git a/BatchProcessNew.lua b/BatchProcessNew.lua index 2bd6e7c..8a2c12e 100644 --- a/BatchProcessNew.lua +++ b/BatchProcessNew.lua @@ -574,7 +574,6 @@ 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 @@ -586,7 +585,8 @@ if bToProcess then -- si carica configurazione lavorazioni BeamExec.GetStrategiesFromJSONinBD( PARTS[i].sAISetupConfig) - PARTS[i].GeneralParameters = BeamLib.GetPieceGeneralParameters( PARTS[i].id, GENERAL_PARAMETERS_JSON) + 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) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 5f39cc7..0c91f9f 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -239,43 +239,16 @@ function BeamExec.GetStrategiesFromJSONinBD( sAISetupConfigName) -- metto la tabella letta nella lista globale STRATEGIES STRATEGIES[sAISetupConfigName] = {} - STRATEGIES[sAISetupConfigName].PROJECT = FeatureList.PROJECT - STRATEGIES[sAISetupConfigName].BTL = FeatureList.BTL - STRATEGIES[sAISetupConfigName].PIECE = FeatureList.PIECE + STRATEGIES[sAISetupConfigName].GENERAL = FeatureList.GENERAL STRATEGIES[sAISetupConfigName].FEATURE = FeatureList.FEATURE - STRATEGIES[sAISetupConfigName].sAISetupConfigName = sAISetupConfigName 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) @@ -295,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 @@ -303,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 @@ -312,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 @@ -480,11 +479,10 @@ 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, 'PROJ', 's') or nil + 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 @@ -493,7 +491,9 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS, b -- si carica configurazione lavorazioni BeamExec.GetStrategiesFromJSONinBD( PARTS[i].sAISetupConfig) - PARTS[i].GeneralParameters = BeamLib.GetPieceGeneralParameters( PARTS[i].id, GENERAL_PARAMETERS_JSON) + 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 @@ -862,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 @@ -888,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 @@ -914,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] @@ -925,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 @@ -975,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 @@ -1275,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 @@ -1365,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 @@ -1379,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 @@ -1460,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 @@ -1517,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 @@ -1579,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 309a7dc..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) @@ -460,27 +460,32 @@ end -- TODO bisogna recuperare il nome del parametro NGE, perchè in questo caso è forzato ------------------------------------------------------------------------------------------------------------- -function BeamLib.GetPieceGeneralParameters( idPart, DefaultGeneralParamList) +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.PIECE do - if DefaultGeneralParamList.PIECE[i].sType ~= 'inherited' then - - local sParamNameNGE = DefaultGeneralParamList.PIECE[i].sNameNge - local xParameterValue = EgtGetInfo( idPart, sParamNameNGE, 's') or DefaultGeneralParamList.PIECE[i].sValue - -- salvataggio dato su lista con accesso diretto - if DefaultGeneralParamList.PIECE[i].sType == 'b' then - GeneralParameters[DefaultGeneralParamList.PIECE[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true - elseif DefaultGeneralParamList.PIECE[i].sType == 'd' then - if #DefaultGeneralParamList.PIECE[i].sValue > 0 then - GeneralParameters[DefaultGeneralParamList.PIECE[i].sName] = tonumber( xParameterValue) + 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.PIECE[i].sName] = nil + GeneralParameters[DefaultGeneralParamList[i].sName] = nil end else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' - GeneralParameters[DefaultGeneralParamList.PIECE[i].sName] = xParameterValue + 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 @@ -564,54 +569,49 @@ end function BeamLib.LoadGeneralParametersInList( DefaultGeneralParamList) local UpdatedParameters = { PROJECT = {}, BTL = {}} -- aggiornamento parametri PROJECT - if DefaultGeneralParamList and DefaultGeneralParamList.PROJECT then + 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.PROJECT do - local sParamNameNGE = DefaultGeneralParamList.PROJECT[i].sNameNge - local xParameterValue = EgtGetInfo( idProjectInfo, sParamNameNGE, 's') or DefaultGeneralParamList.PROJECT[i].sValue + 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.PROJECT[i].sType == 'b' then - UpdatedParameters.PROJECT[DefaultGeneralParamList.PROJECT[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true - elseif DefaultGeneralParamList.PROJECT[i].sType == 'd' then - if #DefaultGeneralParamList.PROJECT[i].sValue > 0 then - UpdatedParameters.PROJECT[DefaultGeneralParamList.PROJECT[i].sName] = tonumber( xParameterValue) + 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.PROJECT[i].sName] = nil + UpdatedParameters.PROJECT[DefaultGeneralParamList[i].sName] = nil end else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' - UpdatedParameters.PROJECT[DefaultGeneralParamList.PROJECT[i].sName] = xParameterValue + UpdatedParameters.PROJECT[DefaultGeneralParamList[i].sName] = xParameterValue end end - end - -- aggiornamento parametri BTL - if DefaultGeneralParamList and DefaultGeneralParamList.BTL then - -- TODO verificare perchè sembra non funzionare, mentre la EgtGetFirstNameInGroup restituiva l'ID + -- aggiornamento parametri BTL local BTLInfo = EgtGetNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL for j = 1, #BTLInfo do - local BTLName = EgtGetInfo( BTLInfo[j], 'PROJ', 's') - UpdatedParameters.BTL[BTLName].sAISetupConfig = EgtGetInfo( BTLName, 'AISETUP', 's') or nil - for i = 1, #DefaultGeneralParamList.BTL do - if DefaultGeneralParamList.BTL[i].sType == 'inherited' then - UpdatedParameters.BTL[BTLName][DefaultGeneralParamList.BTL[i].sName] = UpdatedParameters.PROJECT[DefaultGeneralParamList.BTL[i].sName] - else - local sParamNameNGE = DefaultGeneralParamList.BTL[i].sNameNge - - local xParameterValue = EgtGetInfo( BTLInfo[j], sParamNameNGE, 's') or DefaultGeneralParamList.BTL[i].sValue + 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.BTL[i].sType == 'b' then - UpdatedParameters.BTL[BTLName][DefaultGeneralParamList.BTL[i].sName] = xParameterValue == 'true' or xParameterValue == '1' or xParameterValue == true - elseif DefaultGeneralParamList.BTL[i].sType == 'd' then - if #DefaultGeneralParamList.BTL[i].sValue > 0 then - UpdatedParameters.BTL[BTLName][DefaultGeneralParamList.BTL[i].sName] = tonumber( xParameterValue) + 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.BTL[i].sName] = nil + UpdatedParameters.BTL[BTLName][DefaultGeneralParamList[i].sName] = nil end else --DefaultGeneralParamList[i].sType == 's' or DefaultGeneralParamList[i].sType == 'combo' - UpdatedParameters.BTL[BTLName][DefaultGeneralParamList.BTL[i].sName] = xParameterValue + UpdatedParameters.BTL[BTLName][DefaultGeneralParamList[i].sName] = xParameterValue end end end @@ -620,7 +620,7 @@ function BeamLib.LoadGeneralParametersInList( DefaultGeneralParamList) return UpdatedParameters end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.GetChainSawInitAngs( vtN, vtO, nInd) if BeamData.GetChainSawInitAngs then return BeamData.GetChainSawInitAngs( vtN, vtO, nInd) @@ -637,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 @@ -659,7 +659,7 @@ function BeamLib.GetBlockedAxis( nToolIndex, sBlockedAxis, b3Raw, vtTool, vtOut) return '' end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.BinaryToDecimal( dNumber) local sNumberToConvert = tostring( dNumber) local dResult = 0 @@ -674,7 +674,7 @@ function BeamLib.BinaryToDecimal( dNumber) return dResult end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.DecimalToBinary( dNumber) local sNumberToConvert = tostring( dNumber) local n = sNumberToConvert @@ -699,7 +699,7 @@ function BeamLib.DecimalToBinary( dNumber) return tonumber( sResult) end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.CalculateStringBinaryFormat( dNumber, CharNumber) local NumberString = tostring( dNumber) while #NumberString < CharNumber do @@ -709,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) @@ -743,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 @@ -751,7 +751,7 @@ function BeamLib.MergeTables( OriginalTable, InputTable) return result end ---------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- function BeamLib.FindEdgeBestOrientedAsDirection( Edges, vtDirection) local BestEdge = {} @@ -870,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