Detailed instructions for use are in the User's Guide.
[. . . ] S o l u t i o n s
Software Limited Agreement
LIMITED WARRANTY
LIMITED WARRANTY. AMX Corporation warrants that the SOFTWARE will perform substantially in accordance with the accompanying written materials for a period of ninety (90) days from the date of receipt. Any implied warranties on the SOFTWARE and hardware are limited to ninety (90) days and one (1) year, respectively. Some states/countries do not allow limitations on duration of an implied warranty, so the above limitation may not apply to you. [. . . ] An example is provided below: SmtpSetUser('user1', 'password') // include only if you need SMTP authentication If the SMTP email server allows anonymous access and does not require authentication, you simply comment out the previous SmtpSetUser() function call. Without an SMTP username and password configured, i!-EquipmentMonitor will connect to the SMTP server with anonymous access.
i!-EquipmentMonitor
3
Running i!-EquipmentMonitor
Now, all you need to do is call the function that sends an email. If you want to send an email every time someone presses a button on a touch panel, your code would look like this:
BUTTON_EVENT[dvTP, 1] { PUSH: { SmtpQueMessage('fromAddress@mydomain. com', 'toAddress@mydomain. com ', 'My Emails subject', 'this is the body of my email!Wow, this is Cool!', '') } }
The call to SmtpQueMessage() causes your email to queue and transmit to the SMTP server. The maximum number of emails that can be queued is controlled by the constant SMTP_MAX_EMAILS, which defaults to 10. You can override this value if you choose; you will probably never have a need to since the emails are sent very quickly. The parameters to SmtpQueMessage() control where your email will be sent. This usually does not have to be a real email address but some SMTP server configurations may require a valid one. This can be a list of addresses separated by a ";" so you can send an email to more than one recipient in a single call to SmtpQueMessage(). The message can be up to SMTP_MSG_MAX characters long (the default value is 2000 but you can override it if necessary). If you supply a value for this parameter, i!-EquipmentMonitorOut attempts to open this file from the Master's file system and include it as an attachment to the email. Binary files are not supported at this time so the file must be ASCII (text) only. If the file does not exist or cannot be opened, an error is printed to the terminal, but the email is still sent without an attachment.
Receiving Email
To support receiving email, first include the i!-EquipmentMonitorIn. axi (page 11) into you program:
#INCLUDE 'i!-EquipmentMonitorIn. axi' // Include to get email
Next, make sure that the default IP local port used by i!-EquipmentMonitorIn. axi is available on your system. Make sure there is no current entry in your DEFINE_DEVICE section for 0:11:0. If there is a current entry for 0:11:0, you can change the existing entry to another local port number or override the default local port used by i!EquipmentMonitorIn. axi like this in the DEFINE_DEVICE section:
dvPop3Socket = 0:4:0
Next, you need to initialize the POP3 server value by calling Pop3SetServer (). The names of the files attached.
The subject and body are the items you need most in the structure. The count of file attachments tells you the total number of files attached but the cAttachments containing up to POP3_ATTACH_MAX (default is 5) file names. Only the file names are supplied for reference.
Continued
i!-EquipmentMonitor
5
Running i!-EquipmentMonitor
You can use the following code to loop through the downloaded emails whenever new email arrives:
DATA_EVENT[dvPop3Socket] { OFFLINE: { STACK_VAR INTEGER nLoop Integer nLoop1 For (nLoop=1;nLoop<=nPop3QtyMail;nLoop++) { SEND_STRING 0, 'i!Email Test-Print Message' SEND_STRING 0, ' ' SEND_STRING 0, "'Message #', Itoa(nLoop)" SEND_STRING 0, "'Date:', sPop3EmailMessage[nLoop]. cDate" SEND_STRING 0, "'From: "', sPop3EmailMessage[nLoop]. cFromPersonal, '" <', sPop3EmailMessage[nLoop]. cFrom, '>'" SEND_STRING 0, "'To: "', sPop3EmailMessage[nLoop]. cToPersonal, '" <', sPop3EmailMessage[nLoop]. cTo, '>'" SEND_STRING 0, "'Subject:', sPop3EmailMessage[nLoop]. cSubject" SEND_STRING 0, "'Message:', sPop3EmailMessage[nLoop]. cMessage" SEND_STRING 0, "'Attachments:', Itoa(sPop3EmailMessage[nLoop]. nAttachCount)" For (nLoop1=1;nLoop1<=sPop3EmailMessage[nLoop]. nAttachCount;nLoop1++) SEND_STRING 0, "'Attachment ', Itoa(nLoop1), ':', sPop3EmailMessage[nLoop]. cAttachments[nLoop1]" SEND_STRING 0, ' ' } } }
Once the emails are processed, you can delete any emails you like by calling Pop3ClearEmailMessage () or Pop3ClearAllEmailMessages (). Pop3ClearEmailMessage allows you to delete one email at a time; Pop3ClearAllEmailMessages () allows you to delete all the emails at once.
Configuring for Timezone
The i!-EquipmentMonitorOut. axi file can read the time zone information from i!-TimeManager and includes this information in email and notifications. Simply include the i!-TimeManager moodule and make sure to name the i!-TimeManager virtual device 'vdvTmEvents'. The file 'i!-EquipmentMonitorTest with i!-TimeManager. axs' provides an example of using these two applications together. Using i!-TimeManager is recommended for use with i!-EquipmentMonitor since some email clients may improperly display the time when the email or notification was sent. [. . . ] The file parameter is the path and file of an ASCII (text) only file contained on the Master's file systems. If the message was successfully queued for sending.
Continued
10
i!-EquipmentMonitor
Running i!-EquipmentMonitor
i!-EquipmentMonitorIn. axi
Constants The following table lists the i!-EquipmentMonitorIn. axi constants. i!-EquipmentMonitorIn. axi Constants
dvPop3Socket POP3_VERSION POP3_PORT POP3_BUFFER_MAX POP3_SERVER_TO POP3_URL_MAX POP3_USER_MAX POP3_PASS_MAX POP3_LINE_MAX POP3_MAX_EMAILS POP3_MSG_MAX POP3_ATTACH_MAX The IP device number for sending e-mails (default = 0:11:0}. Maximum number of attachment file names stored (default = 5).
Structures The following describes an i!-EquipmentMonitorIn. axi structure:
Structure _sEmailMessage { Integer nMsgNum; Char cUniqueID[POP3_USER_MAX]; long lMsgSize; Char cFrom[POP3_USER_MAX]; Char cFromPersonal[POP3_USER_MAX]; Char cTo[POP3_USER_MAX]; Char cToPersonal[POP3_USER_MAX]; Char cDate[POP3_USER_MAX]; Char cSubject[POP3_LINE_MAX]; Char cMessage[POP3_MSG_MAX]; Integer nAttachCount; Char cAttachments[POP3_ATTACH_MAX][POP3_LINE_MAX];
Variables The following are a list of i!-EquipmentMonitorIn. axi variables:
VOLATILE _sEmailMessage sEmailMessage[POP3_MAX_EMAILS] VOLATILE Integer nPop3QtyMail; VOLATILE Integer nPop3TotalMail; VOLATILE CHAR bPop3Debug
Emails retrieved from server
Number of message retrieved from server
Number of total messages on server
Set to 1 to debug
i!-EquipmentMonitor
11
Running i!-EquipmentMonitor
Functions The following table lists i!EmailIn. axi functions. [. . . ]