Importing test parameters from a text file
Hello Dewesoft team :) !
I would like to import test parameter to use as variables in the math module from an external text file.
Is it possible to load these parameters using the scheduler ? I have successfully passed parameters to an external program using the scheduler which is fantastic,
I am hoping there is a way to do something similar but opposite
Cheers
Jeremy
Dear Jeremy,
thank you for reaching out to us. DewesoftX supports only five command prompt commands:
1) /S PathSetupFile
2) /P PathProjectFile
3) /T PathSequenceFile
4) /CHANNELSETUP … move to Ch. setup tab
5) /MEASURE … set all channels to used and start measurement
For reading the parameters from a text file you could use C++ Script to read the text file and output the values in a channel.
DewesoftX has global variables which are stored in the setup file (xml) and you can change this xml to reflect the values in a text file.
Would you please be so kind and explain the use case in more detail - is the text file generated with a program? Than you could use for example a python script to edit xml setup file with the correct values of variables and than start DewesoftX.
Kind regards.
Hi Gregor,
Thankyou very much for your reply! I hope you had a good weekend!
Thanks for explaining those commands, they are the only commands that DewesoftX takes on start up if I was to launch it from command line is that correct?
To explain my application, we will be conducting testing that requires calibration of the equipment. I would like to have a separate project file for this that is just for running a calibration test, I will be automating it using the sequencer. A test will be performed then the sequencer will export the channel data to a text file and then the sequencer will load my custom python program using File Manager block. The program will open the test data, perform an analysis and then update a text file with new variables. Once the python program has finished, I then want the sequencer to load the new variables from the text file to be used within DewesoftX (it sounds like C++ script is my only option for this is that right, for post-processing after the test has run ? ). I with these calibration variables imported I would then like to post-process the original raw data with the imported variables and create a new channel that I can plot against the original data in the same file for analysis.
Under normal testing ( not calibration ) circumstances, the text file with the variables would be imported at the beginning of the testing session before the data has been captured and used to calculate a new channel with the math module .
I really would like to keep the calibration and import process all driven from the sequencer , so that is all automated.
Thankyou for your help, and I look forward to hearing your reply
Cheers
Jeremy
Dear Jeremy,
thank you for the additional information about your measurement.
Thanks for explaining those commands, they are the only commands that DewesoftX takes on start up if I was to launch it from command line is that correct?
Yes.
Since you are using Python through Sequencer you can also use python to modify a setup file (you need to save the setup file as xml, not dxs) or project file (.dxp file in System folder) i.e. you can change the Global variables in the project file and load Project file before a measurement is started. Or you can use User Inputs and change the default value.
Kind regards.
Hi Gregor,
Thankyou for the reply. I can only change the global project variables while DewesoftX is not running , is that right ?
I would really like to read the parameters from a text file and use a C++ Script to read the text file and output the values in a channel, as you mentioned while DewesoftX is still running and in the sequence. Can you explain how I could achieve this with C++ ?
Thankyou very much
Cheers
Jeremy
Dear Jeremy,
you will need C++ license and in C++ Script you simply write code to open a data file and read the values. It depends when you would like to read the values, at start of measurement, you need to write the code in void Module::start() function.
When I performed a test I noticed that the values do not get updated so I opened a bug and will keep you updated.
Kind regards.
Dear Jeremy,
in the attachment I am sending an example setup file and C++ Script where three values are read from the txt file and C++ script outputs those three values in three channels.
Kind regards.
Attached files:
Hi Gregor,
Thankyou very much for your reply and the example ! That's fantastic
With the C++ scripts can they be run in Analyse mode as well as in measure mode ?
With the bug you found was that related to just using the script in start() phase or in general ?
If I wanted to import data to a async channel using C++ is this achieved in a similar way ? or is it better to use an external python script for this triggered by the scheduler ?
Cheers
Jeremy
Dear Jeremy,
the C++ Scripts can be run in Analyze mode - jus set it to offline and the C++ Script will be recalculated over the whole file.
The bug was actually a bug in my code as I did not clear the values (values.clear()) before reading the txt file.
If I wanted to import data to a async channel using C++ is this achieved in a similar way ?
Yes this can be achieved in a similar way. You will need to change the output to async, define the expected async rate and write the data to it accordingly. For more information on calculation sample rate please refer to calculate sample rate timebase .
Kind regards.
Thankyou very much Gregor for all your help , that is great to know !
Just to be super clear so I understand , can I put the system in analyse mode from the sequencer and then the script will run , is there a way for the script to know if it is running in measure or analyse ?
Thankyou again
Cheers
Jeremy
Dear Jeremy,
the script will not run automatically when opening a file - the C++ Script will need to be recalculated. You will need to use apply action, with another data file where the C++ Script is set to offline, and than replace all formulas with apply action. This should trigger recalculation of C++ Script on reopening the data file.
Is there a way for the script to know if it is running in measure or analyse?
By default no. You would need to have a variable to track this and than read this variable in C++ Script.
Kind regards.