1199 lines
56 KiB
VB.net
1199 lines
56 KiB
VB.net
Imports CMSCncLib.Config.Settings
|
|
|
|
Namespace CNC
|
|
|
|
Public Class OSAI_OPEN
|
|
Inherits OSAI
|
|
|
|
'Variabili per Web Service OPENcontrol
|
|
Protected _szIpAddress As String
|
|
Friend OPENws As OPENcontrol.OPENcontrolPortTypeClient
|
|
Private nReturn As Short
|
|
|
|
Protected Const MAXRET = 3
|
|
|
|
Public Enum O_Table
|
|
TOOL_TABLE_ID = 1
|
|
OFFSET_TABLE_ID = 2
|
|
ORIGIN_TABLE_ID = 3
|
|
USER_TABLE_ID = 4
|
|
End Enum
|
|
|
|
Public Overrides Property Licenza() As Integer
|
|
Get
|
|
Dim uiLicence(0) As UInteger
|
|
'leggo dal cn il valore
|
|
Me.O_RW_DWord(R, MemTypeWord.GW_CODE, 303, uiLicence)
|
|
Return UnsignedToInteger(uiLicence(0))
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
'setto sul cn il valore
|
|
Dim uiLicence(0) As UInteger
|
|
uiLicence(0) = IntegerToUnsigned(value)
|
|
Me.O_RW_DWord(W, MemTypeWord.GW_CODE, 303, uiLicence)
|
|
End Set
|
|
End Property
|
|
|
|
Public Overrides Property LicenzaScaduta() As Boolean
|
|
Get
|
|
Dim bLicenzaScaduta As Boolean
|
|
'leggo dal cn il valore
|
|
Me.O_RW_Boolean(R, MemTypeWord.GW_CODE, 302, 0, bLicenzaScaduta)
|
|
Return bLicenzaScaduta
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
'setto sul cn il valore
|
|
Me.O_RW_Boolean(W, MemTypeWord.GW_CODE, 302, 0, value)
|
|
End Set
|
|
End Property
|
|
|
|
Public Sub New(ByRef szIpAddress As String)
|
|
_Type = NcType.OSAI
|
|
_szIpAddress = szIpAddress
|
|
|
|
Dim conf As String = "OPENcontrol"
|
|
Dim url As String = "http://" & szIpAddress & ":8080"
|
|
|
|
Try
|
|
OPENws = New OPENcontrol.OPENcontrolPortTypeClient(conf, url)
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
End Try
|
|
|
|
|
|
'Inizializzo le variabili
|
|
Me._Descrizione = "NC OSAI OPENcontrol" & vbNewLine
|
|
Me._Descrizione = Me._Descrizione & "IpAddress: " & _szIpAddress
|
|
End Sub
|
|
|
|
Public Overrides Sub Connect(Optional ByRef szStatus As String = "")
|
|
Dim BootPhaseEnquiryR As New OPENcontrol.BootPhaseEnquiryR
|
|
Dim BootPhaseEnquiry As OPENcontrol.BootPhaseEnquiry
|
|
Dim szReturn As String = ""
|
|
Dim usValue(0) As UShort
|
|
Dim TimeStart As Date
|
|
|
|
BootPhaseEnquiry = New OPENcontrol.BootPhaseEnquiry()
|
|
|
|
'leggo in che fase di boot mi trovo
|
|
Try
|
|
BootPhaseEnquiryR = OPENws.BootPhaseEnquiry(BootPhaseEnquiry)
|
|
Catch ex As System.ServiceModel.EndpointNotFoundException
|
|
_bConnected = False
|
|
Throw New CmsNcException(ex.Message)
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
_bConnected = False
|
|
Throw New CmsNcException(ex.Message)
|
|
End Try
|
|
|
|
If O_CheckRetError(BootPhaseEnquiryR.retval, BootPhaseEnquiryR.ErrClass, BootPhaseEnquiryR.ErrNum, String.Format("BootPhaseEnquiry({0}) Connect CNC.OSAI_OPEN", BootPhaseEnquiry), szReturn) Then
|
|
_bConnected = False
|
|
Throw New CmsNcException(szReturn)
|
|
Else
|
|
'verifico che il sistema si trovi in una fase operativa "stabile"
|
|
If BootPhaseEnquiryR.Phase = 4 Then 'SYSTEM_UP_PHASE
|
|
|
|
'leggo matricola e verifico che sia diversa da zero
|
|
TimeStart = Now
|
|
Do
|
|
|
|
nReturn = O_RW_Word(R, MemTypeWord.MW_CODE, 3403, usValue)
|
|
|
|
If usValue(0) > 0 Then
|
|
Threading.Thread.Sleep(500)
|
|
Exit Do
|
|
End If
|
|
|
|
If (Now - TimeStart).Seconds > 30 Then
|
|
Select Case MsgBox("Matricola non inizializzata in 30 secondi: Verificare inizializzazione PLC", MsgBoxStyle.Exclamation + MsgBoxStyle.RetryCancel)
|
|
Case MsgBoxResult.Retry : TimeStart = Now
|
|
Case MsgBoxResult.Cancel : Exit Do
|
|
End Select
|
|
End If
|
|
Threading.Thread.Sleep(500) 'aspetto 500ms prima di ritentare
|
|
Loop
|
|
|
|
_bConnected = True
|
|
Else
|
|
_bConnected = False
|
|
Throw New CmsNcException("ERR BootPhase NOT OK CNC.OSAI_OPEN")
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Overrides Sub Disconnect(Optional ByRef szStatus As String = "")
|
|
_bConnected = False
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Legge le memorie di configurazione dal cn
|
|
''' </summary>
|
|
Public Overrides Sub GetStaticData()
|
|
Dim nValue(0) As Integer
|
|
Dim sValue(0) As Short
|
|
Dim ucValue(0) As Byte
|
|
|
|
If Not bStaticDataReaded Then
|
|
Try
|
|
Select Case Settings.MemoryMapping
|
|
Case MemoryMapping.ElsManager
|
|
|
|
Case MemoryMapping.Default,
|
|
MemoryMapping.ToolManager,
|
|
MemoryMapping.ToolTable
|
|
|
|
'Matricola
|
|
nReturn = O_RW_Short(R, MemTypeWord.MW_CODE, 3403, sValue)
|
|
Me._Matricola = sValue(0)
|
|
'Teste
|
|
nReturn = O_RW_Short(R, MemTypeWord.MW_CODE, 3405, sValue)
|
|
Me._Teste = sValue(0)
|
|
'Magazzini
|
|
nReturn = O_RW_Short(R, MemTypeWord.MW_CODE, 3407, sValue)
|
|
Me._Magazzini = sValue(0)
|
|
'Manine per Magazzino
|
|
ReDim Me._ManineMagazzino(Me._Magazzini - 1)
|
|
ReDim ucValue(19)
|
|
nReturn = O_RW_Byte(R, MemTypeWord.MW_CODE, 2900, LOW_ORDER, ucValue)
|
|
Array.Copy(ucValue, Me._ManineMagazzino, Me._ManineMagazzino.Length)
|
|
ReDim ucValue(0)
|
|
|
|
'Magazzini Con Attrezzaggio Automatico (maschera)
|
|
O_RW_Integer(R, MemTypeWord.MW_CODE, 4060, nValue)
|
|
Me._MagazziniConAttrezzaggioAutomatico = nValue(0)
|
|
End Select
|
|
|
|
Me._MaxUtensiliGestibili = 300 'TODO IMPLEMENTARE
|
|
Me._MaxIdUtensile = 300 'TODO IMPLEMENTARE
|
|
|
|
Select Case Settings.MemoryMapping
|
|
Case MemoryMapping.ElsManager
|
|
Case MemoryMapping.ToolManager
|
|
Case MemoryMapping.Default,
|
|
MemoryMapping.ToolTable
|
|
'ZoomSpeed
|
|
nReturn = O_RW_Short(R, MemTypeWord.MW_CODE, 3425, sValue)
|
|
If sValue(0) > 0 And sValue(0) <= 100 Then
|
|
Me._ZoomSpeed = sValue(0)
|
|
Else
|
|
Me._ZoomSpeed = 1
|
|
End If
|
|
End Select
|
|
|
|
bStaticDataReaded = True
|
|
|
|
Catch ex As CmsNcException
|
|
Me.CncException(ex.Message)
|
|
End Try
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
''' <summary>
|
|
''' Legge o scrive Boolean da MEMORIE PLC
|
|
''' </summary>
|
|
''' <param name="bWrite">Se True SCRIVE, se False LEGGE</param>
|
|
''' <param name="MemType">Tipo di memoria Osai</param>
|
|
''' <param name="MemIndex">Indice di memoria</param>
|
|
''' <param name="MemBit">Bit della memoria</param>
|
|
''' <param name="Value">Valore da scrivere su scrittura e letto su lettura</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overloads Overrides Function O_RW_Boolean(ByVal bWrite As Boolean, ByVal MemType As MemTypeWord, ByVal MemIndex As Integer, ByVal MemBit As Integer, ByRef Value As Boolean) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
If bWrite Then ' *** Write
|
|
Dim myWriteVarWordBitR As OPENcontrol.WriteVarWordBitR
|
|
Dim myWriteVarWordBit As New OPENcontrol.WriteVarWordBit
|
|
myWriteVarWordBit.Code = MemType
|
|
myWriteVarWordBit.Index = MemIndex
|
|
myWriteVarWordBit.BitIndex = MemBit
|
|
myWriteVarWordBit.BitValue = IIf(Value, 1, 0)
|
|
myWriteVarWordBitR = OPENws.WriteVarWordBit(myWriteVarWordBit)
|
|
If O_CheckRetError(myWriteVarWordBitR.retval, myWriteVarWordBitR.ErrClass, myWriteVarWordBitR.ErrNum, String.Format("WriteVarWordBit({0},{1}) O_RW_Boolean CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
Else ' ************* Read
|
|
Dim myReadVarWordR As OPENcontrol.ReadVarWordR
|
|
Dim myReadVarWord As New OPENcontrol.ReadVarWord
|
|
myReadVarWord.Code = MemType
|
|
myReadVarWord.Index = MemIndex
|
|
myReadVarWord.NumVar = 1
|
|
myReadVarWordR = OPENws.ReadVarWord(myReadVarWord)
|
|
If O_CheckRetError(myReadVarWordR.retval, myReadVarWordR.ErrClass, myReadVarWordR.ErrNum, String.Format("ReadVarWord({0},{1}) O_RW_Boolean CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
If (myReadVarWordR.Value(0) And (2 ^ MemBit)) = (2 ^ MemBit) Then 'True
|
|
Value = True
|
|
Else 'False
|
|
Value = False
|
|
End If
|
|
End If
|
|
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
Catch ex As System.TimeoutException
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Legge o scrive Byte da MEMORIE PLC
|
|
''' </summary>
|
|
''' <param name="bWrite">Se True SCRIVE, se False LEGGE</param>
|
|
''' <param name="MemType">Tipo di memoria Osai</param>
|
|
''' <param name="MemIndex">Indice di memoria</param>
|
|
''' <param name="MemOrderStart">Ordine di partenza LOW_ORDER = 0 HIGH_ORDER = 1</param>
|
|
''' <param name="Value">Matrice di valori da scrivere su scrittura o letti su lettura</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overloads Overrides Function O_RW_Byte(ByVal bWrite As Boolean, ByVal MemType As MemTypeWord, ByVal MemIndex As Integer, ByVal MemOrderStart As Integer, ByRef Value() As Byte) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim bStartHigh As Boolean = MemOrderStart
|
|
Dim bEndDispari As Boolean = (Value.Length + MemOrderStart) Mod 2
|
|
Dim cStart, cEnd As Byte
|
|
Dim ValueTmp(((Value.Length + MemOrderStart) \ 2) + ((Value.Length + MemOrderStart) Mod 2) - 1) As UShort
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
If bWrite Then ' *** Write
|
|
'se comincio con hi leggo la prima memo
|
|
If bStartHigh Then
|
|
Dim ValStartTmp(0) As UShort
|
|
O_RW_Word(R, MemType, MemIndex, ValStartTmp)
|
|
cStart = WordToByte(ValStartTmp(0), LOW_ORDER)
|
|
End If
|
|
|
|
'se finisco dispari, leggo l'ultima memo
|
|
If bEndDispari Then
|
|
Dim ValEndTmp(0) As UShort
|
|
O_RW_Word(R, MemType, MemIndex + ValueTmp.Length - 1, ValEndTmp)
|
|
cEnd = WordToByte(ValEndTmp(0), HIGH_ORDER)
|
|
End If
|
|
|
|
For i = 0 To ValueTmp.Length - 1
|
|
Dim cLow, cHigh As Byte
|
|
'Low
|
|
If i = 0 AndAlso bStartHigh Then
|
|
cLow = cStart
|
|
Else
|
|
cLow = Value(i * 2 - MemOrderStart)
|
|
End If
|
|
'High
|
|
If i = (ValueTmp.Length - 1) AndAlso bEndDispari Then
|
|
cHigh = cEnd
|
|
Else
|
|
cHigh = Value(i * 2 + 1 - MemOrderStart)
|
|
End If
|
|
|
|
ValueTmp(i) = ByteToWord(cLow, cHigh)
|
|
Next
|
|
|
|
O_RW_Word(W, MemType, MemIndex, ValueTmp)
|
|
|
|
Else ' ************* Read
|
|
Dim myReadVarWordR As OPENcontrol.ReadVarWordR
|
|
Dim myReadVarWord As New OPENcontrol.ReadVarWord
|
|
myReadVarWord.Code = MemType
|
|
myReadVarWord.Index = MemIndex
|
|
myReadVarWord.NumVar = ValueTmp.Length
|
|
myReadVarWordR = OPENws.ReadVarWord(myReadVarWord)
|
|
If O_CheckRetError(myReadVarWordR.retval, myReadVarWordR.ErrClass, myReadVarWordR.ErrNum, String.Format("ReadVarWord({0},{1}) O_RW_Byte CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
For i = 0 To Value.Length - 1
|
|
Value(i) = WordToByte(myReadVarWordR.Value((i + MemOrderStart) \ 2), (i + MemOrderStart) Mod 2)
|
|
Next
|
|
End If
|
|
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
Catch ex As System.TimeoutException
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Legge o scrive Word da MEMORIE PLC
|
|
''' </summary>
|
|
''' <param name="bWrite">Se True SCRIVE, se False LEGGE</param>
|
|
''' <param name="MemType">Tipo di memoria Osai</param>
|
|
''' <param name="MemIndex">Indice di memoria</param>
|
|
''' <param name="Value">Matrice di valori da scrivere su scrittura o letti su lettura</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overloads Overrides Function O_RW_Word(ByVal bWrite As Boolean, ByVal MemType As MemTypeWord, ByVal MemIndex As Integer, ByRef Value() As UShort) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
If bWrite Then ' *** Write
|
|
Dim myWriteVarWordR As OPENcontrol.WriteVarWordR
|
|
Dim myWriteVarWord As New OPENcontrol.WriteVarWord
|
|
myWriteVarWord.Code = MemType
|
|
myWriteVarWord.Index = MemIndex
|
|
myWriteVarWord.NumVar = Value.Length
|
|
ReDim myWriteVarWord.Value(Value.Length - 1)
|
|
Array.Copy(Value, myWriteVarWord.Value, Value.Length)
|
|
myWriteVarWordR = OPENws.WriteVarWord(myWriteVarWord)
|
|
If O_CheckRetError(myWriteVarWordR.retval, myWriteVarWordR.ErrClass, myWriteVarWordR.ErrNum, String.Format("WriteVarWord({0},{1}) O_RW_Word CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
Else ' ************* Read
|
|
Dim myReadVarWordR As OPENcontrol.ReadVarWordR
|
|
Dim myReadVarWord As New OPENcontrol.ReadVarWord
|
|
myReadVarWord.Code = MemType
|
|
myReadVarWord.Index = MemIndex
|
|
myReadVarWord.NumVar = Value.Length
|
|
myReadVarWordR = OPENws.ReadVarWord(myReadVarWord)
|
|
If O_CheckRetError(myReadVarWordR.retval, myReadVarWordR.ErrClass, myReadVarWordR.ErrNum, String.Format("ReadVarWord({0},{1}) O_RW_Word CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
Array.Copy(myReadVarWordR.Value, Value, Value.Length)
|
|
End If
|
|
|
|
Return True
|
|
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
Catch ex As System.TimeoutException
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
|
|
''' <summary>
|
|
''' Legge o scrive Short da MEMORIE PLC
|
|
''' </summary>
|
|
''' <param name="bWrite">Se True SCRIVE, se False LEGGE</param>
|
|
''' <param name="MemType">Tipo di memoria Osai</param>
|
|
''' <param name="MemIndex">Indice di memoria</param>
|
|
''' <param name="Value">Matrice di valori da scrivere su scrittura o letti su lettura</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overloads Overrides Function O_RW_Short(ByVal bWrite As Boolean, ByVal MemType As MemTypeWord, ByVal MemIndex As Integer, ByRef Value() As Short) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
If bWrite Then ' *** Write
|
|
Dim myWriteVarWordR As OPENcontrol.WriteVarWordR
|
|
Dim myWriteVarWord As New OPENcontrol.WriteVarWord
|
|
myWriteVarWord.Code = MemType
|
|
myWriteVarWord.Index = MemIndex
|
|
myWriteVarWord.NumVar = Value.Length
|
|
ReDim myWriteVarWord.Value(Value.Length - 1)
|
|
For i = 0 To Value.Length - 1
|
|
myWriteVarWord.Value(i) = ShortToUnsigned(Value(i))
|
|
Next
|
|
myWriteVarWordR = OPENws.WriteVarWord(myWriteVarWord)
|
|
If O_CheckRetError(myWriteVarWordR.retval, myWriteVarWordR.ErrClass, myWriteVarWordR.ErrNum, String.Format("WriteVarWord({0},{1}) O_RW_Short CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
Else ' ************* Read
|
|
Dim myReadVarWordR As OPENcontrol.ReadVarWordR
|
|
Dim myReadVarWord As New OPENcontrol.ReadVarWord
|
|
myReadVarWord.Code = MemType
|
|
myReadVarWord.Index = MemIndex
|
|
myReadVarWord.NumVar = Value.Length
|
|
myReadVarWordR = OPENws.ReadVarWord(myReadVarWord)
|
|
If O_CheckRetError(myReadVarWordR.retval, myReadVarWordR.ErrClass, myReadVarWordR.ErrNum, String.Format("ReadVarWord({0},{1}) O_RW_Short CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
For i = 0 To Value.Length - 1
|
|
Value(i) = UnsignedToShort(myReadVarWordR.Value(i))
|
|
Next
|
|
End If
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
Catch ex As System.TimeoutException
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
|
|
''' <summary>
|
|
''' Legge o scrive Integer da MEMORIE PLC
|
|
''' </summary>
|
|
''' <param name="bWrite">Se True SCRIVE, se False LEGGE</param>
|
|
''' <param name="MemType">Tipo di memoria Osai</param>
|
|
''' <param name="MemIndex">Indice di memoria</param>
|
|
''' <param name="Value">Matrice di valori da scrivere su scrittura o letti su lettura</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overloads Overrides Function O_RW_DWord(ByVal bWrite As Boolean, ByVal MemType As MemTypeWord, ByVal MemIndex As Integer, ByRef Value() As UInteger) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim ValueTmp(Value.Length * 2 - 1) As UShort
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
If bWrite Then ' *** Write
|
|
Dim myWriteVarWordR As OPENcontrol.WriteVarWordR
|
|
Dim myWriteVarWord As New OPENcontrol.WriteVarWord
|
|
myWriteVarWord.Code = MemType
|
|
myWriteVarWord.Index = MemIndex
|
|
myWriteVarWord.NumVar = ValueTmp.Length
|
|
For i = 0 To Value.Length - 1
|
|
ValueTmp(i * 2) = DWordToWord(Value(i), LOW_ORDER)
|
|
ValueTmp(i * 2 + 1) = DWordToWord(Value(i), HIGH_ORDER)
|
|
Next
|
|
ReDim myWriteVarWord.Value(ValueTmp.Length - 1)
|
|
Array.Copy(ValueTmp, myWriteVarWord.Value, ValueTmp.Length)
|
|
myWriteVarWordR = OPENws.WriteVarWord(myWriteVarWord)
|
|
If O_CheckRetError(myWriteVarWordR.retval, myWriteVarWordR.ErrClass, myWriteVarWordR.ErrNum, String.Format("WriteVarWord({0},{1}) O_RW_DWord CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
Else ' ************* Read
|
|
Dim myReadVarWordR As OPENcontrol.ReadVarWordR
|
|
Dim myReadVarWord As New OPENcontrol.ReadVarWord
|
|
myReadVarWord.Code = MemType
|
|
myReadVarWord.Index = MemIndex
|
|
myReadVarWord.NumVar = ValueTmp.Length
|
|
myReadVarWordR = OPENws.ReadVarWord(myReadVarWord)
|
|
If O_CheckRetError(myReadVarWordR.retval, myReadVarWordR.ErrClass, myReadVarWordR.ErrNum, String.Format("ReadVarWord({0},{1}) O_RW_DWord CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
Else
|
|
For i = 0 To Value.Length - 1
|
|
Value(i) = WordsToDWord(myReadVarWordR.Value(i * 2), myReadVarWordR.Value(i * 2 + 1))
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
Catch ex As System.TimeoutException
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
|
|
''' <summary>
|
|
''' Legge o scrive Integer da MEMORIE PLC
|
|
''' </summary>
|
|
''' <param name="bWrite">Se True SCRIVE, se False LEGGE</param>
|
|
''' <param name="MemType">Tipo di memoria Osai</param>
|
|
''' <param name="MemIndex">Indice di memoria</param>
|
|
''' <param name="Value">Matrice di valori da scrivere su scrittura o letti su lettura</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overloads Overrides Function O_RW_Integer(ByVal bWrite As Boolean, ByVal MemType As MemTypeWord, ByVal MemIndex As Integer, ByRef Value() As Integer) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim ValueTmp(Value.Length * 2 - 1) As UShort
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
If bWrite Then ' *** Write
|
|
Dim myWriteVarWordR As OPENcontrol.WriteVarWordR
|
|
Dim myWriteVarWord As New OPENcontrol.WriteVarWord
|
|
myWriteVarWord.Code = MemType
|
|
myWriteVarWord.Index = MemIndex
|
|
myWriteVarWord.NumVar = ValueTmp.Length
|
|
For i = 0 To Value.Length - 1
|
|
ValueTmp(i * 2) = IntegerToWord(Value(i), LOW_ORDER)
|
|
ValueTmp(i * 2 + 1) = IntegerToWord(Value(i), HIGH_ORDER)
|
|
Next
|
|
ReDim myWriteVarWord.Value(ValueTmp.Length - 1)
|
|
Array.Copy(ValueTmp, myWriteVarWord.Value, ValueTmp.Length)
|
|
myWriteVarWordR = OPENws.WriteVarWord(myWriteVarWord)
|
|
If O_CheckRetError(myWriteVarWordR.retval, myWriteVarWordR.ErrClass, myWriteVarWordR.ErrNum, String.Format("WriteVarDWord({0},{1}) O_RW_DWord CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
Else ' ************* Read
|
|
Dim myReadVarWordR As OPENcontrol.ReadVarWordR
|
|
Dim myReadVarWord As New OPENcontrol.ReadVarWord
|
|
myReadVarWord.Code = MemType
|
|
myReadVarWord.Index = MemIndex
|
|
myReadVarWord.NumVar = ValueTmp.Length
|
|
myReadVarWordR = OPENws.ReadVarWord(myReadVarWord)
|
|
If O_CheckRetError(myReadVarWordR.retval, myReadVarWordR.ErrClass, myReadVarWordR.ErrNum, String.Format("ReadVarDWord({0},{1}) O_RW_DWord CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
Else
|
|
For i = 0 To Value.Length - 1
|
|
Value(i) = WordsToInteger(myReadVarWordR.Value(i * 2), myReadVarWordR.Value(i * 2 + 1))
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
Catch ex As System.TimeoutException
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Legge o scrive Double da MEMORIE PLC
|
|
''' </summary>
|
|
''' <param name="bWrite">Se True SCRIVE, se False LEGGE</param>
|
|
''' <param name="MemType">Tipo di memoria Osai</param>
|
|
''' <param name="MemIndex">Indice di memoria</param>
|
|
''' <param name="Value">Matrice di valori da scrivere su scrittura o letti su lettura</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overloads Overrides Function O_RW_Double(ByVal bWrite As Boolean, ByVal MemType As MemTypeDouble, ByVal MemIndex As Integer, ByRef Value() As Double) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
If bWrite Then ' *** Write
|
|
Dim myWriteVarDoubleR As OPENcontrol.WriteVarDoubleR
|
|
Dim myWriteVarDouble As New OPENcontrol.WriteVarDouble
|
|
myWriteVarDouble.Code = MemType
|
|
myWriteVarDouble.Index = MemIndex
|
|
myWriteVarDouble.NumVar = Value.Length
|
|
ReDim myWriteVarDouble.Value(Value.Length - 1)
|
|
Array.Copy(Value, myWriteVarDouble.Value, Value.Length)
|
|
myWriteVarDoubleR = OPENws.WriteVarDouble(myWriteVarDouble)
|
|
If O_CheckRetError(myWriteVarDoubleR.retval, myWriteVarDoubleR.ErrClass, myWriteVarDoubleR.ErrNum, String.Format("WriteVarDouble({0},{1}) O_RW_Double CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
Else ' ************* Read
|
|
Dim myReadVarDoubleR As OPENcontrol.ReadVarDoubleR
|
|
Dim myReadVarDouble As New OPENcontrol.ReadVarDouble
|
|
myReadVarDouble.Code = MemType
|
|
myReadVarDouble.Index = MemIndex
|
|
myReadVarDouble.NumVar = Value.Length
|
|
myReadVarDoubleR = OPENws.ReadVarDouble(myReadVarDouble)
|
|
If O_CheckRetError(myReadVarDoubleR.retval, myReadVarDoubleR.ErrClass, myReadVarDoubleR.ErrNum, String.Format("ReadVarDouble({0},{1}) O_RW_Double CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
Array.Copy(myReadVarDoubleR.Value, Value, Value.Length)
|
|
End If
|
|
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
Catch ex As System.TimeoutException
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Legge o scrive Stringhe da MEMORIE SC
|
|
''' </summary>
|
|
''' <param name="bWrite">Se True SCRIVE, se False LEGGE</param>
|
|
''' <param name="MemIndex">Indice di memoria</param>
|
|
''' <param name="MemLength">Lunghezza caratteri</param>
|
|
''' <param name="Value">Stringa da scrivere su scrittura o leggere su lettura</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overloads Overrides Function O_RW_Text(ByVal bWrite As Boolean, ByVal MemType As MemTypeText, ByVal MemIndex As Integer, ByVal MemLength As Integer, ByRef Value As String) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
If bWrite Then ' *** Write
|
|
Dim myWriteVarTextR As OPENcontrol.WriteVarTextR
|
|
Dim myWriteVarText As New OPENcontrol.WriteVarText
|
|
myWriteVarText.Code = MemType
|
|
myWriteVarText.Index = MemIndex
|
|
myWriteVarText.Len = MemLength
|
|
myWriteVarText.Text = Value
|
|
myWriteVarText.Process = 1 'serve per le variabili SC
|
|
myWriteVarTextR = OPENws.WriteVarText(myWriteVarText)
|
|
If O_CheckRetError(myWriteVarTextR.retval, myWriteVarTextR.ErrClass, myWriteVarTextR.ErrNum, String.Format("WriteVarText({0},{1}) O_RW_Text CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
Else ' ************* Read
|
|
Dim myReadVarTextR As OPENcontrol.ReadVarTextR
|
|
Dim myReadVarText As New OPENcontrol.ReadVarText
|
|
myReadVarText.Code = MemType
|
|
myReadVarText.Index = MemIndex
|
|
myReadVarText.Size = MemLength
|
|
myReadVarText.Process = 1 'serve per le variabili SC
|
|
myReadVarTextR = OPENws.ReadVarText(myReadVarText)
|
|
If O_CheckRetError(myReadVarTextR.retval, myReadVarTextR.ErrClass, myReadVarTextR.ErrNum, String.Format("ReadVarText({0},{1}) O_RW_Text CNC.OSAI_OPEN", [Enum].GetName(MemType.GetType, MemType), MemIndex), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
Value = myReadVarTextR.Text
|
|
End If
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
Catch ex As System.TimeoutException
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
|
|
Return True
|
|
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Legge o scrive Length and Radius Offset da tabella Utensili CN
|
|
''' </summary>
|
|
''' <param name="bWrite">Se True SCRIVE, se False LEGGE</param>
|
|
''' <param name="ToolOffsetNumber">Numero dell'offset utensile</param>
|
|
Public Overrides Function O_RW_ToolOffset(ByVal bWrite As Boolean, ByVal ToolOffsetNumber As Integer, ByRef CutterRadius_Wear As Double, ByRef CutterRadius_Geometry As Double, ByRef ToolLenght_Wear As Double, ByRef ToolLenght_Geometry As Double) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
If bWrite Then ' *** Write
|
|
'leggo il correttore per usarlo come template
|
|
Dim myGetOffsetTabRecordIIR As OPENcontrol.GetOffsetTabRecordIIR
|
|
Dim myGetOffsetTabRecordII As New OPENcontrol.GetOffsetTabRecordII
|
|
myGetOffsetTabRecordII.RecordNum = ToolOffsetNumber
|
|
myGetOffsetTabRecordIIR = OPENws.GetOffsetTabRecordII(myGetOffsetTabRecordII)
|
|
If O_CheckRetError(myGetOffsetTabRecordIIR.retval, myGetOffsetTabRecordIIR.ErrClass, myGetOffsetTabRecordIIR.ErrNum, String.Format("GetOffsetTabRecordII({0}) O_RW_ToolOffset CNC.OSAI_OPEN", ToolOffsetNumber), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
Dim mySetOffsetTabRecordIIR As OPENcontrol.SetOffsetTabRecordIIR
|
|
Dim mySetOffsetTabRecordII As New OPENcontrol.SetOffsetTabRecordII
|
|
mySetOffsetTabRecordII.RecordNum = ToolOffsetNumber
|
|
mySetOffsetTabRecordII.RecordBuff = myGetOffsetTabRecordIIR.RecordBuff
|
|
'modifico i valori che mi interesssano
|
|
mySetOffsetTabRecordII.RecordBuff.DiaVal(0).ActChangeVal = CutterRadius_Wear
|
|
mySetOffsetTabRecordII.RecordBuff.DiaVal(0).ValOrig = CutterRadius_Geometry
|
|
mySetOffsetTabRecordII.RecordBuff.LenVal(0).ActChangeVal = ToolLenght_Wear
|
|
mySetOffsetTabRecordII.RecordBuff.LenVal(0).ValOrig = ToolLenght_Geometry
|
|
|
|
'scrivo il correttore
|
|
mySetOffsetTabRecordIIR = OPENws.SetOffsetTabRecordII(mySetOffsetTabRecordII)
|
|
If O_CheckRetError(mySetOffsetTabRecordIIR.retval, mySetOffsetTabRecordIIR.ErrClass, mySetOffsetTabRecordIIR.ErrNum, String.Format("SetOffsetTabRecordII({0}) O_RW_ToolOffset CNC.OSAI_OPEN", ToolOffsetNumber), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
Else ' ************* Read
|
|
Dim myGetOffsetTabRecordIIR As OPENcontrol.GetOffsetTabRecordIIR
|
|
Dim myGetOffsetTabRecordII As New OPENcontrol.GetOffsetTabRecordII
|
|
myGetOffsetTabRecordII.RecordNum = ToolOffsetNumber
|
|
myGetOffsetTabRecordIIR = OPENws.GetOffsetTabRecordII(myGetOffsetTabRecordII)
|
|
If O_CheckRetError(myGetOffsetTabRecordIIR.retval, myGetOffsetTabRecordIIR.ErrClass, myGetOffsetTabRecordIIR.ErrNum, String.Format("GetOffsetTabRecordII({0}) O_RW_ToolOffset CNC.OSAI_OPEN", ToolOffsetNumber), szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
CutterRadius_Wear = myGetOffsetTabRecordIIR.RecordBuff.DiaVal(0).ActChangeVal
|
|
CutterRadius_Geometry = myGetOffsetTabRecordIIR.RecordBuff.DiaVal(0).ValOrig
|
|
ToolLenght_Wear = myGetOffsetTabRecordIIR.RecordBuff.LenVal(0).ActChangeVal
|
|
ToolLenght_Geometry = myGetOffsetTabRecordIIR.RecordBuff.LenVal(0).ValOrig
|
|
End If
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
|
|
Return True
|
|
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Blocca l'accesso alla tabella dei correttori
|
|
''' </summary>
|
|
''' <param name="Lock">=True: Blocca la tabella, =False: Sblocca la tabella</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overrides Function O_LockOffsetTable(ByVal Lock As Boolean) As Boolean
|
|
Static bLocked As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
If Lock Then
|
|
If Not bLocked Then
|
|
Dim myLockTableIIR As OPENcontrol.LockTableIIR
|
|
Dim myLockTableII As New OPENcontrol.LockTableII
|
|
myLockTableII.TableNum = O_Table.OFFSET_TABLE_ID
|
|
myLockTableIIR = OPENws.LockTableII(myLockTableII)
|
|
If O_CheckRetError(myLockTableIIR.retval, myLockTableIIR.ErrClass, myLockTableIIR.ErrNum, String.Format("LockTableII({0}) O_LockOffsetTable CNC.OSAI_OPEN", myLockTableII.TableNum), szReturn) Then
|
|
'Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
bLocked = True
|
|
End If
|
|
Else
|
|
Dim myUnLockTableIIR As OPENcontrol.UnLockTableIIR
|
|
Dim myUnLockTableII As New OPENcontrol.UnLockTableII
|
|
myUnLockTableII.TableNum = O_Table.OFFSET_TABLE_ID
|
|
myUnLockTableIIR = OPENws.UnLockTableII(myUnLockTableII)
|
|
If O_CheckRetError(myUnLockTableIIR.retval, myUnLockTableIIR.ErrClass, myUnLockTableIIR.ErrNum, String.Format("UnLockTableII({0}) O_LockOffsetTable CNC.OSAI_OPEN", myUnLockTableII.TableNum), szReturn) Then
|
|
'Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
bLocked = False
|
|
End If
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
|
|
''' <summary>
|
|
''' Legge il numero del processo attivo
|
|
''' </summary>
|
|
''' <param name="ProcessId">Valore di ritorno del processo selezionato</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overloads Overrides Function O_GetSelectedProcess(ByRef ProcessId As Short) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim myGetSelectedProcessR As OPENcontrol.GetSelectedProcessR
|
|
Dim myGetSelectedProcess As New OPENcontrol.GetSelectedProcess
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
myGetSelectedProcessR = OPENws.GetSelectedProcess(myGetSelectedProcess)
|
|
If O_CheckRetError(myGetSelectedProcessR.retval, myGetSelectedProcessR.ErrClass, myGetSelectedProcessR.ErrNum, "GetSelectedProcess() O_GetSelectedProcess CNC.OSAI_OPEN", szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
ProcessId = UnsignedToShort(myGetSelectedProcessR.ProcNum)
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Legge la riga del programma attivo
|
|
''' </summary>
|
|
''' <param name="Line">Riga in esecuzione del programma attivo</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overloads Overrides Function O_GetActiveLineProgram(ByRef Line As String) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim myGetPartProgramLinesR As OPENcontrol.GetPartProgramLinesR
|
|
Dim myGetPartProgramLines As New OPENcontrol.GetPartProgramLines
|
|
Dim ProcessId As Short
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
O_GetSelectedProcess(ProcessId)
|
|
|
|
myGetPartProgramLines.ProcNum = ProcessId
|
|
myGetPartProgramLinesR = OPENws.GetPartProgramLines(myGetPartProgramLines)
|
|
If O_CheckRetError(myGetPartProgramLinesR.retval, myGetPartProgramLinesR.ErrClass, myGetPartProgramLinesR.ErrNum, "GetPartProgramLines() O_GetActiveLineProgram CNC.OSAI_OPEN", szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
Line = myGetPartProgramLinesR.PPLine2
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
|
|
' ''' <summary>
|
|
' ''' Legge la tabella assi
|
|
' ''' </summary>
|
|
' ''' <param name="ProcessId">Processo selezionato</param>
|
|
' ''' <param name="AxisTable">Valore di ritorno Assi del processo selezionato</param>
|
|
' ''' <returns>True se andata a buon fine</returns>
|
|
' Public Overloads Overrides Function O_GetAxisTab(ByVal ProcessId As Short, ByRef AxisTable() As Char, ByRef AxisIdTable() As Short) As Boolean
|
|
' Dim szReturn As String = ""
|
|
' Dim i, j As Integer
|
|
' Dim myGetAxesInfo3R As OPENcontrol.GetAxesInfo3R
|
|
' Dim myGetAxesInfo3 As New OPENcontrol.GetAxesInfo3
|
|
' Dim nRetry As Integer
|
|
'Retry: nRetry += 1
|
|
|
|
' Try
|
|
' myGetAxesInfo3.AxesNum = 64
|
|
' myGetAxesInfo3R = OPENws.GetAxesInfo3(myGetAxesInfo3)
|
|
' If O_CheckRetError(myGetAxesInfo3R.retval, myGetAxesInfo3R.ErrClass, myGetAxesInfo3R.ErrNum, "GetAxesInfo3() O_RW_Word CNC.OSAI_OPEN", szReturn) Then
|
|
' Throw New CmsNcException(szReturn)
|
|
' Return False
|
|
' End If
|
|
|
|
' For i = 0 To 63
|
|
' If myGetAxesInfo3R.AxOwnerList(i) = ProcessId Then
|
|
' If (myGetAxesInfo3R.AxNameList(i) < Asc("a") Or myGetAxesInfo3R.AxNameList(i) > Asc("z")) And myGetAxesInfo3R.AxNameList(i) <> Asc("S") Then
|
|
' AxisTable(j) = Chr(myGetAxesInfo3R.AxNameList(i))
|
|
' AxisIdTable(j) = i + 1
|
|
' j += 1
|
|
' End If
|
|
' 'ElseIf myGetAxesInfo3R.AxOwnerList(i) = &HFFFF& Then 'Non esco perchè gli assi potrebbero non essere in fila
|
|
' ' Exit For
|
|
' End If
|
|
' Next i
|
|
|
|
' Return True
|
|
' Catch ex As System.ServiceModel.CommunicationException
|
|
' If nRetry < MAXRET Then GoTo Retry
|
|
' Throw New CmsNcException(ex.Message)
|
|
' Return False
|
|
' End Try
|
|
' End Function
|
|
|
|
#Region "Funzioni specifiche IOT"
|
|
|
|
Public Overloads Overrides Function O_GetNcInfo1(ByRef NcInfo As OPENcontrol.GETINFO1DATA) As Boolean
|
|
' RIFERIMENTO:
|
|
' CndexLinkUser.pdf | pag 148, 266
|
|
|
|
Dim szReturn As String = ""
|
|
Dim myGetNcInfo1R As OPENcontrol.GetNcInfo1R
|
|
Dim myGetNcInfo1 As New OPENcontrol.GetNcInfo1
|
|
Dim ProcessId As Short
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
O_GetSelectedProcess(ProcessId)
|
|
|
|
myGetNcInfo1.ProcNum = ProcessId
|
|
myGetNcInfo1R = OPENws.GetNcInfo1(myGetNcInfo1)
|
|
If O_CheckRetError(myGetNcInfo1R.retval, myGetNcInfo1R.ErrClass, myGetNcInfo1R.ErrNum, "GetNcInfo1() O_GetNcInfo1 CNC.OSAI_OPEN", szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
NcInfo = myGetNcInfo1R.GetInfo
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
|
|
End Function
|
|
|
|
Public Overloads Overrides Function O_ReadCurrentErrorMsg(ByRef CurrMsgError As OPENcontrol.MSGERROR) As Boolean
|
|
' RIFERIMENTO:
|
|
' CndexLinkUser.pdf | pag 162, 270
|
|
|
|
Dim szReturn As String = ""
|
|
Dim myReadCurrentErrorMsgR As OPENcontrol.ReadCurrentErrorMsgR
|
|
Dim myReadCurrentErrorMsg As New OPENcontrol.ReadCurrentErrorMsg
|
|
Dim ProcessId As Short
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
O_GetSelectedProcess(ProcessId)
|
|
|
|
myReadCurrentErrorMsg.Process = ProcessId
|
|
myReadCurrentErrorMsgR = OPENws.ReadCurrentErrorMsg(myReadCurrentErrorMsg)
|
|
If O_CheckRetError(myReadCurrentErrorMsgR.retval, myReadCurrentErrorMsgR.ErrClass, myReadCurrentErrorMsgR.ErrNum, "ReadCurrentErrorMsg() O_ReadCurrentErrorMsg CNC.OSAI_OPEN", szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
CurrMsgError = myReadCurrentErrorMsgR.Data
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
|
|
End Function
|
|
Public Overloads Overrides Function O_ReadCurrentEmergMsg(ByRef CurrMsgEmerg As OPENcontrol.MSGEMERGENCY) As Boolean
|
|
' RIFERIMENTO:
|
|
' CndexLinkUser.pdf | pag 163, 271
|
|
|
|
Dim szReturn As String = ""
|
|
Dim myReadCurrentEmergMsgR As OPENcontrol.ReadCurrentEmergMsgR
|
|
Dim myReadCurrentEmergMsg As New OPENcontrol.ReadCurrentEmergMsg
|
|
Dim ProcessId As Short
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
O_GetSelectedProcess(ProcessId)
|
|
|
|
myReadCurrentEmergMsg.Process = ProcessId
|
|
myReadCurrentEmergMsgR = OPENws.ReadCurrentEmergMsg(myReadCurrentEmergMsg)
|
|
If O_CheckRetError(myReadCurrentEmergMsgR.retval, myReadCurrentEmergMsgR.ErrClass, myReadCurrentEmergMsgR.ErrNum, "ReadCurrentEmergMsg() O_ReadCurrentEmergMsg CNC.OSAI_OPEN", szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
CurrMsgEmerg = myReadCurrentEmergMsgR.Data
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
|
|
End Function
|
|
Public Overloads Overrides Function O_ReadCurrentAnomalyMsg(ByRef CurrMsgAnomaly As OPENcontrol.MSGANOMALY) As Boolean
|
|
' RIFERIMENTO:
|
|
' CndexLinkUser.pdf | pag 164, 271
|
|
|
|
Dim szReturn As String = ""
|
|
Dim myReadCurrentAnomalyMsgR As OPENcontrol.ReadCurrentAnomalyMsgR
|
|
Dim myReadCurrentAnomalyMsg As New OPENcontrol.ReadCurrentAnomalyMsg
|
|
Dim ProcessId As Short
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
O_GetSelectedProcess(ProcessId)
|
|
|
|
myReadCurrentAnomalyMsgR = OPENws.ReadCurrentAnomalyMsg(myReadCurrentAnomalyMsg)
|
|
If O_CheckRetError(myReadCurrentAnomalyMsgR.retval, myReadCurrentAnomalyMsgR.ErrClass, myReadCurrentAnomalyMsgR.ErrNum, "ReadCurrentAnomalyMsg() O_ReadCurrentAnomalyMsg CNC.OSAI_OPEN", szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
CurrMsgAnomaly = myReadCurrentAnomalyMsgR.Data
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Legge la tabella assi
|
|
''' </summary>
|
|
''' <param name="ProcessId">Processo selezionato</param>
|
|
''' <param name="AxisTable">Valore di ritorno Assi del processo selezionato</param>
|
|
''' <returns>True se andata a buon fine</returns>
|
|
Public Overloads Overrides Function O_GetAxisTab(ByVal ProcessId As Short, ByRef AxisTable() As Char, ByRef AxisIdTable() As Short) As Boolean
|
|
Dim szReturn As String = ""
|
|
Dim i, j As Integer
|
|
Dim myGetAxesInfo3R As OPENcontrol.GetAxesInfo3R
|
|
Dim myGetAxesInfo3 As New OPENcontrol.GetAxesInfo3
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
myGetAxesInfo3.AxesNum = 64
|
|
myGetAxesInfo3R = OPENws.GetAxesInfo3(myGetAxesInfo3)
|
|
If O_CheckRetError(myGetAxesInfo3R.retval, myGetAxesInfo3R.ErrClass, myGetAxesInfo3R.ErrNum, "GetAxesInfo3() O_RW_Word CNC.OSAI_OPEN", szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
For i = 0 To 63
|
|
If myGetAxesInfo3R.AxOwnerList(i) = ProcessId Then
|
|
If (myGetAxesInfo3R.AxNameList(i) < Asc("a") Or myGetAxesInfo3R.AxNameList(i) > Asc("z")) And myGetAxesInfo3R.AxNameList(i) <> Asc("S") Then
|
|
AxisTable(j) = Chr(myGetAxesInfo3R.AxNameList(i))
|
|
AxisIdTable(j) = i + 1
|
|
j += 1
|
|
End If
|
|
'ElseIf myGetAxesInfo3R.AxOwnerList(i) = &HFFFF& Then 'Non esco perchè gli assi potrebbero non essere in fila
|
|
' Exit For
|
|
End If
|
|
Next i
|
|
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
|
|
Public Overloads Overrides Function getAllAxisPos(tipoPos As Int16, ProcessId As Short, ByRef AxisPos As OPENcontrol.GETINTDATA()) As Boolean
|
|
' RIFERIMENTO:
|
|
' CndexLinkUser.pdf | pag 146, 266
|
|
|
|
Dim szReturn As String = ""
|
|
Dim myGetAxesPositionR As OPENcontrol.GetAxesPositionR
|
|
Dim myGetAxesPosition As New OPENcontrol.GetAxesPosition
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
'O_GetSelectedProcess(ProcessId)
|
|
myGetAxesPosition.ProcNum = ProcessId
|
|
myGetAxesPosition.AxisName = "0"
|
|
myGetAxesPosition.NumAxis = AxisPos.Length
|
|
myGetAxesPosition.Select = tipoPos
|
|
|
|
myGetAxesPositionR = OPENws.GetAxesPosition(myGetAxesPosition)
|
|
If O_CheckRetError(myGetAxesPositionR.retval, myGetAxesPositionR.ErrClass, myGetAxesPositionR.ErrNum, "GetAxesPosition() getAllAxisPos CNC.OSAI_OPEN", szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
AxisPos = myGetAxesPositionR.IntPos
|
|
|
|
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
|
|
End Function
|
|
Public Overloads Overrides Function getPathGCodeMod(Processo As Int32, ByRef GCodeCurr As UShort()) As Boolean
|
|
' RIFERIMENTO:
|
|
' CndexLinkUser.pdf | pag 165
|
|
|
|
Dim szReturn As String = ""
|
|
Dim myGetGCodeR As OPENcontrol.GetGCodeR
|
|
Dim myGetGCode As New OPENcontrol.GetGCode
|
|
Dim ProcessId As UShort
|
|
Dim nRetry As Integer
|
|
Retry: nRetry += 1
|
|
|
|
Try
|
|
O_GetSelectedProcess(ProcessId)
|
|
'myGetGCode.ProcNum = ProcessId
|
|
myGetGCode.ProcNum = Processo
|
|
|
|
myGetGCodeR = OPENws.GetGCode(myGetGCode)
|
|
If O_CheckRetError(myGetGCodeR.retval, myGetGCodeR.ErrClass, myGetGCodeR.ErrNum, "ReadCurrentGCodes() O_ReadCurrentGCodes CNC.OSAI_OPEN", szReturn) Then
|
|
Throw New CmsNcException(szReturn)
|
|
Return False
|
|
End If
|
|
|
|
GCodeCurr = myGetGCodeR.GCode
|
|
|
|
Return True
|
|
Catch ex As System.ServiceModel.CommunicationException
|
|
If nRetry < MAXRET Then GoTo Retry
|
|
Throw New CmsNcException(ex.Message)
|
|
Return False
|
|
End Try
|
|
|
|
End Function
|
|
|
|
#If False Then
|
|
|
|
|
|
Public Function getCncAlarm() As Focas1.ODBALMMSG2
|
|
' RIFERIMENTO:
|
|
' C:\Users\samuele\Documents\FOCAS A02B-0207-K737_04.20\Document\SpecE\Misc\cnc_rdalmmsg2.htm
|
|
' C:\Users\samuele\Documents\FOCAS A02B-0207-K737_04.20\Document\SpecE\Misc\cnc_rdalminfo.htm
|
|
|
|
Dim nPathIdx As Integer
|
|
Dim nNumAxisRead As Integer
|
|
Dim nReturn As Integer
|
|
|
|
Dim allData As Focas1.ODBALMMSG2
|
|
' inizializzo
|
|
allData = New Focas1.ODBALMMSG2
|
|
|
|
'leggo il numero del processo attivo
|
|
nPathIdx = GetActivePath()
|
|
'leggo num max assi dal cn
|
|
nNumAxisRead = Focas1.MAX_AXIS
|
|
|
|
' vettore num allarmi MAX da leggere......
|
|
Dim numAllarmi As Int16
|
|
numAllarmi = 512
|
|
|
|
If Is30Series Then
|
|
|
|
' leggo tutto!!!
|
|
nReturn = Focas1.cnc_rdalmmsg2(nLibHandle(nPathIdx), -1, numAllarmi, allData)
|
|
|
|
If F_CheckRetError_Cnc(nReturn, "cnc_rdalmmsg2 GetCncAlarm CNC.FANUC.CMS_CncLib") Then
|
|
Throw New CmsNcException("ERR cnc_rdalmmsg2 GetCncAlarm CNC.FANUC.CMS_CncLib")
|
|
End If
|
|
End If
|
|
|
|
Return allData
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Public Function getPathTTCoord() As Focas1.ODB5AXMAN
|
|
' RIFERIMENTO:
|
|
' C:\Users\samuele\Documents\FOCAS A02B-0207-K737_04.20\Document\SpecE\Position\cnc_rd5axmandt.htm
|
|
|
|
Dim nPathIdx As Integer
|
|
Dim nNumAxisRead As Integer
|
|
Dim nReturn As Integer
|
|
|
|
Dim ttCoord As Focas1.ODB5AXMAN
|
|
' inizializzo
|
|
ttCoord = New Focas1.ODB5AXMAN
|
|
|
|
'leggo il numero del processo attivo
|
|
nPathIdx = GetActivePath()
|
|
'leggo num max assi dal cn
|
|
nNumAxisRead = Focas1.MAX_AXIS
|
|
|
|
If Is30Series Then
|
|
|
|
' leggo tutto!!!
|
|
nReturn = Focas1.cnc_rd5axmandt(nLibHandle(nPathIdx), ttCoord)
|
|
|
|
If F_CheckRetError_Cnc(nReturn, "cnc_rd3dtooltip RefreshPathTTCoord CNC.FANUC.CMS_CncLib") Then
|
|
Throw New CmsNcException("ERR cnc_rd3dtooltip RefreshPathTTCoord CNC.FANUC.CMS_CncLib")
|
|
End If
|
|
End If
|
|
|
|
Return ttCoord
|
|
|
|
End Function
|
|
|
|
|
|
#End If
|
|
|
|
#End Region
|
|
|
|
|
|
End Class
|
|
|
|
End Namespace
|