public FormDescSubmodelElement(FormDescSubmodelElement other) : base(other) { // this part == static, therefore only shallow copy this.Multiplicity = other.Multiplicity; this.IsReadOnly = other.IsReadOnly; }
protected void InitReferable(FormDescSubmodelElement desc, AdminShell.SubmodelElement source) { if (desc == null || sme == null) { return; } sme.idShort = desc.PresetIdShort; if (source?.idShort != null) { sme.idShort = source.idShort; } sme.category = desc.PresetCategory; if (desc.PresetDescription != null) { sme.description = new AdminShell.Description(desc.PresetDescription); } if (source?.description != null) { sme.description = new AdminShell.Description(source.description); } if (desc.KeySemanticId != null) { sme.semanticId = AdminShell.SemanticId.CreateFromKey(desc.KeySemanticId); } }
// Member management //================== public void Add(FormDescSubmodelElement subDescription) { if (value == null) { value = new FormDescListOfElement(); } value.Add(subDescription); }
// Dynamic behaviour //================== public void Add(FormDescSubmodelElement elem) { if (elem == null) { return; } if (SubmodelElements == null) { SubmodelElements = new FormDescListOfElement(); } SubmodelElements.Add(elem); }
/// <summary> /// Event was raised from master because matching slave. /// </summary> public override void OnSlaveEvent( FormDescSubmodelElement masterDesc, FormInstanceSubmodelElement masterInst, int index) { // access to master var pMasterInst = masterInst as FormInstanceProperty; var pMaster = pMasterInst?.sme as AdminShell.Property; if (pMaster?.value == null) { return; } // accues to this var pThis = this.sme as AdminShell.Property; if (pThis == null) { return; } // desc of this var pDesc = this.desc as FormDescProperty; if (pDesc == null || pDesc.valueFromMasterValue == null || !pDesc.valueFromMasterValue.ContainsKey(pMaster.value.Trim())) { return; } // simply take value pThis.value = pDesc.valueFromMasterValue[pMaster.value.Trim()]; this.Touch(); // refresh if (this.subControl != null && this.subControl is FormSubControlProperty scp) { scp.UpdateDisplay(); } }
/// <summary> /// Event was raised from master because matching slave. /// </summary> public virtual void OnSlaveEvent( FormDescSubmodelElement masterDesc, FormInstanceSubmodelElement masterInst, int index) { }
private static void RecurseExportAsTemplate( AdminShell.SubmodelElementWrapperCollection smwc, FormDescListOfElement tels, AdminShell.AdministrationShellEnv env = null, AdminShell.ListOfConceptDescriptions cds = null) { // access if (smwc == null || tels == null) { return; } // over all elems foreach (var smw in smwc) { if (smw != null && smw.submodelElement != null) { FormDescSubmodelElement tsme = null; if (smw.submodelElement is AdminShell.Property p) { tsme = new FormDescProperty( "" + p.idShort, FormMultiplicity.One, p.semanticId?.GetAsExactlyOneKey(), "" + p.idShort, valueType: p.valueType); } if (smw.submodelElement is AdminShell.MultiLanguageProperty mlp) { tsme = new FormDescMultiLangProp( "" + mlp.idShort, FormMultiplicity.One, mlp.semanticId?.GetAsExactlyOneKey(), "" + mlp.idShort); } if (smw.submodelElement is AdminShell.File fl) { tsme = new FormDescFile( "" + fl.idShort, FormMultiplicity.One, fl.semanticId?.GetAsExactlyOneKey(), "" + fl.idShort); } if (smw.submodelElement is AdminShell.ReferenceElement rf) { tsme = new FormDescReferenceElement( "" + rf.idShort, FormMultiplicity.One, rf.semanticId?.GetAsExactlyOneKey(), "" + rf.idShort); } if (smw.submodelElement is AdminShell.SubmodelElementCollection smec) { tsme = new FormDescSubmodelElementCollection( "" + smec.idShort, FormMultiplicity.One, smec.semanticId?.GetAsExactlyOneKey(), "" + smec.idShort); } if (tsme != null) { // take over directly tsme.PresetCategory = smw.submodelElement.category; // Qualifers var qs = smw.submodelElement.qualifiers; var q = qs?.FindType("FormTitle"); if (q != null) { tsme.FormTitle = "" + q.value; } q = qs?.FindType("FormInfo"); if (q != null) { tsme.FormInfo = "" + q.value; } q = qs?.FindType("EditIdShort"); if (q != null) { tsme.FormEditIdShort = q.value.Trim().ToLower() == "true"; } q = qs?.FindType("EditDescription"); if (q != null) { tsme.FormEditDescription = q.value.Trim().ToLower() == "true"; } q = qs?.FindType("Multiplicity"); if (q != null) { foreach (var m in (FormMultiplicity[])Enum.GetValues(typeof(FormMultiplicity))) { if (("" + q.value) == Enum.GetName(typeof(FormMultiplicity), m)) { tsme.Multiplicity = m; } } } q = qs?.FindType("PresetValue"); if (q != null && tsme is FormDescProperty) { (tsme as FormDescProperty).presetValue = "" + q.value; } q = qs?.FindType("PresetMimeType"); if (q != null && tsme is FormDescFile) { (tsme as FormDescFile).presetMimeType = "" + q.value; } q = qs?.FindType("FormChoices"); if (q != null && q.value.HasContent() && tsme is FormDescProperty fdprop) { var choices = q.value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (choices != null && choices.Length > 0) { fdprop.comboBoxChoices = choices; } } // adopt presetIdShort if (tsme.Multiplicity == FormMultiplicity.ZeroToMany || tsme.Multiplicity == FormMultiplicity.OneToMany) { tsme.PresetIdShort += "{0:00}"; } // Ignore this element q = qs?.FindType("FormIgnore"); if (q != null) { continue; } } if (tsme != null) { tels.Add(tsme); } // in any case, check for CD if (env != null && cds != null && smw?.submodelElement?.semanticId?.Keys != null) { var masterCd = env.FindConceptDescription(smw?.submodelElement?.semanticId?.Keys); if (masterCd != null && masterCd.identification != null) { // already in cds? var copyCd = cds.Find(masterCd.identification); if (copyCd == null) { // add clone cds.Add(new AdminShell.ConceptDescription(masterCd)); } } } // recurse if (smw.submodelElement is AdminShell.SubmodelElementCollection) { RecurseExportAsTemplate( (smw.submodelElement as AdminShell.SubmodelElementCollection).value, (tsme as FormDescSubmodelElementCollection).value, env, cds); } } } }