-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,4 @@ | |
"hideGenerator": true, | ||
"tsconfig": "../tsconfig/tsconfig.app.json", | ||
"categorizeByGroup": true, | ||
"media": "media" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { DataFrame, PushOptions, SinkNode, SinkNodeOptions } from "@openhps/core"; | ||
import { Property } from "@openhps/rdf"; | ||
import { SolidSession } from "../common"; | ||
|
||
/** | ||
* Solid property sink is a sink node that writes data to a Solid pod. | ||
*/ | ||
export class SolidPropertySink<Out extends DataFrame> extends SinkNode<Out> { | ||
protected options: SolidPropertySinkOptions; | ||
|
||
constructor(options?: SolidPropertySinkOptions) { | ||
super(options); | ||
} | ||
|
||
onPush(frame: Out | Out[], options?: PushOptions): Promise<void> { | ||
return new Promise<void>((resolve, reject) => { | ||
if (Array.isArray(frame)) { | ||
Promise.all(frame.map((f) => this.writeProperty(f))) | ||
.then(() => resolve()) | ||
.catch(reject); | ||
} else { | ||
this.writeProperty(frame) | ||
.then(() => resolve()) | ||
.catch(reject); | ||
} | ||
}); | ||
} | ||
|
||
protected prepareProperty(session: SolidSession): Promise<void> { | ||
return new Promise<void>((resolve, reject) => { | ||
|
||
}); | ||
} | ||
|
||
protected writeProperty(frame: Out): Promise<void> { | ||
return new Promise<void>((resolve, reject) => { | ||
for (const dataObject of frame.getObjects()) { | ||
for (const property of this.options.properties) { | ||
if (property === PropertyType.POSITION) { | ||
// Write position | ||
const position = dataObject.getPosition(); | ||
if (position) { | ||
// Write position to Solid pod | ||
|
||
} | ||
} else if (property === PropertyType.VELOCITY) { | ||
// Write velocity | ||
const velocity = dataObject.getPosition().velocity; | ||
if (velocity) { | ||
// Write velocity to Solid pod | ||
} | ||
} else if (property === PropertyType.ORIENTATION) { | ||
// Write orientation | ||
const orientation = dataObject.getPosition().orientation; | ||
if (orientation) { | ||
// Write orientation to Solid pod | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
export enum PropertyType { | ||
POSITION, | ||
VELOCITY, | ||
ORIENTATION, | ||
} | ||
|
||
export interface SolidPropertySinkOptions extends SinkNodeOptions { | ||
properties?: PropertyType[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './SolidClientService'; | ||
export * from './SolidPropertySink'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters