Scheduled task

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
bjornidar
Posts: 49
Joined: Thu Nov 17, 2011 2:10 am
Location: Norway
Contact:

Scheduled task

Post by bjornidar »

Hi,

is it possible to run a scheduled task every second in iX?

User avatar
Kyle W.
Posts: 36
Joined: Wed Apr 09, 2014 3:16 pm

Re: Scheduled task

Post by Kyle W. »

There are a couple options for scheduling a task. The first doesn't require any scripting. You could add the Demo Controller as an additional controller, which has counters built into it. See screenshots 1 and 2. You can set the timer to a tag and give the tag an action to do something every time the value of the timer changes.

A second option involves scripting but doesn't require a second controller. You can instantiate a timer with an interval and have it execute code every time the timer event "clicks". See the sample code:

Code: Select all

//Tie the start of the timer to an event like screen open or tag value change
		void Screen1_Opened(System.Object sender, System.EventArgs e)
		{
			m_Timer = new Timer();
			m_Timer.Interval = 500;
			m_Timer.Tick += doSomething;
			m_Timer.Enabled = true;
		}
			
		void doSomething (object sender, EventArgs e)
		{
			//code to execute on each timer tick
		}
Attachments
Screenshot2.png
Screenshot2.png (126.23 KiB) Viewed 6387 times
Screenshot1.png
Screenshot1.png (170.72 KiB) Viewed 6387 times
Best Regards,

Kyle W. | Applications Engineer
Beijer Electronics, Inc.

Post Reply