Exemple #1
0
        //convert the current configuration into an XElement node
        public void SaveCurrentConfig(byte group)
        {
            XElement cfgNode = new XElement("Item");
            XElement sNode   = new XElement("Item");

            //group = pack|vib|sub
            if (group > 3) //save pack config
            {
                _curr_cfg.ToElement(ref cfgNode);
                pkg_confs.AddConfig(pkg_confs.cfg_name, cfgNode);
            }

            if ((group % 4) > 1) //save vib config
            {
                sNode.RemoveAll();
                try
                {
                    NodeMaster.GetNodeElement(vib_addr, ref sNode);
                    nodes_config[vib_addr].AddConfig(pkg_confs.cfg_name, sNode);
                    if (bot_addr != vib_addr)
                    {
                        NodeMaster.GetNodeElement(bot_addr, ref sNode);
                        nodes_config[bot_addr].AddConfig(pkg_confs.cfg_name, sNode);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Write(ex.Message);
                }
            }
            if ((group % 2) == 1) //save sub config
            {
                foreach (byte n in weight_nodes)
                {
                    sNode.RemoveAll();
                    try
                    {
                        NodeMaster.GetNodeElement(n, ref sNode);
                        nodes_config[n].AddConfig(pkg_confs.cfg_name, sNode);
                    }
                    catch (Exception ex)
                    {
                        Debug.Write(ex.Message);
                    }
                }
            }
        }