Skip to content

Commit 29627e0

Browse files
XML Documentation
1 parent eecb4e0 commit 29627e0

File tree

4 files changed

+752
-28
lines changed

4 files changed

+752
-28
lines changed

bHapticsLib/HapticPattern.cs

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,71 @@ public class HapticPattern
66
/// <value>Pattern key id</value>
77
public string Key { get; private set; }
88

9+
/// <summary>Loads a pattern from raw json into HapticPattern</summary>
10+
/// <param name="key">The key id of the pattern</param>
11+
/// <param name="tactFileJson">The raw json of the pattern</param>
12+
public static HapticPattern LoadFromJson(string key, string tactFileJson)
13+
{
14+
bHapticsManager.RegisterPatternFromJson(key, tactFileJson);
15+
return new HapticPattern { Key = key };
16+
}
917

18+
/// <summary>Loads a pattern from file path into HapticPattern</summary>
19+
/// <param name="key">The key id of the pattern</param>
20+
/// <param name="tactFilePath">The file path of the pattern</param>
1021
public static HapticPattern LoadFromFile(string key, string tactFilePath)
1122
{
1223
bHapticsManager.RegisterPatternFromFile(key, tactFilePath);
1324
return new HapticPattern { Key = key };
1425
}
1526

16-
public static HapticPattern LoadFromJson(string key, string tactFileStr)
27+
/// <summary>Loads a pattern swapped from raw json into HapticPattern</summary>
28+
/// <param name="key">The key id of the pattern</param>
29+
/// <param name="tactFileJson">The raw json of the pattern</param>
30+
public static HapticPattern LoadSwappedFromJson(string key, string tactFileJson)
1731
{
18-
bHapticsManager.RegisterPatternFromJson(key, tactFileStr);
32+
bHapticsManager.RegisterPatternSwappedFromJson(key, tactFileJson);
1933
return new HapticPattern { Key = key };
2034
}
2135

36+
/// <summary>Loads a pattern swapped from file path into HapticPattern</summary>
37+
/// <param name="key">The key id of the pattern</param>
38+
/// <param name="tactFilePath">The file path of the pattern</param>
2239
public static HapticPattern LoadSwappedFromFile(string key, string tactFilePath)
2340
{
2441
bHapticsManager.RegisterPatternSwappedFromFile(key, tactFilePath);
2542
return new HapticPattern { Key = key };
2643
}
2744

28-
public static HapticPattern LoadSwappedFromJson(string key, string tactFileStr)
29-
{
30-
bHapticsManager.RegisterPatternSwappedFromJson(key, tactFileStr);
31-
return new HapticPattern { Key = key };
32-
}
33-
45+
/// <summary>Checks if the HapticPattern is Registered</summary>
3446
public bool IsRegistered()
3547
=> bHapticsManager.IsPatternRegistered(Key);
48+
49+
/// <summary>Checks if the HapticPattern is Playing</summary>
3650
public bool IsPlaying()
3751
=> bHapticsManager.IsPlaying(Key);
52+
53+
/// <summary>Stops the HapticPattern</summary>
3854
public void Stop()
3955
=> bHapticsManager.StopPlaying(Key);
4056

57+
/// <summary>Plays the HapticPattern</summary>
4158
public void Play()
4259
=> bHapticsManager.PlayRegistered(Key);
60+
61+
/// <summary>Plays the HapticPattern</summary>
62+
/// <param name="option">Custom Playback Scale Option</param>
4363
public void Play(ScaleOption option)
4464
=> bHapticsManager.PlayRegistered(Key, option);
65+
66+
/// <summary>Plays the HapticPattern</summary>
67+
/// <param name="option">Custom Playback Rotation Option</param>
4568
public void Play(RotationOption option)
4669
=> bHapticsManager.PlayRegistered(Key, option);
70+
71+
/// <summary>Plays the HapticPattern</summary>
72+
/// <param name="scaleOption">Custom Playback Scale Option</param>
73+
/// <param name="rotationOption">Custom Playback Rotation Option</param>
4774
public void Play(ScaleOption scaleOption, RotationOption rotationOption)
4875
=> bHapticsManager.PlayRegistered(Key, scaleOption, rotationOption);
4976
}

bHapticsLib/bHapticsConnection.cs

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public IPAddress IPAddress
5858

5959
internal bHapticsConnection() { }
6060

61-
6261
public bHapticsConnection(string id, string name, bool tryToReconnect = true, int maxRetries = 5)
6362
: this(IPAddress.Loopback, id, name, tryToReconnect, maxRetries) { }
6463

@@ -156,14 +155,22 @@ public bHapticsStatus Status
156155
#endregion
157156

158157
#region Device
158+
/// <summary>Gets the total amount of devices currently connected to the bHaptics Player</summary>
159+
/// <returns>The total amount of devices currently connected to the bHaptics Player</returns>
159160
public int GetConnectedDeviceCount() => Socket?.LastResponse?.ConnectedDeviceCount ?? 0;
161+
162+
/// <summary>Gets if a specific device is currently connected to the bHaptics Player</summary>
163+
/// <returns>true if the device is connected, otherwise false</returns>
160164
public bool IsDeviceConnected(PositionID type)
161165
{
162166
if ((type == PositionID.VestFront)
163167
|| (type == PositionID.VestBack))
164168
type = PositionID.Vest;
165169
return Socket?.LastResponse?.ConnectedPositions?.ContainsValue(type.ToPacketString()) ?? false;
166170
}
171+
172+
/// <summary>Gets the current status a specific device.</summary>
173+
/// <returns>An Integer Array containing the current intensity value for each motor of the device</returns>
167174
public int[] GetDeviceStatus(PositionID type)
168175
{
169176
if ((Socket == null)
@@ -201,17 +208,27 @@ public int[] GetDeviceStatus(PositionID type)
201208
#endregion
202209

203210
#region IsPlaying
211+
/// <summary>Gets if a specified pattern is currently playing</summary>
212+
/// <param name="key">The key id of the pattern</param>
213+
/// <returns>true if the specified pattern is playing, otherwise false</returns>
204214
public bool IsPlaying(string key) => Socket?.LastResponse?.ActiveKeys?.ContainsValue(key) ?? false;
215+
216+
/// <summary>Gets if any pattern is currently playing</summary>
217+
/// <returns>true if any pattern is playing, otherwise false</returns>
205218
public bool IsPlayingAny() => (Socket?.LastResponse?.ActiveKeys?.Count > 0);
206219
#endregion
207220

208221
#region StopPlaying
222+
/// <summary>Stops the specified pattern</summary>
223+
/// <param name="key">The key id of the pattern</param>
209224
public void StopPlaying(string key)
210225
{
211226
if (!IsAlive() || !IsConnected())
212227
return;
213228
SubmitQueue.Enqueue(new SubmitRequest { key = key, type = "turnOff" });
214229
}
230+
231+
/// <summary>Stops all currently playing patterns</summary>
215232
public void StopPlayingAll()
216233
{
217234
if (!IsAlive() || !IsConnected())
@@ -221,8 +238,14 @@ public void StopPlayingAll()
221238
#endregion
222239

223240
#region PatternRegister
241+
/// <summary>Checks if the specified pattern is Registered in the Cache</summary>
242+
/// <param name="key">The key id of the pattern</param>
243+
/// <returns>true if Registered, otherwise false</returns>
224244
public bool IsPatternRegistered(string key) => Socket?.LastResponse?.RegisteredKeys?.ContainsValue(key) ?? false;
225245

246+
/// <summary>Registers a pattern from file path in the cache</summary>
247+
/// <param name="key">The key id of the pattern</param>
248+
/// <param name="tactFilePath">The file path of the pattern</param>
226249
public void RegisterPatternFromFile(string key, string tactFilePath)
227250
{
228251
if (!File.Exists(tactFilePath))
@@ -231,22 +254,28 @@ public void RegisterPatternFromFile(string key, string tactFilePath)
231254
RegisterPatternFromJson(key, File.ReadAllText(tactFilePath));
232255
}
233256

234-
public void RegisterPatternFromJson(string key, string tactFileStr)
257+
/// <summary>Registers a pattern from raw json in the cache</summary>
258+
/// <param name="key">The key id of the pattern</param>
259+
/// <param name="tactFileJson">The raw json of the pattern</param>
260+
public void RegisterPatternFromJson(string key, string tactFileJson)
235261
{
236262
if (string.IsNullOrEmpty(key))
237263
return; // To-Do: Exception Here
238264

239-
if (string.IsNullOrEmpty(tactFileStr))
265+
if (string.IsNullOrEmpty(tactFileJson))
240266
return; // To-Do: Exception Here
241267

242268
RegisterRequest request = new RegisterRequest();
243269
request.key = key;
244-
request.project = JSON.Parse(tactFileStr)[nameof(request.project)].AsObject;
270+
request.project = JSON.Parse(tactFileJson)[nameof(request.project)].AsObject;
245271

246272
RegisterCache.Add(request);
247273
RegisterQueue.Enqueue(request);
248274
}
249275

276+
/// <summary>Registers a pattern swapped from file path in the cache</summary>
277+
/// <param name="key">The key id of the pattern</param>
278+
/// <param name="tactFilePath">The file path of the pattern</param>
250279
public void RegisterPatternSwappedFromFile(string key, string tactFilePath)
251280
{
252281
if (!File.Exists(tactFilePath))
@@ -255,18 +284,21 @@ public void RegisterPatternSwappedFromFile(string key, string tactFilePath)
255284
RegisterPatternSwappedFromJson(key, File.ReadAllText(tactFilePath));
256285
}
257286

258-
public void RegisterPatternSwappedFromJson(string key, string tactFileStr)
287+
/// <summary>Registers a pattern swapped from raw json in the cache</summary>
288+
/// <param name="key">The key id of the pattern</param>
289+
/// <param name="tactFileJson">The raw json of the pattern</param>
290+
public void RegisterPatternSwappedFromJson(string key, string tactFileJson)
259291
{
260292
if (string.IsNullOrEmpty(key))
261293
return; // To-Do: Exception Here
262294

263-
if (string.IsNullOrEmpty(tactFileStr))
295+
if (string.IsNullOrEmpty(tactFileJson))
264296
return; // To-Do: Exception Here
265297

266298
RegisterRequest request = new RegisterRequest();
267299
request.key = key;
268300

269-
JSONObject project = JSON.Parse(tactFileStr)[nameof(project)].AsObject;
301+
JSONObject project = JSON.Parse(tactFileJson)[nameof(project)].AsObject;
270302
JSONArray tracks = project[nameof(tracks)].AsArray;
271303
LoopTracks(tracks, (effect) =>
272304
{
@@ -304,6 +336,15 @@ private static void LoopTracks(JSONArray tracks, Action<JSONObject> act)
304336
#endregion
305337

306338
#region Play
339+
/// <summary>Plays a pattern</summary>
340+
/// <typeparam name="A">DotPoint Collection Type</typeparam>
341+
/// <typeparam name="B">PathPoint Collection Type</typeparam>
342+
/// <param name="key">Key id of this pattern</param>
343+
/// <param name="durationMillis">Duration of Playback</param>
344+
/// <param name="position">Position for Playback</param>
345+
/// <param name="dotPoints">Collection of int, byte, or DotPoint</param>
346+
/// <param name="pathPoints">Collection of PathPoint</param>
347+
/// <param name="dotMirrorDirection">Direction to Mirror Playback</param>
307348
public void Play<A, B>(
308349
string key,
309350
int durationMillis,
@@ -389,6 +430,11 @@ public void Play<A, B>(
389430
#endregion
390431

391432
#region PlayRegistered
433+
/// <summary>Plays a registered pattern from the Cache</summary>
434+
/// <param name="key">Key id of this pattern</param>
435+
/// <param name="altKey">Alternative Key id of this pattern, can be null</param>
436+
/// <param name="scaleOption">Custom Playback Scale Option, can be null</param>
437+
/// <param name="rotationOption">Custom Playback Rotation Option, can be null</param>
392438
public void PlayRegistered(string key, string altKey = null, ScaleOption scaleOption = null, RotationOption rotationOption = null)
393439
{
394440
if (!IsAlive())
@@ -407,6 +453,10 @@ public void PlayRegistered(string key, string altKey = null, ScaleOption scaleOp
407453

408454
SubmitQueue.Enqueue(request);
409455
}
456+
457+
/// <summary>Plays a registered pattern from the Cache</summary>
458+
/// <param name="key">Key id of this pattern</param>
459+
/// <param name="startTimeMillis">Playback Start Time Delay in Milliseconds</param>
410460
public void PlayRegisteredMillis(string key, int startTimeMillis = 0)
411461
{
412462
if (!IsAlive())

0 commit comments

Comments
 (0)