From 78470c8ad05f1c6038bfeed7134c19cc68bbbcc4 Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Thu, 4 Nov 2021 18:01:43 +0100 Subject: [PATCH] - Integrazione dei comandi Num di COMMTest --- EgtBEAMWALL.Core/Constants/ConstGen.vb | 1 + EgtBEAMWALL.Core/Constants/ConstIni.vb | 1 + EgtBEAMWALL.Core/Constants/ConstMachComm.vb | 5 +- EgtBEAMWALL.Core/Constants/ConstMachIni.vb | 2 + EgtBEAMWALL.Core/Utility/MachLog.vb | 2 +- .../AxesPanel/AxesPanelV.xaml | 20 + .../AxesPanel/AxesPanelV.xaml.vb | 3 + .../AxesPanel/AxesPanelVM.vb | 123 +++ .../Comms/NUMFlexiumComm.vb | 834 ++++++++++++++++++ EgtBEAMWALL.Supervisor/Comms/TPAComm.cs | 333 ------- EgtBEAMWALL.Supervisor/Comms/TPAComm.old.vb | 244 +++++ EgtBEAMWALL.Supervisor/Comms/TPAComm.vb | 8 +- .../ConfigurationPage/ConfigurationPageVM.vb | 20 +- .../Constants/ConstCommVar.vb | 23 + .../EgtBEAMWALL.Supervisor.vbproj | 26 + .../LeftPanel/LeftPanelV.xaml | 16 +- .../LeftPanel/LeftPanelVM.vb | 65 +- .../MachCommandMessagePanelV.xaml | 4 +- .../MachCommandMessagePanelVM.vb | 267 ++---- .../MachGroupPanel/MyMachGroupVM.vb | 22 +- .../MachManagingThread/MachCommConst.vb | 2 +- .../MachManagingThread/MachManaging.vb | 576 +++++++----- .../MachManagingThread/MachManagingThread.vb | 4 +- .../MachManagingThread/NewValueEventArgs.vb | 18 + .../MachManagingThread/RWVariableManager.vb | 88 +- .../MachinePanel/MachinePanelVM.vb | 2 +- .../MainWindow/MainWindowVM.vb | 2 +- .../Utility/CurrentMachine.vb | 10 + .../Utility/Dictionary.xaml | 2 + EgtBEAMWALL.Supervisor/Utility/Map.vb | 14 +- .../VariablesList/VariablesListV.xaml | 15 + .../VariablesList/VariablesListV.xaml.vb | 3 + .../VariablesList/VariablesListVM.vb | 96 ++ 33 files changed, 2071 insertions(+), 780 deletions(-) create mode 100644 EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelV.xaml create mode 100644 EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelV.xaml.vb create mode 100644 EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelVM.vb create mode 100644 EgtBEAMWALL.Supervisor/Comms/NUMFlexiumComm.vb delete mode 100644 EgtBEAMWALL.Supervisor/Comms/TPAComm.cs create mode 100644 EgtBEAMWALL.Supervisor/Comms/TPAComm.old.vb create mode 100644 EgtBEAMWALL.Supervisor/MachManagingThread/NewValueEventArgs.vb create mode 100644 EgtBEAMWALL.Supervisor/VariablesList/VariablesListV.xaml create mode 100644 EgtBEAMWALL.Supervisor/VariablesList/VariablesListV.xaml.vb create mode 100644 EgtBEAMWALL.Supervisor/VariablesList/VariablesListVM.vb diff --git a/EgtBEAMWALL.Core/Constants/ConstGen.vb b/EgtBEAMWALL.Core/Constants/ConstGen.vb index 95ae00e0..3101c6cb 100644 --- a/EgtBEAMWALL.Core/Constants/ConstGen.vb +++ b/EgtBEAMWALL.Core/Constants/ConstGen.vb @@ -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 diff --git a/EgtBEAMWALL.Core/Constants/ConstIni.vb b/EgtBEAMWALL.Core/Constants/ConstIni.vb index 2d8b51d3..8bea697d 100644 --- a/EgtBEAMWALL.Core/Constants/ConstIni.vb +++ b/EgtBEAMWALL.Core/Constants/ConstIni.vb @@ -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" diff --git a/EgtBEAMWALL.Core/Constants/ConstMachComm.vb b/EgtBEAMWALL.Core/Constants/ConstMachComm.vb index 00efd083..0c837a1f 100644 --- a/EgtBEAMWALL.Core/Constants/ConstMachComm.vb +++ b/EgtBEAMWALL.Core/Constants/ConstMachComm.vb @@ -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 diff --git a/EgtBEAMWALL.Core/Constants/ConstMachIni.vb b/EgtBEAMWALL.Core/Constants/ConstMachIni.vb index 28d3bb7f..0b874795 100644 --- a/EgtBEAMWALL.Core/Constants/ConstMachIni.vb +++ b/EgtBEAMWALL.Core/Constants/ConstMachIni.vb @@ -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" diff --git a/EgtBEAMWALL.Core/Utility/MachLog.vb b/EgtBEAMWALL.Core/Utility/MachLog.vb index 30326fe3..2cce8cf7 100644 --- a/EgtBEAMWALL.Core/Utility/MachLog.vb +++ b/EgtBEAMWALL.Core/Utility/MachLog.vb @@ -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 diff --git a/EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelV.xaml b/EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelV.xaml new file mode 100644 index 00000000..5431defa --- /dev/null +++ b/EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelV.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelV.xaml.vb b/EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelV.xaml.vb new file mode 100644 index 00000000..3b014fcb --- /dev/null +++ b/EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class AxesPanelV + +End Class diff --git a/EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelVM.vb b/EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelVM.vb new file mode 100644 index 00000000..0fa9155a --- /dev/null +++ b/EgtBEAMWALL.Supervisor/AxesPanel/AxesPanelVM.vb @@ -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 diff --git a/EgtBEAMWALL.Supervisor/Comms/NUMFlexiumComm.vb b/EgtBEAMWALL.Supervisor/Comms/NUMFlexiumComm.vb new file mode 100644 index 00000000..19c9ee6c --- /dev/null +++ b/EgtBEAMWALL.Supervisor/Comms/NUMFlexiumComm.vb @@ -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 diff --git a/EgtBEAMWALL.Supervisor/Comms/TPAComm.cs b/EgtBEAMWALL.Supervisor/Comms/TPAComm.cs deleted file mode 100644 index c4c6cfb8..00000000 --- a/EgtBEAMWALL.Supervisor/Comms/TPAComm.cs +++ /dev/null @@ -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 - /// - /// Notify operative state change - /// - /// New operative state - void RemoteObject_OpStateUpdate(ISOCNC.Remoting.MachineOperatingState newOpState) - { - _opState = newOpState; - _MainWindowVM.SelOPState = _opState; - if (_MainWindowVM.SelOPState == ISOCNC.Remoting.MachineOperatingState.Pending) - remObject.RemoveAllProgramsFromList(); - } - /// - /// Notify the execution of a command – server side - /// - /// Command executed index - 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; - } - /// - /// Notify an error occured during the execution of a command – server side - /// - /// - /// Error - void RemoteObject_ServerError(object sender, ISOCNC.Remoting.ServerErrorEventArgs seEA) - { - MessageBoxResult dr = MessageBox.Show("Server Error: " + seEA.Error); - } - /// - /// Notify the update of an axis coordinate - /// - /// New axis value - /// Axis index - void RemoteObject_AxisCoordinatesUpdate(double axisValue, int axisIndex) - { - _axesVal[axisIndex] = axisValue; - _MainWindowVM.AxisList[axisIndex].Value = axisValue; - _MainWindowVM.AxisList[axisIndex].NotifyPropertyChanged("Value"); - } - /// - /// Notify the actual ISO line processed - /// - /// Actual ISO Line - void RemoteObject_RPCUpdate(uint newRPC) - { - _rpc = (int)newRPC; - } - /// - /// Receive program list information - /// - /// Program count - /// Program at index - /// Program List - 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; - } - } - /// - /// Notify the adding or removal of an alarm - /// - /// Operation: Add-Remove - /// Type: Cycle, Message, System, ISO - /// Alarm - /// Alarm code - /// Data - 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; - } - } - /// - /// Notify info on the executed command - /// - /// Indice di comando eseguito - /// True se il comando è stato eseguito correttamente - /// Nome variabile ovvero percorso in Albatros della variabile - /// Valore variabile - /// Tipologia variabile - void RemoteObject_VariableCommandExecuted(int executedCommand, bool commandExecutedCorrectly, string varName, string varValue, int varType) - { - _MainWindowVM.SetVarValue(varValue); - } - /// - /// Notify the server alive - /// - /// Tick corrente per verifica server alive - void RemoteObject_TickUpdate(ulong newTick) - { - - } - - #endregion Event management - #endregion Remoting obj events -} diff --git a/EgtBEAMWALL.Supervisor/Comms/TPAComm.old.vb b/EgtBEAMWALL.Supervisor/Comms/TPAComm.old.vb new file mode 100644 index 00000000..c319576b --- /dev/null +++ b/EgtBEAMWALL.Supervisor/Comms/TPAComm.old.vb @@ -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 + + + + 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 diff --git a/EgtBEAMWALL.Supervisor/Comms/TPAComm.vb b/EgtBEAMWALL.Supervisor/Comms/TPAComm.vb index c319576b..57fd9154 100644 --- a/EgtBEAMWALL.Supervisor/Comms/TPAComm.vb +++ b/EgtBEAMWALL.Supervisor/Comms/TPAComm.vb @@ -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 - 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" diff --git a/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageVM.vb b/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageVM.vb index 2f373974..d679977b 100644 --- a/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageVM.vb +++ b/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageVM.vb @@ -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 diff --git a/EgtBEAMWALL.Supervisor/Constants/ConstCommVar.vb b/EgtBEAMWALL.Supervisor/Constants/ConstCommVar.vb index 65249eb4..850d25bd 100644 --- a/EgtBEAMWALL.Supervisor/Constants/ConstCommVar.vb +++ b/EgtBEAMWALL.Supervisor/Constants/ConstCommVar.vb @@ -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 diff --git a/EgtBEAMWALL.Supervisor/EgtBEAMWALL.Supervisor.vbproj b/EgtBEAMWALL.Supervisor/EgtBEAMWALL.Supervisor.vbproj index 5323cbd8..0d177a54 100644 --- a/EgtBEAMWALL.Supervisor/EgtBEAMWALL.Supervisor.vbproj +++ b/EgtBEAMWALL.Supervisor/EgtBEAMWALL.Supervisor.vbproj @@ -123,6 +123,14 @@ ..\packages\FluentFTP.19.2.2\lib\net45\FluentFTP.dll + + ..\..\..\EgtProg\EgtBEAMWALL\Interop.FXLog.dll + True + + + ..\..\..\EgtProg\EgtBEAMWALL\Interop.FXServer.dll + True + ..\..\..\Albatros\Bin\ISOCNC.Remoting.dll @@ -216,11 +224,16 @@ AboutBoxV.xaml + + AxesPanelV.xaml + + CalcPanelV.xaml + ConfigurationPageV.xaml @@ -261,6 +274,7 @@ + MainMenuV.xaml @@ -295,6 +309,10 @@ + + VariablesListV.xaml + + @@ -309,6 +327,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -385,6 +407,10 @@ MSBuild:Compile Designer + + Designer + XamlIntelliSenseFileGenerator + MSBuild:Compile Designer diff --git a/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelV.xaml b/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelV.xaml index b8acf6a8..f77bdfc1 100644 --- a/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelV.xaml +++ b/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelV.xaml @@ -13,11 +13,16 @@ - + + + + + + + + diff --git a/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelVM.vb b/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelVM.vb index 30395114..c8fb2987 100644 --- a/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelVM.vb +++ b/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelVM.vb @@ -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 \ No newline at end of file diff --git a/EgtBEAMWALL.Supervisor/MachCommandMessagePanel/MachCommandMessagePanelV.xaml b/EgtBEAMWALL.Supervisor/MachCommandMessagePanel/MachCommandMessagePanelV.xaml index 2bd19021..6ed89647 100644 --- a/EgtBEAMWALL.Supervisor/MachCommandMessagePanel/MachCommandMessagePanelV.xaml +++ b/EgtBEAMWALL.Supervisor/MachCommandMessagePanel/MachCommandMessagePanelV.xaml @@ -29,8 +29,8 @@