Exemplo n.º 1
0
 /// <summary>
 /// clone object
 /// </summary>
 /// <returns></returns>
 public object Clone()
 {
     DataTag output = new DataTag();
     output.expression = this.expression;
     output.IsUpdated = this.IsUpdated;
     output.point = this.point;
     output.staticZero = this.staticZero;
     output.tagKind = this.tagKind;
     output.TagNameC = this.TagNameC;
     output.TagNameE = this.TagNameE;
     output.TagNameJ = this.TagNameJ;
     output.tagNo = this.tagNo;
     output.UnitC = this.UnitC;
     output.UnitE = this.UnitE;
     output.UnitJ = this.UnitJ;
     output.FilePath = this.FilePath;
     return output;
 }
Exemplo n.º 2
0
        /// <summary>
        /// load setting data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmTagSettingSelect_Load(object sender, EventArgs e)
        {
            int count = 0;
            try
            {
                string tempString = string.Empty;
                AppResource.SetControlsText(this);
                if(this.setting != null)
                {
                    dataGridView1.Rows.Clear();
                    if (this.setting != null && this.setting.DataTagList != null)
                    {
                        this.list.AddRange(this.setting.DataTagList);
                        count = this.setting.DataTagList.Length;
                        for (int i = 0; i < count; i++)
                        {

                            if (this.setting.DataTagList[i] != null)
                            {
                                dataGridView1.Rows.Add(new object[] { this.setting.DataTagList[i].TagNo, this.setting.DataTagList[i].GetSystemTagName(), this.setting.DataTagList[i].GetSystemUnit() });
                            }
                            else
                            {
                                dataGridView1.Rows.Add(new object[] { "-1", "---", "---" });
                            }
                        }
                        this.currentData = this.list[0];
                    }
                }
                else
                {
                    ShowErrorMessage(AppResource.GetString("ERROR_TAG_SETTING_DATATAG_FILE_NOT_FOUND"));
                    this.setting = new DataTagSetting();
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// get this.currentData record
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (this.list.Count > 0 && e.RowIndex >= 0)
         {
             this.currentData = this.list[e.RowIndex];
         }
     }
     catch (Exception ex)
     {
         ShowErrorMessage(ex);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// row active info
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (this.list.Count > 0)
         {
             bool oldValue = this.dirtyFlag;
             this.currentTag = this.list[e.RowIndex];
             ShowInfo(this.currentTag);
             this.dirtyFlag = oldValue;
         }
     }
     catch (Exception ex)
     {
         ShowErrorMessage(ex);
     }
 }
Exemplo n.º 5
0
 private void frmTagSettingSelect_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (this.DialogResult == System.Windows.Forms.DialogResult.OK)
     {
         if (this.dataGridView1.CurrentCell.RowIndex >= 0)
         {
             this.currentData = this.list[(int)this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Cells[0].Value - 1];
             //this.currentData = this.list[this.dataGridView1.CurrentCell.RowIndex];
         }
         if (this.currentData == null || this.EditingTag == null)
         {
             e.Cancel = true;
             MessageBox.Show(AppResource.GetString("MSG_TAG_SELECT_INVALID"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return;
         }
         if (EditingTag != null)
         {
             //check to not select the same tag as editing tag
             if (this.currentData.TagNo == EditingTag.TagNo)
             {
                 e.Cancel = true;
                 MessageBox.Show(AppResource.GetString("MSG_TAG_SELECT_INVALID"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
             else if (this.EditingTag.TagKind == 2 || (!this.IsMeasure && this.EditingTag.IsBlank))
             {
                 //check not to select Calc Tag to Calc tag
                 if (this.currentData.TagKind == 2 || (!this.IsMeasure && this.currentData.IsBlank))
                 {
                     e.Cancel = true;
                     MessageBox.Show(AppResource.GetString("MSG_TAG_SELECT_INVALID"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                     return;
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
        private bool ValidateValue()
        {
            if (this.list != null)
            {
                decimal val;
                //check the last edit row
                if (!decimal.TryParse(ntbZeroStatic.Text.Trim(), out val))
                {
                    ShowInfo(this.currentTag);
                    ShowWarningMessage(AppResource.GetString("ERROR_INVALID_VALUE"));
                    ntbZeroStatic.Focus();
                    return false;
                }
                for (int i = 0; i < this.list.Count; i++)
                {
                    this.currentTag = this.list[i];
                    if (this.currentTag != null)
                    {
                        if (!string.IsNullOrEmpty(this.currentTag.GetSystemUnit()) && string.IsNullOrEmpty(this.currentTag.GetSystemTagName()))
                        {
                            dgvTagList.Rows[i].Selected = true;
                            dgvTagList.CurrentCell = dgvTagList[0, i];
                            ShowInfo(this.currentTag);

                            ShowWarningMessage(AppResource.GetString("ERROR_INVALID_VALUE"));
                            txtTagName.Focus();
                            return false;
                        }
                    }
                }
            }

            return true;
        }
Exemplo n.º 7
0
        /// <summary>
        /// update data then close
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dataTagSetting != null)
                {
                    //validate value
                    if (ValidateValue() == false)
                    { return; }
                    string retString = string.Empty;
                    for (int i = 0; i < this.dataTagSetting.DataTagList.Length; i++)
                    {
                        if (this.dataTagSetting.DataTagList[i].TagKind == 2)
                        {
                            //if (!string.IsNullOrEmpty(this.dataTagSetting.DataTagList[i].Expression))
                            //{
                                this.currentTag = this.list[i];

                                retString = EvaluateExpression(
                                    System.Text.RegularExpressions.Regex.Replace(
                                         this.dataTagSetting.DataTagList[i].Expression
                                        , @"(\[(\w*[-+/*\[\]\(\)]*)*\])+"
                                        , ""
                                        ));

                                if (!string.IsNullOrEmpty(retString))
                                {
                                    this.dgvTagList.CurrentCell = this.dgvTagList.Rows[i].Cells[0];
                                    ShowWarningMessage(retString);
                                    return;
                                }
                            //}
                        }
                    }

                    if (this.dirtyFlag)
                    {
                        if (MessageBox.Show(AppResource.GetString("MSG_CONFIRM_SAVE"), this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                        {
                            PutLog("Save DataTagSetting.xml");
                            this.dataTagSetting.DataTagList = this.list.ToArray();
                            if (IsMeasure)
                            { this.dataTagSetting.Serialize(); }
                            else
                            {
                                this.AnalyzeData.DataTagSetting.Serialize();
                            }

                            this.dirtyFlag = false;
                            this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        }
                        else
                        {
                            return;
                        }
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// update DataTagInfo
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        private bool UpdateInfo(ref DataTag value)
        {
            decimal tempData = 0;
            try
            {
                DataTag dt = new DataTag();
                dt.TagKind = Convert.ToInt32(cboTagKind.SelectedValue);

                dt.SetSystemTagName(txtTagName.Text);
                dt.SetSystemUnit(txtUnit.Text);

                dt.Point = cboPoint.SelectedIndex;
                if (decimal.TryParse(ntbZeroStatic.Text, out tempData))
                {
                    dt.StaticZero = tempData;
                }
                else
                {
                    throw new Exception(AppResource.GetString("ERROR_INVALID_VALUE"));
                }
                if (Convert.ToInt32(cboTagKind.SelectedValue) == 2)
                {
                    dt.Expression = txtCalc2.Text;
                }
                else
                { dt.Expression = string.Empty; }
                value = dt;
                return true;
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
                return false;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// show DataTag info
        /// </summary>
        /// <param name="dt"></param>
        private void ShowInfo(DataTag dt)
        {
            try
            {
                if (dt != null)
                {
                    this.isLoadingData = true;
                    ClearControls();
                    cboTagKind.SelectedValue = dt.TagKind;

                    txtTagName.Text = dt.GetSystemTagName();
                    txtUnit.Text = dt.GetSystemUnit();
                    cboPoint.SelectedIndex = dt.Point;
                    ntbZeroStatic.Text = CalcOperator.GetRoundDownString((double)dt.StaticZero , dt.Point);

                    if (dt.TagKind == 2)
                    {
                        if (dt.Expression != null)
                        {
                            txtCalc2.Text = dt.Expression;
                        }
                    }

                    if (!IsMeasure)
                    {
                        pnlTagInfo.Enabled = dt.TagKind == 2 || (dt.IsBlank && dt.TagKind == 0) ? true : false;
                        btnDelete.Enabled = dt.TagKind == 0 ? false : true;
                        if (dt.IsBlank)
                        {
                            cboTagKind.SelectedValue = 2;
                        }
                        cboTagKind.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
            finally
            { this.isLoadingData = false; }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="log">ログ</param>
        public frmTagChannelRelation(LogManager log)
        {
            InitializeComponent();

            int index = 0;
            this.log = log;

            try
            {
                //タグリスト
                this.setting = SystemSetting.DataTagSetting;
                dgvDataTag.Rows.Clear();
                if (this.setting != null && this.setting.DataTagList != null)
                {
                    this.list.AddRange(this.setting.DataTagList);
                    int count = this.setting.DataTagList.Length;
                    for (int i = 0; i < count; i++)
                    {

                        if (this.setting.DataTagList[i] != null)
                        {
                            dgvDataTag.Rows.Add(new object[] { this.setting.DataTagList[i].TagNo, this.setting.DataTagList[i].GetSystemTagName(), this.setting.DataTagList[i].GetSystemUnit() });
                        }
                        else
                        {
                            dgvDataTag.Rows.Add(new object[] { "---", "---", "---" });
                        }
                    }
                }

                this.chSetting = SystemSetting.ChannelsSetting;
                if (this.chSetting.ChannelSettingList == null)
                {
                    this.chSetting.ChannelSettingList = new ChannelSetting[10];
                    for (int i = 0; i < this.chSetting.ChannelSettingList.Length; i++)
                    {
                        this.chSetting.ChannelSettingList[i] = new ChannelSetting();
                        this.chSetting.ChannelSettingList[i].ChKind = 0;
                        this.chSetting.ChannelSettingList[i].ChNo = i + 1;
                    }
                }
                //回転数結び付け設定
                dgvRotation.Rows.Add(new string[] { "---", "---", "-1" });

                this.relationSetting = SystemSetting.RelationSetting;
                if (this.relationSetting != null && this.relationSetting.RelationList != null)
                {
                    if (this.relationSetting.RelationList.Length <= 11)
                    {
                        DataTag tag = null;
                        if (this.relationSetting.RelationList[0] != null)
                        {
                            tag = FindDataTag(this.relationSetting.RelationList[0].TagNo_1);
                            if (tag != null)
                            {
                                dgvRotation.Rows[0].Cells[0].Value = tag.GetSystemTagName();
                                dgvRotation.Rows[0].Cells[1].Value = tag.GetSystemUnit();
                                dgvRotation.Rows[0].Cells[2].Value = tag.TagNo.ToString();
                                selectedRotation = tag;
                            }
                        }

                        for (index = 1; index < 11; index++)
                        {
                            if (this.relationSetting.RelationList[index] != null)
                            {
                                tag = FindDataTag(this.relationSetting.RelationList[index].TagNo_1);
                                if (tag != null)
                                {
                                    this.selectedTagArray[index - 1] = tag;
                                }
                                if (this.relationSetting.RelationList[index].TagNo_2 > 0)
                                {
                                    tag = FindDataTag(this.relationSetting.RelationList[index].TagNo_2);
                                    this.selectedTagSecond[index - 1] = tag;
                                }
                            }

                        }

                        LoadBoardDataByChannelType();
                    }
                }
                else
                {
                    this.relationSetting.RelationList = new RelationSetting[11];
                    for (int i = 0; i < 11; i++)
                    {
                        dgvBoardChannel.Rows.Add(new string[] { i.ToString(), "---", "---", "---", "-1" });
                    }
                }

                AppResource.SetControlsText(this);
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// select rotation DataTag
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnRotation_Click(object sender, EventArgs e)
 {
     try
     {
         selectedRotation = this.list[dgvDataTag.CurrentCell.RowIndex];
         dgvRotation.Rows.Clear();
         dgvRotation.Rows.Add(new string[] { selectedRotation.GetSystemTagName(), selectedRotation.GetSystemUnit(), selectedRotation.TagNo.ToString() });
         this.relationSetting.RelationList[0] = new RelationSetting();
         this.relationSetting.RelationList[0].ChannelNo = 0;
         this.relationSetting.RelationList[0].TagNo_1 = selectedRotation.TagNo;
         this.relationSetting.RelationList[0].TagNo_2 = -1;
         this.dirtyFlag = true;
     }
     catch (Exception ex)
     {
         ShowErrorMessage(ex);
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// open pattern read
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRead_Click(object sender, EventArgs e)
        {
            try
            {
                using (var f = new frmTagChannelPatternRead())
                {
                    if (f.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                    {
                        if (f.SelectedPatternData != null)
                        {
                            lblSelectedPatternFile.Text = f.SelectedPatternFile;
                            var pt = f.SelectedPatternData;
                            //set revolution tag
                            this.selectedRotation = FindDataTag(pt.RelationSetting.RelationList[0].TagNo_1);

                            for (int i = 1; i <= 10; i++)
                            {
                                this.selectedTagArray[i - 1] = FindDataTag(pt.RelationSetting.RelationList[i].TagNo_1);
                                this.selectedTagSecond[i - 1] = FindDataTag(pt.RelationSetting.RelationList[i].TagNo_2);
                            }

                            //compare current ChannelSetting to loaded ChannelSetting
                            if (this.chSetting != null)
                            {
                                if (this.chSetting.ChannelSettingList != null)
                                {
                                    for (int k = 0; k < this.chSetting.ChannelSettingList.Length; k++)
                                    {
                                        if (this.chSetting.ChannelSettingList[k] != null)
                                        {
                                            if (pt.ChannelsSetting != null && pt.ChannelsSetting.ChannelSettingList[k] != null)
                                            {
                                                if (this.chSetting.ChannelSettingList[k].ChKind != pt.ChannelsSetting.ChannelSettingList[k].ChKind)
                                                {
                                                    this.selectedTagArray[k] = null;
                                                    this.selectedTagSecond[k] = null;
                                                }
                                            }
                                            else
                                            {
                                                this.selectedTagArray[k] = null;
                                                this.selectedTagSecond[k] = null;
                                            }
                                        }
                                        else
                                        {
                                            this.selectedTagArray[k] = null;
                                            this.selectedTagSecond[k] = null;
                                        }
                                    }
                                }
                            }
                            //this.chSetting = pt.ChannelsSetting;
                            LoadBoardDataByChannelType();
                        }
                        this.dirtyFlag = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }