Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Merge pull request #19 from 2nd-Semester-Project/fix-folders
Browse files Browse the repository at this point in the history
Fix folders
  • Loading branch information
svenons authored May 7, 2024
2 parents ece0745 + f317c08 commit 9d3c7dc
Show file tree
Hide file tree
Showing 46 changed files with 592 additions and 799 deletions.
37 changes: 37 additions & 0 deletions HeatOptimiser.Tests/OptimiserTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Xunit;

namespace HeatOptimiser.Tests
{
public class OptimiserTest
{

[Fact]
public void TestOptimise()
{
// Arrange
SourceDataManager sourceManager = new SourceDataManager();
string projectDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;
string file = Path.Combine(projectDirectory, "SourceDataTest.xlsx");
var data = sourceManager.LoadXLSXFile(file, 4, 2);

IAssetManager assetManager = new AssetManager();
assetManager.AddUnit("GB", "none", 5.0, 0, 1.1, 500, 215);
assetManager.AddUnit("OB", "none", 4.0, 0, 1.2, 700, 265);

Optimiser optimiser = new Optimiser(sourceManager, assetManager);
string startDateStr = "12/02/2023";
string endDateStr = "25/02/2023";
DateTime startDate = DateTime.ParseExact(startDateStr, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime endDate = DateTime.ParseExact(endDateStr, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);

// Act
Schedule schedule = optimiser.Optimise(startDate, endDate);

// Assert
Assert.NotNull(schedule);
Assert.Equal(startDate, schedule.startDate);
Assert.Equal(endDate, schedule.endDate);
}
}

}
40 changes: 40 additions & 0 deletions HeatOptimiser.Tests/SourceDataManagerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Xunit;

namespace HeatOptimiser.Tests
{
public class SourceDataManagerTest
{
[Fact]
public void TestLoadXLSXFile()
{
// Arrange
SourceDataManager sourceManager = new SourceDataManager();
string projectDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;
string file = Path.Combine(projectDirectory, "SourceDataTest.xlsx");
Console.WriteLine(file);

// Act
var result = sourceManager.LoadXLSXFile(file, 4, 2);

// Assert
Assert.NotNull(result);
Assert.NotEmpty(result);
}

[Fact]
public void TestGetDataInRange()
{
// Arrange
SourceData data = new SourceData();
SourceDataManager sourceManager = new SourceDataManager();
DateTime startDate = new DateTime(2023, 1, 1);
DateTime endDate = new DateTime(2023, 1, 31);

// Act
var result = sourceManager.GetDataInRange(data, startDate, endDate);

// Assert
Assert.NotNull(result);
}
}
}
30 changes: 15 additions & 15 deletions HeatOptimiser/UserInterface/App.axaml → HeatOptimiser/App.axaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="UserInterface.App"
xmlns:local="using:UserInterface"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>

<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://UserInterface/Assets/Icons.axaml"/>
</Application.Styles>
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="UserInterface.App"
xmlns:local="using:UserInterface"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>

<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://HeatOptimiser/Assets/Icons.axaml"/>
</Application.Styles>
</Application>
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using UserInterface.ViewModels;
using UserInterface.Views;

namespace UserInterface;

public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}

base.OnFrameworkInitializationCompleted();
}
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using UserInterface.ViewModels;
using UserInterface.Views;

namespace UserInterface;

public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}

base.OnFrameworkInitializationCompleted();
}
}
File renamed without changes.
22 changes: 17 additions & 5 deletions HeatOptimiser/HeatOptimiser.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>

<ItemGroup>
<Folder Include="Models\" />
<AvaloniaResource Include="Assets\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.10" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.10" />
Expand All @@ -15,9 +21,15 @@
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.10" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.10" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CsvHelper" Version="32.0.1" />
<PackageReference Include="LiveChartsCore" Version="2.0.0-rc2" />
<PackageReference Include="LiveChartsCore.SkiaSharpView" Version="2.0.0-rc2" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.Avalonia" Version="2.0.0-rc2" />
<PackageReference Include="ReactiveUI" Version="19.5.72" />
<PackageReference Include="EPPlus" Version="7.0.10" />
<PackageReference Include="EPPlus" Version="7.1.1" />
<!-- <ProjectReference Include="../heat-production-optimization/HeatOptimiser/HeatOptimiser.csproj" /> -->


</ItemGroup>

</Project>
12 changes: 0 additions & 12 deletions HeatOptimiser/Interfaces/GUInterface.cs

This file was deleted.

7 changes: 0 additions & 7 deletions HeatOptimiser/Interfaces/IDataVisualizer.cs

This file was deleted.

7 changes: 0 additions & 7 deletions HeatOptimiser/Interfaces/IUserInterface.cs

This file was deleted.

56 changes: 20 additions & 36 deletions HeatOptimiser/Program.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
namespace HeatOptimiser
{
class Program {
public static void Main()
{
AssetManager assets = new();
assets.AddUnit("GB", "none", 5.0, 0, 1.1, 500, 215);
assets.AddUnit("OB", "none", 4.0, 0, 1.2, 700, 265);

SourceDataManager dataManager = new();
Optimiser optimiser = new(dataManager, assets);
string startDateStr = "12/02/2023";
string endDateStr = "25/02/2023";
DateTime startDate = DateTime.ParseExact(startDateStr, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime endDate = DateTime.ParseExact(endDateStr, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
Schedule optimisedData = optimiser.Optimise(startDate, endDate);
using Avalonia;
using Avalonia.ReactiveUI;
using System;

namespace UserInterface;

// Example on visualizing the data

// foreach (ScheduleHour hour in optimisedData.schedule)
// {
// Console.WriteLine(hour.Hour);
// foreach (ProductionAsset asset in hour.Assets)
// {
// Console.Write($"{asset.Name} ");
// }
// Console.WriteLine();
// foreach (double demand in hour.Demands)
// {
// Console.Write($"{demand} ");
// }
// Console.WriteLine("\n");
// }
sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);

new TextBasedUI().Interface();
}
}
}
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace()
.UseReactiveUI();
}
23 changes: 0 additions & 23 deletions HeatOptimiser/UserInterface/Program.cs

This file was deleted.

35 changes: 0 additions & 35 deletions HeatOptimiser/UserInterface/UserInterface.csproj

This file was deleted.

Loading

0 comments on commit 9d3c7dc

Please sign in to comment.