- Prima versione con gestione parametri generali

- Possibilità di aprire più configurazioni delle strategie
- Gestione parametri ereditati
- Nuovo JSON parametri generali
- Adeguamento strategie per gestione parametri generali
This commit is contained in:
andrea.villa
2025-10-03 11:15:17 +02:00
parent 1a14d156cf
commit a508b4bb94
25 changed files with 346 additions and 86 deletions
+115 -5
View File
@@ -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