- BasicCustomerStrategies Egalware sono lette ora da JSON. Quelle Essetre restano nel lua.
- Corretta formattazione AvailableStrategyList.json
This commit is contained in:
+16
-52
@@ -210,21 +210,6 @@ function BeamExec.GetToolsFromDB()
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function 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 BeamExec.GetStrategiesFromJSONinBD()
|
||||
-- si legge il JSON contenente la configurazione da utilizzare (nome del file salvato nel BeamData)
|
||||
@@ -238,7 +223,7 @@ function BeamExec.GetStrategiesFromJSONinBD()
|
||||
end
|
||||
|
||||
local FeatureList = {}
|
||||
FeatureList = ImportFileJSON( sFile)
|
||||
FeatureList = BeamLib.ImportFileJSON( sFile)
|
||||
|
||||
-- metto la tabella letta nella lista globale STRATEGIES
|
||||
STRATEGIES = {}
|
||||
@@ -546,49 +531,28 @@ end
|
||||
-- *** Inserimento delle lavorazioni nelle travi ***
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local function GetStrategiesFromGlobalList( Proc)
|
||||
-- cerco tra le feature
|
||||
for i = 1, #STRATEGIES.FeatureList do
|
||||
-- se trovo la feature
|
||||
if Proc.nPrc == STRATEGIES.FeatureList[i].nPrc then
|
||||
local bGroupIsCompatible = false
|
||||
-- nel JSON il gruppo è sempre 0/1, mente da BTL possono arrivare altri valori.
|
||||
if STRATEGIES.FeatureList[i].nGrp == 0 then
|
||||
if Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4 then
|
||||
bGroupIsCompatible = true
|
||||
end
|
||||
elseif STRATEGIES.FeatureList[i].nGrp == 1 then
|
||||
if Proc.nGrp == 1 or Proc.nGrp == 2 then
|
||||
bGroupIsCompatible = true
|
||||
end
|
||||
end
|
||||
|
||||
-- si controlla gruppo
|
||||
if bGroupIsCompatible then
|
||||
-- cerco tra le topologie
|
||||
for j = 1, #STRATEGIES.FeatureList[i].TopologyList do
|
||||
-- se trovo la topologia
|
||||
if Proc.Topology.sName == STRATEGIES.FeatureList[i].TopologyList[j].sName then
|
||||
-- ritorno le strategie disponibili per la feature che sto analizzando
|
||||
return BeamLib.TableCopyDeep( STRATEGIES.FeatureList[i].TopologyList[j].StrategyList)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function GetStrategies( Proc)
|
||||
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 = GetStrategiesFromGlobalList( Proc)
|
||||
AvailableStrategiesForProc = BeamLib.GetStrategiesFromList( Proc, STRATEGIES)
|
||||
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
|
||||
AvailableStrategiesForProc = BCS.GetStrategiesFromBasicCustomerStrategies( Proc)
|
||||
-- se ci sono strategie disponibili, si recuperano eventuali parametri custom
|
||||
if AvailableStrategiesForProc then
|
||||
for i = 1, #AvailableStrategiesForProc do
|
||||
-- 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 AvailableStrategiesForProc.bIsBasicStrategy then
|
||||
-- essendo una strategia basic, la lista dei parametri custom dovrebbe essere sempre vuota. Si leggono ora
|
||||
if not AvailableStrategiesForProc[i].ParameterList then
|
||||
AvailableStrategiesForProc[i].ParameterList = BCS.GetParametersFromBasicCustomerStrategies( Proc, AvailableStrategiesForProc[i].sStrategyId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return AvailableStrategiesForProc
|
||||
end
|
||||
@@ -855,9 +819,9 @@ local function RunStrategyLibraries( sStrategyId)
|
||||
-- se config strategia non ancora caricato, importo il JSON
|
||||
if not STRATEGIES_CONFIG[sStrategyId] then
|
||||
if EgtExistsFile( StrategyConfigPathStandard) then
|
||||
STRATEGIES_CONFIG[sStrategyId] = ImportFileJSON( StrategyConfigPathStandard)
|
||||
STRATEGIES_CONFIG[sStrategyId] = BeamLib.ImportFileJSON( StrategyConfigPathStandard)
|
||||
else
|
||||
STRATEGIES_CONFIG[sStrategyId] = ImportFileJSON( StrategyConfigPathSpecial)
|
||||
STRATEGIES_CONFIG[sStrategyId] = BeamLib.ImportFileJSON( StrategyConfigPathSpecial)
|
||||
end
|
||||
end
|
||||
StrategyLib.Config = STRATEGIES_CONFIG[sStrategyId]
|
||||
|
||||
Reference in New Issue
Block a user