OmagCUT :

- migliorie varie per comunicazione con macchina
- teach-in anche con laser.
This commit is contained in:
Dario Sassi
2015-12-14 07:45:17 +00:00
parent 9c2729d278
commit 07e379ef92
12 changed files with 282 additions and 174 deletions
+2
View File
@@ -57,7 +57,9 @@ Public Class AlarmsPageUC
Friend Sub NcError()
If m_CN.sz_NC_error_messages.Count > 0 Then
NCErrorMessages.Text = m_CN.sz_NC_error_messages(0)
If m_CN.bIsErrorMessage Then
m_MainWindow.m_MachineStatusUC.MachineStatusGrid.Background = Brushes.Red
End If
Else
NCErrorMessages.Text = ""
Dim BackColor As SolidColorBrush = m_MainWindow.m_MachineStatusUC.MachineStatusGrid.Background
+44 -16
View File
@@ -124,8 +124,9 @@ Public Class CNCommunication
m_MachineStatus.MachineStatusGrid.Background = Brushes.Gold
' istanzio l'oggetto CN
' 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
@@ -134,12 +135,24 @@ Public Class CNCommunication
Case Else
m_CN = New Num.NumNC
End Select
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_TestingPage.m_CN = Me.m_CN
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.m_CN = Me.m_CN
m_MainWindow.m_DirectCutPageUC.m_CN = Me.m_CN
m_MainWindow.m_DirectCutPageUC.m_ManualAxesMove.m_CN = Me.m_CN
' 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)
' Inizializzo la comunicazione
m_CN.Init()
Catch ex As Exception
' set status to statusbar
EgtOutLog("Error starting NC communication : " & ex.Message)
@@ -149,21 +162,23 @@ Public Class CNCommunication
Case 0 'Debug
Case 1, 2 'Axium, Flexium
If IsNothing(m_CN) OrElse m_CN.n_state < 2 Then
'Per evitare crash nel caso si clickino bottoni che agiscono sul controllo, avvio il controllo di debug al posto del flexium
' Per evitare crash con azioni verso il controllo, avvio quello di debug
Me.m_CN = New CN_Debug
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_TestingPage.m_CN = Me.m_CN
m_MainWindow.m_DirectCutPageUC.m_MachineButtons.m_CN = Me.m_CN
m_MainWindow.m_DirectCutPageUC.m_CN = Me.m_CN
m_MachineStatus.MachineStatusGrid.Background = Brushes.Red
Else
m_CN.b_axis_events_enable = True
m_MachineStatus.MachineStatusGrid.Background = Brushes.Gray
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_TestingPage.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
End Sub
Private Sub NewVarChanged_handler(ByVal nst As Object) Handles m_CN.NewVarChanged
@@ -196,8 +211,8 @@ Public Class CNCommunication
m_MachineStatus.DisplayPositionDelta(m_nL1, m_nL2, m_nL3, m_nR1, m_nR2)
End If
If m_CN.b_feed_override_changed Then
m_CN.b_feed_override_changed = False
If m_CN.b_feed_changed Then
m_CN.b_feed_changed = False
m_MachineStatus.DisplayFeed()
End If
@@ -288,6 +303,19 @@ Public Class CNCommunication
Return m_bAxesOk
End Function
Friend Function GetLinearAxesPositions(ByRef dL1 As Double, ByRef dL2 As Double, ByRef dL3 As Double)
dL1 = m_CN.d_axis_position(m_nL1)
dL2 = m_CN.d_axis_position(m_nL2)
dL3 = m_CN.d_axis_position(m_nL3)
Return m_bAxesOk
End Function
Friend Function GetRotaryAxesPositions(ByRef dR1 As Double, ByRef dR2 As Double) As Boolean
dR1 = m_CN.d_axis_position(m_nR1)
dR2 = m_CN.d_axis_position(m_nR2)
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
+6 -1
View File
@@ -2,13 +2,18 @@
Inherits CN_generico
Sub New()
End Sub
Public Overrides Function Init() As Boolean
' Assegno valori ad assi per test
d_axis_position(0) = -3740 + 2000
d_axis_position(1) = -2424 + 363.5 + 800
d_axis_position(2) = -1379.5 + 45 + 50 + 50
d_axis_position(8) = 90.0
d_axis_position(7) = 90.0
End Sub
Return True
End Function
Public Overrides Function ActivateProgram(n_part_program As Integer) As Short
Return 0
+22 -3
View File
@@ -6,6 +6,16 @@
Public Const MAX_VAR As Short = 100
Public Const MAX_VALUES As Short = 9 ' Max. index to read the data from the FXServer array
Public Const MAX_TOOLS As Short = 100
Public Const NUM_DATA = 7 ' Numero di dati del CN (Speed,Feed,...)
Public Enum CnData
Mode = 0
JogIncr = 1
Feed = 2
FeedOvr = 3
Speed = 4
SpeedOvr = 5
Power = 6
End Enum
#End Region
@@ -56,12 +66,11 @@
Public d_DInterpo_values(MAX_AXES) As Double
Public d_DInterpo_Prog_Feed As Double
Public d_DInterpo_Feed_override As Double
Public l_channel_override(MAX_VALUES) As Long
Public b_feed_changed As Boolean = False
Public n_activate_error_code As Short
Public l_channel_override(MAX_VALUES) As Long
Public b_feed_override_changed As Boolean = False
Public d_spindle_prog(MAX_VALUES) As Double
Public d_spindle_eff(MAX_VALUES) As Double
Public n_spindle_override(MAX_VALUES) As Short
@@ -77,6 +86,9 @@
Public sz_NC_error_messages As List(Of String)
Public b_PLC_error As Boolean
Public b_NC_error As Boolean
Public bIsErrorMessage As Boolean = True
Public m_szCnDataVar(NUM_DATA - 1) As String
Public Event NewPositionData(ByVal sender As Object)
Public Event NewPosDeltaData(ByVal sender As Object)
@@ -97,6 +109,8 @@
#Region " Metodi pubblici"
Public MustOverride Function Init() As boolean
Public MustOverride Sub ReadEls_Add_Parameter(sz_var As String, n_par As Short)
Public MustOverride Sub DVariables_WriteVariables(sz_parameters As String, sz_values As String)
@@ -161,6 +175,11 @@
Return (nAx >= 0 And nAx <= MAX_AXES)
End Function
Public Function SetCnDataVar(nId As CnData, sVal As String)
m_szCnDataVar(nId) = sVal
Return True
End Function
#End Region
End Class
+9
View File
@@ -17,6 +17,15 @@
Public Const K_R3NAME As String = "R3Name"
Public Const K_R3ID As String = "R3Id"
Public Const S_NCDATA As String = "NcData"
Public Const K_MODE As String = "Mode"
Public Const K_JOGINCR As String = "JogIncr"
Public Const K_FEED As String = "Feed"
Public Const K_FEEDOVR As String = "FeedOvr"
Public Const K_SPEED As String = "Speed"
Public Const K_SPEEDOVR As String = "SpeedOvr"
Public Const K_POWER As String = "Power"
Public Const S_TABLE As String = "Table"
Public Const K_ADDITIONALTABLE As String = "AdditionalTable"
+63 -43
View File
@@ -114,20 +114,25 @@ Namespace Num
Private l_Gcodes_2 As ULong
Private l_current_Gcodes As ULong
Private m_nCnDataVarNum As Integer = 0
Private m_nCnDataVarInd(NUM_DATA - 1) As Integer
#End Region
#Region " Constructor"
Sub New()
Sub New()
n_state = 0
sz_NC_error_messages = New List(Of String)
End Sub
' Initialize and start Runtime System
Public Overrides Function Init() As Boolean
sz_NC_error_messages = New List(Of String)
' Initialize and start Runtime System
InitFxServer()
InitFxServer()
End Sub
Return n_state >= 2
End Function
#End Region
@@ -436,14 +441,29 @@ Namespace Num
Dim sz_var_names As New ArrayList
Dim n_ret As Short
sz_var_names.Add("Application.IOCONFIG_GLOBALS.Flexium_NCK.RCNC.General.Mode") ' modo 0:AUTO;1:SEQ;2:MDI;3:RAPIDO;4:SERCH;5:EDIT;6:TEST;7:MANUALE;
sz_var_names.Add("Application.IOCONFIG_GLOBALS.Flexium_NCK.RCNC.General.JogIncrement") ' Tipo man. 0:0.1 u; 1:1 u; 2:10 u; 3:100 u; 4:1 mm; 5:10 mm; 6:ILL; 8:HANDWEEL; 9:0.01 u; 10:0.001 u;
sz_var_names.Add("Application.IOCONFIG_GLOBALS.Flexium_NCK.WCNC.Channel[1].FeedOveride") ' Potenziom. Feed = *0.47059
'sz_var_names.Add("Application.IOCONFIG_GLOBALS.Flexium_NCK.RCNC.General.Mode") ' modo 0:AUTO;1:SEQ;2:MDI;3:RAPIDO;4:SERCH;5:EDIT;6:TEST;7:MANUALE;
'sz_var_names.Add("Application.IOCONFIG_GLOBALS.Flexium_NCK.RCNC.General.JogIncrement") ' Tipo man. 0:0.1 u; 1:1 u; 2:10 u; 3:100 u; 4:1 mm; 5:10 mm; 6:ILL; 8:HANDWEEL; 9:0.01 u; 10:0.001 u;
'sz_var_names.Add("Application.IOCONFIG_GLOBALS.Flexium_NCK.WCNC.Channel[1].FeedOveride") ' Potenziom. Feed = *0.47059
'sz_var_names.Add("Application.IOCONFIG_GLOBALS.Flexium_NCK.WCNC.Spindle[2].Override") ' segnaposto per la speed override
'sz_var_names.Add("Application.GVL_HMI_OMAG.HMI_Vel_prog") ' FEED
'sz_var_names.Add("Application.GVL_HMI_OMAG.HMI_LabRPM") ' Speed
'sz_var_names.Add("Application.GVL_HMI_OMAG.HMI_LabAmper") ' Ampère = *0.01
'sz_var_names.Add("Application.GVL_HMI_OMAG.HMI_LabRPM") ' segnaposto per la speed override
' Creo lista nomi variabili PLC da leggere
m_nCnDataVarNum = 0
For nI As Integer = 0 To NUM_DATA - 1
If Not String.IsNullOrWhiteSpace(m_szCnDataVar(nI)) AndAlso
m_szCnDataVar(nI).StartsWith("PLC,") Then
' inserisco nome variabile in lista di variabili da leggere
sz_var_names.Add(m_szCnDataVar(nI).Substring(4))
' imposto indice variabile
m_nCnDataVarInd(m_nCnDataVarNum) = nI
' incremento numero di variabili da leggere
m_nCnDataVarNum += 1
End If
Next
' Imposto lettura variabili
n_ret = objDPlcVariables.ReadVariables(sz_var_names.ToArray())
If n_ret <> 0 Then
@@ -628,7 +648,7 @@ Namespace Num
l_channel_override(ni) = CLng(values(n))
Next
b_feed_override_changed = True
b_feed_changed = True
End Sub
#End Region
@@ -932,29 +952,28 @@ Namespace Num
For n = 0 To index.Length - 1
ni = CInt(index(n))
If ni >= m_nCnDataVarNum Then
Continue For
End If
Select Case ni
Case 0 ' modo 0:AUTO;1:SEQ;2:MDI;3:RAPIDO;4:SERCH;5:EDIT;6:TEST;7:MANUALE;
Case 1 ' Tipo man. 0:0.1 u; 1:1 u; 2:10 u; 3:100 u; 4:1 mm; 5:10 mm; 6:ILL; 8:HANDWEEL; 9:0.01 u; 10:0.001 u;
Case 2 ' Potenziom. Feed = *0.47059
d_DInterpo_Feed_override = CDbl(CLng(values(n))) * 0.47059
b_feed_override_changed = True
Case 3 ' FEED
Select Case m_nCnDataVarInd(ni)
Case CnData.Mode ' (0) modo 0:AUTO;1:SEQ;2:MDI;3:RAPIDO;4:SERCH;5:EDIT;6:TEST;7:MANUALE;
' ...
Case CnData.JogIncr ' (1) Tipo man. 0:0.1 u; 1:1 u; 2:10 u; 3:100 u; 4:1 mm; 5:10 mm; 6:ILL; 8:HANDWEEL; 9:0.01 u; 10:0.001 u;
' ...
Case CnData.Feed ' (2)
'd_DInterpo_Prog_Feed = CDbl(CLng(values(n))) ' d_DInterpo_Prog_Feed
Case 4 ' Speed
Case 5 ' Ampère = *0.01
Case CnData.FeedOvr ' (3) Potenziom. Feed = * 0.47059
d_DInterpo_Feed_override = CDbl(CLng(values(n))) * 0.47059
b_feed_changed = True
Case CnData.Speed ' (4) Speed
d_spindle_eff(0) = CDbl(values(n))
Case CnData.SpeedOvr ' (5) Potenziom. speed = ...
n_spindle_override(0) = Math.Round((CDbl(values(n)) * 50 / 255) + 50)
Case CnData.Power ' (6) Ampère = * 0.01
d_spindle_power = CDbl(CLng(values(n))) * 0.01
b_spindle_power_changed = True
Case 6 ' Potenziom. speed = ????????????
End Select
Next
End Sub
@@ -988,9 +1007,9 @@ Namespace Num
d_DInterpo_values(n) = CDbl(CLng(values(n)))
Next
'd_DInterpo_Prog_Feed = d_DInterpo_values(3) ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
d_DInterpo_Prog_Feed = d_DInterpo_values(3)
'd_DInterpo_Feed_override = d_DInterpo_values(4)
'b_feed_override_changed = True
b_feed_changed = True
End Sub
#End Region
@@ -1020,7 +1039,7 @@ Namespace Num
Case 2 ' % override
n_spindle_override(n_spindle) = CShort(values(n))
'n_spindle_override(n_spindle) = CShort(values(n))
Case 3 ' prog speed
d_spindle_prog(n_spindle) = CDbl(values(n))
@@ -1242,11 +1261,11 @@ Namespace Num
'CNC boot message
'sMessaggio = objSystemFunctions.GetSysErrorText(vErrorNumber(i)) ' Recupero il testo del messaggio ????
sMessaggio = "Boot: " & ErrorMessage(i)
bIsErrorMessage = True
Case 1
'CNC sys warning
sMessaggio = "All.Sys: " & vErrorNumber(i) & " " & ErrorMessage(i)
bIsErrorMessage = True
Case 2
'CNC msg
vNumberError = vErrorNumber(i) And &HFFFF
@@ -1274,7 +1293,7 @@ Namespace Num
sMessaggio = "CN: " & vNumberError & " Ext" & vExtNumberError & " N" & vErrorLine(i) & " L" & vErrorAdditional(i) & ErrorMessage(i)
End If
End If
bIsErrorMessage = True
Case 3
'Drive Error
vNumberError = vErrorNumber(i) And &HFFFF0000
@@ -1282,12 +1301,12 @@ Namespace Num
vExtNumberError = vErrorNumber(i) - (vNumberError * 2 ^ 16) '--> vNumberError(i) AND &hFFFF
sMessaggio = "Azionamento: " & "Asse " & vErrorIndex(i) & " Errore: " & vNumberError & " Ext " & vExtNumberError & " " & ErrorMessage(i)
bIsErrorMessage = True
Case 5
'Communication Message
'sMessaggio = objFXLib_SystemFunctions.GetUniteError(vNumberError) ' Recupero il testo del messaggio ????
sMessaggio = "COMM: " & vErrorNumber(i) & " " & ErrorMessage(i)
bIsErrorMessage = True
Case 6, 7, 8, 9, 10, 11, 12, 13
'PLC msg Reaction Class 1->8
ClassPLCMsg = vErrorType(i) - 5
@@ -1301,28 +1320,29 @@ Namespace Num
' sz_NC_error_messages.Add(sMessaggio)
' sMessaggio = sMessaggio1
' Next nLinee
bIsErrorMessage = True
Case 20
'HMI msg
'sMessaggio = objSystemFunctions.GetHmiMessageText(vErrorNumber(i)) ' Recupero il testo del messaggio ????
sMessaggio = "HMI: " & vErrorNumber(i) & " " & ErrorMessage(i)
bIsErrorMessage = False
Case 21
'User msg
'sMessaggio = objSystemFunctions.GetUserMessageText(vErrorNumber(i)) ' Recupero il testo del messaggio ????
sMessaggio = "User: " & vErrorNumber(i) & " " & ErrorMessage(i)
bIsErrorMessage = True
Case 22
'RTS msg
' sMessaggio = objSystemFunctions.GetRunTimeSystemError(vErrorNumber(i)) ' Recupero il testo del messaggio ????
sMessaggio = "RTS: " & vErrorNumber(i) & " " & ErrorMessage(i)
bIsErrorMessage = True
Case 23
'Drive Warning
sMessaggio = "Azionamento: " & "Asse " & vErrorIndex(i) & " Avviso: " & vErrorNumber(i) & ": " & ErrorMessage(i)
bIsErrorMessage = True
Case Else
sMessaggio = "Type ??: " & vErrorNumber(i) & " " & ErrorMessage(i)
bIsErrorMessage = True
End Select
sz_NC_error_messages.Add(sMessaggio)
+20 -19
View File
@@ -221,34 +221,35 @@ Namespace Num
#Region " Constructor"
Sub New()
Sub New()
n_state = 0
sz_NC_error_messages = New List(Of String)
End Sub
Dim nret As Integer
Public Overrides Function Init() As Boolean
n_state = 0
n_state = 0
sz_NC_error_messages = New List(Of String)
' !!!!!!!!!!!!!!!!!!!!!!!!!1 da leggere da file di configurazione !!!!!!!
'nret = NC_connect("COM")
Dim nret As Integer = NC_connect("XIP01, 0, 10, 0, 0, 0")
' !!!!!!!!!!!!!!!!!!!!!!!!!1 da leggere da file di configurazione !!!!!!!
n_state = 2
'nret = NC_connect("COM")
nret = NC_connect("XIP01, 0, 10, 0, 0, 0")
' Create a timer and set an half second interval.
aTimer = New System.Timers.Timer()
n_state = 2
aTimer.Interval = 500 ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' Create a timer and set an half second interval.
aTimer = New System.Timers.Timer()
' Hook up the Elapsed event for the timer.
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
aTimer.Interval = 500 ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
aTimer.AutoReset = True ' Have the timer fire repeated events (true is the default)
' Hook up the Elapsed event for the timer.
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
aTimer.Enabled = True ' Start the timer
aTimer.AutoReset = True ' Have the timer fire repeated events (true is the default)
aTimer.Enabled = True ' Start the timer
End Sub
Return n_state >= 2
End Function
Private Sub OnTimedEvent(source As Object, e As System.Timers.ElapsedEventArgs)
@@ -345,7 +346,7 @@ Namespace Num
Var600D = MyData.data(3) ' active_mode
Var600E = MyData.data(4)
b_feed_override_changed = True
b_feed_changed = True
d_DInterpo_Feed_override = Math.Round(Var600A * 120.0 / 255, 0)
b_spindle_data_changed = True
+3 -2
View File
@@ -124,7 +124,8 @@ Public Class MachineStatusUC
End Sub
Sub DisplayFeed()
FeedLbl.Content = DoubleToString(m_CN.d_DInterpo_Prog_Feed, 0)
Dim dRealFeed As Double = m_CN.d_DInterpo_Prog_Feed * m_CN.d_DInterpo_Feed_override / 100
FeedLbl.Content = DoubleToString(dRealFeed, 0)
FeedOverrideLbl.Content = DoubleToString(m_CN.d_DInterpo_Feed_override, 0) & "%"
End Sub
@@ -134,7 +135,7 @@ Public Class MachineStatusUC
End Sub
Sub DisplayPower()
ConsumptionLbl.Content = DoubleToString(m_CN.d_spindle_power, -1)
ConsumptionLbl.Content = DoubleToString(m_CN.d_spindle_power, -2)
' AOverrideLbl
End Sub
+4 -16
View File
@@ -200,7 +200,6 @@ Class MainWindow
Dim sLuaBaseLib As String = String.Empty
GetPrivateProfileString(S_LUA, K_BASELIB, "EgtBase", sLuaBaseLib, m_sIniFile)
EgtLuaRequire(sLuaBaseLib)
' Imposto posizione e dimensioni della MainWindow
Dim nFlag As Integer
Dim nLeft As Integer
@@ -214,10 +213,8 @@ Class MainWindow
Me.Height = nHeight
Me.Width = nWidth
WindowState = If(nFlag = 1, WindowState.Maximized, WindowState.Normal)
' Crezione della MachineStatusBar
m_MachineStatusUC = New MachineStatusUC
' Creazione delle Page UserControl
m_WorkInProgressPageUC = New WorkInProgressPageUC
m_DirectCutPageUC = New DirectCutPageUC
@@ -232,12 +229,10 @@ Class MainWindow
m_CurrentProjectPageUC = New CurrentProjectPageUC
m_MachinePageUC = New MachinePageUC
m_OptionsPageUC = New OptionsPageUC
' Creazione gestore comunicazione con macchina CN
m_CNCommunication = New CNCommunication
' Posizionamento nella griglia della MachineStatusBar
m_MachineStatusUC.SetValue(Grid.RowProperty, 2)
' Posizionemento nella griglia delle Page UserControl
m_WorkInProgressPageUC.SetValue(Grid.ColumnProperty, 0)
m_WorkInProgressPageUC.SetValue(Grid.RowProperty, 1)
@@ -259,16 +254,13 @@ Class MainWindow
m_MachinePageUC.SetValue(Grid.RowProperty, 1)
m_OptionsPageUC.SetValue(Grid.ColumnProperty, 0)
m_OptionsPageUC.SetValue(Grid.RowProperty, 1)
'Posizionemento nella griglia di pagine e usercontrol di utilità
m_WorkInProgressPageUC.SetValue(Grid.ColumnProperty, 0)
m_WorkInProgressPageUC.SetValue(Grid.RowProperty, 1)
'Disabilita la possibilità di imitare il click del tasto destro del mouse tenendo premuto il dito sul touch
'NB: Se abilitato impedisce di utilizzare lo stato Pressed dei Button che quindi non si evidenziano quando premuti
Stylus.SetIsPressAndHoldEnabled(Me, False)
'Leggo lista materiali da file ini
' Leggo lista materiali da file ini
Dim index As Integer = 1
Dim sMaterial As String = String.Empty
While GetPrivateProfileString(S_MATERIALS, K_MATERIAL & index, "", sMaterial, GetIniFile) > 0
@@ -276,8 +268,7 @@ Class MainWindow
m_MaterialsList.Add(cMaterial)
index += 1
End While
'Leggo materiale corrente da file ini
' Leggo materiale corrente da file ini
Dim sCurrentMaterial As String = String.Empty
GetPrivateProfileString(S_MATERIALS, K_CURRMATERIAL, "", sCurrentMaterial, GetIniFile)
For i As Integer = 0 To m_MaterialsList.Count - 1
@@ -286,15 +277,13 @@ Class MainWindow
Exit For
End If
Next
'Imposto i messaggi letti dal file dei messaggi
' Imposto i messaggi letti dal file dei messaggi
WorkInProgressTxBl.Text = EgtMsg(MSG_GENERAL + 1)
DirectCutBtn.Content = EgtMsg(MSG_GENERAL + 2)
CadCutBtn.Content = EgtMsg(MSG_GENERAL + 3)
FrameCutBtn.Content = EgtMsg(MSG_GENERAL + 4)
MachineBtn.Content = EgtMsg(MSG_GENERAL + 5)
OptionsBtn.Content = EgtMsg(MSG_GENERAL + 6)
End Sub
Private Sub ManageSingleIstance()
@@ -782,7 +771,6 @@ Class MainWindow
End Sub
Private Sub Window_ContentRendered(sender As Object, e As EventArgs)
' Verifico presenza del collegamento al CN
m_bNCLink = (GetPrivateProfileInt(S_GENERAL, K_CNLINK, 0, m_sIniFile) <> 0)
m_CNCommunication.CNCommunication_Initialization()
+81 -66
View File
@@ -1,4 +1,5 @@
Imports EgtUILib
Imports System.Windows.Threading
Imports EgtUILib
Public Class ManualAxesMoveUC
@@ -6,46 +7,65 @@ Public Class ManualAxesMoveUC
Private m_MainWindow As MainWindow = Application.Current.MainWindow
Friend m_CN As CN_generico
' Timer per aggiornamento nomi assi
Private m_Timer As New DispatcherTimer
Private Sub ManualAxesMove_Initialized(sender As Object, e As EventArgs)
FeedTxBl.Text = "F"
SpeedTxBl.Text = "S"
Dim AxesName As String = String.Empty
GetPrivateProfileString(S_AXES, K_L1NAME, "", AxesName, m_MainWindow.GetMachIniFile())
L1Btn.Content = AxesName
GetPrivateProfileString(S_AXES, K_L2NAME, "", AxesName, m_MainWindow.GetMachIniFile())
L2Btn.Content = AxesName
GetPrivateProfileString(S_AXES, K_L3NAME, "", AxesName, m_MainWindow.GetMachIniFile())
L3Btn.Content = AxesName
GetPrivateProfileString(S_AXES, K_R1NAME, "", AxesName, m_MainWindow.GetMachIniFile())
R1Btn.Content = AxesName
GetPrivateProfileString(S_AXES, K_R2NAME, "", AxesName, m_MainWindow.GetMachIniFile())
R2Btn.Content = AxesName
AddHandler m_Timer.Tick, AddressOf Timer_tick
End Sub
Private Sub ManualAxesMove_Loaded(sender As Object, e As RoutedEventArgs)
Dim nTemp As Integer = 0
' Nomi feed e speed
FeedTxBl.Text = "F"
SpeedTxBl.Text = "S"
' Valori feed e speed da lama corrente
Dim dTemp As Double = 0
' Leggo feed e speed da lama corrente
EgtTdbSetCurrTool(m_MainWindow.m_CurrentProjectPageUC.ToolTxBx.Text)
EgtTdbGetCurrToolParam(MCH_TP.FEED, dTemp)
FeedTxBx.Text = dTemp
EgtTdbGetCurrToolParam(MCH_TP.SPEED, dTemp)
SpeedTxBx.Text = dTemp
' Agli assi lineari assegno '0' (sono incrementali)
' Nomi assi
UpdateAxesNames()
' Valori assi lineari : assegno '0' perchè incrementali
L1TxBx.Text = "0"
L2TxBx.Text = "0"
L3TxBx.Text = "0"
' Agli assi rotanti assegno i valori macchina
nTemp = GetPrivateProfileInt(S_AXES, K_R1ID, 8, m_MainWindow.GetMachIniFile())
R1TxBx.Text = DoubleToString(m_CN.d_axis_position(nTemp), 3)
nTemp = GetPrivateProfileInt(S_AXES, K_R2ID, 7, m_MainWindow.GetMachIniFile())
R2TxBx.Text = DoubleToString(m_CN.d_axis_position(nTemp), 3)
' Valori assi rotanti : assegno i valori macchina
Dim dL1, dL2, dL3, dR1, dR2 As Double
m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2)
R1TxBx.Text = DoubleToString(dR1, 3)
R2TxBx.Text = DoubleToString(dR2, 3)
' Lancio timer per aggiornamento interfaccia
m_Timer.Interval = TimeSpan.FromMilliseconds(200)
m_Timer.Start()
End Sub
Private Sub L1Btn_Click(sender As Object, e As RoutedEventArgs) Handles L1Btn.Click, L2Btn.Click, L3Btn.Click, R1Btn.Click, R2Btn.Click
Private Sub UpdateAxesNames()
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
If Not m_CN.Is_G24_active() Then
L1Btn.Content = sL1 ' X
L2Btn.Content = sL2 ' Y
L3Btn.Content = sL3 ' Z
Else
L1Btn.Content = "P" ' perpendicular
L2Btn.Content = "H" ' horizontal
L3Btn.Content = "V" ' vertical
End If
R1Btn.Content = sR1 ' C
R2Btn.Content = sR2 ' B
End Sub
Private Sub Timer_tick()
UpdateAxesNames()
End Sub
Private Sub XXBtn_Click(sender As Object, e As RoutedEventArgs) Handles L1Btn.Click, L2Btn.Click, L3Btn.Click, R1Btn.Click, R2Btn.Click
Dim CurrentBtn As Button = e.Source
Dim nTemp As Integer = 0
Dim dTemp As Double = 0
@@ -57,32 +77,28 @@ Public Class ManualAxesMoveUC
EgtLuaSetGlobNumVar("CMD.S", dTemp)
' Leggo gli assi lineari rispetto allo 0 pezzo (per essere compatibile con G150)
m_CN.set_OP_OM(1)
System.Threading.Thread.Sleep(500)
nTemp = GetPrivateProfileInt(S_AXES, K_L1ID, 0, m_MainWindow.GetMachIniFile())
dTemp = m_CN.d_axis_position(nTemp)
EgtLuaSetGlobNumVar("CMD.L1", dTemp)
nTemp = GetPrivateProfileInt(S_AXES, K_L2ID, 1, m_MainWindow.GetMachIniFile())
dTemp = m_CN.d_axis_position(nTemp)
EgtLuaSetGlobNumVar("CMD.L2", dTemp)
nTemp = GetPrivateProfileInt(S_AXES, K_L3ID, 2, m_MainWindow.GetMachIniFile())
dTemp = m_CN.d_axis_position(nTemp)
EgtLuaSetGlobNumVar("CMD.L3", dTemp)
' Ritorno a leggere dallo 0 macchina
System.Threading.Thread.Sleep(1000)
Dim dL1, dL2, dL3 As Double
m_MainWindow.m_CNCommunication.GetLinearAxesPositions(dL1, dL2, dL3)
EgtLuaSetGlobNumVar("CMD.L1", dL1)
EgtLuaSetGlobNumVar("CMD.L2", dL2)
EgtLuaSetGlobNumVar("CMD.L3", dL3)
' Leggo gli assi rotanti rispetto allo 0 macchina
m_CN.set_OP_OM(0)
nTemp = GetPrivateProfileInt(S_AXES, K_R1ID, 8, m_MainWindow.GetMachIniFile())
dTemp = m_CN.d_axis_position(nTemp)
EgtLuaSetGlobNumVar("CMD.R1", dTemp)
nTemp = GetPrivateProfileInt(S_AXES, K_R2ID, 7, m_MainWindow.GetMachIniFile())
dTemp = m_CN.d_axis_position(nTemp)
EgtLuaSetGlobNumVar("CMD.R2", dTemp)
System.Threading.Thread.Sleep(100)
Dim dR1, dR2 As Double
m_MainWindow.m_CNCommunication.GetRotaryAxesPositions(dR1, dR2)
EgtLuaSetGlobNumVar("CMD.R1", dR1)
EgtLuaSetGlobNumVar("CMD.R2", dR2)
' Assegno nome e valore asse da muovere
EgtLuaSetGlobStringVar("CMD.AXISNAME", GetAxisName(CurrentBtn))
StringToDouble(GetAxisMove(CurrentBtn), dTemp)
EgtLuaSetGlobNumVar("CMD.AXISMOVE", dTemp)
EgtLuaSetGlobNumVar("CMD.AXISMOVE", GetAxisMove(CurrentBtn))
' Calcolo stringa di comando risultante
EgtLuaExecLine("CmdString()")
EgtLuaGetGlobStringVar("CMD.CMDSTRING", CmdString)
EgtLuaResetGlobVar("CmdString")
EgtLuaResetGlobVar("CMD")
' Eseguo in MDI
m_CN.DGeneralFunctions_WriteCncMode(2) ' Modalità MDI
System.Threading.Thread.Sleep(150)
m_CN.sz_ManualDataInput = CmdString
@@ -90,46 +106,45 @@ Public Class ManualAxesMoveUC
System.Threading.Thread.Sleep(150)
m_CN.DGeneralFunctions_CycleStart()
m_CN.DGeneralFunctions_WriteCncMode(7)
End Sub
Private Function GetAxisName(ByVal nBtnName As Button) As String
Dim AxesName As String = String.Empty
Dim sL1 As String = String.Empty
Dim sL2 As String = String.Empty
Dim sL3 As String = String.Empty
Dim sR1 As String = String.Empty
Dim sR2 As String = String.Empty
m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2)
Select Case nBtnName.Name
Case L1Btn.Name
GetPrivateProfileString(S_AXES, K_L1NAME, "", AxesName, m_MainWindow.GetMachIniFile())
Return AxesName
Return sL1
Case L2Btn.Name
GetPrivateProfileString(S_AXES, K_L2NAME, "", AxesName, m_MainWindow.GetMachIniFile())
Return AxesName
Return sL2
Case L3Btn.Name
GetPrivateProfileString(S_AXES, K_L3NAME, "", AxesName, m_MainWindow.GetMachIniFile())
Return AxesName
Return sL3
Case R1Btn.Name
GetPrivateProfileString(S_AXES, K_R1NAME, "", AxesName, m_MainWindow.GetMachIniFile())
Return AxesName
Return sR1
Case R2Btn.Name
GetPrivateProfileString(S_AXES, K_R2NAME, "", AxesName, m_MainWindow.GetMachIniFile())
Return AxesName
Return sR2
End Select
Return String.Empty
End Function
Private Function GetAxisMove(ByVal nBtnName As Button) As String
Dim AxesMove As Double = 0
Private Function GetAxisMove(ByVal nBtnName As Button) As Double
Dim dVal As Double = 0
Select Case nBtnName.Name
Case L1Btn.Name
Return L1TxBx.Text
StringToDouble(L1TxBx.Text, dVal)
Case L2Btn.Name
Return L2TxBx.Text
StringToDouble(L2TxBx.Text, dVal)
Case L3Btn.Name
Return L3TxBx.Text
StringToDouble(L3TxBx.Text, dVal)
Case R1Btn.Name
Return R1TxBx.Text
StringToDouble(R1TxBx.Text, dVal)
Case R2Btn.Name
Return R2TxBx.Text
StringToDouble(R2TxBx.Text, dVal)
End Select
Return String.Empty
Return dVal
End Function
End Class
+2
View File
@@ -65,6 +65,8 @@
VerticalAlignment="Center" />
</Button>
<CheckBox Name="LaserOnChBx" Grid.Row="5" Grid.ColumnSpan="2" Height="40" Width="200" Content="Acquisisci laser" FontSize="22"/>
</Grid>
</UserControl>
+26 -8
View File
@@ -76,17 +76,35 @@ Public Class SingleCutUC
If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then
Return
End If
' Imposto la lama corrente
' Ricavo dati lama corrente
Dim sSaw As String = String.Empty
GetPrivateProfileString(S_MACH, K_CURRSAW, "", sSaw, m_MainWindow.GetIniFile())
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
' Se punto da laser
If LaserOnChBx.IsChecked Then
' Imposto come testa corrente il laser (senza utensile ovviamente)
If Not EgtSetCalcTool("", "H3", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTip) Then
Return
End If
' Ora imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Altrimenti da lama
Else
' Imposto la lama corrente
If Not EgtSetCalcTool(sSaw, "H1", 1) Then
Return
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTip) Then
Return
End If
End If
' Trasformo in posizione punta utensile in basso
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, dR1, dR2, True, m_ptTip) Then
Return
End If
' Calcolo direzione utensile
' Calcolo direzione asse lama
If Not EgtGetCalcToolDirFromAngles(dR1, dR2, m_vtTool) Then
Return
End If