Can a script to stop/start planner

@jpledger00
Plant shuts down occasionally and customer’s no longer want to receive the daily emails from Flexy. Is there a script that could turn the planner on or off or stop the emails temporarily by flipping a bit in PLC tag?

Also, wanted to know how to send data in the email body and not as attachment using script.

@jpledger00

I did find a way to do this that should work. You could create a tag for a boolean value and attach to your HMI, you could create a command like:

 ONCHANGE "YourTag", "@SetDate()" 

 FUNCTION MyFunc()
 SENDMAIL "me@myco.com", "", "Subject", "Message"
 ENDFN

 FUNCTION SetDate()
 IF (YourTag@ = 1) THEN 
    ONDATE 1,"15 8 * * 1","@MyFunc()"
    Print "first"
 ELSE 
    ONDATE 1
    Print "second"
 ENDIF
 ENDFN

You would just have to change the email Message to be the Export Block descriptor you are currently using in the planner, set the right times to send the email, and set up the tag in the Flexy, PLC, and HMI screen.

Hi Kyle

My apologies, but im just an automation engineer and PLC programmer. Do you have any instructions on getting this into the Ewon? Like, should it be a txt document? And html? Here is what I’ve done, just as a test. I tried an txt and html file in the usr directory

ONCHANGE “Enable_Production_Email”, “@SetDate()”

FUNCTION MyFunc()

SENDMAIL “----------@unitedsalesinc.net”, “”, “Subject”, “Message”

ENDFN

FUNCTION SetDate()

IF (Enable_Production_Email@ = 1) THEN

ONDATE 1,“3 7 * * 1”,"@MyFunc()"

Print “first”

ELSE

ONDATE 1

Print “second”

ENDIF

ENDFN

So you can just copy and paste it into the BASIC IDE in the web interface, but you will need to substitute for “message” your export block descriptor, which you can find in the planner and the frequency. Can you take a screen shot of your current planner entries and I’ll show you what I mean?

Hi Kyle,

Here ya go. Let me know if you need anything else

Jason

Hey Jason,

I just sent you a message with the script. You’ll have to test it with you Flexy to make sure it works. You are going to want to disable the current planner entries.

Please let me know ify ou have any questions.

Kyle

Not sure why this is not emailing out. ‘Enable Production Email’ is a Boolean and is a 1. I have tried the tag as a integer, with it being a 1, still wont email out. The scheduled actions log shows nothing being sent.

ONCHANGE “Enable_Production_Email”, “@SetDate()”
FUNCTION Entry1()
SENDMAIL “xx@xx.com”, “xx@xx.net,xx@xx.net”, “Production Performance Report”, “[$dtUF $fnreport_shift_1.html]”
ENDFN
FUNCTION Entry2()
SENDMAIL “xx@xx.net”, “xx@xx.net”, “FN lifts report”, “[dtUF $fnlifts_report.html]”
ENDFN
FUNCTION Entry3()
SENDMAIL “xx@xx.net”, “xx@xx.net”, “FN lifts report”, “[dtUF $fnlifts_report.html]”
ENDFN
FUNCTION SetDate()
IF (Enable_Production_Email@ = 1) THEN
ONDATE 1,“0 18 * * *”,"@Entry1()"
ONDATE 2,“0 16 * * *”,"@Entry2()"
ONDATE 3,“52 12 * * *”,"@Entry3()"
Print “Emails ON”
ELSE
ONDATE 1
ONDATE 2
ONDATE 3
Print “Emails OFF”
ENDIF
ENDFN

Hi Joseph,

Do you already have this setup?

Can you also check and see if the status for the sendmail shows successful?

Yes. I have put it in the cyclic and init section to no avail.

How do I go about doing that? I see the logs and schedule actions? (That is not showing any records of failed or attempted emails”(

Make sure to keep that code out of the cyclic section because that will be running every processor cycle and usually will cause the device to run into issues.

Can you take out the section of code you have right now and try and just run this section

SENDMAIL “xx@xx.net”, “xx@xx.net”, “FN lifts report”, “[dtUF $fnlifts_report.html]”

I have all of this in the Basic IDE

That worked but the attachment was not an attachment.

When I toggle ‘Enable Production Email’ I get ‘Email Off / Email On’ so the its picking up the bit.