Friend Class frmMain_OLD Inherits System.Windows.Forms.Form #Region "Controles" Friend WithEvents BtnSalir As System.Windows.Forms.Button Friend WithEvents BtnLog As System.Windows.Forms.Button #End Region #Region "Declaraciones" Dim Postes As New Collection Friend WithEvents Logo As System.Windows.Forms.PictureBox Friend WithEvents ImageListLeds As System.Windows.Forms.ImageList Friend WithEvents ListaPostes As New E301ControlDemo.ClassSosPhoneList Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents ImageListLogo As System.Windows.Forms.ImageList Friend WithEvents LBMasterSlave As System.Windows.Forms.ListBox #End Region #Region "Código generado por el Diseñador de Windows Forms " Public Sub New() MyBase.New() If m_vb6FormDefInstance Is Nothing Then If m_InitializingDefInstance Then m_vb6FormDefInstance = Me Else Try 'Para el formulario de inicio, la primera instancia creada es la instancia predeterminada. If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then m_vb6FormDefInstance = Me End If Catch End Try End If End If 'El Diseñador de Windows Forms requiere esta llamada. InitializeComponent() End Sub 'Form reemplaza a Dispose para limpiar la lista de componentes. Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean) If Disposing Then If Not components Is Nothing Then components.Dispose() End If End If MyBase.Dispose(Disposing) End Sub 'Requerido por el Diseñador de Windows Forms Private components As System.ComponentModel.IContainer Public ToolTip1 As System.Windows.Forms.ToolTip 'Public WithEvents TcpClient As AxMSWinsockLib.AxWinsock 'NOTA: el siguiente procedimiento es necesario para el Diseñador de Windows Forms 'Se puede modificar mediante el Diseñador de Windows Forms. 'No lo modifique con el editor de código. Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMain_OLD)) Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) Me.BtnSalir = New System.Windows.Forms.Button Me.BtnLog = New System.Windows.Forms.Button Me.ImageListLeds = New System.Windows.Forms.ImageList(Me.components) Me.ImageListLogo = New System.Windows.Forms.ImageList(Me.components) Me.Logo = New System.Windows.Forms.PictureBox Me.ListaPostes = New E301ControlDemo.ClassSosPhoneList Me.Label2 = New System.Windows.Forms.Label Me.LBMasterSlave = New System.Windows.Forms.ListBox CType(Me.Logo, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'BtnSalir ' Me.BtnSalir.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.BtnSalir.Location = New System.Drawing.Point(511, 288) Me.BtnSalir.Name = "BtnSalir" Me.BtnSalir.Size = New System.Drawing.Size(75, 23) Me.BtnSalir.TabIndex = 27 Me.BtnSalir.Text = "SALIR" Me.BtnSalir.UseVisualStyleBackColor = True ' 'BtnLog ' Me.BtnLog.Location = New System.Drawing.Point(430, 288) Me.BtnLog.Name = "BtnLog" Me.BtnLog.Size = New System.Drawing.Size(75, 23) Me.BtnLog.TabIndex = 1 Me.BtnLog.Text = "Ver Log..." Me.BtnLog.UseVisualStyleBackColor = True ' 'ImageListLeds ' Me.ImageListLeds.ImageStream = CType(resources.GetObject("ImageListLeds.ImageStream"), System.Windows.Forms.ImageListStreamer) Me.ImageListLeds.TransparentColor = System.Drawing.Color.White Me.ImageListLeds.Images.SetKeyName(0, "Verde") Me.ImageListLeds.Images.SetKeyName(1, "Rojo") Me.ImageListLeds.Images.SetKeyName(2, "Off") ' 'ImageListLogo ' Me.ImageListLogo.ImageStream = CType(resources.GetObject("ImageListLogo.ImageStream"), System.Windows.Forms.ImageListStreamer) Me.ImageListLogo.TransparentColor = System.Drawing.Color.White Me.ImageListLogo.Images.SetKeyName(0, "logo") ' 'Logo ' Me.Logo.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom Me.Logo.Location = New System.Drawing.Point(12, 257) Me.Logo.Margin = New System.Windows.Forms.Padding(0) Me.Logo.Name = "Logo" Me.Logo.Size = New System.Drawing.Size(238, 54) Me.Logo.TabIndex = 32 Me.Logo.TabStop = False ' 'ListaPostes ' Me.ListaPostes.BackColor = System.Drawing.Color.White Me.ListaPostes.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable Me.ListaPostes.FormattingEnabled = True Me.ListaPostes.Location = New System.Drawing.Point(12, 52) Me.ListaPostes.Name = "ListaPostes" Me.ListaPostes.Size = New System.Drawing.Size(200, 196) Me.ListaPostes.TabIndex = 33 ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(12, 36) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(71, 13) Me.Label2.TabIndex = 34 Me.Label2.Text = "SOS Phones:" ' 'LBMasterSlave ' Me.LBMasterSlave.FormattingEnabled = True Me.LBMasterSlave.Items.AddRange(New Object() {"Master", "Slave"}) Me.LBMasterSlave.Location = New System.Drawing.Point(218, 52) Me.LBMasterSlave.Name = "LBMasterSlave" Me.LBMasterSlave.Size = New System.Drawing.Size(92, 30) Me.LBMasterSlave.TabIndex = 29 ' 'frmMain ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.SystemColors.Control Me.ClientSize = New System.Drawing.Size(709, 317) Me.Controls.Add(Me.LBMasterSlave) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.ListaPostes) Me.Controls.Add(Me.Logo) Me.Controls.Add(Me.BtnLog) Me.Controls.Add(Me.BtnSalir) Me.Cursor = System.Windows.Forms.Cursors.Default Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.HelpButton = True Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.Location = New System.Drawing.Point(4, 23) Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "frmMain" Me.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Text = "EQUITEL E301 Control Demo" CType(Me.Logo, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() End Sub #End Region #Region "Soporte para la actualización " Private Shared m_vb6FormDefInstance As frmMain_OLD Private Shared m_InitializingDefInstance As Boolean Public Shared Property DefInstance() As frmMain_OLD Get If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then m_InitializingDefInstance = True m_vb6FormDefInstance = New frmMain_OLD() m_InitializingDefInstance = False End If DefInstance = m_vb6FormDefInstance End Get Set(ByVal value As frmMain_OLD) m_vb6FormDefInstance = value End Set End Property #End Region Private Sub frmPrincipal_HelpButtonClicked(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.HelpButtonClicked Dim F As New Form F = AboutBox2 F.ShowDialog() e.Cancel = True End Sub Private Sub Form_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load Dim Linea(255) As String Const ConfigurationFile As String = "E301_Control_Demo.ini" Control.CheckForIllegalCrossThreadCalls = False VentanaLog.Show() 'VentanaLog.Hide() ListaPostes.DisplayMember = "Nombre" TestMode = True Try Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(ConfigurationFile) MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.HasFieldsEnclosedInQuotes = True MyReader.SetDelimiters(" ") While Not MyReader.EndOfData Try Linea = MyReader.ReadFields() If UCase(Linea(0)) = "POSTE" Then If UBound(Linea) <> 4 Then MsgBox("Numero erroneo de campos en definición poste en fichero .ini") Else CreaPoste(Linea(1), Linea(2), CInt(Linea(3)), CInt(Linea(4))) End If End If If UCase(Linea(0)) = "MODOPRUEBAS" Then TestMode = (UCase(Linea(1)) = "SI") End If Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException If Mid(Linea(0), 1, 1) <> "#" Then MsgBox("Fichero .ini: Error de sintaxis: " & ex.Message) End If End Try End While End Using Catch MsgBox("ERROR: Configuration file '" + ConfigurationFile + "' not found", MsgBoxStyle.Critical) End End Try If ListaPostes.Items.Count > 0 Then ListaPostes.SelectedIndex = 0 Logo.Image = ImageListLogo.Images.Item("Logo") LedTestFon.Image = ImageListLeds.Images.Item("Off") lblVol.Text = "(D)" 'lblVolMic.Text = "(D)" LBMasterSlave.SelectedIndex = 0 End Sub Private Sub CreaPoste(ByVal Ip As String, ByVal Comentario As String, ByVal PuertoCTRL As Integer, ByVal PuertoRTP As Integer) Dim Poste As ClasePoste Static N As Integer = 1 Poste = New ClasePoste(Ip, N, Comentario) Poste.PuertoCTRL = PuertoCTRL Poste.PuertoRTP = PuertoRTP AddHandler Poste.Log, AddressOf OnLog AddHandler Poste.OnExitoConexion, AddressOf OnExitoConexion AddHandler Poste.OnFalloConexion, AddressOf OnFalloConexion AddHandler Poste.OnRespuestaTestFonia, AddressOf OnResultadoTestFonia AddHandler Poste.OnEnvioAlarmas, AddressOf OnEnvioAlarmas AddHandler Poste.OnRespuestaTestMantenimiento, AddressOf OnRespuestaTestMantenimiento AddHandler Poste.OnLecturaIO, AddressOf OnLecturaIO Postes.Add(Poste, N) ListaPostes.Items.Add(Poste) N = N + 1 End Sub Private Sub OnFalloConexion(ByVal NumeroPoste As Integer) ListaPostes.MyRefresh() End Sub Private Sub OnExitoConexion(ByVal NumeroPoste As Integer) ListaPostes.MyRefresh() End Sub Private Sub OnLog(ByVal S As String, ByVal NumeroPoste As Integer) VentanaLog.NuevaLinea = "P_" + Str(NumeroPoste) + "->" + S + vbCrLf End Sub Private Function MasterOrSlave() As Byte If LBMasterSlave.SelectedIndex = 1 Then Return P_ESC Else Return P_MAS End If End Function Private Sub Btn_VOZ_ON_LL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.ActivarSintetizador(ClasePoste.TiposMensaje.LlamadaRecibida, MasterOrSlave()) End Sub Private Sub Btn_VOZ_ON_F_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.ActivarSintetizador(ClasePoste.TiposMensaje.FueraDeServicio, MasterOrSlave()) End Sub Private Sub Btn_VOZ_OFF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.DesactivarSintetizador(MasterOrSlave()) End Sub Private Sub BtnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSalir.Click End End Sub Private Sub BtnLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLog.Click frmLog.Show() End Sub Private Sub BtnTonoLlamadaON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.ActivarTono(MasterOrSlave(), ClasePoste.TiposTono.Llamada) End Sub Private Sub BtnTonoComON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.ActivarTono(MasterOrSlave(), ClasePoste.TiposTono.Comunicando) End Sub Private Sub BtnTonoOFF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.DesactivarTono(MasterOrSlave()) End Sub Private Sub BtnFoniaOn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.ActivarFoníaDesdeCentral(MasterOrSlave()) End Sub Private Sub BtnFoniaOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.DesactivarFoníaDesdeCentral(MasterOrSlave()) End Sub Private Sub BtnTestMantenimiento_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.TestMantenimiento() End Sub Private Sub BtnTestFonia_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem LedTestFon.Image = ImageListLeds.Images.Item("Off") P.TestFonia(MasterOrSlave()) End Sub Private Sub BtnLeerIO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.LecturaPuerto() End Sub Private Sub BtnEscribirIO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste Dim Valor As Byte = 0 If Bt_Salida_0.Text = "1" Then Valor = Valor Or &H1 If Bt_Salida_1.Text = "1" Then Valor = Valor Or &H2 If Bt_Salida_2.Text = "1" Then Valor = Valor Or &H4 If Bt_Salida_3.Text = "1" Then Valor = Valor Or &H8 If Bt_Salida_4.Text = "1" Then Valor = Valor Or &H10 If Bt_Salida_5.Text = "1" Then Valor = Valor Or &H20 If Bt_Salida_6.Text = "1" Then Valor = Valor Or &H40 If Bt_Salida_7.Text = "1" Then Valor = Valor Or &H80 P = ListaPostes.SelectedItem P.EscrituraPuerto(Valor) End Sub Private Sub OnResultadoTestFonia(ByVal Resultado As Byte) If Resultado = TST_OK Then LedTestFon.Image = ImageListLeds.Images.Item("Verde") Else LedTestFon.Image = ImageListLeds.Images.Item("Rojo") End If End Sub Private Sub OnEnvioAlarmas(ByVal EstadoMaestro As Byte, ByVal EstadoEsclavo As Byte, ByVal NumeroPoste As Byte) If ListaPostes.SelectedIndex = (NumeroPoste - 1) Then RefrescaEstadoAlarmas() End If End Sub Private Sub OnLecturaIO(ByVal Valor As Byte) RB_Entrada_0.Checked = ((Valor And &H1) <> 0) RB_Entrada_1.Checked = ((Valor And &H2) <> 0) RB_Entrada_2.Checked = ((Valor And &H4) <> 0) RB_Entrada_3.Checked = ((Valor And &H8) <> 0) RB_Entrada_4.Checked = ((Valor And &H10) <> 0) RB_Entrada_5.Checked = ((Valor And &H20) <> 0) RB_Entrada_6.Checked = ((Valor And &H40) <> 0) RB_Entrada_7.Checked = ((Valor And &H80) <> 0) End Sub Private Sub RefrescaEstadoAlarmas() Dim P As ClasePoste P = ListaPostes.SelectedItem If P.AlarmasActualizadas Then ChkBx_PAM.Checked = P.PuertaAbiertaMaestro ChkBx_PAE.Checked = P.PuertaAbiertaEsclavo ChkBx_FM.Checked = P.FoniaOnMaestro ChkBx_FE.Checked = P.FoniaOnEsclavo ChkBx_TM.Checked = P.TonoOnMaestro ChkBx_TE.Checked = P.TonoOnEsclavo ChkBx_BB.Checked = P.BateriaBaja ChkBx_AL.Checked = P.FalloAlimentacion Else ChkBx_PAM.Checked = False ChkBx_PAE.Checked = False ChkBx_FM.Checked = False ChkBx_FE.Checked = False ChkBx_TM.Checked = False ChkBx_TE.Checked = False ChkBx_BB.Checked = False ChkBx_AL.Checked = False ChkBx_PAM.CheckState = CheckState.Indeterminate ChkBx_PAE.CheckState = CheckState.Indeterminate ChkBx_FM.CheckState = CheckState.Indeterminate ChkBx_FE.CheckState = CheckState.Indeterminate ChkBx_TM.CheckState = CheckState.Indeterminate ChkBx_TE.CheckState = CheckState.Indeterminate ChkBx_BB.CheckState = CheckState.Indeterminate ChkBx_AL.CheckState = CheckState.Indeterminate End If End Sub Private Sub ListaPostes_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem RefrescaHabilitacionBotones() 'Hacemos un test de mantenimiento para que se refresque el valor 'de volumen y las alarmas If P.Conectado Then P.TestMantenimiento() End Sub Private Sub RefrescaHabilitacionBotones() Dim P As ClasePoste P = ListaPostes.SelectedItem Me.GB_CanEco.Enabled = P.Conectado Me.Btn_ECO_OFF.Enabled = P.Conectado Me.Btn_ECO_ON.Enabled = P.Conectado Me.AjusteVolumen.Enabled = P.Conectado Me.BtnFoniaOff.Enabled = P.Conectado Me.BotFoniaOn.Enabled = P.Conectado Me.BtnTonoComON.Enabled = P.Conectado Me.BtnTonoOFF.Enabled = P.Conectado Me.BtnTonoLamadaON.Enabled = P.Conectado Me.Btn_VOZ_OFF.Enabled = P.Conectado Me.Btn_VOZ_ON_F.Enabled = P.Conectado Me.Btn_VOZ_ON_LL.Enabled = P.Conectado Me.BtnTestFonia.Enabled = P.Conectado Me.BtnTestMantenimiento.Enabled = P.Conectado Me.GB_Salidas.Enabled = P.Conectado Me.GB_Entradas.Enabled = P.Conectado Me.BtnEscribirIO.Enabled = P.Conectado Me.BtnLeerIO.Enabled = P.Conectado Me.Label4.Enabled = P.Conectado Me.lblVol.Enabled = P.Conectado End Sub Private Sub OnRespuestaTestMantenimiento(ByVal NumeroPoste As Byte) If ListaPostes.SelectedIndex = (NumeroPoste - 1) Then RefrescaEstadoAlarmas() RefrescaEstadoVolumen() End If End Sub Private Sub RefrescaEstadoVolumen() Dim P As ClasePoste P = ListaPostes.SelectedItem If P.VolumenMaestro > 1 And P.VolumenMaestro < 7 Then AjusteVolumen.Value = P.VolumenMaestro lblVol.Text = P.VolumenMaestro.ToString Else AjusteVolumen.Value = 1 lblVol.Text = "¿" + P.VolumenMaestro.ToString + "?" End If End Sub Private Sub AjusteVolumen_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim P As ClasePoste If e.Button = Windows.Forms.MouseButtons.Left Then P = ListaPostes.SelectedItem P.AjusteVolumenSalida(MasterOrSlave(), AjusteVolumen.Value) End If End Sub Private Sub Btn_ECO_ON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.CanceladorEcoON() End Sub Private Sub Btn_ECO_OFF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim P As ClasePoste P = ListaPostes.SelectedItem P.CanceladorEcoOFF() End Sub Private Sub SlideVolMic_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim P As ClasePoste If e.Button = Windows.Forms.MouseButtons.Left Then P = ListaPostes.SelectedItem P.AjusteVolumenMicrofono(MasterOrSlave(), SlideVolMic.Value) End If End Sub Private Sub SlideVolMic_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) lblVolMic.Text = Format(SlideVolMic.Value, "0") End Sub Private Sub AjusteVolumen_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) lblVol.Text = AjusteVolumen.Value.ToString End Sub Private Sub Bt_Salida_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) If sender.text = "0" Then sender.text = "1" Else sender.text = "0" End Sub End Class