ff30a4d3b6
- gestione nesting allineato (con regione di riferimento a L) - gestione epl pezzi rovinati da OmagVIEW per linee di produzione - piccole migliorie varie.
547 lines
22 KiB
VB.net
547 lines
22 KiB
VB.net
Imports System.Windows.Threading
|
|
Imports System.Globalization
|
|
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
|
|
Public Class CNCommunication
|
|
|
|
' Riferimenti a pagine
|
|
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
Private m_MachineStatus As MachineStatusUC = m_MainWindow.m_MachineStatusUC
|
|
Private m_AlarmsPage As AlarmsPageUC = m_MainWindow.m_MachinePageUC.m_AlarmsPageUC
|
|
Private m_CurrProjPage As CurrentProjectPageUC = m_MainWindow.m_CurrentProjectPageUC
|
|
|
|
' Variabile per tipologia CN
|
|
Friend m_nNCType As Integer
|
|
|
|
' Variabile che indica il Mode corrente
|
|
Private m_nCurrMode As Integer = -1
|
|
|
|
' Variabile che contiene la path del programmino di comunicazione CN Siemens
|
|
Public m_sCNSiemensPath As String = String.Empty
|
|
Public m_sCNSiemensHMIPath As String = String.Empty
|
|
|
|
' Oggetto CN
|
|
Public WithEvents m_CN As CN_generico
|
|
|
|
' Flag di aggiornamento dati
|
|
Private m_bNewPosData As Boolean = True
|
|
Private m_bNewDeltaData As Boolean = True
|
|
Private m_bNewVarData As Boolean = False
|
|
Private m_bTimerBusy As Boolean = False
|
|
|
|
' Lista errori
|
|
Friend ErrorList As New ObservableCollection(Of String)
|
|
|
|
' Timer
|
|
Private m_RefreshTimer As New DispatcherTimer
|
|
|
|
' Nomi e indici degli assi macchina
|
|
Private m_bAxesOk As Boolean = False
|
|
Private m_sL1 As String = "X"
|
|
Private m_nL1 As Integer = 0
|
|
Private m_sL2 As String = "Y"
|
|
Private m_nL2 As Integer = 1
|
|
Private m_sL3 As String = "Z"
|
|
Private m_nL3 As Integer = 2
|
|
Private m_sR1 As String = "C"
|
|
Private m_nR1 As Integer = 8
|
|
Private m_sR2 As String = "B"
|
|
Private m_nR2 As Integer = 7
|
|
Private m_bInInches As Boolean = False ' Solo per comandi diretti (assi sempre in mm)
|
|
|
|
|
|
Friend Sub CNCommunication_Initialization()
|
|
|
|
' Verifico tipologia del CN
|
|
If Not m_MainWindow.m_bNCLink Then
|
|
m_nNCType = 0
|
|
Else
|
|
m_nNCType = GetPrivateProfileInt(S_NUMERICALCONTROL, K_TYPE, 0, m_MainWindow.GetMachIniFile())
|
|
End If
|
|
EgtOutLog("NcLink=" & m_MainWindow.m_bNCLink.ToString & " type=" & m_nNCType)
|
|
|
|
' Se CNSiemens leggo dati programma intermedio di comunicazione
|
|
If m_nNCType = 3 Then
|
|
Dim sExeName As String = String.Empty
|
|
GetPrivateProfileString(S_NCSIEMENS, K_COMM_NAME, "", sExeName, m_MainWindow.m_CurrentMachine.sMachIniFile)
|
|
m_sCNSiemensPath = m_MainWindow.GetExeRootDir() & "\" & sExeName
|
|
GetPrivateProfileString(S_NCSIEMENS, K_PATH_HMI, "", m_sCNSiemensHMIPath, m_MainWindow.m_CurrentMachine.sMachIniFile)
|
|
End If
|
|
|
|
' Inizializzo la connessione
|
|
InitCn()
|
|
|
|
' Verifico se la connessione è avvenuta e in caso affermativo lancio il timer di aggiornamento dell'interfaccia
|
|
If m_nNCType > 0 Then
|
|
AddHandler m_RefreshTimer.Tick, AddressOf RefreshTimer_tick
|
|
m_RefreshTimer.Interval = TimeSpan.FromMilliseconds(100)
|
|
m_RefreshTimer.Start()
|
|
End If
|
|
|
|
' Leggo dati sugli assi della macchina
|
|
ReadAxesData()
|
|
' Aggiorno nomi assi
|
|
m_MachineStatus.DisplayPositionName()
|
|
|
|
End Sub
|
|
|
|
Private Sub RefreshTimer_tick()
|
|
If Not m_bTimerBusy Then
|
|
|
|
m_bTimerBusy = True
|
|
m_RefreshTimer.Stop()
|
|
|
|
If m_nNCType = 3 Then
|
|
RefreshNoEvents()
|
|
Else
|
|
Refresh()
|
|
End If
|
|
|
|
m_bTimerBusy = False
|
|
m_RefreshTimer.Start()
|
|
Else
|
|
Dim nDummy As Integer = 10
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub ReadAxesData()
|
|
' Nomi e indici degli assi macchina
|
|
m_bAxesOk = True
|
|
GetPrivateProfileString(S_AXES, K_L1NAME, "X", m_sL1, m_MainWindow.GetMachIniFile())
|
|
m_nL1 = GetPrivateProfileInt(S_AXES, K_L1ID, 0, m_MainWindow.GetMachIniFile())
|
|
If Not m_CN.VerifyAxis(m_nL1) Then
|
|
m_bAxesOk = False
|
|
EgtOutLog("Error on L1ID")
|
|
End If
|
|
GetPrivateProfileString(S_AXES, K_L2NAME, "Y", m_sL2, m_MainWindow.GetMachIniFile())
|
|
m_nL2 = GetPrivateProfileInt(S_AXES, K_L2ID, 1, m_MainWindow.GetMachIniFile())
|
|
If Not m_CN.VerifyAxis(m_nL2) Then
|
|
m_bAxesOk = False
|
|
EgtOutLog("Error on L2ID")
|
|
End If
|
|
GetPrivateProfileString(S_AXES, K_L3NAME, "Z", m_sL3, m_MainWindow.GetMachIniFile())
|
|
m_nL3 = GetPrivateProfileInt(S_AXES, K_L3ID, 2, m_MainWindow.GetMachIniFile())
|
|
If Not m_CN.VerifyAxis(m_nL3) Then
|
|
m_bAxesOk = False
|
|
EgtOutLog("Error on L3ID")
|
|
End If
|
|
GetPrivateProfileString(S_AXES, K_R1NAME, "C", m_sR1, m_MainWindow.GetMachIniFile())
|
|
m_nR1 = GetPrivateProfileInt(S_AXES, K_R1ID, 8, m_MainWindow.GetMachIniFile())
|
|
If Not m_CN.VerifyAxis(m_nR1) Then
|
|
m_bAxesOk = False
|
|
EgtOutLog("Error on R1ID")
|
|
End If
|
|
GetPrivateProfileString(S_AXES, K_R2NAME, "B", m_sR2, m_MainWindow.GetMachIniFile())
|
|
m_nR2 = GetPrivateProfileInt(S_AXES, K_R2ID, 7, m_MainWindow.GetMachIniFile())
|
|
If Not m_CN.VerifyAxis(m_nR2) Then
|
|
m_bAxesOk = False
|
|
EgtOutLog("Error on R2ID")
|
|
End If
|
|
' Unità di misura
|
|
m_bInInches = (GetPrivateProfileInt(S_AXES, K_ININCHES, 0, m_MainWindow.GetMachIniFile()) <> 0)
|
|
End Sub
|
|
|
|
Private Sub InitCn()
|
|
|
|
m_MachineStatus.MachineStatusGrid.Background = Application.Current.FindResource("OmagCut_Yellow")
|
|
|
|
' istanzio l'oggetto CN e lo inizializzo
|
|
Try
|
|
' Creo l'oggetto per la comunicazione
|
|
Select Case m_nNCType
|
|
Case 0
|
|
m_CN = New CN_Debug
|
|
Case 1
|
|
m_CN = New Num.NumNCOld
|
|
Case 2
|
|
m_CN = New Num.NumNC
|
|
Case 3
|
|
m_CN = New CN_Siemens
|
|
End Select
|
|
' Recupero e imposto le variabili per i dati del CN (feed, speed,...)
|
|
Dim sVal As String = String.Empty
|
|
GetPrivateProfileString(S_NCDATA, K_MODE, "", sVal, m_MainWindow.GetMachIniFile())
|
|
m_CN.SetCnDataVar(CN_generico.CnData.Mode, sVal)
|
|
GetPrivateProfileString(S_NCDATA, K_JOGINCR, "", sVal, m_MainWindow.GetMachIniFile())
|
|
m_CN.SetCnDataVar(CN_generico.CnData.JogIncr, sVal)
|
|
GetPrivateProfileString(S_NCDATA, K_FEED, "", sVal, m_MainWindow.GetMachIniFile())
|
|
m_CN.SetCnDataVar(CN_generico.CnData.Feed, sVal)
|
|
GetPrivateProfileString(S_NCDATA, K_FEEDOVR, "", sVal, m_MainWindow.GetMachIniFile())
|
|
m_CN.SetCnDataVar(CN_generico.CnData.FeedOvr, sVal)
|
|
GetPrivateProfileString(S_NCDATA, K_SPEED, "", sVal, m_MainWindow.GetMachIniFile())
|
|
m_CN.SetCnDataVar(CN_generico.CnData.Speed, sVal)
|
|
GetPrivateProfileString(S_NCDATA, K_SPEEDOVR, "", sVal, m_MainWindow.GetMachIniFile())
|
|
m_CN.SetCnDataVar(CN_generico.CnData.SpeedOvr, sVal)
|
|
GetPrivateProfileString(S_NCDATA, K_POWER, "", sVal, m_MainWindow.GetMachIniFile())
|
|
m_CN.SetCnDataVar(CN_generico.CnData.Power, sVal)
|
|
GetPrivateProfileString(S_NCDATA, K_SPINDLE, "", sVal, m_MainWindow.GetMachIniFile())
|
|
m_CN.SetCnDataVar(CN_generico.CnData.Spindle, sVal)
|
|
GetPrivateProfileString(S_NCDATA, K_COOLANT, "", sVal, m_MainWindow.GetMachIniFile())
|
|
m_CN.SetCnDataVar(CN_generico.CnData.Coolant, sVal)
|
|
GetPrivateProfileString(S_NCDATA, K_LASER, "", sVal, m_MainWindow.GetMachIniFile())
|
|
m_CN.SetCnDataVar(CN_generico.CnData.Laser, sVal)
|
|
GetPrivateProfileString(S_NCDATA, K_POWEROVR, "", sVal, m_MainWindow.GetMachIniFile())
|
|
m_CN.SetCnDataVar(CN_generico.CnData.PowerOvr, sVal)
|
|
|
|
' Inizializzo la comunicazione
|
|
m_CN.Init()
|
|
|
|
Catch ex As Exception
|
|
' set status to statusbar
|
|
EgtOutLog("Error starting NC communication : " & ex.Message)
|
|
End Try
|
|
|
|
Select Case m_nNCType
|
|
Case 0 'Debug
|
|
m_MachineStatus.MachineStatusGrid.Background = Application.Current.FindResource("OmagCut_Yellow")
|
|
Case 1, 2 'Axium, Flexium
|
|
If IsNothing(m_CN) OrElse m_CN.n_state < 2 Then
|
|
' Per evitare crash con azioni verso il controllo, avvio quello di debug
|
|
m_nNCType = 0
|
|
Me.m_CN = New CN_Debug
|
|
m_MachineStatus.MachineStatusGrid.Background = Application.Current.FindResource("OmagCut_Red")
|
|
Else
|
|
m_CN.b_axis_events_enable = True
|
|
m_MachineStatus.MachineStatusGrid.Background = Application.Current.FindResource("OmagCut_DarkGray")
|
|
End If
|
|
Case 3 'Siemens
|
|
If IsNothing(m_CN) Then
|
|
' Per evitare crash con azioni verso il controllo, avvio quello di debug
|
|
m_nNCType = 0
|
|
Me.m_CN = New CN_Debug
|
|
m_MachineStatus.MachineStatusGrid.Background = Application.Current.FindResource("OmagCut_Red")
|
|
Else
|
|
' Avvio programmino di comunicazione
|
|
Try
|
|
m_MachineStatus.MachineStatusGrid.Background = Application.Current.FindResource("OmagCut_DarkGray")
|
|
Dim sArg As String = "-start """ & m_sCNSiemensPath & """"
|
|
EgtOutLog("ProcessStart : " & m_sCNSiemensHMIPath & " " & sArg)
|
|
Process.Start(m_sCNSiemensHMIPath, sArg)
|
|
Catch ex As Exception
|
|
EgtOutLog("Error starting Process -> NcLink=True type=0")
|
|
' Per evitare crash con azioni verso il controllo, avvio quello di debug
|
|
Me.m_CN.Stop_Connection()
|
|
m_nNCType = 0
|
|
Me.m_CN = New CN_Debug
|
|
m_MachineStatus.MachineStatusGrid.Background = Application.Current.FindResource("OmagCut_Red")
|
|
End Try
|
|
End If
|
|
End Select
|
|
|
|
' Assegno riferimento al CN alle diverse pagine
|
|
m_MainWindow.m_MachineStatusUC.m_CN = Me.m_CN
|
|
m_MainWindow.m_MachinePageUC.m_AlarmsPageUC.m_CN = Me.m_CN
|
|
m_MainWindow.m_MachinePageUC.m_MachineCNPageUC.m_CN = Me.m_CN
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.m_CN = Me.m_CN
|
|
m_MainWindow.m_DirectCutPageUC.m_ManualAxesMove.m_CN = Me.m_CN
|
|
m_MainWindow.m_DirectCutPageUC.m_CN = Me.m_CN
|
|
m_MainWindow.m_RawPartPage.m_MachineButtons.m_CN = Me.m_CN
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.m_CN = Me.m_CN
|
|
|
|
End Sub
|
|
|
|
Private Sub NewVarChanged_handler(ByVal nst As Object) Handles m_CN.NewVarChanged
|
|
|
|
m_bNewVarData = True
|
|
|
|
End Sub
|
|
|
|
Private Sub NewPositionData_handler(ByVal nst As Short) Handles m_CN.NewPositionData
|
|
|
|
m_bNewPosData = True
|
|
|
|
End Sub
|
|
|
|
Private Sub NewPosDeltaData_handler(ByVal nst As Short) Handles m_CN.NewPosDeltaData
|
|
|
|
m_bNewDeltaData = True
|
|
|
|
End Sub
|
|
|
|
Private Sub Refresh()
|
|
|
|
If m_bNewPosData Then
|
|
m_bNewPosData = False
|
|
m_MachineStatus.DisplayPosition()
|
|
End If
|
|
|
|
If m_bNewDeltaData Then
|
|
m_bNewDeltaData = False
|
|
m_MachineStatus.DisplayPositionDelta()
|
|
End If
|
|
|
|
If m_CN.b_feed_changed Then
|
|
m_CN.b_feed_changed = False
|
|
m_MachineStatus.DisplayFeed()
|
|
End If
|
|
|
|
If m_CN.b_spindle_data_changed Then
|
|
m_CN.b_spindle_data_changed = False
|
|
m_MachineStatus.DisplaySpeed()
|
|
End If
|
|
|
|
If m_CN.b_spindle_power_changed Then
|
|
m_CN.b_spindle_power_changed = False
|
|
m_MachineStatus.DisplayPower()
|
|
End If
|
|
|
|
If m_bNewVarData Then
|
|
m_bNewVarData = False
|
|
m_MachineStatus.DisplayVar()
|
|
End If
|
|
|
|
If m_CN.b_Tool_data_changed Then
|
|
m_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
|
|
|
|
Select Case m_nNCType
|
|
Case 1
|
|
If m_CN.read_active_mode() <> m_nCurrMode Then
|
|
m_nCurrMode = m_CN.read_active_mode()
|
|
m_MachineStatus.DisplayActiveMode(m_nCurrMode)
|
|
End If
|
|
Case 2
|
|
If m_CN.nMachineMode <> m_nCurrMode Then
|
|
m_nCurrMode = m_CN.nMachineMode
|
|
m_MachineStatus.DisplayActiveMode(m_nCurrMode)
|
|
End If
|
|
End Select
|
|
|
|
|
|
If m_CN.b_NC_error Then
|
|
ErrorList.Clear()
|
|
If m_CN.sz_NC_error_messages.Count > 0 Then
|
|
For Each Item In m_CN.sz_NC_error_messages
|
|
ErrorList.Add(Item)
|
|
Next
|
|
m_MainWindow.m_MachinePageUC.m_MachineCNPageUC.ErrorLstBx.ItemsSource = ErrorList
|
|
End If
|
|
m_CN.b_NC_error = False
|
|
m_AlarmsPage.NcError()
|
|
End If
|
|
|
|
If m_CN.b_PLC_error Then
|
|
m_AlarmsPage.PlcError(m_CN.sz_PLC_error_messages)
|
|
Else
|
|
'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
|
|
|
|
' Flag e variabili per bottoni macchina, che verifico solo nelle pagine in cui ci sono
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.DirectCut Then
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.SpindleStateChanged(m_CN.bSpindleState)
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.CoolantStateChanged(m_CN.bCoolantState)
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.LaserStateChanged(m_CN.bLaserState)
|
|
If m_CN.Is_G24_active() Then
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.ThreeAxisStateChanged(False)
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.FiveAxisStateChanged(True)
|
|
Else
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.ThreeAxisStateChanged(True)
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.FiveAxisStateChanged(False)
|
|
End If
|
|
End If
|
|
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.RawPart Then
|
|
m_MainWindow.m_RawPartPage.m_MachineButtons.SpindleStateChanged(m_CN.bSpindleState)
|
|
m_MainWindow.m_RawPartPage.m_MachineButtons.CoolantStateChanged(m_CN.bCoolantState)
|
|
m_MainWindow.m_RawPartPage.m_MachineButtons.LaserStateChanged(m_CN.bLaserState)
|
|
If m_CN.Is_G24_active() Then
|
|
m_MainWindow.m_RawPartPage.m_MachineButtons.ThreeAxisStateChanged(False)
|
|
m_MainWindow.m_RawPartPage.m_MachineButtons.FiveAxisStateChanged(True)
|
|
Else
|
|
m_MainWindow.m_RawPartPage.m_MachineButtons.ThreeAxisStateChanged(True)
|
|
m_MainWindow.m_RawPartPage.m_MachineButtons.FiveAxisStateChanged(False)
|
|
End If
|
|
End If
|
|
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.WorkInProgress Then
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.SpindleStateChanged(m_CN.bSpindleState)
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.CoolantStateChanged(m_CN.bCoolantState)
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.LaserStateChanged(m_CN.bLaserState)
|
|
If m_CN.Is_G24_active() Then
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.ThreeAxisStateChanged(False)
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.FiveAxisStateChanged(True)
|
|
Else
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.ThreeAxisStateChanged(True)
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.FiveAxisStateChanged(False)
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub RefreshNoEvents()
|
|
|
|
m_MachineStatus.DisplayPosition()
|
|
|
|
m_MachineStatus.DisplayPositionDelta()
|
|
|
|
m_MachineStatus.DisplayFeed()
|
|
|
|
m_MachineStatus.DisplaySpeed()
|
|
|
|
m_MachineStatus.DisplayPower()
|
|
|
|
m_MachineStatus.DisplayVar()
|
|
'EgtOutLog("Modo attivato: " & m_CN.read_active_mode & " modo attivo: " & m_nCurrMode)
|
|
|
|
If m_CN.read_active_mode() <> m_nCurrMode Then
|
|
'EgtOutLog("Modo attivo: " & m_CN.read_active_mode)
|
|
m_nCurrMode = m_CN.read_active_mode()
|
|
m_MachineStatus.DisplayActiveMode(m_nCurrMode)
|
|
End If
|
|
|
|
|
|
If m_CN.b_NC_error Then
|
|
ErrorList.Clear()
|
|
If m_CN.sz_NC_error_messages.Count > 0 Then
|
|
For Each Item In m_CN.sz_NC_error_messages
|
|
ErrorList.Add(Item)
|
|
Next
|
|
m_MainWindow.m_MachinePageUC.m_MachineCNPageUC.ErrorLstBx.ItemsSource = ErrorList
|
|
End If
|
|
m_CN.b_NC_error = False
|
|
m_AlarmsPage.NcError()
|
|
Else
|
|
If ErrorList.Count > 0 Then
|
|
ErrorList.Clear()
|
|
m_MainWindow.m_MachinePageUC.m_MachineCNPageUC.ErrorLstBx.ItemsSource = ErrorList
|
|
m_AlarmsPage.NcError()
|
|
End If
|
|
End If
|
|
|
|
' Flag e variabili per bottoni macchina, che verifico solo nelle pagine in cui ci sono
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.DirectCut Then
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.SpindleStateChanged(m_CN.bSpindleState)
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.CoolantStateChanged(m_CN.bCoolantState)
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.LaserStateChanged(m_CN.bLaserState)
|
|
If m_CN.Is_G24_active() Then
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.ThreeAxisStateChanged(False)
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.FiveAxisStateChanged(True)
|
|
Else
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.ThreeAxisStateChanged(True)
|
|
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.FiveAxisStateChanged(False)
|
|
End If
|
|
End If
|
|
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.WorkInProgress Then
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.SpindleStateChanged(m_CN.bSpindleState)
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.CoolantStateChanged(m_CN.bCoolantState)
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.LaserStateChanged(m_CN.bLaserState)
|
|
If m_CN.Is_G24_active() Then
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.ThreeAxisStateChanged(False)
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.FiveAxisStateChanged(True)
|
|
Else
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.ThreeAxisStateChanged(True)
|
|
m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.FiveAxisStateChanged(False)
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Friend Function SendProgram(ByVal sCncPath As String, ByVal nNumProg As Integer,
|
|
Optional bActivate As Boolean = True) As Boolean
|
|
Dim bOk As Boolean = True
|
|
' Download programma
|
|
If m_MainWindow.m_bNCLink Then
|
|
bOk = (m_nNCType > 0)
|
|
Dim sNumProg As String = String.Empty
|
|
If m_nNCType = 1 Or m_nNCType = 2 Then
|
|
sNumProg = "%"
|
|
End If
|
|
sNumProg &= nNumProg.ToString() & ".0"
|
|
' Se richiesta successiva attivazione, faccio reset
|
|
If bActivate Then
|
|
m_CN.DGeneralFunctions_Reset()
|
|
End If
|
|
' Attesa opportuna
|
|
System.Threading.Thread.Sleep(1000)
|
|
If m_nNCType = 1 Then
|
|
' Cancellazione eventuale file già presente con lo stesso nome (ignoro eventuale errore)
|
|
m_CN.Delete_NC_prog(sNumProg)
|
|
' Attesa opportuna
|
|
System.Threading.Thread.Sleep(100)
|
|
End If
|
|
bOk = bOk AndAlso (m_CN.Download_NC_prog(sCncPath, sNumProg) = 0)
|
|
' Attesa opportuna
|
|
System.Threading.Thread.Sleep(100)
|
|
' Se richiesta attivazione
|
|
If bActivate Then
|
|
' Attivazione programma
|
|
bOk = bOk AndAlso (m_CN.ActivateProgram(nNumProg) = 0)
|
|
' Attesa opportuna
|
|
System.Threading.Thread.Sleep(100)
|
|
' Modalità automatica
|
|
bOk = bOk AndAlso (m_CN.DGeneralFunctions_WriteCncMode(0) = 0)
|
|
End If
|
|
' Messaggio con risultato
|
|
If bOk Then
|
|
m_CurrProjPage.SetInfoMessage(EgtMsg(90317)) 'Programma CN trasmesso con successo
|
|
Else
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(90315)) 'Errore nella trasmissione del programma CN
|
|
End If
|
|
Else
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90316)) 'Non connesso alla macchina
|
|
End If
|
|
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function GetAxesPositions(ByRef dL1 As Double, ByRef dL2 As Double, ByRef dL3 As Double,
|
|
ByRef dR1 As Double, ByRef dR2 As Double) As Boolean
|
|
dL1 = If(m_nL1 >= 0, m_CN.d_axis_position(m_nL1), 0)
|
|
dL2 = If(m_nL2 >= 0, m_CN.d_axis_position(m_nL2), 0)
|
|
dL3 = If(m_nL3 >= 0, m_CN.d_axis_position(m_nL3), 0)
|
|
dR1 = If(m_nR1 >= 0, m_CN.d_axis_position(m_nR1), 0)
|
|
dR2 = If(m_nR2 >= 0, m_CN.d_axis_position(m_nR2), 0)
|
|
' sono già in mm
|
|
Return m_bAxesOk
|
|
End Function
|
|
|
|
Friend Function GetLinearAxesPositions(ByRef dL1 As Double, ByRef dL2 As Double, ByRef dL3 As Double) As Boolean
|
|
dL1 = If(m_nL1 >= 0, m_CN.d_axis_position(m_nL1), 0)
|
|
dL2 = If(m_nL2 >= 0, m_CN.d_axis_position(m_nL2), 0)
|
|
dL3 = If(m_nL3 >= 0, m_CN.d_axis_position(m_nL3), 0)
|
|
' sono già in mm
|
|
Return m_bAxesOk
|
|
End Function
|
|
|
|
Friend Function GetRotaryAxesPositions(ByRef dR1 As Double, ByRef dR2 As Double) As Boolean
|
|
dR1 = If(m_nR1 >= 0, m_CN.d_axis_position(m_nR1), 0)
|
|
dR2 = If(m_nR2 >= 0, m_CN.d_axis_position(m_nR2), 0)
|
|
Return m_bAxesOk
|
|
End Function
|
|
|
|
Friend Function GetAxesDeltas(ByRef dL1 As Double, ByRef dL2 As Double, ByRef dL3 As Double,
|
|
ByRef dR1 As Double, ByRef dR2 As Double) As Boolean
|
|
dL1 = If(m_nL1 >= 0, m_CN.d_axis_delta(m_nL1), 0)
|
|
dL2 = If(m_nL2 >= 0, m_CN.d_axis_delta(m_nL2), 0)
|
|
dL3 = If(m_nL3 >= 0, m_CN.d_axis_delta(m_nL3), 0)
|
|
dR1 = If(m_nR1 >= 0, m_CN.d_axis_delta(m_nR1), 0)
|
|
dR2 = If(m_nR2 >= 0, m_CN.d_axis_delta(m_nR2), 0)
|
|
' sono già in mm
|
|
Return m_bAxesOk
|
|
End Function
|
|
|
|
Friend Function GetAxesNames(ByRef sL1 As String, ByRef sL2 As String, ByRef sL3 As String,
|
|
ByRef sR1 As String, ByRef sR2 As String) As Boolean
|
|
sL1 = m_sL1
|
|
sL2 = m_sL2
|
|
sL3 = m_sL3
|
|
sR1 = m_sR1
|
|
sR2 = m_sR2
|
|
Return m_bAxesOk
|
|
End Function
|
|
|
|
Friend Function GetMachineInInches() As Boolean
|
|
Return m_bInInches
|
|
End Function
|
|
|
|
End Class
|