--BasicCustomerStrategies.lua by Egalware s.r.l. 2024/04/02 -- Libreria strategie di base disponibili per i clienti -- 2024/04/02 PRIMA VERSIONE CALCOLO LAVORAZIONI CON STRATEGIE -- Tabella per definizione modulo local BasicCustomerStrategies = {} -- Include require( 'EgtBase') -- Carico i dati globali local BeamData = require( 'BeamData') local BeamLib = require( 'BeamLib') local ID = require( 'Identity') -- TODO tabella da compleatare man mano che si inseriscono le varie strategie -- ESEMPIO SCRITTURA TABELLA CON STRATEGIE DISPONIBILI --------------------------------------------------------------------- -- Feature : Cut -- if ID.TipoFeature( Proc) then -- if Proc.Topology.sName == 'QQQQQQQQQ' then -- Strategies = { -- { sStrategyId = 'STR9999', -- Parameters = { -- { sName = 'Val_1', sValue = '15', sType = 'd'}, -- { sName = 'Val_2', sValue = 'false', sType = 'b'} -- } -- } -- { sStrategyId = 'STR9998'} -- } -- end -- end ---------------------------------------------------------------------------------- -- *** STRATEGIE *** ---------------------------------------------------------------------------------- ---------------------------------------------------------------------------------- -- *** EGALWARE *** ---------------------------------------------------------------------------------- local function GetStrategies_Egalware( Proc) local Strategies = {} local sFile = BEAM.BASEDIR .. '\\Strategies\\AvailableStrategyList.json' -- se non esiste file JSON, annullo la lista contenente le strategie if not EgtExistsFile( sFile) then return nil end local CompleteList = {} CompleteList.FeatureList = BeamLib.ImportFileJSON( sFile) Strategies = BeamLib.GetStrategiesFromList( Proc, CompleteList) -- si salva che la strategia è stata presa dallo standard if Strategies and #Strategies > 0 then Strategies.bIsBasicStrategy = true end return Strategies end ---------------------------------------------------------------------------------- -- *** ESSETRE *** ---------------------------------------------------------------------------------- local function GetStrategies_Essetre( Proc) local Strategies = {} --------------------------------------------------------------------- -- Feature : Cut (1-340) if ID.IsHeadCut( Proc) then Strategies = { { sStrategyId = 'HEADCUT'}} --------------------------------------------------------------------- -- Feature : Cut (2-350) elseif ID.IsTailCut( Proc) then Strategies = { { sStrategyId = 'TAILCUT'}} --------------------------------------------------------------------- -- Feature : Cut (1-10) elseif ID.IsCut( Proc) then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0005'}} --------------------------------------------------------------------- -- Feature : Longitudinal Cut (0-10) elseif ID.IsLongitudinalCut( Proc) then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0005'}, { sStrategyId = 'STR0010'}} --------------------------------------------------------------------- -- Feature : Double Cut (1-11) elseif ID.IsDoubleCut( Proc) then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0005'}} --------------------------------------------------------------------- -- Feature : Ridge or Valley Cut (0-12) elseif ID.IsDoubleLongitudinalCut( Proc) then Strategies = { { sStrategyId = 'STR0005'}, { sStrategyId = 'STR0010'}} --------------------------------------------------------------------- -- Feature : Saw Cut (0-13) elseif ID.IsSawCut( Proc) then --------------------------------------------------------------------- -- Feature : Slot (0-16) elseif ID.IsSlot( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Tunnel-4-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Bevel-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Rabbet-2-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} end --------------------------------------------------------------------- -- Feature : Front Slot (0-17) elseif ID.IsFrontSlot( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Tunnel-4-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Bevel-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Rabbet-2-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} end --------------------------------------------------------------------- -- Feature : Birds Mouth (0-20) elseif ID.IsBirdsMouth( Proc) then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} --------------------------------------------------------------------- -- Feature : Hip or Valley Rafter Notch (0-25) elseif ID.IsHipValleyRafterNotch( Proc) then --------------------------------------------------------------------- -- Feature : Ridge Lap (1-30) elseif ID.IsRidgeLap( Proc) then if Proc.Topology.sName == 'RidgeLap-3-Through' then Strategies = { { sStrategyId = 'STR0012'}} elseif Proc.Topology.sName == 'Groove-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Bevel-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Rabbet-2-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} elseif Proc.Topology.sName == 'Cut-1-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0005'}} end --------------------------------------------------------------------- -- Feature : Lap Joint (0-30) elseif ID.IsLapJoint( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Tunnel-4-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Bevel-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Rabbet-2-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} end --------------------------------------------------------------------- -- Feature : Notch/Rabbet (0-32) elseif ID.IsNotchRabbet( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Tunnel-4-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Bevel-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Rabbet-2-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} end --------------------------------------------------------------------- -- Feature : Block Haus (0-33) elseif ID.IsBlockHaus( Proc) then if Proc.Topology.sName == 'Groove-3-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} end --------------------------------------------------------------------- -- Feature : Notch (0-32) elseif ID.IsNotch( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Tunnel-4-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Bevel-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Rabbet-2-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} end --------------------------------------------------------------------- -- Feature : French Ridge Lap (1-35) elseif ID.IsFrenchRidgeLap( Proc) then --------------------------------------------------------------------- -- Feature : Chamfer (0-36) elseif ID.IsChamfer( Proc) then --------------------------------------------------------------------- -- Feature : Block Haus Half Lap (0-37) elseif ID.IsHalfBlockHaus( Proc) then --------------------------------------------------------------------- -- Feature : Block Haus Front (0-38) elseif ID.IsFrontBlockHaus( Proc) then --------------------------------------------------------------------- -- Feature : Pocket (0-39) elseif ID.IsPocket( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Tunnel-4-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Bevel-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Rabbet-2-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} end --------------------------------------------------------------------- -- Feature : Drilling (0-40) elseif ID.IsDrilling( Proc) then Strategies = { { sStrategyId = 'STR0011'}} --------------------------------------------------------------------- -- Feature : Tenon (1-50) elseif ID.IsTenon( Proc) then Strategies = { { sStrategyId = 'STR0006'}} --------------------------------------------------------------------- -- Feature : Mortise (0-50) elseif ID.IsMortise( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Tunnel-4-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Bevel-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Rabbet-2-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} elseif Proc.Topology.sName == 'Pocket-Round' or Proc.Topology.sName == 'Pocket-Round-Front' or Proc.Topology.sName == 'Pocket-Round-Through' then Strategies = { { sStrategyId = 'STR0008'}} end --------------------------------------------------------------------- -- Feature : Front Mortise (0-51) elseif ID.IsFrontMortise( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Tunnel-4-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}, { sStrategyId = 'STR0004'}} elseif Proc.Topology.sName == 'Groove-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Bevel-3-Blind' then Strategies = { { sStrategyId = 'STR0002'}} elseif Proc.Topology.sName == 'Rabbet-2-Through' then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} elseif Proc.Topology.sName == 'Pocket-Round' or Proc.Topology.sName == 'Pocket-Round-Front' or Proc.Topology.sName == 'Pocket-Round-Through' then Strategies = { { sStrategyId = 'STR0008'}} end --------------------------------------------------------------------- -- Feature : House (1-52) elseif ID.IsHouse( Proc) then --------------------------------------------------------------------- -- Feature : House Mortise (0-53) elseif ID.IsHouseMortise( Proc) then --------------------------------------------------------------------- -- Feature : Dovetail Tenon (1-55) elseif ID.IsDovetailTenon( Proc) then Strategies = { { sStrategyId = 'STR0001'}} --------------------------------------------------------------------- -- Feature : Dovetail Mortise (0-55) elseif ID.IsDovetailMortise( Proc) then Strategies = { { sStrategyId = 'STR0007'}} --------------------------------------------------------------------- -- Feature : Dovetail Mortise Front (0-56) elseif ID.IsFrontDovetailMortise( Proc) then Strategies = { { sStrategyId = 'STR0007'}} --------------------------------------------------------------------- -- Feature : Marking (0-60) elseif ID.IsMarking( Proc) then --------------------------------------------------------------------- -- Feature : Text (0-61) elseif ID.IsText( Proc) then --------------------------------------------------------------------- -- Feature : Scarf Simple (1-70) elseif ID.IsScarfSimple( Proc) then --------------------------------------------------------------------- -- Feature : Scarf Joint (1-71) elseif ID.IsScarfJoint( Proc) then --------------------------------------------------------------------- -- Feature : Step Joint (1-80) elseif ID.IsStepJoint( Proc) then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} --------------------------------------------------------------------- -- Feature : Step Joint Notch (0-80) elseif ID.IsStepJointNotch( Proc) then Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0010'}} --------------------------------------------------------------------- -- Feature : Planing (0-90) elseif ID.IsPlaning( Proc) then --------------------------------------------------------------------- -- Feature : Front Profile (0-100) elseif ID.IsFrontProfile( Proc) then --------------------------------------------------------------------- -- Feature : Head Concave Profile (0-101) elseif ID.IsHeadConcaveProfile( Proc) then --------------------------------------------------------------------- -- Feature : Head Convex Profile (0-102) elseif ID.IsHeadConvexProfile( Proc) then Strategies = { { sStrategyId = 'STR0009'}} --------------------------------------------------------------------- -- Feature : Head Cambered Profile (0-103) elseif ID.IsHeadCamberedProfile( Proc) then --------------------------------------------------------------------- -- Feature : Round Arch (0-104) elseif ID.IsRoundArch( Proc) then Strategies = { { sStrategyId = 'STR0009'}} --------------------------------------------------------------------- -- Feature : Head Profile (0-106) elseif ID.IsHeadProfile( Proc) then --------------------------------------------------------------------- -- Feature : Sphere (0-107) elseif ID.IsSphere( Proc) then --------------------------------------------------------------------- -- Feature : Triangle Cut (0-120) elseif ID.IsTriangleCut( Proc) then --------------------------------------------------------------------- -- Feature : TyroleanDovetail (0-136) elseif ID.IsTyroleanDovetail( Proc) then --------------------------------------------------------------------- -- Feature : Dovetail (0-138) elseif ID.IsDovetail( Proc) then --------------------------------------------------------------------- -- Feature : Free Contour (0-250) elseif ID.IsFreeContour( Proc) then --------------------------------------------------------------------- -- Feature : Outline (0-251) elseif ID.IsOutline( Proc) then --------------------------------------------------------------------- -- Feature : Aperture (0-252) elseif ID.IsAperture( Proc) then --------------------------------------------------------------------- -- Feature : Variant (0-900) elseif ID.IsVariant( Proc) then --------------------------------------------------------------------- end -- si salva che la strategia è stata presa dallo script if #Strategies > 0 then Strategies.bIsBasicStrategy = true end return Strategies end ---------------------------------------------------------------------------------- -- *** PARAMETRI *** ---------------------------------------------------------------------------------- ---------------------------------------------------------------------------------- -- *** ESSETRE *** ---------------------------------------------------------------------------------- -- funzione che recupera i paraemtri custom della strategia. Per cliente Essetre, vengono salvati dei valori 'Q' sul processing del file NGE per modificare il comportamento delle macro local function GetParameters_Essetre( Proc, sStrategyIdToGet) local Parameters = {} -- Feature : Cut (1-340) if ID.IsHeadCut( Proc) then -- Per Essetre non esiste il taglio di testa, quindi si leggono le variabili Q sul processing che coincide con il taglio di testa if sStrategyIdToGet == 'HEADCUT' then local dDepthChamfer = 0 -- eventuali informazioni da recuperare sulla feature sostituita if Proc.SlaveProcIndexes then local idSlaveProc = PROCESSINGS[Proc.idPart].Rotation[Proc.nCurrentRotation][Proc.SlaveProcIndexes[1]].id dDepthChamfer = EgtGetInfo( idSlaveProc or GDB_ID.NULL, 'Q06', 'd') or 0 end Parameters = { { sName = 'dDepthChamfer', sValue = dDepthChamfer, sType = 'd'}} end end return Parameters end ---------------------------------------------------------------------------------- -- *** Esecuzione *** ---------------------------------------------------------------------------------- -- 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 = {} -- CLIENTE : ESSETRE if BeamData.STRATEGIES_SCRIPT == 'Essetre' then StrategiesFromScript = GetStrategies_Essetre( Proc) -- se nessuno script specifico in BeamData, si carica standard di default EGALWARE elseif not BeamData.STRATEGIES_SCRIPT or BeamData.STRATEGIES_SCRIPT == 'Egalware' then StrategiesFromScript = GetStrategies_Egalware( Proc) else StrategiesFromScript = nil end return StrategiesFromScript end ---------------------------------------------------------------------------------- -- lettura parametri che personalizzano le strategie. I parametri di default sono decisi con cliente function BasicCustomerStrategies.GetParametersFromBasicCustomerStrategies( Proc, sStrategyIdToGet) local ParametersFromScript = {} -- CLIENTE : ESSETRE if BeamData.STRATEGIES_SCRIPT == 'Essetre' then ParametersFromScript = GetParameters_Essetre( Proc, sStrategyIdToGet) else ParametersFromScript = nil end return ParametersFromScript end ------------------------------------------------------------------------------------------------------------- return BasicCustomerStrategies