Esempio n. 1
0
 public void Dispose()
 {
     if (autoSavedManager != null)
     {
         autoSavedManager.Abort();
     }
     if (AutoInstManager != null &&
         AutoInstManager.IsAlive)
     {
         AutoInstManager.Abort();
     }
     MainRoutine.Dispose();
     MainRoutine = null;
     foreach (var subRoutine in SubRoutines)
     {
         subRoutine.Dispose();
     }
     SubRoutines.Clear();
     MMonitorManager.Dispose();
     MTVModel.Dispose();
     MMonitorManager = null;
     //MTVModel = null;
     PManager = null;
     UManager = null;
     LibFuncBlock.Dispose();
     LibFuncBlock = null;
     foreach (var funcBlock in FuncBlocks)
     {
         funcBlock.Dispose();
     }
     FuncBlocks.Clear();
 }
Esempio n. 2
0
        public bool Open(XElement rootNode)
        {
            ProjectName = rootNode.Attribute("Name").Value;
            PLCDeviceManager.GetPLCDeviceManager().SetSelectDeviceType((PLCDeviceType)Enum.Parse(typeof(PLCDeviceType), rootNode.Attribute("DeviceType").Value));
            SubRoutines.Clear();
            FuncBlocks.Clear();
            ValueAliasManager.Clear();
            ValueCommentManager.Clear();
            InstructionCommentManager.Clear();
            ProjectHelper.LoadValueCommentsByXElement(rootNode.Element("ValueComments"));
            ProjectHelper.LoadValueAliasByXElement(rootNode.Element("ValueAlias"));
            ProjectPropertyManager.LoadProjectPropertyByXElement(rootNode.Element("ProjectPropertyParams"));
            MMonitorManager.MMWindow.LoadTablesByXElement(rootNode.Element("Tables"));
            EleInitializeData = rootNode.Element("EleInitialize");
            var ldnodes = rootNode.Elements("Ladder");

            foreach (XElement ldnode in ldnodes)
            {
                var ldmodel = ProjectHelper.CreateLadderDiagramByXElement(ldnode, this);
                if (ldmodel.IsMainLadder)
                {
                    MainRoutine = ldmodel;
                }
                else
                {
                    SubRoutines.Add(ldmodel);
                    TreeViewItem item = new TreeViewItem();
                    item.Header = ldmodel;
                }
            }
            // Open FunctionBlock
            var fbnodes = rootNode.Elements("FuncBlock");

            foreach (XElement fbnode in fbnodes)
            {
                var fbmodel = ProjectHelper.CreateFuncBlockByXElement(fbnode, this);
                FuncBlocks.Add(fbmodel);
            }
            var mtnodes = rootNode.Element("Modbus");
            var mtmodel = new ModbusTableViewModel(this);

            mtmodel.Load(mtnodes);
            MTVModel = mtmodel;
            return(true);
        }