OmagCUT :

- Aggiunti tagli multipli.
- Iniziati tagli griglia.
This commit is contained in:
Emmanuele Sassi
2016-01-11 15:15:16 +00:00
parent 4ba2bb442f
commit 81e801c698
15 changed files with 1683 additions and 100 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ Public Class CadCutPageUC
Private Sub RawPartBtn_Click(sender As Object, e As RoutedEventArgs) Handles RawPartBtn.Click
m_MainWindow.m_CurrentProjectPageUC.CurrProjGrid.Visibility = Windows.Visibility.Hidden
m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC)
m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Remove(Me)
m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_RawPartPage)
m_MainWindow.m_ActivePage = MainWindow.Pages.RawPart
End Sub
+5 -2
View File
@@ -36,13 +36,16 @@
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="4*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<Button Name="ManualBtn" Grid.Column="2" Grid.Row="0" Content="Movimento manuale"
Style="{StaticResource OmagCut_YellowTextButton}"/>
<Button Name="SingleCutBtn" Grid.Row="1" Content="Taglio singolo"
Style="{StaticResource OmagCut_YellowTextButton}"/>
<Button Name="Cut2PBtn" Grid.Row="2" Content="Taglio per due punti"
<Button Name="MultipleCutBtn" Grid.Row="2" Content="Taglio multiplo"
Style="{StaticResource OmagCut_YellowTextButton}"/>
<Button Name="GridCutBtn" Grid.Row="3" Content="Taglio griglia"
Style="{StaticResource OmagCut_YellowTextButton}"/>
</Grid>
</Grid>
+21 -2
View File
@@ -7,6 +7,8 @@ Public Class DirectCutPageUC
Friend m_MachineButtons As MachineButtonsUC
Friend m_ManualAxesMove As ManualAxesMoveUC
Friend m_SingleCut As SingleCutUC
Friend m_MultipleCut As MultipleCut
Friend m_GridCut As GridCut
Friend m_CN As CN_generico
Private m_bFirst As Boolean = True
@@ -17,6 +19,8 @@ Public Class DirectCutPageUC
Enum DirectCutPages
DirectCut
SingleCut
MultipleCut
GridCut
End Enum
Private Sub DirectCutPage_Initialized(sender As Object, e As EventArgs)
@@ -25,12 +29,15 @@ Public Class DirectCutPageUC
m_MachineButtons = New MachineButtonsUC
m_ManualAxesMove = New ManualAxesMoveUC
m_SingleCut = New SingleCutUC
m_MultipleCut = New MultipleCut
m_GridCut = New GridCut
'Posizionemento nella griglia delle Page UserControl
m_MachineButtons.SetValue(Grid.RowProperty, 2)
m_ManualAxesMove.SetValue(Grid.RowProperty, 1)
m_SingleCut.SetValue(Grid.RowProperty, 1)
m_MultipleCut.SetValue(Grid.RowProperty, 1)
m_GridCut.SetValue(Grid.RowProperty, 1)
'Assegno MachineButtons alla pagina
LowerButtonGrid.Children.Add(m_MachineButtons)
@@ -49,12 +56,24 @@ Public Class DirectCutPageUC
m_ActiveDirectCutPage = DirectCutPages.SingleCut
End Sub
Private Sub DirectCutPage_Unloaded(sender As Object, e As RoutedEventArgs)
Private Sub MultipleCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles MultipleCutBtn.Click
LeftButtonGrid.Children.Add(m_MultipleCut)
m_ActiveDirectCutPage = DirectCutPages.MultipleCut
End Sub
Private Sub GridCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles GridCutBtn.Click
LeftButtonGrid.Children.Add(m_GridCut)
m_ActiveDirectCutPage = DirectCutPages.GridCut
End Sub
Friend Sub DirectCutPage_Unloaded(sender As Object, e As RoutedEventArgs)
Select Case m_ActiveDirectCutPage
Case DirectCutPages.DirectCut
' Non è necessario fare alcunché
Case DirectCutPages.SingleCut
LeftButtonGrid.Children.Remove(m_SingleCut)
Case DirectCutPages.MultipleCut
LeftButtonGrid.Children.Remove(m_MultipleCut)
End Select
End Sub
+123
View File
@@ -0,0 +1,123 @@
<UserControl x:Class="GridCut"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:EgtWPFLib="clr-namespace:EgtWPFLib;assembly=EgtWPFLib"
mc:Ignorable="d"
d:DesignHeight="597.3" d:DesignWidth="256">
<!-- Chiamata al Dictionary -->
<UserControl.Resources>
<ResourceDictionary Source="OmagCutDictionary.xaml"/>
</UserControl.Resources>
<Border CornerRadius="{StaticResource Page_CornerRadius}" Background="{StaticResource OmagCut_LightGray}">
<!-- Definizione della Grid MultipleCut -->
<Grid Name="SingleCutGrid" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<ToggleButton Name="Point1Btn" Grid.Column="0" Content="Acquisisci P1"
Style="{StaticResource OmagCut_YellowToggleButton}"/>
<ToggleButton Name="Point2Btn" Grid.Column="1" Content="Acquisisci P2"
Style="{StaticResource OmagCut_YellowToggleButton}"/>
</Grid>
<CheckBox Name="LaserOnChBx" Grid.Row="1" Grid.ColumnSpan="2" Height="40" Width="220" Content="Acquisisci laser" FontSize="22"/>
<TextBlock Name="DepthTxBl" Grid.Column="0" Grid.Row="2"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Affondamento" />
<EgtWPFLib:EgtTextBox Name="DepthTxBx" Grid.Column="1" Grid.Row="2" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<TextBlock Name="LenghtTxBl" Grid.Column="0" Grid.Row="3"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Lunghezza" />
<EgtWPFLib:EgtTextBox Name="LenghtTxBx" Grid.Column="1" Grid.Row="3" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<TextBlock Name="DirectionTxBl" Grid.Column="0" Grid.Row="4"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Direzione" />
<EgtWPFLib:EgtTextBox Name="DirectionTxBx" Grid.Column="1" Grid.Row="4" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<TextBlock Name="SideAngleTxBl" Grid.Column="0" Grid.Row="5"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Inclinazione" />
<EgtWPFLib:EgtTextBox Name="SideAngleTxBx" Grid.Column="1" Grid.Row="5" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<Grid Grid.Row="6" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition Width="2"/>
<ColumnDefinition Width="1.5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<Border Grid.Column="1" Grid.Row="0" Grid.RowSpan="4" Background="Black" />
<TextBlock Name="NumPzTxBl" Grid.Column="0" Grid.Row="0"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Numero" />
<TextBlock Name="DimPzTxBl" Grid.Column="2" Grid.Row="0"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Dimensioni" />
<EgtWPFLib:EgtTextBox Name="NumPz1TxBx" Grid.Column="0" Grid.Row="1" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<EgtWPFLib:EgtTextBox Name="DimPz1TxBx" Grid.Column="2" Grid.Row="1" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<EgtWPFLib:EgtTextBox Name="NumPz2TxBx" Grid.Column="0" Grid.Row="2" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<EgtWPFLib:EgtTextBox Name="DimPz2TxBx" Grid.Column="2" Grid.Row="2" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<EgtWPFLib:EgtTextBox Name="NumPz3TxBx" Grid.Column="0" Grid.Row="3" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<EgtWPFLib:EgtTextBox Name="DimPz3TxBx" Grid.Column="2" Grid.Row="3" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
</Grid>
<CheckBox Name="SideChBx" Grid.Row="7" Grid.ColumnSpan="2" Height="40" Width="220" Content="Tagli lato motore" FontSize="22"/>
<!--<TextBlock Name="SawTipTxBl" Grid.Column="0" Grid.Row="10" Grid.ColumnSpan="2"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text=""/>-->
<Button Name="OkBtn" Grid.Column="0" Grid.Row="11" Style="{StaticResource OmagCut_GradientBlueTextButton}"
Content="Esegui"/>
<Button Name="ExitBtn" Grid.Column="2" Grid.Row="11" Style="{StaticResource OmagCut_YellowIconButton}">
<Image Source="Resources/X.png" Style="{StaticResource OmagCut_ButtonIcon}"/>
</Button>
</Grid>
</Border>
</UserControl>
+549
View File
@@ -0,0 +1,549 @@
Imports EgtUILib
Public Class GridCut
' Riferimenti a pagine
Private m_MainWindow As MainWindow = Application.Current.MainWindow
Private m_CurrProjPage As CurrentProjectPageUC
' Origine tavola e dati grezzo
Private m_bRawOk As Boolean = False
Private m_ptTabOri As Point3d
Private m_ptRawMin As Point3d
Private m_ptRawMax As Point3d
' Parametri P1 acquisito
Private m_bPointP1Ok As Boolean = False
Private m_ptTipP1 As Point3d
Private m_vtToolP1 As Vector3d
' Parametri P2 acquisito
Private m_bPointP2Ok As Boolean = False
Private m_ptTipP2 As Point3d
Private m_vtToolP2 As Vector3d
' Lato di creazione dei tagli
Private m_bCutSide As CutSide = CutSide.Left
' Parametri della lavorazione
Private m_bCutOk As Boolean = False
Private m_dDepth As Double = 0
Private m_dLen As Double = 1000
Private m_dAngO As Double = 180
Private m_dAngV As Double = 0
' Costanti
Private Const MAX_TAB_DEPTH As Double = 10.0
Private Const MIN_CUT_LEN As Double = 10.0
Private Const MAX_SIDE_ANG As Double = 60.0
Private Const DIRECTCUT As String = "DirectCut"
Private Enum CutSide As Integer
Left
Right
End Enum
Private Sub MultipleCut_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
' Reset punto acquisito
m_bPointP1Ok = False
'SawTipTxBl.Text = String.Empty
' Assegno parametri di lavorazione già definiti
DepthTxBx.Text = DoubleToString(m_dDepth, 1)
LenghtTxBx.Text = DoubleToString(m_dLen, 1)
' Origine tavola
m_bRawOk = True
If Not EgtGetTableRef(1, m_ptTabOri) Then
m_bRawOk = False
EgtOutLog("Error on TableRef1")
End If
' Dati del grezzo
If Not m_MainWindow.m_RawPartPage.GetRawBox(m_ptRawMin, m_ptRawMax) Then
m_bRawOk = False
EgtOutLog("Error on RawBox")
End If
' Reset taglio e disabilito bottone esecuzione
m_bCutOk = False
UpdateOkBtn()
' Disabilito bottone secondo punto
Point2Btn.IsEnabled = False
' Deseleziono bottone primo punto
Point1Btn.IsChecked = False
' Disabilito registrazione progetto modificato
EgtDisableModified()
End Sub
Friend Sub MultipleCut_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded
' Rimuovo eventuale pezzo per taglio diretto
EraseDirectCutPart()
' Riattivo eventuali lavorazioni presenti
ActivateAllMachinings()
' Abilito registrazione progetto modificato
EgtEnableModified()
' Nascondo la macchina
EgtShowOnlyTable(True)
EgtDraw()
End Sub
Private Sub UpdateOkBtn()
If m_bCutOk Then
OkBtn.IsEnabled = True
OkBtn.Foreground = Brushes.Black
Else
OkBtn.IsEnabled = False
OkBtn.Foreground = Brushes.DarkGray
End If
End Sub
Private Sub Point1Btn_Click(sender As Object, e As RoutedEventArgs) Handles Point1Btn.Click
' Reset punto non acquisito
m_bPointP1Ok = False
' Verifico configurazione tavola e grezzo
If Not m_bRawOk Then
Return
End If
' Recupero la posizione macchina
Dim dL1, dL2, dL3, dR1, dR2 As Double
If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then
Return
End If
' Ricavo dati lama corrente
Dim sSaw As String = String.Empty
GetPrivateProfileString(S_MACH, K_CURRSAW, "", sSaw, m_MainWindow.GetIniFile())
' Se punto da laser
If LaserOnChBx.IsChecked Then
' Imposto come testa corrente il laser (senza utensile ovviamente)
If Not EgtSetCalcTool("", "H3", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then
Return
End If
' Ora imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Altrimenti da lama
Else
' Imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then
Return
End If
End If
' Calcolo direzione asse lama
If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP1) Then
Return
End If
' Porto il tip nell'origine tavola
m_ptTipP1.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP1Ok = True
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
' Visualizzo macchina in posizione
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
' Visualizzo quote
Dim sSawTip As String = "X" & DoubleToString(m_ptTipP1.x, 0) & " Y" & DoubleToString(m_ptTipP1.y, 0) &
" Z" & DoubleToString(m_ptTipP1.z, 0) & " C" & DoubleToString(dR1, 0) &
" B" & DoubleToString(dR2, 0)
'SawTipTxBl.Text = sSawTip
' Assegno angoli
Dim dTLen, dTAngV, dTAngO As Double
m_vtToolP1.ToSpherical(dTLen, dTAngV, dTAngO)
m_dAngO = dTAngO + 90
m_dAngV = 90 - dTAngV
DirectionTxBx.Text = DoubleToString(m_dAngO, 2)
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Disegno il taglio
CreateMultipleCut()
EgtShowOnlyTable(False)
EgtDraw()
' Seleziono il bottone per indicare che il primo punto è stato acquisito
Point1Btn.IsChecked = True
' Abilito e deseleziono secondo punto
Point2Btn.IsEnabled = True
Point2Btn.IsChecked = False
' Annullo secondo punto selezionato
m_bPointP2Ok = False
End Sub
Private Sub Point2Btn_Click(sender As Object, e As RoutedEventArgs) Handles Point2Btn.Click
' Deseleziono il bottone (poichè si seleziona automaticamente) cos' nel caso ci sia un errore rimane deselezionato
Point2Btn.IsChecked = False
' Reset punto non acquisito
m_bPointP2Ok = False
' Verifico configurazione tavola e grezzo
If Not m_bRawOk Then
Return
End If
' Recupero la posizione macchina
Dim dL1, dL2, dL3, dR1, dR2 As Double
If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then
Return
End If
' Ricavo dati lama corrente
Dim sSaw As String = String.Empty
GetPrivateProfileString(S_MACH, K_CURRSAW, "", sSaw, m_MainWindow.GetIniFile())
' Se punto da laser
If LaserOnChBx.IsChecked Then
' Imposto come testa corrente il laser (senza utensile ovviamente)
If Not EgtSetCalcTool("", "H3", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then
Return
End If
' Ora imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Altrimenti da lama
Else
' Imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then
Return
End If
End If
' Calcolo direzione asse lama
If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP2) Then
Return
End If
' Porto il tip nell'origine tavola
m_ptTipP2.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP2Ok = True
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
' Visualizzo macchina in posizione
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
' Visualizzo quote
Dim sSawTip As String = "X" & DoubleToString(m_ptTipP2.x, 0) & " Y" & DoubleToString(m_ptTipP2.y, 0) &
" Z" & DoubleToString(m_ptTipP2.z, 0) & " C" & DoubleToString(dR1, 0) &
" B" & DoubleToString(dR2, 0)
'SawTipTxBl.Text = sSawTip
' Assegno angolo verticale da direzione utensile
Dim dTLen, dTAngV, dTAngO As Double
m_vtToolP2.ToSpherical(dTLen, dTAngV, dTAngO)
m_dAngV = 90 - dTAngV
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Se il secondo punto non coincide con il primo, disegno il taglio
Dim vtDiff As Vector3d = m_ptTipP2 - m_ptTipP1
vtDiff.z = 0
Dim dLen As Double
Dim dAngVertDeg As Double
Dim dAngOrizzDeg As Double
vtDiff.ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
If dLen > EPS_SMALL Then
LenghtTxBx.Text = DoubleToString(dLen, 1)
m_dAngO = dAngOrizzDeg
DirectionTxBx.Text = DoubleToString(dAngOrizzDeg, 2)
Create2PointsMultipleCut()
EgtShowOnlyTable(False)
EgtDraw()
' Seleziono il bottone per indicare che il secondo punto è stato acquisito
Point2Btn.IsChecked = True
Else
' Deseleziono il bottone per indicare che il secondo punto non è stato acquisito perchè uguale al primo
Point2Btn.IsChecked = False
End If
End Sub
Private Sub DepthTxBx_EgtClosed(sender As Object, e As EventArgs) Handles DepthTxBx.EgtClosed
' Verifico che l'affondamento impostato non sia superiore a quello massimo
Dim dMaxDepth = m_ptRawMax.z - m_ptRawMin.z + MAX_TAB_DEPTH
Dim dDepth As Double = 0
StringToDouble(DepthTxBx.Text, dDepth)
If dDepth < 0 Then
m_dDepth = 0
ElseIf dDepth > dMaxDepth Then
m_dDepth = dMaxDepth
Else
m_dDepth = dDepth
End If
DepthTxBx.Text = DoubleToString(m_dDepth, 2)
' Disegno il taglio
CreateMultipleCut()
EgtDraw()
End Sub
Private Sub LenghtTxBx_EgtClosed(sender As Object, e As EventArgs) Handles LenghtTxBx.EgtClosed
' Verifico che la lunghezza del taglio impostata non sia inferiore a quella minima
Dim dLenght As Double = 0
StringToDouble(LenghtTxBx.Text, dLenght)
If dLenght < MIN_CUT_LEN Then
m_dLen = MIN_CUT_LEN
Else
m_dLen = dLenght
End If
LenghtTxBx.Text = DoubleToString(m_dLen, 2)
' Disegno il taglio
CreateMultipleCut()
EgtDraw()
End Sub
Private Sub DirectionTxBx_EgtClosed(sender As Object, e As EventArgs) Handles DirectionTxBx.EgtClosed
' Assegno il nuovo valore di direzione
Dim dDirection As Double = 0
StringToDouble(DirectionTxBx.Text, dDirection)
m_dAngO = dDirection
' Disegno il taglio
CreateMultipleCut()
EgtDraw()
End Sub
Private Sub SideAngleTxBx_EgtClosed(sender As Object, e As EventArgs) Handles SideAngleTxBx.EgtClosed
' Verifico che l'inclinazione del taglio impostata non sia superiore a quella massima
Dim dSideAngle As Double = 0
StringToDouble(SideAngleTxBx.Text, dSideAngle)
If dSideAngle < 0 Then
m_dAngV = 0
ElseIf dSideAngle > MAX_SIDE_ANG Then
m_dAngV = MAX_SIDE_ANG
Else
m_dAngV = dSideAngle
End If
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Disegno il taglio
CreateMultipleCut()
EgtDraw()
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
' Verifico ci sia un taglio valido
If Not m_bCutOk Then
Return
End If
' Salvo il progetto con le lavorazioni
Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge"
m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath)
' Genero file CNC (lancio anche se errore in precedenza)
Dim sCncPath As String = m_MainWindow.GetCncDir() & "\DirectCut.xpi"
Dim bOk As Boolean = EgtGenerate(sCncPath, "OmagCut")
' Se errore in generazione, segnalo l'errore ed esco
If Not bOk Then
m_CurrProjPage.SetErrorMessage(EgtMsg(90314)) 'Errore nella generazione del programma CN
Return
End If
' Download programma (eventuali errori sono segnalati dalla funzione)
If m_MainWindow.m_CNCommunication.SendProgram(sCncPath, 900) Then
' copio il progetto corrente come progetto in lavorazione
Dim sWrkPath As String = m_MainWindow.GetTempDir() & "\" & "WorkProj.nge"
My.Computer.FileSystem.CopyFile(sMchPath, sWrkPath, True)
End If
End Sub
Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click
m_MainWindow.m_DirectCutPageUC.LeftButtonGrid.Children.Remove(Me)
m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut
End Sub
Private Function CreateMultipleCut() As Boolean
' Verifico sia definito il punto iniziale e il grezzo
If Not m_bPointP1Ok Or Not m_bRawOk Then
m_bCutOk = False
Return False
End If
' Spessore grezzo
Dim dRawHeight As Integer = m_ptRawMax.z - m_ptRawMin.z
' Rimuovo eventuale vecchio pezzo per taglio diretto
EraseDirectCutPart()
' Disattivo eventuali lavorazioni presenti
DeactivateAllMachinings()
' Creo nuovo pezzo per il taglio diretto
Dim nPartId = EgtCreateGroup(GDB_ID.ROOT)
EgtSetName(nPartId, DIRECTCUT)
Dim nLayerId = EgtCreateGroup(nPartId)
EgtSetName(nLayerId, "OutLoop")
' Creo il taglio
Dim ptStart As Point3d = m_ptTipP1
ptStart.z = 0
Dim nCutId = EgtCreateLinePDL(nLayerId, ptStart, m_dAngO, m_dLen)
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutId, "Depth", m_dDepth)
EgtSetInfo(nCutId, "SideAng", m_dAngV)
' Funzione che crea i tagli successivi al primo
MultiplyCut(nLayerId, nCutId)
' Creo layer per crocetta di riferimento
Dim nCrossLayerId = EgtCreateGroup(nPartId)
' Aggiungo crocetta
CreateCross(nCrossLayerId, ptStart)
' Calcolo punto di inserimento nel grezzo
Dim ptMin, ptMax As Point3d
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, ptMin, ptMax)
Dim ptIns As Point3d = ptMin + (m_ptTabOri - m_ptRawMin)
ptIns.z = dRawHeight
' Inserisco il pezzo nel grezzo
EgtAddPartToRawPart(nPartId, ptIns, m_MainWindow.m_CurrentProjectPageUC.m_nRawId)
' Inserisco la lavorazione
m_bCutOk = AddMachinings(nPartId, True, True)
UpdateOkBtn()
Return m_bCutOk
End Function
Private Function Create2PointsMultipleCut() As Boolean
' Verifico siano definiti punto iniziale punto finale e grezzo
If Not m_bPointP1Ok Or Not m_bPointP2Ok Or Not m_bRawOk Then
m_bCutOk = False
Return False
End If
' Spessore grezzo
Dim dRawHeight As Integer = m_ptRawMax.z - m_ptRawMin.z
' Rimuovo eventuale vecchio pezzo per taglio diretto
EraseDirectCutPart()
' Disattivo eventuali lavorazioni presenti
DeactivateAllMachinings()
' Creo nuovo pezzo per il taglio diretto
Dim nPartId = EgtCreateGroup(GDB_ID.ROOT)
EgtSetName(nPartId, DIRECTCUT)
' Creo layer di taglio
Dim nLayerId = EgtCreateGroup(nPartId)
EgtSetName(nLayerId, "OutLoop")
' Creo il taglio
Dim ptStart As Point3d = m_ptTipP1
Dim ptEnd As Point3d = m_ptTipP2
ptStart.z = 0
ptEnd.z = 0
Dim nCutId = EgtCreateLine(nLayerId, ptStart, ptEnd)
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutId, "Depth", m_dDepth)
EgtSetInfo(nCutId, "SideAng", m_dAngV)
' Funzione che crea i tagli successivi al primo
MultiplyCut(nLayerId, nCutId)
' Creo layer per crocette di riferimento
Dim nCrossLayerId = EgtCreateGroup(nPartId)
' Aggiungo crocette
CreateCross(nCrossLayerId, ptStart)
CreateCross(nCrossLayerId, ptEnd)
' Calcolo punto di inserimento nel grezzo
Dim ptMin, ptMax As Point3d
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, ptMin, ptMax)
Dim ptIns As Point3d = ptMin + (m_ptTabOri - m_ptRawMin)
ptIns.z = dRawHeight
' Inserisco il pezzo nel grezzo
EgtAddPartToRawPart(nPartId, ptIns, m_MainWindow.m_CurrentProjectPageUC.m_nRawId)
' Inserisco la lavorazione
m_bCutOk = AddMachinings(nPartId, True, True)
UpdateOkBtn()
Return m_bCutOk
End Function
Private Function MultiplyCut(nLayerId As Integer, nCutId As Integer)
' Recupero spessore della lama correntemente attiva
Dim dThick As Double = 0
EgtTdbGetCurrToolParam(MCH_TP.THICK, dThick)
' Ricalcolo lo spessore della lama in base all'inclinazione
dThick = dThick / Math.Cos(m_dAngV * Math.PI / 180)
' Imposto angolo di rotazione a seconda del lato dei tagli
Dim dRotAngO As Double = If(SideChBx.IsChecked, -90, 90)
'Variabile che contiene la somma degli spostamenti
Dim dTotPerpMove As Vector3d
' Definisco vettore di spostamento
Dim vtDelta As Vector3d
' Calcolo primo vettore di spostamento
Dim dDimPz1 As Double
Dim nNumPz1 As Integer
StringToDouble(DimPz1TxBx.Text, dDimPz1)
StringToDouble(NumPz1TxBx.Text, nNumPz1)
If dDimPz1 <> 0 And nNumPz1 > 0 Then
vtDelta = Vector3d.FromPolar((dDimPz1 + dThick), m_dAngO)
vtDelta.Rotate(Vector3d.Z_AX, dRotAngO)
For Index As Integer = 1 To nNumPz1
Dim vtPerpMove As Vector3d = Index * vtDelta
' Creo copie
Dim nCut2Id = EgtCopyGlob(nCutId, nLayerId)
EgtMove(nCut2Id, vtPerpMove, GDB_RT.GLOB)
Next
dTotPerpMove += vtDelta * nNumPz1
End If
' Calcolo secondo vettore di spostamento
Dim dDimPz2 As Double
Dim nNumPz2 As Integer
StringToDouble(DimPz2TxBx.Text, dDimPz2)
StringToDouble(NumPz2TxBx.Text, nNumPz2)
If dDimPz2 <> 0 And nNumPz2 > 0 Then
vtDelta = Vector3d.FromPolar((dDimPz2 + dThick), m_dAngO)
vtDelta.Rotate(Vector3d.Z_AX, dRotAngO)
For Index As Integer = 1 To nNumPz2
Dim vtPerpMove As Vector3d = dTotPerpMove + vtDelta * Index
' Creo copie
Dim nCut3Id = EgtCopyGlob(nCutId, nLayerId)
EgtMove(nCut3Id, vtPerpMove, GDB_RT.GLOB)
Next
dTotPerpMove += vtDelta * nNumPz2
End If
' Calcolo terzo vettore di spostamento
Dim dDimPz3 As Double
Dim nNumPz3 As Integer
StringToDouble(DimPz3TxBx.Text, dDimPz3)
StringToDouble(NumPz3TxBx.Text, nNumPz3)
If dDimPz3 <> 0 And nNumPz3 > 0 Then
vtDelta = Vector3d.FromPolar((dDimPz3 + dThick), m_dAngO)
vtDelta.Rotate(Vector3d.Z_AX, dRotAngO)
For Index As Integer = 1 To nNumPz3
Dim vtPerpMove As Vector3d = dTotPerpMove + vtDelta * Index
' Creo copie
Dim nCut4Id = EgtCopyGlob(nCutId, nLayerId)
EgtMove(nCut4Id, vtPerpMove, GDB_RT.GLOB)
Next
dTotPerpMove += vtDelta * nNumPz3
End If
Return True
End Function
Private Function EraseDirectCutPart()
' Recupero identificativo del pezzo
Dim nDirPartId As Integer = EgtGetFirstNameInGroup(m_MainWindow.m_CurrentProjectPageUC.m_nRawId, DIRECTCUT)
If nDirPartId = GDB_ID.NULL Then
Return True
End If
' Cancello le lavorazioni
EraseMachinings(nDirPartId)
' Tolgo il pezzo dal grezzo
EgtRemovePartFromRawPart(nDirPartId)
' Cancello il pezzo
EgtErase(nDirPartId)
Return True
End Function
Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean
' Aggiungo crocette
Dim vtCrossX As New Vector3d(20, 0, 0)
Dim vtCrossY As New Vector3d(0, 20, 0)
Dim nCrossId1 = EgtCreateLine(nLayerId, ptP + (-vtCrossX), ptP + vtCrossX)
EgtSetColor(nCrossId1, New Color3d(255, 0, 0))
Dim nCrossId2 = EgtCreateLine(nLayerId, ptP + (-vtCrossY), ptP + vtCrossY)
EgtSetColor(nCrossId2, New Color3d(255, 0, 0))
Return True
End Function
Private Sub NumPz1TxBx_EgtClosed(sender As Object, e As EventArgs) Handles NumPz1TxBx.EgtClosed, NumPz2TxBx.EgtClosed, NumPz3TxBx.EgtClosed, DimPz1TxBx.EgtClosed, DimPz2TxBx.EgtClosed, DimPz3TxBx.EgtClosed, SideChBx.Click
' Disegno il taglio
If m_bPointP2Ok Then
Create2PointsMultipleCut()
Else
CreateMultipleCut()
End If
EgtDraw()
End Sub
End Class
+42 -30
View File
@@ -7,6 +7,7 @@ Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports EgtUILib
Imports EgtWPFLib
Namespace Num
Public Class NumNC
@@ -117,22 +118,24 @@ Namespace Num
Private m_nCnDataVarNum As Integer = 0
Private m_nCnDataVarInd(NUM_DATA - 1) As Integer
Private m_ConnectionError5000 As Boolean = False
#End Region
#Region " Constructor"
Sub New()
n_state = 0
sz_NC_error_messages = New List(Of String)
End Sub
Sub New()
n_state = 0
sz_NC_error_messages = New List(Of String)
End Sub
Public Overrides Function Init() As Boolean
Public Overrides Function Init() As Boolean
' Initialize and start Runtime System
InitFxServer()
' Initialize and start Runtime System
InitFxServer()
Return n_state >= 2
End Function
Return n_state >= 2
End Function
#End Region
@@ -152,31 +155,37 @@ Namespace Num
Dim Index As Integer = 0
Dim SaveCurrProj As New SaveCurrProjWD
Dim ConnectionWnd As New EgtMsgBox(Application.Current.MainWindow, "CONNESSIONE AL CN", "Connessione in corso...", True, EgtMsgBox.Icons.NULL, 1)
ConnectionWnd.LoadingPrBr_Value = 5
While n_state < 2 And Index < 20
If Index = 0 Then
SaveCurrProj.sTextString = "Collegamento in corso"
SaveCurrProj.Show()
End If
Dim ConnectionError As Integer = 0
While (n_state < 2 Or m_ConnectionError5000) And Index < 20
System.Threading.Thread.Sleep(500) ' 0.5 sec wait
ConnectionWnd.LoadingPrBr_Value += 5
Index += 1
' Costringo ad aggiornare GUI
Dim nDummy As Integer
Application.Current.Dispatcher.Invoke(Windows.Threading.DispatcherPriority.Background, New Action(Function() nDummy = 0))
End While
If n_state < 2 Then
SaveCurrProj.Close()
SaveCurrProj = New SaveCurrProjWD
SaveCurrProj.sTextString = "Collegamento non riuscito"
SaveCurrProj.Show()
System.Threading.Thread.Sleep(2000) ' 2 sec wait
SaveCurrProj.Close()
If n_state < 2 Or m_ConnectionError5000 Then
ConnectionWnd.Text = "Connessione non riuscita"
' Costringo ad aggiornare GUI
Dim nDummy As Integer
Application.Current.Dispatcher.Invoke(Windows.Threading.DispatcherPriority.Background, New Action(Function() nDummy = 0))
System.Threading.Thread.Sleep(1500) ' 2 sec wait
ConnectionWnd.Close()
Else
SaveCurrProj.Close()
SaveCurrProj = New SaveCurrProjWD
SaveCurrProj.sTextString = "Collegamento riuscito"
SaveCurrProj.Show()
System.Threading.Thread.Sleep(2000) ' 2 sec wait
SaveCurrProj.Close()
ConnectionWnd.Text = "Connessione riuscita"
ConnectionWnd.LoadingPrBr_Value = 100
' Costringo ad aggiornare GUI
Dim nDummy As Integer
Application.Current.Dispatcher.Invoke(Windows.Threading.DispatcherPriority.Background, New Action(Function() nDummy = 0))
System.Threading.Thread.Sleep(1500) ' 2 sec wait
ConnectionWnd.Close()
' lancio della lettura delle variabili PLC
set_Read_PLC_var()
@@ -534,7 +543,10 @@ Namespace Num
' ' ------->> FXServer Event DGroupManager ErrorHandler
'
Private Sub objDGroupManager_ErrorHandler(szError As String, nTextNumber As Short) Handles objDGroupManager.ErrorHandler
MessageBox.Show("DGroupManager.ErrorHandler message : " & szError & "ErrorHandler number : " & nTextNumber.ToString)
EgtOutLog("DGroupManager.ErrorHandler message : " & szError & "ErrorHandler number : " & nTextNumber.ToString)
If nTextNumber = 5000 Then
m_ConnectionError5000 = True
End If
End Sub
#End Region
@@ -966,7 +978,7 @@ Namespace Num
d_DInterpo_Feed_override = CDbl(CLng(values(n))) * 0.47059
b_feed_changed = True
Case CnData.Speed ' (4) Speed
d_spindle_eff(0) = CDbl(values(n))
d_spindle_eff(0) = CDbl(values(n))
Case CnData.SpeedOvr ' (5) Potenziom. speed = ...
n_spindle_override(0) = Math.Round((CDbl(values(n)) * 50 / 255) + 50)
Case CnData.Power ' (6) Ampère = * 0.01
+3
View File
@@ -756,6 +756,9 @@ Class MainWindow
' Non devo fare alcunchè
End Select
End If
If m_ActivePage = Pages.DirectCut And m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.SingleCut Then
m_DirectCutPageUC.m_SingleCut.SingleCut_Unloaded(sender, e)
End If
MainWindow_Unloaded(sender, e)
Me.Close()
End Sub
+120
View File
@@ -0,0 +1,120 @@
<UserControl x:Class="MultipleCut"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:EgtWPFLib="clr-namespace:EgtWPFLib;assembly=EgtWPFLib"
mc:Ignorable="d"
d:DesignHeight="597.3" d:DesignWidth="256">
<!-- Chiamata al Dictionary -->
<UserControl.Resources>
<ResourceDictionary Source="OmagCutDictionary.xaml"/>
</UserControl.Resources>
<Border CornerRadius="{StaticResource Page_CornerRadius}" Background="{StaticResource OmagCut_LightGray}">
<!-- Definizione della Grid MultipleCut -->
<Grid Name="SingleCutGrid" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<ToggleButton Name="Point1Btn" Grid.Column="0" Content="Acquisisci P1"
Style="{StaticResource OmagCut_YellowToggleButton}"/>
<ToggleButton Name="Point2Btn" Grid.Column="1" Content="Acquisisci P2"
Style="{StaticResource OmagCut_YellowToggleButton}"/>
</Grid>
<CheckBox Name="LaserOnChBx" Grid.Row="1" Grid.ColumnSpan="2" Height="40" Width="220" Content="Acquisisci laser" FontSize="22"/>
<TextBlock Name="DepthTxBl" Grid.Column="0" Grid.Row="2"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Affondamento" />
<EgtWPFLib:EgtTextBox Name="DepthTxBx" Grid.Column="1" Grid.Row="2" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<TextBlock Name="LenghtTxBl" Grid.Column="0" Grid.Row="3"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Lunghezza" />
<EgtWPFLib:EgtTextBox Name="LenghtTxBx" Grid.Column="1" Grid.Row="3" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<TextBlock Name="DirectionTxBl" Grid.Column="0" Grid.Row="4"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Direzione" />
<EgtWPFLib:EgtTextBox Name="DirectionTxBx" Grid.Column="1" Grid.Row="4" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<TextBlock Name="SideAngleTxBl" Grid.Column="0" Grid.Row="5"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Inclinazione" />
<EgtWPFLib:EgtTextBox Name="SideAngleTxBx" Grid.Column="1" Grid.Row="5" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<Grid Grid.Row="6" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition Width="2"/>
<ColumnDefinition Width="1.5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<Border Grid.Column="1" Grid.Row="0" Grid.RowSpan="4" Background="Black" />
<TextBlock Name="NumPzTxBl" Grid.Column="0" Grid.Row="0"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Numero" />
<TextBlock Name="DimPzTxBl" Grid.Column="2" Grid.Row="0"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Dimensioni" />
<EgtWPFLib:EgtTextBox Name="NumPz1TxBx" Grid.Column="0" Grid.Row="1" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<EgtWPFLib:EgtTextBox Name="DimPz1TxBx" Grid.Column="2" Grid.Row="1" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<EgtWPFLib:EgtTextBox Name="NumPz2TxBx" Grid.Column="0" Grid.Row="2" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<EgtWPFLib:EgtTextBox Name="DimPz2TxBx" Grid.Column="2" Grid.Row="2" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<EgtWPFLib:EgtTextBox Name="NumPz3TxBx" Grid.Column="0" Grid.Row="3" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
<EgtWPFLib:EgtTextBox Name="DimPz3TxBx" Grid.Column="2" Grid.Row="3" Width="75"
Style="{StaticResource OmagCut_CalculatorTextBox}"/>
</Grid>
<CheckBox Name="SideChBx" Grid.Row="7" Grid.ColumnSpan="2" Height="40" Width="220" Content="Tagli lato motore" FontSize="22"/>
<Button Name="OkBtn" Grid.Column="0" Grid.Row="11" Style="{StaticResource OmagCut_GradientBlueTextButton}"
Content="Esegui"/>
<Button Name="ExitBtn" Grid.Column="2" Grid.Row="11" Style="{StaticResource OmagCut_YellowIconButton}">
<Image Source="Resources/X.png" Style="{StaticResource OmagCut_ButtonIcon}"/>
</Button>
</Grid>
</Border>
</UserControl>
+550
View File
@@ -0,0 +1,550 @@
Imports EgtUILib
Public Class MultipleCut
' Riferimenti a pagine
Private m_MainWindow As MainWindow = Application.Current.MainWindow
Private m_CurrProjPage As CurrentProjectPageUC
' Origine tavola e dati grezzo
Private m_bRawOk As Boolean = False
Private m_ptTabOri As Point3d
Private m_ptRawMin As Point3d
Private m_ptRawMax As Point3d
' Parametri P1 acquisito
Private m_bPointP1Ok As Boolean = False
Private m_ptTipP1 As Point3d
Private m_vtToolP1 As Vector3d
' Parametri P2 acquisito
Private m_bPointP2Ok As Boolean = False
Private m_ptTipP2 As Point3d
Private m_vtToolP2 As Vector3d
' Lato di creazione dei tagli
Private m_bCutSide As CutSide = CutSide.Left
' Parametri della lavorazione
Private m_bCutOk As Boolean = False
Private m_dDepth As Double = 0
Private m_dLen As Double = 1000
Private m_dAngO As Double = 180
Private m_dAngV As Double = 0
' Costanti
Private Const MAX_TAB_DEPTH As Double = 10.0
Private Const MIN_CUT_LEN As Double = 10.0
Private Const MAX_SIDE_ANG As Double = 60.0
Private Const DIRECTCUT As String = "DirectCut"
Private Enum CutSide As Integer
Left
Right
End Enum
Private Sub MultipleCut_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
' Reset punto acquisito
m_bPointP1Ok = False
'SawTipTxBl.Text = String.Empty
' Assegno parametri di lavorazione già definiti
DepthTxBx.Text = DoubleToString(m_dDepth, 1)
LenghtTxBx.Text = DoubleToString(m_dLen, 1)
' Origine tavola
m_bRawOk = True
If Not EgtGetTableRef(1, m_ptTabOri) Then
m_bRawOk = False
EgtOutLog("Error on TableRef1")
End If
' Dati del grezzo
If Not m_MainWindow.m_RawPartPage.GetRawBox(m_ptRawMin, m_ptRawMax) Then
m_bRawOk = False
EgtOutLog("Error on RawBox")
End If
' Reset taglio e disabilito bottone esecuzione
m_bCutOk = False
UpdateOkBtn()
' Disabilito bottone secondo punto
Point2Btn.IsEnabled = False
' Deseleziono bottone primo punto
Point1Btn.IsChecked = False
' Disabilito registrazione progetto modificato
EgtDisableModified()
End Sub
Friend Sub MultipleCut_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded
' Rimuovo eventuale pezzo per taglio diretto
EraseDirectCutPart()
' Riattivo eventuali lavorazioni presenti
ActivateAllMachinings()
' Abilito registrazione progetto modificato
EgtEnableModified()
' Nascondo la macchina
EgtShowOnlyTable(True)
EgtDraw()
End Sub
Private Sub UpdateOkBtn()
If m_bCutOk Then
OkBtn.IsEnabled = True
OkBtn.Foreground = Brushes.Black
Else
OkBtn.IsEnabled = False
OkBtn.Foreground = Brushes.DarkGray
End If
End Sub
Private Sub Point1Btn_Click(sender As Object, e As RoutedEventArgs) Handles Point1Btn.Click
' Reset punto non acquisito
m_bPointP1Ok = False
' Verifico configurazione tavola e grezzo
If Not m_bRawOk Then
Return
End If
' Recupero la posizione macchina
Dim dL1, dL2, dL3, dR1, dR2 As Double
If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then
Return
End If
' Ricavo dati lama corrente
Dim sSaw As String = String.Empty
GetPrivateProfileString(S_MACH, K_CURRSAW, "", sSaw, m_MainWindow.GetIniFile())
' Se punto da laser
If LaserOnChBx.IsChecked Then
' Imposto come testa corrente il laser (senza utensile ovviamente)
If Not EgtSetCalcTool("", "H3", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then
Return
End If
' Ora imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Altrimenti da lama
Else
' Imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then
Return
End If
End If
' Calcolo direzione asse lama
If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP1) Then
Return
End If
' Porto il tip nell'origine tavola
m_ptTipP1.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP1Ok = True
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
' Visualizzo macchina in posizione
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
' Visualizzo quote
Dim sSawTip As String = "X" & DoubleToString(m_ptTipP1.x, 0) & " Y" & DoubleToString(m_ptTipP1.y, 0) &
" Z" & DoubleToString(m_ptTipP1.z, 0) & " C" & DoubleToString(dR1, 0) &
" B" & DoubleToString(dR2, 0)
'SawTipTxBl.Text = sSawTip
' Assegno angoli
Dim dTLen, dTAngV, dTAngO As Double
m_vtToolP1.ToSpherical(dTLen, dTAngV, dTAngO)
m_dAngO = dTAngO + 90
m_dAngV = 90 - dTAngV
DirectionTxBx.Text = DoubleToString(m_dAngO, 2)
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Disegno il taglio
CreateMultipleCut()
EgtShowOnlyTable(False)
EgtDraw()
' Seleziono il bottone per indicare che il primo punto è stato acquisito
Point1Btn.IsChecked = True
' Abilito e deseleziono secondo punto
Point2Btn.IsEnabled = True
Point2Btn.IsChecked = False
' Annullo secondo punto selezionato
m_bPointP2Ok = False
End Sub
Private Sub Point2Btn_Click(sender As Object, e As RoutedEventArgs) Handles Point2Btn.Click
' Deseleziono il bottone (poichè si seleziona automaticamente) cos' nel caso ci sia un errore rimane deselezionato
Point2Btn.IsChecked = False
' Reset punto non acquisito
m_bPointP2Ok = False
' Verifico configurazione tavola e grezzo
If Not m_bRawOk Then
Return
End If
' Recupero la posizione macchina
Dim dL1, dL2, dL3, dR1, dR2 As Double
If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then
Return
End If
' Ricavo dati lama corrente
Dim sSaw As String = String.Empty
GetPrivateProfileString(S_MACH, K_CURRSAW, "", sSaw, m_MainWindow.GetIniFile())
' Se punto da laser
If LaserOnChBx.IsChecked Then
' Imposto come testa corrente il laser (senza utensile ovviamente)
If Not EgtSetCalcTool("", "H3", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then
Return
End If
' Ora imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Altrimenti da lama
Else
' Imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then
Return
End If
End If
' Calcolo direzione asse lama
If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP2) Then
Return
End If
' Porto il tip nell'origine tavola
m_ptTipP2.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP2Ok = True
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
' Visualizzo macchina in posizione
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
' Visualizzo quote
Dim sSawTip As String = "X" & DoubleToString(m_ptTipP2.x, 0) & " Y" & DoubleToString(m_ptTipP2.y, 0) &
" Z" & DoubleToString(m_ptTipP2.z, 0) & " C" & DoubleToString(dR1, 0) &
" B" & DoubleToString(dR2, 0)
'SawTipTxBl.Text = sSawTip
' Assegno angolo verticale da direzione utensile
Dim dTLen, dTAngV, dTAngO As Double
m_vtToolP2.ToSpherical(dTLen, dTAngV, dTAngO)
m_dAngV = 90 - dTAngV
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Se il secondo punto non coincide con il primo, disegno il taglio
Dim vtDiff As Vector3d = m_ptTipP2 - m_ptTipP1
vtDiff.z = 0
Dim dLen As Double
Dim dAngVertDeg As Double
Dim dAngOrizzDeg As Double
vtDiff.ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
If dLen > EPS_SMALL Then
LenghtTxBx.Text = DoubleToString(dLen, 1)
m_dAngO = dAngOrizzDeg
DirectionTxBx.Text = DoubleToString(dAngOrizzDeg, 2)
Create2PointsMultipleCut()
EgtShowOnlyTable(False)
EgtDraw()
' Seleziono il bottone per indicare che il secondo punto è stato acquisito
Point2Btn.IsChecked = True
Else
' Deseleziono il bottone per indicare che il secondo punto non è stato acquisito perchè uguale al primo
Point2Btn.IsChecked = False
End If
End Sub
Private Sub DepthTxBx_EgtClosed(sender As Object, e As EventArgs) Handles DepthTxBx.EgtClosed
' Verifico che l'affondamento impostato non sia superiore a quello massimo
Dim dMaxDepth = m_ptRawMax.z - m_ptRawMin.z + MAX_TAB_DEPTH
Dim dDepth As Double = 0
StringToDouble(DepthTxBx.Text, dDepth)
If dDepth < 0 Then
m_dDepth = 0
ElseIf dDepth > dMaxDepth Then
m_dDepth = dMaxDepth
Else
m_dDepth = dDepth
End If
DepthTxBx.Text = DoubleToString(m_dDepth, 2)
' Disegno il taglio
CreateMultipleCut()
EgtDraw()
End Sub
Private Sub LenghtTxBx_EgtClosed(sender As Object, e As EventArgs) Handles LenghtTxBx.EgtClosed
' Verifico che la lunghezza del taglio impostata non sia inferiore a quella minima
Dim dLenght As Double = 0
StringToDouble(LenghtTxBx.Text, dLenght)
If dLenght < MIN_CUT_LEN Then
m_dLen = MIN_CUT_LEN
Else
m_dLen = dLenght
End If
LenghtTxBx.Text = DoubleToString(m_dLen, 2)
' Disegno il taglio
CreateMultipleCut()
EgtDraw()
End Sub
Private Sub DirectionTxBx_EgtClosed(sender As Object, e As EventArgs) Handles DirectionTxBx.EgtClosed
' Assegno il nuovo valore di direzione
Dim dDirection As Double = 0
StringToDouble(DirectionTxBx.Text, dDirection)
m_dAngO = dDirection
' Disegno il taglio
CreateMultipleCut()
EgtDraw()
End Sub
Private Sub SideAngleTxBx_EgtClosed(sender As Object, e As EventArgs) Handles SideAngleTxBx.EgtClosed
' Verifico che l'inclinazione del taglio impostata non sia superiore a quella massima
Dim dSideAngle As Double = 0
StringToDouble(SideAngleTxBx.Text, dSideAngle)
If dSideAngle < 0 Then
m_dAngV = 0
ElseIf dSideAngle > MAX_SIDE_ANG Then
m_dAngV = MAX_SIDE_ANG
Else
m_dAngV = dSideAngle
End If
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Disegno il taglio
CreateMultipleCut()
EgtDraw()
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
' Verifico ci sia un taglio valido
If Not m_bCutOk Then
Return
End If
' Salvo il progetto con le lavorazioni
Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge"
m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath)
' Genero file CNC (lancio anche se errore in precedenza)
Dim sCncPath As String = m_MainWindow.GetCncDir() & "\DirectCut.xpi"
Dim bOk As Boolean = EgtGenerate(sCncPath, "OmagCut")
' Se errore in generazione, segnalo l'errore ed esco
If Not bOk Then
m_CurrProjPage.SetErrorMessage(EgtMsg(90314)) 'Errore nella generazione del programma CN
Return
End If
' Download programma (eventuali errori sono segnalati dalla funzione)
If m_MainWindow.m_CNCommunication.SendProgram(sCncPath, 900) Then
' copio il progetto corrente come progetto in lavorazione
Dim sWrkPath As String = m_MainWindow.GetTempDir() & "\" & "WorkProj.nge"
My.Computer.FileSystem.CopyFile(sMchPath, sWrkPath, True)
End If
End Sub
Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click
m_MainWindow.m_DirectCutPageUC.LeftButtonGrid.Children.Remove(Me)
m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut
End Sub
Private Function CreateMultipleCut() As Boolean
' Verifico sia definito il punto iniziale e il grezzo
If Not m_bPointP1Ok Or Not m_bRawOk Then
m_bCutOk = False
Return False
End If
' Spessore grezzo
Dim dRawHeight As Integer = m_ptRawMax.z - m_ptRawMin.z
' Rimuovo eventuale vecchio pezzo per taglio diretto
EraseDirectCutPart()
' Disattivo eventuali lavorazioni presenti
DeactivateAllMachinings()
' Creo nuovo pezzo per il taglio diretto
Dim nPartId = EgtCreateGroup(GDB_ID.ROOT)
EgtSetName(nPartId, DIRECTCUT)
Dim nLayerId = EgtCreateGroup(nPartId)
EgtSetName(nLayerId, "OutLoop")
' Creo il taglio
Dim ptStart As Point3d = m_ptTipP1
ptStart.z = 0
Dim nCutId = EgtCreateLinePDL(nLayerId, ptStart, m_dAngO, m_dLen)
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutId, "Depth", m_dDepth)
EgtSetInfo(nCutId, "SideAng", m_dAngV)
' Funzione che crea i tagli successivi al primo
MultiplyCut(nLayerId, nCutId)
' Creo layer per crocetta di riferimento
Dim nCrossLayerId = EgtCreateGroup(nPartId)
' Aggiungo crocetta
CreateCross(nCrossLayerId, ptStart)
' Calcolo punto di inserimento nel grezzo
Dim ptMin, ptMax As Point3d
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, ptMin, ptMax)
Dim ptIns As Point3d = ptMin + (m_ptTabOri - m_ptRawMin)
ptIns.z = dRawHeight
' Inserisco il pezzo nel grezzo
EgtAddPartToRawPart(nPartId, ptIns, m_MainWindow.m_CurrentProjectPageUC.m_nRawId)
' Inserisco la lavorazione
m_bCutOk = AddMachinings(nPartId, True, True)
UpdateOkBtn()
Return m_bCutOk
End Function
Private Function Create2PointsMultipleCut() As Boolean
' Verifico siano definiti punto iniziale punto finale e grezzo
If Not m_bPointP1Ok Or Not m_bPointP2Ok Or Not m_bRawOk Then
m_bCutOk = False
Return False
End If
' Spessore grezzo
Dim dRawHeight As Integer = m_ptRawMax.z - m_ptRawMin.z
' Rimuovo eventuale vecchio pezzo per taglio diretto
EraseDirectCutPart()
' Disattivo eventuali lavorazioni presenti
DeactivateAllMachinings()
' Creo nuovo pezzo per il taglio diretto
Dim nPartId = EgtCreateGroup(GDB_ID.ROOT)
EgtSetName(nPartId, DIRECTCUT)
' Creo layer di taglio
Dim nLayerId = EgtCreateGroup(nPartId)
EgtSetName(nLayerId, "OutLoop")
' Creo il taglio
Dim ptStart As Point3d = m_ptTipP1
Dim ptEnd As Point3d = m_ptTipP2
ptStart.z = 0
ptEnd.z = 0
Dim nCutId = EgtCreateLine(nLayerId, ptStart, ptEnd)
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutId, "Depth", m_dDepth)
EgtSetInfo(nCutId, "SideAng", m_dAngV)
' Funzione che crea i tagli successivi al primo
MultiplyCut(nLayerId, nCutId)
' Creo layer per crocette di riferimento
Dim nCrossLayerId = EgtCreateGroup(nPartId)
' Aggiungo crocette
CreateCross(nCrossLayerId, ptStart)
CreateCross(nCrossLayerId, ptEnd)
' Calcolo punto di inserimento nel grezzo
Dim ptMin, ptMax As Point3d
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, ptMin, ptMax)
Dim ptIns As Point3d = ptMin + (m_ptTabOri - m_ptRawMin)
ptIns.z = dRawHeight
' Inserisco il pezzo nel grezzo
EgtAddPartToRawPart(nPartId, ptIns, m_MainWindow.m_CurrentProjectPageUC.m_nRawId)
' Inserisco la lavorazione
m_bCutOk = AddMachinings(nPartId, True, True)
UpdateOkBtn()
Return m_bCutOk
End Function
Private Function MultiplyCut(nLayerId As Integer, nCutId As Integer)
' Recupero spessore della lama correntemente attiva
Dim dThick As Double = 0
EgtTdbGetCurrToolParam(MCH_TP.THICK, dThick)
' Ricalcolo lo spessore della lama in base all'inclinazione
dThick = dThick / Math.Cos(m_dAngV * Math.PI / 180)
' Imposto angolo di rotazione a seconda del lato dei tagli
Dim dRotAngO As Double = If(SideChBx.IsChecked, -90, 90)
'Variabile che contiene la somma degli spostamenti
Dim dTotPerpMove As Vector3d
' Definisco vettore di spostamento
Dim vtDelta As Vector3d
' Calcolo primo vettore di spostamento
Dim dDimPz1 As Double
Dim nNumPz1 As Integer
StringToDouble(DimPz1TxBx.Text, dDimPz1)
StringToDouble(NumPz1TxBx.Text, nNumPz1)
If dDimPz1 <> 0 And nNumPz1 > 0 Then
vtDelta = Vector3d.FromPolar((dDimPz1 + dThick), m_dAngO)
vtDelta.Rotate(Vector3d.Z_AX, dRotAngO)
For Index As Integer = 1 To nNumPz1
Dim vtPerpMove As Vector3d = Index * vtDelta
' Creo copie
Dim nCut2Id = EgtCopyGlob(nCutId, nLayerId)
EgtMove(nCut2Id, vtPerpMove, GDB_RT.GLOB)
Next
dTotPerpMove += vtDelta * nNumPz1
End If
' Calcolo secondo vettore di spostamento
Dim dDimPz2 As Double
Dim nNumPz2 As Integer
StringToDouble(DimPz2TxBx.Text, dDimPz2)
StringToDouble(NumPz2TxBx.Text, nNumPz2)
If dDimPz2 <> 0 And nNumPz2 > 0 Then
vtDelta = Vector3d.FromPolar((dDimPz2 + dThick), m_dAngO)
vtDelta.Rotate(Vector3d.Z_AX, dRotAngO)
For Index As Integer = 1 To nNumPz2
Dim vtPerpMove As Vector3d = dTotPerpMove + vtDelta * Index
' Creo copie
Dim nCut3Id = EgtCopyGlob(nCutId, nLayerId)
EgtMove(nCut3Id, vtPerpMove, GDB_RT.GLOB)
Next
dTotPerpMove += vtDelta * nNumPz2
End If
' Calcolo terzo vettore di spostamento
Dim dDimPz3 As Double
Dim nNumPz3 As Integer
StringToDouble(DimPz3TxBx.Text, dDimPz3)
StringToDouble(NumPz3TxBx.Text, nNumPz3)
If dDimPz3 <> 0 And nNumPz3 > 0 Then
vtDelta = Vector3d.FromPolar((dDimPz3 + dThick), m_dAngO)
vtDelta.Rotate(Vector3d.Z_AX, dRotAngO)
For Index As Integer = 1 To nNumPz3
Dim vtPerpMove As Vector3d = dTotPerpMove + vtDelta * Index
' Creo copie
Dim nCut4Id = EgtCopyGlob(nCutId, nLayerId)
EgtMove(nCut4Id, vtPerpMove, GDB_RT.GLOB)
Next
dTotPerpMove += vtDelta * nNumPz3
End If
Return True
End Function
Private Function EraseDirectCutPart()
' Recupero identificativo del pezzo
Dim nDirPartId As Integer = EgtGetFirstNameInGroup(m_MainWindow.m_CurrentProjectPageUC.m_nRawId, DIRECTCUT)
If nDirPartId = GDB_ID.NULL Then
Return True
End If
' Cancello le lavorazioni
EraseMachinings(nDirPartId)
' Tolgo il pezzo dal grezzo
EgtRemovePartFromRawPart(nDirPartId)
' Cancello il pezzo
EgtErase(nDirPartId)
Return True
End Function
Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean
' Aggiungo crocette
Dim vtCrossX As New Vector3d(20, 0, 0)
Dim vtCrossY As New Vector3d(0, 20, 0)
Dim nCrossId1 = EgtCreateLine(nLayerId, ptP + (-vtCrossX), ptP + vtCrossX)
EgtSetColor(nCrossId1, New Color3d(255, 0, 0))
Dim nCrossId2 = EgtCreateLine(nLayerId, ptP + (-vtCrossY), ptP + vtCrossY)
EgtSetColor(nCrossId2, New Color3d(255, 0, 0))
Return True
End Function
Private Sub NumPz1TxBx_EgtClosed(sender As Object, e As EventArgs) Handles NumPz1TxBx.EgtClosed, NumPz2TxBx.EgtClosed, NumPz3TxBx.EgtClosed, DimPz1TxBx.EgtClosed, DimPz2TxBx.EgtClosed, DimPz3TxBx.EgtClosed, SideChBx.Click
' Disegno il taglio
If m_bPointP2Ok Then
Create2PointsMultipleCut()
Else
CreateMultipleCut()
End If
EgtDraw()
End Sub
End Class
+1 -1
View File
@@ -44,7 +44,7 @@
VerticalAlignment="Center" />
</Button>
<ToggleButton Name="MaximizeMoveBtn" Grid.Column="1" Grid.Row="2"
Style="{StaticResource OmagCut_YellowToggleButton}">
Style="{StaticResource OmagCut_YellowIconToggleButton}">
<Image Source="Resources/MaxMove.png" Width="65" Height="65" HorizontalAlignment="Center"
VerticalAlignment="Center" />
</ToggleButton>
+14
View File
@@ -149,6 +149,9 @@
<Compile Include="FrameCutPageUC.xaml.vb">
<DependentUpon>FrameCutPageUC.xaml</DependentUpon>
</Compile>
<Compile Include="GridCut.xaml.vb">
<DependentUpon>GridCut.xaml</DependentUpon>
</Compile>
<Compile Include="Keyboard.xaml.vb">
<DependentUpon>Keyboard.xaml</DependentUpon>
</Compile>
@@ -161,6 +164,9 @@
<Compile Include="ManualAxesMoveUC.xaml.vb">
<DependentUpon>ManualAxesMoveUC.xaml</DependentUpon>
</Compile>
<Compile Include="MultipleCut.xaml.vb">
<DependentUpon>MultipleCut.xaml</DependentUpon>
</Compile>
<Compile Include="M_Num.vb" />
<Compile Include="M_Num_old.vb" />
<Compile Include="NestPageUC.xaml.vb">
@@ -258,6 +264,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="GridCut.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Keyboard.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -274,6 +284,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MultipleCut.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="NestPageUC.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
+14 -3
View File
@@ -422,18 +422,29 @@
</Style.Triggers>
</Style>
<Style x:Key="OmagCut_YellowToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource OmagCut_ToggleButton}">
<Style x:Key="OmagCut_YellowToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource OmagCut_ToggleButton_Wrap}">
<Setter Property="BorderBrush" Value="{StaticResource OmagCut_Yellow}"/>
<Setter Property="Background" Value="{StaticResource OmagCut_LightGray}"/>
<Setter Property="FontSize" Value="{StaticResource FontSize_UpperCaseCharacter}"/>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="ToggleButton.Background" Value="Transparent" />
<Setter Property="ToggleButton.Foreground" Value="Black"/>
<Setter Property="ToggleButton.Background" Value="{StaticResource OmagCut_Blue}" />
<Setter Property="ToggleButton.Foreground" Value="{StaticResource OmagCut_Yellow}"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="OmagCut_YellowIconToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource OmagCut_ToggleButton}">
<Setter Property="BorderBrush" Value="{StaticResource OmagCut_Yellow}"/>
<Setter Property="Background" Value="{StaticResource OmagCut_LightGray}"/>
<Setter Property="FontSize" Value="{StaticResource FontSize_UpperCaseCharacter}"/>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="ToggleButton.Background" Value="{StaticResource OmagCut_Blue}" />
<Setter Property="ToggleButton.Foreground" Value="{StaticResource OmagCut_Yellow}"/>
</Trigger>
</Style.Triggers>
</Style>
<!-- ______________________________________________________________________________________________________________________ -->
+14 -4
View File
@@ -34,10 +34,20 @@
<RowDefinition Height="0.5*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Button Name="PointBtn" Grid.Row="0" Grid.ColumnSpan="2" Content="Acquisisci punto"
Style="{StaticResource OmagCut_YellowTextButton}"/>
<Grid Grid.Row="0" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<ToggleButton Name="Point1Btn" Grid.Column="0" Content="Acquisisci P1"
Style="{StaticResource OmagCut_YellowToggleButton}"/>
<ToggleButton Name="Point2Btn" Grid.Column="1" Content="Acquisisci P2"
Style="{StaticResource OmagCut_YellowToggleButton}"/>
</Grid>
<TextBlock Name="DepthTxBl" Grid.Column="0" Grid.Row="1"
Style="{StaticResource OmagCut_CurrProjSummeryTextBlock}" Text="Affondamento" />
<EgtWPFLib:EgtTextBox Name="DepthTxBx" Grid.Column="1" Grid.Row="1" Width="75"
+196 -43
View File
@@ -11,10 +11,14 @@ Public Class SingleCutUC
Private m_ptTabOri As Point3d
Private m_ptRawMin As Point3d
Private m_ptRawMax As Point3d
' Parametri punto acquisito
Private m_bPointOk As Boolean = False
Private m_ptTip As Point3d
Private m_vtTool As Vector3d
' Parametri P1 acquisito
Private m_bPointP1Ok As Boolean = False
Private m_ptTipP1 As Point3d
Private m_vtToolP1 As Vector3d
' Parametri P2 acquisito
Private m_bPointP2Ok As Boolean = False
Private m_ptTipP2 As Point3d
Private m_vtToolP2 As Vector3d
' Parametri della lavorazione
Private m_bCutOk As Boolean = False
Private m_dDepth As Double = 0
@@ -31,7 +35,7 @@ Public Class SingleCutUC
Private Sub SingleCut_Loaded(sender As Object, e As RoutedEventArgs)
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
' Reset punto acquisito
m_bPointOk = False
m_bPointP1Ok = False
SawTipTxBl.Text = String.Empty
' Assegno parametri di lavorazione già definiti
DepthTxBx.Text = DoubleToString(m_dDepth, 1)
@@ -50,11 +54,15 @@ Public Class SingleCutUC
' Reset taglio e disabilito bottone esecuzione
m_bCutOk = False
UpdateOkBtn()
' Disabilito bottone secondo punto
Point2Btn.IsEnabled = False
' Deseleziono bottone primo punto
Point1Btn.IsChecked = False
' Disabilito registrazione progetto modificato
EgtDisableModified()
End Sub
Private Sub SingleCut_Unloaded(sender As Object, e As RoutedEventArgs)
Friend Sub SingleCut_Unloaded(sender As Object, e As RoutedEventArgs)
' Rimuovo eventuale pezzo per taglio diretto
EraseDirectCutPart()
' Riattivo eventuali lavorazioni presenti
@@ -76,9 +84,9 @@ Public Class SingleCutUC
End If
End Sub
Private Sub PointBtn_Click(sender As Object, e As RoutedEventArgs) Handles PointBtn.Click
Private Sub Point1Btn_Click(sender As Object, e As RoutedEventArgs) Handles Point1Btn.Click
' Reset punto non acquisito
m_bPointOk = False
m_bPointP1Ok = False
SawTipTxBl.Text = String.Empty
' Verifico configurazione tavola e grezzo
If Not m_bRawOk Then
@@ -99,31 +107,31 @@ Public Class SingleCutUC
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTip) Then
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then
Return
End If
' Ora imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Altrimenti da lama
' Altrimenti da lama
Else
' Imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTip) Then
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP1) Then
Return
End If
End If
' Calcolo direzione asse lama
If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtTool) Then
If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP1) Then
Return
End If
' Porto il tip nell'origine tavola
m_ptTip.ToLoc(New Frame3d(m_ptTabOri))
m_bPointOk = True
m_ptTipP1.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP1Ok = True
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
@@ -138,21 +146,124 @@ Public Class SingleCutUC
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
' Visualizzo quote
Dim sSawTip As String = "X" & DoubleToString(m_ptTip.x, 0) & " Y" & DoubleToString(m_ptTip.y, 0) &
" Z" & DoubleToString(m_ptTip.z, 0) & " C" & DoubleToString(dR1, 0) &
Dim sSawTip As String = "X" & DoubleToString(m_ptTipP1.x, 0) & " Y" & DoubleToString(m_ptTipP1.y, 0) &
" Z" & DoubleToString(m_ptTipP1.z, 0) & " C" & DoubleToString(dR1, 0) &
" B" & DoubleToString(dR2, 0)
SawTipTxBl.Text = sSawTip
' Assegno angoli
Dim dTLen, dTAngV, dTAngO As Double
m_vtTool.ToSpherical(dTLen, dTAngV, dTAngO)
m_vtToolP1.ToSpherical(dTLen, dTAngV, dTAngO)
m_dAngO = dTAngO + 90
m_dAngV = 90 - dTAngV
DirectionTxBx.Text = DoubleToString(m_dAngO, 2)
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Disegno il taglio
CreateCut()
CreateSingleCut()
EgtShowOnlyTable(False)
EgtDraw()
' Seleziono il bottone per indicare che il primo punto è stato acquisito
Point1Btn.IsChecked = True
' Abilito e deseleziono secondo punto
Point2Btn.IsEnabled = True
Point2Btn.IsChecked = False
' Annullo secondo punto selezionato
m_bPointP2Ok = False
End Sub
Private Sub Point2Btn_Click(sender As Object, e As RoutedEventArgs) Handles Point2Btn.Click
' Deseleziono il bottone (poichè si seleziona automaticamente) cos' nel caso ci sia un errore rimane deselezionato
Point2Btn.IsChecked = False
' Reset punto non acquisito
m_bPointP2Ok = False
SawTipTxBl.Text = String.Empty
' Verifico configurazione tavola e grezzo
If Not m_bRawOk Then
Return
End If
' Recupero la posizione macchina
Dim dL1, dL2, dL3, dR1, dR2 As Double
If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then
Return
End If
' Ricavo dati lama corrente
Dim sSaw As String = String.Empty
GetPrivateProfileString(S_MACH, K_CURRSAW, "", sSaw, m_MainWindow.GetIniFile())
' Se punto da laser
If LaserOnChBx.IsChecked Then
' Imposto come testa corrente il laser (senza utensile ovviamente)
If Not EgtSetCalcTool("", "H3", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then
Return
End If
' Ora imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Altrimenti da lama
Else
' Imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTipP2) Then
Return
End If
End If
' Calcolo direzione asse lama
If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtToolP2) Then
Return
End If
' Porto il tip nell'origine tavola
m_ptTipP2.ToLoc(New Frame3d(m_ptTabOri))
m_bPointP2Ok = True
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
' Visualizzo macchina in posizione
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
' Visualizzo quote
Dim sSawTip As String = "X" & DoubleToString(m_ptTipP2.x, 0) & " Y" & DoubleToString(m_ptTipP2.y, 0) &
" Z" & DoubleToString(m_ptTipP2.z, 0) & " C" & DoubleToString(dR1, 0) &
" B" & DoubleToString(dR2, 0)
SawTipTxBl.Text = sSawTip
' Assegno angoli
Dim dTLen, dTAngV, dTAngO As Double
m_vtToolP2.ToSpherical(dTLen, dTAngV, dTAngO)
m_dAngV = 90 - dTAngV
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Se il secondo punto non coincide con il primo, disegno il taglio
Dim vtDiff As Vector3d = m_ptTipP2 - m_ptTipP1
vtDiff.z = 0
Dim dLen As Double
Dim dAngVertDeg As Double
Dim dAngOrizzDeg As Double
vtDiff.ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
If dLen > EPS_SMALL Then
m_dLen = dLen
m_dAngO = dAngOrizzDeg
LenghtTxBx.Text = DoubleToString(m_dLen, 1)
DirectionTxBx.Text = DoubleToString(m_dAngO, 2)
Create2PointsCut()
EgtShowOnlyTable(False)
EgtDraw()
' Seleziono il bottone per indicare che il secondo punto è stato acquisito
Point2Btn.IsChecked = True
Else
' Deseleziono il bottone per indicare che il secondo punto non è stato acquisito perchè uguale al primo
Point2Btn.IsChecked = False
End If
End Sub
Private Sub DepthTxBx_EgtClosed(sender As Object, e As EventArgs) Handles DepthTxBx.EgtClosed
@@ -169,7 +280,7 @@ Public Class SingleCutUC
End If
DepthTxBx.Text = DoubleToString(m_dDepth, 2)
' Disegno il taglio
CreateCut()
CreateSingleCut()
EgtDraw()
End Sub
@@ -184,7 +295,7 @@ Public Class SingleCutUC
End If
LenghtTxBx.Text = DoubleToString(m_dLen, 2)
' Disegno il taglio
CreateCut()
CreateSingleCut()
EgtDraw()
End Sub
@@ -194,7 +305,7 @@ Public Class SingleCutUC
StringToDouble(DirectionTxBx.Text, dDirection)
m_dAngO = dDirection
' Disegno il taglio
CreateCut()
CreateSingleCut()
EgtDraw()
End Sub
@@ -202,8 +313,8 @@ Public Class SingleCutUC
' Verifico che l'inclinazione del taglio impostata non sia superiore a quella massima
Dim dSideAngle As Double = 0
StringToDouble(SideAngleTxBx.Text, dSideAngle)
If dSideAngle < 0 Then
m_dAngV = 0
If dSideAngle < -MAX_SIDE_ANG Then
m_dAngV = -MAX_SIDE_ANG
ElseIf dSideAngle > MAX_SIDE_ANG Then
m_dAngV = MAX_SIDE_ANG
Else
@@ -211,7 +322,7 @@ Public Class SingleCutUC
End If
SideAngleTxBx.Text = DoubleToString(m_dAngV, 2)
' Disegno il taglio
CreateCut()
CreateSingleCut()
EgtDraw()
End Sub
@@ -244,9 +355,9 @@ Public Class SingleCutUC
m_MainWindow.m_DirectCutPageUC.m_ActiveDirectCutPage = DirectCutPageUC.DirectCutPages.DirectCut
End Sub
Private Function CreateCut() As Boolean
Private Function CreateSingleCut() As Boolean
' Verifico sia definito il punto iniziale e il grezzo
If Not m_bPointOk Or Not m_bRawOk Then
If Not m_bPointP1Ok Or Not m_bRawOk Then
m_bCutOk = False
Return False
End If
@@ -262,41 +373,72 @@ Public Class SingleCutUC
Dim nLayerId = EgtCreateGroup(nPartId)
EgtSetName(nLayerId, "OutLoop")
' Creo il taglio
Dim ptStart As Point3d = m_ptTip
Dim ptStart As Point3d = m_ptTipP1
ptStart.z = 0
Dim nCutId = EgtCreateLinePDL(nLayerId, ptStart, m_dAngO, m_dLen)
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutId, "Depth", m_dDepth)
EgtSetInfo(nCutId, "SideAng", m_dAngV)
' Creo layer per crocetta di riferimento
Dim nCrossLayerId = EgtCreateGroup(nPartId)
' Aggiungo crocetta
CreateCross(nCrossLayerId, ptStart)
' Calcolo punto di inserimento nel grezzo
Dim ptMin, ptMax As Point3d
EgtGetBBoxGlob(nCutId, GDB_BB.STANDARD, ptMin, ptMax)
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, ptMin, ptMax)
Dim ptIns As Point3d = ptMin + (m_ptTabOri - m_ptRawMin)
ptIns.z = dRawHeight
' Inserisco il pezzo nel grezzo
EgtAddPartToRawPart(nPartId, ptIns, m_MainWindow.m_CurrentProjectPageUC.m_nRawId)
' Inserisco la lavorazione
m_bCutOk = AddMachinings(nPartId, True, True)
'm_bCutOk = ExecCamDirect()
UpdateOkBtn()
Return m_bCutOk
End Function
Private Function ExecCamDirect() As Boolean
' Inserisco le lavorazioni
Dim sSawMch As String = String.Empty
GetPrivateProfileString(S_MACH, K_CURRMACHINING, "", sSawMch, m_MainWindow.GetIniFile())
EgtLuaCreateGlobTable("CAM")
EgtLuaSetGlobStringVar("CAM.SAWMCH", sSawMch)
Dim bOk As Boolean = EgtLuaExecFile(m_MainWindow.GetCamAutoDir() & "\CamDirect.lua")
Dim nErr As Integer = 999
EgtLuaGetGlobIntVar("CAM.ERR", nErr)
EgtLuaResetGlobVar("CAM")
If nErr <> 0 Then
bOk = False
EgtOutLog("Error in CamDirect : " & nErr.ToString())
Private Function Create2PointsCut() As Boolean
' Verifico siano definiti punto iniziale punto finale e grezzo
If Not m_bPointP1Ok Or Not m_bPointP2Ok Or Not m_bRawOk Then
m_bCutOk = False
Return False
End If
Return bOk
' Spessore grezzo
Dim dRawHeight As Integer = m_ptRawMax.z - m_ptRawMin.z
' Rimuovo eventuale vecchio pezzo per taglio diretto
EraseDirectCutPart()
' Disattivo eventuali lavorazioni presenti
DeactivateAllMachinings()
' Creo nuovo pezzo per il taglio diretto
Dim nPartId = EgtCreateGroup(GDB_ID.ROOT)
EgtSetName(nPartId, DIRECTCUT)
' Creo layer di taglio
Dim nLayerId = EgtCreateGroup(nPartId)
EgtSetName(nLayerId, "OutLoop")
' Creo il taglio
Dim ptStart As Point3d = m_ptTipP1
Dim ptEnd As Point3d = m_ptTipP2
ptStart.z = 0
ptEnd.z = 0
Dim nCutId = EgtCreateLine(nLayerId, ptStart, ptEnd)
' Imposto affondamento e angolo di fianco sul taglio
EgtSetInfo(nCutId, "Depth", m_dDepth)
EgtSetInfo(nCutId, "SideAng", m_dAngV)
' Creo layer per crocette di riferimento
Dim nCrossLayerId = EgtCreateGroup(nPartId)
' Aggiungo crocette
CreateCross(nCrossLayerId, ptStart)
CreateCross(nCrossLayerId, ptEnd)
' Calcolo punto di inserimento nel grezzo
Dim ptMin, ptMax As Point3d
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, ptMin, ptMax)
Dim ptIns As Point3d = ptMin + (m_ptTabOri - m_ptRawMin)
ptIns.z = dRawHeight
' Inserisco il pezzo nel grezzo
EgtAddPartToRawPart(nPartId, ptIns, m_MainWindow.m_CurrentProjectPageUC.m_nRawId)
' Inserisco la lavorazione
m_bCutOk = AddMachinings(nPartId, True, True)
UpdateOkBtn()
Return m_bCutOk
End Function
Private Function EraseDirectCutPart()
@@ -314,4 +456,15 @@ Public Class SingleCutUC
Return True
End Function
Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean
' Aggiungo crocette
Dim vtCrossX As New Vector3d(20, 0, 0)
Dim vtCrossY As New Vector3d(0, 20, 0)
Dim nCrossId1 = EgtCreateLine(nLayerId, ptP + (-vtCrossX), ptP + vtCrossX)
EgtSetColor(nCrossId1, New Color3d(255, 0, 0))
Dim nCrossId2 = EgtCreateLine(nLayerId, ptP + (-vtCrossY), ptP + vtCrossY)
EgtSetColor(nCrossId2, New Color3d(255, 0, 0))
Return True
End Function
End Class
+30 -14
View File
@@ -191,26 +191,42 @@ Public Class WorkInProgressPageUC
If m_bExecuting Then
Return False
End If
' Valori precedenti degli assi macchina
Dim dL1p, dL2p, dL3p, dR1p, dR2p As Double
Dim bFirst As Boolean = True
' Ciclo
While m_bContinue
m_bExecuting = True
' Recupero la posizione degli assi macchina
Dim dL1, dL2, dL3, dR1, dR2 As Double
m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2)
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
' Muovo la macchina
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
EgtDraw()
If bFirst OrElse
Math.Abs(dL1 - dL1p) > EPS_SMALL OrElse Math.Abs(dL2 - dL2p) > EPS_SMALL OrElse Math.Abs(dL3 - dL3p) > EPS_SMALL OrElse
Math.Abs(dR1 - dR1p) > EPS_ANG_SMALL OrElse Math.Abs(dR2 - dR2p) > EPS_ANG_SMALL Then
bFirst = False
dL1p = dL1
dL2p = dL2
dL3p = dL3
dR1p = dR1
dR2p = dR2
' Recupero il nome degli assi macchina
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
' Muovo la macchina
EgtSetAxisPos(sL1, dL1)
EgtSetAxisPos(sL2, dL2)
EgtSetAxisPos(sL3, dL3)
EgtSetAxisPos(sR1, dR1)
EgtSetAxisPos(sR2, dR2)
EgtDraw()
Else
' Per evitare di ciclare rapidissimamente e consumare inutilmente CPU
System.Threading.Thread.Sleep(1)
End If
' Costringo ad aggiornare UI
Dim nDummy As Integer
Application.Current.Dispatcher.Invoke(Windows.Threading.DispatcherPriority.Background, _