Exemplo n.º 1
0
 private void ValueTextBox5_TextChanged(object sender, TextChangedEventArgs e)
 {
     switch (InstMode)
     {
     case INST_ATCH:
         IEnumerable <string> fit = SubRoutines.Where(
             (string name) => { return(name.Equals(ValueString5)); });
         if (fit.Count() == 0)
         {
             ValueTextBox5.Background = Brushes.Red;
         }
         else
         {
             ValueTextBox5.Background = Brushes.White;
         }
         PropertyChanged(this, new PropertyChangedEventArgs("CollectionSource"));
         return;
     }
     if (ValueParser.IsVariablePattern(ValueString5))
     {
         CommentString5 = ValueCommentManager.GetComment(ValueString5);
     }
     else
     {
         CommentString5 = ValueCommentManager.GetComment(ValueString5.ToUpper());
     }
 }
Exemplo n.º 2
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();
 }
Exemplo n.º 3
0
 public void Remove(LadderDiagramViewModel ldmodel)
 {
     if (SubRoutines.Contains(ldmodel))
     {
         SubRoutines.Remove(ldmodel);
         IsModify = true;
     }
 }
Exemplo n.º 4
0
 public void Add(LadderDiagramViewModel ldmodel)
 {
     if (!SubRoutines.Contains(ldmodel))
     {
         SubRoutines.Add(ldmodel);
         IsModify = true;
     }
 }
Exemplo n.º 5
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);
        }