Files
OmagCUT/MachineStatusUC.xaml.vb
T
Emmanuele Sassi 555a19603c OmagCUT :
- aggiunta tastiera.
- migliorata comunicazione Axium(non visualizza gli errori).
- aggiunti bottoni macchina nella pagina tagli diretti.
- migliorata pagina db utensili.
2015-11-17 08:38:52 +00:00

285 lines
7.5 KiB
VB.net

Imports System.Windows.Threading
Imports System.Globalization
Imports EgtUILib
Public Class MachineStatusUC
Friend m_CN As CN_generico
' 'Const
Private Const MAX_AXES As Integer = 9
' ' Riferimento alla MainWindow
Private m_MainWindow As MainWindow = Application.Current.MainWindow
' 'Variabile per presenza collegamento al CN
' Private m_bNCLink As Integer
' 'Variabile per tipologia CN
' Private m_iNCType As Integer
' 'Variabile per stato CN
' Private b_Nc_simulation As Boolean = False
''Variabile che indica il Mode corrente
'Private CurrMode As Integer
' 'Classe del CN
'Public WithEvents cn As CN_generico
' Private b_new_pos_data As Boolean = False
' Private b_new_delta_data As Boolean = False
' Private b_new_var_data As Boolean = False
' Private b_timer_busy As Boolean = False
' 'Creazione timer
' Dim RefreshTimer As New DispatcherTimer
Private Sub MachineStatus_Initialized(sender As Object, e As EventArgs)
''Verifico presenza del collegamento al CN
'm_bNCLink = GetPrivateProfileInt(S_GENERAL, K_CNLINK, 0, m_MainWindow.GetIniFile())
''Verifico tipologia del CN
'm_iNCType = GetPrivateProfileInt(S_NUMERICALCONTROL, K_TYPE, 0, m_MainWindow.m_sMachIniFile)
'If m_bNCLink Then
' AddHandler RefreshTimer.Tick, AddressOf RefreshTimer_tick
' RefreshTimer.Interval = TimeSpan.FromMilliseconds(100)
' RefreshTimer.Start()
' Call InitCn()
'End If
End Sub
'Private Sub RefreshTimer_tick()
' If Not b_timer_busy Then
' b_timer_busy = True
' RefreshTimer.Stop()
' Call refresh()
' b_timer_busy = False
' RefreshTimer.Start()
' Else
' Dim x As Integer = 10
' End If
'End Sub
'Private Sub InitCn()
' If m_bNCLink = 1 Then
' MachineStatusGrid.Background = Brushes.Tomato
' ' istanzio l'oggetto CN
' Try
' Select Case m_iNCType
' Case 1
' cn = New Num.NumNCOld
' Case Else
' cn = New Num.NumNC
' End Select
' Catch ex As Exception
' ' set status to statusbar
' MsgBox(ex.Message)
' End Try
' Select Case m_iNCType
' Case 1
' Case Else
' While cn.n_state < 2
' System.Threading.Thread.Sleep(500) ' 0.5 sec wait!!!!!!!!
' End While
' End Select
' cn.b_axis_events_enable = True
' MachineStatusGrid.Background = Brushes.Gray
' Else ' se in debug
' MachineStatusGrid.Background = Brushes.Gold
' End If
'End Sub
'Private Sub NewVarChanged_handler(ByVal nst As Object) Handles cn.NewVarChanged
' b_new_var_data = True
'End Sub
'Private Sub NewPositionData_handler(ByVal nst As Short) Handles cn.NewPositionData
' b_new_pos_data = True
'End Sub
'Private Sub NewPosDeltaData_handler(ByVal nst As Short) Handles cn.NewPosDeltaData
' b_new_delta_data = True
'End Sub
'Sub refresh()
' If b_new_pos_data Then
' b_new_pos_data = False
' Call DisplayPosition()
' End If
' If b_new_delta_data Then
' b_new_delta_data = False
' Call DisplayDeltaPosition()
' End If
' If b_new_var_data Then
' b_new_var_data = False
' Call DisplayVar()
' End If
' If cn.b_feed_override_changed Then
' cn.b_feed_override_changed = False
' FeedOverrideLbl.Content = cn.d_DInterpo_Feed_override.ToString & "%"
' FeedLbl.Content = cn.d_DInterpo_Prog_Feed.ToString
' End If
' If cn.b_spindle_data_changed Then
' cn.b_spindle_data_changed = False
' SpeedOverrideLbl.Content = cn.n_spindle_override(0).ToString
' SpeedLbl.Content = cn.d_spindle_prog(0).ToString
' End If
' If cn.b_Tool_data_changed Then
' cn.b_Tool_data_changed = False
' 'FrmMain.LblToolLen.Text = cn.Tools(0).lenght.ToString
' 'FrmMain.LblToolRad.Text = cn.Tools(0).radius.ToString
' 'FrmMain.LblToolComp.Text = cn.Tools(0).comp_num.ToString
' End If
' If cn.read_active_mode() <> CurrMode Then
' CurrMode = cn.read_active_mode()
' Call DisplayActiveMode(CurrMode)
' End If
' If cn.b_NC_error Then
' m_MainWindow.m_AlarmsPageUC.ErrorMessages.Text = cn.sz_NC_error_messages(0)
' Else
' m_MainWindow.m_AlarmsPageUC.ErrorMessages.Text = "---------"
' End If
' If cn.b_PLC_error Then
' m_MainWindow.m_AlarmsPageUC.ErrorMessages.Text = cn.sz_PLC_error_messages
' Else
' m_MainWindow.m_AlarmsPageUC.ErrorMessages.Text = "---------"
' End If
'End Sub
Sub DisplayPosition()
For n As Short = 0 To MAX_AXES - 1
Select Case n
Case 0 'X
Axis1Lbl.Content = m_CN.d_axis_position(n).ToString("F3", CultureInfo.InvariantCulture)
Case 1
Axis2Lbl.Content = m_CN.d_axis_position(n).ToString("F3", CultureInfo.InvariantCulture)
Case 2
Axis3Lbl.Content = m_CN.d_axis_position(n).ToString("F3", CultureInfo.InvariantCulture)
Case 7
Axis5Lbl.Content = m_CN.d_axis_position(n).ToString("F3", CultureInfo.InvariantCulture)
Case 8
Axis4Lbl.Content = m_CN.d_axis_position(n).ToString("F3", CultureInfo.InvariantCulture)
End Select
Next
End Sub
Sub DisplayDeltaPosition()
For n As Short = 0 To MAX_AXES - 1
Select Case n
Case 0 'X
DeltaAxis1Lbl.Content = m_CN.d_axis_delta(n).ToString("F3", CultureInfo.InvariantCulture)
Case 1
DeltaAxis2Lbl.Content = m_CN.d_axis_delta(n).ToString("F3", CultureInfo.InvariantCulture)
Case 2
DeltaAxis3Lbl.Content = m_CN.d_axis_delta(n).ToString("F3", CultureInfo.InvariantCulture)
Case 7
DeltaAxis4Lbl.Content = m_CN.d_axis_delta(n).ToString("F3", CultureInfo.InvariantCulture)
Case 8
DeltaAxis5Lbl.Content = m_CN.d_axis_delta(n).ToString("F3", CultureInfo.InvariantCulture)
End Select
Next
End Sub
Sub DisplayFeed()
FeedOverrideLbl.Content = m_CN.d_DInterpo_Feed_override.ToString & "%"
FeedLbl.Content = m_CN.d_DInterpo_Prog_Feed.ToString
End Sub
Sub DisplaySpeed()
SpeedOverrideLbl.Content = m_CN.n_spindle_override(0).ToString
SpeedLbl.Content = m_CN.d_spindle_prog(0).ToString
End Sub
Sub DisplayCNError(CNError As Boolean)
End Sub
Sub DisplayPLCError()
End Sub
Sub DisplayActiveMode(Mode As Integer)
Select Case Mode
Case 0
MachineStatusImage.Source = New System.Windows.Media.Imaging.BitmapImage(New Uri("/Resources/Nest.png", UriKind.Relative))
Case 1
Case 2
Case 3
Case 7
End Select
End Sub
Sub DisplayVar()
'For n As Short = 0 To FrmMain.MAX_AXES - 1
' lbl_var_values(n).Text = cn.d_Dvariable_values(n * 10).ToString
'Next
End Sub
End Class