DataBeam :

- migliorie e correzioni varie
- unificati BirdsMouth con LapJoint.
This commit is contained in:
Dario Sassi
2019-07-03 10:27:55 +00:00
parent 9ac596d5d7
commit 7c1a4ba546
20 changed files with 473 additions and 511 deletions
+83 -54
View File
@@ -1,4 +1,4 @@
-- BeamExec.lua by Egaltech s.r.l. 2019/06/14
-- BeamExec.lua by Egaltech s.r.l. 2019/07/01
-- Libreria esecuzione lavorazioni per Travi
-- Tabella per definizione modulo
@@ -37,8 +37,6 @@ _G.package.loaded.ProcessLongCut = nil
local LongCut = require( 'ProcessLongCut')
_G.package.loaded.ProcessLongDoubleCut = nil
local Long2Cut = require( 'ProcessLongDoubleCut')
_G.package.loaded.ProcessBirdsMouth = nil
local BirdsMouth = require( 'ProcessBirdsMouth')
_G.package.loaded.ProcessRidgeLap = nil
local RidgeLap = require( 'ProcessRidgeLap')
_G.package.loaded.ProcessLapJoint = nil
@@ -205,9 +203,6 @@ local function IsHeadFeature( Proc, b3Raw, dCurrOvmH)
return ( Proc.Box:getCenter():getX() > b3Raw:getCenter():getX())
end
-- gestioni speciali
if BirdsMouth.Identify( Proc) then
return BirdsMouth.IsHeadFeature( Proc, b3Raw, dCurrOvmH)
end
if LapJoint.Identify( Proc) then
return LapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH)
end
@@ -236,9 +231,6 @@ local function IsTailFeature( Proc, b3Raw)
return ( Proc.Box:getCenter():getX() < b3Raw:getCenter():getX())
end
-- gestioni speciali
if BirdsMouth.Identify( Proc) then
return BirdsMouth.IsTailFeature( Proc, b3Raw)
end
if LapJoint.Identify( Proc) then
return LapJoint.IsTailFeature( Proc, b3Raw)
end
@@ -271,6 +263,8 @@ local function CollectFeatures( PartId, b3Raw, dCurrOvmH)
local nGrp = EgtGetInfo( ProcId, 'GRP', 'i')
local nPrc = EgtGetInfo( ProcId, 'PRC', 'i')
local nDo = EgtGetInfo( ProcId, 'DO', 'i') or 1
local nCutId = EgtGetInfo( EgtGetParent( EgtGetParent( ProcId)), 'CUTID', 'i') or 0
local nTaskId = EgtGetInfo( ProcId, 'TASKID', 'i') or 0
if nGrp and nPrc and nDo == 1 then
local Proc = {}
Proc.Id = ProcId
@@ -284,6 +278,8 @@ local function CollectFeatures( PartId, b3Raw, dCurrOvmH)
Proc.Diam = 0
Proc.Fcs = 0
Proc.Fce = 0
Proc.CutId = nCutId
Proc.TaskId = nTaskId
table.insert( vProc, Proc)
-- se foro
if Drill.Identify( Proc) then
@@ -309,6 +305,8 @@ local function CollectFeatures( PartId, b3Raw, dCurrOvmH)
Proc2.Tail = Drill.IsTailFeature( Proc2, b3Raw)
Proc2.Fcs = Proc.Fce
Proc2.Fce = Proc.Fcs
Proc2.CutId = Proc.CutId
Proc2.TaskId = Proc.TaskId
table.insert( vProc, Proc2)
end
end
@@ -358,7 +356,7 @@ local function OrderFeatures( vProc, b3Raw)
return B1.Box:getMax():getX() + 100 > B2.Box:getCenter():getX()
end
-- se sono fori e hanno posizione praticamente uguale ordino secondo diametro e faccia di inizio (Fcs)
if B1.Prc == 40 and B2.Prc == 40 and abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) < 200 then
if B1.Prc == 40 and B2.Prc == 40 and abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) < 400 then
if abs( B1.Diam - B2.Diam) < 1.0 then
if B1.Fcs == B2.Fcs then
return B1.Box:getCenter():getX() > B2.Box:getCenter():getX()
@@ -404,10 +402,12 @@ local function OrderFeatures( vProc, b3Raw)
end
-------------------------------------------------------------------------------------------------------------
local function ClassifyFeatures( vProc, b3Raw)
local function ClassifyFeatures( vProc, b3Raw, Stats)
local bAllOk = true
local bSomeDown = false
local bSplitRot = false
local nHeading
local nSplitting
for i = 1, #vProc do
local Proc = vProc[i]
local bOk = true
@@ -415,6 +415,9 @@ local function ClassifyFeatures( vProc, b3Raw)
-- se intestatura
if Hcut.Identify( Proc) then
nHeading = i
-- se separazione
elseif Split.Identify( Proc) then
nSplitting = i
-- se doppio taglio
elseif DoubleCut.Identify( Proc) then
bOk, bDown = DoubleCut.Classify( Proc)
@@ -424,13 +427,10 @@ local function ClassifyFeatures( vProc, b3Raw)
-- se doppio taglio longitudinale
elseif Long2Cut.Identify( Proc) then
bOk, bDown = Long2Cut.Classify( Proc)
-- se tacca
elseif BirdsMouth.Identify( Proc) then
bOk, bDown = BirdsMouth.Classify( Proc)
-- se mezzo-legno di testa
elseif RidgeLap.Identify( Proc) then
bOk, bDown = RidgeLap.Classify( Proc)
-- se mezzo-legno, fessura, fessura frontale, notch, tasca
-- se mezzo-legno, fessura, fessura frontale, notch, tasca, tacca
elseif LapJoint.Identify( Proc) then
bOk, bDown = LapJoint.Classify( Proc)
-- se foratura
@@ -469,11 +469,17 @@ local function ClassifyFeatures( vProc, b3Raw)
end
-- assegno risultato
if bOk then
-- non ammessa feature di testa o di coda da lavorare ribaltata
if ( Proc.Head or Proc.Tail) and bDown then
-- non ammessa feature di testa da lavorare ribaltata
if Proc.Head and bDown then
Proc.Flg = 0
Proc.Down = true
bAllOk = false
table.insert( Stats, {Err = 1, Msg='Error : impossible to machine by orientation', CutId=Proc.CutId, TaskId=Proc.TaskId})
-- gestione feature di coda da lavorare ribaltata
elseif Proc.Tail and bDown then
Proc.Down = true
bSomeDown = true
bSplitRot = true
-- caso normale
else
Proc.Down = bDown
@@ -488,7 +494,11 @@ local function ClassifyFeatures( vProc, b3Raw)
if bSomeDown and nHeading then
vProc[nHeading].Down = true
end
return bAllOk, bSomeDown
-- se necessaria rotazione del ribaltato, assegno separazione alla fase ribaltata
if bSplitRot then
vProc[nSplitting].Down = true
end
return bAllOk, bSomeDown, bSplitRot
end
-------------------------------------------------------------------------------------------------------------
@@ -496,8 +506,9 @@ local function PrintFeatures( vProc, b3Raw)
EgtOutLog( ' RawBox=' .. tostring( b3Raw))
for i = 1, #vProc do
local Proc = vProc[i]
local sOut = string.format( ' Proc=%3d Grp=%1d Prc=%3d Flg=%2d Down=%s Head=%s Tail=%s Fcse=%1d,%1d Diam=%.2f Fct=%2d Box=%s',
Proc.Id, Proc.Grp, Proc.Prc, Proc.Flg, EgtIf( Proc.Down, 'T', 'F'), EgtIf( Proc.Head, 'T', 'F'), EgtIf( Proc.Tail, 'T', 'F'),
local sOut = string.format( ' Proc=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Down=%s Head=%s Tail=%s Fcse=%1d,%1d Diam=%.2f Fct=%2d Box=%s',
Proc.Id, Proc.Grp, Proc.Prc, Proc.TaskId, Proc.CutId,
Proc.Flg, EgtIf( Proc.Down, 'T', 'F'), EgtIf( Proc.Head, 'T', 'F'), EgtIf( Proc.Tail, 'T', 'F'),
Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, tostring( Proc.Box))
EgtOutLog( sOut)
end
@@ -544,15 +555,11 @@ local function AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3
else
bOk, sErr = LongCut.Make( Proc, nPhase, nRawId, nPartId)
end
-- se tacca ( 3/4-020-X)
elseif BirdsMouth.Identify( Proc) then
-- esecuzione tacca
bOk, sErr = BirdsMouth.Make( Proc, nPhase, nRawId, nPartId)
-- se mezzo-legno di testa ( 1/2-030-X)
elseif RidgeLap.Identify( Proc) then
-- esecuzione mezzo-legno di testa
bOk, sErr = RidgeLap.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH)
-- se mezzo-legno ( 3/4-030-X) o scanalatura ( 3/4-016-X)
-- se mezzo-legno ( 3/4-030-X) o scanalatura ( 3/4-016-X) o tacca ( 3/4-020-X)
elseif LapJoint.Identify( Proc) then
-- esecuzione mezzo-legno o scanalatura
bOk, sErr = LapJoint.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH)
@@ -635,10 +642,8 @@ end
-------------------------------------------------------------------------------------------------------------
function BeamExec.ProcessFeatures()
local bAddOk = true
local sAddErrors = ''
local nCutId
local nTaskId
local nTotErr = 0
local Stats = {}
local nOrd = 1
local nRawId = EgtGetFirstRawPart()
while nRawId do
@@ -664,10 +669,9 @@ function BeamExec.ProcessFeatures()
-- le ordino lungo X
OrderFeatures( vProc, b3Raw)
-- le classifico
local bOk, bSomeDown = ClassifyFeatures( vProc, b3Raw)
if not bOk then
bAddOk = false
sAddErrors = 'Warning : some features not machinable'
local bAllOk, bSomeDown, bSplitRot = ClassifyFeatures( vProc, b3Raw, Stats)
if not bAllOk then
nTotErr = nTotErr + 1
end
-- debug
if EgtGetDebugLevel() >= 1 then
@@ -687,22 +691,47 @@ function BeamExec.ProcessFeatures()
-- creo la lavorazione
local Proc = vProc[i]
if Proc.Flg ~= 0 and Proc.Down then
local bOk, sErr = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw)
local bOk, sMsg, bNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw)
if not bOk then
bAddOk = false
sAddErrors = sAddErrors .. sErr .. '\n'
if not nCutId then
nCutId = EgtGetInfo( EgtGetParent( EgtGetParent( Proc.Id)), 'CUTID', 'i')
nTaskId = EgtGetInfo( Proc.Id, 'TASKID', 'i')
end
nTotErr = nTotErr + 1
table.insert( Stats, {Err=1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId})
elseif sMsg and #sMsg > 0 then
table.insert( Stats, {Err=-1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId})
else
table.insert( Stats, {Err=0, Msg='', CutId=Proc.CutId, TaskId=Proc.TaskId})
end
-- se era taglio di separazione, aggiungo nuova fase
if bNewPhase then
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, BD.RAW_OFFSET)
EgtRotateRawPart( nRawId, X_AX(), 180)
-- se grezzo successivo senza pezzi e finale, va tolto
local nNextRawId = EgtGetNextRawPart( nRawId)
if nNextRawId and EgtGetPartInRawPartCount( nNextRawId) == 0 and EgtGetRawPartBBox( nNextRawId):getDimX() < BD.MinRaw then
EgtRemoveRawPartFromCurrPhase( nNextRawId)
end
nPhase = EgtGetCurrPhase()
nDispId = EgtGetPhaseDisposition( nPhase)
EgtSetInfo( nDispId, 'TYPE', 'MID2')
EgtSetInfo( nDispId, 'ORD', nOrd)
EgtSetInfo( nDispId, 'ROT', -2)
end
end
end
-- aggiungo nuova fase con le travi in posizione standard
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, 0)
-- se separazione non ancora effettuata, aggiungo nuova fase con le travi in posizione standard
if not bSplitRot then
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, 0)
-- altrimenti
else
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, BD.RAW_OFFSET)
-- se grezzo successivo senza pezzi e finale, va tolto
local nNextRawId = EgtGetNextRawPart( nRawId)
if nNextRawId and EgtGetPartInRawPartCount( nNextRawId) == 0 and EgtGetRawPartBBox( nNextRawId):getDimX() < BD.MinRaw then
EgtRemoveRawPartFromCurrPhase( nNextRawId)
end
end
nPhase = EgtGetCurrPhase()
nDispId = EgtGetPhaseDisposition( nPhase)
EgtSetInfo( nDispId, 'TYPE', 'MID')
EgtSetInfo( nDispId, 'TYPE', EgtIf( not bSplitRot, 'MID', 'END2'))
EgtSetInfo( nDispId, 'ORD', nOrd)
end
-- inserisco le lavorazioni non ribaltate della trave
@@ -710,14 +739,14 @@ function BeamExec.ProcessFeatures()
-- creo la lavorazione
local Proc = vProc[i]
if Proc.Flg ~= 0 and not Proc.Down then
local bOk, sErr, bNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw)
local bOk, sMsg, bNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw)
if not bOk then
bAddOk = false
sAddErrors = sAddErrors .. sErr .. '\n'
if not nCutId then
nCutId = EgtGetInfo( EgtGetParent( EgtGetParent( Proc.Id)), 'CUTID', 'i')
nTaskId = EgtGetInfo( Proc.Id, 'TASKID', 'i')
end
nTotErr = nTotErr + 1
table.insert( Stats, {Err=1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId})
elseif sMsg and #sMsg > 0 then
table.insert( Stats, {Err=-1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId})
else
table.insert( Stats, {Err=0, Msg='', CutId=Proc.CutId, TaskId=Proc.TaskId})
end
-- se era taglio di separazione, aggiungo nuova fase
if bNewPhase then
@@ -742,12 +771,12 @@ function BeamExec.ProcessFeatures()
-- Aggiornamento finale di tutto
EgtSetCurrPhase( 1)
local bApplOk, sApplErrors = EgtApplyAllMachinings()
if not bAddOk or not bApplOk then
local sErrors = ( sAddErrors or '') .. ( sApplErrors or '')
return false, sErrors, nCutId, nTaskId
if not bApplOk then
nTotErr = nTotErr + 1
table.insert( Stats, {Err = 1, Msg=sApplErrors, CutId=0, TaskId=0})
end
return true
return ( nTotErr == 0), Stats
end
-------------------------------------------------------------------------------------------------------------