Ejemplo n.º 1
0
        static public short ShortValue(string strGroupName, string strItemName)
        {
            short sReturn = 0;

            try
            {
                sReturn = short.Parse(m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].objValue.ToString());
            }
            catch
            {
                if (m_Doc.m_dataDictionary.ContainsKey(strGroupName) == false)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("不存在组名字为:" + strGroupName + "的参数据");
                    ProjectDataS group = new ProjectDataS();
                    m_Doc.m_dataDictionary.Add(strGroupName, group);
                }
                if (m_Doc.m_dataDictionary[strGroupName].m_dataDictionary.ContainsKey(strItemName) == false)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("参数组:" + strGroupName + "不存在名字为:" + strItemName + "的参数");
                    ProjectDataBase data = new ProjectDataBase();
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary.Add(strItemName, data);
                    data.strName  = strItemName;
                    data.dataType = ProjectDataType.SHORT;
                    data.objValue = 0;
                }
                if (m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].dataType != ProjectDataType.SHORT)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("参数组:" + strGroupName + ":" + strItemName + "的参数" + "不是Short");
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].dataType = ProjectDataType.SHORT;
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].objValue = 0;
                }
            }
            return(sReturn);
        }
Ejemplo n.º 2
0
        static public string StrValue(string strGroupName, string strItemName)
        {
            string strReturn = "";

            try
            {
                strReturn = m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].objValue.ToString();
            }
            catch
            {
                if (m_Doc.m_dataDictionary.ContainsKey(strGroupName) == false)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("不存在组名字为:" + strGroupName + "的参数据");
                    ProjectDataS group = new ProjectDataS();
                    m_Doc.m_dataDictionary.Add(strGroupName, group);
                }
                if (m_Doc.m_dataDictionary[strGroupName].m_dataDictionary.ContainsKey(strItemName) == false)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("参数组:" + strGroupName + "不存在名字为:" + strItemName + "的参数");
                    ProjectDataBase data = new ProjectDataBase();
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary.Add(strItemName, data);
                    data.strName  = strItemName;
                    data.dataType = ProjectDataType.STRING;
                    data.objValue = "";
                }
                if (m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].dataType != ProjectDataType.STRING)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("参数组:" + strGroupName + ":" + strItemName + "的参数" + "不是字符");
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].dataType = ProjectDataType.STRING;
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].objValue = "";
                }
            }
            return(strReturn);
        }
Ejemplo n.º 3
0
        static public bool BOOLValue(string strGroupName, string strItemName)
        {
            bool bReturn = false;

            try
            {
                bReturn = bool.Parse(m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].objValue.ToString());
            }
            catch
            {
                if (m_Doc.m_dataDictionary.ContainsKey(strGroupName) == false)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("不存在组名字为:" + strGroupName + "的参数据");
                    ProjectDataS group = new ProjectDataS();
                    m_Doc.m_dataDictionary.Add(strGroupName, group);
                }
                if (m_Doc.m_dataDictionary[strGroupName].m_dataDictionary.ContainsKey(strItemName) == false)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("参数组:" + strGroupName + "不存在名字为:" + strItemName + "的参数");
                    ProjectDataBase data = new ProjectDataBase();
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary.Add(strItemName, data);
                    data.strName  = strItemName;
                    data.dataType = ProjectDataType.BOOL;
                    data.objValue = false;
                }
                if (m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].dataType != ProjectDataType.BOOL)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("参数组:" + strGroupName + ":" + strItemName + "的参数" + "不是布尔型");
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].dataType = ProjectDataType.BOOL;
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].objValue = false;
                }
            }
            return(bReturn);
        }
Ejemplo n.º 4
0
        static public double DoubleValue(string strGroupName, string strItemName)
        {
            double dReturn = 0.0;

            try
            {
                dReturn = double.Parse(m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].objValue.ToString());
            }
            catch
            {
                if (m_Doc.m_dataDictionary.ContainsKey(strGroupName) == false)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("不存在组名字为:" + strGroupName + "的参数据");
                    ProjectDataS group = new ProjectDataS();
                    m_Doc.m_dataDictionary.Add(strGroupName, group);
                }
                if (m_Doc.m_dataDictionary[strGroupName].m_dataDictionary.ContainsKey(strItemName) == false)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("参数组:" + strGroupName + "不存在名字为:" + strItemName + "的参数");
                    ProjectDataBase data = new ProjectDataBase();
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary.Add(strItemName, data);
                    data.strName  = strItemName;
                    data.dataType = ProjectDataType.DOUBLE;
                    data.objValue = 0.0;
                }
                if (m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].dataType != ProjectDataType.DOUBLE)
                {
                    MainModule.FormMain.m_formAlarm.InsertAlarmMessage("参数组:" + strGroupName + ":" + strItemName + "的参数" + "浮点型的");
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].dataType = ProjectDataType.DOUBLE;
                    m_Doc.m_dataDictionary[strGroupName].m_dataDictionary[strItemName].objValue = 0.0;
                }
            }
            return(dReturn);
        }
Ejemplo n.º 5
0
        private void dataGridViewOutput_CellValidated(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                string          strItemName = dataGridViewOutput.Rows[e.RowIndex].Cells[0].Value.ToString();
                ProjectDataBase data        = datas.m_dataList[e.RowIndex];

                data.objValue  = dataGridViewOutput.Rows[e.RowIndex].Cells[2].Value;
                data.strRemark = dataGridViewOutput.Rows[e.RowIndex].Cells[3].Value.ToString();
            }
            catch
            {
            }
        }
Ejemplo n.º 6
0
        private void buttonItemAdd_Click(object sender, EventArgs e)
        {
            if (textBoxItemName.Text == "")
            {
                return;
            }
            try
            {
                ProjectDataBase data = new ProjectDataBase();
                datas.m_dataDictionary.Add(textBoxItemName.Text, data);
                datas.m_dataList.Add(data);
                data.strName = textBoxItemName.Text;

                DataGridViewRow rowAdd = new DataGridViewRow();

                DataGridViewTextBoxCell NameCell = new DataGridViewTextBoxCell();
                NameCell.Value = data.strName;


                data.dataType = (ProjectDataType)(comboBoxType.SelectedIndex);
                DataGridViewComboBoxCell DataTypeCell = new DataGridViewComboBoxCell();
                foreach (ProjectDataType itemType in Enum.GetValues(typeof(ProjectDataType)))
                {
                    DataTypeCell.Items.Add(itemType);
                }
                DataTypeCell.Value = data.dataType;

                if ((ProjectDataType)(comboBoxType.SelectedIndex) == ProjectDataType.STRING)
                {
                    data.objValue = "";
                }
                if ((ProjectDataType)(comboBoxType.SelectedIndex) == ProjectDataType.DOUBLE)
                {
                    data.objValue = 0.0;
                }
                if ((ProjectDataType)(comboBoxType.SelectedIndex) == ProjectDataType.INT)
                {
                    data.objValue = (int)0;
                }
                if ((ProjectDataType)(comboBoxType.SelectedIndex) == ProjectDataType.SHORT)
                {
                    data.objValue = (short)0;
                }
                if ((ProjectDataType)(comboBoxType.SelectedIndex) == ProjectDataType.BOOL)
                {
                    data.objValue = false;
                }

                DataGridViewTextBoxCell ValueCell = new DataGridViewTextBoxCell();
                ValueCell.Value = data.objValue.ToString();


                DataGridViewTextBoxCell RemarkCell = new DataGridViewTextBoxCell();
                RemarkCell.Value = data.strRemark;

                rowAdd.Cells.Add(NameCell);
                rowAdd.Cells.Add(DataTypeCell);
                rowAdd.Cells.Add(ValueCell);
                rowAdd.Cells.Add(RemarkCell);
                dataGridViewOutput.Rows.Add(rowAdd);
            }
            catch
            {
            }
        }