Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

FBF.FactoryBase PROPERTY prvInstCount

jtebokkel
2020-06-10
2021-11-19
  • jtebokkel

    jtebokkel - 2020-06-10
    PROPERTY prvInstCount : CAA.COUNT (* ctInst *)
    
    // prvInstCount.Get body
    (* Please choose a proper value for prvInstCount *)
    prvInstCount := 10;
    

    I can't seem to find any documentation on what a "proper" value is for this property or even what specifically it is supposed to be. By the name I would think it to be the Instance Count, but then how does one keep track of that? a VAR_STAT and FB_Init to increment it?

    leaving this value as 10 seems to work, but that just confuses me more.

     
  • jtebokkel

    jtebokkel - 2021-11-19

    I may have gotten a better understanding with some new comments provided in the 3.5.17 release.

    FBF.FactoryBase Properties

    (* Is called by ``prvMemAlloc``, if ``prvPoolAdr`` returns ``CAA.gc_pNULL``*)
    PROPERTY prvInstCount : FBF.CAA.COUNT
    
    (* Is called by ``prvMemAlloc``, if ``prvPoolAdr`` returns not ``CAA.gc_pNULL``.
     it should be implementet like :code:`prvPoolSize := sizeof(abyPoolMemory)`*)
     PROPERTY prvInstPoolSize : FBF.CAA.SIZE
    
    (* Is called by ``prvMemAlloc``, to determine the Methode of allocation. (``MBM.PoolCreateH`` or ``MBM.PoolCreateP``)
     If the return value is ``CAA.gc_pNULL`` then ``MBM.PoolCreateH`` is used.
     If the return value is not equal ``CAA.gc_pNULL`` this value is used as a basis for ``MBM.PoolCreateP``*)
    PROPERTY prvInstPoolAdr : FBF.CAA.PVOID
    

    What seems to happen

    As doc comment on prvInstPoolAdr indicates what this property returns determines if we are using the heap or a pool. I'm presuming that if we are in heap mode that prvInstCount is used for the value of ctNumBlocks (the first argument of PoolCreateH) This value then would signify the initial number of instances that can be created on the heap before the heap pool needs to be extended.

    I don't know what happens when you go down the PoolCreateP route other than once your initial pool is used up, more memory is allocated some how. I'd guess that it comes from the heap.

    Hopefully this helps someone else down the road.

    If the codesys team is listening...

    Please increase the quality of the core library documentation. It would make working in this environment so much more pleasant. So many times I'm having to dig through layers and layers to find the bit that clears it up or just end up not able to find what I need.

     

Log in to post a comment.