f5c89ac320
- Risolti errori in DrawPage per textbox true o false.
270 lines
12 KiB
VB.net
270 lines
12 KiB
VB.net
Imports System.Windows.Threading
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib
|
|
|
|
Public Class AlarmsPageUC
|
|
|
|
' Riferimento alla MainWindow
|
|
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
|
Private m_CurrentMachine As CurrentMachine
|
|
Friend m_CN As CN_generico
|
|
|
|
' Properties
|
|
Private m_bFirst As Boolean = True
|
|
|
|
'Lista che contiene le lame disponibili (per Combobox pagina Alarms)
|
|
Private m_SawList As New List(Of String)
|
|
Private m_DrillList As New List(Of String)
|
|
Private m_MillList As New List(Of String)
|
|
Private m_AuxToolTypeList As New List(Of String)
|
|
|
|
Private Sub AlarmsPage_Initialized(sender As Object, e As EventArgs)
|
|
|
|
'Assegno liste a combobox
|
|
CurrSawCmBx.ItemsSource = m_SawList
|
|
CurrDrillCmBx.ItemsSource = m_DrillList
|
|
CurrMillCmBx.ItemsSource = m_MillList
|
|
AuxiliaryToolCmBx.ItemsSource = m_AuxToolTypeList
|
|
|
|
'Imposto i messaggi letti dal file dei messaggi
|
|
CurrSawTxBl.Text = EgtMsg(MSG_ALARMSPAGEUC + 1)
|
|
AuxiliaryToolTxBl.Text = EgtMsg(MSG_ALARMSPAGEUC + 2)
|
|
CurrDrillTxBl.Text = EgtMsg(MSG_ALARMSPAGEUC + 3)
|
|
CurrMillTxBl.Text = EgtMsg(MSG_ALARMSPAGEUC + 4)
|
|
SafeZTxBl.Text = EgtMsg(MSG_ALARMSPAGEUC + 5)
|
|
CutExtraLenTxBl.Text = EgtMsg(MSG_ALARMSPAGEUC + 6)
|
|
AngleCutExtraLenTxBl.Text = EgtMsg(MSG_ALARMSPAGEUC + 7)
|
|
CompleteCutsTxBl.Text = EgtMsg(MSG_ALARMSPAGEUC + 8)
|
|
|
|
End Sub
|
|
|
|
Private Sub AlarmsPage_Loaded(sender As Object, e As RoutedEventArgs)
|
|
|
|
' Variabile che accorcia il riferimento alla macchina corrente
|
|
m_CurrentMachine = m_MainWindow.m_CurrentMachine
|
|
|
|
If Not m_MainWindow.m_bNCLink = 0 Then
|
|
ErrorLstBx.ItemsSource = m_CN.sz_NC_error_messages
|
|
End If
|
|
|
|
' Aggiorno lista delle lame per pagina macchina in cui scegliere quella corrente
|
|
CreateToolList(MCH_TF.SAWBLADE, m_SawList)
|
|
' Seleziono lama corrente
|
|
CurrSawCmBx.SelectedItem = m_CurrentMachine.sCurrSaw
|
|
|
|
' Verifico la configurazione della macchina per creare i combobox
|
|
Select Case m_CurrentMachine.MountedToolConfig
|
|
Case CurrentMachine.MountedToolConfigs.SAW
|
|
'Non eseguo alcuna azione
|
|
Case CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL
|
|
m_AuxToolTypeList.Add("Nessuno")
|
|
If m_CurrentMachine.bDrilling Then
|
|
m_AuxToolTypeList.Add("Fresatura")
|
|
If m_CurrentMachine.bMilling Then
|
|
m_AuxToolTypeList.Add("Foratura")
|
|
End If
|
|
Else
|
|
If m_CurrentMachine.bMilling Then
|
|
m_AuxToolTypeList.Add("Foratura")
|
|
End If
|
|
End If
|
|
|
|
AuxiliaryToolTxBl.Visibility = Windows.Visibility.Visible
|
|
AuxiliaryToolCmBx.Visibility = Windows.Visibility.Visible
|
|
CurrDrillTxBl.Visibility = Windows.Visibility.Hidden
|
|
CurrDrillCmBx.Visibility = Windows.Visibility.Hidden
|
|
CurrMillTxBl.Visibility = Windows.Visibility.Hidden
|
|
CurrMillCmBx.Visibility = Windows.Visibility.Hidden
|
|
|
|
If m_CurrentMachine.sCurrDrill <> String.Empty Then
|
|
AuxiliaryToolCmBx.SelectedItem = "Foratura"
|
|
CurrDrillTxBl.SetValue(Grid.RowProperty, 4)
|
|
CurrDrillCmBx.SetValue(Grid.RowProperty, 5)
|
|
CurrDrillTxBl.Visibility = Windows.Visibility.Visible
|
|
CurrDrillCmBx.Visibility = Windows.Visibility.Visible
|
|
ElseIf m_CurrentMachine.sCurrMill <> String.Empty Then
|
|
AuxiliaryToolCmBx.SelectedItem = "Fresatura"
|
|
CurrMillTxBl.Visibility = Windows.Visibility.Visible
|
|
CurrMillCmBx.Visibility = Windows.Visibility.Visible
|
|
Else
|
|
AuxiliaryToolCmBx.SelectedItem = "Nessuno"
|
|
End If
|
|
|
|
Case CurrentMachine.MountedToolConfigs.MANUALTOOLCHANGER, CurrentMachine.MountedToolConfigs.TOOLCHANGER
|
|
SetUpBtn.Visibility = Windows.Visibility.Visible
|
|
'CreateToolList(MCH_TF.DRILLBIT, m_DrillList)
|
|
'm_DrillList.Add("Nessuno")
|
|
'CreateToolList(MCH_TF.MILL, m_MillList)
|
|
'm_MillList.Add("Nessuna")
|
|
'AuxiliaryToolTxBl.Visibility = Windows.Visibility.Hidden
|
|
'AuxiliaryToolCmBx.Visibility = Windows.Visibility.Hidden
|
|
'CurrDrillTxBl.Visibility = Windows.Visibility.Visible
|
|
'CurrDrillCmBx.Visibility = Windows.Visibility.Visible
|
|
'CurrMillTxBl.Visibility = Windows.Visibility.Visible
|
|
'CurrMillCmBx.Visibility = Windows.Visibility.Visible
|
|
'If m_CurrentMachine.sCurrDrill <> String.Empty Then
|
|
' CurrDrillCmBx.SelectedItem = m_CurrentMachine.sCurrDrill
|
|
'Else
|
|
' CurrDrillCmBx.SelectedItem = "Nessuno"
|
|
'End If
|
|
'If m_CurrentMachine.sCurrMill <> String.Empty Then
|
|
' CurrMillCmBx.SelectedItem = m_CurrentMachine.sCurrMill
|
|
'Else
|
|
' CurrMillCmBx.SelectedItem = "Nessuna"
|
|
'End If
|
|
End Select
|
|
|
|
' Leggo distanza di sicurezza
|
|
Dim dSafeZ As Double = 0
|
|
EgtMdbGetSafeZ(dSafeZ)
|
|
SafeZTxBx.Text = LenToString(dSafeZ, 2)
|
|
|
|
' Leggo tagli ridotti per interferenza in nesting
|
|
CompleteCutsChBx.IsChecked =
|
|
(GetPrivateProfileInt(S_MACH_NEST, K_MACH_REDUCEDCUT, 0, m_MainWindow.GetMachIniFile()) = 0)
|
|
End Sub
|
|
|
|
Private Sub AuxiliaryToolCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles AuxiliaryToolCmBx.SelectionChanged
|
|
Select Case AuxiliaryToolCmBx.SelectedItem
|
|
Case "Nessuno"
|
|
CurrDrillTxBl.Visibility = Windows.Visibility.Hidden
|
|
CurrDrillCmBx.Visibility = Windows.Visibility.Hidden
|
|
CurrMillTxBl.Visibility = Windows.Visibility.Hidden
|
|
CurrMillCmBx.Visibility = Windows.Visibility.Hidden
|
|
m_CurrentMachine.sCurrDrill = String.Empty
|
|
m_CurrentMachine.sCurrMill = String.Empty
|
|
Case "Foratura"
|
|
CreateToolList(MCH_TF.DRILLBIT, m_DrillList)
|
|
m_DrillList.Add("Nessuno")
|
|
CurrDrillTxBl.SetValue(Grid.RowProperty, 4)
|
|
CurrDrillCmBx.SetValue(Grid.RowProperty, 5)
|
|
If m_CurrentMachine.sCurrDrill = String.Empty Then
|
|
CurrDrillCmBx.SelectedItem = "Nessuno"
|
|
Else
|
|
CurrDrillCmBx.SelectedItem = m_CurrentMachine.sCurrDrill
|
|
End If
|
|
m_CurrentMachine.sCurrMill = String.Empty
|
|
CurrDrillTxBl.Visibility = Windows.Visibility.Visible
|
|
CurrDrillCmBx.Visibility = Windows.Visibility.Visible
|
|
CurrMillTxBl.Visibility = Windows.Visibility.Hidden
|
|
CurrMillCmBx.Visibility = Windows.Visibility.Hidden
|
|
Case "Fresatura"
|
|
CreateToolList(MCH_TF.MILL, m_MillList)
|
|
m_MillList.Add("Nessuna")
|
|
If m_CurrentMachine.sCurrMill = String.Empty Then
|
|
CurrMillCmBx.SelectedItem = "Nessuna"
|
|
Else
|
|
CurrMillCmBx.SelectedItem = m_CurrentMachine.sCurrMill
|
|
End If
|
|
m_CurrentMachine.sCurrDrill = String.Empty
|
|
CurrMillCmBx.SelectedItem = m_CurrentMachine.sCurrMill
|
|
CurrDrillTxBl.Visibility = Windows.Visibility.Hidden
|
|
CurrDrillCmBx.Visibility = Windows.Visibility.Hidden
|
|
CurrMillTxBl.Visibility = Windows.Visibility.Visible
|
|
CurrMillCmBx.Visibility = Windows.Visibility.Visible
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub CurrSawCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles CurrSawCmBx.SelectionChanged
|
|
'WritePrivateProfileString(S_MACH, K_CURRSAW, CurrSawCmBx.SelectedItem, m_MainWindow.GetIniFile())
|
|
m_CurrentMachine.sCurrSaw = CurrSawCmBx.SelectedItem
|
|
|
|
End Sub
|
|
|
|
Private Sub CurrDrillCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles CurrDrillCmBx.SelectionChanged
|
|
If CurrDrillCmBx.SelectedItem = "Nessuno" Then
|
|
m_CurrentMachine.sCurrDrill = String.Empty
|
|
Else
|
|
m_CurrentMachine.sCurrDrill = CurrDrillCmBx.SelectedItem
|
|
If m_CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL Then
|
|
m_CurrentMachine.sCurrMill = String.Empty
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CurrMillCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles CurrMillCmBx.SelectionChanged
|
|
If CurrMillCmBx.SelectedItem = "Nessuna" Then
|
|
m_CurrentMachine.sCurrMill = String.Empty
|
|
Else
|
|
m_CurrentMachine.sCurrMill = CurrMillCmBx.SelectedItem
|
|
If m_CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL Then
|
|
m_CurrentMachine.sCurrDrill = String.Empty
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CreateToolList(ToolType As Integer, ToolList As List(Of String))
|
|
'SawList.Clear()
|
|
Dim ToolName As String = String.Empty
|
|
Dim nType As Integer = MCH_TY.NONE
|
|
If EgtTdbGetFirstTool(ToolType, ToolName, nType) Then
|
|
ToolList.Add(ToolName)
|
|
While EgtTdbGetNextTool(ToolType, ToolName, nType)
|
|
ToolList.Add(ToolName)
|
|
End While
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private Sub SafeZTxBx_EgtClosed(sender As Object, e As EventArgs) Handles SafeZTxBx.EgtClosed
|
|
Dim dSafeZ As Double = 0
|
|
StringToLen(SafeZTxBx.Text, dSafeZ)
|
|
EgtMdbSetSafeZ(dSafeZ)
|
|
EgtMdbSave()
|
|
End Sub
|
|
|
|
Private Sub CompleteCutsChBx_Click(sender As Object, e As RoutedEventArgs) Handles CompleteCutsChBx.Click
|
|
Dim NestPage As NestPageUC = m_MainWindow.m_CadCutPageUC.m_NestPage
|
|
If CompleteCutsChBx.IsChecked() Then
|
|
' Se pezzi in interferenza
|
|
If Not NestPage.VerifyPartsNesting(False) Then
|
|
' Ci sono interferenze, alcuni pezzi saranno parcheggiati. Vuoi continuare ?
|
|
Dim Dlg As New EgtMsgBox(m_MainWindow, "", EgtMsg(91105), EgtMsgBox.Buttons.OK_CANCEL, EgtMsgBox.Icons.ESCLAMATION, 1)
|
|
If Dlg.DialogResult = 1 Then ' Ok
|
|
NestPage.StoreCollisionParts(False)
|
|
WritePrivateProfileString(S_MACH_NEST, K_MACH_REDUCEDCUT, "0", m_MainWindow.GetMachIniFile())
|
|
End If
|
|
Else
|
|
WritePrivateProfileString(S_MACH_NEST, K_MACH_REDUCEDCUT, "0", m_MainWindow.GetMachIniFile())
|
|
End If
|
|
Else
|
|
WritePrivateProfileString(S_MACH_NEST, K_MACH_REDUCEDCUT, "1", m_MainWindow.GetMachIniFile())
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Friend Sub NcError()
|
|
If m_CN.sz_NC_error_messages.Count > 0 Then
|
|
NCErrorMessages.Text = m_CN.sz_NC_error_messages(0)
|
|
If m_CN.bIsErrorMessage Then
|
|
m_MainWindow.m_MachineStatusUC.MachineStatusGrid.Background = Brushes.Red
|
|
End If
|
|
Else
|
|
NCErrorMessages.Text = ""
|
|
Dim BackColor As SolidColorBrush = m_MainWindow.m_MachineStatusUC.MachineStatusGrid.Background
|
|
If Colors.Red.Equals(BackColor.Color) Then
|
|
m_MainWindow.m_MachineStatusUC.MachineStatusGrid.Background = Brushes.DarkGray
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub PlcError(ErrorMsg As String)
|
|
' m_MainWindow.m_MachineStatusUC.Background = Brushes.Red
|
|
' Dim sFilePath As String = m_MainWindow.GetMachinesRootDir() & "/PLCMessages/" & EgtMsg(MSG_MACHINEPAGEUC + 1)
|
|
' Try
|
|
' Dim sErrorText As String = File.ReadLines(sFilePath).Skip(m_CN.sz_PLC_error_messages).Take(1).First()
|
|
' sErrorText = sErrorText.Substring(sErrorText.IndexOf("$"))
|
|
' If sErrorText(0) = " " Then
|
|
' sErrorText = sErrorText.Substring(1)
|
|
' End If
|
|
' PLCErrorMessages.Text = sErrorText
|
|
' Catch ex As Exception
|
|
' MsgBox("Errore lettura errori PLC")
|
|
' End Try
|
|
|
|
End Sub
|
|
|
|
End Class
|