diff --git a/Common_ONE-PF.mlpe b/Common_ONE-PF.mlpe index 05e905e..2827b37 100644 --- a/Common_ONE-PF.mlpe +++ b/Common_ONE-PF.mlpe @@ -1099,54 +1099,36 @@ function OnSimulMoveEnd() ExecRemoveScraps() end - -- tipo di movimento - local bLastClimb = EgtGetInfo( EMT.MOVEID, 'LastClimb', 'b') - local bUniqueClimb = EgtGetInfo( EMT.MOVEID, 'UniqueClimb', 'b') - -- se il link non arriva dalla OnSpecial, non ha nessuna nota - local bStdClimb = ( EMT.FLAG2 ~= 2 and EMT.FLAG == 2) - local bStdMachRapid = ( EMT.FLAG2 == 0 and ( EMT.FLAG == 0 or EMT.FLAG == 1)) - - -- se primo rapido della lavorazione è un movimento standard, allora questo è l'ultimo climb - if bStdMachRapid and EMT.MCHFIRST then - bStdClimb = true - end - - local bCloseRollers = bLastClimb or bUniqueClimb or bStdClimb - - -- se rapido - if EMT.MOVE == 0 then + if EMT.MOVE == 0 and ( EMT.MASK & 1) == 1 then -- se lavorazione split, dichiaro carro Y1 riagganciato - if EMT.SPLIT_Y1DELTA and ( EMT.MASK & 1) == 1 then + if EMT.SPLIT_Y1DELTA then EMT.SPLIT_Y1DELTA = nil ExecMovePY1( true) end - -- se ultimo movimento di climb, si chiudono i rulli - if bCloseRollers then - -- chiusura pinza speciale (e posizionamento iniziale) - if EMT.W2DELTA then - local dPosQW = EgtGetAxisPos( 'QW') or 0 - if dPosQW < 1 then - EgtSetAxisPos( 'W', EMT.A5) - EgtSetAxisPos( 'QW', 30) - EgtSetAxisPos( 'PW', EMT.HB) - end + -- chiusura pinza speciale (e posizionamento iniziale) + if EMT.W2DELTA then + local dPosQW = EgtGetAxisPos( 'QW') or 0 + if dPosQW < 1 then + EgtSetAxisPos( 'W', EMT.A5) + EgtSetAxisPos( 'QW', 30) + EgtSetAxisPos( 'PW', EMT.HB) end - -- chiusura o apertura rulli V1 - if GetV1ToClose() then - ExecCloseRoller( 1) - else - ExecOpenRoller( 1) - end - -- chiusura o apertura rulli V2 - if GetV2ToClose() then - ExecCloseRoller( 2) - else - ExecOpenRoller( 2) - end - EMT.MCHFIRST = false - EgtOutText( '') end + -- chiusura o apertura rulli V1 + if GetV1ToClose() then + ExecCloseRoller( 1) + else + ExecOpenRoller( 1) + end + -- chiusura o apertura rulli V2 + if GetV2ToClose() then + ExecCloseRoller( 2) + else + ExecOpenRoller( 2) + end + EMT.MCHFIRST = false + EgtOutText( '') end -- se utensile flottante e movimento di compressione diff --git a/Common_ONE-PF.mlse b/Common_ONE-PF.mlse index 0304f59..c704880 100644 --- a/Common_ONE-PF.mlse +++ b/Common_ONE-PF.mlse @@ -874,14 +874,20 @@ function OnSpecialApplyMachining() -- Inizializzo codice di errore EMC.ERR = 0 - EMC.ZMAX = false + EMC.ENDZMAX = false -- Verifico flag di separazione e fase di scarico local sNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) - local sPrevTool, dPrevValR3 - + local bZMaxForced = false + if EgtGetValInNotes( sNotes, 'StartZmax', 's') == 'FORCED' then + bZMaxForced = true + end + -- si cancella eventuale flag per risalita in ZMAX sNotes = EgtSetValInNotes( sNotes, 'StartZmax') + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) + + local sPrevTool, dPrevValR3 -- Recupero la posizione della trave e dei carrelli al termine della precedente operazione local nPrevOpeId = EgtGetPrevActiveOperation( EMC.MCHID) @@ -901,7 +907,6 @@ function OnSpecialApplyMachining() EMC.V1POS = ParkV1 EMC.V2POS = ParkV2 EMC.CNT = nil - EMC.ZMAX = true elseif IsStartOrRestPhase( EMC.PHASE) then -- carico le posizioni local dPosT = EgtGetInfo( nPrevOpeId, 'TPOS', 'd') @@ -980,7 +985,6 @@ function OnSpecialApplyMachining() local bPreRotMch = IsLastOperationBeforeRotation( EMC.MCHID) -- Verifico flag di separazione e fase di scarico - sNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) local bPreSplit = ( false and sNotes:find( 'Presplit', 1, true) ~= nil) local bSplitting = ( sNotes:find( 'Split', 1, true) ~= nil) local bPreCut = ( sNotes:find( 'Precut', 1, true) ~= nil) @@ -1069,7 +1073,7 @@ function OnSpecialApplyMachining() end -- Se richiesto movimento preliminare della testa a Zmax perchè c'è stato un riposizionamento delle pinze - if EMC.ZMAX then + if EMC.ZMAX or bZMaxForced then sNotes = EgtSetValInNotes( sNotes, 'StartZmax', 11) EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) end @@ -2639,7 +2643,6 @@ function SpecAdjustCarrA( WorkTab) -- eseguo eventuale posizionamento sicuro di teste e rulli if WorkTab.bCloseV then EnsureZmax( true, vCmd) - EMC.ZMAX = true MyMinY1V1 = EgtIf( EMC.CNT == 1, MinY1 + AggLoad, MinY1) MaxY2V2 = MaxY2 end @@ -2745,7 +2748,6 @@ function SpecAdjustCarrB1( WorkTab) -- ------------------------------------------ if WorkTab.bCloseV then EnsureZmax( true, vCmd) - EMC.ZMAX = true MyMinY1V1 = EgtIf( EMC.CNT == 1, MinY1 + AggLoad, MinY1) MaxY2V2 = MaxY2 end @@ -2817,7 +2819,6 @@ function SpecAdjustCarrB2( WorkTab) -- eseguo eventuale posizionamento sicuro di teste e rulli if WorkTab.bCloseV then EnsureZmax( true, vCmd) - EMC.ZMAX = true MyMinY1V1 = EgtIf( EMC.CNT == 1, MinY1 + AggLoad, MinY1) MaxY2V2 = MaxY2 end @@ -2888,7 +2889,6 @@ function SpecAdjustCarrC( WorkTab) -- eseguo eventuale posizionamento sicuro di teste e rulli if WorkTab.bCloseV then EnsureZmax( true, vCmd) - EMC.ZMAX = true MyMinY1V1 = EgtIf( EMC.CNT == 1, MinY1 + AggLoad, MinY1) MaxY2V2 = MaxY2 end @@ -3022,6 +3022,12 @@ function SpecOutputCmds( vCmd, bEnd) elseif Cmd[1] == 4 then local sInfo = '4,'..EgtNumToString( Cmd[2],0) EgtSetInfo( EMC.PATHID, sKey, sInfo) + -- se chiusura rulli + if bEnd then + EMC.ENDZMAX = true + else + EMC.ZMAX = true + end -- apertura/chiusura morsa Y elseif Cmd[1] == 11 then local sInfo = '11,'..EgtNumToString( Cmd[2],0) @@ -3097,8 +3103,26 @@ function SpecOutputCmds( vCmd, bEnd) EgtSetInfo( NextDispId, 'V1POS', EMC.V1POS) EgtSetInfo( NextDispId, 'V2POS', EMC.V2POS) end + -- se bisogna andare a ZMAX alla fine, si setta il parametro sulla lavorazione successiva in modo che la corrente vada in home + if EMC.ENDZMAX then + -- recupero lavorazione successiva + local nNextMchId = EgtGetNextActiveOperation( EMC.MCHID, true) + while nNextMchId do + if EgtGetOperationType( nNextMchId) ~= MCH_OY.DISP then + if EgtSetCurrMachining( nNextMchId) then + -- Verifico flag di separazione e fase di scarico + local sNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + -- si cancella eventuale flag per risalita in ZMAX + sNotes = EgtSetValInNotes( sNotes, 'StartZmax', 'FORCED') + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) + EgtSetCurrMachining( EMC.MCHID) + break + end + end + nNextMchId = EgtGetNextActiveOperation( nNextMchId, true) + end + end end - end ---------------------------------------------------------------------