From 7193f2595d033f757ed8601c546de939e04030d4 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 19 Apr 2024 09:59:59 +0200 Subject: [PATCH 1/5] =?UTF-8?q?-=20Per=20valori=20default=20strategia=20si?= =?UTF-8?q?=20legge=20Config.lua=20e=20non=20pi=C3=B9=20JSON-Strategia=20-?= =?UTF-8?q?=20piccole=20correzioni=20gestione=20lista=20strategie=20-=20cr?= =?UTF-8?q?eazione=20cartelle=20delle=20prime=20due=20strategie=20(vuote,?= =?UTF-8?q?=20solo=20per=20test)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/BasicCustomerStrategies.lua | 359 +++++++++++++++++++++++++-- LuaLibs/BeamExec.lua | 76 +++--- LuaLibs/FeatureData.lua | 9 +- Process.lua | 9 +- Strategies/STR0001/STR0001.lua | 0 Strategies/STR0001/STR0001Config.lua | 16 ++ Strategies/STR0002/STR0002.lua | 0 Strategies/STR0002/STR0002Config.lua | 0 8 files changed, 395 insertions(+), 74 deletions(-) create mode 100644 Strategies/STR0001/STR0001.lua create mode 100644 Strategies/STR0001/STR0001Config.lua create mode 100644 Strategies/STR0002/STR0002.lua create mode 100644 Strategies/STR0002/STR0002Config.lua diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index cd754ca..b9dd076 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -12,6 +12,343 @@ require( 'EgtBase') local BD = require( 'BeamData') local ID = require( 'Identity') + +---------------------------------------------------------------------------------- +-- *** EGALWARE *** +---------------------------------------------------------------------------------- +local function GetStrategies_Egalware( Proc) + local Strategy_Egalware = {} + local Strategies_Egalware = {} + + -- TODO tabella da compleatare man mano che si inseriscono le varie strategie + + -- Feature : Cut + if ID.IsCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Longitudinal Cut + elseif ID.IsLongitudinalCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Double Cut + elseif ID.IsDoubleCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Ridge or Valley Cut + elseif ID.IsDoubleLongitudinalCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Saw Cut + elseif ID.IsSawCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Slot + elseif ID.IsSlot( Proc) then + --------------------------------------------------------------------- + -- Feature : Front Slot + elseif ID.IsFrontSlot( Proc) then + --------------------------------------------------------------------- + -- Feature : Birds Mouth + elseif ID.IsBirdsMouth( Proc) then + --------------------------------------------------------------------- + -- Feature : Hip or Valley Rafter Notch + elseif ID.IsHipValleyRafterNotch( Proc) then + --------------------------------------------------------------------- + -- Feature : Ridge Lap + elseif ID.IsRidgeLap( Proc) then + --------------------------------------------------------------------- + -- Feature : Lap Joint + elseif ID.IsLapJoint( Proc) then + --------------------------------------------------------------------- + -- Feature : Notch/Rabbet + elseif ID.IsNotchRabbet( Proc) then + --------------------------------------------------------------------- + -- Feature : Block Haus + elseif ID.IsBlockHaus( Proc) then + --------------------------------------------------------------------- + -- Feature : Notch + elseif ID.IsNotch( Proc) then + --------------------------------------------------------------------- + -- Feature : French Ridge Lap + elseif ID.IsFrenchRidgeLap( Proc) then + --------------------------------------------------------------------- + -- Feature : Chamfer + elseif ID.IsChamfer( Proc) then + --------------------------------------------------------------------- + -- Feature : Block Haus Half Lap + elseif ID.IsHalfBlockHaus( Proc) then + --------------------------------------------------------------------- + -- Feature : Block Haus Front + elseif ID.IsFrontBlockHaus( Proc) then + --------------------------------------------------------------------- + -- Feature : Pocket + elseif ID.IsPocket( Proc) then + --------------------------------------------------------------------- + -- Feature : Drilling + elseif ID.IsDrilling( Proc) then + --------------------------------------------------------------------- + -- Feature : Tenon + elseif ID.IsTenon( Proc) then + --------------------------------------------------------------------- + -- Feature : Mortise + elseif ID.IsMortise( Proc) then + --------------------------------------------------------------------- + -- Feature : Front Mortise + elseif ID.IsFrontMortise( Proc) then + --------------------------------------------------------------------- + -- Feature : House + elseif ID.IsHouse( Proc) then + --------------------------------------------------------------------- + -- Feature : House Mortise + elseif ID.IsHouseMortise( Proc) then + --------------------------------------------------------------------- + -- Feature : Dovetail Tenon + elseif ID.IsDovetailTenon( Proc) then + --------------------------------------------------------------------- + -- Feature : Dovetail Mortise + elseif ID.IsDovetailMortise( Proc) then + --------------------------------------------------------------------- + -- Feature : Dovetail Mortise Front + elseif ID.IsFrontDovetailMortise( Proc) then + --------------------------------------------------------------------- + -- Feature : Marking + elseif ID.IsMarking( Proc) then + --------------------------------------------------------------------- + -- Feature : Text + elseif ID.IsText( Proc) then + --------------------------------------------------------------------- + -- Feature : Scarf Simple + elseif ID.IsScarfSimple( Proc) then + --------------------------------------------------------------------- + -- Feature : Scarf Joint + elseif ID.IsScarfJoint( Proc) then + --------------------------------------------------------------------- + -- Feature : Step Joint + elseif ID.IsStepJoint( Proc) then + --------------------------------------------------------------------- + -- Feature : Step Joint Notch + elseif ID.IsStepJointNotch( Proc) then + --------------------------------------------------------------------- + -- Feature : Planing + elseif ID.IsPlaning( Proc) then + --------------------------------------------------------------------- + -- Feature : Front Profile + elseif ID.IsFrontProfile( Proc) then + --------------------------------------------------------------------- + -- Feature : Head Concave Profile + elseif ID.IsHeadConcaveProfile( Proc) then + --------------------------------------------------------------------- + -- Feature : Head Convex Profile + elseif ID.IsHeadConvexProfile( Proc) then + --------------------------------------------------------------------- + -- Feature : Head Cambered Profile + elseif ID.IsHeadCamberedProfile( Proc) then + --------------------------------------------------------------------- + -- Feature : Round Arch + elseif ID.IsRoundArch( Proc) then + --------------------------------------------------------------------- + -- Feature : Head Profile + elseif ID.IsHeadProfile( Proc) then + --------------------------------------------------------------------- + -- Feature : Sphere + elseif ID.IsSphere( Proc) then + --------------------------------------------------------------------- + -- Feature : Triangle Cut + elseif ID.IsTriangleCut( Proc) then + --------------------------------------------------------------------- + -- Feature : TyroleanDovetail + elseif ID.IsTyroleanDovetail( Proc) then + --------------------------------------------------------------------- + -- Feature : Dovetail + elseif ID.IsDovetail( Proc) then + --------------------------------------------------------------------- + -- Feature : Free Contour + elseif ID.IsFreeContour( Proc) then + --------------------------------------------------------------------- + -- Feature : Outline + elseif ID.IsOutline( Proc) then + --------------------------------------------------------------------- + -- Feature : Aperture + elseif ID.IsAperture( Proc) then + --------------------------------------------------------------------- + -- Feature : Variant + elseif ID.IsVariant( Proc) then + end + + return Strategies_Egalware +end + +---------------------------------------------------------------------------------- +-- *** ESSETRE *** +---------------------------------------------------------------------------------- +local function GetStrategies_Essetre( Proc) + local Strategy_Essetre = {} + local Strategies_Essetre = {} + + -- TODO tabella da compleatare man mano che si inseriscono le varie strategie + + --------------------------------------------------------------------- + -- Feature : Cut + if ID.IsCut( Proc) then + if Proc.TopologyName == 'FEATURE' then + Strategy_Essetre = { + StrategyID = 'STR0001', + Parameters = { + { + { Value = '15', Name = 'Step', Description = 'Questo è lo step di lavorazione', Type = 'd'}, + { Value = '2', Name = 'Depth', Description = 'Affondamento lavorazione', Type = 'd'}, + { Value = 'false', Name = 'AntiSplint', Description = 'Antischeggia', Type = 'b'} + } + } + } + table.insert( Strategies_Essetre, Strategy_Essetre) + Strategy_Essetre = {} + end + --------------------------------------------------------------------- + -- Feature : Longitudinal Cut + elseif ID.IsLongitudinalCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Double Cut + elseif ID.IsDoubleCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Ridge or Valley Cut + elseif ID.IsDoubleLongitudinalCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Saw Cut + elseif ID.IsSawCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Slot + elseif ID.IsSlot( Proc) then + --------------------------------------------------------------------- + -- Feature : Front Slot + elseif ID.IsFrontSlot( Proc) then + --------------------------------------------------------------------- + -- Feature : Birds Mouth + elseif ID.IsBirdsMouth( Proc) then + --------------------------------------------------------------------- + -- Feature : Hip or Valley Rafter Notch + elseif ID.IsHipValleyRafterNotch( Proc) then + --------------------------------------------------------------------- + -- Feature : Ridge Lap + elseif ID.IsRidgeLap( Proc) then + --------------------------------------------------------------------- + -- Feature : Lap Joint + elseif ID.IsLapJoint( Proc) then + --------------------------------------------------------------------- + -- Feature : Notch/Rabbet + elseif ID.IsNotchRabbet( Proc) then + --------------------------------------------------------------------- + -- Feature : Block Haus + elseif ID.IsBlockHaus( Proc) then + --------------------------------------------------------------------- + -- Feature : Notch + elseif ID.IsNotch( Proc) then + --------------------------------------------------------------------- + -- Feature : French Ridge Lap + elseif ID.IsFrenchRidgeLap( Proc) then + --------------------------------------------------------------------- + -- Feature : Chamfer + elseif ID.IsChamfer( Proc) then + --------------------------------------------------------------------- + -- Feature : Block Haus Half Lap + elseif ID.IsHalfBlockHaus( Proc) then + --------------------------------------------------------------------- + -- Feature : Block Haus Front + elseif ID.IsFrontBlockHaus( Proc) then + --------------------------------------------------------------------- + -- Feature : Pocket + elseif ID.IsPocket( Proc) then + --------------------------------------------------------------------- + -- Feature : Drilling + elseif ID.IsDrilling( Proc) then + --------------------------------------------------------------------- + -- Feature : Tenon + elseif ID.IsTenon( Proc) then + --------------------------------------------------------------------- + -- Feature : Mortise + elseif ID.IsMortise( Proc) then + --------------------------------------------------------------------- + -- Feature : Front Mortise + elseif ID.IsFrontMortise( Proc) then + --------------------------------------------------------------------- + -- Feature : House + elseif ID.IsHouse( Proc) then + --------------------------------------------------------------------- + -- Feature : House Mortise + elseif ID.IsHouseMortise( Proc) then + --------------------------------------------------------------------- + -- Feature : Dovetail Tenon + elseif ID.IsDovetailTenon( Proc) then + --------------------------------------------------------------------- + -- Feature : Dovetail Mortise + elseif ID.IsDovetailMortise( Proc) then + --------------------------------------------------------------------- + -- Feature : Dovetail Mortise Front + elseif ID.IsFrontDovetailMortise( Proc) then + --------------------------------------------------------------------- + -- Feature : Marking + elseif ID.IsMarking( Proc) then + --------------------------------------------------------------------- + -- Feature : Text + elseif ID.IsText( Proc) then + --------------------------------------------------------------------- + -- Feature : Scarf Simple + elseif ID.IsScarfSimple( Proc) then + --------------------------------------------------------------------- + -- Feature : Scarf Joint + elseif ID.IsScarfJoint( Proc) then + --------------------------------------------------------------------- + -- Feature : Step Joint + elseif ID.IsStepJoint( Proc) then + --------------------------------------------------------------------- + -- Feature : Step Joint Notch + elseif ID.IsStepJointNotch( Proc) then + --------------------------------------------------------------------- + -- Feature : Planing + elseif ID.IsPlaning( Proc) then + --------------------------------------------------------------------- + -- Feature : Front Profile + elseif ID.IsFrontProfile( Proc) then + --------------------------------------------------------------------- + -- Feature : Head Concave Profile + elseif ID.IsHeadConcaveProfile( Proc) then + --------------------------------------------------------------------- + -- Feature : Head Convex Profile + elseif ID.IsHeadConvexProfile( Proc) then + --------------------------------------------------------------------- + -- Feature : Head Cambered Profile + elseif ID.IsHeadCamberedProfile( Proc) then + --------------------------------------------------------------------- + -- Feature : Round Arch + elseif ID.IsRoundArch( Proc) then + --------------------------------------------------------------------- + -- Feature : Head Profile + elseif ID.IsHeadProfile( Proc) then + --------------------------------------------------------------------- + -- Feature : Sphere + elseif ID.IsSphere( Proc) then + --------------------------------------------------------------------- + -- Feature : Triangle Cut + elseif ID.IsTriangleCut( Proc) then + --------------------------------------------------------------------- + -- Feature : TyroleanDovetail + elseif ID.IsTyroleanDovetail( Proc) then + --------------------------------------------------------------------- + -- Feature : Dovetail + elseif ID.IsDovetail( Proc) then + --------------------------------------------------------------------- + -- Feature : Free Contour + elseif ID.IsFreeContour( Proc) then + --------------------------------------------------------------------- + -- Feature : Outline + elseif ID.IsOutline( Proc) then + --------------------------------------------------------------------- + -- Feature : Aperture + elseif ID.IsAperture( Proc) then + --------------------------------------------------------------------- + -- Feature : Variant + elseif ID.IsVariant( Proc) then + end + + return Strategies_Essetre +end + + ---------------------------------------------------------------------------------- -- *** Esecuzione *** ---------------------------------------------------------------------------------- @@ -32,28 +369,6 @@ function BasicCustomerStrategies.GetStrategiesFromBasicCustomerStrategies( Proc) return StrategiesFromScript end ----------------------------------------------------------------------------------- --- *** EGALWARE *** ----------------------------------------------------------------------------------- -local function GetStrategies_Egalware( Proc) - local Strategy_Egalware = {} - local Strategies_Egalware = {} - - -- TODO tabella da compleatare man mano che si inseriscono le varie strategie - return Strategies_Egalware -end - ----------------------------------------------------------------------------------- --- *** ESSETRE *** ----------------------------------------------------------------------------------- -local function GetStrategies_Essetre( Proc) - local Strategy_Essetre = {} - local Strategies_Essetre = {} - - -- TODO tabella da compleatare man mano che si inseriscono le varie strategie - return Strategies_Essetre -end - ------------------------------------------------------------------------------------------------------------- return BasicCustomerStrategies \ No newline at end of file diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index b97ff7f..9cb3b01 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -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 diff --git a/LuaLibs/FeatureData.lua b/LuaLibs/FeatureData.lua index 4fb67f6..bb92361 100644 --- a/LuaLibs/FeatureData.lua +++ b/LuaLibs/FeatureData.lua @@ -132,6 +132,11 @@ local function GetFacesWithGivenAdjacencyNumber( Proc, vAdj) if not vAdj then vAdj = GetAdjacencyMatrix( Proc) end local nFct = #( vAdj or {}) local vFacesWithAdj = {} + vFacesWithAdj[1] = {} + vFacesWithAdj[2] = {} + vFacesWithAdj[3] = {} + vFacesWithAdj[4] = {} + vFacesWithAdj[5] = {} for i = 1, nFct do local nAdjCount = 0 for j = 1, nFct do @@ -163,7 +168,7 @@ end -- restituisce una stringa con il nome esteso della topologia della feature -- *famiglia - numero di facce - passante* local function GetTopologyName( sFamily, nNumberOfFaces, bIsThrough) - return sFamily .. '-' .. nNumberOfFaces .. '-' .. EgtIf( bIsThrough, 'Through', 'Blind') + return sFamily .. '-' .. tostring( nNumberOfFaces) .. '-' .. EgtIf( bIsThrough, 'Through', 'Blind') end --------------------------------------------------------------------- -- recupera topologia feature @@ -235,7 +240,7 @@ local function ClassifyTopology( Proc, b3Raw) FeatureTopology.Family = sFamily FeatureTopology.IsThrough = bIsThrough FeatureTopology.AllRightAngles = bAllRightAngles - FeatureTopology.Name = GetTopologyName( sFamily, bIsThrough, bAllRightAngles) + FeatureTopology.Name = GetTopologyName( sFamily, Proc.Fct, bIsThrough) FeatureTopology.vAdj = vAdj -- feature che necessita di essere catalogata, ma non si capisce come else diff --git a/Process.lua b/Process.lua index 3c824bc..19f868e 100644 --- a/Process.lua +++ b/Process.lua @@ -3,14 +3,16 @@ -- Si opera sulla macchina corrente -- 2024/04/02 PRIMA VERSIONE + -- Intestazioni require( 'EgtBase') _ENV = EgtProtectGlobal() EgtEnableDebug( true) --- TODO caricare strategie come librerie -- Imposto direttorio libreria specializzata per Travi EgtAddToPackagePath( BEAM.BASEDIR .. '\\LuaLibs\\?.lua') +-- Imposto direttorio strategie. N.B. Le strategie dovranno essere caricate con il nome del direttorio padre +EgtAddToPackagePath( BEAM.BASEDIR .. '\\Strategies') -- Verifico che la macchina corrente sia abilitata per la lavorazione delle Travi local sMachDir = EgtGetCurrMachineDir() @@ -34,6 +36,10 @@ EgtOutLog( '*** Beam Process Start ***', 1) _G.package.loaded.BeamExec = nil _G.package.loaded.BeamLib = nil _G.package.loaded.BeamData = nil +_G.package.loaded.Identity = nil +_G.package.loaded.BasicCustomerStrategies = nil +_G.package.loaded.FeatureData = nil + local BE = require( 'BeamExec') local BL = require( 'BeamLib') @@ -264,7 +270,6 @@ end -- *** Inserimento delle lavorazioni nelle travi *** ------------------------------------------------------------------------------------------------------------- local function MyProcessFeatures() - local bOk, Stats = BE.ProcessFeatures() local nErrCnt = 0 local nWarnCnt = 0 diff --git a/Strategies/STR0001/STR0001.lua b/Strategies/STR0001/STR0001.lua new file mode 100644 index 0000000..e69de29 diff --git a/Strategies/STR0001/STR0001Config.lua b/Strategies/STR0001/STR0001Config.lua new file mode 100644 index 0000000..27e090f --- /dev/null +++ b/Strategies/STR0001/STR0001Config.lua @@ -0,0 +1,16 @@ +-- Parametri configurabili da cliente per strategia: STR0001 + +local STR0001Data = { + { + StrategyID = 'STR0001', + Parameters = { + { + { Value = '15', Name = 'Step', Description = 'Questo è lo step di lavorazione', Type = 'd'}, + { Value = '2', Name = 'Depth', Description = 'Affondamento lavorazione', Type = 'd'}, + { Value = 'false', Name = 'AntiSplint', Description = 'Antischeggia', Type = 'b'} + } + } + } +} + +return STR0001Data \ No newline at end of file diff --git a/Strategies/STR0002/STR0002.lua b/Strategies/STR0002/STR0002.lua new file mode 100644 index 0000000..e69de29 diff --git a/Strategies/STR0002/STR0002Config.lua b/Strategies/STR0002/STR0002Config.lua new file mode 100644 index 0000000..e69de29 From bdc7c45204ef280a4186cff286690ff997252e47 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 19 Apr 2024 10:33:28 +0200 Subject: [PATCH 2/5] - Aggiunti HeadCut e SplitCut a Identify - Piccole correzioni lettura e salvataggio strategie lette da JSON su Vproc --- LuaLibs/BeamExec.lua | 4 ++-- LuaLibs/Identity.lua | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 9cb3b01..fb9ef13 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -388,7 +388,7 @@ local function GetStrategiesFromGlobalList( Proc) -- cerco tra le topologie for j = 1, #STRATEGIES.Features[i].Topologies do -- se trovo la topologia - if Proc.Topology.Name == #STRATEGIES.Features[i].Topologies[j].Name then + if Proc.Topology.Name == STRATEGIES.Features[i].Topologies[j].Name then -- ritorno le strategie disponibili per la feature che sto analizzando return STRATEGIES.Features[i].Topologies[j].Strategies end @@ -402,7 +402,7 @@ end local function GetStrategies( Proc) local AvailableStrategiesForProc = {} -- se la lista STRATEGIES è stata letta da JSON (quindi non è vuota), ritorno le strategie possibili - if STRATEGIES and #STRATEGIES > 0 then + if STRATEGIES and #STRATEGIES.Features > 0 then AvailableStrategiesForProc = GetStrategiesFromGlobalList( Proc) -- altrimenti lancio script che setta le strategie in modo statico, come definito con cliente else diff --git a/LuaLibs/Identity.lua b/LuaLibs/Identity.lua index 31fd1e1..9d4a4b6 100644 --- a/LuaLibs/Identity.lua +++ b/LuaLibs/Identity.lua @@ -5,6 +5,21 @@ -- Tabella per definizione modulo local Identity = {} +--------------------------------------------------------------------- +------------------ EGALWARE FEATURES ------------------------------ +--------------------------------------------------------------------- +-- Feature : Head Cut +function Identity.IsHeadCut( Proc) + return ( Proc.Grp == 1 and Proc.Prc == 340) +end +--------------------------------------------------------------------- +-- Feature : Split Cut +function Identity.IsSplitCut( Proc) + return ( Proc.Grp == 2 and Proc.Prc == 350) +end + +--------------------------------------------------------------------- +------------------ STANDARD FEATURES ------------------------------ --------------------------------------------------------------------- -- Feature : Cut function Identity.IsCut( Proc) From e58cf7e3982c6e9b53ddb733175d92b53f76f93a Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 19 Apr 2024 11:38:19 +0200 Subject: [PATCH 3/5] - BasicStrategies se JSON non presente o in JSON nessuna strategia --- LuaLibs/BasicCustomerStrategies.lua | 38 +++++++++++++++++++++++++---- LuaLibs/BeamExec.lua | 7 +++--- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index b9dd076..b47b5b3 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -22,8 +22,15 @@ local function GetStrategies_Egalware( Proc) -- TODO tabella da compleatare man mano che si inseriscono le varie strategie + --------------------------------------------------------------------- -- Feature : Cut - if ID.IsCut( Proc) then + if ID.IsHeadCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Cut + elseif ID.IsSplitCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Cut + elseif ID.IsCut( Proc) then --------------------------------------------------------------------- -- Feature : Longitudinal Cut elseif ID.IsLongitudinalCut( Proc) then @@ -184,7 +191,27 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Cut - if ID.IsCut( Proc) then + if ID.IsHeadCut( Proc) then + --------------------------------------------------------------------- + -- Feature : Cut + elseif ID.IsSplitCut( Proc) then + if Proc.TopologyName == 'FEATURE' then + Strategy_Essetre = { + StrategyID = 'STR0010', + Parameters = { + { + { Value = '15', Name = 'Step', Description = 'Questo è lo step di lavorazione', Type = 'd'}, + { Value = '2', Name = 'Depth', Description = 'Affondamento lavorazione', Type = 'd'}, + { Value = 'false', Name = 'AntiSplint', Description = 'Antischeggia', Type = 'b'} + } + } + } + table.insert( Strategies_Essetre, Strategy_Essetre) + Strategy_Essetre = {} + end + --------------------------------------------------------------------- + -- Feature : Cut + elseif ID.IsCut( Proc) then if Proc.TopologyName == 'FEATURE' then Strategy_Essetre = { StrategyID = 'STR0001', @@ -353,12 +380,13 @@ end -- *** Esecuzione *** ---------------------------------------------------------------------------------- --- si legge lo script delle strategie di base definito con cliente (statico e non modificabile) +-- script delle strategie di base standard definito con cliente (statico e non modificabile) +-- se non esiste JSON configurazione, o se non ha trovato nessuna strategia, prova a cercare in questi script function BasicCustomerStrategies.GetStrategiesFromBasicCustomerStrategies( Proc) local StrategiesFromScript = {} - -- se non esiste JSON e nessuan info in BeamData, si carica standard di default EGALWARE - if not STRATEGIES and not BD.STRATEGIES_SCRIPT then + -- se nessuno script specifico in BeamData, si carica standard di default EGALWARE + if not BD.STRATEGIES_SCRIPT or BD.STRATEGIES_SCRIPT == 'Egalware' then StrategiesFromScript = GetStrategies_Egalware( Proc) -- CLIENTE : ESSETRE elseif BD.STRATEGIES_SCRIPT == 'Essetre' then diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index fb9ef13..845d024 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -400,12 +400,13 @@ end ------------------------------------------------------------------------------------------------------------- local function GetStrategies( Proc) - local AvailableStrategiesForProc = {} + local AvailableStrategiesForProc = nil -- se la lista STRATEGIES è stata letta da JSON (quindi non è vuota), ritorno le strategie possibili if STRATEGIES and #STRATEGIES.Features > 0 then AvailableStrategiesForProc = GetStrategiesFromGlobalList( Proc) - -- altrimenti lancio script che setta le strategie in modo statico, come definito con cliente - else + 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) end -- TODO se ci sono strategie, posso caricare qui le varie librerie delle strategie. Oppure farlo quando si lanciano From ce156606e657ff18734cc0aa30a47b2a8845a57c Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 19 Apr 2024 11:51:48 +0200 Subject: [PATCH 4/5] - Corretto campo nome topologia --- LuaLibs/BasicCustomerStrategies.lua | 16 ++++++++-------- LuaLibs/BeamLib.lua | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index b47b5b3..a8e1d9b 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -195,14 +195,14 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Cut elseif ID.IsSplitCut( Proc) then - if Proc.TopologyName == 'FEATURE' then + if Proc.Topology.Name == 'FEATURE' then Strategy_Essetre = { StrategyID = 'STR0010', Parameters = { { - { Value = '15', Name = 'Step', Description = 'Questo è lo step di lavorazione', Type = 'd'}, - { Value = '2', Name = 'Depth', Description = 'Affondamento lavorazione', Type = 'd'}, - { Value = 'false', Name = 'AntiSplint', Description = 'Antischeggia', Type = 'b'} + { Value = '15', Name = 'Step', Type = 'd'}, + { Value = '2', Name = 'Depth', Type = 'd'}, + { Value = 'false', Name = 'AntiSplint', Type = 'b'} } } } @@ -212,14 +212,14 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Cut elseif ID.IsCut( Proc) then - if Proc.TopologyName == 'FEATURE' then + if Proc.Topology.Name == 'FEATURE' then Strategy_Essetre = { StrategyID = 'STR0001', Parameters = { { - { Value = '15', Name = 'Step', Description = 'Questo è lo step di lavorazione', Type = 'd'}, - { Value = '2', Name = 'Depth', Description = 'Affondamento lavorazione', Type = 'd'}, - { Value = 'false', Name = 'AntiSplint', Description = 'Antischeggia', Type = 'b'} + { Value = '15', Name = 'Step', Type = 'd'}, + { Value = '2', Name = 'Depth', Type = 'd'}, + { Value = 'false', Name = 'AntiSplint', Type = 'b'} } } } diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index e2f5142..723de89 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -177,7 +177,7 @@ function BeamLib.Is3EdgesApprox( Proc, nFacet, nAddGrpId) -- recupero il numero effettivo di lati local _, nEntityCount = EgtCurveDomain( nContourId) local nEdges = nEntityCount - if nEntityCount and nEntityCount == 3 then + if nEntityCount and nEntityCount == 3 then bResult = true -- rimuovo i lati molto corti dal conteggio totale elseif nEntityCount then From fb47b28173686297107f0baee9933272d2250f43 Mon Sep 17 00:00:00 2001 From: "andrea.villa" Date: Fri, 19 Apr 2024 12:49:21 +0200 Subject: [PATCH 5/5] - Librerie con nome esteso - Piccole correzioni dopo merge con Branch GetMainFaces --- LuaLibs/BasicCustomerStrategies.lua | 6 ++-- LuaLibs/BeamExec.lua | 48 +++++++++++++-------------- LuaLibs/BeamLib.lua | 3 -- LuaLibs/FaceData.lua | 50 +++++++++++++++-------------- LuaLibs/FeatureData.lua | 6 ++-- LuaLibs/MachiningLib.lua | 3 -- Process.lua | 50 ++++++++++++++--------------- 7 files changed, 81 insertions(+), 85 deletions(-) diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index a8e1d9b..3651fcf 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -9,7 +9,7 @@ local BasicCustomerStrategies = {} require( 'EgtBase') -- Carico i dati globali -local BD = require( 'BeamData') +local BeamData = require( 'BeamData') local ID = require( 'Identity') @@ -386,10 +386,10 @@ function BasicCustomerStrategies.GetStrategiesFromBasicCustomerStrategies( Proc) local StrategiesFromScript = {} -- se nessuno script specifico in BeamData, si carica standard di default EGALWARE - if not BD.STRATEGIES_SCRIPT or BD.STRATEGIES_SCRIPT == 'Egalware' then + if not BeamData.STRATEGIES_SCRIPT or BeamData.STRATEGIES_SCRIPT == 'Egalware' then StrategiesFromScript = GetStrategies_Egalware( Proc) -- CLIENTE : ESSETRE - elseif BD.STRATEGIES_SCRIPT == 'Essetre' then + elseif BeamData.STRATEGIES_SCRIPT == 'Essetre' then StrategiesFromScript = GetStrategies_Essetre( Proc) else StrategiesFromScript = nil diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 460fcbc..f01e37f 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -9,7 +9,7 @@ local BeamExec = {} require( 'EgtBase') -- Carico i dati globali -local BD = require( 'BeamData') +local BeamData = require( 'BeamData') -- carico librerie local BeamLib = require( 'BeamLib') @@ -20,7 +20,7 @@ local FaceData = require( 'FaceData') EgtOutLog( ' BeamExec started', 1) -EgtMdbSetGeneralParam( MCH_GP.MAXDEPTHSAFE, BD.COLL_SIC) +EgtMdbSetGeneralParam( MCH_GP.MAXDEPTHSAFE, BeamData.COLL_SIC) EgtMdbSave() ------------------------------------------------------------------------------------------------------------- @@ -192,8 +192,8 @@ end function BeamExec.GetStrategiesFromJSONinBD() -- si legge il JSON contenente la configurazione da utilizzare (nome del file salvato nel BeamData) local sMachDir = EgtGetCurrMachineDir() - if BD.STRATEGIES_CONFIG_FILE then - local sFile = sMachDir .. '\\Beam\\' .. BD.STRATEGIES_CONFIG_FILE + if BeamData.STRATEGIES_CONFIG_FILE then + local sFile = sMachDir .. '\\Beam\\' .. BeamData.STRATEGIES_CONFIG_FILE -- se non esiste file JSON, annullo la lista contenente le strategie if not EgtExistsFile( sFile) then STRATEGIES = nil @@ -215,8 +215,8 @@ end function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, bMachGroupOk) -- default per nuove costanti qualora non definite - BD.OVM_BLADE_HBEAM = ( BD.OVM_BLADE_HBEAM or 11) - BD.OVM_CHAIN_HBEAM = ( BD.OVM_CHAIN_HBEAM or 8) + BeamData.OVM_BLADE_HBEAM = ( BeamData.OVM_BLADE_HBEAM or 11) + BeamData.OVM_CHAIN_HBEAM = ( BeamData.OVM_CHAIN_HBEAM or 8) -- sovramateriale intermedio nullo se non definito dOvmMid = ( dOvmMid or 0) @@ -249,9 +249,9 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b -- Area tavola local b3Tab = EgtGetTableArea() -- Calcolo posizione estremo TR/BR della tavola rispetto a sua origine in BL - local dPosY = EgtIf( BD.CENTER_BEAM, ( b3Tab:getDimY() + dRawW * EgtIf( BD.RIGHT_LOAD, -1, 1)) / 2, EgtIf( BD.RIGHT_LOAD, 0, b3Tab:getDimY())) - BD.OriXR = Point3d( b3Tab:getDimX(), dPosY, 0) - BD.PosXR = EgtIf( BD.RIGHT_LOAD, MCH_CR.BR, MCH_CR.TR) + local dPosY = EgtIf( BeamData.CENTER_BEAM, ( b3Tab:getDimY() + dRawW * EgtIf( BeamData.RIGHT_LOAD, -1, 1)) / 2, EgtIf( BeamData.RIGHT_LOAD, 0, b3Tab:getDimY())) + BeamData.OriXR = Point3d( b3Tab:getDimX(), dPosY, 0) + BeamData.PosXR = EgtIf( BeamData.RIGHT_LOAD, MCH_CR.BR, MCH_CR.TR) -- Impostazione dell'attrezzaggio di default EgtImportSetup() @@ -262,7 +262,7 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b local nPrevRaw, dPrevDelta local DeltaS = dOvmHead local DeltaSMin = 0 - local DeltaE = BD.OVM_MID + local DeltaE = BeamData.OVM_MID for i = 1, #vBeam do -- assegno identificativo pezzo local Pz = vBeam[i].Id @@ -291,8 +291,8 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b local CrawLen = min( PartLen + DeltaS + DeltaE, Len) local Delta = CrawLen - PartLen - DeltaS -- creo e posiziono il grezzo - local nRaw = EgtAddRawPart( Point3d(0,0,0), CrawLen, dRawW, dRawH, BD.RAWCOL) - EgtMoveToCornerRawPart( nRaw, BD.OriXR, BD.PosXR) + local nRaw = EgtAddRawPart( Point3d(0,0,0), CrawLen, dRawW, dRawH, BeamData.RAWCOL) + EgtMoveToCornerRawPart( nRaw, BeamData.OriXR, BeamData.PosXR) EgtMoveRawPart( nRaw, Vector3d( Len - dRawL, 0, 0)) -- assegno ordine in lavorazione Cnt = Cnt + 1 @@ -339,7 +339,7 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b return false, sOut end -- se rimasto troppo poco grezzo, esco - --if Len < BD.MinRaw then break end + --if Len < BeamData.MinRaw then break end DeltaS = 0 end if nPrevRaw then @@ -348,8 +348,8 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b -- Se rimasto materiale aggiungo grezzo dell'avanzo if Len > 10 then - local nRaw = EgtAddRawPart( Point3d(0,0,0), Len, dRawW, dRawH, BD.RAWCOL) - EgtMoveToCornerRawPart( nRaw, BD.OriXR, BD.PosXR) + local nRaw = EgtAddRawPart( Point3d(0,0,0), Len, dRawW, dRawH, BeamData.RAWCOL) + EgtMoveToCornerRawPart( nRaw, BeamData.OriXR, BeamData.PosXR) EgtMoveRawPart( nRaw, Vector3d( Len - dRawL, 0, 0)) -- assegno ordine in lavorazione Cnt = Cnt + 1 @@ -361,19 +361,19 @@ end ------------------------------------------------------------------------------------------------------------- function BeamExec.CalcMinUnloadableRaw( dRawW, dRawH) - if BD.GetMinUnloadableRaw then - BD.MinRaw = BD.GetMinUnloadableRaw( dRawW, dRawH) + if BeamData.GetMinUnloadableRaw then + BeamData.MinRaw = BeamData.GetMinUnloadableRaw( dRawW, dRawH) else local H_S = 200 local H_L = 400 -- Determinazione minimo grezzo scaricabile if dRawH <= H_S then - BD.MinRaw = BD.MINRAW_S + BeamData.MinRaw = BeamData.MINRAW_S elseif dRawH <= H_L then local Coeff = ( dRawH - H_S) / ( H_L - H_S) - BD.MinRaw = ( 1 - Coeff) * BD.MINRAW_S + Coeff * BD.MINRAW_L + BeamData.MinRaw = ( 1 - Coeff) * BeamData.MINRAW_S + Coeff * BeamData.MINRAW_L else - BD.MinRaw = BD.MINRAW_L + BeamData.MinRaw = BeamData.MINRAW_L end end end @@ -549,9 +549,9 @@ local function GetFeatureInfoAndDependency( vProc, b3Raw) Proc.PassedByHole = true end -- verifiche per specchiature - if BD.DOWN_HEAD or BD.TWO_EQUAL_HEADS then + if BeamData.DOWN_HEAD or BeamData.TWO_EQUAL_HEADS then -- forature - if BD.DOUBLE_HEAD_DRILLING and ID.IsDrilling( Proc) and ID.IsDrilling( ProcB) and not Proc.Mirror then + if BeamData.DOUBLE_HEAD_DRILLING and ID.IsDrilling( Proc) and ID.IsDrilling( ProcB) and not Proc.Mirror then if AreDrillingsMirrored( Proc, ProcB, b3Raw) then Proc.Mirror = ProcB end @@ -572,12 +572,12 @@ function BeamExec.ProcessFeatures() while nRawId do -- verifico che il grezzo contenga pezzi oppure sia abbastanza lungo da essere scaricato coi carrelli local nPartId = EgtGetFirstPartInRawPart( nRawId) - if not nPartId and EgtGetRawPartBBox( nRawId):getDimX() < BD.MinRaw then break end + if not nPartId and EgtGetRawPartBBox( nRawId):getDimX() < BeamData.MinRaw then break end -- aggiungo la fase, se non è la prima if nOrd == 1 then EgtSetCurrPhase( 1) else - BeamLib.AddPhaseWithRawParts( nRawId, BD.OriXR, BD.PosXR, 0) + BeamLib.AddPhaseWithRawParts( nRawId, BeamData.OriXR, BeamData.PosXR, 0) end local nPhase = EgtGetCurrPhase() local nDispId = EgtGetPhaseDisposition( nPhase) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 7f73c2e..0d026fc 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -11,9 +11,6 @@ require( 'EgtBase') EgtOutLog( ' BeamLib started', 1) --- Dati -local BD = require( 'BeamData') - --TODO refactoring di queste funzioni ------------------------------------------------------------------------------------------------------------- diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index e42f737..b6662e1 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -5,9 +5,6 @@ -- Tabella per definizione modulo local FaceData = {} --- Carico i dati globali -local BD = require( 'BeamData') - -- carico librerie local BeamLib = require( 'BeamLib') @@ -68,6 +65,7 @@ local function GetAdjacentFaces( Proc, idFace) if vAdj[idFace + 1][i] and vAdj[idFace + 1][i] ~= 0 and ( idFace + 1 ~= i) then local _, ptP1, ptP2 = EgtSurfTmFacetsContact( Proc.Id, idFace, i - 1, GDB_ID.ROOT) local dLength = dist( ptP1, ptP2) + AdjacentFaces[i] = {} AdjacentFaces[i].Id = i - 1 AdjacentFaces[i].LengthOnMainFace = dLength end @@ -82,6 +80,9 @@ function FaceData.GetFacesByAdjacencyNumber( Proc) local FacesByAdjacencyNumber = {} for i = 1, Proc.Fct do + if not FacesByAdjacencyNumber[#Proc.Faces[i].Adjacencies] then + FacesByAdjacencyNumber[#Proc.Faces[i].Adjacencies] = {} + end table.insert( FacesByAdjacencyNumber[#Proc.Faces[i].Adjacencies], i - 1) end @@ -100,10 +101,10 @@ local function GetBottomFace( Proc) local dMinElevation = GEO.INFINITO for i = 1, #vBottomFace do for j = 1, Proc.Fct do - if vBottomFace[i] == Proc.Face[j].Id then - if Proc.Face[j].Elevation < dMinElevation then - dMinElevation = Proc.Face[j].Elevation - nBottomFace = Proc.Face[j].Id + if vBottomFace[i] == Proc.Faces[j].Id then + if Proc.Faces[j].Elevation < dMinElevation then + dMinElevation = Proc.Faces[j].Elevation + nBottomFace = Proc.Faces[j].Id end end end @@ -113,11 +114,11 @@ local function GetBottomFace( Proc) end BottomFace.Id = nBottomFace - BottomFace.FrameHV = Proc.Face[nBottomFace + 1].FrameHV - BottomFace.Width = Proc.Face[nBottomFace + 1].Width - BottomFace.Height = Proc.Face[nBottomFace + 1].Height - BottomFace.Elevation = Proc.Face[nBottomFace + 1].Elevation - BottomFace.VtN = Proc.Face[nBottomFace + 1].VtN + BottomFace.FrameHV = Proc.Faces[nBottomFace + 1].FrameHV + BottomFace.Width = Proc.Faces[nBottomFace + 1].Width + BottomFace.Height = Proc.Faces[nBottomFace + 1].Height + BottomFace.Elevation = Proc.Faces[nBottomFace + 1].Elevation + BottomFace.VtN = Proc.Faces[nBottomFace + 1].VtN return BottomFace end @@ -131,7 +132,7 @@ local function GetLongFaces( Proc) end local idBottomFace = GDB_ID.NULL - if Proc.MainFaces.BottomFace.Id then + if Proc.MainFaces.BottomFace and Proc.MainFaces.BottomFace.Id then idBottomFace = Proc.MainFaces.BottomFace.Id else local BottomFace = GetBottomFace( Proc) @@ -149,8 +150,8 @@ local function GetLongFaces( Proc) for i = 1, Proc.Fct do if ( i - 1) ~= idBottomFace and ( i - 1) ~= LongFaces[1].Id then local bIsAdjacent = false - for j = 1, #Proc.Face[i].Adjacences do - if Proc.Face[i].Adjacences[j].Id == LongFaces[i].Id then + for j = 1, #Proc.Faces[i].Adjacences do + if Proc.Faces[i].Adjacences[j].Id == LongFaces[i].Id then bIsAdjacent = true end end @@ -164,12 +165,12 @@ local function GetLongFaces( Proc) for i = 1, #LongFaces do for j = 1, Proc.Fct do - if LongFaces[i].Id == Proc.Face[j].Id then - LongFaces[i].Frame = Proc.Face[j].FrameHV - LongFaces[i].Width = Proc.Face[j].Width - LongFaces[i].Height = Proc.Face[j].Height - LongFaces[i].Elevation = Proc.Face[j].Elevation - LongFaces[i].VtN = Proc.Face[j].VtN + if LongFaces[i].Id == Proc.Faces[j].Id then + LongFaces[i].Frame = Proc.Faces[j].FrameHV + LongFaces[i].Width = Proc.Faces[j].Width + LongFaces[i].Height = Proc.Faces[j].Height + LongFaces[i].Elevation = Proc.Faces[j].Elevation + LongFaces[i].VtN = Proc.Faces[j].VtN end end end @@ -179,10 +180,11 @@ end ------------------------------------------------------------------------------------------------------------- function FaceData.GetFacesInfo( Proc, b3Raw) - Faces = {} + local Faces = {} local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Proc.PartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) for i = 1, Proc.Fct do + Faces[i] = {} Faces[i].Id = i - 1 Faces[i].VtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT ) if Proc.Fct < 6 then @@ -209,12 +211,12 @@ function FaceData.GetMainFaces( Proc) local MainFaces = {} -- faccia di fondo - if Proc.FeatureTopology.Family == 'Rabbet' or Proc.FeatureTopology.Family == 'VGroove' or Proc.FeatureTopology.Family == 'Groove' or Proc.FeatureTopology.Family == 'Pocket' then + if Proc.Topology.Family == 'Rabbet' or Proc.Topology.Family == 'VGroove' or Proc.Topology.Family == 'Groove' or Proc.Topology.Family == 'Pocket' then MainFaces.BottomFace = GetBottomFace( Proc) end -- facce lunghe - if Proc.FeatureTopology.Family == 'Rabbet' or Proc.FeatureTopology.Family == 'VGroove' or Proc.FeatureTopology.Family == 'Groove' or Proc.FeatureTopology.Family == 'Pocket' or Proc.FeatureTopology.Family == 'Tunnel' then + if Proc.Topology.Family == 'Rabbet' or Proc.Topology.Family == 'VGroove' or Proc.Topology.Family == 'Groove' or Proc.Topology.Family == 'Pocket' or Proc.Topology.Family == 'Tunnel' then MainFaces.LongFaces = GetLongFaces( Proc) end diff --git a/LuaLibs/FeatureData.lua b/LuaLibs/FeatureData.lua index 5a9fd8b..e6a83da 100644 --- a/LuaLibs/FeatureData.lua +++ b/LuaLibs/FeatureData.lua @@ -6,7 +6,7 @@ local FeatureData = {} -- Carico i dati globali -local BD = require( 'BeamData') +local BeamData = require( 'BeamData') -- carico librerie local BeamLib = require( 'BeamLib') @@ -222,8 +222,8 @@ function FeatureData.GetDrillingData( Proc) -- verifico se foro da adattare if EgtExistsInfo( Proc.Id, 'DiamUser') then if AuxId then AuxId = AuxId + Proc.Id end - if AuxId and EgtGetType( AuxId) == GDB_TY.CRV_ARC and BD.USER_HOLE_DIAM and BD.USER_HOLE_DIAM > 1 then - EgtModifyArcRadius( AuxId, BD.USER_HOLE_DIAM / 2) + if AuxId and EgtGetType( AuxId) == GDB_TY.CRV_ARC and BeamData.USER_HOLE_DIAM and BeamData.USER_HOLE_DIAM > 1 then + EgtModifyArcRadius( AuxId, BeamData.USER_HOLE_DIAM / 2) end end diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 2ce06e3..3f4b08c 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -10,8 +10,5 @@ require( 'EgtBase') EgtOutLog( ' MachiningLib started', 1) --- Dati -local BD = require( 'BeamData') - ------------------------------------------------------------------------------------------------------------- return MachiningLib diff --git a/Process.lua b/Process.lua index 19f868e..422ac4f 100644 --- a/Process.lua +++ b/Process.lua @@ -39,12 +39,12 @@ _G.package.loaded.BeamData = nil _G.package.loaded.Identity = nil _G.package.loaded.BasicCustomerStrategies = nil _G.package.loaded.FeatureData = nil +_G.package.loaded.FaceData = nil -local BE = require( 'BeamExec') -local BL = require( 'BeamLib') +local BeamExec = require( 'BeamExec') -- Carico i dati globali -local BD = require( 'BeamData') +local BeamData = require( 'BeamData') -- Variabili di modulo local vBeam = {} @@ -129,11 +129,11 @@ end ------------------------------------------------------------------------------------------------------------- local function GetDataConfig() -- recupero utensili dal magazzino - BE.GetToolsFromDB() + 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 - BE.GetStrategiesFromJSONinBD() + BeamExec.GetStrategiesFromJSONinBD() end -- TODO da gestire eventuali errori bloccanti return true @@ -144,23 +144,23 @@ end ------------------------------------------------------------------------------------------------------------- local function MyProcessBeams() -- Determinazione minimo grezzo scaricabile - BE.CalcMinUnloadableRaw( dRawW, dRawH) + BeamExec.CalcMinUnloadableRaw( dRawW, dRawH) -- Lunghezza totale delle travi local dTotLen = 0 for i = 1, #vBeam - 1 do dTotLen = dTotLen + vBeam[i].Box:getDimX() end - dTotLen = dTotLen + max( vBeam[#vBeam].Box:getDimX(), BD.MinRaw) - local dAddLen = BD.OVM_HEAD + ( #vBeam - 1) * BD.OVM_MID - EgtOutLog( 'Ltot : '..EgtNumToString( dTotLen, 1) .. ' Lagg : '..EgtNumToString( dAddLen, 1)..' MinUnloadRaw : '.. EgtNumToString( BD.MinRaw + BD.OVM_MID, 1), 1) + dTotLen = dTotLen + max( vBeam[#vBeam].Box:getDimX(), BeamData.MinRaw) + local dAddLen = BeamData.OVM_HEAD + ( #vBeam - 1) * BeamData.OVM_MID + EgtOutLog( 'Ltot : '..EgtNumToString( dTotLen, 1) .. ' Lagg : '..EgtNumToString( dAddLen, 1)..' MinUnloadRaw : '.. EgtNumToString( BeamData.MinRaw + BeamData.OVM_MID, 1), 1) -- Richiedo lunghezza del grezzo, sovramateriale di testa, forzatura verticale e ordinamento automatico secondo la lunghezza local vsVal = EgtDialogBox( 'Lavora Travi' .. ' (Ltot='..EgtNumToString( dTotLen + dAddLen + 0.5, 0).. - ', Lmax='..EgtNumToString( BD.MAX_RAW, 0)..',MinUlr='..EgtNumToString( BD.MinRaw + BD.OVM_MID, 0)..')', - {'Lunghezza grezzo', EgtNumToString( BD.STD_RAW, 0)}, - {'Sovramateriale di testa', EgtNumToString( BD.OVM_HEAD, 0)}, - {'Offset intermedio', EgtNumToString( BD.OVM_MID, 0)}, + ', Lmax='..EgtNumToString( BeamData.MAX_RAW, 0)..',MinUlr='..EgtNumToString( BeamData.MinRaw + BeamData.OVM_MID, 0)..')', + {'Lunghezza grezzo', EgtNumToString( BeamData.STD_RAW, 0)}, + {'Sovramateriale di testa', EgtNumToString( BeamData.OVM_HEAD, 0)}, + {'Offset intermedio', EgtNumToString( BeamData.OVM_MID, 0)}, {'Forza sezione verticale', ' CB:true,*false'}, {'Ordina per lunghezza', ' CB:true,*false'}, {'Calcolo Lavorazioni', ' CB:*Da progetto,Ricalcolo standard,Ricalcolo IA'}) @@ -177,7 +177,7 @@ local function MyProcessBeams() return false end if dRawL < GEO.EPS_SMALL then dRawL = dTotLen + dAddLen + 0.5 end - dRawL = min( dRawL, BD.MAX_RAW) + dRawL = min( dRawL, BeamData.MAX_RAW) local dOvmHead = EgtEvalNumExpr( vsVal[2]) if not dOvmHead then local sOut = 'Sovramateriale di testa errato : ' .. vsVal[2] @@ -203,21 +203,21 @@ local function MyProcessBeams() EgtOutLog( 'Lraw : ' .. EgtNumToString( dRawL, 1) .. ' Lovm : '.. EgtNumToString( dOvmHead, 1), 1) -- Verifico sezione barra non troppo grande - if not BD.MAX_WIDTH2 or not BD.MAX_HEIGHT2 then - if ( dRawW > BD.MAX_WIDTH + 10 * GEO.EPS_SMALL or dRawH > BD.MAX_HEIGHT + 10 * GEO.EPS_SMALL) then + if not BeamData.MAX_WIDTH2 or not BeamData.MAX_HEIGHT2 then + if ( dRawW > BeamData.MAX_WIDTH + 10 * GEO.EPS_SMALL or dRawH > BeamData.MAX_HEIGHT + 10 * GEO.EPS_SMALL) then local sOut = 'Sezione (' .. EgtNumToString( dRawW, 2) .. ' x ' .. EgtNumToString( dRawH, 2) .. ') ' .. - 'oltre i limiti della macchina (' .. EgtNumToString( BD.MAX_WIDTH, 2) .. ' x ' .. EgtNumToString( BD.MAX_HEIGHT, 2) .. ') ' + 'oltre i limiti della macchina (' .. EgtNumToString( BeamData.MAX_WIDTH, 2) .. ' x ' .. EgtNumToString( BeamData.MAX_HEIGHT, 2) .. ') ' EgtOutLog( sOut) EgtOutBox( sOut, 'Lavora Travi', 'WARNING') EgtDraw() return false end else - if ( dRawW > BD.MAX_WIDTH + 10 * GEO.EPS_SMALL or dRawH > BD.MAX_HEIGHT + 10 * GEO.EPS_SMALL) and - ( dRawW > BD.MAX_WIDTH2 + 10 * GEO.EPS_SMALL or dRawH > BD.MAX_HEIGHT2 + 10 * GEO.EPS_SMALL) then + if ( dRawW > BeamData.MAX_WIDTH + 10 * GEO.EPS_SMALL or dRawH > BeamData.MAX_HEIGHT + 10 * GEO.EPS_SMALL) and + ( dRawW > BeamData.MAX_WIDTH2 + 10 * GEO.EPS_SMALL or dRawH > BeamData.MAX_HEIGHT2 + 10 * GEO.EPS_SMALL) then local sOut = 'Sezione (' .. EgtNumToString( dRawW, 2) .. ' x ' .. EgtNumToString( dRawH, 2) .. ') ' .. - 'oltre i limiti della macchina (' .. EgtNumToString( BD.MAX_WIDTH, 2) .. ' x ' .. EgtNumToString( BD.MAX_HEIGHT, 2) .. ') ' .. - 'e (' .. EgtNumToString( BD.MAX_WIDTH2, 2) .. ' x ' .. EgtNumToString( BD.MAX_HEIGHT2, 2) .. ')' + 'oltre i limiti della macchina (' .. EgtNumToString( BeamData.MAX_WIDTH, 2) .. ' x ' .. EgtNumToString( BeamData.MAX_HEIGHT, 2) .. ') ' .. + 'e (' .. EgtNumToString( BeamData.MAX_WIDTH2, 2) .. ' x ' .. EgtNumToString( BeamData.MAX_HEIGHT2, 2) .. ')' EgtOutLog( sOut) EgtOutBox( sOut, 'Lavora Travi', 'WARNING') EgtDraw() @@ -226,9 +226,9 @@ local function MyProcessBeams() end -- Verifico sezione barra non troppo piccola - if dRawW < BD.MIN_WIDTH - 10 * GEO.EPS_SMALL or dRawH < BD.MIN_HEIGHT - 10 * GEO.EPS_SMALL then + if dRawW < BeamData.MIN_WIDTH - 10 * GEO.EPS_SMALL or dRawH < BeamData.MIN_HEIGHT - 10 * GEO.EPS_SMALL then local sOut = 'Sezione (' .. EgtNumToString( dRawW, 2) .. ' x ' .. EgtNumToString( dRawH, 2) .. ') ' .. - 'sotto i limiti della macchina (' .. EgtNumToString( BD.MIN_WIDTH, 2) .. ' x ' .. EgtNumToString( BD.MIN_HEIGHT, 2) .. ')' + 'sotto i limiti della macchina (' .. EgtNumToString( BeamData.MIN_WIDTH, 2) .. ' x ' .. EgtNumToString( BeamData.MIN_HEIGHT, 2) .. ')' EgtOutLog( sOut) EgtOutBox( sOut, 'Lavora Travi', 'WARNING') EgtDraw() @@ -256,7 +256,7 @@ local function MyProcessBeams() end -- Sistemo le travi nel grezzo - local bOk, sErr = BE.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam) + local bOk, sErr = BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam) if not bOk then EgtOutLog( sErr) EgtOutBox( sErr, 'Lavora Travi', 'ERROR') @@ -270,7 +270,7 @@ end -- *** Inserimento delle lavorazioni nelle travi *** ------------------------------------------------------------------------------------------------------------- local function MyProcessFeatures() - local bOk, Stats = BE.ProcessFeatures() + local bOk, Stats = BeamExec.ProcessFeatures() local nErrCnt = 0 local nWarnCnt = 0 local sOutput = ''