Skip to content

Commit

Permalink
Merge pull request #107 from AllenNeuralDynamics/docs-add-harp-enviro…
Browse files Browse the repository at this point in the history
…nment-sensor

Add Harp environement sensor documentation
  • Loading branch information
bruno-f-cruz authored Nov 8, 2024
2 parents de20c21 + ab1264c commit 5df2dbf
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "docs/harp_devices_src/harp.device.white-rabbit"]
path = docs/harp_devices_src/harp.device.white-rabbit
url = https://github.com/AllenNeuralDynamics/harp.device.white-rabbit
[submodule "docs/harp_devices_src/harp.device.environment-sensor"]
path = docs/harp_devices_src/harp.device.environment-sensor
url = https://github.com/AllenNeuralDynamics/harp.device.environment-sensor
17 changes: 17 additions & 0 deletions docs/articles/environment-sensor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Environment Sensor
==========

The repository of this device can be found [here](https://github.com/AllenNeuralDynamics/harp.device.environment-sensor).

# Examples

It is advisable to first get familiar with the general Bonsai interface for Harp devices. This documentation can be found at [harp-tech.org](https://harp-tech.org/articles/intro.html).

## Parsing sensor data

Device sensor data can be parsed from the individual sensor registers ([`Pressure`, `Temperature`, `Humidity`]). For simplicity, a single register with a packed data structure is also provided. By default, this register will emit a period message with the data from all sensors. The following pattern can be used to parse the register:

:::workflow
![EnvironmentSensorDataParsing](~/workflows/EnvironmentSensorExample.bonsai)
:::

4 changes: 3 additions & 1 deletion docs/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
- name: Treadmill
href: treadmill.md
- name: AIND Manipulator
href: aind-manipulator.md
href: aind-manipulator.md
- name: EnvironmentSensor
href: environment-sensor.md
8 changes: 7 additions & 1 deletion docs/build.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Build device tables
$files = Get-ChildItem .\harp_devices_src\harp.device.*\software\bonsai\device.yml
$files_root = Get-ChildItem .\harp_devices_src\harp.device.*\device.yml
$files += $files_root

foreach ($file in $files)
{
Write-Output "Generating schema tables for $file..."
$readmePath = (get-item $file ).Directory.Parent.Parent.FullName + "\README.md"
$readmePath = (Get-Item $file).Directory.Parent.Parent.FullName + "\README.md"
if (-Not (Test-Path $readmePath)) {
$readmePath = (Get-Item $file).Directory.FullName + "\README.md"
}
$readmePath = ("." + (Resolve-Path -Relative $readmePath))
$readmePath = $readmePath.Replace("\", "/")
dotnet run --project .\harp_devices_src\harp.schemaprocessor $file .\harp_devices_spec $readmePath
Expand Down
4 changes: 3 additions & 1 deletion docs/harp_devices_spec/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
- name: WhiteRabbit
href: Harp_WhiteRabbit.md
- name: cuTTLefish
href: Harp_Cuttlefish.md
href: Harp_Cuttlefish.md
- name: EnvironmentSensor
href: Harp_EnvironmentSensor.md
1 change: 1 addition & 0 deletions docs/harp_devices_src/harp.device.environment-sensor
52 changes: 52 additions & 0 deletions docs/workflows/EnvironmentSensorExample.bonsai
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<WorkflowBuilder Version="2.8.5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core"
xmlns:harp="clr-namespace:Bonsai.Harp;assembly=Bonsai.Harp"
xmlns:p1="clr-namespace:AllenNeuralDynamics.EnvironmentSensor;assembly=AllenNeuralDynamics.EnvironmentSensor"
xmlns="https://bonsai-rx.org/2018/workflow">
<Workflow>
<Nodes>
<Expression xsi:type="rx:BehaviorSubject" TypeArguments="harp:HarpMessage">
<rx:Name>Commands</rx:Name>
</Expression>
<Expression xsi:type="Combinator">
<Combinator xsi:type="p1:Device">
<harp:OperationMode>Active</harp:OperationMode>
<harp:OperationLed>On</harp:OperationLed>
<harp:DumpRegisters>true</harp:DumpRegisters>
<harp:VisualIndicators>On</harp:VisualIndicators>
<harp:Heartbeat>Disabled</harp:Heartbeat>
<harp:IgnoreErrors>false</harp:IgnoreErrors>
<harp:PortName>COMx</harp:PortName>
</Combinator>
</Expression>
<Expression xsi:type="rx:PublishSubject">
<Name>Events</Name>
</Expression>
<Expression xsi:type="SubscribeSubject">
<Name>Events</Name>
</Expression>
<Expression xsi:type="p1:Parse">
<harp:Register xsi:type="p1:SensorData" />
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>Pressure</Selector>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>Temperature</Selector>
</Expression>
<Expression xsi:type="MemberSelector">
<Selector>Humidity</Selector>
</Expression>
</Nodes>
<Edges>
<Edge From="0" To="1" Label="Source1" />
<Edge From="1" To="2" Label="Source1" />
<Edge From="3" To="4" Label="Source1" />
<Edge From="4" To="5" Label="Source1" />
<Edge From="4" To="6" Label="Source1" />
<Edge From="4" To="7" Label="Source1" />
</Edges>
</Workflow>
</WorkflowBuilder>

0 comments on commit 5df2dbf

Please sign in to comment.