Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(veristand-zeromq-bridge): rename alias to channel #20604

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ await Console.Out.WriteLineAsync(
var producerTasks = new List<Task>();
for (int i = 0; i < NUM_PRODUCERS; i++)
{
producerTasks.Add(Task.Run(() => ProducerTask(workspace, aliases)));
producerTasks.Add(Task.Run(() => ProducerTask(workspace, channels)));
}

// Consumer task
Expand Down Expand Up @@ -97,13 +97,13 @@ await Console.Out.WriteLineAsync(

var channelValues = string.Join(
" | ",
channels.Zip(currentValues, (alias, value) => $"{alias}:{value:F2}")
channels.Zip(currentValues, (name, value) => $"{name}:{value:F2}")
);

Console.WriteLine(
$"[Update] Speed: {messagesPerSecond:F2} msg/s | Total: {messageCount:N0}"
);
Console.WriteLine($"[Update] Values: {channelValues}");
// Console.WriteLine($"[Update] Values: {channelValues}");
}

// Cleanup
Expand All @@ -125,21 +125,21 @@ await Console.Out.WriteLineAsync(
}
}

private static async Task ProducerTask(IWorkspace2 workspace, string[] aliases)
private static async Task ProducerTask(IWorkspace2 workspace, string[] channels)
{
double[] values = new double[aliases.Length];
double[] values = new double[channels.Length];

while (isRunning)
{
workspace.GetMultipleChannelValues(aliases, out values);
workspace.GetMultipleChannelValues(channels, out values);
var signals = new Signals
{
Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
Signals_ =
{
aliases.Zip(
channels.Zip(
values,
(alias, value) => new Signal { Alias = alias, Value = value }
(name, value) => new Signal { Name = name, Value = value }
),
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
syntax = "proto3";

package production.iot;
option csharp_namespace = "VeriStandZeroMQBridge";

message Signals {
Expand All @@ -8,6 +9,6 @@ message Signals {
}

message Signal {
string alias = 1;
string name = 1;
double value = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\signals.proto" />
<Protobuf Include="Protos\production.iot.signals.proto" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AsyncIO" Version="0.1.69" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ message Signals {
}

message Signal {
string alias = 1;
string name = 1;
double value = 2;
}
Loading