- BasicCustomerStrategies Egalware sono lette ora da JSON. Quelle Essetre restano nel lua.
- Corretta formattazione AvailableStrategyList.json
This commit is contained in:
+54
-9
@@ -9,7 +9,6 @@ local BeamLib = {}
|
||||
-- Include
|
||||
require( 'EgtBase')
|
||||
local BeamData = require( 'BeamData')
|
||||
local BCS = require( 'BasicCustomerStrategies')
|
||||
|
||||
|
||||
EgtOutLog( ' BeamLib started', 1)
|
||||
@@ -429,14 +428,6 @@ function BeamLib.LoadCustomParametersInStrategy( Proc, CustomParameters, Default
|
||||
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
|
||||
-- se le strategie disponibili sono le basic, non si possono customizzare valori di default da interfaccia, si leggono allora eventuali parametri di default decisi con cliente
|
||||
if Proc.AvailableStrategies.bIsBasicStrategy then
|
||||
-- essendo una strategia basic, la lista dei parametri custom dovrebbe essere sempre vuota. Si leggono ora
|
||||
if not CustomParameters.ParameterList then
|
||||
CustomParameters.ParameterList = BCS.GetParametersFromBasicCustomerStrategies( Proc, CustomParameters.sStrategyId)
|
||||
end
|
||||
end
|
||||
|
||||
-- lettura e settaggio parametri finali per la strategia (customizzati o default)
|
||||
for i=1, #DefaultStrategyParamList.ParameterList do
|
||||
local xParameterValue = nil
|
||||
@@ -672,6 +663,59 @@ function BeamLib.PutStartNearestToEdge( nCrvId, b3Raw, dMaxDist, nNearSide)
|
||||
return true
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function BeamLib.ImportFileJSON( sFileToImport)
|
||||
local JSON = require( 'JSON')
|
||||
|
||||
local function readAll( sFileToImport)
|
||||
local f = io.open( sFileToImport, "rb")
|
||||
local content = f:read( "*all")
|
||||
f:close()
|
||||
return content
|
||||
end
|
||||
|
||||
local content = readAll( sFileToImport)
|
||||
return JSON:decode( content)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function BeamLib.GetStrategiesFromList( Proc, StrategyList)
|
||||
-- cerco tra le feature
|
||||
for i = 1, #StrategyList.FeatureList do
|
||||
-- se trovo la feature
|
||||
if Proc.nPrc == StrategyList.FeatureList[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 Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4 then
|
||||
bGroupIsCompatible = true
|
||||
end
|
||||
elseif StrategyList.FeatureList[i].nGrp == 1 then
|
||||
if Proc.nGrp == 1 or Proc.nGrp == 2 then
|
||||
bGroupIsCompatible = true
|
||||
end
|
||||
end
|
||||
|
||||
-- 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)
|
||||
else
|
||||
-- cerco tra le topologie
|
||||
for j = 1, #StrategyList.FeatureList[i].TopologyList do
|
||||
-- se trovo la topologia
|
||||
if Proc.Topology.sName == StrategyList.FeatureList[i].TopologyList[j].sName then
|
||||
-- ritorno le strategie disponibili per la feature che sto analizzando
|
||||
return BeamLib.TableCopyDeep( StrategyList.FeatureList[i].TopologyList[j].StrategyList)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
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??)
|
||||
@@ -724,5 +768,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
return BeamLib
|
||||
|
||||
Reference in New Issue
Block a user