Clock
Hi,experts
    I really want to have a better understanding of the self-define FunctionBlock. Could you just tell what the FunctionBlock is?  What is the significance of  FunctionBlock? 
Reply 0 0
thiagoralves
A functionBlock is like a function that can retain the contents of its local variables. It is similar to classes and objects in object-oriented programming languages. Check this for more info: http://ua.automation.com/resources-tools/application-stories/programmable-logic-controller-plc/iec-61131-3-functions-and-function-blocks-what-is-the-difference
Reply 0 0
Clock
dear thiagoralves, well, my job is designing the soft-PLC. And my company's Plc-Editor do not have the function of "function Block". Recently one of our customers have a demand on it, and of cause I have referred to the software openplc Editor in your website. The plcEditor of you do have functionBlock, but the function Block cannot be separated from the Current Project(A.xml file), right? I mean, when we design a function Block, it can not be
use by the another Project(B.xml file). So the function block doesn't seem to be a function that can reuse in object-oriented programming languages, though it can retain the contents of its local variables.So, would you like to give me some suggestions on separating the function Block from it's project(like add two buttons "Import function Block"  and  "export function Block"), I am really appreciate it.
Reply 0 0
thiagoralves
You can reuse a function or functionBlock inside the same project only. There isn't a straightforward way to "import" a function or functionBlock on PLCOpen Editor. Perhaps the easiest way to reuse a function or functionBlock in another project is to just copy/paste its contents among different projects.
Reply 0 0
skv
You can reuse a function or functionBlock inside the same project only. There isn't a straightforward way to "import" a function or functionBlock on PLCOpen Editor. Perhaps the easiest way to reuse a function or functionBlock in another project is to just copy/paste its contents among different projects.


Yes, the easiest way would be copy-paste. PlcOpenEditor/Beremiz use PLCOpen XML format. If you copy Function block and paste into any text editor, PLCOpen xml text will be pasted.

<pou name="functionBlock0" pouType="functionBlock">
  <interface>
    <inputVars>
      <variable name="In1">
        <type>
          <BOOL/>
        </type>
      </variable>
      <variable name="In2">
        <type>
          <BOOL/>
        </type>
      </variable>
    </inputVars>
    <outputVars>
      <variable name="Out">
        <type>
          <BOOL/>
        </type>
      </variable>
    </outputVars>
  </interface>
  <body>
    <ST>
      <xhtml😋><![CDATA[Out := In1;]]></xhtml😋>
    </ST>
  </body>
</pou>



If you want create your own library with blocks that will be always available in your editor, then you can read this post.
Later I'll write article about that on Beremiz wiki
Reply 0 0
Reply