Author Topic: Message Handler  (Read 4821 times)

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Message Handler
« Reply #30 on: June 17, 2019, 06:13:13 PM »
Post the MessageHandler.vb file you currently have and I will have to modify it to handle faster value changes.

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Message Handler
« Reply #31 on: June 17, 2019, 09:00:52 PM »
Archie;

I don't think that is the problem. Making the changes you suggested to line *86 didn't work. I set MessageHandler1.value to 1 with the click of a button. When I leave the form (by clicking a form change button)I have the value being set back to 0. It will not change forms with line*86 that way.

The MessageHandler is being overrun because the server either the xmiter or the receiver locks it out for four hours. I have tested this and after 4 hours I can send 5 emails no more. I have changed the size of the emails by changing the text in the message and heading. I also waited 5 minutes between sending the emails. It still locks it out at 5 emails every 4 hours. This should not be a problem as they will have their own email server and should be able to set it up to allow more emails than 5. I have tried changing the username to see if it would accept another email but it will not until the 4 the hour as it is still the same server.

With all that said I have a couple of other questions.

Can I run more than one message handler at a time?
Can I run the Messagehandler and MessageHandlerPLC at the same time?
I noticed a variable in the messageHandler called acknowledge, what is this?
Is there feedback telling when the messagehandler is complete?
Is there a way to interrupt the MessageHandler i.e. set MessageHandler.Value to 0 and it stops?

Thanks again,
Dave

PS Did you get a price and invoice on the fanless PCs?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Message Handler
« Reply #32 on: June 17, 2019, 09:19:44 PM »
I need to re-think and rework the message handler because as-is it can only handle processing one message at a time. If one was initiated, then another alarm occurs before all 3 emails were sent from the first, it will not complete the 3 from the first. I need to set it up to queue alarms and handle unlimited simultaneous active alarms.

The Acknowledge property is used to stop any further emails from being sent for the current alarm.

You can use MessageHandler and MessageHandlerPLC at the same time.

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Message Handler
« Reply #33 on: June 17, 2019, 09:45:29 PM »
Archie;

Attached is the message handler

Dave

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Message Handler
« Reply #34 on: June 17, 2019, 10:17:14 PM »
Archie;

Very peculiar!

I am using mail.com to send a message to excite.com it is now locked out for another 3 hours with advanced hmi. However, I can send a email from my laptop using mail.com sending it to excite.com and it works?

That's a head scratcher!!!

Dave

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Message Handler
« Reply #35 on: June 18, 2019, 12:59:04 AM »
Archie:

I added a second Message Handler and a second button to launch it. I ran the first message handler waited 10 seconds and then ran the 2nd. They both sent their messages however they alarmed out after 5 messages.

The point. I think designing a message handler to accept an unlimited number of emails is a big job and overkill for what we need to do. From what I can see in the code the only real problem would be in recording the events and alarms.

I could copy the message handler and rename it to messagehandlerA,B, and C. 3 of them. Change the code to open event log A,B,C and alarm log A,B,C. Then the only thing I would need is feedback to tell me when the message handler is complete. From there it would be easy to select an available handler for the next email.

What do you think?

Dave

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Message Handler
« Reply #36 on: June 18, 2019, 06:46:42 AM »
I completely revamped the MessageHandler to use independent timers for each message, run multithreaded, and use a queue for email sending. This gets around the problems related to the message handler. I will post the code later this morning after I do a little more testing.

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Message Handler
« Reply #37 on: June 18, 2019, 07:01:14 AM »
Archie;

I just tested using two message handlers again this morning it worked fine to 5 emails.

But if you already did a new one, wow! It will be interesting to see how you handled the multi thread problem.

Thanks,
Dave

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Message Handler
« Reply #38 on: June 18, 2019, 04:28:34 PM »
This version has major changes, so I'm sure there will need to be some debugging. But overall it is much more robust.

- Download the attached file
- Unzip the file
- Open you project in Visual Studio
- Right click the AdvancedHMI project and select Add->Existing item (if these files were put in a folder, you will need to right click the folder.
- Browse to and select all of the files the were extracted
- Make sure it asks you to replace existing files (if not they are not replacing the old ones)
- Rebuild Solution

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Message Handler
« Reply #39 on: June 18, 2019, 09:03:59 PM »
Archie;

This is scary! I did what you instructed, and got the following error on rebuild.

'Count' is not a member of 'String()'.

8 times.

I do not see count in the property box but will dig deeper.

Dave

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Message Handler
« Reply #40 on: June 18, 2019, 09:05:31 PM »
Archie;

I also got this one.

Severity   Code   Description   Project   File   Line   Suppression State
Error      Could not copy the file "obj\Debug\AdvancedHMICS.exe" because it was not found.   AdvancedHMIcs         
Dave

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Message Handler
« Reply #41 on: June 18, 2019, 09:10:34 PM »
Archie;

I did something wrong the message handler code is the same as the old one, or the old one no longer exists? I don't know.

Dave

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Message Handler
« Reply #42 on: June 18, 2019, 09:18:04 PM »
Archie;

This is scary! I did what you instructed, and got the following error on rebuild.

'Count' is not a member of 'String()'.

8 times.

I do not see count in the property box but will dig deeper.
If you double click on the error, what line of code does it take you to?

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Message Handler
« Reply #43 on: June 18, 2019, 10:42:08 PM »
Try changing Count to Length or use the attached files.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Message Handler
« Reply #44 on: June 18, 2019, 11:35:48 PM »
Godra is correct. Any error that goes to ".count" should be changed to ".length"

Arrays should use the Length property, but I tend to use Count out of habit. For a reason that I cannot explain, it compiles with no errors on my PC, but often not on others.