Пример #1
0
 /// <summary>
 /// opcitem save button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void opcitem_save_button_Click(object sender, EventArgs e)
 {
     try
     {
         if (!OpcitemCheck())
         {
             MessageBoxEx.Show("界面参数不能为空!");
             return;
         }
         if (xio.Name == opcitem_name_textBox.Text)
         {
             xio.Name          = opcitem_name_textBox.Text;
             xio.Addr          = opcitem_address_textBox.Text;
             xio.BackAddr      = opcitem_backAddress_textBox.Text;
             xio.AddrType      = opcitem_addressType_textBox.Text;
             xio.OperationDesc = opcitem_operationDesc_textBox.Text;
             if (xio.Tag.Count == 0)
             {
                 Xml_InfoConfig_Tags xml_InfoConfig_Tags = new Xml_InfoConfig_Tags();
                 xml_InfoConfig_Tags.Name = "条码数据";
                 xio.Tag.Add(xml_InfoConfig_Tags);
             }
             XML_Tool.Save();
             MessageBoxEx.Show("opcitem层修改成功!");
         }
         else
         {
             Xml_InfoConfig_Opcitem xml_InfoConfig_Opcitem = new Xml_InfoConfig_Opcitem();
             xml_InfoConfig_Opcitem.Name          = opcitem_name_textBox.Text;
             xml_InfoConfig_Opcitem.Addr          = opcitem_address_textBox.Text;
             xml_InfoConfig_Opcitem.BackAddr      = opcitem_backAddress_textBox.Text;
             xml_InfoConfig_Opcitem.AddrType      = opcitem_addressType_textBox.Text;
             xml_InfoConfig_Opcitem.OperationDesc = opcitem_operationDesc_textBox.Text;
             Xml_InfoConfig_Tags xml_InfoConfig_Tags = new Xml_InfoConfig_Tags();
             xml_InfoConfig_Tags.Name = "条码数据";
             xml_InfoConfig_Opcitem.Tag.Add(xml_InfoConfig_Tags);
             xis.Opcitem.Add(xml_InfoConfig_Opcitem);
             XML_Tool.Save();
             MessageBoxEx.Show("opcitem层添加成功!");
         }
         PageFrush(treeNode);
     }
     catch (Exception ex)
     {
         MessageBoxEx.Show("opcitem保存异常:" + ex.Message);
     }
 }
Пример #2
0
 /// <summary>
 /// station save button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void station_save_button_Click(object sender, EventArgs e)
 {
     try
     {
         if (!StationCheck())
         {
             MessageBoxEx.Show("工位名称不能为空!");
             return;
         }
         if (xis.Name == station_name_textBox.Text)
         {
             xis.Name      = station_name_textBox.Text;
             xis.Desc      = station_desc_textBox.Text;
             xis.PlanTime  = station_planTime_textBox.Text;
             xis.AlarmAddr = station_alarmAddress_textBox.Text;
             xis.AddrType  = station_addressType_textBox.Text;
             XML_Tool.Save();
             MessageBoxEx.Show("station层修改成功!");
         }
         else
         {
             Xml_InfoConfig_Station xml_InfoConfig_Station = new Xml_InfoConfig_Station
             {
                 Name      = station_name_textBox.Text,
                 Desc      = station_desc_textBox.Text,
                 PlanTime  = station_planTime_textBox.Text,
                 AlarmAddr = station_alarmAddress_textBox.Text,
                 AddrType  = station_addressType_textBox.Text
             };
             Xml_InfoConfig_Opcitem xml_InfoConfig_Opcitem = new Xml_InfoConfig_Opcitem();
             xml_InfoConfig_Opcitem.Name = "条码验证";
             xml_InfoConfig_Station.Opcitem.Add(xml_InfoConfig_Opcitem);
             xi.STATION.Add(xml_InfoConfig_Station);
             XML_Tool.Save();
             MessageBox.Show("station层保存成功!");
             PageFrush(treeNode);
         }
     }
     catch (Exception ex)
     {
         MessageBoxEx.Show("station层保存按钮事件出现异常:" + ex.Message);
     }
 }
Пример #3
0
        /// <summary>
        /// tree select event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void plcAddress_tree_advTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                if (e.Node.Level == 0)
                {
                    ShowPanel(0);
                    var line = XML_Tool.xml.LINE.Single(n => n.Name == e.Node.Text);
                    xi = line;
                    line_name_textBox.Text         = xi.Name;
                    line_index_textBox.Text        = xi.Index.ToString();
                    line_heartAddress_textBox.Text = xi.HeartBeatAddr;
                    line_ip_textBox.Text           = xi.IP;
                    line_plcSolt_textBox.Text      = xi.PLCSlot.ToString();
                    line_threadCount_textBox.Text  = xi.ThreaCount.ToString();
                    line_updateRate_textBox.Text   = xi.UpdateRate.ToString();
                    line_plcBrand_comboBox.Text    = xi.PLCType;
                    line_addressType_textBox.Text  = xi.AddrType;
                    treeNode = plcAddress_tree_advTree.Nodes[e.Node.Index];
                }
                else if (e.Node.Level == 1)
                {
                    ShowPanel(1);
                    var line = XML_Tool.xml.LINE.Single(n => n.Name == e.Node.Parent.Text);
                    xi = line;
                    var station = line.STATION.Single(n => n.Name == e.Node.Text);
                    xis = station;
                    station_name_textBox.Text         = station.Name;
                    station_desc_textBox.Text         = station.Desc;
                    station_planTime_textBox.Text     = station.PlanTime;
                    station_alarmAddress_textBox.Text = station.AlarmAddr;
                    station_addressType_textBox.Text  = station.AddrType;
                    treeNode = plcAddress_tree_advTree.Nodes[e.Node.Parent.Index];
                }
                else if (e.Node.Level == 2)
                {
                    ShowPanel(2);
                    var station = XML_Tool.xml.LINE.Single(n => n.Name == e.Node.Parent.Parent.Text).STATION.
                                  Single(n => n.Name == e.Node.Parent.Text);
                    xis = station;
                    var opc = station.Opcitem.Single(n => n.Name == e.Node.Text);
                    xio = opc;
                    opcitem_name_textBox.Text          = opc.Name;
                    opcitem_address_textBox.Text       = opc.Addr;
                    opcitem_backAddress_textBox.Text   = opc.BackAddr;
                    opcitem_addressType_textBox.Text   = opc.AddrType;
                    opcitem_operationDesc_textBox.Text = opc.OperationDesc;
                    treeNode = plcAddress_tree_advTree.Nodes[e.Node.Parent.Parent.Index];
                }
                else if (e.Node.Level == 3)
                {
                    ShowPanel(3);
                    var opc = XML_Tool.xml.LINE.Single(n => n.Name == e.Node.Parent.Parent.Parent.Text).STATION.
                              Single(n => n.Name == e.Node.Parent.Parent.Text).Opcitem.
                              Single(n => n.Name == e.Node.Parent.Text);
                    xio = opc;
                    var tag = opc.Tag.Single(n => n.Name == e.Node.Text);
                    xit = tag;
                    tag_name_textBox.Text      = xit.Name;
                    tag_tag_textBox.Text       = xit.Tag.ToString();
                    tag_tableName_textBox.Text = xit.TableName;
                    treeNode = plcAddress_tree_advTree.Nodes[e.Node.Parent.Parent.Parent.Index];
                }
                else if (e.Node.Level == 4)
                {
                    ShowPanel(4);
                    var tag = XML_Tool.xml.LINE.Single(n => n.Name == e.Node.Parent.Parent.Parent.Parent.Text).
                              STATION.Single(n => n.Name == e.Node.Parent.Parent.Parent.Text).Opcitem.
                              Single(n => n.Name == e.Node.Parent.Parent.Text).Tag.Single(n => n.Name == e.Node.Parent.Text);
                    xit = tag;
                    var dataitem = tag.Dataitem.Single(n => n.Name == e.Node.Text);
                    xid = dataitem;
                    dataitem_name_textBox.Text          = xid.Name;
                    dataitem_address_textBox.Text       = xid.Addr;
                    dataitem_columnName_textBox.Text    = xid.ColmnName;
                    dataitem_addressType_textBox.Text   = xid.AddrType;
                    dataitem_addressLength_textBox.Text = xid.AddrLength;
                    treeNode = plcAddress_tree_advTree.Nodes[e.Node.Parent.Parent.Parent.Parent.Index];
                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show("树点击事件出现异常:" + ex.Message);
            }
        }