Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Katriel

Pages: [1]
1
Application Showcase / Re: Email Alerts
« on: March 14, 2018, 09:39:53 AM »
Here is a sample where I send the same style email where one bit (alarm for part missing) is on and the sensor to detect the critical part is off.  Certain components here are high risk, so we only want the email for those (email for an alarm is pretty serious response.)  So here I add some variables in the public class mainform to track multiple datasubscriber results outside of there subs.

Public Class MainForm

    '*******************************************************************************

    '* Stop polling when the form is not visible in order to reduce communications

    '* Copy this section of code to every new form created

    '*******************************************************************************

    Public F_RH_ST390_NUT01, F_RH_ST390_NUT02, F_RH_ST390_NUT03, F_RH_ST390_NUT04 As String

    Private NotFirstShow As Boolean

 

 

 

 

 

    Private Sub DataSubscriber92_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber92.DataChanged

        '* Make sure Data came back

        If e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then

            '* Did it come back as True or 1?

            If (String.Compare(e.Values(0), "TRUE", True) = 0 Or e.Values(0) = "1") And (F_RH_ST390_NUT01 = "MISSING" Or F_RH_ST390_NUT02 = "MISSING" Or F_RH_ST390_NUT03 = "MISSING" Or F_RH_ST390_NUT04 = "MISSING") Then

                SendEmailMessage("F_RH_ST390_NUT RH ST390 MISSING NUT")

            End If

        End If

    End Sub

 

    Private Sub DataSubscriber93_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber93.DataChanged

        '* Make sure Data came back

        If e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then

            '* Did it come back as True or 1?

            If (String.Compare(e.Values(0), "TRUE", True) = 0 Or e.Values(0) = "1") Then

                F_RH_ST390_NUT01 = "PRESENT"

            Else F_RH_ST390_NUT01 = "MISSING"

            End If

        Else

        End If

    End Sub

 

    Private Sub DataSubscriber94_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber94.DataChanged

        '* Make sure Data came back

        If e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then

            '* Did it come back as True or 1?

            If (String.Compare(e.Values(0), "TRUE", True) = 0 Or e.Values(0) = "1") Then

                F_RH_ST390_NUT02 = "PRESENT"

            Else F_RH_ST390_NUT02 = "MISSING"

            End If

        Else

        End If

    End Sub

 

    Private Sub DataSubscriber95_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber95.DataChanged

        '* Make sure Data came back

        If e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then

            '* Did it come back as True or 1?

            If (String.Compare(e.Values(0), "TRUE", True) = 0 Or e.Values(0) = "1") Then

                F_RH_ST390_NUT03 = "PRESENT"

            Else F_RH_ST390_NUT03 = "MISSING"

            End If

        Else

        End If

    End Sub

 

    Private Sub DataSubscriber96_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber96.DataChanged

        '* Make sure Data came back

        If e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then

            '* Did it come back as True or 1?

            If (String.Compare(e.Values(0), "TRUE", True) = 0 Or e.Values(0) = "1") Then

                F_RH_ST390_NUT04 = "PRESENT"

            Else F_RH_ST390_NUT04 = "MISSING"

            End If

        Else

        End If

    End Sub

2
Application Showcase / Re: Email Alerts
« on: March 14, 2018, 09:34:51 AM »
I say we should charge more for the red models we ship!

3
Application Showcase / Email Alerts
« on: March 13, 2018, 05:59:21 PM »
I just followed the instructions and set up some email alerts for "failed red rabbits" which is when we verify our poka yokes are working correctly.  This was to try to catch if someone accidentally "fixes" a machine rather than notice the component was missing.  Here is a small amount of the 1000+ lines of code for all the faults at my plant.  This was NOT my development but just came from samples I found here (thanks Archie) and because there are about 100 email messages, I set it up as a subroutine and pass the subject and body in to match where it was called from.  For me, it is an exciting beginning, for many, it is like watching a baby trying to stand up.

   Private Sub DataSubscriber68_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber68.DataChanged

        '* Make sure Data came back

        If e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then

            '* Did it come back as True or 1?

            If String.Compare(e.Values(0), "TRUE", True) = 0 Or e.Values(0) = "1" Then

                SendEmailMessage("F RH ST485 FAILED RED RABBIT")

 

            End If

        End If

    End Sub

    Private Sub DataSubscriber69_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber69.DataChanged

        '* Make sure Data came back

        If e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then

            '* Did it come back as True or 1?

            If String.Compare(e.Values(0), "TRUE", True) = 0 Or e.Values(0) = "1" Then

                SendEmailMessage("F LH ST390 FAILED RED RABBIT")

 

            End If

        End If

    End Sub

 

    Private Sub DataSubscriber70_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber70.DataChanged

        '* Make sure Data came back

        If e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then

            '* Did it come back as True or 1?

            If String.Compare(e.Values(0), "TRUE", True) = 0 Or e.Values(0) = "1" Then

                SendEmailMessage("F LH ST485 FAILED RED RABBIT")

 

            End If

        End If

    End Sub

 

 

 

 

    Private Sub SendEmailMessage(subject As String)

        Using email As New System.Net.Mail.MailMessage

            '* Set who it is from

            email.From = New System.Net.Mail.MailAddress("EmailAccount@Company.com")

 

            '* Add the recipients

            email.To.Add(New System.Net.Mail.MailAddress("Name_of_Group@Company.com"))

 

            email.Subject = subject

            email.Body = subject

 

            '* Create the client that will send the message

            Dim MailSendingClient As New System.Net.Mail.SmtpClient

            '* set this to the smtp server you will use

            MailSendingClient.Host = "Address of mail server"

            MailSendingClient.Port = port of mail sending server

 

            '* If your SMTP Server does not require a password, then remove this section

            'Dim credentials As New System.Net.NetworkCredential("email@domain.com", "password")

            'MailSendingClient.Credentials = credentials

            'MailSendingClient.EnableSsl = True

 

            '* Send the email

            MailSendingClient.Send(email)

        End Using

    End Sub


4
Support Questions / Re: DataSubscriber2 values
« on: March 13, 2018, 05:46:38 PM »
I am pretty new at this and have been setting up some plant area overviews and my boss requested some email alerts for certain events.  When the event was a specific alarm in the PLC, it was easy to set up about 100 DataSubscriber from the tool box, double click and have your auto code generated for data change to call a Private Sub SendEmailMessage("Event One Happened") so I used the same email sub for all the messages.  I should mention that this is currently 21 control logix PLCs for all of these connections and messages.  Now, I am wondering if I can consider using some more logic in my Subs so that perhaps I look at the status of two PLC tags and only alert when specific conditions occur.  I was wondering about grabbing multiple tags using DataSubscriber2 to get a few words and then trying to compare if tag[0].0 and tag[1].3 then SendEmailMessage("Nut 2 missing") and of course have multiple items considered (critical alarms for the station).  I have seen the examples of a popup to display the data from the DataSubscriber2 but not really an example of how to work with the values of multiple variables, at the same time.

Pages: [1]