예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Project"/> class and sets it to
        /// a singleton instance.
        /// </summary>
        public static void New()
        {
            // Create new project properties
            ProjectProperties.New();

            // Create new neural network configuration
            NetConfig.New();
        }
예제 #2
0
        /// <summary>
        /// Saves all elements instances from <see cref="Project"/> to XML file.
        /// </summary>
        public static void Save()
        {
            // TODO: Save to xml

            // Save project properties to file
            ProjectProperties.SaveToFile(ProjectFolderPath + Path.DirectorySeparatorChar
                                         + ProjectPropertiesFile);

            // Save neural network configuration to file
            NetConfig.SaveToFile(ProjectFolderPath + Path.DirectorySeparatorChar
                                 + NetConfigFile);
        }
예제 #3
0
        /// <summary>
        /// Loads the elements instance from XML file to <see cref="Project"/>.
        /// </summary>
        public static void Open()
        {
            // TODO: Read from xml

            // Load project properties from file
            ProjectProperties.LoadFromFile(ProjectFolderPath +
                                           Path.DirectorySeparatorChar + ProjectPropertiesFile);

            // Load neural network configuration from file
            NetConfig.LoadFromFile(ProjectFolderPath + Path.DirectorySeparatorChar
                                   + NetConfigFile);
        }
예제 #4
0
        /// <summary>
        /// Loads the content from XML file to <see cref="NetConfig"/> instance.
        /// </summary>
        /// <param name="filePath">The XML file path.</param>
        public static void LoadFromFile(string filePath)
        {
            // Desearialize XML to a new instance
            var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            try
            {
                _instance = (NetConfig) new XmlSerializer(Instance.GetType()).Deserialize(fileStream);
            }
            catch (InvalidOperationException ex)
            {
                throw new Exception("Invalid network configuration file.", ex);
            }
            finally
            {
                fileStream.Close();
            }
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NetConfig"/> class and sets it to a singleton instance.
 /// </summary>
 public static void New()
 {
     _instance = new NetConfig();
 }
예제 #6
0
 /// <summary>
 /// Loads the content from XML file to <see cref="NetConfig"/> instance.
 /// </summary>
 /// <param name="filePath">The XML file path.</param>
 public static void LoadFromFile(string filePath)
 {
     // Desearialize XML to a new instance
     var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
     try
     {
         _instance = (NetConfig) new XmlSerializer(Instance.GetType()).Deserialize(fileStream);
     }
     catch (InvalidOperationException ex)
     {
         throw new Exception("Invalid network configuration file.", ex);
     }
     finally
     {
         fileStream.Close();
     }
 }
예제 #7
0
 /// <summary>
 /// Add a new child to this node.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="name"></param>
 public void AddNewChild(NetConfig.Type type, string name)
 {
     TreeNode treeNode = null;
     switch (type)
     {
         case NetConfig.Type.Region:
             var newRegionParams = new NetConfig.RegionParams((NetConfig.RegionParams) this.Params, name);
             treeNode = new TreeNode(this, newRegionParams);
             break;
         case NetConfig.Type.FileSensor:
             var newFileSensorParams = new NetConfig.FileSensorParams((NetConfig.RegionParams) this.Params, name);
             treeNode = new TreeNode(this, newFileSensorParams);
             break;
         case NetConfig.Type.DatabaseSensor:
             var newDatabaseSensorParams = new NetConfig.DatabaseSensorParams((NetConfig.RegionParams) this.Params, name);
             treeNode = new TreeNode(this, newDatabaseSensorParams);
             break;
     }
     this.Children.Add(treeNode);
 }
예제 #8
0
            /// <summary>
            /// Initializes a new instance of the <see cref="TreeNode"/> class.
            /// </summary>
            public TreeNode(TreeNode parentNode, NetConfig.NodeParams nodeParams)
            {
                // Set fields
                this.ParentNode = parentNode;
                this.Params = nodeParams;

                // If this region is parent of lower regions/sensors in the hierarchy then create and add nodes to them.
                foreach (var childNodeParams in this.Params.Children)
                {
                    var childTreeNode = new TreeNode(this, childNodeParams);
                    this.Children.Add(childTreeNode);
                }
            }
예제 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NetConfig"/> class and sets it to a singleton instance.
 /// </summary>
 public static void New()
 {
     _instance = new NetConfig();
 }