- Gestita chiusura Db utensili con alt + F4
- Gestione Num Axium - Conversione automatica del file messaggi macchina nel nostro formato
This commit is contained in:
@@ -0,0 +1,847 @@
|
||||
Imports EgtBEAMWALL.Core
|
||||
Imports EgtBEAMWALL.Core.ConstMachComm
|
||||
Imports EgtUILib
|
||||
Imports EgtWPFLib5
|
||||
|
||||
Public Class NUMAxiumComm
|
||||
|
||||
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
|
||||
|
||||
Public ReadOnly Property bIsTransferActive As Boolean
|
||||
Get
|
||||
Return If(Not IsNothing(objDFileTransfer), objDFileTransfer.IsTransferActive(), False)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'Private objDRunTimeSystem As FXServer.DRunTimeSystem
|
||||
Private WithEvents objDGroupManager As APServer.DGroupManager
|
||||
Private WithEvents objDGeneralFunction As APServer.DGeneralFunctions
|
||||
Private WithEvents objDMainCncData As APServer.DMainCncData
|
||||
Private WithEvents objErrorHandler As APLog.ErrorHandler
|
||||
Private WithEvents objDReadELS As APServer.DReadELS
|
||||
Private WithEvents objDReadPlcVarList As APServer.DReadPlcVarList
|
||||
Private WithEvents objDFileTransfer As APServer.DFileTransfer
|
||||
Private WithEvents objDPosition As APServer.DPosition
|
||||
Private WithEvents objDMdiCommand As APServer.DMdiCommand
|
||||
Private WithEvents objDVariables As APServer.DVariables
|
||||
Private WithEvents objDCncMode As APServer.DCncMode
|
||||
Private WithEvents objDReadOperatorMessage As APServer.DReadOperatorMessage
|
||||
|
||||
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 m_ReadFXMessages As New List(Of ReadMessages)
|
||||
Private m_ReadOperatorMessages As New List(Of ReadMessages)
|
||||
' lista variabili in lettura
|
||||
Private Shared m_ReadingVars(100) As CommVar
|
||||
Private m_BytesTransferedCounter As Integer
|
||||
Private m_LinearAxisPrecision As Integer
|
||||
|
||||
Public Sub New(MachManaging As MachManaging)
|
||||
Dim lRet As Integer
|
||||
m_MachManaging = MachManaging
|
||||
End Sub
|
||||
|
||||
#Region "METHODS"
|
||||
|
||||
Friend Sub InitFxServer()
|
||||
End Sub
|
||||
|
||||
Friend Sub InitFxObjects()
|
||||
objDGroupManager = CreateObject("APServer.DGroupManager")
|
||||
AddHandler objDGroupManager.ErrorHandler, AddressOf objDGroupManager_ErrorHandler
|
||||
AddHandler objDGroupManager.AssignmentChanged, AddressOf objDGroupManager_AssignmentChanged
|
||||
objDGroupManager.CncNumber = 0
|
||||
objDGroupManager.AxisGroup = 0
|
||||
|
||||
objDMainCncData = CreateObject("APServer.DMainCncData")
|
||||
Dim s = objDMainCncData.Init(objDGroupManager.Handle)
|
||||
m_LinearAxisPrecision = objDMainCncData.GetLinearPrecision()
|
||||
Dim CncFxIdentifier As String = objDMainCncData.GetCncIdentifier()
|
||||
EgtOutLog("CncFxIdentifier: " & CncFxIdentifier)
|
||||
|
||||
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
|
||||
|
||||
objDGeneralFunction = CreateObject("APServer.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
|
||||
Dim l = objDGeneralFunction.Init(objDGroupManager.Handle)
|
||||
Dim MaxWaiting As Integer = 100
|
||||
Dim WaitingIndex As Integer = 0
|
||||
While objDGeneralFunction.ConnectionStatus <> 2 AndAlso WaitingIndex < MaxWaiting
|
||||
Threading.Thread.Sleep(100)
|
||||
UpdateUI()
|
||||
WaitingIndex += 1
|
||||
End While
|
||||
Dim j = objDGeneralFunction.ConnectionStatus
|
||||
Dim oi = objDGeneralFunction.ConnectionString
|
||||
' Initialize FXLog Objects
|
||||
objErrorHandler = CreateObject("APLog.ErrorHandler")
|
||||
'AddHandler objErrorHandler.ErrorFromActiveCnc, 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)
|
||||
|
||||
'Initialize FXServer class DFileTransferv
|
||||
objDFileTransfer = CreateObject("APServer.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 = CreateObject("APServer.DPosition")
|
||||
AddHandler objDPosition.PositionChanged, AddressOf objDPosition_PositionChanged
|
||||
objDPosition.ModeOP = 1
|
||||
objDPosition.Flag = 0
|
||||
objDPosition.Init(objDGroupManager.Handle)
|
||||
objDPosition.FireValidAxis()
|
||||
objDPosition.FireValues()
|
||||
|
||||
'Initialize FXServer class DMdiCommand
|
||||
objDMdiCommand = CreateObject("APServer.DMdiCommand")
|
||||
AddHandler objDMdiCommand.CommandWritten, AddressOf objDMdiCommand_CommandWritten
|
||||
objDMdiCommand.Init(objDGroupManager.Handle)
|
||||
|
||||
' Initialize FXServer class DCncMode
|
||||
objDCncMode = CreateObject("APServer.DCncMode")
|
||||
AddHandler objDCncMode.ValueChanged, AddressOf objDCncMode_ValueChanged
|
||||
objDCncMode.Init(objDGroupManager.Handle)
|
||||
|
||||
' Initialize FXServer class DReadOperatorMessage
|
||||
objDReadOperatorMessage = CreateObject("APServer.DReadOperatorMessage")
|
||||
AddHandler objDReadOperatorMessage.ValueChanged, AddressOf objDReadOperatorMessage_ValueChanged
|
||||
Dim tc = objDReadOperatorMessage.Init(objDGroupManager.Handle)
|
||||
If tc <> 0 Then EgtOutLog("Init failed ! return code : " + tc)
|
||||
|
||||
' Initialize FXServer class DReadELS
|
||||
'objDReadELS = CreateObject("APServer.DReadELS")
|
||||
'AddHandler objDReadELS.ValueChanged, AddressOf objDReadELS_ValueChanged
|
||||
'Dim y = objDReadELS.Init(objDGroupManager.Handle)
|
||||
|
||||
objDReadPlcVarList = CreateObject("APServer.DReadPlcVarList")
|
||||
AddHandler objDReadPlcVarList.ValueChanged, AddressOf objDPlcVariables_ReadPLCVariablesChanged
|
||||
' Init & send the list of requested variables
|
||||
'tc = objDReadPlcVarList.Init(objDGroupManager.Handle)
|
||||
'If tc <> 0 Then EgtOutLog(" objDReadPlcVarList.Init() Error : " + tc)
|
||||
|
||||
'Initialize FXServer class DVariables
|
||||
objDVariables = CreateObject("APServer.DVariables")
|
||||
'AddHandler objDVariables.ValueChanged, AddressOf objDVariables_ValueChanged
|
||||
' Init & send the list of requested variables
|
||||
'Dim rc As Short = objDVariables.Init(objDGroupManager.Handle, "E80000", 0)
|
||||
AddHandler objDVariables.VariableWritten, AddressOf objDVariables_VariableWritten
|
||||
AddHandler objDVariables.ValueChanged, AddressOf objDPlcVariables_ReadVariablesChanged
|
||||
'If rc <> 0 Then EgtOutLog(" objDVariables.Init() Error : " + rc)
|
||||
|
||||
' attivo programma main
|
||||
Map.refMachManaging.Num_Axium.ActivateProg(9000)
|
||||
|
||||
End Sub
|
||||
|
||||
Friend Sub CloseFxObjects()
|
||||
If Not IsNothing(objDReadOperatorMessage) Then
|
||||
objDReadOperatorMessage.Close()
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDReadOperatorMessage)
|
||||
objDReadOperatorMessage = Nothing
|
||||
End If
|
||||
If Not IsNothing(objDCncMode) Then
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDCncMode)
|
||||
objDCncMode = Nothing
|
||||
End If
|
||||
If Not IsNothing(objDReadPlcVarList) Then
|
||||
objDReadPlcVarList.Close()
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDReadPlcVarList)
|
||||
objDReadPlcVarList = Nothing
|
||||
End If
|
||||
If Not IsNothing(objDVariables) Then
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDVariables)
|
||||
objDVariables = Nothing
|
||||
End If
|
||||
If Not IsNothing(objDMdiCommand) Then
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDMdiCommand)
|
||||
objDMdiCommand = Nothing
|
||||
End If
|
||||
If Not IsNothing(objDPosition) Then
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDPosition)
|
||||
objDPosition = Nothing
|
||||
End If
|
||||
If Not IsNothing(objDFileTransfer) Then
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDFileTransfer)
|
||||
objDFileTransfer = Nothing
|
||||
End If
|
||||
If Not IsNothing(objDReadELS) Then
|
||||
objDReadELS.Close()
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDReadELS)
|
||||
objDReadELS = Nothing
|
||||
End If
|
||||
If Not IsNothing(objErrorHandler) Then
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objErrorHandler)
|
||||
objErrorHandler = Nothing
|
||||
End If
|
||||
If Not IsNothing(objDGeneralFunction) Then
|
||||
objDGeneralFunction.Connect(0)
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDGeneralFunction)
|
||||
objDGeneralFunction = Nothing
|
||||
End If
|
||||
If Not IsNothing(objDMainCncData) Then
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDMainCncData)
|
||||
objDMainCncData = Nothing
|
||||
End If
|
||||
If Not IsNothing(objDGroupManager) Then
|
||||
System.Runtime.InteropServices.Marshal.ReleaseComObject(objDGroupManager)
|
||||
objDGroupManager = Nothing
|
||||
End If
|
||||
Dim ServerProcList As Process() = Process.GetProcessesByName("APServer")
|
||||
Dim LogProcList As Process() = Process.GetProcessesByName("APLog")
|
||||
For Each ServerProc In ServerProcList
|
||||
ServerProc.Kill()
|
||||
Next
|
||||
For Each LogProc In LogProcList
|
||||
LogProc.Kill()
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Friend Sub GetGeneralFunctions()
|
||||
Dim _GetConnectState As Int16 = 0
|
||||
Dim MaxWaiting As Integer = 100
|
||||
Dim WaitingIndex As Integer = 0
|
||||
While _GetConnectState <> 2 AndAlso WaitingIndex < MaxWaiting
|
||||
_GetConnectState = objDGeneralFunction.ConnectionStatus
|
||||
Threading.Thread.Sleep(100)
|
||||
UpdateUI()
|
||||
WaitingIndex += 1
|
||||
End While
|
||||
|
||||
Select Case _GetConnectState
|
||||
Case 0
|
||||
' Not connected
|
||||
m_MachManaging.SetConnected(False)
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.NULL, ResultTypes.RESULT, "")
|
||||
Case 1
|
||||
' Connection error
|
||||
m_MachManaging.SetConnected(False)
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.ERROR_, ResultTypes.RESULT, "")
|
||||
Case 2
|
||||
' Connected
|
||||
m_MachManaging.SetConnected(True)
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.OK, ResultTypes.RESULT, "")
|
||||
' avvio lettura variabili
|
||||
'MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.READ_NUMFLEXIUM))
|
||||
StartReadList()
|
||||
StartReadPLCList()
|
||||
'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
|
||||
|
||||
Friend Sub SetChannel(value As Integer)
|
||||
ChangeChannel(CShort(value))
|
||||
'objDGroupManager.AxisGroup = CShort(value)
|
||||
End Sub
|
||||
|
||||
Friend Sub ActivateProg(PartProgramNumberActivate As Integer)
|
||||
' attivo programma main
|
||||
Dim _FXReturn As Int16 = objDGeneralFunction.ActivateProgram(PartProgramNumberActivate * 10, 0)
|
||||
If _FXReturn <> 0 Then
|
||||
EgtOutLog("Error Activate Program:" & " " & _FXReturn.ToString())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ChangeChannel(Channel As Short)
|
||||
objErrorHandler.SetChannel(1, 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()
|
||||
'm_PlcVariablesList = New ArrayList((From CommVar In m_ReadingVars
|
||||
' Where Not IsNothing(CommVar) AndAlso CommVar.nType = CommVar.Types.PLC
|
||||
' Select CommVar.sAddress).ToArray())
|
||||
Dim nPLCVarIndex As Integer = 0
|
||||
Dim PlcVariablesList As New ArrayList
|
||||
Dim sPLCVariableList = ""
|
||||
For VarIndex = 0 To m_ReadingVars.Length - 1
|
||||
Dim CommVar As CommVar = m_ReadingVars(VarIndex)
|
||||
If Not IsNothing(CommVar) AndAlso CommVar.Paragraph = CommVar.Paragraphs.MAIN AndAlso CommVar.nType = CommVar.Types.CN Then
|
||||
PlcVariablesList.Add(CommVar.sAddress)
|
||||
If Not String.IsNullOrWhiteSpace(sPLCVariableList) Then
|
||||
sPLCVariableList &= ","
|
||||
End If
|
||||
sPLCVariableList &= """" & CommVar.sAddress & """"
|
||||
CommVar.Index = nPLCVarIndex
|
||||
nPLCVarIndex += 1
|
||||
End If
|
||||
Next
|
||||
''Dim sPLCVariableList = ""
|
||||
''For VariableIndex = 0 To PlcVariablesList.Count - 1
|
||||
'' If VariableIndex <> 0 Then
|
||||
'' sPLCVariableList &= ","
|
||||
'' End If
|
||||
'' sPLCVariableList &= """" & PlcVariablesList(VariableIndex) & """"
|
||||
''Next
|
||||
Dim _FXReturn As Short = objDVariables.Init(objDGroupManager.Handle, sPLCVariableList, 1) 'PlcVariablesList.ToArray().ToString())
|
||||
''Dim _FXReturn As Short = objDVariables.ReadVariables(PlcVariablesList.ToArray())
|
||||
|
||||
'If _FXReturn <> 0 Then
|
||||
' EgtOutLog("Error ReadVariables:" & " " & _FXReturn.ToString())
|
||||
'End If
|
||||
End Sub
|
||||
|
||||
Friend Sub StartReadPLCList()
|
||||
'Dim AddressList() As String = (From CommVar In m_ReadingVars
|
||||
' Where Not IsNothing(CommVar) AndAlso CommVar.nType = CommVar.Types.PLC
|
||||
' Select CommVar.sAddress).ToArray()
|
||||
'm_PlcVariablesList = New ArrayList((From CommVar In m_ReadingVars
|
||||
' Where Not IsNothing(CommVar) AndAlso CommVar.nType = CommVar.Types.PLC
|
||||
' Select CommVar.sAddress).ToArray())
|
||||
Dim nPLCVarIndex As Integer = 0
|
||||
Dim PlcVariablesList As New ArrayList
|
||||
Dim sPLCVariableList = ""
|
||||
For VarIndex = 0 To m_ReadingVars.Length - 1
|
||||
Dim CommVar As CommVar = m_ReadingVars(VarIndex)
|
||||
If Not IsNothing(CommVar) AndAlso CommVar.nType = CommVar.Types.PLC AndAlso
|
||||
CommVar.Paragraph = CommVar.Paragraphs.MAIN Then
|
||||
PlcVariablesList.Add(CommVar.sAddress)
|
||||
If Not String.IsNullOrWhiteSpace(sPLCVariableList) Then
|
||||
sPLCVariableList &= ","
|
||||
End If
|
||||
sPLCVariableList &= CommVar.sAddress
|
||||
CommVar.Index = nPLCVarIndex
|
||||
nPLCVarIndex += 1
|
||||
End If
|
||||
Next
|
||||
objDReadPlcVarList.Argument = sPLCVariableList ' "%M5.L,%M5.B"
|
||||
Dim h = objDReadPlcVarList.Init(objDGroupManager.Handle)
|
||||
''Dim _FXReturn As Short = objDVariables.ReadVariables(PlcVariablesList.ToArray())
|
||||
|
||||
'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)) Then Continue For 'OrElse m_ReadingVars(Index).nType <> CommVar.Types.CN Then Continue For
|
||||
Dim rc As Short = objDReadELS.AddParameter(m_ReadingVars(Index).sAddress, Index + 1)
|
||||
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.FileDownload(10, sFileType, sFilePath, "", 1)
|
||||
|
||||
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.WriteVariables(objDGroupManager.Handle, Address, value)
|
||||
|
||||
'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)
|
||||
EgtOutLog("Part program activated:" & " " & nerrorCode)
|
||||
DbControllers.m_LogMachineController.Create(MachLog.CreateResultLog(CommandTypes.SENDPROG, CommandStates.OK, ResultTypes.EXECUTED, "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.STOP_, 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.RESET, 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 objDGroupManager_ErrorHandler(ByVal sError As String, ByVal nTextNumber As Short)
|
||||
EgtOutLog("ErrorHandler message:" & " " & sError & " " & "ErrorHandler number:" & " " & nTextNumber.ToString())
|
||||
End Sub
|
||||
|
||||
Private Sub objDGroupManager_AssignmentChanged(ByVal CncNumber As Short, ByVal AxisGroup As Short)
|
||||
m_ChannelCallbackDlg(AxisGroup)
|
||||
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
|
||||
|
||||
Friend Sub objErrorHandler_ErrorFromActiveCnc2(ErrorNumber As List(Of Integer))
|
||||
' resetto stati bFound
|
||||
For Each Message In m_ReadFXMessages
|
||||
Message.bFound = False
|
||||
Next
|
||||
|
||||
For index As Integer = 0 To ErrorNumber.Count - 1
|
||||
Dim NewMessageInList As ReadMessages = m_ReadFXMessages.FirstOrDefault(Function(x) x.CMsgCncNumber = 0.ToString() AndAlso
|
||||
x.CMsgErrorType = 6.ToString() AndAlso
|
||||
x.CMsgErrorIndex = "" AndAlso
|
||||
x.CMsgErrorNumber = ErrorNumber(index).ToString() AndAlso
|
||||
x.CMsgErrorLine = "" AndAlso
|
||||
x.CMsgErrorMessage = "")
|
||||
' se il messaggio e' gia' in lista
|
||||
If Not IsNothing(NewMessageInList) Then
|
||||
' lo segno come trovato
|
||||
NewMessageInList.bFound = True
|
||||
Else
|
||||
' lo aggiungo
|
||||
Dim NewMessage As ReadMessages = New ReadMessages(0.ToString(),
|
||||
6.ToString(),
|
||||
"",
|
||||
ErrorNumber(index).ToString(),
|
||||
"",
|
||||
"",
|
||||
"")
|
||||
NewMessage.bFound = True
|
||||
m_ReadFXMessages.Add(NewMessage)
|
||||
m_NUMAlarmCallbackDlg(0, 0, 6.ToString(), "", ErrorNumber(index).ToString(), "", "", "")
|
||||
End If
|
||||
Next
|
||||
|
||||
' cancello messaggi non trovati
|
||||
For Index = m_ReadFXMessages.Count - 1 To 0 Step -1
|
||||
Dim Message As ReadMessages = m_ReadFXMessages(Index)
|
||||
If Not Message.bFound Then
|
||||
m_NUMAlarmCallbackDlg(Message.CMsgCncNumber, 1, Message.CMsgErrorType, Message.CMsgErrorIndex, Message.CMsgErrorNumber, Message.CMsgErrorLine, Message.CMsgErrorMessage, Message.CMsgErrorAdditional)
|
||||
m_ReadFXMessages.RemoveAt(Index)
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
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())
|
||||
|
||||
For index = 0 To _ObjIndex.Length - 1
|
||||
Dim nObjIndex As Integer = Integer.Parse(_ObjIndex(index).ToString())
|
||||
Dim CommVar As CommVar = m_ReadingVars.FirstOrDefault(Function(x) Not IsNothing(x) AndAlso
|
||||
x.Paragraph = CommVar.Paragraphs.MAIN AndAlso
|
||||
x.nType = CommVar.Types.CN AndAlso
|
||||
x.Index = nObjIndex)
|
||||
If Not IsNothing(CommVar) Then
|
||||
CommVar.SetValue(_ObjValue(index).ToString())
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub objDPlcVariables_ReadPLCVariablesChanged(ByVal index As Object, ByVal value As Object)
|
||||
Dim _ObjIndex As Object() = CType(index, Object())
|
||||
Dim _ObjValue As Object() = CType(value, Object())
|
||||
|
||||
For index = 0 To _ObjIndex.Length - 1
|
||||
Dim nObjIndex As Integer = Integer.Parse(_ObjIndex(index).ToString())
|
||||
Dim CommVar As CommVar = m_ReadingVars.FirstOrDefault(Function(x) Not IsNothing(x) AndAlso
|
||||
x.Paragraph = CommVar.Paragraphs.MAIN AndAlso
|
||||
x.nType = CommVar.Types.PLC AndAlso
|
||||
x.Index = nObjIndex)
|
||||
If Not IsNothing(CommVar) Then
|
||||
CommVar.SetValue(_ObjValue(index).ToString())
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub objDPlcVariables_InvalidReadList(ByVal errorCode As Short)
|
||||
EgtOutLog("InvalidReadList - ErrorCode: " & errorCode)
|
||||
End Sub
|
||||
|
||||
Private Sub objDPlcVariables_AbortReadVariables()
|
||||
EgtOutLog("InvalidReadList - ErrorCode: ")
|
||||
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_ValueChanged(ByVal nHandle As Short, 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 - 1).SetValue(dValue.ToString("F04"))
|
||||
Catch Ex As Exception
|
||||
EgtOutLog(Ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
#End Region ' ReadELS
|
||||
|
||||
#Region "File transfer"
|
||||
|
||||
Private Sub objDFileTransfer_Completed(ByVal lHandle As Integer)
|
||||
If lHandle = 10 OrElse lHandle = 20 Then
|
||||
'resetto contatore di trasferimento
|
||||
m_BytesTransferedCounter = 0
|
||||
EgtOutLog("Up- or Download successful completed:" & " " & lHandle.ToString())
|
||||
' aggiorno variabili del MAIN
|
||||
Dim ISONumVariable As Variable = Map.refMachCommandMessagePanelVM.MainVariablesList.FirstOrDefault(Function(x) x.sName = ISO_NUM)
|
||||
Dim ISOSentVariable As Variable = Map.refMachCommandMessagePanelVM.MainVariablesList.FirstOrDefault(Function(x) x.sName = ISO_SENT)
|
||||
Dim SentMachGroup As MyMachGroupVM = Map.refSupervisorMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x As MyMachGroupVM) x.bSendingToMachine)
|
||||
If Not IsNothing(SentMachGroup) Then
|
||||
ISONumVariable.sValue = SentMachGroup.Name
|
||||
ISOSentVariable.sValue = 0
|
||||
SentMachGroup.SetSentToMachine(True)
|
||||
End If
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
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
|
||||
Map.refMDIPageVM.SendMDIResult(retVal)
|
||||
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
|
||||
|
||||
For index As Integer = 0 To AplArrayIndex.Length - 1
|
||||
Dim nHandle As Integer = CType(AplArrayIndex.GetValue(index), Int16)
|
||||
If nHandle < 1 OrElse nHandle > m_ReadingVars.Count - 1 Then Return
|
||||
Dim dValue As Double = CDbl(AplArrayValue.GetValue(index))
|
||||
Try
|
||||
m_ReadingVars(nHandle - 1).SetValue(dValue.ToString("F04"))
|
||||
Catch Ex As Exception
|
||||
EgtOutLog(Ex.Message)
|
||||
End Try
|
||||
Next
|
||||
End Sub
|
||||
|
||||
#End Region ' Variables
|
||||
|
||||
#Region "CNCMode"
|
||||
|
||||
Private Sub objDCncMode_ValueChanged(ByVal mode As Short, ByVal preselected As Short)
|
||||
m_OpModeCallbackDlg(mode)
|
||||
End Sub
|
||||
|
||||
#End Region ' CNCMode
|
||||
|
||||
#Region "ReadOperatorMessage"
|
||||
|
||||
Private Sub objDReadOperatorMessage_ValueChanged(ByVal line As Object)
|
||||
' resetto stati bFound
|
||||
For Each Message In m_ReadOperatorMessages
|
||||
Message.bFound = False
|
||||
Next
|
||||
Dim objLine As String = TryCast(line, String)
|
||||
Dim OpMsgErrType As Integer = 30
|
||||
Dim NewMessageInList As ReadMessages = m_ReadOperatorMessages.FirstOrDefault(Function(x) x.CMsgCncNumber = 0 AndAlso
|
||||
x.CMsgErrorType = OpMsgErrType.ToString() AndAlso
|
||||
x.CMsgErrorIndex = "" AndAlso
|
||||
x.CMsgErrorNumber = "" AndAlso
|
||||
x.CMsgErrorLine = "" AndAlso
|
||||
x.CMsgErrorMessage = objLine AndAlso
|
||||
x.CMsgErrorAdditional = "")
|
||||
' se il messaggio e' gia' in lista
|
||||
If Not IsNothing(NewMessageInList) Then
|
||||
' lo segno come trovato
|
||||
NewMessageInList.bFound = True
|
||||
Else
|
||||
' se e' diverso da stringa vuota
|
||||
If Not String.IsNullOrWhiteSpace(objLine.ToString()) Then
|
||||
' lo aggiungo
|
||||
Dim NewMessage As ReadMessages = New ReadMessages(0,
|
||||
OpMsgErrType.ToString(),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
objLine,
|
||||
"")
|
||||
NewMessage.bFound = True
|
||||
m_ReadOperatorMessages.Add(NewMessage)
|
||||
m_NUMAlarmCallbackDlg(0, 0, OpMsgErrType.ToString(), "", "", "", objLine, "")
|
||||
End If
|
||||
End If
|
||||
|
||||
' cancello messaggi non trovati
|
||||
If m_ReadOperatorMessages.Count > 0 Then
|
||||
For Index = m_ReadOperatorMessages.Count - 1 To 0 Step -1
|
||||
Dim Message As ReadMessages = m_ReadOperatorMessages(Index)
|
||||
If Not Message.bFound Then
|
||||
m_NUMAlarmCallbackDlg(Message.CMsgCncNumber, 1, Message.CMsgErrorType, Message.CMsgErrorIndex, Message.CMsgErrorNumber, Message.CMsgErrorLine, Message.CMsgErrorMessage, Message.CMsgErrorAdditional)
|
||||
m_ReadOperatorMessages.RemoveAt(Index)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region ' ReadOperatorMessage
|
||||
|
||||
#End Region ' EVENTS
|
||||
|
||||
End Class
|
||||
@@ -17,6 +17,7 @@ Module ConstCommVar
|
||||
NULL = 0
|
||||
TPA = 1
|
||||
NUM_FLEXIUM = 2
|
||||
NUM_AXIUM = 3
|
||||
End Enum
|
||||
|
||||
' Assi
|
||||
@@ -44,6 +45,8 @@ Module ConstCommVar
|
||||
Public Const RUNNING As String = "Running"
|
||||
' indice della lavorazione in corso (pareti NUM)
|
||||
Public Const MACHINDEX As String = "MachIndex"
|
||||
' variabile per lettura errori PLC bit a bit
|
||||
Public Const PLC_MESSAGES As String = "PLC_Messages"
|
||||
|
||||
Public Enum OPStates
|
||||
Start = 1
|
||||
|
||||
@@ -100,6 +100,14 @@
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="APLog">
|
||||
<HintPath>..\ExtLibs\APLog.dll</HintPath>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="APServer">
|
||||
<HintPath>..\ExtLibs\APServer.dll</HintPath>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="BouncyCastle.Crypto, Version=1.8.2.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Portable.BouncyCastle.1.8.2\lib\net40\BouncyCastle.Crypto.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -236,6 +244,7 @@
|
||||
<DependentUpon>CalcPanelV.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CALCPanel\CALCPanelVM.vb" />
|
||||
<Compile Include="Comms\NUMAxiumComm.vb" />
|
||||
<Compile Include="Comms\NUMFlexiumComm.vb" />
|
||||
<Compile Include="Comms\TPAComm.vb" />
|
||||
<Compile Include="Constants\ConstMachMsg.vb" />
|
||||
|
||||
@@ -229,7 +229,7 @@ Public Class LeftPanelVM
|
||||
|
||||
Public ReadOnly Property OPMode_Visibility As Visibility
|
||||
Get
|
||||
Return If(CurrentMachine.NCType = NCTypes.NUM_FLEXIUM, Visibility.Visible, Visibility.Collapsed)
|
||||
Return If(CurrentMachine.NCType = NCTypes.NUM_FLEXIUM Or CurrentMachine.NCType = NCTypes.NUM_AXIUM, Visibility.Visible, Visibility.Collapsed)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
@@ -341,7 +341,7 @@ Public Class LeftPanelVM
|
||||
' carico stati della macchina
|
||||
Select Case NCType
|
||||
Case NCTypes.TPA
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
m_ChannelList = New List(Of IdNameStruct)
|
||||
Dim ChannelIndex As Integer = 1
|
||||
Dim ChannelString As String = ""
|
||||
@@ -390,7 +390,7 @@ Public Class LeftPanelVM
|
||||
New OPState("Pending", OPStates.Pending),
|
||||
New OPState("Unspecified", OPStates.Unspecified)
|
||||
}
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
m_OPStateList = New List(Of OPState) From {
|
||||
New OPState("Start", OPStates.Start),
|
||||
New OPState("Stop", OPStates.Stop),
|
||||
@@ -410,7 +410,7 @@ Public Class LeftPanelVM
|
||||
m_OPModeList = New List(Of OPState) From {
|
||||
New OPState("Manual", OPModes.Manual)
|
||||
}
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
m_OPModeList = New List(Of OPState) From {
|
||||
New OPState("Auto", OPModes.Auto),
|
||||
New OPState("Single", OPModes.Single),
|
||||
|
||||
@@ -4,6 +4,7 @@ Imports System.Windows.Threading
|
||||
Imports EgtBEAMWALL.Core.ConstMachComm
|
||||
Imports EgtBEAMWALL.Core
|
||||
Imports EgtWPFLib5
|
||||
Imports EgtUILib
|
||||
|
||||
Public Class MachCommandMessagePanelVM
|
||||
Inherits VMBase
|
||||
@@ -152,7 +153,7 @@ Public Class MachCommandMessagePanelVM
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Return If(Not IsNothing(ShownErr), ShownErr.sCode & ": " & ShownErr.sMessage, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
Return If(Not IsNothing(ShownErr), ShownErr.sMessage, "")
|
||||
Case Else
|
||||
Return ""
|
||||
@@ -174,7 +175,7 @@ Public Class MachCommandMessagePanelVM
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Return If(Not IsNothing(ShownErr), ShownErr.sCode & ": " & ShownErr.sMessage, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
Return If(Not IsNothing(ShownErr), ShownErr.sMessage, "")
|
||||
Case Else
|
||||
Return ""
|
||||
@@ -196,7 +197,7 @@ Public Class MachCommandMessagePanelVM
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Return If(Not IsNothing(ShownErr), ShownErr.sCode & ": " & ShownErr.sMessage, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
Return If(Not IsNothing(ShownErr), ShownErr.sMessage, "")
|
||||
Case Else
|
||||
Return ""
|
||||
@@ -218,7 +219,7 @@ Public Class MachCommandMessagePanelVM
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Return If(Not IsNothing(ShownErr), ShownErr.sCode & ": " & ShownErr.sMessage, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
Return If(Not IsNothing(ShownErr), ShownErr.sMessage, "")
|
||||
Case Else
|
||||
Return ""
|
||||
@@ -525,6 +526,9 @@ Public Class MachCommandMessagePanelVM
|
||||
MachineCommThread.StartTick()
|
||||
' inizializzo variabili
|
||||
Init()
|
||||
If CurrentMachine.NCType = NCTypes.NUM_AXIUM Then
|
||||
Map.refMachManaging.Num_Axium.GetGeneralFunctions()
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Case CommandTypes.DISCONNECT
|
||||
@@ -752,7 +756,7 @@ Public Class MachCommandMessagePanelVM
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
m_ErrSystem.RemoveAll(Function(x) x.sCode = AlarmCode)
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
m_ErrSystem.RemoveAll(Function(x) x.sMessage = AlarmMessage)
|
||||
End Select
|
||||
End If
|
||||
@@ -785,7 +789,7 @@ Public Class MachCommandMessagePanelVM
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
Map.refLeftPanelVM.SetOPState(NewState)
|
||||
End Select
|
||||
DbControllers.m_LogMachineController.Create(MachLog.CreateOPStateLog(newOpState))
|
||||
@@ -793,8 +797,12 @@ Public Class MachCommandMessagePanelVM
|
||||
|
||||
Friend Sub OpModeCallbackDlg(newOpState As Integer)
|
||||
Dim NewState As OPState = Map.refLeftPanelVM.OPModeList.FirstOrDefault(Function(x) x.Id = newOpState)
|
||||
If IsNothing(NewState) Then
|
||||
EgtOutLog("Machine state not recognized, state " & newOpState)
|
||||
Return
|
||||
End If
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
Map.refLeftPanelVM.SetOPMode(NewState)
|
||||
End Select
|
||||
DbControllers.m_LogMachineController.Create(MachLog.CreateOPStateLog(newOpState))
|
||||
@@ -803,7 +811,7 @@ Public Class MachCommandMessagePanelVM
|
||||
Friend Sub ChannelCallbackDlg(NewChannelId As Short)
|
||||
Dim NewChannel As IdNameStruct = Map.refLeftPanelVM.ChannelList.FirstOrDefault(Function(x) x.Id = NewChannelId)
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
Map.refLeftPanelVM.SetChannel(NewChannel)
|
||||
End Select
|
||||
'DbControllers.m_LogMachineController.Create(MachLog.CreateOPStateLog(NewChannelId))
|
||||
|
||||
@@ -36,6 +36,11 @@ Public Class MachManaging
|
||||
Return m_CN
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property Num_Axium As NUMAxiumComm
|
||||
Get
|
||||
Return m_CN
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private Shared WithEvents m_CommandList As New ObservableCollection(Of ThreadCommand)
|
||||
Public Shared ReadOnly Property CommandList As ObservableCollection(Of ThreadCommand)
|
||||
@@ -212,7 +217,7 @@ Public Class MachManaging
|
||||
' Threading.Thread.Sleep(300)
|
||||
' End If
|
||||
' End If
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.TPA
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.TPA, NCTypes.NUM_AXIUM
|
||||
' eseguo ciclo principale
|
||||
Dim nReset_State As Integer
|
||||
Dim nStart_State As Boolean
|
||||
@@ -272,6 +277,83 @@ Public Class MachManaging
|
||||
If nCurrMachIndex > 0 AndAlso nReset_State = 0 Then
|
||||
m_nMachIndex = nCurrMachIndex
|
||||
End If
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Dim dTemp As Double = 0
|
||||
Dim nTemp As Integer = 0
|
||||
If Not IsNothing(ResetVariable.sValue) Then
|
||||
StringToDouble(ResetVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nReset_State)
|
||||
Else
|
||||
nReset_State = 1
|
||||
End If
|
||||
If Not IsNothing(StartVariable.sValue) Then
|
||||
StringToDouble(StartVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nTemp)
|
||||
nStart_State = (nTemp = 1)
|
||||
Else
|
||||
nStart_State = -1
|
||||
End If
|
||||
If Not IsNothing(StopVariable.sValue) Then
|
||||
StringToDouble(StopVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nTemp)
|
||||
nStop_State = (nTemp = 1)
|
||||
Else
|
||||
nStop_State = -1
|
||||
End If
|
||||
If Not IsNothing(ProdVariable.sValue) Then
|
||||
StringToDouble(ProdVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nP_Prod)
|
||||
Else
|
||||
nP_Prod = -1
|
||||
End If
|
||||
If Not IsNothing(MachGroupVariable.sValue) Then
|
||||
StringToDouble(MachGroupVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nP_Machgroup)
|
||||
Else
|
||||
nP_Machgroup = -1
|
||||
End If
|
||||
If Not IsNothing(PartVariable.sValue) Then
|
||||
StringToDouble(PartVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nP_Part)
|
||||
Else
|
||||
nP_Part = -1
|
||||
End If
|
||||
If Not IsNothing(StateVariable.sValue) Then
|
||||
StringToDouble(StateVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nP_State)
|
||||
Else
|
||||
nP_State = -1
|
||||
End If
|
||||
If Not IsNothing(ISONumVariable.sValue) Then
|
||||
StringToDouble(ISONumVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nISO_Num)
|
||||
Else
|
||||
nISO_Num = -1
|
||||
End If
|
||||
If Not IsNothing(ISOSentVariable.sValue) Then
|
||||
StringToDouble(ISOSentVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nISO_Sent)
|
||||
Else
|
||||
nISO_Sent = -1
|
||||
End If
|
||||
If Not IsNothing(RunningVariable.sValue) Then
|
||||
StringToDouble(RunningVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nRunning)
|
||||
Else
|
||||
nRunning = -1
|
||||
End If
|
||||
If Not IsNothing(MachIndexVariable.sValue) Then
|
||||
StringToDouble(MachIndexVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nCurrMachIndex)
|
||||
Else
|
||||
nCurrMachIndex = -1
|
||||
End If
|
||||
' se indice lavorazione positivo, lo aggiorno
|
||||
If nCurrMachIndex > 0 AndAlso nReset_State = 0 Then
|
||||
m_nMachIndex = nCurrMachIndex
|
||||
End If
|
||||
' leggo messaggi plc
|
||||
ReadPLCMessages()
|
||||
End Select
|
||||
' se NUM aggiorno stato della macchina
|
||||
If CurrentMachine.NCType = NCTypes.NUM_FLEXIUM Then
|
||||
@@ -286,14 +368,31 @@ Public Class MachManaging
|
||||
If OpState <> Map.refLeftPanelVM.SelOPState.Id Then
|
||||
m_OpStateCallbackDlg(OpState)
|
||||
End If
|
||||
ElseIf CurrentMachine.NCType = NCTypes.NUM_AXIUM Then
|
||||
Dim OpState As OPStates
|
||||
If nReset_State = 1 Then
|
||||
OpState = OPStates.End
|
||||
ElseIf nStop_State Then
|
||||
OpState = OPStates.Stop
|
||||
ElseIf nStart_State Then
|
||||
OpState = OPStates.Start
|
||||
Else
|
||||
OpState = OPStates.End
|
||||
End If
|
||||
If OpState <> Map.refLeftPanelVM.SelOPState.Id Then
|
||||
m_OpStateCallbackDlg(OpState)
|
||||
End If
|
||||
End If
|
||||
' se TPA e non ancora fatto, preparo variabili barra successiva
|
||||
If CurrentMachine.NCType = NCTypes.TPA AndAlso CurrentMachine.Flow = FlowTypes.CONTINUOUS AndAlso m_NextBarId = 0 Then
|
||||
SetNextBarVars()
|
||||
' se macchina NUM, non sto gia' spedendo e variabile spedizione me lo permette
|
||||
ElseIf CurrentMachine.NCType = NCTypes.NUM_FLEXIUM AndAlso
|
||||
ElseIf (CurrentMachine.NCType = NCTypes.NUM_FLEXIUM AndAlso
|
||||
Not Num_Flexium.bIsTransferActive AndAlso
|
||||
nISO_Sent = 1 Then
|
||||
nISO_Sent = 1) OrElse
|
||||
(CurrentMachine.NCType = NCTypes.NUM_AXIUM AndAlso
|
||||
Not Num_Axium.bIsTransferActive AndAlso
|
||||
nISO_Sent = 1) Then
|
||||
' verifico se c'e' un programma da lanciare
|
||||
SendNextProgram()
|
||||
End If
|
||||
@@ -372,7 +471,7 @@ Public Class MachManaging
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
Tpa.RWVariableManager.WriteVarByName(P_STATE, 0)
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
StateVariable.sValue = "0"
|
||||
End Select
|
||||
' se nessun pezzo della barra diverso da quello corrente e' in start
|
||||
@@ -523,7 +622,8 @@ Public Class MachManaging
|
||||
Private Function SendNextProgram() As Boolean
|
||||
Dim bSent As Boolean = False
|
||||
If (CurrentMachine.NCType = NCTypes.TPA AndAlso Not m_bStartPending AndAlso Tpa.opState = MachineOperatingState.Pending) OrElse
|
||||
(CurrentMachine.NCType = NCTypes.NUM_FLEXIUM AndAlso Not Num_Flexium.bIsTransferActive) Then ' Or Tpa.opState = MachineOperatingState.Start) Then
|
||||
(CurrentMachine.NCType = NCTypes.NUM_FLEXIUM AndAlso Not Num_Flexium.bIsTransferActive) OrElse
|
||||
(CurrentMachine.NCType = NCTypes.NUM_AXIUM AndAlso Not Num_Axium.bIsTransferActive) Then ' Or Tpa.opState = MachineOperatingState.Start) Then
|
||||
' verifico se c'e' un programma da lanciare
|
||||
If Not IsNothing(Map.refProjectVM.SupervisorMachGroupPanelVM) Then
|
||||
EgtOutLog("Start " & DateTime.Now())
|
||||
@@ -532,14 +632,14 @@ Public Class MachManaging
|
||||
If Not MyMachGroup.bSentToMachine AndAlso (MyMachGroup.dtStartTime = DateTime.MinValue OrElse
|
||||
(Map.refSupervisorManagerVM.CurrProd.nType = BWType.WALL AndAlso MyMachGroup.bResetWhileCutting)) Then
|
||||
' verifico se ricalcolo finito
|
||||
If MyMachGroup.bReadyForMachining AndAlso If(CurrentMachine.NCType = NCTypes.NUM_FLEXIUM, Not MyMachGroup.bSendingToMachine, True) Then
|
||||
If MyMachGroup.bReadyForMachining AndAlso If(CurrentMachine.NCType = NCTypes.NUM_FLEXIUM Or CurrentMachine.NCType = NCTypes.NUM_AXIUM, Not MyMachGroup.bSendingToMachine, True) Then
|
||||
' lo lancio
|
||||
bSent = SendProgram(MyMachGroup.CnFilePath(), MyMachGroup.Name)
|
||||
EgtOutLog("Mandato " & DateTime.Now() & " " & MyMachGroup.Name & " " & bSent.ToString())
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
MyMachGroup.SetSentToMachine(bSent)
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Case NCTypes.NUM_FLEXIUM, NCTypes.NUM_AXIUM
|
||||
MyMachGroup.SetSendingToMachine(bSent)
|
||||
End Select
|
||||
m_NextBarId = 0
|
||||
@@ -603,9 +703,9 @@ Public Class MachManaging
|
||||
Num_Flexium.CloseReadList()
|
||||
Num_Flexium.CloseReadELS()
|
||||
Case CommandTypes.MDI
|
||||
Num_Flexium.MDI_Execute(Command.sVariable)
|
||||
SendMDI(Command.sVariable)
|
||||
Case CommandTypes.SETCHANNEL
|
||||
Num_Flexium.SetChannel(Command.nVariable)
|
||||
SetChannel(Command.nVariable)
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
@@ -634,6 +734,16 @@ Public Class MachManaging
|
||||
m_ResultCallbackDlg(CommandTypes.CONNECT, CommandStates.ERROR_, ResultTypes.EXECUTED, "Errore: impossibile connettersi!")
|
||||
Return
|
||||
End Try
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Try
|
||||
m_CN = New NUMAxiumComm(Me)
|
||||
Num_Axium.InitFxObjects()
|
||||
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
|
||||
|
||||
@@ -652,6 +762,13 @@ Public Class MachManaging
|
||||
' chiudo classe Num_Flexium
|
||||
Me.OnDispose()
|
||||
'Num_Flexium.OnDispose()
|
||||
Case NCTypes.NUM_AXIUM
|
||||
m_bConnected = False
|
||||
Num_Axium.CloseFxObjects()
|
||||
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()
|
||||
@@ -661,6 +778,8 @@ Public Class MachManaging
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.SetMode(CNMode)
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Num_Axium.SetMode(CNMode)
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
@@ -700,6 +819,8 @@ Public Class MachManaging
|
||||
m_ResultCallbackDlg(CommandTypes.START, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.Start()
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Num_Axium.Start()
|
||||
End Select
|
||||
' aggiorno stato bottoni in LeftPanel
|
||||
Map.refLeftPanelVM.UpdateButtonIsEnabledState()
|
||||
@@ -712,6 +833,8 @@ Public Class MachManaging
|
||||
m_ResultCallbackDlg(CommandTypes.STOP_, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.Stop_()
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Num_Axium.Stop_()
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
@@ -722,6 +845,8 @@ Public Class MachManaging
|
||||
m_ResultCallbackDlg(CommandTypes.RESET, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.Reset()
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Num_Axium.Reset()
|
||||
End Select
|
||||
' aggiorno stato bottoni in LeftPanel
|
||||
Map.refLeftPanelVM.UpdateButtonIsEnabledState()
|
||||
@@ -744,6 +869,8 @@ Public Class MachManaging
|
||||
m_ResultCallbackDlg(CommandTypes.SETPOINT, If(bOk, CommandStates.OK, CommandStates.ERROR_), ResultTypes.EXECUTED, "")
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Map.refLeftPanelVM.SelOPMode = Map.refLeftPanelVM.OPModeList.Find(Function(x) x.Id = OPModes.Home)
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Map.refLeftPanelVM.SelOPMode = Map.refLeftPanelVM.OPModeList.Find(Function(x) x.Id = OPModes.Home)
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
@@ -766,6 +893,11 @@ Public Class MachManaging
|
||||
Num_Flexium.FileDownload(sFileType, ProgramPath)
|
||||
Num_Flexium.StartTransfer()
|
||||
Return True
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Dim sFileType As String = "%" & ProgramId.ToString()
|
||||
Num_Axium.FileDownload(sFileType, ProgramPath)
|
||||
Num_Axium.StartTransfer()
|
||||
Return True
|
||||
End Select
|
||||
End Function
|
||||
|
||||
@@ -786,6 +918,9 @@ Public Class MachManaging
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.FileDelete(ProgramType, ProgramPath)
|
||||
Num_Flexium.StartTransfer()
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Num_Axium.FileDelete(ProgramType, ProgramPath)
|
||||
Num_Axium.StartTransfer()
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
@@ -805,6 +940,24 @@ Public Class MachManaging
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub SetChannel(value As Integer)
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.SetChannel(value)
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Num_Axium.SetChannel(value)
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub SendMDI(value As String)
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Num_Flexium.MDI_Execute(value)
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Num_Axium.MDI_Execute(value)
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub WriteVar(Address As String, Value As String, Type As CommVar.Types)
|
||||
Select Case CurrentMachine.NCType
|
||||
Case NCTypes.TPA
|
||||
@@ -816,6 +969,13 @@ Public Class MachManaging
|
||||
Case CommVar.Types.CN
|
||||
Num_Flexium.WriteNCVariables(Address, Value)
|
||||
End Select
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Select Case Type
|
||||
Case CommVar.Types.PLC
|
||||
Num_Axium.WritePlcVariables(Address, Value)
|
||||
Case CommVar.Types.CN
|
||||
Num_Axium.WriteNCVariables(Address, Value)
|
||||
End Select
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
@@ -827,6 +987,8 @@ Public Class MachManaging
|
||||
Return RWVariableManager.InitVar(NewVar)
|
||||
Case NCTypes.NUM_FLEXIUM
|
||||
Return NUMFlexiumComm.InitVar(NewVar)
|
||||
Case NCTypes.NUM_AXIUM
|
||||
Return NUMAxiumComm.InitVar(NewVar)
|
||||
End Select
|
||||
End Function
|
||||
|
||||
@@ -869,4 +1031,30 @@ Public Class MachManaging
|
||||
Return New CommVar(sVariableValues(0), sVariableValues(1), ReadType, Type, Paragraph)
|
||||
End Function
|
||||
|
||||
Private Sub ReadPLCMessages()
|
||||
Dim nPlc_Msg(5) As Integer
|
||||
For Index As Integer = 1 To 6
|
||||
Dim nIndex As Integer = Index
|
||||
Dim PLCMessagesVariable As Variable = Map.refMachCommandMessagePanelVM.MainVariablesList.FirstOrDefault(Function(x) x.sName = PLC_MESSAGES & nIndex)
|
||||
If IsNothing(PLCMessagesVariable) OrElse IsNothing(PLCMessagesVariable.sValue) Then Return
|
||||
Dim dTemp As Double = 0
|
||||
Dim nTemp As Integer = 0
|
||||
StringToDouble(PLCMessagesVariable.sValue, dTemp)
|
||||
Integer.TryParse(dTemp, nTemp)
|
||||
Dim Bytes As Byte() = BitConverter.GetBytes(nTemp)
|
||||
Dim NewBytes As Byte() = BitConverter.GetBytes(nTemp)
|
||||
For nBIndex = Bytes.Count - 1 To 0 Step -1
|
||||
NewBytes(Bytes.Count - 1 - nBIndex) = Bytes(nBIndex)
|
||||
Next
|
||||
Dim Res = BitConverter.ToInt32(NewBytes, 0)
|
||||
nPlc_Msg(nIndex - 1) = Res
|
||||
Next
|
||||
Dim BitArray As New BitArray(nPlc_Msg)
|
||||
Dim ErrorList As New List(Of Integer)
|
||||
For BitIndex = 0 To BitArray.Count - 1
|
||||
If BitIndex <= 169 AndAlso BitArray(BitIndex) Then ErrorList.Add(BitIndex)
|
||||
Next
|
||||
Num_Axium.objErrorHandler_ErrorFromActiveCnc2(ErrorList)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
@@ -131,13 +131,24 @@ Public Class MainWindowVM
|
||||
Map.refLeftPanelVM.NotifyPropertyChanged(NameOf(Map.refLeftPanelVM.FeatureList_Visibility))
|
||||
|
||||
' inizializzo thread di aggiornamento e comunicazione con DB
|
||||
' creo thread gestione macchina
|
||||
' creo thread di comunicazione con ViewOptim
|
||||
m_ViewerOptimizerCommThread = New Thread(Sub()
|
||||
ViewerOptimizerCommThread.ViewerOptimizerCommThreadFunction()
|
||||
End Sub)
|
||||
m_ViewerOptimizerCommThread.SetApartmentState(ApartmentState.STA)
|
||||
' avvio thread di gestione della macchina che avvia la connessione
|
||||
' avvio thread di gestione comunicazione con ViewOptim
|
||||
m_ViewerOptimizerCommThread.Start()
|
||||
' se controllo axium, chiudo eventuale server di comunicazione rimasto aperto
|
||||
If CurrentMachine.NCType = NCTypes.NUM_AXIUM Then
|
||||
Dim ServerProcList As Process() = Process.GetProcessesByName("APServer")
|
||||
Dim LogProcList As Process() = Process.GetProcessesByName("APLog")
|
||||
For Each ServerProc In ServerProcList
|
||||
ServerProc.Kill()
|
||||
Next
|
||||
For Each LogProc In LogProcList
|
||||
LogProc.Kill()
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Friend Function ProcessCommandLine(ByRef nCommandType As Integer, ByRef nProdId As Integer) As Boolean
|
||||
|
||||
@@ -3,6 +3,7 @@ Imports EgtUILib
|
||||
Imports EgtWPFLib5
|
||||
Imports EgtBEAMWALL.Core
|
||||
Imports System.IO
|
||||
Imports System.Text.RegularExpressions
|
||||
|
||||
Public Module CurrentMachine
|
||||
|
||||
@@ -199,6 +200,24 @@ Public Module CurrentMachine
|
||||
' aggiorno parametro in gestore viste
|
||||
Core.ViewPanelVM.UpdateMachParam(m_nViewDir)
|
||||
End If
|
||||
' se axium
|
||||
If NCType = NCTypes.NUM_AXIUM Then
|
||||
' verifico se il file messaggi macchina è da aggiornare
|
||||
Dim sFromMachine As String = sMachinesRootDir & "\" & sMachineName & "\Messages\" & "FromMachine_" & sMsgName
|
||||
If File.Exists(sFromMachine) Then
|
||||
' se file messaggi macchina piu' nuovo
|
||||
If File.GetLastWriteTime(sFromMachine) > File.GetLastWriteTime(m_sMachMessagesFile) Then
|
||||
' aggiorno il file
|
||||
Dim FromMachineLines() As String = File.ReadAllLines(sFromMachine)
|
||||
For Each sLine In FromMachineLines
|
||||
Dim Value As Match = Regex.Match(sLine, "N(\d*)\s*\$\d*:(.*)$")
|
||||
If Not IsNothing(Value) AndAlso Value.Groups.Count >= 2 AndAlso Not IsNothing(Value.Groups(0)) AndAlso Not IsNothing(Value.Groups(1)) Then
|
||||
WritePrivateProfileString("PLC", Value.Groups(1).Value, Value.Groups(2).Value, m_sMachMessagesFile)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
' inizializzo stati e modi
|
||||
Map.refLeftPanelVM.LoadChannels()
|
||||
Map.refLeftPanelVM.LoadOPStates()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user