<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Executing Actions as tasks</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3bf0cfe419/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3bf0cfe419/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/3bf0cfe419/</id><updated>2020-02-27T14:17:12.434000Z</updated><subtitle>Recent posts to Executing Actions as tasks</subtitle><entry><title>Executing Actions as tasks</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3bf0cfe419/?limit=25#f2ee" rel="alternate"/><published>2020-02-27T14:17:12.434000Z</published><updated>2020-02-27T14:17:12.434000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.coma1dc944e2a80b70d8e7044758e0b08b14006f22a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; Paul K.&lt;/p&gt;
&lt;p&gt;Thanks a lot Hermsen for this quick course. I'm quite comfortable with the C language but there are some details in ST and Codesys I still don't master so this kind of precision is always welcome.&lt;/p&gt;
&lt;p&gt;Anyway, my problem was solved earlier using POUs but I don't feel like rewriting the whole actual code taking advantage of Codesys 3.5's new features. Having it to build, download and run already was painful enough!&lt;/p&gt;
&lt;p&gt;Cheers.&lt;/p&gt;
&lt;p&gt;Paul&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Executing Actions as tasks</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3bf0cfe419/?limit=250#aa31" rel="alternate"/><published>2020-02-27T14:17:11.904000Z</published><updated>2020-02-27T14:17:11.904000Z</updated><author><name>Hermsen</name><uri>https://forge.codesys.com/u/hermsen/</uri></author><id>https://forge.codesys.comaf21e9dd0b836a478f60259a003613e84ab7d259</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;An action is actually a method without an argument or a return value i.e.;&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;POU&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Action&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;You can call the action from inside the POU itself like;&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;Action&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Or you can call the action of the POU from anywhere in the program. I.e. via;&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;PRG&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;POU&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Action&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;An action is always argumentless, and cannot return any values!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Instead of using actions, it is generally smarter in Codesys3.5 to use Methods, because methods can return values (like a function) and can be passed arguments. yay!    Offcourse, methods are not provided is Codesys2.3 but actions are. Generally, Anything an Action does, a Program POU within Codesys 2.3 does that job better (i.e more flexibility!). So Personally I tend to not use actions but Programs within Codesys2.3.&lt;br/&gt;
A few codesys 3.5 method call examples;&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;MyPOU&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DoSomething&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;Start&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Go&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="n"&gt;MyPou&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DoSomething&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="k"&gt;Start&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MyPou&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DoSomething&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="k"&gt;Result&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ar&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Array&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;You can see, an argument can be passed arbitrairily, and a result may be returned (both not mandatory), so you have flexibility which actions do not provide, which is in my opinion is superior. Be also aware that calling a method on a POU, only the method is resolved. To resolve the POU, it must be called explicitly.&lt;br/&gt;
So calling;&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;POU&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Method1&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Only executes the method, you still need to call;&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;POU&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Hope this primer on Actions/Methods helps a bit on understanding the basics. Methods in combination with interfaces is not covered in this primer. Anyhow, any and all feedback on the usage of methods subject is welcome!&lt;/strong&gt;Ps using methods calls in graphics can result into drama. This is a point which codesys should resolve within the foreseeable future &lt;br/&gt;
In the mean time there several workarounds to achieve that job which you can find in this forum.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Executing Actions as tasks</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3bf0cfe419/?limit=25#5518" rel="alternate"/><published>2020-02-27T14:17:10.751000Z</published><updated>2020-02-27T14:17:10.751000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com0b48b58445042900be6e42ed4e729aa0d68e9068</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; Paul K.&lt;/p&gt;
&lt;p&gt;Hello, and thank you for your answer.&lt;/p&gt;
&lt;p&gt;I understand what you're saying, I'm still rather new to Codesys and still learning things...&lt;br/&gt;
The problem was solved, as you said, by calling the action in a separate POU and by calling the POU from the task.&lt;/p&gt;
&lt;p&gt;Thanks again!&lt;/p&gt;
&lt;p&gt;Paul&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Executing Actions as tasks</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3bf0cfe419/?limit=25#bcbb" rel="alternate"/><published>2020-02-27T14:17:10.383000Z</published><updated>2020-02-27T14:17:10.383000Z</updated><author><name>chris.beard</name><uri>https://forge.codesys.com/u/chris-beard/</uri></author><id>https://forge.codesys.com7c84068ac4ee0766aba45fb25fd6954a8fbd385b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I've never tried to start an action using a task. The only way I do it is calling the action from a POU which is started  from a task. Generally speaking best practice would be to keep actions and methods specific to the POU they are from.  Otherwise they should be seperate prgs if you want to call them from a task. &lt;/p&gt;
&lt;p&gt;Sent from my SM-N9005 using Tapatalk&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Executing Actions as tasks</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/3bf0cfe419/?limit=25#6f56" rel="alternate"/><published>2020-02-27T14:17:09.997000Z</published><updated>2020-02-27T14:17:09.997000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.coma8ea528487b03baa9a73a805aa77d637ce055fbe</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; Paul K.&lt;/p&gt;
&lt;p&gt;Hi everyone,&lt;/p&gt;
&lt;p&gt;I'm currently porting a Codesys 2.3 project to the latest 3.5 and I'm running into this problem.&lt;br/&gt;
I have several POUs and each one has a number of actions, in the 2.3 project the Task Manager was used to start some of those actions. &lt;br/&gt;
After porting the project to 3.5 the tasks are still here, however the call to the actions are gone. For example in 2.3 I had a task with the "Program call" filled as Program.Action, and after importing the tasks in 3.5 the field only reads the program and not the action, and I can't figure out how to specify what action to execute.&lt;br/&gt;
I tried adding manually by adding the Action name after the program name, like it used to be with the 2.3 project, but my tasks do not start.&lt;/p&gt;
&lt;p&gt;What am I doing wrong? Is there even a way in 3.5 to start an action in a task? If not, is there a possible workaround?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;Paul&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>