Skip to content

Commit f0d6586

Browse files
authored
Merge pull request #10 from harp-tech/feature-update-generators-to-include-metadata
Include device metadata file as embedded resource
2 parents 19993ef + d103784 commit f0d6586

File tree

4 files changed

+132
-3
lines changed

4 files changed

+132
-3
lines changed

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.Synchronizer</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.Synchronizer/Device.Generated.cs

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,47 @@ public Device() : base(WhoAmI) { }
4141
{ 33, typeof(DigitalOutputState) },
4242
{ 34, typeof(DigitalInputsSamplingMode) },
4343
{ 35, typeof(DO0Config) },
44+
{ 36, typeof(Reserved0) },
45+
{ 37, typeof(Reserved1) },
46+
{ 38, typeof(Reserved2) },
47+
{ 39, typeof(Reserved3) },
4448
{ 40, typeof(EnableEvents) }
4549
};
50+
51+
/// <summary>
52+
/// Gets the contents of the metadata file describing the <see cref="Synchronizer"/>
53+
/// device registers.
54+
/// </summary>
55+
public static readonly string Metadata = GetDeviceMetadata();
56+
57+
static string GetDeviceMetadata()
58+
{
59+
var deviceType = typeof(Device);
60+
using var metadataStream = deviceType.Assembly.GetManifestResourceStream($"{deviceType.Namespace}.device.yml");
61+
using var streamReader = new System.IO.StreamReader(metadataStream);
62+
return streamReader.ReadToEnd();
63+
}
64+
}
65+
66+
/// <summary>
67+
/// Represents an operator that returns the contents of the metadata file
68+
/// describing the <see cref="Synchronizer"/> device registers.
69+
/// </summary>
70+
[Description("Returns the contents of the metadata file describing the Synchronizer device registers.")]
71+
public partial class GetMetadata : Source<string>
72+
{
73+
/// <summary>
74+
/// Returns an observable sequence with the contents of the metadata file
75+
/// describing the <see cref="Synchronizer"/> device registers.
76+
/// </summary>
77+
/// <returns>
78+
/// A sequence with a single <see cref="string"/> object representing the
79+
/// contents of the metadata file.
80+
/// </returns>
81+
public override IObservable<string> Generate()
82+
{
83+
return Observable.Return(Device.Metadata);
84+
}
4685
}
4786

4887
/// <summary>
@@ -546,6 +585,94 @@ public static Timestamped<DO0ConfigMode> GetPayload(HarpMessage message)
546585
}
547586
}
548587

588+
/// <summary>
589+
/// Represents a register that reserved for future use.
590+
/// </summary>
591+
[Description("Reserved for future use.")]
592+
internal partial class Reserved0
593+
{
594+
/// <summary>
595+
/// Represents the address of the <see cref="Reserved0"/> register. This field is constant.
596+
/// </summary>
597+
public const int Address = 36;
598+
599+
/// <summary>
600+
/// Represents the payload type of the <see cref="Reserved0"/> register. This field is constant.
601+
/// </summary>
602+
public const PayloadType RegisterType = PayloadType.U8;
603+
604+
/// <summary>
605+
/// Represents the length of the <see cref="Reserved0"/> register. This field is constant.
606+
/// </summary>
607+
public const int RegisterLength = 1;
608+
}
609+
610+
/// <summary>
611+
/// Represents a register that reserved for future use.
612+
/// </summary>
613+
[Description("Reserved for future use.")]
614+
internal partial class Reserved1
615+
{
616+
/// <summary>
617+
/// Represents the address of the <see cref="Reserved1"/> register. This field is constant.
618+
/// </summary>
619+
public const int Address = 37;
620+
621+
/// <summary>
622+
/// Represents the payload type of the <see cref="Reserved1"/> register. This field is constant.
623+
/// </summary>
624+
public const PayloadType RegisterType = PayloadType.U8;
625+
626+
/// <summary>
627+
/// Represents the length of the <see cref="Reserved1"/> register. This field is constant.
628+
/// </summary>
629+
public const int RegisterLength = 1;
630+
}
631+
632+
/// <summary>
633+
/// Represents a register that reserved for future use.
634+
/// </summary>
635+
[Description("Reserved for future use.")]
636+
internal partial class Reserved2
637+
{
638+
/// <summary>
639+
/// Represents the address of the <see cref="Reserved2"/> register. This field is constant.
640+
/// </summary>
641+
public const int Address = 38;
642+
643+
/// <summary>
644+
/// Represents the payload type of the <see cref="Reserved2"/> register. This field is constant.
645+
/// </summary>
646+
public const PayloadType RegisterType = PayloadType.U8;
647+
648+
/// <summary>
649+
/// Represents the length of the <see cref="Reserved2"/> register. This field is constant.
650+
/// </summary>
651+
public const int RegisterLength = 1;
652+
}
653+
654+
/// <summary>
655+
/// Represents a register that reserved for future use.
656+
/// </summary>
657+
[Description("Reserved for future use.")]
658+
internal partial class Reserved3
659+
{
660+
/// <summary>
661+
/// Represents the address of the <see cref="Reserved3"/> register. This field is constant.
662+
/// </summary>
663+
public const int Address = 39;
664+
665+
/// <summary>
666+
/// Represents the payload type of the <see cref="Reserved3"/> register. This field is constant.
667+
/// </summary>
668+
public const PayloadType RegisterType = PayloadType.U8;
669+
670+
/// <summary>
671+
/// Represents the length of the <see cref="Reserved3"/> register. This field is constant.
672+
/// </summary>
673+
public const int RegisterLength = 1;
674+
}
675+
549676
/// <summary>
550677
/// Represents a register that specifies all the active events in the device.
551678
/// </summary>

Interface/Harp.Synchronizer/Harp.Synchronizer.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 Synchronizer devices.</Description>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
12+
<PackageType>Dependency;BonsaiLibrary</PackageType>
1213
<PackageTags>Harp Synchronizer Bonsai Rx</PackageTags>
1314
<PackageProjectUrl>https://harp-tech.org</PackageProjectUrl>
1415
<RepositoryUrl>https://github.com/harp-tech/device.synchronizer.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: Synchronizer
55
whoAmI: 1104
66
firmwareVersion: "1.7"

0 commit comments

Comments
 (0)