主程序变量公众battery_voltage酒吧lic panel_temperature Public temperature 'EmailRelay() constants Const _EMAIL_ATTACHMENT = "" Const _EMAIL_SUBJECT = "Email Message" Const _EMAIL_TO_ADDRESS = "some.user@campbellsci.com" Const _CR_LF = CHR(13) & CHR(10) 'EmailRelay() variables Public email_message As String * 300 Public email_relay_server_response As String * 100 Public email_relay_results_human_readable As String * 100 Public email_trigger As Boolean Public email_tx_success BeginProg Scan (1,Sec,3,0) Battery (battery_voltage) PanelTemp (panel_temperature,250) TCDiff (temperature,1,mV200C,U1,TypeT,panel_temperature,True ,0,250,1.0,0) If temperature > 30 Then email_trigger = True EndIf NextScan SlowSequence Do If email_trigger = True Then email_trigger = False 'reset my trigger email_message = "Warning!" & _CR_LF & _CR_LF email_message = email_message & "This is a automatic email message from the datalogger station " & Status.StationName & ". " email_message = email_message & "An alarm condition has been identified." & _CR_LF email_message = email_message & "The temperature is " & temperature & " degrees C." & _CR_LF email_message = email_message & "Datalogger time is " & Status.Timestamp '1st attempt email_tx_success = EmailRelay (_EMAIL_TO_ADDRESS,_EMAIL_SUBJECT,email_message,email_relay_server_response,_EMAIL_ATTACHMENT) 'If EmailRelay was not successful, lets try one more time. If (email_tx_success <> -1) Then '2nd attempt email_tx_success = EmailRelay (_EMAIL_TO_ADDRESS,_EMAIL_SUBJECT,email_message,email_relay_server_response,_EMAIL_ATTACHMENT) EndIf 'tell my human what happened with EmailRelay in human speak instead of loggerspeak ' my user got this information from the CRBasic help for EmailRelay Select Case email_tx_success Case -1 email_relay_results_human_readable = "EmailRelay server received the message from the datalogger successfully!" Case 0 email_relay_results_human_readable = "The connection to the EmailRelay server failed." Case -2 email_relay_results_human_readable = "Execution of the EmailRelay function did not occur due to lack of records or not enough time." Case -3 email_relay_results_human_readable = "A connection to the EmailRelay server was made but there was an error in communication." EndSelect EndIf Loop EndProg
Baidu