public void InitReferable(FormDescSubmodel desc, AdminShell.Submodel source) { if (desc == null) { return; } // create sm here! (different than handling of SME!!) this.sm = new AdminShell.Submodel(); this.sourceSM = source; sm.idShort = desc.PresetIdShort; if (source?.idShort != null) { sm.idShort = source.idShort; } sm.category = desc.PresetCategory; if (desc.PresetDescription != null) { sm.description = new AdminShell.Description(desc.PresetDescription); } if (source?.description != null) { sm.description = new AdminShell.Description(source.description); } if (desc.KeySemanticId != null) { sm.semanticId = AdminShell.SemanticId.CreateFromKey(desc.KeySemanticId); } }
public static void Test123() { var ttt = new AasForms.FormDescProperty("t", AasForms.FormMultiplicity.One, null, "xdscdsds"); var descDoc = new FormDescListOfElement(); descDoc.Add(ttt); using (var s = new StreamWriter("test2.json")) { JsonSerializerSettings settings = new JsonSerializerSettings { SerializationBinder = new DisplayNameSerializationBinder( new[] { typeof(FormDescListOfElement), typeof(FormDescProperty) }), NullValueHandling = NullValueHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Serialize, TypeNameHandling = TypeNameHandling.Auto, Formatting = Formatting.Indented }; JsonSerializer serializer = JsonSerializer.Create(settings); using (JsonWriter writer = new JsonTextWriter(s)) { serializer.Serialize(writer, descDoc, typeof(FormDescProperty)); } } var settings2 = AasxPluginOptionSerialization.GetDefaultJsonSettings(new[] { typeof(FormDescBase) }); var test2 = new AasForms.FormDescSubmodel("t", null, "xdscdsds"); var test22 = new AasForms.FormDescProperty("t", AasForms.FormMultiplicity.One, null, "xdscdsds"); test2.Add(test22); Newtonsoft.Json.JsonConvert.SerializeObject(test2, settings2); }
public static void ExportAsTemplate(AdminShell.Submodel sm, string fn) { // access if (fn == null || sm == null || sm.submodelElements == null) { return; } // make submodel template var templateArr = new List <FormDescSubmodel>(); var tsm = new FormDescSubmodel( "Submodel", sm.semanticId?.GetAsExactlyOneKey(), sm.idShort, ""); tsm.SubmodelElements = new FormDescListOfElement(); templateArr.Add(tsm); // ok, export all SubmodelElems RecurseExportAsTemplate(sm.submodelElements, tsm.SubmodelElements); // write var settings = AasxPluginOptionSerialization.GetDefaultJsonSettings(new[] { typeof(FormDescBase) }); settings.Formatting = Newtonsoft.Json.Formatting.Indented; var json = Newtonsoft.Json.JsonConvert.SerializeObject(templateArr, templateArr.GetType(), settings); File.WriteAllText(fn, json); }
public static void ExportAsGenericFormsOptions( AdminShell.AdministrationShellEnv env, AdminShell.Submodel sm, string fn) { // access if (fn == null || env == null || sm == null || sm.submodelElements == null) { return; } // make submodel template var tsm = new FormDescSubmodel( "Submodel", sm.semanticId?.GetAsExactlyOneKey(), sm.idShort, ""); tsm.SubmodelElements = new FormDescListOfElement(); // will collect a list of CDs var cds = new AdminShell.ListOfConceptDescriptions(); // ok, export all SubmodelElems into tsm RecurseExportAsTemplate(sm.submodelElements, tsm.SubmodelElements, env, cds); // fill out record var rec = new ExportAsGenericFormsOptions_OptionsRecord(); rec.FormTag = "TBD"; var q = sm.qualifiers?.FindType("FormTag"); if (q != null) { rec.FormTag = "" + q.value; } rec.FormTitle = "TBD/" + sm.idShort; q = sm.qualifiers?.FindType("FormTitle"); if (q != null) { rec.FormTitle = "" + q.value; } rec.FormSubmodel = tsm; rec.ConceptDescriptions = cds; // fill out overall data var overall = new ExportAsGenericFormsOptions_OptionsOverall(); overall.Records.Add(rec); // write var settings = AasxPluginOptionSerialization.GetDefaultJsonSettings(new[] { typeof(FormDescBase) }); settings.Formatting = Newtonsoft.Json.Formatting.Indented; var json = Newtonsoft.Json.JsonConvert.SerializeObject(overall, overall.GetType(), settings); File.WriteAllText(fn, json); }
public FormInstanceSubmodel(FormDescSubmodel desc) : base(null, desc) { // require desc! if (desc == null || desc.SubmodelElements == null) { // done return; } foreach (var subDesc in desc.SubmodelElements) { var los = new FormInstanceListOfSame(this, subDesc); var pair = new FormDescInstancesPair(subDesc, los); PairInstances.Add(pair); } }
public static void ExportAsTemplate(AdminShellPackageEnv package, string fn) { // access if (fn == null || package == null || package.AasEnv == null) { return; } // build templates var templateArr = new List <FormDescSubmodel>(); foreach (var aas in package.AasEnv.AdministrationShells) { foreach (var smref in aas.submodelRefs) { // get Submodel var sm = package.AasEnv.FindSubmodel(smref); if (sm == null) { continue; } // make submodel template var tsm = new FormDescSubmodel( "Submodel", sm.GetSemanticKey(), sm.idShort, ""); tsm.SubmodelElements = new FormDescListOfElement(); templateArr.Add(tsm); // ok, export all SubmodelElems RecurseExportAsTemplate(sm.submodelElements, tsm.SubmodelElements); } } // write var settings = AasxPluginOptionSerialization.GetDefaultJsonSettings(new[] { typeof(FormDescBase) }); settings.Formatting = Newtonsoft.Json.Formatting.Indented; var json = Newtonsoft.Json.JsonConvert.SerializeObject(templateArr, templateArr.GetType(), settings); File.WriteAllText(fn, json); }
public FormDescSubmodel(FormDescSubmodel other) : base(other) { // this part == static, therefore only shallow copy this.SubmodelElements = other.SubmodelElements; }