831 lines
34 KiB
VB.net
831 lines
34 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class MoveRawModeVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Fase corrente
|
|
Private m_nCurrPhase As Integer = 0
|
|
' Gestione movimento manuale perpendicolare
|
|
Private m_vtDir As New Vector3d ' direzione di movimento
|
|
Private m_ptMid As New Point3d ' punto medio del taglio
|
|
Private m_dOrigDist As Double = 0 ' distanza iniziale (spessore taglio)
|
|
Private m_dCurrDist As Double = 0 ' distanza corrente
|
|
' Gestione movimento con ventose
|
|
Private m_bRemovedRaw As Boolean = False ' flag per rimozione manuale pezzi
|
|
Private m_RawMoveDataList As New List(Of RawMoveData) ' dati di movimento
|
|
Private m_bRawWithCups As Boolean = False ' flag per pezzo corrente con ventose
|
|
Private m_CurrRawOnVacuum As Integer = GDB_ID.NULL ' identificativo pezzo correntemente attaccato alle ventose
|
|
|
|
Private m_dMoveStep As Double
|
|
Public Property MoveStep As String
|
|
Get
|
|
Return LenToString(m_dMoveStep, 2)
|
|
End Get
|
|
Set(value As String)
|
|
StringToLen(value, m_dMoveStep)
|
|
End Set
|
|
End Property
|
|
|
|
Private m_dRotationStep As Double
|
|
Public Property RotationStep As String
|
|
Get
|
|
Return DoubleToString(m_dRotationStep, 2)
|
|
End Get
|
|
Set(value As String)
|
|
StringToDouble(value, m_dRotationStep)
|
|
End Set
|
|
End Property
|
|
|
|
Private m_MoveRawModeIsEnabled As Boolean
|
|
Public Property MoveRawModeIsEnabled As Boolean
|
|
Get
|
|
Return m_MoveRawModeIsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_MoveRawModeIsEnabled = value
|
|
NotifyPropertyChanged("MoveRawModeIsEnabled")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_LRArrowVisibility As Visibility
|
|
Public Property LRArrowVisibility As Visibility
|
|
Get
|
|
Return m_LRArrowVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
If value <> m_LRArrowVisibility Then
|
|
m_LRArrowVisibility = value
|
|
NotifyPropertyChanged("LRArrowVisibility")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_RotationVisibility As Visibility
|
|
Public Property RotationVisibility As Visibility
|
|
Get
|
|
Return m_RotationVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
If value <> m_RotationVisibility Then
|
|
m_RotationVisibility = value
|
|
NotifyPropertyChanged("RotationVisibility")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property RemoveMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_MOVERAWPAGEUC + 1) ' Rimuovi
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' Definizione comandi
|
|
Private m_cmdUp As ICommand
|
|
Private m_cmdLeft As ICommand
|
|
Private m_cmdRight As ICommand
|
|
Private m_cmdDown As ICommand
|
|
Private m_cmdCcwRot As ICommand
|
|
Private m_cmdCwRot As ICommand
|
|
Private m_cmdRemovePart As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in OmagOFFICEMap
|
|
OmagOFFICEMap.SetRefMoveRawModeVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Function InitMoveRaw() As Boolean
|
|
'' verifico che il pezzo sia depositabile
|
|
'If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then
|
|
' ' mantengo la selezione del pezzo
|
|
' EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL)
|
|
' OmagOFFICEMap.refStatusBarVM.SetOutputMessage("Collisione pezzi", 3, MSG_TYPE.ERROR_)
|
|
' EgtDraw()
|
|
' ' non cambio pagina
|
|
' Return False
|
|
'End If
|
|
' resetto l'inidice del pezzo da mnovimentare
|
|
m_CurrRawOnVacuum = GDB_ID.NULL
|
|
' Deseleziono tutto
|
|
EgtDeselectAll()
|
|
' Recupero i tagli allungati prima definiti
|
|
Dim Cuts(0) As Integer
|
|
OmagOFFICEMap.refSplitModeVM.GetEnabledCuts(Cuts)
|
|
' Fase precedente
|
|
Dim nPrevPhase As Integer = EgtGetCurrPhase()
|
|
If Not OmagOFFICEMap.refMachiningTabVM.IsShow Then
|
|
' Creo nuova fase, eseguo spezzatura grezzi e vi sposto le lavorazioni
|
|
Dim vNewRaws As New List(Of Integer)
|
|
SplitRawParts(nPrevPhase, Cuts, vNewRaws)
|
|
Else
|
|
EgtSetCurrPhase(nPrevPhase + 1)
|
|
HideAllMachinings()
|
|
End If
|
|
m_nCurrPhase = EgtGetCurrPhase()
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
' Carico i parametri di movimento
|
|
m_dMoveStep = GetMainPrivateProfileDouble(S_RAWMOVE, K_RAWSTEP, 50)
|
|
NotifyPropertyChanged("MoveStep")
|
|
m_dRotationStep = GetMainPrivateProfileDouble(S_RAWMOVE, K_RAWROTATION, 30)
|
|
NotifyPropertyChanged("RotationStep")
|
|
' Se movimento manuale perpendicolare
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
' Se esiste taglio passante determino direzione di movimento
|
|
If Cuts.Length() > 0 Then
|
|
' recupero taglio di separazione
|
|
Dim nCutId As Integer = Cuts(0)
|
|
' recupero linea di base del taglio
|
|
EgtSetCurrMachining(nCutId)
|
|
' Recupero la prima entità geometrica della lavorazione
|
|
Dim nEntId, nSub As Integer
|
|
If EgtGetMachiningGeometry(0, nEntId, nSub) Then
|
|
' Direzione perpendicolare al taglio
|
|
EgtStartVector(nEntId, GDB_ID.ROOT, m_vtDir)
|
|
m_vtDir.Rotate(Vector3d.Z_AX(), 90)
|
|
' Punto medio del taglio
|
|
EgtMidPoint(nEntId, GDB_ID.ROOT, m_ptMid)
|
|
' Recupero il preview della lavorazione
|
|
Dim nPvId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(EgtGetFirstNameInGroup(nCutId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId)
|
|
' Recupero la larghezza del taglio
|
|
Dim nGrpId As Integer = EgtGetFirstGroupInGroup(nPvId)
|
|
If Not EgtGetInfo(nGrpId, "WT", m_dOrigDist) Then
|
|
m_dOrigDist = 4
|
|
End If
|
|
' Distanza iniziale
|
|
m_dCurrDist = 0
|
|
End If
|
|
' Non dovrebbe mai accadere, ma inizializzo con default
|
|
Else
|
|
m_vtDir = Vector3d.Y_AX()
|
|
m_ptMid = Point3d.ORIG()
|
|
m_dOrigDist = 0
|
|
m_dCurrDist = 0
|
|
End If
|
|
' Altrimenti movimento con ventose
|
|
Else
|
|
m_bRemovedRaw = False
|
|
m_bRawWithCups = False
|
|
' Pulisco lista info per grezzi
|
|
m_RawMoveDataList.Clear()
|
|
m_RawMoveDataList.Capacity() = 10
|
|
' Se solo visualizzazione carico i movimenti già fatti nella fase
|
|
If Not OmagOFFICEMap.refMachiningTabVM.IsShow Then
|
|
Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
GetMoveInfoInDisposition(nDispId, m_RawMoveDataList)
|
|
End If
|
|
End If
|
|
' Aggiorno interfaccia per taglio perpendicolare
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
LRArrowVisibility = Visibility.Hidden
|
|
RotationVisibility = Visibility.Hidden
|
|
' Altrimenti per movimento con ventose
|
|
Else
|
|
LRArrowVisibility = Visibility.Visible
|
|
RotationVisibility = If(CurrentMachine.bRawSplMovRotate, Visibility.Visible, Visibility.Hidden)
|
|
End If
|
|
' Ritorno a precedente sempre abilitato
|
|
OmagOFFICEMap.refMachiningTabVM.PrevIsEnabled = True
|
|
' Gestione abilitazione altri bottoni
|
|
EnableButtons()
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function ExitMoveRaw() As Boolean
|
|
' verifico che il pezzo sia depositabile
|
|
If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then
|
|
' mantengo la selezione del pezzo
|
|
EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage("Collisione pezzi", 3, MSG_TYPE.ERROR_)
|
|
EgtDraw()
|
|
' non cambio pagina
|
|
Return False
|
|
End If
|
|
' resetto l'inidice del pezzo da mnovimentare
|
|
m_CurrRawOnVacuum = GDB_ID.NULL
|
|
' Deseleziono tutto
|
|
EgtDeselectAll()
|
|
' Se movimento con ventose
|
|
If Not OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
' nascondo le ventose
|
|
EgtDisableModified()
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
EgtEnableModified()
|
|
' se non solo visualizzazione
|
|
If Not OmagOFFICEMap.refMachiningTabVM.IsShow Then
|
|
' recupero disposizione fase corrente
|
|
Dim nDispId As Integer = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
' aggiungo al gruppo disposizione dei sottogruppi con i dati di movimento dei grezzi spostati
|
|
SaveMoveInfoInDisposition(nDispId, m_RawMoveDataList)
|
|
' imposto presenza operazioni manuali
|
|
SaveRemoveByHandInDisposition(nDispId, m_bRemovedRaw)
|
|
' Eseguo calcolo speciale dei movimenti
|
|
SpecialApplyDisposition(nDispId, True)
|
|
End If
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Sub ChangeToModify()
|
|
' Elimino le fasi successive alla corrente
|
|
While EgtGetPhaseCount() > m_nCurrPhase
|
|
RemoveLastPhase()
|
|
End While
|
|
' Svuoto gruppo disposizione
|
|
Dim nDispId = EgtGetPhaseDisposition(m_nCurrPhase)
|
|
EgtEmptyGroup(nDispId)
|
|
' Disabilito le lavorazioni della fase corrente e ne nascondo i percorsi utensile
|
|
Dim nOpeId As Integer = EgtGetNextOperation(nDispId)
|
|
While nOpeId <> GDB_ID.NULL
|
|
EgtSetOperationMode(nOpeId, False)
|
|
EgtSetInfo(nOpeId, INFO_MCH_USER_OFF, True)
|
|
EgtSetOperationStatus(nOpeId, False)
|
|
nOpeId = EgtGetNextOperation(nOpeId)
|
|
End While
|
|
' Aggiono abilitazione bottoni
|
|
EnableButtons()
|
|
End Sub
|
|
|
|
Private Sub EnableButtons()
|
|
' Per bottone MODIFY
|
|
OmagOFFICEMap.refMachiningTabVM.ModifyIsEnabled = OmagOFFICEMap.refMachiningTabVM.IsShow
|
|
' Altri bottoni
|
|
MoveRawModeIsEnabled = Not OmagOFFICEMap.refMachiningTabVM.IsShow
|
|
End Sub
|
|
|
|
Friend Sub Refresh(PrevMeasureUnit As MeasureUnitOpt)
|
|
NotifyPropertyChanged("MoveStep")
|
|
End Sub
|
|
|
|
' verifica che la posizione di rialascio sia corretta, altrimenti coreggo il vettore di posizione
|
|
Private Function VerifyReleasdPositionIsValid(ByRef vtMove As Vector3d) As Boolean
|
|
Dim bOk As Boolean = True
|
|
' determino il punto finale dello spostamento
|
|
Dim ptEndPointLift As Point3d = VacuumCups.ptStartPointLift
|
|
ptEndPointLift.x += vtMove.x
|
|
ptEndPointLift.y += vtMove.y
|
|
Dim sInfo As String = String.Empty
|
|
Select Case VacuumCups.VerifyOutOfStrokes(ptEndPointLift, VacuumCups.dDegRotStartAng)
|
|
Case 1
|
|
' extra corsa sulla x-: devo ridurre del valore di extra corsa
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo, 3, MSG_TYPE.WARNING) 'Extracorsa ...
|
|
ptEndPointLift.x -= vtMove.x
|
|
Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo)
|
|
If Math.Abs(dMaxMove - vtMove.x) <= EPS_SMALL * 100 Then
|
|
vtMove.x = 0
|
|
Else
|
|
vtMove.x -= dMaxMove - EPS_SMALL * 100
|
|
End If
|
|
ptEndPointLift.x += vtMove.x
|
|
bOk = False
|
|
Case 2
|
|
' extra corsa sulla x+: devo ridurre del valore di extra corsa
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo, 3, MSG_TYPE.WARNING) 'Extracorsa ...
|
|
ptEndPointLift.x -= vtMove.x
|
|
Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo)
|
|
If Math.Abs(dMaxMove - vtMove.x) <= EPS_SMALL * 100 Then
|
|
vtMove.x = 0
|
|
Else
|
|
vtMove.x -= dMaxMove + EPS_SMALL * 100
|
|
End If
|
|
ptEndPointLift.x += vtMove.x
|
|
bOk = False
|
|
Case 4
|
|
' extra corsa sulla y-
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo, 3, MSG_TYPE.WARNING) 'Extracorsa ...
|
|
ptEndPointLift.y -= vtMove.y
|
|
Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo)
|
|
If Math.Abs(dMaxMove - vtMove.y) <= EPS_SMALL * 100 Then
|
|
vtMove.y = 0
|
|
Else
|
|
vtMove.y -= dMaxMove - EPS_SMALL * 100
|
|
End If
|
|
ptEndPointLift.y += vtMove.y
|
|
bOk = False
|
|
Case 8
|
|
' extra corsa sulla y+
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo, 3, MSG_TYPE.WARNING) 'Extracorsa ...
|
|
ptEndPointLift.y -= vtMove.y
|
|
Dim dMaxMove As Double = VacuumCups.GetExtraStrokeValue(sInfo)
|
|
If Math.Abs(dMaxMove - vtMove.y) <= EPS_SMALL * 100 Then
|
|
vtMove.y = 0
|
|
Else
|
|
vtMove.y -= dMaxMove + EPS_SMALL * 100
|
|
End If
|
|
ptEndPointLift.y += vtMove.y
|
|
bOk = False
|
|
End Select
|
|
' il movimento del pezzo è accettabile, aggiorno le posizione per la verifica dello step successivo
|
|
VacuumCups.ptStartPointLift = ptEndPointLift
|
|
Return bOk
|
|
End Function
|
|
' verifica che la posizione di rialascio sia corretta, altrimenti coreggo l'angolo di posizione
|
|
Private Function VerifyReleasdAngleIsValid(ByRef dAngDeg As Double, ByVal ptCenter As Point3d) As Boolean
|
|
Dim bOk As Boolean = True
|
|
' determino il punto finale dello spostamento
|
|
Dim ptEndPointLift As Point3d = VacuumCups.ptStartPointLift
|
|
Dim dDegRotEndAng As Double = VacuumCups.dDegRotStartAng + dAngDeg
|
|
ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), dAngDeg)
|
|
Dim sInfo As String = String.Empty
|
|
Select Case VacuumCups.VerifyOutOfStrokes(ptEndPointLift, dDegRotEndAng)
|
|
Case 16
|
|
' extra corsa sulla c-
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo, 3, MSG_TYPE.WARNING) 'Extracorsa ...
|
|
ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), -dAngDeg)
|
|
dDegRotEndAng -= dAngDeg
|
|
dAngDeg += VacuumCups.GetExtraStrokeValue(sInfo) + EPS_SMALL
|
|
dDegRotEndAng += dAngDeg
|
|
ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), dAngDeg)
|
|
bOk = False
|
|
Case 34
|
|
' extra corsa sulla c+
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo, 3, MSG_TYPE.WARNING) 'Extracorsa ...
|
|
ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), -dAngDeg)
|
|
dDegRotEndAng -= dAngDeg
|
|
dAngDeg -= VacuumCups.GetExtraStrokeValue(sInfo) + EPS_SMALL
|
|
dDegRotEndAng += dAngDeg
|
|
ptEndPointLift.Rotate(ptCenter, Vector3d.Z_AX(), dAngDeg)
|
|
bOk = False
|
|
End Select
|
|
' il movimento del pezzo è accettabile, aggiorno le posizione per la verifica dello step successivo
|
|
VacuumCups.ptStartPointLift = ptEndPointLift
|
|
VacuumCups.dDegRotStartAng = dDegRotEndAng
|
|
Return bOk
|
|
End Function
|
|
|
|
' Veririfica che il grezzo non entri in colliosione con altri pezzi
|
|
Private Function VerifyCollisionWithOtherRawPart(nIdOnVacumm As Integer) As Boolean
|
|
If nIdOnVacumm = GDB_ID.NULL Then Return False
|
|
' Creo gruppo temporaneo in cui generare le superfici per la veririfica di collisione
|
|
Dim m_nTempId As Integer = EgtCreateGroup(GDB_ID.ROOT)
|
|
If m_nTempId = GDB_ID.NULL Then Return False
|
|
EgtSetName(m_nTempId, "RawTemp")
|
|
Dim nIdActualRawOutLine As Integer = EgtGetFirstNameInGroup(nIdOnVacumm, "RawOutline")
|
|
Dim ActualRawFlatRegion As Integer = EgtCreateSurfFlatRegion(m_nTempId, nIdActualRawOutLine)
|
|
Dim nCurrPhase As Integer = EgtGetCurrPhase()
|
|
Dim nRawGroupId = EgtGetParent(EgtGetFirstRawPart())
|
|
Dim nIdRaw As Integer = EgtGetFirstRawPart()
|
|
' ciclo su tutti i grezzi per veririficare eventuali collisioni
|
|
While nIdRaw <> GDB_ID.NULL
|
|
' verifico la fase del grezzo
|
|
If EgtVerifyRawPartCurrPhase(nIdRaw) And nIdOnVacumm <> nIdRaw Then
|
|
' recupero il contorno del pezzo
|
|
Dim nIdRawOutLine As Integer = EgtGetFirstNameInGroup(nIdRaw, "RawOutline")
|
|
Dim nIdRawFlatRegion As Integer = EgtCreateSurfFlatRegion(m_nTempId, nIdRawOutLine)
|
|
If EgtSurfFrIntersect(nIdRawFlatRegion, ActualRawFlatRegion) Then
|
|
If EgtExistsObj(nIdRawFlatRegion) Then
|
|
EgtErase(m_nTempId)
|
|
' esiste una intersezione delle superfici
|
|
Return True
|
|
End If
|
|
End If
|
|
End If
|
|
nIdRaw = EgtGetNextRawPart(nIdRaw)
|
|
End While
|
|
EgtErase(m_nTempId)
|
|
Return False
|
|
End Function
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "UpCommand"
|
|
|
|
Public ReadOnly Property UpCommand As ICommand
|
|
Get
|
|
If m_cmdUp Is Nothing Then
|
|
m_cmdUp = New Command(AddressOf Up)
|
|
End If
|
|
Return m_cmdUp
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Up(ByVal param As Object)
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
' Se movimento perpendicolare, è allontanamento
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
' Recupero il centro del grezzo
|
|
Dim ptRawCen As Point3d
|
|
EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
' Calcolo la distanza di movimento
|
|
Dim dMove As Double = m_dMoveStep
|
|
If m_dCurrDist < EPS_SMALL Then
|
|
dMove -= m_dOrigDist
|
|
End If
|
|
If (m_vtDir * (ptRawCen - m_ptMid) < 0) Then dMove *= -1
|
|
' Eseguo il movimento
|
|
If EgtMoveRawPart(nRawId, dMove * m_vtDir) Then
|
|
m_dCurrDist += Math.Abs(dMove)
|
|
End If
|
|
' Altrimenti movimento Y +
|
|
Else
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(0, m_dMoveStep, 0)
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
VerifyReleasdPositionIsValid(vtMove)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.ptStartPointLift.y -= vtMove.y
|
|
End If
|
|
Else
|
|
' Pezzo troppo piccolo : non si può muovere
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' UpCommand
|
|
|
|
#Region "LeftCommand"
|
|
|
|
Public ReadOnly Property LeftCommand As ICommand
|
|
Get
|
|
If m_cmdLeft Is Nothing Then
|
|
m_cmdLeft = New Command(AddressOf Left)
|
|
End If
|
|
Return m_cmdLeft
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Left(ByVal param As Object)
|
|
' Solo movimento con ventose
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then Return
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(-m_dMoveStep, 0, 0)
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
VerifyReleasdPositionIsValid(vtMove)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.ptStartPointLift.x -= vtMove.x
|
|
End If
|
|
Else
|
|
' Pezzo troppo piccolo : non si può muovere
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' LeftCommand
|
|
|
|
#Region "RightCommand"
|
|
|
|
Public ReadOnly Property RightCommand As ICommand
|
|
Get
|
|
If m_cmdRight Is Nothing Then
|
|
m_cmdRight = New Command(AddressOf Right)
|
|
End If
|
|
Return m_cmdRight
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Right(ByVal param As Object)
|
|
' Solo movimento con ventose
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then Return
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(m_dMoveStep, 0, 0)
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
VerifyReleasdPositionIsValid(vtMove)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.ptStartPointLift.x -= vtMove.x
|
|
End If
|
|
Else
|
|
' Pezzo troppo piccolo : non si può muovere
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' RightCommand
|
|
|
|
#Region "DownCommand"
|
|
|
|
Public ReadOnly Property DownCommand As ICommand
|
|
Get
|
|
If m_cmdDown Is Nothing Then
|
|
m_cmdDown = New Command(AddressOf Down)
|
|
End If
|
|
Return m_cmdDown
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Down(ByVal param As Object)
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
' Se movimento perpendicolare, è avvicinamento
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
' Se sono già a contatto, non devo fare alcunché
|
|
If m_dCurrDist < EPS_SMALL Then Return
|
|
' Recupero il centro del grezzo
|
|
Dim ptRawCen As Point3d
|
|
EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
' Calcolo la distanza di movimento
|
|
Dim dMove As Double = m_dMoveStep
|
|
If m_dCurrDist < m_dMoveStep Then
|
|
dMove -= m_dOrigDist
|
|
End If
|
|
If (m_vtDir * (ptRawCen - m_ptMid) > 0) Then dMove *= -1
|
|
' Eseguo il movimento
|
|
If EgtMoveRawPart(nRawId, dMove * m_vtDir) Then
|
|
m_dCurrDist -= Math.Abs(dMove)
|
|
End If
|
|
' Altrimenti movimento Y -
|
|
Else
|
|
If m_bRawWithCups Then
|
|
Dim vtMove As New Vector3d(0, -m_dMoveStep, 0)
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
VerifyReleasdPositionIsValid(vtMove)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtMoveRawPart(nRawId, vtMove) Then
|
|
EgtMove(GetVacuumId(), vtMove, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, vtMove, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.ptStartPointLift.y -= vtMove.y
|
|
End If
|
|
Else
|
|
' Pezzo troppo piccolo : non si può muovere
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' DownCommand
|
|
|
|
#Region "CcwRotCommand"
|
|
|
|
Public ReadOnly Property CcwRotCommand As ICommand
|
|
Get
|
|
If m_cmdCcwRot Is Nothing Then
|
|
m_cmdCcwRot = New Command(AddressOf CcwRot)
|
|
End If
|
|
Return m_cmdCcwRot
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub CcwRot(ByVal param As Object)
|
|
' Solo movimento con ventose
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then Return
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
If m_bRawWithCups Then
|
|
Dim dAng As Double = m_dRotationStep
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
' Recupero il centro del grezzo
|
|
Dim ptRawCen As Point3d
|
|
EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
VerifyReleasdAngleIsValid(dAng, ptRawCen)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAng) Then
|
|
EgtRotate(GetVacuumId(), ptRawCen, Vector3d.Z_AX(), dAng, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, dAng, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.ptStartPointLift.Rotate(ptRawCen, Vector3d.Z_AX(), dAng)
|
|
VacuumCups.dDegRotStartAng -= dAng
|
|
End If
|
|
Else
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' CcwRotCommand
|
|
|
|
#Region "CwRotCommand"
|
|
|
|
Public ReadOnly Property CwRotCommand As ICommand
|
|
Get
|
|
If m_cmdCwRot Is Nothing Then
|
|
m_cmdCwRot = New Command(AddressOf CwRot)
|
|
End If
|
|
Return m_cmdCwRot
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub CwRot(ByVal param As Object)
|
|
' Solo movimento con ventose
|
|
If OmagOFFICEMap.refMachiningTabVM.ByHand Then Return
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
If m_bRawWithCups Then
|
|
Dim dAng As Double = -m_dRotationStep
|
|
' ----------- INIZIO verifica di essere entro i limiti macchina -----------
|
|
' Recupero il centro del grezzo
|
|
Dim ptRawCen As Point3d
|
|
EgtGetRawPartCenter(nRawId, ptRawCen)
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
VerifyReleasdAngleIsValid(dAng, ptRawCen)
|
|
' ----------- FINE verifica di essere entro i limiti macchina -----------
|
|
If EgtRotateRawPart(nRawId, Vector3d.Z_AX(), dAng) Then
|
|
EgtRotate(GetVacuumId(), ptRawCen, Vector3d.Z_AX(), dAng, GDB_RT.GLOB)
|
|
AddRawMoveData(nRawId, dAng, m_RawMoveDataList)
|
|
Else
|
|
VacuumCups.ptStartPointLift.Rotate(ptRawCen, Vector3d.Z_AX(), dAng)
|
|
VacuumCups.dDegRotStartAng -= dAng
|
|
End If
|
|
Else
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
nRawId = EgtGetNextSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' CwRotCommand
|
|
|
|
#Region "RemovePartCommand"
|
|
|
|
Public ReadOnly Property RemovePartCommand As ICommand
|
|
Get
|
|
If m_cmdRemovePart Is Nothing Then
|
|
m_cmdRemovePart = New Command(AddressOf RemovePart)
|
|
End If
|
|
Return m_cmdRemovePart
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub RemovePart(ByVal param As Object)
|
|
Dim nRawId As Integer = EgtGetFirstSelectedObj()
|
|
While nRawId <> GDB_ID.NULL
|
|
EgtRemoveRawPartFromCurrPhase(nRawId)
|
|
' Se con ventose
|
|
If Not OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
m_bRemovedRaw = True
|
|
' rimuovo eventuali indicazioni di movimento
|
|
RemoveRawMoveData(nRawId, m_RawMoveDataList)
|
|
' nascondo le ventose
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
' Reset eventuale messaggio
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
End If
|
|
nRawId = EgtGetFirstSelectedObj()
|
|
End While
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' RemovePartCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
#Region "EVENTS"
|
|
|
|
Friend Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs)
|
|
' Verifico di non essere in modalità solo visualizzazione
|
|
If OmagOFFICEMap.refMachiningTabVM.IsShow Then Return
|
|
' Gruppo dei grezzi
|
|
Dim nRawGroupId = EgtGetParent(EgtGetFirstRawPart())
|
|
' Verifico se selezionato indicativo di grezzo attivo
|
|
EgtSetObjFilterForSelWin(True, True, True, True, True)
|
|
Dim nSel As Integer
|
|
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
|
|
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
|
While nId <> GDB_ID.NULL
|
|
' Cerco l'identificativo del grezzo cui appartiene
|
|
Dim nParentId = EgtGetParent(nId)
|
|
While nParentId <> GDB_ID.NULL And nParentId <> nRawGroupId
|
|
nId = nParentId
|
|
nParentId = EgtGetParent(nId)
|
|
End While
|
|
' Se trovato il grezzo
|
|
If nParentId = nRawGroupId Then
|
|
Dim nStat As Integer = GDB_ST.ON_
|
|
' Se il pezzo corrente è selezionato allora lo disattivo -> deposito del pezzo
|
|
EgtGetStatus(nId, nStat)
|
|
If nStat = GDB_ST.SEL Then
|
|
EgtSetStatus(nId, GDB_ST.ON_)
|
|
' prima di rilasciare il pezzo verifico che non vada in collisione con altri pezzi sulla tavola
|
|
If VerifyCollisionWithOtherRawPart(nId) Then
|
|
' mantengo la selezione del pezzo
|
|
EgtSetStatus(nId, GDB_ST.SEL)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(91231), 3, MSG_TYPE.ERROR_) ' Collisione pezzi
|
|
Else
|
|
' Se con ventose, le nascondo
|
|
If Not OmagOFFICEMap.refMachiningTabVM.ByHand Then EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
End If
|
|
|
|
Else
|
|
|
|
' verifico che il pezzo precedente possa essere depositato correttamente
|
|
If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then
|
|
' mantengo la selezione del pezzo
|
|
EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(91231), 3, MSG_TYPE.ERROR_) ' Collisione pezzi
|
|
EgtDraw()
|
|
' esco dal ciclo, prima devo depositare correttamente il pezzo
|
|
Exit While
|
|
End If
|
|
' salvo l'indice del pezzo correntemente attaccato alle ventose
|
|
m_CurrRawOnVacuum = nId
|
|
|
|
EgtDeselectAll()
|
|
EgtSetStatus(nId, GDB_ST.SEL)
|
|
' Se con ventose, le posiziono sul grezzo
|
|
If Not OmagOFFICEMap.refMachiningTabVM.ByHand Then
|
|
Dim rmData As New RawMoveData
|
|
' inizializzo i dati del grezzo per il cacolo del peso
|
|
Dim MaxSinglePlugger As Double = 250
|
|
MaxSinglePlugger = GetPrivateProfileDouble(S_MACH_RAWMOVE, K_MACH_WEIGHT_SINGLEPLUGGER, MaxSinglePlugger, sMachIniFile)
|
|
Dim MaxDoublePlugger As Double = 750
|
|
MaxDoublePlugger = GetPrivateProfileDouble(S_MACH_RAWMOVE, K_MACH_WEIGHT_DOUBLEPLUGGER, MaxDoublePlugger, sMachIniFile)
|
|
Dim AverageDensity As Double = 2700
|
|
AverageDensity = GetPrivateProfileDouble(S_MATERIALS, K_AVERAGEDENSITY, AverageDensity, sMachIniFile)
|
|
VacuumCups.GetWeightInformation(AverageDensity, MaxSinglePlugger, MaxDoublePlugger)
|
|
VacuumCups.GetRotationForExtraStrokeY(GetPrivateProfileInt(S_MACH_RAWMOVE, K_MACH_ROTATEVACUUMFOREXTRASTROKEY, 0, sMachIniFile) <> 0)
|
|
VacuumCups.GetRotationForExtraStrokeX(GetPrivateProfileInt(S_MACH_RAWMOVE, K_MACH_ROTATEVACUUMFOREXTRASTROKEX, 0, sMachIniFile) <> 0)
|
|
If PutVacuumCupsOnRaw(nId, rmData) Then
|
|
' Visualizzo le ventose
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.ON_)
|
|
' Aggiorno i dati
|
|
AddRawMoveData(rmData, m_RawMoveDataList)
|
|
m_bRawWithCups = True
|
|
' Reset eventuale messaggio
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
Else
|
|
' Visualizzo le ventose
|
|
EgtSetStatus(GetVacuumId(), GDB_ST.OFF)
|
|
' Aggiorno i dati
|
|
m_bRawWithCups = False
|
|
If VacuumCups.bOverWeight Then
|
|
' Messaggio di avvertimento (Pezzo troppo piccolo : non si può muovere)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 4), 3, MSG_TYPE.WARNING)
|
|
ElseIf VacuumCups.bExtraStroke Then
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 5), 3, MSG_TYPE.WARNING) 'Pezzo oltre le corse : non si può muovere
|
|
Else
|
|
' Messaggio di avvertimento (Pezzo troppo piccolo : non si può muovere)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_MOVERAWPAGEUC + 2), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
EgtDraw()
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
|
|
' clicco su un oggetto che non è un grezzo -> verifico che il pezzo precedente possa essere depositato correttamente
|
|
If VerifyCollisionWithOtherRawPart(m_CurrRawOnVacuum) Then
|
|
' mantengo la selezione del pezzo
|
|
EgtSetStatus(m_CurrRawOnVacuum, GDB_ST.SEL)
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(91231), 3, MSG_TYPE.ERROR_) ' Collisione pezzi
|
|
EgtDraw()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region ' EVENTS
|
|
|
|
End Class
|