diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index 29175e9..66aea4b 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -24,13 +24,13 @@ local function GetStrategies_Egalware( Proc) --------------------------------------------------------------------- -- Feature : Cut - if true or ID.IsHeadCut( Proc) then -- TODO TOGLIERE IL true PER FORZARE IF!!! PROVVISORIO PER PROVARE STRATEGIE + if ID.IsHeadCut( Proc) then -- TODO TOGLIERE IL true PER FORZARE IF!!! PROVVISORIO PER PROVARE STRATEGIE if Proc.Topology.Name == 'FEATURE' then Strategy_Egalware = { StrategyId = 'STR0001', Parameters = { - { Value = '15', Name = 'Step', Type = 'd'}, - { Value = 'false', Name = 'AntiSplint', Type = 'b'} + { Name = 'Step', Value = '15', Type = 'd'}, + { Name = 'AntiSplint', Value = 'false', Type = 'b'} } } table.insert( Strategies_Egalware, Strategy_Egalware) @@ -57,6 +57,11 @@ local function GetStrategies_Egalware( Proc) --------------------------------------------------------------------- -- Feature : Slot elseif ID.IsSlot( Proc) then + if Proc.Topology.Name == 'Pocket-5-Blind' then + Strategy_Egalware = { StrategyId = 'STR0002'} + table.insert( Strategies_Egalware, Strategy_Egalware) + Strategy_Egalware = {} + end --------------------------------------------------------------------- -- Feature : Front Slot elseif ID.IsFrontSlot( Proc) then @@ -96,6 +101,11 @@ local function GetStrategies_Egalware( Proc) --------------------------------------------------------------------- -- Feature : Pocket elseif ID.IsPocket( Proc) then + if Proc.Topology.Name == 'Pocket-5-Blind' then + Strategy_Egalware = { StrategyId = 'STR0002'} + table.insert( Strategies_Egalware, Strategy_Egalware) + Strategy_Egalware = {} + end --------------------------------------------------------------------- -- Feature : Drilling elseif ID.IsDrilling( Proc) then @@ -203,18 +213,7 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Cut - if true or ID.IsHeadCut( Proc) then -- TODO TOGLIERE IL true PER FORZARE IF!!! PROVVISORIO PER PROVARE STRATEGIE - if Proc.Topology.Name == 'FEATURE' then - Strategy_Essetre = { - StrategyId = 'STR0001', - Parameters = { - { Value = '15', Name = 'Step', Type = 'd'}, - { Value = 'false', Name = 'AntiSplint', Type = 'b'} - } - } - table.insert( Strategies_Essetre, Strategy_Essetre) - Strategy_Essetre = {} - end + if ID.IsHeadCut( Proc) then --------------------------------------------------------------------- -- Feature : Cut elseif ID.IsSplitCut( Proc) then @@ -236,6 +235,11 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Slot elseif ID.IsSlot( Proc) then + if Proc.Topology.Name == 'Pocket-5-Blind' then + Strategy_Essetre = { StrategyId = 'STR0002'} + table.insert( Strategies_Essetre, Strategy_Essetre) + Strategy_Essetre = {} + end --------------------------------------------------------------------- -- Feature : Front Slot elseif ID.IsFrontSlot( Proc) then @@ -275,6 +279,11 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Pocket elseif ID.IsPocket( Proc) then + if Proc.Topology.Name == 'Pocket-5-Blind' then + Strategy_Essetre = { StrategyId = 'STR0002'} + table.insert( Strategies_Essetre, Strategy_Essetre) + Strategy_Essetre = {} + end --------------------------------------------------------------------- -- Feature : Drilling elseif ID.IsDrilling( Proc) then diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index d30559f..e4e522b 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -17,7 +17,7 @@ local ID = require( 'Identity') local BCS = require( 'BasicCustomerStrategies') local FeatureData = require( 'FeatureData') local FaceData = require( 'FaceData') -local MachiningLib = require( 'MachiningLib') +local MachLib = require( 'MachiningLib') EgtOutLog( ' BeamExec started', 1) @@ -562,11 +562,11 @@ local function AreDrillingsMirrored( Proc, ProcMirror, Part) if AreOppositeVectorApprox( vtExtr, vtExtrMirror) then -- fori lungo Y -- per macchine tipo PF il foro principale è sul lato back, per macchine tipo PF1250 è sul lato front - if ( BD.TWO_EQUAL_HEADS and AreSameVectorApprox( vtExtr, Y_AX())) or - ( BD.DOWN_HEAD and AreOppositeVectorApprox( vtExtr, Y_AX())) then + if ( BeamData.TWO_EQUAL_HEADS and AreSameVectorApprox( vtExtr, Y_AX())) or + ( BeamData.DOWN_HEAD and AreOppositeVectorApprox( vtExtr, Y_AX())) then nDouble = 2 -- fori lungo Z - elseif BD.DOWN_HEAD and AreSameVectorApprox( vtExtr, Z_AX()) then + elseif BeamData.DOWN_HEAD and AreSameVectorApprox( vtExtr, Z_AX()) then nDouble = 3 else return false @@ -751,7 +751,7 @@ local function ExecPieceFeatures( vProc, Part) local Proc = vProc[i] if Proc.Flg ~= 0 and Proc.ChosenStrategy then -- carico file script strategia (non serve verificare presenza del file perchè già fatto durante scelta strategia) - local StrategyScriptName = '\\Strategies\\' .. Proc.ChosenStrategy.StrategyId .. '\\' .. Proc.ChosenStrategy.StrategyId + local StrategyScriptName = Proc.ChosenStrategy.StrategyId .. '\\' .. Proc.ChosenStrategy.StrategyId local StrategyScript = require( StrategyScriptName) -- eseguo la strategia e si applicano le lavorazioni. Si passa la Proc e i parametri personalizzati Proc = StrategyScript.Make( true, Proc, Part, Proc.ChosenStrategy.Parameters) @@ -862,6 +862,8 @@ function BeamExec.ProcessFeatures() -- ordino le features -- OrderFeatures( vProc, Part) + -- TODO PROVVISORIO in atesa di scelta lavorazione in fase opportuna + vProc = vProcRot[1] -- TODO da fare -- esegue le strategie migliori che ha precedentemente scelto diff --git a/LuaLibs/FeatureData.lua b/LuaLibs/FeatureData.lua index d6a4e32..59dff4b 100644 --- a/LuaLibs/FeatureData.lua +++ b/LuaLibs/FeatureData.lua @@ -143,7 +143,6 @@ function FeatureData.ClassifyTopology( Proc, Part) local vTriangularFaces = FaceData.GetTriangularFaces( Proc) local vFacesByAdjNumber = FaceData.GetFacesByAdjacencyNumber( Proc) - local sFamily local bIsThrough if Proc.Fct == 1 and ( bIsFeatureCuttingEntireSection or bIsFeatureCuttingEntireLength) then @@ -229,6 +228,45 @@ function FeatureData.GetDrillingData( Proc) return dDiam, dLen, nFcs, nFce end +------------------------------------------------------------------------------------------------------------- +-- funzione che restituisce rating feature in base al numero di lavorazioni, tipo di utensili e indice di completamento +-- TODO feature da sistemare +function FeatureData.GetFeatureRating( sTypeTools, dCompletionPercentage) + local dRating = 5 + local dCompletionIndex = 0 + local TypeTools = EgtSplitString( sTypeTools) + + -- se non è stato fatto nulla, esco subito + if dCompletionPercentage == 0 then + return 0 + end + + -- indice in base a utensile + for i=1, #TypeTools do + if TypeTools[i] == 'Blade' then + dRating = min( dRating, 5) + elseif TypeTools[i] == 'Mill' then + dRating = min( dRating, 4) + elseif TypeTools[i] == 'ChainSaw' then + dRating = min( dRating, 3) + else + dRating = min( dRating, 1) + end + end + + -- indice di completamento + if dCompletionPercentage < 50 then + dCompletionIndex = 1 + elseif dCompletionPercentage < 80 then + dCompletionIndex = 2 + else + dCompletionIndex = 5 + end + + dRating = dRating + dCompletionIndex + return dRating +end + ------------------------------------------------------------------------------------------------------------- return FeatureData \ No newline at end of file diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 3f4b08c..834d08c 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -10,5 +10,20 @@ require( 'EgtBase') EgtOutLog( ' MachiningLib started', 1) +------------------------------------------------------------------------------------------------------------- +-- funzione per cercare utensile tipo FRESA con certe caratteristiche +function MachiningLib.FindMill() +end + +------------------------------------------------------------------------------------------------------------- +-- funzione per cercare utensile tipo LAMA con certe caratteristiche +function MachiningLib.FindBlade() +end + +------------------------------------------------------------------------------------------------------------- +-- funzione per cercare utensile tipo PUNTA A FORARE con certe caratteristiche +function MachiningLib.FindDrill() +end + ------------------------------------------------------------------------------------------------------------- return MachiningLib diff --git a/Process.lua b/Process.lua index dc59b45..04b5467 100644 --- a/Process.lua +++ b/Process.lua @@ -48,7 +48,7 @@ _G.package.loaded.MachiningLib = nil -- reset strategie caricate come librerie for i = 1, 999 do local IdSTRTemp = EgtReplaceString( tostring( i/10000, 4), '0.', '') - local sLibraryToReload = "STR" .. IdSTRTemp .. "\\STR" .. IdSTRTemp .. "Config" + local sLibraryToReload = "STR" .. IdSTRTemp .. "\\STR" .. IdSTRTemp local sLibraryConfigToReload = sLibraryToReload .. "Config" if _G.package.loaded[sLibraryToReload] then _G.package.loaded[sLibraryToReload] = nil diff --git a/Strategies/STR0001/STR0001.lua b/Strategies/STR0001/STR0001.lua index 10521f5..a0ee662 100644 --- a/Strategies/STR0001/STR0001.lua +++ b/Strategies/STR0001/STR0001.lua @@ -1,4 +1,7 @@ -- Strategia: STR0001 +-- Descrizione +-- Lama + fresa CodaDiRondine per tenone +-- Feature: 55,1 -- carico librerie local BeamLib = require( 'BeamLib') diff --git a/Strategies/STR0002/STR0002.lua b/Strategies/STR0002/STR0002.lua index f435d6e..f7d9c39 100644 --- a/Strategies/STR0002/STR0002.lua +++ b/Strategies/STR0002/STR0002.lua @@ -1,19 +1,77 @@ -- Strategia: STR0002 +-- Descrizione +-- Svuotatura tasca +-- Feature: +-- Slot +-- FrontSlot +-- IsRidgeLap +-- IsLapJoint +-- IsNotchRabbet +-- IsNotch +-- IsPocket +-- Topology: 'Pocket-5-Blind' -- carico librerie local BeamLib = require( 'BeamLib') +local MachLib = require( 'MachiningLib') -- Tabella per definizione modulo local STR0002 = {} +local Strategy = {} + +------------------------------------------------------------------------------------------------------------- +local function IsTopologyOk( Proc) + if Proc.Topology.Name == 'Pocket-5-Blind' then + return true + else + return false + end +end ------------------------------------------------------------------------------------------------------------- function STR0002.Make( AddMachining, Proc, Part, CustomParameters) - -- carico parametri de default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) - local StrategyLib = {} - StrategyLib.Config = require( 'STR0002\\STR0002Config') - CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters) - StrategyParameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) + -- carico parametri de default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) + local StrategyLib = {} + StrategyLib.Config = require( 'STR0002\\STR0002Config') + Strategy.Name = StrategyLib.Config.StrategyId + CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) + if not IsTopologyOk( Proc) then + local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Strategy.Config.StrategyId .. ' not implemented' + EgtOutLog( sErr) + return false, sErr + end + + -- TODO fare calcolo per decidere se spezzare + + local Tool = {} + + -- serve utensile che possa lavorare di testa + local sTypeMill = 'MILL_STD' + local dMaxToolDiameter = min( Strategy.Parameters.MaxCornerRadius * 2, Proc.MainFaces.BottomFace.Height, Proc.MainFaces.BottomFace.Width) + + -- TODO cercare utensile appropriato + -- Tool = MachLib.FindMill( sTypeMill, dMaxToolDiameter) + + if Tool then + Strategy.RatingResult.Status = 'Completed' + Strategy.RatingResult.Rating = FeatureData.GetFeatureRating( 'Mill', 100) + Strategy.RatingResult.CompletionIndex = 5 + Strategy.RatingResult.Info = '' + else + Strategy.RatingResult.Status = 'Not-Applicable' + Strategy.RatingResult.Rating = FeatureData.GetFeatureRating( 'None', 0) + Strategy.RatingResult.CompletionIndex = 0 + Strategy.RatingResult.Info = 'Mill not found' + end + + -- se richiesto applico lavorazione + if AddMachining then + EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, 'Fresa25x130') + end + + return Strategy.RatingResult end ------------------------------------------------------------------------------------------------------------- diff --git a/Strategies/STR0002/STR0002Config.lua b/Strategies/STR0002/STR0002Config.lua index 06f7e67..56636a4 100644 --- a/Strategies/STR0002/STR0002Config.lua +++ b/Strategies/STR0002/STR0002Config.lua @@ -3,8 +3,7 @@ local STR0002Data = { StrategyId = 'STR0002', Parameters = { - { Name = 'Step', Value = '10', Description = 'Questo è lo step di lavorazione', Type = 'd'}, - { Name = 'Depth', Value = '5', Description = 'Affondamento lavorazione', Type = 'd'}, + { Name = 'MaxCornerRadius', Value = '15', Description = 'Affondamento lavorazione', Type = 'd'} } } diff --git a/Strategies/Strategies.ini b/Strategies/Strategies.ini index 3e93932..72f9b37 100644 --- a/Strategies/Strategies.ini +++ b/Strategies/Strategies.ini @@ -1,6 +1,7 @@ ; Commento per evitare BOM con UTF-8 [Comments] STR0001 = Tenone a coda di rondine. Lama + fresa a coda di rondine +STR0002 = Topologia tipo LapJoint. Svuotatura con fresa [Strategies] ; Processing , Gruppo , Topologia , Strategie @@ -15,23 +16,23 @@ STR0001 = Tenone a coda di rondine. Lama + fresa a coda di rondine ; Feature : Saw Cut 13,0,Feature, ; Feature : Slot -16.0,Feature, +16.0,Pocket-5-Blind,STR0002 ; Feature : Front Slot -17,0,Feature, +17,0,Pocket-5-Blind,STR0002 ; Feature : Birds Mouth 20,0,Feature, ; Feature : Hip or Valley Rafter Notch 25,0,Feature, ; Feature : Ridge Lap -30,1,Feature, +30,1,Pocket-5-Blind,STR0002 ; Feature : Lap Joint -30,0,Feature, +30,0,Pocket-5-Blind,STR0002 ; Feature : Notch/Rabbet -32,0,Feature, +32,0,Pocket-5-Blind,STR0002 ; Feature : Block Haus 33,0,Feature, ; Feature : Notch -34,0,Feature, +34,0,Pocket-5-Blind,STR0002 ; Feature : French Ridge Lap 35,1,Feature, ; Feature : Chamfer @@ -41,7 +42,7 @@ STR0001 = Tenone a coda di rondine. Lama + fresa a coda di rondine ; Feature : Block Haus Front 38,0,Feature, ; Feature : Pocket -39,0,Feature, +39,0,Pocket-5-Blind,STR0002 ; Feature : Drilling 40,0,Feature, ; Feature : Tenon