public override void ParseValue(IList <string> valueStrings) { try { InputValue1 = ValueParser.ParseFloatValue(valueStrings[0]); } catch (ValueParseException exception) { InputValue1 = FloatValue.Null; } try { InputValue2 = ValueParser.ParseFloatValue(valueStrings[1]); } catch (ValueParseException exception) { InputValue2 = FloatValue.Null; } try { OutputValue = ValueParser.ParseFloatValue(valueStrings[2]); } catch (ValueParseException exception) { OutputValue = FloatValue.Null; } }
/* * 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 override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(2); * dialog.Title = InstructionName; * dialog.ShowLine3("IN:", InputValue); * dialog.ShowLine5("OUT:", OutputValue); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = InputValue.ValueString; var oldvaluestring2 = OutputValue.ValueString; bool check1 = ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyFloatRegex, ValueParser.VerifyIntKHValueRegex }); bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyFloatRegex }); if (check1 && check2) { InputValue = ValueParser.ParseFloatValue(valueStrings[0], contextDevice); OutputValue = ValueParser.ParseFloatValue(valueStrings[2], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, InputValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, OutputValue.ValueString); ValueCommentManager.UpdateComment(InputValue, valueStrings[1]); ValueCommentManager.UpdateComment(OutputValue, valueStrings[3]); } else if (!check1) { throw new ValueParseException("IN格式错误!"); } else if (!check2) { throw new ValueParseException("OUT格式错误!"); } }
/// <summary> /// 获取一个监视表格内所有被监视的软元件 /// </summary> /// <param name="table">监视表格</param> static private void GetRegisters(MonitorVariableTable table) { foreach (ElementModel emodel in table.Elements) { string ivname = emodel.ShowName; if (!regids.ContainsKey(ivname)) { IValueModel ivmodel = null; switch (emodel.ShowType) { case "BOOL": ivmodel = ValueParser.ParseBitValue(ivname); break; case "WORD": case "UWORD": case "BCD": ivmodel = ValueParser.ParseWordValue(ivname); break; case "DWORD": case "UDWORD": ivmodel = ValueParser.ParseDoubleWordValue(ivname); break; case "FLOAT": ivmodel = ValueParser.ParseFloatValue(ivname); break; } regs.Add(ivmodel); regids.Add(ivname, regids.Count()); } } }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(2); * dialog.Title = InstructionName; * dialog.ShowLine3("FW1",Value1); * dialog.ShowLine5("FW2",Value2); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = Value1.ValueString; var oldvaluestring2 = Value2.ValueString; if (ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyFloatRegex, ValueParser.VerifyFloatKValueRegex }) && ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyFloatRegex, ValueParser.VerifyFloatKValueRegex })) { Value1 = ValueParser.ParseFloatValue(valueStrings[0], contextDevice); Value2 = ValueParser.ParseFloatValue(valueStrings[2], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, Value1.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, Value2.ValueString); ValueCommentManager.UpdateComment(Value1, valueStrings[1]); ValueCommentManager.UpdateComment(Value2, valueStrings[3]); } else { throw new ValueParseException("Unexpected input"); } }
public override void ParseValue(IList <string> valueStrings) { try { LeftValue = ValueParser.ParseFloatValue(valueStrings[0]); } catch (ValueParseException) { LeftValue = FloatValue.Null; } try { RightValue = ValueParser.ParseFloatValue(valueStrings[1]); } catch (ValueParseException) { RightValue = FloatValue.Null; } }
/* * public override IPropertyDialog PreparePropertyDialog() * { * var dialog = new ElementPropertyDialog(2); * dialog.Title = InstructionName; * dialog.ShowLine3("In",InputValue); * dialog.ShowLine5("Out",OutputValue); * return dialog; * } */ public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice) { var oldvaluestring1 = InputValue.ValueString; var oldvaluestring2 = OutputValue.ValueString; if (ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyDoubleWordRegex2, ValueParser.VerifyIntKHValueRegex }) && ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyFloatRegex })) { InputValue = ValueParser.ParseDoubleWordValue(valueStrings[0], contextDevice); OutputValue = ValueParser.ParseFloatValue(valueStrings[2], contextDevice); InstructionCommentManager.ModifyValue(this, oldvaluestring1, InputValue.ValueString); InstructionCommentManager.ModifyValue(this, oldvaluestring2, OutputValue.ValueString); ValueCommentManager.UpdateComment(InputValue, valueStrings[1]); ValueCommentManager.UpdateComment(OutputValue, valueStrings[3]); } else { throw new ValueParseException("Unexpected input"); } }
public override void ParseValue(IList <string> valueStrings) { try { SourceValue = ValueParser.ParseFloatValue(valueStrings[0]); } catch (ValueParseException exception) { SourceValue = FloatValue.Null; } try { DestinationValue = ValueParser.ParseFloatValue(valueStrings[1]); } catch (ValueParseException exception) { DestinationValue = FloatValue.Null; } }