diff --git a/CAM/CamAuto.vb b/CAM/CamAuto.vb index e2b567e..b5a0ab6 100644 --- a/CAM/CamAuto.vb +++ b/CAM/CamAuto.vb @@ -22,12 +22,12 @@ Friend Module CamAuto bOk = bOk AndAlso EgtLuaCallFunction("CAM.Add") EgtLuaGetGlobIntVar("CAM.ERR", nErr) EgtLuaResetGlobVar("CAM") - If nErr <> 0 Then + If nErr > 0 Then bOk = False EgtOutLog("Error in CamAuto : " & nErr.ToString()) - If nErr < 0 Then - m_MainWindow.m_CurrentProjectPageUC.SetWarningMessage(EgtMsg(91017)) - End If + ElseIf nErr < 0 Then + EgtOutLog("Warning in CamAuto : " & nErr.ToString()) + m_MainWindow.m_CurrentProjectPageUC.SetWarningMessage(EgtMsg(91017)) End If m_MainWindow.m_CurrentProjectPageUC.ResetOrderMachiningFlag() Return bOk @@ -43,10 +43,12 @@ Friend Module CamAuto bOk = bOk AndAlso EgtLuaCallFunction("CAM.AddWaterJet") EgtLuaGetGlobIntVar("CAM.ERR", nErr) EgtLuaResetGlobVar("CAM") - If nErr <> 0 Then + If nErr > 0 Then bOk = False EgtOutLog("Error in CamAuto : " & nErr.ToString()) m_MainWindow.m_CurrentProjectPageUC.ClearMessage() + ElseIf nErr < 0 Then + EgtOutLog("Warning in CamAuto : " & nErr.ToString()) End If Return bOk End Function @@ -64,9 +66,11 @@ Friend Module CamAuto bOk = bOk AndAlso EgtLuaCallFunction("CAM.AddWaterJets") EgtLuaGetGlobIntVar("CAM.ERR", nErr) EgtLuaResetGlobVar("CAM") - If nErr <> 0 Then + If nErr > 0 Then bOk = False EgtOutLog("Error in CamAuto : " & nErr.ToString()) + ElseIf nErr < 0 Then + EgtOutLog("Warning in CamAuto : " & nErr.ToString()) End If Return bOk End Function @@ -80,9 +84,11 @@ Friend Module CamAuto bOk = bOk AndAlso EgtLuaCallFunction("CAM.Erase") EgtLuaGetGlobIntVar("CAM.ERR", nErr) EgtLuaResetGlobVar("CAM") - If nErr <> 0 Then + If nErr > 0 Then bOk = False EgtOutLog("Error in CamAuto : " & nErr.ToString()) + ElseIf nErr < 0 Then + EgtOutLog("Warning in CamAuto : " & nErr.ToString()) End If m_MainWindow.m_CurrentProjectPageUC.ResetOrderMachiningFlag() m_MainWindow.m_CurrentProjectPageUC.ResetProjectNcRestart() @@ -98,9 +104,11 @@ Friend Module CamAuto bOk = bOk AndAlso EgtLuaCallFunction("CAM.InvertVerticalCut") EgtLuaGetGlobIntVar("CAM.ERR", nErr) EgtLuaResetGlobVar("CAM") - If nErr <> 0 Then + If nErr > 0 Then bOk = False EgtOutLog("Error in CamAuto : " & nErr.ToString()) + ElseIf nErr < 0 Then + EgtOutLog("Warning in CamAuto : " & nErr.ToString()) End If Return bOk End Function @@ -295,9 +303,11 @@ Friend Module CamAuto bOk = bOk AndAlso EgtLuaCallFunction("CAM.UpdateAllTp") EgtLuaGetGlobIntVar("CAM.ERR", nErr) EgtLuaResetGlobVar("CAM") - If nErr <> 0 Then + If nErr > 0 Then bOk = False EgtOutLog("Error in CamAuto : " & nErr.ToString()) + ElseIf nErr < 0 Then + EgtOutLog("Warning in CamAuto : " & nErr.ToString()) End If Return bOk End Function @@ -311,9 +321,11 @@ Friend Module CamAuto bOk = bOk AndAlso EgtLuaCallFunction("CAM.Sort") EgtLuaGetGlobIntVar("CAM.ERR", nErr) EgtLuaResetGlobVar("CAM") - If nErr <> 0 Then + If nErr > 0 Then bOk = False EgtOutLog("Error in CamAuto : " & nErr.ToString()) + ElseIf nErr < 0 Then + EgtOutLog("Warning in CamAuto : " & nErr.ToString()) End If Return bOk End Function @@ -328,9 +340,11 @@ Friend Module CamAuto bOk = bOk AndAlso EgtLuaCallFunction("CAM.SpecApplyDisp") EgtLuaGetGlobIntVar("CAM.ERR", nErr) EgtLuaResetGlobVar("CAM") - If nErr <> 0 Then + If nErr > 0 Then bOk = False EgtOutLog("Error in CamAuto : " & nErr.ToString()) + ElseIf nErr < 0 Then + EgtOutLog("Warning in CamAuto : " & nErr.ToString()) End If If ResetOrderMachiningFlag Then m_MainWindow.m_CurrentProjectPageUC.ResetOrderMachiningFlag() diff --git a/DirectCuts/DirectCutPageUC.xaml.vb b/DirectCuts/DirectCutPageUC.xaml.vb index 4368af7..a3ae609 100644 --- a/DirectCuts/DirectCutPageUC.xaml.vb +++ b/DirectCuts/DirectCutPageUC.xaml.vb @@ -482,7 +482,7 @@ Public Class DirectCutPageUC Private Sub ManualModeBtn_Click(sender As Object, e As RoutedEventArgs) Handles ManualModeBtn.Click ' Imposto modalità manuale della macchina - Dim nResult As Short = m_CN.DGeneralFunctions_WriteCncMode(7) ' Modalità manuale + Dim nResult As Short = m_MainWindow.m_DirectCutPageUC.m_CN.DGeneralFunctions_WriteCncMode(7) ' Modalità manuale End Sub diff --git a/MainWindow.xaml.vb b/MainWindow.xaml.vb index f6145d8..01a277d 100644 --- a/MainWindow.xaml.vb +++ b/MainWindow.xaml.vb @@ -345,8 +345,8 @@ Class MainWindow ' Verifico abilitazione nesting automatico m_bAutoNest = Not String.IsNullOrWhiteSpace(sNestKey) ' Recupero opzioni della chiave - Dim bKey As Boolean = EgtGetKeyLevel(9423, 2702, 1, m_nKeyLevel) And - EgtGetKeyOptions(9423, 2702, 1, m_nKeyOptions) + Dim bKey As Boolean = EgtGetKeyLevel(9423, 2703, 1, m_nKeyLevel) And + EgtGetKeyOptions(9423, 2703, 1, m_nKeyOptions) ' Verifico abilitazione prodotto Dim bProd As Boolean = GetKeyOption(KEY_OPT.CUT_BASE) ' Impostazione per programma OnlyFrame: solo se CUT_BASE non attivo diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index be316a2..79fec5c 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -62,5 +62,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/RawPhoto/RawPartPageUC.xaml.vb b/RawPhoto/RawPartPageUC.xaml.vb index 739a521..a404a03 100644 --- a/RawPhoto/RawPartPageUC.xaml.vb +++ b/RawPhoto/RawPartPageUC.xaml.vb @@ -1,9 +1,6 @@ -Imports System.Globalization -Imports System.IO -Imports System.Windows.Media.Animation +Imports System.IO Imports EgtUILib Imports EgtWPFLib -Imports Microsoft.VisualBasic.Devices Public Class RawPartPageUC @@ -84,6 +81,14 @@ Public Class RawPartPageUC ' Costante raggio cerchietto Private Const RAD_CIRCLE As Double = 30 + Private m_nIdMinRedX As Integer = -1 + Private m_SafetyZone_X = 0 + Private m_nIdMinRedY As Integer = -1 + Private m_SafetyZone_Y = 0 + Private m_bSafetyZoneRight As Boolean = True + Private m_bSafetyZoneBottom As Boolean = True + Private m_bExistsSafetyZone As Boolean = False + ' Riferimento grezzo Private m_bEnableOtherRefTab As Boolean = False Private m_bOtherRefTab As Boolean @@ -128,6 +133,13 @@ Public Class RawPartPageUC TL = 3 End Enum + Private Enum STATDRAG As Integer + OK = 0 + X_ = 1 + _Y = 2 + XY = 3 + End Enum + Private Sub RawPartPage_Initialized(sender As Object, e As EventArgs) 'Creazione della Page UserControl e relative impostazioni @@ -217,6 +229,7 @@ Public Class RawPartPageUC ConfirmPhotoBtn.Content = EgtMsg(MSG_RAWPARTPAGEUC + 24) 'Conferma OtherRefTabTxBl.Text = "New Ref On Tab" + End Sub Private Sub RawPartPage_Loaded(sender As Object, e As RoutedEventArgs) @@ -323,8 +336,23 @@ Public Class RawPartPageUC OffsetXTxBx.Text = LenToString(m_RawOffsX, 2) OffsetYTxBx.Text = LenToString(m_RawOffsY, 2) KerfTxBx.Text = LenToString(dInvertKerf * m_RawKerf, 2) - ' Verifico se attivare la visualizzazione dell'area sicura - DrawSafetyZone(m_RawHeight, m_CurrentMachine.dHighPieceZ) + + ' Recupero gli ID delle pareti che delimitano l'area Protetta (movimenti in OverZ) + Dim nIdBase As Integer = EgtGetBaseId("Base") + m_nIdMinRedX = EgtGetFirstNameInGroup(nIdBase, "MinRedX") + m_nIdMinRedY = EgtGetFirstNameInGroup(nIdBase, "MinRedY") + If m_nIdMinRedY <> GDB_ID.NULL And m_nIdMinRedY <> GDB_ID.NULL Then + m_bExistsSafetyZone = True + Dim ptMinX, ptMaxX As Point3d + EgtGetBBoxGlob(m_nIdMinRedX, GDB_BB.STANDARD, ptMinX, ptMaxX) + m_SafetyZone_X = ptMinX.x + Dim ptMinY, ptMaxY As Point3d + EgtGetBBoxGlob(m_nIdMinRedY, GDB_BB.STANDARD, ptMinY, ptMaxY) + m_SafetyZone_Y = ptMinY.y + End If + ' Verifico se attivare la visualizzazione dell'area sicura (prendo la posizione corrente come posizione di partenza) + DrawSafetyZone(m_RawHeight, m_CurrentMachine.dHighPieceZ, New Vector3d(0, 0, 0)) + ' Creo layer temporaneo per crocette m_nTempLay = EgtCreateGroup(GDB_ID.ROOT) EgtSetLevel(m_nTempLay, GDB_LV.TEMP) @@ -353,7 +381,6 @@ Public Class RawPartPageUC EgtZoom(ZM.ALL) End If 'Imposto il materiale corrente nella combobox - 'MaterialsCmbx.SelectedItem = m_CurrentMachine.CurrMat Dim Item As Material For Each Item In MaterialsCmbx.Items If Not IsNothing(m_CurrentMachine.CurrMat) AndAlso Item.sName = m_CurrentMachine.CurrMat.sName Then @@ -577,7 +604,17 @@ Public Class RawPartPageUC Dim ptCurr As Point3d EgtUnProjectPoint(e.Location, ptCurr) - If Not DrawSafetyZone(m_RawHeight, m_CurrentMachine.dHighPieceZ) Then Return + ' Creo una copia del punto corrente + Dim ptTemp As New Point3d(ptCurr.x, ptCurr.y, ptCurr.z) + Select Case DrawSafetyZone(m_RawHeight, m_CurrentMachine.dHighPieceZ, ptCurr - m_ptPrev) + Case STATDRAG.X_ + ptCurr.x = m_ptPrev.x + Case STATDRAG._Y + ptCurr.y = m_ptPrev.y + Case STATDRAG.XY + m_ptPrev = ptCurr + Return + End Select ' Eseguo modifica Select Case m_ActiveRawMode @@ -589,7 +626,7 @@ Public Class RawPartPageUC ModifyDamaged(ptCurr) End Select ' Aggiorno il punto precedente - m_ptPrev = ptCurr + m_ptPrev = ptTemp ' Resetto i ponticelli (per ora non sono in grado di muoverli assieme ai pezzi) ResetAllBRidges() End Sub @@ -753,8 +790,6 @@ Public Class RawPartPageUC If Not m_bActive Then Return ' Disabilito modalità drag m_bDrag = False - ' Verifico che il pezzo sia in una posizione corretta - DrawSafetyZone(m_RawHeight, m_CurrentMachine.dHighPieceZ) End Sub Private Sub MaterialsCmbx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles MaterialsCmbx.SelectionChanged @@ -2029,6 +2064,8 @@ Public Class RawPartPageUC Dim dInvertKerf As Double = 1 EgtGetInfo(EgtGetFirstRawPart(), KEY_INVERT_KERF, dInvertKerf) Dim dMaxLen = m_dTableLength - m_RawOffsX - m_RawKerf * dInvertKerf + ' Se è attiva l'area sicura allora devo ricalcolare la dimensione massima + If dLength <= dMaxLen Then m_CurrProjPage.ClearMessage() If dKerf < 0 Then @@ -2074,7 +2111,7 @@ Public Class RawPartPageUC Return End If ' verifico se l'altezza del pezzo è maggiore di quella consentita in macchina - DrawSafetyZone(dHeight, m_CurrentMachine.dHighPieceZ) + DrawSafetyZone(dHeight, m_CurrentMachine.dHighPieceZ, New Vector3d(0, 0, 0)) If dHeight > -EPS_ZERO Then m_CurrProjPage.ClearMessage() If Math.Abs(dHeight - m_RawHeight) > EPS_SMALL Then @@ -2144,64 +2181,91 @@ Public Class RawPartPageUC End If End Sub - Private Function DrawSafetyZone(dHeight As Double, dHighPieceZ As Double) As Boolean + ' Funzione che si occupa di disegnare le pareti dell'area sicura e di gestire il grezzo ( + Private Function DrawSafetyZone(dHeight As Double, dHighPieceZ As Double, vtMove As Vector3d) As STATDRAG + ' Se non esiste allora esci senza eseguire controlli + If Not m_bExistsSafetyZone Then Return STATDRAG.OK + ' Verifico se attivare la visualizzazione Dim nStatus As GDB_ST = GDB_ST.OFF If dHeight > dHighPieceZ Then nStatus = GDB_ST.ON_ End If - ' attivo la visualizzazione delle pareti che delimitano l'area sicura - Dim nIdBase As Integer = EgtGetBaseId("Base") - Dim nIdMinRedX As Integer = EgtGetFirstNameInGroup(nIdBase, "MinRedX") - EgtSetStatus(nIdMinRedX, nStatus) - Dim nIdMinRedY As Integer = EgtGetFirstNameInGroup(nIdBase, "MinRedY") - EgtSetStatus(nIdMinRedY, nStatus) + ' gestisco la visualizzazione delle pareti che delimitano l'area sicura + EgtSetStatus(m_nIdMinRedX, nStatus) + EgtSetStatus(m_nIdMinRedY, nStatus) EgtDraw() If nStatus = GDB_ST.ON_ Then - Return VerifyRawInSafetyZone(nIdMinRedX, nIdMinRedY) + Return VerifyDimensionRawSafetyZone(vtMove) End If - Return True + Return STATDRAG.OK End Function - Private Function VerifyRawInSafetyZone(nIdMinRedX As Integer, nIdMinRedY As Integer) As Boolean - Dim bOk As Boolean = True + ' Verifica che le dimensioni del grezzo siano conformi con l'area sicura (altrimenti provvedo a ridimensionare il grezzo) + Private Function VerifyDimensionRawSafetyZone(vtMove As Vector3d) As STATDRAG Dim nRawSolidId = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, NAME_RAW_SOLID) Dim ptMinRaw, ptMaxRaw As Point3d EgtGetBBoxGlob(nRawSolidId, GDB_BB.STANDARD, ptMinRaw, ptMaxRaw) - Dim ptMinX, ptMaxX As Point3d - EgtGetBBoxGlob(nIdMinRedX, GDB_BB.STANDARD, ptMinX, ptMaxX) - Dim ptMinY, ptMaxY As Point3d - EgtGetBBoxGlob(nIdMinRedY, GDB_BB.STANDARD, ptMinY, ptMaxY) + ' Dimensioni grezzo + Dim Len_X As Double = ptMaxRaw.x - ptMinRaw.x + Dim Wid_Y As Double = ptMaxRaw.y - ptMinRaw.y + ' Posiztion SafetyZone: RIGHT-BOTTOM + Dim RedTab_X = m_dTableLength - Math.Abs(m_SafetyZone_X - m_ptTableMin.x) + Dim RedTab_Y = Math.Abs(m_SafetyZone_Y - m_ptTableMin.y) + If RedTab_X < Len_X Then + ' riduco le dimensioni del grezzo + m_RawLength = RedTab_X - EPS_SMALL * 10 + LengthTxBx.Text = LenToString(m_RawLength, 2) + UpdateRawPart() + End If + If RedTab_Y < Wid_Y Then + ' riduco le dimensioni del grezzo + m_RawWidth = RedTab_Y - EPS_SMALL * 10 + WidthTxBx.Text = LenToString(m_RawWidth, 2) + UpdateRawPart() + End If + Return VerifyRawInSafetyZone(vtMove) + End Function + + ' Verifico che la posizione del grezzo sia conforme con la posizione di area sicura + Private Function VerifyRawInSafetyZone(vtMove As Vector3d) As STATDRAG + Dim nStat As STATDRAG = STATDRAG.OK + Dim bCalcBBoxRaw As Boolean = False + Dim nRawSolidId = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, NAME_RAW_SOLID) + Dim ptMinRaw, ptMaxRaw As Point3d + EgtGetBBoxGlob(nRawSolidId, GDB_BB.STANDARD, ptMinRaw, ptMaxRaw) + ' Posiztion SafetyZone: RIGHT-BOTTOM ' Verifico che il grezzo sia all'interno di questi estremi - If ptMinRaw.x < ptMinX.x Then - ' EgtSetColor(nRawSolidId, New Color3d(255, 0, 0), 40) - Dim ptRef As Point3d = New Point3d(ptMinX.x - m_ptTableMin.x, ptMinRaw.y - m_ptTableMin.y, 0) + If ptMinRaw.x + vtMove.x < m_SafetyZone_X Then + ' riposiziono il grezzo sulla parete + Dim ptRef As Point3d = New Point3d(m_SafetyZone_X - m_ptTableMin.x, ptMinRaw.y - m_ptTableMin.y, 0) EgtMoveToCornerRawPart(m_CurrProjPage.m_nRawId, ptRef, MCH_CR.BL) - m_RawOffsX = ptMinX.x + m_RawKerf - m_ptTableMin.x + ' aggiorno il valore di Offset + m_RawOffsX = m_SafetyZone_X + m_RawKerf - m_ptTableMin.x m_RawOffsY = ptMinRaw.y + m_RawKerf - m_ptTableMin.y OffsetXTxBx.Text = LenToString(m_RawOffsX, 2) OffsetYTxBx.Text = LenToString(m_RawOffsY, 2) - EgtDraw() - bOk = False + bCalcBBoxRaw = True + nStat = STATDRAG.X_ End If ' Ricalcolo la posizione del grezzo se nel processo sopra ho eseguito uno spostamento - If Not bOk Then EgtGetBBoxGlob(nRawSolidId, GDB_BB.STANDARD, ptMinRaw, ptMaxRaw) - If ptMaxRaw.y > ptMinY.y Then - ' EgtSetColor(nRawSolidId, New Color3d(255, 0, 0), 40) + If bCalcBBoxRaw Then EgtGetBBoxGlob(nRawSolidId, GDB_BB.STANDARD, ptMinRaw, ptMaxRaw) + If ptMaxRaw.y + vtMove.y > m_SafetyZone_Y Then Dim dRawWidth As Double = ptMaxRaw.y - ptMinRaw.y - Dim ptRef As Point3d = New Point3d(ptMinRaw.x - m_ptTableMin.x, ptMinY.y - dRawWidth - m_ptTableMin.y, 0) + Dim ptRef As Point3d = New Point3d(ptMinRaw.x - m_ptTableMin.x, m_SafetyZone_Y - dRawWidth - m_ptTableMin.y, 0) EgtMoveToCornerRawPart(m_CurrProjPage.m_nRawId, ptRef, MCH_CR.BL) m_RawOffsX = ptMinRaw.x + m_RawKerf - m_ptTableMin.x - m_RawOffsY = ptMinY.y - dRawWidth + m_RawKerf - m_ptTableMin.y + m_RawOffsY = m_SafetyZone_Y - dRawWidth + m_RawKerf - m_ptTableMin.y OffsetXTxBx.Text = LenToString(m_RawOffsX, 2) OffsetYTxBx.Text = LenToString(m_RawOffsY, 2) - EgtDraw() - bOk = False + bCalcBBoxRaw = True + nStat = nStat + STATDRAG._Y End If - If bOk Then EgtSetColor(nRawSolidId, m_RawCol) EgtDraw() - Return bOk + ' Se ho ricalcolato la posizione del BBox grezzo allora ritorno falso + Return nStat End Function + #Region "OTHERREFTAB" Private Sub OtherRefTabChBx_Click(sender As Object, e As EventArgs) Handles OtherRefTabChBx.Click @@ -2305,7 +2369,7 @@ Public Class RawPartPageUC Private Sub ManualModeBtn_Click(sender As Object, e As RoutedEventArgs) Handles ManualModeBtn.Click ' Imposto modalità manuale della macchina - Dim nResult As Short = m_CN.DGeneralFunctions_WriteCncMode(7) ' Modalità manuale + Dim nResult As Short = m_MainWindow.m_CNCommunication.m_CN.DGeneralFunctions_WriteCncMode(7) ' Modalità manuale End Sub @@ -2428,6 +2492,8 @@ Public Class RawPartPageUC KerfTxBx.Text = LenToString(m_RawKerf, 2) m_CurrProjPage.SetErrorMessage(EgtMsg(MSG_RAWPARTPAGEUC + 22) & " " & LenToString(dMaxKerf, 2)) 'Massimo kerf = End If + ' Verifico se attivare la visualizzazione dell'area sicura (prendo la posizione corrente come posizione di partenza) + DrawSafetyZone(m_RawHeight, m_CurrentMachine.dHighPieceZ, New Vector3d(0, 0, 0)) End Sub Private Sub RawProbingBtn_Click(sender As Object, e As RoutedEventArgs) Handles RawProbingBtn.Click