Skip to content

Commit 5a27f34

Browse files
authored
Merge pull request #8 from harp-tech/Feature-update-generators-to-include-metadata
Include device metadata file as embedded resource
2 parents 12d907c + 0f5097d commit 5a27f34

4 files changed

Lines changed: 111 additions & 3 deletions

File tree

Generators/Generators.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<FirmwarePath>..\Firmware\Harp.LedArray</FirmwarePath>
1616
</PropertyGroup>
1717
<ItemGroup>
18-
<PackageReference Include="Harp.Generators" Version="0.1.0" GeneratePathProperty="true" />
18+
<PackageReference Include="Harp.Generators" Version="0.3.0" GeneratePathProperty="true" />
1919
</ItemGroup>
2020
<Target Name="TextTransform" BeforeTargets="AfterBuild">
2121
<PropertyGroup>

Interface/Harp.LedArray/Device.Generated.cs

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,44 @@ public Device() : base(WhoAmI) { }
6969
{ 61, typeof(AuxDigitalOutputState) },
7070
{ 62, typeof(AuxLedPower) },
7171
{ 63, typeof(DigitalOutputState) },
72+
{ 64, typeof(Reserved0) },
7273
{ 65, typeof(EnableEvents) }
7374
};
75+
76+
/// <summary>
77+
/// Gets the contents of the metadata file describing the <see cref="LedArray"/>
78+
/// device registers.
79+
/// </summary>
80+
public static readonly string Metadata = GetDeviceMetadata();
81+
82+
static string GetDeviceMetadata()
83+
{
84+
var deviceType = typeof(Device);
85+
using var metadataStream = deviceType.Assembly.GetManifestResourceStream($"{deviceType.Namespace}.device.yml");
86+
using var streamReader = new System.IO.StreamReader(metadataStream);
87+
return streamReader.ReadToEnd();
88+
}
89+
}
90+
91+
/// <summary>
92+
/// Represents an operator that returns the contents of the metadata file
93+
/// describing the <see cref="LedArray"/> device registers.
94+
/// </summary>
95+
[Description("Returns the contents of the metadata file describing the LedArray device registers.")]
96+
public partial class GetMetadata : Source<string>
97+
{
98+
/// <summary>
99+
/// Returns an observable sequence with the contents of the metadata file
100+
/// describing the <see cref="LedArray"/> device registers.
101+
/// </summary>
102+
/// <returns>
103+
/// A sequence with a single <see cref="string"/> object representing the
104+
/// contents of the metadata file.
105+
/// </returns>
106+
public override IObservable<string> Generate()
107+
{
108+
return Observable.Return(Device.Metadata);
109+
}
74110
}
75111

76112
/// <summary>
@@ -3511,6 +3547,28 @@ public static Timestamped<DigitalOutputs> GetPayload(HarpMessage message)
35113547
}
35123548
}
35133549

3550+
/// <summary>
3551+
/// Represents a register that reserved for future use.
3552+
/// </summary>
3553+
[Description("Reserved for future use")]
3554+
internal partial class Reserved0
3555+
{
3556+
/// <summary>
3557+
/// Represents the address of the <see cref="Reserved0"/> register. This field is constant.
3558+
/// </summary>
3559+
public const int Address = 64;
3560+
3561+
/// <summary>
3562+
/// Represents the payload type of the <see cref="Reserved0"/> register. This field is constant.
3563+
/// </summary>
3564+
public const PayloadType RegisterType = PayloadType.U8;
3565+
3566+
/// <summary>
3567+
/// Represents the length of the <see cref="Reserved0"/> register. This field is constant.
3568+
/// </summary>
3569+
public const int RegisterLength = 1;
3570+
}
3571+
35143572
/// <summary>
35153573
/// Represents a register that specifies all the active events in the device.
35163574
/// </summary>
@@ -5599,6 +5657,22 @@ public DigitalOutputSyncPayload(
55995657
/// Configuration of the DO1 functionality.
56005658
/// </summary>
56015659
public DO1SyncConfig DO1Sync;
5660+
5661+
/// <summary>
5662+
/// Returns a <see cref="string"/> that represents the payload of
5663+
/// the DigitalOutputSync register.
5664+
/// </summary>
5665+
/// <returns>
5666+
/// A <see cref="string"/> that represents the payload of the
5667+
/// DigitalOutputSync register.
5668+
/// </returns>
5669+
public override string ToString()
5670+
{
5671+
return "DigitalOutputSyncPayload { " +
5672+
"DO0Sync = " + DO0Sync + ", " +
5673+
"DO1Sync = " + DO1Sync + " " +
5674+
"}";
5675+
}
56025676
}
56035677

56045678
/// <summary>
@@ -5628,6 +5702,22 @@ public DigitalInputTriggerPayload(
56285702
/// Configuration of the DI1 input pin.
56295703
/// </summary>
56305704
public DigitalInputTriggerConfig DI1Trigger;
5705+
5706+
/// <summary>
5707+
/// Returns a <see cref="string"/> that represents the payload of
5708+
/// the DigitalInputTrigger register.
5709+
/// </summary>
5710+
/// <returns>
5711+
/// A <see cref="string"/> that represents the payload of the
5712+
/// DigitalInputTrigger register.
5713+
/// </returns>
5714+
public override string ToString()
5715+
{
5716+
return "DigitalInputTriggerPayload { " +
5717+
"DI0Trigger = " + DI0Trigger + ", " +
5718+
"DI1Trigger = " + DI1Trigger + " " +
5719+
"}";
5720+
}
56315721
}
56325722

56335723
/// <summary>
@@ -5657,6 +5747,22 @@ public PulseModePayload(
56575747
/// Sets the pulse mode used in LED0
56585748
/// </summary>
56595749
public PulseModeConfig Led1Mode;
5750+
5751+
/// <summary>
5752+
/// Returns a <see cref="string"/> that represents the payload of
5753+
/// the PulseMode register.
5754+
/// </summary>
5755+
/// <returns>
5756+
/// A <see cref="string"/> that represents the payload of the
5757+
/// PulseMode register.
5758+
/// </returns>
5759+
public override string ToString()
5760+
{
5761+
return "PulseModePayload { " +
5762+
"Led0Mode = " + Led0Mode + ", " +
5763+
"Led1Mode = " + Led1Mode + " " +
5764+
"}";
5765+
}
56605766
}
56615767

56625768
/// <summary>

Interface/Harp.LedArray/Harp.LedArray.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<GeneratePackageOnBuild Condition="'$(Configuration)'=='Release'">true</GeneratePackageOnBuild>
1010
<Description>Bonsai Library containing interfaces for data acquisition and control of Harp LedArray devices.</Description>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
12+
<PackageType>Dependency;BonsaiLibrary</PackageType>
1213
<PackageTags>Harp LedArray Bonsai Rx</PackageTags>
1314
<PackageProjectUrl>https://harp-tech.org</PackageProjectUrl>
1415
<RepositoryUrl>https://github.com/harp-tech/device.ledarray.git</RepositoryUrl>
@@ -17,7 +18,7 @@
1718
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1819
<PackageOutputPath>..\bin\$(Configuration)</PackageOutputPath>
1920
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
20-
<VersionPrefix>0.1.0</VersionPrefix>
21+
<VersionPrefix>0.2.0</VersionPrefix>
2122
<VersionSuffix></VersionSuffix>
2223
<LangVersion>9.0</LangVersion>
2324
</PropertyGroup>
@@ -29,6 +30,7 @@
2930
<ItemGroup>
3031
<Content Include="..\LICENSE" PackagePath="/" />
3132
<Content Include="..\icon.png" PackagePath="/" />
33+
<EmbeddedResource Include="..\..\device.yml" />
3234
</ItemGroup>
3335

3436
</Project>

device.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%YAML 1.1
22
---
3-
# yaml-language-server: $schema=https://raw.githubusercontent.com/harp-tech/reflex-generator/main/schema/device.json
3+
# yaml-language-server: $schema=https://harp-tech.org/draft-02/schema/device.json
44
device: LedArray
55
whoAmI: 1088
66
firmwareVersion: "2.4"

0 commit comments

Comments
 (0)