Beispiel #1
0
        /// <summary>
        /// Generates xml element containing the settings.
        /// </summary>
        /// <param name="rootElemName">Name to be used as a name of the root element.</param>
        /// <param name="suppressDefaults">Specifies whether to ommit optional nodes having set default values</param>
        /// <returns>XElement containing the settings</returns>
        public override XElement GetXml(string rootElemName, bool suppressDefaults)
        {
            XElement rootElem = new XElement(rootElemName);

            if (!suppressDefaults || !IsDefaultComponentHalfCodeLength)
            {
                rootElem.Add(new XAttribute("componentHalfCodeLength", ComponentHalfCodeLength.ToString(CultureInfo.InvariantCulture)));
            }
            if (!suppressDefaults || !IsDefaultLowestThreshold)
            {
                rootElem.Add(new XAttribute("lowestThreshold", LowestThreshold.ToString(CultureInfo.InvariantCulture)));
            }
            if (!suppressDefaults || !IsDefaultThresholdFullSpikeSet)
            {
                rootElem.Add(new XAttribute("thresholdFullSpikeSet", ThresholdFullSpikeSet.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
            }
            if (!suppressDefaults || !IsDefaultSignalComponent)
            {
                rootElem.Add(new XAttribute("signalComponent", SignalComponent.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
            }
            if (!suppressDefaults || !IsDefaultDeltaComponent)
            {
                rootElem.Add(new XAttribute("deltaComponent", DeltaComponent.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
            }
            if (!suppressDefaults || !IsDefaultBinaryComponent)
            {
                rootElem.Add(new XAttribute("binaryComponent", BinaryComponent.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
            }
            Validate(rootElem, XsdTypeName);
            return(rootElem);
        }
Beispiel #2
0
 //Methods
 /// <summary>
 /// Checks consistency
 /// </summary>
 protected override void Check()
 {
     if (ComponentHalfCodeLength < 1 || ComponentHalfCodeLength > 32)
     {
         throw new ArgumentException($"Invalid ComponentHalfCodeLength {ComponentHalfCodeLength.ToString(CultureInfo.InvariantCulture)}. ComponentHalfCodeLength must be GE to 1 and LE to 32.", "ComponentHalfCodeLength");
     }
     if (LowestThreshold <= 0 || LowestThreshold >= 1d)
     {
         throw new ArgumentException($"Invalid LowestThreshold {LowestThreshold.ToString(CultureInfo.InvariantCulture)}. LowestThreshold must be GT 0 and LT 1.", "LowestThreshold");
     }
     if (NumOfComponents == 0)
     {
         throw new ArgumentException($"At least one component of the spike code has to be used.", "SignalComponent/DeltaComponent/BinaryComponent");
     }
     return;
 }