I have a application that is part console application written in C# and part PHP web application.
The console application connects to multiple serial devices and reads data pertaining to moisture and temperature in a Grain Dryer. [The application] then stores the information in a MySQL database.
The PHP reads the MySQL database and displays the information to the user (simple).
I have also written a PHP script to email / sms the user if one of the temperatures of moistures reaches alarm levels (alarm levels are read off the device and stored in the MySQL database).
Currently, I post to the PHP page with each "update" from the device (10 seconds) and check each value against it's limits. If an alarm is required I send it off and update the database indicating an alarm has been sent.
This looks like (pseudo code)
IF moisture IS GREATER THAN moisture_high_critical_limit THEN IF moisture_high_critical_alarm_has_been_sent IS FALSE THEN SEND_ALARM(); moisture_high_critical_alarm_has_been_sent = TRUE; END IF ELSE IF moisture IS GREATER THAN moisture_high_warning_limit THEN IF moisture_high_warning_alarm_has_been_sent IS FALSE THEN SEND_ALARM(); moisture_high_warning_alarm_has_been_sent = TRUE; END IF ELSE IF moisture IS LESS THAN moisture_low_critical_limit THEN IF moisture_low_critical_alarm_has_been_sent IS FALSE THEN SEND_ALARM(); moisture_low_critical_alarm_has_been_sent = TRUE; END IF ELSE IF moisture IS LESS THAN moisture_low_warning_limit THEN IF moisture_low_warning_alarm_has_been_sent IS FALSE THEN SEND_ALARM(); moisture_low_warning_alarm_has_been_sent = TRUE; END IF END IF
The above IF statement is repeated for every temperature and moisture reading from the device, which can be quite a few.
Should this type of processing be happening in my Console application? Then if a Alarm notification is required post to the page only to send the email / SMS?
Processing this information in the console application will reduce my total number of handshakes with the MySQL Database. But if the MySQL Database is hosted locally will this have much impact?
I will eventually benchmark both (if it seems the doing the processing in the console application is in fact the right approach), however there is a lot of code to port over so I thought I'd come here and ask first.