public void Execute() { _network.RemoveElements(_elements); _network.RemoveVerticalLines(_vlines); InstructionCommentManager.RaiseMappedMessageChangedEvent(); //_network.INVModel.Setup(_network); }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(2, ElementPropertyDialog.INST_ATCH); * dialog.ShowLine3("EVENT:", IDValue); * dialog.ShowLine5("FUNC:"); * dialog.ValueString5 = FuncName; * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = IDValue.ValueString; var oldvaluestring2 = FuncName; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyIntKHValueRegex }); bool check2 = true; if (check1) { IDValue = ValueParser.ParseWordValue(valueStrings[0], contextDevice); int id = int.Parse(IDValue.GetValue()); if (id < 0 || id > 7) { throw new ValueParseException("ID超出范围(0-7)"); } } if (check1 && check2) { FuncName = valueStrings[2]; InstructionCommentManager.ModifyValue(this, oldvaluestring1, IDValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, FuncName); //ValueCommentManager.UpdateComment(InputValue, valueStrings[1]); ValueCommentManager.UpdateComment(IDValue, valueStrings[1]); } else if (!check2) { throw new ValueParseException(String.Format("找不到函数{0:s}", valueStrings[2])); } else if (!check1) { throw new ValueParseException("EVENT格式非法!"); } }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(2); * dialog.ShowLine3("F:", FreqValue); * dialog.ShowLine5("OUT:", OutputValue); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = FreqValue.ValueString; var oldvaluestring2 = OutputValue.ValueString; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyWordRegex3, ValueParser.VerifyIntKHValueRegex }); bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyBitRegex4 }); if (check1 && check2) { FreqValue = ValueParser.ParseWordValue(valueStrings[0], contextDevice); OutputValue = ValueParser.ParseBitValue(valueStrings[2], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, FreqValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, OutputValue.ValueString); ValueCommentManager.UpdateComment(FreqValue, valueStrings[1]); ValueCommentManager.UpdateComment(OutputValue, valueStrings[3]); } else if (!check1) { throw new ValueParseException("F格式非法!"); } else if (!check2) { throw new ValueParseException("OUT格式非法"); } }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(3); * dialog.ShowLine2("F:", FreqValue); * dialog.ShowLine4("DC:", DutyCycleValue); * dialog.ShowLine6("OUT:", OutputValue); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = FreqValue.ValueString; var oldvaluestring2 = DutyCycleValue.ValueString; var oldvaluestring3 = OutputValue.ValueString; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyDoubleWordRegex2, ValueParser.VerifyIntKHValueRegex }); bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyDoubleWordRegex2, ValueParser.VerifyIntKHValueRegex }); bool check3 = ValueParser.CheckValueString(valueStrings[4], new Regex[] { ValueParser.VerifyBitRegex4 }); if (check1 && check2 && check3) { FreqValue = ValueParser.ParseDoubleWordValue(valueStrings[0], contextDevice); DutyCycleValue = ValueParser.ParseDoubleWordValue(valueStrings[2], contextDevice); OutputValue = ValueParser.ParseBitValue(valueStrings[4], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, FreqValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, DutyCycleValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring3, OutputValue.ValueString); ValueCommentManager.UpdateComment(FreqValue, valueStrings[1]); ValueCommentManager.UpdateComment(DutyCycleValue, valueStrings[3]); ValueCommentManager.UpdateComment(OutputValue, valueStrings[5]); } }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(2); * dialog.Title = InstructionName; * dialog.ShowLine3("L:", LeftValue); * dialog.ShowLine5("R:", RightValue); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = LeftValue.ValueString; var oldvaluestring2 = RightValue.ValueString; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyFloatRegex }); bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyFloatRegex }); if (check1 && check2) { LeftValue = ValueParser.ParseFloatValue(valueStrings[0], contextDevice); RightValue = ValueParser.ParseFloatValue(valueStrings[2], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, LeftValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, RightValue.ValueString); ValueCommentManager.UpdateComment(LeftValue, valueStrings[1]); ValueCommentManager.UpdateComment(RightValue, valueStrings[3]); } else if (!check1) { throw new ValueParseException("L格式错误!"); } else if (!check2) { throw new ValueParseException("R格式错误!"); } }
public void Undo() { _network.RowCount = _oldRowCount; var movedElements = _network.GetElements().Where(e => e.Y >= _startRow).ToList().OrderBy(x => { return(x.Y); }).Reverse(); var movedVLines = _network.GetVerticalLines().Where(e => e.Y >= _startRow).ToList().OrderBy(x => { return(x.Y); }).Reverse(); foreach (var ele in movedElements) { _network.RemoveEle(ele.X, ele.Y); ele.Y += _count; _network.ReplaceEle(ele); } foreach (var vline in movedVLines) { _network.RemoveVLine(vline.X, vline.Y); vline.Y += _count; _network.ReplaceVLine(vline); } _network.ReplaceElements(_removedElements); _network.ReplaceVerticalLines(_removedVerticalLines); InstructionCommentManager.RaiseMappedMessageChangedEvent(); if (_oldarea != null) { _oldarea.Select(_network); } }
public static LadderNetworkViewModel CreateLadderNetworkByXElement(XElement xEle, LadderDiagramViewModel parent) { LadderNetworkViewModel result = new LadderNetworkViewModel(parent, int.Parse(xEle.Attribute("Number").Value)); result.RowCount = int.Parse(xEle.Attribute("RowCount").Value); if (xEle.Attribute("IsMasked") != null) { result.IsMasked = bool.Parse(xEle.Attribute("IsMasked").Value); } else { result.IsMasked = false; } result.NetworkBrief = xEle.Element("Brief").Value; result.NetworkDescription = xEle.Element("Description").Value; XElement contentNode = xEle.Element("LadderContent"); foreach (var instEle in CreateLadderElementsByXElement(contentNode)) { result.ReplaceElement(instEle); } foreach (var vline in CreateLadderVertialLineByXElement(contentNode)) { result.ReplaceVerticalLine(vline); } InstructionCommentManager.RaiseMappedMessageChangedEvent(); return(result); }
public void Undo() { _network.ReplaceElements(_elements); _network.ReplaceVerticalLines(_vlines); InstructionCommentManager.RaiseMappedMessageChangedEvent(); if (_area != null) { _area.Select(_network); } }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(4); * dialog.Title = InstructionName; * dialog.ShowLine1("IN1:", InputValue1); * dialog.ShowLine3("IN2:", InputValue2); * dialog.ShowLine5("IN3:", InputValue3); * dialog.ShowLine7("OUT:", OutputValue); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = InputValue1.ValueString; var oldvaluestring2 = InputValue2.ValueString; var oldvaluestring3 = InputValue3.ValueString; var oldvaluestring4 = OutputValue.ValueString; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex }); bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex }); bool check3 = ValueParser.CheckValueString(valueStrings[4], new Regex[] { ValueParser.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex }); bool check4 = ValueParser.CheckValueString(valueStrings[6], new Regex[] { ValueParser.VerifyBitRegex3 }); if (check1 && check2 && check3 && check4) { InputValue1 = ValueParser.ParseDoubleWordValue(valueStrings[0], contextDevice); InputValue2 = ValueParser.ParseDoubleWordValue(valueStrings[2], contextDevice); InputValue3 = ValueParser.ParseDoubleWordValue(valueStrings[4], contextDevice); OutputValue = ValueParser.ParseBitValue(valueStrings[6], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, InputValue1.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, InputValue2.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring3, InputValue3.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring4, OutputValue.ValueString); ValueCommentManager.UpdateComment(InputValue1, valueStrings[1]); ValueCommentManager.UpdateComment(InputValue2, valueStrings[3]); ValueCommentManager.UpdateComment(InputValue3, valueStrings[5]); ValueCommentManager.UpdateComment(OutputValue, valueStrings[7]); } else if (!check1) { throw new ValueParseException("IN1格式错误!"); } else if (!check2) { throw new ValueParseException("IN2格式错误!"); } else if (!check3) { throw new ValueParseException("IN3格式错误!"); } else if (!check4) { throw new ValueParseException("OUT格式错误!"); } }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(4); * dialog.ShowLine1("BV:", BackValue); * dialog.ShowLine3("CV:", CrawValue); * dialog.ShowLine5("SIGN:", SignalValue); * dialog.ShowLine7("OUT:", OutputValue); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = BackValue.ValueString; var oldvaluestring2 = CrawValue.ValueString; var oldvaluestring3 = SignalValue.ValueString; var oldvaluestring4 = OutputValue.ValueString; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyWordRegex3 }); bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyWordRegex3, ValueParser.VerifyIntKHValueRegex }); bool check3 = ValueParser.CheckValueString(valueStrings[4], new Regex[] { ValueParser.VerifyBitRegex5 }); bool check4 = ValueParser.CheckValueString(valueStrings[6], new Regex[] { ValueParser.VerifyBitRegex4 }); if (check1 && check2 && check3 && check4) { BackValue = ValueParser.ParseWordValue(valueStrings[0], contextDevice); CrawValue = ValueParser.ParseWordValue(valueStrings[2], contextDevice); SignalValue = ValueParser.ParseBitValue(valueStrings[4], contextDevice); OutputValue = ValueParser.ParseBitValue(valueStrings[6], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, BackValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, CrawValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring3, SignalValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring3, OutputValue.ValueString); ValueCommentManager.UpdateComment(BackValue, valueStrings[1]); ValueCommentManager.UpdateComment(CrawValue, valueStrings[3]); ValueCommentManager.UpdateComment(SignalValue, valueStrings[5]); ValueCommentManager.UpdateComment(OutputValue, valueStrings[7]); } else if (!check1) { throw new ValueParseException("BV格式非法!"); } else if (!check2) { throw new ValueParseException("CV格式非法"); } else if (!check3) { throw new ValueParseException("SIGN格式非法!"); } else if (!check4) { throw new ValueParseException("OUT格式非法!"); } }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(4); * dialog.ShowLine1("D:", ArgumentValue); * dialog.ShowLine3("V:", VelocityValue); * dialog.ShowLine5("OUT1:", OutputValue1); * dialog.ShowLine7("OUT2:", OutputValue2); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = ArgumentValue.ValueString; var oldvaluestring2 = VelocityValue.ValueString; var oldvaluestring3 = OutputValue1.ValueString; var oldvaluestring4 = OutputValue2.ValueString; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyWordRegex3 }); bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyWordRegex3, ValueParser.VerifyIntKHValueRegex }); bool check3 = ValueParser.CheckValueString(valueStrings[4], new Regex[] { ValueParser.VerifyBitRegex4 }); bool check4 = ValueParser.CheckValueString(valueStrings[6], new Regex[] { ValueParser.VerifyBitRegex4 }); if (check1 && check2 && check3) { ArgumentValue = ValueParser.ParseWordValue(valueStrings[0], contextDevice); VelocityValue = ValueParser.ParseWordValue(valueStrings[2], contextDevice); OutputValue1 = ValueParser.ParseBitValue(valueStrings[4], contextDevice); OutputValue2 = ValueParser.ParseBitValue(valueStrings[6], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, ArgumentValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, VelocityValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring3, OutputValue1.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring3, OutputValue2.ValueString); ValueCommentManager.UpdateComment(ArgumentValue, valueStrings[1]); ValueCommentManager.UpdateComment(VelocityValue, valueStrings[3]); ValueCommentManager.UpdateComment(OutputValue1, valueStrings[5]); ValueCommentManager.UpdateComment(OutputValue2, valueStrings[7]); } else if (!check1) { throw new ValueParseException("D格式非法!"); } else if (!check2) { throw new ValueParseException("V格式非法"); } else if (!check3) { throw new ValueParseException("OUT1格式非法!"); } else if (!check4) { throw new ValueParseException("OUT2格式非法!"); } }
public virtual void Undo() { _network.RowCount = _oldRowCount; _network.RemoveElements(_elements); _network.RemoveVerticalLines(_vlines); _network.ReplaceElements(_oldelements); _network.ReplaceVerticalLines(_oldvlines); InstructionCommentManager.RaiseMappedMessageChangedEvent(); _oldarea?.Select(_network); if (_oldarea == null) { _area?.Select(_network); } }
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); }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(1); * dialog.ShowLine4("OUT:", OutputValue); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = OutputValue.ValueString; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyBitRegex4 }); if (check1) { OutputValue = ValueParser.ParseBitValue(valueStrings[0], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, OutputValue.ValueString); ValueCommentManager.UpdateComment(OutputValue, valueStrings[1]); } else { throw new ValueParseException("OUT格式非法!"); } }
public virtual void Execute() { _oldRowCount = _network.RowCount; int tempRowCount = ComputeRowCount(); if (_network.RowCount < tempRowCount) { _network.RowCount = tempRowCount; } _network.RemoveElements(_oldelements); _network.RemoveVerticalLines(_oldvlines); _network.ReplaceElements(_elements); _network.ReplaceVerticalLines(_vlines); InstructionCommentManager.RaiseMappedMessageChangedEvent(); if (_area != null) { _area.Select(_network); } }
public void Redo() { _network.RemoveElements(_removedElements); _network.RemoveVerticalLines(_removedVerticalLines); var movedElements = _network.GetElements().Where(e => e.Y > _startRow + _count - 1).ToList().OrderBy(x => { return(x.Y); }); var movedVLines = _network.GetVerticalLines().Where(e => e.Y > _startRow + _count - 1).ToList().OrderBy(x => { return(x.Y); }); foreach (var ele in movedElements) { _network.RemoveEle(ele.X, ele.Y); ele.Y -= _count; _network.ReplaceEle(ele); } foreach (var vline in movedVLines) { _network.RemoveVLine(vline.X, vline.Y); vline.Y -= _count; _network.ReplaceVLine(vline); } InstructionCommentManager.RaiseMappedMessageChangedEvent(); _oldRowCount = _network.RowCount; if (_count == _network.RowCount) { _network.RowCount = 1; } else { _network.RowCount -= _count; } _network.AcquireSelectRect(); LadderDiagramViewModel ldvmodel = _network.LDVModel; ldvmodel.SelectionRect.X = 0; ldvmodel.SelectionRect.Y = (_startRow < _network.RowCount ? _startRow : _startRow - 1); ldvmodel.ProjectModel.IFacade.NavigateToNetwork( new NavigateToNetworkEventArgs( _network.NetworkNumber, ldvmodel.ProgramName, ldvmodel.SelectionRect.X, ldvmodel.SelectionRect.Y)); }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(3); * dialog.Title = InstructionName; * dialog.ShowLine2("SV:", SourceValue); * dialog.ShowLine4("TV:", DestinationValue); * dialog.ShowLine6("CT:", CountValue); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = SourceValue.ValueString; var oldvaluestring2 = DestinationValue.ValueString; var oldvaluestring3 = CountValue.ValueString; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex }); bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyDoubleWordRegex1 }); bool check3 = ValueParser.CheckValueString(valueStrings[4], new Regex[] { ValueParser.VerifyWordRegex3, ValueParser.VerifyIntKHValueRegex }); if (check1 && check2 && check3) { SourceValue = ValueParser.ParseDoubleWordValue(valueStrings[0], contextDevice); DestinationValue = ValueParser.ParseDoubleWordValue(valueStrings[2], contextDevice); CountValue = ValueParser.ParseWordValue(valueStrings[4], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, SourceValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, DestinationValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring3, CountValue.ValueString); ValueCommentManager.UpdateComment(SourceValue, valueStrings[1]); ValueCommentManager.UpdateComment(DestinationValue, valueStrings[3]); ValueCommentManager.UpdateComment(CountValue, valueStrings[5]); } else if (!check1) { throw new ValueParseException("SV格式错误!"); } else if (!check2) { throw new ValueParseException("TV格式错误!"); } else if (!check3) { throw new ValueParseException("CT格式错误!"); } }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(2); * dialog.Title = InstructionName; * dialog.ShowLine3("CT:", CountValue); * dialog.ShowLine5("SV:", StartValue); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = CountValue.ValueString; var oldvaluestring2 = StartValue.ValueString; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyDoubleWordRegex3 }); bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyWordRegex1, ValueParser.VerifyIntKHValueRegex }); if (check1 && check2) { try { CountValue = ValueParser.ParseWordValue(valueStrings[0], contextDevice); StartValue = ValueParser.ParseWordValue(valueStrings[2], contextDevice); } catch (ValueParseException) { CountValue = ValueParser.ParseDoubleWordValue(valueStrings[0], contextDevice); StartValue = ValueParser.ParseDoubleWordValue(valueStrings[2], contextDevice); } InstructionCommentManager.ModifyValue(this, oldvaluestring1, CountValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, StartValue.ValueString); ValueCommentManager.UpdateComment(CountValue, valueStrings[1]); ValueCommentManager.UpdateComment(StartValue, valueStrings[3]); } else if (!check1) { throw new ValueParseException("计数器输入错误!"); } else if (!check2) { throw new ValueParseException("最大值输入错误!"); } }
public static ErrorMessage Execute(LadderDiagramViewModel ladderDiagram) { ErrorType error = ErrorType.None; foreach (var network in ladderDiagram.GetNetworks().Where(x => { return(!x.IsMasked); })) { if (!network.ladderExpander.IsExpand) { network.ladderExpander.IsExpand = true; } error = CheckNetwork(network); if (error != ErrorType.None) { List <LadderNetworkViewModel> templist = new List <LadderNetworkViewModel>(); templist.Add(network); InstructionCommentManager.RaiseMappedMessageChangedEvent(); return(new ErrorMessage(error, templist)); } else { network.InitializeLadderLogicModules(); if (network.IsSingleSelected()) { network.ReleaseSelectRect(); } LadderGraphRelocationModule.Execute(network); } } //ladderDiagram.IsModify = false; if (!CheckProgramControlInstructions(ladderDiagram)) { error = ErrorType.InstPair; } InstructionCommentManager.RaiseMappedMessageChangedEvent(); return(new ErrorMessage(error, null)); }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(5); * dialog.Title = InstructionName; * dialog.ShowLine1("SV:", SourceValue); * dialog.ShowLine2("SS:", SourceStart); * dialog.ShowLine4("SC:", SourceCount); * dialog.ShowLine6("DV:", DestinationValue); * dialog.ShowLine7("DS:", DestinationStart); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = SourceValue.ValueString; var oldvaluestring2 = SourceStart.ValueString; var oldvaluestring3 = SourceCount.ValueString; var oldvaluestring4 = DestinationValue.ValueString; var oldvaluestring5 = DestinationStart.ValueString; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyWordRegex1 }); bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyIntKHValueRegex }); bool check3 = ValueParser.CheckValueString(valueStrings[4], new Regex[] { ValueParser.VerifyIntKHValueRegex }); bool check4 = ValueParser.CheckValueString(valueStrings[6], new Regex[] { ValueParser.VerifyWordRegex1 }); bool check5 = ValueParser.CheckValueString(valueStrings[8], new Regex[] { ValueParser.VerifyIntKHValueRegex }); if (check1 && check2 && check3 && check4 && check5) { SourceValue = ValueParser.ParseWordValue(valueStrings[0], contextDevice); SourceStart = ValueParser.ParseWordValue(valueStrings[2], contextDevice); SourceCount = ValueParser.ParseWordValue(valueStrings[4], contextDevice); DestinationValue = ValueParser.ParseWordValue(valueStrings[6], contextDevice); DestinationStart = ValueParser.ParseWordValue(valueStrings[8], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, SourceValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, SourceStart.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring3, SourceCount.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring4, DestinationValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring5, DestinationStart.ValueString); ValueCommentManager.UpdateComment(SourceValue, valueStrings[1]); ValueCommentManager.UpdateComment(SourceStart, valueStrings[3]); ValueCommentManager.UpdateComment(SourceCount, valueStrings[5]); ValueCommentManager.UpdateComment(DestinationValue, valueStrings[7]); ValueCommentManager.UpdateComment(DestinationStart, valueStrings[9]); } else if (!check1) { throw new ValueParseException("SV格式错误!"); } else if (!check2) { throw new ValueParseException("SS格式错误!"); } else if (!check3) { throw new ValueParseException("SC格式错误!"); } else if (!check4) { throw new ValueParseException("DV格式错误!"); } else if (!check5) { throw new ValueParseException("DS格式错误!"); } }
static private void Read(LadderNetworkViewModel lnvmodel) { int sz = ReadE32(); sz += eid; if ((option & OPTION_COMMENT) != 0) { lnvmodel.NetworkBrief = ReadTextE8(); } lnvmodel.RowCount = edata[eid++]; int le = (lnvmodel.RowCount * GlobalSetting.LadderXCapacity) >> 2; for (int y = 0; y < lnvmodel.RowCount; y++) { for (int x = 0; x < GlobalSetting.LadderXCapacity; x++) { int p = y * GlobalSetting.LadderXCapacity + x; int p1 = p >> 2; int p2 = (p & 3) * 2; if ((edata[eid + p1] & (1 << p2)) != 0) { HorizontalLineViewModel hlvmodel = new HorizontalLineViewModel(); hlvmodel.X = x; hlvmodel.Y = y; lnvmodel.ReplaceElement(hlvmodel); } if ((edata[eid + p1] & (1 << (p2 + 1))) != 0) { VerticalLineViewModel vlvmodel = new VerticalLineViewModel(); vlvmodel.X = x; vlvmodel.Y = y; lnvmodel.ReplaceVerticalLine(vlvmodel); } } } while (eid < sz) { BaseViewModel bvmodel = null; int x = edata[eid++]; int y = edata[eid++]; int catalog = LadderInstViewModelPrototype.GetCatalogFromOrder(edata[eid++]); bvmodel = LadderInstViewModelPrototype.Clone(catalog); bvmodel.X = x; bvmodel.Y = y; for (int i = 0; i < bvmodel.Model.ParaCount; i++) { IValueModel ivmold = bvmodel.Model.GetPara(i); IValueModel ivmnew = regs[ReadE16()]; if (ivmnew is DWordValue || ivmnew is DDoubleWordValue || ivmnew is DFloatValue) { if (ivmold is WordValue) { ivmnew = new DWordValue(ivmnew.Index, ivmnew.Offset); } if (ivmold is DoubleWordValue) { ivmnew = new DDoubleWordValue(ivmnew.Index, ivmnew.Offset); } if (ivmold is FloatValue) { ivmnew = new DFloatValue(ivmnew.Index, ivmnew.Offset); } } bvmodel.Model.SetPara(i, ivmnew); } lnvmodel.ReplaceElement(bvmodel); } InstructionCommentManager.RaiseMappedMessageChangedEvent(); }
/// <summary> /// 撤销 /// </summary> public void Undo() { lnvmodel.ReplaceElement(BVM_old); Element.BVModel = BVM_old; InstructionCommentManager.RaiseMappedMessageChangedEvent(); }
/// <summary> /// 执行 /// </summary> public void Execute() { lnvmodel.ReplaceElement(BVM_new); Element.BVModel = BVM_new; InstructionCommentManager.RaiseMappedMessageChangedEvent(); }