18.01.2015 Views

Technical Reference Manual - InduSoft

Technical Reference Manual - InduSoft

Technical Reference Manual - InduSoft

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Introduction<br />

Executing and switching the Background Task<br />

The Background Task executes scripts from the Math and Scheduler worksheets (for example, messages from<br />

Alarm and Trend worksheets). In addition, the Background Task executes all Recipe and Report commands<br />

when the Recipe or Report functions are executed during the runtime.<br />

Although the Alarm, Math, Scheduler, and Trend tasks are not threads, you can specify or change their<br />

Period time in the Program Settings.ini file located in the IWS program directory.<br />

The Period default values (in milliseconds) are as follows:<br />

[Period]<br />

Math=100<br />

Sched=50<br />

Alarm=100<br />

Trend=1000<br />

These values mean that every 100ms, IWS generates a Period message to the Math task. Every 50ms, IWS<br />

generates a Period message to the Scheduler task, and so on.<br />

Caution: We strongly recommend that you do not modify the Background Task default values<br />

unless it is absolutely necessary. Configuring any of these parameters incorrectly can cause your<br />

entire system to malfunction (for example, CPU usage will go to 100%) and/or cause some tasks to<br />

perform poorly.<br />

If you must change the parameter defaults, note the values before making your changes so if a<br />

malfunction occurs you can return to the original settings.<br />

Keep in mind that the Background Task thread has the same priority as other threads in IWS (Drivers,<br />

Viewer, and so forth), which means that the operating system will not execute this task continuously for more<br />

than 20ms.<br />

The Background Task executes the Recipe and Report worksheets when the Recipe and Report functions are<br />

called, respectively. Because the Recipe and Report functions are synchronous, once the Background Task<br />

starts executing the functions, it will not switch to another task (Alarm, Math, Scheduler, or Trend) until it<br />

completely executes the functions. Executing a Recipe or Report function usually takes a few milliseconds.<br />

The Background Task must switch between the Alarm, Math, Scheduler, and Trend tasks. When Background<br />

Task switches to the Scheduler task, it will not switch to another task (Alarm, Math, or Trend) until all<br />

Scheduler worksheets are executed. After executing all Scheduler worksheets, the Background Task will not<br />

execute the Scheduler again until it receives the next Period message for the Scheduler task.<br />

The Background Task applies the same behavior when executing the Alarm and Trend tasks — when the<br />

Background Task switches to the Alarm or Trend task, it will not switch to another task until it handles<br />

all pending messages. So, the Background Task will not execute the Alarm or Trend task again, until IWS<br />

generates the next Period message for each of these tasks.<br />

The Background Task typically executes the Alarm, Scheduler, and Trend tasks in a few milliseconds.<br />

However, it can take longer to execute the Math task because it usually contains loops and complex scripts.<br />

Consequently, the mechanism used to execute the Alarm, Scheduler, and Trend tasks cannot be applied to<br />

the Math task.<br />

The Background Task executes the Math task for no more than 10ms continuously before switching to other<br />

task (such as the Scheduler). The Background Task cannot execute the Math task again for the next 50ms;<br />

however, the Background Task can execute other tasks (Alarm, Recipe, Report, Scheduler, or Trend) during<br />

this 50ms period. After the Background Task executes all of the Math worksheets, it will not begin a new scan<br />

of the Math worksheets until IWS generates a new Period message for the Math task.<br />

It is important to re-emphasize that this process was created to prevent 100% CPU usage all the time.<br />

Caution: We recommend caution when using the Math function in a Scheduler worksheet or for a<br />

screen object (such as the Command animation).<br />

When the Scheduler task executes a Math function, no other task can be executed by the<br />

Background Task until the Scheduler executes the entire Math worksheet called by the Math<br />

Page 28<br />

<strong>InduSoft</strong> Web Studio

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!