Author Topic: Email QUESTIONS  (Read 1400 times)

PLCROBOTGUY1

  • Newbie
  • *
  • Posts: 3
    • View Profile
Email QUESTIONS
« on: March 01, 2020, 09:46:34 AM »
Hi All,
I have 2 questions about the email in AHMI

1. I need to be able to send an email with values IE. If a PV goes High send that high value to QA
2.I have the email function working but it runs once when I start up the HMI. I don't want it to do this because the computer that its on is shutoff at night.

Thanks

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Email QUESTIONS
« Reply #1 on: March 01, 2020, 10:09:08 AM »
You may be able to handle the ValueChanged event and modify the MessageBody property like this to insert values:
Code: [Select]
   Private Sub Emailer1_ValueChanged(sender As Object, e As EventArgs) Handles Emailer1.ValueChanged
        Emailer1.MessageBody = "Current Value=" & EthernetIPforCLXCom1.Read("MyTag")
    End Sub

The initial send is caused by the control not knowing the existing value, so when it starts up, it can only assume the value changed. In the upcoming Beta 35, there will be a fix to prevent this.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Email QUESTIONS
« Reply #2 on: March 01, 2020, 10:12:19 AM »
IN the PLC, you'd setup PV> HV then TriggerSend

in the AAHMI, setup an event to catch the TriggerSend  bit, and capture your PV value, then send email to your favorite QA.

Looks like Archie just beat me.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

PLCROBOTGUY1

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Email QUESTIONS
« Reply #3 on: March 01, 2020, 12:13:55 PM »
You may be able to handle the ValueChanged event and modify the MessageBody property like this to insert values:
Code: [Select]
   Private Sub Emailer1_ValueChanged(sender As Object, e As EventArgs) Handles Emailer1.ValueChanged
        Emailer1.MessageBody = "Current Value=" & EthernetIPforCLXCom1.Read("MyTag")
    End Sub

The initial send is caused by the control not knowing the existing value, so when it starts up, it can only assume the value changed. In the upcoming Beta 35, there will be a fix to prevent this.

Thanks this worked but not with my SLC 500

Emailer1.MessageBody = "PV HIGH!=" & EthernetIPforSLCMicroCom15.Read("Nxx:xx")

I get the message below
System.NullReferenceException: 'Object reference not set to an instance of an object.'

timryder

  • Jr. Member
  • **
  • Posts: 84
  • Still trying to figure it out
    • View Profile
Re: Email QUESTIONS
« Reply #4 on: March 02, 2020, 11:05:38 AM »
Could use the Inner Exception to debug where the issue is better.  When that comes up, look on the Exception Handler dialog for the "See Inner Exception" and post that information.
Still just trying to figure out this thing called Life.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Email QUESTIONS
« Reply #5 on: March 02, 2020, 01:51:38 PM »
Null Reference could indicate that either the code is executed before the connection to the PLC is established or before the EthernetIPforSLCMicroCom15 is created.

Or maybe the address "Nxx:xx" does not exist.

PLCROBOTGUY1

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Email QUESTIONS
« Reply #6 on: March 02, 2020, 04:01:53 PM »
Ok got this working with the Above code but the value only updates when i run a debug. When i trigger the email it sends the last values from the last start up. Fixed the error my plc was not connected.

Emailer1.MessageBody = "Current Value=" & EthernetIPforCLXCom1.Read("MyTag")

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Email QUESTIONS
« Reply #7 on: March 02, 2020, 09:57:27 PM »
EthernetIPforCLXCom1.Read("MyTag") doesn't really do anything else but ask the PLC to provide a value that's currently in "MyTag".

If it is the last values from the last start up then that's what is currently in the PLC.