- Integrazione dei comandi Num di COMMTest
This commit is contained in:
@@ -76,6 +76,7 @@ Public Module ConstGen
|
||||
Public Const MACRO_DFL_DIR As String = "Macro"
|
||||
|
||||
' Variables della macchina corrente
|
||||
Public Const S_MAINVARIABLES As String = "MainVariables"
|
||||
Public Const S_VARIABLES As String = "Variables"
|
||||
|
||||
End Module
|
||||
|
||||
@@ -88,6 +88,7 @@ Public Module ConstIni
|
||||
'Public Const K_MACHINESDIR As String = "MachinesDir"
|
||||
'Public Const K_TOOLMAKERSDIR As String = "ToolMakersDir"
|
||||
'Public Const K_CURRMACH As String = "CurrMach"
|
||||
Public Const K_SUPERVISORMACH As String = "SupervisorMach"
|
||||
Public Const K_PASSWORD As String = "Password"
|
||||
|
||||
'Public Const S_SIMUL As String = "Simul"
|
||||
|
||||
@@ -19,10 +19,13 @@
|
||||
SENDPROG = 10
|
||||
REMOVEPROG = 11
|
||||
REMOVEALLPROG = 12
|
||||
READ = 13
|
||||
READ_TPA = 13
|
||||
WRITE = 14
|
||||
DELETEALARMS = 15
|
||||
SETOP = 16
|
||||
READ_NUMFLEXIUM = 17
|
||||
STOPREAD_NUMFLEXIUM = 18
|
||||
MDI = 19
|
||||
End Enum
|
||||
|
||||
Public Enum LogCommandTypes As Integer
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
Public Const MACH_INI_FILE_NAME As String = "MachData.ini"
|
||||
|
||||
Public Const K_NCTYPE As String = "NCType"
|
||||
|
||||
Public Const K_BEAM As String = "Beam"
|
||||
Public Const K_WALL As String = "Wall"
|
||||
Public Const K_NAME As String = "Name"
|
||||
|
||||
@@ -147,7 +147,7 @@
|
||||
|
||||
Public Shared Function CreateReadLog(CommandExecutedCorrectly As Boolean, VarAddress As String, VarValue As String)
|
||||
Dim NewMachLog As New MachLog
|
||||
NewMachLog.m_CommandType = CommandTypes.READ
|
||||
NewMachLog.m_CommandType = CommandTypes.READ_TPA
|
||||
NewMachLog.m_CommandExecutedCorrectly = CommandExecutedCorrectly
|
||||
NewMachLog.m_VarAddress = VarAddress
|
||||
NewMachLog.m_VarValue = VarValue
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<UserControl x:Class="AxesPanelV"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:EgtCOMMTest"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<ItemsControl ItemsSource="{Binding AxesList}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<UniformGrid Columns="3">
|
||||
<TextBlock Text="{Binding nId}"/>
|
||||
<TextBlock Text="{Binding sName}"/>
|
||||
<TextBlock Text="{Binding dValue}"/>
|
||||
</UniformGrid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,3 @@
|
||||
Public Class AxesPanelV
|
||||
|
||||
End Class
|
||||
@@ -0,0 +1,123 @@
|
||||
Imports System.Collections.ObjectModel
|
||||
Imports EgtWPFLib5
|
||||
Imports EgtUILib
|
||||
|
||||
Public Class AxesPanelVM
|
||||
Inherits VMBase
|
||||
|
||||
Private m_AxesList As New ObservableCollection(Of Axis)
|
||||
Public ReadOnly Property AxesList As ObservableCollection(Of Axis)
|
||||
Get
|
||||
Return m_AxesList
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Sub New()
|
||||
' immposto riferimento in Map
|
||||
Map.SetRefAxesPanelVM(Me)
|
||||
' leggo assi da ini
|
||||
Dim nIndex As Integer = 1
|
||||
Dim Axis As Axis = GetPrivateProfileAxis(S_AXES, nIndex.ToString(), CurrentMachine.sMachIniFile)
|
||||
' leggo assi lineari
|
||||
While Not IsNothing(Axis)
|
||||
AxesList.Add(Axis)
|
||||
nIndex += 1
|
||||
Axis = GetPrivateProfileAxis(S_AXES, nIndex, CurrentMachine.sMachIniFile)
|
||||
End While
|
||||
End Sub
|
||||
|
||||
Private Function GetPrivateProfileAxis(IpAppName As String, IpKeyName As String, IpFileName As String) As Axis
|
||||
Dim sAxis As String = ""
|
||||
EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, "", sAxis, IpFileName)
|
||||
Dim sAxisValues() As String = sAxis.Split(","c)
|
||||
If Not sAxisValues.Count >= 3 Then Return Nothing
|
||||
For Each Value In sAxisValues
|
||||
Value = Value.Trim()
|
||||
Next
|
||||
Dim nId As Integer = 0
|
||||
Dim Type As Axis.AxisTypes = Axis.AxisTypes.NULL
|
||||
Integer.TryParse(sAxisValues(1), nId)
|
||||
Select Case sAxisValues(0).ToLower()
|
||||
Case "l"
|
||||
Type = Axis.AxisTypes.LINEAR
|
||||
Case "r"
|
||||
Type = Axis.AxisTypes.ROTATIONAL
|
||||
Case Else
|
||||
Type = Axis.AxisTypes.NULL
|
||||
End Select
|
||||
Return New Axis(nId, Type, sAxisValues(2))
|
||||
End Function
|
||||
|
||||
Friend Sub AxisCoordinatesCallbackDlg(AxisValue As Double, AxisIndex As Integer)
|
||||
Dim Axis As Axis = m_AxesList.FirstOrDefault(Function(x) x.nId = AxisIndex)
|
||||
If Not IsNothing(Axis) Then
|
||||
Axis.SetValue(AxisValue)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub SetAxisValue(VarName As String, VarValue As String)
|
||||
Dim Axis As Axis = m_AxesList.FirstOrDefault(Function(x) x.sName = VarName)
|
||||
If Not IsNothing(Axis) Then
|
||||
Axis.SetValue(VarValue)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Public Class Axis
|
||||
Inherits VMBase
|
||||
|
||||
Public Enum AxisTypes As Integer
|
||||
NULL = 0
|
||||
LINEAR = 1
|
||||
ROTATIONAL = 2
|
||||
End Enum
|
||||
|
||||
Private m_nId As String
|
||||
Public ReadOnly Property nId As String
|
||||
Get
|
||||
Return m_nId
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_sName As String
|
||||
Public ReadOnly Property sName As String
|
||||
Get
|
||||
Return m_sName
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_Type As AxisTypes
|
||||
Public ReadOnly Property Type As AxisTypes
|
||||
Get
|
||||
Return m_Type
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_dValue As Double
|
||||
Public ReadOnly Property dValue As Double
|
||||
Get
|
||||
Return m_dValue
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Friend Sub SetValue(value As Double)
|
||||
Select Case Type
|
||||
Case AxisTypes.LINEAR
|
||||
m_dValue = value / 1000
|
||||
Case AxisTypes.ROTATIONAL
|
||||
m_dValue = value / 10000
|
||||
Case Else
|
||||
m_dValue = value
|
||||
|
||||
End Select
|
||||
NotifyPropertyChanged(NameOf(dValue))
|
||||
End Sub
|
||||
|
||||
Public Sub New(nId As String, Type As AxisTypes, sName As String)
|
||||
m_nId = nId
|
||||
m_Type = Type
|
||||
m_sName = sName
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
@@ -0,0 +1,834 @@
|
||||
Imports EgtBEAMWALL.Core.ConstMachComm
|
||||
Imports EgtUILib
|
||||
Imports EgtWPFLib5
|
||||
|
||||
Public Class NUMFlexiumComm
|
||||
|
||||
Enum CNMode As Integer
|
||||
AUTO = 0
|
||||
SINGLE_ = 1
|
||||
MDI = 2
|
||||
MANUAL = 7
|
||||
End Enum
|
||||
|
||||
Private m_MachManaging As MachManaging
|
||||
Friend ReadOnly Property MachManaging As MachManaging
|
||||
Get
|
||||
Return m_MachManaging
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private objDRunTimeSystem As FXServer.DRunTimeSystem
|
||||
Private objDGroupManager As FXServer.DGroupManager
|
||||
Private objDGeneralFunction As FXServer.DGeneralFunctions
|
||||
Private objDMainCncData As FXServer.DMainCncData
|
||||
Private objErrorHandler As FXLog.ErrorHandler
|
||||
Private objDPlcVariables As FXServer.DPlcVariables
|
||||
Private objDReadELS As FXServer.DReadELS
|
||||
Private objDFileTransfer As FXServer.DFileTransfer
|
||||
Private objDPosition As FXServer.DPosition
|
||||
Private objDMdiCommand As FXServer.DMdiCommand
|
||||
Private objDVariables As FXServer.DVariables
|
||||
Private objDCncMode As FXServer.DCncMode
|
||||
|
||||
Private m_IsFlexiumPlus As Boolean = False
|
||||
Private m_CNCVersion As String = ""
|
||||
Private _PartProgramNumber As Single
|
||||
Private _CNCAxisChannelArray As String() = New String() {"Channel 1", "Channel 2"}
|
||||
Private m_ChannelList As New List(Of String)
|
||||
' Arraylist for read out the messages
|
||||
Private _ReadFXMessages As New ArrayList
|
||||
' lista variabili in lettura
|
||||
Private Shared m_ReadingVars(19) As CommVar
|
||||
Private m_BytesTransferedCounter As Integer
|
||||
Private m_LinearAxisPrecision As Integer
|
||||
|
||||
Public Sub New(MachManaging As MachManaging)
|
||||
m_MachManaging = MachManaging
|
||||
End Sub
|
||||
|
||||
#Region "METHODS"
|
||||
|
||||
Friend Sub InitFxServer()
|
||||
objDRunTimeSystem = New FXServer.DRunTimeSystem()
|
||||
AddHandler objDRunTimeSystem.ServerInitializationFinished, AddressOf objDRunTimeSystem_ServerInitializationFinished
|
||||
AddHandler objDRunTimeSystem.ServerReinitializationStarted, AddressOf objDRunTimeSystem_ServerReinitializationStarted
|
||||
objDRunTimeSystem.Init()
|
||||
End Sub
|
||||
|
||||
Private Sub InitFxObjects()
|
||||
objDGroupManager = New FXServer.DGroupManager()
|
||||
AddHandler objDGroupManager.ErrorHandler, AddressOf objDGroupManager_ErrorHandler
|
||||
objDGroupManager.CncNumber = 0
|
||||
objDGroupManager.AxisGroup = 0
|
||||
|
||||
objDGeneralFunction = New FXServer.DGeneralFunctions()
|
||||
AddHandler objDGeneralFunction.ProgramActivated, AddressOf objDGeneralFunction_ProgramActivated
|
||||
AddHandler objDGeneralFunction.OnCncStart, AddressOf objDGeneralFunction_OnCncStart
|
||||
AddHandler objDGeneralFunction.OnCncStop, AddressOf objDGeneralFunction_OnCncStop
|
||||
AddHandler objDGeneralFunction.OnCncReset, AddressOf objDGeneralFunction_OnCncReset
|
||||
AddHandler objDGeneralFunction.CncModeWritten, AddressOf objDGeneralFunction_CncModeWritten
|
||||
AddHandler objDGeneralFunction.VariableWritten, AddressOf objDGeneralFunction_VariableWritten
|
||||
objDGeneralFunction.Init(objDGroupManager.Handle)
|
||||
objDMainCncData = New FXServer.DMainCncData()
|
||||
objDMainCncData.Init(objDGroupManager.Handle)
|
||||
m_LinearAxisPrecision = objDMainCncData.GetLinearPrecision()
|
||||
Dim CncFxIdentifier As String = objDMainCncData.GetCncIdentifier()
|
||||
EgtOutLog("CncFxIdentifier: " & CncFxIdentifier)
|
||||
|
||||
m_IsFlexiumPlus = Not (CncFxIdentifier = "Flexium 6" OrElse CncFxIdentifier = "Flexium 8" OrElse CncFxIdentifier = "Flexium 68")
|
||||
|
||||
m_CNCVersion = objDMainCncData.GetCncVersion()
|
||||
|
||||
' Initialize for Channel Change
|
||||
Dim CncGroupNumber As Integer = objDMainCncData.GetCncGroupNumber()
|
||||
Dim PlcGroupNumber As Integer = objDMainCncData.GetPlcGroupNumber()
|
||||
|
||||
Dim sumChannels As Integer = 0
|
||||
sumChannels = PlcGroupNumber + CncGroupNumber
|
||||
For i = 1 To sumChannels
|
||||
m_ChannelList.Add(i)
|
||||
Next
|
||||
|
||||
' Initialize FXLog Objects
|
||||
objErrorHandler = New FXLog.ErrorHandler()
|
||||
AddHandler objErrorHandler.ErrorFromActiveCnc2, AddressOf objErrorHandler_ErrorFromActiveCnc2
|
||||
AddHandler objErrorHandler.ErrorOnCnc, AddressOf objErrorHandler_ErrorOnCnc
|
||||
AddHandler objErrorHandler.ErrorOnOtherChannel, AddressOf objErrorHandler_ErrorOnOtherChannel
|
||||
AddHandler objErrorHandler.Exception, AddressOf objErrorHandler_Exception
|
||||
'Initialisation config for testing
|
||||
'Accepting all messages
|
||||
'Consult the documentation for detailed information
|
||||
|
||||
objErrorHandler.AllError = 1
|
||||
objErrorHandler.ErrorGlobal = 0
|
||||
objErrorHandler.SetChannel(0, 0)
|
||||
objErrorHandler.AcceptBootSysMessage(1)
|
||||
objErrorHandler.AcceptException(0)
|
||||
|
||||
objDPlcVariables = New FXServer.DPlcVariables()
|
||||
'objDPlcVariables.Symbols += New FXServer.IDPlcVariablesEvents_SymbolsEventHandler(AddressOf objDPlcVariables_Symbols)
|
||||
AddHandler objDPlcVariables.ReadVariablesChanged, AddressOf objDPlcVariables_ReadVariablesChanged
|
||||
AddHandler objDPlcVariables.VariablesWritten2, AddressOf objDPlcVariables_VariablesWritten2
|
||||
AddHandler objDPlcVariables.ReadOnceVariablesChanged, AddressOf objDPlcVariables_ReadOnceVariablesChanged
|
||||
objDPlcVariables.Flag = 3
|
||||
objDPlcVariables.Init(objDGroupManager.Handle)
|
||||
|
||||
' Initialize FXServer class DReadELS
|
||||
objDReadELS = New FXServer.DReadELS()
|
||||
AddHandler objDReadELS.ValueChanged, AddressOf objDReadELS_ValueChanged
|
||||
AddHandler objDReadELS.ValueChanged2, AddressOf objDReadELS_ValueChanged2
|
||||
' Only for FX Server >= 3.9.0.0
|
||||
AddHandler objDReadELS.ValueChanged3, AddressOf objDReadELS_ValueChanged3
|
||||
objDReadELS.Init(objDGroupManager.Handle)
|
||||
|
||||
'Initialize FXServer class DFileTransfer
|
||||
objDFileTransfer = New FXServer.DFileTransfer()
|
||||
AddHandler objDFileTransfer.Completed, AddressOf objDFileTransfer_Completed
|
||||
AddHandler objDFileTransfer.TransferStarted, AddressOf objDFileTransfer_TransferStarted
|
||||
AddHandler objDFileTransfer.Failed, AddressOf objDFileTransfer_Failed
|
||||
AddHandler objDFileTransfer.BytesTransfered, AddressOf objDFileTransfer_BytesTransfered
|
||||
|
||||
objDFileTransfer.Init(objDGroupManager.Handle)
|
||||
|
||||
objDPosition = New FXServer.DPosition()
|
||||
'objDPosition.ValidAxisChanged += New FXServer.IDPositionEvents_ValidAxisChangedEventHandler(AddressOf objDPosition_ValidAxisChanged)
|
||||
AddHandler objDPosition.PositionChanged, AddressOf objDPosition_PositionChanged
|
||||
'objDPosition.DeltaChanged += New FXServer.IDPositionEvents_DeltaChangedEventHandler(AddressOf objDPosition_DeltaChanged)
|
||||
'objDPosition.ReadOnceValidAxisChanged += New FXServer.IDPositionEvents_ReadOnceValidAxisChangedEventHandler(AddressOf objDPosition_ReadOnceValidAxisChanged)
|
||||
'objDPosition.ReadOncePositionChanged += New FXServer.IDPositionEvents_ReadOncePositionChangedEventHandler(AddressOf objDPosition_ReadOncePositionChanged)
|
||||
'objDPosition.ReadOnceDeltaChanged += New FXServer.IDPositionEvents_ReadOnceDeltaChangedEventHandler(AddressOf objDPosition_ReadOnceDeltaChanged)
|
||||
'objDPosition.EndposChanged += New FXServer.IDPositionEvents_EndposChangedEventHandler(AddressOf objDPosition_EndposChanged)
|
||||
|
||||
objDPosition.Flag = 0
|
||||
objDPosition.ModeOP = 0
|
||||
objDPosition.FastUpdate = 0 ' Disable FastUpdate=0 To show the refresh time by Flag > 0
|
||||
objDPosition.Init(objDGroupManager.Handle)
|
||||
|
||||
'Initialize FXServer class DMdiCommand
|
||||
objDMdiCommand = New FXServer.DMdiCommand()
|
||||
AddHandler objDMdiCommand.CommandWritten, AddressOf objDMdiCommand_CommandWritten
|
||||
objDMdiCommand.Init(objDGroupManager.Handle)
|
||||
|
||||
'Initialize FXServer class DVariables
|
||||
objDVariables = New FXServer.DVariables()
|
||||
'AddHandler objDVariables.ValueChanged, AddressOf objDVariables_ValueChanged
|
||||
'AddHandler objDVariables.ValueChanged2, AddressOf objDVariables_ValueChanged2
|
||||
AddHandler objDVariables.VariableWritten, AddressOf objDVariables_VariableWritten
|
||||
AddHandler objDVariables.VariableWritten2, AddressOf objDVariables_VariableWritten2
|
||||
' Init & send the list of requested variables
|
||||
Dim rc As Short = objDVariables.Init(objDGroupManager.Handle, "E80000", 1)
|
||||
If (rc <> 0) Then EgtOutLog(" objDVariables.Init() Error : " + rc)
|
||||
|
||||
' Initialize FXServer class DCncMode
|
||||
objDCncMode = New FXServer.DCncMode()
|
||||
AddHandler objDCncMode.ValueChanged, AddressOf objDCncMode_ValueChanged
|
||||
objDCncMode.Init(objDGroupManager.Handle)
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CloseFxObjects()
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDGroupManager)
|
||||
objDGroupManager = Nothing
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDGeneralFunction)
|
||||
objDGeneralFunction = Nothing
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objErrorHandler)
|
||||
objErrorHandler = Nothing
|
||||
objDReadELS.Close()
|
||||
objDPlcVariables.Close()
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDReadELS)
|
||||
objDReadELS = Nothing
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDFileTransfer)
|
||||
objDFileTransfer = Nothing
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDPosition)
|
||||
objDPosition = Nothing
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDMdiCommand)
|
||||
objDMdiCommand = Nothing
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDVariables)
|
||||
objDVariables = Nothing
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub GetGeneralFunctions()
|
||||
Dim _GetConnectState As Int16 = objDGeneralFunction.ConnectionStatus
|
||||
|
||||
Select Case _GetConnectState
|
||||
Case 0
|
||||
' Not connected
|
||||
m_MachManaging.SetConnected(False)
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.NULL, ResultTypes.EXECUTED, "")
|
||||
Case 1
|
||||
' Connection error
|
||||
m_MachManaging.SetConnected(False)
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.ERROR_, ResultTypes.EXECUTED, "")
|
||||
Case 2
|
||||
' Connected
|
||||
m_MachManaging.SetConnected(True)
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.OK, ResultTypes.EXECUTED, "")
|
||||
' avvio lettura variabili
|
||||
'MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.READ_NUMFLEXIUM))
|
||||
StartReadList()
|
||||
StartReadELS()
|
||||
Case Else
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Friend Sub Start()
|
||||
objDGeneralFunction.CncStart()
|
||||
End Sub
|
||||
|
||||
Friend Sub Stop_()
|
||||
objDGeneralFunction.CncStop()
|
||||
End Sub
|
||||
|
||||
Friend Sub Reset()
|
||||
objDGeneralFunction.CncReset()
|
||||
End Sub
|
||||
|
||||
Friend Sub SetMode(value As CNMode)
|
||||
objDGeneralFunction.WriteCncMode(value, 0)
|
||||
End Sub
|
||||
|
||||
'Private Sub WriteVariable(ByVal sender As Object, ByVal e As EventArgs)
|
||||
' Dim _E80011FxStd As Int32 = 88888
|
||||
' Dim _FXReturn As Short = objDGeneralFunction.WriteVariable("E80011", _E80011FxStd)
|
||||
|
||||
' If _FXReturn <> 0 Then
|
||||
' MessageBox.Show("Error from WriteVariable:" & " " & _FXReturn.ToString())
|
||||
' End If
|
||||
'End Sub
|
||||
|
||||
'Private Sub WriteVariable2(ByVal sender As Object, ByVal e As EventArgs)
|
||||
' Dim _E80010FxPlus As Double = 51515.6161
|
||||
' Dim _FXReturn As Short = objDGeneralFunction.WriteVariable2("E80010", _E80010FxPlus)
|
||||
|
||||
' If _FXReturn <> 0 Then
|
||||
' MessageBox.Show("Error from WriteVariable2:" & " " & _FXReturn.ToString())
|
||||
' End If
|
||||
'End Sub
|
||||
|
||||
Private Sub ChangeChannel(Channel As Short)
|
||||
objErrorHandler.SetChannel(0, Channel)
|
||||
End Sub
|
||||
|
||||
Friend Sub StartReadList()
|
||||
Dim AddressList() As String = (From CommVar In m_ReadingVars
|
||||
Where Not IsNothing(CommVar) AndAlso CommVar.nType = CommVar.Types.PLC
|
||||
Select CommVar.sAddress).ToArray()
|
||||
Dim _FXReturn As Short = objDPlcVariables.ReadVariables(AddressList)
|
||||
|
||||
If _FXReturn <> 0 Then
|
||||
EgtOutLog("Error ReadVariables:" & " " & _FXReturn.ToString())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Friend Sub CloseReadList()
|
||||
objDPlcVariables.CloseReadList()
|
||||
End Sub
|
||||
|
||||
Private Sub ReadVariablesOnce(Address As String)
|
||||
'Dim _ReadSymbolicPlcVariableOnetime As String = "Application.IOCONFIG_GLOBALS.Flexium_NCK.RCNC.General.Mode"
|
||||
Dim _FXReturn As Int16 = objDPlcVariables.ReadVariablesOnce(10, Address)
|
||||
|
||||
If _FXReturn <> 0 Then
|
||||
EgtOutLog("Error ReadVariablesOnce:" & " " & _FXReturn.ToString())
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Friend Sub WritePlcVariables(Address As String, value As String)
|
||||
'Dim _WriteSymbolicPlcVariable As String = _txtReadWritePlcVariables0.Text
|
||||
Dim _FXReturn As Int16 = objDPlcVariables.WriteVariables2(11, Address, value)
|
||||
|
||||
If _FXReturn <> 0 Then
|
||||
EgtOutLog("Error WriteVariables2 :" & " " & _FXReturn.ToString())
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Public Shared Function InitVar(Variable As CommVar) As CommVar
|
||||
Dim Index As Integer = Array.IndexOf(m_ReadingVars, Nothing)
|
||||
m_ReadingVars(Index) = Variable
|
||||
Return m_ReadingVars(Index)
|
||||
End Function
|
||||
|
||||
Friend Sub StartReadELS()
|
||||
For Index = 0 To m_ReadingVars.Length - 1
|
||||
If IsNothing(m_ReadingVars(Index)) OrElse m_ReadingVars(Index).nType <> CommVar.Types.CN Then Continue For
|
||||
Dim rc As Short = objDReadELS.AddParameter(m_ReadingVars(Index).sAddress, Index)
|
||||
If rc <> 0 Then EgtOutLog(" Error AddParameter2 : " & rc & " on Variable : " & m_ReadingVars(Index).sAddress)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Friend Sub CloseReadELS()
|
||||
objDPlcVariables.CloseReadList()
|
||||
End Sub
|
||||
|
||||
#Region "File transfer"
|
||||
|
||||
Friend Sub FileDownload(sFileType As String, sFilePath As String)
|
||||
Dim _Return_Download As Short
|
||||
|
||||
_Return_Download = objDFileTransfer.FileDownload2(10, sFileType, sFilePath, "", 1, 0)
|
||||
|
||||
If _Return_Download <> 0 Then
|
||||
EgtOutLog("Error: File not stored to the job list:" & " " & _Return_Download.ToString())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub FileUpload(sFileType As String, sFilePath As String)
|
||||
Dim _Return_Upload As Short
|
||||
_Return_Upload = objDFileTransfer.FileUpload(20, sFileType, sFilePath, "")
|
||||
|
||||
If _Return_Upload <> 0 Then
|
||||
EgtOutLog("Error: File not stored to the job list:" & " " & _Return_Upload.ToString())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Friend Sub FileDelete(sFileType As String, sFilePath As String)
|
||||
Dim _ReturnFileDelete As Short
|
||||
_ReturnFileDelete = objDFileTransfer.FileDelete(20, sFileType, "")
|
||||
|
||||
If _ReturnFileDelete <> 0 Then
|
||||
EgtOutLog("Error: File not deleted:" & " " & _ReturnFileDelete.ToString())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Friend Sub StartTransfer()
|
||||
Dim _Return_StartTransfer As Short
|
||||
_Return_StartTransfer = objDFileTransfer.StartTransfer()
|
||||
|
||||
If _Return_StartTransfer <> 0 Then
|
||||
EgtOutLog("Error: Start transfer not executed:" & " " & _Return_StartTransfer.ToString())
|
||||
Else
|
||||
m_BytesTransferedCounter = 0
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region ' File transfer
|
||||
|
||||
#Region "MDI"
|
||||
|
||||
Friend Sub MDI_Execute(sCommand As String)
|
||||
Dim _FxReturn As Int16 = objDMdiCommand.ExecuteCommand(sCommand)
|
||||
|
||||
If _FxReturn <> 0 Then
|
||||
EgtOutLog("Error ExecuteCommand :" & " " & _FxReturn.ToString())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region ' MDI
|
||||
|
||||
#Region "Variables"
|
||||
|
||||
Friend Sub WriteNCVariables(Address As String, value As String)
|
||||
Try
|
||||
Dim dValue As Double = 0
|
||||
StringToDouble(value, dValue)
|
||||
Dim rc As Short = objDVariables.WriteVariables2(2, objDGroupManager.Handle, Address, dValue)
|
||||
|
||||
If rc <> 0 Then EgtOutLog(" objDVariables.WriteVariables2() Error : " & rc)
|
||||
|
||||
Catch ex As Exception
|
||||
EgtOutLog(" objDVariables.WriteVariables2() Exception : " & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
#End Region ' Variables
|
||||
#End Region ' METHODS
|
||||
|
||||
#Region "EVENTS"
|
||||
|
||||
Private Sub objDRunTimeSystem_ServerInitializationFinished()
|
||||
InitFxObjects()
|
||||
GetGeneralFunctions()
|
||||
End Sub
|
||||
|
||||
Private Sub objDRunTimeSystem_ServerReinitializationStarted()
|
||||
CloseFxObjects()
|
||||
End Sub
|
||||
|
||||
Private Sub objDGeneralFunction_ProgramActivated(ByVal nerrorCode As Short)
|
||||
MessageBox.Show("Part program activated:" & " " & nerrorCode)
|
||||
End Sub
|
||||
|
||||
Private Sub objDGeneralFunction_OnCncStart(ByVal errorCode As Short)
|
||||
Dim bOk As Boolean = (errorCode = 0)
|
||||
m_MachManaging.SetStartPending(bOk)
|
||||
m_ResultCallbackDlg(CommandTypes.START, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, If(bOk, "", "Error CNC Start: " & errorCode.ToString()))
|
||||
End Sub
|
||||
|
||||
Private Sub objDGeneralFunction_OnCncStop(ByVal errorCode As Short)
|
||||
Dim bOk As Boolean = (errorCode = 0)
|
||||
m_ResultCallbackDlg(CommandTypes.START, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, If(bOk, "", "Error Feed Hold: " & errorCode.ToString()))
|
||||
End Sub
|
||||
|
||||
Private Sub objDGeneralFunction_OnCncReset(ByVal errorCode As Short)
|
||||
Dim bOk As Boolean = (errorCode = 0)
|
||||
m_ResultCallbackDlg(CommandTypes.START, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, If(bOk, "", "Error CNC Reset: " & errorCode.ToString()))
|
||||
End Sub
|
||||
|
||||
Private Sub objDGeneralFunction_CncModeWritten(ByVal errorCode As Short)
|
||||
If errorCode <> 0 Then EgtOutLog("Error CNC Mode selection completed:" & " " & errorCode.ToString())
|
||||
End Sub
|
||||
|
||||
'Private Sub _txtPartProgramNumber_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
|
||||
' If e.KeyChar = CChar(Keys.[Return]) Then
|
||||
' e.Handled = True
|
||||
' Dim _CncAxisChannelIndependent As Int16
|
||||
' _PartProgramNumber = Single.Parse(_txtPartProgramNumber.Text)
|
||||
' MessageBox.Show("PartProgNumber:" & " " & _PartProgramNumber.ToString())
|
||||
' Dim _PartProgramNumberActivate As Int32 = Convert.ToInt32(_PartProgramNumber * 10)
|
||||
' MessageBox.Show("PartProgNumberActivate:" & " " & _PartProgramNumberActivate.ToString())
|
||||
|
||||
' If _checkChannelTypeState.Checked = True Then
|
||||
' _CncAxisChannelIndependent = 1
|
||||
' Else
|
||||
' _CncAxisChannelIndependent = 0
|
||||
' End If
|
||||
|
||||
' Dim _FXReturn As Int16 = objDGeneralFunction.ActivateProgram(_PartProgramNumberActivate, _CncAxisChannelIndependent)
|
||||
|
||||
' If _FXReturn <> 0 Then
|
||||
' MessageBox.Show("Error Activate Program:" & " " & _FXReturn.ToString())
|
||||
' End If
|
||||
' End If
|
||||
'End Sub
|
||||
|
||||
Private Sub objDGroupManager_ErrorHandler(ByVal sError As String, ByVal nTextNumber As Short)
|
||||
EgtOutLog("ErrorHandler message:" & " " & sError & " " & "ErrorHandler number:" & " " & nTextNumber.ToString())
|
||||
End Sub
|
||||
|
||||
Private Sub _comboCncAxisChannel_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
|
||||
'Select Case _comboCncAxisChannel.SelectedItem.ToString()
|
||||
' Case "Channel 1"
|
||||
' objDGroupManager.AxisGroup = 0
|
||||
' Case "Channel 2"
|
||||
' objDGroupManager.AxisGroup = 1
|
||||
' Case Else
|
||||
'End Select
|
||||
End Sub
|
||||
|
||||
Private Sub objDGeneralFunction_VariableWritten(ByVal errorCode As Short)
|
||||
If errorCode <> 0 Then
|
||||
MessageBox.Show("Error from VariableWritten:" & " " & errorCode.ToString())
|
||||
Else
|
||||
MessageBox.Show("VariableWritten successfully")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub objErrorHandler_ErrorOnCnc(ByVal cnc As Short, ByVal channel As Short, ByVal [set] As Short)
|
||||
'AplCncNumber.Add(cnc)
|
||||
'AplChannel.Add(channel)
|
||||
'AplSet.Add([set])
|
||||
End Sub
|
||||
|
||||
Private Sub objErrorHandler_ErrorOnOtherChannel(ByVal status As Short)
|
||||
'AplStatus = status
|
||||
End Sub
|
||||
|
||||
Private Sub objErrorHandler_Exception(ByVal status As Short)
|
||||
'ExceptStatus = status
|
||||
End Sub
|
||||
|
||||
Private Sub objErrorHandler_ErrorFromActiveCnc2(ByVal CncNumber As Short, ByVal numberOfError As Short, ByVal ErrorTyp As Object, ByVal ErrorIndex As Object, ByVal ErrorNumber As Object, ByVal ErrorLine As Object, ByVal ErrorMessage As Object, ByVal ErrorAdditional As Object)
|
||||
_ReadFXMessages.Clear()
|
||||
Dim AplCnCNumber As Short = CncNumber
|
||||
Dim AplnumberofError As Short = numberOfError
|
||||
Dim AplErrorType As Object() = CType(ErrorTyp, Object())
|
||||
Dim AplErrorIndex As Object() = CType(ErrorIndex, Object())
|
||||
Dim AplErrorNumber As Object() = CType(ErrorNumber, Object())
|
||||
Dim AplErrorLine As Object() = CType(ErrorLine, Object())
|
||||
Dim AplErrorMessage As Object() = CType(ErrorMessage, Object())
|
||||
Dim AplErrorAdditional As Object() = CType(ErrorAdditional, Object())
|
||||
|
||||
For index As Integer = 0 To numberOfError - 1
|
||||
_ReadFXMessages.Add(New ReadMessages(AplCnCNumber.ToString(), AplnumberofError.ToString(), AplErrorType(index).ToString(), AplErrorIndex(index).ToString(), AplErrorNumber(index).ToString(), AplErrorLine(index).ToString(), AplErrorMessage(index).ToString(), AplErrorAdditional(index).ToString()))
|
||||
Next
|
||||
|
||||
'Timers(TimerStartCounter).Interval = 100
|
||||
'AddHandler Timers(TimerStartCounter).Elapsed, New System.Timers.ElapsedEventHandler(timer1_Elapsed)
|
||||
'Timers(TimerStartCounter).Start()
|
||||
'TimerStartCounter += 1
|
||||
'Debug.WriteLine("Timer Started")
|
||||
'Debug.WriteLine(DateTime.Now)
|
||||
End Sub
|
||||
|
||||
#Region "PLC Variables"
|
||||
|
||||
Private Sub objDPlcVariables_ReadVariablesChanged(ByVal index As Object, ByVal value As Object)
|
||||
Dim _ObjIndex As Object() = CType(index, Object())
|
||||
Dim _ObjValue As Object() = CType(value, Object())
|
||||
Dim index_1 As Integer = 0
|
||||
|
||||
For Each PlcVarIndex As Object In _ObjIndex
|
||||
Dim indexIn As Integer = Integer.Parse(PlcVarIndex.ToString())
|
||||
m_ReadingVars(indexIn).SetValue(_ObjValue(index_1).ToString())
|
||||
index_1 += 1
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub objDPlcVariables_ReadOnceVariablesChanged(ByVal lHandle As Integer, ByVal value As Object)
|
||||
'Dim _ObjValue As Object() = CType(value, Object())
|
||||
|
||||
'If lHandle = 10 Then
|
||||
|
||||
' For i As Integer = 0 To _ObjValue.Length - 1
|
||||
' _ReadPlcVariableOnetime(i).Invoke(CType(Function()
|
||||
' _ReadPlcVariableOnetime(i).Text = _ObjValue(i).ToString()
|
||||
' End Function, MethodInvoker))
|
||||
' Next
|
||||
'End If
|
||||
End Sub
|
||||
|
||||
Private Sub objDPlcVariables_VariablesWritten2(ByVal lHandle As Integer, ByVal errorCode As Integer)
|
||||
Dim bOk As Boolean = (errorCode <> 0)
|
||||
m_ResultCallbackDlg(CommandTypes.WRITE, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.RESULT, If(bOk, "", "Error VariablesWritten2 :" & " " & errorCode.ToString()))
|
||||
End Sub
|
||||
|
||||
#End Region ' PLC Variables
|
||||
|
||||
#Region "ReadELS"
|
||||
|
||||
Private Sub objDReadELS_ValueChanged2(ByVal nHandle As Integer, ByVal dValue As Double, ByVal nerrorCode As Short)
|
||||
If nHandle < 1 OrElse nHandle > m_ReadingVars.Count - 1 Then Return
|
||||
If nerrorCode <> 0 Then EgtOutLog(" Error in Validchanged2 : " & nerrorCode & " Handle : " & nHandle)
|
||||
|
||||
Try
|
||||
m_ReadingVars(nHandle).SetValue(dValue.ToString("F04"))
|
||||
Catch Ex As Exception
|
||||
EgtOutLog(Ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub objDReadELS_ValueChanged3(ByVal nHandle As Integer, ByVal value As Object, ByVal DataType As Short, ByVal Writable As Short, ByVal nerrorCode As Short)
|
||||
If nHandle < 1 OrElse nHandle > m_ReadingVars.Count - 1 Then
|
||||
EgtOutLog(" Invalid handle in Validchanged3 : " & nHandle)
|
||||
Return
|
||||
End If
|
||||
|
||||
If nerrorCode <> 0 Then EgtOutLog(" Error in Validchanged3 : " & nerrorCode & " Handle : " & nHandle)
|
||||
Dim sValue As String
|
||||
|
||||
Try
|
||||
|
||||
Select Case DataType
|
||||
Case 0
|
||||
sValue = (CSByte(value)).ToString()
|
||||
Case 1
|
||||
sValue = (CByte(value)).ToString()
|
||||
Case 2
|
||||
sValue = (CType(value, Int16)).ToString()
|
||||
Case 3
|
||||
sValue = (CType(value, UInt16)).ToString()
|
||||
Case 4
|
||||
sValue = (CType(value, Int32)).ToString()
|
||||
Case 5
|
||||
sValue = (CType(value, UInt32)).ToString()
|
||||
Case 6
|
||||
sValue = (CDbl(value)).ToString()
|
||||
Case 7
|
||||
sValue = (CBool(value)).ToString()
|
||||
Case 8
|
||||
sValue = (CBool(value)).ToString()
|
||||
Case 9
|
||||
sValue = (CBool(value)).ToString()
|
||||
Case 10
|
||||
sValue = (CType(value, Int64)).ToString()
|
||||
Case 11
|
||||
sValue = (CType(value, UInt32)).ToString()
|
||||
Case -1
|
||||
sValue = value.ToString()
|
||||
Case Else
|
||||
sValue = String.Empty
|
||||
EgtOutLog("objDReadELS_ValueChanged3() : Unknown Datatype !")
|
||||
End Select
|
||||
|
||||
m_ReadingVars(nHandle).SetValue(sValue)
|
||||
|
||||
'_ELS(nHandle - 1, 1).Text = sValue
|
||||
'_ELS(nHandle - 1, 2).Text = (CType(DataType, eDatatype)).ToString()
|
||||
'_ELS(nHandle - 1, 3).Text = If(Writable = 0, "No", If(Writable = 1, "Yes", Writable.ToString()))
|
||||
Catch Ex As Exception
|
||||
EgtOutLog("objDReadELS_ValueChanged3 " & Ex.Message & " Handle : " + nHandle)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub objDReadELS_ValueChanged(ByVal nHandle As Short, ByVal dValue As Double, ByVal nerrorCode As Short)
|
||||
'Throw New NotImplementedException()
|
||||
End Sub
|
||||
|
||||
#End Region ' ReadELS
|
||||
|
||||
#Region "File transfer"
|
||||
|
||||
Private Sub objDFileTransfer_Completed(ByVal lHandle As Integer)
|
||||
If lHandle = 10 OrElse lHandle = 20 Then
|
||||
EgtOutLog("Up- or Download successful completed:" & " " & lHandle.ToString())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub objDFileTransfer_TransferStarted(ByVal lHandle As Integer)
|
||||
EgtOutLog("Transfer has been started !")
|
||||
End Sub
|
||||
|
||||
Private Sub objDFileTransfer_Failed(ByVal lHandle As Integer, ByVal nSeq As Short, ByVal nReason As Short)
|
||||
EgtOutLog("Sequence:" & " " & nSeq.ToString() & " " & "Reason:" & " " & nReason.ToString())
|
||||
End Sub
|
||||
|
||||
Private Sub objDFileTransfer_BytesTransfered(ByVal lHandle As Integer, ByVal lBytes As Integer)
|
||||
m_BytesTransferedCounter += lBytes
|
||||
End Sub
|
||||
|
||||
#End Region ' File transfer
|
||||
|
||||
#Region "Position"
|
||||
|
||||
Private Sub objDPosition_PositionChanged(ByVal vtArrayIndex As Object, ByVal vtArrayValues As Object)
|
||||
Dim _indexArray As Object() = CType(vtArrayIndex, Object())
|
||||
Dim _valueArray As Object() = CType(vtArrayValues, Object())
|
||||
|
||||
For _index As Integer = 0 To _indexArray.Length - 1
|
||||
|
||||
If m_IsFlexiumPlus = True Then
|
||||
Dim _index1 As Int16 = CType(_indexArray.GetValue(_index), Int16)
|
||||
Dim _axisPosValue As Double = CType(_valueArray.GetValue(_index), Double)
|
||||
Dim _axisRefPosValue As Double = CType(_axisPosValue, Double) / m_LinearAxisPrecision
|
||||
m_AxisCoordinatesCallbackDlg(_axisPosValue, _index1)
|
||||
Else
|
||||
Dim _index1 As Int16 = CType(_indexArray.GetValue(_index), Int16)
|
||||
Dim _axisPosValue As Int32 = CType(_valueArray.GetValue(_index), Int32)
|
||||
Dim _axisRefPosValue As Single = CSng(_axisPosValue) / m_LinearAxisPrecision
|
||||
m_AxisCoordinatesCallbackDlg(_axisPosValue, _index1)
|
||||
End If
|
||||
|
||||
Next
|
||||
End Sub
|
||||
|
||||
#End Region ' Position
|
||||
|
||||
#Region "MDI"
|
||||
|
||||
Private Sub objDMdiCommand_CommandWritten(ByVal retVal As Short)
|
||||
If retVal <> 0 Then
|
||||
EgtOutLog("Error CommandWritten :" & " " & retVal.ToString())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region ' MDI
|
||||
|
||||
#Region "Variables"
|
||||
|
||||
Private Sub objDVariables_VariableWritten2(ByVal lHandle As Integer, ByVal errorCode As Short)
|
||||
If lHandle <> 2 OrElse errorCode <> 0 Then
|
||||
EgtOutLog(" Error on objDVariables_VariableWritten2 : handle " & lHandle.ToString() & " errorCode : " & errorCode.ToString())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub objDVariables_VariableWritten(ByVal errorCode As Short)
|
||||
If errorCode <> 0 Then
|
||||
EgtOutLog(" Error on objDVariables_VariableWritten errorCode : " & errorCode.ToString())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Private Sub objDVariables_ValueChanged(ByVal vtArrayIndex As Object, ByVal vtArrayValues As Object)
|
||||
' Dim AplArrayIndex As Object() = CType(vtArrayIndex, Object())
|
||||
' Dim AplArrayValue As Object() = CType(vtArrayValues, Object())
|
||||
' Dim Idx As Int16
|
||||
' If IsFlexiumPlus Then Return
|
||||
|
||||
' For index As Integer = 0 To AplArrayIndex.Length - 1
|
||||
|
||||
' Try
|
||||
' Idx = CType(AplArrayIndex.GetValue(index), Int16)
|
||||
' If Idx > 8 Then Exit For
|
||||
' _Variables(Idx, 1).Invoke(CType(Function()
|
||||
' _Variables(Idx, 1).Text = (CDbl(AplArrayValue.GetValue(index))).ToString()
|
||||
' End Function, MethodInvoker))
|
||||
' Catch Ex As Exception
|
||||
' DisplayMessage(Ex.Message)
|
||||
' End Try
|
||||
' Next
|
||||
'End Sub
|
||||
|
||||
'Private Sub objDVariables_ValueChanged2(ByVal vtArrayIndex As Object, ByVal vtArrayValues As Object)
|
||||
' Dim AplArrayIndex As Object() = CType(vtArrayIndex, Object())
|
||||
' Dim AplArrayValue As Object() = CType(vtArrayValues, Object())
|
||||
' Dim index, IdxVar, IdxData, Idx As Int16, Datatype As Int16 = -1
|
||||
' Dim _objValue As Object = Nothing
|
||||
' Dim sValue As String
|
||||
|
||||
' For index = 0 To AplArrayIndex.Length - 1
|
||||
|
||||
' Try
|
||||
' Idx = CType(AplArrayIndex.GetValue(index), Int16)
|
||||
' IdxVar = CShort((Idx / 10))
|
||||
' IdxData = CShort((Idx Mod 10))
|
||||
' If IdxData < 0 OrElse IdxData > 2 OrElse IdxVar > 8 Then Continue For
|
||||
|
||||
' Select Case IdxData
|
||||
' Case 0
|
||||
' _objValue = AplArrayValue.GetValue(index)
|
||||
' Case 1
|
||||
' Me.Invoke(CType(Function()
|
||||
' _Variables(IdxVar, 2).Tag = CShort(AplArrayValue.GetValue(index))
|
||||
' _Variables(IdxVar, 2).Text = (CType(AplArrayValue.GetValue(index), eDatatype)).ToString()
|
||||
' End Function, MethodInvoker))
|
||||
' Case 2
|
||||
' Me.Invoke(CType(Function()
|
||||
' _Variables(IdxVar, 3).Text = If((CShort(AplArrayValue.GetValue(index))) = 0, "No", If((CShort(AplArrayValue.GetValue(index))) = 1, "Yes", (CShort(AplArrayValue.GetValue(index))).ToString()))
|
||||
' End Function, MethodInvoker))
|
||||
' End Select
|
||||
|
||||
' Me.Invoke(CType(Function()
|
||||
' Datatype = If(_Variables(IdxVar, 2).Tag IsNot Nothing, CShort(_Variables(IdxVar, 2).Tag), CShort(-2))
|
||||
' End Function, MethodInvoker))
|
||||
|
||||
' If IdxData = 1 OrElse IdxData = 0 AndAlso Datatype <> -1 Then
|
||||
|
||||
' Select Case Datatype
|
||||
' Case 0
|
||||
' sValue = (CSByte(_objValue)).ToString()
|
||||
' Case 1
|
||||
' sValue = (CByte(_objValue)).ToString()
|
||||
' Case 2
|
||||
' sValue = (CType(_objValue, Int16)).ToString()
|
||||
' Case 3
|
||||
' sValue = (CType(_objValue, UInt16)).ToString()
|
||||
' Case 4
|
||||
' sValue = (CType(_objValue, Int32)).ToString()
|
||||
' Case 5
|
||||
' sValue = (CType(_objValue, UInt32)).ToString()
|
||||
' Case 6
|
||||
' sValue = (CDbl(_objValue)).ToString()
|
||||
' Case 7
|
||||
' sValue = (CBool(_objValue)).ToString()
|
||||
' Case 8
|
||||
' sValue = (CBool(_objValue)).ToString()
|
||||
' Case 9
|
||||
' sValue = (CBool(_objValue)).ToString()
|
||||
' Case 10
|
||||
' sValue = (CType(_objValue, Int64)).ToString()
|
||||
' Case 11
|
||||
' sValue = (CType(_objValue, UInt32)).ToString()
|
||||
' Case -1
|
||||
' sValue = (CType(_objValue, Int32)).ToString()
|
||||
' Case Else
|
||||
' sValue = String.Empty
|
||||
' DisplayMessage("objDVariables_ValueChanged2() : Unknown Datatype !")
|
||||
' End Select
|
||||
|
||||
' Me.Invoke(CType(Function()
|
||||
' _Variables(IdxVar, 1).Text = sValue
|
||||
' End Function, MethodInvoker))
|
||||
' End If
|
||||
|
||||
' Catch Ex As Exception
|
||||
' DisplayMessage("objDVariables_ValueChanged2 " & Ex.Message & " Index : " + index)
|
||||
' End Try
|
||||
' Next
|
||||
'End Sub
|
||||
|
||||
#End Region ' Variables
|
||||
|
||||
#Region "CNCMode"
|
||||
|
||||
Private Sub objDCncMode_ValueChanged(ByVal mode As Short, ByVal preselected As Short)
|
||||
|
||||
m_OpStateCallbackDlg(mode)
|
||||
|
||||
'Select Case mode
|
||||
' Case 0
|
||||
' CncModeSelect = "Auto"
|
||||
' Case 1
|
||||
' CncModeSelect = "Single"
|
||||
' Case 2
|
||||
' CncModeSelect = "MDI"
|
||||
' Case 8
|
||||
' CncModeSelect = "Home"
|
||||
' Case Else
|
||||
'End Select
|
||||
|
||||
'Select Case preselected
|
||||
' Case 0
|
||||
' CncModePreselect = "Auto"
|
||||
' Case 1
|
||||
' CncModePreselect = "Single"
|
||||
' Case 2
|
||||
' CncModePreselect = "MDI"
|
||||
' Case 8
|
||||
' CncModePreselect = "Home"
|
||||
' Case Else
|
||||
'End Select
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region ' CNCMode
|
||||
|
||||
#End Region ' EVENTS
|
||||
|
||||
End Class
|
||||
|
||||
Public Class ReadMessages
|
||||
|
||||
Public CMsgCncNumber As String
|
||||
Public CMsgNumberOfError As String
|
||||
Public CMsgErrorType As String
|
||||
Public CMsgErrorIndex As String
|
||||
Public CMsgErrorNumber As String
|
||||
Public CMsgErrorLine As String
|
||||
Public CMsgErrorMessage As String
|
||||
Public CMsgErrorAdditional As String
|
||||
|
||||
Public Sub New(ByVal MsgCncNumber As String, ByVal MsgNumberofError As String, ByVal MsgErrorType As String, ByVal MsgErrorIndex As String, ByVal MsgErrorNumber As String, ByVal MsgErrorLine As String, ByVal MsgErrorMessage As String, ByVal MsgErrorAdditional As String)
|
||||
CMsgCncNumber = MsgCncNumber
|
||||
CMsgNumberOfError = MsgNumberofError
|
||||
CMsgErrorType = MsgErrorType
|
||||
CMsgErrorIndex = MsgErrorIndex
|
||||
CMsgErrorNumber = MsgErrorNumber
|
||||
CMsgErrorLine = MsgErrorLine
|
||||
CMsgErrorMessage = MsgErrorMessage
|
||||
CMsgErrorAdditional = MsgErrorAdditional
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
@@ -1,333 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Remoting.Channels;
|
||||
using System.Runtime.Remoting.Channels.Ipc;
|
||||
using System.Security.Permissions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
class TPAComm
|
||||
{
|
||||
#region Fields
|
||||
//VM
|
||||
private MainWindowVM _MainWindowVM;
|
||||
//Axes values
|
||||
private double[] _axesVal = new double[24];
|
||||
//Active command
|
||||
private int _cmdActive = 0;
|
||||
//Current machine operative state
|
||||
private ISOCNC.Remoting.MachineOperatingState _opState = ISOCNC.Remoting.MachineOperatingState.Unspecified;
|
||||
#region Remoting - Client
|
||||
// Instance of the remote server object.
|
||||
private ISOCNC.Remoting_Server _remObject;
|
||||
public ISOCNC.Remoting_Server remObject
|
||||
{
|
||||
get => _remObject;
|
||||
}
|
||||
// Server IPC URI address
|
||||
private string serverURI = "ipc://localhost:9090/IRemoteObject.rem";
|
||||
//Remoting events proxy manager object
|
||||
ISOCNC.Remoting.EventProxyManager eventProxy;
|
||||
#endregion Remoting - Client
|
||||
//RPC
|
||||
private int _rpc;
|
||||
//List Info
|
||||
private int _prgCount;
|
||||
private string _prgAtIndex;
|
||||
private string[] _prgList;
|
||||
private bool _prgListUpdated;
|
||||
|
||||
//Alarms
|
||||
private string _errCycle;
|
||||
private string _iso;
|
||||
private string _message;
|
||||
private string _errSystem;
|
||||
#endregion Fields
|
||||
|
||||
#region Constructor
|
||||
[SecurityPermission(SecurityAction.Demand)]
|
||||
public TPAComm(MainWindowVM MainWindowVM)
|
||||
{
|
||||
//imposto VM
|
||||
_MainWindowVM = MainWindowVM;
|
||||
//Set up for remoting events properly
|
||||
System.Collections.Hashtable properties = new System.Collections.Hashtable();
|
||||
properties["name"] = "remotingClient";
|
||||
properties["priority"] = "20";
|
||||
properties["portName"] = "67";
|
||||
BinaryClientFormatterSinkProvider clientProv = new
|
||||
BinaryClientFormatterSinkProvider();
|
||||
BinaryServerFormatterSinkProvider serverProv = new
|
||||
BinaryServerFormatterSinkProvider();
|
||||
serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
|
||||
//// Create the IPC channel.
|
||||
IpcChannel channel = new IpcChannel(properties, clientProv, serverProv);
|
||||
// Register the channel.
|
||||
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);
|
||||
// Register as client for remote object.
|
||||
System.Runtime.Remoting.WellKnownClientTypeEntry remoteType =
|
||||
new System.Runtime.Remoting.WellKnownClientTypeEntry(typeof(ISOCNC.Remoting_Server), serverURI);
|
||||
System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownClientType(remoteType);
|
||||
// Create a message sink.
|
||||
string objectUri;
|
||||
System.Runtime.Remoting.Messaging.IMessageSink messageSink =
|
||||
channel.CreateMessageSink("ipc://localhost:9090/IRemoteObject.rem", null, out objectUri);
|
||||
Console.WriteLine("The URI of the message sink is {0}.", objectUri);
|
||||
if (messageSink != null)
|
||||
{
|
||||
Console.WriteLine("The type of the message sink is {0}.",
|
||||
messageSink.GetType().ToString());
|
||||
}
|
||||
//Event Proxy management
|
||||
eventProxy = new ISOCNC.Remoting.EventProxyManager();
|
||||
eventProxy.CommandExecuted += new
|
||||
ISOCNC.Remoting.CommandExecutedEventHandler(RemoteObject_CommandExecuted);
|
||||
eventProxy.ServerError += new
|
||||
ISOCNC.Remoting.ServerErrorEventHandler(RemoteObject_ServerError);
|
||||
eventProxy.AxisCoordinatesUpdate += new
|
||||
ISOCNC.Remoting.AxesCoordinatesUpdateEventHandler(RemoteObject_AxisCoordinatesUpdate);
|
||||
eventProxy.OpStateUpdate += new
|
||||
ISOCNC.Remoting.OpStateUpdateEventHandler(RemoteObject_OpStateUpdate);
|
||||
eventProxy.AlarmNotification += new
|
||||
ISOCNC.Remoting.AlarmNotificationEventHandler(RemoteObject_AlarmNotification);
|
||||
eventProxy.ListInfoResponse += new
|
||||
ISOCNC.Remoting.ListInfoEventHandler(RemoteObject_ListInfoResponse);
|
||||
eventProxy.RPCUpdate += new
|
||||
ISOCNC.Remoting.RPCUpdateEventHandler(RemoteObject_RPCUpdate);
|
||||
eventProxy.VariableCommandExecuted += new
|
||||
ISOCNC.Remoting.VariableCommandExecutedEventHandler(RemoteObject_VariableCommandExecuted);
|
||||
eventProxy.TickUpdate += new
|
||||
ISOCNC.Remoting.TickUpdateEventHandler(RemoteObject_TickUpdate);
|
||||
//Connection to Remote Server instance
|
||||
_remObject = (ISOCNC.Remoting_Server)Activator.GetObject(typeof(ISOCNC.Remoting_Server), serverURI);
|
||||
try
|
||||
{
|
||||
//Event management
|
||||
_remObject.CommandExecuted += new
|
||||
ISOCNC.Remoting.CommandExecutedEventHandler(eventProxy.LocallyHandleCommandExecuted);
|
||||
_remObject.ServerError += new
|
||||
ISOCNC.Remoting.ServerErrorEventHandler(eventProxy.LocallyHandleServerError);
|
||||
_remObject.AxisCoordinatesUpdate += new
|
||||
ISOCNC.Remoting.AxesCoordinatesUpdateEventHandler(eventProxy.LocallyHandleAxisCoordinatesUpdate);
|
||||
_remObject.OpStateUpdate += new
|
||||
ISOCNC.Remoting.OpStateUpdateEventHandler(eventProxy.LocallyHandleOpStateUpdate);
|
||||
_remObject.AlarmNotification += new
|
||||
ISOCNC.Remoting.AlarmNotificationEventHandler(eventProxy.LocallyHandleAlarmNotification);
|
||||
_remObject.ListInfoResponse += new
|
||||
ISOCNC.Remoting.ListInfoEventHandler(eventProxy.LocallyHandleListInfo);
|
||||
_remObject.RPCUpdate += new
|
||||
ISOCNC.Remoting.RPCUpdateEventHandler(eventProxy.LocallyHandleRPCUpdate);
|
||||
_remObject.VariableCommandExecuted += new
|
||||
ISOCNC.Remoting.VariableCommandExecutedEventHandler(eventProxy.LocallyHandleVariableCommandExecuted);
|
||||
//_remObject.TickUpdate += new
|
||||
//ISOCNC.Remoting.TickUpdateEventHandler(eventProxy.LocallyHandleTickUpdate)
|
||||
}
|
||||
catch (System.Runtime.Remoting.RemotingException ex)
|
||||
{
|
||||
MessageBoxResult dR = MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
#endregion Constructor
|
||||
|
||||
#region Event management
|
||||
#region Remoting obj events
|
||||
/// <summary>
|
||||
/// Notify operative state change
|
||||
/// </summary>
|
||||
/// <param name="newOpState">New operative state</param>
|
||||
void RemoteObject_OpStateUpdate(ISOCNC.Remoting.MachineOperatingState newOpState)
|
||||
{
|
||||
_opState = newOpState;
|
||||
_MainWindowVM.SelOPState = _opState;
|
||||
if (_MainWindowVM.SelOPState == ISOCNC.Remoting.MachineOperatingState.Pending)
|
||||
remObject.RemoveAllProgramsFromList();
|
||||
}
|
||||
/// <summary>
|
||||
/// Notify the execution of a command – server side
|
||||
/// </summary>
|
||||
/// <param name="executedCommand">Command executed index</param>
|
||||
void RemoteObject_CommandExecuted(int executedCommand)
|
||||
{
|
||||
switch (executedCommand)
|
||||
{
|
||||
case (int)ISOCNC.Remoting.Commands.NoCommand:
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.Commands.End:
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.Commands.Error:
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.Commands.MDI_End:
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.Commands.MDI_Start:
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.Commands.MDI_Stop:
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.Commands.SetPoint:
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.Commands.Start:
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.Commands.Step:
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.Commands.Stop:
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.Commands.Start_Program_Soft:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Update internal active executed command field
|
||||
_cmdActive = (int)executedCommand;
|
||||
}
|
||||
/// <summary>
|
||||
/// Notify an error occured during the execution of a command – server side
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="seEA">Error</param>
|
||||
void RemoteObject_ServerError(object sender, ISOCNC.Remoting.ServerErrorEventArgs seEA)
|
||||
{
|
||||
MessageBoxResult dr = MessageBox.Show("Server Error: " + seEA.Error);
|
||||
}
|
||||
/// <summary>
|
||||
/// Notify the update of an axis coordinate
|
||||
/// </summary>
|
||||
/// <param name="axisValue">New axis value</param>
|
||||
/// <param name="axisIndex">Axis index</param>
|
||||
void RemoteObject_AxisCoordinatesUpdate(double axisValue, int axisIndex)
|
||||
{
|
||||
_axesVal[axisIndex] = axisValue;
|
||||
_MainWindowVM.AxisList[axisIndex].Value = axisValue;
|
||||
_MainWindowVM.AxisList[axisIndex].NotifyPropertyChanged("Value");
|
||||
}
|
||||
/// <summary>
|
||||
/// Notify the actual ISO line processed
|
||||
/// </summary>
|
||||
/// <param name="newRPC">Actual ISO Line</param>
|
||||
void RemoteObject_RPCUpdate(uint newRPC)
|
||||
{
|
||||
_rpc = (int)newRPC;
|
||||
}
|
||||
/// <summary>
|
||||
/// Receive program list information
|
||||
/// </summary>
|
||||
/// <param name="prgCount">Program count</param>
|
||||
/// <param name="prgAtIndex">Program at index </param>
|
||||
/// <param name="prgList">Program List</param>
|
||||
void RemoteObject_ListInfoResponse(int prgCount, string prgAtIndex, string[] prgList)
|
||||
{
|
||||
// Program count
|
||||
if (prgCount >= 0)
|
||||
{
|
||||
_prgCount = prgCount;
|
||||
}
|
||||
//Program at index
|
||||
if (prgAtIndex != "")
|
||||
{
|
||||
_prgAtIndex = prgAtIndex;
|
||||
}
|
||||
//Program List
|
||||
if (prgList != null && prgList.Length > 0)
|
||||
{
|
||||
_prgList = prgList;
|
||||
_prgListUpdated = true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Notify the adding or removal of an alarm
|
||||
/// </summary>
|
||||
/// <param name="alarmOperation">Operation: Add-Remove</param>
|
||||
/// <param name="alarmType">Type: Cycle, Message, System, ISO</param>
|
||||
/// <param name="alarmMessage">Alarm</param>
|
||||
/// <param name="alarmCode">Alarm code</param>
|
||||
/// <param name="alarmDateTime">Data</param>
|
||||
void RemoteObject_AlarmNotification(int alarmOperation, int alarmType, string alarmMessage, string alarmCode, string alarmDateTime)
|
||||
{
|
||||
switch (alarmType)
|
||||
{
|
||||
case (int)ISOCNC.Remoting.AlarmType.Cycle:
|
||||
if (alarmOperation == (int)ISOCNC.Remoting.AlarmOperation.Addition)
|
||||
_errCycle = alarmCode + ": " + alarmMessage;
|
||||
else
|
||||
{
|
||||
//Removal
|
||||
if (_errCycle != null && _errCycle != "")
|
||||
{
|
||||
if (_errCycle.Split(':')[0] == alarmCode)
|
||||
_errCycle = "";
|
||||
}
|
||||
}
|
||||
_MainWindowVM.UpdateErrCycle(_errCycle);
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.AlarmType.ISO:
|
||||
if (alarmOperation == (int)ISOCNC.Remoting.AlarmOperation.Addition)
|
||||
_iso = alarmCode + ": " + alarmMessage;
|
||||
else
|
||||
{
|
||||
// Removal
|
||||
if (_iso != null && _iso != "")
|
||||
{
|
||||
if (_iso.Split(':')[0] == alarmCode)
|
||||
_iso = "";
|
||||
}
|
||||
}
|
||||
_MainWindowVM.UpdateIso(_iso);
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.AlarmType.Message:
|
||||
if (alarmOperation == (int)ISOCNC.Remoting.AlarmOperation.Addition)
|
||||
_message = alarmCode + ": " + alarmMessage;
|
||||
else
|
||||
{
|
||||
// Removal
|
||||
if (_message != null && _message != "")
|
||||
{
|
||||
if (_message.Split(':')[0] == alarmCode)
|
||||
_message = "";
|
||||
}
|
||||
}
|
||||
_MainWindowVM.UpdateMessage(_message);
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.AlarmType.None:
|
||||
break;
|
||||
case (int)ISOCNC.Remoting.AlarmType.System:
|
||||
if (alarmOperation == (int)ISOCNC.Remoting.AlarmOperation.Addition)
|
||||
_errSystem = alarmCode + ": " + alarmMessage;
|
||||
else
|
||||
{
|
||||
// Removal
|
||||
if (_errSystem != null && _errSystem != "")
|
||||
{
|
||||
if (_errSystem.Split(':')[0] == alarmCode)
|
||||
_errSystem = "";
|
||||
}
|
||||
}
|
||||
_MainWindowVM.UpdateErrSystem(_errSystem);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Notify info on the executed command
|
||||
/// </summary>
|
||||
/// <param name="executedCommand">Indice di comando eseguito</param>
|
||||
/// <param name="commandExecutedCorrectly">True se il comando è stato eseguito correttamente</param>
|
||||
/// <param name="varName">Nome variabile ovvero percorso in Albatros della variabile</param>
|
||||
/// <param name="varValue">Valore variabile</param>
|
||||
/// <param name="varType">Tipologia variabile</param>
|
||||
void RemoteObject_VariableCommandExecuted(int executedCommand, bool commandExecutedCorrectly, string varName, string varValue, int varType)
|
||||
{
|
||||
_MainWindowVM.SetVarValue(varValue);
|
||||
}
|
||||
/// <summary>
|
||||
/// Notify the server alive
|
||||
/// </summary>
|
||||
/// <param name="newTick">Tick corrente per verifica server alive</param>
|
||||
void RemoteObject_TickUpdate(ulong newTick)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion Event management
|
||||
#endregion Remoting obj events
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
Imports System
|
||||
Imports System.Collections.Generic
|
||||
Imports System.Linq
|
||||
Imports System.Runtime.Remoting.Channels
|
||||
Imports System.Runtime.Remoting.Channels.Ipc
|
||||
Imports System.Security.Permissions
|
||||
Imports System.Text
|
||||
Imports System.Threading.Tasks
|
||||
Imports System.Windows
|
||||
Imports EgtBEAMWALL.Core.ConstMachComm
|
||||
Imports ISOCNC.Remoting
|
||||
|
||||
Class TPAComm
|
||||
|
||||
' creo classe di gestione variabili
|
||||
Private m_RWVariableManager As RWVariableManager
|
||||
Friend ReadOnly Property RWVariableManager As RWVariableManager
|
||||
Get
|
||||
Return m_RWVariableManager
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_MachManaging As MachManaging
|
||||
Friend ReadOnly Property MachManaging As MachManaging
|
||||
Get
|
||||
Return m_MachManaging
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private _axesVal As Double() = New Double(23) {}
|
||||
Private _cmdActive As Integer = 0
|
||||
Private m_opState As ISOCNC.Remoting.MachineOperatingState = ISOCNC.Remoting.MachineOperatingState.Unspecified
|
||||
Public ReadOnly Property opState As ISOCNC.Remoting.MachineOperatingState
|
||||
Get
|
||||
Return m_opState
|
||||
End Get
|
||||
End Property
|
||||
Private _remObject As ISOCNC.Remoting_Server
|
||||
|
||||
Public ReadOnly Property remObject As ISOCNC.Remoting_Server
|
||||
Get
|
||||
Return _remObject
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private serverURI As String = "ipc://localhost:9090/IRemoteObject.rem"
|
||||
Private m_eventProxy As ISOCNC.Remoting.EventProxyManager
|
||||
Friend ReadOnly Property eventProxy As ISOCNC.Remoting.EventProxyManager
|
||||
Get
|
||||
Return m_eventProxy
|
||||
End Get
|
||||
End Property
|
||||
Private _rpc As Integer
|
||||
Private _prgCount As Integer
|
||||
Private _prgAtIndex As String
|
||||
Private _prgList As String()
|
||||
Private _prgListUpdated As Boolean
|
||||
Private _errCycle As String
|
||||
Private _iso As String
|
||||
Private _message As String
|
||||
Private _errSystem As String
|
||||
|
||||
Private m_Proxy_CommandExecutedEventHandler As New CommandExecutedEventHandler(AddressOf RemoteObject_CommandExecuted)
|
||||
Private m_Proxy_ServerErrorEventHandler As New ServerErrorEventHandler(AddressOf RemoteObject_ServerError)
|
||||
Private m_Proxy_AxesCoordinatesUpdateEventHandler As New AxesCoordinatesUpdateEventHandler(AddressOf RemoteObject_AxisCoordinatesUpdate)
|
||||
Private m_Proxy_OpStateUpdateEventHandler As New OpStateUpdateEventHandler(AddressOf RemoteObject_OpStateUpdate)
|
||||
Private m_Proxy_AlarmNotificationEventHandler As New AlarmNotificationEventHandler(AddressOf RemoteObject_AlarmNotification)
|
||||
Private m_Proxy_ListInfoEventHandler As New ListInfoEventHandler(AddressOf RemoteObject_ListInfoResponse)
|
||||
Private m_Proxy_RPCUpdateEventHandler As New RPCUpdateEventHandler(AddressOf RemoteObject_RPCUpdate)
|
||||
Private m_Proxy_VariableCommandExecutedEventHandler As New VariableCommandExecutedEventHandler(AddressOf RemoteObject_VariableCommandExecuted)
|
||||
Private m_Proxy_TickUpdateEventHandler As New TickUpdateEventHandler(AddressOf RemoteObject_TickUpdate)
|
||||
Private m_Rem_CommandExecutedEventHandler As CommandExecutedEventHandler
|
||||
Private m_Rem_ServerErrorEventHandler As ServerErrorEventHandler
|
||||
Private m_Rem_AxesCoordinatesUpdateEventHandler As AxesCoordinatesUpdateEventHandler
|
||||
Private m_Rem_OpStateUpdateEventHandler As OpStateUpdateEventHandler
|
||||
Private m_Rem_AlarmNotificationEventHandler As AlarmNotificationEventHandler
|
||||
Private m_Rem_ListInfoEventHandler As ListInfoEventHandler
|
||||
Private m_Rem_RPCUpdateEventHandler As RPCUpdateEventHandler
|
||||
Private m_Rem_VariableCommandExecutedEventHandler As VariableCommandExecutedEventHandler
|
||||
|
||||
|
||||
<SecurityPermission(SecurityAction.Demand)>
|
||||
Public Sub New(Machmanaging As MachManaging)
|
||||
m_MachManaging = Machmanaging
|
||||
Dim properties As System.Collections.Hashtable = New System.Collections.Hashtable()
|
||||
properties("name") = "remotingClient"
|
||||
properties("priority") = "20"
|
||||
properties("portName") = "67"
|
||||
Dim clientProv As BinaryClientFormatterSinkProvider = New BinaryClientFormatterSinkProvider()
|
||||
Dim serverProv As BinaryServerFormatterSinkProvider = New BinaryServerFormatterSinkProvider()
|
||||
serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
|
||||
Dim channel As IpcChannel = New IpcChannel(properties, clientProv, serverProv)
|
||||
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, False)
|
||||
Dim remoteType As System.Runtime.Remoting.WellKnownClientTypeEntry = New System.Runtime.Remoting.WellKnownClientTypeEntry(GetType(ISOCNC.Remoting_Server), serverURI)
|
||||
System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownClientType(remoteType)
|
||||
Dim objectUri As String
|
||||
Dim messageSink As System.Runtime.Remoting.Messaging.IMessageSink = channel.CreateMessageSink("ipc://localhost:9090/IRemoteObject.rem", Nothing, objectUri)
|
||||
Console.WriteLine("The URI of the message sink is {0}.", objectUri)
|
||||
|
||||
If messageSink IsNot Nothing Then
|
||||
Console.WriteLine("The type of the message sink is {0}.", messageSink.[GetType]().ToString())
|
||||
End If
|
||||
|
||||
m_eventProxy = New ISOCNC.Remoting.EventProxyManager()
|
||||
AddHandler m_eventProxy.CommandExecuted, m_Proxy_CommandExecutedEventHandler
|
||||
AddHandler m_eventProxy.ServerError, m_Proxy_ServerErrorEventHandler
|
||||
AddHandler m_eventProxy.AxisCoordinatesUpdate, m_Proxy_AxesCoordinatesUpdateEventHandler
|
||||
AddHandler m_eventProxy.OpStateUpdate, m_Proxy_OpStateUpdateEventHandler
|
||||
AddHandler m_eventProxy.AlarmNotification, m_Proxy_AlarmNotificationEventHandler
|
||||
AddHandler m_eventProxy.ListInfoResponse, m_Proxy_ListInfoEventHandler
|
||||
AddHandler m_eventProxy.RPCUpdate, m_Proxy_RPCUpdateEventHandler
|
||||
AddHandler m_eventProxy.VariableCommandExecuted, m_Proxy_VariableCommandExecutedEventHandler
|
||||
AddHandler m_eventProxy.TickUpdate, m_Proxy_TickUpdateEventHandler
|
||||
|
||||
_remObject = CType(Activator.GetObject(GetType(ISOCNC.Remoting_Server), serverURI), ISOCNC.Remoting_Server)
|
||||
Try
|
||||
m_Rem_CommandExecutedEventHandler = New CommandExecutedEventHandler(AddressOf m_eventProxy.LocallyHandleCommandExecuted)
|
||||
m_Rem_ServerErrorEventHandler = New ServerErrorEventHandler(AddressOf m_eventProxy.LocallyHandleServerError)
|
||||
m_Rem_AxesCoordinatesUpdateEventHandler = New AxesCoordinatesUpdateEventHandler(AddressOf m_eventProxy.LocallyHandleAxisCoordinatesUpdate)
|
||||
m_Rem_OpStateUpdateEventHandler = New OpStateUpdateEventHandler(AddressOf m_eventProxy.LocallyHandleOpStateUpdate)
|
||||
m_Rem_AlarmNotificationEventHandler = New AlarmNotificationEventHandler(AddressOf m_eventProxy.LocallyHandleAlarmNotification)
|
||||
m_Rem_ListInfoEventHandler = New ListInfoEventHandler(AddressOf m_eventProxy.LocallyHandleListInfo)
|
||||
m_Rem_RPCUpdateEventHandler = New RPCUpdateEventHandler(AddressOf m_eventProxy.LocallyHandleRPCUpdate)
|
||||
m_Rem_VariableCommandExecutedEventHandler = New VariableCommandExecutedEventHandler(AddressOf m_eventProxy.LocallyHandleVariableCommandExecuted)
|
||||
AddHandler _remObject.CommandExecuted, m_Rem_CommandExecutedEventHandler
|
||||
AddHandler _remObject.ServerError, m_Rem_ServerErrorEventHandler
|
||||
AddHandler _remObject.AxisCoordinatesUpdate, m_Rem_AxesCoordinatesUpdateEventHandler
|
||||
AddHandler _remObject.OpStateUpdate, m_Rem_OpStateUpdateEventHandler
|
||||
AddHandler _remObject.AlarmNotification, m_Rem_AlarmNotificationEventHandler
|
||||
AddHandler _remObject.ListInfoResponse, m_Rem_ListInfoEventHandler
|
||||
AddHandler _remObject.RPCUpdate, m_Rem_RPCUpdateEventHandler
|
||||
AddHandler _remObject.VariableCommandExecuted, m_Rem_VariableCommandExecutedEventHandler
|
||||
Catch ex As System.Runtime.Remoting.RemotingException
|
||||
Dim dR As MessageBoxResult = MessageBox.Show(ex.Message)
|
||||
End Try
|
||||
' creo classe che gestisce variabili
|
||||
m_RWVariableManager = RWVariableManager.CreateRWVariableManager(Me)
|
||||
End Sub
|
||||
|
||||
Friend Sub OnDispose()
|
||||
RemoveHandler _remObject.CommandExecuted, m_Rem_CommandExecutedEventHandler
|
||||
RemoveHandler _remObject.ServerError, m_Rem_ServerErrorEventHandler
|
||||
RemoveHandler _remObject.AxisCoordinatesUpdate, m_Rem_AxesCoordinatesUpdateEventHandler
|
||||
RemoveHandler _remObject.OpStateUpdate, m_Rem_OpStateUpdateEventHandler
|
||||
RemoveHandler _remObject.AlarmNotification, m_Rem_AlarmNotificationEventHandler
|
||||
RemoveHandler _remObject.ListInfoResponse, m_Rem_ListInfoEventHandler
|
||||
RemoveHandler _remObject.RPCUpdate, m_Rem_RPCUpdateEventHandler
|
||||
RemoveHandler _remObject.VariableCommandExecuted, m_Rem_VariableCommandExecutedEventHandler
|
||||
RemoveHandler m_eventProxy.CommandExecuted, m_Proxy_CommandExecutedEventHandler
|
||||
RemoveHandler m_eventProxy.ServerError, m_Proxy_ServerErrorEventHandler
|
||||
RemoveHandler m_eventProxy.AxisCoordinatesUpdate, m_Proxy_AxesCoordinatesUpdateEventHandler
|
||||
RemoveHandler m_eventProxy.OpStateUpdate, m_Proxy_OpStateUpdateEventHandler
|
||||
RemoveHandler m_eventProxy.AlarmNotification, m_Proxy_AlarmNotificationEventHandler
|
||||
RemoveHandler m_eventProxy.ListInfoResponse, m_Proxy_ListInfoEventHandler
|
||||
RemoveHandler m_eventProxy.RPCUpdate, m_Proxy_RPCUpdateEventHandler
|
||||
RemoveHandler m_eventProxy.VariableCommandExecuted, m_Proxy_VariableCommandExecutedEventHandler
|
||||
RemoveHandler m_eventProxy.TickUpdate, m_Proxy_TickUpdateEventHandler
|
||||
End Sub
|
||||
|
||||
Private Sub RemoteObject_OpStateUpdate(ByVal newOpState As ISOCNC.Remoting.MachineOperatingState)
|
||||
' resetto stato pending iniziale
|
||||
If Map.refMachManaging.StartPending AndAlso newOpState = MachineOperatingState.Pending Then
|
||||
MachManaging.ResetStartPending()
|
||||
End If
|
||||
m_opState = newOpState
|
||||
m_OpStateCallbackDlg(newOpState)
|
||||
End Sub
|
||||
|
||||
Private Sub RemoteObject_CommandExecuted(ByVal executedCommand As Integer)
|
||||
Select Case executedCommand
|
||||
Case CInt(ISOCNC.Remoting.Commands.NoCommand)
|
||||
Case CInt(ISOCNC.Remoting.Commands.[End])
|
||||
m_ResultCallbackDlg(CommandTypes.RESET, CommandStates.OK, ResultTypes.RESULT, "")
|
||||
Case CInt(ISOCNC.Remoting.Commands.[Error])
|
||||
m_ResultCallbackDlg(CommandTypes.ERROR_, CommandStates.ERROR_, ResultTypes.RESULT, "")
|
||||
Case CInt(ISOCNC.Remoting.Commands.MDI_End)
|
||||
Case CInt(ISOCNC.Remoting.Commands.MDI_Start)
|
||||
Case CInt(ISOCNC.Remoting.Commands.MDI_Stop)
|
||||
Case CInt(ISOCNC.Remoting.Commands.SetPoint)
|
||||
m_ResultCallbackDlg(CommandTypes.SETPOINT, CommandStates.OK, ResultTypes.RESULT, "")
|
||||
Case CInt(ISOCNC.Remoting.Commands.Start)
|
||||
m_ResultCallbackDlg(CommandTypes.START, CommandStates.OK, ResultTypes.RESULT, "")
|
||||
Case CInt(ISOCNC.Remoting.Commands.[Step])
|
||||
m_ResultCallbackDlg(CommandTypes.STEP_, CommandStates.OK, ResultTypes.RESULT, "")
|
||||
Case CInt(ISOCNC.Remoting.Commands.[Stop])
|
||||
m_ResultCallbackDlg(CommandTypes.STOP_, CommandStates.OK, ResultTypes.RESULT, "")
|
||||
Case CInt(ISOCNC.Remoting.Commands.Start_Program_Soft)
|
||||
m_ResultCallbackDlg(CommandTypes.SOFTSTART, CommandStates.OK, ResultTypes.RESULT, "")
|
||||
Case Else
|
||||
End Select
|
||||
_cmdActive = CInt(executedCommand)
|
||||
End Sub
|
||||
|
||||
Private Sub RemoteObject_ServerError(ByVal sender As Object, ByVal seEA As ISOCNC.Remoting.ServerErrorEventArgs)
|
||||
m_ResultCallbackDlg(CommandTypes.ERROR_, CommandStates.ERROR_, ResultTypes.RESULT, "Server Error: " & seEA.[Error])
|
||||
Dim dr As MessageBoxResult = MessageBox.Show("Server Error: " & seEA.[Error])
|
||||
End Sub
|
||||
|
||||
Private Sub RemoteObject_AxisCoordinatesUpdate(ByVal axisValue As Double, ByVal axisIndex As Integer)
|
||||
m_AxisCoordinatesCallbackDlg(axisValue, axisIndex)
|
||||
End Sub
|
||||
|
||||
Private Sub RemoteObject_RPCUpdate(ByVal newRPC As UInteger)
|
||||
_rpc = CInt(newRPC)
|
||||
End Sub
|
||||
|
||||
Private Sub RemoteObject_ListInfoResponse(ByVal prgCount As Integer, ByVal prgAtIndex As String, ByVal prgList As String())
|
||||
If prgCount >= 0 Then
|
||||
_prgCount = prgCount
|
||||
End If
|
||||
|
||||
If prgAtIndex <> "" Then
|
||||
_prgAtIndex = prgAtIndex
|
||||
End If
|
||||
|
||||
If prgList IsNot Nothing AndAlso prgList.Length > 0 Then
|
||||
_prgList = prgList
|
||||
_prgListUpdated = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub RemoteObject_AlarmNotification(ByVal alarmOperation As Integer, ByVal alarmType As Integer, ByVal alarmMessage As String, ByVal alarmCode As String, ByVal alarmDateTime As String)
|
||||
' restituisco errore ad interfaccia
|
||||
m_AlarmCallbackDlg(alarmOperation, alarmType, alarmMessage, alarmCode, alarmDateTime)
|
||||
End Sub
|
||||
|
||||
Private Sub RemoteObject_VariableCommandExecuted(ByVal executedCommand As Integer, ByVal commandExecutedCorrectly As Boolean, ByVal varName As String, ByVal varValue As String, ByVal varType As Integer)
|
||||
' riporto valore variabile su array
|
||||
Select Case executedCommand
|
||||
Case VariableCommands.Error
|
||||
Case VariableCommands.NotExecuted
|
||||
Case VariableCommands.ReadVar
|
||||
m_RWVariableManager.UpdateVar(commandExecutedCorrectly, varName, varValue, varType)
|
||||
Case VariableCommands.WriteVar
|
||||
m_ResultCallbackDlg(CommandTypes.WRITE, If(commandExecutedCorrectly, CommandStates.OK, CommandStates.ERROR_), ResultTypes.RESULT, varName & "=" & varValue)
|
||||
Case VariableCommands.ReadAxis
|
||||
Case VariableCommands.ReadAny
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub RemoteObject_TickUpdate(ByVal newTick As ULong)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
@@ -10,7 +10,7 @@ Imports System.Windows
|
||||
Imports EgtBEAMWALL.Core.ConstMachComm
|
||||
Imports ISOCNC.Remoting
|
||||
|
||||
Class TPAComm
|
||||
Public Class TPAComm
|
||||
|
||||
' creo classe di gestione variabili
|
||||
Private m_RWVariableManager As RWVariableManager
|
||||
@@ -27,8 +27,8 @@ Class TPAComm
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private _axesVal As Double() = New Double(23) {}
|
||||
Private _cmdActive As Integer = 0
|
||||
|
||||
Private m_opState As ISOCNC.Remoting.MachineOperatingState = ISOCNC.Remoting.MachineOperatingState.Unspecified
|
||||
Public ReadOnly Property opState As ISOCNC.Remoting.MachineOperatingState
|
||||
Get
|
||||
@@ -80,8 +80,8 @@ Class TPAComm
|
||||
|
||||
|
||||
<SecurityPermission(SecurityAction.Demand)>
|
||||
Public Sub New(Machmanaging As MachManaging)
|
||||
m_MachManaging = Machmanaging
|
||||
Public Sub New(MachManaging As MachManaging)
|
||||
m_MachManaging = MachManaging
|
||||
Dim properties As System.Collections.Hashtable = New System.Collections.Hashtable()
|
||||
properties("name") = "remotingClient"
|
||||
properties("priority") = "20"
|
||||
|
||||
@@ -77,22 +77,22 @@ Public Class ConfigurationPageVM
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_VariablesList As New ObservableCollection(Of Variable)
|
||||
Public Property VariablesList As ObservableCollection(Of Variable)
|
||||
Private m_VariablesList As New ObservableCollection(Of ConfigVariable)
|
||||
Public Property VariablesList As ObservableCollection(Of ConfigVariable)
|
||||
Get
|
||||
Return m_VariablesList
|
||||
End Get
|
||||
Set(value As ObservableCollection(Of Variable))
|
||||
Set(value As ObservableCollection(Of ConfigVariable))
|
||||
m_VariablesList = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_SelVariable As Variable
|
||||
Public Property SelVariable As Variable
|
||||
Private m_SelVariable As ConfigVariable
|
||||
Public Property SelVariable As ConfigVariable
|
||||
Get
|
||||
Return m_SelVariable
|
||||
End Get
|
||||
Set(value As Variable)
|
||||
Set(value As ConfigVariable)
|
||||
m_SelVariable = value
|
||||
End Set
|
||||
End Property
|
||||
@@ -303,7 +303,7 @@ Public Class ConfigurationPageVM
|
||||
End Property
|
||||
|
||||
Public Sub AddVariable()
|
||||
VariablesList.Add(New Variable("[Name]", "[VariablePath]", "plc"))
|
||||
VariablesList.Add(New ConfigVariable("[Name]", "[VariablePath]", "plc"))
|
||||
End Sub
|
||||
|
||||
#End Region ' AddVariable
|
||||
@@ -382,7 +382,7 @@ Public Class ConfigurationPageVM
|
||||
|
||||
' funzione che legge le variabili della macchina dall'INI
|
||||
Public Sub LoadVariables()
|
||||
VariablesList = New ObservableCollection(Of Variable)
|
||||
VariablesList = New ObservableCollection(Of ConfigVariable)
|
||||
Dim VarIndex As Integer = 1
|
||||
Dim sValue As String = Nothing
|
||||
While EgtUILib.GetPrivateProfileString(S_VARIABLES, VarIndex, String.Empty, sValue, CurrentMachine.sMachIniFile)
|
||||
@@ -397,7 +397,7 @@ Public Class ConfigurationPageVM
|
||||
Dim sName As String = sVariableValues(0)
|
||||
Dim sVarPath As String = sVariableValues(1)
|
||||
Dim sType As String = sVariableValues(3)
|
||||
VariablesList.Add(New Variable(sName, sVarPath, sType))
|
||||
VariablesList.Add(New ConfigVariable(sName, sVarPath, sType))
|
||||
End If
|
||||
VarIndex += 1
|
||||
End While
|
||||
@@ -654,7 +654,7 @@ Public Class IniDataGridColumn
|
||||
|
||||
End Class
|
||||
|
||||
Public Class Variable
|
||||
Public Class ConfigVariable
|
||||
|
||||
Private m_sName As String
|
||||
Public Property sName As String
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
|
||||
Module ConstCommVa
|
||||
|
||||
Public Enum NCTypes As Integer
|
||||
NULL = 0
|
||||
TPA = 1
|
||||
NUM_FLEXIUM = 2
|
||||
End Enum
|
||||
|
||||
' Assi
|
||||
Public Const ASSE_X As String = "AsseX"
|
||||
Public Const ASSE_Y As String = "AsseY"
|
||||
@@ -29,4 +35,21 @@ Module ConstCommVa
|
||||
' variabili V per anticipo carico
|
||||
Public Const VPAR As String = "V"
|
||||
|
||||
Public Enum TPA_OPState
|
||||
Start = 1
|
||||
[Stop] = 2
|
||||
[End] = 3
|
||||
SetPoint = 4
|
||||
Pending = 5
|
||||
Unspecified = 100
|
||||
End Enum
|
||||
|
||||
Public Enum NUM_OPState
|
||||
Auto = 0
|
||||
[Single] = 1
|
||||
Mdi = 2
|
||||
Manual = 7
|
||||
Home = 8
|
||||
End Enum
|
||||
|
||||
End Module
|
||||
|
||||
@@ -123,6 +123,14 @@
|
||||
<Reference Include="FluentFTP, Version=19.2.2.0, Culture=neutral, PublicKeyToken=f4af092b1d8df44f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FluentFTP.19.2.2\lib\net45\FluentFTP.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Interop.FXLog">
|
||||
<HintPath>..\..\..\EgtProg\EgtBEAMWALL\Interop.FXLog.dll</HintPath>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Interop.FXServer">
|
||||
<HintPath>..\..\..\EgtProg\EgtBEAMWALL\Interop.FXServer.dll</HintPath>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="ISOCNC.Remoting">
|
||||
<HintPath>..\..\..\Albatros\Bin\ISOCNC.Remoting.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -216,11 +224,16 @@
|
||||
<Compile Include="AboutBoxWindow\AboutBoxV.xaml.vb">
|
||||
<DependentUpon>AboutBoxV.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="AxesPanel\AxesPanelV.xaml.vb">
|
||||
<DependentUpon>AxesPanelV.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="AxesPanel\AxesPanelVM.vb" />
|
||||
<Compile Include="BTLViewModel\BTLFeatureVM.vb" />
|
||||
<Compile Include="CALCPanel\CalcPanelV.xaml.vb">
|
||||
<DependentUpon>CalcPanelV.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CALCPanel\CALCPanelVM.vb" />
|
||||
<Compile Include="Comms\NUMFlexiumComm.vb" />
|
||||
<Compile Include="Comms\TPAComm.vb" />
|
||||
<Compile Include="ConfigurationPage\ConfigurationPageV.xaml.vb">
|
||||
<DependentUpon>ConfigurationPageV.xaml</DependentUpon>
|
||||
@@ -261,6 +274,7 @@
|
||||
<Compile Include="MachManagingThread\MachCommConst.vb" />
|
||||
<Compile Include="MachManagingThread\MachManaging.vb" />
|
||||
<Compile Include="MachManagingThread\MachManagingThread.vb" />
|
||||
<Compile Include="MachManagingThread\NewValueEventArgs.vb" />
|
||||
<Compile Include="MachManagingThread\RWVariableManager.vb" />
|
||||
<Compile Include="MainMenu\MainMenuV.xaml.vb">
|
||||
<DependentUpon>MainMenuV.xaml</DependentUpon>
|
||||
@@ -295,6 +309,10 @@
|
||||
</Compile>
|
||||
<Compile Include="Utility\LuaExec.vb" />
|
||||
<Compile Include="Utility\Map.vb" />
|
||||
<Compile Include="VariablesList\VariablesListV.xaml.vb">
|
||||
<DependentUpon>VariablesListV.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="VariablesList\VariablesListVM.vb" />
|
||||
<Compile Include="ViewerOptimizerCommThread\ViewerOptimizerComm.vb" />
|
||||
<Compile Include="ViewerOptimizerCommThread\ViewerOptimizerCommThread.vb" />
|
||||
<Compile Include="ViewPanel\ViewPanelV.xaml.vb">
|
||||
@@ -309,6 +327,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="AxesPanel\AxesPanelV.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="CALCPanel\CalcPanelV.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -385,6 +407,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="VariablesList\VariablesListV.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>XamlIntelliSenseFileGenerator</Generator>
|
||||
</Page>
|
||||
<Page Include="ViewPanel\ViewPanelV.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
@@ -13,11 +13,16 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<UniformGrid Columns="2">
|
||||
<GroupBox Header="OPState">
|
||||
<ComboBox ItemsSource="{Binding OPStateList}"
|
||||
SelectedItem="{Binding SelOPState}"
|
||||
DisplayMemberPath="Name"/>
|
||||
</GroupBox>
|
||||
<!--<UniformGrid Columns="2">
|
||||
<TextBlock Text="OPState"/>
|
||||
<TextBlock Text="{Binding sOPState}"/>
|
||||
</UniformGrid>
|
||||
<GroupBox Grid.Row="1"
|
||||
</UniformGrid>-->
|
||||
<!--<GroupBox Grid.Row="1"
|
||||
Header="Axis">
|
||||
<ItemsControl ItemsSource="{Binding AxisList}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
@@ -29,7 +34,12 @@
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</GroupBox>-->
|
||||
<GroupBox Grid.Row="1"
|
||||
Header="Axis">
|
||||
<EgtBEAMWALL:AxesPanelV DataContext="{StaticResource AxesPanelVM}"/>
|
||||
</GroupBox>
|
||||
|
||||
<StackPanel Grid.Row="2"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right">
|
||||
|
||||
@@ -12,17 +12,30 @@ Public Class LeftPanelVM
|
||||
|
||||
Private m_PrintTimer As New DispatcherTimer
|
||||
|
||||
Public ReadOnly Property AxisList As ObservableCollection(Of Axis)
|
||||
Private _OPStateList As List(Of OPState)
|
||||
Public Property OPStateList As List(Of OPState)
|
||||
Get
|
||||
Return Map.refMachCommandMessagePanelVM.AxisList
|
||||
Return _OPStateList
|
||||
End Get
|
||||
Set(ByVal value As List(Of OPState))
|
||||
_OPStateList = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property sOPState As String
|
||||
Private _SelOPState As OPState
|
||||
Public Property SelOPState As OPState
|
||||
Get
|
||||
Return Map.refMachCommandMessagePanelVM.sOPState
|
||||
Return _SelOPState
|
||||
End Get
|
||||
Set(ByVal value As OPState)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.SETOP, value.Id))
|
||||
_SelOPState = value
|
||||
End Set
|
||||
End Property
|
||||
Friend Sub SetOPState(value As OPState)
|
||||
_SelOPState = value
|
||||
NotifyPropertyChanged(NameOf(SelOPState))
|
||||
End Sub
|
||||
|
||||
Private m_bRestart As Boolean = False
|
||||
Public Property bRestart As Boolean
|
||||
@@ -81,8 +94,28 @@ Public Class LeftPanelVM
|
||||
Sub New()
|
||||
' imposto riferimento su mappa
|
||||
Map.SetRefLeftPanelVM(Me)
|
||||
m_PrintTimer.Interval = TimeSpan.FromMilliseconds(5000)
|
||||
m_PrintTimer.Interval = TimeSpan.FromMilliseconds(1000)
|
||||
AddHandler m_PrintTimer.Tick, AddressOf PrintTimer_Tick
|
||||
' carico stati della macchina
|
||||
Select Case NCType
|
||||
Case NCTypes.TPA
|
||||
_OPStateList = New List(Of OPState) From {
|
||||
New OPState("Start", TPA_OPState.Start),
|
||||
New OPState("Stop", TPA_OPState.Stop),
|
||||
New OPState("End", TPA_OPState.End),
|
||||
New OPState("SetPoint", TPA_OPState.SetPoint),
|
||||
New OPState("Pending", TPA_OPState.Pending),
|
||||
New OPState("Unspecified", TPA_OPState.Unspecified)
|
||||
}
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
_OPStateList = New List(Of OPState) From {
|
||||
New OPState("Auto", NUM_OPState.Auto),
|
||||
New OPState("Single", NUM_OPState.Single),
|
||||
New OPState("Mdi", NUM_OPState.Mdi),
|
||||
New OPState("Manual", NUM_OPState.Manual),
|
||||
New OPState("Home", NUM_OPState.Home)
|
||||
}
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
#Region "METHODS"
|
||||
@@ -458,3 +491,25 @@ Public Class LeftPanelVM
|
||||
#End Region ' COMMANDS
|
||||
|
||||
End Class
|
||||
|
||||
Public Class OPState
|
||||
|
||||
Private m_Name As String
|
||||
Public ReadOnly Property Name As String
|
||||
Get
|
||||
Return m_Name
|
||||
End Get
|
||||
End Property
|
||||
Private m_Id As Integer
|
||||
Public ReadOnly Property Id As Integer
|
||||
Get
|
||||
Return m_Id
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Sub New(Name As String, Id As Integer)
|
||||
m_Name = Name
|
||||
m_Id = Id
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
@@ -29,8 +29,8 @@
|
||||
<Button Content="SET POINT"
|
||||
Command="{Binding SetPoint_Command}"
|
||||
Style="{StaticResource ToolBar_TextButton}"/>
|
||||
<Button Content="PRINT LABEL"
|
||||
Command="{Binding PrintLabel_Command}"
|
||||
<Button Content="DELETE ALARMS"
|
||||
Command="{Binding DeleteAlarms_Command}"
|
||||
Style="{StaticResource ToolBar_TextButton}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
@@ -8,19 +8,23 @@ Imports EgtWPFLib5
|
||||
Public Class MachCommandMessagePanelVM
|
||||
Inherits VMBase
|
||||
|
||||
Public Enum MachineOperatingState
|
||||
Start = 1
|
||||
[Stop] = 2
|
||||
[End] = 3
|
||||
SetPoint = 4
|
||||
Pending = 5
|
||||
Unspecified = 100
|
||||
End Enum
|
||||
|
||||
Private m_AlarmTimer As New DispatcherTimer
|
||||
|
||||
Private m_MachManagingThread As Thread
|
||||
|
||||
Public ReadOnly Property MachManagingThread As Thread
|
||||
Get
|
||||
Return m_MachManagingThread
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_MainVariablesList As List(Of Variable)
|
||||
Public ReadOnly Property MainVariablesList As List(Of Variable)
|
||||
Get
|
||||
Return m_MainVariablesList
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_bPrinterLink As Boolean = False
|
||||
Public ReadOnly Property bPrinterLink As Boolean
|
||||
Get
|
||||
@@ -87,40 +91,32 @@ Public Class MachCommandMessagePanelVM
|
||||
NotifyPropertyChanged(NameOf(VarValue))
|
||||
End Sub
|
||||
|
||||
Private m_AxisList As ObservableCollection(Of Axis)
|
||||
'Private m_OPState As MachineOperatingState
|
||||
|
||||
Public ReadOnly Property AxisList As ObservableCollection(Of Axis)
|
||||
Get
|
||||
Return m_AxisList
|
||||
End Get
|
||||
End Property
|
||||
'Public ReadOnly Property OPState As MachineOperatingState
|
||||
' Get
|
||||
' Return m_OPState
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
Private m_OPState As MachineOperatingState
|
||||
|
||||
Public ReadOnly Property OPState As MachineOperatingState
|
||||
Get
|
||||
Return m_OPState
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property sOPState As String
|
||||
Get
|
||||
Select Case m_OPState
|
||||
Case MachineOperatingState.Start
|
||||
Return "START"
|
||||
Case MachineOperatingState.Stop
|
||||
Return "STOP"
|
||||
Case MachineOperatingState.End
|
||||
Return "RESET"
|
||||
Case MachineOperatingState.SetPoint
|
||||
Return "SETPOINT"
|
||||
Case MachineOperatingState.Pending
|
||||
Return "PENDING"
|
||||
Case Else
|
||||
Return "UNSPECIFIED"
|
||||
End Select
|
||||
End Get
|
||||
End Property
|
||||
'Public ReadOnly Property sOPState As String
|
||||
' Get
|
||||
' Select Case m_OPState
|
||||
' Case MachineOperatingState.Start
|
||||
' Return "START"
|
||||
' Case MachineOperatingState.Stop
|
||||
' Return "STOP"
|
||||
' Case MachineOperatingState.End
|
||||
' Return "RESET"
|
||||
' Case MachineOperatingState.SetPoint
|
||||
' Return "SETPOINT"
|
||||
' Case MachineOperatingState.Pending
|
||||
' Return "PENDING"
|
||||
' Case Else
|
||||
' Return "UNSPECIFIED"
|
||||
' End Select
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
Private m_ErrCycle As New List(Of Alarm)
|
||||
Private m_ErrCycleCount As Integer = 0
|
||||
@@ -166,30 +162,14 @@ Public Class MachCommandMessagePanelVM
|
||||
Private m_cmdStop As ICommand
|
||||
Private m_cmdReset As ICommand
|
||||
Private m_cmdStep As ICommand
|
||||
Private m_cmdSearchFilePath As ICommand
|
||||
Private m_cmdAddProgram As ICommand
|
||||
Private m_cmdRemoveProgram As ICommand
|
||||
Private m_cmdReadVar As ICommand
|
||||
Private m_cmdWriteVar As ICommand
|
||||
Private m_cmdDeleteAlarms As ICommand
|
||||
Private m_cmdSetPoint As ICommand
|
||||
Private m_cmdPrintLabel As ICommand
|
||||
|
||||
Public Sub New()
|
||||
Map.SetRefMachCommandMessagePanelVM(Me)
|
||||
' impostazioni timer degli allarmi
|
||||
m_AlarmTimer.Interval = TimeSpan.FromMilliseconds(1500)
|
||||
AddHandler m_AlarmTimer.Tick, AddressOf AlarmTimer_Tick
|
||||
' impostazione assi (leggerli da conf macchina)
|
||||
m_AxisList = New ObservableCollection(Of Axis)({New Axis(ASSE_X),
|
||||
New Axis(ASSE_Y),
|
||||
New Axis(ASSE_Z),
|
||||
New Axis(ASSE_C),
|
||||
New Axis(ASSE_B)})
|
||||
' verifico se stampante collegata
|
||||
m_bPrinterLink = (GetMainPrivateProfileInt(S_PRINTER, K_ENABLE, 0) = 1)
|
||||
' connetto stampante etichette
|
||||
If bPrinterLink Then LabelPrinter.ConnectPrinter()
|
||||
|
||||
NotifyPropertyChanged(NameOf(Connect_Background))
|
||||
End Sub
|
||||
@@ -307,25 +287,41 @@ Public Class MachCommandMessagePanelVM
|
||||
't = Map.refMachManaging.Tpa.remObject.SetVariableCommand(ISOCNC.Remoting.VariableCommands.ReadVar, "0.TESTA.C", "")
|
||||
't = Map.refMachManaging.Tpa.remObject.SetVariableCommand(ISOCNC.Remoting.VariableCommands.ReadVar, "0.TESTA.B", "")
|
||||
|
||||
RWVariableManager.InitVar(ASSE_X, GetVarPathByName(ASSE_X), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(ASSE_Y, GetVarPathByName(ASSE_Y), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(ASSE_Z, GetVarPathByName(ASSE_Z), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(ASSE_B, GetVarPathByName(ASSE_B), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(P_PROD, GetVarPathByName(P_PROD), CommVar.CommVarTypes.CONTINUOUS)
|
||||
RWVariableManager.InitVar(P_MACHGROUP, GetVarPathByName(P_MACHGROUP), CommVar.CommVarTypes.CONTINUOUS)
|
||||
RWVariableManager.InitVar(P_PART, GetVarPathByName(P_PART), CommVar.CommVarTypes.CONTINUOUS)
|
||||
RWVariableManager.InitVar(P_STATE, GetVarPathByName(P_STATE), CommVar.CommVarTypes.CONTINUOUS)
|
||||
RWVariableManager.InitVar(RESET_STATE, GetVarPathByName(RESET_STATE), CommVar.CommVarTypes.CONTINUOUS)
|
||||
RWVariableManager.InitVar(VPAR & "1", GetVarPathByName(VPAR & "1"), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(VPAR & "2", GetVarPathByName(VPAR & "2"), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(VPAR & "3", GetVarPathByName(VPAR & "3"), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(VPAR & "4", GetVarPathByName(VPAR & "4"), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(VPAR & "5", GetVarPathByName(VPAR & "5"), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(VPAR & "6", GetVarPathByName(VPAR & "6"), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(VPAR & "7", GetVarPathByName(VPAR & "7"), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(VPAR & "8", GetVarPathByName(VPAR & "8"), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(VPAR & "9", GetVarPathByName(VPAR & "9"), CommVar.CommVarTypes.ONETIME)
|
||||
RWVariableManager.InitVar(VPAR & "10", GetVarPathByName(VPAR & "10"), CommVar.CommVarTypes.ONETIME)
|
||||
' inizializzo le variabili principali
|
||||
Dim Index As Integer = 1
|
||||
Dim CommVariable As CommVar = MachManaging.InitVar(S_MAINVARIABLES, Index)
|
||||
While Not IsNothing(CommVariable)
|
||||
m_MainVariablesList.Add(New Variable(CommVariable))
|
||||
Index += 1
|
||||
CommVariable = MachManaging.InitVar(S_MAINVARIABLES, Index)
|
||||
End While
|
||||
|
||||
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 1)))
|
||||
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 2)))
|
||||
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 3)))
|
||||
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 4)))
|
||||
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 5)))
|
||||
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 6)))
|
||||
|
||||
'RWVariableManager.InitVar(ASSE_X, GetVarPathByName(ASSE_X), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(ASSE_Y, GetVarPathByName(ASSE_Y), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(ASSE_Z, GetVarPathByName(ASSE_Z), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(ASSE_B, GetVarPathByName(ASSE_B), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(P_PROD, GetVarPathByName(P_PROD), CommVar.CommVarTypes.CONTINUOUS)
|
||||
'RWVariableManager.InitVar(P_MACHGROUP, GetVarPathByName(P_MACHGROUP), CommVar.CommVarTypes.CONTINUOUS)
|
||||
'RWVariableManager.InitVar(P_PART, GetVarPathByName(P_PART), CommVar.CommVarTypes.CONTINUOUS)
|
||||
'RWVariableManager.InitVar(P_STATE, GetVarPathByName(P_STATE), CommVar.CommVarTypes.CONTINUOUS)
|
||||
'RWVariableManager.InitVar(RESET_STATE, GetVarPathByName(RESET_STATE), CommVar.CommVarTypes.CONTINUOUS)
|
||||
'RWVariableManager.InitVar(VPAR & "1", GetVarPathByName(VPAR & "1"), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(VPAR & "2", GetVarPathByName(VPAR & "2"), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(VPAR & "3", GetVarPathByName(VPAR & "3"), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(VPAR & "4", GetVarPathByName(VPAR & "4"), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(VPAR & "5", GetVarPathByName(VPAR & "5"), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(VPAR & "6", GetVarPathByName(VPAR & "6"), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(VPAR & "7", GetVarPathByName(VPAR & "7"), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(VPAR & "8", GetVarPathByName(VPAR & "8"), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(VPAR & "9", GetVarPathByName(VPAR & "9"), CommVar.CommVarTypes.ONETIME)
|
||||
'RWVariableManager.InitVar(VPAR & "10", GetVarPathByName(VPAR & "10"), CommVar.CommVarTypes.ONETIME)
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property Disconnect_Command As ICommand
|
||||
@@ -400,66 +396,6 @@ Public Class MachCommandMessagePanelVM
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.SETPOINT))
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property PrintLabel_Command As ICommand
|
||||
Get
|
||||
If m_cmdPrintLabel Is Nothing Then m_cmdPrintLabel = New Command(AddressOf PrintLabel)
|
||||
Return m_cmdPrintLabel
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub PrintLabel()
|
||||
DbControllers.m_LogMachineController.Create(MachLog.CreateResultLog(LogCommandTypes.ALARM, CommandStates.ERROR_, ResultTypes.EXECUTED, ""))
|
||||
DbControllers.m_LogMachineController.Create(MachLog.CreateAlarmLog(5, 7, "Allaaaaaaaarmeeeeeeeeee!!", 7645, DateTime.Now()))
|
||||
DbControllers.m_LogMachineController.Create(MachLog.CreateOPStateLog(85))
|
||||
DbControllers.m_LogMachineController.Create(MachLog.CreateReadLog(True, "E80048", "46"))
|
||||
|
||||
'LabelPrinter.SetTestPrintVariables(2, 34, 76)
|
||||
'LabelPrinter.Print()
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property AddProgram_Command As ICommand
|
||||
Get
|
||||
If m_cmdAddProgram Is Nothing Then m_cmdAddProgram = New Command(AddressOf AddProgram)
|
||||
Return m_cmdAddProgram
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub AddProgram(ByVal param As Object)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.SENDPROG))
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property RemoveProgram_Command As ICommand
|
||||
Get
|
||||
If m_cmdRemoveProgram Is Nothing Then m_cmdRemoveProgram = New Command(AddressOf RemoveProgram)
|
||||
Return m_cmdRemoveProgram
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub RemoveProgram(ByVal param As Object)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.REMOVEPROG))
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property ReadVar_Command As ICommand
|
||||
Get
|
||||
If m_cmdReadVar Is Nothing Then m_cmdReadVar = New Command(AddressOf ReadVar)
|
||||
Return m_cmdReadVar
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub ReadVar(ByVal param As Object)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.READ))
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property WriteVar_Command As ICommand
|
||||
Get
|
||||
If m_cmdWriteVar Is Nothing Then m_cmdWriteVar = New Command(AddressOf WriteVar)
|
||||
Return m_cmdWriteVar
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub WriteVar(ByVal param As Object)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.WRITE))
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property DeleteAlarms_Command As ICommand
|
||||
Get
|
||||
@@ -579,20 +515,25 @@ Public Class MachCommandMessagePanelVM
|
||||
End Sub
|
||||
|
||||
Friend Sub AxisCoordinatesCallbackDlg(AxisValue As Double, AxisIndex As Integer)
|
||||
m_AxisList(AxisIndex).SetValue(AxisValue)
|
||||
Map.refAxesPanelVM.AxisCoordinatesCallbackDlg(AxisValue, AxisIndex)
|
||||
End Sub
|
||||
|
||||
Friend Sub OpStateCallbackDlg(newOpState As MachineOperatingState)
|
||||
If newOpState <> MachineOperatingState.Unspecified Then
|
||||
Dim bDifferent As Boolean = (m_OPState <> newOpState)
|
||||
m_OPState = newOpState
|
||||
If bDifferent Then
|
||||
For Each MachGroup As MyMachGroupVM In Map.refSupervisorMachGroupPanelVM.MachGroupVMList
|
||||
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Produce_IsEnabled))
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
Map.refLeftPanelVM.NotifyPropertyChanged(NameOf(Map.refLeftPanelVM.sOPState))
|
||||
Friend Sub OpStateCallbackDlg(newOpState As Integer)
|
||||
Dim NewState As OPState = Map.refLeftPanelVM.OPStateList.FirstOrDefault(Function(x) x.Id = newOpState)
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
If newOpState <> TPA_OPState.Unspecified Then
|
||||
Dim bDifferent As Boolean = (Map.refLeftPanelVM.SelOPState.Id <> newOpState)
|
||||
Map.refLeftPanelVM.SetOPState(NewState)
|
||||
If bDifferent Then
|
||||
For Each MachGroup As MyMachGroupVM In Map.refSupervisorMachGroupPanelVM.MachGroupVMList
|
||||
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Produce_IsEnabled))
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Map.refLeftPanelVM.SetOPState(NewState)
|
||||
End Select
|
||||
DbControllers.m_LogMachineController.Create(MachLog.CreateOPStateLog(newOpState))
|
||||
End Sub
|
||||
|
||||
@@ -608,7 +549,7 @@ Public Class MachCommandMessagePanelVM
|
||||
End Sub
|
||||
|
||||
Private Sub SetAxisValue(VarName As String, VarValue As String)
|
||||
Dim Axis As Axis = m_AxisList.FirstOrDefault(Function(x) x.sName = VarName)
|
||||
Dim Axis As Axis = Map.refAxesPanelVM.AxesList.FirstOrDefault(Function(x) x.sName = VarName)
|
||||
If Not IsNothing(Axis) Then
|
||||
Axis.SetValue(VarValue)
|
||||
End If
|
||||
@@ -618,34 +559,6 @@ Public Class MachCommandMessagePanelVM
|
||||
|
||||
End Class
|
||||
|
||||
Public Class Axis
|
||||
Inherits VMBase
|
||||
|
||||
Private m_Name As String
|
||||
Public ReadOnly Property sName As String
|
||||
Get
|
||||
Return m_Name
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_Value As Double
|
||||
Public ReadOnly Property sValue As Double
|
||||
Get
|
||||
Return m_Value
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Friend Sub SetValue(value As Double)
|
||||
m_Value = value
|
||||
NotifyPropertyChanged(NameOf(sValue))
|
||||
End Sub
|
||||
|
||||
Public Sub New(Name As String)
|
||||
m_Name = Name
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Class Alarm
|
||||
|
||||
Private m_sCode As String
|
||||
|
||||
@@ -22,10 +22,13 @@ Public Class MyMachGroupVM
|
||||
ElseIf m_bToBeProduced OrElse m_bSentToMachine Then
|
||||
Return False
|
||||
' se la macchina e' ferma
|
||||
ElseIf Map.refMachCommandMessagePanelVM.OPState = 0 OrElse
|
||||
Map.refMachCommandMessagePanelVM.OPState = MachCommandMessagePanelVM.MachineOperatingState.End OrElse
|
||||
Map.refMachCommandMessagePanelVM.OPState = MachCommandMessagePanelVM.MachineOperatingState.Stop OrElse
|
||||
Map.refMachCommandMessagePanelVM.OPState = MachCommandMessagePanelVM.MachineOperatingState.Unspecified Then
|
||||
ElseIf IsNothing(Map.refLeftPanelVM.SelOPState) OrElse (CurrentMachine.NCType = NCTypes.TPA AndAlso
|
||||
(Map.refLeftPanelVM.SelOPState.Id = 0 OrElse
|
||||
Map.refLeftPanelVM.SelOPState.Id = TPA_OPState.End OrElse
|
||||
Map.refLeftPanelVM.SelOPState.Id = TPA_OPState.Stop OrElse
|
||||
Map.refLeftPanelVM.SelOPState.Id = TPA_OPState.Unspecified)) OrElse
|
||||
(CurrentMachine.NCType = NCTypes.NUM_FLEXIUM AndAlso
|
||||
(Map.refLeftPanelVM.SelOPState.Id = NUM_OPState.Auto)) Then
|
||||
' verifico se c'e' un pezzo non finito
|
||||
Dim ToBeRestartedPart As MyMachGroupVM = Map.refSupervisorMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x As MyMachGroupVM) x.nProduction_State = ItemState.WIP And Not m_bToBeProduced)
|
||||
' se c'e', attivo solo il pezzo non finito
|
||||
@@ -47,10 +50,13 @@ Public Class MyMachGroupVM
|
||||
Case ItemState.WIP
|
||||
If Not m_bToBeProduced AndAlso Not m_bSentToMachine Then
|
||||
Return True
|
||||
ElseIf Map.refMachCommandMessagePanelVM.OPState = 0 OrElse
|
||||
Map.refMachCommandMessagePanelVM.OPState = MachCommandMessagePanelVM.MachineOperatingState.End OrElse
|
||||
Map.refMachCommandMessagePanelVM.OPState = MachCommandMessagePanelVM.MachineOperatingState.Stop OrElse
|
||||
Map.refMachCommandMessagePanelVM.OPState = MachCommandMessagePanelVM.MachineOperatingState.Unspecified Then
|
||||
ElseIf (CurrentMachine.NCType = NCTypes.TPA AndAlso
|
||||
(Map.refLeftPanelVM.SelOPState.Id = 0 OrElse
|
||||
Map.refLeftPanelVM.SelOPState.Id = TPA_OPState.End OrElse
|
||||
Map.refLeftPanelVM.SelOPState.Id = TPA_OPState.Stop OrElse
|
||||
Map.refLeftPanelVM.SelOPState.Id = TPA_OPState.Unspecified)) OrElse
|
||||
(CurrentMachine.NCType = NCTypes.NUM_FLEXIUM AndAlso
|
||||
(Map.refLeftPanelVM.SelOPState.Id = NUM_OPState.Auto)) Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
|
||||
@@ -21,7 +21,7 @@ Module MachCommConst
|
||||
Public Delegate Sub UpdateCallbackDlg(Param As String, Params As String)
|
||||
Public Delegate Sub AlarmCallbackDlg(ByVal AlarmOperation As Integer, ByVal AlarmType As Integer, ByVal AlarmMessage As String, ByVal AlarmCode As String, ByVal AlarmDateTime As String)
|
||||
Public Delegate Sub AxisCoordinatesCallbackDlg(ByVal AxisValue As Double, ByVal AxisIndex As Integer)
|
||||
Public Delegate Sub OpStateCallbackDlg(ByVal newOpState As ISOCNC.Remoting.MachineOperatingState)
|
||||
Public Delegate Sub OpStateCallbackDlg(ByVal newOpState As Integer)
|
||||
Public Delegate Sub ReadVarCallbackDlg(CommandExecutedCorrectly As Boolean, VarAddress As String, VarValue As String, VarType As Integer)
|
||||
|
||||
Friend m_ResultCallbackDlg As ResultCallbackDlg
|
||||
|
||||
@@ -7,7 +7,7 @@ Imports EgtWPFLib5
|
||||
Imports System.IO
|
||||
Imports EgtBEAMWALL.Core
|
||||
|
||||
Class MachManaging
|
||||
Public Class MachManaging
|
||||
|
||||
Private m_bConnected As Boolean = False
|
||||
Public ReadOnly Property bConnected As Boolean
|
||||
@@ -15,11 +15,24 @@ Class MachManaging
|
||||
Return m_bConnected
|
||||
End Get
|
||||
End Property
|
||||
Friend Sub SetConnected(value As Boolean)
|
||||
m_bConnected = value
|
||||
End Sub
|
||||
|
||||
Private m_Tpa As TPAComm = Nothing
|
||||
Private m_CN As Object = Nothing
|
||||
Public ReadOnly Property CN As Object
|
||||
Get
|
||||
Return m_CN
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property Tpa As TPAComm
|
||||
Get
|
||||
Return m_Tpa
|
||||
Return m_CN
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property Num_Flexium As NUMFlexiumComm
|
||||
Get
|
||||
Return m_CN
|
||||
End Get
|
||||
End Property
|
||||
|
||||
@@ -39,6 +52,9 @@ Class MachManaging
|
||||
Friend Sub ResetStartPending()
|
||||
m_bStartPending = False
|
||||
End Sub
|
||||
Friend Sub SetStartPending(value As Boolean)
|
||||
m_bStartPending = value
|
||||
End Sub
|
||||
|
||||
' prossima barra di cui mando i parametri di carico
|
||||
Private m_NextBarId As Integer
|
||||
@@ -56,135 +72,141 @@ Class MachManaging
|
||||
End Sub
|
||||
|
||||
Friend Sub Timer_Tick()
|
||||
'Dim bCancel As Boolean = False
|
||||
'callback(0, "Init", bCancel)
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
'Dim bCancel As Boolean = False
|
||||
'callback(0, "Init", bCancel)
|
||||
|
||||
' leggo tutte le variabili
|
||||
Tpa.RWVariableManager.RefreshAllVars()
|
||||
' leggo tutte le variabili
|
||||
CN.RWVariableManager.RefreshAllVars()
|
||||
|
||||
' eseguo ciclo principale
|
||||
Dim nReset_State As Integer
|
||||
Dim nP_Prod As Integer
|
||||
Dim nP_Machgroup As Integer
|
||||
Dim nP_Part As Integer
|
||||
Dim nP_State As Integer
|
||||
Tpa.RWVariableManager.ReadVar(P_PROD, nP_Prod)
|
||||
Tpa.RWVariableManager.ReadVar(P_MACHGROUP, nP_Machgroup)
|
||||
Tpa.RWVariableManager.ReadVar(P_PART, nP_Part)
|
||||
Tpa.RWVariableManager.ReadVar(P_STATE, nP_State)
|
||||
Tpa.RWVariableManager.ReadVar(RESET_STATE, nReset_State)
|
||||
' se non ancora fatto, preparo variabili barra successiva
|
||||
If CurrentMachine.Flow = FlowTypes.CONTINUOUS AndAlso m_NextBarId = 0 Then
|
||||
SetNextBarVars()
|
||||
End If
|
||||
Dim TestOpState As Integer = Tpa.remObject.MachineOperativeStatus
|
||||
' verifico se scattato stato reset
|
||||
If nReset_State <> 0 Then
|
||||
' resetto tutti i programmi
|
||||
If Not IsNothing(Map.refProjectVM.SupervisorMachGroupPanelVM) Then Map.refProjectVM.SupervisorMachGroupPanelVM.ResetAllMachGroups()
|
||||
' resetto variabili P
|
||||
Tpa.RWVariableManager.WriteVar(P_PROD, 0)
|
||||
Tpa.RWVariableManager.WriteVar(P_MACHGROUP, 0)
|
||||
Tpa.RWVariableManager.WriteVar(P_PART, 0)
|
||||
Tpa.RWVariableManager.WriteVar(P_STATE, 0)
|
||||
' cancello tutti i programmi da memoria CN
|
||||
RemoveAllProgram() ' rimuovo programma default per pending
|
||||
' azzero variabile reset
|
||||
Tpa.remObject.SetVariableCommand(CInt(ISOCNC.Remoting.VariableCommands.WriteVar),
|
||||
RWVariableManager.GetReadVarFromName(RESET_STATE).sAddress, "0")
|
||||
' resetto prossima barra e variabili V
|
||||
If CurrentMachine.Flow = FlowTypes.CONTINUOUS Then
|
||||
m_NextBarId = 0
|
||||
For Index = 1 To 6
|
||||
Tpa.RWVariableManager.WriteVar(VPAR & Index.ToString(), 0)
|
||||
Next
|
||||
End If
|
||||
Return
|
||||
' se macchina pronta e non sta tagliando alcun pezzo
|
||||
ElseIf (nP_Prod = 0 AndAlso
|
||||
nP_Machgroup = 0 AndAlso
|
||||
nP_Part = 0 AndAlso
|
||||
nP_State = PartState.NULL) AndAlso
|
||||
Tpa.opState = MachineOperatingState.Pending AndAlso Tpa.remObject.MachineOperativeStatus = MachineOperatingState.Pending Then
|
||||
' verifico se c'e' un programma da lanciare
|
||||
SendNextProgram()
|
||||
' attesa per essere sicuro che abbia scritto e riletto variabili
|
||||
Threading.Thread.Sleep(300)
|
||||
' verifico stati inizio e fine pezzi
|
||||
ElseIf nP_Prod <> 0 AndAlso
|
||||
nP_Machgroup <> 0 AndAlso
|
||||
nP_Part <> 0 Then
|
||||
If nP_State = PartState.START Then
|
||||
' scrivo data start su Db pezzo
|
||||
Dim dtStart As DateTime = DateTime.Now()
|
||||
DbControllers.m_PartController.UpdateStart(nP_Prod, nP_Machgroup, nP_Part, dtStart)
|
||||
DbControllers.m_PartController.UpdateStatus(nP_Prod, nP_Machgroup, nP_Part, ItemState.WIP)
|
||||
' recupero gruppo di lavorazione del pezzo
|
||||
Dim MachGroup As MyMachGroupVM = Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) x.Id = nP_Machgroup)
|
||||
' recupero pezzo
|
||||
Dim Part As PartVM = MachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nP_Part)
|
||||
' scrivo stato start
|
||||
Part.nProduction_State = ItemState.WIP
|
||||
Part.dtStartTime = dtStart
|
||||
Part.NotifyPropertyChanged(NameOf(Part.nProduction_State))
|
||||
' azzero variabile per far ripartire macchina
|
||||
Tpa.RWVariableManager.WriteVar(P_STATE, 0)
|
||||
' se nessun pezzo della barra diverso da quello corrente e' in start
|
||||
If Not MachGroup.PartVMList.Any(Function(x) x.nPartId <> nP_Part AndAlso x.nProduction_State = 1) Then
|
||||
' scrivo data start su Db barra
|
||||
DbControllers.m_MachGroupController.UpdateStart(nP_Prod, nP_Machgroup, dtStart)
|
||||
DbControllers.m_MachGroupController.UpdateStatus(nP_Prod, nP_Machgroup, ItemState.WIP)
|
||||
' scrivo stato start
|
||||
MachGroup.MyMachGroupM.SetProductionState(ItemState.WIP)
|
||||
MachGroup.dtStartTime = dtStart
|
||||
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.nProduction_State))
|
||||
' eseguo ciclo principale
|
||||
Dim nReset_State As Integer
|
||||
Dim nP_Prod As Integer
|
||||
Dim nP_Machgroup As Integer
|
||||
Dim nP_Part As Integer
|
||||
Dim nP_State As Integer
|
||||
CN.RWVariableManager.ReadVar(P_PROD, nP_Prod)
|
||||
CN.RWVariableManager.ReadVar(P_MACHGROUP, nP_Machgroup)
|
||||
CN.RWVariableManager.ReadVar(P_PART, nP_Part)
|
||||
CN.RWVariableManager.ReadVar(P_STATE, nP_State)
|
||||
CN.RWVariableManager.ReadVar(RESET_STATE, nReset_State)
|
||||
' se non ancora fatto, preparo variabili barra successiva
|
||||
If CurrentMachine.Flow = FlowTypes.CONTINUOUS AndAlso m_NextBarId = 0 Then
|
||||
SetNextBarVars()
|
||||
End If
|
||||
' attesa per essere sicuro che abbia scritto e riletto variabili
|
||||
Threading.Thread.Sleep(300)
|
||||
ElseIf nP_State = PartState.END_ Then
|
||||
' scrivo data end su Db pezzo
|
||||
Dim dtEnd As DateTime = DateTime.Now()
|
||||
DbControllers.m_PartController.UpdateEnd(nP_Prod, nP_Machgroup, nP_Part, dtEnd)
|
||||
DbControllers.m_PartController.UpdateStatus(nP_Prod, nP_Machgroup, nP_Part, ItemState.Produced)
|
||||
' recupero gruppo di lavorazione del pezzo
|
||||
Dim MachGroup As MyMachGroupVM = Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) x.Id = nP_Machgroup)
|
||||
' recupero pezzo
|
||||
Dim Part As PartVM = MachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nP_Part)
|
||||
' scrivo stato end
|
||||
Part.nProduction_State = ItemState.Produced
|
||||
Part.dtEndTime = dtEnd
|
||||
Part.NotifyPropertyChanged(NameOf(Part.nProduction_State))
|
||||
' resetto stato redo
|
||||
Part.bRedo = False
|
||||
' azzero variabile per far ripartire macchina
|
||||
Tpa.RWVariableManager.WriteVar(P_STATE, 0)
|
||||
' se tutti i pezzi della barra sono in end
|
||||
If MachGroup.PartVMList.All(Function(x) x.nProduction_State >= 2) Then
|
||||
' scrivo data end su Db barra
|
||||
DbControllers.m_MachGroupController.UpdateEnd(nP_Prod, nP_Machgroup, dtEnd)
|
||||
DbControllers.m_MachGroupController.UpdateStatus(nP_Prod, nP_Machgroup, ItemState.Produced)
|
||||
' scrivo stato end
|
||||
MachGroup.MyMachGroupM.SetProductionState(ItemState.Produced)
|
||||
MachGroup.dtEndTime = dtEnd
|
||||
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.nProduction_State))
|
||||
' azzero tutte le variabilli per iniziare barra successiva
|
||||
Dim TestOpState As Integer = Tpa.remObject.MachineOperativeStatus
|
||||
' verifico se scattato stato reset
|
||||
If nReset_State <> 0 Then
|
||||
' resetto tutti i programmi
|
||||
If Not IsNothing(Map.refProjectVM.SupervisorMachGroupPanelVM) Then Map.refProjectVM.SupervisorMachGroupPanelVM.ResetAllMachGroups()
|
||||
' resetto variabili P
|
||||
Tpa.RWVariableManager.WriteVar(P_PROD, 0)
|
||||
Tpa.RWVariableManager.WriteVar(P_MACHGROUP, 0)
|
||||
Tpa.RWVariableManager.WriteVar(P_PART, 0)
|
||||
Tpa.RWVariableManager.WriteVar(P_STATE, 0)
|
||||
' resetto stati di produzione
|
||||
MachGroup.ResetProduce()
|
||||
' se partenza pezzi uno a uno
|
||||
If CurrentMachine.Flow = FlowTypes.ONEBYONE Then
|
||||
' riattivo bottone produzione per tutti gli altri
|
||||
MyMachGroupVM.UpdateProduceIsEnabledForAll()
|
||||
' cancello tutti i programmi da memoria CN
|
||||
RemoveAllProgram() ' rimuovo programma default per pending
|
||||
' azzero variabile reset
|
||||
Tpa.remObject.SetVariableCommand(CInt(ISOCNC.Remoting.VariableCommands.WriteVar),
|
||||
RWVariableManager.GetReadVarFromName(RESET_STATE).sAddress, "0")
|
||||
' resetto prossima barra e variabili V
|
||||
If CurrentMachine.Flow = FlowTypes.CONTINUOUS Then
|
||||
m_NextBarId = 0
|
||||
For Index = 1 To 6
|
||||
Tpa.RWVariableManager.WriteVar(VPAR & Index.ToString(), 0)
|
||||
Next
|
||||
End If
|
||||
Return
|
||||
' se macchina pronta e non sta tagliando alcun pezzo
|
||||
ElseIf (nP_Prod = 0 AndAlso
|
||||
nP_Machgroup = 0 AndAlso
|
||||
nP_Part = 0 AndAlso
|
||||
nP_State = PartState.NULL) AndAlso
|
||||
Tpa.opState = MachineOperatingState.Pending AndAlso Tpa.remObject.MachineOperativeStatus = MachineOperatingState.Pending Then
|
||||
' verifico se c'e' un programma da lanciare
|
||||
SendNextProgram()
|
||||
' attesa per essere sicuro che abbia scritto e riletto variabili
|
||||
Threading.Thread.Sleep(300)
|
||||
' verifico stati inizio e fine pezzi
|
||||
ElseIf nP_Prod <> 0 AndAlso
|
||||
nP_Machgroup <> 0 AndAlso
|
||||
nP_Part <> 0 Then
|
||||
If nP_State = PartState.START Then
|
||||
' scrivo data start su Db pezzo
|
||||
Dim dtStart As DateTime = DateTime.Now()
|
||||
DbControllers.m_PartController.UpdateStart(nP_Prod, nP_Machgroup, nP_Part, dtStart)
|
||||
DbControllers.m_PartController.UpdateStatus(nP_Prod, nP_Machgroup, nP_Part, ItemState.WIP)
|
||||
' recupero gruppo di lavorazione del pezzo
|
||||
Dim MachGroup As MyMachGroupVM = Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) x.Id = nP_Machgroup)
|
||||
' recupero pezzo
|
||||
Dim Part As PartVM = MachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nP_Part)
|
||||
' scrivo stato start
|
||||
Part.nProduction_State = ItemState.WIP
|
||||
Part.dtStartTime = dtStart
|
||||
Part.NotifyPropertyChanged(NameOf(Part.nProduction_State))
|
||||
' azzero variabile per far ripartire macchina
|
||||
Tpa.RWVariableManager.WriteVar(P_STATE, 0)
|
||||
' se nessun pezzo della barra diverso da quello corrente e' in start
|
||||
If Not MachGroup.PartVMList.Any(Function(x) x.nPartId <> nP_Part AndAlso x.nProduction_State = 1) Then
|
||||
' scrivo data start su Db barra
|
||||
DbControllers.m_MachGroupController.UpdateStart(nP_Prod, nP_Machgroup, dtStart)
|
||||
DbControllers.m_MachGroupController.UpdateStatus(nP_Prod, nP_Machgroup, ItemState.WIP)
|
||||
' scrivo stato start
|
||||
MachGroup.MyMachGroupM.SetProductionState(ItemState.WIP)
|
||||
MachGroup.dtStartTime = dtStart
|
||||
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.nProduction_State))
|
||||
End If
|
||||
' attesa per essere sicuro che abbia scritto e riletto variabili
|
||||
Threading.Thread.Sleep(300)
|
||||
ElseIf nP_State = PartState.END_ Then
|
||||
' scrivo data end su Db pezzo
|
||||
Dim dtEnd As DateTime = DateTime.Now()
|
||||
DbControllers.m_PartController.UpdateEnd(nP_Prod, nP_Machgroup, nP_Part, dtEnd)
|
||||
DbControllers.m_PartController.UpdateStatus(nP_Prod, nP_Machgroup, nP_Part, ItemState.Produced)
|
||||
' recupero gruppo di lavorazione del pezzo
|
||||
Dim MachGroup As MyMachGroupVM = Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) x.Id = nP_Machgroup)
|
||||
' recupero pezzo
|
||||
Dim Part As PartVM = MachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nP_Part)
|
||||
' scrivo stato end
|
||||
Part.nProduction_State = ItemState.Produced
|
||||
Part.dtEndTime = dtEnd
|
||||
Part.NotifyPropertyChanged(NameOf(Part.nProduction_State))
|
||||
' resetto stato redo
|
||||
Part.bRedo = False
|
||||
' azzero variabile per far ripartire macchina
|
||||
Tpa.RWVariableManager.WriteVar(P_STATE, 0)
|
||||
' se tutti i pezzi della barra sono in end
|
||||
If MachGroup.PartVMList.All(Function(x) x.nProduction_State >= 2) Then
|
||||
' scrivo data end su Db barra
|
||||
DbControllers.m_MachGroupController.UpdateEnd(nP_Prod, nP_Machgroup, dtEnd)
|
||||
DbControllers.m_MachGroupController.UpdateStatus(nP_Prod, nP_Machgroup, ItemState.Produced)
|
||||
' scrivo stato end
|
||||
MachGroup.MyMachGroupM.SetProductionState(ItemState.Produced)
|
||||
MachGroup.dtEndTime = dtEnd
|
||||
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.nProduction_State))
|
||||
' azzero tutte le variabilli per iniziare barra successiva
|
||||
Tpa.RWVariableManager.WriteVar(P_PROD, 0)
|
||||
Tpa.RWVariableManager.WriteVar(P_MACHGROUP, 0)
|
||||
Tpa.RWVariableManager.WriteVar(P_PART, 0)
|
||||
Tpa.RWVariableManager.WriteVar(P_STATE, 0)
|
||||
' resetto stati di produzione
|
||||
MachGroup.ResetProduce()
|
||||
' se partenza pezzi uno a uno
|
||||
If CurrentMachine.Flow = FlowTypes.ONEBYONE Then
|
||||
' riattivo bottone produzione per tutti gli altri
|
||||
MyMachGroupVM.UpdateProduceIsEnabledForAll()
|
||||
End If
|
||||
End If
|
||||
Map.refLeftPanelVM.PrintLabel(MachGroup, Part)
|
||||
' attesa per essere sicuro che abbia scritto e riletto variabili
|
||||
Threading.Thread.Sleep(300)
|
||||
End If
|
||||
End If
|
||||
Map.refLeftPanelVM.PrintLabel(MachGroup, Part)
|
||||
' attesa per essere sicuro che abbia scritto e riletto variabili
|
||||
Threading.Thread.Sleep(300)
|
||||
End If
|
||||
End If
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
|
||||
End Select
|
||||
|
||||
End Sub
|
||||
|
||||
Private m_Lock_SendProgram As New Object
|
||||
@@ -231,7 +253,7 @@ Class MachManaging
|
||||
' verifico se ricalcolo finito
|
||||
If MyMachGroup.bReadyForMachining Then
|
||||
' lo lancio
|
||||
bSent = SendProgram(MyMachGroup.CnFilePath())
|
||||
bSent = SendProgram(MyMachGroup.CnFilePath(), MyMachGroup.Id)
|
||||
EgtOutLog("Mandato " & DateTime.Now() & " " & MyMachGroup.Name & " " & bSent.ToString())
|
||||
MyMachGroup.SetSentToMachine(bSent)
|
||||
m_NextBarId = 0
|
||||
@@ -275,142 +297,268 @@ Class MachManaging
|
||||
Case CommandTypes.SETPOINT
|
||||
SetPoint()
|
||||
Case CommandTypes.SENDPROG
|
||||
SendProgram(Command.sVariable)
|
||||
SendProgram(Command.sVariable, Command.sVariables(1))
|
||||
Case CommandTypes.REMOVEPROG
|
||||
RemoveProgram(Command.nVariable, Command.sVariable)
|
||||
RemoveProgram(Command.nVariable, Command.sVariable, Command.sVariables(1))
|
||||
Case CommandTypes.REMOVEALLPROG
|
||||
RemoveAllProgram()
|
||||
Case CommandTypes.READ
|
||||
Case CommandTypes.READ_TPA
|
||||
Tpa.RWVariableManager.RefreshVar(Command.sVariable)
|
||||
Case CommandTypes.WRITE
|
||||
Tpa.RWVariableManager.WriteVar(Command.sVariable, Command.sVariable(1))
|
||||
WriteVar(Command.sVariable, Command.sVariables(1), Command.nVariable)
|
||||
Case CommandTypes.DELETEALARMS
|
||||
DeleteAlarms()
|
||||
Case CommandTypes.SETOP
|
||||
|
||||
SetOPState(Command.nVariable)
|
||||
Case CommandTypes.READ_NUMFLEXIUM
|
||||
Num_Flexium.StartReadList()
|
||||
Num_Flexium.StartReadELS()
|
||||
Case CommandTypes.STOPREAD_NUMFLEXIUM
|
||||
Num_Flexium.CloseReadList()
|
||||
Num_Flexium.CloseReadELS()
|
||||
Case CommandTypes.MDI
|
||||
Num_Flexium.MDI_Execute(Command.sVariable)
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub Connect()
|
||||
Try
|
||||
m_Tpa = New TPAComm(Me)
|
||||
m_bConnected = Tpa.remObject.OnConnect()
|
||||
' creo classe di gestione variabili
|
||||
Catch ex As Exception
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.ERROR_, ResultTypes.EXECUTED, "Errore: impossibile connettersi!")
|
||||
Return
|
||||
End Try
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.OK, ResultTypes.EXECUTED, "")
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Try
|
||||
m_CN = New TPAComm(Me)
|
||||
m_bConnected = Tpa.remObject.OnConnect()
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.OK, ResultTypes.EXECUTED, "")
|
||||
' creo classe di gestione variabili
|
||||
Catch ex As Exception
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.ERROR_, ResultTypes.EXECUTED, "Errore: impossibile connettersi!")
|
||||
Return
|
||||
End Try
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Try
|
||||
m_CN = New NUMFlexiumComm(Me)
|
||||
Num_Flexium.InitFxServer()
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.OK, ResultTypes.EXECUTED, "")
|
||||
' creo classe di gestione variabili
|
||||
Catch ex As Exception
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.ERROR_, ResultTypes.EXECUTED, "Errore: impossibile connettersi!")
|
||||
Return
|
||||
End Try
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub Disconnect()
|
||||
Dim bOk As Boolean = Tpa.remObject.OnClose()
|
||||
m_bConnected = Not bOk
|
||||
m_ResultCallbackDlg(CommandTypes.DISCONNECT, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
' chiudo classe Tpa
|
||||
Me.OnDispose()
|
||||
m_Tpa.OnDispose()
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Dim bOk As Boolean = Tpa.remObject.OnClose()
|
||||
m_bConnected = Not bOk
|
||||
m_ResultCallbackDlg(CommandTypes.DISCONNECT, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
' chiudo classe Tpa
|
||||
Me.OnDispose()
|
||||
Tpa.OnDispose()
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
m_bConnected = False
|
||||
m_ResultCallbackDlg(CommandTypes.DISCONNECT, CommandStates.OK, ResultTypes.EXECUTED, "")
|
||||
' chiudo classe Num_Flexium
|
||||
Me.OnDispose()
|
||||
'Num_Flexium.OnDispose()
|
||||
End Select
|
||||
' termino thread di comunicazione
|
||||
MachineCommThread.StopThread()
|
||||
End Sub
|
||||
|
||||
Public Sub SetOPState()
|
||||
|
||||
Public Sub SetOPState(CNMode As NUMFlexiumComm.CNMode)
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.SetMode(CNMode)
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub Start()
|
||||
Dim bOk As Boolean
|
||||
' imposto programma default.iso
|
||||
If Tpa.opState = MachineOperatingState.End OrElse Tpa.opState = MachineOperatingState.Unspecified Then
|
||||
Tpa.remObject.RemoveAllProgramsFromList()
|
||||
Dim bFileOk As Boolean = False
|
||||
Dim DefaultIsoFilePath As String = "C:\Albatros\system\DEFAULT.iso"
|
||||
' verifico se esiste path
|
||||
Try
|
||||
If File.Exists(DefaultIsoFilePath) Then bFileOk = True
|
||||
Catch ex As Exception
|
||||
bFileOk = False
|
||||
End Try
|
||||
If Not bFileOk Then
|
||||
Try
|
||||
File.Copy(Map.refMainWindowVM.MainWindowM.sMachineMacroDir & "\" & "DEFAULT.ISO", DefaultIsoFilePath)
|
||||
bFileOk = True
|
||||
Catch ex As Exception
|
||||
m_ResultCallbackDlg(CommandTypes.START, CommandStates.ERROR_, ResultTypes.NULL, "Error in copying DEFAULT.ISO file")
|
||||
MessageBox.Show("Impossibile copiare il file DEFAULT.ISO!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
||||
Return
|
||||
End Try
|
||||
End If
|
||||
'ProgramPath = ProgramPath.Replace("\\", "\")
|
||||
bOk = Tpa.remObject.AddProgramToList(DefaultIsoFilePath)
|
||||
Threading.Thread.Sleep(1000)
|
||||
bOk = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.Start))
|
||||
m_ResultCallbackDlg(CommandTypes.START, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "DEFAULT.ISO send")
|
||||
End If
|
||||
bOk = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.Start))
|
||||
m_bStartPending = bOk
|
||||
m_ResultCallbackDlg(CommandTypes.START, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Dim bOk As Boolean
|
||||
' imposto programma default.iso
|
||||
If Tpa.opState = MachineOperatingState.End OrElse Tpa.opState = MachineOperatingState.Unspecified Then
|
||||
Tpa.remObject.RemoveAllProgramsFromList()
|
||||
Dim bFileOk As Boolean = False
|
||||
Dim DefaultIsoFilePath As String = "C:\Albatros\system\DEFAULT.iso"
|
||||
' verifico se esiste path
|
||||
Try
|
||||
If File.Exists(DefaultIsoFilePath) Then bFileOk = True
|
||||
Catch ex As Exception
|
||||
bFileOk = False
|
||||
End Try
|
||||
If Not bFileOk Then
|
||||
Try
|
||||
File.Copy(Map.refMainWindowVM.MainWindowM.sMachineMacroDir & "\" & "DEFAULT.ISO", DefaultIsoFilePath)
|
||||
bFileOk = True
|
||||
Catch ex As Exception
|
||||
m_ResultCallbackDlg(CommandTypes.START, CommandStates.ERROR_, ResultTypes.NULL, "Error in copying DEFAULT.ISO file")
|
||||
MessageBox.Show("Impossibile copiare il file DEFAULT.ISO!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
|
||||
Return
|
||||
End Try
|
||||
End If
|
||||
'ProgramPath = ProgramPath.Replace("\\", "\")
|
||||
bOk = Tpa.remObject.AddProgramToList(DefaultIsoFilePath)
|
||||
Threading.Thread.Sleep(1000)
|
||||
bOk = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.Start))
|
||||
m_ResultCallbackDlg(CommandTypes.START, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "DEFAULT.ISO send")
|
||||
End If
|
||||
bOk = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.Start))
|
||||
m_bStartPending = bOk
|
||||
m_ResultCallbackDlg(CommandTypes.START, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.Start()
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub [Stop]()
|
||||
Dim bOk As Boolean = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.[Stop]))
|
||||
m_ResultCallbackDlg(CommandTypes.STOP_, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Dim bOk As Boolean = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.[Stop]))
|
||||
m_ResultCallbackDlg(CommandTypes.STOP_, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.Stop_()
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub Reset()
|
||||
Dim bOk As Boolean = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.[End]))
|
||||
m_ResultCallbackDlg(CommandTypes.RESET, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Dim bOk As Boolean = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.[End]))
|
||||
m_ResultCallbackDlg(CommandTypes.RESET, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.Reset()
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub Step_()
|
||||
Dim bOk As Boolean = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.Step))
|
||||
m_ResultCallbackDlg(CommandTypes.STEP_, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Dim bOk As Boolean = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.Step))
|
||||
m_ResultCallbackDlg(CommandTypes.STEP_, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
''
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub SetPoint()
|
||||
Dim bOk As Boolean = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.SetPoint))
|
||||
m_ResultCallbackDlg(CommandTypes.SETPOINT, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Dim bOk As Boolean = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.SetPoint))
|
||||
m_ResultCallbackDlg(CommandTypes.SETPOINT, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
''
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Function SendProgram(ProgramPath As String) As Boolean
|
||||
If Tpa.opState = MachineOperatingState.Pending Then
|
||||
Tpa.remObject.RemoveAllProgramsFromList()
|
||||
Dim bOk As Boolean = False
|
||||
ProgramPath = ProgramPath.Replace("\\", "\")
|
||||
bOk = Tpa.remObject.AddProgramToList(ProgramPath)
|
||||
Threading.Thread.Sleep(1000)
|
||||
bOk = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.Start_Program_Soft))
|
||||
m_ResultCallbackDlg(CommandTypes.SENDPROG, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Return bOk
|
||||
End If
|
||||
Return False
|
||||
Public Function SendProgram(ProgramPath As String, ProgramId As String) As Boolean
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
If Tpa.opState = MachineOperatingState.Pending Then
|
||||
Tpa.remObject.RemoveAllProgramsFromList()
|
||||
Dim bOk As Boolean = False
|
||||
ProgramPath = ProgramPath.Replace("\\", "\")
|
||||
bOk = Tpa.remObject.AddProgramToList(ProgramPath)
|
||||
Threading.Thread.Sleep(1000)
|
||||
bOk = Tpa.remObject.SetCommand(CInt(ISOCNC.Remoting.Commands.Start_Program_Soft))
|
||||
m_ResultCallbackDlg(CommandTypes.SENDPROG, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Return bOk
|
||||
End If
|
||||
Return False
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Dim sFileType As String = "%" & ProgramId.ToString()
|
||||
Num_Flexium.FileDownload(sFileType, ProgramPath)
|
||||
Num_Flexium.StartTransfer()
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Public Sub RemoveProgram(ProgramIndex As Integer, ProgramPath As String)
|
||||
Dim bOk As Boolean
|
||||
Dim sError As String = ""
|
||||
If ProgramIndex > 0 Then
|
||||
bOk = Tpa.remObject.RemoveProgramFromListAtIndex(ProgramIndex)
|
||||
ElseIf Not String.IsNullOrEmpty(ProgramPath) Then
|
||||
bOk = Tpa.remObject.RemoveProgramFromList(ProgramPath)
|
||||
Else
|
||||
bOk = False
|
||||
sError = "Errore: nessun parametro passato"
|
||||
End If
|
||||
m_ResultCallbackDlg(CommandTypes.REMOVEPROG, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, sError)
|
||||
Public Sub RemoveProgram(ProgramIndex As Integer, ProgramPath As String, ProgramType As String)
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Dim bOk As Boolean
|
||||
Dim sError As String = ""
|
||||
If ProgramIndex > 0 Then
|
||||
bOk = CN.remObject.RemoveProgramFromListAtIndex(ProgramIndex)
|
||||
ElseIf Not String.IsNullOrEmpty(ProgramPath) Then
|
||||
bOk = CN.remObject.RemoveProgramFromList(ProgramPath)
|
||||
Else
|
||||
bOk = False
|
||||
sError = "Errore: nessun parametro passato"
|
||||
End If
|
||||
m_ResultCallbackDlg(CommandTypes.REMOVEPROG, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, sError)
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.FileDelete(ProgramType, ProgramPath)
|
||||
Num_Flexium.StartTransfer()
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub RemoveAllProgram()
|
||||
Dim bOk As Boolean = Tpa.remObject.RemoveAllProgramsFromList()
|
||||
Dim bOk As Boolean = CN.remObject.RemoveAllProgramsFromList()
|
||||
m_ResultCallbackDlg(CommandTypes.REMOVEALLPROG, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
End Sub
|
||||
|
||||
Public Sub DeleteAlarms()
|
||||
Dim bOk As Boolean = Tpa.remObject.DeleteAlarms(CInt(AlarmType.ISO))
|
||||
bOk = Tpa.remObject.DeleteAlarms(CInt(AlarmType.Message))
|
||||
bOk = Tpa.remObject.DeleteAlarms(CInt(AlarmType.Cycle))
|
||||
bOk = Tpa.remObject.DeleteAlarms(CInt(AlarmType.System))
|
||||
Dim bOk As Boolean = CN.remObject.DeleteAlarms(CInt(AlarmType.ISO))
|
||||
bOk = CN.remObject.DeleteAlarms(CInt(AlarmType.Message))
|
||||
bOk = CN.remObject.DeleteAlarms(CInt(AlarmType.Cycle))
|
||||
bOk = CN.remObject.DeleteAlarms(CInt(AlarmType.System))
|
||||
m_ResultCallbackDlg(CommandTypes.DELETEALARMS, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
End Sub
|
||||
|
||||
Public Sub WriteVar(Address As String, Value As String, Type As CommVar.Types)
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
CN.RWVariableManager.WriteVar(Address, Value)
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Select Case Type
|
||||
Case CommVar.Types.PLC
|
||||
Num_Flexium.WritePlcVariables(Address, Value)
|
||||
Case CommVar.Types.CN
|
||||
Num_Flexium.WriteNCVariables(Address, Value)
|
||||
End Select
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Shared Function InitVar(Section As String, nIndex As Integer) As CommVar
|
||||
Dim NewVar As CommVar = GetPrivateProfileVariable(Section, nIndex, CurrentMachine.sMachIniFile)
|
||||
If IsNothing(NewVar) Then Return Nothing
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Return RWVariableManager.InitVar(NewVar)
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Return NUMFlexiumComm.InitVar(NewVar)
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Private Shared Function GetPrivateProfileVariable(IpAppName As String, IpKeyName As String, IpFileName As String) As CommVar
|
||||
Dim sVariable As String = ""
|
||||
EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, "", sVariable, IpFileName)
|
||||
If String.IsNullOrWhiteSpace(sVariable) Then Return Nothing
|
||||
Dim sVariableValues() As String = sVariable.Split(","c)
|
||||
If Not sVariableValues.Count >= 4 Then Return Nothing
|
||||
For Index = 0 To sVariableValues.Count - 1
|
||||
sVariableValues(Index) = sVariableValues(Index).Trim()
|
||||
Next
|
||||
Dim ReadType As CommVar.ReadTypes
|
||||
Select Case sVariableValues(2).ToLower()
|
||||
Case "o"
|
||||
ReadType = CommVar.ReadTypes.ONETIME
|
||||
Case "c"
|
||||
ReadType = CommVar.ReadTypes.CONTINUOUS
|
||||
Case Else
|
||||
ReadType = CommVar.ReadTypes.NULL
|
||||
End Select
|
||||
Dim Type As CommVar.Types
|
||||
Select Case sVariableValues(3).ToLower()
|
||||
Case "plc"
|
||||
Type = CommVar.Types.PLC
|
||||
Case "cn"
|
||||
Type = CommVar.Types.CN
|
||||
Case Else
|
||||
Type = CommVar.ReadTypes.NULL
|
||||
End Select
|
||||
Return New CommVar(sVariableValues(0), sVariableValues(1), ReadType, Type)
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
@@ -42,7 +42,7 @@ Class MachineCommThread
|
||||
|
||||
End Class
|
||||
|
||||
Class ThreadCommand
|
||||
Public Class ThreadCommand
|
||||
|
||||
Private m_CommandType As CommandTypes
|
||||
Public ReadOnly Property CommandType As CommandTypes
|
||||
@@ -121,7 +121,7 @@ Class ThreadCommand
|
||||
End Function
|
||||
Public Shared Function CreateReadCommand(sVariable As String) As ThreadCommand
|
||||
Dim NewCommand As ThreadCommand = New ThreadCommand
|
||||
NewCommand.m_CommandType = CommandTypes.READ
|
||||
NewCommand.m_CommandType = CommandTypes.READ_TPA
|
||||
NewCommand.m_sVariables(0) = sVariable
|
||||
Return NewCommand
|
||||
End Function
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
Public Class NewValueEventArgs
|
||||
Inherits EventArgs
|
||||
|
||||
Public m_NewValue As String
|
||||
Public Property NewValue As String
|
||||
Get
|
||||
Return m_NewValue
|
||||
End Get
|
||||
Private Set(value As String)
|
||||
m_NewValue = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Sub New(NewValue As String)
|
||||
m_NewValue = NewValue
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
@@ -49,19 +49,50 @@ Public Class RWVariableManager
|
||||
End Function
|
||||
|
||||
Public Sub RefreshAllVars()
|
||||
EgtOutLog("RefreshAllVars")
|
||||
For Each Var In m_ReadingVars
|
||||
' rileggo solo variabili continue
|
||||
If Not IsNothing(Var) AndAlso Var.sType = CommVar.CommVarTypes.CONTINUOUS Then IntRefreshVar(Var.sAddress)
|
||||
If Not IsNothing(Var) AndAlso Var.nReadType = CommVar.ReadTypes.CONTINUOUS Then IntRefreshVar(Var.sAddress)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Public Shared Function InitVar(Name As String, Address As String, Type As CommVar.CommVarTypes) As Integer
|
||||
Public Shared Function InitVar(Name As String, Address As String, Type As CommVar.ReadTypes) As Integer
|
||||
Dim Index As Integer = Array.IndexOf(m_ReadingVars, Nothing)
|
||||
m_ReadingVars(Index) = New CommVar(Name, Address, Type)
|
||||
m_ReadingVars(Index) = New CommVar(Name, Address, Type, CommVar.Types.NULL)
|
||||
Return Index
|
||||
End Function
|
||||
|
||||
'Public Shared Function InitVar(nIndex As Integer) As CommVar
|
||||
' Dim Index As Integer = Array.IndexOf(m_ReadingVars, Nothing)
|
||||
' m_ReadingVars(Index) = GetPrivateProfileVariable(S_VARIABLES, nIndex, CurrentMachine.sMachIniFile)
|
||||
' Return m_ReadingVars(Index)
|
||||
'End Function
|
||||
|
||||
Public Shared Function InitVar(Variable As CommVar) As CommVar
|
||||
Dim Index As Integer = Array.IndexOf(m_ReadingVars, Nothing)
|
||||
m_ReadingVars(Index) = Variable
|
||||
Return m_ReadingVars(Index)
|
||||
End Function
|
||||
|
||||
Private Shared Function GetPrivateProfileVariable(IpAppName As String, IpKeyName As String, IpFileName As String) As CommVar
|
||||
Dim sVariable As String = ""
|
||||
EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, "", sVariable, IpFileName)
|
||||
Dim sVariableValues() As String = sVariable.Split(","c)
|
||||
If Not sVariableValues.Count >= 3 Then Return Nothing
|
||||
For Index = 0 To sVariableValues.Count - 1
|
||||
sVariableValues(Index) = sVariableValues(Index).Trim()
|
||||
Next
|
||||
Dim Type As CommVar.ReadTypes
|
||||
Select Case sVariableValues(2).ToLower()
|
||||
Case "o"
|
||||
Type = CommVar.ReadTypes.ONETIME
|
||||
Case "c"
|
||||
Type = CommVar.ReadTypes.CONTINUOUS
|
||||
Case Else
|
||||
Type = CommVar.ReadTypes.NULL
|
||||
End Select
|
||||
Return New CommVar(sVariableValues(0), sVariableValues(1), Type, CommVar.Types.NULL)
|
||||
End Function
|
||||
|
||||
Public Sub RefreshVar(Name As String)
|
||||
Dim Var As CommVar = GetReadVarFromName(Name)
|
||||
If Not IsNothing(Var) Then
|
||||
@@ -124,7 +155,7 @@ Public Class RWVariableManager
|
||||
Friend Shared Function GetReadVarFromAddress(Address As String) As CommVar
|
||||
Dim nIndex As Integer = GetIndexFromAddress(Address)
|
||||
If nIndex >= 0 Then
|
||||
Return m_ReadingVars(GetIndexFromAddress(Address))
|
||||
Return m_ReadingVars(nIndex)
|
||||
End If
|
||||
Return Nothing
|
||||
End Function
|
||||
@@ -136,7 +167,7 @@ Public Class RWVariableManager
|
||||
Private Sub UpdateContinuousVars()
|
||||
Dim bReaded As Boolean = True
|
||||
For Each Var In m_ReadingVars
|
||||
If Not IsNothing(Var) AndAlso Var.sType = CommVar.CommVarTypes.CONTINUOUS AndAlso Not Var.bReaded Then
|
||||
If Not IsNothing(Var) AndAlso Var.nReadType = CommVar.ReadTypes.CONTINUOUS AndAlso Not Var.bReaded Then
|
||||
bReaded = False
|
||||
Exit For
|
||||
End If
|
||||
@@ -161,7 +192,7 @@ Public Class RWVariableManager
|
||||
'Dim bChangedVal As Boolean = ()
|
||||
Var.SetValue(VarValue)
|
||||
' se variabile ripetitiva lancio update variabili ripetitive
|
||||
If Var.sType = CommVar.CommVarTypes.CONTINUOUS Then
|
||||
If Var.nReadType = CommVar.ReadTypes.CONTINUOUS Then
|
||||
EgtOutLog(CommandExecutedCorrectly & " . " & VarName & " . " & VarValue)
|
||||
EgtOutLog(Var.sName & " . " & Var.sAddress & " . " & Var.sValue & " . " & Var.bReaded)
|
||||
UpdateContinuousVars()
|
||||
@@ -190,29 +221,51 @@ End Class
|
||||
|
||||
Public Class CommVar
|
||||
|
||||
Public Enum CommVarTypes As Integer
|
||||
ONETIME
|
||||
CONTINUOUS
|
||||
Public Event NewValue As EventHandler(Of NewValueEventArgs)
|
||||
|
||||
Public Enum ReadTypes As Integer
|
||||
NULL = 0
|
||||
ONETIME = 1
|
||||
CONTINUOUS = 2
|
||||
End Enum
|
||||
|
||||
Public Enum Types As Integer
|
||||
NULL = 0
|
||||
PLC = 1
|
||||
CN = 2
|
||||
End Enum
|
||||
|
||||
Private m_sName As String
|
||||
Public ReadOnly Property sName As String
|
||||
Public Property sName As String
|
||||
Get
|
||||
Return m_sName
|
||||
End Get
|
||||
Set(value As String)
|
||||
m_sName = value
|
||||
End Set
|
||||
End Property
|
||||
Private m_sAddress As String
|
||||
Public ReadOnly Property sAddress As String
|
||||
Public Property sAddress As String
|
||||
Get
|
||||
Return m_sAddress
|
||||
End Get
|
||||
Set(value As String)
|
||||
m_sAddress = value
|
||||
End Set
|
||||
End Property
|
||||
Private m_nType As CommVarTypes
|
||||
Public ReadOnly Property sType As CommVarTypes
|
||||
Private m_nReadType As ReadTypes
|
||||
Public ReadOnly Property nReadType As ReadTypes
|
||||
Get
|
||||
Return m_nReadType
|
||||
End Get
|
||||
End Property
|
||||
Private m_nType As Types
|
||||
Public ReadOnly Property nType As Types
|
||||
Get
|
||||
Return m_nType
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_sValue As String
|
||||
Public ReadOnly Property sValue As String
|
||||
Get
|
||||
@@ -220,8 +273,10 @@ Public Class CommVar
|
||||
End Get
|
||||
End Property
|
||||
Public Sub SetValue(Value As String)
|
||||
m_sValue = Value
|
||||
Dim bNewValue As Boolean = m_sValue <> value
|
||||
m_sValue = value
|
||||
m_bReaded = True
|
||||
If bNewValue Then RaiseEvent NewValue(Me, New NewValueEventArgs(value))
|
||||
End Sub
|
||||
|
||||
Private m_bReaded As Boolean
|
||||
@@ -231,9 +286,10 @@ Public Class CommVar
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Sub New(Name As String, Address As String, Type As CommVarTypes)
|
||||
Sub New(Name As String, Address As String, ReadType As ReadTypes, Type As Types)
|
||||
m_sName = Name
|
||||
m_sAddress = Address
|
||||
m_nReadType = ReadType
|
||||
m_nType = Type
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ Public Class MachinePanelVM
|
||||
Friend Sub LoadCurrentMachine()
|
||||
If m_MachineList.Count = 0 Then Return
|
||||
Dim CurrMach As String = String.Empty
|
||||
GetMainPrivateProfileString(S_MACH, K_CURRMACH, String.Empty, CurrMach)
|
||||
GetMainPrivateProfileString(S_MACH, K_SUPERVISORMACH, String.Empty, CurrMach)
|
||||
Dim bFound As Boolean = False
|
||||
If Not String.IsNullOrEmpty(CurrMach) Then
|
||||
For Each Mach In MachineList
|
||||
|
||||
@@ -42,7 +42,7 @@ Public Class MainWindowVM
|
||||
Sub New()
|
||||
' Avvio l'inizializzazione della mappa passandogli il riferimento al MainWindowVM
|
||||
Map.BeginInit(Me)
|
||||
'' Creo Model della MainWindow
|
||||
' Creo Model della MainWindow
|
||||
m_MainWindowM = New MainWindowM
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -19,6 +19,14 @@ Public Module CurrentMachine
|
||||
' File ini dei parametri macchina
|
||||
Private m_sMachParamIniFile As String = String.Empty
|
||||
|
||||
' tipo di CN della macchina
|
||||
Private m_NCType As NCTypes = NCTypes.NULL
|
||||
Public ReadOnly Property NCType As Integer
|
||||
Get
|
||||
Return m_NCType
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_Flow As FlowTypes = FlowTypes.ONEBYONE
|
||||
Friend ReadOnly Property Flow As FlowTypes
|
||||
Get
|
||||
@@ -80,6 +88,8 @@ Public Module CurrentMachine
|
||||
|
||||
' crea l'elenco dei parametri della macchina corrente
|
||||
CreateMachParams()
|
||||
' recupero tipo di controllo
|
||||
m_NCType = GetPrivateProfileInt(S_GENERAL, K_NCTYPE, 0, m_sMachIniFile)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
<!--<EgtBEAMWALL:PartParametersVM x:Key="PartParametersVM"/>-->
|
||||
<EgtBEAMWALL:LeftPanelVM x:Key="LeftPanelVM"/>
|
||||
<EgtBEAMWALL:MachCommandMessagePanelVM x:Key="MachCommandMessagePanelVM"/>
|
||||
<EgtBEAMWALL:AxesPanelVM x:Key="AxesPanelVM"/>
|
||||
<EgtBEAMWALL:VariablesListVM x:Key="VariablesListVM"/>
|
||||
<EgtBEAMWALL:MainMenuVM x:Key="MainMenuVM"/>
|
||||
<EgtBEAMWALL:MyStatusBarVM x:Key="StatusBarVM"/>
|
||||
<!--<EgtBEAMWALL:BottomPanelVM x:Key="BottomPanelVM"/>-->
|
||||
|
||||
@@ -12,6 +12,7 @@ Module Map
|
||||
Private m_refMyMachGroupPanelVM As MyMachGroupPanelVM
|
||||
Private m_refLeftPanelVM As LeftPanelVM
|
||||
Private m_refMachCommandMessagePanelVM As MachCommandMessagePanelVM
|
||||
Private m_refAxesPanelVM As AxesPanelVM
|
||||
'Private m_refBottomPanelVM As BottomPanelVM
|
||||
'Private m_refShowBeamPanelVM As ShowBeamPanelVM
|
||||
Private m_refConfigurationPageVM As ConfigurationPageVM
|
||||
@@ -102,6 +103,12 @@ Module Map
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property refAxesPanelVM As AxesPanelVM
|
||||
Get
|
||||
Return m_refAxesPanelVM
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property refCALCPanelVM As CALCPanelVM
|
||||
Get
|
||||
Return m_refCALCPanelVM
|
||||
@@ -263,6 +270,11 @@ Module Map
|
||||
Return Not IsNothing(m_refMachCommandMessagePanelVM)
|
||||
End Function
|
||||
|
||||
Friend Function SetRefAxesPanelVM(AxesPanelVM As AxesPanelVM) As Boolean
|
||||
m_refAxesPanelVM = AxesPanelVM
|
||||
Return Not IsNothing(m_refAxesPanelVM)
|
||||
End Function
|
||||
|
||||
Friend Function SetRefCALCPanelVM(CALCPanelVM As CALCPanelVM) As Boolean
|
||||
m_refCALCPanelVM = CALCPanelVM
|
||||
Return Not IsNothing(m_refCALCPanelVM)
|
||||
@@ -369,7 +381,7 @@ Module Map
|
||||
Return Not IsNothing(m_refMainWindowVM) AndAlso 'Not IsNothing(m_refMainMenuVM) AndAlso
|
||||
Not IsNothing(LibMap.refStatusBarVM) AndAlso 'Not IsNothing(m_refProjManagerVM) AndAlso Not IsNothing(m_refProdManagerVM) AndAlso
|
||||
Not IsNothing(m_refConfigurationPageVM) AndAlso Not IsNothing(m_refFeatureInPartInRawPartListVM) AndAlso
|
||||
Not IsNothing(m_refPartInRawPartListVM) AndAlso
|
||||
Not IsNothing(m_refPartInRawPartListVM) AndAlso Not IsNothing(m_refAxesPanelVM) AndAlso
|
||||
Not IsNothing(LibMap.refSceneHostVM) AndAlso Not IsNothing(LibMap.refShowPanelVM) AndAlso
|
||||
Not IsNothing(m_refMachinePanelVM) AndAlso Not IsNothing(LibMap.refMachGroupPanelVM) AndAlso Not IsNothing(m_refRawPartListVM) AndAlso 'Not IsNothing(m_refWarehouseWndVM) AndAlso Not IsNothing(m_refShowBeamPanelVM) AndAlso
|
||||
Not IsNothing(m_refMachCommandMessagePanelVM) AndAlso LibMap.EndInit()
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<UserControl x:Class="VariablesListV"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Height="200">
|
||||
|
||||
<DataGrid ItemsSource="{Binding VariablesList}"
|
||||
AutoGenerateColumns="False">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Name" Binding="{Binding sName}" Width="1*"/>
|
||||
<DataGridTextColumn Header="Address" Binding="{Binding sAddress}" Width="1*"/>
|
||||
<DataGridTextColumn Header="Value" Binding="{Binding sValue}" Width="1*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,3 @@
|
||||
Public Class VariablesListV
|
||||
|
||||
End Class
|
||||
@@ -0,0 +1,96 @@
|
||||
Imports System.Collections.ObjectModel
|
||||
Imports System.Windows.Threading
|
||||
Imports EgtWPFLib5
|
||||
Imports EgtBEAMWALL.Core
|
||||
|
||||
Public Class VariablesListVM
|
||||
|
||||
|
||||
Private m_VariablesList As New ObservableCollection(Of Variable)
|
||||
Public ReadOnly Property VariablesList As ObservableCollection(Of Variable)
|
||||
Get
|
||||
Return m_VariablesList
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Sub New()
|
||||
' inizializzo tutte le variabili
|
||||
Dim Index As Integer = 1
|
||||
Dim CommVariable As CommVar = MachManaging.InitVar(S_VARIABLES, Index)
|
||||
While Not IsNothing(CommVariable)
|
||||
m_VariablesList.Add(New Variable(CommVariable))
|
||||
Index += 1
|
||||
CommVariable = MachManaging.InitVar(S_VARIABLES, Index)
|
||||
End While
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 1)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 2)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 3)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 4)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 5)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 6)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 7)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 8)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 9)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 10)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 11)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 12)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 13)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(14)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(15)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(16)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(17)))
|
||||
'm_VariablesList.Add(New Variable(MachManaging.InitVar(18)))
|
||||
'm_VariablesList.Add(New Variable(RWVariableManager.InitVar(19)))
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Public Class Variable
|
||||
Inherits VMBase
|
||||
|
||||
Private m_CommVar As CommVar
|
||||
Public ReadOnly Property CommVar As CommVar
|
||||
Get
|
||||
Return m_CommVar
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Property sName As String
|
||||
Get
|
||||
Return CommVar.sName
|
||||
End Get
|
||||
Set(value As String)
|
||||
CommVar.sName = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property sAddress As String
|
||||
Get
|
||||
Return CommVar.sAddress
|
||||
End Get
|
||||
Set(value As String)
|
||||
CommVar.sAddress = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property sValue As String
|
||||
Get
|
||||
Return CommVar.sValue
|
||||
End Get
|
||||
Set(value As String)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.WRITE, {CommVar.nType}, Nothing, {CommVar.sName, value}))
|
||||
NotifyPropertyChanged(NameOf(sValue))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Sub New(CommVar As CommVar)
|
||||
m_CommVar = CommVar
|
||||
AddHandler CommVar.NewValue, AddressOf CommVar_NewValue
|
||||
End Sub
|
||||
|
||||
Private Sub CommVar_NewValue(sender As Object, e As NewValueEventArgs)
|
||||
NotifyPropertyChanged(NameOf(sValue))
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user