OmagCUT :

- modifiche per spezzatura automatica
- modifiche per passo indietro in spezzatura.
This commit is contained in:
Dario Sassi
2016-07-06 16:08:22 +00:00
parent 6860b37ee2
commit eee6096423
11 changed files with 1166 additions and 613 deletions
+4 -1
View File
@@ -20,7 +20,10 @@ Public Class AboutBoxWD
Private Sub AboutBoxWD_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
DescriptionLbl.Text = My.Application.Info.Description.ToString()
VersionLbl.Text = "Version : " & My.Application.Info.Version.ToString()
VersionLbl.Text = "Version : " & My.Application.Info.Version.Major.ToString() &
"." & My.Application.Info.Version.Minor.ToString() &
(ChrW(97 - 1 + My.Application.Info.Version.Build)).ToString() &
My.Application.Info.Version.Revision.ToString()
Dim sKey As String = String.Empty
EgtGetKeyInfo(sKey)
Dim sOpts As String = m_MainWindow.GetKeyOptions().ToString()
+2 -2
View File
@@ -140,7 +140,7 @@ Public Class CadCutPageUC
CadCutPageGrid.Children.Add(m_SplitPage)
m_CadCutMode = CadCutModes.Split
' Carico eventuale manipolatore pezzi
m_MoveRawPartPage.LoadVacuumCups()
LoadVacuumCups()
' !!! Provvisorio : riparto da capo !!!
' Cancello tutte le lavorazioni
EraseMachinings(GDB_ID.NULL)
@@ -150,7 +150,7 @@ Public Class CadCutPageUC
EgtDraw()
Case CadCutModes.Split
' Cancello eventuale manipolatore pezzi
m_MoveRawPartPage.RemoveVacuumCups()
RemoveVacuumCups()
' Passo alla pagina Nest
SplitImage.Source = New System.Windows.Media.Imaging.BitmapImage(New Uri("/Resources/Split.png", UriKind.Relative))
CadCutPageGrid.Children.Remove(m_SplitPage)
+2 -1
View File
@@ -400,7 +400,8 @@ Public Module CamAuto
Dim dReducedDepth As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_REDUCEDDEPTH, 1, m_MainWindow.GetMachIniFile())
Dim dHolesOffset As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_HOLES_OFFSET, 0, m_MainWindow.GetMachIniFile())
Dim dHolesOverlap As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_HOLES_OVERLAP, 0, m_MainWindow.GetMachIniFile())
Dim dCornerSafety As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_SAFE_LEN_INTCORNER, 0, m_MainWindow.GetMachIniFile())
Dim dCornerSafety As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_SAFE_LEN_INTCORNER, 1, m_MainWindow.GetMachIniFile())
dCornerSafety = Math.Max(dCornerSafety, 10 * EPS_SMALL)
EgtLuaSetGlobStringVar("CAM.SAWMCH", sSawMch)
EgtLuaSetGlobStringVar("CAM.DRILLMCH", sDrillMch)
EgtLuaSetGlobNumVar("CAM.REDUCEDDEPTH", dReducedDepth)
+6
View File
@@ -137,6 +137,12 @@ Module ConstGen
Public Const NAME_PV_DOWN_PRECUT As String = "DPRC"
' Nome contorno in basso post-taglio
Public Const NAME_PV_DOWN_POSTCUT As String = "DPOC"
' Nome regione taglio
Public Const NAME_PV_RCUT As String = "RCUT"
' Nome regione pre-taglio (attacco)
Public Const NAME_PV_RLICUT As String = "RLICUT"
' Nome regione post-taglio (uscita)
Public Const NAME_PV_RLOCUT As String = "RLOCUT"
' Info in lavorazione taglio per attacco originale
Public Const INFO_MCH_ORILEADIN As String = "OriLI"
' Info in lavorazione taglio per uscita originale
+48 -416
View File
@@ -10,8 +10,6 @@ Public Class MoveRawPartPage
Private m_nCurrPhase As Integer = 0
' Dati movimento
Private m_dStep As Double = 0
' Tipo manipolatore con ventosa
Private m_nVacType As Integer = 0
' Tipo movimento dei grezzi (manuale o con testa ventosa)
Private m_bByHand As Boolean = True
' Gestione movimento manuale perpendicolare
@@ -20,11 +18,10 @@ Public Class MoveRawPartPage
Private m_dOrigDist As Double = 0 ' distanza iniziale (spessore taglio)
Private m_dCurrDist As Double = 0 ' distanza corrente
' Gestione movimento con ventose
Private m_nTempId As Integer = GDB_ID.NULL
Private m_nVacId As Integer = GDB_ID.NULL
Private m_nRefId As Integer = GDB_ID.NULL
Private m_RawPartDataList As New List(Of RawPartData)
Private m_ptTabCen As New Point3d
'Private m_nTempId As Integer = GDB_ID.NULL
'Private m_nVacId As Integer = GDB_ID.NULL
'Private m_nRefId As Integer = GDB_ID.NULL
Private m_RawMoveDataList As New List(Of RawMoveData)
Private Sub MoveRawPartPage_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
PrevBtn.IsEnabled = False
@@ -35,12 +32,8 @@ Public Class MoveRawPartPage
Private Sub MoveRawPartPage_Loaded(sender As Object, e As EventArgs) Handles Me.Loaded
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
m_bActive = True
' Leggo tipo manipolatore con ventosa
' (0=assente, 1=dietro, 2=laterale esterno, 3= laterale interno)
m_nVacType = 0
EgtGetInfo(EgtGetHeadId(VACUUM_HEAD), "VacType", m_nVacType)
' Leggo tipo movimento grezzi
m_bByHand = (m_nVacType = 0 Or
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))
' Deseleziono tutto
@@ -48,98 +41,12 @@ Public Class MoveRawPartPage
' Recupero i tagli allungati prima definiti
Dim Cuts(0) As Integer
m_MainWindow.m_CadCutPageUC.m_SplitPage.GetSplitCuts(Cuts)
' Aggiorno preview di questi tagli lasciandoli nella lavorazione
For Each nCut As Integer In Cuts
UpdateMachiningPreview(nCut, False)
Next
' Fase precedente
Dim nPrevPhase As Integer = EgtGetCurrPhase()
' Creo nuova fase
m_nCurrPhase = EgtAddPhase()
' Origine della tavola
Dim ptOri As Point3d
EgtGetTableRef(1, ptOri)
Dim vtOri As New Vector3d(ptOri.x, ptOri.y, ptOri.z)
' Centro della tavola
Dim b3Tab As New BBox3d
EgtGetTableArea(1, b3Tab)
m_ptTabCen = b3Tab.Center()
' Se non ci sono tagli allungati, confermo i grezzi
If Cuts.Length() = 0 Then
' Ciclo sui grezzi
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL
If EgtVerifyRawPartPhase(nRawId, nPrevPhase) Then
' Confermo il grezzo
EgtKeepRawPart(nRawId)
' Fisso posizione del grezzo
Dim ptMin, ptMax As Point3d
GetRawBox(nRawId, ptMin, ptMax)
EgtMoveToCornerRawPart(nRawId, ptMin - vtOri, MCH_CR.BL)
End If
nRawId = EgtGetNextRawPart(nRawId)
End While
' Altrimenti eseguo eventuali spezzature dei grezzi e vi sposto i pezzi
Else
' eseguo spezzature
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL
' se il grezzo è presente nella fase precedente
If EgtVerifyRawPartPhase(nRawId, nPrevPhase) Then
' Calcolo nuovi grezzi
Dim nRaw1Id = EgtSplitFlatRawPartWithMachinings(nRawId, Cuts)
' Fisso posizione dei nuovi grezzi
Dim nNewRawId = nRaw1Id
While nNewRawId <> GDB_ID.NULL
Dim ptMin, ptMax As Point3d
GetRawBox(nNewRawId, ptMin, ptMax)
EgtMoveToCornerRawPart(nNewRawId, ptMin - vtOri, MCH_CR.BL)
nNewRawId = EgtGetNextRawPart(nNewRawId)
End While
' Assegno ai nuovi grezzi eventuale texture del grezzo originale
Dim nSolidId = EgtGetFirstNameInGroup(nRawId, NAME_RAW_SOLID)
Dim nameTxr As String = String.Empty
If EgtGetTextureName(nSolidId, nameTxr) Then
Dim refTxr As New Frame3d
EgtGetTextureFrame(nSolidId, GDB_ID.ROOT, refTxr)
nNewRawId = nRaw1Id
While nNewRawId <> GDB_ID.NULL
' Carico la texture sul nuovo grezzo
Dim nNewSolidId = EgtGetFirstNameInGroup(nNewRawId, NAME_RAW_SOLID)
EgtSetTextureName(nNewSolidId, nameTxr)
' Sistemo il riferimento della texture
EgtSetTextureFrame(nNewSolidId, refTxr, GDB_RT.GLOB)
' Passo al grezzo successivo
nNewRawId = EgtGetNextRawPart(nNewRawId)
End While
End If
End If
' passo al successivo grezzo
nRawId = EgtGetNextRawPart(nRawId)
End While
End If
' Cancello preview dei tagli allungati dalla lavorazione
For Each nCut As Integer In Cuts
RemoveMachiningPreview(nCut)
Next
' Sposto tutte le lavorazioni disabilitate e le eventuali inglobate nella nuova fase
Dim nId = EgtGetFirstOperation()
While nId <> GDB_ID.NULL
Dim nNextId = EgtGetNextOperation(nId)
If IsValidMachining(nId) And EgtGetOperationPhase(nId) = m_nCurrPhase - 1 And EgtExistsInfo(nId, INFO_MCH_USER_OFF) Then
' sposto la lavorazione
EgtChangeOperationPhase(nId, m_nCurrPhase)
' sposto le inglobate
Dim sInfo As String = String.Empty
If EgtGetInfo(nId, INFO_MCH_OTHMID, sInfo) Then
Dim sItems() As String = sInfo.Split(",".ToCharArray)
For Each sId In sItems
EgtChangeOperationPhase(CInt(sId), m_nCurrPhase)
Next
End If
End If
nId = nNextId
End While
' Creo nuova fase, eseguo spezzatura grezzi e vi sposto le lavorazioni
Dim vNewRaws As New List(Of Integer)
SplitRawParts(nPrevPhase, Cuts, vNewRaws)
m_nCurrPhase = EgtGetCurrPhase()
' Aggiorno visualizzazione
EgtDraw()
' Carico i parametri di movimento
@@ -182,8 +89,8 @@ Public Class MoveRawPartPage
' Altrimenti movimento con ventose
Else
' Pulisco lista info per grezzi
m_RawPartDataList.Clear()
m_RawPartDataList.Capacity() = 10
m_RawMoveDataList.Clear()
m_RawMoveDataList.Capacity() = 10
End If
' Aggiorno interfaccia per taglio perpendicolare
If m_bByHand Then
@@ -230,12 +137,20 @@ Public Class MoveRawPartPage
If nStat = GDB_ST.SEL Then
EgtSetStatus(nId, GDB_ST.ON_)
' Se con ventose, le nascondo
If Not m_bByHand Then EgtSetStatus(m_nVacId, GDB_ST.OFF)
If Not m_bByHand Then EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
Else
EgtDeselectAll()
EgtSetStatus(nId, GDB_ST.SEL)
' Se con ventose le posiziono sul grezzo
If Not m_bByHand Then PutVacuumCupsOnRaw(nId)
' Se con ventose, le posiziono sul grezzo
If Not m_bByHand Then
Dim rmData As New RawMoveData
If PutVacuumCupsOnRaw(nId, rmData) Then
' Visualizzo le ventose
EgtSetStatus(GetVacuumId(), GDB_ST.ON_)
' Aggiorno i dati
AddRawMoveData(rmData)
End If
End If
End If
EgtDraw()
Exit While
@@ -266,8 +181,8 @@ Public Class MoveRawPartPage
Else
Dim vtMove As New Vector3d(0, m_dStep, 0)
If EgtMoveRawPart(nRawId, vtMove) Then
EgtMove(m_nVacId, vtMove, GDB_RT.GLOB)
AddRawPartData(nRawId, vtMove)
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
AddRawMoveData(nRawId, vtMove)
End If
End If
nRawId = EgtGetNextSelectedObj()
@@ -299,8 +214,8 @@ Public Class MoveRawPartPage
Else
Dim vtMove As New Vector3d(0, -m_dStep, 0)
If EgtMoveRawPart(nRawId, vtMove) Then
EgtMove(m_nVacId, vtMove, GDB_RT.GLOB)
AddRawPartData(nRawId, vtMove)
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
AddRawMoveData(nRawId, vtMove)
End If
End If
nRawId = EgtGetNextSelectedObj()
@@ -313,8 +228,8 @@ Public Class MoveRawPartPage
While nRawId <> GDB_ID.NULL
Dim vtMove As New Vector3d(m_dStep, 0, 0)
If EgtMoveRawPart(nRawId, vtMove) Then
EgtMove(m_nVacId, vtMove, GDB_RT.GLOB)
AddRawPartData(nRawId, vtMove)
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
AddRawMoveData(nRawId, vtMove)
End If
nRawId = EgtGetNextSelectedObj()
End While
@@ -326,8 +241,8 @@ Public Class MoveRawPartPage
While nRawId <> GDB_ID.NULL
Dim vtMove As New Vector3d(-m_dStep, 0, 0)
If EgtMoveRawPart(nRawId, vtMove) Then
EgtMove(m_nVacId, vtMove, GDB_RT.GLOB)
AddRawPartData(nRawId, vtMove)
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
AddRawMoveData(nRawId, vtMove)
End If
nRawId = EgtGetNextSelectedObj()
End While
@@ -364,35 +279,14 @@ Public Class MoveRawPartPage
' Se movimento con ventose
If Not m_bByHand Then
' nascondo le ventose
EgtSetStatus(m_nVacId, GDB_ST.OFF)
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
' aggiungo al gruppo disposizione dei sottogruppi con i dati di movimento dei grezzi spostati
Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
Dim nI As Integer = 0
For Each rwData As RawPartData In m_RawPartDataList
For Each rmData As RawMoveData In m_RawMoveDataList
' Se movimento significativo
If Not rwData.m_vtMove.IsSmall() Then
' Incremento contatore
nI += 1
' Creo il gruppo
Dim nRpmId As Integer = EgtCreateGroup(nDispId)
EgtSetName(nRpmId, "Rpm" & rwData.m_nId.ToString())
Dim sInfo As String = String.Empty
sInfo = rwData.m_nId.ToString()
EgtSetInfo(nRpmId, "Id", sInfo)
sInfo = DoubleToString(rwData.m_vtMove.x, 4) & "," &
DoubleToString(rwData.m_vtMove.y, 4) & "," &
DoubleToString(rwData.m_vtMove.z, 4)
EgtSetInfo(nRpmId, "Mv", sInfo)
sInfo = DoubleToString(rwData.m_vtDelta.x, 4) & "," &
DoubleToString(rwData.m_vtDelta.y, 4) & "," &
DoubleToString(rwData.m_vtDelta.z, 4)
EgtSetInfo(nRpmId, "Dt", sInfo)
sInfo = DoubleToString(rwData.m_dAngRotDeg, 4)
EgtSetInfo(nRpmId, "Ad", sInfo)
sInfo = rwData.m_sCups
EgtSetInfo(nRpmId, "Vc", sInfo)
sInfo = m_nVacType.ToString()
EgtSetInfo(nRpmId, "Vt", sInfo)
If Not rmData.m_vtMove.IsSmall() Then
' Creo gruppo e salvo dati per movimento grezzo
SaveMoveInfoInDisposition(nDispId, rmData)
End If
Next
' Eseguo calcolo speciale dei movimenti
@@ -400,305 +294,43 @@ Public Class MoveRawPartPage
End If
End Sub
Friend Function LoadVacuumCups() As Boolean
' Cancello eventuali vecchie ventose
RemoveVacuumCups()
' Identificativo ventose nella macchina
Dim nLayId As Integer = EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), VACUUM_HEAD_LAYOUT)
If nLayId = GDB_ID.NULL Then Return False
' Identificativo riferimento della testa nella macchina
Dim nT1Id As Integer = EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), HEAD_FIRST_EXIT)
If nT1Id = GDB_ID.NULL Then Return False
' Creo gruppo temporaneo in cui copiarli
m_nTempId = EgtCreateGroup(GDB_ID.ROOT)
If m_nTempId = GDB_ID.NULL Then Return False
EgtSetName(m_nTempId, "VacTmp")
EgtSetLevel(m_nTempId, GDB_LV.SYSTEM)
' Eseguo copia in globale
m_nVacId = EgtCopyGlob(nLayId, m_nTempId)
If m_nVacId = GDB_ID.NULL Then Return False
' Nascondo il gruppo ma rendo visibili le curve di contorno delle ventose
EgtSetStatus(m_nVacId, GDB_ST.OFF)
Dim nId As Integer = EgtGetFirstInGroup(m_nVacId)
While nId <> GDB_ID.NULL
Select Case EgtGetType(nId)
Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO
EgtSetStatus(nId, GDB_ST.ON_)
Case Else
EgtSetStatus(nId, GDB_ST.OFF)
End Select
nId = EgtGetNext(nId)
End While
m_nRefId = EgtCopyGlob(nT1Id, m_nVacId)
If m_nRefId = GDB_ID.NULL Then Return False
EgtSetStatus(m_nRefId, GDB_ST.ON_)
Return True
End Function
Friend Function RemoveVacuumCups() As Boolean
' cancello eventuale gruppo per ventose
EgtErase(m_nTempId)
m_nTempId = GDB_ID.NULL
m_nVacId = GDB_ID.NULL
m_nRefId = GDB_ID.NULL
Return True
End Function
Private Function ResetVacuumCups() As Boolean
' Ripristino posizione e rotazione originali
Dim frOriRef As New Frame3d
EgtFrame(EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), HEAD_FIRST_EXIT), GDB_ID.ROOT, frOriRef)
Dim frCurrRef As New Frame3d
EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef)
EgtMove(m_nVacId, frOriRef.Orig() - frCurrRef.Orig(), GDB_RT.GLOB)
frCurrRef.ToLoc(frOriRef)
Dim dLen, dAngVertDeg, dAngOrizzDeg As Double
frCurrRef.VersX().ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
EgtRotate(m_nVacId, frOriRef.Orig(), frOriRef.VersZ(), -dAngOrizzDeg, GDB_RT.GLOB)
' Ripristino visualizzazione originale
Dim nId As Integer = EgtGetFirstInGroup(m_nVacId)
While nId <> GDB_ID.NULL
Select Case EgtGetType(nId)
Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO
EgtSetStatus(nId, GDB_ST.ON_)
Case Else
EgtSetStatus(nId, GDB_ST.OFF)
End Select
nId = EgtGetNext(nId)
End While
EgtSetStatus(m_nRefId, GDB_ST.ON_)
Return True
End Function
Private Function PutVacuumCupsOnRaw(nRawId As Integer) As Boolean
If m_bByHand Then Return False
' Ripristino posizione originale ventose
ResetVacuumCups()
' Visualizzo le ventose
EgtSetStatus(m_nVacId, GDB_ST.ON_)
' Box e baricentro del grezzo (riportato sopra al grezzo)
Dim b3Raw As New BBox3d
GetRawBox(nRawId, b3Raw)
Dim ptRawCen As Point3d
GetRawCenter(nRawId, ptRawCen)
ptRawCen.z += b3Raw.DimZ() / 2
' Se non esiste, creo la regione del kerf del grezzo
Dim nRawRegId = EgtGetFirstNameInGroup(nRawId, NAME_KERF_REGION)
If nRawRegId = GDB_ID.NULL Then
Dim nOutlineId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_KERF)
nRawRegId = EgtCreateSurfFlatRegion(nRawId, nOutlineId)
EgtSetName(nRawRegId, NAME_KERF_REGION)
EgtSetStatus(nRawRegId, GDB_ST.OFF)
End If
' Baricentro della regione di kerf
Dim ptKerfCen As Point3d
EgtCentroid(nRawRegId, GDB_ID.ROOT, ptKerfCen)
' Cerco migliore configurazione di ventose per prendere il grezzo
Const MAX_SEL As Integer = 20
For nI As Integer = 1 To MAX_SEL
' Recupero la configurazione di ventose nI-esima
Dim sCups() As String = Nothing
Dim sCups2() As String = Nothing
If Not GetVacuumCupSelection(nI, sCups, sCups2) Then Return False
' Determino validità soluzioni della configurazione
Dim vtMove As New Vector3d
Dim ptRotCen As New Point3d
Dim dRotAngDeg As Double = 0
Dim vtMove2 As New Vector3d
Dim ptRotCen2 As New Point3d
Dim dRotAngDeg2 As Double = 0
Dim dDist = TestVacuumCupSelection(sCups, b3Raw, ptKerfCen, nRawRegId, vtMove, ptRotCen, dRotAngDeg)
Dim dDist2 = TestVacuumCupSelection(sCups2, b3Raw, ptKerfCen, nRawRegId, vtMove2, ptRotCen2, dRotAngDeg2)
If dDist > INFINITO - 1 And dDist2 > INFINITO - 1 Then Continue For
If dDist2 < dDist Then
sCups = sCups2
vtMove = vtMove2
ptRotCen = ptRotCen2
dRotAngDeg = dRotAngDeg2
End If
' Eseguo il movimento
EgtMove(m_nVacId, vtMove, GDB_RT.GLOB)
EgtRotate(m_nVacId, ptRotCen, Vector3d.Z_AX(), dRotAngDeg, GDB_RT.GLOB)
' Visualizzo le ventose
For nJ As Integer = 0 To sCups.Length() - 1
Dim nCupId = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ))
EgtSetStatus(nCupId, GDB_ST.ON_)
Next
' Aggiorno dati del grezzo
Dim frCurrRef As New Frame3d
EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef)
Dim vtDelta As Vector3d = frCurrRef.Orig() - ptRawCen
AddRawPartData(nRawId, vtDelta, dRotAngDeg, sCups)
Return True
Next
Return False
End Function
Private Function GetVacuumCupSelection(nInd As Integer, ByRef sCups() As String, ByRef sCups2() As String) As Boolean
' Recupero elenco ventose nella soluzione
Dim sSel As String = "Sel" & nInd.ToString()
Dim sVal As String = String.Empty
If Not EgtGetInfo(m_nVacId, sSel, sVal) Then Return False
If sVal.IndexOf("/") >= 0 Then
Dim sSplit() As String = sVal.Split("/".ToCharArray)
If sSplit.Length() >= 2 Then
sCups = sSplit(0).Split(",".ToCharArray)
sCups2 = sSplit(1).Split(",".ToCharArray)
ElseIf sSplit.Length() >= 1 Then
sCups = sSplit(0).Split(",".ToCharArray)
sCups2 = Nothing
Else
sCups = Nothing
sCups2 = Nothing
End If
Else
sCups = sVal.Split(",".ToCharArray)
sCups2 = Nothing
End If
Return True
End Function
Private Function TestVacuumCupSelection(sCups() As String, b3Raw As BBox3d, ptRawCen As Point3d, nRawRegId As Integer,
ByRef vtMove As Vector3d, ByRef ptRotCen As Point3d, ByRef dRotAngDeg As Double) As Double
' Se definizione mancante, scarto soluzione
If IsNothing(sCups) Then Return INFINITO
' Ne calcolo il box
Dim b3Vac As New BBox3d
For nJ As Integer = 0 To sCups.Length() - 1
Dim nCupId = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ))
Dim b3Cup As New BBox3d
If EgtGetBBoxGlob(nCupId, GDB_BB.STANDARD, b3Cup) Then b3Vac.Add(b3Cup)
Next
If b3Vac.IsEmpty() Then Return INFINITO
' Se box maggiore di quello del pezzo, scarto soluzione
If Not ((b3Vac.DimX() < b3Raw.DimX() And b3Vac.DimY() < b3Raw.DimY()) Or
(b3Vac.DimX() < b3Raw.DimY() And b3Vac.DimY() < b3Raw.DimX())) Then
Return INFINITO
End If
' Determino il movimento
vtMove = ptRawCen - b3Vac.Center()
b3Vac.Move(vtMove)
' Determino la rotazione, allineando il lato lungo delle ventose con quello del grezzo
ptRotCen = b3Vac.Center()
dRotAngDeg = 0
If (b3Vac.DimX() >= b3Vac.DimY() And b3Raw.DimX() < b3Raw.DimY()) Or
(b3Vac.DimX() < b3Vac.DimY() And b3Raw.DimX() >= b3Raw.DimY()) Then
dRotAngDeg = 90
End If
' Identificativi delle ventose
Dim nCups(sCups.Length() - 1) As Integer
For nJ As Integer = 0 To sCups.Length() - 1
nCups(nJ) = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ))
Next
' Eseguo verifica delle ventose rispetto al grezzo
Dim bVacOk As Boolean = True
If Not TestVacuumCups(nCups, nRawRegId, vtMove, ptRotCen, dRotAngDeg) Then
' Provo ad aggiungere rotazione di + 45
dRotAngDeg += 45
If Not TestVacuumCups(nCups, nRawRegId, vtMove, ptRotCen, dRotAngDeg) Then
' Provo ad aggiungere rotazione di - 45
dRotAngDeg -= 90
If Not TestVacuumCups(nCups, nRawRegId, vtMove, ptRotCen, dRotAngDeg) Then
bVacOk = False
End If
End If
End If
If Not bVacOk Then Return INFINITO
' Recupero riferimento della testa ventose
Dim frCurrRef As New Frame3d
EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef)
Dim ptRef As Point3d = frCurrRef.Orig()
' Applico movimento e rotazione al punto
ptRef.Move(vtMove)
ptRef.Rotate(ptRotCen, Vector3d.Z_AX(), dRotAngDeg)
' Ne calcolo la distanza dal centro della tavola
Dim dDist As Double = Point3d.DistXY(ptRef, m_ptTabCen)
Return dDist
End Function
Private Function TestVacuumCups(nCups() As Integer, nRawRegId As Integer,
vtMove As Vector3d, ptRotCen As Point3d, dRotAngDeg As Double) As Boolean
' Eseguo verifica delle ventose rispetto al grezzo
Dim bVacOk As Boolean = True
For nJ As Integer = 0 To nCups.Length() - 1
Dim nCupId = nCups(nJ)
' Eseguo rototraslazione delle ventose per verificare se sono contenute nel grezzo
EgtMove(nCupId, vtMove, GDB_RT.GLOB)
EgtRotate(nCupId, ptRotCen, Vector3d.Z_AX(), dRotAngDeg, GDB_RT.GLOB)
' Confronto le regioni
If EgtSurfFrChunkSimpleClassify(nRawRegId, 0, nCupId, 0) <> REGC.IN2 Then bVacOk = False
' Annullo rototraslazione
EgtRotate(nCupId, ptRotCen, Vector3d.Z_AX(), -dRotAngDeg, GDB_RT.GLOB)
EgtMove(nCupId, -vtMove, GDB_RT.GLOB)
' Se verifica fallita, esco dal ciclo
If Not bVacOk Then Exit For
Next
Return bVacOk
End Function
Private Function AddRawPartData(nRawId As Integer) As Integer
Private Function AddRawMoveData(nRawId As Integer) As Integer
' Cerco in lista record con dati del grezzo indicato
Dim nInd As Integer = -1
For i As Integer = 0 To m_RawPartDataList.Count() - 1
If m_RawPartDataList(i).m_nId = nRawId Then
For i As Integer = 0 To m_RawMoveDataList.Count() - 1
If m_RawMoveDataList(i).m_nId = nRawId Then
nInd = i
Exit For
End If
Next
' Se non trovato, lo accodo
If nInd = -1 Then
m_RawPartDataList.Add(New RawPartData(nRawId))
nInd = m_RawPartDataList.Count() - 1
m_RawMoveDataList.Add(New RawMoveData(nRawId))
nInd = m_RawMoveDataList.Count() - 1
End If
Return nInd
End Function
Private Function AddRawPartData(nRawId As Integer, vtMove As Vector3d) As Integer
Private Function AddRawMoveData(nRawId As Integer, vtMove As Vector3d) As Integer
' Recupero o creo record con dati del grezzo indicato
Dim nInd As Integer = AddRawPartData(nRawId)
Dim nInd As Integer = AddRawMoveData(nRawId)
If nInd = -1 Then Return -1
' Aggiorno i valori
m_RawPartDataList(nInd).m_vtMove += vtMove
m_RawMoveDataList(nInd).m_vtMove += vtMove
Return nInd
End Function
Private Function AddRawPartData(nRawId As Integer, vtDelta As Vector3d, dAngRotDeg As Double, sCups() As String) As Integer
Private Function AddRawMoveData(rmData As RawMoveData) As Integer
' Recupero o creo record con dati del grezzo indicato
Dim nInd As Integer = AddRawPartData(nRawId)
Dim nInd As Integer = AddRawMoveData(rmData.m_nId)
If nInd = -1 Then Return -1
' Aggiorno i valori
m_RawPartDataList(nInd).m_vtDelta = vtDelta
m_RawPartDataList(nInd).m_dAngRotDeg = dAngRotDeg
Dim sVal As String = String.Empty
For Each sCup As String In sCups
If String.IsNullOrEmpty(sVal) Then
sVal &= sCup
Else
sVal &= "," & sCup
End If
Next
m_RawPartDataList(nInd).m_sCups = sVal
m_RawMoveDataList(nInd).m_vtDelta = rmData.m_vtDelta
m_RawMoveDataList(nInd).m_dAngRotDeg = rmData.m_dAngRotDeg
m_RawMoveDataList(nInd).m_sCups = rmData.m_sCups
Return nInd
End Function
'-----------------------------------------------------------------------------------------------
Private Class RawPartData
Public m_nId As Integer
Public m_vtMove As Vector3d
Public m_vtDelta As Vector3d
Public m_dAngRotDeg As Double
Public m_sCups As String
Sub New(nId As Integer)
m_nId = nId
m_vtMove = Vector3d.NULL()
m_vtDelta = Vector3d.NULL()
m_dAngRotDeg = 0
m_sCups = String.Empty
End Sub
End Class
End Class
+2
View File
@@ -253,6 +253,7 @@
<Compile Include="SingleCutUC.xaml.vb">
<DependentUpon>SingleCutUC.xaml</DependentUpon>
</Compile>
<Compile Include="SplitAuto.vb" />
<Compile Include="SplitPageUC.xaml.vb">
<DependentUpon>SplitPageUC.xaml</DependentUpon>
</Compile>
@@ -266,6 +267,7 @@
<DependentUpon>ToolsDbPageUC.xaml</DependentUpon>
</Compile>
<Compile Include="Utility.vb" />
<Compile Include="VacuumCups.vb" />
<Compile Include="WorkInProgressPageUC.xaml.vb">
<DependentUpon>WorkInProgressPageUC.xaml</DependentUpon>
</Compile>
+2
View File
@@ -65,6 +65,8 @@ Public Class ProjectMgrUC
End Sub
Private Sub LoadBtn_Click(sender As Object, e As RoutedEventArgs) Handles LoadBtn.Click
' Cancello eventuali messaggi
m_CurrProjPage.ClearMessage()
' Se progetto modificato, chiedo se salvarlo
If EgtGetModified() Then
Dim SaveCurrProj As New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 1), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL)
+669
View File
@@ -0,0 +1,669 @@
Imports EgtUILib
Public Module SplitAuto
Private m_MainWindow As MainWindow = Application.Current.MainWindow
Private m_dLastDT As Double = 0
'-----------------------------------------------------------------------------------------------
Friend Class SplitMach
Public m_nId As Integer
Public m_vOthId As New List(Of Integer)
Public m_nType As Integer
Public m_sLay As String
Public m_nNbrId As Integer
Public m_nInterf As Integer
Public m_bCanStartAll As Boolean
Public m_bCanEndAll As Boolean
Public m_bStartAll As Boolean
Public m_bEndAll As Boolean
Public m_bEnabled As Boolean
End Class
'-----------------------------------------------------------------------------------------------
Friend Function CalculateSplitMachList(nCurrPhase As Integer, ByRef MachSplitList As List(Of SplitMach)) As Boolean
' Pulisco la lista delle lavorazioni
MachSplitList.Clear()
' La riempio
Dim nOperId As Integer = EgtGetFirstOperation()
While nOperId <> GDB_ID.NULL
' verifico sia una lavorazione valida della fase corrente
If IsValidMachining(nOperId) And EgtGetOperationPhase(nOperId) = nCurrPhase Then
' se appartiene ad un grezzo attivo la inserisco in lista
If IsMachiningInActiveRaw(nOperId) Then
Dim Mach As New SplitMach
' identificativo
Mach.m_nId = nOperId
' eventuali lavorazioni inglobate
Dim sInfo As String = String.Empty
If EgtGetInfo(nOperId, INFO_MCH_OTHMID, sInfo) Then
Dim sItems() As String = sInfo.Split(",".ToCharArray)
For Each sId In sItems
Mach.m_vOthId.Add(CInt(sId))
Next
End If
' tipo
Mach.m_nType = EgtGetOperationType(nOperId)
' layer di origine
EgtGetInfo(nOperId, "Lay", Mach.m_sLay)
' verifica interferenza
If Mach.m_sLay = NAME_OUTLOOP Then
EgtVerifyMachining(nOperId, Mach.m_nInterf)
For Each nId As Integer In Mach.m_vOthId
Dim nRes As Integer = FMI_TYPE.LI Or FMI_TYPE.RM Or FMI_TYPE.LO
EgtVerifyMachining(nId, nRes)
Mach.m_nInterf = Mach.m_nInterf Or nRes
Next
Else
Mach.m_nInterf = FMI_TYPE.NONE
End If
' la imposto come lavorazione corrente e ne ricavo il tipo
EgtSetCurrMachining(nOperId)
Dim nMchType As Integer = MCH_MY.NONE
EgtGetMachiningParam(MCH_MP.TYPE, nMchType)
' se taglio con lama, recupero l'angolo di fianco
Dim dSideAng As Double = 90
EgtGetMachiningParam(MCH_MP.SIDEANGLE, dSideAng)
' se taglio con lama, recupero allungamento iniziale e finale (negativi vicino ad angoli interni)
Dim dStartAddLen As Double = -10
EgtGetMachiningParam(MCH_MP.STARTADDLEN, dStartAddLen)
Dim dEndAddLen As Double = -10
EgtGetMachiningParam(MCH_MP.ENDADDLEN, dEndAddLen)
' verifico se trasformabile in un taglio di separazione
If Math.Abs(dSideAng) < EPS_ANG_SMALL And
dStartAddLen > -EPS_SMALL And dEndAddLen > -EPS_SMALL And
Mach.m_sLay = NAME_OUTLOOP And Mach.m_nInterf = FMI_TYPE.NONE Then
Dim nRes As Integer = EgtVerifyCutAsSplitting(nOperId)
Mach.m_bCanStartAll = (nRes And CAR_RES.LI_OK) <> 0
Mach.m_bCanEndAll = (nRes And CAR_RES.LO_OK) <> 0
Else
Mach.m_bCanStartAll = False
Mach.m_bCanEndAll = False
End If
' se trasformabile in taglio di separazione, verifico se lo è
If Mach.m_bCanStartAll Or Mach.m_bCanEndAll Then
EgtSetCurrMachining(nOperId)
Dim nLiType As Integer
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiType)
Dim nLoType As Integer
EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nLoType)
Mach.m_bStartAll = (nLiType = MCH_SAW_LI.EXT_CENT Or nLiType = MCH_SAW_LI.EXT_OUT)
Mach.m_bEndAll = (nLoType = MCH_SAW_LO.EXT)
Else
Mach.m_bStartAll = False
Mach.m_bEndAll = False
End If
' abilitazione
Mach.m_bEnabled = Not EgtExistsInfo(nOperId, INFO_MCH_USER_OFF)
' inserisco in lista
MachSplitList.Add(Mach)
' altrimenti la disattivo
Else
EgtSetOperationMode(nOperId, False)
End If
End If
nOperId = EgtGetNextOperation(nOperId)
End While
Return True
End Function
'-----------------------------------------------------------------------------------------------
Friend Sub ColorMachining(MachSplit As SplitMach, Optional bReset As Boolean = False)
' Assegno stato
Dim bEnabled As Boolean = MachSplit.m_bEnabled
Dim nInterf As Integer = If(bReset, FMI_TYPE.NONE, MachSplit.m_nInterf)
' Colore della lavorazione principale
ColorSingleMachining(MachSplit.m_nId, bEnabled, nInterf)
' Colore delle lavorazioni inglobate
For Each nId As Integer In MachSplit.m_vOthId
ColorSingleMachining(nId, bEnabled, nInterf)
Next
End Sub
Private Sub ColorSingleMachining(nOperId As Integer, bEnabled As Boolean, nInterf As Integer)
' Recupero il preview della lavorazione
Dim nPvId As Integer = GDB_ID.NULL
EgtGetInfo(EgtGetFirstNameInGroup(nOperId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId)
' Cambio il colore
Dim nGrpId As Integer = EgtGetFirstGroupInGroup(nPvId)
While nGrpId <> GDB_ID.NULL
Dim nCutId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_CUT)
Dim nPrcId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_PRECUT)
Dim nPocId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_POSTCUT)
Dim nDwnCutId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_CUT)
Dim nDwnPrcId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_PRECUT)
Dim nDwnPocId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_POSTCUT)
If Not bEnabled Then
EgtSetColor(nCutId, COL_MCH_DISABLED)
EgtSetColor(nDwnCutId, COL_MCH_DISABLED)
Dim bFreeStart As Boolean = (nInterf And FMI_TYPE.LI) <> FMI_TYPE.LI
EgtSetColor(nPrcId, If(bFreeStart, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
EgtSetColor(nDwnPrcId, If(bFreeStart, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
Dim bFreeEnd As Boolean = (nInterf And FMI_TYPE.LO) <> FMI_TYPE.LO
EgtSetColor(nPocId, If(bFreeEnd, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
EgtSetColor(nDwnPocId, If(bFreeEnd, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
Else
EgtSetColor(nCutId, COL_MCH_CUT)
EgtSetColor(nDwnCutId, COL_MCH_CUT)
Dim bFreeStart As Boolean = (nInterf And FMI_TYPE.LI) <> FMI_TYPE.LI
EgtSetColor(nPrcId, If(bFreeStart, COL_MCH_FREE, COL_MCH_INTERF))
EgtSetColor(nDwnPrcId, If(bFreeStart, COL_MCH_FREE, COL_MCH_INTERF))
Dim bFreeEnd As Boolean = (nInterf And FMI_TYPE.LO) <> FMI_TYPE.LO
EgtSetColor(nPocId, If(bFreeEnd, COL_MCH_FREE, COL_MCH_INTERF))
EgtSetColor(nDwnPocId, If(bFreeEnd, COL_MCH_FREE, COL_MCH_INTERF))
End If
nGrpId = EgtGetNextGroup(nGrpId)
End While
End Sub
'-----------------------------------------------------------------------------------------------
Friend Function SplitRawParts(nPrevPhase As Integer, vCuts() As Integer,
ByRef vNewRaws As List(Of Integer)) As Boolean
' Aggiorno preview di questi tagli lasciandoli nella lavorazione
For Each nCut As Integer In vCuts
UpdateMachiningPreview(nCut, False)
Next
' Creo nuova fase
Dim nNewPhase As Integer = EgtAddPhase()
' Origine della tavola
Dim ptOri As Point3d
EgtGetTableRef(1, ptOri)
Dim vtOri As New Vector3d(ptOri.x, ptOri.y, ptOri.z)
' Se non ci sono tagli allungati, confermo i grezzi
If vCuts.Count() = 0 Then
' Ciclo sui grezzi
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL
If EgtVerifyRawPartPhase(nRawId, nPrevPhase) Then
' Confermo il grezzo
EgtKeepRawPart(nRawId)
' Fisso posizione del grezzo
Dim ptMin, ptMax As Point3d
GetRawBox(nRawId, ptMin, ptMax)
EgtMoveToCornerRawPart(nRawId, ptMin - vtOri, MCH_CR.BL)
End If
nRawId = EgtGetNextRawPart(nRawId)
End While
' Altrimenti eseguo eventuali spezzature dei grezzi e vi sposto i pezzi
Else
' eseguo spezzature
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL
' se il grezzo è presente nella fase precedente
If EgtVerifyRawPartPhase(nRawId, nPrevPhase) Then
' Calcolo nuovi grezzi
Dim nRaw1Id = EgtSplitFlatRawPartWithMachinings(nRawId, vCuts)
' Fisso posizione dei nuovi grezzi
Dim nNewRawId = nRaw1Id
While nNewRawId <> GDB_ID.NULL
Dim ptMin, ptMax As Point3d
GetRawBox(nNewRawId, ptMin, ptMax)
EgtMoveToCornerRawPart(nNewRawId, ptMin - vtOri, MCH_CR.BL)
nNewRawId = EgtGetNextRawPart(nNewRawId)
End While
' Se almeno 2 grezzi da uno vecchio, li considero nuovi
If EgtGetNextRawPart(nRaw1Id) <> GDB_ID.NULL Then
nNewRawId = nRaw1Id
While nNewRawId <> GDB_ID.NULL
vNewRaws.Add(nNewRawId)
nNewRawId = EgtGetNextRawPart(nNewRawId)
End While
End If
' Assegno ai nuovi grezzi eventuale texture del grezzo originale
Dim nSolidId = EgtGetFirstNameInGroup(nRawId, NAME_RAW_SOLID)
Dim nameTxr As String = String.Empty
If EgtGetTextureName(nSolidId, nameTxr) Then
Dim refTxr As New Frame3d
EgtGetTextureFrame(nSolidId, GDB_ID.ROOT, refTxr)
nNewRawId = nRaw1Id
While nNewRawId <> GDB_ID.NULL
' Carico la texture sul nuovo grezzo
Dim nNewSolidId = EgtGetFirstNameInGroup(nNewRawId, NAME_RAW_SOLID)
EgtSetTextureName(nNewSolidId, nameTxr)
' Sistemo il riferimento della texture
EgtSetTextureFrame(nNewSolidId, refTxr, GDB_RT.GLOB)
' Passo al grezzo successivo
nNewRawId = EgtGetNextRawPart(nNewRawId)
End While
End If
End If
' passo al successivo grezzo
nRawId = EgtGetNextRawPart(nRawId)
End While
End If
' Cancello preview dei tagli allungati dalla lavorazione
For Each nCut As Integer In vCuts
RemoveMachiningPreview(nCut)
Next
' Sposto tutte le lavorazioni disabilitate e le eventuali inglobate nella nuova fase
Dim nId = EgtGetFirstOperation()
While nId <> GDB_ID.NULL
Dim nNextId = EgtGetNextOperation(nId)
If IsValidMachining(nId) And EgtGetOperationPhase(nId) = nNewPhase - 1 And EgtExistsInfo(nId, INFO_MCH_USER_OFF) Then
' sposto la lavorazione
EgtChangeOperationPhase(nId, nNewPhase)
' sposto le inglobate
Dim sInfo As String = String.Empty
If EgtGetInfo(nId, INFO_MCH_OTHMID, sInfo) Then
Dim sItems() As String = sInfo.Split(",".ToCharArray)
For Each sId In sItems
EgtChangeOperationPhase(CInt(sId), nNewPhase)
Next
End If
End If
nId = nNextId
End While
Return True
End Function
'-----------------------------------------------------------------------------------------------
Friend Function CalculateSplitAuto() As Boolean
' Fase iniziale
EgtSetCurrPhase(1)
' Cancello tutte le lavorazioni
EraseMachinings(GDB_ID.NULL)
' Reinserisco tutte le lavorazioni
AddMachinings(GDB_ID.NULL, True, False)
' Carico ventose
LoadVacuumCups()
' Lancio calcolo separazione
Dim bFinished As Boolean = False
While CalculateOnePhaseSplitAuto(bFinished)
If bFinished Then
Exit While
End If
End While
' Se non finito con successo, verifico se necessario limitare lavorazioni
If Not bFinished Then
If Not TestMachiningCurrPhaseForStrict() Then
m_MainWindow.m_CurrentProjectPageUC.SetWarningMessage(EgtMsg(90321)) 'Ridotte alcune lavorazioni per evitare interferenze
End If
End If
EgtSetCurrPhase(1)
' Scarico ventose
RemoveVacuumCups()
Return bFinished
End Function
'-----------------------------------------------------------------------------------------------
Friend Function CalculateOnePhaseSplitAuto(ByRef bFinished As Boolean) As Boolean
' Faccio ordine automatico delle lavorazioni
If Not SortAllMachinings() Then Return False
m_MainWindow.m_CurrentProjectPageUC.SetOrderMachiningFlag()
' Recupero l'indice della fase corrente
Dim nCurrPhase As Integer = EgtGetCurrPhase()
' Preparo la lista delle lavorazioni
Dim MachSplitList As New List(Of SplitMach)
If Not CalculateSplitMachList(nCurrPhase, MachSplitList) Then Return False
' Se non ci sono interferenze
If Not FindInterferences(MachSplitList) Then
' Abilito tutte le lavorazioni della lista
EnableAllMachinings(MachSplitList)
' Dichiaro conclusione ed esco
bFinished = True
Return True
End If
' Disabilito tutte le lavorazioni della lista
DisableAllMachinings(MachSplitList)
' Cerco il miglior taglio di separazione
Dim nCutInd As Integer = FindBestSeparationCut(MachSplitList)
If nCutInd < 0 Then Return False
' Eseguo il taglio
If Not MakeSeparatingCut(MachSplitList(nCutInd).m_nId) Then Return False
MachSplitList(nCutInd).m_bEnabled = True
MachSplitList(nCutInd).m_bStartAll = True
MachSplitList(nCutInd).m_bEndAll = True
ColorMachining(MachSplitList(nCutInd))
' Spezzo i grezzi creando una nuova fase di lavoro
Dim vCuts() As Integer = {MachSplitList(nCutInd).m_nId}
Dim vNewRaws As New List(Of Integer)
If SplitRawParts(nCurrPhase, vCuts, vNewRaws) Then
' Eseguo gli spostamenti dei grezzi
If MoveRawParts(MachSplitList(nCutInd).m_nId, vNewRaws) Then
bFinished = False
Return True
End If
End If
' Ci sono stati errori dopo aver creato la nuova fase, ripristino la vecchia
RemoveLastPhase()
bFinished = False
Return False
End Function
'-----------------------------------------------------------------------------------------------
Friend Function RemoveLastPhase() As Boolean
' Non posso eliminare la prima fase
Dim nLastPhase As Integer = EgtGetPhaseCount()
If nLastPhase = 1 Then Return False
' Sposto le lavorazioni in coda a quelle della fase precedente
Dim nDispId As Integer = EgtGetPhaseDisposition(nLastPhase)
Dim nMachId As Integer = EgtGetNextOperation(nDispId)
While nMachId <> GDB_ID.NULL
EgtChangeOperationPhase(nMachId, nLastPhase - 1)
nMachId = EgtGetNextOperation(nDispId)
End While
' Rimuovo l'ultima fase
Return EgtRemoveLastPhase()
End Function
'-----------------------------------------------------------------------------------------------
'-----------------------------------------------------------------------------------------------
Private Function FindInterferences(ByRef MachSplitList As List(Of SplitMach)) As Boolean
Dim bInterf As Boolean = False
For Each MachSplit As SplitMach In MachSplitList
If MachSplit.m_nInterf <> FMI_TYPE.NONE Then
bInterf = True
Exit For
End If
Next
Return bInterf
End Function
Private Function EnableAllMachinings(ByRef MachSplitList As List(Of SplitMach)) As Boolean
For nI As Integer = 0 To MachSplitList.Count() - 1
If Not MachSplitList(nI).m_bEnabled Then
MachSplitList(nI).m_bEnabled = True
EgtSetOperationMode(MachSplitList(nI).m_nId, True)
EgtRemoveInfo(MachSplitList(nI).m_nId, INFO_MCH_USER_OFF)
ColorMachining(MachSplitList(nI))
End If
Next
Return True
End Function
Private Function DisableAllMachinings(ByRef MachSplitList As List(Of SplitMach)) As Boolean
For nI As Integer = 0 To MachSplitList.Count() - 1
If MachSplitList(nI).m_bEnabled Then
MachSplitList(nI).m_bEnabled = False
EgtSetOperationMode(MachSplitList(nI).m_nId, False)
EgtSetInfo(MachSplitList(nI).m_nId, INFO_MCH_USER_OFF, 1)
ColorMachining(MachSplitList(nI))
End If
Next
Return True
End Function
Private Function FindBestSeparationCut(MachSplitList As List(Of SplitMach)) As Integer
Dim nInd As Integer = -1
Dim nMaxInterf As Integer = 0
m_dLastDT = 0
For nI As Integer = 0 To MachSplitList.Count() - 1
Dim MachSplit As SplitMach = MachSplitList(nI)
' Se non allungabile ad entrambi gli estremi, vado oltre
If Not MachSplit.m_bCanStartAll Or Not MachSplit.m_bCanEndAll Then Continue For
' Se ci sono lavorazioni componenti, calcolo preview completo in lavorazione
If MachSplit.m_vOthId.Count() > 0 Then
UpdateMachiningPreview(MachSplit.m_nId, False)
End If
' Contatore interferenze altri tagli con taglio corrente
Dim nCurrInterf As Integer = 0
' Lunghezza baffi altri tagli che interferiscono su taglio corrente
Dim dCurrInterfLen As Double = 0
' Determino quanti tagli con interferenza interseca
For Each MachSplit2 As SplitMach In MachSplitList
' Se coincide con il precedente, vado oltre
If MachSplit2.m_nId = MachSplit.m_nId Then Continue For
' Se non interferisce, vado oltre
If MachSplit2.m_nInterf = FMI_TYPE.NONE Then Continue For
' Se ci sono lavorazioni componenti, calcolo preview completo in lavorazione
If MachSplit2.m_vOthId.Count() > 0 Then
UpdateMachiningPreview(MachSplit2.m_nId, False)
End If
' Eseguo verifica tra le lavorazioni
Dim bInterf As Boolean = False
If GetInterferenceWithOtherCut(MachSplit.m_nId, MachSplit2.m_nId, MachSplit2.m_nInterf) Then
bInterf = True
' Recupero lunghezza baffo secondo taglio
Dim nPvId As Integer = GDB_ID.NULL
EgtGetInfo(EgtGetFirstNameInGroup(MachSplit2.m_nId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId)
Dim dDT As Double
If EgtGetInfo(EgtGetFirstGroupInGroup(nPvId), "DT", dDT) And dDT > dCurrInterfLen Then
dCurrInterfLen = dDT
End If
End If
If bInterf Then nCurrInterf += 1
' Rimozione eventuale preview completo in lavorazione
RemoveMachiningPreview(MachSplit2.m_nId)
Next
' Verifico se taglio corrente è nuovo campione
If nCurrInterf > nMaxInterf Then
nMaxInterf = nCurrInterf
nInd = nI
m_dLastDT = dCurrInterfLen
End If
' Rimozione eventuale preview completo in lavorazione
RemoveMachiningPreview(MachSplit.m_nId)
Next
Return nInd
End Function
Private Function GetInterferenceWithOtherCut(nId As Integer, nId2 As Integer, nInterf2 As Integer) As Boolean
' Se il secondo non ha interferenze, esco subito
If nInterf2 = FMI_TYPE.NONE Then Return False
' Regione di taglio ridotta del primo
Dim nPvId As Integer = EgtGetFirstNameInGroup(nId, NAME_PREVIEW)
If EgtGetGroupObjs(nPvId) = 0 Then EgtGetInfo(nPvId, INFO_PV_ONPART_ID, nPvId)
Dim nRCutId As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(nPvId), NAME_PV_RCUT)
' Se il secondo ha l'attacco che interferisce
If (nInterf2 And FMI_TYPE.LI) <> 0 Then
' Recupero regione dell'attacco
Dim nPv2Id As Integer = EgtGetFirstNameInGroup(nId2, NAME_PREVIEW)
If EgtGetGroupObjs(nPv2Id) = 0 Then EgtGetInfo(nPv2Id, INFO_PV_ONPART_ID, nPv2Id)
Dim nRLiCut2Id As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(nPv2Id), NAME_PV_RLICUT)
' Verifico se questa regione interferisce con quella del taglio di riferimento
If EgtSurfFrChunkSimpleClassify(nRCutId, 0, nRLiCut2Id, 0) <> REGC.OUT Then Return True
End If
' Se il secondo ha l'uscita che interferisce
If (nInterf2 And FMI_TYPE.LO) <> 0 Then
' Recupero Id della regione dell'uscita
Dim nPv2Id As Integer = EgtGetFirstNameInGroup(nId2, NAME_PREVIEW)
If EgtGetGroupObjs(nPv2Id) = 0 Then EgtGetInfo(nPv2Id, INFO_PV_ONPART_ID, nPv2Id)
Dim nRLoCut2Id As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(nPv2Id), NAME_PV_RLOCUT)
' Verifico se questa regione interferisce con quella del taglio di riferimento
If EgtSurfFrChunkSimpleClassify(nRCutId, 0, nRLoCut2Id, 0) <> REGC.OUT Then Return True
End If
Return False
End Function
Private Function MakeSeparatingCut(nCutId As Integer) As Boolean
EgtSetCurrMachining(nCutId)
Dim nLiPrev As Integer
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev)
' allungo
If nLiPrev = MCH_SAW_LI.OUT Then
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_OUT)
Else
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT)
End If
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT)
UpdateMachiningPreview(nCutId, True)
EgtSetOperationMode(nCutId, True)
EgtRemoveInfo(nCutId, INFO_MCH_USER_OFF)
Return True
End Function
Private Function MoveRawParts(nCutId As Integer, ByRef vNewRaws As List(Of Integer)) As Boolean
' Almeno 2 nuovi grezzi (dovrebbero essere solo 2)
If vNewRaws.Count() < 2 Then Return False
' Privilegio il grezzo più piccolo (lo porto in seconda posizione per essere mosso per primo)
If GetSmallerRaw(vNewRaws(0), vNewRaws(1)) = 1 Then
Dim nTmp As Integer = vNewRaws(0)
vNewRaws(0) = vNewRaws(1)
vNewRaws(1) = nTmp
End If
' Centri dei primi 2 grezzi
Dim ptCen0 As Point3d
If Not GetRawCenter(vNewRaws(0), ptCen0) Then Return False
Dim ptCen1 As Point3d
If Not GetRawCenter(vNewRaws(1), ptCen1) Then Return False
' Direzione del taglio
EgtSetCurrMachining(nCutId)
Dim nEntId, nSub As Integer
If Not EgtGetMachiningGeometry(0, nEntId, nSub) Then Return False
Dim vtCutDir As Vector3d
EgtStartVector(nEntId, GDB_ID.ROOT, vtCutDir)
' Distanza minima di spostamento
Dim dExtraL As Double = 0
EgtMdbGetGeneralParam(MCH_GP.EXTRALONCUTREG, dExtraL)
Dim dMinMove As Double = m_dLastDT + dExtraL + 1
' Decido cosa muovere
Dim nDispId As Integer = EgtGetPhaseDisposition(EgtGetCurrPhase())
Dim dDeltaX = ptCen1.x - ptCen0.x
Dim dDeltaY = ptCen1.y - ptCen0.y
If Math.Abs(dDeltaX) < Math.Abs(dDeltaY) Then
Dim vtMove As New Vector3d(0, dMinMove / Math.Abs(vtCutDir.x), 0)
If dDeltaY < 0 Then vtMove = -vtMove
Dim vtMove2 As Vector3d = -vtMove
Dim rmData As New RawMoveData
If PutVacuumCupsOnRaw(vNewRaws(1), rmData) AndAlso
SafeMoveRawPart(vNewRaws(1), vtMove, dMinMove) Then
rmData.m_vtMove = vtMove
SaveMoveInfoInDisposition(nDispId, rmData)
ElseIf PutVacuumCupsOnRaw(vNewRaws(0), rmData) AndAlso
SafeMoveRawPart(vNewRaws(0), vtMove2, dMinMove) Then
rmData.m_vtMove = vtMove2
SaveMoveInfoInDisposition(nDispId, rmData)
Else
Return False
End If
Else
Dim vtMove As New Vector3d(dMinMove / Math.Abs(vtCutDir.y), 0, 0)
If dDeltaX < 0 Then vtMove = -vtMove
Dim vtMove2 As Vector3d = -vtMove
Dim rmData As New RawMoveData
If PutVacuumCupsOnRaw(vNewRaws(1), rmData) AndAlso
SafeMoveRawPart(vNewRaws(1), vtMove, dMinMove) Then
rmData.m_vtMove = vtMove
SaveMoveInfoInDisposition(nDispId, rmData)
ElseIf PutVacuumCupsOnRaw(vNewRaws(0), rmData) AndAlso
SafeMoveRawPart(vNewRaws(0), vtMove2, dMinMove) Then
rmData.m_vtMove = vtMove2
SaveMoveInfoInDisposition(nDispId, rmData)
Else
Return False
End If
End If
Return True
End Function
Private Function TestMachiningCurrPhaseForStrict() As Boolean
' Recupero l'indice della fase corrente
Dim nCurrPhase As Integer = EgtGetCurrPhase()
' Preparo la lista delle lavorazioni
Dim MachSplitList As New List(Of SplitMach)
If Not CalculateSplitMachList(nCurrPhase, MachSplitList) Then Return False
' Affondamento ridotto
Dim dReducedDepth As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_REDUCEDDEPTH, 1, m_MainWindow.GetMachIniFile())
' Restringo o rialzo lavorazioni abilitate ma con interferenza
Dim bModified As Boolean = False
For Each Mach As SplitMach In MachSplitList
If Mach.m_bEnabled And Mach.m_nInterf <> FMI_TYPE.NONE Then
If AdjustMachining(Mach.m_nId, Mach.m_nInterf, dReducedDepth) Then
bModified = True
End If
End If
Next
Return bModified
End Function
Private Function GetSmallerRaw(nRaw1Id As Integer, nRaw2Id As Integer) As Integer
' Area del primo grezzo
Dim nRc1Id As Integer = EgtGetFirstNameInGroup(nRaw1Id, NAME_RAW_OUTLINE)
Dim dArea1 As Double = 0
If Not EgtCurveAreaXY(nRc1Id, dArea1) Then Return 0
' Area del secondo grezzo
Dim nRc2Id As Integer = EgtGetFirstNameInGroup(nRaw2Id, NAME_RAW_OUTLINE)
Dim dArea2 As Double = 0
If Not EgtCurveAreaXY(nRc2Id, dArea2) Then Return 0
' Confronto le aree
If dArea1 < dArea2 Then
Return 1
Else
Return 2
End If
End Function
Private Function SafeMoveRawPart(nRawId As Integer, ByRef vtMove As Vector3d, dMindist As Double) As Boolean
' Se esce dalla tavola, movimento già annullato ed esco con errore
If Not EgtMoveRawPart(nRawId, vtMove) Then Return False
' Se interferisce con altri grezzi, annullo movimento ed esco con errore
If Not VerifyRawWithOtherRaws(nRawId, dMindist) Then
EgtMoveRawPart(nRawId, -vtMove)
Return False
End If
' Provo ad aggiungere un altro movimento
If EgtMoveRawPart(nRawId, vtMove) Then
If VerifyRawWithOtherRaws(nRawId, dMindist) Then
vtMove += vtMove
Else
EgtMoveRawPart(nRawId, -vtMove)
End If
End If
' Provo ad aggiungere un movimento dimezzato
If EgtMoveRawPart(nRawId, 0.5 * vtMove) Then
If VerifyRawWithOtherRaws(nRawId, dMindist) Then
vtMove += 0.5 * vtMove
Else
EgtMoveRawPart(nRawId, -0.5 * vtMove)
End If
End If
' Provo ad aggiunger un movimento 1/4
If EgtMoveRawPart(nRawId, 0.25 * vtMove) Then
If VerifyRawWithOtherRaws(nRawId, dMindist) Then
vtMove += 0.25 * vtMove
Else
EgtMoveRawPart(nRawId, -0.25 * vtMove)
End If
End If
Return True
End Function
Private Function VerifyRawWithOtherRaws(nRawId As Integer, dMindist As Double) As Boolean
' Contorno del grezzo in esame
Dim nRcId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_RAW_OUTLINE)
If nRcId = GDB_ID.NULL Then Return False
' Fase corrente
Dim nCurrPhase As Integer = EgtGetCurrPhase()
' Recupero elenco dei contorni degli altri grezzi della fase indicata
Dim OthRawList As New List(Of Integer)
Dim nOthId As Integer = EgtGetFirstRawPart()
While nOthId <> GDB_ID.NULL
If EgtVerifyRawPartPhase(nOthId, nCurrPhase) Then
If nOthId <> nRawId Then
Dim nOthRcId As Integer = EgtGetFirstNameInGroup(nOthId, NAME_RAW_OUTLINE)
If nOthRcId <> GDB_ID.NULL Then OthRawList.Add(nOthRcId)
End If
End If
nOthId = EgtGetNextRawPart(nOthId)
End While
' Box del grezzo in esame
Dim b3Raw As New BBox3d
EgtGetBBoxGlob(nRcId, GDB_BB.STANDARD, b3Raw)
b3Raw.Expand(dMindist)
' Creo la curva offsettata della minima distanza (considero solo la prima, ovvero la più lunga)
Dim nCount As Integer = 0
Dim nOffsId = EgtOffsetCurveAdv(nRcId, dMindist, OFF_TYPE.FILLET, nCount)
' Verifico
Dim bInterf As Boolean = False
For Each nId As Integer In OthRawList
Dim b3OthRaw As New BBox3d
EgtGetBBoxGlob(nId, GDB_BB.STANDARD, b3OthRaw)
' Se i box interferiscono
If b3Raw.OverlapsXY(b3OthRaw) Then
' Verifico i contorni esterni
If EgtClosedCurveClassify(nOffsId, nId) <> CCREGC.OUT Then
bInterf = True
Exit For
End If
End If
Next
' Cancello curve offset
For i = 0 To nCount - 1
EgtErase(nOffsId + i)
Next
Return (Not bInterf)
End Function
End Module
+3 -1
View File
@@ -35,7 +35,8 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Button Name="PrevBtn" Grid.Column="0" Style="{StaticResource OmagCut_YellowIconButton}">
@@ -50,6 +51,7 @@
</Image.RenderTransform>
</Image>
</Button>
<Button Name="AutoBtn" Grid.Column="2" Style="{StaticResource OmagCut_YellowTextButton}" FontSize="16"/>
</Grid>
</Grid>
+102 -192
View File
@@ -10,7 +10,7 @@ Public Class SplitPageUC
Private m_bByHand As Boolean = True
' Stato
Private m_nCurrPhase As Integer = 0
Private m_MachiningList As New List(Of Machining)
Private m_MachiningList As New List(Of SplitMach)
Private m_ItemList As New ObservableCollection(Of NameIdLsBxItem)
Private m_CurrInd As Integer = -1
Private m_bModified As Boolean = False
@@ -31,12 +31,14 @@ Public Class SplitPageUC
OutCenStartBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 7) ' Inizio Centro/Fuori
AllOutStartBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 8) ' Inizi Tutti Fuori
AllCenStartBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 9) ' Inizi Tutti Centro
AutoBtn.Content = "Auto"
End Sub
Private Sub SplitPageUC_Loaded(sender As Object, e As EventArgs) Handles Me.Loaded
' Leggo tipo movimento grezzi
m_bByHand = (EgtGetHeadId(VACUUM_HEAD) = GDB_ID.NULL Or
(GetPrivateProfileInt(S_RAWMOVE, K_PERPENDICULAR, 0, m_MainWindow.GetIniFile()) <> 0))
Not m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.AUTO_MANIP) Or
(GetPrivateProfileInt(S_RAWMOVE, K_PERPENDICULAR, 0, m_MainWindow.GetIniFile()) <> 0))
' Nascondo eventuali pezzi in parcheggio
HideParkedParts()
EgtZoom(ZM.ALL)
@@ -55,84 +57,18 @@ Public Class SplitPageUC
' Recupero l'indice della fase corrente
m_nCurrPhase = EgtGetCurrPhase()
' Preparo la lista delle lavorazioni
m_MachiningList.Clear()
Dim nOperId As Integer = EgtGetFirstOperation()
While nOperId <> GDB_ID.NULL
' verifico sia una lavorazione valida della fase corrente
If IsValidMachining(nOperId) And EgtGetOperationPhase(nOperId) = m_nCurrPhase Then
' se appartiene ad un grezzo attivo la inserisco in lista
If IsMachiningInActiveRaw(nOperId) Then
Dim Mach As New Machining
' identificativo
Mach.m_nId = nOperId
' eventuali lavorazioni inglobate
Dim sInfo As String = String.Empty
If EgtGetInfo(nOperId, INFO_MCH_OTHMID, sInfo) Then
Dim sItems() As String = sInfo.Split(",".ToCharArray)
For Each sId In sItems
Mach.m_vOthId.Add(CInt(sId))
Next
End If
' tipo
Mach.m_nType = EgtGetOperationType(nOperId)
' layer di origine
EgtGetInfo(nOperId, "Lay", Mach.m_sLay)
' verifica interferenza
If Mach.m_sLay = NAME_OUTLOOP Then
EgtVerifyMachining(nOperId, Mach.m_nInterf)
For Each nId As Integer In Mach.m_vOthId
Dim nRes As Integer = FMI_TYPE.LI Or FMI_TYPE.RM Or FMI_TYPE.LO
EgtVerifyMachining(nId, nRes)
Mach.m_nInterf = Mach.m_nInterf Or nRes
Next
Else
Mach.m_nInterf = FMI_TYPE.NONE
End If
' se taglio con lama, recupero l'angolo di fianco
EgtSetCurrMachining(nOperId)
Dim dSideAng As Double = 90
EgtGetMachiningParam(MCH_MP.SIDEANGLE, dSideAng)
' verifica se trasformabile in un taglio di separazione
If Math.Abs(dSideAng) < EPS_ANG_SMALL And Mach.m_sLay = NAME_OUTLOOP And Mach.m_nInterf = FMI_TYPE.NONE Then
Dim nRes As Integer = EgtVerifyCutAsSplitting(nOperId)
Mach.m_bCanAllStart = (nRes And CAR_RES.LI_OK) <> 0
Mach.m_bCanAllEnd = (nRes And CAR_RES.LO_OK) <> 0
Else
Mach.m_bCanAllStart = False
Mach.m_bCanAllEnd = False
End If
' se trasformabile in taglio di separazione, verifico se lo è
If Mach.m_bCanAllStart Or Mach.m_bCanAllEnd Then
EgtSetCurrMachining(nOperId)
Dim nLiType As Integer
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiType)
Dim nLoType As Integer
EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nLoType)
Mach.m_bAllStart = (nLiType = MCH_SAW_LI.EXT_CENT Or nLiType = MCH_SAW_LI.EXT_OUT)
Mach.m_bAllEnd = (nLoType = MCH_SAW_LO.EXT)
Else
Mach.m_bAllStart = False
Mach.m_bAllEnd = False
End If
' abilitazione
Mach.m_bEnabled = Not EgtExistsInfo(nOperId, INFO_MCH_USER_OFF)
' inserisco in lista
m_MachiningList.Add(Mach)
' sistemo colore
ColorMachining(m_MachiningList.Count() - 1)
' assegno numerazione
NumberMachining(m_MachiningList.Count() - 1)
' altrimenti la disattivo
Else
EgtSetOperationMode(nOperId, False)
End If
End If
nOperId = EgtGetNextOperation(nOperId)
End While
CalculateSplitMachList(m_nCurrPhase, m_MachiningList)
' Aggiorno visualizzazione delle lavorazioni
For nI As Integer = 0 To m_MachiningList.Count() - 1
' sistemo colore
ColorMachining(m_MachiningList(nI))
' assegno numerazione
NumberMachining(nI)
Next
' Preparo la lista degli Item
m_ItemList.Clear()
For i As Integer = 1 To m_MachiningList.Count()
Dim Mach As Machining = m_MachiningList(i - 1)
Dim Mach As SplitMach = m_MachiningList(i - 1)
If Mach.m_nType = MCH_OY.SAWING Then ' Taglio
Dim sText As String = EgtMsg(90791) & i.ToString()
m_ItemList.Add(New NameIdLsBxItem(sText, i - 1, Mach.m_bEnabled))
@@ -144,6 +80,7 @@ Public Class SplitPageUC
m_ItemList.Add(New NameIdLsBxItem(sText, i - 1, Mach.m_bEnabled))
End If
Next
' Aggiorno visualizzazione
EgtDraw()
' Abilito impostazione modificato
EgtEnableModified()
@@ -154,7 +91,7 @@ Public Class SplitPageUC
' Reset flag tipo uscita
m_bToNext = False
' Abilitazione bottone Next
EnableNextButton()
EnableButtons()
End Sub
Private Sub MachiningLsBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles MachiningLsBx.SelectionChanged
@@ -217,13 +154,13 @@ Public Class SplitPageUC
m_MachiningList(nI).m_bEnabled = True
SelItem.bIsActive = True
End If
ColorMachining(nI)
ColorMachining(m_MachiningList(nI))
ColorNumber(nI)
EgtDraw()
' Imposto flag di modifica
m_bModified = True
' Abilitazione bottone Next
EnableNextButton()
EnableButtons()
End Sub
Private Sub AllOnBtn_Click(sender As Object, e As RoutedEventArgs) Handles AllOnBtn.Click
@@ -231,7 +168,7 @@ Public Class SplitPageUC
If Not m_MachiningList(nI).m_bEnabled Then
m_MachiningList(nI).m_bEnabled = True
m_ItemList(nI).bIsActive = True
ColorMachining(nI)
ColorMachining(m_MachiningList(nI))
ColorNumber(nI)
End If
Next
@@ -239,7 +176,7 @@ Public Class SplitPageUC
' Imposto flag di modifica
m_bModified = True
' Abilitazione bottone Next
EnableNextButton()
EnableButtons()
End Sub
Private Sub AllOffBtn_Click(sender As Object, e As RoutedEventArgs) Handles AllOffBtn.Click
@@ -247,7 +184,7 @@ Public Class SplitPageUC
If m_MachiningList(nI).m_bEnabled Then
m_MachiningList(nI).m_bEnabled = False
m_ItemList(nI).bIsActive = False
ColorMachining(nI)
ColorMachining(m_MachiningList(nI))
ColorNumber(nI)
End If
Next
@@ -255,7 +192,7 @@ Public Class SplitPageUC
' Imposto flag di modifica
m_bModified = True
' Abilitazione bottone Next
EnableNextButton()
EnableButtons()
End Sub
Private Sub CutBtn_Click(sender As Object, e As RoutedEventArgs) Handles CutBtn.Click
@@ -264,11 +201,11 @@ Public Class SplitPageUC
Return
End If
Dim nI As Integer = SelItem.Ind
If m_MachiningList(nI).m_bCanAllStart And m_MachiningList(nI).m_bCanAllEnd Then
If m_MachiningList(nI).m_bCanStartAll And m_MachiningList(nI).m_bCanEndAll Then
EgtSetCurrMachining(m_MachiningList(nI).m_nId)
Dim nLiPrev As Integer
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev)
If m_MachiningList(nI).m_bAllStart Or m_MachiningList(nI).m_bAllEnd Then
If m_MachiningList(nI).m_bStartAll Or m_MachiningList(nI).m_bEndAll Then
' accorcio
If nLiPrev = MCH_SAW_LI.EXT_OUT Then
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.OUT)
@@ -277,8 +214,8 @@ Public Class SplitPageUC
End If
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT)
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
m_MachiningList(nI).m_bAllStart = False
m_MachiningList(nI).m_bAllEnd = False
m_MachiningList(nI).m_bStartAll = False
m_MachiningList(nI).m_bEndAll = False
Else
' allungo
If nLiPrev = MCH_SAW_LI.OUT Then
@@ -288,14 +225,14 @@ Public Class SplitPageUC
End If
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT)
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
m_MachiningList(nI).m_bAllStart = True
m_MachiningList(nI).m_bAllEnd = True
m_MachiningList(nI).m_bStartAll = True
m_MachiningList(nI).m_bEndAll = True
End If
ColorMachining(nI)
ColorMachining(m_MachiningList(nI))
EgtDraw()
End If
' Abilitazione bottone Next
EnableNextButton()
EnableButtons()
End Sub
Private Sub CutStartBtn_Click(sender As Object, e As RoutedEventArgs) Handles CutStartBtn.Click
@@ -304,11 +241,11 @@ Public Class SplitPageUC
Return
End If
Dim nI As Integer = SelItem.Ind
If m_MachiningList(nI).m_bCanAllStart Then
If m_MachiningList(nI).m_bCanStartAll Then
EgtSetCurrMachining(m_MachiningList(nI).m_nId)
Dim nLiPrev As Integer
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev)
If m_MachiningList(nI).m_bAllStart Then
If m_MachiningList(nI).m_bStartAll Then
' accorcio
If nLiPrev = MCH_SAW_LI.EXT_OUT Then
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.OUT)
@@ -316,7 +253,7 @@ Public Class SplitPageUC
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT)
End If
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
m_MachiningList(nI).m_bAllStart = False
m_MachiningList(nI).m_bStartAll = False
Else
' allungo
If nLiPrev = MCH_SAW_LI.OUT Then
@@ -325,13 +262,13 @@ Public Class SplitPageUC
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT)
End If
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
m_MachiningList(nI).m_bAllStart = True
m_MachiningList(nI).m_bStartAll = True
End If
ColorMachining(nI)
ColorMachining(m_MachiningList(nI))
EgtDraw()
End If
' Abilitazione bottone Next
EnableNextButton()
EnableButtons()
End Sub
Private Sub CutEndBtn_Click(sender As Object, e As RoutedEventArgs) Handles CutEndBtn.Click
@@ -340,23 +277,23 @@ Public Class SplitPageUC
Return
End If
Dim nI As Integer = SelItem.Ind
If m_MachiningList(nI).m_bCanAllEnd Then
If m_MachiningList(nI).m_bCanEndAll Then
EgtSetCurrMachining(m_MachiningList(nI).m_nId)
If m_MachiningList(nI).m_bAllEnd Then
If m_MachiningList(nI).m_bEndAll Then
' accorcio
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT)
m_MachiningList(nI).m_bAllEnd = False
m_MachiningList(nI).m_bEndAll = False
Else
' allungo
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT)
m_MachiningList(nI).m_bAllEnd = True
m_MachiningList(nI).m_bEndAll = True
End If
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
ColorMachining(nI)
ColorMachining(m_MachiningList(nI))
EgtDraw()
End If
' Abilitazione bottone Next
EnableNextButton()
EnableButtons()
End Sub
Private Sub OutCenStartBtn_Click(sender As Object, e As RoutedEventArgs) Handles OutCenStartBtn.Click
@@ -394,7 +331,7 @@ Public Class SplitPageUC
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
ModifyOtherLeadIn(nI, MCH_SAW_LI.OUT)
End If
ColorMachining(nI)
ColorMachining(m_MachiningList(nI))
ColorNumber(nI)
EgtDraw()
' Imposto flag di modifica
@@ -420,7 +357,7 @@ Public Class SplitPageUC
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
ModifyOtherLeadIn(nI, MCH_SAW_LI.OUT)
End If
ColorMachining(nI)
ColorMachining(m_MachiningList(nI))
ColorNumber(nI)
Next
EgtDraw()
@@ -446,7 +383,7 @@ Public Class SplitPageUC
UpdateMachiningPreview(m_MachiningList(nI).m_nId, True)
ModifyOtherLeadIn(nI, MCH_SAW_LI.CENT)
End If
ColorMachining(nI)
ColorMachining(m_MachiningList(nI))
ColorNumber(nI)
Next
EgtDraw()
@@ -454,6 +391,14 @@ Public Class SplitPageUC
m_bModified = True
End Sub
Private Sub PrevBtn_Click(sender As Object, e As RoutedEventArgs) Handles PrevBtn.Click
ExitSplit(False)
' Elimino la fase corrente
RemoveLastPhase()
' Reimposto la precedente
SplitPageUC_Loaded(Nothing, Nothing)
End Sub
Private Sub NextBtn_Click(sender As Object, e As RoutedEventArgs) Handles NextBtn.Click
m_bToNext = True
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC.m_SplitPage)
@@ -461,26 +406,37 @@ Public Class SplitPageUC
m_MainWindow.m_CadCutPageUC.m_CadCutMode = CadCutPageUC.CadCutModes.MoveRawPart
End Sub
Private Sub AutoBtn_Click(sender As Object, e As RoutedEventArgs) Handles AutoBtn.Click
' Con movimento manuale, non disponibile movimento automatico
If m_bByHand Then Return
' Elimino evidenziazione e numerazione
RemoveMarkAndNumbers()
' Calcolo automatico
Dim bFinished As Boolean = False
Dim bOk As Boolean = CalculateOnePhaseSplitAuto(bFinished)
If Not bOk Then
m_MainWindow.m_CurrentProjectPageUC.SetWarningMessage("Calcolo automatico non riuscito") 'Calcolo automatico non riuscito
End If
' Ricarico
SplitPageUC_Loaded(Nothing, Nothing)
End Sub
Private Sub SplitPageUC_Unloaded(sender As Object, e As EventArgs) Handles Me.Unloaded
ExitSplit()
ExitSplit(Not m_bToNext)
EgtDraw()
End Sub
Friend Sub ExitSplit()
' cancello evidenziazione
If m_CurrInd >= 0 Then
MarkMachining(m_CurrInd, False)
m_CurrInd = -1
End If
' cancello gruppo di numerazione e ripristino colori lavorazioni
Friend Sub ExitSplit(Optional bTrueExit As Boolean = True)
' Rimuovo evidenziazione e numeri
RemoveMarkAndNumbers()
' Ripristino colori lavorazioni
EgtDisableModified()
EgtErase(m_nNbrGrpId)
For i As Integer = 1 To m_MachiningList.Count()
ColorMachining(i - 1, True)
For i As Integer = 0 To m_MachiningList.Count() - 1
ColorMachining(m_MachiningList(i), True)
Next
EgtEnableModified()
' se modificato salvo ordine e stato delle lavorazioni
If m_bModified Or Not m_bToNext Then
If m_bModified Or bTrueExit Then
' Al primo posto deve rimanere la disposizione della fase
Dim nFirstOperId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
For i = m_ItemList.Count() - 1 To 0 Step -1
@@ -502,21 +458,20 @@ Public Class SplitPageUC
Dim dReducedDepth As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_REDUCEDDEPTH, 1, m_MainWindow.GetMachIniFile())
' Restringo o rialzo lavorazioni abilitate ma con interferenza
Dim bModified As Boolean = False
For Each Mach As Machining In m_MachiningList
For Each Mach As SplitMach In m_MachiningList
If Mach.m_bEnabled And Mach.m_nInterf <> FMI_TYPE.NONE Then
If AdjustMachining(Mach.m_nId, Mach.m_nInterf, dReducedDepth) Then
bModified = True
End If
End If
Next
If Not m_bToNext Then
If bTrueExit Then
' ritorno a fase 1
EgtSetCurrPhase(1)
End If
If bModified Then
m_MainWindow.m_CurrentProjectPageUC.SetWarningMessage(EgtMsg(90321)) 'Ridotte alcune lavorazioni per evitare interferenze
End If
EgtDraw()
End Sub
Friend Function GetDisabledCutsCount() As Integer
@@ -535,7 +490,7 @@ Public Class SplitPageUC
Dim nCount As Integer = 0
For nI As Integer = 0 To m_MachiningList.Count() - 1
If m_MachiningList(nI).m_bEnabled And
(m_MachiningList(nI).m_bAllStart Or m_MachiningList(nI).m_bAllEnd) Then
(m_MachiningList(nI).m_bStartAll Or m_MachiningList(nI).m_bEndAll) Then
nCount += 1
End If
Next
@@ -547,7 +502,7 @@ Public Class SplitPageUC
Dim nCount As Integer = 0
For nI As Integer = 0 To m_MachiningList.Count() - 1
If m_MachiningList(nI).m_bEnabled And
(m_MachiningList(nI).m_bAllStart Or m_MachiningList(nI).m_bAllEnd) Then
(m_MachiningList(nI).m_bStartAll Or m_MachiningList(nI).m_bEndAll) Then
nCount += 1
End If
Next
@@ -556,7 +511,7 @@ Public Class SplitPageUC
Dim nInd As Integer = 0
For nI As Integer = 0 To m_MachiningList.Count() - 1
If m_MachiningList(nI).m_bEnabled And
(m_MachiningList(nI).m_bAllStart Or m_MachiningList(nI).m_bAllEnd) Then
(m_MachiningList(nI).m_bStartAll Or m_MachiningList(nI).m_bEndAll) Then
MyCuts(nInd) = m_MachiningList(nI).m_nId
nInd += 1
End If
@@ -565,7 +520,10 @@ Public Class SplitPageUC
Cuts = MyCuts
End Sub
Private Sub EnableNextButton()
Private Sub EnableButtons()
' Per bottone PREV
PrevBtn.IsEnabled = (m_nCurrPhase > 1)
' Per bottone NEXT
' Se abilitato manipolatore
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.MAN_MANIP) Or
m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.AUTO_MANIP) Then
@@ -581,10 +539,12 @@ Public Class SplitPageUC
Else
NextBtn.IsEnabled = False
End If
' Per bottone AUTO
AutoBtn.IsEnabled = ((GetDisabledCutsCount() > 0 Or m_nCurrPhase = 1) And Not m_bByHand)
End Sub
Private Function ModifyOtherLeadIn(nI As Integer, nLiOthType As Integer) As Boolean
' Modifico l'attacco dell lavorazioni inglobate
' Modifico l'attacco delle lavorazioni inglobate
For Each nMchId As Integer In m_MachiningList(nI).m_vOthId
EgtSetCurrMachining(nMchId)
EgtSetMachiningParam(MCH_MP.LEADINTYPE, nLiOthType)
@@ -680,56 +640,6 @@ Public Class SplitPageUC
End If
End Sub
Private Sub ColorMachining(nI As Integer, Optional bReset As Boolean = False)
If nI < 0 Then Return
' Assegno stato
'Dim bEnabled As Boolean = If(bReset, True, m_MachiningList(nI).m_bEnabled)
Dim bEnabled As Boolean = m_MachiningList(nI).m_bEnabled
Dim nInterf As Integer = If(bReset, FMI_TYPE.NONE, m_MachiningList(nI).m_nInterf)
' Colore della lavorazione principale
ColorSingleMachining(m_MachiningList(nI).m_nId, bEnabled, nInterf)
' Colore delle lavorazioni inglobate
For Each nId As Integer In m_MachiningList(nI).m_vOthId
ColorSingleMachining(nId, bEnabled, nInterf)
Next
End Sub
Private Sub ColorSingleMachining(nOperId As Integer, bEnabled As Boolean, nInterf As Integer)
' Recupero il preview della lavorazione
Dim nPvId As Integer = GDB_ID.NULL
EgtGetInfo(EgtGetFirstNameInGroup(nOperId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId)
' Cambio il colore
Dim nGrpId As Integer = EgtGetFirstGroupInGroup(nPvId)
While nGrpId <> GDB_ID.NULL
Dim nCutId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_CUT)
Dim nPrcId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_PRECUT)
Dim nPocId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_POSTCUT)
Dim nDwnCutId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_CUT)
Dim nDwnPrcId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_PRECUT)
Dim nDwnPocId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_POSTCUT)
If Not bEnabled Then
EgtSetColor(nCutId, COL_MCH_DISABLED)
EgtSetColor(nDwnCutId, COL_MCH_DISABLED)
Dim bFreeStart As Boolean = (nInterf And FMI_TYPE.LI) <> FMI_TYPE.LI
EgtSetColor(nPrcId, If(bFreeStart, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
EgtSetColor(nDwnPrcId, If(bFreeStart, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
Dim bFreeEnd As Boolean = (nInterf And FMI_TYPE.LO) <> FMI_TYPE.LO
EgtSetColor(nPocId, If(bFreeEnd, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
EgtSetColor(nDwnPocId, If(bFreeEnd, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
Else
EgtSetColor(nCutId, COL_MCH_CUT)
EgtSetColor(nDwnCutId, COL_MCH_CUT)
Dim bFreeStart As Boolean = (nInterf And FMI_TYPE.LI) <> FMI_TYPE.LI
EgtSetColor(nPrcId, If(bFreeStart, COL_MCH_FREE, COL_MCH_INTERF))
EgtSetColor(nDwnPrcId, If(bFreeStart, COL_MCH_FREE, COL_MCH_INTERF))
Dim bFreeEnd As Boolean = (nInterf And FMI_TYPE.LO) <> FMI_TYPE.LO
EgtSetColor(nPocId, If(bFreeEnd, COL_MCH_FREE, COL_MCH_INTERF))
EgtSetColor(nDwnPocId, If(bFreeEnd, COL_MCH_FREE, COL_MCH_INTERF))
End If
nGrpId = EgtGetNextGroup(nGrpId)
End While
End Sub
Private Sub ColorNumber(nI As Integer)
If nI < 0 Then Return
If Not m_MachiningList(nI).m_bEnabled And m_MachiningList(nI).m_nInterf = FMI_TYPE.NONE Then
@@ -743,6 +653,21 @@ Public Class SplitPageUC
End If
End Sub
Private Sub RemoveMarkAndNumbers()
' cancello evidenziazione
If m_CurrInd >= 0 Then
MarkMachining(m_CurrInd, False)
m_CurrInd = -1
End If
' cancello gruppo di numerazione e ripristino colori lavorazioni
EgtDisableModified()
EgtErase(m_nNbrGrpId)
For i As Integer = 0 To m_MachiningList.Count() - 1
ColorMachining(m_MachiningList(i), True)
Next
EgtEnableModified()
End Sub
'-----------------------------------------------------------------------------------------------
Private Class NameIdLsBxItem
Implements INotifyPropertyChanged
@@ -798,19 +723,4 @@ Public Class SplitPageUC
End Class
'-----------------------------------------------------------------------------------------------
Private Class Machining
Public m_nId As Integer
Public m_vOthId As New List(Of Integer)
Public m_nType As Integer
Public m_sLay As String
Public m_nNbrId As Integer
Public m_nInterf As Integer
Public m_bCanAllStart As Boolean
Public m_bCanAllEnd As Boolean
Public m_bAllStart As Boolean
Public m_bAllEnd As Boolean
Public m_bEnabled As Boolean
End Class
End Class
+326
View File
@@ -0,0 +1,326 @@
Imports EgtUILib
Module VacuumCups
' Tipo manipolatore con ventosa (0=assente, 1=dietro, 2=laterale)
Private m_nVacType As Integer = 0
' Dati del manipolatore
Private m_nTempId As Integer = GDB_ID.NULL
Private m_nVacId As Integer = GDB_ID.NULL
Private m_nRefId As Integer = GDB_ID.NULL
'-----------------------------------------------------------------------------------------------
Friend Class RawMoveData
Public m_nId As Integer
Public m_vtMove As Vector3d
Public m_vtDelta As Vector3d
Public m_dAngRotDeg As Double
Public m_sCups As String
Sub New()
m_nId = GDB_ID.NULL
m_vtMove = Vector3d.NULL()
m_vtDelta = Vector3d.NULL()
m_dAngRotDeg = 0
m_sCups = String.Empty
End Sub
Sub New(nId As Integer)
m_nId = nId
m_vtMove = Vector3d.NULL()
m_vtDelta = Vector3d.NULL()
m_dAngRotDeg = 0
m_sCups = String.Empty
End Sub
End Class
'-----------------------------------------------------------------------------------------------
Friend Function GetVacuumType() As Integer
Return m_nVacType
End Function
Friend Function GetVacuumId() As Integer
Return m_nVacId
End Function
Friend Function LoadVacuumCups() As Boolean
' Leggo tipo manipolatore con ventosa
m_nVacType = 0
EgtGetInfo(EgtGetHeadId(VACUUM_HEAD), "VacType", m_nVacType)
' Cancello eventuali vecchie ventose
RemoveVacuumCups()
' Identificativo ventose nella macchina
Dim nLayId As Integer = EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), VACUUM_HEAD_LAYOUT)
If nLayId = GDB_ID.NULL Then Return False
' Identificativo riferimento della testa nella macchina
Dim nT1Id As Integer = EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), HEAD_FIRST_EXIT)
If nT1Id = GDB_ID.NULL Then Return False
' Creo gruppo temporaneo in cui copiarli
m_nTempId = EgtCreateGroup(GDB_ID.ROOT)
If m_nTempId = GDB_ID.NULL Then Return False
EgtSetName(m_nTempId, "VacTmp")
EgtSetLevel(m_nTempId, GDB_LV.SYSTEM)
' Eseguo copia in globale
m_nVacId = EgtCopyGlob(nLayId, m_nTempId)
If m_nVacId = GDB_ID.NULL Then Return False
' Nascondo il gruppo ma rendo visibili le curve di contorno delle ventose
EgtSetStatus(m_nVacId, GDB_ST.OFF)
Dim nId As Integer = EgtGetFirstInGroup(m_nVacId)
While nId <> GDB_ID.NULL
Select Case EgtGetType(nId)
Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO
EgtSetStatus(nId, GDB_ST.ON_)
Case Else
EgtSetStatus(nId, GDB_ST.OFF)
End Select
nId = EgtGetNext(nId)
End While
m_nRefId = EgtCopyGlob(nT1Id, m_nVacId)
If m_nRefId = GDB_ID.NULL Then Return False
EgtSetStatus(m_nRefId, GDB_ST.ON_)
Return True
End Function
Friend Function RemoveVacuumCups() As Boolean
' cancello eventuale gruppo per ventose
EgtErase(m_nTempId)
m_nTempId = GDB_ID.NULL
m_nVacId = GDB_ID.NULL
m_nRefId = GDB_ID.NULL
Return True
End Function
Friend Function ResetVacuumCups() As Boolean
' Ripristino posizione e rotazione originali
Dim frOriRef As New Frame3d
EgtFrame(EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), HEAD_FIRST_EXIT), GDB_ID.ROOT, frOriRef)
Dim frCurrRef As New Frame3d
EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef)
EgtMove(m_nVacId, frOriRef.Orig() - frCurrRef.Orig(), GDB_RT.GLOB)
frCurrRef.ToLoc(frOriRef)
Dim dLen, dAngVertDeg, dAngOrizzDeg As Double
frCurrRef.VersX().ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
EgtRotate(m_nVacId, frOriRef.Orig(), frOriRef.VersZ(), -dAngOrizzDeg, GDB_RT.GLOB)
' Ripristino visualizzazione originale
Dim nId As Integer = EgtGetFirstInGroup(m_nVacId)
While nId <> GDB_ID.NULL
Select Case EgtGetType(nId)
Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO
EgtSetStatus(nId, GDB_ST.ON_)
Case Else
EgtSetStatus(nId, GDB_ST.OFF)
End Select
nId = EgtGetNext(nId)
End While
EgtSetStatus(m_nRefId, GDB_ST.ON_)
Return True
End Function
Friend Function PutVacuumCupsOnRaw(nRawId As Integer, ByRef rmData As RawMoveData) As Boolean
' Ripristino posizione originale ventose
ResetVacuumCups()
' Box e baricentro del grezzo (riportato sopra al grezzo)
Dim b3Raw As New BBox3d
GetRawBox(nRawId, b3Raw)
Dim ptRawCen As Point3d
GetRawCenter(nRawId, ptRawCen)
ptRawCen.z += b3Raw.DimZ() / 2
' Se non esiste, creo la regione del kerf del grezzo
Dim nRawRegId = EgtGetFirstNameInGroup(nRawId, NAME_KERF_REGION)
If nRawRegId = GDB_ID.NULL Then
Dim nOutlineId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_KERF)
nRawRegId = EgtCreateSurfFlatRegion(nRawId, nOutlineId)
EgtSetName(nRawRegId, NAME_KERF_REGION)
EgtSetStatus(nRawRegId, GDB_ST.OFF)
End If
' Baricentro della regione di kerf
Dim ptKerfCen As Point3d
EgtCentroid(nRawRegId, GDB_ID.ROOT, ptKerfCen)
' Cerco migliore configurazione di ventose per prendere il grezzo
Const MAX_SEL As Integer = 20
For nI As Integer = 1 To MAX_SEL
' Recupero la configurazione di ventose nI-esima
Dim sCups() As String = Nothing
Dim sCups2() As String = Nothing
If Not GetVacuumCupSelection(nI, sCups, sCups2) Then Return False
' Determino validità soluzioni della configurazione
Dim vtMove As New Vector3d
Dim ptRotCen As New Point3d
Dim dRotAngDeg As Double = 0
Dim vtMove2 As New Vector3d
Dim ptRotCen2 As New Point3d
Dim dRotAngDeg2 As Double = 0
Dim dDist = TestVacuumCupSelection(sCups, b3Raw, ptKerfCen, nRawRegId, vtMove, ptRotCen, dRotAngDeg)
Dim dDist2 = TestVacuumCupSelection(sCups2, b3Raw, ptKerfCen, nRawRegId, vtMove2, ptRotCen2, dRotAngDeg2)
If dDist > INFINITO - 1 And dDist2 > INFINITO - 1 Then Continue For
If dDist2 < dDist Then
sCups = sCups2
vtMove = vtMove2
ptRotCen = ptRotCen2
dRotAngDeg = dRotAngDeg2
End If
' Eseguo il movimento
EgtMove(m_nVacId, vtMove, GDB_RT.GLOB)
EgtRotate(m_nVacId, ptRotCen, Vector3d.Z_AX(), dRotAngDeg, GDB_RT.GLOB)
' Visualizzo le ventose
For nJ As Integer = 0 To sCups.Length() - 1
Dim nCupId = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ))
EgtSetStatus(nCupId, GDB_ST.ON_)
Next
' Calcolo delta posizione
Dim frCurrRef As New Frame3d
EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef)
Dim vtDelta As Vector3d = frCurrRef.Orig() - ptRawCen
' Assegno dati noti al movimento del grezzo
rmData.m_nId = nRawId
rmData.m_vtMove = Vector3d.NULL()
rmData.m_vtDelta = vtDelta
rmData.m_dAngRotDeg = dRotAngDeg
Dim sVal As String = String.Empty
For Each sCup As String In sCups
If String.IsNullOrEmpty(sVal) Then
sVal &= sCup
Else
sVal &= "," & sCup
End If
Next
rmData.m_sCups = sVal
Return True
Next
Return False
End Function
Private Function GetVacuumCupSelection(nInd As Integer, ByRef sCups() As String, ByRef sCups2() As String) As Boolean
' Recupero elenco ventose nella soluzione
Dim sSel As String = "Sel" & nInd.ToString()
Dim sVal As String = String.Empty
If Not EgtGetInfo(m_nVacId, sSel, sVal) Then Return False
If sVal.IndexOf("/") >= 0 Then
Dim sSplit() As String = sVal.Split("/".ToCharArray)
If sSplit.Length() >= 2 Then
sCups = sSplit(0).Split(",".ToCharArray)
sCups2 = sSplit(1).Split(",".ToCharArray)
ElseIf sSplit.Length() >= 1 Then
sCups = sSplit(0).Split(",".ToCharArray)
sCups2 = Nothing
Else
sCups = Nothing
sCups2 = Nothing
End If
Else
sCups = sVal.Split(",".ToCharArray)
sCups2 = Nothing
End If
Return True
End Function
Private Function TestVacuumCupSelection(sCups() As String, b3Raw As BBox3d, ptRawCen As Point3d, nRawRegId As Integer,
ByRef vtMove As Vector3d, ByRef ptRotCen As Point3d, ByRef dRotAngDeg As Double) As Double
' Se definizione mancante, scarto soluzione
If IsNothing(sCups) Then Return INFINITO
' Ne calcolo il box
Dim b3Vac As New BBox3d
For nJ As Integer = 0 To sCups.Length() - 1
Dim nCupId = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ))
Dim b3Cup As New BBox3d
If EgtGetBBoxGlob(nCupId, GDB_BB.STANDARD, b3Cup) Then b3Vac.Add(b3Cup)
Next
If b3Vac.IsEmpty() Then Return INFINITO
' Se box maggiore di quello del pezzo, scarto soluzione
If Not ((b3Vac.DimX() < b3Raw.DimX() And b3Vac.DimY() < b3Raw.DimY()) Or
(b3Vac.DimX() < b3Raw.DimY() And b3Vac.DimY() < b3Raw.DimX())) Then
Return INFINITO
End If
' Determino il movimento
vtMove = ptRawCen - b3Vac.Center()
b3Vac.Move(vtMove)
' Determino la rotazione, allineando il lato lungo delle ventose con quello del grezzo
ptRotCen = b3Vac.Center()
dRotAngDeg = 0
If (b3Vac.DimX() >= b3Vac.DimY() And b3Raw.DimX() < b3Raw.DimY()) Or
(b3Vac.DimX() < b3Vac.DimY() And b3Raw.DimX() >= b3Raw.DimY()) Then
dRotAngDeg = 90
End If
' Identificativi delle ventose
Dim nCups(sCups.Length() - 1) As Integer
For nJ As Integer = 0 To sCups.Length() - 1
nCups(nJ) = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ))
Next
' Eseguo verifica delle ventose rispetto al grezzo
Dim bVacOk As Boolean = True
If Not TestVacuumCups(nCups, nRawRegId, vtMove, ptRotCen, dRotAngDeg) Then
' Provo ad aggiungere rotazione di + 45
dRotAngDeg += 45
If Not TestVacuumCups(nCups, nRawRegId, vtMove, ptRotCen, dRotAngDeg) Then
' Provo ad aggiungere rotazione di - 45
dRotAngDeg -= 90
If Not TestVacuumCups(nCups, nRawRegId, vtMove, ptRotCen, dRotAngDeg) Then
bVacOk = False
End If
End If
End If
If Not bVacOk Then Return INFINITO
' Recupero riferimento della testa ventose
Dim frCurrRef As New Frame3d
EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef)
Dim ptRef As Point3d = frCurrRef.Orig()
' Applico movimento e rotazione al punto
ptRef.Move(vtMove)
ptRef.Rotate(ptRotCen, Vector3d.Z_AX(), dRotAngDeg)
' Ne calcolo la distanza dal centro della tavola
Dim b3Tab As New BBox3d
EgtGetTableArea(1, b3Tab)
Dim dDist As Double = Point3d.DistXY(ptRef, b3Tab.Center())
Return dDist
End Function
Private Function TestVacuumCups(nCups() As Integer, nRawRegId As Integer,
vtMove As Vector3d, ptRotCen As Point3d, dRotAngDeg As Double) As Boolean
' Eseguo verifica delle ventose rispetto al grezzo
Dim bVacOk As Boolean = True
For nJ As Integer = 0 To nCups.Length() - 1
Dim nCupId = nCups(nJ)
' Eseguo rototraslazione delle ventose per verificare se sono contenute nel grezzo
EgtMove(nCupId, vtMove, GDB_RT.GLOB)
EgtRotate(nCupId, ptRotCen, Vector3d.Z_AX(), dRotAngDeg, GDB_RT.GLOB)
' Confronto le regioni
If EgtSurfFrChunkSimpleClassify(nRawRegId, 0, nCupId, 0) <> REGC.IN2 Then bVacOk = False
' Annullo rototraslazione
EgtRotate(nCupId, ptRotCen, Vector3d.Z_AX(), -dRotAngDeg, GDB_RT.GLOB)
EgtMove(nCupId, -vtMove, GDB_RT.GLOB)
' Se verifica fallita, esco dal ciclo
If Not bVacOk Then Exit For
Next
Return bVacOk
End Function
Friend Function SaveMoveInfoInDisposition(nDispId As Integer, rmData As RawMoveData) As Boolean
' Verifico DispId
If EgtGetOperationType(nDispId) <> MCH_OY.DISP Then Return False
' Creo il gruppo
Dim nRpmId As Integer = EgtCreateGroup(nDispId)
If nRpmId = GDB_ID.NULL Then Return False
EgtSetName(nRpmId, "Rpm" & rmData.m_nId.ToString())
' Assegno le informazioni
Dim sInfo As String = String.Empty
sInfo = rmData.m_nId.ToString()
EgtSetInfo(nRpmId, "Id", sInfo)
sInfo = DoubleToString(rmData.m_vtMove.x, 4) & "," &
DoubleToString(rmData.m_vtMove.y, 4) & "," &
DoubleToString(rmData.m_vtMove.z, 4)
EgtSetInfo(nRpmId, "Mv", sInfo)
sInfo = DoubleToString(rmData.m_vtDelta.x, 4) & "," &
DoubleToString(rmData.m_vtDelta.y, 4) & "," &
DoubleToString(rmData.m_vtDelta.z, 4)
EgtSetInfo(nRpmId, "Dt", sInfo)
sInfo = DoubleToString(rmData.m_dAngRotDeg, 4)
EgtSetInfo(nRpmId, "Ad", sInfo)
sInfo = rmData.m_sCups
EgtSetInfo(nRpmId, "Vc", sInfo)
sInfo = GetVacuumType().ToString()
EgtSetInfo(nRpmId, "Vt", sInfo)
Return True
End Function
End Module