OmagCUT 1.6u4 :
- gestione nesting allineato (con regione di riferimento a L) - gestione epl pezzi rovinati da OmagVIEW per linee di produzione - piccole migliorie varie.
This commit is contained in:
+87
-103
@@ -21,6 +21,7 @@ Module M_MMFiles
|
||||
#Region " Structures"
|
||||
|
||||
|
||||
<StructLayout(LayoutKind.Sequential)> _
|
||||
Structure SiemensSendStruct
|
||||
|
||||
Public n_Flag As Integer
|
||||
@@ -42,7 +43,7 @@ Module M_MMFiles
|
||||
|
||||
End Structure
|
||||
|
||||
Dim SiemensSend As SiemensSendStruct
|
||||
Private SiemensSend As SiemensSendStruct
|
||||
|
||||
|
||||
<StructLayout(LayoutKind.Sequential)> _
|
||||
@@ -116,7 +117,7 @@ Module M_MMFiles
|
||||
' view must be within the maximum size of the file mapping object (MAP_SIZE).
|
||||
' If VIEW_SIZE is 0, the mapping extends from the offset (VIEW_OFFSET) to
|
||||
' the end of the file mapping.
|
||||
Friend Const ViewSize As UInt32 = &H400
|
||||
Friend Const ViewSize As UInt32 = &H1000
|
||||
|
||||
#End Region
|
||||
|
||||
@@ -192,9 +193,9 @@ Module M_MMFiles
|
||||
'
|
||||
Sub init()
|
||||
|
||||
Call MMFile_init()
|
||||
MMFile_init()
|
||||
|
||||
Call Timer_init()
|
||||
Timer_init()
|
||||
|
||||
End Sub
|
||||
|
||||
@@ -270,7 +271,7 @@ Module M_MMFiles
|
||||
' scrivo !!!!!
|
||||
Marshal.StructureToPtr(SiemensSend, pView, False)
|
||||
|
||||
' Call execute_command()
|
||||
' execute_command()
|
||||
|
||||
System.Threading.Thread.Sleep(2000)
|
||||
|
||||
@@ -316,7 +317,7 @@ Module M_MMFiles
|
||||
SiemensSend.n_Command = CMD.CMD_ActivateProgram
|
||||
SiemensSend.sz_string = sz_part_program
|
||||
|
||||
Call execute_command()
|
||||
execute_command()
|
||||
EgtOutLog("ActivateProgram end dell'm_mmFiles")
|
||||
Return SiemensRet.n_result
|
||||
|
||||
@@ -328,7 +329,7 @@ Module M_MMFiles
|
||||
SiemensSend.n_Command = CMD.CMD_Delete_NC_prog
|
||||
SiemensSend.sz_string = sz_filename
|
||||
|
||||
Call execute_command()
|
||||
execute_command()
|
||||
EgtOutLog("Delete_NC_prog end dell'm_mmFiles")
|
||||
Return SiemensRet.n_result
|
||||
|
||||
@@ -339,7 +340,7 @@ Module M_MMFiles
|
||||
|
||||
SiemensSend.n_Command = CMD.CMD_CycleStart
|
||||
|
||||
Call execute_command()
|
||||
execute_command()
|
||||
EgtOutLog("CycleStart end dell'm_mmFiles")
|
||||
Return SiemensRet.n_result
|
||||
|
||||
@@ -350,7 +351,7 @@ Module M_MMFiles
|
||||
|
||||
SiemensSend.n_Command = CMD.CMD_FeedHold
|
||||
|
||||
Call execute_command()
|
||||
execute_command()
|
||||
EgtOutLog("FeedHold end dell'm_mmFiles")
|
||||
Return SiemensRet.n_result
|
||||
|
||||
@@ -361,7 +362,7 @@ Module M_MMFiles
|
||||
|
||||
SiemensSend.n_Command = CMD.CMD_Reset
|
||||
|
||||
Call execute_command()
|
||||
execute_command()
|
||||
EgtOutLog("Reset end dell'm_mmFiles")
|
||||
Return SiemensRet.n_result
|
||||
|
||||
@@ -372,7 +373,7 @@ Module M_MMFiles
|
||||
SiemensSend.n_Command = CMD.CMD_WriteCncMode
|
||||
SiemensSend.n_param1 = nmode
|
||||
|
||||
Call execute_command()
|
||||
execute_command()
|
||||
EgtOutLog("WriteCncMode end dell'm_mmFiles")
|
||||
Return SiemensRet.n_result
|
||||
|
||||
@@ -384,7 +385,7 @@ Module M_MMFiles
|
||||
SiemensSend.sz_string = sz_Pc_file_name
|
||||
SiemensSend.sz_string_2 = sz_NC_filen
|
||||
|
||||
Call execute_command()
|
||||
execute_command()
|
||||
EgtOutLog("Download_NC_prog end dell'm_mmFiles")
|
||||
Return SiemensRet.n_result
|
||||
|
||||
@@ -400,7 +401,7 @@ Module M_MMFiles
|
||||
SiemensSend.n_Command = CMD.CMD_MDI_command
|
||||
SiemensSend.sz_string = sz_command
|
||||
|
||||
Call execute_command()
|
||||
execute_command()
|
||||
EgtOutLog("MDI_command end dell'm_mmFiles")
|
||||
Return SiemensRet.n_result
|
||||
|
||||
@@ -411,7 +412,7 @@ Module M_MMFiles
|
||||
SiemensSend.n_Command = CMD.CMD_set_OP_OM
|
||||
SiemensSend.n_param1 = n
|
||||
|
||||
Call execute_command()
|
||||
execute_command()
|
||||
EgtOutLog("set_OP_OM end dell'm_mmFiles")
|
||||
End Sub
|
||||
|
||||
@@ -419,7 +420,7 @@ Module M_MMFiles
|
||||
EgtOutLog("read_active_mode start dell'm_mmFiles")
|
||||
SiemensSend.n_Command = CMD.CMD_read_active_mode
|
||||
|
||||
Call execute_command()
|
||||
execute_command()
|
||||
EgtOutLog("read_active_mode end dell'm_mmFiles")
|
||||
Return SiemensRet.n_result
|
||||
|
||||
@@ -440,7 +441,7 @@ Module M_MMFiles
|
||||
SiemensSend.n_Command = CMD.CMD_Read_Nc_var
|
||||
SiemensSend.n_param1 = n_var
|
||||
|
||||
Call execute_command()
|
||||
execute_command()
|
||||
|
||||
m_MainWindow.m_CNCommunication.m_CN.d_DReadELS_value = SiemensRet.d_param1
|
||||
EgtOutLog("Read_Nc_var end dell'm_mmFiles")
|
||||
@@ -453,64 +454,54 @@ Module M_MMFiles
|
||||
'
|
||||
Sub execute_command()
|
||||
|
||||
Dim lstate As State = State.Command_on
|
||||
Dim b_end As Boolean = False
|
||||
Try
|
||||
|
||||
' attesa eventuale busy iniziale
|
||||
b_end = False
|
||||
While Not b_end
|
||||
' Attesa eventuale busy iniziale
|
||||
Dim bEnd As Boolean = False
|
||||
While Not bEnd
|
||||
If SiemensRet.b_busy Then
|
||||
System.Threading.Thread.Sleep(100) ' se busy attendo a botte di 100 msec
|
||||
System.Threading.Thread.Sleep(50)
|
||||
Else
|
||||
b_end = True
|
||||
bEnd = True
|
||||
End If
|
||||
End While
|
||||
|
||||
SiemensSend.n_Flag = COMMAND_ON ' alzo il comando
|
||||
' scrivo !!!!!
|
||||
' Alzo il comando
|
||||
SiemensSend.n_Flag = COMMAND_ON
|
||||
' scrivo
|
||||
Marshal.StructureToPtr(SiemensSend, pView, False)
|
||||
|
||||
b_end = False
|
||||
While Not b_end
|
||||
|
||||
Select Case lstate
|
||||
|
||||
Case State.Command_on ' alzato il comando attendo il busy
|
||||
|
||||
If SiemensRet.b_busy Then
|
||||
lstate = State.Busy_On
|
||||
Else
|
||||
System.Threading.Thread.Sleep(100)
|
||||
End If
|
||||
|
||||
Case State.Busy_On ' trovato il busy abbasso il comando
|
||||
|
||||
SiemensSend.n_Flag = COMMAND_OFF ' abbasso il comando
|
||||
' scrivo !!!!!
|
||||
Marshal.StructureToPtr(SiemensSend, pView, False)
|
||||
|
||||
lstate = State.Command_off
|
||||
|
||||
|
||||
Case State.Command_off
|
||||
|
||||
If Not SiemensRet.b_busy Then ' abbassato il comando attendo il busy basso
|
||||
lstate = State.Busy_Off
|
||||
Else
|
||||
System.Threading.Thread.Sleep(100)
|
||||
End If
|
||||
|
||||
|
||||
Case State.Busy_Off
|
||||
b_end = True
|
||||
|
||||
' Ciclo di attesa della risposta
|
||||
Dim nState As State = State.Command_on
|
||||
bEnd = False
|
||||
While Not bEnd
|
||||
Select Case nState
|
||||
Case State.Command_on ' alzato il comando attendo il busy
|
||||
If SiemensRet.b_busy Then
|
||||
nState = State.Busy_On
|
||||
Else
|
||||
System.Threading.Thread.Sleep(50)
|
||||
End If
|
||||
Case State.Busy_On ' trovato il busy abbasso il comando
|
||||
SiemensSend.n_Flag = COMMAND_OFF ' abbasso il comando
|
||||
' scrivo !!!!!
|
||||
Marshal.StructureToPtr(SiemensSend, pView, False)
|
||||
nState = State.Command_off
|
||||
Case State.Command_off
|
||||
If Not SiemensRet.b_busy Then ' abbassato il comando attendo il busy basso
|
||||
nState = State.Busy_Off
|
||||
Else
|
||||
System.Threading.Thread.Sleep(50)
|
||||
End If
|
||||
Case State.Busy_Off
|
||||
bEnd = True
|
||||
End Select
|
||||
|
||||
End While
|
||||
|
||||
EgtOutLog("Eseguito comando :" & SiemensSend.n_Command.ToString())
|
||||
|
||||
Catch ex As Exception
|
||||
EgtOutLog("Errore nell'esecuzione di un comando" & ex.ToString)
|
||||
EgtOutLog("Errore nell'esecuzione di un comando :" & ex.ToString())
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
@@ -545,7 +536,7 @@ Module M_MMFiles
|
||||
aTimer.Enabled = False
|
||||
b_busy = True
|
||||
|
||||
Call TimerProcessing()
|
||||
TimerProcessing()
|
||||
|
||||
b_busy = False
|
||||
aTimer.Enabled = True
|
||||
@@ -555,12 +546,11 @@ Module M_MMFiles
|
||||
|
||||
Sub TimerProcessing()
|
||||
|
||||
' !!!!!!!!!!!! mettete tutti i travasi di dati
|
||||
|
||||
Try
|
||||
|
||||
SiemensRet = Marshal.PtrToStructure(pView2, SiemensRet.GetType)
|
||||
EgtOutLog("Siemens TimerProcessing start")
|
||||
|
||||
SiemensRet = Marshal.PtrToStructure(pView2, SiemensRet.GetType)
|
||||
|
||||
For n As Short = 0 To COPY_MAX_AXES - 1
|
||||
|
||||
@@ -569,7 +559,6 @@ Module M_MMFiles
|
||||
|
||||
Next
|
||||
|
||||
|
||||
' copy R vars
|
||||
|
||||
For n = 0 To (N_R_VAR - 1)
|
||||
@@ -578,8 +567,6 @@ Module M_MMFiles
|
||||
|
||||
' copy spindle current
|
||||
m_MainWindow.m_CNCommunication.m_CN.d_spindle_power = SiemensRet.d_interf_spindle_power
|
||||
'EgtOutLog("Ampere =" & m_MainWindow.m_CNCommunication.m_CN.d_spindle_power)
|
||||
|
||||
|
||||
m_MainWindow.m_CNCommunication.m_CN.n_spindle_override(0) = SiemensRet.n_interf_spindle_override
|
||||
|
||||
@@ -606,6 +593,8 @@ Module M_MMFiles
|
||||
|
||||
End If
|
||||
|
||||
EgtOutLog("stop")
|
||||
|
||||
Catch ex As Exception
|
||||
EgtOutLog("Errore nella lettura delle quote e simili variabili" & ex.ToString)
|
||||
End Try
|
||||
@@ -661,25 +650,24 @@ Module M_MMFiles
|
||||
''' Represents a wrapper class for a file mapping handle.
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
<HostProtection(SecurityAction.LinkDemand, MayLeakOnAbort:=True)> _
|
||||
<HostProtection(SecurityAction.Demand, MayLeakOnAbort:=True)>
|
||||
Friend NotInheritable Class SafeFileMappingHandle
|
||||
Inherits SafeHandleZeroOrMinusOneIsInvalid
|
||||
|
||||
<SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode:=True)> _
|
||||
<SecurityPermission(SecurityAction.Demand, UnmanagedCode:=True)>
|
||||
Private Sub New()
|
||||
MyBase.New(True)
|
||||
End Sub
|
||||
|
||||
<SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode:=True)> _
|
||||
Public Sub New(ByVal handle As IntPtr, ByVal ownsHandle As Boolean)
|
||||
<SecurityPermission(SecurityAction.Demand, UnmanagedCode:=True)>
|
||||
Public Sub New(handle As IntPtr, ownsHandle As Boolean)
|
||||
MyBase.New(ownsHandle)
|
||||
MyBase.SetHandle(handle)
|
||||
End Sub
|
||||
|
||||
<ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success), _
|
||||
DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
|
||||
Private Shared Function CloseHandle(ByVal handle As IntPtr) _
|
||||
As <MarshalAs(UnmanagedType.Bool)> Boolean
|
||||
<ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success),
|
||||
DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
|
||||
Private Shared Function CloseHandle(handle As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
|
||||
End Function
|
||||
|
||||
Protected Overrides Function ReleaseHandle() As Boolean
|
||||
@@ -725,15 +713,14 @@ Module M_MMFiles
|
||||
''' If the function succeeds, the return value is a handle to the newly
|
||||
''' created file mapping object.
|
||||
''' </returns>
|
||||
<DllImport("Kernel32.dll", SetLastError:=True)> _
|
||||
Public Shared Function CreateFileMapping( _
|
||||
ByVal hFile As IntPtr, _
|
||||
ByVal lpAttributes As IntPtr, _
|
||||
ByVal flProtect As FileProtection, _
|
||||
ByVal dwMaximumSizeHigh As UInt32, _
|
||||
ByVal dwMaximumSizeLow As UInt32, _
|
||||
ByVal lpName As String) _
|
||||
As SafeFileMappingHandle
|
||||
<DllImport("Kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
|
||||
Public Shared Function CreateFileMapping(
|
||||
hFile As IntPtr,
|
||||
lpAttributes As IntPtr,
|
||||
flProtect As FileProtection,
|
||||
dwMaximumSizeHigh As UInt32,
|
||||
dwMaximumSizeLow As UInt32,
|
||||
lpName As String) As SafeFileMappingHandle
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
@@ -755,12 +742,11 @@ Module M_MMFiles
|
||||
''' If the function succeeds, the return value is an open handle to the
|
||||
''' specified file mapping object.
|
||||
''' </returns>
|
||||
<DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
|
||||
Public Shared Function OpenFileMapping( _
|
||||
ByVal dwDesiredAccess As FileMapAccess, _
|
||||
ByVal bInheritHandle As Boolean, _
|
||||
ByVal lpName As String) _
|
||||
As SafeFileMappingHandle
|
||||
<DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
|
||||
Public Shared Function OpenFileMapping(
|
||||
dwDesiredAccess As FileMapAccess,
|
||||
bInheritHandle As Boolean,
|
||||
lpName As String) As SafeFileMappingHandle
|
||||
End Function
|
||||
|
||||
|
||||
@@ -790,14 +776,13 @@ Module M_MMFiles
|
||||
''' If the function succeeds, the return value is the starting address of
|
||||
''' the mapped view.
|
||||
''' </returns>
|
||||
<DllImport("Kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
|
||||
Public Shared Function MapViewOfFile( _
|
||||
ByVal hFileMappingObject As SafeFileMappingHandle, _
|
||||
ByVal dwDesiredAccess As FileMapAccess, _
|
||||
ByVal dwFileOffsetHigh As UInt32, _
|
||||
ByVal dwFileOffsetLow As UInt32, _
|
||||
ByVal dwNumberOfBytesToMap As UInt32) _
|
||||
As IntPtr
|
||||
<DllImport("Kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
|
||||
Public Shared Function MapViewOfFile(
|
||||
hFileMappingObject As SafeFileMappingHandle,
|
||||
dwDesiredAccess As FileMapAccess,
|
||||
dwFileOffsetHigh As UInt32,
|
||||
dwFileOffsetLow As UInt32,
|
||||
dwNumberOfBytesToMap As UInt32) As IntPtr
|
||||
End Function
|
||||
|
||||
|
||||
@@ -810,10 +795,9 @@ Module M_MMFiles
|
||||
''' be unmapped.
|
||||
''' </param>
|
||||
''' <returns></returns>
|
||||
<DllImport("Kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
|
||||
Public Shared Function UnmapViewOfFile( _
|
||||
ByVal lpBaseAddress As IntPtr) _
|
||||
As <MarshalAs(UnmanagedType.Bool)> Boolean
|
||||
<DllImport("Kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
|
||||
Public Shared Function UnmapViewOfFile(
|
||||
lpBaseAddress As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user