<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Automatic assignment of instances</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5a47a7dc9f/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5a47a7dc9f/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/5a47a7dc9f/</id><updated>2020-02-27T14:07:05.193000Z</updated><subtitle>Recent posts to Automatic assignment of instances</subtitle><entry><title>Automatic assignment of instances</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5a47a7dc9f/?limit=25#a231" rel="alternate"/><published>2020-02-27T14:07:05.193000Z</published><updated>2020-02-27T14:07:05.193000Z</updated><author><name>lothar</name><uri>https://forge.codesys.com/u/lothar/</uri></author><id>https://forge.codesys.com6e1df4a5a315089bdc8192b1b47fe8839addeab1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Andreaz,&lt;/p&gt;
&lt;p&gt;your suggestion sounds interesting but i still wasn't succeessfull getting this to run. I'm afraid I havn't understood the example. Could you please explain this a little bit more?&lt;/p&gt;
&lt;p&gt;best regards&lt;br/&gt;
Lothar&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Automatic assignment of instances</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5a47a7dc9f/?limit=25#8358" rel="alternate"/><published>2020-02-27T14:07:04.242000Z</published><updated>2020-02-27T14:07:04.242000Z</updated><author><name>Andreaz</name><uri>https://forge.codesys.com/u/andreaz/</uri></author><id>https://forge.codesys.coma809159377c30c0ccc053c03147300ef79f09664</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Yes this is very possible indeed using the new OOP features in V3:&lt;/p&gt;
&lt;p&gt;Create a interface called IDevice and add a method Update to that interface (and the other methods you'd need ) and then create a few function blocks implementing the interface and the interface methods.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;FUNCTION_BLOCK&lt;/span&gt; &lt;span class="n"&gt;FB_Drive1&lt;/span&gt; &lt;span class="n"&gt;IMPLEMENTS&lt;/span&gt; &lt;span class="n"&gt;IDevice&lt;/span&gt;
&lt;span class="k"&gt;METHOD&lt;/span&gt; &lt;span class="k"&gt;Update&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Zitat:&lt;/strong&gt;&lt;br/&gt;
VAR_GLOBAL&lt;br/&gt;
    Drive1: FB_Drive1;&lt;br/&gt;
    Drive2: FB_Drive2;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;IO1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;FB_IO1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;    
&lt;span class="n"&gt;Devices&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ARRAY&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;span class="mi"&gt;9&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="n"&gt;OF&lt;/span&gt; &lt;span class="n"&gt;IDevice&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;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;Devices&lt;/span&gt;[&lt;span class="mi"&gt;0&lt;/span&gt;]:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;Drive1&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;Devices&lt;/span&gt;[&lt;span class="mi"&gt;1&lt;/span&gt;]:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;Drive2&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;Devices&lt;/span&gt;[&lt;span class="mi"&gt;2&lt;/span&gt;]:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;IO1&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="nv"&gt;I&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="nv"&gt;TO&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;DO&lt;/span&gt;
   &lt;span class="nv"&gt;Devices&lt;/span&gt;[&lt;span class="mi"&gt;0&lt;/span&gt;].&lt;span class="nv"&gt;Update&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_FOR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>Automatic assignment of instances</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5a47a7dc9f/?limit=25#fc11" rel="alternate"/><published>2020-02-27T14:07:03.936000Z</published><updated>2020-02-27T14:07:03.936000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.comf17a653f397f08649ff7107479fdc79ffc0bbbd0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;no impossible as a declaration is not dynamic.&lt;br/&gt;
however you can compile it with a variable in the compile list.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Automatic assignment of instances</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/5a47a7dc9f/?limit=25#05f8" rel="alternate"/><published>2020-02-27T14:07:03.618000Z</published><updated>2020-02-27T14:07:03.618000Z</updated><author><name>rahulnshinde</name><uri>https://forge.codesys.com/u/rahulnshinde/</uri></author><id>https://forge.codesys.coma2ebf55558691ad72a9472a5201c9a9556e4b4ea</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;span style="color: #008000;"&gt;Device&lt;br/&gt;
|-Drive &lt;br/&gt;
|       ^---Type1&lt;br/&gt;
|       ^---Type2&lt;br/&gt;
|       ^---Type3&lt;br/&gt;
|       ^---Type4&lt;br/&gt;
|&lt;br/&gt;
|-IO&lt;br/&gt;
|     ^---Type1&lt;br/&gt;
|     ^---Type2&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Hi,&lt;br/&gt;
I have the product line as mentioned above. I have 4 &lt;strong&gt;types &lt;/strong&gt;of drive devices and 2 types of IO devices.&lt;br/&gt;
Please note that the &lt;strong&gt;number &lt;/strong&gt;of each device may vary as per my PLC configuration.&lt;/p&gt;
&lt;p&gt;I wish to declare in my program a global variable as below:&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #0000FF;"&gt;VAR&lt;br/&gt;
    device : Array &lt;span&gt;[1..MAX_NO_OF_DEVICE]&lt;/span&gt; of Device ;&lt;br/&gt;
END_VAR&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Is it possible that I can assign an individual type of device to the indexed element.&lt;/p&gt;
&lt;p&gt;For e.g. &lt;br/&gt;
device&lt;span&gt;[1]&lt;/span&gt; is (Drive &amp;gt; Type1)&lt;br/&gt;
device&lt;span&gt;[2]&lt;/span&gt; is (Drive &amp;gt; Type4)&lt;br/&gt;
device&lt;span&gt;[3]&lt;/span&gt; is (Drive &amp;gt; Type3)&lt;br/&gt;
device&lt;span&gt;[4]&lt;/span&gt; is (IO &amp;gt; Type2)&lt;br/&gt;
device&lt;span&gt;[5]&lt;/span&gt; is (IO&amp;gt; Type1)&lt;/p&gt;
&lt;p&gt;Regards,&lt;br/&gt;
Rahul.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>