70 lines
2.7 KiB
VB.net
70 lines
2.7 KiB
VB.net
Imports Effector.Plugin.Lib
|
|
Imports NGP_COMM_DLL
|
|
|
|
Public Class MachineManager
|
|
|
|
Private m_MachineList(20) As NC.NC_generic
|
|
Friend ReadOnly Property MachineList As NC.NC_generic()
|
|
Get
|
|
Return m_MachineList
|
|
End Get
|
|
End Property
|
|
|
|
Sub New()
|
|
End Sub
|
|
|
|
Sub Init()
|
|
If GetMainPrivateProfileInt(S_NC, K_NC_SIMULATE, 0) = 1 Then
|
|
Dim nMachineIndex As Integer = 1
|
|
Dim sMachine As String = ""
|
|
While GetMainPrivateProfileString(S_NC, K_MACHINE & nMachineIndex.ToString(), "", sMachine) > 0
|
|
If Map.refMainWindowVM.MainWindowM.GetKeyOption1(nMachineIndex) Then
|
|
Dim NewSimulatedMachine As New NC.Simulated
|
|
NewSimulatedMachine.Connect("")
|
|
m_MachineList(nMachineIndex - 1) = NewSimulatedMachine
|
|
Else
|
|
EgtOutLog("Attempt to load machines beyond the limit imposed by the key!")
|
|
End If
|
|
nMachineIndex += 1
|
|
End While
|
|
Else
|
|
Dim nMachineIndex As Integer = 1
|
|
Dim sMachine As String = ""
|
|
While GetMainPrivateProfileString(S_NC, K_MACHINE & nMachineIndex.ToString(), "", sMachine) > 0
|
|
If Map.refMainWindowVM.MainWindowM.GetKeyOption1(nMachineIndex) Then
|
|
Dim sMachineSplit() As String = sMachine.Split(","c)
|
|
Dim nType As Integer = 0
|
|
If sMachineSplit.Count >= 1 AndAlso Not String.IsNullOrWhiteSpace(sMachineSplit(0)) AndAlso Integer.TryParse(sMachineSplit(0), nType) Then
|
|
Select Case nType
|
|
Case 1 ' OsaiOpen
|
|
If sMachineSplit.Count >= 2 AndAlso Not String.IsNullOrWhiteSpace(sMachineSplit(1)) Then
|
|
Dim NewOsaiOpen As New NC.OsaiOpen
|
|
NewOsaiOpen.Connect(sMachineSplit(1))
|
|
m_MachineList(nMachineIndex - 1) = NewOsaiOpen
|
|
End If
|
|
Case 2 ' Fanuc
|
|
If sMachineSplit.Count >= 2 AndAlso Not String.IsNullOrWhiteSpace(sMachineSplit(1)) Then
|
|
Dim NewFanuc As New NC.Fanuc
|
|
NewFanuc.Connect(sMachineSplit(1))
|
|
m_MachineList(nMachineIndex - 1) = NewFanuc
|
|
End If
|
|
End Select
|
|
End If
|
|
Else
|
|
EgtOutLog("Attempt to load machines beyond the limit imposed by the key!")
|
|
End If
|
|
nMachineIndex += 1
|
|
End While
|
|
End If
|
|
End Sub
|
|
|
|
Sub Close()
|
|
For Each Machine In m_MachineList
|
|
If Not IsNothing(Machine) Then
|
|
Machine.Disconnect()
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
End Class
|