<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to FB string and naming</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c33ce1ce45/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c33ce1ce45/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/c33ce1ce45/</id><updated>2024-10-02T04:49:46.985000Z</updated><subtitle>Recent posts to FB string and naming</subtitle><entry><title>FB string and naming</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c33ce1ce45/?limit=25#bcfe" rel="alternate"/><published>2024-10-02T04:49:46.985000Z</published><updated>2024-10-02T04:49:46.985000Z</updated><author><name>nano</name><uri>https://forge.codesys.com/u/nano/</uri></author><id>https://forge.codesys.com0a3af29da2b267e0d33b2f16f25b03976f4ee250</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;inside the fb, use the reflection-attribute and get the instancename includibg whole path.when im right, the applicationname will also reflected, if yes. you have to trim it.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_pragma_attribute_instance_path.html" rel="nofollow"&gt;https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_pragma_attribute_instance_path.html&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>FB string and naming</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c33ce1ce45/?limit=25#3831/c203" rel="alternate"/><published>2024-10-01T13:06:07.843000Z</published><updated>2024-10-01T13:06:07.843000Z</updated><author><name>andrebrandt</name><uri>https://forge.codesys.com/u/andrebrandt/</uri></author><id>https://forge.codesys.com706117f54f525560e30ef8381806f65379099fa2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you so much. This worked.&lt;/p&gt;
&lt;p&gt;Waht im trying to do here is to automatically tag each sensors, valves and so on. There is a preatty nasty tag system i working on.&lt;/p&gt;
&lt;p&gt;"_320" is not alloved. I can have a tag "+4f=320.004-RT001V"&lt;br/&gt;
In codesys I want to build the FB in folders.&lt;/p&gt;
&lt;p&gt;-4f&lt;br/&gt;
  |&lt;br/&gt;
   --320&lt;br/&gt;
        |&lt;br/&gt;
         --001&lt;br/&gt;
This is the system structure.&lt;br/&gt;
Inside here is all of the sensors and so on. But with Codesys, I cannot tag this like this.&lt;br/&gt;
So what I'm trying to do now is to Make a folder for the building "4f" and one for the system "320", and a POU _001.&lt;br/&gt;
Is there a way in init to get folder names?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>FB string and naming</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c33ce1ce45/?limit=25#3831" rel="alternate"/><published>2024-09-30T10:42:22.542000Z</published><updated>2024-09-30T10:42:22.542000Z</updated><author><name>TimvH</name><uri>https://forge.codesys.com/u/timvh/</uri></author><id>https://forge.codesys.com1188eac8f9f8ca3adace0949a7e274c1041fcd88</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I see, you want to initialize the FB.&lt;br/&gt;
To be able to initialise it like you described, you need to add the FB_Init method to your FB.&lt;br/&gt;
(right click on the FB, select add object --&amp;gt; method).&lt;br/&gt;
Then press the arrow down, to select the FB_Init (overwrite default implementation).&lt;/p&gt;
&lt;p&gt;In the VAR_INPUT section of this method, add the variable --&amp;gt; Tag : STRING;&lt;br/&gt;
Then in the code section of this method add:&lt;br/&gt;
THIS^.Tag := Tag; // copy initial value to local variable in FB&lt;/p&gt;
&lt;p&gt;Search Google if you want to know more about FB_Init.&lt;/p&gt;
&lt;p&gt;PS, reflection + instance path, is also an option if you want to get the full name of the instance (path) of the Function Block.&lt;br/&gt;
See: &lt;a href="https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_pragma_attribute_instance_path.html" rel="nofollow"&gt;https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_pragma_attribute_instance_path.html&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>FB string and naming</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c33ce1ce45/?limit=25#de2c/fa24" rel="alternate"/><published>2024-09-30T04:45:42.244000Z</published><updated>2024-09-30T04:45:42.244000Z</updated><author><name>andrebrandt</name><uri>https://forge.codesys.com/u/andrebrandt/</uri></author><id>https://forge.codesys.com89bb0e2409890fd21a9037b9236c115526f54c70</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Tim.&lt;br/&gt;
Not quite correct.&lt;br/&gt;
What i'd like, is when you place the FB in prog, i choose a block NTC10k, and name this RT401. &lt;br/&gt;
What i'm trying to do, is to get the name RT401 automaticly into the FB, so i can put this into the string i pass in a struct.&lt;/p&gt;
&lt;p&gt;So in var in POU,  i saw this a place i could do this, RT401: NTC10k(Tag:='RT401'), but i can't get this to work.&lt;/p&gt;
&lt;p&gt;I shurly must have had something like this in FB:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;FUNCTION_BLOCK NTC10k String TAG&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;But it's here where I'm stuck...&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>FB string and naming</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c33ce1ce45/?limit=25#de2c" rel="alternate"/><published>2024-09-28T12:04:46.030000Z</published><updated>2024-09-28T12:04:46.030000Z</updated><author><name>TimvH</name><uri>https://forge.codesys.com/u/timvh/</uri></author><id>https://forge.codesys.com7c9543c07a61e9ed4df524569af67802bd0debef</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Really not clear what you are trying to do, but isn't a Struct enough?&lt;br/&gt;
So add an object of the type DUT to the Application.&lt;br/&gt;
Then create a structure&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kr"&gt;TYPE&lt;/span&gt; &lt;span class="n"&gt;ST_Sensor&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;STRUCT&lt;/span&gt;
    &lt;span class="n"&gt;sName&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;STRING&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;uiNumber&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;UINT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_STRUCT&lt;/span&gt;
&lt;span class="n"&gt;END_TYPE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then in you application add an instance of this Structure&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;stSensor1&lt;/span&gt;&lt;span class="w"&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;ST_Sensor&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sName&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'my sensor'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;uiNumber&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;or use it like this&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;stSensor1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;sName&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="nv"&gt;my&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;sensor&lt;/span&gt;&lt;span class="o"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</summary></entry><entry><title>FB string and naming</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c33ce1ce45/?limit=25#b780" rel="alternate"/><published>2024-09-26T09:35:58.187000Z</published><updated>2024-09-26T09:35:58.187000Z</updated><author><name>andrebrandt</name><uri>https://forge.codesys.com/u/andrebrandt/</uri></author><id>https://forge.codesys.com2353dca766ffa4314c334e5bb91ab75b001b75fa</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi all.&lt;br/&gt;
I have a FB written in ST.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nt"&gt;FUNCTION_BLOCK&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;NTC10k&lt;/span&gt;
&lt;span class="nt"&gt;VAR_INPUT&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;Syst&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;In&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;REAL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="nt"&gt;VAR_OUTPUT&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;Out&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;REAL&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;OTag&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;Out_St&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;Struct_NTC10K&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;

&lt;span class="nt"&gt;VAR&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;Tag&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;InstanceName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;STRING&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;Structure&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;Struct_NTC10K&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;What i'm trying to do, is to pass data to structure. In structure i want to add a tag with systemnumber and sensorname.&lt;br/&gt;
'320.001-RT401'&lt;/p&gt;
&lt;p&gt;In pou i use this RT401: NTC10k;, and tried this RT401: NTC10k(Tag:='RT401');&lt;/p&gt;
&lt;p&gt;Anyone done this?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>