From 411215d72751653314d35651e6f3b764fcb8679d Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Tue, 2 Apr 2024 14:51:49 -0700 Subject: [PATCH] Added example with Windows line endings --- IBPSA/Resources/Data/scheduleWindows.txt | 7 +++ ...ation_WeeklyScheduleWindowsLineEndings.txt | 12 ++++ .../WeeklyScheduleWindowsLineEndings.mos | 2 + .../WeeklyScheduleWindowsLineEndings.mo | 55 +++++++++++++++++++ .../Utilities/IO/Files/Validation/package.mo | 12 ++++ .../IO/Files/Validation/package.order | 1 + IBPSA/Utilities/IO/Files/package.order | 1 + 7 files changed, 90 insertions(+) create mode 100644 IBPSA/Resources/Data/scheduleWindows.txt create mode 100644 IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Utilities_IO_Files_Validation_WeeklyScheduleWindowsLineEndings.txt create mode 100644 IBPSA/Resources/Scripts/Dymola/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mos create mode 100644 IBPSA/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mo create mode 100644 IBPSA/Utilities/IO/Files/Validation/package.mo create mode 100644 IBPSA/Utilities/IO/Files/Validation/package.order diff --git a/IBPSA/Resources/Data/scheduleWindows.txt b/IBPSA/Resources/Data/scheduleWindows.txt new file mode 100644 index 0000000000..beabafdb0c --- /dev/null +++ b/IBPSA/Resources/Data/scheduleWindows.txt @@ -0,0 +1,7 @@ +# Comments start with a # +# The user is responsible for making sure that the header dimensions are correct +double tab1(3,5) # Comments can be added at the end of a line for adding local documentation +mon:0:0:10 - 3 1 - +# Comments can be added in the table too +tue,thu:20:30:59 123 - 45 - +wed 12 1 4 - diff --git a/IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Utilities_IO_Files_Validation_WeeklyScheduleWindowsLineEndings.txt b/IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Utilities_IO_Files_Validation_WeeklyScheduleWindowsLineEndings.txt new file mode 100644 index 0000000000..cb6e638234 --- /dev/null +++ b/IBPSA/Resources/ReferenceResults/Dymola/IBPSA_Utilities_IO_Files_Validation_WeeklyScheduleWindowsLineEndings.txt @@ -0,0 +1,12 @@ +last-generated=2024-04-02 +statistics-simulation= +{ + "linear": " ", + "nonlinear": " ", + "numerical Jacobians": "0" +} +time=[-1e+04, 1e+06] +weeSchLin.y[1]=[1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02] +weeSchLin.y[2]=[1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00] +weeSchLin.y[3]=[4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 4.5e+01, 4.5e+01, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01] +weeSchLin.y[4]=[0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00] diff --git a/IBPSA/Resources/Scripts/Dymola/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mos b/IBPSA/Resources/Scripts/Dymola/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mos new file mode 100644 index 0000000000..d90d3a8c46 --- /dev/null +++ b/IBPSA/Resources/Scripts/Dymola/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mos @@ -0,0 +1,2 @@ +simulateModel("IBPSA.Utilities.IO.Files.Validation.WeeklyScheduleWindowsLineEndings", startTime=-10000, stopTime=1000000, tolerance=1e-6, method="dassl", resultFile="WeeklyScheduleWindowsLineEndings"); +createPlot(id=1, position={15, 15, 592, 364}, y={"weeSchLin.y[1]", "weeSchLin.y[2]", "weeSchLin.y[3]", "weeSchLin.y[4]"}, range={-100000.0, 1000000.0, -20.0, 140.0}, grid=true, colors={{28,108,200}, {238,46,47}, {0,140,72}, {217,67,180}}, timeUnit="s"); diff --git a/IBPSA/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mo b/IBPSA/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mo new file mode 100644 index 0000000000..30ab9564ad --- /dev/null +++ b/IBPSA/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mo @@ -0,0 +1,55 @@ +within IBPSA.Utilities.IO.Files.Validation; +model WeeklyScheduleWindowsLineEndings "Weekly schedule example" + extends Modelica.Icons.Example; + parameter String data = "double tab1(3,5) #test: +mon:0:0:10 - 3 1 - +tue,thu:20:30:59 123 - 45 - +wed 12 1 4 -" "Contents of schedule.txt"; + IBPSA.Utilities.IO.Files.WeeklySchedule weeSchLin( + columns={2,3,4,5}, + tableOnFile=true, + fileName=Modelica.Utilities.Files.loadResource("modelica://IBPSA/Resources/Data/schedule.txt"), + t_offset=1e6) "Weekly schedule example using file data source" + annotation (Placement(transformation(extent={{-10,20},{10,40}}))); + + IBPSA.Utilities.IO.Files.WeeklySchedule weeSchWin( + columns={2,3,4,5}, + tableOnFile=true, + fileName=Modelica.Utilities.Files.loadResource("modelica://IBPSA/Resources/Data/scheduleWindows.txt"), + t_offset=1e6) "Weekly schedule example using parameter data source" + annotation (Placement(transformation(extent={{-10,-32},{10,-12}}))); + Diagnostics.AssertEquality assEqu[4]( + each startTime=-10000, + each threShold=Modelica.Constants.small) + "Trigger an assertion if the outputs differ" + annotation (Placement(transformation(extent={{40,-10},{60,10}}))); +equation + connect(weeSchLin.y, assEqu.u1) + annotation (Line(points={{11,30},{24,30},{24,6},{38,6}}, color={0,0,127})); + connect(weeSchWin.y, assEqu.u2) annotation (Line(points={{11,-22},{24,-22},{24, + -6},{38,-6}}, color={0,0,127})); + annotation ( + Documentation(info=" +

+Example for a weekly schedule that reads the schedule data from a file. +There are two file readers, one reading a file with Windows line endings and the other with Linux line endings. +

+", +revisions=" + +"), + experiment( + StartTime=-10000, + StopTime=1000000, + Tolerance=1e-06), + __Dymola_Commands(file= + "modelica://IBPSA/Resources/Scripts/Dymola/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mos" + "Simulate and plot")); +end WeeklyScheduleWindowsLineEndings; diff --git a/IBPSA/Utilities/IO/Files/Validation/package.mo b/IBPSA/Utilities/IO/Files/Validation/package.mo new file mode 100644 index 0000000000..4b75a38058 --- /dev/null +++ b/IBPSA/Utilities/IO/Files/Validation/package.mo @@ -0,0 +1,12 @@ +within IBPSA.Utilities.IO.Files; +package Validation "Collection of models that validate the models that access files" + extends Modelica.Icons.ExamplesPackage; + +annotation (preferredView="info", Documentation(info=" +

+This package contains models that validate the models that access files. +The examples plot various outputs. These model outputs are stored as reference data to +allow continuous validation whenever models in the library change. +

+")); +end Validation; diff --git a/IBPSA/Utilities/IO/Files/Validation/package.order b/IBPSA/Utilities/IO/Files/Validation/package.order new file mode 100644 index 0000000000..a47e6a26b0 --- /dev/null +++ b/IBPSA/Utilities/IO/Files/Validation/package.order @@ -0,0 +1 @@ +WeeklyScheduleWindowsLineEndings diff --git a/IBPSA/Utilities/IO/Files/package.order b/IBPSA/Utilities/IO/Files/package.order index 6cbc46401f..41dcc44817 100644 --- a/IBPSA/Utilities/IO/Files/package.order +++ b/IBPSA/Utilities/IO/Files/package.order @@ -3,4 +3,5 @@ CombiTimeTableWriter JSONWriter WeeklySchedule Examples +Validation BaseClasses