gpt4 book ai didi

datetime - Modelica 打印当前时间

转载 作者:行者123 更新时间:2023-12-02 07:17:28 25 4
gpt4 key购买 nike

如何从 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com