ed0ac05479
- Miglioramenti comunicazione CN Flexium. - Aggiunti comandi MDI attraverso LUA in pagina tagli diretti.
167 lines
6.2 KiB
VB.net
167 lines
6.2 KiB
VB.net
Imports EgtUILib
|
|
|
|
Public Class MachineButtonsUC
|
|
|
|
'Riferimento alla MainWindow
|
|
Dim m_MainWindow As MainWindow = Application.Current.MainWindow
|
|
Private m_DirectCutPage As DirectCutPageUC
|
|
Friend m_CN As CN_generico
|
|
|
|
Private m_bFirst As Boolean = True
|
|
|
|
Dim CommandArray(15) As String
|
|
|
|
Private Sub MachineButtons_Loaded(sender As Object, e As RoutedEventArgs)
|
|
|
|
If m_bFirst Then
|
|
|
|
m_DirectCutPage = m_MainWindow.m_DirectCutPageUC
|
|
|
|
'If m_MainWindow.m_bNCLink <> 0 Then
|
|
' 'Rinomino cn per avere nome più corto
|
|
' m_CN = m_MainWindow.m_CNCommunication.m_CN
|
|
'End If
|
|
m_bFirst = False
|
|
End If
|
|
' Creazione converter da String a ImageSource
|
|
Dim ImageConverter As New ImageSourceConverter
|
|
|
|
Dim sButtonImage As String = String.Empty
|
|
Dim sButtonImageSource As ImageSource
|
|
Dim sButtonCommand As String = String.Empty
|
|
Dim nIndex As Integer = 0
|
|
While GetPrivateProfileMachineButtons(S_MACHBUTTONS, K_BUTTON & (nIndex + 1), sButtonImage, sButtonCommand, m_MainWindow.GetMachIniFile())
|
|
CommandArray(nIndex) = sButtonCommand
|
|
Try
|
|
Dim s As String = m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sButtonImage
|
|
sButtonImageSource = ImageConverter.ConvertFromString(s)
|
|
GetImage(nIndex + 1).Source = sButtonImageSource
|
|
Catch ex As Exception
|
|
EgtOutLog("Error loading image " & sButtonImage)
|
|
End Try
|
|
nIndex += 1
|
|
End While
|
|
End Sub
|
|
|
|
Private Sub MachineButton_Click(sender As Object, e As RoutedEventArgs) Handles MachineButton1.Click, MachineButton2.Click, MachineButton3.Click, MachineButton4.Click, MachineButton5.Click, MachineButton6.Click, MachineButton7.Click,
|
|
MachineButton8.Click, MachineButton9.Click, MachineButton10.Click, MachineButton11.Click, MachineButton12.Click, MachineButton13.Click
|
|
Dim CurrentBtn As Button = e.Source
|
|
Dim dTemp As Double = 0
|
|
Dim sTemp As String = String.Empty
|
|
Dim CmdString As String = String.Empty
|
|
EgtLuaExecFile(m_MainWindow.GetMachinesRootDir() & "\" & m_MainWindow.GetCurrMachine() & "\DirectCmd\" & CommandArray(GetButtonIndex(CurrentBtn) - 1))
|
|
StringToDouble(m_DirectCutPage.FeedTxBx.Text, dTemp)
|
|
EgtLuaSetGlobNumVar("CMD.F", dTemp)
|
|
StringToDouble(m_DirectCutPage.SpeedTxBx.Text, dTemp)
|
|
EgtLuaSetGlobNumVar("CMD.S", dTemp)
|
|
GetPrivateProfileString(S_AXES, K_L1ID, "", sTemp, m_MainWindow.GetMachIniFile())
|
|
StringToDouble(m_MainWindow.m_CNCommunication.m_CN.d_axis_position(sTemp), dTemp)
|
|
EgtLuaSetGlobNumVar("CMD.L1", dTemp)
|
|
GetPrivateProfileString(S_AXES, K_L2ID, "", sTemp, m_MainWindow.GetMachIniFile())
|
|
StringToDouble(m_MainWindow.m_CNCommunication.m_CN.d_axis_position(sTemp), dTemp)
|
|
EgtLuaSetGlobNumVar("CMD.L2", dTemp)
|
|
GetPrivateProfileString(S_AXES, K_L3ID, "", sTemp, m_MainWindow.GetMachIniFile())
|
|
StringToDouble(m_MainWindow.m_CNCommunication.m_CN.d_axis_position(sTemp), dTemp)
|
|
EgtLuaSetGlobNumVar("CMD.L3", dTemp)
|
|
GetPrivateProfileString(S_AXES, K_R1ID, "", sTemp, m_MainWindow.GetMachIniFile())
|
|
StringToDouble(m_MainWindow.m_CNCommunication.m_CN.d_axis_position(sTemp), dTemp)
|
|
EgtLuaSetGlobNumVar("CMD.R1", dTemp)
|
|
GetPrivateProfileString(S_AXES, K_R2ID, "", sTemp, m_MainWindow.GetMachIniFile())
|
|
StringToDouble(m_MainWindow.m_CNCommunication.m_CN.d_axis_position(sTemp), dTemp)
|
|
EgtLuaSetGlobNumVar("CMD.R2", dTemp)
|
|
EgtLuaExecLine("CmdString()")
|
|
EgtLuaGetGlobStringVar("CMD.CMDSTRING", CmdString)
|
|
EgtLuaResetGlobVar("CmdString")
|
|
EgtLuaResetGlobVar("CMD")
|
|
|
|
m_CN.DGeneralFunctions_WriteCncMode(2)
|
|
m_CN.sz_ManualDataInput = CmdString
|
|
m_CN.MDI_command()
|
|
m_CN.DGeneralFunctions_CycleStart()
|
|
m_CN.DGeneralFunctions_WriteCncMode(7)
|
|
|
|
End Sub
|
|
|
|
Private Function GetButtonIndex(ByVal nBtnName As Button) As Integer
|
|
Select Case nBtnName.Name
|
|
Case MachineButton1.Name
|
|
Return 1
|
|
Case MachineButton2.Name
|
|
Return 2
|
|
Case MachineButton3.Name
|
|
Return 3
|
|
Case MachineButton4.Name
|
|
Return 4
|
|
Case MachineButton5.Name
|
|
Return 5
|
|
Case MachineButton6.Name
|
|
Return 6
|
|
Case MachineButton7.Name
|
|
Return 7
|
|
Case MachineButton8.Name
|
|
Return 8
|
|
Case MachineButton9.Name
|
|
Return 9
|
|
Case MachineButton10.Name
|
|
Return 10
|
|
Case MachineButton11.Name
|
|
Return 11
|
|
Case MachineButton12.Name
|
|
Return 12
|
|
Case Else
|
|
Return 13
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetImage(ByVal nInd As Integer) As Image
|
|
Select Case nInd
|
|
Case 1
|
|
Return ImageButton1
|
|
Case 2
|
|
Return ImageButton2
|
|
Case 3
|
|
Return ImageButton3
|
|
Case 4
|
|
Return ImageButton4
|
|
Case 5
|
|
Return ImageButton5
|
|
Case 6
|
|
Return ImageButton6
|
|
Case 7
|
|
Return ImageButton7
|
|
Case 8
|
|
Return ImageButton8
|
|
Case 9
|
|
Return ImageButton9
|
|
Case 10
|
|
Return ImageButton10
|
|
Case 11
|
|
Return ImageButton11
|
|
Case 12
|
|
Return ImageButton12
|
|
Case Else
|
|
Return ImageButton13
|
|
End Select
|
|
End Function
|
|
|
|
Public Function GetPrivateProfileMachineButtons(
|
|
ByVal lpAppName As String,
|
|
ByVal lpKeyName As String,
|
|
ByRef lpButtonImage As String,
|
|
ByRef lpCommand As String,
|
|
ByVal lpFileName As String) As Boolean
|
|
|
|
Dim sVal As String = String.Empty
|
|
GetPrivateProfileString(lpAppName, lpKeyName, "", sVal, lpFileName)
|
|
Dim sItems() As String = sVal.Split(",".ToCharArray)
|
|
If sItems.Count() >= 2 Then
|
|
lpButtonImage = sItems(0)
|
|
lpCommand = sItems(1)
|
|
Return True
|
|
End If
|
|
Return False
|
|
|
|
End Function
|
|
|
|
End Class
|