如何将当前日期和/或时间从 Modelica 打印到文件(例如日志文件或 csv 文件)?我需要外部代码吗?我在 Modelica 标准库中找不到任何示例代码。
最佳答案
https://build.openmodelica.org/Documentation/Modelica.Utilities.Streams.print.html
您需要将此添加到您的方程或算法部分:
.Modelica.Utilities.Streams.print(String(time));
对于本地系统时间使用:
https://build.openmodelica.org/Documentation/Modelica.Utilities.System.getTime.html
model GetTime
Integer ms;
Integer sec;
Integer min;
Integer hour;
Integer mday;
Integer mon;
Integer year;
algorithm
(ms, sec, min, hour, mday, mon, year) := .Modelica.Utilities.System.getTime();
.Modelica.Utilities.Streams.print("ms:" + String(ms) + "\n");
.Modelica.Utilities.Streams.print("sec:" + String(sec) + "\n");
.Modelica.Utilities.Streams.print("min:" + String(min) + "\n");
.Modelica.Utilities.Streams.print("hour:" + String(hour) + "\n");
.Modelica.Utilities.Streams.print("mday:" + String(mday) + "\n");
.Modelica.Utilities.Streams.print("mon:" + String(mon) + "\n");
.Modelica.Utilities.Streams.print("year:" + String(year) + "\n");
end GetTime;
关于datetime - Modelica 打印当前时间,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58320730/