719 lines
25 KiB
VB.net
719 lines
25 KiB
VB.net
Imports System.Runtime.InteropServices
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Module Osai_RW
|
|
|
|
|
|
'Dim webservice As New OPENControl.OPENcontrolPortTypeClient
|
|
|
|
'Public Const NO_ERROR As UShort = 1
|
|
|
|
' Axis Table Descriptor
|
|
Public Structure AXIS_TABLE
|
|
Public ax_owner() As UShort ' ambient owner
|
|
Public ax_name() As Byte ' ascii axis name
|
|
'Public orig As Double ' actual origin
|
|
'Public free1 As Double ' FREE FIELD
|
|
'Public ofg92 As Double ' offset G92
|
|
'Public toff As Double ' actual tool offset
|
|
'Public free2 As Double ' FREE FIELD
|
|
'Public Offset As Double ' axis total offset
|
|
'Public orig1 As Double ' origin 1
|
|
'Public orig2 As Double ' origin 2
|
|
'Public orig3 As Double ' origin 3
|
|
'Public orig4 As Double ' origin 4
|
|
'Public orig5 As Double ' origin 5
|
|
'Public orig6 As Double ' origin 6
|
|
'Public orig7 As Double ' origin 7
|
|
'Public orig8 As Double ' origin 8
|
|
'Public orig9 As Double ' origin 9
|
|
'Public orig10 As Double ' origin 10
|
|
'Public reserved1 As Integer ' reserved
|
|
'Public reserved2 As Integer ' reserved
|
|
End Structure
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'Boot phase
|
|
Public Const EMERG_SWITCH_PHASE As UShort = 1
|
|
Public Const HW_BOOT_PHASE As UShort = 2
|
|
Public Const SW_BOOT_PHASE As UShort = 3
|
|
Public Const SYSTEM_UP_PHASE As UShort = 4
|
|
Public Const SERVER_MODE_PHASE As UShort = 5
|
|
Public Const REMOTE_SETUP_PHASE As UShort = 6
|
|
Public Const SERVICE_MODE_PHASE As UShort = 7
|
|
Public Const AX_PARAM_VERIFY_PHASE As UShort = 8
|
|
|
|
' Logic variables identifier
|
|
' boolean variables
|
|
Public Const I_CODE As UShort = 0
|
|
Public Const O_CODE As UShort = 1
|
|
Public Const M_CODE As UShort = 2
|
|
Public Const G_CODE As UShort = 3
|
|
Public Const S_CODE As UShort = 4
|
|
Public Const P_CODE As UShort = 7
|
|
Public Const U_CODE As UShort = 8
|
|
' WORD variables
|
|
Public Const MW_CODE As UShort = 20
|
|
Public Const GW_CODE As UShort = 21
|
|
Public Const SW_CODE As UShort = 22
|
|
Public Const PW_CODE As UShort = 62
|
|
Public Const UW_CODE As UShort = 63
|
|
' DOUBLE variables
|
|
Public Const MD_CODE As UShort = 40
|
|
Public Const GD_CODE As UShort = 41
|
|
Public Const PD_CODE As UShort = 43
|
|
Public Const UD_CODE As UShort = 44
|
|
|
|
' TEXT variables
|
|
Public Const SC_CODE As UShort = 50
|
|
|
|
Public OsaiServer As New OpenControl.OPENcontrolPortTypeClient()
|
|
Public bOsaiServerCreated As Boolean
|
|
|
|
Public 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)
|
|
|
|
nErrClass = retBootPhaseInquiry.ErrClass
|
|
nErrNum = retBootPhaseInquiry.ErrNum
|
|
Phase = retBootPhaseInquiry.Phase
|
|
|
|
O_BootPhaseEnquiry = retBootPhaseInquiry.retval
|
|
|
|
End Function
|
|
|
|
Public Function O_WriteVarText(ByVal nTypeMem As Integer, ByVal nProcess As Integer, ByVal nStartVar As Integer, ByVal nVariable As Integer, ByRef szText As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
|
|
Dim oWriteVarText As New OpenControl.WriteVarText
|
|
Dim retWriteVarText As New OpenControl.WriteVarTextR
|
|
|
|
oWriteVarText.Code = nTypeMem
|
|
oWriteVarText.Index = nStartVar
|
|
oWriteVarText.Len = nVariable
|
|
oWriteVarText.Process = nProcess
|
|
oWriteVarText.Text = szText
|
|
|
|
retWriteVarText = OsaiServer.WriteVarText(oWriteVarText)
|
|
|
|
nErrClass = retWriteVarText.ErrClass
|
|
nErrNum = retWriteVarText.ErrNum
|
|
|
|
O_WriteVarText = retWriteVarText.retval
|
|
|
|
|
|
End Function
|
|
|
|
Public Function O_ReadVarText(ByVal nTypeMem As Integer, ByVal nProcess As Integer, ByVal nStartVar As Integer, ByVal nVariable As Integer, ByRef szText As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
|
|
Dim oReadVarText As New OpenControl.ReadVarText
|
|
Dim retReadVarText As New OpenControl.ReadVarTextR
|
|
|
|
oReadVarText.Code = nTypeMem
|
|
oReadVarText.Index = nStartVar
|
|
oReadVarText.Size = nVariable
|
|
oReadVarText.Process = nProcess
|
|
|
|
retReadVarText = OsaiServer.ReadVarText(oReadVarText)
|
|
|
|
nErrClass = retReadVarText.ErrClass
|
|
nErrNum = retReadVarText.ErrNum
|
|
szText = retReadVarText.Text
|
|
|
|
O_ReadVarText = retReadVarText.retval
|
|
|
|
End Function
|
|
|
|
Public Function O_WriteVarDouble(ByVal nTypeMem As Integer, ByVal nProcess As Integer, ByVal nIndex As Integer, ByVal nNumVar As Integer, ByRef sValue() As Double, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
|
|
Dim oWriteVarDouble As New OpenControl.WriteVarDouble
|
|
Dim retWriteVarDouble As New OpenControl.WriteVarDoubleR
|
|
|
|
oWriteVarDouble.Code = nTypeMem
|
|
oWriteVarDouble.Index = nIndex
|
|
oWriteVarDouble.NumVar = nNumVar
|
|
oWriteVarDouble.Process = nProcess
|
|
ReDim oWriteVarDouble.Value(nNumVar - 1)
|
|
oWriteVarDouble.Value = sValue
|
|
|
|
retWriteVarDouble = OsaiServer.WriteVarDouble(oWriteVarDouble)
|
|
|
|
nErrClass = retWriteVarDouble.ErrClass
|
|
nErrNum = retWriteVarDouble.ErrNum
|
|
|
|
O_WriteVarDouble = retWriteVarDouble.retval
|
|
|
|
End Function
|
|
|
|
Public Function O_ReadVarDouble(ByVal nTypeMem As UShort, ByVal nProcess As UShort, ByVal nIndex As UShort, ByVal nNumVar As UShort, ByRef sValue() As Double, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim oReadVarDouble As New OpenControl.ReadVarDouble
|
|
Dim retReadVarDouble As New OpenControl.ReadVarDoubleR
|
|
|
|
oReadVarDouble.Code = nTypeMem
|
|
oReadVarDouble.Index = nIndex
|
|
oReadVarDouble.NumVar = nNumVar
|
|
oReadVarDouble.Process = nProcess
|
|
|
|
retReadVarDouble = OsaiServer.ReadVarDouble(oReadVarDouble)
|
|
|
|
If retReadVarDouble.retval = NO_ERROR Then
|
|
sValue = retReadVarDouble.Value
|
|
End If
|
|
|
|
nErrClass = retReadVarDouble.ErrClass
|
|
nErrNum = retReadVarDouble.ErrNum
|
|
|
|
O_ReadVarDouble = retReadVarDouble.retval
|
|
|
|
End Function
|
|
|
|
Public Function O_WriteVarWordBit(ByVal nTypeMem As Integer, ByVal nProcess As Integer, ByVal nIndex As Integer, ByVal nBitIndex As UShort, ByVal nBitValue As UShort, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
|
|
Dim oWriteVarWordBit As New OpenControl.WriteVarWordBit
|
|
Dim retWriteVarWordBit As New OpenControl.WriteVarWordBitR
|
|
|
|
oWriteVarWordBit.Code = nTypeMem
|
|
oWriteVarWordBit.Index = nIndex
|
|
oWriteVarWordBit.BitIndex = nBitIndex
|
|
oWriteVarWordBit.Process = nProcess
|
|
oWriteVarWordBit.BitValue = nBitValue
|
|
|
|
|
|
retWriteVarWordBit = OsaiServer.WriteVarWordBit(oWriteVarWordBit)
|
|
|
|
nErrClass = retWriteVarWordBit.ErrClass
|
|
nErrNum = retWriteVarWordBit.ErrNum
|
|
|
|
O_WriteVarWordBit = retWriteVarWordBit.retval
|
|
|
|
End Function
|
|
|
|
Public Function O_WriteVarWord(ByVal nTypeMem As Integer, ByVal nProcess As Integer, ByVal nIndex As Integer, ByVal nNumVar As Integer, ByRef sValue() As UShort, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
|
|
Dim oWriteVarWord As New OpenControl.WriteVarWord
|
|
Dim retWriteVarWord As New OpenControl.WriteVarWordR
|
|
|
|
oWriteVarWord.Code = nTypeMem
|
|
oWriteVarWord.Index = nIndex
|
|
oWriteVarWord.NumVar = nNumVar
|
|
oWriteVarWord.Process = nProcess
|
|
ReDim oWriteVarWord.Value(nNumVar - 1)
|
|
oWriteVarWord.Value = sValue
|
|
|
|
retWriteVarWord = OsaiServer.WriteVarWord(oWriteVarWord)
|
|
|
|
nErrClass = retWriteVarWord.ErrClass
|
|
nErrNum = retWriteVarWord.ErrNum
|
|
|
|
O_WriteVarWord = retWriteVarWord.retval
|
|
|
|
End Function
|
|
|
|
Public Function O_ReadVarWordBit(ByVal nTypeMem As Integer, ByVal nProcess As Integer, ByVal nIndex As Integer, ByVal nBitIndex As UShort, ByRef nBitValue As UShort, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim retStatus As Integer
|
|
Dim swValue(0) As UShort
|
|
|
|
retStatus = O_ReadVarWord(nTypeMem, nProcess, nIndex, 1, swValue, nErrClass, nErrNum)
|
|
|
|
If retStatus = NO_ERROR Then
|
|
If (swValue(0) And (2 ^ nBitIndex)) = (2 ^ nBitIndex) Then
|
|
nBitValue = 1
|
|
Else
|
|
nBitValue = 0
|
|
End If
|
|
End If
|
|
|
|
O_ReadVarWordBit = retStatus
|
|
|
|
End Function
|
|
|
|
Public Function O_ReadVarWord(ByVal nTypeMem As UShort, ByVal nProcess As UShort, ByVal nIndex As UShort, ByVal nNumVar As UShort, ByRef sValue() As UShort, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim oReadVarWord As New OpenControl.ReadVarWord
|
|
Dim retReadVarWord As New OpenControl.ReadVarWordR
|
|
|
|
oReadVarWord.Code = nTypeMem
|
|
oReadVarWord.Index = nIndex
|
|
oReadVarWord.NumVar = nNumVar
|
|
oReadVarWord.Process = nProcess
|
|
|
|
retReadVarWord = OsaiServer.ReadVarWord(oReadVarWord)
|
|
|
|
If retReadVarWord.retval = NO_ERROR Then
|
|
sValue = retReadVarWord.Value
|
|
End If
|
|
|
|
nErrClass = retReadVarWord.ErrClass
|
|
nErrNum = retReadVarWord.ErrNum
|
|
|
|
O_ReadVarWord = retReadVarWord.retval
|
|
|
|
End Function
|
|
|
|
Public Function O_GetSelectedProcess(ByRef nProcess As Integer, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim oGetSelectedProcess As New OpenControl.GetSelectedProcess
|
|
Dim retGetSelectedProcess As New OpenControl.GetSelectedProcessR
|
|
|
|
retGetSelectedProcess = OsaiServer.GetSelectedProcess(oGetSelectedProcess)
|
|
nErrClass = retGetSelectedProcess.ErrClass
|
|
nErrNum = retGetSelectedProcess.ErrNum
|
|
nProcess = retGetSelectedProcess.ProcNum
|
|
|
|
O_GetSelectedProcess = retGetSelectedProcess.retval
|
|
|
|
End Function
|
|
|
|
Public Function O_GetAxisTabRecord(ByVal nAxes As Integer, ByRef sAxisTable As AXIS_TABLE, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim oGetAxisInfo3 As New OpenControl.GetAxesInfo3
|
|
Dim retGetAxisInfo3 As New OpenControl.GetAxesInfo3R
|
|
|
|
oGetAxisInfo3.AxesNum = nAxes
|
|
|
|
retGetAxisInfo3 = OsaiServer.GetAxesInfo3(oGetAxisInfo3)
|
|
|
|
sAxisTable.ax_name = retGetAxisInfo3.AxNameList
|
|
sAxisTable.ax_owner = retGetAxisInfo3.AxOwnerList
|
|
nErrClass = retGetAxisInfo3.ErrClass
|
|
nErrNum = retGetAxisInfo3.ErrNum
|
|
|
|
O_GetAxisTabRecord = retGetAxisInfo3.retval
|
|
|
|
End Function
|
|
|
|
'non utilizzabile verso il cnc
|
|
Public Function O_LogFSCopyFile(ByRef szPathFile As String, ByVal szTargetPath As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim oLogFSCopyFile As New OpenControl.LogFSCopyFile
|
|
Dim retLogFSCopyFile As New OpenControl.LogFSCopyFileR
|
|
|
|
oLogFSCopyFile.FailIfExists = False
|
|
oLogFSCopyFile.PathName = szPathFile
|
|
oLogFSCopyFile.NewPathName = szTargetPath
|
|
|
|
retLogFSCopyFile = OsaiServer.LogFSCopyFile(oLogFSCopyFile)
|
|
|
|
nErrClass = retLogFSCopyFile.ErrClass
|
|
nErrNum = retLogFSCopyFile.ErrNum
|
|
|
|
O_LogFSCopyFile = retLogFSCopyFile.retval
|
|
|
|
End Function
|
|
|
|
'utilizzabile per la copia di file dal cnc
|
|
Public Function O_GetBinaryFile(ByRef szPathFile As String, ByVal szTargetPath As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim oGetFile As New OpenControl.GetBinaryFile
|
|
Dim retGetFile As New OpenControl.GetBinaryFileR
|
|
|
|
|
|
Dim oSizeFile As New OpenControl.LogFSGetFileSize
|
|
Dim retSizeFile As New OpenControl.LogFSGetFileSizeR
|
|
|
|
Dim szStringaFinale As String
|
|
|
|
oSizeFile.PathName = szPathFile
|
|
retSizeFile = OsaiServer.LogFSGetFileSize(oSizeFile)
|
|
|
|
oGetFile.PathName = szPathFile
|
|
oGetFile.Size = retSizeFile.Size
|
|
|
|
retGetFile = OsaiServer.GetBinaryFile(oGetFile)
|
|
|
|
szStringaFinale = System.Text.Encoding.Default.GetString(retGetFile.Data)
|
|
|
|
If (retGetFile.retval = NO_ERROR) Then
|
|
'apro il file in szTargetPath
|
|
My.Computer.FileSystem.WriteAllText(szTargetPath, szStringaFinale, False)
|
|
End If
|
|
|
|
nErrClass = retGetFile.ErrClass
|
|
nErrNum = retGetFile.ErrNum
|
|
|
|
O_GetBinaryFile = retGetFile.retval
|
|
|
|
End Function
|
|
|
|
'utilizzabile per la copia di file verso cnc
|
|
Public Function O_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
|
|
|
|
szData = ""
|
|
|
|
'apro il file in szPathFile
|
|
szData = My.Computer.FileSystem.ReadAllText(szPathFile, System.Text.Encoding.UTF8)
|
|
|
|
oPutFile.Data = szData
|
|
oPutFile.Size = FileSize
|
|
|
|
'calcolo la dimensione in byte e la metto in oPutFile.Size
|
|
oPutFile.Size = szData.Length
|
|
|
|
retPutFile = OsaiServer.PutFile(oPutFile)
|
|
|
|
nErrClass = retPutFile.ErrClass
|
|
nErrNum = retPutFile.ErrNum
|
|
|
|
O_PutFile = retPutFile.retval
|
|
|
|
End Function
|
|
|
|
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
|
|
|
|
If usValue > (2 ^ (numBit - 1) - 1) Then
|
|
dValue = CDbl(usValue)
|
|
dValue = dValue - CDbl(2 ^ numBit)
|
|
UShortToShort = CShort(dValue)
|
|
Else
|
|
UShortToShort = CShort(usValue)
|
|
End If
|
|
|
|
End Function
|
|
|
|
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
|
|
|
|
If sValue < 0 Then
|
|
dValue = CDbl(sValue)
|
|
dValue = dValue + CDbl(2 ^ numBit)
|
|
ShortToUShort = CUShort(dValue)
|
|
Else
|
|
ShortToUShort = CUShort(sValue)
|
|
End If
|
|
|
|
End Function
|
|
|
|
Public Function UIntToInt(ByVal usValue As UInteger) As Integer
|
|
Dim dValue As Double
|
|
Dim numBit As Byte
|
|
|
|
'numero bit tipo di dato (short -> 16 bit, integer -> 32 bit, long -> 64bit)
|
|
numBit = 32
|
|
|
|
If usValue > (2 ^ (numBit - 1) - 1) Then
|
|
dValue = CDbl(usValue)
|
|
dValue = dValue - CDbl(2 ^ numBit)
|
|
UIntToInt = CInt(dValue)
|
|
Else
|
|
UIntToInt = CInt(usValue)
|
|
End If
|
|
|
|
End Function
|
|
|
|
Public Function IntToUInt(ByVal sValue As Integer) As UInteger
|
|
Dim dValue As Double
|
|
Dim numBit As Byte
|
|
|
|
'numero bit tipo di dato (short -> 16 bit, integer -> 32 bit, long -> 64bit)
|
|
numBit = 32
|
|
|
|
If sValue < 0 Then
|
|
dValue = CDbl(sValue)
|
|
dValue = dValue + CDbl(2 ^ numBit)
|
|
IntToUInt = CUInt(dValue)
|
|
Else
|
|
IntToUInt = CUInt(sValue)
|
|
End If
|
|
|
|
End Function
|
|
|
|
Public Function ULongToLong(ByVal usValue As ULong) As Long
|
|
Dim dValue As Double
|
|
Dim numBit As Byte
|
|
|
|
'numero bit tipo di dato (short -> 16 bit, integer -> 32 bit, long -> 64bit)
|
|
numBit = 64
|
|
|
|
If usValue > (2 ^ (numBit - 1) - 1) Then
|
|
dValue = CDbl(usValue)
|
|
dValue = dValue - CDbl(2 ^ numBit)
|
|
ULongToLong = CLng(dValue)
|
|
Else
|
|
ULongToLong = CLng(usValue)
|
|
End If
|
|
|
|
End Function
|
|
|
|
Public Function LongToULong(ByVal sValue As Long) As ULong
|
|
Dim dValue As Double
|
|
Dim numBit As Byte
|
|
|
|
'numero bit tipo di dato (short -> 16 bit, integer -> 32 bit, long -> 64bit)
|
|
numBit = 64
|
|
|
|
If sValue < 0 Then
|
|
dValue = CDbl(sValue)
|
|
dValue = dValue + CDbl(2 ^ numBit)
|
|
LongToULong = CLng(dValue)
|
|
Else
|
|
LongToULong = CLng(sValue)
|
|
End If
|
|
|
|
End Function
|
|
|
|
Public Function o_Connection(ByVal sValue As String) As ULong
|
|
OsaiServer = New OPENControl.OPENcontrolPortTypeClient("OPENcontrol", "http://" & sValue & ":8080")
|
|
o_Connection = OsaiServer.State
|
|
End Function
|
|
|
|
Public Function o_GetNumDrive(ByRef DriveLog As Integer) As String
|
|
' Legge numero drive connessi
|
|
Dim oGetNumDrive As New OpenControl.LogFSGetNumDrive
|
|
Dim retGetNumDrive As New OpenControl.LogFSGetNumDriveR
|
|
'
|
|
retGetNumDrive = OsaiServer.LogFSGetNumDrive(oGetNumDrive)
|
|
'
|
|
DriveLog = retGetNumDrive.NumUserDrive
|
|
o_GetNumDrive = retGetNumDrive.retval
|
|
'
|
|
End Function
|
|
|
|
Public Function O_GetNameDrive(ByRef DriveLog As Integer, ByRef NameLogic() As String) As String
|
|
' Leggo nome drive logici
|
|
Dim oGetDriveList As New OpenControl.LogFSGetDriveList
|
|
Dim retGetDriveList As New OpenControl.LogFSGetDriveListR
|
|
For i = 1 To DriveLog
|
|
oGetDriveList.Index = i
|
|
retGetDriveList = OsaiServer.LogFSGetDriveList(oGetDriveList)
|
|
errClass = retGetDriveList.ErrClass
|
|
errNum = retGetDriveList.ErrNum
|
|
Console.WriteLine(retGetDriveList.DriveName & " " & errClass & " " & errNum)
|
|
ReDim Preserve NameLogic(i)
|
|
NameLogic(i) = retGetDriveList.DriveName
|
|
Next i
|
|
O_GetNameDrive = retGetDriveList.retval
|
|
End Function
|
|
|
|
Public Function o_FindDirFile(ByRef NomeDrive As String, ByRef ListaDir() As String, ByRef ListaFile() As String) As Boolean
|
|
' Leggo nome file/directory nel path specificato
|
|
' Cerca primo file/dir
|
|
Dim oFindFirst As New OpenControl.LogFSFindFirst
|
|
Dim retFindFirst As New OpenControl.LogFSFindFirstR
|
|
' Cerca successivo file/dir
|
|
Dim oFindNext As New OpenControl.LogFSFindNext
|
|
Dim retFindNext As New OpenControl.LogFSFindNextR
|
|
' Chiudi ricerca
|
|
Dim oFindClose As New OpenControl.LogFSFindClose
|
|
Dim retFindClose As New OpenControl.LogFSFindCloseR
|
|
'
|
|
Dim ContaFile As Integer = 1
|
|
Dim ContaDir As Integer = 1
|
|
'
|
|
oFindFirst.FileName = NomeDrive & "\\*.*"
|
|
retFindFirst = OsaiServer.LogFSFindFirst(oFindFirst)
|
|
errClass = retFindFirst.ErrClass
|
|
errNum = retFindFirst.ErrNum
|
|
Console.WriteLine(errClass & " " & errNum)
|
|
If retFindFirst.FindData.FileAttributes = 32 Then ReDim Preserve ListaFile(ContaFile) : ListaFile(ContaFile) = retFindFirst.FindData.FileName : ContaFile = ContaFile + 1
|
|
If retFindFirst.FindData.FileAttributes = 16 Then ReDim Preserve ListaDir(ContaDir) : ListaDir(ContaDir) = retFindFirst.FindData.FileName : ContaDir = ContaDir + 1
|
|
oFindNext.Finder = retFindFirst.Finder
|
|
repeat:
|
|
retFindNext = OsaiServer.LogFSFindNext(oFindNext)
|
|
If retFindNext.FindData.FileAttributes = 32 Then ReDim Preserve ListaFile(ContaFile) : ListaFile(ContaFile) = retFindNext.FindData.FileName : ContaFile = ContaFile + 1
|
|
If retFindNext.FindData.FileAttributes = 16 Then ReDim Preserve ListaDir(ContaDir) : ListaDir(ContaDir) = retFindNext.FindData.FileName : ContaDir = ContaDir + 1
|
|
If retFindNext.Found = True Then GoTo repeat
|
|
oFindClose.Finder = oFindNext.Finder
|
|
retFindClose = OsaiServer.LogFSFindClose(oFindClose)
|
|
errClass = retFindClose.ErrClass
|
|
errNum = retFindClose.ErrNum
|
|
Console.WriteLine(errClass & " " & errNum)
|
|
o_FindDirFile = True
|
|
End Function
|
|
|
|
Public Function O_ReadPartProgramMsg(ByVal nProcess As Integer, ByRef MessaggioDis As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim oReadPartProgramMsg As New OpenControl.ReadPartProgramMsg
|
|
Dim retReadPartProgramMsg As New OpenControl.ReadPartProgramMsgR
|
|
oReadPartProgramMsg.ProcNum = nProcess
|
|
retReadPartProgramMsg = OsaiServer.ReadPartProgramMsg(oReadPartProgramMsg)
|
|
MessaggioDis = retReadPartProgramMsg.PartProgramMsg
|
|
nErrClass = retReadPartProgramMsg.ErrClass
|
|
nErrNum = retReadPartProgramMsg.ErrNum
|
|
O_ReadPartProgramMsg = retReadPartProgramMsg.retval
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Public Function O_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
|
|
|
|
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)
|
|
|
|
Dim text2 As MESSAGE_TEXT
|
|
text2.Line1 = ""
|
|
text2.Line2 = ""
|
|
text2.Line3 = ""
|
|
text2.Line4 = ""
|
|
|
|
'Invoke native function TranslateErrorMsg() in library OSAI_ErrorMgr.dll
|
|
OSAIErrorManagerLibrary.TranslateErrorMsg(datoErr, text2)
|
|
|
|
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
|
|
Dim text2 As MESSAGE_TEXT
|
|
text2.Line1 = ""
|
|
text2.Line2 = ""
|
|
text2.Line3 = ""
|
|
text2.Line4 = ""
|
|
|
|
'Invoke native function TranslateErrorMsg() in library OSAI_ErrorMgr.dll
|
|
OSAIErrorManagerLibrary.TranslateErrorMsg(datoErr, text2)
|
|
|
|
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
|
|
|
|
|
|
O_ReadCurrentErrorMsg = retReadCurrentErrorMsg.retval
|
|
|
|
End Function
|
|
|
|
Public Function O_ActiveProgram(ByVal nProcess As Integer, ByRef ProgramActive As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim oGetActivePartProgram As New OpenControl.GetActivePartProgram
|
|
Dim retGetActivePartProgram As New OpenControl.GetActivePartProgramR
|
|
oGetActivePartProgram.ProcNum = nProcess
|
|
retGetActivePartProgram = OsaiServer.GetActivePartProgram(oGetActivePartProgram)
|
|
ProgramActive = retGetActivePartProgram.Main
|
|
nErrClass = retGetActivePartProgram.ErrClass
|
|
nErrNum = retGetActivePartProgram.ErrNum
|
|
O_ActiveProgram = retGetActivePartProgram.retval
|
|
End Function
|
|
|
|
Public Function O_SelectPartProgram(ByVal nProcess As Integer, ByRef ProgramToActive As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim oSelectPartProgram As New OpenControl.SelectPartProgramFromDrive
|
|
Dim retSelectPartProgram As New OpenControl.SelectPartProgramFromDriveR
|
|
oSelectPartProgram.ProcNum = nProcess
|
|
oSelectPartProgram.PPName = ProgramToActive
|
|
retSelectPartProgram = OsaiServer.SelectPartProgramFromDrive(oSelectPartProgram)
|
|
nErrClass = retSelectPartProgram.ErrClass
|
|
nErrNum = retSelectPartProgram.ErrNum
|
|
O_SelectPartProgram = retSelectPartProgram.retval
|
|
End Function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Public Function O_ReadMessage(ByVal nProcNum As UShort, ByRef szErrMsg() As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim oReadErrMsg As New OpenControl.ReadErrMsg
|
|
Dim retReadErrMsg As New OpenControl.ReadErrMsgR
|
|
|
|
Dim sErrMsg As OpenControl.ERRMSG
|
|
|
|
oReadErrMsg.ProcNum = nProcNum
|
|
|
|
retReadErrMsg = OsaiServer.ReadErrMsg(oReadErrMsg)
|
|
|
|
sErrMsg = retReadErrMsg.SysErrMsg
|
|
|
|
Try
|
|
|
|
ReDim szErrMsg(4)
|
|
|
|
szErrMsg(0) = sErrMsg.Msg1
|
|
szErrMsg(1) = sErrMsg.Msg2
|
|
szErrMsg(2) = sErrMsg.Msg3
|
|
szErrMsg(3) = sErrMsg.Msg4
|
|
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
nErrClass = retReadErrMsg.ErrClass
|
|
nErrNum = retReadErrMsg.ErrNum
|
|
|
|
O_ReadMessage = retReadErrMsg.retval
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Public Function O_ReadWarningMessage(ByVal nProcNum As UShort, ByRef szErrMsg As String, ByRef nErrClass As UInteger, ByRef nErrNum As UInteger) As Integer
|
|
Dim oReadWarningMsg As New OpenControl.ReadWarningMsg
|
|
Dim retReadWarningMsg As New OpenControl.ReadWarningMsgR
|
|
|
|
retReadWarningMsg = OsaiServer.ReadWarningMsg(oReadWarningMsg)
|
|
|
|
szErrMsg = retReadWarningMsg.WarningMsg
|
|
|
|
nErrClass = retReadWarningMsg.ErrClass
|
|
nErrNum = retReadWarningMsg.ErrNum
|
|
|
|
O_ReadWarningMessage = retReadWarningMsg.retval
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End Module
|