blob: a8cdf4b3241ad33bc2e2ab75269f993ffd051b5f [file] [log] [blame]
Constantin Ziesche857c7ab2020-02-25 11:24:51 +01001/*******************************************************************************
2* Copyright (c) 2020 Robert Bosch GmbH
3* Author: Constantin Ziesche (constantin.ziesche@bosch.com)
4*
5* This program and the accompanying materials are made available under the
6* terms of the Eclipse Public License 2.0 which is available at
7* http://www.eclipse.org/legal/epl-2.0
8*
9* SPDX-License-Identifier: EPL-2.0
10*******************************************************************************/
11using BaSyx.Models.Core.AssetAdministrationShell.Enums;
12using BaSyx.Models.Core.Common;
13using Newtonsoft.Json;
14using System.Collections.Generic;
15using System.Xml.Serialization;
16
17namespace BaSyx.Models.Export
18{
19 [XmlType(TypeName = "submodelElement")]
20 public class EnvironmentSubmodelElement_V1_0
21 {
22 [XmlElement(ElementName = "property", Type = typeof(Property_V1_0))]
23 [XmlElement(ElementName = "file", Type = typeof(File_V1_0))]
24 [XmlElement(ElementName = "blob", Type = typeof(Blob_V1_0))]
25 [XmlElement(ElementName = "event", Type = typeof(Event_V1_0))]
26 [XmlElement(ElementName = "referenceElement", Type = typeof(ReferenceElement_V1_0))]
27 [XmlElement(ElementName = "relationshipElement", Type = typeof(RelationshipElement_V1_0))]
28 [XmlElement(ElementName = "submodelElementCollection", Type = typeof(SubmodelElementCollection_V1_0))]
29 [XmlElement(ElementName = "operation", Type = typeof(Operation_V1_0))]
30 public SubmodelElementType_V1_0 submodelElement;
31 }
32
33 public class SubmodelElementType_V1_0 : EnvironmentReferable_V1_0, IModelType
34 {
35 [JsonProperty("semanticId")]
36 [XmlElement("semanticId")]
37 public EnvironmentReference_V1_0 SemanticId { get; set; }
38
39 [JsonProperty("kind")]
40 [XmlElement("kind")]
41 public ModelingKind Kind { get; set; }
42
43 [JsonProperty("constraints")]
44 [XmlArray("qualifier")]
45 [XmlArrayItem("qualifier")]
46 public List<EnvironmentQualifier_V1_0> Qualifier { get; set; } = new List<EnvironmentQualifier_V1_0>();
47
48 [XmlIgnore]
49 public virtual ModelType ModelType { get; }
50
51 public SubmodelElementType_V1_0() { }
52 public SubmodelElementType_V1_0(SubmodelElementType_V1_0 submodelElementType)
53 {
54 this.Category = submodelElementType.Category;
55 this.Description = submodelElementType.Description;
56 this.IdShort = submodelElementType.IdShort;
57 this.Kind = submodelElementType.Kind;
58 this.Parent = submodelElementType.Parent;
59 this.Qualifier = submodelElementType.Qualifier;
60 this.SemanticId = submodelElementType.SemanticId;
61 }
62
Constantin Ziesche02817f12020-08-04 21:40:43 +020063 public bool ShouldSerializeQualifier()
64 {
65 if (Qualifier == null || Qualifier.Count == 0)
66 return false;
67 else
68 return true;
69 }
Constantin Ziesche857c7ab2020-02-25 11:24:51 +010070 }
71}