diff --git a/CVCncLib/Modules/ComCnOsaiOpen_Series.vb b/CVCncLib/Modules/ComCnOsaiOpen_Series.vb index 845b75c8..85c455c4 100644 --- a/CVCncLib/Modules/ComCnOsaiOpen_Series.vb +++ b/CVCncLib/Modules/ComCnOsaiOpen_Series.vb @@ -13,24 +13,24 @@ Imports System.Diagnostics Imports System.Runtime.InteropServices Public Class Open_Series - Inherits ComCNOsai + Inherits ComCNOsai - Dim OsaiServer As OpenControl.OPENcontrolPortTypeClient + Dim OsaiServer As OpenControl.OPENcontrolPortTypeClient - Public Const L_CODE As Integer = 145 + Public Const L_CODE As Integer = 145 - Private Const NO_ERROR As UShort = 1 + Private Const NO_ERROR As UShort = 1 - Private PhaseCN As Integer - Private ProcessCN As Integer + Private PhaseCN As Integer + Private ProcessCN As Integer #Region "COSTRUTTORE" - Public Sub New(ByVal szAddress As String, ByVal bIsDebug As Boolean, Optional ByVal sVersion As Short = 2) + Public Sub New(ByVal szAddress As String, ByVal bIsDebug As Boolean, Optional ByVal sVersion As Short = 2) - MyBase.New(szAddress, bIsDebug, sVersion) + MyBase.New(szAddress, bIsDebug, sVersion) - End Sub + End Sub #End Region @@ -40,738 +40,738 @@ Public Class Open_Series #Region "METODI - Open/close connection" - ' ------------------------------ - ' Apertura sessione con CN Osai - ' ------------------------------ - ' Public Overrides Function OpenSession(ByVal szNomeCn As String) As ULong - Public Overrides Function OpenSession() As Boolean + ' ------------------------------ + ' Apertura sessione con CN Osai + ' ------------------------------ + ' Public Overrides Function OpenSession(ByVal szNomeCn As String) As ULong + Public Overrides Function OpenSession() As Boolean - Connected = False + Connected = False - OsaiServer = New OpenControl.OPENcontrolPortTypeClient("OPENcontrol", "http://" & NomeCn & ":8080") + OsaiServer = New OpenControl.OPENcontrolPortTypeClient("OPENcontrol", "http://" & NomeCn & ":8080") - If OsaiServer.State = ServiceModel.CommunicationState.Created Then - Try - O_BootPhaseEnquiry(PhaseCN, ErrClass, ErrNum) + If OsaiServer.State = ServiceModel.CommunicationState.Created Then + Try + O_BootPhaseEnquiry(PhaseCN, ErrClass, ErrNum) - Catch ex As Exception - MsgBox("Controllo non connesso !!!" & vbCrLf & ex.Message) '!!!!!!!!!!!!!!!!!!!!!!!!!! - Me.ErrMsg = "Open NC not connected !!!" & vbCrLf & ex.Message - End Try - ' Lettura processo CN - If PhaseCN = SYSTEM_UP_PHASE Then - Connected = True - Else - MsgBox("Boot phase " & ErrNum) - Me.ErrMsg = "Open NC Boot phase error : " & ErrNum - End If + Catch ex As Exception + 'MsgBox("Controllo non connesso !!!" & vbCrLf & ex.Message) '!!!!!!!!!!!!!!!!!!!!!!!!!! + 'Me.ErrMsg = "Open NC not connected !!!" & vbCrLf & ex.Message + End Try + ' Lettura processo CN + If PhaseCN = SYSTEM_UP_PHASE Then + Connected = True + Else + 'MsgBox("Boot phase " & ErrNum) + 'Me.ErrMsg = "Open NC Boot phase error : " & ErrNum + End If - End If + End If - Return Connected + Return Connected - End Function + End Function - Private Function O_BootPhaseEnquiry(ByRef Phase As Integer, ByRef nErrClass As UShort, ByRef nErrNum As UShort) As Integer - Dim oBootPhaseInquiry As New OpenControl.BootPhaseEnquiry - Dim retBootPhaseInquiry As OpenControl.BootPhaseEnquiryR + Private Function O_BootPhaseEnquiry(ByRef Phase As Integer, ByRef nErrClass As UShort, ByRef nErrNum As UShort) As Integer + Dim oBootPhaseInquiry As New OpenControl.BootPhaseEnquiry + Dim retBootPhaseInquiry As OpenControl.BootPhaseEnquiryR - retBootPhaseInquiry = OsaiServer.BootPhaseEnquiry(oBootPhaseInquiry) + retBootPhaseInquiry = OsaiServer.BootPhaseEnquiry(oBootPhaseInquiry) - nErrClass = retBootPhaseInquiry.ErrClass - nErrNum = retBootPhaseInquiry.ErrNum - Phase = retBootPhaseInquiry.Phase + nErrClass = retBootPhaseInquiry.ErrClass + nErrNum = retBootPhaseInquiry.ErrNum + Phase = retBootPhaseInquiry.Phase - O_BootPhaseEnquiry = retBootPhaseInquiry.retval + O_BootPhaseEnquiry = retBootPhaseInquiry.retval - End Function + End Function - Public Overrides Function CloseSession() As Boolean + Public Overrides Function CloseSession() As Boolean - Try + Try - OsaiServer.Close() + OsaiServer.Close() - Catch ex As Exception + Catch ex As Exception - End Try + End Try - End Function + End Function #End Region #Region "METODI - Lettura/scrittura variabili CN" - '------------------------------ - ' Lettura / scittura variabili SC su Cn - '------------------------------ - Public Overrides Function ReadSCVar(ByVal nIndex As Integer, ByVal nNumChar As Integer, Optional ByVal nProcess As Integer = 1) As String - - Dim InputStruct As New OpenControl.ReadVarText - Dim RetVal As OpenControl.ReadVarTextR - - If (Not (Debug)) Then ' se macchina collegata e non in debug - - InputStruct.Code = CndexLinkDotNet.Cndex.SC_CODE ' 50 - InputStruct.Index = nIndex - InputStruct.Size = nNumChar - InputStruct.Process = nProcess - - RetVal = OsaiServer.ReadVarText(InputStruct) - If (RetVal.retval > 0) Then - Return RetVal.Text - Else - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on reading string variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return "?????????????????????" - End If - ' se sono in debug - Else - Return "OK" - End If ' Endif gestione macchina collegata - - End Function - - Public Overrides Function WriteSCVar(ByVal nIndex As Integer, ByVal nNumChar As Integer, ByVal szText As String, Optional ByVal nProcess As Integer = 1) As Boolean - - Dim InputStruct As New OpenControl.WriteVarText - Dim RetVal As OpenControl.WriteVarTextR - - - If (Not (Debug)) Then ' se macchina collegata e non in debug - - InputStruct.Code = CndexLinkDotNet.Cndex.SC_CODE ' 50 - InputStruct.Index = nIndex - InputStruct.Len = nNumChar - InputStruct.Process = nProcess - InputStruct.Text = szText - - RetVal = OsaiServer.WriteVarText(InputStruct) - - If (RetVal.retval > 0) Then - Return True - Else - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on writing SC variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return False - End If - ' se sono in debug - Else - Return True - End If ' Endif gestione macchina collegata - - End Function - - '------------------------------ - ' Lettura variabile Bool su Cn - '------------------------------ - Public Overrides Function ReadBoolVar(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Short - Dim InputStruct As New OpenControl.ReadVarWord - Dim RetVal As OpenControl.ReadVarWordR - Dim nValues(0) As Short ' Array (lo vuole la libreria Osai) che conterrà il valore letto - - InputStruct.NumVar = 1 - InputStruct.Process = nProcess - InputStruct.Code = CndexLinkDotNet.Cndex.GW_CODE ' 21 - InputStruct.Index = szVar.nAddress - - RetVal = OsaiServer.ReadVarWord(InputStruct) - If (RetVal.retval > 0) Then - nValues(0) = RetVal.Value(0) - If ((nValues(0) And (2 ^ szVar.nBit)) <> 0) Then ' Maschera per controllare solo il bit che mi interessa - nValues(0) = 1 - Else - nValues(0) = 0 - End If - - ' return con il valore letto - Return nValues(0) - - Else - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on reading G bool variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore - - End If - - End Function - - '------------------------------ - ' Lettura variabile G Short su Cn - '------------------------------ - Public Overrides Function ReadShortVar(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Short - Dim nValue(0) As Short - - Dim nNumVar As UShort = 1 - Dim nIndex As UShort = 1 - Dim sValue() As UShort = {} - Dim InputStruct As New OpenControl.ReadVarWord - Dim RetVal As OpenControl.ReadVarWordR - - InputStruct.Code = CndexLinkDotNet.Cndex.GW_CODE ' 21 - InputStruct.Index = szVar.nAddress - InputStruct.NumVar = 1 - InputStruct.Process = nProcess - - Try - - RetVal = OsaiServer.ReadVarWord(InputStruct) - If (RetVal.retval > 0) Then - Return UShortToShort(RetVal.Value(0)) - Else - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on reading short variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore - End If - Catch ex As Exception - - Me.ErrMsg = ex.Message - Return CShort(CRASHVALUE) ' In uscita setto variabile a CRASHVALUE errore - - End Try - - End Function - - '------------------------------ - ' Lettura variabile G Double su Cn - '------------------------------ - Public Overrides Function ReadDoubleVar(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Double - 'Dim nValue(0) As Short - - Dim nNumVar As UShort = 1 - Dim nIndex As UShort = 1 - Dim dResult As Double = 0.0 - Dim InputStruct As New OpenControl.ReadVarDouble - Dim RetVal As OpenControl.ReadVarDoubleR - - InputStruct.Code = CndexLinkDotNet.Cndex.GD_CODE ' 41 - InputStruct.Index = szVar.nAddress - InputStruct.NumVar = 1 - InputStruct.Process = nProcess - - RetVal = OsaiServer.ReadVarDouble(InputStruct) - If (RetVal.retval > 0) Then - dResult = RetVal.Value(0) - Return dResult - Else - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on reading G double variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore - End If - - End Function - - '------------------------------ - ' Lettura variabile E ( double ) su Cn - '------------------------------ - Public Overrides Function ReadVarE(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Double - - Dim nValue(0) As Short - Dim nNumVar As UShort = 1 - Dim InputStruct As New OpenControl.ReadVarDouble - Dim RetVal As OpenControl.ReadVarDoubleR - - InputStruct.Code = CndexLinkDotNet.Cndex.E_CODE ' 46 - - InputStruct.Index = szVar.nAddress - InputStruct.NumVar = 1 - InputStruct.Process = nProcess - - RetVal = OsaiServer.ReadVarDouble(InputStruct) - If (RetVal.retval > 0) Then - Return RetVal.Value(0) - Else - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on reading E variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return CDbl(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore - End If - - End Function - - '------------------------------ - ' Lettura variabile L ( double ) su Cn - '------------------------------ - Public Overrides Function ReadVarL(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Double - - Dim nValue(0) As Short - Dim nNumVar As UShort = 1 - Dim InputStruct As New OpenControl.ReadVarDouble - Dim RetVal As OpenControl.ReadVarDoubleR - - InputStruct.Code = L_CODE ' 145 - - InputStruct.Index = szVar.nAddress - InputStruct.NumVar = 1 - InputStruct.Process = nProcess - - RetVal = OsaiServer.ReadVarDouble(InputStruct) - If (RetVal.retval > 0) Then - Return RetVal.Value(0) - - Else - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on reading L variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return CDbl(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore - End If - - End Function - - '------------------------------ - ' Lettura variabile MW su Cn - '------------------------------ - Public Overrides Function ReadVarMW(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As UShort - - Dim nNumVar As UShort = 1 - Dim InputStruct As New OpenControl.ReadVarWord - Dim RetVal As OpenControl.ReadVarWordR - - InputStruct.Code = CndexLinkDotNet.Cndex.MW_CODE ' 20 - InputStruct.Index = szVar.nAddress - InputStruct.NumVar = 1 - InputStruct.Process = nProcess - - RetVal = OsaiServer.ReadVarWord(InputStruct) - If (RetVal.retval > 0) Then - - Return (RetVal.Value(0)) - Else - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on reading MW variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - - Return CUShort(-ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore - End If - - End Function - - ' ------------------------------- - ' Scrittura variabile bool su Cn - '--------------------------------- - Public Overrides Function WriteBoolVar(ByVal szVar As stVAR, ByVal nValue As Short, Optional ByVal nProcess As Integer = 1) As Boolean - - Dim nValues(0) As Short ' Array (lo vuole la libreria Osai) che conterrà il valore letto - Dim nNumVarToBeWrited As Integer = 1 ' Numero di variabili da leggere (fisso a 1) - Dim nResult As Integer = -1 - Dim InputStruct As New OpenControl.WriteVarWordBit - Dim RetVal As OpenControl.WriteVarWordBitR - - nValues(0) = nValue - - ' se macchina collegata e non in debug - If (Not (Debug)) Then - - InputStruct.Code = CndexLinkDotNet.Cndex.GW_CODE ' 21 - InputStruct.Process = nProcess - InputStruct.Index = szVar.nAddress - InputStruct.BitIndex = szVar.nBit - InputStruct.BitValue = nValue - RetVal = OsaiServer.WriteVarWordBit(InputStruct) + '------------------------------ + ' Lettura / scittura variabili SC su Cn + '------------------------------ + Public Overrides Function ReadSCVar(ByVal nIndex As Integer, ByVal nNumChar As Integer, Optional ByVal nProcess As Integer = 1) As String + + Dim InputStruct As New OpenControl.ReadVarText + Dim RetVal As OpenControl.ReadVarTextR + + If (Not (Debug)) Then ' se macchina collegata e non in debug + + InputStruct.Code = CndexLinkDotNet.Cndex.SC_CODE ' 50 + InputStruct.Index = nIndex + InputStruct.Size = nNumChar + InputStruct.Process = nProcess + + RetVal = OsaiServer.ReadVarText(InputStruct) + If (RetVal.retval > 0) Then + Return RetVal.Text + Else + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on reading string variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return "?????????????????????" + End If + ' se sono in debug + Else + Return "OK" + End If ' Endif gestione macchina collegata + + End Function + + Public Overrides Function WriteSCVar(ByVal nIndex As Integer, ByVal nNumChar As Integer, ByVal szText As String, Optional ByVal nProcess As Integer = 1) As Boolean + + Dim InputStruct As New OpenControl.WriteVarText + Dim RetVal As OpenControl.WriteVarTextR + + + If (Not (Debug)) Then ' se macchina collegata e non in debug + + InputStruct.Code = CndexLinkDotNet.Cndex.SC_CODE ' 50 + InputStruct.Index = nIndex + InputStruct.Len = nNumChar + InputStruct.Process = nProcess + InputStruct.Text = szText + + RetVal = OsaiServer.WriteVarText(InputStruct) + + If (RetVal.retval > 0) Then + Return True + Else + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on writing SC variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return False + End If + ' se sono in debug + Else + Return True + End If ' Endif gestione macchina collegata + + End Function + + '------------------------------ + ' Lettura variabile Bool su Cn + '------------------------------ + Public Overrides Function ReadBoolVar(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Short + Dim InputStruct As New OpenControl.ReadVarWord + Dim RetVal As OpenControl.ReadVarWordR + Dim nValues(0) As Short ' Array (lo vuole la libreria Osai) che conterrà il valore letto + + InputStruct.NumVar = 1 + InputStruct.Process = nProcess + InputStruct.Code = CndexLinkDotNet.Cndex.GW_CODE ' 21 + InputStruct.Index = szVar.nAddress + + RetVal = OsaiServer.ReadVarWord(InputStruct) + If (RetVal.retval > 0) Then + nValues(0) = RetVal.Value(0) + If ((nValues(0) And (2 ^ szVar.nBit)) <> 0) Then ' Maschera per controllare solo il bit che mi interessa + nValues(0) = 1 + Else + nValues(0) = 0 + End If + + ' return con il valore letto + Return nValues(0) + + Else + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on reading G bool variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore + + End If + + End Function + + '------------------------------ + ' Lettura variabile G Short su Cn + '------------------------------ + Public Overrides Function ReadShortVar(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Short + Dim nValue(0) As Short + + Dim nNumVar As UShort = 1 + Dim nIndex As UShort = 1 + Dim sValue() As UShort = {} + Dim InputStruct As New OpenControl.ReadVarWord + Dim RetVal As OpenControl.ReadVarWordR + + InputStruct.Code = CndexLinkDotNet.Cndex.GW_CODE ' 21 + InputStruct.Index = szVar.nAddress + InputStruct.NumVar = 1 + InputStruct.Process = nProcess + + Try + + RetVal = OsaiServer.ReadVarWord(InputStruct) + If (RetVal.retval > 0) Then + Return UShortToShort(RetVal.Value(0)) + Else + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on reading short variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore + End If + Catch ex As Exception + + Me.ErrMsg = ex.Message + Return CShort(CRASHVALUE) ' In uscita setto variabile a CRASHVALUE errore + + End Try + + End Function + + '------------------------------ + ' Lettura variabile G Double su Cn + '------------------------------ + Public Overrides Function ReadDoubleVar(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Double + 'Dim nValue(0) As Short + + Dim nNumVar As UShort = 1 + Dim nIndex As UShort = 1 + Dim dResult As Double = 0.0 + Dim InputStruct As New OpenControl.ReadVarDouble + Dim RetVal As OpenControl.ReadVarDoubleR + + InputStruct.Code = CndexLinkDotNet.Cndex.GD_CODE ' 41 + InputStruct.Index = szVar.nAddress + InputStruct.NumVar = 1 + InputStruct.Process = nProcess + + RetVal = OsaiServer.ReadVarDouble(InputStruct) + If (RetVal.retval > 0) Then + dResult = RetVal.Value(0) + Return dResult + Else + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on reading G double variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore + End If + + End Function + + '------------------------------ + ' Lettura variabile E ( double ) su Cn + '------------------------------ + Public Overrides Function ReadVarE(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Double + + Dim nValue(0) As Short + Dim nNumVar As UShort = 1 + Dim InputStruct As New OpenControl.ReadVarDouble + Dim RetVal As OpenControl.ReadVarDoubleR + + InputStruct.Code = CndexLinkDotNet.Cndex.E_CODE ' 46 + + InputStruct.Index = szVar.nAddress + InputStruct.NumVar = 1 + InputStruct.Process = nProcess + + RetVal = OsaiServer.ReadVarDouble(InputStruct) + If (RetVal.retval > 0) Then + Return RetVal.Value(0) + Else + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on reading E variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return CDbl(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore + End If + + End Function + + '------------------------------ + ' Lettura variabile L ( double ) su Cn + '------------------------------ + Public Overrides Function ReadVarL(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As Double + + Dim nValue(0) As Short + Dim nNumVar As UShort = 1 + Dim InputStruct As New OpenControl.ReadVarDouble + Dim RetVal As OpenControl.ReadVarDoubleR + + InputStruct.Code = L_CODE ' 145 + + InputStruct.Index = szVar.nAddress + InputStruct.NumVar = 1 + InputStruct.Process = nProcess + + RetVal = OsaiServer.ReadVarDouble(InputStruct) + If (RetVal.retval > 0) Then + Return RetVal.Value(0) + + Else + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on reading L variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return CDbl(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore + End If + + End Function + + '------------------------------ + ' Lettura variabile MW su Cn + '------------------------------ + Public Overrides Function ReadVarMW(ByVal szVar As stVAR, Optional ByVal nProcess As Integer = 1) As UShort + + Dim nNumVar As UShort = 1 + Dim InputStruct As New OpenControl.ReadVarWord + Dim RetVal As OpenControl.ReadVarWordR + + InputStruct.Code = CndexLinkDotNet.Cndex.MW_CODE ' 20 + InputStruct.Index = szVar.nAddress + InputStruct.NumVar = 1 + InputStruct.Process = nProcess + + RetVal = OsaiServer.ReadVarWord(InputStruct) + If (RetVal.retval > 0) Then + + Return (RetVal.Value(0)) + Else + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on reading MW variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + + Return CUShort(-ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore + End If + + End Function + + ' ------------------------------- + ' Scrittura variabile bool su Cn + '--------------------------------- + Public Overrides Function WriteBoolVar(ByVal szVar As stVAR, ByVal nValue As Short, Optional ByVal nProcess As Integer = 1) As Boolean + + Dim nValues(0) As Short ' Array (lo vuole la libreria Osai) che conterrà il valore letto + Dim nNumVarToBeWrited As Integer = 1 ' Numero di variabili da leggere (fisso a 1) + Dim nResult As Integer = -1 + Dim InputStruct As New OpenControl.WriteVarWordBit + Dim RetVal As OpenControl.WriteVarWordBitR + + nValues(0) = nValue + + ' se macchina collegata e non in debug + If (Not (Debug)) Then + + InputStruct.Code = CndexLinkDotNet.Cndex.GW_CODE ' 21 + InputStruct.Process = nProcess + InputStruct.Index = szVar.nAddress + InputStruct.BitIndex = szVar.nBit + InputStruct.BitValue = nValue + RetVal = OsaiServer.WriteVarWordBit(InputStruct) - If (RetVal.retval <= 0) Then - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on writing bool variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return False ' - Else - Return True - End If + If (RetVal.retval <= 0) Then + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on writing bool variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return False ' + Else + Return True + End If - ' se sono in debug - Else - Return True - End If ' Endif gestione macchina collegata + ' se sono in debug + Else + Return True + End If ' Endif gestione macchina collegata - End Function + End Function - ' ------------------------------- - ' Scrittura variabile G Short su Cn - '--------------------------------- - Public Overrides Function WriteShortVar(ByVal szVar As stVAR, ByVal nValue As Short, Optional ByVal nProcess As Integer = 1) As Boolean + ' ------------------------------- + ' Scrittura variabile G Short su Cn + '--------------------------------- + Public Overrides Function WriteShortVar(ByVal szVar As stVAR, ByVal nValue As Short, Optional ByVal nProcess As Integer = 1) As Boolean - Dim nValues(0) As Short ' Array (lo vuole la libreria Osai) che conterrà il valore letto - Dim nNumVarToBeWrited As Integer = 1 ' Numero di variabili da leggere (fisso a 1) - Dim nResult As Integer = -1 - Dim InputStruct As New OpenControl.WriteVarWord - Dim RetVal As OpenControl.WriteVarWordR + Dim nValues(0) As Short ' Array (lo vuole la libreria Osai) che conterrà il valore letto + Dim nNumVarToBeWrited As Integer = 1 ' Numero di variabili da leggere (fisso a 1) + Dim nResult As Integer = -1 + Dim InputStruct As New OpenControl.WriteVarWord + Dim RetVal As OpenControl.WriteVarWordR - nValues(0) = nValue + nValues(0) = nValue - ' se macchina collegata e non in debug - If (Not (Debug)) Then + ' se macchina collegata e non in debug + If (Not (Debug)) Then - InputStruct.Code = CndexLinkDotNet.Cndex.GW_CODE ' 21 - InputStruct.NumVar = 1 - InputStruct.Process = nProcess - InputStruct.Index = szVar.nAddress - ReDim InputStruct.Value(0) - InputStruct.Value(0) = ShortToUShort(nValues(0)) + InputStruct.Code = CndexLinkDotNet.Cndex.GW_CODE ' 21 + InputStruct.NumVar = 1 + InputStruct.Process = nProcess + InputStruct.Index = szVar.nAddress + ReDim InputStruct.Value(0) + InputStruct.Value(0) = ShortToUShort(nValues(0)) - RetVal = OsaiServer.WriteVarWord(InputStruct) + RetVal = OsaiServer.WriteVarWord(InputStruct) - If (RetVal.retval <= 0) Then - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on writing short variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return False ' In uscita setto variabile a ERRORVALUE errore - Else + If (RetVal.retval <= 0) Then + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on writing short variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return False ' In uscita setto variabile a ERRORVALUE errore + Else - Return True + Return True - End If + End If - ' se sono in debug - Else - - Return True + ' se sono in debug + Else + + Return True - End If ' Endif gestione macchina collegata + End If ' Endif gestione macchina collegata - End Function + End Function - ' ------------------------------- - ' Scrittura variabile G Double su Cn - '--------------------------------- - Public Overrides Function WriteDoubleVar(ByVal szVar As stVAR, ByVal dValue As Double, Optional ByVal nProcess As Integer = 1) As Boolean + ' ------------------------------- + ' Scrittura variabile G Double su Cn + '--------------------------------- + Public Overrides Function WriteDoubleVar(ByVal szVar As stVAR, ByVal dValue As Double, Optional ByVal nProcess As Integer = 1) As Boolean - Dim dValues(0) As Double ' Array (lo vuole la libreria Osai) che conterrà il valore letto - Dim nNumVarToBeWrited As Integer = 1 ' Numero di variabili da leggere (fisso a 1) - Dim nResult As Integer = -1 - Dim InputStruct As New OpenControl.WriteVarWord - Dim RetVal As OpenControl.WriteVarWordR + Dim dValues(0) As Double ' Array (lo vuole la libreria Osai) che conterrà il valore letto + Dim nNumVarToBeWrited As Integer = 1 ' Numero di variabili da leggere (fisso a 1) + Dim nResult As Integer = -1 + Dim InputStruct As New OpenControl.WriteVarWord + Dim RetVal As OpenControl.WriteVarWordR - dValues(0) = dValue + dValues(0) = dValue - ' se macchina collegata e non in debug - If (Not (Debug)) Then - - InputStruct.Code = CndexLinkDotNet.Cndex.GD_CODE ' 41 - InputStruct.NumVar = 1 - InputStruct.Process = nProcess - InputStruct.Index = szVar.nAddress - ReDim InputStruct.Value(0) - InputStruct.Value(0) = dValues(0) - - RetVal = OsaiServer.WriteVarWord(InputStruct) + ' se macchina collegata e non in debug + If (Not (Debug)) Then + + InputStruct.Code = CndexLinkDotNet.Cndex.GD_CODE ' 41 + InputStruct.NumVar = 1 + InputStruct.Process = nProcess + InputStruct.Index = szVar.nAddress + ReDim InputStruct.Value(0) + InputStruct.Value(0) = dValues(0) + + RetVal = OsaiServer.WriteVarWord(InputStruct) - If (RetVal.retval <= 0) Then - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on writing G DoubleVar " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return False ' In uscita setto variabile a ERRORVALUE errore - Else - - Return True - - End If - - ' se sono in debug - Else - - Return True - - End If ' Endif gestione macchina collegata - - End Function - - ' ------------------------------- - ' Scrittura variabile E su Cn - '--------------------------------- - Public Overrides Function WriteVarE(ByVal szVar As stVAR, ByVal nValue As Double, Optional ByVal nProcess As Integer = 1) As Boolean - - Dim nValues(0) As Double ' Array (lo vuole la libreria Osai) che conterrà il valore letto - Dim nNumVarToBeWrited As Integer = 1 ' Numero di variabili da leggere (fisso a 1) - Dim nResult As Integer = -1 - Dim InputStruct As New OpenControl.WriteVarDouble - Dim RetVal As OpenControl.WriteVarDoubleR - - nValues(0) = nValue - - If (Not (Debug)) Then ' se macchina collegata e non in debug - - InputStruct.Code = CndexLinkDotNet.Cndex.E_CODE ' 46 - InputStruct.NumVar = 1 - InputStruct.Process = nProcess - InputStruct.Index = szVar.nAddress - ReDim InputStruct.Value(0) - InputStruct.Value(0) = nValues(0) - - RetVal = OsaiServer.WriteVarDouble(InputStruct) - - If (RetVal.retval <= 0) Then - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on writing Write E DoubleVar variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return False ' In uscita setto variabile a ERRORVALUE errore - Else - Return True - End If - - ' se sono in debug - Else - Return True - End If ' Endif gestione macchina collegata - - End Function - ' ------------------------------- - ' Scrittura variabile L su Cn - '--------------------------------- - Public Overrides Function WriteVarL(ByVal szVar As stVAR, ByVal nValue As Double, Optional ByVal nProcess As Integer = 1) As Boolean - - Dim nValues(0) As Double ' Array (lo vuole la libreria Osai) che conterrà il valore letto - Dim nNumVarToBeWrited As Integer = 1 ' Numero di variabili da leggere (fisso a 1) - Dim nResult As Integer = -1 - Dim InputStruct As New OpenControl.WriteVarDouble - Dim RetVal As OpenControl.WriteVarDoubleR - - nValues(0) = nValue - - If (Not (Debug)) Then ' se macchina collegata e non in debug - - InputStruct.Code = L_CODE ' 145 - InputStruct.NumVar = 1 - InputStruct.Process = nProcess - InputStruct.Index = szVar.nAddress - ReDim InputStruct.Value(0) - InputStruct.Value(0) = nValues(0) - - RetVal = OsaiServer.WriteVarDouble(InputStruct) - - If (RetVal.retval <= 0) Then - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on writing Write L DoubleVar variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return False ' In uscita setto variabile a ERRORVALUE errore - Else - Return True - End If - - ' se sono in debug - Else - Return True - End If ' Endif gestione macchina collegata - - End Function - - '------------------------------ - ' Lettura variabile SN Double su Cn - '------------------------------ - Public Overrides Function ReadVarSN(ByVal nVar As Short, Optional ByVal nProcess As Integer = 1) As Double - 'Dim nValue(0) As Short - - Dim nNumVar As UShort = 1 - Dim nIndex As UShort = 1 - Dim dResult As Double = 0.0 - Dim InputStruct As New OpenControl.ReadVarDouble - Dim RetVal As OpenControl.ReadVarDoubleR - - InputStruct.Code = CndexLinkDotNet.Cndex.SN_CODE ' 47 - InputStruct.Index = nVar - InputStruct.NumVar = 1 - InputStruct.Process = nProcess - - RetVal = OsaiServer.ReadVarDouble(InputStruct) - If (RetVal.retval > 0) Then - dResult = RetVal.Value(0) - Return dResult - Else - ErrClass = RetVal.ErrClass - ErrNum = RetVal.ErrNum - ErrMsg = "Error on reading SN variable " & InputStruct.Index.ToString & vbCrLf & what_happened() - Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore - End If - - End Function + If (RetVal.retval <= 0) Then + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on writing G DoubleVar " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return False ' In uscita setto variabile a ERRORVALUE errore + Else + + Return True + + End If + + ' se sono in debug + Else + + Return True + + End If ' Endif gestione macchina collegata + + End Function + + ' ------------------------------- + ' Scrittura variabile E su Cn + '--------------------------------- + Public Overrides Function WriteVarE(ByVal szVar As stVAR, ByVal nValue As Double, Optional ByVal nProcess As Integer = 1) As Boolean + + Dim nValues(0) As Double ' Array (lo vuole la libreria Osai) che conterrà il valore letto + Dim nNumVarToBeWrited As Integer = 1 ' Numero di variabili da leggere (fisso a 1) + Dim nResult As Integer = -1 + Dim InputStruct As New OpenControl.WriteVarDouble + Dim RetVal As OpenControl.WriteVarDoubleR + + nValues(0) = nValue + + If (Not (Debug)) Then ' se macchina collegata e non in debug + + InputStruct.Code = CndexLinkDotNet.Cndex.E_CODE ' 46 + InputStruct.NumVar = 1 + InputStruct.Process = nProcess + InputStruct.Index = szVar.nAddress + ReDim InputStruct.Value(0) + InputStruct.Value(0) = nValues(0) + + RetVal = OsaiServer.WriteVarDouble(InputStruct) + + If (RetVal.retval <= 0) Then + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on writing Write E DoubleVar variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return False ' In uscita setto variabile a ERRORVALUE errore + Else + Return True + End If + + ' se sono in debug + Else + Return True + End If ' Endif gestione macchina collegata + + End Function + ' ------------------------------- + ' Scrittura variabile L su Cn + '--------------------------------- + Public Overrides Function WriteVarL(ByVal szVar As stVAR, ByVal nValue As Double, Optional ByVal nProcess As Integer = 1) As Boolean + + Dim nValues(0) As Double ' Array (lo vuole la libreria Osai) che conterrà il valore letto + Dim nNumVarToBeWrited As Integer = 1 ' Numero di variabili da leggere (fisso a 1) + Dim nResult As Integer = -1 + Dim InputStruct As New OpenControl.WriteVarDouble + Dim RetVal As OpenControl.WriteVarDoubleR + + nValues(0) = nValue + + If (Not (Debug)) Then ' se macchina collegata e non in debug + + InputStruct.Code = L_CODE ' 145 + InputStruct.NumVar = 1 + InputStruct.Process = nProcess + InputStruct.Index = szVar.nAddress + ReDim InputStruct.Value(0) + InputStruct.Value(0) = nValues(0) + + RetVal = OsaiServer.WriteVarDouble(InputStruct) + + If (RetVal.retval <= 0) Then + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on writing Write L DoubleVar variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return False ' In uscita setto variabile a ERRORVALUE errore + Else + Return True + End If + + ' se sono in debug + Else + Return True + End If ' Endif gestione macchina collegata + + End Function + + '------------------------------ + ' Lettura variabile SN Double su Cn + '------------------------------ + Public Overrides Function ReadVarSN(ByVal nVar As Short, Optional ByVal nProcess As Integer = 1) As Double + 'Dim nValue(0) As Short + + Dim nNumVar As UShort = 1 + Dim nIndex As UShort = 1 + Dim dResult As Double = 0.0 + Dim InputStruct As New OpenControl.ReadVarDouble + Dim RetVal As OpenControl.ReadVarDoubleR + + InputStruct.Code = CndexLinkDotNet.Cndex.SN_CODE ' 47 + InputStruct.Index = nVar + InputStruct.NumVar = 1 + InputStruct.Process = nProcess + + RetVal = OsaiServer.ReadVarDouble(InputStruct) + If (RetVal.retval > 0) Then + dResult = RetVal.Value(0) + Return dResult + Else + ErrClass = RetVal.ErrClass + ErrNum = RetVal.ErrNum + ErrMsg = "Error on reading SN variable " & InputStruct.Index.ToString & vbCrLf & what_happened() + Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore + End If + + End Function #End Region #Region "METODI - Modo CN / PP" - ' --------------------------------------------------------------- - ' Attivazione del modo Auto - '---------------------------------------------------------------- - Public Overrides Function SetAutoMode(Optional ByVal nProcess As Integer = 1) As Boolean - Dim RetVal As New OpenControl.SetProcessModeR - Dim Mode As New OpenControl.SetProcessMode + ' --------------------------------------------------------------- + ' Attivazione del modo Auto + '---------------------------------------------------------------- + Public Overrides Function SetAutoMode(Optional ByVal nProcess As Integer = 1) As Boolean + Dim RetVal As New OpenControl.SetProcessModeR + Dim Mode As New OpenControl.SetProcessMode - Mode.Mode = 2 - Mode.ProcNum = nProcess + Mode.Mode = 2 + Mode.ProcNum = nProcess - RetVal = OsaiServer.SetProcessMode(Mode) - If RetVal.retval > 0 Then - Return RetVal.retval + RetVal = OsaiServer.SetProcessMode(Mode) + If RetVal.retval > 0 Then + Return RetVal.retval - Else - 'MsgBox("Error on activating Auto mode " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return RetVal.retval - End If - End Function + Else + 'MsgBox("Error on activating Auto mode " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return RetVal.retval + End If + End Function - ' --------------------------------------------------------------- - ' Lettura modalità selezionata su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetModeSelected(Optional ByVal nProcess As Integer = 1) As Byte - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura modalità selezionata su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetModeSelected(Optional ByVal nProcess As Integer = 1) As Byte + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.modeselect + If RetVal.retval > 0 Then + Return RetVal.GetInfo.modeselect - Else - 'MsgBox("Error on reading Mode Selected" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If + Else + 'MsgBox("Error on reading Mode Selected" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If - End Function + End Function - ' --------------------------------------------------------------- - ' Attivazione del pp passato per parametro - '---------------------------------------------------------------- - Public Overrides Function ActivatePP(ByVal szPartPrg As String, Optional ByVal nProcess As UShort = 1) As Short - Dim RetVal As New OpenControl.SelectPartProgramFromDriveR - Dim InputStruct As New OpenControl.SelectPartProgramFromDrive + ' --------------------------------------------------------------- + ' Attivazione del pp passato per parametro + '---------------------------------------------------------------- + Public Overrides Function ActivatePP(ByVal szPartPrg As String, Optional ByVal nProcess As UShort = 1) As Short + Dim RetVal As New OpenControl.SelectPartProgramFromDriveR + Dim InputStruct As New OpenControl.SelectPartProgramFromDrive - InputStruct.PPName = szPartPrg - InputStruct.ProcNum = nProcess + InputStruct.PPName = szPartPrg + InputStruct.ProcNum = nProcess - RetVal = OsaiServer.SelectPartProgramFromDrive(InputStruct) - If RetVal.retval > 0 Then ' > 0 ok - Return RetVal.retval + RetVal = OsaiServer.SelectPartProgramFromDrive(InputStruct) + If RetVal.retval > 0 Then ' > 0 ok + Return RetVal.retval - Else ' = 0 errore - mErrMsg = "Error on activating part-program " - mErrClass = RetVal.ErrClass - mErrNum = RetVal.ErrNum - Return RetVal.retval + Else ' = 0 errore + mErrMsg = "Error on activating part-program " + mErrClass = RetVal.ErrClass + mErrNum = RetVal.ErrNum + Return RetVal.retval - End If - End Function + End If + End Function - ' --------------------------------- - ' Lettura Programma corrente - '---------------------------------- - Public Function GetActivePP(ByVal nProcess As Integer) As String - Dim InputStruct As New OpenControl.GetActivePartProgram - Dim RetVal As OpenControl.GetActivePartProgramR + ' --------------------------------- + ' Lettura Programma corrente + '---------------------------------- + Public Function GetActivePP(ByVal nProcess As Integer) As String + Dim InputStruct As New OpenControl.GetActivePartProgram + Dim RetVal As OpenControl.GetActivePartProgramR - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetActivePartProgram(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetActivePartProgram(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.Main + If RetVal.retval > 0 Then + Return RetVal.Main - Else - mErrMsg = "Error on reading Active Program " - mErrClass = RetVal.ErrClass - mErrNum = RetVal.ErrNum - Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore - End If + Else + mErrMsg = "Error on reading Active Program " + mErrClass = RetVal.ErrClass + mErrNum = RetVal.ErrNum + Return CShort(ERRORVALUE) ' In uscita setto variabile a ERRORVALUE errore + End If - End Function + End Function - ' --------------------------------------------------------------- - ' Lettura informazioni CN - '---------------------------------------------------------------- - Public Function NcInfo1Open(ByRef ncInfo As OpenControl.GetNcInfo1R, Optional ByVal nProcess As Integer = 1) As OpenControl.GetNcInfo1R - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura informazioni CN + '---------------------------------------------------------------- + Public Function NcInfo1Open(ByRef ncInfo As OpenControl.GetNcInfo1R, Optional ByVal nProcess As Integer = 1) As OpenControl.GetNcInfo1R + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal + If RetVal.retval > 0 Then + Return RetVal - Else - mErrMsg = "Error on reading NcInfo " - mErrClass = RetVal.ErrClass - mErrNum = RetVal.ErrNum - Return RetVal - End If - End Function + Else + mErrMsg = "Error on reading NcInfo " + mErrClass = RetVal.ErrClass + mErrNum = RetVal.ErrNum + Return RetVal + End If + End Function - ' --------------------------------- - ' Lettura info CN 1 - '---------------------------------- - Public Overrides Function NcInfo1(ByRef ncInfo As CndexLinkDotNet.Cndex.GETINFO1DATA, Optional ByVal nProcess As Integer = 1) As Boolean + ' --------------------------------- + ' Lettura info CN 1 + '---------------------------------- + Public Overrides Function NcInfo1(ByRef ncInfo As CndexLinkDotNet.Cndex.GETINFO1DATA, Optional ByVal nProcess As Integer = 1) As Boolean - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then + If RetVal.retval > 0 Then - ' ncInfo = RetVal.GetInfo - ' Assegno 1:1 variabili... + ' ncInfo = RetVal.GetInfo + ' Assegno 1:1 variabili... - ncInfo.actual_tool = RetVal.GetInfo.actualtool - ncInfo.actual_tool_off = RetVal.GetInfo.actualtooloff - ncInfo.auto_jog_ret = RetVal.GetInfo.autojogret - ncInfo.ax_sel = RetVal.GetInfo.axsel + ncInfo.actual_tool = RetVal.GetInfo.actualtool + ncInfo.actual_tool_off = RetVal.GetInfo.actualtooloff + ncInfo.auto_jog_ret = RetVal.GetInfo.autojogret + ncInfo.ax_sel = RetVal.GetInfo.axsel - ncInfo.block_retrace = RetVal.GetInfo.blockretrace + ncInfo.block_retrace = RetVal.GetInfo.blockretrace - ncInfo.disable_slashed_blk = RetVal.GetInfo.disableslashedblk - ncInfo.dry_run = RetVal.GetInfo.dryrun + ncInfo.disable_slashed_blk = RetVal.GetInfo.disableslashedblk + ncInfo.dry_run = RetVal.GetInfo.dryrun - ncInfo.feed_mis_unit = RetVal.GetInfo.feedmisunit - ncInfo.feed_ov = RetVal.GetInfo.feedov - ncInfo.force_rapid_feed = RetVal.GetInfo.forcerapidfeed + ncInfo.feed_mis_unit = RetVal.GetInfo.feedmisunit + ncInfo.feed_ov = RetVal.GetInfo.feedov + ncInfo.force_rapid_feed = RetVal.GetInfo.forcerapidfeed - ncInfo.jog_dir = RetVal.GetInfo.jogdir - ncInfo.jog_incr = RetVal.GetInfo.jogincr + ncInfo.jog_dir = RetVal.GetInfo.jogdir + ncInfo.jog_incr = RetVal.GetInfo.jogincr - ncInfo.last_nc_error = RetVal.GetInfo.lastncerror + ncInfo.last_nc_error = RetVal.GetInfo.lastncerror - ncInfo.main_progr_name = System.Text.Encoding.ASCII.GetBytes(RetVal.GetInfo.mainprogrname) + ncInfo.main_progr_name = System.Text.Encoding.ASCII.GetBytes(RetVal.GetInfo.mainprogrname) - ncInfo.man_feed_ov = RetVal.GetInfo.manfeedov - ncInfo.mode_select = RetVal.GetInfo.modeselect + ncInfo.man_feed_ov = RetVal.GetInfo.manfeedov + ncInfo.mode_select = RetVal.GetInfo.modeselect - ncInfo.num_ax_sel = RetVal.GetInfo.numaxsel + ncInfo.num_ax_sel = RetVal.GetInfo.numaxsel - ncInfo.optional_stop = RetVal.GetInfo.optionalstop + ncInfo.optional_stop = RetVal.GetInfo.optionalstop - ncInfo.progr_feed = RetVal.GetInfo.progrfeed - ncInfo.progr_speed = RetVal.GetInfo.progrspeed - ncInfo.progr_tool = RetVal.GetInfo.progrtool - ncInfo.progr_tool_off = RetVal.GetInfo.progrtooloff + ncInfo.progr_feed = RetVal.GetInfo.progrfeed + ncInfo.progr_speed = RetVal.GetInfo.progrspeed + ncInfo.progr_tool = RetVal.GetInfo.progrtool + ncInfo.progr_tool_off = RetVal.GetInfo.progrtooloff - ncInfo.rapid_feed = RetVal.GetInfo.rapidfeed - ncInfo.rapid_override = RetVal.GetInfo.rapidoverride - ncInfo.rap_feed_ov = RetVal.GetInfo.rapfeedov - ncInfo.real_feed = RetVal.GetInfo.realfeed - ncInfo.real_speed = RetVal.GetInfo.realspeed + ncInfo.rapid_feed = RetVal.GetInfo.rapidfeed + ncInfo.rapid_override = RetVal.GetInfo.rapidoverride + ncInfo.rap_feed_ov = RetVal.GetInfo.rapfeedov + ncInfo.real_feed = RetVal.GetInfo.realfeed + ncInfo.real_speed = RetVal.GetInfo.realspeed - ncInfo.speed_ov = RetVal.GetInfo.speedov - ncInfo.status = RetVal.GetInfo.status - ncInfo.substatus = RetVal.GetInfo.substatus + ncInfo.speed_ov = RetVal.GetInfo.speedov + ncInfo.status = RetVal.GetInfo.status + ncInfo.substatus = RetVal.GetInfo.substatus - Return True + Return True - Else - mErrMsg = "Error on reading NcInfo " - mErrClass = RetVal.ErrClass - mErrNum = RetVal.ErrNum - Return False - End If + Else + mErrMsg = "Error on reading NcInfo " + mErrClass = RetVal.ErrClass + mErrNum = RetVal.ErrNum + Return False + End If - End Function + End Function @@ -781,531 +781,531 @@ Public Class Open_Series - ' --------------------------------------------------------------- - ' Ritorna True se lo stato del CN è IDLE - '---------------------------------------------------------------- - Public Overrides Function IsResetStatus(Optional ByVal nProcess As Integer = 1) As Boolean - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Ritorna True se lo stato del CN è IDLE + '---------------------------------------------------------------- + Public Overrides Function IsResetStatus(Optional ByVal nProcess As Integer = 1) As Boolean + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then + If RetVal.retval > 0 Then - If RetVal.GetInfo.modeselect = 0 Then - Return True - Else - Return False - End If + If RetVal.GetInfo.modeselect = 0 Then + Return True + Else + Return False + End If - Else - mErrMsg = "Error in IsResetStatus" - mErrClass = RetVal.ErrClass - mErrNum = RetVal.ErrNum + Else + mErrMsg = "Error in IsResetStatus" + mErrClass = RetVal.ErrClass + mErrNum = RetVal.ErrNum - Return False - End If + Return False + End If - End Function + End Function - ' ------------------------------------------------- - ' Lettura stato macchina su processo passato per parametro - '-------------------------------------------------- - Public Overrides Function GetMachineStatus(Optional ByVal nProcess As Integer = 1) As Byte - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' ------------------------------------------------- + ' Lettura stato macchina su processo passato per parametro + '-------------------------------------------------- + Public Overrides Function GetMachineStatus(Optional ByVal nProcess As Integer = 1) As Byte + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.status + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) + If RetVal.retval > 0 Then + Return RetVal.GetInfo.status - Else - mErrMsg = "Error on reading Machine Status" - mErrClass = RetVal.ErrClass - mErrNum = RetVal.ErrNum - Return 0 - End If + Else + mErrMsg = "Error on reading Machine Status" + mErrClass = RetVal.ErrClass + mErrNum = RetVal.ErrNum + Return 0 + End If - End Function + End Function #End Region #Region "METODI - Utensili / correttori" - ' --------------------------------------------------------------- - ' Lettura utensile corrente su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetActualTool(Optional ByVal nProcess As Integer = 1) As Double - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura utensile corrente su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetActualTool(Optional ByVal nProcess As Integer = 1) As Double + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.progrtool + If RetVal.retval > 0 Then + Return RetVal.GetInfo.progrtool - Else - 'MsgBox("Error on reading Mode Selected" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If + Else + 'MsgBox("Error on reading Mode Selected" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If - End Function + End Function - ' --------------------------------------------------------------- - ' Lettura correttore corrente su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetActualCorr(Optional ByVal nProcess As Integer = 1) As UShort - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura correttore corrente su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetActualCorr(Optional ByVal nProcess As Integer = 1) As UShort + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.actualtooloff + If RetVal.retval > 0 Then + Return RetVal.GetInfo.actualtooloff - Else - 'MsgBox("Error on reading Mode Selected" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If + Else + 'MsgBox("Error on reading Mode Selected" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If - End Function + End Function - ' --------------------------------------------------------------- - ' Lettura lunghezza correttore corrente su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetActualToolLen(ByVal nRecord As UInteger) As Double - Dim InputStruct As New OpenControl.GetOffsetTabRecordII - Dim RetVal As OpenControl.GetOffsetTabRecordIIR - Dim Len() As OpenControl.OFFSETVALII + ' --------------------------------------------------------------- + ' Lettura lunghezza correttore corrente su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetActualToolLen(ByVal nRecord As UInteger) As Double + Dim InputStruct As New OpenControl.GetOffsetTabRecordII + Dim RetVal As OpenControl.GetOffsetTabRecordIIR + Dim Len() As OpenControl.OFFSETVALII - InputStruct.RecordNum = nRecord - RetVal = OsaiServer.GetOffsetTabRecordII(InputStruct) + InputStruct.RecordNum = nRecord + RetVal = OsaiServer.GetOffsetTabRecordII(InputStruct) - If RetVal.retval > 0 Then - Len = RetVal.RecordBuff.LenVal - Return Len(0).ValOrig + If RetVal.retval > 0 Then + Len = RetVal.RecordBuff.LenVal + Return Len(0).ValOrig - Else - 'MsgBox("Error on reading actual tool length" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If + Else + 'MsgBox("Error on reading actual tool length" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If - End Function + End Function - ' --------------------------------------------------------------- - ' Lettura Diametro correttore corrente su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetActualToolDiam(ByVal nRecord As UInteger) As Double - Dim InputStruct As New OpenControl.GetOffsetTabRecordII - Dim RetVal As OpenControl.GetOffsetTabRecordIIR - Dim Len() As OpenControl.OFFSETVALII + ' --------------------------------------------------------------- + ' Lettura Diametro correttore corrente su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetActualToolDiam(ByVal nRecord As UInteger) As Double + Dim InputStruct As New OpenControl.GetOffsetTabRecordII + Dim RetVal As OpenControl.GetOffsetTabRecordIIR + Dim Len() As OpenControl.OFFSETVALII - InputStruct.RecordNum = nRecord - RetVal = OsaiServer.GetOffsetTabRecordII(InputStruct) + InputStruct.RecordNum = nRecord + RetVal = OsaiServer.GetOffsetTabRecordII(InputStruct) - If RetVal.retval > 0 Then - Len = RetVal.RecordBuff.DiaVal - Return Len(0).ValOrig + If RetVal.retval > 0 Then + Len = RetVal.RecordBuff.DiaVal + Return Len(0).ValOrig - Else - 'MsgBox("Error on reading actual tool diameter" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If + Else + 'MsgBox("Error on reading actual tool diameter" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If - End Function - ' --------------------------------------------------------------- - ' Lettura Diametro correttore corrente 2 su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetActualToolDiam2(ByVal nRecord As UInteger) As Double - Dim InputStruct As New OpenControl.GetOffsetTabRecordII - Dim RetVal As OpenControl.GetOffsetTabRecordIIR - Dim Len() As OpenControl.OFFSETVALII + End Function + ' --------------------------------------------------------------- + ' Lettura Diametro correttore corrente 2 su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetActualToolDiam2(ByVal nRecord As UInteger) As Double + Dim InputStruct As New OpenControl.GetOffsetTabRecordII + Dim RetVal As OpenControl.GetOffsetTabRecordIIR + Dim Len() As OpenControl.OFFSETVALII - InputStruct.RecordNum = nRecord - RetVal = OsaiServer.GetOffsetTabRecordII(InputStruct) + InputStruct.RecordNum = nRecord + RetVal = OsaiServer.GetOffsetTabRecordII(InputStruct) - If RetVal.retval > 0 Then - Len = RetVal.RecordBuff.DiaVal + If RetVal.retval > 0 Then + Len = RetVal.RecordBuff.DiaVal - Return Len(0).ActChangeVal + Return Len(0).ActChangeVal - Else - 'MsgBox("Error on reading actual tool diameter2" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If + Else + 'MsgBox("Error on reading actual tool diameter2" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If - End Function + End Function #End Region #Region "METODI - Feed / Speed" - ' --------------------------------------------------------------- - ' Lettura Feed Override su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetFeedOverride(Optional ByVal nProcess As Integer = 1) As UShort - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura Feed Override su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetFeedOverride(Optional ByVal nProcess As Integer = 1) As UShort + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.feedov / 100 + If RetVal.retval > 0 Then + Return RetVal.GetInfo.feedov / 100 - Else - ' MsgBox("Error on reading Feed Override" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If + Else + ' MsgBox("Error on reading Feed Override" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If - End Function + End Function - ' --------------------------------------------------------------- - ' Lettura Rapid Override su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetRapidOverride(Optional ByVal nProcess As Integer = 1) As UShort - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura Rapid Override su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetRapidOverride(Optional ByVal nProcess As Integer = 1) As UShort + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.rapfeedov / 100 + If RetVal.retval > 0 Then + Return RetVal.GetInfo.rapfeedov / 100 - Else - 'MsgBox("Error on reading Rapid Override" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If + Else + 'MsgBox("Error on reading Rapid Override" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If - End Function + End Function - ' --------------------------------------------------------------- - ' Lettura Speed Override su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetSpeedOverride(Optional ByVal nProcess As Integer = 1) As UShort - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura Speed Override su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetSpeedOverride(Optional ByVal nProcess As Integer = 1) As UShort + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.speedov / 100 + If RetVal.retval > 0 Then + Return RetVal.GetInfo.speedov / 100 - Else - 'MsgBox("Error on reading Speed Override" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If - End Function + Else + 'MsgBox("Error on reading Speed Override" & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If + End Function - ' --------------------------------------------------------------- - ' Lettura velocità rapido programmata su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetProgrammedRapid(Optional ByVal nProcess As Integer = 1) As Double - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura velocità rapido programmata su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetProgrammedRapid(Optional ByVal nProcess As Integer = 1) As Double + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.rapidfeed + If RetVal.retval > 0 Then + Return RetVal.GetInfo.rapidfeed - Else - 'MsgBox("Error on reading Programmed Rapid " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If - End Function + Else + 'MsgBox("Error on reading Programmed Rapid " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If + End Function - ' --------------------------------------------------------------- - ' Lettura Feed programmata su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetProgrammedFeed(Optional ByVal nProcess As Integer = 1) As Double - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura Feed programmata su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetProgrammedFeed(Optional ByVal nProcess As Integer = 1) As Double + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.progrfeed + If RetVal.retval > 0 Then + Return RetVal.GetInfo.progrfeed - Else - 'MsgBox("Error on reading Programmed Feed " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If - End Function + Else + 'MsgBox("Error on reading Programmed Feed " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If + End Function - ' --------------------------------------------------------------- - ' Lettura Speed programmata su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetProgrammedSpeed(Optional ByVal nProcess As Integer = 1) As Double - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura Speed programmata su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetProgrammedSpeed(Optional ByVal nProcess As Integer = 1) As Double + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.progrspeed + If RetVal.retval > 0 Then + Return RetVal.GetInfo.progrspeed - Else - 'MsgBox("Error on reading Programmed Feed " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return ErrMsg - End If - End Function + Else + 'MsgBox("Error on reading Programmed Feed " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return ErrMsg + End If + End Function - ' --------------------------------------------------------------- - ' Lettura Feed reale su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetActualFeed(Optional ByVal nProcess As Integer = 1) As Double - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura Feed reale su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetActualFeed(Optional ByVal nProcess As Integer = 1) As Double + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.realfeed + If RetVal.retval > 0 Then + Return RetVal.GetInfo.realfeed - Else - 'MsgBox("Error on reading Actual Feed " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If - End Function + Else + 'MsgBox("Error on reading Actual Feed " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If + End Function - ' --------------------------------------------------------------- - ' Lettura Speed reale su processo passato per parametro - '---------------------------------------------------------------- - Public Overrides Function GetActualSpeed(Optional ByVal nProcess As Integer = 1) As Double - Dim InputStruct As New OpenControl.GetNcInfo1 - Dim RetVal As OpenControl.GetNcInfo1R + ' --------------------------------------------------------------- + ' Lettura Speed reale su processo passato per parametro + '---------------------------------------------------------------- + Public Overrides Function GetActualSpeed(Optional ByVal nProcess As Integer = 1) As Double + Dim InputStruct As New OpenControl.GetNcInfo1 + Dim RetVal As OpenControl.GetNcInfo1R - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetNcInfo1(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetNcInfo1(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.GetInfo.realspeed + If RetVal.retval > 0 Then + Return RetVal.GetInfo.realspeed - Else - 'MsgBox("Error on reading Actual Speed " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) - Return 0 - End If - End Function + Else + 'MsgBox("Error on reading Actual Speed " & vbCrLf & "Class: " & Str(ErrClass) & " Number: 0x" & Hex(ErrNum)) + Return 0 + End If + End Function #End Region #Region "METODI - copia files" - Public Overrides Function CopyFileToNC(ByVal sz_logical_drive As String, - ByVal sz_source_filename As String, - ByVal sz_dest_filename As String) As Short + Public Overrides Function CopyFileToNC(ByVal sz_logical_drive As String, + ByVal sz_source_filename As String, + ByVal sz_dest_filename As String) As Short - Return PutFile(sz_source_filename, "PROGRAMS" & "\\" & sz_dest_filename, ErrClass, ErrNum, 0) + Return PutFile(sz_source_filename, "PROGRAMS" & "\\" & sz_dest_filename, ErrClass, ErrNum, 0) - End Function + End Function - 'utilizzabile per la copia di file verso cnc + 'utilizzabile per la copia di file verso cnc - Public Overrides Function PutFile(ByRef szPathFile As String, ByVal szTargetPath As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger, ByRef FileSize As Integer) As Integer - Dim oPutFile As New OpenControl.PutFile - Dim retPutFile As New OpenControl.PutFileR - Dim szData As String + Public Overrides Function PutFile(ByRef szPathFile As String, ByVal szTargetPath As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger, ByRef FileSize As Integer) As Integer + Dim oPutFile As New OpenControl.PutFile + Dim retPutFile As New OpenControl.PutFileR + Dim szData As String - oPutFile.PathName = szTargetPath + oPutFile.PathName = szTargetPath - szData = "" + szData = "" - 'apro il file in szPathFile - szData = My.Computer.FileSystem.ReadAllText(szPathFile, System.Text.Encoding.UTF8) + 'apro il file in szPathFile + szData = My.Computer.FileSystem.ReadAllText(szPathFile, System.Text.Encoding.UTF8) - oPutFile.Data = szData - oPutFile.Size = FileSize + oPutFile.Data = szData + oPutFile.Size = FileSize - 'calcolo la dimensione in byte e la metto in oPutFile.Size - oPutFile.Size = szData.Length + 'calcolo la dimensione in byte e la metto in oPutFile.Size + oPutFile.Size = szData.Length - retPutFile = OsaiServer.PutFile(oPutFile) + retPutFile = OsaiServer.PutFile(oPutFile) - nErrClass = retPutFile.ErrClass - nErrNum = retPutFile.ErrNum + nErrClass = retPutFile.ErrClass + nErrNum = retPutFile.ErrNum - PutFile = retPutFile.retval + PutFile = retPutFile.retval - End Function + End Function #End Region - ' ---------------------------------------------------------------------------------------------------------------------------- - ' Lettura Errori CN - ' ---------------------------------------------------------------------------------------------------------------------------- - 'Public Function ReadCurrentErrorMsg(ByVal nProcess As Integer, ByRef MessaggioErr() As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer + ' ---------------------------------------------------------------------------------------------------------------------------- + ' Lettura Errori CN + ' ---------------------------------------------------------------------------------------------------------------------------- + 'Public Function ReadCurrentErrorMsg(ByVal nProcess As Integer, ByRef MessaggioErr() As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer - ' Dim oReadCurrentErrorMsg As New OpenControl.ReadCurrentErrorMsg - ' Dim retReadCurrentErrorMsg As New OpenControl.ReadCurrentErrorMsgR + ' Dim oReadCurrentErrorMsg As New OpenControl.ReadCurrentErrorMsg + ' Dim retReadCurrentErrorMsg As New OpenControl.ReadCurrentErrorMsgR - ' oReadCurrentErrorMsg.Process = nProcess - ' retReadCurrentErrorMsg = OsaiServer.ReadCurrentErrorMsg(oReadCurrentErrorMsg) - ' 'SOAP function call - ' Dim datoErr As New CndexLinkDotNet.Cndex.MSG_ERROR + ' oReadCurrentErrorMsg.Process = nProcess + ' retReadCurrentErrorMsg = OsaiServer.ReadCurrentErrorMsg(oReadCurrentErrorMsg) + ' 'SOAP function call + ' Dim datoErr As New CndexLinkDotNet.Cndex.MSG_ERROR - ' Try - ' datoErr.BootID = CUInt(retReadCurrentErrorMsg.Data.BootID) - ' datoErr.UnIdSeq = CUInt(retReadCurrentErrorMsg.Data.UnIdSeq) - ' datoErr.Code_Err = CUInt(retReadCurrentErrorMsg.Data.CodeErr) - ' datoErr.Comando = CByte(retReadCurrentErrorMsg.Data.Comando) - ' datoErr.FormatTxt = retReadCurrentErrorMsg.Data.FormatTxt - ' datoErr.Process = retReadCurrentErrorMsg.Data.Process - ' datoErr.SubCom = CByte(retReadCurrentErrorMsg.Data.SubCom) + ' Try + ' datoErr.BootID = CUInt(retReadCurrentErrorMsg.Data.BootID) + ' datoErr.UnIdSeq = CUInt(retReadCurrentErrorMsg.Data.UnIdSeq) + ' datoErr.Code_Err = CUInt(retReadCurrentErrorMsg.Data.CodeErr) + ' datoErr.Comando = CByte(retReadCurrentErrorMsg.Data.Comando) + ' datoErr.FormatTxt = retReadCurrentErrorMsg.Data.FormatTxt + ' datoErr.Process = retReadCurrentErrorMsg.Data.Process + ' datoErr.SubCom = CByte(retReadCurrentErrorMsg.Data.SubCom) - ' Dim text2 As MESSAGE_TEXT - ' text2.Line1 = "" - ' text2.Line2 = "" - ' text2.Line3 = "" - ' text2.Line4 = "" + ' Dim text2 As MESSAGE_TEXT + ' text2.Line1 = "" + ' text2.Line2 = "" + ' text2.Line3 = "" + ' text2.Line4 = "" - ' 'Invoke native function TranslateErrorMsg() in library OSAI_ErrorMgr.dll - ' TranslateErrorMsg(datoErr, text2) + ' 'Invoke native function TranslateErrorMsg() in library OSAI_ErrorMgr.dll + ' TranslateErrorMsg(datoErr, text2) - ' ReDim MessaggioErr(4) + ' ReDim MessaggioErr(4) - ' 'Display error message text - ' MessaggioErr(1) = text2.Line1 - ' MessaggioErr(2) = text2.Line2 - ' MessaggioErr(3) = text2.Line3 - ' MessaggioErr(4) = text2.Line4 - ' Catch ex As Exception + ' 'Display error message text + ' MessaggioErr(1) = text2.Line1 + ' MessaggioErr(2) = text2.Line2 + ' MessaggioErr(3) = text2.Line3 + ' MessaggioErr(4) = text2.Line4 + ' Catch ex As Exception - ' Return 0 - ' 'Dim text2 As MESSAGE_TEXT - ' 'text2.Line1 = "" - ' 'text2.Line2 = "" - ' 'text2.Line3 = "" - ' 'text2.Line4 = "" + ' Return 0 + ' 'Dim text2 As MESSAGE_TEXT + ' 'text2.Line1 = "" + ' 'text2.Line2 = "" + ' 'text2.Line3 = "" + ' 'text2.Line4 = "" - ' ''Invoke native function TranslateErrorMsg() in library OSAI_ErrorMgr.dll - ' 'TranslateErrorMsg(datoErr, text2) + ' ''Invoke native function TranslateErrorMsg() in library OSAI_ErrorMgr.dll + ' 'TranslateErrorMsg(datoErr, text2) - ' 'ReDim MessaggioErr(4) + ' 'ReDim MessaggioErr(4) - ' ''Display error message text - ' 'MessaggioErr(1) = text2.Line1 - ' 'MessaggioErr(2) = text2.Line2 - ' 'MessaggioErr(3) = text2.Line3 - ' 'MessaggioErr(4) = text2.Line4 - ' End Try + ' ''Display error message text + ' 'MessaggioErr(1) = text2.Line1 + ' 'MessaggioErr(2) = text2.Line2 + ' 'MessaggioErr(3) = text2.Line3 + ' 'MessaggioErr(4) = text2.Line4 + ' End Try - ' ReadCurrentErrorMsg = retReadCurrentErrorMsg.retval + ' ReadCurrentErrorMsg = retReadCurrentErrorMsg.retval - 'End Function + 'End Function - '------------------------------ - ' Lettura messaggio DIS - '------------------------------ + '------------------------------ + ' Lettura messaggio DIS + '------------------------------ - Public Overrides Function ReadDisMsg(Optional ByVal nProcess As Integer = 1, Optional ByVal nMac As Integer = 1) As String - Dim InputStruct As New OpenControl.ReadPartProgramMsg - Dim RetVal As OpenControl.ReadPartProgramMsgR + Public Overrides Function ReadDisMsg(Optional ByVal nProcess As Integer = 1, Optional ByVal nMac As Integer = 1) As String + Dim InputStruct As New OpenControl.ReadPartProgramMsg + Dim RetVal As OpenControl.ReadPartProgramMsgR - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.ReadPartProgramMsg(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.ReadPartProgramMsg(InputStruct) - If RetVal.retval > 0 Then - Return RetVal.PartProgramMsg + If RetVal.retval > 0 Then + Return RetVal.PartProgramMsg - Else - mErrMsg = "Error on reading DIS messages" - mErrClass = RetVal.ErrClass - mErrNum = RetVal.ErrNum - Return "" - End If + Else + mErrMsg = "Error on reading DIS messages" + mErrClass = RetVal.ErrClass + mErrNum = RetVal.ErrNum + Return "" + End If - End Function + End Function - ' ------------------------------------------------- - ' Lettura Linee programma corrente - '-------------------------------------------------- - Public Overrides Function ReadPPLines(ByVal nProcess As Integer, ByRef EightLines() As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Boolean - Dim InputStruct As New OpenControl.GetPartProgramLines - Dim RetVal As OpenControl.GetPartProgramLinesR + ' ------------------------------------------------- + ' Lettura Linee programma corrente + '-------------------------------------------------- + Public Overrides Function ReadPPLines(ByVal nProcess As Integer, ByRef EightLines() As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Boolean + Dim InputStruct As New OpenControl.GetPartProgramLines + Dim RetVal As OpenControl.GetPartProgramLinesR - InputStruct.ProcNum = nProcess - RetVal = OsaiServer.GetPartProgramLines(InputStruct) + InputStruct.ProcNum = nProcess + RetVal = OsaiServer.GetPartProgramLines(InputStruct) - If RetVal.retval > 0 Then - EightLines(0) = RetVal.PPLine1 - EightLines(1) = RetVal.PPLine2 - EightLines(2) = RetVal.PPLine3 - EightLines(3) = RetVal.PPLine4 - EightLines(4) = RetVal.PPLine5 - EightLines(5) = RetVal.PPLine6 - EightLines(6) = RetVal.PPLine7 - EightLines(7) = RetVal.PPLine8 + If RetVal.retval > 0 Then + EightLines(0) = RetVal.PPLine1 + EightLines(1) = RetVal.PPLine2 + EightLines(2) = RetVal.PPLine3 + EightLines(3) = RetVal.PPLine4 + EightLines(4) = RetVal.PPLine5 + EightLines(5) = RetVal.PPLine6 + EightLines(6) = RetVal.PPLine7 + EightLines(7) = RetVal.PPLine8 - Return True + Return True - Else - mErrMsg = "Error on reading PP Lines" - mErrClass = RetVal.ErrClass - mErrNum = RetVal.ErrNum + Else + mErrMsg = "Error on reading PP Lines" + mErrClass = RetVal.ErrClass + mErrNum = RetVal.ErrNum - Return False - End If - End Function + Return False + End If + End Function #Region "METODI - funz. aux ( short <> ushort), ..." - ' ---------------------------------------- - ' Trasforma un Unsigned Short in un Short - ' ---------------------------------------- - Public Function UShortToShort(ByVal usValue As UShort) As Short - Dim dValue As Double - Dim numBit As Byte + ' ---------------------------------------- + ' Trasforma un Unsigned Short in un Short + ' ---------------------------------------- + Public Function UShortToShort(ByVal usValue As UShort) As Short + Dim dValue As Double + Dim numBit As Byte - 'numero bit tipo di dato (short -> 16 bit, integer -> 32 bit, long -> 64bit) - numBit = 16 + 'numero bit tipo di dato (short -> 16 bit, integer -> 32 bit, long -> 64bit) + numBit = 16 - If usValue > (2 ^ (numBit - 1) - 1) Then - dValue = CDbl(usValue) - dValue = dValue - CDbl(2 ^ numBit) - UShortToShort = CShort(dValue) - Else - UShortToShort = CShort(usValue) - End If + If usValue > (2 ^ (numBit - 1) - 1) Then + dValue = CDbl(usValue) + dValue = dValue - CDbl(2 ^ numBit) + UShortToShort = CShort(dValue) + Else + UShortToShort = CShort(usValue) + End If - Return UShortToShort - End Function + Return UShortToShort + End Function - ' ---------------------------------------- - ' Trasforma uno Short in un UnisignedShort - ' ---------------------------------------- - Public Function ShortToUShort(ByVal sValue As Short) As UShort - Dim dValue As Double - Dim numBit As Byte + ' ---------------------------------------- + ' Trasforma uno Short in un UnisignedShort + ' ---------------------------------------- + Public Function ShortToUShort(ByVal sValue As Short) As UShort + Dim dValue As Double + Dim numBit As Byte - 'numero bit tipo di dato (short -> 16 bit, integer -> 32 bit, long -> 64bit) - numBit = 16 + 'numero bit tipo di dato (short -> 16 bit, integer -> 32 bit, long -> 64bit) + numBit = 16 - If sValue < 0 Then - dValue = CDbl(sValue) - dValue = dValue + CDbl(2 ^ numBit) - ShortToUShort = CUShort(dValue) - Else - ShortToUShort = CUShort(sValue) - End If + If sValue < 0 Then + dValue = CDbl(sValue) + dValue = dValue + CDbl(2 ^ numBit) + ShortToUShort = CUShort(dValue) + Else + ShortToUShort = CUShort(sValue) + End If - Return ShortToUShort + Return ShortToUShort - End Function + End Function #End Region diff --git a/CVCncLib/testSam.dll b/CVCncLib/testSam.dll index e13ee8be..80054d6b 100644 Binary files a/CVCncLib/testSam.dll and b/CVCncLib/testSam.dll differ diff --git a/Jenkinsfile b/Jenkinsfile index fcc76ce2..e29860ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=306']) { + withEnv(['NEXT_BUILD_NUMBER=307']) { // env.versionNumber = VersionNumber(versionNumberString : '1.18.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '1.18.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO-IOB-WIN'