Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

Exercise: Setting

...

To observe the operation of the scheduler, adjust the scheduled start date to occur the current date and start times to occur within the next 5 minutes, then run the simulator. At the scheduled start time of their respective schedule, the tag values should display “1”.

...

an oil change reminder with the Scheduler feature.

...

Create three BOOL tags named “Washer”, “Light”, and “Vending”.

...

 

...

Create 3 different action lists by clicking Tools > Script Editor… > click + icon > Create New Commands > name the first action list “Activate Vending” > click Add New Command, then assign the value “true” to the “Vending” tag > click OK.

...

Repeat this step for the second and third action list called “Activate Washer” and “Activate Light”. Make sure to assign a corresponding tag in the Parameters section

...

 

...

Create 3 different schedules by clicking Tools > Schedule Editor… > click + icon. Each Schedule Title will be “Activate Vending”, “Activate Washer”, and “Activate Light”.

...

Configure the schedule setup based on the information provided below and make sure to assign a corresponding action in the Action section.

  1. Activate Vending: Start on 2023-03-01 at 07:30 military time and repeat every 1 day.

  2. Activate Washer: Start on 2023-03-22 at 07:45 military time and repeat once a week every Wednesday.

  3. Activate Light: Start on 2023-03-01 at 18:00 military time and repeat once every first day of the month.

    Image Removed

     

...

Create three different text boxes and bind the “Vending”, “Washer”, and “Light” tags to the Text property of their respective text boxes.

...

 

 

Scheduler Configuration

  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.

Image Added

Image Added

  1. 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. 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.

Image Added

  1. 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. 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. Click and drag across the screen to place the Fillable Rectangle.

Image Added

Image Added

Image Added

  1. 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.

Image Added

  1. 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:

Code Block
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.

Image Added

Image Added

Image Added

  1. 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.

Image Added

Image Added

Scheduler Runtime

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

Image Added

  1. 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.

Image Added

  1. 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.”

Image Added