Search talk: codesys container

 
<< < 1 .. 83 84 85 86 87 .. 894 > >> (Page 85 of 894)

CODESYS Raspberry Pi – How to use CODESYS tags with external script? CODESYS Forge talk (Thread)
CODESYS Raspberry Pi – How to use CODESYS tags with external script?
Last updated: 2017-10-04

Difference between CODESYS Control RTE x64 and CODESYS Control RTE V3 x64 CODESYS Forge talk (Thread)
Difference between CODESYS Control RTE x64 and CODESYS Control RTE V3 x64
Last updated: 2021-05-10

Migrate from Codesys WIN 32 bit to Codesys RTE 64 bit CODESYS Forge talk (Thread)
Migrate from Codesys WIN 32 bit to Codesys RTE 64 bit
Last updated: 2015-12-15

how to convert library from CodeSys 2.3 to CodeSys 3.x ? CODESYS Forge talk (Thread)
how to convert library from CodeSys 2.3 to CodeSys 3.x ?
Last updated: 2020-01-21

Is it possible to simulate the codesys visualizations without project file/codesys? CODESYS Forge talk (Thread)
Is it possible to simulate the codesys visualizations without project file/codesys?
Last updated: 2018-10-10

Identifier ioConfigConnector not defined. CODESYS IDE V3.5SP6 corruption after installation of CODESYS IDE V3.5SP10 CODESYS Forge talk (Thread)
Identifier ioConfigConnector not defined. CODESYS IDE V3.5SP6 corruption after installation of CODESYS IDE V3.5SP10
Last updated: 2017-10-20

[HELP] Connecting Codesys v2.3 program with a Codesys HMI SL project in V3 CODESYS Forge talk (Thread)
[HELP] Connecting Codesys v2.3 program with a Codesys HMI SL project in V3
Last updated: 2021-10-18

Codesys sales and support. Is it true that Codesys wants to get more customers? CODESYS Forge talk (Thread)
Codesys sales and support. Is it true that Codesys wants to get more customers?
Last updated: 2023-07-03

Post by struccc on Inheritence of struct, CODESYS Forge talk (Post)
Strangely reminds me to my struggles... Want to do something "Elegant", reusable, universal, practical... In CODESYS??? πŸ™ƒ First of all, before you get too deep into this: If you could find a way, to make a "universal" log entry object, containing the variable length data itself, you wouldn't be able to store them in an array, or access them like an array, or pass them by value as a type. (please correct me, if I'm wrong, incorrect, or not precise). Because... Basically you can't declare a type with variable memory footprint. This is a very deeply embedded characteristic of CODESYS, and all IEC 61131-3 systems, and it has many reasons behind. And yes, it is a very common trap / mistake, to forget about. So, with a log entry - I guess - it's pretty much the purpose: store data and metadata together, and then handle it in a uniform way. There are ways to handle this, really depends on what is the purpose. For example: 1. Entries with fixed length (Maybe it is not as evil as it looks for the first time. Depends on the situation, but definitely the fastest and easiest code) You can have your base object, with an internal, fixed length string or byte array variable. I would go with a string, and call it _Data.; And then you can make properties, like As_Bool, As_Int, As_Real... In the 'set' accessors, you can do like: pReal := ADR(_Data); // POINTER TO REAL As_Real := pReal^; In the 'get' accessors, evidently: pReal := ADR(_Data); // POINTER TO REAL pReal^ := AS_Real; Or, can use ANY type, if you are not obsessed with variable / property like access: 2. Fixed length, but nicer First, some disadvantage to any values: - You can only assign values with write access. No literals, constants, etc... - Can only be used as input variable of function or function_block - Therefore, stg you could reach: LogEntry.Initialize (stVariable|rVariable|iVariable|xVariable); Just a quick example (it's funny to play with ANY): Be careful it was not tested. I'm sure can be done better, please feel free to comment FUNCTION_BLOCK FB_LogEntry VAR_INPUT MsgClass : UDINT; // Like DEBUG, WARN, ERR... MsgCode : UDINT; // Like Errors.ERR_FAILED MsgTS : DT; // The timestamp END_VAR VAR _Data : STRING(80); // Our data container... _Descr : __SYSTEM.AnyType; // A standard descriptor for our data, containing TYPE_CLASS, address and size END_VAR METHOD SET_Value : BOOL VAR_INPUT anyValue : ANY; END_VAR VAR I : DINT; diSize : DINT; pStr : POINTER TO STRING; END_VAR // Check what did we receive in anyValue. diSize := anyValue.diSize; // We use constant __SYSTEM.TYPE_CLASS to identify the received data type CASE anyValue.TypeClass OF // Maybe we don't want to store references, pointers... and who knows what else... __SYSTEM.TYPE_CLASS.TYPE_REFERENCE, __SYSTEM.TYPE_CLASS.TYPE_POINTER : SET_Value := FALSE; // For the planned types we will be just fine. TYPE_CLASS.TYPE_BOOL, TYPE_CLASS.TYPE_INT, TYPE_CLASS.TYPE_REAL : SET_Value := TRUE; // Optionally string can be handled separately, maybe we have received STRING(255), but practically it is shorter than 80 bytes... TYPE_CLASS.TYPE_STRING : pStr := anyValue.pValue; diSize := MIN(anyValue.diSize, LEN(pStr^) + 1); // Get the actual size, and rewrite the received structure member diSize := MIN(SIZEOF(_Data), diSize); // Can chop down the received string to our length... SET_Value := TRUE; // Maybe want to play a little bit more here, to narrow down or convert datatypes, etc... // Or just reject any other datatype ELSE SET_Value := FALSE; RETURN; END_CASE // Fail, if the received value is still larger than our container... IF diSize > SIZEOF(_Data) THEN SET_Value := FALSE; END_IF // Here we should be ok, just set up the _DataType structure, and copy store the data IF SET_Value THEN THIS^._Descr.TypeClass := anyValue.TypeClass; // The typeclass is already filtered THIS^._Descr.diSize := diSize; // Set the (adjusted) size THIS^._Descr.pValue := ADR(_Data); // This will not change, just to be sure {IF defined (pou:SysMem.SysMemCpy)} SysMem.SysMemCpy(_DataType.pValue, anyValue.pValue, TO_UDINT(anyValue.diSize)); {ELSE} // An ugly replacement MemCpy FOR I:=0 TO diSize - 1 DO _Descr.pValue[I] := anyValue.pValue[i]; END_FOR {END_IF} // Otherwise, in case of failure maybe better set an empty value (overwrite the former data descriptor) ELSE THIS^._Descr.TypeClass := TYPE_CLASS.TYPE_NONE; THIS^._Descr.pValue := ADR(_Data); THIS^._Descr.diSize := 0; END_IF METHOD GET_Value : BOOL VAR_INPUT anyValue : ANY; END_VAR VAR I : DINT; END_VAR // We just have to serve the data, using the __System.AnyType structure received // Roughly we can say: IF anyValue.TypeClass = _Descr.TypeClass AND anyValue.pValue <> 0 // This should not be possible, already taken care of by Codesys (?) THEN {IF defined (pou:SysMem.SysMemCpy)} SysMem.SysMemCpy(anyValue.pValue, _DataType.pValue, TO_UDINT(MIN(anyValue.diSize, _Descr.diSize))); {ELSE} // An ugly replacement MemCpy FOR I:=0 TO MIN(anyValue.diSize -1, _Descr.diSize - 1) DO anyValue.pValue[I] := _Descr.pValue[I]; END_FOR {END_IF} // Just to make sure, that our string is terminated... IF anyValue.TypeClass = TYPE_CLASS.TYPE_STRING THEN anyValue.pValue[anyValue.diSize -1] := 0; END_IF GET_Value := TRUE; RETURN; END_IF // ... But can play more CASE anyValue.TypeClass OF TYPE_CLASS.TYPE_WSTRING : ; // Could do conversion TYPE_CLASS.TYPE_XSTRING : ; // Wow, I have to figure this out TYPE_CLASS.TYPE_PARAMS : ; // BTW, what is this, how to use? TYPE_CLASS.TYPE_ANYNUM : ; // ... END_CASE Be careful it was not tested. I'm sure can be done better, please feel free to comment 3. If you really want to do entries with variable size In a standard environment, it would be similar to the previous, except you dont have the container variable _Data, just use a pointer, practically _Descr.pValue At Initialize (SET_Value), you have to allocate the memory, would be easy with SysMem.SysMemAlloc - nowadays with SysMem.SysMemAllocData -, and you make sure to release it after use with SysMem.SysMemFreeData... SysMemAlloc was already hidden. The problem with this, that sooner or later your application will totally fragment the dynamic memory, and fail... So should look for some form of dynMaybe MemUtils.MemoryManager (I am not sure what is the status and the future of it). 4. You will end up by a LogEntry Factory ... 5. You could still have a look at this IEC Snippets BTW, Standard Codesys Logger is not a bad choice either. If you are really interested, I share some more code / library.
Last updated: 2025-03-09

Problems connecting to Codesys 4.9.0.0 runtime on my Wago PFC200 CODESYS Forge talk (Thread)
Problems connecting to Codesys 4.9.0.0 runtime on my Wago PFC200
Last updated: 2023-08-26

CODESYS Automation Server Connector for 3.5 SP11 CODESYS Forge talk (Thread)
CODESYS Automation Server Connector for 3.5 SP11
Last updated: 2023-08-30

Introductory short video series on PLC programming (CODESYS) CODESYS Forge talk (Thread)
Introductory short video series on PLC programming (CODESYS)
Last updated: 2023-08-28

Network Variable List in Codesys 3.5 on CAN CODESYS Forge talk (Thread)
Network Variable List in Codesys 3.5 on CAN
Last updated: 2023-08-05

How to read structure in CodeSys using pythong script? CODESYS Forge talk (Thread)
How to read structure in CodeSys using pythong script?
Last updated: 2017-10-09

Barcode-Reader O2I (TCP/IP) mit Codesys auslesen CODESYS Forge talk (Thread)
Barcode-Reader O2I (TCP/IP) mit Codesys auslesen
Last updated: 2018-04-01

Compiling CoDeSys project using the command line interface CODESYS Forge talk (Thread)
Compiling CoDeSys project using the command line interface
Last updated: 2021-01-27

CodeSys v3 Vendors/PLCs with C-Integration CODESYS Forge talk (Thread)
CodeSys v3 Vendors/PLCs with C-Integration
Last updated: 2018-03-05

General question about Codesys and control RTE CODESYS Forge talk (Thread)
General question about Codesys and control RTE
Last updated: 2020-01-27

Using ScriptEngine in C# for Creating Codesys Project CODESYS Forge talk (Thread)
Using ScriptEngine in C# for Creating Codesys Project
Last updated: 2019-06-24

Newbie questions regarding CodeSys V3 Modbus RTU CODESYS Forge talk (Thread)
Newbie questions regarding CodeSys V3 Modbus RTU
Last updated: 2016-06-09

Codesys Wago Going Online from Different Computer CODESYS Forge talk (Thread)
Codesys Wago Going Online from Different Computer
Last updated: 2022-12-15

Adding a CANBUS device on Codesys Control Linux SL CODESYS Forge talk (Thread)
Adding a CANBUS device on Codesys Control Linux SL
Last updated: 2022-05-25

CODESYS Control Not Showing Up in Devices CODESYS Forge talk (Thread)
CODESYS Control Not Showing Up in Devices
Last updated: 2023-01-02

Datenaustausch zwischen mehreren Codesys-SPS in Echtzeit CODESYS Forge talk (Thread)
Datenaustausch zwischen mehreren Codesys-SPS in Echtzeit
Last updated: 2022-11-18

Codesys 2.3 Grâßere Texte, Strings in Visu darstellen CODESYS Forge talk (Thread)
Codesys 2.3 Grâßere Texte, Strings in Visu darstellen
Last updated: 2010-12-10

<< < 1 .. 83 84 85 86 87 .. 894 > >> (Page 85 of 894)

Showing results of 22341

Sort by relevance or date