fb4ebfd60c
- miglioramenti alla simulazione.
770 lines
25 KiB
VB.net
770 lines
25 KiB
VB.net
Imports System.IO
|
|
Imports EgtUILib
|
|
|
|
Namespace EgtCAM5
|
|
|
|
Public Class SimulationExpanderViewModel
|
|
Inherits ViewModelBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
'EGT PROPERTIES
|
|
' Stato di visualizzazione della macchina
|
|
Private m_nMachLook As Integer = MCH_LOOK.ALL
|
|
' Utensile corrente
|
|
Private m_sCurrTool As String = String.Empty
|
|
' Stato e comando correnti
|
|
Public Enum SIM_ST As Integer
|
|
ST_STOP = 1
|
|
ST_PLAY = 2
|
|
ST_STEP = 3
|
|
ST_PAUSE = 4
|
|
End Enum
|
|
Private m_nStatus As Integer = SIM_ST.ST_STOP
|
|
' Stato bottone Play
|
|
Private m_bShowPlay As Boolean = True
|
|
' Coefficiente per valore Slider
|
|
Private m_SliderX As Double = 1
|
|
|
|
'GRAPHICAL PROPERTIES
|
|
|
|
Private m_IsExpanded As Boolean
|
|
Public Property IsExpanded As Boolean
|
|
Get
|
|
Return m_IsExpanded
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_IsExpanded Then
|
|
If value Then
|
|
EgtDeselectAll()
|
|
Application.Msn.NotifyColleagues(Application.REMOVEMARKFROMLASTOPERATION)
|
|
Application.Msn.NotifyColleagues(Application.GETDISTANCE_ISCHECKED, False)
|
|
InitializeSimulation()
|
|
Else
|
|
CloseSimulation()
|
|
End If
|
|
m_IsExpanded = value
|
|
Application.Msn.NotifyColleagues(Application.SIMULATIONEXPANDER_GET_ISEXPANDED, value)
|
|
OnPropertyChanged("IsExpanded")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A1Name As String
|
|
Public Property A1Name As String
|
|
Get
|
|
Return m_A1Name
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A1Name Then
|
|
m_A1Name = value
|
|
OnPropertyChanged("A1Name")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A1Value As String
|
|
Public Property A1Value As String
|
|
Get
|
|
Return m_A1Value
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A1Value Then
|
|
m_A1Value = value
|
|
OnPropertyChanged("A1Value")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A2Name As String
|
|
Public Property A2Name As String
|
|
Get
|
|
Return m_A2Name
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A2Name Then
|
|
m_A2Name = value
|
|
OnPropertyChanged("A2Name")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A2Value As String
|
|
Public Property A2Value As String
|
|
Get
|
|
Return m_A2Value
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A2Value Then
|
|
m_A2Value = value
|
|
OnPropertyChanged("A2Value")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A3Name As String
|
|
Public Property A3Name As String
|
|
Get
|
|
Return m_A3Name
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A3Name Then
|
|
m_A3Name = value
|
|
OnPropertyChanged("A3Name")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A3Value As String
|
|
Public Property A3Value As String
|
|
Get
|
|
Return m_A3Value
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A3Value Then
|
|
m_A3Value = value
|
|
OnPropertyChanged("A3Value")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A4Name As String
|
|
Public Property A4Name As String
|
|
Get
|
|
Return m_A4Name
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A4Name Then
|
|
m_A4Name = value
|
|
OnPropertyChanged("A4Name")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A4Value As String
|
|
Public Property A4Value As String
|
|
Get
|
|
Return m_A4Value
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A4Value Then
|
|
m_A4Value = value
|
|
OnPropertyChanged("A4Value")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A5Name As String
|
|
Public Property A5Name As String
|
|
Get
|
|
Return m_A5Name
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A5Name Then
|
|
m_A5Name = value
|
|
OnPropertyChanged("A5Name")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A5Value As String
|
|
Public Property A5Value As String
|
|
Get
|
|
Return m_A5Value
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A5Value Then
|
|
m_A5Value = value
|
|
OnPropertyChanged("A5Value")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A6Name As String
|
|
Public Property A6Name As String
|
|
Get
|
|
Return m_A6Name
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A6Name Then
|
|
m_A6Name = value
|
|
OnPropertyChanged("A6Name")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A6Value As String
|
|
Public Property A6Value As String
|
|
Get
|
|
Return m_A6Value
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A6Value Then
|
|
m_A6Value = value
|
|
OnPropertyChanged("A6Value")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A7Name As String
|
|
Public Property A7Name As String
|
|
Get
|
|
Return m_A7Name
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A7Name Then
|
|
m_A7Name = value
|
|
OnPropertyChanged("A7Name")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A7Value As String
|
|
Public Property A7Value As String
|
|
Get
|
|
Return m_A7Value
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A7Value Then
|
|
m_A7Value = value
|
|
OnPropertyChanged("A7Value")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A8Name As String
|
|
Public Property A8Name As String
|
|
Get
|
|
Return m_A8Name
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A8Name Then
|
|
m_A8Name = value
|
|
OnPropertyChanged("A8Name")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_A8Value As String
|
|
Public Property A8Value As String
|
|
Get
|
|
Return m_A8Value
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_A8Value Then
|
|
m_A8Value = value
|
|
OnPropertyChanged("A8Value")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_GCode As String
|
|
Public Property GCode As String
|
|
Get
|
|
Return m_GCode
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_GCode Then
|
|
m_GCode = value
|
|
OnPropertyChanged("GCode")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_FValue As String
|
|
Public Property FValue As String
|
|
Get
|
|
Return m_FValue
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_FValue Then
|
|
m_FValue = value
|
|
OnPropertyChanged("FValue")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TName As String
|
|
Public Property TName As String
|
|
Get
|
|
Return m_TName
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_TName Then
|
|
m_TName = value
|
|
OnPropertyChanged("TName")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SValue As String
|
|
Public Property SValue As String
|
|
Get
|
|
Return m_SValue
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_SValue Then
|
|
m_SValue = value
|
|
OnPropertyChanged("SValue")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_PlayPauseImage As String
|
|
Public ReadOnly Property PlayPauseImage As String
|
|
Get
|
|
If m_bShowPlay Then
|
|
Return "/Resources/OptionPanel/MachiningOptionPanel/SimulationExpander/Play.png"
|
|
Else
|
|
Return "/Resources/OptionPanel/MachiningOptionPanel/SimulationExpander/Pause.png"
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SliderValue As Double
|
|
Public Property SliderValue As Double
|
|
Get
|
|
Return m_SliderValue
|
|
End Get
|
|
Set(value As Double)
|
|
If value <> m_SliderValue Then
|
|
m_SliderValue = value
|
|
EgtSimSetStep(value * m_SliderX)
|
|
OnPropertyChanged("SliderValue")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdStep As ICommand
|
|
Private m_cmdPlayPause As ICommand
|
|
Private m_cmdStop As ICommand
|
|
Private m_cmdGenerate As ICommand
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property SimulationMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATION + 7)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property GenerateMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATION + 30)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region "ToolTip"
|
|
|
|
Public ReadOnly Property OneStepToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATION + 8)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property PlayPauseToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATION + 9)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property StopHomeToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATION + 10)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
Application.Msn.Register(Application.CLOSEAPPLICATION, Sub()
|
|
If IsExpanded Then
|
|
ResetSimulation()
|
|
End If
|
|
End Sub)
|
|
Application.Msn.Register(Application.SIMULATIONEXPANDER_SET_ISEXPANDED, Sub(bValue As Boolean)
|
|
IsExpanded = bValue
|
|
End Sub)
|
|
Application.Msn.Register(Application.SIMULATIONEXPANDER_UPDATE_CNCDATA, Sub()
|
|
If IsExpanded Then
|
|
ShowCncData()
|
|
End If
|
|
End Sub)
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "StepCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property StepCommand As ICommand
|
|
Get
|
|
If m_cmdStep Is Nothing Then
|
|
m_cmdStep = New RelayCommand(AddressOf StepCmd)
|
|
End If
|
|
Return m_cmdStep
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub StepCmd(ByVal param As Object)
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, "")
|
|
' Se stato stop, devo avviare simulazione
|
|
If m_nStatus = SIM_ST.ST_STOP Then
|
|
m_nStatus = SIM_ST.ST_STEP
|
|
' Aggiorno bottone
|
|
m_bShowPlay = False
|
|
OnPropertyChanged("PlayPauseImage")
|
|
ExecSim()
|
|
' Aggiorno bottone
|
|
m_bShowPlay = True
|
|
OnPropertyChanged("PlayPauseImage")
|
|
' Alrimenti imposto solo il nuovo stato
|
|
Else
|
|
m_nStatus = SIM_ST.ST_STEP
|
|
' Aggiornamenti per bottone Play/Pause
|
|
m_bShowPlay = False
|
|
OnPropertyChanged("PlayPauseImage")
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' StepCommand
|
|
|
|
#Region "PlayPauseCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property PlayPauseCommand As ICommand
|
|
Get
|
|
If m_cmdPlayPause Is Nothing Then
|
|
m_cmdPlayPause = New RelayCommand(AddressOf PlayPause)
|
|
End If
|
|
Return m_cmdPlayPause
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub PlayPause(ByVal param As Object)
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, "")
|
|
If m_bShowPlay Then
|
|
' Aggiorno bottone
|
|
m_bShowPlay = False
|
|
OnPropertyChanged("PlayPauseImage")
|
|
' Eseguo
|
|
If m_nStatus = SIM_ST.ST_STOP Then
|
|
' Lancio simulazione
|
|
m_nStatus = SIM_ST.ST_PLAY
|
|
ExecSim()
|
|
' Aggiorno bottone
|
|
m_bShowPlay = True
|
|
OnPropertyChanged("PlayPauseImage")
|
|
ElseIf m_nStatus = SIM_ST.ST_PAUSE Then
|
|
m_nStatus = SIM_ST.ST_PLAY
|
|
End If
|
|
Else
|
|
' Aggiorno bottone
|
|
m_bShowPlay = True
|
|
OnPropertyChanged("PlayPauseImage")
|
|
' Se play o step, imposto stato pausa
|
|
If m_nStatus = SIM_ST.ST_PLAY Or m_nStatus = SIM_ST.ST_STEP Then
|
|
m_nStatus = SIM_ST.ST_PAUSE
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_SIMULATION + 11)) ' Pausa
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#End Region ' PlayPauseCommand
|
|
|
|
#Region "StopCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property StopCommand As ICommand
|
|
Get
|
|
If m_cmdStop Is Nothing Then
|
|
m_cmdStop = New RelayCommand(AddressOf StopCmd)
|
|
End If
|
|
Return m_cmdStop
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub StopCmd(ByVal param As Object)
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, "")
|
|
' Se stato già stop, porto in home
|
|
If m_nStatus = SIM_ST.ST_STOP Then
|
|
' Vado in home
|
|
EgtSimHome()
|
|
' Imposto prima fase
|
|
EgtSetCurrPhase(1, True)
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
' Aggiorno dati CNC
|
|
ShowCncData()
|
|
Else
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_SIMULATION + 12)) ' Simulazione interrotta
|
|
End If
|
|
' Aggiorno bottone
|
|
m_bShowPlay = True
|
|
OnPropertyChanged("PlayPauseImage")
|
|
' Imposto il nuovo stato
|
|
m_nStatus = SIM_ST.ST_STOP
|
|
End Sub
|
|
|
|
|
|
#End Region ' StopCommand
|
|
|
|
#Region "GenerateCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property GenerateCommand As ICommand
|
|
Get
|
|
If m_cmdGenerate Is Nothing Then
|
|
m_cmdGenerate = New RelayCommand(AddressOf Generate)
|
|
End If
|
|
Return m_cmdGenerate
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub Generate(ByVal param As Object)
|
|
Dim sCurrFilePath As String = String.Empty
|
|
EgtGetCurrFilePath(sCurrFilePath)
|
|
If String.IsNullOrEmpty(sCurrFilePath) Then
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATION + 31), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Stop)
|
|
End If
|
|
Dim sInfo As String = "EgtCAM5 - " & sCurrFilePath
|
|
If Not EgtGenerate(Path.ChangeExtension(sCurrFilePath, ".cnc"), sInfo) Then
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATION + 6), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Stop)
|
|
Else
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_SIMULATION + 32))
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' GenerateCommand
|
|
|
|
#End Region
|
|
|
|
#Region "METHODS"
|
|
|
|
Private Sub InitializeSimulation()
|
|
' Imposto prima fase
|
|
EgtSetCurrPhase(1)
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Imposto stato corrente
|
|
m_nStatus = SIM_ST.ST_STOP
|
|
m_bShowPlay = True
|
|
m_SliderX = GetPrivateProfileDouble(S_SIMUL, K_SLIDERX, 1)
|
|
Dim SliderVal As Double = GetPrivateProfileDouble(S_SIMUL, K_SLIDERVAL, 10)
|
|
SliderValue = SliderVal
|
|
' Porto la testa in home
|
|
EgtSimStart()
|
|
EgtSimHome()
|
|
LoadCurrTools()
|
|
EgtDraw()
|
|
ShowCncData()
|
|
End Sub
|
|
|
|
Private Sub CloseSimulation()
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, "")
|
|
' Mi assicuro di terminare la simulazione
|
|
ResetSimulation()
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub ResetSimulation()
|
|
' Termino la simulazione
|
|
m_nStatus = SIM_ST.ST_STOP
|
|
EgtSimStop()
|
|
' Salvo valore dello slider
|
|
Dim sVal As String = DoubleToString(SliderValue, 1)
|
|
WritePrivateProfileString(S_SIMUL, K_SLIDERVAL, sVal)
|
|
' Torno alla prima fase
|
|
EgtSetCurrPhase(1, True)
|
|
' Ripristino visibilità standard
|
|
'EgtSetMachineLook(MCH_LOOK.TAB)
|
|
End Sub
|
|
|
|
Private Sub ExecSim()
|
|
EgtSimStart()
|
|
LoadCurrTools()
|
|
EgtSimSetStep(SliderValue * m_SliderX)
|
|
While m_nStatus <> SIM_ST.ST_STOP
|
|
' Se simulazione in svolgimento
|
|
If m_nStatus = SIM_ST.ST_PLAY Or m_nStatus = SIM_ST.ST_STEP Then
|
|
' Eseguo movimento
|
|
Dim nMove As Integer
|
|
Dim bMove As Boolean = EgtSimMove(nMove)
|
|
' Se arrivato a fine step e sono in step
|
|
If bMove Then
|
|
If m_nStatus = SIM_ST.ST_STEP And nMove = MCH_SIM.END_STEP Then
|
|
' Imposto stato Pausa
|
|
m_nStatus = SIM_ST.ST_PAUSE
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_SIMULATION + 11)) ' Pausa
|
|
' Aggiornamenti per bottone Play/Pause
|
|
m_bShowPlay = True
|
|
OnPropertyChanged("PlayPauseImage")
|
|
End If
|
|
' Se movimento non riuscito
|
|
Else
|
|
m_nStatus = SIM_ST.ST_STOP
|
|
' Aggiornamenti per bottone Play/Pause
|
|
m_bShowPlay = True
|
|
OnPropertyChanged("PlayPauseImage")
|
|
Select Case nMove
|
|
Case MCH_SIM.END_
|
|
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_SIMULATION + 1))
|
|
' MessageBox.Show(EgtMsg(MSG_SIMULATION + 1), "", MessageBoxButton.OK) 'Simulazione completata
|
|
Case MCH_SIM.OUTSTROKE
|
|
Dim sInfo As String = String.Empty
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATION + 2) & " " & sInfo, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Stop) 'Extracorsa ...
|
|
Case MCH_SIM.DIR_ERR
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATION + 3), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Stop) 'Direzione utensile irraggiungibile
|
|
Case Else
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATION + 4), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Stop) 'Errore
|
|
End Select
|
|
End If
|
|
' Aggiorno stato visualizzazione macchina (dipende anche da utensile)
|
|
'UpdateMachView()
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
' Aggiorno dati CNC
|
|
ShowCncData()
|
|
Else
|
|
' Per evitare di ciclare rapidissimamente e consumare inutilmente CPU
|
|
System.Threading.Thread.Sleep(1)
|
|
End If
|
|
'' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
End While
|
|
End Sub
|
|
|
|
Private Sub ShowCncData()
|
|
' Assi
|
|
Dim nInd As Integer = 0
|
|
ShowAxisNameVal(nInd, A1Name, A1Value)
|
|
ShowAxisNameVal(nInd, A2Name, A2Value)
|
|
ShowAxisNameVal(nInd, A3Name, A3Value)
|
|
ShowAxisNameVal(nInd, A4Name, A4Value)
|
|
ShowAxisNameVal(nInd, A5Name, A5Value)
|
|
ShowAxisNameVal(nInd, A6Name, A6Value)
|
|
ShowAxisNameVal(nInd, A7Name, A7Value)
|
|
ShowAxisNameVal(nInd, A8Name, A8Value)
|
|
' Tipo di movimento e feed
|
|
ShowMoveTypeFeed()
|
|
' Nome utensile e speed
|
|
ShowToolNameSpeed()
|
|
End Sub
|
|
|
|
Private Function ShowAxisNameVal(ByRef nInd As Integer, ByRef sName As String, ByRef sVal As String) As Boolean
|
|
Dim sInfo As String = String.Empty
|
|
Dim bLinear As Boolean = True
|
|
Dim dVal As Double = 0
|
|
If EgtSimGetAxisInfoPos(nInd, sInfo, bLinear, dVal) Then
|
|
If sInfo <> "**" Then
|
|
sName = sInfo
|
|
sVal = If(bLinear, LenToString(dVal, -3), DoubleToString(dVal, -3))
|
|
nInd += 1
|
|
Return True
|
|
Else
|
|
nInd += 1
|
|
Return ShowAxisNameVal(nInd, sName, sVal)
|
|
End If
|
|
Else
|
|
sName = String.Empty
|
|
sVal = String.Empty
|
|
nInd += 1
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
Private Function ShowMoveTypeFeed() As Boolean
|
|
Dim nG As Integer = 0
|
|
Dim dFeed As Double = 0
|
|
If EgtSimGetMoveInfo(nG, dFeed) Then
|
|
If nG <> 0 Then
|
|
GCode = "G" & nG.ToString()
|
|
FValue = "F" & LenToString(dFeed, 0)
|
|
Else
|
|
GCode = "G" & nG.ToString()
|
|
FValue = ""
|
|
End If
|
|
Return True
|
|
Else
|
|
GCode = ""
|
|
FValue = ""
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
Private Function ShowToolNameSpeed() As Boolean
|
|
Dim sTool As String = String.Empty
|
|
Dim dSpeed As Double = 0
|
|
If EgtSimGetToolInfo(sTool, dSpeed) Then
|
|
TName = sTool
|
|
SValue = "S" & DoubleToString(dSpeed, 0)
|
|
Return True
|
|
Else
|
|
TName = ""
|
|
SValue = ""
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
Private Function LoadCurrTools() As Boolean
|
|
'' Imposto la lama corrente
|
|
'Dim sSaw As String = m_MainWindow.m_CurrentMachine.sCurrSaw
|
|
'If Not EgtLoadTool("H1", 1, sSaw) Then
|
|
' Return False
|
|
'End If
|
|
'' Imposto eventuale secondo utensile montato
|
|
'If m_MainWindow.m_CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL Then
|
|
' Dim sTool As String = m_MainWindow.m_CurrentMachine.sCurrDrill
|
|
' If String.IsNullOrEmpty(sTool) Then sTool = m_MainWindow.m_CurrentMachine.sCurrMill
|
|
' If Not String.IsNullOrEmpty(sTool) AndAlso Not EgtLoadTool("H1", 2, sTool) Then
|
|
' Return False
|
|
' End If
|
|
'End If
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub UpdateMachView()
|
|
' Se cambiato utensile, aggiorno stato visualizzazione macchina
|
|
Dim sTool As String = String.Empty
|
|
Dim dSpeed As Double = 0
|
|
If EgtSimGetToolInfo(sTool, dSpeed) Then
|
|
If sTool <> m_sCurrTool Then
|
|
m_sCurrTool = sTool
|
|
EgtSetMachineLook(m_nMachLook)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
End Class
|
|
|
|
End Namespace |