From 4cba7ff833c4b8c2638f8a19e1085c51972b8c47 Mon Sep 17 00:00:00 2001 From: Sasha Date: Thu, 28 Sep 2023 10:22:48 +1300 Subject: [PATCH 1/2] Removed an absolute path, removed WinForms --- .../ConsoleAppSVS-test.csproj} | 14 +- modelCsharp/ConsoleAppSVS-test/Program.cs | 4 + modelCsharp/SVSModel.sln | 16 ++- modelCsharp/TestModel/TestModel/Test.cs | 14 +- .../TestModel/TestModel/TestModel.csproj | 1 - modelCsharp/TestModel/testGraph/testGraph.sln | 23 ++++ .../testGraph/testGraph/testGraph.py | 9 +- .../testGraph/testGraph/testGraph.pyproj | 7 - .../WinFormsSVS-test/Form1.Designer.cs | 65 ---------- modelCsharp/WinFormsSVS-test/Form1.cs | 23 ---- modelCsharp/WinFormsSVS-test/Form1.resx | 120 ------------------ modelCsharp/WinFormsSVS-test/Program.cs | 17 --- 12 files changed, 57 insertions(+), 256 deletions(-) rename modelCsharp/{WinFormsSVS-test/WinFormsSVS-test.csproj => ConsoleAppSVS-test/ConsoleAppSVS-test.csproj} (55%) create mode 100644 modelCsharp/ConsoleAppSVS-test/Program.cs create mode 100644 modelCsharp/TestModel/testGraph/testGraph.sln delete mode 100644 modelCsharp/WinFormsSVS-test/Form1.Designer.cs delete mode 100644 modelCsharp/WinFormsSVS-test/Form1.cs delete mode 100644 modelCsharp/WinFormsSVS-test/Form1.resx delete mode 100644 modelCsharp/WinFormsSVS-test/Program.cs diff --git a/modelCsharp/WinFormsSVS-test/WinFormsSVS-test.csproj b/modelCsharp/ConsoleAppSVS-test/ConsoleAppSVS-test.csproj similarity index 55% rename from modelCsharp/WinFormsSVS-test/WinFormsSVS-test.csproj rename to modelCsharp/ConsoleAppSVS-test/ConsoleAppSVS-test.csproj index 14f8950..00c8944 100644 --- a/modelCsharp/WinFormsSVS-test/WinFormsSVS-test.csproj +++ b/modelCsharp/ConsoleAppSVS-test/ConsoleAppSVS-test.csproj @@ -1,13 +1,11 @@  - WinExe - net6.0-windows - WinFormsSVS_test - enable - true - true + Exe + net6.0 + ConsoleAppSVS_test enable + enable @@ -15,6 +13,4 @@ - - - \ No newline at end of file + diff --git a/modelCsharp/ConsoleAppSVS-test/Program.cs b/modelCsharp/ConsoleAppSVS-test/Program.cs new file mode 100644 index 0000000..2ef032b --- /dev/null +++ b/modelCsharp/ConsoleAppSVS-test/Program.cs @@ -0,0 +1,4 @@ + +using TestModel; + +Test.RunTests(TestConfigData.configDict); \ No newline at end of file diff --git a/modelCsharp/SVSModel.sln b/modelCsharp/SVSModel.sln index 9352c35..b6cbc12 100644 --- a/modelCsharp/SVSModel.sln +++ b/modelCsharp/SVSModel.sln @@ -10,10 +10,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SVSModel.Excel", "SVSModel. {255D77C7-5338-42BC-A136-8801657D51BB} = {255D77C7-5338-42BC-A136-8801657D51BB} EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsSVS-test", "WinFormsSVS-test\WinFormsSVS-test.csproj", "{7DD24577-0C84-42E1-B10C-551BB92A718A}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestModel", "TestModel\TestModel\TestModel.csproj", "{B98654E6-CEB9-4418-ACC8-DFC06055081B}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleAppSVS-test", "ConsoleAppSVS-test\ConsoleAppSVS-test.csproj", "{9C1F1537-6CE7-4C6E-8B89-CD9276C3F6D6}" +EndProject +Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "testGraph", "TestModel\testGraph\testGraph\testGraph.pyproj", "{4311625B-8B0C-45C1-B2C3-C7CFC084E381}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -28,14 +30,16 @@ Global {30EFA8DB-CE6D-4B36-9EBC-0A0B2CD7A444}.Debug|Any CPU.Build.0 = Debug|Any CPU {30EFA8DB-CE6D-4B36-9EBC-0A0B2CD7A444}.Release|Any CPU.ActiveCfg = Release|Any CPU {30EFA8DB-CE6D-4B36-9EBC-0A0B2CD7A444}.Release|Any CPU.Build.0 = Release|Any CPU - {7DD24577-0C84-42E1-B10C-551BB92A718A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7DD24577-0C84-42E1-B10C-551BB92A718A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7DD24577-0C84-42E1-B10C-551BB92A718A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7DD24577-0C84-42E1-B10C-551BB92A718A}.Release|Any CPU.Build.0 = Release|Any CPU {B98654E6-CEB9-4418-ACC8-DFC06055081B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B98654E6-CEB9-4418-ACC8-DFC06055081B}.Debug|Any CPU.Build.0 = Debug|Any CPU {B98654E6-CEB9-4418-ACC8-DFC06055081B}.Release|Any CPU.ActiveCfg = Release|Any CPU {B98654E6-CEB9-4418-ACC8-DFC06055081B}.Release|Any CPU.Build.0 = Release|Any CPU + {9C1F1537-6CE7-4C6E-8B89-CD9276C3F6D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C1F1537-6CE7-4C6E-8B89-CD9276C3F6D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C1F1537-6CE7-4C6E-8B89-CD9276C3F6D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C1F1537-6CE7-4C6E-8B89-CD9276C3F6D6}.Release|Any CPU.Build.0 = Release|Any CPU + {4311625B-8B0C-45C1-B2C3-C7CFC084E381}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4311625B-8B0C-45C1-B2C3-C7CFC084E381}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/modelCsharp/TestModel/TestModel/Test.cs b/modelCsharp/TestModel/TestModel/Test.cs index b215621..a7fff0f 100644 --- a/modelCsharp/TestModel/TestModel/Test.cs +++ b/modelCsharp/TestModel/TestModel/Test.cs @@ -19,6 +19,8 @@ using IronPython.Hosting; using Microsoft.Scripting.Hosting; using Microsoft.Scripting; +using static IronPython.Modules._ast; +using System.IO; namespace TestModel { @@ -26,8 +28,10 @@ public class Test { private static void runPythonScript() { - ////just checking - string progToRun = @"C:\Users\1989s\source\repos\SVS\modelCsharp\TestModel\testGraph\testGraph\testGraph.py"; + string dir = Directory.GetCurrentDirectory(); + string newPath = Path.GetFullPath(Path.Combine(dir, @"..\..\..\..\")); + string progToRun = newPath+ @"TestModel\testGraph\testGraph\testGraph.py"; + Process proc = new Process(); proc.StartInfo.FileName = "python.exe"; proc.StartInfo.RedirectStandardOutput = true; @@ -42,7 +46,7 @@ private static void runPythonScript() public static void RunTests(Dictionary _configDict) { - + string dir = Directory.GetCurrentDirectory(); //DataFrame testConfigs = Crop.LoadCoefficients("SVSModel.Data.TestConfig.csv"); string resourceName = "TestModel.TestConfig.csv"; @@ -97,9 +101,9 @@ public static void RunTests(Dictionary _configDict) nextRow.Add(new KeyValuePair(OutPutHeaders[c], output[r, c])); } newDataframe.Append(nextRow, true); - } + } - DataFrame.SaveCsv(newDataframe, @"C:\Users\1989s\source\repos\svs\modelCsharp\TestModel\testGraph\OutputFiles\" + test + ".csv"); + DataFrame.SaveCsv(newDataframe, dir + "\\OutputFiles\\" + test + ".csv"); } runPythonScript(); diff --git a/modelCsharp/TestModel/TestModel/TestModel.csproj b/modelCsharp/TestModel/TestModel/TestModel.csproj index 04ddc19..e8603e3 100644 --- a/modelCsharp/TestModel/TestModel/TestModel.csproj +++ b/modelCsharp/TestModel/TestModel/TestModel.csproj @@ -16,7 +16,6 @@ - diff --git a/modelCsharp/TestModel/testGraph/testGraph.sln b/modelCsharp/TestModel/testGraph/testGraph.sln new file mode 100644 index 0000000..ed4e20b --- /dev/null +++ b/modelCsharp/TestModel/testGraph/testGraph.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34024.191 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "PythonApplication1", "PythonApplication1\PythonApplication1.pyproj", "{4311625B-8B0C-45C1-B2C3-C7CFC084E381}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4311625B-8B0C-45C1-B2C3-C7CFC084E381}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4311625B-8B0C-45C1-B2C3-C7CFC084E381}.Release|Any CPU.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {38768DFE-027F-45DB-A2A1-524708782CA6} + EndGlobalSection +EndGlobal diff --git a/modelCsharp/TestModel/testGraph/testGraph/testGraph.py b/modelCsharp/TestModel/testGraph/testGraph/testGraph.py index 5ca686d..c3508e4 100644 --- a/modelCsharp/TestModel/testGraph/testGraph/testGraph.py +++ b/modelCsharp/TestModel/testGraph/testGraph/testGraph.py @@ -1,10 +1,13 @@ +import os import pandas as pd import matplotlib.pyplot as plt import datetime as dt import numpy as np -data = pd.read_csv(r"C:\Users\1989s\source\repos\svs\modelCsharp\TestModel\testGraph\OutputFiles\test 1.csv",index_col=0) -observed_data = pd.read_csv(r"C:\Users\1989s\source\repos\svs\modelCsharp\TestModel\testGraph\OutputFiles\observed.csv",index_col=0) +path = os.getcwd() + +data = pd.read_csv(path + r"\OutputFiles\test 1.csv",index_col=0) +observed_data = pd.read_csv(path +r"\OutputFiles\observed.csv",index_col=0) observed_data.sort_index(axis=0,inplace=True) @@ -12,7 +15,7 @@ Alltests =[] for t in tests[:]: - Alltests.append(pd.read_csv(r"C:/Users/1989s/source/repos/svs/modelCsharp/TestModel/testGraph/OutputFiles/"+t+".csv",index_col=0)) + Alltests.append(pd.read_csv( path + "\\OutputFiles\\"+t+".csv",index_col=0)) AllData = pd.concat(Alltests,axis=1,keys=tests) AllData.index = pd.to_datetime(AllData.index,format = "%d/%m/%Y %H:%M:%S %p") diff --git a/modelCsharp/TestModel/testGraph/testGraph/testGraph.pyproj b/modelCsharp/TestModel/testGraph/testGraph/testGraph.pyproj index 0a48feb..8e3b2a9 100644 --- a/modelCsharp/TestModel/testGraph/testGraph/testGraph.pyproj +++ b/modelCsharp/TestModel/testGraph/testGraph/testGraph.pyproj @@ -25,13 +25,6 @@ - - - SVSModel - {255d77c7-5338-42bc-a136-8801657d51bb} - True - - diff --git a/modelCsharp/WinFormsSVS-test/Form1.Designer.cs b/modelCsharp/WinFormsSVS-test/Form1.Designer.cs deleted file mode 100644 index 627c3b4..0000000 --- a/modelCsharp/WinFormsSVS-test/Form1.Designer.cs +++ /dev/null @@ -1,65 +0,0 @@ -namespace WinFormsSVS_test -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - startButton = new Button(); - lblHelloWorld = new Label(); - SuspendLayout(); - // - // startButton - // - startButton.Font = new Font("Segoe UI", 15F, FontStyle.Regular, GraphicsUnit.Point); - startButton.Location = new Point(157, 83); - startButton.Name = "startButton"; - startButton.Size = new Size(318, 164); - startButton.TabIndex = 0; - startButton.Text = "Start Project"; - startButton.UseVisualStyleBackColor = true; - startButton.Click += button1_Click; - // - - // Form1 - // - AutoScaleDimensions = new SizeF(10F, 25F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1156, 752); - Controls.Add(lblHelloWorld); - Controls.Add(startButton); - Name = "Form1"; - Text = "Form1"; - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private Button startButton; - private Label lblHelloWorld; - } -} \ No newline at end of file diff --git a/modelCsharp/WinFormsSVS-test/Form1.cs b/modelCsharp/WinFormsSVS-test/Form1.cs deleted file mode 100644 index 516d89c..0000000 --- a/modelCsharp/WinFormsSVS-test/Form1.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Diagnostics; -using TestModel; - -namespace WinFormsSVS_test -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - - private void button1_Click(object sender, EventArgs e) - { - - startButton.BackColor = Color.BlueViolet; - System.Threading.Thread.Sleep(3000); - Test.Main(TestConfigData.configDict); - - } - - } -} \ No newline at end of file diff --git a/modelCsharp/WinFormsSVS-test/Form1.resx b/modelCsharp/WinFormsSVS-test/Form1.resx deleted file mode 100644 index a395bff..0000000 --- a/modelCsharp/WinFormsSVS-test/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/modelCsharp/WinFormsSVS-test/Program.cs b/modelCsharp/WinFormsSVS-test/Program.cs deleted file mode 100644 index 2f7b869..0000000 --- a/modelCsharp/WinFormsSVS-test/Program.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace WinFormsSVS_test -{ - internal static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); - } - } -} \ No newline at end of file From c797e3a7b16ec9e1effd2c9568c2d443db833274 Mon Sep 17 00:00:00 2001 From: Sasha Date: Thu, 28 Sep 2023 11:58:29 +1300 Subject: [PATCH 2/2] Removed testGraph solution --- modelCsharp/TestModel/testGraph/testGraph.sln | 23 ------------------- .../testGraph/testGraph/testGraph.py | 11 +++++++++ 2 files changed, 11 insertions(+), 23 deletions(-) delete mode 100644 modelCsharp/TestModel/testGraph/testGraph.sln diff --git a/modelCsharp/TestModel/testGraph/testGraph.sln b/modelCsharp/TestModel/testGraph/testGraph.sln deleted file mode 100644 index ed4e20b..0000000 --- a/modelCsharp/TestModel/testGraph/testGraph.sln +++ /dev/null @@ -1,23 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.7.34024.191 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "PythonApplication1", "PythonApplication1\PythonApplication1.pyproj", "{4311625B-8B0C-45C1-B2C3-C7CFC084E381}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4311625B-8B0C-45C1-B2C3-C7CFC084E381}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4311625B-8B0C-45C1-B2C3-C7CFC084E381}.Release|Any CPU.ActiveCfg = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {38768DFE-027F-45DB-A2A1-524708782CA6} - EndGlobalSection -EndGlobal diff --git a/modelCsharp/TestModel/testGraph/testGraph/testGraph.py b/modelCsharp/TestModel/testGraph/testGraph/testGraph.py index c3508e4..10f9a71 100644 --- a/modelCsharp/TestModel/testGraph/testGraph/testGraph.py +++ b/modelCsharp/TestModel/testGraph/testGraph/testGraph.py @@ -4,6 +4,9 @@ import datetime as dt import numpy as np +import glob + + path = os.getcwd() data = pd.read_csv(path + r"\OutputFiles\test 1.csv",index_col=0) @@ -13,6 +16,14 @@ tests = ['test 1','test 2','test 3'] +#tests = [] + +#fullpath =path + r"\\OutputFiles\\" + +#for file in os.listdir(fullpath): + # if file.endswith(".csv") and file.startswith("test"): + # tests.append(file) + Alltests =[] for t in tests[:]: Alltests.append(pd.read_csv( path + "\\OutputFiles\\"+t+".csv",index_col=0))