-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathSammClasses.cs
2069 lines (1819 loc) · 68.6 KB
/
SammClasses.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (c) 2018-2023 Festo SE & Co. KG <https://www.festo.com/net/de_de/Forms/web/contact_international>
Author: Michael Hoffmeister
This source code is licensed under the Apache License 2.0 (see LICENSE.txt).
This source code may use other Open Source software components (see LICENSE.txt).
*/
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.Metrics;
using System.Drawing;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.PortableExecutable;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using AasCore.Aas3_0;
using AdminShellNS;
using Extensions;
using Microsoft.VisualBasic;
using Newtonsoft.Json;
using Aas = AasCore.Aas3_0;
// Note: Nice regex for searching prefix in .ttl files:
// @prefix\s+([^:]*)\:\s+<([^>]+)>.
namespace AasCore.Samm2_2_0
{
/// <summary>
/// LangString similar to AasCore
/// </summary>
public class LangString
{
/// <summary>
/// Language, lower case code, accoding to BCP 47 or ISO 639-1
/// </summary>
public string? Language { get; set; }
/// <summary>
/// Text in this language.
/// </summary>
public string? Text { get; set; }
public LangString() { }
public LangString(string language, string text)
{
Language = language;
Text = text;
}
public LangString(Aas.ILangStringTextType ls)
{
Language = ls.Language;
Text = ls.Text;
}
}
/// <summary>
/// This attribute gives a list of given presets to an field or property.
/// in order to avoid cycles
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = true)]
public class SammPresetListAttribute : System.Attribute
{
public string PresetListName = "";
public SammPresetListAttribute(string presetListName)
{
if (presetListName != null)
PresetListName = presetListName;
}
}
/// <summary>
/// This attribute marks a string field/ property as multiline.
/// in order to avoid cycles
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property)]
public class SammMultiLineAttribute : System.Attribute
{
public int? MaxLines = null;
public SammMultiLineAttribute(int maxLines = -1)
{
if (maxLines > 0)
MaxLines = maxLines;
}
}
/// <summary>
/// This attribute identifies the uri of a single property within a class.
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = true)]
public class SammPropertyUriAttribute : System.Attribute
{
public string Uri = "";
public SammVersion Version = SammVersion.V_1_0_0;
public SammPropertyUriAttribute(string uri, SammVersion version)
{
Uri = uri;
Version = version;
}
}
/// <summary>
/// If a RDF collection is parsed, this attribute identifies the uri of
/// the relationship pointing to the content node.
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = true)]
public class SammCollectionContentUriAttribute : System.Attribute
{
public string Uri = "";
public SammVersion Version = SammVersion.V_1_0_0;
public SammCollectionContentUriAttribute(string uri, SammVersion version)
{
Uri = uri;
Version = version;
}
}
/// <summary>
/// Some string based flags to attach to the property
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = true)]
public class SammPropertyFlagsAttribute : System.Attribute
{
public string Flags = "";
public SammPropertyFlagsAttribute(string flags)
{
Flags = flags;
}
}
/// <summary>
/// Enum string representation need a namespace prefix to be serialized to Turtle
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = true)]
public class SammPropertyPrefixAttribute : System.Attribute
{
public string Prefix = "";
public SammVersion Version = SammVersion.V_1_0_0;
public SammPropertyPrefixAttribute(string prefix, SammVersion version)
{
Prefix = prefix;
Version = version;
}
}
/// <summary>
/// Shall be implemented by all non-abstract model elements
/// </summary>
public interface ISammSelfDescription
{
/// <summary>
/// get short name, which can als be used to distinguish elements.
/// Exmaple: samm-x
/// </summary>
string GetSelfName();
/// <summary>
/// Get URN of this element class.
/// </summary>
string GetSelfUrn(SammVersion version);
}
/// <summary>
/// Shall be implemented in order to give hints about the
/// (hierarchical) structuring of elements
/// </summary>
public interface ISammStructureModel
{
/// <summary>
/// True, if a top element of a hierarchy
/// </summary>
bool IsTopElement();
/// <summary>
/// Iterate over all the SAMM elements referenced from this instance
/// without further recursion (see AasCore).
/// </summary>
IEnumerable<SammReference> DescendOnce();
}
/// <summary>
/// SAMM model element; base clase
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/modeling-guidelines.html#attributes-that-all-model-elements-have"/>
/// </summary>
public class ModelElement
{
// Note:
// The SAMM meta model details, that every element has a name.
// For AAS, the name is given by the Id of the ConceptDescription
/// <summary>
/// Human readable name in a specific language. This attribute may be defined multiple
/// times for different languages but only once for a specific language. There should
/// be at least one preferredName defined with an "en" language tag.
/// </summary>
[SammPropertyUri("bamm:preferredName", SammVersion.V_1_0_0)]
[SammPropertyUri("samm:preferredName", SammVersion.V_2_0_0)]
[SammPropertyUri("samm:preferredName", SammVersion.V_2_1_0)]
public List<LangString>? PreferredName { get; set; } = null;
// Note: Description is already in the Referable
///// <summary>
///// Human readable description in a specific language. This attribute may be defined multiple
///// times for different languages but only once for a specific language. There should be at
///// least one description defined with an "en" language tag.
///// </summary>
//[SammPropertyUri("bamm:description")]
//public List<LangString>? Description { get; set; } = null;
/// <summary>
/// A reference to a related element in an external taxonomy, ontology or other standards document.
/// The datatype is xsd:anyURI. This attribute may be defined multiple times.
/// </summary>
[SammPropertyUri("bamm:see", SammVersion.V_1_0_0)]
[SammPropertyUri("samm:see", SammVersion.V_2_0_0)]
[SammPropertyUri("samm:see", SammVersion.V_2_1_0)]
[SammPropertyFlags("anyuri")]
public List<string>? See { get; set; } = null;
}
/// <summary>
/// The system of types used in the Semantic Aspect Meta Model (and subsequently in the models conforming
/// to the Semantic Aspect Meta Model) is largely based on a subset of the XML Schema Definition 1.1
/// (XSD, [xmlschema11-2]), including the types such as data ranges. In addition to types from XSD, the
/// type langString is included as described in the RDF [rdf11] specification; it is used to represent
/// strings with an explicit language tag. Using these types allows for example the distinction between
/// a plain string and a dateTime string, unlike in JSON. The JSON data of a Property with a certain
/// type uses the most convenient corresponding JSON type, i.e. booleans for XSD boolean, number for
/// all numeric types, JSON object for Entities and string for everying else.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/datatypes.html#type-hierarchy"/>
/// </summary>
public enum SammDataType
{
[EnumMember(Value = "xsd:anyURI")]
AnyUri,
[EnumMember(Value = "xsd:base64Binary")]
Base64Binary,
[EnumMember(Value = "xsd:boolean")]
Boolean,
[EnumMember(Value = "xsd:byte")]
Byte,
[EnumMember(Value = "xsd:date")]
Date,
[EnumMember(Value = "xsd:dateTime")]
DateTime,
[EnumMember(Value = "xsd:decimal")]
Decimal,
[EnumMember(Value = "xsd:double")]
Double,
[EnumMember(Value = "xsd:duration")]
Duration,
[EnumMember(Value = "xsd:float")]
Float,
[EnumMember(Value = "xsd:gDay")]
GDay,
[EnumMember(Value = "xsd:gMonth")]
GMonth,
[EnumMember(Value = "xsd:gMonthDay")]
GMonthDay,
[EnumMember(Value = "xsd:gYear")]
GYear,
[EnumMember(Value = "xsd:gYearMonth")]
GYearMonth,
[EnumMember(Value = "xsd:hexBinary")]
HexBinary,
[EnumMember(Value = "xsd:int")]
Int,
[EnumMember(Value = "xsd:integer")]
Integer,
[EnumMember(Value = "xsd:long")]
Long,
[EnumMember(Value = "xsd:negativeInteger")]
NegativeInteger,
[EnumMember(Value = "xsd:nonNegativeInteger")]
NonNegativeInteger,
[EnumMember(Value = "xsd:nonPositiveInteger")]
NonPositiveInteger,
[EnumMember(Value = "xsd:positiveInteger")]
PositiveInteger,
[EnumMember(Value = "xsd:short")]
Short,
[EnumMember(Value = "xsd:string")]
String,
[EnumMember(Value = "xsd:time")]
Time,
[EnumMember(Value = "xsd:unsignedByte")]
UnsignedByte,
[EnumMember(Value = "xsd:unsignedInt")]
UnsignedInt,
[EnumMember(Value = "xsd:unsignedLong")]
UnsignedLong,
[EnumMember(Value = "xsd:unsignedShort")]
UnsignedShort,
[EnumMember(Value = "langString")]
LangString
}
/// <summary>
/// The AT_LEAST and AT_MOST values for lowerBoundDefinition and upperBoundDefinition define that the
/// values for minValue and maxValue are inclusive. The LESS_THAN and GREATER_THAN values for the
/// lowerBoundDefinition and upperBoundDefinition define that the values for minValue and maxValue are exclusive.
/// </summary>
public enum SammUpperBoundDefinition
{
[EnumMember(Value = "AT_MOST")]
AtMost,
[EnumMember(Value = "LESS_THAN")]
LessThan
}
/// <summary>
/// The AT_LEAST and AT_MOST values for lowerBoundDefinition and upperBoundDefinition define that the
/// values for minValue and maxValue are inclusive. The LESS_THAN and GREATER_THAN values for the
/// lowerBoundDefinition and upperBoundDefinition define that the values for minValue and maxValue are exclusive.
/// </summary>
public enum SammLowerBoundDefinition
{
[EnumMember(Value = "AT_LEAST")]
AtLeast,
[EnumMember(Value = "GREATER_THAN")]
GreaterThan
}
/// <summary>
/// Allowed encodings for byte streams
/// </summary>
public enum SammEncoding
{
[EnumMember(Value = "US-ASCII")]
UsAscii,
[EnumMember(Value = "ISO-8859-1")]
Iso8859_1,
[EnumMember(Value = "UTF-8")]
Utf8,
[EnumMember(Value = "UTF-16")]
Utf16,
[EnumMember(Value = "UTF-16BE")]
Utf16BE,
[EnumMember(Value = "UTF-16LE")]
Utf16LE
}
/// <summary>
/// This class creates a <c>SammReference</c>, which "feels" like a string.
/// </summary>
public class SammReference
{
public string Value { get; set; }
public SammReference(string val = "")
{
Value = val;
}
}
/// <summary>
/// When Properties are used in Aspects and Entities, they can be marked as optional
/// (not possible for properties of Abstract Entities).
/// This means that a Property’s usage is optional, not the Property itself, which
/// would make reusing a Property more difficult.
/// </summary>
public class OptionalSammReference : SammReference
{
public bool Optional { get; set; } = false;
public OptionalSammReference(string val = "", bool optional = false)
{
Value = val;
Optional = optional;
}
}
/// <summary>
/// Single item for <c>NamespaceMap</c>.
/// </summary>
public class NamespaceMapItem
{
/// <summary>
/// Prefix of a namespace.
/// Format: short sequence of chars. ALWAYS trailing colon (:).
/// </summary>
public string Prefix { get; set; } = "";
/// <summary>
/// Absolute URI to replace a prefix.
/// </summary>
public string Uri { get; set; } = "";
public NamespaceMapItem() { }
public NamespaceMapItem(string prefix, string uri)
{
Prefix = prefix;
Uri = uri;
}
}
/// <summary>
/// This (proprietary) map links prefixes and uris together.
/// Intended use case is to be embedded into the SAMM aspect
/// and help resolving complete URIs.
/// </summary>
public class NamespaceMap
{
/// <summary>
/// Container of map items.
/// </summary>
[JsonIgnore]
public Dictionary<string, NamespaceMapItem> Map { get; set; } =
new Dictionary<string, NamespaceMapItem>();
// For JSON
public NamespaceMapItem[] Items
{
get => Map.Keys.Select(k => Map[k]).ToArray();
set {
Map.Clear();
foreach (var v in value)
AddOrIgnore(v.Prefix, v.Uri);
}
}
public int Count() => Map.Count();
public NamespaceMapItem this[int index] => Map[Map.Keys.ElementAt(index)];
public void RemoveAt(int index) => Map.Remove(Map.Keys.ElementAt(index));
public bool AddOrIgnore(string prefix, string uri)
{
if (prefix == null || uri == null)
return false;
prefix = prefix.Trim();
if (!prefix.EndsWith(':'))
return false;
if (Map.ContainsKey(prefix))
return false;
Map[prefix] = new NamespaceMapItem(prefix, uri);
return true;
}
public string? ExtendUri(string input)
{
if (input == null)
return null;
var p = input.IndexOf(':');
if (p < 0)
return input;
var ask = input.Substring(0, p) + ':';
if (!Map.ContainsKey(ask) || (p+1) > input.Length)
return input;
var res = Map[ask].Uri + input.Substring(p + 1);
return res;
}
public string? PrefixUri(string input)
{
// access
if (input == null)
return null;
// tedious searching
foreach (var mi in Map.Values)
if (input.StartsWith(mi.Uri))
{
var pf = mi.Prefix;
return pf + input.Substring(mi.Uri.Length);
}
// not found .. give whole back
return input;
}
public bool ContainsPrefix(string prefix) => Map.ContainsKey(prefix);
public NamespaceMapItem GetFromPrefix(string prefix) => Map[prefix];
}
/// <summary>
/// Base class for other constraints that constrain a Characteristic in some way, e.g., the Range Constraint
/// limits the value range for a Property.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#constraint"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#Constraint"/>
/// </summary>
public class Constraint : ModelElement, ISammSelfDescription
{
// self description
public string GetSelfName() => "samm-constraint";
public string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:Constraint" : "samm-c:Constraint";
}
/// <summary>
/// Restricts a value to a specific language.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#language-constraint"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#LanguageConstraint"/>
/// </summary>
public class LanguageConstraint : Constraint, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-language-constraint";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:LanguageConstraint" : "samm-c:LanguageConstraint";
/// <summary>
/// An ISO 639-1 [iso639] language code for the language of the value of the constrained Property,
/// e.g., "de".
/// </summary>
[SammPropertyUri("bamm-c:languageCode", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:languageCode", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:languageCode", SammVersion.V_2_1_0)]
public string? LanguageCode { get; set; }
}
/// <summary>
/// Restricts a value to a specific locale, i.e., a language with additional region information.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#locale-constraint"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#LocaleConstraint"/>
/// </summary>
public class LocaleConstraint : Constraint, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-locale-constraint";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:LocaleConstraint" : "samm-c:LocaleConstraint";
/// <summary>
/// An IETF BCP 47 language code for the locale of the value of the constrained Property, e.g., "de-DE".
/// </summary>
[SammPropertyUri("bamm-c:localeCode", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:localeCode", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:localeCode", SammVersion.V_2_1_0)]
public string? LocaleCode { get; set; }
}
/// <summary>
/// Restricts the value range of a Property. At least one of <c>maxValue</c> or <c>minValue</c> must be present in a
/// Range Constraint.
/// </summary>
public class RangeConstraint : Constraint, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-range-constraint";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:RangeConstraint" : "samm-c:RangeConstraint";
/// <summary>
/// The upper bound of a range.
/// </summary>
[SammPropertyUri("bamm-c:maxValue", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:maxValue", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:maxValue", SammVersion.V_2_1_0)]
public string? MaxValue { get; set; }
/// <summary>
/// The lower bound of a range.
/// </summary>
[SammPropertyUri("bamm-c:minValue", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:minValue", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:minValue", SammVersion.V_2_1_0)]
public string? MinValue { get; set; }
/// <summary>
/// Defines whether the upper bound of a range is inclusive or exclusive. Possible values are
/// <c>AT_MOST</c> and <c>LESS_THAN</c>.
/// </summary>
[SammPropertyUri("bamm-c:upperBoundDefinition", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:upperBoundDefinition", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:upperBoundDefinition", SammVersion.V_2_1_0)]
[SammPropertyPrefix("bamm-c:", SammVersion.V_1_0_0)]
[SammPropertyPrefix("samm-c:", SammVersion.V_2_0_0)]
[SammPropertyPrefix("samm-c:", SammVersion.V_2_1_0)]
public SammUpperBoundDefinition? UpperBoundDefinition { get; set; }
/// <summary>
/// Defines whether the lower bound of a range is inclusive or exclusive. Possible values are
/// <c>AT_LEAST</c> and <c>GREATER_THAN</c>.
/// </summary>
[SammPropertyUri("bamm-c:lowerBoundDefinition", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:lowerBoundDefinition", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:lowerBoundDefinition", SammVersion.V_2_1_0)]
[SammPropertyPrefix("bamm-c:", SammVersion.V_1_0_0)]
[SammPropertyPrefix("samm-c:", SammVersion.V_2_0_0)]
[SammPropertyPrefix("samm-c:", SammVersion.V_2_1_0)]
public SammLowerBoundDefinition? LowerBoundDefinition { get; set; }
}
/// <summary>
/// Restricts the encoding of a Property.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#encoding-constraint"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#EncodingConstraint"/>
/// </summary>
public class EncodingConstraint : Constraint, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-encoding-constraint";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:EncodingConstraint" : "samm-c:EncodingConstraint";
/// <summary>
/// Configures the encoding. This must be one of the following:
/// <c>US-ASCII</c>, <c>ISO-8859-1</c>, <c>UTF-8</c>, <c>UTF-16</c>, <c>UTF-16BE</c> or <c>UTF-16LE</c>.
/// </summary>
[SammPropertyUri("bamm-c:value", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:value", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:value", SammVersion.V_2_1_0)]
[SammPropertyPrefix("bamm-c:", SammVersion.V_1_0_0)]
[SammPropertyPrefix("samm-c:", SammVersion.V_2_0_0)]
[SammPropertyPrefix("samm-c:", SammVersion.V_2_1_0)]
public SammEncoding? Value { get; set; }
}
/// <summary>
/// This Constraint can be used to restrict two types of Characteristics:
/// Characteristics that have a string-like value space; in this case the Constraint restricts the length of the
/// (string-) value.
/// Collection Characteristics (Collection, Set, Sorted Set, List). In this case the Constraint restricts the
/// number of elements in the collection.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#length-constraint"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#LengthConstraint"/>
/// </summary>
public class LengthConstraint : Constraint, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-length-constraint";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:LengthConstraint" : "samm-c:LengthConstraint";
/// <summary>
/// The maximum length. Must be given as xsd:nonNegativeInteger.
/// </summary>
[SammPropertyUri("bamm-c:maxValue", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:maxValue", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:maxValue", SammVersion.V_2_1_0)]
public uint? MaxValue { get; set; }
/// <summary>
/// The minimum length. Must be given as xsd:nonNegativeInteger.
/// </summary>
[SammPropertyUri("bamm-c:minValue", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:minValue", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:minValue", SammVersion.V_2_1_0)]
public uint? MinValue { get; set; }
}
/// <summary>
/// Restricts a string value to a regular expression as defined by XQuery 1.0 and XPath 2.0 Functions
/// and Operators [xpath-functions].
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#regular-expression-constraint"/>
/// <see href="https://www.w3.org/TR/xpath-functions-3/#regex-syntax"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#RegularExpressionConstraint"/>
/// </summary>
public class RegularExpressionConstraint : Constraint, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-regular-expression-constraint";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:RegularExpressionConstraint" : "samm-c:RegularExpressionConstraint";
/// <summary>
/// The regular expression.
/// <see href="https://www.w3.org/TR/xpath-functions-3/#regex-syntax"/>
/// </summary>
[SammPropertyUri("bamm:value", SammVersion.V_1_0_0)]
[SammPropertyUri("samm:value", SammVersion.V_2_0_0)]
[SammPropertyUri("samm:value", SammVersion.V_2_1_0)]
public string? Value { get; set; }
}
/// <summary>
/// Defines the scaling factor as well as the amount of integral numbers for a fixed point number.
/// The constraint may only be used in conjunction with Characteristics which use the xsd:decimal data type.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#fixed-point-constraint"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#FixedPointConstraint"/>
/// </summary>
public class FixedPointConstraint : Constraint, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-fixed-point-constraint";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:FixedPointConstraint" : "samm-c:FixedPointConstraint";
/// <summary>
/// The scaling factor for a fixed point number. E.g., if a fixedpoint number is 123.04, the
/// scaling factor is 2 (the number of digits after the decimal point).
/// Must be given as xsd:positiveInteger.
/// </summary>
[SammPropertyUri("bamm-c:scale", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:scale", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:scale", SammVersion.V_2_1_0)]
public uint? Scale { get; set; }
/// <summary>
/// The number of integral digits for a fixed point number. E.g., if a fixedpoint number
/// is 123.04, the integer factor is 3 (the number of digits before the decimal point).
/// Must be given as xsd:positiveInteger.
/// </summary>
[SammPropertyUri("bamm-c:integer", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:integer", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:integer", SammVersion.V_2_1_0)]
public uint? Integer { get; set; }
}
/// <summary>
/// Base class of all characteristics. This Characteristics Class can also be instantiated directly
/// (i.e., without creating a subclass).
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#characteristic-characteristic"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#Characteristic"/>
/// </summary>
public class Characteristic : ModelElement, ISammSelfDescription, ISammStructureModel
{
// self description
public string GetSelfName() => "samm-characteristic";
public string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm:Characteristic" : "samm:Characteristic";
// structure model
public bool IsTopElement() => false;
public IEnumerable<SammReference> DescendOnce()
{
if (DataType != null)
yield return DataType;
}
/// <summary>
/// Reference to a scalar or complex (Entity) data type. See Section "Type System" in the Aspect Meta Model.
/// Also the scalar data types (e.g. xsd:decimal) are treated as references in the first degree.
/// </summary>
[SammPresetList("SammXsdDataTypes")]
[SammPropertyUri("bamm:dataType", SammVersion.V_1_0_0)]
[SammPropertyUri("samm:dataType", SammVersion.V_2_0_0)]
[SammPropertyUri("samm:dataType", SammVersion.V_2_1_0)]
public SammReference DataType { get; set; }
public Characteristic()
{
DataType = new SammReference("");
}
}
/// <summary>
/// The Trait is used to add one or more Constraints to another Characteristic, which is
/// referred to as the "base Characteristic". A Trait itself has no samm:dataType,
/// because it inherits the type of its samm-c:baseCharacteristic.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#trait-characteristic"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#Trait"/>
/// </summary>
public class Trait : Characteristic, ISammSelfDescription, ISammStructureModel
{
// self description
public new string GetSelfName() => "samm-trait";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:Trait" : "samm-c:Trait";
// structure model
public new bool IsTopElement() => false;
public new IEnumerable<SammReference> DescendOnce()
{
if (BaseCharacteristic != null)
yield return BaseCharacteristic;
if (Constraint != null)
foreach (var cn in Constraint)
yield return cn;
}
/// <summary>
/// The Characterstic that is being constrained.
/// Identified via <c>preferredName</c> in any language
/// </summary>
[SammPropertyUri("bamm-c:baseCharacteristic", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:baseCharacteristic", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:baseCharacteristic", SammVersion.V_2_1_0)]
public SammReference? BaseCharacteristic { get; set; }
/// <summary>
/// A Constraint that is applicable to the base Characteristic. This attribute may be used multiple times,
/// to add multiple Constraints to the base Characteristic.
/// </summary>
[SammPropertyUri("bamm-c:constraint", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:constraint", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:constraint", SammVersion.V_2_1_0)]
[SammPropertyFlags("constraints")]
public List<SammReference>? Constraint { get; set; }
}
/// <summary>
/// A value which can be quantified and may have a unit, e.g., the number of bolts required for a
/// processing step or the expected torque with which these bolts should be tightened.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#quantifiable-characteristic"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#Quantifiable"/>
/// </summary>
public class Quantifiable : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-quantifiable";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:Quantifiable" : "samm-c:Quantifiable";
/// <summary>
/// Reference to a Unit as defined in the Unit catalog
/// </summary>
[SammPropertyUri("bamm-c:unit", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:unit", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:unit", SammVersion.V_2_1_0)]
public SammReference? Unit { get; set; }
}
/// <summary>
/// A measurement is a numeric value with an associated unit and quantity kind.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#measurement-characteristic"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#Measurement"/>
/// </summary>
public class Measurement : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-measurement";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:Measurement" : "samm-c:Measurement";
/// <summary>
/// Reference to a Unit as defined in the Unit catalog
/// </summary>
[SammPropertyUri("bamm-c:unit", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:unit", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:unit", SammVersion.V_2_1_0)]
public SammReference Unit { get; set; }
public Measurement()
{
Unit = new SammReference("");
}
}
/// <summary>
/// An enumeration represents a list of possible values.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#enumeration-characteristic"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#Enumeration"/>
/// </summary>
public class Enumeration : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-enumeration";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:Enumeration" : "samm-c:Enumeration";
/// <summary>
/// List of possible values. The dataType of each of the values must match the
/// dataType of the Enumeration.
/// </summary>
[SammPropertyUri("bamm-c:values", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:values", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:values", SammVersion.V_2_1_0)]
public List<string>? Values { get; set; } = null;
public Enumeration()
{
}
}
/// <summary>
/// A state is subclass of Enumeration with a default value.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#state-characteristic"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#State"/>
/// </summary>
public class State : Enumeration, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-state";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:State" : "samm-c:State";
/// <summary>
/// The default value for the state.
/// </summary>
[SammPropertyUri("bamm-c:defaultValue", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:defaultValue", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:defaultValue", SammVersion.V_2_1_0)]
public string DefaultValue { get; set; }
public State()
{
DefaultValue = "";
}
}
/// <summary>
/// A time duration.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#duration-characteristic"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#Duration"/>
/// </summary>
public class Duration : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-duration";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:Duration" : "samm-c:Duration";
/// <summary>
/// Reference to a Unit as defined in the Unit catalog. The referenced unit or its referenceUnit
/// must have the quantityKind unit:time. Currently, the following units can therefore be used:
/// unit:centipoisePerBar unit:commonYear unit:day unit:henryPerKiloohm unit:henryPerOhm
/// unit:hour unit:kilosecond unit:microhenryPerKiloohm unit:microhenryPerOhm unit:microsecond
/// unit:millihenryPerKiloohm unit:millihenryPerOhm unit:millipascalSecondPerBar unit:millisecond
/// unit:minuteUnitOfTime unit:month unit:nanosecond unit:pascalSecondPerBar unit:picosecond
/// unit:poisePerBar unit:poisePerPascal unit:reciprocalMinute unit:secondUnitOfTime
/// unit:shake unit:siderealYear unit:tropicalYear unit:week unit:year
/// </summary>
[SammPropertyUri("bamm-c:unit", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:unit", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:unit", SammVersion.V_2_1_0)]
public SammReference Unit { get; set; }
public Duration()
{
Unit = new SammReference();
}
}
/// <summary>
/// A group of values which may be either of a scalar or Entity type. The values may be duplicated and
/// are not ordered (i.e., bag semantics).
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#collection-characteristic"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#Collection"/>
/// </summary>
public class Collection : Characteristic, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-collection";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:Collection" : "samm-c:Collection";
/// <summary>
/// Reference to a Characteristic which describes the individual elements contained in the Collection.
/// </summary>
[SammPropertyUri("bamm-c:elementCharacteristic", SammVersion.V_1_0_0)]
[SammPropertyUri("samm-c:elementCharacteristic", SammVersion.V_2_0_0)]
[SammPropertyUri("samm-c:elementCharacteristic", SammVersion.V_2_1_0)]
public SammReference ElementCharacteristic { get; set; }
public Collection()
{
ElementCharacteristic = new SammReference();
}
}
/// <summary>
/// A subclass of Collection which may contain duplicates and is ordered.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#list-characteristic"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#List"/>
/// </summary>
public class List : Collection, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-list";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:List" : "samm-c:List";
}
/// <summary>
/// A subclass of Collection which may not contain duplicates and is unordered.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#set-characteristic"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#Set"/>
/// </summary>
public class Set : Collection, ISammSelfDescription
{
// self description
public new string GetSelfName() => "samm-set";
public new string GetSelfUrn(SammVersion v) => (v == SammVersion.V_1_0_0) ? "bamm-c:Set" : "samm-c:Set";
}
/// <summary>
/// A subclass of Collection which may not contain duplicates and is ordered.
/// <see href="https://eclipse-esmf.github.io/samm-specification/snapshot/characteristics.html#sorted-set-characteristic"/>
/// <seealso href="urn:bamm:io.openmanufacturing:characteristic:1.0.0#SortedSet"/>
/// </summary>
public class SortedSet : Collection, ISammSelfDescription