- Per valori default strategia si legge Config.lua e non più JSON-Strategia
- piccole correzioni gestione lista strategie - creazione cartelle delle prime due strategie (vuote, solo per test)
This commit is contained in:
+28
-48
@@ -95,6 +95,8 @@ function BeamExec.GetToolsFromDB()
|
||||
|
||||
-- se verifica condizioni minime, recupero tutti gli altri dati
|
||||
if bToolLoadedOnSetup and sToolType then
|
||||
-- TODO Tool.AName -> da rimuovere perchè non serve. Per il momento lo manteniamo solo perchè è più facile vedere e interpretare la lista utensili nella watch di zerobrane
|
||||
-- Nell'utilizzo, si legge sempre il Tool.Name
|
||||
Tool.AName = Tool.Name
|
||||
Tool.TcPos = sToolTCPos
|
||||
Tool.Family = sToolFamily
|
||||
@@ -110,6 +112,7 @@ function BeamExec.GetToolsFromDB()
|
||||
Tool.Feeds.StartFeed = EgtTdbGetCurrToolParam( MCH_TP.STARTFEED)
|
||||
Tool.Feeds.EndFeed = EgtTdbGetCurrToolParam( MCH_TP.ENDFEED)
|
||||
Tool.Feeds.TipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED)
|
||||
-- TODO serve funzione in BeamData che data la posizione dell'utensile e della testa, capisca il montaggio (testa sopra - testa sotto - aggregato - ecc...)
|
||||
Tool.Head = EgtTdbGetCurrToolParam( MCH_TP.HEAD)
|
||||
Tool.UUID = EgtTdbGetCurrToolParam( MCH_TP.UUID)
|
||||
Tool.UserNotes = EgtTdbGetCurrToolParam( MCH_TP.USERNOTES)
|
||||
@@ -180,7 +183,6 @@ local function ImportFileJSON( sFileToImport)
|
||||
end
|
||||
|
||||
local content = readAll( sFileToImport)
|
||||
|
||||
return JSON:decode( content)
|
||||
end
|
||||
|
||||
@@ -190,7 +192,11 @@ function BeamExec.GetStrategiesFromJSONinBD()
|
||||
local sMachDir = EgtGetCurrMachineDir()
|
||||
if BD.STRATEGIES_CONFIG_FILE then
|
||||
local sFile = sMachDir .. '\\Beam\\' .. BD.STRATEGIES_CONFIG_FILE
|
||||
if not sFile then return end
|
||||
-- se non esiste file JSON, annullo la lista contenente le strategie
|
||||
if not EgtExistsFile( sFile) then
|
||||
STRATEGIES = nil
|
||||
return
|
||||
end
|
||||
|
||||
local FeaturesList = {}
|
||||
FeaturesList = ImportFileJSON( sFile)
|
||||
@@ -396,69 +402,43 @@ end
|
||||
local function GetStrategies( Proc)
|
||||
local AvailableStrategiesForProc = {}
|
||||
-- se la lista STRATEGIES è stata letta da JSON (quindi non è vuota), ritorno le strategie possibili
|
||||
if STRATEGIES then
|
||||
if STRATEGIES and #STRATEGIES > 0 then
|
||||
AvailableStrategiesForProc = GetStrategiesFromGlobalList( Proc)
|
||||
-- altrimenti lancio script che setta le strategie in modo statico, come definito con cliente
|
||||
else
|
||||
AvailableStrategiesForProc = BCS.GetStrategiesFromBasicCustomerStrategies( Proc)
|
||||
end
|
||||
-- TODO se ci sono strategie, posso caricare qui le varie librerie delle strategie
|
||||
-- TODO se ci sono strategie, posso caricare qui le varie librerie delle strategie. Oppure farlo quando si lanciano
|
||||
return AvailableStrategiesForProc
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function GetFeatureForcedStrategy( Proc)
|
||||
local ForcedStrategiesForProc = {}
|
||||
local ForcedStrategyForProc = {}
|
||||
local ForcedParametersForProc = {}
|
||||
local ForcedParameter = {}
|
||||
-- cerco nelle note se è stata forzata una strategia specifica
|
||||
local sStrategyID = EgtGetInfo( Proc.Id, 'STRATEGY', 's')
|
||||
|
||||
-- se è presente la strategia forzata
|
||||
if sStrategyID then
|
||||
-- importo JSON della strategia per leggere nomi parametri configurabili
|
||||
local sJSONFile = BEAM.BASEDIR .. '\\Strategies\\' .. sStrategyID .. '\\' .. sStrategyID .. '.lua'
|
||||
-- se non trovo file esco
|
||||
if not sJSONFile then return end
|
||||
local StrategyData = require( sStrategyID .. '\\' .. sStrategyID .. 'Config.lua')
|
||||
-- se ID strategia letto in NGE è differente da quello letto nella strategia, esco subito
|
||||
if StrategyData.StrategyID ~= sStrategyID then return nil end
|
||||
|
||||
local JSONStrategy = {}
|
||||
JSONStrategy = ImportFileJSON( sJSONFile)
|
||||
|
||||
-- cerco tra le feature del JSON strategia
|
||||
for i = 1, #JSONStrategy.Features do
|
||||
-- se trovo la feature
|
||||
if Proc.Prc == JSONStrategy.Features[i].Prc and Proc.Grp == JSONStrategy.Features[i].Grp then
|
||||
-- cerco tra le topologie
|
||||
for j = 1, #JSONStrategy.Features[i].Topologies do
|
||||
-- se trovo la topologia
|
||||
if Proc.Topology.Name == JSONStrategy.Features[i].Topologies[j].Name then
|
||||
-- leggo i parametri
|
||||
for k = 1, #JSONStrategy.Features[i].Topologies[j].Parameters do
|
||||
local sParameterNameToSearch = sStrategyID .. '_' .. JSONStrategy.Features[i].Topologies[j].Parameters[k].Name
|
||||
-- leggo i parametri configurabili della strategia sulla Proc
|
||||
local xValue = EgtGetInfo( Proc.Id, sParameterNameToSearch, JSONStrategy.Features[i].Topologies[j].Parameters[k].Type)
|
||||
-- salvo in lista il parametro letto se presente, altrimenti prendo quello nel JSON di default. Teoricamernte dovrebbero esserci sempre tutti
|
||||
if xValue then
|
||||
ForcedParameter.Value = xValue
|
||||
else
|
||||
ForcedParameter.Value = JSONStrategy.Features[i].Topologies[j].Parameters[k].Name
|
||||
end
|
||||
ForcedParameter.Name = JSONStrategy.Features[i].Topologies[j].Parameters[k].Name
|
||||
table.insert( ForcedStrategyForProc, ForcedParameter)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- cerco e aggiorno i parametri come sono settati nel processing
|
||||
for i = 1, #StrategyData do
|
||||
local sParameterToRead = StrategyData.StrategyID .. '_' .. StrategyData.Parameters[i].Name
|
||||
ForcedParameterForProc = EgtGetInfo( Proc.Id, sParameterToRead, 's')
|
||||
-- se ho trovato il valore, lo sovrascrivo al default
|
||||
if ForcedParameterForProc then
|
||||
StrategyData.Parameters[i].Value = ForcedParameterForProc
|
||||
end
|
||||
end
|
||||
|
||||
ForcedStrategyForProc.StrategyID = sStrategyID
|
||||
ForcedStrategyForProc.Parameters = ForcedParametersForProc
|
||||
-- per il momento sarà sempre e solo una strategia, ma la inserisco comunque in una lista per analogia con gestione standard
|
||||
table.insert( ForcedStrategiesForProc, ForcedStrategyForProc)
|
||||
else
|
||||
ForcedStrategiesForProc = nil
|
||||
-- ritorno la lista strategia con parametri
|
||||
local StrategyToProc = {}
|
||||
table.insert( StrategyToProc, StrategyData)
|
||||
return StrategyToProc
|
||||
end
|
||||
|
||||
return ForcedStrategiesForProc
|
||||
return nil
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
@@ -524,7 +504,7 @@ local function CollectFeatures( PartId, b3Raw)
|
||||
Proc.Strategies = GetStrategies( Proc)
|
||||
end
|
||||
-- se ci sono strategie disponibili, aggiungo a lista delle feature da lavorare
|
||||
if Proc.Strategies then
|
||||
if Proc.Strategies and #Proc.Strategies > 0 then
|
||||
table.insert( vProc, Proc)
|
||||
-- altrimenti errore (non ci sono strategie per lavorare la topologia riconosciuta)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user