Files
OmagCUT/Machine/MachineCNPageUC.xaml.vb
T
Emmanuele Sassi 8c6fbcf8ac OmagCUT :
- correzioni per comunicazione Siemens.
2021-02-17 11:01:56 +00:00

182 lines
8.3 KiB
VB.net

Imports EgtUILib
Public Class MachineCNPageUC
' Riferimento alla MainWindow
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
Friend m_CN As CN_generico
Private m_bFirst As Boolean = True
Private Sub TestingPage_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
StartBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 1)
StopBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 2)
ResetBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 3)
AutoBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 4)
SingleBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 5)
MDIBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 6)
ManualBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 7)
HomeBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 8)
DownloadBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 9)
UploadBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 10)
ActivateBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 11)
DeleteBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 12)
MDIConfirmBtn.Content = EgtMsg(MSG_MACHINECNPAGEUC + 13)
CNModeGpBx.Header = EgtMsg(MSG_MACHINECNPAGEUC + 14)
CommandsGpBx.Header = EgtMsg(MSG_MACHINECNPAGEUC + 15)
MDICommandGpBx.Header = EgtMsg(MSG_MACHINECNPAGEUC + 16)
PartProgTransferGpBx.Header = EgtMsg(MSG_MACHINECNPAGEUC + 17)
ErrorLstGpBx.Header = EgtMsg(MSG_ALARMSPAGEUC + 12)
' Attivo gruppo PartProgTransferGpBx leggendo la variabile nel file ini
If GetPrivateProfileInt(S_GENERAL, K_TESTINGPAGE, 0, m_MainWindow.GetIniFile()) = 1 Then
PartProgTransferGpBx.Visibility = Windows.Visibility.Visible
Else
PartProgTransferGpBx.Visibility = Windows.Visibility.Hidden
End If
End Sub
Private Sub TestingPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
If m_MainWindow.m_CNCommunication.m_nNCType = 3 AndAlso m_MainWindow.m_CNCommunication.m_CN.m_IsSiemensOne Then
HomeBtn.Visibility = Visibility.Collapsed
SingleBtn.Visibility = Visibility.Collapsed
PartProgTransferGpBx.Visibility = Windows.Visibility.Hidden
End If
End Sub
Private Sub StartBtn_Click(sender As Object, e As RoutedEventArgs) Handles StartBtn.Click
If m_MainWindow.m_CNCommunication.m_nNCType = 3 AndAlso m_MainWindow.m_CNCommunication.m_CN.m_IsSiemensOne Then
Dim sDBVarPath As String = ""
GetPrivateProfileString(S_NCSIEMENS, K_DBVARPATH, "", sDBVarPath, m_MainWindow.GetMachIniFile)
sDBVarPath &= "Start_Cycle"
m_CN.DVariables_WriteVariables3(sDBVarPath, 1, 1, 0, 0, "") ' Modalità manuale
Else
m_CN.DGeneralFunctions_CycleStart()
End If
End Sub
Private Sub StopBtn_Click(sender As Object, e As RoutedEventArgs) Handles StopBtn.Click
If m_MainWindow.m_CNCommunication.m_nNCType = 3 AndAlso m_MainWindow.m_CNCommunication.m_CN.m_IsSiemensOne Then
Dim sDBVarPath As String = ""
GetPrivateProfileString(S_NCSIEMENS, K_DBVARPATH, "", sDBVarPath, m_MainWindow.GetMachIniFile)
sDBVarPath &= "Stop_Cycle"
m_CN.DVariables_WriteVariables3(sDBVarPath, 1, 0, 0, 0, "") ' Modalità manuale
Else
m_CN.DGeneralFunctions_FeedHold()
End If
End Sub
Private Sub ResetBtn_Click(sender As Object, ghe As RoutedEventArgs) Handles ResetBtn.Click
If m_MainWindow.m_CNCommunication.m_nNCType = 3 AndAlso m_MainWindow.m_CNCommunication.m_CN.m_IsSiemensOne Then
Dim sDBVarPath As String = ""
GetPrivateProfileString(S_NCSIEMENS, K_DBVARPATH, "", sDBVarPath, m_MainWindow.GetMachIniFile)
sDBVarPath &= "Reset_Cycle"
m_CN.DVariables_WriteVariables3(sDBVarPath, 1, 1, 0, 0, "") ' Modalità manuale
Else
Call m_CN.DGeneralFunctions_Reset()
End If
End Sub
Private Sub AutoBtn_Click(sender As Object, e As RoutedEventArgs) Handles AutoBtn.Click
m_CN.DGeneralFunctions_WriteCncMode(0)
End Sub
Private Sub SingleBtn_Click(sender As Object, e As RoutedEventArgs) Handles SingleBtn.Click
m_CN.DGeneralFunctions_WriteCncMode(1)
End Sub
Private Sub MDIBtn_Click(sender As Object, e As RoutedEventArgs) Handles MDIBtn.Click
m_CN.DGeneralFunctions_WriteCncMode(2)
End Sub
Private Sub ManualBtn_Click(sender As Object, e As RoutedEventArgs) Handles ManualBtn.Click
m_CN.DGeneralFunctions_WriteCncMode(7)
End Sub
Private Sub HomeBtn_Click(sender As Object, e As RoutedEventArgs) Handles HomeBtn.Click
m_CN.DGeneralFunctions_WriteCncMode(8)
End Sub
Private Sub MDITxBx_KeyDown(sender As Object, e As KeyEventArgs) Handles MDITxBx.KeyDown
If e.Key = Key.Return Then
' leggo se stato reset
If Not m_CN.bResetState Then Return
m_CN.sz_ManualDataInput = MDITxBx.Text
' se attivi nuovi comandi MDI su siemens
If m_MainWindow.m_CNCommunication.m_nNCType = 3 AndAlso GetPrivateProfileInt(S_NCSIEMENS, K_USENEWMDI, 0, m_MainWindow.GetMachIniFile()) > 0 Then
EgtOutLog("MDI command: " & m_CN.sz_ManualDataInput)
Dim x = m_CN.New_MDI_command(1)
EgtOutLog("MDI command res: " & x)
Else
m_CN.MDI_command()
End If
MDITxBx.Background = Brushes.LightGray
'Keyboard.ClearFocus()
End If
End Sub
Private Sub MDITxBx_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) Handles MDITxBx.PreviewMouseDown
MDITxBx.Background = Brushes.White
End Sub
Friend Sub DownloadBtn_Click(sender As Object, e As RoutedEventArgs) Handles DownloadBtn.Click
If m_MainWindow.m_CNCommunication.m_nNCType = 1 Then
m_CN.Delete_NC_prog(DULoadTxBx.Text)
End If
Dim DownloadName As String = String.Empty
If m_MainWindow.m_CNCommunication.m_nNCType = 1 Or m_MainWindow.m_CNCommunication.m_nNCType = 2 Then
DownloadName = "%" & DULoadTxBx.Text
Else
DownloadName = DULoadTxBx.Text
End If
Dim sPcFile As String = m_MainWindow.GetCncDir() & "\" & DULoadTxBx.Text & m_MainWindow.m_CurrentMachine.sIsoFileExt
m_CN.Download_NC_prog(sPcFile, DownloadName)
End Sub
Private Sub UploadBtn_Click(sender As Object, e As RoutedEventArgs) Handles UploadBtn.Click
Dim DownloadName As String = String.Empty
If m_MainWindow.m_CNCommunication.m_nNCType = 1 Or m_MainWindow.m_CNCommunication.m_nNCType = 2 Then
DownloadName = "%" & DULoadTxBx.Text
Else
DownloadName = DULoadTxBx.Text
End If
Dim sPcFile As String = m_MainWindow.GetCncDir() & "\" & DULoadTxBx.Text & m_MainWindow.m_CurrentMachine.sIsoFileExt
m_CN.Upload_NC_prog(sPcFile, DownloadName)
End Sub
Private Sub ActivateBtn_Click(sender As Object, e As RoutedEventArgs) Handles ActivateBtn.Click
If m_MainWindow.m_CNCommunication.m_nNCType = 1 Or m_MainWindow.m_CNCommunication.m_nNCType = 2 Then
Dim nName As Integer = 0
StringToInt(DULoadTxBx.Text, nName)
m_CN.ActivateProgram(nName) ' integer version
Else
m_CN.ActivateProgram(DULoadTxBx.Text) ' string version
End If
End Sub
Private Sub DeleteBtn_Click(sender As Object, e As RoutedEventArgs) Handles DeleteBtn.Click
Dim DeleteName As String = String.Empty
If m_MainWindow.m_CNCommunication.m_nNCType = 1 Or m_MainWindow.m_CNCommunication.m_nNCType = 2 Then
DeleteName = "%" & DULoadTxBx.Text
Else
DeleteName = DULoadTxBx.Text
End If
m_CN.Delete_NC_prog(DeleteName)
End Sub
Private Sub MDIConfirmBtn_Click(sender As Object, e As RoutedEventArgs) Handles MDIConfirmBtn.Click
m_CN.sz_ManualDataInput = MDITxBx.Text
' se attivi nuovi comandi MDI su siemens
If m_MainWindow.m_CNCommunication.m_nNCType = 3 AndAlso GetPrivateProfileInt(S_NCSIEMENS, K_USENEWMDI, 0, m_MainWindow.GetMachIniFile()) > 0 Then
' leggo se stato reset
If Not m_CN.bResetState Then Return
EgtOutLog("MDI command: " & m_CN.sz_ManualDataInput)
Dim x = m_CN.New_MDI_command(1)
EgtOutLog("MDI command res: " & x)
Else
m_CN.MDI_command()
End If
MDITxBx.Background = Brushes.LightGray
End Sub
End Class