Skip to content

Commit 2d8e383

Browse files
authored
Merge pull request #3 from NtsFranz/master
Making WriteAPI *wide*
2 parents 1e1680b + b574323 commit 2d8e383

19 files changed

+674
-197
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ jobs:
1919
runs-on: windows-latest
2020

2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
2323
- name: Setup .NET Core
24-
uses: actions/setup-dotnet@v1
24+
uses: actions/setup-dotnet@v3
2525
with:
26-
dotnet-version: '3.1.x'
26+
dotnet-version: '6.0.x'
2727
- name: Install dependencies
2828
run: dotnet restore
2929
- name: Build
3030
run: |
3131
dotnet publish -c Release
32-
copy LICENSE WriteAPI\bin\Release\netcoreapp3.1\publish\
32+
copy LICENSE WriteAPI\bin\Release\net6.0\publish\
3333
- name: Upload Write API
34-
uses: actions/upload-artifact@v2
34+
uses: actions/upload-artifact@v3
3535
with:
3636
name: Write API
37-
path: WriteAPI/bin/Release/netcoreapp3.1/publish/
37+
path: WriteAPI/bin/Release/net6.0/publish/
3838
- name: Upload Sample Project
39-
uses: actions/upload-artifact@v2
39+
uses: actions/upload-artifact@v3
4040
with:
4141
name: Sample Project
4242
path: SampleProject/bin/Release/netcoreapp3.1/publish/

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ jobs:
88
runs-on: windows-latest
99

1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
1212

1313
- name: Setup .NET Core
14-
uses: actions/setup-dotnet@v1
14+
uses: actions/setup-dotnet@v3
1515
with:
16-
dotnet-version: '3.1.x'
16+
dotnet-version: '6.0.x'
1717

1818
- name: Install dependencies
1919
run: dotnet restore
2020

2121
- name: Build
2222
run: |
2323
dotnet publish -c Release
24-
copy LICENSE WriteAPI\bin\Release\netcoreapp3.1\publish\
24+
copy LICENSE WriteAPI\bin\Release\net6.0\publish\
2525
2626
- name: Zip Write API
2727
uses: papeloto/action-zip@v1
2828
with:
29-
files: WriteAPI/bin/Release/netcoreapp3.1/publish/
29+
files: WriteAPI/bin/Release/net6.0/publish/
3030
dest: WriteAPI.zip
3131

3232
- name: Zip Sample Project

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ In order to update the camera transform, send a POST request to `127.0.0.1:6723`
3636

3737
In order to get the camera transform, send a GET request to `127.0.0.1:6723`. The response will be json in the same format as the above.
3838

39+
## Development
40+
41+
Run with `--noupdateconfig` to use a modified local config without fetching one from the internet.
42+
3943
## Sample Project
4044

4145
The repository includes a sample project that makes use of the API to move the camera. It is a .NET Core WPF project that interpolates the camera over a user defined path.

SampleProject/MainWindow.xaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:SampleProject"
77
mc:Ignorable="d"
8-
Title="MainWindow" Height="175" Width="575">
9-
<Grid Margin="0,0,0,0">
10-
<Button x:Name="SetStart" Content="Set Start" HorizontalAlignment="Left" Height="75" Margin="10,10,0,0" VerticalAlignment="Top" Width="150" RenderTransformOrigin="0.5,0.5" FontSize="20" Click="SetStart_Click"/>
11-
<Button x:Name="SetEnd" Content="Set End" HorizontalAlignment="Left" Height="75" Margin="165,10,0,0" VerticalAlignment="Top" Width="150" RenderTransformOrigin="0.5,0.5" FontSize="20" Click="SetEnd_Click"/>
12-
<Button x:Name="FollowPath" Content="Follow Path" HorizontalAlignment="Left" Height="75" Margin="320,10,0,0" VerticalAlignment="Top" Width="150" RenderTransformOrigin="0.5,0.5" FontSize="20" Click="FollowPath_Click"/>
13-
</Grid>
14-
</Window>
8+
Title="MainWindow" Height="175" Width="650">
9+
<StackPanel Orientation="Horizontal">
10+
<Button x:Name="SetStart" Content="Set Start" Height="75" Width="150" FontSize="20" Click="SetStart_Click" />
11+
<Button x:Name="SetEnd" Content="Set End" Height="75" Width="150" FontSize="20" Click="SetEnd_Click" />
12+
<Button x:Name="FollowPath" Content="Follow Path" Height="75" Width="150" FontSize="20" Click="FollowPath_Click" />
13+
<Label Content="Time:" Height="25" FontSize="20"/>
14+
<TextBox x:Name="TimeInput" Height="25" Width="100" FontSize="20" />
15+
</StackPanel>
16+
</Window>

SampleProject/MainWindow.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public partial class MainWindow : Window
1515
const string Endpoint = "http://127.0.0.1:6723/";
1616

1717
static readonly HttpClient client = new HttpClient();
18+
private static float duration = 3;
1819

1920
public class CameraTransform
2021
{
@@ -77,15 +78,14 @@ private void FollowPath_Click(object sender, RoutedEventArgs e)
7778
{
7879
if (!followPathThread.IsAlive)
7980
{
81+
float.TryParse(TimeInput.Text, out duration);
8082
followPathThread = new Thread(FollowPathThread);
8183
followPathThread.Start();
8284
}
8385
}
8486

8587
static void FollowPathThread()
8688
{
87-
float duration = 3;
88-
8989
DateTime startTime = DateTime.Now;
9090
DateTime currentTime = startTime;
9191
float t = 0;

WriteAPI/CameraTransform.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

WriteAPI/ConfigurationManager.cs

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42
using Newtonsoft.Json;
53
using System.IO;
64
using System.Net.Http;
@@ -9,13 +7,30 @@ namespace WriteAPI
97
{
108
public static class ConfigurationManager
119
{
12-
const string RemoteConfigPath = @"https://raw.githubusercontent.com/Graicc/WriteAPI/master/WriteAPI/config.json";
13-
const string ConfigPath = "config.json";
10+
private const string RemoteConfigPath = @"https://raw.githubusercontent.com/Graicc/WriteAPI/master/WriteAPI/config.json";
11+
private const string ConfigPath = "config.json";
1412

1513
public struct Config
1614
{
17-
public string cameraPositionAddress;
18-
public string cameraRotationAddress;
15+
public class EchoVRContainer
16+
{
17+
public string cameraPosition;
18+
public string cameraRotation;
19+
}
20+
21+
public class LoneEchoContainer
22+
{
23+
public string speed;
24+
}
25+
26+
public class LoneEcho2Container
27+
{
28+
public string speed;
29+
}
30+
31+
public EchoVRContainer EchoVR;
32+
public LoneEchoContainer LoneEcho;
33+
public LoneEcho2Container LoneEcho2;
1934
}
2035

2136
public static Config config;
@@ -30,28 +45,29 @@ public static void UpdateConfig(bool updateConfig = true)
3045
config = ReadLocalConfig();
3146
}
3247

33-
static void TryUpdateConfigFile()
48+
private static void TryUpdateConfigFile()
3449
{
3550
Console.WriteLine("Checking for updated config file...");
36-
using (var httpClient = new HttpClient()) {
37-
var response = httpClient.GetAsync(RemoteConfigPath).Result;
38-
if (response.IsSuccessStatusCode)
39-
{
40-
FileInfo fileInfo = new FileInfo(ConfigPath);
41-
FileMode fileMode = fileInfo.Exists ? FileMode.Truncate : FileMode.Create;
42-
using (Stream output = File.Open(ConfigPath, fileMode))
43-
{
44-
response.Content.CopyToAsync(output).Wait();
45-
}
46-
Console.WriteLine("Updated config file");
47-
} else
51+
using HttpClient httpClient = new HttpClient();
52+
HttpResponseMessage response = httpClient.GetAsync(RemoteConfigPath).Result;
53+
if (response.IsSuccessStatusCode)
54+
{
55+
FileInfo fileInfo = new FileInfo(ConfigPath);
56+
FileMode fileMode = fileInfo.Exists ? FileMode.Truncate : FileMode.Create;
57+
using (Stream output = File.Open(ConfigPath, fileMode))
4858
{
49-
Console.WriteLine("Could not get remote config file");
59+
response.Content.CopyToAsync(output).Wait();
5060
}
61+
62+
Console.WriteLine("Updated config file");
63+
}
64+
else
65+
{
66+
Console.WriteLine("Could not get remote config file");
5167
}
5268
}
5369

54-
static Config ReadLocalConfig()
70+
private static Config ReadLocalConfig()
5571
{
5672
#if DEBUG
5773
Console.WriteLine("Reading config");
@@ -66,10 +82,10 @@ static Config ReadLocalConfig()
6682
Config localConfig = JsonConvert.DeserializeObject<Config>(data);
6783

6884
#if DEBUG
69-
Console.WriteLine($"Position address: {localConfig.cameraPositionAddress} | Rotation address: {localConfig.cameraRotationAddress}");
85+
Console.WriteLine($"Position address: {localConfig.EchoVR.cameraPosition} | Rotation address: {localConfig.EchoVR.cameraRotation}");
7086
#endif
7187

7288
return localConfig;
7389
}
7490
}
75-
}
91+
}

0 commit comments

Comments
 (0)