<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Function Block, Initialisation at instantiation</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/5aa763a4ad/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/5aa763a4ad/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/5aa763a4ad/</id><updated>2020-02-27T21:55:39.927000Z</updated><subtitle>Recent posts to Function Block, Initialisation at instantiation</subtitle><entry><title>Function Block, Initialisation at instantiation</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5aa763a4ad/?limit=25#d5e6" rel="alternate"/><published>2020-02-27T21:55:39.927000Z</published><updated>2020-02-27T21:55:39.927000Z</updated><author><name>annodomini2</name><uri>https://forge.codesys.com/u/annodomini2/</uri></author><id>https://forge.codesys.com5b4be969d7bc4d4cf1a197ff7643d88d7cb10cfc</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;spfeif hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Igor can you elaborate slightly on your last post about actions with the example of myFB1.Run().. etc.. It sounds interesting but I am not sure I understand your point. Or we might be thinking of the same thing.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Actions are required to use the function interface of the heading block.&lt;/p&gt;
&lt;p&gt;In 99% of all other true object orientated languages procedures of the defining class can have a different function interface.&lt;/p&gt;
&lt;p&gt;Does the method changes in 3.0 support this?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Function Block, Initialisation at instantiation</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5aa763a4ad/?limit=25#eeda" rel="alternate"/><published>2020-02-27T21:55:35.683000Z</published><updated>2020-02-27T21:55:35.683000Z</updated><author><name>spfeif</name><uri>https://forge.codesys.com/u/spfeif/</uri></author><id>https://forge.codesys.com831ed50fdaf3b2900c5f0dac0b7ecacaed00424c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Igor can you elaborate slightly on your last post about actions with the example of myFB1.Run().. etc.. It sounds interesting but I am not sure I understand your point. Or we might be thinking of the same thing.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Function Block, Initialisation at instantiation</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5aa763a4ad/?limit=25#e416" rel="alternate"/><published>2020-02-27T21:55:33.888000Z</published><updated>2020-02-27T21:55:33.888000Z</updated><author><name>annodomini2</name><uri>https://forge.codesys.com/u/annodomini2/</uri></author><id>https://forge.codesys.com59d6b70f1d8903b3f649d21fb76a4c05a6c3c4a6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Can't wait till we get 3.0, The limitaiton of this is that the Actions require the usage of the defined inputs for the type, rather than a 'Class' with methods/functions that operate on the instance data.&lt;/p&gt;
&lt;p&gt;Real limitation of the language/system.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Function Block, Initialisation at instantiation</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5aa763a4ad/?limit=25#acdd" rel="alternate"/><published>2020-02-27T21:55:29.666000Z</published><updated>2020-02-27T21:55:29.666000Z</updated><author><name>Igor Petrov</name><uri>https://forge.codesys.com/u/igor-petrov/</uri></author><id>https://forge.codesys.com084b9341554211012341863030fb6d390330f499</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Without actions you need extra inputs for parameters or for change the behavior. As result FB looks like a hedgehog  &lt;/p&gt;
&lt;p&gt;With actions you can write: MyFB1.Stop(), MyFB1.Set_new_ID(), MyFB1.Run()…  &lt;/p&gt;
&lt;p&gt;Unfortunately FB has no a specialized automatic action for initialization (it is possible in SFC), but you could call any action only once for a special work.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Function Block, Initialisation at instantiation</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5aa763a4ad/?limit=25#324c" rel="alternate"/><published>2020-02-27T21:55:28.158000Z</published><updated>2020-02-27T21:55:28.158000Z</updated><author><name>annodomini2</name><uri>https://forge.codesys.com/u/annodomini2/</uri></author><id>https://forge.codesys.com66d035441b699582271d396a8fdc4ce5480e0ec1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Igor Petrov hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
By the way, in CoDeSys you can use 'Actions' in FB = very useful feature.  You could use it for a few 'smart initialization'. For example if you need to calculate something during the initialization.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Sounds interesting, will read up on that, thank you.&lt;/p&gt;
&lt;p&gt;So for example if you had an FB that read a specific CAN message from different sources, for a specific instance you could initialise the instance with the Device Id of a specific source and then at initialisation produce and store the entire message Id?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Function Block, Initialisation at instantiation</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5aa763a4ad/?limit=25#e155" rel="alternate"/><published>2020-02-27T21:55:23.914000Z</published><updated>2020-02-27T21:55:23.914000Z</updated><author><name>Igor Petrov</name><uri>https://forge.codesys.com/u/igor-petrov/</uri></author><id>https://forge.codesys.com41de9af54bf57255b7db9f274775c69fd16f81ba</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;annodomini2 hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Thanks, I assume this also applies to the VAR declaration block and not just VAR_INPUT?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;IEC programmers are used to concentrate all parameters in inputs. Therefore in LD or FBD they connect external constants with the graphic box (FB instance) and get an easy to review and change diagram.&lt;/p&gt;
&lt;p&gt;But if you consider it reasonable… Why not:&lt;/p&gt;
&lt;p&gt;FUNCTION_BLOCK xz_xz&lt;/p&gt;
&lt;p&gt;VAR_INPUT&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;bIn1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;END_VAR&lt;/p&gt;
&lt;p&gt;VAR_OUTPUT&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;bOut1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;END_VAR&lt;/p&gt;
&lt;p&gt;VAR&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;byVar1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BYTE&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;END_VAR&lt;/p&gt;
&lt;p&gt;;&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;Declaration:&lt;/p&gt;
&lt;p&gt;xz1 : xz_xz := (byVar1 := 1);&lt;/p&gt;
&lt;p&gt;By the way, in CoDeSys you can use 'Actions' in FB = very useful feature.  You could use it for a few 'smart initialization'. For example if you need to calculate something during the initialization.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Function Block, Initialisation at instantiation</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5aa763a4ad/?limit=25#0964" rel="alternate"/><published>2020-02-27T21:55:22.405000Z</published><updated>2020-02-27T21:55:22.405000Z</updated><author><name>annodomini2</name><uri>https://forge.codesys.com/u/annodomini2/</uri></author><id>https://forge.codesys.come2907df2da951bb835aea52e5727924c063efa3e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Igor Petrov hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
1) You can do global initialization (for all instances). Example:&lt;br/&gt;
FUNCTION_BLOCK SyncSwitch&lt;br/&gt;
VAR_INPUT&lt;br/&gt;
bSync:  BOOL := TRUE;&lt;br/&gt;
…&lt;br/&gt;
2) In the instances you can redefine the initialization:&lt;br/&gt;
SyncSwitch_1 : SyncSwitch := (bSync := FALSE);&lt;br/&gt;
3) You can use different direct variables in different instances. See  in the manual.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thanks, I assume this also applies to the VAR declaration block and not just VAR_INPUT?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Function Block, Initialisation at instantiation</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5aa763a4ad/?limit=25#46b0" rel="alternate"/><published>2020-02-27T21:55:18.154000Z</published><updated>2020-02-27T21:55:18.154000Z</updated><author><name>Igor Petrov</name><uri>https://forge.codesys.com/u/igor-petrov/</uri></author><id>https://forge.codesys.com6e3e3d846e8aacab0ed0450054fe21e8bf2401e7</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;1) You can do global initialization (for all instances). Example:&lt;/p&gt;
&lt;p&gt;FUNCTION_BLOCK SyncSwitch&lt;/p&gt;
&lt;p&gt;VAR_INPUT&lt;/p&gt;
&lt;p&gt;bSync:  BOOL := TRUE;&lt;/p&gt;
&lt;p&gt;…&lt;/p&gt;
&lt;p&gt;2) In the instances you can redefine the initialization:&lt;/p&gt;
&lt;p&gt;SyncSwitch_1 : SyncSwitch := (bSync := FALSE);&lt;/p&gt;
&lt;p&gt;3) You can use different direct variables in different instances. See &lt;strong&gt;Variable Configuration&lt;/strong&gt; in the manual.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Function Block, Initialisation at instantiation</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5aa763a4ad/?limit=25#746c" rel="alternate"/><published>2020-02-27T21:55:16.622000Z</published><updated>2020-02-27T21:55:16.622000Z</updated><author><name>annodomini2</name><uri>https://forge.codesys.com/u/annodomini2/</uri></author><id>https://forge.codesys.com8768558aa6345952d4333a9372d40ad079eb4ba4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt; &lt;span class="nv"&gt;I&lt;/span&gt; &lt;span class="nv"&gt;new&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;board&lt;/span&gt; &lt;span class="nv"&gt;and&lt;/span&gt; &lt;span class="nv"&gt;CoDeSys&lt;/span&gt;, &lt;span class="nv"&gt;but&lt;/span&gt; &lt;span class="nv"&gt;not&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;software&lt;/span&gt;.



 &lt;span class="nv"&gt;Had&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;search&lt;/span&gt; &lt;span class="nv"&gt;but&lt;/span&gt; &lt;span class="nv"&gt;doesn&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;t appear to be anything relating to this.&lt;/span&gt;



 &lt;span class="nv"&gt;Now&lt;/span&gt; &lt;span class="nv"&gt;my&lt;/span&gt; &lt;span class="nv"&gt;question&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;regarding&lt;/span&gt; &lt;span class="nv"&gt;Function&lt;/span&gt; &lt;span class="nv"&gt;Blocks&lt;/span&gt;, &lt;span class="nv"&gt;which&lt;/span&gt; &lt;span class="nv"&gt;generally&lt;/span&gt; &lt;span class="nv"&gt;need&lt;/span&gt; &lt;span class="nv"&gt;an&lt;/span&gt; &lt;span class="nv"&gt;instance&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;to&lt;/span&gt; &lt;span class="nv"&gt;be&lt;/span&gt; &lt;span class="nv"&gt;used&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;reusability&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;, &lt;span class="nv"&gt;now&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;I&lt;/span&gt; &lt;span class="nv"&gt;initialise&lt;/span&gt; &lt;span class="nv"&gt;some&lt;/span&gt; &lt;span class="nv"&gt;internal&lt;/span&gt; &lt;span class="nv"&gt;variables&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;constants&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;a&lt;/span&gt; &lt;span class="nv"&gt;specific&lt;/span&gt; &lt;span class="nv"&gt;instance&lt;/span&gt;? &lt;span class="nv"&gt;And&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nv"&gt;so&lt;/span&gt;, &lt;span class="nv"&gt;How&lt;/span&gt;?
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Thanks Anno&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>