03-19-2025 05:12 AM
Dear all,
I am creating a custom database schema where I need to include the execution time of each step and the sequence name where the step is called.
Concerning the execution time of each step, I have seen that it was possible to get : Logging.StepResult.TS.StartTime and Logging.StepResult.TS.TotalTime, which are represented by the seconds since the engine started. And it is possible to get the seconds since the engine started by doing : RunState.Engine.SecondsAtStartIn1970UniversalCoordinatedTime. However I need this information to be in a human readable format in my database : YYYY-MM-DD HH:MM:SS, and not in seconds. How is it possible to obtain that ?
Concerning the sequence name, I don't find any options/properties in the database plugin that answer to my need. Is there a way to obtain the sequence caller of a step through the database plugin ?
Thanks a lot in advance for your answers !
Solved! Go to Solution.
03-19-2025 09:37 AM
All the data, you can access from the DB schema has to contained in the ResultList.
If you are looking for the execution time, it's everthing you need. What you are asking for is a timestamp. So you'd need two of them to calculate the execution time, does this make sense?
For determination of the caller, you'd probably need to retrieve this information either in PreStep or PostStep and store it to the result container using the API
03-19-2025 10:25 AM
Dear Oli_Wachno,
Thanks for your prompt answer !
Concerning the caller, that's what I was thinking too.
Concerning the timestamp, it is really important for me to put it in the human readable format : YYYY-MM-DD HH:MM:SS in my database. Do you know how is it possible from the TotalTime of the step ?
03-20-2025 09:26 AM
LabVIEW or C# offer some possibilities to do that. What's your preference? 🙂
03-31-2025 01:24 AM
Dear Oli_Wachno,
Thanks a lot for your answer. Working in PreStep to add the properties "SequenceCaller" and "CurrentTime" worked for me. I used the functions Date() and Time() in TestStand to retrieve the information in the needed format.
03-31-2025 01:55 AM
What Oli posted in the image is the result property tree for a step result. The TS.TotalTime value is just the seconds that the step took to run. The TS.StartTime value is the number of seconds since the start of the application. When using a logging context in a schema the property of interest is Logging.StepResult.TS.StartTime.
The TestStand expression language is limited in date/time processing and the only functions available are Date() and Time(); and these can process a value like Logging.StepResult.TS.StartTime, BUT, there is no way to format into the type of string you desire, the functions only can return short and long formats, and individual values for what makes up the date and time.
So playing with following expression at the message in a Message Popup step you will find that it processes a static start time value of 555 seconds after start of application to obtain the components of a date/time stored into a group of properties of of Locals that I created, and then the expression generating a string into the format that you proposed:
// Get the date/time components
Date(False, Locals.Year, Locals.Month, Locals.Day, Locals.Weekday, 555, True),
Time(True, Locals.Hours, Locals.Minutes, Locals.Seconds, Locals.Milliseconds, 555, True),
// Have the expression output a formatted date/time
Str(Locals.Year) + "-" + Str(Locals.Month, "%02d") + "-" + Str(Locals.Day, "%02d") + " " + Str(Locals.Hours, "%02d") + ":" + Str(Locals.Minutes, "%02d") + ":" + Str(Locals.Seconds, "%02d") + "." + Str(Locals.Milliseconds, "%02d")
Although the above expression could technically be used as a "value to log" expression in a schema; the Locals properties would not exist to capture the values from the Date and Time functions. So you might think that you could create these variables under Station Globals on the test system. This would work if your system only performs one sequential execution at a time; access to the globals should be protected. However, this would not suffice if you are running multiple sequential executions, running a parallel or batch execution, or running using multiple threads in an execution and using on-the-fly logging, so you would need a different solution that ensures the properties exist in the context when the logging is occurring.
So a better solution would be to create the properties as needed on the logging context that is processing results and updating the database. For example you could create a name date type as shown below:
and then the "value to log" expression could create the required property as needed on the logging context, and then update the rest to use the subproperties of the type instance:
// Create the date/time data type as needed
Locals.NewSubProperty("DateTime", PropValType_NamedType, False, "MyDateTime", PropOption_DoNothingIfExists),
// Get the date/time components
Date(False, Locals.DateTime.Year, Locals.DateTime.Month, Locals.DateTime.Day, Locals.DateTime.Weekday, 555, True),
Time(True, Locals.DateTime.Hours, Locals.DateTime.Minutes, Locals.DateTime.Seconds, Locals.DateTime.Milliseconds, 555, True),
// Have the expression output a formatted date/time
Str(Locals.DateTime.Year) + "-" + Str(Locals.DateTime.Month, "%02d") + "-" + Str(Locals.DateTime.Day, "%02d") + " " + Str(Locals.DateTime.Hours, "%02d") + ":" + Str(Locals.DateTime.Minutes, "%02d") + ":" + Str(Locals.DateTime.Seconds, "%02d") + "." + Str(Locals.DateTime.Milliseconds, "%02d")
When using the above expression in a schema, you would replace the '555' with 'Logging.StepResult.TS.StartTime'. I have not tested this but it should work.