protected override bool OnProfileItemCreated(ProfileTypeDefinitionModel profileItem, IDALContext dalContext) { var bUpdated = base.OnProfileItemCreated(profileItem, dalContext); var isNumeric = _model.HasBaseType("nsu=http://opcfoundation.org/UA/;i=26"); // Create data type table entry var dataTypeLookup = new LookupDataTypeModel { ID = null, Name = profileItem.Name, Code = $"{profileItem.Profile.Namespace}.{profileItem.OpcNodeId}", //"custom", CustomTypeId = profileItem.ID, CustomType = profileItem, // TODO verify if OPA UC allows enginering units on non-numeric types UseEngUnit = isNumeric, UseMinMax = isNumeric, IsNumeric = isNumeric, //For standard (UA, UA/DI), AuthorId is null. //For standard imported by owner (UA/Robotics), AuthorId has value and we use this to keep the separation by owner. //For custom (myNodeset), AuthorId has value and we use this to keep the separation by owner. OwnerId = profileItem.AuthorId }; //if (GetBuiltinDataTypeNodeId(dataTypeLookup) == null) var dataTypeId = dalContext.CreateCustomDataTypeAsync(dataTypeLookup).Result; return(bUpdated); }
public LookupDataTypeModel GetAttributeDataType(ProfileTypeDefinitionModel profileItem, IDALContext dalContext) { var attributeDataType = dalContext.GetDataType(_model.DisplayName?.FirstOrDefault()?.Text); if (attributeDataType == null) { //TODO: SC - Question - MH - Please review this. //At this point, can we add the custom data type record (the profile item and the data type record) //Note we first do need to insert the custom data type as a profile item. //Possibly wrap ImportProfileItemAsync and a ImportCustomDataTypeAsync into one call. // MH: DataType.ImportProfileItemAsync now creates the Data Type lookup entry var dataTypeProfile = this.ImportProfileItem(dalContext); if (dataTypeProfile == null) { throw new Exception($"Undefined data type {_model.DisplayName?.FirstOrDefault()?.Text} {_model.NodeId} in profile {profileItem.Name} ({profileItem.ID})"); } attributeDataType = dalContext.GetCustomDataTypeAsync(dataTypeProfile).Result; if (attributeDataType == null) { // TODO expand LookupDataTypeModel with object reference attributeDataType = new LookupDataTypeModel { Name = dataTypeProfile.Name, Code = "custom", CustomType = dataTypeProfile }; } } return(attributeDataType); }