Hello everyone,
I am facing a challenge that I struggle to wrap my head around how it should be done the right way.
I am using a custom CSV result listener. On initialization, I define my directory and filename.
However, during my looong test, I sometime want to create new files (especially for my sweeps that I write raw results) and/or new directories under the base one.
What is the best way to change this parameters on result listener? At the moment I created a Step that is only purpose is to change filename and directory whenever it is run, by calling publishResults
Can someone propose a better way to do it? Or maybe with an example?
Thanks
Regards
CP
Hi @connospp. I want to make sure Iām understanding correctly. Your goal is for the test plan to control which file/directory the results get published to, and that file/directory can change throughout the test plan. Is that correct?
If so, is that functionality absolutely needed, or is it more of a workaround for some other issue youāre experiencing? (e.g. maybe your result file size is getting too big)
Hello @david-wsd ,
That is correct, I want to be able to change file/directory. My issue is not file size. I want to do so because, I have a file that contains generic information such as Serial number, operator, temperature and generic stuff that we want to have access to but are not really measurements.
Then I have another file which essentially is the report being delivered from production line. Those are my crucial measurements and calibration points.
And then I have separate files which are the sweeps. For example i try to calibrate my Tx āSNR per bitā, means sweeping me energy per bit until achieve the values I am looking for.
The final report will only get the calibration points but I want to save the all measurements - (graph) which would normally go to a separate file.
I also want to be able to change directories since a product is going to have 3-4 different modules inside, all these must be under same folder but different set of reports.
At the moment, as I mentioned above, I have steps that are publishing results that contain settings and I handle from there. I donāt know if that is the best way to handle and I am looking for a more experienced personās input
Thank you for you time
CP
I would probably just use some test step property to do this, so whenever you publish the results, you look through the step run and parent step runs, if any of those has a āResultFolderā parameter, you put the results in there, otherwise you just select some default folder.
Then you can make a step like the sequence step whose only purpose is to select a folder for the results of the child steps. In addition, any other step can also have a property like this.
To be able to get this information you need to keep track of the currently active step runs inside the result listener. You can do this by having a Dictionary<Guid, TestStepRun>
, adding to it in OnTestStepRunStart
and removing from it in OnTestStepRunCompleted
. You donāt need to worry about threading as all iResultListener callbacks from OpenTAP are synchronized.
1 Like
@connospp Iāve bumped into these same challenges. The ResultTable class is limited, as itās essentially a collection of name (string) and value (IConvertible) pairs. There doesnāt seem to be a built-in way to attach other metadata (e.g. a file path) to a result parameter.
This was actually the very first thing I worked on when I began OpenTAP development several years ago. I spent a couple months extending the results architecture.
In my case, I ended up formatting several pieces of metadata (e.g. units) into the result name string. All my test steps call a common function for adding metadata to the result name using a fixed format. I used a simple homemade format, but something like JSON might have been a better choice. The formatted name+metadata strings then get passed into ResultSource.Publish as the columnNames argument.
Then on the receiving end, my Result Listeners parse the name and metadata from each column name in the ResultTable, and act accordingly.
Iām not saying this is necessarily the best way to do this, itās just what I arrived at. Rolfās recommendation seems like a reasonable alternative.
Your existing solution also seems reasonable, although I might worry about race conditions. If my memory serves me correctly, the order in which a Result Listener receives results is not always guaranteed, due to the multi-threaded nature of the system. If thatās true, Iād worry there might be occasions where your result listener receives āchangeResultDirā later than expected, so some of your results might end up in the wrong directory. Just something to watch out for.
1 Like
Yes. I realised that this could been a problem.
What I did was adding a Result.wait() right after I publish the change dir or filename.
It is then executing whatever the listener is doing before continue.
I believe it is solvedclike this