14
14
15
15
public class AppSettings
16
16
{
17
- public BlobStorageSettings BlobStorage { get ; set ; }
17
+ public Logitech Logitech { get ; set ; }
18
18
}
19
- public class BlobStorageSettings
19
+
20
+ public class Logitech
20
21
{
21
22
public string BlobUrl { get ; set ; }
22
23
}
@@ -50,7 +51,7 @@ public App(ICloudApplication app, ILogger<App> logger)
50
51
//_qLearnings.Add(new QLearning(numStates, 8, 0.7, 0.7, 1, 0));
51
52
}
52
53
}
53
- private AppSettings ? LoadSettings ( )
54
+ private static AppSettings LoadSettings ( )
54
55
{
55
56
string filePath = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "appsettings.json" ) ;
56
57
if ( File . Exists ( filePath ) )
@@ -62,43 +63,21 @@ public App(ICloudApplication app, ILogger<App> logger)
62
63
}
63
64
catch ( Exception ex )
64
65
{
65
- _logger . LogError ( $ "Error loading appsettings.json: { ex . Message } ") ;
66
66
return null ;
67
67
}
68
68
}
69
69
else
70
70
{
71
- _logger . LogWarning ( "appsettings.json not found." ) ;
72
71
return null ;
73
72
}
74
73
}
75
-
76
-
77
-
74
+
78
75
public async Task StartAsync ( CancellationToken token )
79
76
{
80
- //Deep Eyes
81
- //var btnSphere = (TransformNode)_app.Scene.FindChildByPath("CubeOrSphere/ButtonSphere");
82
- //var sensorSphere = btnSphere.FindFirstChild<InteractableNode>();
83
- //var btnCube = (TransformNode)_app.Scene.FindChildByPath("CubeOrSphere/ButtonCube");
84
- //var sensorCube = btnCube.FindFirstChild<InteractableNode>();
85
- //sensorCube.Selected += async (sender, args) =>
86
- //{
87
- // await UploadImageToBlobStorage(1, _appSettings);
88
- // btnCube.IsActive = false;
89
- //};
90
- //sensorSphere.Selected += async (sender, args) =>
91
- //{
92
- // await UploadImageToBlobStorage(2, _appSettings);
93
- // btnSphere.IsActive = false;
94
- //};
95
- // Machine Learning
96
-
97
-
98
77
99
78
List < DescriptionLogitech > descriptions = new List < DescriptionLogitech > ( ) ;
100
79
101
- descriptions = await GetLogitechDescriptions ( new Uri ( _appSettings . BlobStorage . BlobUrl ) ) ;
80
+ descriptions = await GetLogitechDescriptions ( ) ;
102
81
103
82
if ( descriptions != null )
104
83
{
@@ -108,11 +87,11 @@ public async Task StartAsync(CancellationToken token)
108
87
var webCockpit = screenCockpit . FindFirstChild < WebSlateNode > ( ) ;
109
88
110
89
var siteScheduler1 = ( TransformNode ) _app . Scene . FindChildByPath ( "Logitech/SiteSchedulerCockpit" ) ;
111
- var screenScheduler = ( TransformNode ) siteCockpit . FindChildByPath ( "WebSlate" ) ;
90
+ var screenScheduler = ( TransformNode ) siteScheduler1 . FindChildByPath ( "WebSlate" ) ;
112
91
var webScheduler1 = screenScheduler . FindFirstChild < WebSlateNode > ( ) ;
113
92
114
93
var siteScheduler2 = ( TransformNode ) _app . Scene . FindChildByPath ( "Logitech/SiteStudio" ) ;
115
- var screenScheduler2 = ( TransformNode ) siteCockpit . FindChildByPath ( "WebSlate" ) ;
94
+ var screenScheduler2 = ( TransformNode ) siteScheduler2 . FindChildByPath ( "WebSlate" ) ;
116
95
var webScheduler2 = screenScheduler2 . FindFirstChild < WebSlateNode > ( ) ;
117
96
118
97
@@ -147,7 +126,6 @@ public async Task StartAsync(CancellationToken token)
147
126
if ( siteCockpit . IsActive )
148
127
{
149
128
siteCockpit . IsActive = false ;
150
- Task . Delay ( 3000 ) ;
151
129
webCockpit . Url = newUrl ;
152
130
siteCockpit . IsActive = true ;
153
131
}
@@ -165,7 +143,6 @@ public async Task StartAsync(CancellationToken token)
165
143
if ( siteCockpit . IsActive )
166
144
{
167
145
siteCockpit . IsActive = false ;
168
- Task . Delay ( 3000 ) ;
169
146
webCockpit . Url = newUrl ;
170
147
siteCockpit . IsActive = true ;
171
148
}
@@ -183,7 +160,6 @@ public async Task StartAsync(CancellationToken token)
183
160
if ( siteCockpit . IsActive )
184
161
{
185
162
siteCockpit . IsActive = false ;
186
- Task . Delay ( 3000 ) ;
187
163
webCockpit . Url = newUrl ;
188
164
siteCockpit . IsActive = true ;
189
165
}
@@ -201,7 +177,6 @@ public async Task StartAsync(CancellationToken token)
201
177
if ( siteCockpit . IsActive )
202
178
{
203
179
siteCockpit . IsActive = false ;
204
- Task . Delay ( 3000 ) ;
205
180
webCockpit . Url = newUrl ;
206
181
siteCockpit . IsActive = true ;
207
182
}
@@ -219,7 +194,6 @@ public async Task StartAsync(CancellationToken token)
219
194
if ( siteScheduler1 . IsActive )
220
195
{
221
196
siteScheduler1 . IsActive = false ;
222
- Task . Delay ( 3000 ) ;
223
197
webScheduler1 . Url = newUrl ;
224
198
siteScheduler1 . IsActive = true ;
225
199
}
@@ -237,7 +211,6 @@ public async Task StartAsync(CancellationToken token)
237
211
if ( siteScheduler1 . IsActive )
238
212
{
239
213
siteScheduler1 . IsActive = false ;
240
- Task . Delay ( 3000 ) ;
241
214
webScheduler1 . Url = newUrl ;
242
215
siteScheduler1 . IsActive = true ;
243
216
}
@@ -255,7 +228,6 @@ public async Task StartAsync(CancellationToken token)
255
228
if ( siteScheduler2 . IsActive )
256
229
{
257
230
siteScheduler2 . IsActive = false ;
258
- Task . Delay ( 3000 ) ;
259
231
webScheduler2 . Url = newUrl ;
260
232
siteScheduler2 . IsActive = true ;
261
233
}
@@ -272,6 +244,8 @@ public async Task StartAsync(CancellationToken token)
272
244
273
245
}
274
246
}
247
+
248
+
275
249
public async Task < string > GetImage ( TransformNode node , string imageUrl )
276
250
{
277
251
using ( HttpClient client = new HttpClient ( ) )
@@ -285,8 +259,13 @@ public async Task<string> GetImage(TransformNode node, string imageUrl)
285
259
}
286
260
}
287
261
288
- static async Task < List < DescriptionLogitech > > GetLogitechDescriptions ( Uri blobUrl )
262
+ static async Task < List < DescriptionLogitech > > GetLogitechDescriptions ( )
289
263
{
264
+ AppSettings appSettings = LoadSettings ( ) ;
265
+
266
+ string blobUrl = appSettings . Logitech . BlobUrl ;
267
+
268
+
290
269
using ( HttpClient client = new HttpClient ( ) )
291
270
{
292
271
try
@@ -310,27 +289,6 @@ static async Task<List<DescriptionLogitech>> GetLogitechDescriptions(Uri blobUrl
310
289
}
311
290
}
312
291
313
- //static async Task UploadImageToBlobStorage(int choice, AppSettings appSettings)
314
- //{
315
- // string blobName = choice == 1 ? "cube.jpg" : "sphere.jpg";
316
- // string imageUrl = choice == 1 ? "https://images.pexels.com/photos/1340185/pexels-photo-1340185.jpeg?cs=srgb&dl=pexels-magda-ehlers-1340185.jpg&fm=jpg" : "https://images.unsplash.com/photo-1617358142775-4be217d9cc19?q=80&w=1000&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8c3BoZXJlfGVufDB8fDB8fHww";
317
- // HttpClient httpClient = new HttpClient();
318
- // var imageData = await httpClient.GetByteArrayAsync(imageUrl);
319
- // string blobUrl = $"{appSettings.DeepEyes.Url}{blobName}{appSettings.DeepEyes.Token}";
320
- // using (MemoryStream memoryStream = new MemoryStream(imageData))
321
- // {
322
- // using (HttpClient client = new HttpClient())
323
- // {
324
- // ByteArrayContent content = new ByteArrayContent(memoryStream.ToArray());
325
- // content.Headers.ContentType = new MediaTypeHeaderValue("image/jpg");
326
- // content.Headers.Add("x-ms-blob-type", "BlockBlob");
327
- // HttpResponseMessage response = await client.PutAsync(blobUrl, content);
328
- // Console.WriteLine(response.StatusCode);
329
- // }
330
- // }
331
- //}
332
-
333
-
334
292
/// <inheritdoc/>
335
293
public Task StopAsync ( CancellationToken token )
336
294
{
0 commit comments