Skip to content

Commit 35bcd7c

Browse files
authored
Merge pull request #6 from harp-tech/feature-update-generators-to-include-metadata
Include device metadata file as embedded resource
2 parents 938ba3b + 62023c6 commit 35bcd7c

4 files changed

Lines changed: 223 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.LoadCells</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.LoadCells/Device.Generated.cs

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,18 @@ public Device() : base(WhoAmI) { }
4141
{ 33, typeof(LoadCellData) },
4242
{ 34, typeof(DigitalInputState) },
4343
{ 35, typeof(SyncOutputState) },
44+
{ 36, typeof(BufferThresholdState) },
45+
{ 37, typeof(Reserved0) },
46+
{ 38, typeof(Reserved1) },
4447
{ 39, typeof(DI0Trigger) },
4548
{ 40, typeof(DO0Sync) },
4649
{ 41, typeof(DO0PulseWidth) },
4750
{ 42, typeof(DigitalOutputSet) },
4851
{ 43, typeof(DigitalOutputClear) },
4952
{ 44, typeof(DigitalOutputToggle) },
5053
{ 45, typeof(DigitalOutputState) },
54+
{ 46, typeof(Reserved2) },
55+
{ 47, typeof(Reserved3) },
5156
{ 48, typeof(OffsetLoadCell0) },
5257
{ 49, typeof(OffsetLoadCell1) },
5358
{ 50, typeof(OffsetLoadCell2) },
@@ -56,6 +61,8 @@ public Device() : base(WhoAmI) { }
5661
{ 53, typeof(OffsetLoadCell5) },
5762
{ 54, typeof(OffsetLoadCell6) },
5863
{ 55, typeof(OffsetLoadCell7) },
64+
{ 56, typeof(Reserved4) },
65+
{ 57, typeof(Reserved5) },
5966
{ 58, typeof(DO1TargetLoadCell) },
6067
{ 59, typeof(DO2TargetLoadCell) },
6168
{ 60, typeof(DO3TargetLoadCell) },
@@ -90,6 +97,41 @@ public Device() : base(WhoAmI) { }
9097
{ 89, typeof(DO8TimeBelowThreshold) },
9198
{ 90, typeof(EnableEvents) }
9299
};
100+
101+
/// <summary>
102+
/// Gets the contents of the metadata file describing the <see cref="LoadCells"/>
103+
/// device registers.
104+
/// </summary>
105+
public static readonly string Metadata = GetDeviceMetadata();
106+
107+
static string GetDeviceMetadata()
108+
{
109+
var deviceType = typeof(Device);
110+
using var metadataStream = deviceType.Assembly.GetManifestResourceStream($"{deviceType.Namespace}.device.yml");
111+
using var streamReader = new System.IO.StreamReader(metadataStream);
112+
return streamReader.ReadToEnd();
113+
}
114+
}
115+
116+
/// <summary>
117+
/// Represents an operator that returns the contents of the metadata file
118+
/// describing the <see cref="LoadCells"/> device registers.
119+
/// </summary>
120+
[Description("Returns the contents of the metadata file describing the LoadCells device registers.")]
121+
public partial class GetMetadata : Source<string>
122+
{
123+
/// <summary>
124+
/// Returns an observable sequence with the contents of the metadata file
125+
/// describing the <see cref="LoadCells"/> device registers.
126+
/// </summary>
127+
/// <returns>
128+
/// A sequence with a single <see cref="string"/> object representing the
129+
/// contents of the metadata file.
130+
/// </returns>
131+
public override IObservable<string> Generate()
132+
{
133+
return Observable.Return(Device.Metadata);
134+
}
93135
}
94136

95137
/// <summary>
@@ -951,6 +993,72 @@ public static Timestamped<SyncOutputs> GetPayload(HarpMessage message)
951993
}
952994
}
953995

996+
/// <summary>
997+
/// Represents a register that state of the buffer thresholds.
998+
/// </summary>
999+
[Description("State of the buffer thresholds.")]
1000+
internal partial class BufferThresholdState
1001+
{
1002+
/// <summary>
1003+
/// Represents the address of the <see cref="BufferThresholdState"/> register. This field is constant.
1004+
/// </summary>
1005+
public const int Address = 36;
1006+
1007+
/// <summary>
1008+
/// Represents the payload type of the <see cref="BufferThresholdState"/> register. This field is constant.
1009+
/// </summary>
1010+
public const PayloadType RegisterType = PayloadType.U8;
1011+
1012+
/// <summary>
1013+
/// Represents the length of the <see cref="BufferThresholdState"/> register. This field is constant.
1014+
/// </summary>
1015+
public const int RegisterLength = 1;
1016+
}
1017+
1018+
/// <summary>
1019+
/// Represents a register that reserved.
1020+
/// </summary>
1021+
[Description("Reserved")]
1022+
internal partial class Reserved0
1023+
{
1024+
/// <summary>
1025+
/// Represents the address of the <see cref="Reserved0"/> register. This field is constant.
1026+
/// </summary>
1027+
public const int Address = 37;
1028+
1029+
/// <summary>
1030+
/// Represents the payload type of the <see cref="Reserved0"/> register. This field is constant.
1031+
/// </summary>
1032+
public const PayloadType RegisterType = PayloadType.U8;
1033+
1034+
/// <summary>
1035+
/// Represents the length of the <see cref="Reserved0"/> register. This field is constant.
1036+
/// </summary>
1037+
public const int RegisterLength = 1;
1038+
}
1039+
1040+
/// <summary>
1041+
/// Represents a register that reserved.
1042+
/// </summary>
1043+
[Description("Reserved")]
1044+
internal partial class Reserved1
1045+
{
1046+
/// <summary>
1047+
/// Represents the address of the <see cref="Reserved1"/> register. This field is constant.
1048+
/// </summary>
1049+
public const int Address = 38;
1050+
1051+
/// <summary>
1052+
/// Represents the payload type of the <see cref="Reserved1"/> register. This field is constant.
1053+
/// </summary>
1054+
public const PayloadType RegisterType = PayloadType.U8;
1055+
1056+
/// <summary>
1057+
/// Represents the length of the <see cref="Reserved1"/> register. This field is constant.
1058+
/// </summary>
1059+
public const int RegisterLength = 1;
1060+
}
1061+
9541062
/// <summary>
9551063
/// Represents a register that configuration of the digital input pin 0.
9561064
/// </summary>
@@ -1629,6 +1737,50 @@ public static Timestamped<DigitalOutputs> GetPayload(HarpMessage message)
16291737
}
16301738
}
16311739

1740+
/// <summary>
1741+
/// Represents a register that reserved.
1742+
/// </summary>
1743+
[Description("Reserved")]
1744+
internal partial class Reserved2
1745+
{
1746+
/// <summary>
1747+
/// Represents the address of the <see cref="Reserved2"/> register. This field is constant.
1748+
/// </summary>
1749+
public const int Address = 46;
1750+
1751+
/// <summary>
1752+
/// Represents the payload type of the <see cref="Reserved2"/> register. This field is constant.
1753+
/// </summary>
1754+
public const PayloadType RegisterType = PayloadType.U8;
1755+
1756+
/// <summary>
1757+
/// Represents the length of the <see cref="Reserved2"/> register. This field is constant.
1758+
/// </summary>
1759+
public const int RegisterLength = 1;
1760+
}
1761+
1762+
/// <summary>
1763+
/// Represents a register that reserved.
1764+
/// </summary>
1765+
[Description("Reserved")]
1766+
internal partial class Reserved3
1767+
{
1768+
/// <summary>
1769+
/// Represents the address of the <see cref="Reserved3"/> register. This field is constant.
1770+
/// </summary>
1771+
public const int Address = 47;
1772+
1773+
/// <summary>
1774+
/// Represents the payload type of the <see cref="Reserved3"/> register. This field is constant.
1775+
/// </summary>
1776+
public const PayloadType RegisterType = PayloadType.U8;
1777+
1778+
/// <summary>
1779+
/// Represents the length of the <see cref="Reserved3"/> register. This field is constant.
1780+
/// </summary>
1781+
public const int RegisterLength = 1;
1782+
}
1783+
16321784
/// <summary>
16331785
/// Represents a register that offset value for Load Cell channel 0.
16341786
/// </summary>
@@ -2397,6 +2549,50 @@ public static Timestamped<short> GetPayload(HarpMessage message)
23972549
}
23982550
}
23992551

2552+
/// <summary>
2553+
/// Represents a register that reserved.
2554+
/// </summary>
2555+
[Description("Reserved")]
2556+
internal partial class Reserved4
2557+
{
2558+
/// <summary>
2559+
/// Represents the address of the <see cref="Reserved4"/> register. This field is constant.
2560+
/// </summary>
2561+
public const int Address = 56;
2562+
2563+
/// <summary>
2564+
/// Represents the payload type of the <see cref="Reserved4"/> register. This field is constant.
2565+
/// </summary>
2566+
public const PayloadType RegisterType = PayloadType.U8;
2567+
2568+
/// <summary>
2569+
/// Represents the length of the <see cref="Reserved4"/> register. This field is constant.
2570+
/// </summary>
2571+
public const int RegisterLength = 1;
2572+
}
2573+
2574+
/// <summary>
2575+
/// Represents a register that reserved.
2576+
/// </summary>
2577+
[Description("Reserved")]
2578+
internal partial class Reserved5
2579+
{
2580+
/// <summary>
2581+
/// Represents the address of the <see cref="Reserved5"/> register. This field is constant.
2582+
/// </summary>
2583+
public const int Address = 57;
2584+
2585+
/// <summary>
2586+
/// Represents the payload type of the <see cref="Reserved5"/> register. This field is constant.
2587+
/// </summary>
2588+
public const PayloadType RegisterType = PayloadType.U8;
2589+
2590+
/// <summary>
2591+
/// Represents the length of the <see cref="Reserved5"/> register. This field is constant.
2592+
/// </summary>
2593+
public const int RegisterLength = 1;
2594+
}
2595+
24002596
/// <summary>
24012597
/// Represents a register that target Load Cell that will be used to trigger a threshold event on DO1 pin.
24022598
/// </summary>
@@ -8700,6 +8896,28 @@ public LoadCellDataPayload(
87008896
///
87018897
/// </summary>
87028898
public short Channel7;
8899+
8900+
/// <summary>
8901+
/// Returns a <see cref="string"/> that represents the payload of
8902+
/// the LoadCellData register.
8903+
/// </summary>
8904+
/// <returns>
8905+
/// A <see cref="string"/> that represents the payload of the
8906+
/// LoadCellData register.
8907+
/// </returns>
8908+
public override string ToString()
8909+
{
8910+
return "LoadCellDataPayload { " +
8911+
"Channel0 = " + Channel0 + ", " +
8912+
"Channel1 = " + Channel1 + ", " +
8913+
"Channel2 = " + Channel2 + ", " +
8914+
"Channel3 = " + Channel3 + ", " +
8915+
"Channel4 = " + Channel4 + ", " +
8916+
"Channel5 = " + Channel5 + ", " +
8917+
"Channel6 = " + Channel6 + ", " +
8918+
"Channel7 = " + Channel7 + " " +
8919+
"}";
8920+
}
87038921
}
87048922

87058923
/// <summary>

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

0 commit comments

Comments
 (0)