Esempio n. 1
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(2);
         *  dialog.Title = InstructionName;
         *  dialog.ShowLine3("CT:", CountValue);
         *  dialog.ShowLine5("SV:", DefineValue);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var  oldvaluestring1 = CountValue.ValueString;
            var  oldvaluestring2 = DefineValue.ValueString;
            bool check1          = ValueParser.CheckValueString(valueStrings[0], new Regex[] {
                ValueParser.VerifyDoubleWordRegex3
            });
            bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] {
                ValueParser.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex
            });

            if (check1 && check2)
            {
                CountValue  = ValueParser.ParseDoubleWordValue(valueStrings[0], contextDevice);
                DefineValue = ValueParser.ParseDoubleWordValue(valueStrings[2], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring1, CountValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring2, DefineValue.ValueString);
                ValueCommentManager.UpdateComment(CountValue, valueStrings[1]);
                ValueCommentManager.UpdateComment(DefineValue, valueStrings[3]);
            }
            else if (!check1)
            {
                throw new ValueParseException("计数器输入错误!");
            }
            else if (!check2)
            {
                throw new ValueParseException("预设值输入错误!");
            }
        }
Esempio n. 2
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(3);
         *  dialog.Title = InstructionName;
         *  dialog.ShowLine3("TV:", TimerValue);
         *  dialog.ShowLine5("SV:", EndValue);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var  oldvaluestring1 = TimerValue.ValueString;
            var  oldvaluestring2 = EndValue.ValueString;
            bool check1          = ValueParser.CheckValueString(valueStrings[0], new Regex[] {
                ValueParser.VerifyWordRegex4
            });
            bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] {
                ValueParser.VerifyWordRegex3, ValueParser.VerifyIntKHValueRegex
            });

            if (check1 && check2)
            {
                TimerValue = ValueParser.ParseWordValue(valueStrings[0], contextDevice);
                EndValue   = ValueParser.ParseWordValue(valueStrings[2], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring1, TimerValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring2, EndValue.ValueString);
                ValueCommentManager.UpdateComment(TimerValue, valueStrings[1]);
                ValueCommentManager.UpdateComment(EndValue, valueStrings[3]);
            }
            else if (!check1)
            {
                throw new ValueParseException("TV格式错误!");
            }
            else if (!check2)
            {
                throw new ValueParseException("SV格式错误!");
            }
        }
Esempio n. 3
0
        /*
         * 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格式非法!");
            }
        }
Esempio n. 4
0
        /*
         * 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]);
            }
        }
Esempio n. 5
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(3, ElementPropertyDialog.INST_MBUS);
         *  dialog.Title = InstructionName;
         *  dialog.ShowLine2("COM:", COMPort);
         *  dialog.ShowLine4("TABLE:");
         *  dialog.ValueString4 = Table;
         *  dialog.ShowLine6("WR:", Message);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var  oldvaluestring1 = COMPort.ValueString;
            var  oldvaluestring2 = Table;
            var  oldvaluestring3 = Message.ValueString;
            bool check1          = ValueParser.CheckValueString(valueStrings[0], new Regex[] {
                ValueParser.VerifyWordRegex1, ValueParser.VerifyIntKHValueRegex
            });
            bool check3 = ValueParser.CheckValueString(valueStrings[4], new Regex[] {
                ValueParser.VerifyWordRegex3
            });

            if (check1 && check3)
            {
                COMPort = ValueParser.ParseWordValue(valueStrings[0], contextDevice);
                Table   = valueStrings[2];
                Message = ValueParser.ParseWordValue(valueStrings[4], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring1, COMPort.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring2, Table);
                InstructionCommentManager.ModifyValue(this, oldvaluestring3, Message.ValueString);
                ValueCommentManager.UpdateComment(COMPort, valueStrings[1]);
                ValueCommentManager.UpdateComment(Message, valueStrings[5]);
            }
            else if (!check1)
            {
                throw new ValueParseException("COM格式错误!");
            }
            else if (!check3)
            {
                throw new ValueParseException("WR格式错误!");
            }
        }
Esempio n. 6
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(4);
         *  dialog.Title = InstructionName;
         *  dialog.ShowLine1("SRC", SourceValue);
         *  dialog.ShowLine3("DST", DestinationValue);
         *  dialog.ShowLine5("N1", CountValue);
         *  dialog.ShowLine7("N2", MoveValue);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var  oldvaluestring1 = SourceValue.ValueString;
            var  oldvaluestring2 = DestinationValue.ValueString;
            var  oldvaluestring3 = CountValue.ValueString;
            var  oldvaluestring4 = MoveValue.ValueString;
            bool check1          = ValueParser.CheckValueString(valueStrings[0],
                                                                new Regex[] { ValueParser.VerifyBitRegex1 });
            bool check2 = ValueParser.CheckValueString(valueStrings[2],
                                                       new Regex[] { ValueParser.VerifyBitRegex2 });
            bool check3 = ValueParser.CheckValueString(valueStrings[4],
                                                       new Regex[] { ValueParser.VerifyWordRegex3, ValueParser.VerifyIntKHValueRegex });
            bool check4 = ValueParser.CheckValueString(valueStrings[6],
                                                       new Regex[] { ValueParser.VerifyWordRegex3, ValueParser.VerifyIntKHValueRegex });

            if (check1 && check2 && check3 && check4)
            {
                SourceValue      = ValueParser.ParseBitValue(valueStrings[0], contextDevice);
                DestinationValue = ValueParser.ParseBitValue(valueStrings[2], contextDevice);
                CountValue       = ValueParser.ParseWordValue(valueStrings[4], contextDevice);
                MoveValue        = ValueParser.ParseWordValue(valueStrings[6], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring1, SourceValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring2, DestinationValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring3, CountValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring4, MoveValue.ValueString);
                ValueCommentManager.UpdateComment(SourceValue, valueStrings[1]);
                ValueCommentManager.UpdateComment(DestinationValue, valueStrings[3]);
                ValueCommentManager.UpdateComment(CountValue, valueStrings[5]);
                ValueCommentManager.UpdateComment(MoveValue, valueStrings[7]);
            }
        }
Esempio n. 7
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());
     }
 }
Esempio n. 8
0
        /*
         * 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格式非法");
            }
        }
Esempio n. 9
0
        /*
         * 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格式错误!");
            }
        }
Esempio n. 10
0
 protected void UpdateComment(string valuestring)
 {
     if (ValueString1.Equals(valuestring))
     {
         CommentString1 = ValueCommentManager.GetComment(valuestring);
         PropertyChanged(this, new PropertyChangedEventArgs("CommentString1"));
     }
     if (ValueString2.Equals(valuestring))
     {
         CommentString2 = ValueCommentManager.GetComment(valuestring);
         PropertyChanged(this, new PropertyChangedEventArgs("CommentString2"));
     }
     if (ValueString3.Equals(valuestring))
     {
         CommentString3 = ValueCommentManager.GetComment(valuestring);
         PropertyChanged(this, new PropertyChangedEventArgs("CommentString3"));
     }
     if (ValueString4.Equals(valuestring))
     {
         CommentString4 = ValueCommentManager.GetComment(valuestring);
         PropertyChanged(this, new PropertyChangedEventArgs("CommentString4"));
     }
     if (ValueString5.Equals(valuestring))
     {
         CommentString5 = ValueCommentManager.GetComment(valuestring);
         PropertyChanged(this, new PropertyChangedEventArgs("CommentString5"));
     }
 }
Esempio n. 11
0
        private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            ValueCommentAlias comment = e.Row.DataContext as ValueCommentAlias;
            TextBox           textBox = e.EditingElement as TextBox;

            if (e.Column == elementComment)
            {
                if (comment != null && textBox != null)
                {
                    ValueCommentManager.UpdateComment(comment.Name, textBox.Text);
                }
            }
            else if (e.Column == elementAlias)
            {
                if (comment != null && textBox != null)
                {
                    if (textBox.Text != string.Empty && !ValueAliasManager.CheckAlias(comment.Name, textBox.Text))
                    {
                        LocalizedMessageBox.Show(Properties.Resources.Message_Alias_Exist, LocalizedMessageIcon.Warning);
                        e.Cancel = true;
                    }
                    else
                    {
                        ValueAliasManager.UpdateAlias(comment.Name, textBox.Text);
                    }
                }
            }
        }
Esempio n. 12
0
 private void ValueTextBox7_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (ValueParser.IsVariablePattern(ValueString7))
     {
         CommentString7 = ValueCommentManager.GetComment(ValueString7);
     }
     else
     {
         CommentString7 = ValueCommentManager.GetComment(ValueString7.ToUpper());
     }
 }
Esempio n. 13
0
 public static void LoadValueCommentsByXElement(XElement xEle)
 {
     if (xEle != null)
     {
         foreach (XElement xele in xEle.Elements("Comment"))
         {
             string valueString = xele.Attribute("Value").Value;
             string comment     = xele.Value;
             ValueCommentManager.UpdateComment(valueString, comment);
         }
     }
 }
Esempio n. 14
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  int argcount = 5;
         *  if (Value4 == ArgumentValue.Null)
         *      argcount = 4;
         *  if (Value3 == ArgumentValue.Null)
         *      argcount = 3;
         *  if (Value2 == ArgumentValue.Null)
         *      argcount = 2;
         *  if (Value1 == ArgumentValue.Null)
         *      argcount = 1;
         *  var dialog = new ElementPropertyDialog(argcount, ElementPropertyDialog.INST_CALLM);
         *  switch (argcount)
         *  {
         *      case 1:
         *          dialog.ShowLine1("FUNC:");
         *          dialog.ValueString1 = FuncName;
         *          break;
         *      case 2:
         *          dialog.ShowLine1("FUNC:");
         *          dialog.ValueString1 = FuncName;
         *          dialog.ShowLine2(Value1.ArgumentName + ":", Value1);
         *          break;
         *      case 3:
         *          dialog.ShowLine1("FUNC:");
         *          dialog.ValueString1 = FuncName;
         *          dialog.ShowLine2(Value1.ArgumentName + ":", Value1);
         *          dialog.ShowLine3(Value2.ArgumentName + ":", Value2);
         *          break;
         *      case 4:
         *          dialog.ShowLine1("FUNC:");
         *          dialog.ValueString1 = FuncName;
         *          dialog.ShowLine2(Value1.ArgumentName + ":", Value1);
         *          dialog.ShowLine3(Value2.ArgumentName + ":", Value2);
         *          dialog.ShowLine4(Value3.ArgumentName + ":", Value3);
         *          break;
         *      case 5:
         *          dialog.ShowLine1("FUNC:");
         *          dialog.ValueString1 = FuncName;
         *          dialog.ShowLine2(Value1.ArgumentName + ":", Value1);
         *          dialog.ShowLine3(Value2.ArgumentName + ":", Value2);
         *          dialog.ShowLine4(Value3.ArgumentName + ":", Value3);
         *          dialog.ShowLine5(Value4.ArgumentName + ":", Value4);
         *          break;
         *  }
         *  return dialog;
         * }
         */
        public void AcceptNewValues(string _funcname, string _funccomment, ArgumentValue[] _values)
        {
            var oldvaluestring1 = FuncName;
            var oldvaluestring2 = Value1.ValueString;
            var oldvaluestring3 = Value2.ValueString;
            var oldvaluestring4 = Value3.ValueString;
            var oldvaluestring5 = Value4.ValueString;

            FuncName    = _funcname;
            FuncComment = _funccomment;
            if (_values.Length > 0)
            {
                Value1 = _values[0];
                InstructionCommentManager.ModifyValue(this, oldvaluestring2, Value1.ValueString);
                ValueCommentManager.UpdateComment(Value1, Value1.Comment);
            }
            else
            {
                Value1 = ArgumentValue.Null;
            }
            if (_values.Length > 1)
            {
                Value2 = _values[1];
                InstructionCommentManager.ModifyValue(this, oldvaluestring3, Value2.ValueString);
                ValueCommentManager.UpdateComment(Value2, Value2.Comment);
            }
            else
            {
                Value2 = ArgumentValue.Null;
            }
            if (_values.Length > 2)
            {
                Value3 = _values[2];
                InstructionCommentManager.ModifyValue(this, oldvaluestring4, Value3.ValueString);
                ValueCommentManager.UpdateComment(Value3, Value3.Comment);
            }
            else
            {
                Value3 = ArgumentValue.Null;
            }
            if (_values.Length > 3)
            {
                Value4 = _values[3];
                InstructionCommentManager.ModifyValue(this, oldvaluestring5, Value4.ValueString);
                ValueCommentManager.UpdateComment(Value4, Value4.Comment);
            }
            else
            {
                Value4 = ArgumentValue.Null;
            }
            UpdateCommentContent();
        }
Esempio n. 15
0
        /*
         * 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格式错误!");
            }
        }
Esempio n. 16
0
        /*
         * 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格式非法!");
            }
        }
Esempio n. 17
0
        /*
         * 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格式非法!");
            }
        }
Esempio n. 18
0
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var oldvaluestring = Value.ValueString;

            if (ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyBitRegex3 }))
            {
                Value = ValueParser.ParseBitValue(valueStrings[0], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring, Value.ValueString);
                ValueCommentManager.UpdateComment(Value, valueStrings[1]);
            }
            else
            {
                throw new ValueParseException("Unexpected input");
            }
        }
Esempio n. 19
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(1);
         *  dialog.Title = InstructionName;
         *  dialog.ShowLine4("LBL",LBLIndex);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var oldvaluestring = LBLIndex.ValueString;

            if (ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyIntKHValueRegex }))
            {
                LBLIndex = ValueParser.ParseWordValue(valueStrings[0], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring, LBLIndex.ValueString);
                ValueCommentManager.UpdateComment(LBLIndex, valueStrings[1]);
            }
            else
            {
                throw new ValueParseException("Unexpected input");
            }
        }
Esempio n. 20
0
        public static void ImportExcute(string filename, IEnumerable <ValueCommentAlias> elementCollection, string separator)
        {
            StreamReader stream = new StreamReader(File.OpenRead(filename));
            string       line;

            while (!stream.EndOfStream)
            {
                line = stream.ReadLine();
                string[] eles = line.Split(new string[] { separator }, StringSplitOptions.None);
                int      last, first = line.IndexOf(separator);
                string   name = line.Substring(0, first);
                string   alias, comment;
                if (QuotationOperation(ref line, out comment, out alias, out last, separator))
                {
                    if (elementCollection.ToList().Exists(x => { return(x.Name == name); }))
                    {
                        var valueCommentAlias = elementCollection.Where(x => { return(x.Name == name); }).First();
                        if (valueCommentAlias.Comment != comment)
                        {
                            if (comment == string.Empty)
                            {
                                valueCommentAlias.HasComment = false;
                            }
                            else
                            {
                                valueCommentAlias.HasComment = true;
                            }
                            ValueCommentManager.UpdateComment(name, comment);
                        }
                        if (valueCommentAlias.Alias != alias && !elementCollection.ToList().Exists(x => { return(x.Name != name && x.Alias == alias && alias != string.Empty); }))
                        {
                            if (alias == string.Empty)
                            {
                                valueCommentAlias.HasAlias = false;
                            }
                            else
                            {
                                valueCommentAlias.HasAlias = true;
                            }
                            ValueAliasManager.UpdateAlias(name, alias);
                        }
                    }
                }
            }
            stream.Close();
        }
Esempio n. 21
0
 public App()
 {
     splashScreen = new SplashScreen(@"Resources\Image\SplashScreen.png");
     splashScreen.Show(false, true);
     InitializeComponent();
     SpecialValueManager.Initialize();
     ValueCommentManager.Initialize();
     ValueAliasManager.Initialize();
     SettingManager.Load();
     if (GlobalSetting.IsOpenLSetting && GlobalSetting.LanagArea != string.Empty)
     {
         Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(GlobalSetting.LanagArea);
     }
     Exit    += App_Exit;
     Startup += App_Startup;
     DispatcherUnhandledException += App_DispatcherUnhandledException;
 }
Esempio n. 22
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);
        }
Esempio n. 23
0
        /*
         * 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格式非法!");
            }
        }
Esempio n. 24
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(2);
         *  dialog.Title = InstructionName;
         *  dialog.ShowLine3("DW1",Value1);
         *  dialog.ShowLine5("DW2",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.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex }) && ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyDoubleWordRegex1, ValueParser.VerifyIntKHValueRegex }))
            {
                Value1 = ValueParser.ParseDoubleWordValue(valueStrings[0], contextDevice);
                Value2 = ValueParser.ParseDoubleWordValue(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");
            }
        }
Esempio n. 25
0
        /*
         * 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.VerifyFloatRegex, ValueParser.VerifyFloatKValueRegex }) && ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyFloatRegex }))
            {
                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
            {
                throw new ValueParseException("Unexpected input");
            }
        }
Esempio n. 26
0
        private void OnClearButtonClick(object sender, RoutedEventArgs e)
        {
            var selectedItems = ElementDataGrid.SelectedItems;

            foreach (var item in selectedItems)
            {
                var tempitem = item as ValueCommentAlias;
                if (tempitem.Comment != string.Empty)
                {
                    tempitem.Comment    = string.Empty;
                    tempitem.HasComment = false;
                    ValueCommentManager.UpdateComment(tempitem.Name, tempitem.Comment);
                }
                if (tempitem.Alias != string.Empty)
                {
                    tempitem.Alias    = string.Empty;
                    tempitem.HasAlias = false;
                    ValueAliasManager.UpdateAlias(tempitem.Name, tempitem.Alias);
                }
            }
        }
Esempio n. 27
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(3);
         *  dialog.Title = InstructionName;
         *  dialog.ShowLine2("COM:", COMPort);
         *  dialog.ShowLine4("ADDR:", BaseValue);
         *  dialog.ShowLine6("LEN:", CountValue);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var  oldvaluestring1 = COMPort.ValueString;
            var  oldvaluestring2 = BaseValue.ValueString;
            var  oldvaluestring3 = CountValue.ValueString;
            bool check1          = ValueParser.CheckValueString(valueStrings[0], new Regex[] {
                ValueParser.VerifyIntKHValueRegex
            });
            bool check2 = ValueParser.CheckValueString(valueStrings[2], new Regex[] {
                ValueParser.VerifyWordRegex3
            });
            bool check3 = ValueParser.CheckValueString(valueStrings[4], new Regex[] {
                ValueParser.VerifyWordRegex3, ValueParser.VerifyIntKHValueRegex
            });

            if (check1 && check2 && check3)
            {
                COMPort    = ValueParser.ParseWordValue(valueStrings[0], contextDevice);
                BaseValue  = ValueParser.ParseWordValue(valueStrings[2], contextDevice);
                CountValue = ValueParser.ParseWordValue(valueStrings[4], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring1, COMPort.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring2, BaseValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring3, CountValue.ValueString);
                ValueCommentManager.UpdateComment(COMPort, valueStrings[1]);
                ValueCommentManager.UpdateComment(BaseValue, valueStrings[3]);
                ValueCommentManager.UpdateComment(CountValue, valueStrings[5]);
            }
            else if (!check1)
            {
                throw new ValueParseException("COM格式错误!");
            }
            else if (!check2)
            {
                throw new ValueParseException("ADDR格式错误!");
            }
            else if (!check3)
            {
                throw new ValueParseException("LEN格式错误!");
            }
        }
Esempio n. 28
0
        /*
         * 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 void UpdateComment()
        {
            foreach (TextBlock comment in comments)
            {
                if (G_Inst.Children.Contains(comment))
                {
                    G_Inst.Children.Remove(comment);
                }
            }
            comments.Clear();
            int rowid = 0;

            foreach (PLCOriginInst inst in insts)
            {
                BaseViewModel bvmodel = inst.ProtoType;
                if (bvmodel != null)
                {
                    TextBlock cmt = new TextBlock();
                    cmt.Visibility = iscommentmode
                        ? Visibility.Visible
                        : Visibility.Hidden;
                    cmt.Foreground = Brushes.Green;
                    cmt.Text       = "//";
                    BaseModel bmodel = bvmodel.Model;
                    for (int i = 0; i < bmodel.ParaCount; i++)
                    {
                        IValueModel ivmodel = bmodel.GetPara(i);
                        cmt.Text += String.Format("{0:s}:{1:s},",
                                                  ivmodel.ValueString,
                                                  ValueCommentManager.GetComment(ivmodel));
                    }
                    Grid.SetRow(cmt, rowid);
                    Grid.SetColumn(cmt, 7);
                    G_Inst.Children.Add(cmt);
                    comments.Add(cmt);
                }
                rowid++;
            }
        }
Esempio n. 30
0
        /*
         * public override IPropertyDialog PreparePropertyDialog()
         * {
         *  var dialog = new ElementPropertyDialog(3);
         *  dialog.Title = InstructionName;
         *  dialog.ShowLine2("S",SourceValue);
         *  dialog.ShowLine4("D",DestinationValue);
         *  dialog.ShowLine6("N",Count);
         *  return dialog;
         * }
         */
        public override void AcceptNewValues(IList <string> valueStrings, Device contextDevice)
        {
            var oldvaluestring1 = SourceValue.ValueString;
            var oldvaluestring2 = DestinationValue.ValueString;
            var oldvaluestring3 = Count.ValueString;

            if (ValueParser.CheckValueString(valueStrings[0], new Regex[] { ValueParser.VerifyWordRegex1 }) && ValueParser.CheckValueString(valueStrings[2], new Regex[] { ValueParser.VerifyWordRegex2 }) && ValueParser.CheckValueString(valueStrings[4], new Regex[] { ValueParser.VerifyWordRegex3, ValueParser.VerifyIntKHValueRegex }))
            {
                SourceValue      = ValueParser.ParseWordValue(valueStrings[0], contextDevice);
                DestinationValue = ValueParser.ParseWordValue(valueStrings[2], contextDevice);
                Count            = ValueParser.ParseWordValue(valueStrings[4], contextDevice);
                InstructionCommentManager.ModifyValue(this, oldvaluestring1, SourceValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring2, DestinationValue.ValueString);
                InstructionCommentManager.ModifyValue(this, oldvaluestring3, Count.ValueString);
                ValueCommentManager.UpdateComment(SourceValue, valueStrings[1]);
                ValueCommentManager.UpdateComment(DestinationValue, valueStrings[3]);
                ValueCommentManager.UpdateComment(Count, valueStrings[5]);
            }
            else
            {
                throw new ValueParseException("Unexpected input");
            }
        }