fadb601732
- drag rettangoli rimesso in funzione - corretto controllo extra-corse in spostamento pezzi con ventose - sistemati alcuni nomi.
1640 lines
75 KiB
VB.net
1640 lines
75 KiB
VB.net
Imports EgtUILib
|
|
|
|
Public Class MoveRawPartPage
|
|
' Riferimento alla MainWindow
|
|
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
Private WithEvents m_CurrProjPage As CurrentProjectPageUC = Nothing
|
|
Private m_SplitPage As SplitPageUC = Nothing
|
|
' Flag di pagina attiva
|
|
Private m_bActive As Boolean = False
|
|
' Eventuale tavola ausiliaria
|
|
Private m_nAuxTabId As Integer = GDB_ID.NULL
|
|
' Fase corrente
|
|
Private m_nCurrPhase As Integer = 0
|
|
' Disposizione corrente
|
|
Private m_nCurrDisposition As Integer = GDB_ID.NULL
|
|
' Premuto Prev
|
|
Private m_bPrev As Boolean = False
|
|
' Pemuto Next
|
|
Private m_bToNext As Boolean = False
|
|
' Dati movimento
|
|
Private m_dStep As Double = 0
|
|
Private m_dRotation As Double = 0
|
|
' Tipo movimento dei grezzi (manuale o con testa ventosa)
|
|
Private m_bByHand As Boolean = True
|
|
' Gestione movimento manuale perpendicolare
|
|
Private m_vtDir As New Vector3d ' direzione di movimento
|
|
Private m_ptMid As New Point3d ' punto medio del taglio
|
|
Private m_dOrigDist As Double = 0 ' distanza iniziale (spessore taglio)
|
|
Private m_dCurrDist As Double = 0 ' distanza corrente
|
|
' Gestione movimento con ventose
|
|
Private m_bRemovedRaw As Boolean = False ' flag per rimozione manuale pezzi
|
|
Private m_RawMoveDataList As New List(Of RawMoveData) ' dati di movimento
|
|
Private m_bRawWithCups As Boolean = False ' flag per pezzo corrente con ventose
|
|
' Visibilità comando Scrap
|
|
Private m_ScrapsVisibility As Visibility = Visibility.Visible
|
|
Private m_CurrRawOnVacuum As Integer = GDB_ID.NULL
|
|
|
|
' definisce se è stata inserito uno scarico
|
|
Private m_IsCurrPhaseUnloaded As Boolean = False
|
|
|
|
Private Sub MoveRawPartPage_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
|
' Assegno testi
|
|
RemovePartBtn.Content = EgtMsg(90361) ' Rimuovi
|
|
ModifyBtn.Content = EgtMsg(90357) ' Modifica
|
|
ResetBtn.Content = EgtMsg(90336) ' Reset
|
|
ScrapsBtn.Content = EgtMsg(90366) ' Add Scraps
|
|
UnloadPartsBtn.Content = EgtMsg(90367) ' Move part
|
|
End Sub
|
|
|
|
Private Sub MoveRawPartPage_Loaded(sender As Object, e As EventArgs) Handles Me.Loaded
|
|
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
|
m_SplitPage = m_MainWindow.m_CadCutPageUC.m_SplitPage
|
|
m_bActive = True
|
|
' resetto l'inidice del pezzo da mnovimentare
|
|
m_CurrRawOnVacuum = GDB_ID.NULL
|
|
' Leggo tipo movimento grezzi
|
|
m_bByHand = (GetVacuumType() = 0 Or
|
|
Not m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.AUTO_MANIP) Or
|
|
(GetPrivateProfileInt(S_RAWMOVE, K_PERPENDICULAR, 0, m_MainWindow.GetIniFile()) <> 0))
|
|
' Se movimento con ventosa, verifico se lama troppo grande
|
|
If Not m_bByHand And Not m_MainWindow.m_CurrentMachine.IsVacuumMovePossible() Then
|
|
m_bByHand = True
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90351)) ' Lama troppo grande per utilizzo ventosa
|
|
End If
|
|
' Deseleziono tutto
|
|
EgtDeselectAll()
|
|
' resetto variabili di navigazione nelle fasi
|
|
m_bPrev = False
|
|
m_bToNext = False
|
|
|
|
'---------------------------- CREATE NEW PHASE ----------------------------
|
|
' Recupero i tagli ABILITATI prima definiti
|
|
Dim Cuts(0) As Integer
|
|
m_SplitPage.GetEnabledCuts(Cuts)
|
|
' Fase precedente
|
|
Dim nPrevPhase As Integer = EgtGetCurrPhase()
|
|
' Creo nuova fase, eseguo spezzatura grezzi e vi sposto le lavorazioni
|
|
Dim vNewRaws As New List(Of Integer)
|
|
If Not m_SplitPage.m_bShow Then
|
|
SplitRawParts(nPrevPhase, Cuts, vNewRaws)
|
|
m_IsCurrPhaseUnloaded = False
|
|
Else
|
|
nPrevPhase = nPrevPhase + 1
|
|
EgtSetCurrPhase(nPrevPhase)
|
|
HideAllMachinings()
|
|
' verifico se la fase corrente è di tipo scarico frontale
|
|
m_nCurrDisposition = EgtGetPhaseDisposition(nPrevPhase)
|
|
If IsDispUnloadOnAuxTab(m_nCurrDisposition) Then
|
|
m_SplitPage.m_bOnAuxTab = True
|
|
End If
|
|
End If
|
|
m_nCurrPhase = EgtGetCurrPhase()
|
|
'---------------------------- CREATE NEW PHASE ----------------------------
|
|
|
|
'---------------------------- SCRAPS ----------------------------
|
|
' gestione visualizzazione del comando "Scraps"
|
|
Dim ScrapsVisibility As Visibility = Visibility.Collapsed
|
|
' verifico se licenza abilitat: m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.SCRAPS)
|
|
If GetPrivateProfileInt(S_SCRAPS, K_ENABLESCRAPS, 0, m_MainWindow.GetIniFile()) <> 0 Then
|
|
' leggo il direttorio in cui cercare il database delle lastre
|
|
Dim PhotDir As String = String.Empty
|
|
GetPrivateProfileString(S_SCRAPS, K_PHOTODIR, "", PhotDir, m_MainWindow.GetIniFile())
|
|
' verifico che esista il file "OmagPHOTOVb.sqlite" nel direttorio inidicato
|
|
If System.IO.File.Exists(PhotDir.Trim & "\OmagPHOTODb.sqlite") Then
|
|
ScrapsVisibility = Visibility.Visible
|
|
End If
|
|
End If
|
|
' verifico che siano stati generati dei nuovi grezzi
|
|
If vNewRaws.Count = 0 Then
|
|
ScrapsVisibility = Visibility.Collapsed
|
|
End If
|
|
' aggiorno la grafica
|
|
m_ScrapsVisibility = ScrapsVisibility
|
|
If m_ScrapsVisibility <> Visibility.Visible Then
|
|
Grid.SetColumnSpan(RemovePartBtn, 3)
|
|
Else
|
|
Grid.SetColumnSpan(RemovePartBtn, 2)
|
|
End If
|
|
'---------------------------- SCRAPS ----------------------------
|
|
|
|
'---------------------------- AUX TABLE ----------------------------
|
|
' Se movimento pezzi finale, sistemazioni per tavolo ausiliario
|
|
If m_SplitPage.m_bOnAuxTab And m_SplitPage.m_bEnableOnAuxTab Then
|
|
' assegnazione delle info tavola ausiliaria alla dispozione corrente (Spostato nella funzione Refresh)
|
|
SetAuxTabInCurrDisposition()
|
|
UnloadPartsBtn.Content = EgtMsg(90368) ' Go to MOVE part
|
|
' altrimenti, aggiorno visualizzazione
|
|
ElseIf Not m_SplitPage.m_bOnAuxTab And m_SplitPage.m_bEnableOnAuxTab Then
|
|
UnloadPartsBtn.Content = EgtMsg(90369) ' Go to UNLOAD part
|
|
End If
|
|
'---------------------------- AUX TABLE ----------------------------
|
|
EgtDraw()
|
|
' Carico i parametri di movimento
|
|
m_dStep = GetPrivateProfileDouble(S_RAWMOVE, K_RAWSTEP, 50, m_MainWindow.GetIniFile())
|
|
' Carico il valore ci
|
|
Dim ExtraStep As Double = GetPrivateProfileDouble(S_RAWMOVE, K_EXTRASTEP, 1, m_MainWindow.GetIniFile())
|
|
' Ricavo la lunghezza del baffo di taglio
|
|
m_dStep = SplitAuto.MaxCuttingMustache(m_dStep)
|
|
If ExtraStep < EPS_SMALL Then
|
|
StepMoveTxBx.Text = LenToString(m_dStep, 1)
|
|
Else
|
|
StepMoveTxBx.Text = LenToString(m_dStep, 1) & "+" & LenToString(ExtraStep, 1)
|
|
' Aggiorno il valore sommando l'extra
|
|
m_dStep = m_dStep + ExtraStep
|
|
End If
|
|
m_dRotation = GetPrivateProfileDouble(S_RAWMOVE, K_RAWROTATION, 30, m_MainWindow.GetIniFile())
|
|
RotationAngleTxBx.Text = DoubleToString(m_dRotation, 3)
|
|
' Se movimento manuale perpendicolare
|
|
If m_bByHand Then
|
|
' Se esiste taglio passante determino direzione di movimento
|
|
If Cuts.Length() > 0 Then
|
|
' recupero taglio di separazione
|
|
Dim nCutId As Integer = Cuts(0)
|
|
' recupero linea di base del taglio
|
|
EgtSetCurrMachining(nCutId)
|
|
' Recupero la prima entità geometrica della lavorazione
|
|
Dim nEntId, nSub As Integer
|
|
If EgtGetMachiningGeometry(0, nEntId, nSub) Then
|
|
' Direzione perpendicolare al taglio
|
|
EgtStartVector(nEntId, GDB_ID.ROOT, m_vtDir)
|
|
m_vtDir.Rotate(Vector3d.Z_AX(), 90)
|
|
' Punto medio del taglio
|
|
EgtMidPoint(nEntId, GDB_ID.ROOT, m_ptMid)
|
|
' Recupero il preview della lavorazione
|
|
Dim nPvId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(EgtGetFirstNameInGroup(nCutId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId)
|
|
' Recupero la larghezza del taglio
|
|
Dim nGrpId As Integer = EgtGetFirstGroupInGroup(nPvId)
|
|
If Not EgtGetInfo(nGrpId, "WT", m_dOrigDist) Then
|
|
m_dOrigDist = 4
|
|
End If
|
|
' Distanza iniziale
|
|
m_dCurrDist = 0
|
|
End If
|
|
' Non dovrebbe mai accadere, ma inizializzo con default
|
|
Else
|
|
m_vtDir = Vector3d.Y_AX()
|
|
m_ptMid = Point3d.ORIG()
|
|
m_dOrigDist = 0
|
|
m_dCurrDist = 0
|
|
End If
|
|
' Altrimenti movimento con ventose
|
|
Else
|
|
m_bRemovedRaw = False
|
|
m_bRawWithCups = False
|
|
' Pulisco lista info per grezzi
|
|
m_RawMoveDataList.Clear()
|
|
m_RawMoveDataList.Capacity() = 10
|
|
' Se solo visualizzazione carico flag rimozione manuale e i movimenti già fatti nella fase
|
|
If m_SplitPage.m_bShow Then
|
|
Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
m_bRemovedRaw = GetRemoveByHandInDisposition(nDispId)
|
|
GetMoveInfoInDisposition(nDispId, m_RawMoveDataList)
|
|
End If
|
|
End If
|
|
|
|
' aggiorno il messaggio del comando per gestire gli sfridi
|
|
VerifyIsNewScrap(m_CurrRawOnVacuum)
|
|
' aggiorno la visibilità dei comandi
|
|
RefreshVisibility()
|
|
' salvo l'idice della fase corrente
|
|
m_nCurrDisposition = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
' Abilitazione bottone modifica
|
|
ModifyBtn.IsEnabled = m_SplitPage.m_bShow
|
|
' gestione abilitazione altri bottoni
|
|
EnableButtons()
|
|
End Sub
|
|
|
|
' Gestione di visualizzazione dei comandi per il movimento dei pezzi
|
|
Private Sub RefreshVisibility()
|
|
' Aggiorno visulizzazione comando per passare alla pagina di scarico
|
|
If Not m_SplitPage.m_bEnableOnAuxTab Then
|
|
UnloadPartsBtn.Visibility = Visibility.Hidden
|
|
Else
|
|
UnloadPartsBtn.Visibility = Visibility.Visible
|
|
If m_SplitPage.m_bOnAuxTab Then
|
|
UnloadPartsBtn.Content = EgtMsg(90368) ' Go to MOVE part
|
|
' altrimenti, aggiorno visualizzazione
|
|
Else
|
|
UnloadPartsBtn.Content = EgtMsg(90369) ' Go to UNLOAD part
|
|
End If
|
|
End If
|
|
' Aggiorno interfaccia per taglio perpendicolare
|
|
If m_bByHand Then
|
|
UpBtn.Visibility = Windows.Visibility.Visible
|
|
LeftBtn.Visibility = Windows.Visibility.Hidden
|
|
RightBtn.Visibility = Windows.Visibility.Hidden
|
|
DownBtn.Visibility = Windows.Visibility.Visible
|
|
StepMoveTxBx.Visibility = Windows.Visibility.Visible
|
|
RotateClockwiseBtn.Visibility = Windows.Visibility.Hidden
|
|
RotateCounterClockwiseBtn.Visibility = Windows.Visibility.Hidden
|
|
RotationAngle.Visibility = Windows.Visibility.Hidden
|
|
RemovePartBtn.Visibility = Windows.Visibility.Visible
|
|
TopLBtn.Visibility = Windows.Visibility.Hidden
|
|
TopRBtn.Visibility = Windows.Visibility.Hidden
|
|
BottomLBtn.Visibility = Windows.Visibility.Hidden
|
|
BottomRBtn.Visibility = Windows.Visibility.Hidden
|
|
PauseBtn.Visibility = Windows.Visibility.Hidden
|
|
ResetBtn.Visibility = Windows.Visibility.Hidden
|
|
ScrapsBtn.Visibility = m_ScrapsVisibility
|
|
' altrimenti per movimento con ventose
|
|
ElseIf Not m_SplitPage.m_bOnAuxTab Then
|
|
UpBtn.Visibility = Windows.Visibility.Visible
|
|
LeftBtn.Visibility = Windows.Visibility.Visible
|
|
RightBtn.Visibility = Windows.Visibility.Visible
|
|
DownBtn.Visibility = Windows.Visibility.Visible
|
|
StepMoveTxBx.Visibility = Windows.Visibility.Visible
|
|
RotateClockwiseBtn.Visibility = If(m_MainWindow.m_CurrentMachine.bRawSplMovRotate, Windows.Visibility.Visible, Windows.Visibility.Hidden)
|
|
RotateCounterClockwiseBtn.Visibility = If(m_MainWindow.m_CurrentMachine.bRawSplMovRotate, Windows.Visibility.Visible, Windows.Visibility.Hidden)
|
|
RotationAngle.Visibility = If(m_MainWindow.m_CurrentMachine.bRawSplMovRotate, Windows.Visibility.Visible, Windows.Visibility.Hidden)
|
|
RemovePartBtn.Visibility = Windows.Visibility.Visible
|
|
TopLBtn.Visibility = Windows.Visibility.Hidden
|
|
TopRBtn.Visibility = Windows.Visibility.Hidden
|
|
BottomLBtn.Visibility = Windows.Visibility.Hidden
|
|
BottomRBtn.Visibility = Windows.Visibility.Hidden
|
|
PauseBtn.Visibility = Windows.Visibility.Hidden
|
|
ResetBtn.Visibility = Windows.Visibility.Hidden
|
|
ScrapsBtn.Visibility = m_ScrapsVisibility
|
|
' altrimenti per movimento finale dei pezzi
|
|
Else
|
|
UpBtn.Visibility = Windows.Visibility.Hidden
|
|
LeftBtn.Visibility = Windows.Visibility.Hidden
|
|
RightBtn.Visibility = Windows.Visibility.Hidden
|
|
DownBtn.Visibility = Windows.Visibility.Hidden
|
|
StepMoveTxBx.Visibility = Windows.Visibility.Hidden
|
|
RotateClockwiseBtn.Visibility = Windows.Visibility.Hidden
|
|
RotateCounterClockwiseBtn.Visibility = Windows.Visibility.Hidden
|
|
RotationAngle.Visibility = Windows.Visibility.Hidden
|
|
RemovePartBtn.Visibility = Windows.Visibility.Hidden
|
|
TopLBtn.Visibility = Windows.Visibility.Visible
|
|
TopRBtn.Visibility = Windows.Visibility.Visible
|
|
BottomLBtn.Visibility = Windows.Visibility.Visible
|
|
BottomRBtn.Visibility = Windows.Visibility.Visible
|
|
PauseBtn.Visibility = Windows.Visibility.Visible
|
|
ResetBtn.Visibility = Windows.Visibility.Visible
|
|
ScrapsBtn.Visibility = Windows.Visibility.Hidden
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub SetAuxTabInCurrDisposition()
|
|
' Se movimento pezzi finale, sistemazioni per tavolo ausiliario
|
|
m_nAuxTabId = EgtGetTableId(AUX_TAB)
|
|
' Visualizzo tavolo ausiliario
|
|
Dim bOldEnMod As Boolean = EgtGetEnableModified()
|
|
If bOldEnMod Then EgtDisableModified()
|
|
EgtSetStatus(m_nAuxTabId, GDB_ST.ON_)
|
|
If bOldEnMod Then EgtEnableModified()
|
|
' Se definizione movimenti
|
|
If Not m_SplitPage.m_bShow Then
|
|
' Area tavolo ausiliario
|
|
Dim b3AuxTab As New BBox3d
|
|
EgtGetBBoxGlob(EgtGetFirstNameInGroup(m_nAuxTabId, "A1"), GDB_BB.STANDARD, b3AuxTab)
|
|
' Area tavolo principale
|
|
Dim b3Tab As New BBox3d
|
|
EgtGetTableArea(1, b3Tab)
|
|
' Imposto offset su tavolo principale per includere anche il secondario
|
|
Dim dOffsXP As Double = Math.Max(b3AuxTab.Max().x - b3Tab.Max().x, 0)
|
|
Dim dOffsYP As Double = Math.Max(b3AuxTab.Max().y - b3Tab.Max().y, 0)
|
|
Dim dOffsXM As Double = Math.Max(b3Tab.Min().x - b3AuxTab.Min().x, 0)
|
|
Dim dOffsYM As Double = Math.Max(b3Tab.Min().y - b3AuxTab.Min().y, 0)
|
|
EgtSetTableAreaOffset(dOffsXP, dOffsYP, dOffsXM, dOffsYM)
|
|
End If
|
|
EgtZoom(ZM.ALL)
|
|
|
|
End Sub
|
|
|
|
Private Sub OnMyMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_CurrProjPage.OnMouseDownScene
|
|
' Verifico di essere il gestore attivo
|
|
If Not m_bActive Then Return
|
|
' Verifico di non essere in modalità solo visualizzazione
|
|
If m_SplitPage.m_bShow Then Return
|
|
' Si può selezionare solo con il tasto sinistro e se stato NULL
|
|
If e.Button <> Windows.Forms.MouseButtons.Left Or
|
|
Not m_CurrProjPage.CurrentProjectScene.IsStatusNull() Then
|
|
Return
|
|
End If
|
|
' Gruppo dei grezzi
|
|
Dim nRawGroupId = EgtGetParent(EgtGetFirstRawPart())
|
|
' Verifico se selezionato indicativo di grezzo attivo
|
|
EgtSetObjFilterForSelWin(True, True, True, True, True)
|
|
Dim nSel As Integer
|
|
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
|
|
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
|
While nId <> GDB_ID.NULL
|
|
' Cerco l'identificativo del grezzo cui appartiene
|
|
Dim nParentId = EgtGetParent(nId)
|
|
While nParentId <> GDB_ID.NULL And nParentId <> nRawGroupId
|
|
nId = nParentId
|
|
nParentId = EgtGetParent(nId)
|
|
End While
|
|
' Se trovato il grezzo
|
|
If nParentId = nRawGroupId Then
|
|
Dim nStat As Integer = GDB_ST.ON_
|
|
EgtGetStatus(nId, nStat)
|
|
' aggiorno il messaggio del bottone "Scrap" a seconda che il grezzo sia già uno scrap
|
|
VerifyIsNewScrap(nId)
|
|
' Se il pezzo corrente è selezionato allora lo disattivo -> deposito del pezzo
|
|
If nStat = GDB_ST.SEL Then
|
|
EgtSetStatus(nId, GDB_ST.ON_)
|
|
' prima di rilasciare il pezzo verifico che non vada in collisione con altri pezzi sulla tavola (evito il controllo se ultima fase)
|
|
If VerifyCollisionWithOtherRawPart(nId) Then
|
|
' mantengo la selezione del pezzo
|
|
EgtSetStatus(nId, GDB_ST.SEL)
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(91231)) ' Collisione pezzi
|
|
Else
|
|
' Se con ventose, le nascondo
|
|
If Not m_bByHand Then EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
End If
|
|
Else
|
|
' verifico che il pezzo precedente possa essere depositato correttamente
|
|
If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then
|
|
' mantengo la selezione del pezzo
|
|
EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL)
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(91231)) ' Collisione pezzi
|
|
EgtDraw()
|
|
' esco dal ciclo, prima devo depositare correttamente il pezzo
|
|
Exit While
|
|
End If
|
|
' Verifico che il pezzo corrente sia prelevabile - versione 2.6c3 -
|
|
If VerifyCollisionWithOtherRawPart(nId, True) Then
|
|
' mantengo la selezione del pezzo
|
|
EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL)
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(91231)) ' Collisione pezzi
|
|
EgtDraw()
|
|
' esco dal ciclo, prima devo depositare correttamente il pezzo
|
|
Exit While
|
|
End If
|
|
' salvo l'indice del pezzo correntemente attaccato alle ventose
|
|
m_CurrRawOnVacuum = nId
|
|
|
|
' Deseleziono tutto e abilito la selezione del pezzo corrente
|
|
EgtDeselectAll()
|
|
EgtSetStatus(nId, GDB_ST.SEL)
|
|
' Se con ventose, le posiziono sul grezzo
|
|
If Not m_bByHand Then
|
|
Dim rmData As New RawMoveData
|
|
' inizializzo i dati del grezzo per il cacolo del peso
|
|
Dim MaxSinglePlugger As Double = 250
|
|
MaxSinglePlugger = GetPrivateProfileDouble(S_MACH_RAWMOVE, K_MACH_WEIGHT_SINGLEPLUGGER, MaxSinglePlugger, m_MainWindow.GetMachIniFile())
|
|
Dim MaxDoublePlugger As Double = 750
|
|
MaxDoublePlugger = GetPrivateProfileDouble(S_MACH_RAWMOVE, K_MACH_WEIGHT_DOUBLEPLUGGER, MaxDoublePlugger, m_MainWindow.GetMachIniFile())
|
|
Dim AverageDensity As Double = 2700
|
|
AverageDensity = GetPrivateProfileDouble(S_MATERIALS, K_AVERAGEDENSITY, AverageDensity, m_MainWindow.GetMachIniFile())
|
|
VacuumCups.SetWeightInformation(AverageDensity, MaxSinglePlugger, MaxDoublePlugger)
|
|
VacuumCups.SetRotationForExtraStrokeY(GetPrivateProfileInt(S_MACH_RAWMOVE, K_MACH_ROTATEVACUUMFOREXTRASTROKEY, 0, m_MainWindow.GetMachIniFile()) <> 0)
|
|
VacuumCups.SetRotationForExtraStrokeX(GetPrivateProfileInt(S_MACH_RAWMOVE, K_MACH_ROTATEVACUUMFOREXTRASTROKEX, 0, m_MainWindow.GetMachIniFile()) <> 0)
|
|
|
|
VacuumCups.ResetHeadName()
|
|
Dim bPutVacuum As Boolean = PutVacuumCupsOnRaw(nId, rmData)
|
|
If Not bPutVacuum Then
|
|
Dim bTwoHeadVac As Boolean = (EgtGetHeadId(VACUUM_HEAD_2) <> GDB_ID.NULL)
|
|
If bTwoHeadVac Then bPutVacuum = PutVacuumCupsOnRaw(nId, rmData)
|
|
End If
|
|
|
|
If bPutVacuum Then
|
|
' Visualizzo le ventose
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.ON_)
|
|
' Aggiorno i dati
|
|
AddRawMoveData(rmData, m_RawMoveDataList)
|
|
m_bRawWithCups = True
|
|
' Reset eventuale messaggio
|
|
m_CurrProjPage.ClearMessage()
|
|
Else
|
|
' nascondo la visualizzazione delle ventose
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
' Aggiorno i dati
|
|
m_bRawWithCups = False
|
|
If VacuumCups.m_bOverWeight Then
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90364)) ' Pezzo troppo pesante : non si può muovere
|
|
ElseIf VacuumCups.m_bExtraStroke Then
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90365)) ' Pezzo oltre le corse : non si può muovere
|
|
Else
|
|
' Messaggio di avvertimento
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90362)) ' Pezzo troppo piccolo : non si può muovere
|
|
End If
|
|
End If
|
|
|
|
|
|
End If
|
|
End If
|
|
EgtDraw()
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
|
|
' clicco su un oggetto che non è un grezzo -> verifico che il pezzo precedente possa essere depositato correttamente
|
|
If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then
|
|
' mantengo la selezione del pezzo
|
|
EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL)
|
|
m_CurrProjPage.SetErrorMessage("Collisione pezzi")
|
|
EgtDraw()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
' Veririfica che il grezzo non entri in colliosione con altri pezzi
|
|
Private Function VerifyCollisionWithOtherRawPart_0(nIdOnVacumm As Integer) As Boolean
|
|
' se movimento su tavola di scarico non eseguo il controllo (evito di segnalre errori per pezzi ricavati interni al grezzo...)
|
|
If m_SplitPage.m_bOnAuxTab Then Return False
|
|
If nIdOnVacumm = GDB_ID.NULL Then Return False
|
|
' Creo gruppo temporaneo in cui generare le superfici per la veririfica di collisione
|
|
Dim m_nTempId As Integer = EgtCreateGroup(GDB_ID.ROOT)
|
|
If m_nTempId = GDB_ID.NULL Then Return False
|
|
EgtSetName(m_nTempId, "RawTemp")
|
|
Dim nIdActualRawOutLine As Integer = EgtGetFirstNameInGroup(nIdOnVacumm, "RawOutline")
|
|
Dim ActualRawFlatRegion As Integer = EgtCreateSurfFlatRegion(m_nTempId, nIdActualRawOutLine)
|
|
Dim nCurrPhase As Integer = EgtGetCurrPhase()
|
|
Dim nRawGroupId = EgtGetParent(EgtGetFirstRawPart())
|
|
Dim nIdRaw As Integer = EgtGetFirstRawPart()
|
|
' ciclo su tutti i grezzi per veririficare eventuali collisioni
|
|
While nIdRaw <> GDB_ID.NULL
|
|
' verifico la fase del grezzo
|
|
If EgtVerifyRawPartCurrPhase(nIdRaw) And nIdOnVacumm <> nIdRaw Then
|
|
' recupero il contorno del pezzo
|
|
Dim nIdRawOutLine As Integer = EgtGetFirstNameInGroup(nIdRaw, "RawOutline")
|
|
Dim nIdRawFlatRegion As Integer = EgtCreateSurfFlatRegion(m_nTempId, nIdRawOutLine)
|
|
If EgtSurfFrIntersect(nIdRawFlatRegion, ActualRawFlatRegion) Then
|
|
If EgtExistsObj(nIdRawFlatRegion) Then
|
|
EgtErase(m_nTempId)
|
|
' esiste una intersezione delle superfici
|
|
Return True
|
|
End If
|
|
End If
|
|
End If
|
|
nIdRaw = EgtGetNextRawPart(nIdRaw)
|
|
End While
|
|
EgtErase(m_nTempId)
|
|
Return False
|
|
End Function
|
|
|
|
' Verifica che il grezzo non entri in collisione con altri pezzi - versione 2.6c3 -
|
|
Private Function VerifyCollisionWithOtherRawPart(nIdOnVacumm As Integer, Optional IsTaking As Boolean = False) As Boolean
|
|
' se movimento su tavola di scarico non eseguo il controllo (evito di segnalare errori per pezzi ricavati interni al grezzo...)
|
|
If m_SplitPage.m_bOnAuxTab Then Return False
|
|
If nIdOnVacumm = GDB_ID.NULL Then Return False
|
|
' Creo gruppo temporaneo in cui generare le superfici per la verifica di collisione
|
|
Dim m_nTempId As Integer = EgtCreateGroup(GDB_ID.ROOT)
|
|
If m_nTempId = GDB_ID.NULL Then Return False
|
|
EgtSetName(m_nTempId, "RawTemp")
|
|
' recupero le regioni del grezzo attaccato alle ventose e da questo genero una superficie
|
|
Dim nIdUpRegionOnVac As Integer = EgtGetFirstNameInGroup(nIdOnVacumm, "RawUpReg")
|
|
Dim nIdDwnRegionOnVac As Integer = EgtGetFirstNameInGroup(nIdOnVacumm, "RawDwnReg")
|
|
' recupero gli ID di tutti i grezzi della fase corrente
|
|
Dim nCurrPhase As Integer = EgtGetCurrPhase()
|
|
Dim nRawGroupId = EgtGetParent(EgtGetFirstRawPart())
|
|
Dim nIdRaw As Integer = EgtGetFirstRawPart()
|
|
' ciclo su tutti i grezzi per veririficare eventuali collisioni
|
|
While nIdRaw <> GDB_ID.NULL
|
|
' verifico la fase del grezzo
|
|
If EgtVerifyRawPartCurrPhase(nIdRaw) And nIdOnVacumm <> nIdRaw Then
|
|
' recupero le regioni del grezzo
|
|
Dim nIdUpRegion As Integer = EgtGetFirstNameInGroup(nIdRaw, "RawUpReg")
|
|
Dim nIdDwnRegion As Integer = EgtGetFirstNameInGroup(nIdRaw, "RawDwnReg")
|
|
' creo la copia delle regioni
|
|
Dim nCopy_IdDwnRegionOnVac As Integer = EgtCopyGlob(nIdDwnRegionOnVac, m_nTempId)
|
|
' PRELIEVO
|
|
If EgtSurfFrIntersect(nCopy_IdDwnRegionOnVac, nIdUpRegion) Then
|
|
' se esiste la regione risultato, allora c'è intersezione
|
|
If EgtExistsObj(nCopy_IdDwnRegionOnVac) Then
|
|
EgtErase(m_nTempId)
|
|
' Esco: Intersezione TROVATA -> true
|
|
Return True
|
|
End If
|
|
End If
|
|
' DEPOSITO : devono essere eseguiti due controlli ulteriori
|
|
If Not IsTaking Then
|
|
nCopy_IdDwnRegionOnVac = EgtCopyGlob(nIdDwnRegionOnVac, m_nTempId)
|
|
If EgtSurfFrIntersect(nCopy_IdDwnRegionOnVac, nIdDwnRegion) Then
|
|
' se esiste la regione risultato, allora c'è intersezione
|
|
If EgtExistsObj(nCopy_IdDwnRegionOnVac) Then
|
|
EgtErase(m_nTempId)
|
|
' Esco: Intersezione TROVATA -> true
|
|
Return True
|
|
End If
|
|
End If
|
|
Dim nCopy_IdUpRegionOnVac As Integer = EgtCopyGlob(nIdUpRegionOnVac, m_nTempId)
|
|
If EgtSurfFrIntersect(nCopy_IdUpRegionOnVac, nIdUpRegion) Then
|
|
' se esiste la regione risultato, allora c'è intersezione
|
|
If EgtExistsObj(nCopy_IdUpRegionOnVac) Then
|
|
EgtErase(m_nTempId)
|
|
' Esco: Intersezione TROVATA -> true
|
|
Return True
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
nIdRaw = EgtGetNextRawPart(nIdRaw)
|
|
End While
|
|
EgtErase(m_nTempId)
|
|
Return False
|
|
End Function
|
|
|
|
Private Function VerifyIsNewScrap(nMyId As Integer) As Boolean
|
|
Dim nVal As Integer = 0
|
|
If EgtGetInfo(nMyId, K_ISNEWSCRAPS, nVal) Then
|
|
If nVal = 1 Or nVal = 2 Then
|
|
' 1 -> definito come nuovo grezzo oppure, 2 -> definito come nuovo grezzo ed inserito nel DB delle lastre
|
|
ScrapsBtn.Content = EgtMsg(91228) ' Remove Scrap
|
|
ScrapsBtn.IsEnabled = True And Not m_SplitPage.m_bShow
|
|
Return True
|
|
ElseIf nVal = 3 Then
|
|
' non è possibile rimuovere il grezzo in questa fase
|
|
ScrapsBtn.Content = EgtMsg(91229) ' Defined as Scrap
|
|
ScrapsBtn.IsEnabled = False
|
|
Return True
|
|
End If
|
|
End If
|
|
' non è un nuovo grezzo
|
|
ScrapsBtn.Content = EgtMsg(91230) ' Add Scrap
|
|
ScrapsBtn.IsEnabled = True And Not m_SplitPage.m_bShow
|
|
Return False
|
|
End Function
|
|
|
|
#Region "Move Up/Down/Left/Right"
|
|
|
|
Private Sub UpBtn_Click(sender As Object, e As RoutedEventArgs) Handles UpBtn.Click
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
' Se movimento perpendicolare, è allontanamento
|
|
If m_bByHand Then
|
|
' Recupero il centro del grezzo
|
|
Dim ptRawCen As Point3d
|
|
EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
' Calcolo la distanza di movimento
|
|
Dim dMove As Double = m_dStep
|
|
If m_dCurrDist < EPS_SMALL Then
|
|
dMove -= m_dOrigDist
|
|
End If
|
|
If (m_vtDir * (ptRawCen - m_ptMid) < 0) Then dMove *= -1
|
|
' Eseguo il movimento
|
|
If EgtMoveRawPart(nRawId, dMove * m_vtDir) Then
|
|
m_dCurrDist += Math.Abs(dMove)
|
|
End If
|
|
' Altrimenti movimento Y +
|
|
Else
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(0, m_dStep, 0)
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
m_CurrProjPage.ClearMessage()
|
|
VerifyReleasePositionIsValid(vtMove)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.m_ptStartPointLift.y -= vtMove.y
|
|
End If
|
|
Else
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90362)) 'Pezzo troppo piccolo : non si può muovere
|
|
End If
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub DownBtn_Click(sender As Object, e As RoutedEventArgs) Handles DownBtn.Click
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
' Se movimento perpendicolare, è avvicinamento
|
|
If m_bByHand Then
|
|
' Se sono già a contatto, non devo fare alcunché
|
|
If m_dCurrDist < EPS_SMALL Then Return
|
|
' Recupero il centro del grezzo
|
|
Dim ptRawCen As Point3d
|
|
EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
' Calcolo la distanza di movimento
|
|
Dim dMove As Double = m_dStep
|
|
If m_dCurrDist < m_dStep Then
|
|
dMove -= m_dOrigDist
|
|
End If
|
|
If (m_vtDir * (ptRawCen - m_ptMid) > 0) Then dMove *= -1
|
|
' Eseguo il movimento
|
|
If EgtMoveRawPart(nRawId, dMove * m_vtDir) Then
|
|
m_dCurrDist -= Math.Abs(dMove)
|
|
End If
|
|
' Altrimenti movimento Y -
|
|
Else
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(0, -m_dStep, 0)
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
m_CurrProjPage.ClearMessage()
|
|
VerifyReleasePositionIsValid(vtMove)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.m_ptStartPointLift.y -= vtMove.y
|
|
End If
|
|
Else
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90362)) 'Pezzo troppo piccolo : non si può muovere
|
|
End If
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub RightBtn_Click(sender As Object, e As RoutedEventArgs) Handles RightBtn.Click
|
|
' Solo movimento con ventose
|
|
If m_bByHand Then Return
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(m_dStep, 0, 0)
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
m_CurrProjPage.ClearMessage()
|
|
VerifyReleasePositionIsValid(vtMove)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.m_ptStartPointLift.x -= vtMove.x
|
|
End If
|
|
Else
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90362)) 'Pezzo troppo piccolo : non si può muovere
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub LeftBtn_Click(sender As Object, e As RoutedEventArgs) Handles LeftBtn.Click
|
|
' Solo movimento con ventose
|
|
If m_bByHand Then Return
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(-m_dStep, 0, 0)
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
m_CurrProjPage.ClearMessage()
|
|
VerifyReleasePositionIsValid(vtMove)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.m_ptStartPointLift.x -= vtMove.x
|
|
End If
|
|
Else
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90362)) ' Pezzo troppo piccolo : non si può muovere
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region 'Move Up/Down/Left/Right
|
|
|
|
' verifica che la posizione da raggiungere sia nei limiti delle corse
|
|
Private Function VerifyReleasePositionIsValid(ByRef vtMove As Vector3d) As Boolean
|
|
Dim bOk As Boolean = True
|
|
' determino il punto finale dello spostamento
|
|
Dim ptEndPointLift As Point3d = VacuumCups.m_ptStartPointLift
|
|
ptEndPointLift.x += vtMove.x
|
|
ptEndPointLift.y += vtMove.y
|
|
Dim sInfo As String = String.Empty
|
|
Select Case VacuumCups.VerifyOutOfStrokes(ptEndPointLift, VacuumCups.m_dDegRotStartAng)
|
|
Case 1
|
|
' extra corsa sulla x-: devo ridurre del valore di extra corsa
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90552) & " " & sInfo) ' Extracorsa ...
|
|
ptEndPointLift.x -= vtMove.x
|
|
Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo)
|
|
If Math.Abs(dMaxMove - vtMove.x) <= EPS_SMALL * 100 Then
|
|
vtMove.x = 0
|
|
Else
|
|
vtMove.x -= dMaxMove - EPS_SMALL * 100
|
|
End If
|
|
ptEndPointLift.x += vtMove.x
|
|
bOk = False
|
|
Case 2
|
|
' extra corsa sulla x+: devo ridurre del valore di extra corsa
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90552) & " " & sInfo) ' Extracorsa ...
|
|
ptEndPointLift.x -= vtMove.x
|
|
Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo)
|
|
If Math.Abs(dMaxMove - vtMove.x) <= EPS_SMALL * 100 Then
|
|
vtMove.x = 0
|
|
Else
|
|
vtMove.x -= dMaxMove + EPS_SMALL * 100
|
|
End If
|
|
ptEndPointLift.x += vtMove.x
|
|
bOk = False
|
|
Case 4
|
|
' extra corsa sulla y-
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90552) & " " & sInfo) ' Extracorsa ...
|
|
ptEndPointLift.y -= vtMove.y
|
|
Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo)
|
|
If Math.Abs(dMaxMove - vtMove.y) <= EPS_SMALL * 100 Then
|
|
vtMove.y = 0
|
|
Else
|
|
vtMove.y -= dMaxMove - EPS_SMALL * 100
|
|
End If
|
|
ptEndPointLift.y += vtMove.y
|
|
bOk = False
|
|
Case 8
|
|
' extra corsa sulla y+
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90552) & " " & sInfo) ' Extracorsa ...
|
|
ptEndPointLift.y -= vtMove.y
|
|
Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo)
|
|
If Math.Abs(dMaxMove - vtMove.y) <= EPS_SMALL * 100 Then
|
|
vtMove.y = 0
|
|
Else
|
|
vtMove.y -= dMaxMove + EPS_SMALL * 100
|
|
End If
|
|
ptEndPointLift.y += vtMove.y
|
|
bOk = False
|
|
End Select
|
|
' il movimento del pezzo è accettabile, aggiorno le posizione per la verifica dello step successivo
|
|
VacuumCups.m_ptStartPointLift = ptEndPointLift
|
|
Return bOk
|
|
End Function
|
|
|
|
#Region "Rotate CounterClockWise/ClockWise"
|
|
|
|
Private Sub RotateCounterClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateCounterClockwiseBtn.Click
|
|
' Solo movimento con ventose
|
|
If m_bByHand Then Return
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
If m_bRawWithCups Then
|
|
Dim dAng As Double = m_dRotation
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
' Recupero il centro del grezzo
|
|
Dim ptRawCen As Point3d
|
|
EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
m_CurrProjPage.ClearMessage()
|
|
VerifyReleasdAngleIsValid(dAng, ptRawCen)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAng) Then
|
|
'' Recupero il centro del grezzo
|
|
'Dim ptRawCen As Point3d
|
|
'EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
' Eseguo la rotazione della ventosa
|
|
EgtRotate(GetVacuumId(), ptRawCen, Vector3d.Z_AX(), dAng, GDB_RT.GLOB)
|
|
' Memorizzo
|
|
AddRawMoveData(nRawId, dAng, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.m_ptStartPointLift.Rotate(ptRawCen, Vector3d.Z_AX(), dAng)
|
|
VacuumCups.m_dDegRotStartAng -= dAng
|
|
End If
|
|
Else
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90362)) ' Pezzo troppo piccolo : non si può muovere
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub RotateClockwiseBtn_Click(sender As Object, e As RoutedEventArgs) Handles RotateClockwiseBtn.Click
|
|
' Solo movimento con ventose
|
|
If m_bByHand Then Return
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
If m_bRawWithCups Then
|
|
Dim dAng As Double = -m_dRotation
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
' Recupero il centro del grezzo
|
|
Dim ptRawCen As Point3d
|
|
EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
m_CurrProjPage.ClearMessage()
|
|
VerifyReleasdAngleIsValid(dAng, ptRawCen)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAng) Then
|
|
'' Recupero il centro del grezzo
|
|
'Dim ptRawCen As Point3d
|
|
'EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
' Eseguo la rotazione della ventosa
|
|
EgtRotate(GetVacuumId(), ptRawCen, Vector3d.Z_AX(), dAng, GDB_RT.GLOB)
|
|
' Memorizzo
|
|
AddRawMoveData(nRawId, dAng, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.m_ptStartPointLift.Rotate(ptRawCen, Vector3d.Z_AX(), dAng)
|
|
VacuumCups.m_dDegRotStartAng -= dAng
|
|
End If
|
|
Else
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90362)) ' Pezzo troppo piccolo : non si può muovere
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' Rotate CounterClockWise/ClockWise
|
|
|
|
' verifica che la rotazione da raggiungere sia nei limiti delle corse
|
|
Private Function VerifyReleasdAngleIsValid(ByRef dAngDeg As Double, ByVal ptCenter As Point3d) As Boolean
|
|
Dim bOk As Boolean = True
|
|
' determino il punto finale dello spostamento
|
|
Dim ptEndPointLift As Point3d = VacuumCups.m_ptStartPointLift
|
|
Dim dDegRotEndAng As Double = VacuumCups.m_dDegRotStartAng + dAngDeg
|
|
ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), dAngDeg)
|
|
Dim sInfo As String = String.Empty
|
|
Select Case VacuumCups.VerifyOutOfStrokes(ptEndPointLift, dDegRotEndAng)
|
|
Case 16
|
|
' extra corsa sulla c-
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90552) & " " & sInfo) ' Extracorsa ...
|
|
ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), -dAngDeg)
|
|
dDegRotEndAng -= dAngDeg
|
|
dAngDeg += VacuumCups.GetExtraStrokeValue(sInfo) + EPS_SMALL
|
|
dDegRotEndAng += dAngDeg
|
|
ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), dAngDeg)
|
|
bOk = False
|
|
Case 34
|
|
' extra corsa sulla c+
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90552) & " " & sInfo) ' Extracorsa ...
|
|
ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), -dAngDeg)
|
|
dDegRotEndAng -= dAngDeg
|
|
dAngDeg -= VacuumCups.GetExtraStrokeValue(sInfo) + EPS_SMALL
|
|
dDegRotEndAng += dAngDeg
|
|
ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), dAngDeg)
|
|
bOk = False
|
|
End Select
|
|
' il movimento del pezzo è accettabile, aggiorno le posizione per la verifica dello step successivo
|
|
VacuumCups.m_ptStartPointLift = ptEndPointLift
|
|
VacuumCups.m_dDegRotStartAng = dDegRotEndAng
|
|
Return bOk
|
|
End Function
|
|
|
|
Private Sub RemovePart_KeyCancel(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles m_CurrProjPage.OnKeyCancelDownScene
|
|
If e.KeyCode = System.Windows.Forms.Keys.Delete Then
|
|
RemovePartBtn_Click(Nothing, Nothing)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RemovePartBtn_Click(sender As Object, e As RoutedEventArgs) Handles RemovePartBtn.Click
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
EgtRemoveRawPartFromCurrPhase(nRawId)
|
|
' Se con ventose
|
|
If Not m_bByHand Then
|
|
m_bRemovedRaw = True
|
|
' rimuovo eventuali indicazioni di movimento
|
|
RemoveRawMoveData(nRawId, m_RawMoveDataList)
|
|
' nascondo le ventose
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
' Reset eventuale messaggio
|
|
m_CurrProjPage.ClearMessage()
|
|
End If
|
|
nRawId = EgtGetFirstSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub ScrapsBtn_Click(Sender As Object, e As RoutedEventArgs) Handles ScrapsBtn.Click
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
' verifico che il grezzo non contenga dei pezzi (altrimenti non risulta selezionabile)
|
|
Dim nPartInRaw As Integer = EgtGetFirstPartInRawPart(nRawId)
|
|
If nPartInRaw = GDB_ID.NULL Then
|
|
If Not VerifyIsNewScrap(nRawId) Then
|
|
EgtSetInfo(nRawId, K_ISNEWSCRAPS, "1")
|
|
Else
|
|
EgtRemoveInfo(nRawId, K_ISNEWSCRAPS)
|
|
End If
|
|
' aggiorno il contenuto del bottone
|
|
VerifyIsNewScrap(nRawId)
|
|
Else
|
|
' coumico che il grezzo contiene un pezzo e quindi non può essere definito come grezzo
|
|
m_CurrProjPage.ClearMessage()
|
|
m_CurrProjPage.SetErrorMessage("Part inside raw!")
|
|
End If
|
|
' passo al grezzo succesivo (NON dovrebbero esserci altri grezzi selezionabili contemporaneamente!)
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
End Sub
|
|
|
|
' Passo dalla pagina di movimento dei pezzi alla pagina di scarico
|
|
Private Sub UnloadPartBtn_Click() Handles UnloadPartsBtn.Click
|
|
' forzo lo stato di scarico frontale oppure di movimento
|
|
m_SplitPage.m_bOnAuxTab = Not m_SplitPage.m_bOnAuxTab
|
|
|
|
' se rientro nella fase di spostamenti allora nascondo la tavola di scarico
|
|
If Not m_SplitPage.m_bOnAuxTab Then
|
|
' se ci sono pezzi sulla tavola di scarico non posso nasconderla
|
|
Dim LclLstOfUnldPart As New List(Of Integer)
|
|
If Not PartOnAuxTab(LclLstOfUnldPart, m_nCurrPhase) Then
|
|
EgtDisableModified()
|
|
' nascondo la tavola di scarico
|
|
EgtSetStatus(m_nAuxTabId, GDB_ST.OFF)
|
|
' Nascondo eventuali pezzi in parcheggio
|
|
HideParkedParts()
|
|
EgtEnableModified()
|
|
End If
|
|
Else
|
|
' Assegnazione delle info tavola ausiliaria alla dispozione corrente
|
|
SetAuxTabInCurrDisposition()
|
|
End If
|
|
|
|
' Mantengo la fase che è stata creata e passo a gestire solo la visualizzazione dei bottoni
|
|
RefreshVisibility()
|
|
EgtZoom(ZM.ALL, True)
|
|
|
|
End Sub
|
|
|
|
Private Sub StepMoveTxBx_EgtClosed(sender As Object, e As EventArgs) Handles StepMoveTxBx.EgtClosed
|
|
Dim dStep As Double
|
|
If StringToLen(StepMoveTxBx.Text, dStep) Then
|
|
m_dStep = Math.Max(dStep, 2 * EPS_SMALL)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RotationAngleTxBx_EgtClosed(sender As Object, e As EventArgs) Handles RotationAngleTxBx.EgtClosed
|
|
Dim dRotation As Double
|
|
If StringToDouble(RotationAngleTxBx.Text, dRotation) Then
|
|
m_dRotation = Math.Max(dRotation, 2 * EPS_ANG_SMALL)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub TopLBtn_Click(sender As Object, e As RoutedEventArgs) Handles TopLBtn.Click
|
|
MoveOnRef("REF4", MCH_CR.TL)
|
|
End Sub
|
|
|
|
Private Sub TopRBtn_Click(sender As Object, e As RoutedEventArgs) Handles TopRBtn.Click
|
|
MoveOnRef("REF3", MCH_CR.TR)
|
|
End Sub
|
|
|
|
Private Sub BottomLBtn_Click(sender As Object, e As RoutedEventArgs) Handles BottomLBtn.Click
|
|
MoveOnRef("REF1", MCH_CR.BL)
|
|
End Sub
|
|
|
|
Private Sub BottomRBtn_Click(sender As Object, e As RoutedEventArgs) Handles BottomRBtn.Click
|
|
MoveOnRef("REF2", MCH_CR.BR)
|
|
End Sub
|
|
|
|
' posiziono il pezzo sulla tavola
|
|
Private Sub MoveOnRef(sRef As String, nCorn As Integer)
|
|
' Recupero il primo grezzo selezionato
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
If nRawId = GDB_ID.NULL Then Return
|
|
' Recupero la posizione e il tipo corner del riferimento TL (4)
|
|
Dim nRefId As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(m_nAuxTabId, "SOLID"), sRef)
|
|
If nRefId = GDB_ID.NULL Then Return
|
|
Dim ptRef As Point3d
|
|
If Not EgtGetInfo(nRefId, "Pos", ptRef) Then Return
|
|
Dim sCorn As String = ""
|
|
EgtGetInfo(nRefId, "COR", sCorn)
|
|
Select Case sCorn
|
|
Case "TL"
|
|
nCorn = MCH_CR.TL
|
|
Case "TR"
|
|
nCorn = MCH_CR.TR
|
|
Case "BL"
|
|
nCorn = MCH_CR.BL
|
|
Case "BR"
|
|
nCorn = MCH_CR.BR
|
|
End Select
|
|
' Recupero il centro del grezzo
|
|
Dim ptRawCen As Point3d
|
|
EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
' Sposto il grezzo in battuta sul corner
|
|
Dim dAngRaw As Double = 0
|
|
Dim dNewAngRot As Double = 0
|
|
|
|
Dim AngRotList As New List(Of Double)
|
|
|
|
' ricavo l'angolo di posizionamento del grezzo/pezzo sulla tavola
|
|
If Not DispositionRawOnTable(nRawId, dAngRaw, AngRotList) Then Return
|
|
Dim bb3dRaw As New BBox3d
|
|
EgtGetRawPartBBox(nRawId, bb3dRaw)
|
|
Dim ForceToRotate As Boolean = bb3dRaw.DimX < bb3dRaw.DimY
|
|
|
|
' provo a verificare di poter depositare il pezzo (senza applicare delle rotazioni)
|
|
If Not EgtMoveToCornerRawPart(nRawId, ptRef, nCorn) Or ForceToRotate Then
|
|
' se sono impostati degli step di rotazione
|
|
If AngRotList.Count > 0 Then
|
|
Dim bOkRotate As Boolean = False
|
|
' allora provo a ruotare il pezzo nel verso di rotazione della ventosa
|
|
For Each AngStep As Double In AngRotList
|
|
If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), -AngStep) Then
|
|
If Not EgtMoveToCornerRawPart(nRawId, ptRef, nCorn) Then
|
|
' riposiziono il pezzo come era prima
|
|
EgtRotateRawPart(nRawId, Vector3d.Z_AX(), AngStep)
|
|
Else
|
|
bOkRotate = True
|
|
' salvo l'angolo di deposito utilizzato
|
|
dAngRaw = -AngStep
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
If Not bOkRotate Then Return
|
|
Else
|
|
' sposto il pezzo in centro tavola → perchè tutti i movimenti sono fatti ruotando il pezzo in centro tavola!
|
|
Dim b3Area As New BBox3d
|
|
EgtGetTableArea(1, b3Area)
|
|
Dim b3RawTemp As New BBox3d
|
|
EgtGetRawPartBBox(nRawId, b3RawTemp)
|
|
' ricavo il riferimento dell'angolo in basso a sinstra del grezzo rispetto alla tavola
|
|
Dim ptCorner As Point3d = New Point3d(b3Area.DimX / 2, b3Area.DimY / 2, 0) - New Vector3d(b3RawTemp.DimX / 2, b3RawTemp.DimY / 2, 0)
|
|
' sposto il pezzo in questa posizione
|
|
EgtMoveToCornerRawPart(nRawId, ptCorner, MCH_CR.BL)
|
|
' riprovo il movimento
|
|
dNewAngRot = GetPrefRotAng(dAngRaw)
|
|
'dNewAngRot = DeltaAngC
|
|
If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dNewAngRot) Then
|
|
If Not EgtMoveToCornerRawPart(nRawId, ptRef, nCorn) Then
|
|
' riposiziono il pezzo come era prima
|
|
EgtRotateRawPart(nRawId, Vector3d.Z_AX(), -dAngRaw)
|
|
EgtDraw()
|
|
Return
|
|
End If
|
|
dAngRaw = dNewAngRot
|
|
Else
|
|
Return
|
|
End If
|
|
End If
|
|
Else
|
|
' significa che già il primo posizionamento è andato bene, quindi non devo impostare nessuna rotazione
|
|
dAngRaw = 0
|
|
End If
|
|
|
|
' Verifico non interferisca con altri grezzi
|
|
Dim bRawOk As Boolean = True
|
|
Dim b3Raw As New BBox3d
|
|
EgtGetRawPartBBox(nRawId, b3Raw)
|
|
Dim nOtherRaw As Integer = EgtGetFirstRawPart()
|
|
While nOtherRaw <> GDB_ID.NULL
|
|
If nOtherRaw <> nRawId AndAlso EgtVerifyRawPartCurrPhase(nOtherRaw) Then
|
|
Dim b3OtherRaw As New BBox3d
|
|
EgtGetRawPartBBox(nOtherRaw, b3OtherRaw)
|
|
If b3Raw.OverlapsXY(b3OtherRaw) Then
|
|
bRawOk = False
|
|
Exit While
|
|
End If
|
|
End If
|
|
nOtherRaw = EgtGetNextRawPart(nOtherRaw)
|
|
End While
|
|
|
|
' Determino il movimento effettuato
|
|
Dim ptNewRawCen As Point3d
|
|
EgtGetRawPartCenter(nRawId, ptNewRawCen)
|
|
' Se tutto bene, aggiorno lista movimenti
|
|
If bRawOk Then
|
|
AddRawMoveData(nRawId, ptNewRawCen - ptRawCen, m_RawMoveDataList)
|
|
If dAngRaw <> 0 Then AddRawMoveData(nRawId, dAngRaw, m_RawMoveDataList)
|
|
' altrimenti annullo il movimento
|
|
Else
|
|
EgtMoveRawPart(nRawId, ptRawCen - ptNewRawCen)
|
|
EgtRotateRawPart(nRawId, Vector3d.Z_AX(), -dAngRaw)
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90363)) ' Posizione scelta già occupata
|
|
End If
|
|
' Disabilito pezzo e nascondo le ventose
|
|
EgtSetStatus(nRawId, GDB_ST.ON_)
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
' calcolo la poszione del Pezzo/Grezzo presente sulla tavola
|
|
Private Function DispositionRawOnTable(nRawId As Integer, ByRef dMyAngH As Double, ByRef AngVacList As List(Of Double)) As Boolean
|
|
Dim nPartId As Integer
|
|
If EgtVerifyRawPartCurrPhase(nRawId) Then
|
|
nPartId = EgtGetFirstPartInRawPart(nRawId)
|
|
Dim nTempPart As Integer = nPartId
|
|
While nTempPart <> GDB_ID.NULL
|
|
nTempPart = EgtGetNextPartInRawPart(nPartId)
|
|
' significa che il grezzo contiene più di un pezzo
|
|
If nTempPart <> GDB_ID.NULL Then Return False
|
|
End While
|
|
End If
|
|
|
|
' Verifico sia veramente un pezzo
|
|
If EgtGetRawPartFromPart(nPartId) = GDB_ID.NULL Then Return False
|
|
' Recupero la regione del pezzo
|
|
Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, "Region")
|
|
Dim nRegId As Integer = EgtGetFirstInGroup(nGrpRegId)
|
|
While nRegId <> GDB_ID.NULL
|
|
If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then Exit While
|
|
nRegId = EgtGetNext(nRegId)
|
|
End While
|
|
If nRegId = GDB_ID.NULL Then Return False
|
|
|
|
' recupero il contorno del pezzo
|
|
Dim nIdCurve As Integer = GetRegionOutLoop(nRegId, nGrpRegId)
|
|
If nIdCurve = GDB_ID.NULL Then Return False
|
|
' recupero il versore
|
|
Dim frFrame As New Frame3d
|
|
' recupero le dimensioni del minimo rettangolo
|
|
Dim dLengthX As Double = 0
|
|
Dim dLengthY As Double = 0
|
|
EgtCurveMinAreaRectangleXY(nIdCurve, GDB_ID.ROOT, frFrame, dLengthX, dLengthY)
|
|
' recupero la direzione del lato più lungo (versore X)
|
|
Dim vtDir As Vector3d = frFrame.VersX()
|
|
|
|
' recupero le coordinate sferiche
|
|
Dim dMyLen, dMyAngV As Double
|
|
vtDir.ToSpherical(dMyLen, dMyAngV, dMyAngH)
|
|
' mi riconduco sempre agli angoli
|
|
If dMyAngH >= 180 Then
|
|
dMyAngH = dMyAngH - 180
|
|
End If
|
|
If Math.Abs(dMyAngH - 180) < EPS_ANG_SMALL Then
|
|
dMyAngH = 0
|
|
End If
|
|
|
|
' Recupero l'asse rotante della testa ventosa
|
|
Dim nRotAxId As Integer = EgtGetParent(EgtGetHeadId(VACUUM_HEAD))
|
|
' Verifico se contiene info con STEPS
|
|
Dim sSteps As String = ""
|
|
If Not EgtGetInfo(nRotAxId, KEY_ROTVAC_STEPS, sSteps) Then Return True
|
|
' Leggo gli step previsti
|
|
Dim vStep() As String = sSteps.Split(",".ToCharArray)
|
|
For Each sStep As String In vStep
|
|
Dim dStep As Double = 0
|
|
If StringToDouble(sStep, dStep) Then
|
|
AngVacList.Add(dStep)
|
|
End If
|
|
Next
|
|
|
|
Return True
|
|
End Function
|
|
|
|
' determino la migliore rotazione per portare il pezzo in orizzontale
|
|
Private Function GetPrefRotAng(ByVal dAngDeg As Double) As Double
|
|
Dim dNewAngDeg As Double = -dAngDeg
|
|
If dAngDeg > 90 And dAngDeg < 270 Then
|
|
dNewAngDeg = 180 - dAngDeg
|
|
End If
|
|
Return dNewAngDeg
|
|
End Function
|
|
|
|
Private Sub PauseBtn_Click(sender As Object, e As RoutedEventArgs) Handles PauseBtn.Click
|
|
' verifico la presenza di eventuali pezzi sulla tavola di scarico
|
|
Dim LclLstOfUnldPart As New List(Of Integer)
|
|
PartOnAuxTab(LclLstOfUnldPart, m_nCurrPhase)
|
|
If Not InsertPauseInCurrPhase() Then Return
|
|
AddNewPhase()
|
|
End Sub
|
|
|
|
' restituisce la lista dei pezzi che sono sulla tavola di scarico nella fase indicata
|
|
Private Function PartOnAuxTab(ByRef ListOfUnloadedPatr As List(Of Integer), nPhase As Integer) As Boolean
|
|
m_IsCurrPhaseUnloaded = False
|
|
' Area tavolo ausiliario
|
|
Dim b3AuxTab As New BBox3d
|
|
EgtGetBBoxGlob(EgtGetFirstNameInGroup(m_nAuxTabId, "A1"), GDB_BB.STANDARD, b3AuxTab)
|
|
' Area pezzi
|
|
Dim nOtherRaw As Integer = EgtGetFirstRawPart()
|
|
While nOtherRaw <> GDB_ID.NULL
|
|
If EgtVerifyRawPartPhase(nOtherRaw, nPhase) Then
|
|
Dim b3OtherRaw As New BBox3d
|
|
' EgtGetRawPartBBox(nOtherRaw, b3OtherRaw)
|
|
EgtGetBBoxGlob(nOtherRaw, GDB_BB.STANDARD, b3OtherRaw)
|
|
' se il centro del pezzo è sulla tavola di scarico
|
|
If b3OtherRaw.Center.y < b3AuxTab.Max().y Then
|
|
m_IsCurrPhaseUnloaded = True
|
|
ListOfUnloadedPatr.Add(nOtherRaw)
|
|
' salvo l'info che indica che il pezzo deve essere scaricato
|
|
EgtSetInfo(nOtherRaw, "Unloaded", 1)
|
|
'Exit While
|
|
End If
|
|
End If
|
|
nOtherRaw = EgtGetNextRawPart(nOtherRaw)
|
|
End While
|
|
Return m_IsCurrPhaseUnloaded
|
|
End Function
|
|
|
|
' inserisce una pausa nella fase corrente
|
|
Private Function InsertPauseInCurrPhase() As Boolean
|
|
' verifico che ci sia almeno un elemto selezionato (dati di aggancio pezzo)
|
|
If m_RawMoveDataList.Count = 0 Then Return False
|
|
' verifico che sia stato inseito almeno uno spostamento, altrimenti lo rimuovo
|
|
Dim Index As Integer = 0
|
|
For Index = m_RawMoveDataList.Count - 1 To 0 Step -1
|
|
If Math.Abs(m_RawMoveDataList(Index).m_vtRawMove.x) < EPS_SMALL AndAlso Math.Abs(m_RawMoveDataList(Index).m_vtRawMove.y) < EPS_SMALL Then
|
|
m_RawMoveDataList.RemoveAt(Index)
|
|
End If
|
|
Next
|
|
' verifico che la lista non sia vuota
|
|
If m_RawMoveDataList.Count = 0 Then
|
|
Return False
|
|
End If
|
|
' recupero disposizione fase corrente
|
|
Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
' imposto la pausa nella disposizione corrente
|
|
SetPause(nDispId)
|
|
' aggiungo al gruppo disposizione dei sottogruppi con i dati di movimento dei grezzi spostati
|
|
SaveMoveInfoInDisposition(nDispId, m_RawMoveDataList)
|
|
' imposto eventuale movimento pezzi su tavola ausiliaria
|
|
SaveMovePartsOnAuxTable(nDispId, m_IsCurrPhaseUnloaded)
|
|
' SaveMovePartsOnAuxTable(nDispId, m_SplitPage.m_bOnAuxTab)
|
|
'' Eseguo calcolo speciale dei movimenti: per tavola multicut
|
|
'SpecialApplyDisposition(nDispId, True, Not m_SplitPage.m_bOnAuxTab)
|
|
SaveRemoveByHandInDisposition(nDispId, False)
|
|
Return True
|
|
End Function
|
|
|
|
' crea una nuvoa fase/disposizione, la rende corrente, ricalcolo i grezzi e le lavorazioni della nuova fase
|
|
Private Function AddNewPhase() As Boolean
|
|
' Creo nuova fase
|
|
Dim nNewPhase As Integer = EgtAddPhase()
|
|
' Carico i grezzi rimasti sulla tavola nella nuova fase
|
|
ChangePhaseRawPart(nNewPhase)
|
|
' Sposto le lavorazioni rimaste nella nuova fase
|
|
ChangeOperationPhase(nNewPhase)
|
|
|
|
Dim nCurrDisposition As Integer = EgtGetPhaseDisposition(nNewPhase)
|
|
'SetPause(nCurrDisposition)
|
|
m_nCurrDisposition = nCurrDisposition
|
|
' EgtSetStatus(nRawIdSlected, GDB_ST.OFF)
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
EgtSetCurrPhase(nNewPhase)
|
|
SetAuxTabInCurrDisposition()
|
|
' ripulisco la lista degli spostamenti
|
|
m_RawMoveDataList.Clear()
|
|
m_IsCurrPhaseUnloaded = False
|
|
' aggiorno la fase corrente
|
|
m_nCurrPhase = EgtGetCurrPhase()
|
|
Return True
|
|
End Function
|
|
|
|
' Copio i grezzi rimasti sulla tavola nella fase successiva
|
|
Private Sub ChangePhaseRawPart(ByVal nNewPhase As Integer)
|
|
' recupero l'elenco dei pezzi che sono stati scaricati sulla tavola
|
|
Dim LocalLstOfUnldPart As New List(Of Integer)
|
|
PartOnAuxTab(LocalLstOfUnldPart, nNewPhase - 1)
|
|
' Eseguo eventuali spezzature dei grezzi e vi sposto i pezzi (i grezzi devono essere sempre copiati per Registrazione con rotazione)
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
' se il grezzo è presente nella fase precedente e non è quello selezionato allora procedo a creare una copia nella nuova fase
|
|
If EgtVerifyRawPartPhase(nRawId, nNewPhase - 1) Then
|
|
Dim bKeepRawPart As Boolean = True
|
|
For Each RawOnAuxTabData As RawMoveData In m_RawMoveDataList
|
|
If nRawId = RawOnAuxTabData.m_nId Then
|
|
' se il pezzo è stato scaricato allora non deve essere riportato nella fase successiva
|
|
For Each UnloadPart As Integer In LocalLstOfUnldPart
|
|
If nRawId = UnloadPart Then
|
|
' salvo l'info che indica che il pezzo deve essere scaricato
|
|
EgtSetInfo(nRawId, "Unloaded", 1)
|
|
bKeepRawPart = False
|
|
Exit For
|
|
End If
|
|
Next
|
|
'bKeepRawPart = False
|
|
Exit For
|
|
End If
|
|
Next
|
|
If bKeepRawPart Then EgtKeepRawPart(nRawId, nNewPhase - 1)
|
|
End If
|
|
' passo al successivo grezzo
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
End Sub
|
|
|
|
Private Sub ResetBtn_Click(sender As Object, e As RoutedEventArgs) Handles ResetBtn.Click
|
|
' Recupero il primo grezzo selezionato
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
If nRawId = GDB_ID.NULL Then Return
|
|
' Lo riporto nella posizione originale
|
|
Dim nInd As Integer = FindRawMoveData(nRawId, m_RawMoveDataList)
|
|
If nInd = -1 Then Return
|
|
Dim vtMove As Vector3d = -m_RawMoveDataList(nInd).m_vtRawMove
|
|
Dim dAngRaw As Double = -m_RawMoveDataList(nInd).m_dRawAngRotDeg
|
|
EgtMoveRawPart(nRawId, vtMove)
|
|
EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAngRaw)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
RemoveRawMoveData(nRawId, m_RawMoveDataList)
|
|
' elimino l'info che indica che il pezzo è scaricato sulla tavola
|
|
EgtRemoveInfo(nRawId, "Unloaded")
|
|
' Disabilito pezzo e nascondo le ventose
|
|
EgtSetStatus(nRawId, GDB_ST.ON_)
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub PrevBtn_Click(sender As Object, e As RoutedEventArgs) Handles PrevBtn.Click
|
|
' verifico che il pezzo sia depositabile
|
|
If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then
|
|
' mantengo la selezione del pezzo
|
|
EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL)
|
|
m_CurrProjPage.SetErrorMessage("Collisione pezzi")
|
|
EgtDraw()
|
|
' non cambio pagina
|
|
Return
|
|
End If
|
|
' resetto l'inidice del pezzo da mnovimentare
|
|
m_CurrRawOnVacuum = GDB_ID.NULL
|
|
' Deseleziono tutto
|
|
EgtDeselectAll()
|
|
' Torno alla fase precedente
|
|
m_bPrev = True
|
|
' Passo alla pagina delle spezzature solo se non esiste prima una fased di deposito sulla tavola di scarico
|
|
|
|
Dim nPrevDispId As Integer = EgtGetPrevOperation(m_nCurrDisposition)
|
|
' verifico se la fasa precedente è di tipo scarico
|
|
If IsDispUnloadOnAuxTab(nPrevDispId) <> 0 Then
|
|
EgtSetCurrPhase(m_nCurrPhase - 1)
|
|
m_nCurrDisposition = nPrevDispId
|
|
m_nCurrPhase -= 1
|
|
m_bPrev = False
|
|
m_SplitPage.m_bShow = True
|
|
m_SplitPage.m_bOnAuxTab = True
|
|
' imposto la visibilità della tavola ausiliaria
|
|
SetAuxTabInCurrDisposition()
|
|
' carico le info di disposizione dei pezzi
|
|
m_RawMoveDataList.Clear()
|
|
m_bRemovedRaw = GetRemoveByHandInDisposition(m_nCurrDisposition)
|
|
GetMoveInfoInDisposition(m_nCurrDisposition, m_RawMoveDataList)
|
|
RefreshVisibility()
|
|
EgtDraw()
|
|
Return
|
|
End If
|
|
|
|
'If EgtGetOperationType(EgtGetPrevOperation(m_nCurrDisposition)) = MCH_OY.DISP AndAlso m_SplitPage.m_bOnAuxTab Then
|
|
' EgtSetCurrPhase(m_nCurrPhase - 1)
|
|
' m_nCurrDisposition = EgtGetPrevOperation(m_nCurrDisposition)
|
|
' m_nCurrPhase -= 1
|
|
' m_bPrev = False
|
|
' m_SplitPage.m_bShow = True
|
|
' EgtDraw()
|
|
' Return
|
|
'End If
|
|
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(Me)
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Add(m_SplitPage)
|
|
m_MainWindow.m_CadCutPageUC.m_CadCutMode = CadCutPageUC.CadCutModes.Split
|
|
End Sub
|
|
|
|
Private Sub NextBtn_Click(sender As Object, e As RoutedEventArgs) Handles NextBtn.Click
|
|
' verifico che il pezzo sia depositabile
|
|
If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then
|
|
' mantengo la selezione del pezzo
|
|
EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL)
|
|
m_CurrProjPage.SetErrorMessage("Collisione pezzi")
|
|
EgtDraw()
|
|
' non cambio pagina
|
|
Return
|
|
End If
|
|
|
|
' ------- VISUALIZZAZIONE (navigazione tra le fasi) -------
|
|
If m_SplitPage.m_bShow Then
|
|
' verifico se la fase successiva è uno scarico frontale
|
|
If NextOperationIsUnloading(m_nCurrDisposition) Then
|
|
' imposto la nuova fase (che è stata modificata all'interno della funzione di controllo)
|
|
EgtSetCurrPhase(m_nCurrPhase)
|
|
' carico i dati di movimento dei pezzi nella fase corrente
|
|
m_RawMoveDataList.Clear()
|
|
m_bRemovedRaw = GetRemoveByHandInDisposition(m_nCurrDisposition)
|
|
GetMoveInfoInDisposition(m_nCurrDisposition, m_RawMoveDataList)
|
|
EgtDraw()
|
|
EnableButtons()
|
|
Return
|
|
ElseIf IsDispUnloadOnAuxTab(m_nCurrDisposition) <> 0 AndAlso Not NextOperationIsUnloading(m_nCurrDisposition) Then
|
|
' imposto la nuova fase, al termine della Sub verrà caricata la pagina Split nella fase indicata ora
|
|
m_bToNext = True
|
|
m_nCurrPhase += 1
|
|
EgtSetCurrPhase(m_nCurrPhase)
|
|
EgtDraw()
|
|
End If
|
|
End If
|
|
|
|
' ------- MODIFICA -------
|
|
If Not m_SplitPage.m_bShow Then
|
|
' se la tavola di scarico presente oppure ci sono pezzi sulla tavola di scarico
|
|
Dim LclLstOfUnldPart As New List(Of Integer)
|
|
If m_SplitPage.m_bOnAuxTab Or PartOnAuxTab(LclLstOfUnldPart, m_nCurrPhase) Then
|
|
' se ci sono pezzi sulla tavola di scarico prima di procedere inserisco una pausa e creo una nuoava fase
|
|
If m_IsCurrPhaseUnloaded AndAlso InsertPauseInCurrPhase() Then AddNewPhase()
|
|
' nascondo la tavola di scarico
|
|
EgtDisableModified()
|
|
EgtSetStatus(m_nAuxTabId, GDB_ST.OFF)
|
|
EgtEnableModified()
|
|
End If
|
|
m_bToNext = True
|
|
'' se la disposizione corrente è sulla tavola ausiliaria allora lo sarà anche quella successiva
|
|
'If IsDispUnloadOnAuxTab(m_nCurrDisposition) <> 0 Then
|
|
' EgtSetCurrPhase(m_nCurrPhase + 1)
|
|
' m_nCurrDisposition = EgtGetNextOperation(m_nCurrDisposition)
|
|
' m_nCurrPhase += 1
|
|
' m_bToNext = False
|
|
' m_SplitPage.m_bShow = True
|
|
' EgtDraw()
|
|
' EnableButtons()
|
|
' Return
|
|
'End If
|
|
End If
|
|
' resetto l'inidice del pezzo da mnovimentare
|
|
m_CurrRawOnVacuum = GDB_ID.NULL
|
|
' Deseleziono tutto
|
|
EgtDeselectAll()
|
|
' Passo alla pagina delle spezzature
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(Me)
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Add(m_SplitPage)
|
|
m_MainWindow.m_CadCutPageUC.m_CadCutMode = CadCutPageUC.CadCutModes.Split
|
|
End Sub
|
|
|
|
Private Sub ModifyBtn_Click(sender As Object, e As RoutedEventArgs) Handles ModifyBtn.Click
|
|
' Dichiaro uscita da sola visualizzazione
|
|
m_SplitPage.m_bShow = False
|
|
' Elimino le fasi successive alla corrente
|
|
While EgtGetPhaseCount() > m_nCurrPhase
|
|
RemoveLastPhase()
|
|
End While
|
|
' Svuoto gruppo disposizione
|
|
Dim nDispId = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
EgtEmptyGroup(nDispId)
|
|
' Disabilito le lavorazioni della fase corrente e ne nascondo i percorsi utensile
|
|
Dim nOpeId As Integer = EgtGetNextOperation(nDispId)
|
|
While nOpeId <> GDB_ID.NULL
|
|
EgtSetOperationMode(nOpeId, False)
|
|
EgtSetInfo(nOpeId, INFO_MCH_USER_OFF, True)
|
|
EgtSetOperationStatus(nOpeId, False)
|
|
nOpeId = EgtGetNextOperation(nOpeId)
|
|
End While
|
|
' Preparo la lista delle lavorazioni
|
|
Dim MachiningList As New List(Of SplitMach)
|
|
CalculateSplitMachList(m_nCurrPhase, MachiningList)
|
|
' Aggiorno visualizzazione delle lavorazioni
|
|
For nI As Integer = 0 To MachiningList.Count() - 1
|
|
' sistemo colore
|
|
ColorMachining(MachiningList(nI))
|
|
Next
|
|
' Visualizzo solo anteprime di lavorazioni della fase
|
|
ShowOnePhaseMachiningPreview(m_nCurrPhase)
|
|
EgtDraw()
|
|
' disabilito bottone
|
|
ModifyBtn.IsEnabled = False
|
|
' gestione abilitazione altri bottoni
|
|
EnableButtons(MachiningList.Count > 0)
|
|
End Sub
|
|
|
|
' verifica se la disposizione indicata è uno scarico sulla tavola ausiliaria
|
|
Public Function IsDispUnloadOnAuxTab(nCurrDispId As Integer) As Integer
|
|
' verifico se la fase precedente è uno scarico su tavola ausiliaria
|
|
Dim bVal As Integer = 0
|
|
EgtGetInfo(nCurrDispId, "Pat", bVal)
|
|
Return bVal
|
|
End Function
|
|
|
|
' restituisce e attiva la successiva disposizione se è uno scarico frontale
|
|
Public Function NextOperationIsUnloading(nCurrDispId As Integer) As Boolean
|
|
' recupero la primo operazione successiva
|
|
Dim nNextIdOperation As Integer = EgtGetNextOperation(nCurrDispId)
|
|
' a partire da questa cerco la prima disposizione disponibile
|
|
Dim nNextIdDips As Integer = GetNextDisposition(nNextIdOperation)
|
|
If nNextIdDips = nNextIdOperation And IsDispUnloadOnAuxTab(nNextIdOperation) Then
|
|
m_nCurrPhase += 1
|
|
m_nCurrDisposition = nNextIdOperation
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
' recupero la prima disposizione disponibile tra l'elenco delle operazioni presenti
|
|
Public Function GetNextDisposition(nCurrDisposId As Integer) As Integer
|
|
Dim nDispId As Integer = nCurrDisposId
|
|
While nDispId <> GDB_ID.NULL
|
|
If EgtGetOperationType(nDispId) = MCH_OY.DISP Then
|
|
Return nDispId
|
|
End If
|
|
nDispId = EgtGetNextOperation(nDispId)
|
|
End While
|
|
Return GDB_ID.NULL
|
|
End Function
|
|
|
|
Private Sub EnableButtons(Optional bExistsMachining As Boolean = False)
|
|
UpBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
LeftBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
RightBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
DownBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
StepMoveTxBx.IsEnabled = Not m_SplitPage.m_bShow
|
|
RotateClockwiseBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
RotateCounterClockwiseBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
RotationAngle.IsEnabled = Not m_SplitPage.m_bShow
|
|
RemovePartBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
TopLBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
TopRBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
BottomLBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
BottomRBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
PauseBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
ResetBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
UnloadPartsBtn.IsEnabled = Not m_SplitPage.m_bShow
|
|
If m_SplitPage.m_bShow Then
|
|
' se ultima fase (e non sacrico su tavola)
|
|
If m_nCurrPhase = EgtGetPhaseCount() And m_SplitPage.m_bOnAuxTab Then
|
|
NextBtn.IsEnabled = (m_nCurrPhase < EgtGetPhaseCount())
|
|
Else
|
|
NextBtn.IsEnabled = (m_nCurrPhase <= EgtGetPhaseCount())
|
|
End If
|
|
Else
|
|
' Se esistono delle lavorazioni allora abilito il pulsante per procedere
|
|
If Not bExistsMachining Then
|
|
NextBtn.IsEnabled = Not m_SplitPage.m_bOnAuxTab
|
|
Else
|
|
NextBtn.IsEnabled = True
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
' esco dalla pagina di scarico
|
|
Private Sub MoveRawPartPage_Unloaded(sender As Object, e As EventArgs) Handles Me.Unloaded
|
|
' verifico che la fase corrente non sia vuota
|
|
Dim nLastDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
|
|
'' se sono in visualizzazione allora non elimino essuna operazione
|
|
'If Not m_SplitPage.m_bShow Then
|
|
' If EgtIsOperationEmpty(nLastDispId) And Not m_SplitPage.m_bOnAuxTab And m_RawMoveDataList.Count = 0 Then
|
|
' EgtErase(nLastDispId)
|
|
' ElseIf EgtIsOperationEmpty(nLastDispId) And m_SplitPage.m_bOnAuxTab And m_RawMoveDataList.Count = 0 Then
|
|
' ' Dichiaro pagina non attiva
|
|
' m_bActive = False
|
|
' Return
|
|
' End If
|
|
'End If
|
|
|
|
' Se movimento con ventose
|
|
If Not m_bByHand Then
|
|
' nascondo le ventose
|
|
EgtDisableModified()
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
EgtEnableModified()
|
|
' se non solo visualizzazione
|
|
If Not m_SplitPage.m_bShow Then
|
|
' recupero disposizione fase corrente
|
|
Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
' aggiungo al gruppo disposizione dei sottogruppi con i dati di movimento dei grezzi spostati
|
|
SaveMoveInfoInDisposition(nDispId, m_RawMoveDataList)
|
|
' imposto eventuale presenza rimozioni manuali
|
|
SaveRemoveByHandInDisposition(nDispId, m_bRemovedRaw)
|
|
' imposto eventuale movimento pezzi su tavola ausiliaria (se è realmente avvenuto)
|
|
'SaveMovePartsOnAuxTable(nDispId, m_SplitPage.m_bOnAuxTab)
|
|
SaveMovePartsOnAuxTable(nDispId, m_IsCurrPhaseUnloaded)
|
|
' Eseguo calcolo speciale dei movimenti
|
|
SpecialApplyDisposition(nDispId, True, Not m_SplitPage.m_bOnAuxTab)
|
|
End If
|
|
' se altrimenti movimento senza ventose perchè lama troppo grande
|
|
ElseIf GetVacuumType() > 0 Then
|
|
' se non solo visualizzazione
|
|
If Not m_SplitPage.m_bShow Then
|
|
' recupero disposizione fase corrente
|
|
Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
' imposto presenza operazioni manuali
|
|
SaveRemoveByHandInDisposition(nDispId, True)
|
|
' Eseguo calcolo speciale dei movimenti
|
|
SpecialApplyDisposition(nDispId, True)
|
|
End If
|
|
End If
|
|
|
|
' Nascondo eventuale tavola ausiliaria
|
|
If m_SplitPage.m_bOnAuxTab Then
|
|
EgtDisableModified()
|
|
EgtSetStatus(m_nAuxTabId, GDB_ST.OFF)
|
|
EgtEnableModified()
|
|
' se sto uscendo dalla pagina delle spezzature
|
|
If Not m_bPrev And Not m_bToNext Then
|
|
Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
' se sto uscendo dalla pagina split (senza passare dal comando next)
|
|
Dim lclLstUnlPart As New List(Of Integer)
|
|
SaveMovePartsOnAuxTable(nDispId, PartOnAuxTab(lclLstUnlPart, m_nCurrPhase))
|
|
' Cancello eventuale manipolatore pezzi
|
|
EgtDisableModified()
|
|
RemoveVacuumCups()
|
|
EgtEnableModified()
|
|
' ritorno a fase 1
|
|
EgtSetCurrPhase(1)
|
|
' Ripristino visualizzazione preview lavorazioni
|
|
ShowAllPhasesMachiningPreview()
|
|
End If
|
|
End If
|
|
' Se torno indietro
|
|
If m_bPrev Then
|
|
EgtSetCurrPhase(m_nCurrPhase - 1)
|
|
m_bPrev = False
|
|
m_SplitPage.m_bShow = True
|
|
End If
|
|
|
|
Dim Ph As Integer = EgtGetCurrPhase()
|
|
' aggiorno il disegno
|
|
EgtZoom(ZM.ALL, False)
|
|
' Dichiaro pagina non attiva
|
|
m_bActive = False
|
|
End Sub
|
|
|
|
' ----------------- TEST funzione per debug operazioni -----------------
|
|
Private Sub SaveMyFileTest(sFilename As String)
|
|
LoadCurrPhaseMachining()
|
|
' salvo il file corrente per poterlo studiare e capire cosa è successo nella rappresentazione dei grezzi
|
|
EgtSaveFile("C:\EgtData\OmagCUT\MyProjects\" & sFilename & ".nge", NGE.BIN)
|
|
End Sub
|
|
|
|
Private Sub LoadCurrPhaseMachining()
|
|
Dim m_MachiningList As New List(Of SplitMach)
|
|
'm_SplitPage.ShowMachiningList()
|
|
'm_SplitPage.SaveOrderMachinig(m_nCurrPhase)
|
|
' Preparo la lista delle lavorazioni
|
|
CalculateSplitMachList(m_nCurrPhase, m_MachiningList)
|
|
Dim b As Boolean = False
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
|