digitaltwinconsortium / DTDLParser

Digital Twin Definition Language parser for .NET
MIT License
14 stars 8 forks source link

Fetch Units Information #92

Closed chandra-rayaprol closed 1 year ago

chandra-rayaprol commented 1 year ago

Could you please advise on how to fetch Units" for all defined Unit Semantic types (Acceleration , Angle, AngularAcceleration....)? I'm trying to access metadata defined in supplemental types, but I can't find any method or property to retrieve the "Unit" types. For instance, defined unit types for 'AccelerationUnit' are

` { ModelParser modelParser = new(); var supp = modelParser.GetSupplementalTypes(); foreach (var sup in supp) { Console.WriteLine($"{sup.Key} --> {sup.Value.Type}"); foreach (var prop in sup.Value.Properties) { Console.WriteLine($"{prop.Key} --> {prop.Value?.Type}"); } Console.WriteLine();

    }
}`
chandra-rayaprol commented 1 year ago

Hi Rido,

Thank your for your response.

I'd like to use the DTDL parser library to read the metadata, such as units, without parsing any dtdl file. For your convenience, I've uploaded the github C# console application 'https://github.com/Raysapps/UnitsSample.git.' This sample does not rely on DTDLParser and simply reads the units information defined in the 'DtdlUnits.json' file and displays on the console window. The json file contains content copied from the Github repo file "https://github.com/digitaltwinconsortium/DTDLParser/blob/687b88c7e4268921d16dc77268982dc60cdd4cbd/dtdl/dtdl digest.json".

I'd like to accomplish the same thing with the DTDLParser. Unfortunately, I couldn't find this information. Would it be possible for you be able to expose an API for reading unit meta data? When parsing the data from the actual dtdl file, my intention is to map units information read, to custom data such as Icon.logo and unit symbols, etc. to display to the UI.I hope I've provided you with all of the necessary information.

Best Regards, Chandra Mohan

Sent from Outlookhttp://aka.ms/weboutlook


From: Rido @.> Sent: Friday, 10 March 2023 4:06 PM To: digitaltwinconsortium/DTDLParser @.> Cc: Chandra Mohan Rayaprol @.>; Author @.> Subject: Re: [digitaltwinconsortium/DTDLParser] Fetch Units Information (Issue #92)

there are different APIs for v2 or v3 models, this sample will give you some hints.

https://github.com/digitaltwinconsortium/DTDLParser/blob/687b88c7e4268921d16dc77268982dc60cdd4cbd/samples/DTDLParserResolveSample/DTInfoExtensions.cs#L118-L135

can you share the model and what would be your intended output?

— Reply to this email directly, view it on GitHubhttps://github.com/digitaltwinconsortium/DTDLParser/issues/92#issuecomment-1463281494, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AK2NZABJDUVYOSRSQ6UEPJDW3KZE3ANCNFSM6AAAAAAVVYPS7Q. You are receiving this because you authored the thread.Message ID: @.***>

jrdouceur commented 1 year ago

Added issue #93 proposing feature ModelParser.GetImplicitElements() method.

rido-min commented 1 year ago

reopening until we resolve #93

jrdouceur commented 1 year ago

@Raysapps, until we have a fuller solution, we have added rudimentary support for this request that is explained in Tutorial12#inspect-available-unit-values and Tutorial13#inspect-available-unit-values.

jrdouceur commented 1 year ago

This new feature is not yet in the release NuGet feed, but you can get it from the prerelease NuGet feed. If you find this new API sufficient to unblock you, please close this issue accordingly.

chandra-rayaprol commented 1 year ago

Thank you for the new API's introduced to fetch units from the ModelParser. This feature is sufficient for getting all supported unit values. This issue has been resolved and closing now. Best Regards, Chandra Mohan