EgtCAM5 1.8i1 :

- piccole migliorie.
This commit is contained in:
Dario Sassi
2017-09-05 14:08:35 +00:00
parent 070460a158
commit 67143be354
4 changed files with 36 additions and 34 deletions
+19 -19
View File
@@ -14,8 +14,7 @@ Namespace EgtCAM5
' EGALTECH ENVIRONMENT FIELDS
Private m_objMutex As New Mutex
'' '' '' '' '' ''Private m_nInstance As Integer = 0
Private m_objMutex As Mutex
Private m_sDataRoot As String = String.Empty
Private m_sConfigDir As String = String.Empty
Private m_nDebug As Integer = 0
@@ -162,10 +161,10 @@ Namespace EgtCAM5
' Terminazione generale di EgtInterface
EgtExit()
' Rilascio mutex
m_objMutex.Close()
If Not IsNothing(m_objMutex) Then m_objMutex.Close()
' Aggiorno istanze usate
Dim nTmp As Integer = GetPrivateProfileInt(S_GENERAL, K_INSTANCES, 0)
nTmp -= (1 << (m_nInstance - 1))
nTmp -= (1 << (IniFile.m_nInstance - 1))
WritePrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString())
' Salvo impostazione macchina corrente
Application.Msn.NotifyColleagues(Application.SAVECURRENTMACHINE)
@@ -263,10 +262,10 @@ Namespace EgtCAM5
' Terminazione generale di EgtInterface
EgtExit()
' Rilascio mutex
m_objMutex.Close()
If Not IsNothing(m_objMutex) Then m_objMutex.Close()
' Aggiorno istanze usate
Dim nTmp As Integer = GetPrivateProfileInt(S_GENERAL, K_INSTANCES, 0)
nTmp -= (1 << (m_nInstance - 1))
nTmp -= (1 << (IniFile.m_nInstance - 1))
WritePrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString())
Application.Current.Shutdown()
End Sub)
@@ -307,7 +306,7 @@ Namespace EgtCAM5
End If
IniFile.m_sMachinesRoot = m_sMachinesRoot
' Verifico indice di istanza
ManageIstance()
ManageInstance()
' Imposto tipo di chiave
EgtSetLockType(KEY_TYPE.HW)
' Leggo e imposto chiave di protezione
@@ -322,9 +321,9 @@ Namespace EgtCAM5
EgtGetKeyOptions(3279, 18, 1, IniFile.m_nKeyOptions)
' Inizializzazione generale di EgtInterface
m_nDebug = GetPrivateProfileInt(S_GENERAL, K_DEBUG, 0)
IniFile.m_sLogFile = m_sTempDir & "\" & GENLOG_FILE_NAME.Replace("#", m_nInstance.ToString())
Dim sLogMsg As String = "User " & Environment.UserName & "\" & Environment.MachineName & " (" & m_nInstance.ToString() & ")" & vbLf &
My.Application.Info.Description.ToString() & " ver. " &
IniFile.m_sLogFile = m_sTempDir & "\" & GENLOG_FILE_NAME.Replace("#", IniFile.m_nInstance.ToString())
Dim sLogMsg As String = "User " & Environment.MachineName & "\" & Environment.UserName & " (" & IniFile.m_nInstance.ToString() & ")" & vbLf &
My.Application.Info.Title.ToString() & " ver. " &
My.Application.Info.Version.Major.ToString() &
"." & My.Application.Info.Version.Minor.ToString() &
(ChrW(97 - 1 + My.Application.Info.Version.Build)).ToString() &
@@ -395,7 +394,7 @@ Namespace EgtCAM5
''' <summary>
''' Funzione che permette di gestire il numero di istanze del programma attive contemporaneamente
''' </summary>
Private Sub ManageIstance()
Private Sub ManageInstance()
Dim bCreated As Boolean
Try
m_objMutex = New Mutex(False, "Global\EgtCAM5", bCreated)
@@ -404,23 +403,24 @@ Namespace EgtCAM5
End Try
If bCreated Then
' Prima istanza
m_nInstance = 1
IniFile.m_nInstance = 1
' Aggiorno stato istanze attive
WritePrivateProfileString(S_GENERAL, K_INSTANCES, m_nInstance.ToString)
WritePrivateProfileString(S_GENERAL, K_INSTANCES, IniFile.m_nInstance.ToString)
Else
' Leggo il massimo numero di istanze ammesse
Const MAX_INST As Integer = 32
Dim nMaxInst As Integer = GetPrivateProfileInt(S_GENERAL, K_MAXINST, 1)
nMaxInst = Max(1, Min(nMaxInst, 32))
nMaxInst = Max(1, Min(nMaxInst, MAX_INST))
' Cerco il primo indice di istanza libero (max 32)
Dim nTmp As Integer = GetPrivateProfileInt(S_GENERAL, K_INSTANCES, 0)
m_nInstance = 1
IniFile.m_nInstance = 1
Dim nMask As Integer = 1
While (nTmp And nMask) <> 0 And m_nInstance <= m_nInstance
m_nInstance += 1
While (nTmp And nMask) <> 0 And IniFile.m_nInstance < MAX_INST
IniFile.m_nInstance += 1
nMask *= 2
End While
' Se l'indice supera il massimo
If m_nInstance > nMaxInst Then
If IniFile.m_nInstance > nMaxInst Then
' porto in primo piano la prima istanza
Dim bFound As Boolean = False
' processi del programma a 32 bit
@@ -447,7 +447,7 @@ Namespace EgtCAM5
End
End If
' Aggiorno stato istanze attive
nTmp += (1 << (m_nInstance - 1))
nTmp += (1 << (IniFile.m_nInstance - 1))
WritePrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString())
End If
End Sub