Click here to Skip to main content
15,913,179 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Using dynamic enum as type in a parameter of a method Pin
Shameel23-May-10 4:08
professionalShameel23-May-10 4:08 
GeneralRe: Using dynamic enum as type in a parameter of a method Pin
Not Active23-May-10 4:30
mentorNot Active23-May-10 4:30 
GeneralRe: Using dynamic enum as type in a parameter of a method Pin
PIEBALDconsult23-May-10 6:51
mvePIEBALDconsult23-May-10 6:51 
QuestionCheck the serial port event PinChanged Pin
feromontalvo20-May-10 3:09
feromontalvo20-May-10 3:09 
AnswerRe: Check the serial port event PinChanged Pin
Luc Pattyn20-May-10 5:05
sitebuilderLuc Pattyn20-May-10 5:05 
GeneralRe: Check the serial port event PinChanged Pin
feromontalvo21-May-10 0:38
feromontalvo21-May-10 0:38 
GeneralRe: Check the serial port event PinChanged Pin
Luc Pattyn21-May-10 2:10
sitebuilderLuc Pattyn21-May-10 2:10 
GeneralRe: Check the serial port event PinChanged Pin
feromontalvo21-May-10 8:32
feromontalvo21-May-10 8:32 
Hello Luc, on response at your message, I review the pointS you remarks,and:
-I use the correct serial port, COM1, because I open it and if I change the RtsEnable the true at false, the RTS pin 7 change his signal sign
-I review the pin another time, ans I use the correct, pin 7 and 8
-When I change the RtsEnable the true at false, the RTS pin 7 change to 6.7V at -5.7V, in both cases is this signal that I connect to CTS Pin 8
-Finally I probe with as simple a PinChanged handler as possible and I continue whithout response

The only point what I don't know to do is the use of "CanRaiseEvents" How can i do?

Thanks for all

I send my code:
Imports System
Imports System.IO
Imports System.Threading

Public Class Control_entrada
    Dim bitRTS As Boolean
    Dim bitDTR As Boolean
    Dim estadoCTS_OLD As Boolean
    
    Private Sub comm1_PinChanged(ByVal sender As Object, ByVal e As System.IO.Ports.SerialPinChangedEventArgs) Handles comm1.PinChanged
        ''Timer1.Enabled = False
        MessageBox.Show("SI")
        ''Call ctrl_log.EscribeLog("TZ")
        ''Timer1.Enabled = True
    End Sub

    Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
        ' Utilizamos un Control Timer para mostrar en los text el dia y la _
        'hora del sistema. La propiedad intervalo del control timer esta en 1000 milisegundos
        Call ctrl_log.EscribeLog("CT")
    End Sub

    Private Sub cmdRTS_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRTS.Click
        If bitRTS Then
            cmdRTS.Text = "Activar control puerta (RTS)"
            bitRTS = False
            Call ctrl_log.EscribeLog("PP")
        Else
            cmdRTS.Text = "Activado control puerta (RTS)"
            bitRTS = True
            Call ctrl_log.EscribeLog("AP")
        End If
        'AQUI SE ACTIVA LA SEÑAL DE RTS PARA VIGILAR LA APERTURA DE LA PUERTA
        'esta señal sera constantemente 1, y en caso de abrir la puerta el interruptor la conecta al pin CTS
        'que pasara de ser 0 a ser 1 y es lo que detectaremos para escribir en el log la apertura de puerta
        'comm1.RtsEnable = bitRTS
        comm1.RtsEnable = True
    End Sub

    Private Sub cmdparar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdparar.Click
        If comm1.IsOpen Then
            comm1.Close()
        End If

        Me.Text = "Puerto - cerrado"
        Call ctrl_log.EscribeLog("PG")
        cmdAbrir.Enabled = True
        cmdRTS.Enabled = False
        cmdDTR.Enabled = False
        Timer1.Enabled = False
    End Sub

    Private Sub cmdAbrir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAbrir.Click
        ' por si el puerto ya está abierto por otra aplicación
        On Error Resume Next
        comm1.Open()

        If comm1.IsOpen Then
            Me.Text = "Puerto - abierto"
            Call ctrl_log.EscribeLog("AG")
            cmdAbrir.Enabled = False
            cmdRTS.Enabled = True
            cmdDTR.Enabled = True
            ''Timer1.Enabled = True
        Else
            Me.Text = "no se puede abrir el puerto"
        End If
    End Sub

  
End Class
Public Class ctrl_log
    Public Shared Sub EscribeLog(ByVal tip_msg As String)
        Dim direccionArchivo As String
        direccionArchivo = ".\ctrl\Ficherito.txt"
        Dim sw As StreamWriter = File.AppendText(direccionArchivo)
        Dim txt_log As String
        Dim hora As String
        Dim fecha As String
        Try
            hora = Format(TimeOfDay, "HH:mm:ss")
            fecha = Format(DateTime.Today, "dd/MM/yyyy")
            txt_log = fecha & " " & hora

            Select Case tip_msg
                Case "PC"
                    txt_log = txt_log & ": Puerta cerrada" + System.Convert.ToChar(13)
                Case "PA"
                    txt_log = txt_log & ": Puerta abierta" + System.Convert.ToChar(13)
                Case "PP"
                    txt_log = txt_log & ": Parada proc puerta" + System.Convert.ToChar(13)
                Case "AP"
                    txt_log = txt_log & ": Arranque proc puerta" + System.Convert.ToChar(13)
                Case "PG"
                    txt_log = txt_log & ": Parada proc general" + System.Convert.ToChar(13)
                Case "AG"
                    txt_log = txt_log & ": Arranque proc general" + System.Convert.ToChar(13)
                Case "CT"
                    txt_log = txt_log & ": Control" + System.Convert.ToChar(13)
                Case "TZ"
                    txt_log = txt_log & ": Estoy en evento" + System.Convert.ToChar(13)
                Case "T1"
                    txt_log = txt_log & ": Estoy en evento 1" + System.Convert.ToChar(13)
                Case "T2"
                    txt_log = txt_log & ": Estoy en evento 2" + System.Convert.ToChar(13)
                Case "T3"
                    txt_log = txt_log & ": Estoy en evento 3" + System.Convert.ToChar(13)
            End Select

           sw.Write(txt_log)
            sw.Flush()
            sw.Close()
        Catch exFile As Exception
            sw.Close()
            MsgBox(("Cannot open " & exFile.ToString()))
            Return
        End Try
        sw.Close()
    End Sub
End Class

GeneralRe: Check the serial port event PinChanged Pin
Luc Pattyn21-May-10 8:48
sitebuilderLuc Pattyn21-May-10 8:48 
GeneralRe: Check the serial port event PinChanged Pin
feromontalvo24-May-10 23:07
feromontalvo24-May-10 23:07 
Questioncollection of different sections in app.config file Pin
dashingsidds20-May-10 0:43
dashingsidds20-May-10 0:43 
AnswerRe: collection of different sections in app.config file Pin
Richard MacCutchan20-May-10 2:12
mveRichard MacCutchan20-May-10 2:12 
GeneralRe: collection of different sections in app.config file Pin
dashingsidds20-May-10 19:57
dashingsidds20-May-10 19:57 
QuestionDataSet.AddTable order dependence? Pin
Marc Clifton19-May-10 10:28
mvaMarc Clifton19-May-10 10:28 
AnswerRe: DataSet.AddTable order dependence? Pin
Not Active19-May-10 13:02
mentorNot Active19-May-10 13:02 
QuestionResize a monochrome bitmap without using any class Pin
Mehdi Ghiasi19-May-10 7:54
Mehdi Ghiasi19-May-10 7:54 
AnswerRe: Resize a monochrome bitmap without using any class Pin
Luc Pattyn19-May-10 14:55
sitebuilderLuc Pattyn19-May-10 14:55 
QuestionRe: Resize a monochrome bitmap without using any class Pin
Mehdi Ghiasi20-May-10 2:06
Mehdi Ghiasi20-May-10 2:06 
AnswerRe: Resize a monochrome bitmap without using any class Pin
Luc Pattyn20-May-10 2:19
sitebuilderLuc Pattyn20-May-10 2:19 
QuestionRe: Resize a monochrome bitmap without using any class Pin
Mehdi Ghiasi20-May-10 7:18
Mehdi Ghiasi20-May-10 7:18 
AnswerRe: Resize a monochrome bitmap without using any class Pin
Thomas Krojer21-May-10 4:08
Thomas Krojer21-May-10 4:08 
JokeRe: Resize a monochrome bitmap without using any class Pin
T M Gray21-May-10 5:24
T M Gray21-May-10 5:24 
QuestionAccepting a rejected character in a Masked Textbox Pin
gmhanna18-May-10 1:58
gmhanna18-May-10 1:58 
AnswerRe: Accepting a rejected character in a Masked Textbox Pin
Peace ON18-May-10 2:42
Peace ON18-May-10 2:42 
QuestionAdvanced .NET cource Pin
marca29217-May-10 19:56
marca29217-May-10 19:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.