---
title: "Scheduler Exercise"
canonical: "https://manual.cimon.com/space/AUR/4514283523/Scheduler%20Exercise"
format: markdown
---
# <span style="color: #403294">**Exercise: Setting an oil change reminder with the Scheduler feature.**</span>

- [Scheduler Configuration](https://cimon.atlassian.net/wiki/spaces/AUR/pages/4514283523/Scheduler+Exercise#Scheduler-Configuration)
- [Scheduler Runtime](https://cimon.atlassian.net/wiki/spaces/AUR/pages/4514283523/Scheduler+Exercise#Scheduler-Runtime)

## <span style="color: #4c9aff">**Scheduler Configuration**</span>

1. Create two tags. One will be named “Oil_Level,” and the other will be called “Oil_consumption.” Oil_Level will be an **INT (INT16)** with an **Initial Value** of 50. Oil_consumption will be a **BOOL** with the starting value as False.

2. Create a lamp on the page. To create a Switch/Lamp object, go to **Insert **>** Switch/Lamp** or left-click the **Insert Switch/Lamp** icon in the [Toolbar](https://cimon.atlassian.net/wiki/spaces/AUR/pages/4488265730). Then, click and drag on the screen to place the lamp. Once the Switch/Lamp object is created, drag the Oil_consumption tag to the lamp. This will bind the Value field to the Tag Oil_consumption.

3. Create a **Rectangle** and a **Fillable Rectangle**. Create a Rectangle by going to **Insert** > **Rectangle** or left-clicking the **Insert Rectangle** icon in the [Toolbar](https://cimon.atlassian.net/wiki/spaces/AUR/pages/4488265730). Click and drag across the screen to place the rectangle. While selecting the rectangle, go to **Actions** and create a new Command in the **Under Press** section. Create a set Tag Value command. Make sure the command will set Oil_Level to 100 when Pressed. To insert the Fillable Rectangle, click on **Insert** > **Fillable Rectangle** or by left-clicking the **Insert Fillable Rectangle **icon in the [Toolbar](https://cimon.atlassian.net/wiki/spaces/AUR/pages/4488265730). Click and drag across the screen to place the Fillable Rectangle.

4. Bind Oil_Level to the Fillable Rectangle. This can be achieved by clicking and holding the Oil_level tag and dragging it into the Fillable Rectangle. This will bind the current level property of the Fillable Rectangle to the Oil_level tag.

5. 
6. Click on **Tools > Script Editor**. Click the **+** icon to create a new script; on the popup window, click **OK**. Copy and paste the following code into the new script:

```
thread.msleep(500); // sleeps for 500 ms
while(tag.read("Oil_consumption")){ // while Oil_consumption is true
	thread.sleep(2); // pauses for 2 seconds
	tag.write("Oil_Level", tag.read("Oil_Level") - 1); // deducts 1 from the oil level.
}
```

Once pasted in, close the Script Editor by clicking OK. Select the lamp and go to the **Actions** tab. If **Actions** does not display, go to **View **>** Properties **>** Actions **and check the box. Under **On Press**, click the Action field and **Create New Command**. Click on **Add New Command** and select **Toggle Tag Value**. In the Tag field, select the Oil_consumption tag. Then, in the top left of the Command Editor, click the **+ **icon to create a new command. Change the new command to **Call script** and select the created script.

6. Create a new Schedule. To achieve this, go to **Tools** > **Schedule Editor**. Click the **+** to create a new schedule; set the **Schedule Title** to “Oil_Refill.” Set the **Start Date** to the current date and the **Start Time** to 5 minutes from the present time. For example, if the current time is 2:30, the **Start Time** should be 2:35. Set the schedule to repeat every hour. Click the **Action Field** > **Create New Commands**. Create a Send Screen Notification Command; the message for this notification should be “Refill the oil.” Click **OK** to save and exit, and click **OK** again to exit the Schedule Editor.

## <span style="color: #4c9aff">**Scheduler Runtime**</span>

1. Click** Tools** >**Launch Simulator** to launch the Canvas Simulator.

2. Click the lamp to turn Oil_consumption to True. This will start decreasing Oil_Level every two seconds. If the oil runs out while waiting for the schedule to appear, click the rectangle below the lamp to refill the oil.

3. After the time has been reached for the schedule to take effect, the screen notification set from the schedule should appear with the message “Refill the Oil.”

##### <span style="color: #4c9aff">[Back to Top of Scheduler Exercise](https://cimon.atlassian.net/wiki/spaces/AUR/pages/4514283523/Scheduler+Exercise#Exercise%3A-Setting-an-oil-change-reminder-with-the-Scheduler-feature.)</span>