🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

PyBlockFunction Help in Python BLock

User: "Thinh"
New Altair Community Member
Updated by Thinh

Hello Guys,

 

While checking the PyCustomBlock, the skeleton python code  has this section:

 import hwx.activate.apis import numpy def PyBlockFunction(block,flag): 	apis = hwx.activate.apis 	nevprt=apis.vssGetEventCode(block) 	if flag == apis.vssBlockInitializeFlag(): 		pass 	elif flag == apis.vssBlockReinitializeFlag(): 		pass 	elif flag == apis.vssBlockTerminateFlag(): 		pass 	elif flag == apis.vssBlockOutputUpdateFlag(): 		#apis.vssSetOutputData(block,1,y1,apis.vssGetOutputDataType(block,1)) 		pass

I try to find the description and parameter meanings of PyBlockFunction, vssBlockOutputUpdateFlag, vssBlockInitializeFlag but there no info inside the Help

Please share some info if you know.

 

Thanks,

Thinh

 

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "João Marabisa"
    Altair Employee
    Updated by João Marabisa

    Hi Thinh,

     

    If you take a look at the C, Oml and Python Custom Blocks, you will se that they have a similar structure, telling about these flags and logics. 

     

    Basically the flag is the way that the simulator tells the block what operation needs to performe (usually these jobs consists in updating some of the fiels of the block structure).

     

    Regarding to Initialization, generally speaking it is not used (once the states are usually initializated during evaluation), unless you have to read an write data from files on this code, or even if you require dinamically allocated memory. With respect to Reinitialize, you should think that right after the initialization, the inputs to the block may change from one call to the next, and this state it imposes constraints at the initial time, if successful, these call lead to the convergence of the states and inputs. In the Terminate, the simulator calls each block's computational function, this is useful to flush buffered data  for closing files that have been opened by blocks ate the beginning or during the simulation. Finally, the OutputData requests the output of the block! 

     

    As you can see, this explatation is more based on 'internal' computational functions, what I'd like to tell you that, depending on your model (mostly of them) you can simulate just using OutputData. I'm attaching an example model that you can see it.

     

    Hope this helps.

     

     

     

    Unable to find an attachment - read this blog