kmcloutier
Im trying to import a library .st file I created. The Import Tool asks which POUs I would like to add to OpenPLC, I say all of them. But I am greeted with an error. Is there any help regarding what I should look at
 
[203128%2F9445541%2Fmceclip0]
Reply 0 0
thiagoralves
The import tool works better if you’ve created your .st file from the OpenPLC Editor. It only works with the v3 editor though. How was this .st file generated?
Reply 0 0
kmcloutier
I created it with the editor, but I manually added a new Function Block. Yes, I used v3.
Reply 0 0
thiagoralves
Hmm… it seems that your block crashed MatIEC. The import tool calls MatIEC to generate the C counterpart of the block. If you can share your .st with me I’ll try to take a look at it later. Worst case scenario you can still import it manually following the docs
Reply 0 0
kmcloutier
I originally created it manually successfully, but importing with the import tool is a much easier way to share the "library" that I will make.
 
Here is my .st file.  This imported correctly the first time I tried it. Then I added the ROUT_Toggle block, and it failed afterward.
 
The goal is not to produce real production ST code in this file, but rather have OpenPLC allow us to generate ST programs that I can execute, and when functions are used from this library, they will be treated as Native functions
 
TYPE
  DIN : STRUCT
    state : BOOL;
    counter : INT;
    usage : LINT;
  END_STRUCT;
  DIN_ARRAY : ARRAY [1..16] OF DIN;
END_TYPE

FUNCTION_BLOCK ROUT_Toggle
  VAR_INPUT
    IN : BOOL;
    CH : INT;
  END_VAR
  VAR_OUTPUT
    Q : BOOL;
  END_VAR

  Q := IN;
END_FUNCTION_BLOCK

FUNCTION_BLOCK ROUT_Pulse
  VAR_INPUT
    IN : BOOL;
    CH : INT;
    DUR : INT;
  END_VAR
  VAR_OUTPUT
    Q : BOOL;
  END_VAR

  Q := IN;
END_FUNCTION_BLOCK
 
Reply 0 0
kmcloutier
I added another block and ran the import tool again. I got the same error, but I can see my new blocks in the v3 IDE, but my old ones got duplicated. So this error occurs after the creation of the blocks. I do not need C code to be generated for the blocks. I am only looking to have OpenPLC output the ST program file from the designer.
 
[203128%2F9445600%2Fmceclip0]
Reply 0 0
thiagoralves
For the editor to output the .st code, it needs the C reference for the blocks. That’s how it checks if the code worked and how it runs simulations. The import tool modifies (patches) the source code of the v3 to add your library. It is a “hack”, not the right way to import libraries. When you’re ready to have your blocks in the editor you can create a PR on GitHub with the XML code (that’s what shows in the editor) and the C code (for MatIEC). Then once it is merged, your blocks will be available on the official editor source code for all users
Reply 0 0
Reply