I am writing a HLA and I’d like to emit some statistics via to terminal (via print() calls) when having processed the final frame. Statistics are built up while processing frame after frame and I’d only like to emit them once, when done. Otherwise processing might slow down significantly and the log is likely to be flooded very much.
I don’t think that there’s a way of detecting the final frame in decode() but I may be wrong.
Is there some other method I am not aware of which I could use as a hook for that functionality?
Of course, this would only work for offline decoding and not decoding while recording - but that’d obviously be fine for my use case.
Sure, I could work around this by adding some post-processing on data that’s exported, but it’d be nice to have it all together in a single place.
@maehw Thanks for writing in! After a quick review, I believe you’re right in that we don’t expose any sort of flags that would help indicate that all data has been processed by an HLA. I’ll double check this to be sure however.
In the meantime, can you let me know what kind of statistics you were interested in printing out? Perhaps there may be some workarounds we can suggest.
At the moment, I am into the analysis of an SPI protocol. The first MOSI byte of a transaction is always a command byte followed by a varying number of payload bytes (MOSI or MISO). I’ve implemented a HLA for it. However, I’d like to see a distribution – what command occurs how often, and how often with what payload value. You could think of it as wanting to plot various histograms.
Next step would be a more detailed analysis: what command (probably with what payload) is usually followed by what other command (probably with what payload) – thinking about modeling a Markov chain here… probably visualized later as a state transition graph.
There is no direct way to do this, but under just the right circumstances you can get this to work by adding a def __del__(self): method to your HLA, for example:
def __del__(self):
print("DEL")
This only runs when the instance of your HLA is getting destroyed, which is not when it’s done processing data. HLA instances are destroyed when:
You close the session tab. (not helpful, because you can’t see the results)
When you right-click your HLA instance and select “Reload Source Files”.
When you change any setting your your HLA, after you’ve run it once.
It’s not great, but you can print what you need there, and when you want to produce results, just right-click the analyzer and reload it. This will re-run your analyzer but you will still get the output from the last run.