예제 #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 || !IsDefaultDensity)
            {
                rootElem.Add(new XAttribute("density", Density.ToString(CultureInfo.InvariantCulture)));
            }
            if (!suppressDefaults || !IsDefaultAvgDistance)
            {
                rootElem.Add(new XAttribute("avgDistance", IsDefaultAvgDistance ? DefaultAvgDistanceCode : AvgDistance.ToString(CultureInfo.InvariantCulture)));
            }
            if (!suppressDefaults || !IsDefaultAllowSelfConnection)
            {
                rootElem.Add(new XAttribute("allowSelfConnection", AllowSelfConnection.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
            }
            if (!suppressDefaults || !IsDefaultConstantNumOfConnections)
            {
                rootElem.Add(new XAttribute("constantNumOfConnections", ConstantNumOfConnections.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
            }
            if (!suppressDefaults || !IsDefaultReplaceExistingConnections)
            {
                rootElem.Add(new XAttribute("replaceExistingConnections", ReplaceExistingConnections.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
            }
            if (!suppressDefaults || !IsDefaultRepetitions)
            {
                rootElem.Add(new XAttribute("repetitions", Repetitions.ToString(CultureInfo.InvariantCulture)));
            }
            Validate(rootElem, XsdTypeName);
            return(rootElem);
        }
예제 #2
0
 //Methods
 /// <summary>
 /// Checks consistency
 /// </summary>
 protected override void Check()
 {
     if (TestDataRatio <= 0 || TestDataRatio > MaxTestDataRatio)
     {
         throw new ArgumentException($"Invalid TestDataRatio {TestDataRatio.ToString(CultureInfo.InvariantCulture)}. TestDataRatio must be GT 0 and GE {MaxTestDataRatio.ToString(CultureInfo.InvariantCulture)}.", "TestDataRatio");
     }
     if (Folds < 0)
     {
         throw new ArgumentException($"Invalid Folds {Folds.ToString(CultureInfo.InvariantCulture)}. Folds must be GE to 0 (0 means Auto folds).", "Folds");
     }
     if (Repetitions < 1)
     {
         throw new ArgumentException($"Invalid Repetitions {Repetitions.ToString(CultureInfo.InvariantCulture)}. Repetitions must be GE to 1.", "Repetitions");
     }
     foreach (ReadoutUnitSettings rus in ReadoutUnitsCfg.ReadoutUnitCfgCollection)
     {
         if (rus.TaskCfg.NetworkCfgCollection.Count == 0)
         {
             if (DefaultNetworksCfg.GetTaskNetworksCfgs(rus.TaskCfg.Type).Count == 0)
             {
                 throw new ArgumentException($"Readout unit {rus.Name} has not associated network(s) settings.", "ReadoutUnitsCfg");
             }
         }
     }
     return;
 }
예제 #3
0
        /// <inheritdoc/>
        public override XElement GetXml(string rootElemName, bool suppressDefaults)
        {
            XElement rootElem = new XElement(rootElemName);

            if (!suppressDefaults || !IsDefaultRatio)
            {
                rootElem.Add(new XAttribute("ratio", Ratio.ToString(CultureInfo.InvariantCulture)));
            }
            if (!suppressDefaults || !IsDefaultLDiagonalSelf)
            {
                rootElem.Add(new XAttribute("lDiagonalSelf", LDiagonalSelf.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
            }
            if (!suppressDefaults || !IsDefaultRDiagonalSelf)
            {
                rootElem.Add(new XAttribute("rDiagonalSelf", RDiagonalSelf.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
            }
            if (!suppressDefaults || !IsDefaultReplaceExistingConnections)
            {
                rootElem.Add(new XAttribute("replaceExistingConnections", ReplaceExistingConnections.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()));
            }
            if (!suppressDefaults || !IsDefaultRepetitions)
            {
                rootElem.Add(new XAttribute("repetitions", Repetitions.ToString(CultureInfo.InvariantCulture)));
            }
            Validate(rootElem, XsdTypeName);
            return(rootElem);
        }
예제 #4
0
 //Methods
 /// <inheritdoc/>
 protected override void Check()
 {
     if (Ratio <= 0 || Ratio > 1)
     {
         throw new ArgumentException($"Invalid Ratio {Ratio.ToString(CultureInfo.InvariantCulture)}. Ratio must be GT 0 and LE to 1.", "Ratio");
     }
     if (Repetitions < 1)
     {
         throw new ArgumentException($"Invalid Repetitions {Repetitions.ToString(CultureInfo.InvariantCulture)}. Repetitions must be GT 0.", "Repetitions");
     }
     return;
 }
예제 #5
0
 //Methods
 /// <inheritdoc/>
 protected override void Check()
 {
     if (FoldDataRatio <= 0 || FoldDataRatio > MaxFoldDataRatio)
     {
         throw new ArgumentException($"Invalid FoldDataRatio {FoldDataRatio.ToString(CultureInfo.InvariantCulture)}. TestDataRatio must be GT 0 and GE {MaxFoldDataRatio.ToString(CultureInfo.InvariantCulture)}.", "FoldDataRatio");
     }
     if (Folds < 0)
     {
         throw new ArgumentException($"Invalid Folds {Folds.ToString(CultureInfo.InvariantCulture)}. Folds must be GE to 0 (0 means Auto folds).", "Folds");
     }
     if (Repetitions < 1)
     {
         throw new ArgumentException($"Invalid Repetitions {Repetitions.ToString(CultureInfo.InvariantCulture)}. Repetitions must be GE to 1.", "Repetitions");
     }
     return;
 }
예제 #6
0
 //Methods
 /// <summary>
 /// Checks consistency
 /// </summary>
 protected override void Check()
 {
     if (Density <= 0 || Density > 1)
     {
         throw new ArgumentException($"Invalid Density {Density.ToString(CultureInfo.InvariantCulture)}. Density must be GT 0 and LE to 1.", "Density");
     }
     if (AvgDistance < 0)
     {
         throw new ArgumentException($"Invalid AvgDistance {AvgDistance.ToString(CultureInfo.InvariantCulture)}. AvgDistance must be GE to 0.", "AvgDistance");
     }
     if (Repetitions < 1)
     {
         throw new ArgumentException($"Invalid Repetitions {Repetitions.ToString(CultureInfo.InvariantCulture)}. Repetitions must be GT 0.", "Repetitions");
     }
     return;
 }
예제 #7
0
        /// <inheritdoc/>
        public override XElement GetXml(string rootElemName, bool suppressDefaults)
        {
            XElement rootElem = new XElement(rootElemName);

            if (!suppressDefaults || !IsDefaultFoldDataRatio)
            {
                rootElem.Add(new XAttribute("foldDataRatio", FoldDataRatio.ToString(CultureInfo.InvariantCulture)));
            }
            if (!suppressDefaults || !IsDefaultFolds)
            {
                rootElem.Add(new XAttribute("folds", Folds == DefaultFoldsNum ? DefaultFoldsString : Folds.ToString(CultureInfo.InvariantCulture)));
            }
            if (!suppressDefaults || !IsDefaultRepetitions)
            {
                rootElem.Add(new XAttribute("repetitions", Repetitions.ToString(CultureInfo.InvariantCulture)));
            }
            Validate(rootElem, XsdTypeName);
            return(rootElem);
        }
예제 #8
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);

            rootElem.Add(new XAttribute("testDataRatio", TestDataRatio.ToString(CultureInfo.InvariantCulture)));
            if (!suppressDefaults || !IsDefaultFolds)
            {
                rootElem.Add(new XAttribute("folds", Folds == DefaultFoldsNum ? DefaultFoldsString : Folds.ToString(CultureInfo.InvariantCulture)));
            }
            if (!suppressDefaults || !IsDefaultRepetitions)
            {
                rootElem.Add(new XAttribute("repetitions", Repetitions.ToString(CultureInfo.InvariantCulture)));
            }
            if (!DefaultNetworksCfg.ContainsOnlyDefaults)
            {
                rootElem.Add(DefaultNetworksCfg.GetXml(suppressDefaults));
            }
            rootElem.Add(ReadoutUnitsCfg.GetXml(suppressDefaults));
            Validate(rootElem, XsdTypeName);
            return(rootElem);
        }
예제 #9
0
 /// <summary>
 /// Converts the <see cref="Repetitions"/> to string, so code looks less clustered.
 /// </summary>
 /// <returns></returns>
 public string SetToString()
 {
     return(Repetitions.ToString());
 }