blog Discussion
patch914
blog
(Discussion)
Forum for blog comments
Last updated: 2024-02-05
(no subject)
patch914
wiki
(Thread)
Last updated: 2024-02-05
Home
patch914
wiki
(WikiPage)
Project Members: patch914 (admin)
Last updated: 2024-02-05
Ticket #8: Interface to manage mappings of "ANY" datatype
IEC Snippets
snippets
(Ticket)
There is a nice article, called The wonders o ANY. While I learnt how to use this datatype, I wanted to share an example interface with you. The idea is, that I want to pass a list of variable mappings, containing informations about the variables, to a function block, that can process them. use-cases: communication protocols parsers or generators for data exchange formats (XML, JSON, YAML, ...) FUNCTION_BLOCK mappingEntry VAR // the type of the actual parameter typeclass : __SYSTEM.TYPE_CLASS ; // the pointer to the actual parameter pvalue : POINTER TO BYTE; // the size of the data, to which the pointer points diSize : DINT; END_VAR METHOD FB_Init: BOOL VAR_INPUT bInitRetains: BOOL; // TRUE: the retain variables are initialized (reset warm / reset cold) bInCopyCode: BOOL; // TRUE: the instance will be copied to the copy code afterward (online change) map : ANY; END_VAR typeClass := map.TypeClass; pValue := map.pValue; diSize := map.diSize; FUNCTION_BLOCK MyMappingFB METHOD FB_Init: BOOL VAR_INPUT bInitRetains: BOOL; // TRUE: the retain variables are initialized (reset warm / reset cold) bInCopyCode: BOOL; // TRUE: the instance will be copied to the copy code afterward (online change) mapping : POINTER TO ARRAY [1..0] OF mappingEntry; size : DWORD; END_VAR And the usage can then be: VAR_GLOBAL hugo : DWORD; egon : BYTE; balder : STRING; END_VAR PROGRAM PLC_PRG VAR mappingList : ARRAY [0..2] OF mappingEntry[ (GVL.hugo), (GVL.egon), (GVL.balder) ]; myMappingInst : MyMappingFB(ADR(mappingList), SIZEOF(mappingList) / SIZEOF(mappingEntry)); END_VAR myMappingInst(); What you get in your "MyMappingFB" is: A list of ANY variables (type: mappingEntry) Each member contains info about: Variable Type Size Pointer to the variable2024-02-05 17:09:15.091000 Ticket #8: Interface to manage mappings of "ANY" datatype IEC Snippets iec-snippets tickets snippets False /tol/iec-snippets/snippets/8/ Ticket Interface to manage mappings of "ANY" datatype False 1 2020-09-25 12:12:07.638000 8 Interface to manage mappings of "ANY" datatype Unlicensed There is a nice article, called The wonders o ANY. While I learnt how to use this datatype, I wanted to share an example interface with you. The idea is, that I want to pass a list of variable mappings, containing informations about the variables, to a function block, that can process them. use-cases: communication protocols parsers or generators for data exchange formats (XML, JSON, YAML, ...) FUNCTION_BLOCK mappingEntry VAR // the type of the actual parameter typeclass : __SYSTEM.TYPE_CLASS ; // the pointer to the actual parameter pvalue : POINTER TO BYTE; // the size of the data, to which the pointer points diSize : DINT; END_VAR METHOD FB_Init: BOOL VAR_INPUT bInitRetains: BOOL; // TRUE: the retain variables are initialized (reset warm / reset cold) bInCopyCode: BOOL; // TRUE: the instance will be copied to the copy code afterward (online change) map : ANY; END_VAR typeClass := map.TypeClass; pValue := map.pValue; diSize := map.diSize; FUNCTION_BLOCK MyMappingFB METHOD FB_Init: BOOL VAR_INPUT bInitRetains: BOOL; // TRUE: the retain variables are initialized (reset warm / reset cold) bInCopyCode: BOOL; // TRUE: the instance will be copied to the copy code afterward (online change) mapping : POINTER TO ARRAY [1..0] OF mappingEntry; size : DWORD; END_VAR And the usage can then be: VAR_GLOBAL hugo : DWORD; egon : BYTE; balder : STRING; END_VAR PROGRAM PLC_PRG VAR mappingList : ARRAY [0..2] OF mappingEntry[ (GVL.hugo), (GVL.egon), (GVL.balder) ]; myMappingInst : MyMappingFB(ADR(mappingList), SIZEOF(mappingList) / SIZEOF(mappingEntry)); END_VAR myMappingInst(); What you get in your "MyMappingFB" is: A list of ANY variables (type: mappingEntry) Each member contains info about: Variable Type Size Pointer to the variable False False 2 0 2 None ingo None
Last updated: 2024-02-05
Post by bnewman on #8 Interface to manage mappings of "ANY" datatype
IEC Snippets
snippets
(Post)
I don't understand the point of this. Isn't just better to use __SYSTEM.AnyType instead of making your own type? Also if you wanted to make it an object, shouldn't you just wrap a FB around __SYSTEM.AnyType and then have some conversion Methods? Maybe I am missing the purpose of this code. Maybe add more details on how you would use MyMappingFB
Last updated: 2024-02-05
Post by anttimurtsi on Html5 controls error
CODESYS Forge
talk
(Post)
Still got this problem havent found a fix
Last updated: 2024-02-05
(no subject)
IEC Snippets
snippets
(Thread)
Last updated: 2024-02-05
Post by eschwellinger on Html5 controls error
CODESYS Forge
talk
(Post)
here:
Last updated: 2024-02-05
Home (version 1) discussion
meldawltly
wiki
(Thread)
Home (version 1) discussion
Last updated: 2024-02-05
wiki Discussion
nima-khajehali
wiki
(Discussion)
Forum for wiki comments
Last updated: 2024-02-05
blog Discussion
nima-khajehali
blog
(Discussion)
Forum for blog comments
Last updated: 2024-02-05
(no subject)
nima-khajehali
wiki
(Thread)
Last updated: 2024-02-05
Post by spfollen on Access to the path *** is denied
CODESYS Forge
talk
(Post)
@eschwellinger That worked. Ran as Admin when starting Codesys. Great workaround. Thanks
Last updated: 2024-02-05
Home
nima-khajehali
wiki
(WikiPage)
Project Members: nima-khajehali (admin)
Last updated: 2024-02-05
wiki Discussion
wzzzz
wiki
(Discussion)
Forum for wiki comments
Last updated: 2024-02-05
blog Discussion
wzzzz
blog
(Discussion)
Forum for blog comments
Last updated: 2024-02-05
(no subject)
wzzzz
wiki
(Thread)
Last updated: 2024-02-05
Post by dhumphries on WAGO PLC 200 750-8216 Ethernet connection to Codesys 3.5
CODESYS Forge
talk
(Post)
make sure the PLC and the programming PC have IP addresses that are on the same subnet, you'll have to know the default address of the PLC or you may need to connect to it with a special cable and use a software tool to set the IP address.
Last updated: 2024-02-06
Home
wzzzz
wiki
(WikiPage)
Project Members: wzzzz (admin)
Last updated: 2024-02-05
Post by nima-khajehali on Data Transferring between 2 PLCs in a same PC
CODESYS Forge
talk
(Post)
Hi Guys, I want to simulate the data exchange between 2 soft PLCs on the same PC. We are trying to simulate the process and we could not see the desired result. What should I do to pass all data between these 2 PLC's correctly ? Please see attached
Last updated: 2024-02-05
blog Discussion
elektron785
blog
(Discussion)
Forum for blog comments
Last updated: 2024-02-06
wiki Discussion
kuuki
wiki
(Discussion)
Forum for wiki comments
Last updated: 2024-02-06
blog Discussion
kuuki
blog
(Discussion)
Forum for blog comments
Last updated: 2024-02-06
(no subject)
kuuki
wiki
(Thread)
Last updated: 2024-02-06
Home
kuuki
wiki
(WikiPage)
Project Members: kuuki (admin)
Last updated: 2024-02-06