00a2d37a43
- aggiornamento simulazione per risultato MCH_SIM.STOP_.
852 lines
28 KiB
VB.net
852 lines
28 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class SimulTabVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Stato di visualizzazione della macchina
|
|
Private m_nMachLook As MCH_LOOK = MCH_LOOK.ALL
|
|
' Utensile corrente
|
|
Private m_sCurrTool As String = String.Empty
|
|
|
|
' Stato di comando corrente
|
|
Private m_nStatus As MCH_SIM_ST = MCH_SIM_ST.UI_STOP
|
|
Private Property SimulationStatus As MCH_SIM_ST
|
|
Get
|
|
Return m_nStatus
|
|
End Get
|
|
Set(value As MCH_SIM_ST)
|
|
m_nStatus = value
|
|
If OmagOFFICE.refMainWindowVM.MainWindowM.nUserLevel >= 10 AndAlso
|
|
(m_nStatus = MCH_SIM_ST.UI_PAUSE OrElse m_nStatus = MCH_SIM_ST.UI_STOP) Then
|
|
For Index = 0 To m_MachineAxisList.Count - 1
|
|
m_MachineAxisList(Index).IsReadOnlyAxesValue = False
|
|
Next
|
|
Else
|
|
For Index = 0 To m_MachineAxisList.Count - 1
|
|
m_MachineAxisList(Index).IsReadOnlyAxesValue = True
|
|
Next
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
' Stato bottone Play
|
|
Private m_bShowPlay As Boolean = True
|
|
' Coefficiente per valore Slider
|
|
Private m_SliderX As Double = 1
|
|
|
|
' lista degli assi
|
|
Private m_MachineAxisList As New ObservableCollection(Of MachineAxis)
|
|
Public ReadOnly Property MachineAxisList As ObservableCollection(Of MachineAxis)
|
|
Get
|
|
Return m_MachineAxisList
|
|
End Get
|
|
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
|
|
NotifyPropertyChanged("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
|
|
NotifyPropertyChanged("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
|
|
NotifyPropertyChanged("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
|
|
NotifyPropertyChanged("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/SimulTab/Play.png"
|
|
Else
|
|
Return "/Resources/SimulTab/Pause.png"
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Private m_StatusMsg As String
|
|
Public Property StatusMsg As String
|
|
Get
|
|
Return m_StatusMsg
|
|
End Get
|
|
Set(value As String)
|
|
m_StatusMsg = value
|
|
NotifyPropertyChanged("StatusMsg")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SliderValue As Double
|
|
Public Property SliderValue As Double
|
|
Get
|
|
Return m_SliderValue
|
|
End Get
|
|
Set(value As Double)
|
|
If Math.Abs(value - m_SliderValue) > EPS_SMALL Then
|
|
m_SliderValue = value
|
|
EgtSimSetStep(m_SliderValue * m_SliderX)
|
|
NotifyPropertyChanged("SliderValue")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Estimation_IsEnabled As Boolean = False
|
|
Public Property Estimation_IsEnabled As Boolean
|
|
Get
|
|
Return m_Estimation_IsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_Estimation_IsEnabled = value
|
|
NotifyPropertyChanged("Estimation_IsEnabled")
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property Time As String
|
|
Get
|
|
Dim nTotalTime As Integer = 0
|
|
EgtGetInfo(EgtGetCurrMachGroup(), "Ttot", nTotalTime)
|
|
Dim sTotalTime As New TimeSpan(0, 0, nTotalTime)
|
|
Return sTotalTime.ToString("hh\:mm\:ss")
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CutLen As String
|
|
Get
|
|
Dim dTotalLength As Double = 0
|
|
EgtGetInfo(EgtGetCurrMachGroup(), "Ltot", dTotalLength)
|
|
Dim sTotalLength As String = ""
|
|
If EgtUiUnitsAreMM() Then
|
|
sTotalLength = DoubleToString(dTotalLength / 1000, 1) & " m"
|
|
Else
|
|
sTotalLength = DoubleToString(dTotalLength / (ONEINCH * 12), 1) & " ft"
|
|
End If
|
|
Return sTotalLength
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NetArea As String
|
|
Get
|
|
Dim dNetArea As Double = 0
|
|
EgtGetInfo(EgtGetCurrMachGroup(), "NetArea", dNetArea)
|
|
Dim sTotalLength As String = ""
|
|
If EgtUiUnitsAreMM() Then
|
|
sTotalLength = DoubleToString(dNetArea / 1000000, 1) & " m²"
|
|
Else
|
|
sTotalLength = DoubleToString(dNetArea / (ONEINCH * 12 * ONEINCH * 12), 1) & " ft²"
|
|
End If
|
|
Return sTotalLength
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Usage As String
|
|
Get
|
|
Dim dRawArea As Integer = 0
|
|
EgtGetInfo(EgtGetCurrMachGroup(), "RawArea", dRawArea)
|
|
Dim dNetArea As Double = 0
|
|
EgtGetInfo(EgtGetCurrMachGroup(), "NetArea", dNetArea)
|
|
Dim dUsage As Double = If(dRawArea > EPS_SMALL, dNetArea / dRawArea, 1)
|
|
Return DoubleToString(dUsage * 100, 1) & " %"
|
|
End Get
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdToolMode As ICommand
|
|
Private m_cmdHeadMode As ICommand
|
|
Private m_cmdMachMode As ICommand
|
|
Private m_cmdStep As ICommand
|
|
Private m_cmdPlayPause As ICommand
|
|
Private m_cmdStop As ICommand
|
|
Private m_cmdDetails As ICommand
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property MachViewMsg As String
|
|
Get
|
|
Return "Vista macchina"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EstimationMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATIONPAGEUC + 19) 'Stime
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TimeMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATIONPAGEUC + 15) 'Tempo totale
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CutLenMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATIONPAGEUC + 16) 'Lunghezza totale
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NetAreaMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATIONPAGEUC + 17) 'Area utilizzata
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property UsageMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATIONPAGEUC + 18) 'Percentuale di utilizzo
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DetailsMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATIONPAGEUC + 20) 'Dettagli
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#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 ' ToolTip
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in OmagOFFICEMap
|
|
OmagOFFICEMap.SetRefSimulTabVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub Refresh(PrevMeasureUnit As MeasureUnitOpt)
|
|
|
|
End Sub
|
|
|
|
Friend Sub InitSimulation()
|
|
Dim bOk As Boolean = True
|
|
' L'attrezzaggio utensili è verificato all'avvio simulazione (con attrezzaggio salvato)
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Aggiorno flag per lavaggio
|
|
EstCalc.UpdateWashingFlag()
|
|
' Se non c'è ordine delle lavorazioni, ne faccio uno automatico
|
|
If Not EstCalc.GetOrderMachiningFlag() Then
|
|
RemoveFinalEmptyPhases()
|
|
bOk = SortAllMachinings()
|
|
If bOk Then
|
|
EstCalc.SetOrderMachiningFlag()
|
|
End If
|
|
Dim bModif As Boolean = TestAllMachiningsForStrict()
|
|
If bModif Then
|
|
' Ridotte alcune lavorazioni per evitare interferenze
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90321), 3, MSG_TYPE.WARNING)
|
|
End If
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Disabilito impostazione modificato
|
|
EgtDisableModified()
|
|
' Aggiorno le lavorazioni
|
|
bOk = UpdateAllMachiningsToolpaths() And bOk
|
|
' Se errore in generazione, segnalo l'errore
|
|
If Not bOk Then
|
|
' Errore nella generazione del programma CN
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90314), MSG_TYPE.ERROR_)
|
|
End If
|
|
' Eseguo la stima di tempi, lunghezze ...
|
|
Dim bEstim As Boolean = (GetPrivateProfileInt(S_MACH_ESTIMATIONS, K_ENABLEEST, 0, CurrentMachine.sMachIniFile) <> 0)
|
|
If bEstim Then
|
|
Estimation_IsEnabled = True
|
|
EgtSetCurrPhase(1)
|
|
EgtEstimate(OmagOFFICEMap.refMainWindowVM.MainWindowM.sTempDir & "\MachProj.html", "OmagCut ver." & OmagOFFICEMap.refMainWindowVM.MainWindowM.sVersion)
|
|
Else
|
|
Estimation_IsEnabled = False
|
|
End If
|
|
' Impostazioni box stime
|
|
NotifyPropertyChanged("Time")
|
|
NotifyPropertyChanged("CutLen")
|
|
NotifyPropertyChanged("NetArea")
|
|
NotifyPropertyChanged("Usage")
|
|
' Nascondo eventuali pezzi in parcheggio
|
|
HideParkedParts()
|
|
' Nascondo eventuale contorno da foto
|
|
EstPhoto.ShowContour(False)
|
|
' Imposto prima fase
|
|
EgtSetCurrPhase(1)
|
|
ShowAllCurrPhaseMachinings()
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
'Cambio la vista della scena
|
|
EgtSetView(VT.ISO_SE, False)
|
|
m_nMachLook = MCH_LOOK.ALL
|
|
EgtSetMachineLook(m_nMachLook)
|
|
EgtZoom(ZM.ALL)
|
|
' Avvio ambiente di simulazione
|
|
If Not EgtSimInit() OrElse Not EgtSimStart() Then
|
|
If EgtGetLastMachMgrErrorId() <> 0 Then
|
|
Dim sErr As String = EgtGetLastMachMgrErrorString()
|
|
MessageBox.Show(sErr, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
Else
|
|
MessageBox.Show(EgtMsg(MSG_MESSAGEBOX + 10), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
End If
|
|
End If
|
|
' Imposto stato corrente
|
|
SimulationStatus = MCH_SIM_ST.UI_STOP
|
|
m_bShowPlay = True
|
|
m_SliderX = GetMainPrivateProfileDouble(S_SIMUL, K_SLIDERX, 1)
|
|
Dim SliderVal As Double = GetMainPrivateProfileDouble(S_SIMUL, K_SLIDERVAL, 10)
|
|
SliderValue = SliderVal
|
|
' Carico utensili specializzato
|
|
LoadCurrTools()
|
|
EgtDraw()
|
|
ShowCncData()
|
|
StatusMsg = EgtMsg(MSG_SIMULATIONPAGEUC + 14) ' Home
|
|
End Sub
|
|
|
|
Friend Sub ResetSimulation()
|
|
StatusMsg = ""
|
|
' Termino la simulazione
|
|
SimulationStatus = MCH_SIM_ST.UI_STOP
|
|
EgtSimExit()
|
|
' Salvo valore dello slider
|
|
Dim sVal As String = DoubleToString(SliderValue, 1)
|
|
WriteMainPrivateProfileString(S_SIMUL, K_SLIDERVAL, sVal)
|
|
' Torno alla prima fase
|
|
EgtSetCurrPhase(1, True)
|
|
End Sub
|
|
|
|
Private Sub ExecSim()
|
|
EgtSimStart()
|
|
EgtSimSetStep(SliderValue * m_SliderX)
|
|
Dim nShowDataCounter As Integer = 0
|
|
While m_nStatus <> MCH_SIM_ST.UI_STOP
|
|
' Se simulazione in svolgimento
|
|
If m_nStatus = MCH_SIM_ST.UI_PLAY Or m_nStatus = MCH_SIM_ST.UI_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 = MCH_SIM_ST.UI_STEP And nMove = MCH_SIM.END_STEP Then
|
|
' Imposto stato Pausa
|
|
SimulationStatus = MCH_SIM_ST.UI_PAUSE
|
|
StatusMsg = EgtMsg(MSG_SIMULATIONPAGEUC + 11) ' Pausa
|
|
' Aggiornamenti per bottone Play/Pause
|
|
m_bShowPlay = True
|
|
NotifyPropertyChanged("PlayPauseImage")
|
|
End If
|
|
' Se movimento non riuscito
|
|
Else
|
|
SimulationStatus = MCH_SIM_ST.UI_STOP
|
|
' Aggiornamenti per bottone Play/Pause
|
|
m_bShowPlay = True
|
|
NotifyPropertyChanged("PlayPauseImage")
|
|
Select Case nMove
|
|
Case MCH_SIM.END_
|
|
StatusMsg = EgtMsg(MSG_SIMULATIONPAGEUC + 1) 'Simulazione completata
|
|
Case MCH_SIM.STOP_
|
|
' Simulazione fermata dall'utente (non necessita messaggio)
|
|
Case MCH_SIM.OUTSTROKE
|
|
Dim sInfo As String = String.Empty
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo, EgtMsg(MSG_SIMULATIONPAGEUC + 5), MessageBoxButton.OK, MessageBoxImage.Stop) 'Extracorsa ...
|
|
Case MCH_SIM.DIR_ERR
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATIONPAGEUC + 3), EgtMsg(MSG_SIMULATIONPAGEUC + 5), MessageBoxButton.OK, MessageBoxImage.Stop) 'Direzione utensile irraggiungibile
|
|
Case Else
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATIONPAGEUC + 4), EgtMsg(MSG_SIMULATIONPAGEUC + 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 nEgtIndex As Integer = 0
|
|
Dim nAxisIndex As Integer = 0
|
|
Dim sName As String = String.Empty
|
|
Dim sToken As String = String.Empty
|
|
Dim bLinear As Boolean = True
|
|
Dim dVal As Double = 0
|
|
While EgtSimGetAxisInfoPos(nEgtIndex, sName, sToken, bLinear, dVal)
|
|
If sToken <> "**" Then
|
|
IsValidAxisIndex(nAxisIndex)
|
|
m_MachineAxisList(nAxisIndex).Name = sName
|
|
m_MachineAxisList(nAxisIndex).Token = sToken
|
|
m_MachineAxisList(nAxisIndex).Linear = bLinear
|
|
m_MachineAxisList(nAxisIndex).Value = If(bLinear, LenToString(dVal, -3), DoubleToString(dVal, -3))
|
|
nAxisIndex += 1
|
|
End If
|
|
nEgtIndex += 1
|
|
End While
|
|
For ClearIndex = m_MachineAxisList.Count - 1 To nAxisIndex Step -1
|
|
m_MachineAxisList.RemoveAt(ClearIndex)
|
|
Next
|
|
' Tipo di movimento e feed
|
|
ShowMoveTypeFeed()
|
|
' Nome utensile e speed
|
|
ShowToolNameSpeed()
|
|
End Sub
|
|
|
|
Private Sub IsValidAxisIndex(nIndex As Integer)
|
|
For Index = m_MachineAxisList.Count To nIndex
|
|
m_MachineAxisList.Add(New MachineAxis)
|
|
Next
|
|
End Sub
|
|
|
|
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 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
|
|
|
|
Private Function LoadCurrTools() As Boolean
|
|
' Se macchina con cambio utensile non devo fare alcunché
|
|
If CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.TOOLCHANGER Then
|
|
Return True
|
|
End If
|
|
' Imposto la lama corrente
|
|
Dim sSaw As String = CurrentMachine.sCurrSaw
|
|
If Not EgtLoadTool("H1", 1, sSaw) Then
|
|
Return False
|
|
End If
|
|
' Imposto eventuale secondo utensile montato
|
|
If CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL Then
|
|
Dim sTool As String = CurrentMachine.sCurrDrill
|
|
If String.IsNullOrEmpty(sTool) Then sTool = CurrentMachine.sCurrMill
|
|
If Not String.IsNullOrEmpty(sTool) AndAlso Not EgtLoadTool("H1", 2, sTool) Then
|
|
Return False
|
|
End If
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Sub ExitSimulation()
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
' Mi assicuro di terminare la simulazione
|
|
ResetSimulation()
|
|
' Ripristino visibilità standard
|
|
m_nMachLook = MCH_LOOK.TAB
|
|
EgtSetMachineLook(m_nMachLook)
|
|
' Nascondo tutte le lavorazioni
|
|
CamAuto.HideAllMachinings()
|
|
' Abilito impostazione modificato
|
|
EgtEnableModified()
|
|
' Cambio la vista della scena
|
|
EgtSetView(VT.TOP, False)
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "ToolModeCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property ToolModeCommand As ICommand
|
|
Get
|
|
If m_cmdToolMode Is Nothing Then
|
|
m_cmdToolMode = New Command(AddressOf ToolMode)
|
|
End If
|
|
Return m_cmdToolMode
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub ToolMode(ByVal param As Object)
|
|
' aggiorno lo stato
|
|
If m_nMachLook <> MCH_LOOK.TAB_TOOL Then
|
|
m_nMachLook = MCH_LOOK.TAB_TOOL
|
|
End If
|
|
' aggiorno lo stato della macchina e la sua visualizzazione
|
|
EgtSetMachineLook(m_nMachLook)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' ToolModeCommand
|
|
|
|
#Region "HeadModeCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property HeadModeCommand As ICommand
|
|
Get
|
|
If m_cmdHeadMode Is Nothing Then
|
|
m_cmdHeadMode = New Command(AddressOf HeadMode)
|
|
End If
|
|
Return m_cmdHeadMode
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub HeadMode(ByVal param As Object)
|
|
' aggiorno lo stato
|
|
If m_nMachLook <> MCH_LOOK.TAB_HEAD Then
|
|
m_nMachLook = MCH_LOOK.TAB_HEAD
|
|
End If
|
|
' aggiorno lo stato della macchina e la sua visualizzazione
|
|
EgtSetMachineLook(m_nMachLook)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' HeadModeCommand
|
|
|
|
#Region "MachModeCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property MachModeCommand As ICommand
|
|
Get
|
|
If m_cmdMachMode Is Nothing Then
|
|
m_cmdMachMode = New Command(AddressOf MachMode)
|
|
End If
|
|
Return m_cmdMachMode
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub MachMode(ByVal param As Object)
|
|
' aggiorno lo stato
|
|
If m_nMachLook <> MCH_LOOK.ALL Then
|
|
m_nMachLook = MCH_LOOK.ALL
|
|
End If
|
|
' aggiorno lo stato della macchina e la sua visualizzazione
|
|
EgtSetMachineLook(m_nMachLook)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' MachModeCommand
|
|
|
|
#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 Command(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)
|
|
StatusMsg = ""
|
|
' Se stato stop, devo avviare simulazione
|
|
If m_nStatus = MCH_SIM_ST.UI_STOP Then
|
|
SimulationStatus = MCH_SIM_ST.UI_STEP
|
|
' Aggiorno bottone
|
|
m_bShowPlay = False
|
|
NotifyPropertyChanged("PlayPauseImage")
|
|
ExecSim()
|
|
' Aggiorno bottone
|
|
m_bShowPlay = True
|
|
NotifyPropertyChanged("PlayPauseImage")
|
|
' Alrimenti imposto solo il nuovo stato
|
|
Else
|
|
SimulationStatus = MCH_SIM_ST.UI_STEP
|
|
' Aggiornamenti per bottone Play/Pause
|
|
m_bShowPlay = False
|
|
NotifyPropertyChanged("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 Command(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)
|
|
StatusMsg = ""
|
|
If m_bShowPlay Then
|
|
' Aggiorno bottone
|
|
m_bShowPlay = False
|
|
NotifyPropertyChanged("PlayPauseImage")
|
|
' Eseguo
|
|
If m_nStatus = MCH_SIM_ST.UI_STOP Then
|
|
' Lancio simulazione
|
|
SimulationStatus = MCH_SIM_ST.UI_PLAY
|
|
ExecSim()
|
|
' Aggiorno bottone
|
|
m_bShowPlay = True
|
|
NotifyPropertyChanged("PlayPauseImage")
|
|
ElseIf m_nStatus = MCH_SIM_ST.UI_PAUSE Then
|
|
SimulationStatus = MCH_SIM_ST.UI_PLAY
|
|
End If
|
|
Else
|
|
' Aggiorno bottone
|
|
m_bShowPlay = True
|
|
NotifyPropertyChanged("PlayPauseImage")
|
|
' Se play o step, imposto stato pausa
|
|
If m_nStatus = MCH_SIM_ST.UI_PLAY Or m_nStatus = MCH_SIM_ST.UI_STEP Then
|
|
SimulationStatus = MCH_SIM_ST.UI_PAUSE
|
|
StatusMsg = EgtMsg(MSG_SIMULATIONPAGEUC + 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 Command(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)
|
|
StatusMsg = ""
|
|
' Se stato già stop, porto in home
|
|
If m_nStatus = MCH_SIM_ST.UI_STOP Then
|
|
' Mi riporto all'inizio
|
|
EgtSimStart()
|
|
EgtDraw()
|
|
' Aggiorno dati CNC
|
|
ShowCncData()
|
|
StatusMsg = EgtMsg(MSG_SIMULATIONPAGEUC + 14) ' Home
|
|
Else
|
|
StatusMsg = EgtMsg(MSG_SIMULATIONPAGEUC + 12) ' Simulazione interrotta
|
|
End If
|
|
' Aggiorno bottone
|
|
m_bShowPlay = True
|
|
NotifyPropertyChanged("PlayPauseImage")
|
|
' Imposto il nuovo stato
|
|
SimulationStatus = MCH_SIM_ST.UI_STOP
|
|
End Sub
|
|
|
|
|
|
#End Region ' StopCommand
|
|
|
|
Private Function GetEstimationFileName(bAskSave As Boolean, ByRef sEstFile As String, ByRef sInfo As String) As Boolean
|
|
Dim bOk As Boolean = True
|
|
' Recupero e verifico la path del progetto corrente
|
|
Dim sCurrFilePath As String = String.Empty
|
|
EgtGetCurrFilePath(sCurrFilePath)
|
|
If bAskSave Then
|
|
If String.IsNullOrEmpty(sCurrFilePath) OrElse EgtGetModified() Then
|
|
' Il progetto deve essere salvato prima di poter essere generato. Vuoi farlo ?
|
|
If MessageBox.Show(EgtMsg(MSG_SIMULATION + 31), EgtMsg(MSG_SIMULATION + 15), MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.No Then
|
|
' Abbandono
|
|
bOk = False
|
|
Else
|
|
' Lancio salvataggio
|
|
OmagOFFICEMap.refSceneHostVM.SaveProject()
|
|
EgtGetCurrFilePath(sCurrFilePath)
|
|
' Se non salvato, abbandono
|
|
If EgtGetModified() Then bOk = False
|
|
End If
|
|
End If
|
|
Else
|
|
If String.IsNullOrEmpty(sCurrFilePath) Then
|
|
' File delle stime non trovato
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATION + 18), EgtMsg(MSG_SIMULATION + 15), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
bOk = False
|
|
End If
|
|
End If
|
|
' Creo la path del file di stima e relativo info (con nome gruppo se gestiti)
|
|
If Not String.IsNullOrEmpty(sCurrFilePath) Then
|
|
sEstFile = Path.ChangeExtension(sCurrFilePath, Nothing)
|
|
sInfo = "EgtCAM5 - " & sCurrFilePath
|
|
Dim sMGrpName As String = String.Empty
|
|
If EgtGetMachGroupName(EgtGetCurrMachGroup(), sMGrpName) Then
|
|
sEstFile &= "_" & sMGrpName & ".html"
|
|
sInfo &= "-" & sMGrpName
|
|
Else
|
|
sEstFile &= ".html"
|
|
End If
|
|
End If
|
|
Return bOk
|
|
End Function
|
|
|
|
#Region "Details"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property Details_Command As ICommand
|
|
Get
|
|
If m_cmdDetails Is Nothing Then
|
|
m_cmdDetails = New Command(AddressOf Details)
|
|
End If
|
|
Return m_cmdDetails
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub Details(ByVal param As Object)
|
|
' Determino il nome del file contenente le stime
|
|
Dim sEstFile As String = OmagOFFICEMap.refMainWindowVM.MainWindowM.sTempDir & "\MachProj.html"
|
|
Dim sInfo As String = ""
|
|
'GetEstimationFileName(False, sEstFile, sInfo)
|
|
' Verifico che il file esista
|
|
If Not File.Exists(sEstFile) Then
|
|
' File delle stime non trovato
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATION + 15), EgtMsg(MSG_SIMULATION + 14), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
Return
|
|
End If
|
|
' Visualizzazione
|
|
Dim EstimationsWnd As New EstimationsDetailsWndV(Application.Current.MainWindow, New EstimationsDetailsWndVM(sEstFile, CurrentMachine.sMachIniFile))
|
|
EstimationsWnd.ShowDialog()
|
|
End Sub
|
|
|
|
#End Region ' Details
|
|
|
|
#End Region
|
|
|
|
End Class
|