コード例 #1
0
        private void delete_Click(object sender, EventArgs e)
        {
            try
            {
                TreeNode node     = this.treeView1.SelectedNode;
                string   typename = node.Tag.ToString();
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].typename == typename)
                    {
                        list.RemoveAt(i);
                    }
                }
                string path = Application.StartupPath + "\\TestInfo";
                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "TypeList.json", json);

                InitTree();
                ExpandTree();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
コード例 #2
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                string path = Application.StartupPath + "\\TestInfo";
                var    item = list.Where(x => x.InstrumentCluster == combEquipment.Text && x.TypeName == combtypename.Text).FirstOrDefault();
                if (item != null)
                {
                    item.InstrumentCluster = combEquipment.Text;
                    item.TypeName          = combtypename.Text;
                }
                else
                {
                    EquipmentTestInfo testInfo = new EquipmentTestInfo();
                    testInfo.InstrumentCluster = combEquipment.Text;
                    testInfo.TypeName          = combtypename.Text;
                    list.Add(testInfo);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "InstrumentClusterTestInfo.json", json);
                LoadEquipmentTestInfo();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
コード例 #3
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(txtstepname.Text.Trim()))
                {
                    MessageBox.Show("Stepname can't be empty!");
                    return;
                }
                if (!txtstepname.Text.Trim().Contains("Step"))
                {
                    MessageBox.Show("Stepname should be like 'Step1'!");
                    return;
                }
                if (String.IsNullOrEmpty(combtypename.Text))
                {
                    MessageBox.Show("Typename can't be empty!");
                    return;
                }
                #endregion
                double result = -1;

                string path = Application.StartupPath + "\\TestInfo";
                var    item = stepList.Where(c => c.stepname == txtstepname.Text.Trim() && c.typename == combtypename.Text).FirstOrDefault();
                if (item != null)
                {
                    item.modelname = txtmodename.Text.Trim();
                    item.voltage   = double.TryParse(txtvoltage.Text.Trim(), out result) ? double.Parse(txtvoltage.Text.Trim()):0;
                    item.cycletime = double.TryParse(txtcycletime.Text.Trim(), out result) ? double.Parse(txtcycletime.Text.Trim()) : 0;
                    int msg = -1;
                    item.repeat = int.TryParse(txtrepeat.Text.Trim(), out msg) ? int.Parse(txtrepeat.Text.Trim()) : 1;
                }
                else
                {
                    TestStep step = new TestStep();
                    step.typename  = combtypename.Text;
                    step.stepname  = txtstepname.Text.Trim();
                    step.modelname = txtmodename.Text.Trim();
                    step.voltage   = double.TryParse(txtvoltage.Text.Trim(), out result) ? double.Parse(txtvoltage.Text.Trim()) : 0;
                    step.cycletime = double.TryParse(txtcycletime.Text.Trim(), out result) ? double.Parse(txtcycletime.Text.Trim()) : 0;
                    int msg = -1;
                    step.repeat = int.TryParse(txtrepeat.Text.Trim(), out msg) ? int.Parse(txtrepeat.Text.Trim()) : 1;
                    stepList.Add(step);
                }

                string json = JsonConvert.SerializeObject(stepList, Formatting.Indented);
                JsonOperate.SaveJson(path, "TestStep.json", json);
                LoadStepInfo(combtypename.Text);
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
コード例 #4
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(txttype.Text.Trim()))
                {
                    MessageBox.Show("type can't be empty!");
                    return;
                }
                if (String.IsNullOrEmpty(txtid.Text.Trim()))
                {
                    MessageBox.Show("id can't be empty!");
                    return;
                }
                if (String.IsNullOrEmpty(txtdata.Text.Trim()))
                {
                    MessageBox.Show("data can't be empty!");
                    return;
                }
                #endregion
                string path = Application.StartupPath + "\\SysConfig";
                var    item = list.Where(c => c.id == txtid.Text).FirstOrDefault();
                if (item != null)
                {
                    item.type      = txttype.Text.Trim();
                    item.dlc       = Convert.ToInt32(txtdlc.Text.Trim());
                    item.data      = txtdata.Text.Trim();
                    item.cycletime = Convert.ToInt32(txtct.Text.Trim());
                }
                else
                {
                    ManualInstruction Ins = new ManualInstruction();
                    Ins.type      = txttype.Text.Trim();
                    Ins.id        = txtid.Text.Trim();
                    Ins.dlc       = Convert.ToInt32(txtdlc.Text.Trim());
                    Ins.data      = txtdata.Text.Trim();
                    Ins.cycletime = Convert.ToInt32(txtct.Text.Trim());
                    list.Add(Ins);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "ManualInstrustion.json", json);
                LoadInfo();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
コード例 #5
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(txtPortName.Text.Trim()))
                {
                    MessageBox.Show("AmmeterName can't be empty!");
                    return;
                }
                if (String.IsNullOrEmpty(txtPortName.Text))
                {
                    MessageBox.Show("PortName can't be empty!");
                    return;
                }
                #endregion
                string path = Application.StartupPath + "\\SysConfig";
                var    item = list.Where(c => c.ammeterName == txtAmmeterName.Text.Trim() && c.portName == txtPortName.Text).FirstOrDefault();
                if (item != null)
                {
                    item.baudrate  = String.IsNullOrEmpty(txtBaudRate.Text.Trim())?0:Convert.ToInt32(txtBaudRate.Text.Trim());
                    item.parity    = (Parity)Enum.Parse(typeof(Parity), label11.Text);
                    item.dataBits  = String.IsNullOrEmpty(txtDataBits.Text.Trim()) ? 0 : Convert.ToInt32(txtDataBits.Text.Trim());
                    item.stopBits  = (StopBits)Enum.Parse(typeof(StopBits), txtStopBits.Text);
                    item.handshake = (Handshake)Enum.Parse(typeof(Handshake), txtHandshake.Text);
                }
                else
                {
                    AmmeterConfiguration ammeter = new AmmeterConfiguration();
                    ammeter.ammeterName = txtAmmeterName.Text.Trim();
                    ammeter.portName    = txtPortName.Text.Trim();
                    ammeter.baudrate    = String.IsNullOrEmpty(txtBaudRate.Text.Trim()) ? 0 : Convert.ToInt32(txtBaudRate.Text.Trim());
                    ammeter.parity      = (Parity)Enum.Parse(typeof(Parity), txtParity.Text, true);
                    ammeter.dataBits    = String.IsNullOrEmpty(txtDataBits.Text.Trim()) ? 0 : Convert.ToInt32(txtDataBits.Text.Trim());
                    ammeter.stopBits    = (StopBits)Enum.Parse(typeof(StopBits), txtStopBits.Text, true);
                    ammeter.handshake   = (Handshake)Enum.Parse(typeof(Handshake), txtHandshake.Text, true);
                    list.Add(ammeter);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "AmmeterConfiguration.json", json);
                LoadInfo();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
コード例 #6
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(txtEquipment.Text.Trim()))
                {
                    MessageBox.Show("Equipment can't be empty!");
                    return;
                }
                if (String.IsNullOrEmpty(combParamter.Text))
                {
                    MessageBox.Show("Paramter can't be empty!");
                    return;
                }
                #endregion
                string path = Application.StartupPath + "\\SysConfig";
                var    item = list.Where(c => c.InstrumentCluster == txtEquipment.Text.Trim() && c.CommunicationType == combParamter.Text).FirstOrDefault();
                if (item != null)
                {
                    item.CommunicationType = combParamter.Text;
                    item.Value             = combValue.Text;
                }
                else
                {
                    AutoTestDLL.Model.InstrumentClusterConfiguration equipment = new AutoTestDLL.Model.InstrumentClusterConfiguration();
                    equipment.InstrumentCluster = txtEquipment.Text.Trim();
                    equipment.CommunicationType = combParamter.Text;
                    equipment.Value             = combValue.Text;
                    list.Add(equipment);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "InstrumentClusterConfiguration.json", json);
                LoadInfo();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
コード例 #7
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(combChannel.Text.Trim()))
                {
                    MessageBox.Show("Channel can't be empty!");
                    return;
                }
                if (String.IsNullOrEmpty(combBaudRate.Text))
                {
                    MessageBox.Show("PortName can't be empty!");
                    return;
                }
                #endregion
                string path = Application.StartupPath + "\\SysConfig";
                var    item = list.Where(c => c.Channel == combChannel.Text).FirstOrDefault();
                if (item != null)
                {
                    item.Baudrate = combBaudRate.Text.Trim();
                }
                else
                {
                    CAN can = new CAN();
                    can.Channel  = String.IsNullOrEmpty(combChannel.Text.Trim()) ? "" : combChannel.Text.Trim();
                    can.Baudrate = combBaudRate.Text.Trim();
                    list.Add(can);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "CAN.json", json);
                LoadInfo();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
コード例 #8
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(txtic.Text.Trim()))
                {
                    MessageBox.Show("instrumentcluster can't be empty!");
                    return;
                }
                if (String.IsNullOrEmpty(txtaddr.Text.Trim()))
                {
                    MessageBox.Show("address can't be empty!");
                    return;
                }
                #endregion
                string path = Application.StartupPath + "\\SysConfig";
                var    item = list.Where(c => c.instrumentcluster == txtic.Text).FirstOrDefault();
                if (item != null)
                {
                    item.address = txtaddr.Text.Trim();
                }
                else
                {
                    PowerMeter Ins = new PowerMeter();
                    Ins.instrumentcluster = txtic.Text.Trim();
                    Ins.address           = txtaddr.Text.Trim();
                    list.Add(Ins);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "PowerMeter.json", json);
                LoadInfo();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
コード例 #9
0
 private void delete_Click(object sender, EventArgs e)
 {
     try
     {
         string instrumentcluster = this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["instrumentcluster"].Value.ToString();
         for (int i = 0; i < list.Count; i++)
         {
             if (list[i].instrumentcluster.ToString() == instrumentcluster)
             {
                 list.RemoveAt(i);
             }
         }
         string path = Application.StartupPath + "\\SysConfig";
         string json = JsonConvert.SerializeObject(list, Formatting.Indented);
         JsonOperate.SaveJson(path, "PowerMeter.json", json);
         LoadInfo();
     }
     catch (Exception ex)
     {
         logger.Error(ex, ex.Message);
     }
 }
コード例 #10
0
        private void save_Click(object sender, EventArgs e)
        {
            try
            {
                #region CheckInput
                if (String.IsNullOrEmpty(txttypename.Text))
                {
                    MessageBox.Show("typename can't be empty!");
                    return;
                }
                #endregion

                string path = Application.StartupPath + "\\TestInfo";
                var    item = list.Where(c => c.typename == txttypename.Text.Trim()).FirstOrDefault();
                if (item != null)
                {
                    item.parentname = txtparentname.Text.Trim();
                    item.typeinfo   = txttypeinfo.Text.Trim();
                }
                else
                {
                    TypeList type = new TypeList();
                    type.parentname = txtparentname.Text.Trim();
                    type.typename   = txttypename.Text.Trim();
                    type.typeinfo   = txttypeinfo.Text.Trim();
                    list.Add(type);
                }

                string json = JsonConvert.SerializeObject(list, Formatting.Indented);
                JsonOperate.SaveJson(path, "TypeList.json", json);

                InitTree();
                ExpandTree();
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
        }
コード例 #11
0
 private void delete_Click(object sender, EventArgs e)
 {
     try
     {
         string equipment = this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["InstrumentCluster"].Value.ToString();
         string typename  = this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["TypeName"].Value.ToString();
         for (int i = 0; i < list.Count; i++)
         {
             if (list[i].TypeName == typename && list[i].InstrumentCluster == equipment)
             {
                 list.RemoveAt(i);
             }
         }
         string path = Application.StartupPath + "\\TestInfo";
         string json = JsonConvert.SerializeObject(list, Formatting.Indented);
         JsonOperate.SaveJson(path, "InstrumentClusterTestInfo.json", json);
         LoadEquipmentTestInfo();
     }
     catch (Exception ex)
     {
         logger.Error(ex, ex.Message);
     }
 }
コード例 #12
0
 private void delete_Click(object sender, EventArgs e)
 {
     try
     {
         string stepname = this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["stepname"].Value.ToString();
         string typename = this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["typename"].Value.ToString();
         for (int i = 0; i < stepList.Count; i++)
         {
             if (stepList[i].stepname == stepname && stepList[i].typename == typename)
             {
                 stepList.RemoveAt(i);
             }
         }
         string path = Application.StartupPath + "\\TestInfo";
         string json = JsonConvert.SerializeObject(stepList, Formatting.Indented);
         JsonOperate.SaveJson(path, "TestStep.json", json);
         LoadStepInfo(combtypename.Text);
     }
     catch (Exception ex)
     {
         logger.Error(ex, ex.Message);
     }
 }
コード例 #13
0
 private void delete_Click(object sender, EventArgs e)
 {
     try
     {
         string equipment = this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["SensorName"].Value.ToString();
         string paramter  = this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["CommunicationType"].Value.ToString();
         string value     = this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["Value"].Value.ToString();
         for (int i = 0; i < list.Count; i++)
         {
             if (list[i].SensorName == equipment && list[i].CommunicationType == paramter && list[i].Value == value)
             {
                 list.RemoveAt(i);
             }
         }
         string path = Application.StartupPath + "\\SysConfig";
         string json = JsonConvert.SerializeObject(list, Formatting.Indented);
         JsonOperate.SaveJson(path, "TempSensorConfiguration.json", json);
         LoadInfo();
     }
     catch (Exception ex)
     {
         logger.Error(ex, ex.Message);
     }
 }