Imports CMSControl.App.Runtime
Imports CMSControl.CNC

Namespace CNC

    Public Class Runtime
        Public Shared NC As CMSControl.CNC.CNC

        Public Shared Sub CreateNC()

            '************ Istanzio l'oggetto NC *****************
            Try
                Log.WI("TRY crating NC  CNC.NC", "TypeNC=" & Config.Settings.Settings.TypeNC.ToString, CLog.Lev.Principal)
                Select Case Config.Settings.Settings.TypeNC
                    Case NC_DEMO
                        NC = New DEMO
                    Case NC_FANUC
                        If Not Config.Settings.Settings.Hssb Then 'Ethernet
                            NC = New FANUC(0, Config.Settings.Settings.IpFanuc, Config.Settings.Settings.PortIpFanuc, Config.Settings.Settings.CncScreenHssb)
                        Else              'Hssb
                            NC = New FANUC(1)
                        End If
                    Case NC_OSAI
                        If Config.Settings.Settings.OsaiCommType = 1 Then 'SOAP
                            NC = New OSAI_OPEN(Config.Settings.Settings.IpOsai)
                        Else 'DCOM
                            Dim DotNet As Boolean
                            If OSAI.GetWinnbi(DotNet) Then
                                If DotNet Then
                                    NC = New OSAI(Config.Settings.Settings.NcName)
                                Else
                                    NC = New OSAIVB6(Config.Settings.Settings.NcName)
                                End If
                            Else
                                Log.WE("Error on GetWinnbi or WINNBI are not installed", "Install Osai WINNBI before run this software", True)
                            End If
                        End If

                    Case NC_SIEMENS
#If SIEMENS Then
                        Try
                            NC = New SIEMENS
                        Catch ex As CmsNcException
                            'NC.frmMain_ref.ExitApp()
                            'frmMain.ExitApp()
                            End
                        End Try
#End If
                    Case NC_BECKHOFF
                        NC = New BECKHOFF

                    Case Else
                        NC = New DEMO
                End Select
                Log.WI("OK  crating NC  CNC.NC", , CLog.Lev.Principal)
            Catch ex As Exception
                Log.WE("ERR crating NC  CNC.NC", ex.Message, True)
            End Try


        End Sub


    End Class

End Namespace