eclipse-sparkplug / sparkplug

Sparkplug
Eclipse Public License 2.0
109 stars 39 forks source link

Question: How to store value of type int (not uint) in metric property value #499

Closed SeppPenner closed 8 months ago

SeppPenner commented 8 months ago

What do you want to know?

The proto file looks like this:

message PropertyValue {
    optional uint32 type = 1;
    optional bool is_null = 2;
    oneof value {
        uint32 int_value = 3;
        uint64 long_value = 4;
        float float_value = 5;
        double double_value = 6;
        bool boolean_value = 7;
        string string_value = 8;
        PropertySet propertyset_value = 9;
        PropertySetList propertysets_value = 10; // List of Property Values
        PropertyValueExtension extension_value = 11;
    }
    message PropertyValueExtension {
        extensions 1 to max;
    }
}

How do we store a value of type int32 or int64 / long (Not uint32 or uint64 / ulong)? As float, double, string, extension? Seems all akwar to me...

Is this related to a Sparkplug Listing request? If so, link the issue from https://github.com/eclipse-sparkplug/sparkplug.listings here.

No response

Version

3.0.0 (Default)

Accept EFTL Terms

SeppPenner commented 8 months ago

Same for DateTime --> ValueType DateTime (13) is there, but should we store it as ulong?

bryce-nakatani commented 8 months ago

There are two layers, the protobuf implementation and the Sparkplug Metric.

The Sparkplug Metric encodes and decodes data to respective protobuf data types. To see this in implementation, take a look at SparkplugBPayloadEncoder.java "setMetricValue(SparkplugBProto.Payload.Metric.Builder metricBuilder,..." and SparkplugBPayloadDecoder.java "getMetricValue(SparkplugBProto.Payload.Metric protoMetric,...". You'll want to look a the "builders" that are invoked as well.

From there, you can see how the Sparkplug Metric types are converted to and from the protobuf layer.

On Thu, Dec 7, 2023 at 8:24 AM HansM @.***> wrote:

Same for DateTime --> ValueType DateTime (13) is there, but should we store it as ulong?

— Reply to this email directly, view it on GitHub https://github.com/eclipse-sparkplug/sparkplug/issues/499#issuecomment-1845647251, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEF6AZUIHUPAJHU6IB2XF6TYIHUSBAVCNFSM6AAAAABALKLEQCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBVGY2DOMRVGE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

SeppPenner commented 8 months ago

There are two layers, the protobuf implementation and the Sparkplug Metric. The Sparkplug Metric encodes and decodes data to respective protobuf data types. To see this in implementation, take a look at SparkplugBPayloadEncoder.java "setMetricValue(SparkplugBProto.Payload.Metric.Builder metricBuilder,..." and SparkplugBPayloadDecoder.java "getMetricValue(SparkplugBProto.Payload.Metric protoMetric,...". You'll want to look a the "builders" that are invoked as well. From there, you can see how the Sparkplug Metric types are converted to and from the protobuf layer. On Thu, Dec 7, 2023 at 8:24 AM HansM @.> wrote: Same for DateTime --> ValueType DateTime (13) is there, but should we store it as ulong? — Reply to this email directly, view it on GitHub <#499 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEF6AZUIHUPAJHU6IB2XF6TYIHUSBAVCNFSM6AAAAABALKLEQCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBVGY2DOMRVGE . You are receiving this because you are subscribed to this thread.Message ID: @.>

Alright, I will check that. Thank you for the quick reply.

SeppPenner commented 8 months ago

I guess, I can easily work with that. Thank you for the hints.