/// <summary> /// Set the value for this row from the <see cref="ParameterOrOverrideBase"/> and the associated <see cref="ParameterValueSetBase"/> /// </summary> /// <param name="parameterOrOveride">The <see cref="ParameterOrOverrideBase"/></param> /// <param name="valueSet">The <see cref="ParameterValueSetBase"/></param> /// <param name="index">The Index of the Value to get</param> public void SetScalarValue(ParameterOrOverrideBase parameterOrOveride, ParameterValueSetBase valueSet, int?index = null) { this.Value = index.HasValue && valueSet.Published.Count() > index ? valueSet.Published[index.Value] : valueSet.Published.FirstOrDefault(); var actualValue = index.HasValue && valueSet.Published.Count() > index ? valueSet.ActualValue[index.Value] : valueSet.ActualValue.FirstOrDefault(); this.ModelCode = index.HasValue ? valueSet.ModelCode(index.Value) : valueSet.ModelCode(); this.Switch = valueSet.ValueSwitch; if (this.Value == null || actualValue == null) { return; } if (this.Value != actualValue) { this.IsPublishable = true; } if (this.Scale != null) { this.Value += " [" + this.Scale.ShortName + "]"; } }
/// <summary> /// Set the value for this row from the <see cref="ParameterOrOverrideBase"/> and the associated <see cref="ParameterValueSetBase"/> /// </summary> /// <param name="parameterOrOveride">The <see cref="ParameterOrOverrideBase"/></param> /// <param name="valueSet">The <see cref="ParameterValueSetBase"/></param> public void SetScalarValue(ParameterOrOverrideBase parameterOrOveride, ParameterValueSetBase valueSet) { // perform checks to see if this is indeed a scalar value if (valueSet.Published.Count() > 1) { logger.Warn("The value set of Parameter or override {0} is marked as Scalar, yet has multiple values.", this.Thing.Iid); } this.Value = valueSet.Published.FirstOrDefault(); // handle zero values returned if (this.Value == null) { logger.Warn("The value set of Parameter or override {0} is marked as Scalar, yet has no values.", this.Thing.Iid); this.Value = "-"; } if (parameterOrOveride.Scale != null) { this.Value += " [" + parameterOrOveride.Scale.ShortName + "]"; } this.Switch = valueSet.ValueSwitch; this.ModelCode = valueSet.ModelCode(); }
/// <summary> /// Generate a cell name for the given <paramref name="parameterValueSetBase"/>. Note that non-<see cref="ParameterOverrideValueSet"/>s /// displayed on <see cref="ElementUsage"/> <paramref name="rowThing"/>s will not have a name, as they are not interactible. /// </summary> /// <param name="rowThing"> /// The <see cref="Thing"/> of the associated row. /// </param> /// <param name="parameterValueSetBase"> /// The <see cref="ParameterValueSetBase"/> for which to generate the cell name. /// </param> /// <param name="componentIndex"> /// Optional, the <see cref="ParameterTypeComponent"/> index. /// </param> /// <returns> /// The cell name. /// </returns> private static string GetCellName(Thing rowThing, ParameterValueSetBase parameterValueSetBase, int?componentIndex = null) { // non-overrides displayed on EUs are not interactible if (rowThing is ElementUsage && parameterValueSetBase is ParameterValueSet) { return(null); } return($"{CrossviewSheetConstants.CrossviewSheetName}_{parameterValueSetBase.ModelCode(componentIndex)}"); }