Exemplo n.º 1
0
 /// <summary>
 /// 新增遥控
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void bt_ykadd_Click(object sender, EventArgs e)
 {
     Log.WriteLog("新增遥控");
     try
     {
         if ((m_obj.equtype.ToString()).StartsWith("P_"))
         {
             Yk_cfg ykcfg = new Yk_cfg();
             ykcfg.AreaID = (int)cb_ykarea.SelectedValue;
             ykcfg.Order  = Byklist.Count;
             ykcfg.EquID  = m_obj.equ.EquID;
             DBOPs ds = new DBOPs();
             int   i  = ds.InsertYKConfig(ykcfg);
             Log.WriteLog("新增遥控执行完毕");
             if (i > -1)
             {
                 ykcfg.ID = i;
                 Byklist.Add(ykcfg);
             }
             Log.WriteLog("新增遥控并添加到列表完毕");
         }
     }
     catch (Exception ee)
     {
         Log.WriteLog("新增遥控错误:" + ee.Message);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 新增遥控
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void bt_ykadd_Click(object sender, EventArgs e)
 {
     try
     {
         if ((m_obj.equtype.ToString()).StartsWith("P_"))
         {
             if (cb_ykarea.SelectedItem == null)
             {
                 MessageBox.Show("请选择分区");
                 return;
             }
             Yk_cfg ykcfg = new Yk_cfg();
             ykcfg.AreaID = (int)cb_ykarea.SelectedValue;
             ykcfg.Order  = Byklist.Count;
             ykcfg.EquID  = m_obj.equ.EquID;
             DBOPs ds = new DBOPs();
             int   i  = ds.InsertYKConfig(ykcfg);
             if (i > -1)
             {
                 ykcfg.ID = i;
                 Byklist.Add(ykcfg);
             }
         }
     }
     catch (Exception ee)
     {
         gMain.log.WriteLog("新增遥控错误:" + ee.Message);
     }
 }
Exemplo n.º 3
0
        private void bt_save_Click(object sender, EventArgs e)
        {
            var gcid = comboBox1.SelectedValue.ToString();

            if (!string.IsNullOrEmpty(gcid))
            {
                if (listView1.Items.Count > 0)
                {
                    try
                    {
                        DataStorage          ds         = new DataStorage();
                        List <Gc_triggerequ> triList    = ds.GetGctriggerEqu(gcid);
                        List <Gc_triggerequ> addTriList = new List <Gc_triggerequ>();
                        for (int i = 0; i < listView1.Items.Count; i++)
                        {
                            var trigger = triList.Where(p => p.EquID == listView1.Items[i].SubItems[0].Text).FirstOrDefault();
                            if (trigger == null)
                            {
                                int alarmID = int.Parse(listView1.Items[i].SubItems[2].Text);
                                addTriList.Add(new Gc_triggerequ {
                                    EquID = listView1.Items[i].SubItems[0].Text, GCID = gcid, AlarmTypeID = alarmID, EquRStateID = 0, IsAlarm = 0
                                });
                            }
                        }
                        DBOPs db = new DBOPs();
                        if (db.InsertAddTrigger(addTriList) < 1)
                        {
                            gMain.log.WriteLog("群控触发设备保存失败!插入数据库失败");
                        }
                        this.Hide();
                    }
                    catch (Exception ex)
                    {
                        gMain.log.WriteLog("群控触发设备保存失败:" + ex);
                        MessageBox.Show("群控触发保存失败!");
                    }
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 双击,没有选中双击批量生成设备
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void context_DoubleClicked(object sender, EventArgs e)
 {
     try
     {
         if (this.panel1.m_pCurrentObject == null)
         {
             #region create object
             createAddDialog.StartPosition = FormStartPosition.CenterParent;
             if (createAddDialog.ShowDialog(this) == DialogResult.OK)
             {
                 MyObject.ObjectType obj = (MyObject.ObjectType)createAddDialog.cb_equtype.SelectedValue;
                 int count    = (int)createAddDialog.nd_equNum.Value;//需要生成对象的数量
                 int startNum = 1;
                 int.TryParse(createAddDialog.tb_startNum.Text, out startNum);
                 int cfgNum = 0;
                 try
                 {
                     cfgNum = int.Parse(createAddDialog.tb_cfgnum.Text);
                 }
                 catch (Exception)
                 {
                     Log.WriteLog("配置号码格式不正确");
                     createAddDialog.Hide();
                 }
                 DBOPs db         = new DBOPs();
                 int   parentWith = this.panel1.BackgroundImage.Size.Width;
                 for (int i = 0; i < count; i++)
                 {
                     var lacation = ((MouseEventArgs)e).Location;
                     int x        = (int)(parentWith - 2 * lacation.X) / (count - 1) * i + lacation.X;
                     lacation = new System.Drawing.Point {
                         X = x, Y = lacation.Y
                     };
                     MyObject myObject = panel1.DrawObject(obj.ToString(), lacation);
                     if (createAddDialog.checkbox_way.Checked)
                     {
                         myObject.equ.EquName = createAddDialog.tb_nameFirst.Text + (startNum++);
                     }
                     else
                     {
                         myObject.equ.EquName = createAddDialog.tb_nameFirst.Text + (startNum--);
                     }
                     if (obj == MyObject.ObjectType.EP_T)
                     {
                         ep_c_cfg ep = new ep_c_cfg();
                         ep.EquID = myObject.equ.EquID;
                         ep.Mesg  = myObject.equ.EquName;
                         if (createAddDialog.checkbox_way.Checked)
                         {
                             ep.EPNum = (cfgNum++).ToString();;
                         }
                         else
                         {
                             ep.EPNum = (cfgNum--).ToString();
                         }
                         db.InsertEp(ep);
                     }
                     else if (obj == MyObject.ObjectType.F_L || obj == MyObject.ObjectType.F_SB || obj == MyObject.ObjectType.F_YG)
                     {
                     }
                 }
             }
             #endregion
         }
         else
         {
             SetObjectPro();
         }
     }
     catch (Exception ex)
     {
         Log.WriteLog(ex);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 根据点位自动生成遥控字符串
        /// </summary>
        public void AutoCreateYK(List <MyObject> m_ObjectList)
        {
            try
            {
                DBOPs         db        = new DBOPs();
                int           commandid = 0;
                List <PLCEqu> insertEqu = new List <PLCEqu>();
                for (int i = 0; i < m_ObjectList.Count; i++)
                {
                    if (m_ObjectList[i] is PLCEqu)
                    {
                        //生成遥信字符串
                        var plcEqu = m_ObjectList[i] as PLCEqu;
                        if (plcEqu.plc_pro.ykList.Count > 0)
                        {
                            continue;
                        }
                        #region
                        switch (plcEqu.equtype)
                        {
                        case MyObject.ObjectType.P:
                            break;

                        case MyObject.ObjectType.P_AF:
                            break;

                        case MyObject.ObjectType.P_CL:
                            break;

                        case MyObject.ObjectType.P_CO:
                            break;

                        case MyObject.ObjectType.P_GJ:
                            break;

                        case MyObject.ObjectType.P_HL:
                            commandid = 47;
                            AddYKStr(PlcString.strYKhl, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_HL2:
                            commandid = 51;
                            AddYKStr(PlcString.strYKhl2, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_JF:
                            commandid = 40;
                            AddYKStr(PlcString.strYKjf, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_L:
                            commandid = 34;
                            AddYKStr(PlcString.stryk2byte, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_LJQ:
                            commandid = 36;
                            AddYKStr(PlcString.stryk2byte, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_LLDI:
                            break;

                        case MyObject.ObjectType.P_LYJ:
                            commandid = 38;
                            AddYKStr(PlcString.stryk2byte, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_P:
                            break;

                        case MyObject.ObjectType.P_TD:
                            commandid = 58;
                            AddYKStr(PlcString.strYKTD, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_TL2_Close:
                            commandid = 114;
                            AddYKStr(PlcString.stryk2byte, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_TL2_Down:
                            commandid = 67;
                            AddYKStr(PlcString.stryk2byte, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_TL2_Left:
                            break;

                        case MyObject.ObjectType.P_TL2_Right:
                            break;

                        case MyObject.ObjectType.P_TL2_UP:
                            commandid = 71;
                            AddYKStr(PlcString.stryk2byte, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_TL3_Down:
                            break;

                        case MyObject.ObjectType.P_TL3_Left:
                            break;

                        case MyObject.ObjectType.P_TL3_Right:
                            break;

                        case MyObject.ObjectType.P_TL3_UP:
                            break;

                        case MyObject.ObjectType.P_TL4_Down:
                            break;

                        case MyObject.ObjectType.P_TL4_Left:
                            break;

                        case MyObject.ObjectType.P_TL4_Right:
                            break;

                        case MyObject.ObjectType.P_TL4_UP:
                            break;

                        case MyObject.ObjectType.P_TL5_Down:
                            break;

                        case MyObject.ObjectType.P_TL5_Left:
                            commandid = 105;
                            AddYKStr(PlcString.strYKtl1, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_TL5_Right:
                            commandid = 109;
                            AddYKStr(PlcString.strYKtl1, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_TL5_UP:
                            commandid = 97;
                            AddYKStr(PlcString.strYKtl, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_TL_Down:
                            commandid = 85;
                            AddYKStr(PlcString.strYKtl, plcEqu, commandid);
                            break;

                        case MyObject.ObjectType.P_TL_Left:
                            break;

                        case MyObject.ObjectType.P_TL_Right:
                            break;

                        case MyObject.ObjectType.P_TL_UP:
                            break;

                        case MyObject.ObjectType.P_TW:
                            break;

                        case MyObject.ObjectType.P_VI:
                            break;

                        default:
                            break;
                        }
                        #endregion
                        insertEqu.Add(plcEqu);
                    }
                }

                if (insertEqu.Count > 0)
                {
                    db.InsertYK(insertEqu);
                    gMain.log.WriteLog("自动生成遥控字符串成功!");
                }
            }
            catch (Exception e)
            {
                gMain.log.WriteLog("AutoCreateYK:" + e);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 根据点位自动生成遥信字符串和遥控字符串
        /// </summary>
        public void AutoCreateYX(List <MyObject> m_ObjectList)
        {
            try
            {
                int           stateid   = 0;
                List <PLCEqu> insertEqu = new List <PLCEqu>();
                for (int i = 0; i < m_ObjectList.Count; i++)
                {
                    if (m_ObjectList[i] is PLCEqu)
                    {
                        var plcEqu = m_ObjectList[i] as PLCEqu;
                        //生成遥信字符串
                        if (plcEqu.plc_pro.yxList.Count > 0)
                        {
                            continue;
                        }
                        if (plcEqu.plc_pro.yxcfgList.Count == 0)
                        {
                            continue;
                        }
                        #region
                        switch (plcEqu.equtype)
                        {
                        case MyObject.ObjectType.P:
                            break;

                        case MyObject.ObjectType.P_AF:
                            break;

                        case MyObject.ObjectType.P_CL:
                            break;

                        case MyObject.ObjectType.P_CO:
                            break;

                        case MyObject.ObjectType.P_GJ:
                            break;

                        case MyObject.ObjectType.P_HL:
                            stateid = 75;
                            AddYXStr(PlcString.strYXhl, plcEqu, stateid);
                            break;

                        case MyObject.ObjectType.P_HL2:
                            stateid = 80;
                            AddYXStr(PlcString.strYXhl2, plcEqu, stateid);
                            break;

                        case MyObject.ObjectType.P_JF:
                            CreateFaulte(plcEqu, 66);
                            stateid = 62;
                            AddYXStr(PlcString.strYXjf, plcEqu, stateid);
                            break;

                        case MyObject.ObjectType.P_L:
                            stateid = 57;
                            CreateFaultAndState(plcEqu, PlcString.strYX2byte, stateid, 61);
                            break;

                        case MyObject.ObjectType.P_LJQ:
                            stateid = 162;
                            CreateFaultAndState(plcEqu, PlcString.strYX2byte, stateid, 166);
                            break;

                        case MyObject.ObjectType.P_LLDI:
                            break;

                        case MyObject.ObjectType.P_LYJ:
                            stateid = 167;
                            CreateFaultAndState(plcEqu, PlcString.strYX2byte, stateid, 171);
                            break;

                        case MyObject.ObjectType.P_P:
                            break;

                        case MyObject.ObjectType.P_TD:
                            stateid = 93;
                            AddYXStr(PlcString.strYXTD, plcEqu, stateid);
                            break;

                        case MyObject.ObjectType.P_TL2_Close:
                            stateid = 188;
                            AddTLStr(PlcString.strYXtl, plcEqu, stateid, 1);
                            break;

                        case MyObject.ObjectType.P_TL2_Down:
                            stateid = 121;
                            AddTLStr(PlcString.strYXtl, plcEqu, stateid, 1);
                            break;

                        case MyObject.ObjectType.P_TL2_Left:
                            break;

                        case MyObject.ObjectType.P_TL2_Right:
                            break;

                        case MyObject.ObjectType.P_TL2_UP:
                            stateid = 127;
                            AddTLStr(PlcString.strYXtl, plcEqu, stateid, 1);
                            break;

                        case MyObject.ObjectType.P_TL3_Down:
                            break;

                        case MyObject.ObjectType.P_TL3_Left:
                            break;

                        case MyObject.ObjectType.P_TL3_Right:
                            break;

                        case MyObject.ObjectType.P_TL3_UP:
                            break;

                        case MyObject.ObjectType.P_TL4_Down:
                            break;

                        case MyObject.ObjectType.P_TL4_Left:
                            break;

                        case MyObject.ObjectType.P_TL4_Right:
                            break;

                        case MyObject.ObjectType.P_TL4_UP:
                            break;

                        case MyObject.ObjectType.P_TL5_Down:
                            break;

                        case MyObject.ObjectType.P_TL5_Left:
                            stateid = 180;
                            AddTLStr(PlcString.strYXtl, plcEqu, stateid, 1);
                            break;

                        case MyObject.ObjectType.P_TL5_Right:
                            stateid = 184;
                            AddTLStr(PlcString.strYXtl, plcEqu, stateid, 1);
                            break;

                        case MyObject.ObjectType.P_TL5_UP:
                            stateid = 172;
                            AddTLStr(PlcString.strYXtl, plcEqu, stateid, 1);
                            break;

                        case MyObject.ObjectType.P_TL_Down:
                            break;

                        case MyObject.ObjectType.P_TL_Left:
                            break;

                        case MyObject.ObjectType.P_TL_Right:
                            break;

                        case MyObject.ObjectType.P_TL_UP:
                            break;

                        case MyObject.ObjectType.P_TW:
                            break;

                        case MyObject.ObjectType.P_VI:
                            break;

                        default:
                            break;
                        }
                        #endregion
                        insertEqu.Add(plcEqu);
                    }
                }
                if (insertEqu.Count > 0)
                {
                    DBOPs db = new DBOPs();
                    db.InsertYX(insertEqu);
                    gMain.log.WriteLog("自动生成遥信字符串成功!");
                }
            }
            catch (Exception e)
            {
                gMain.log.WriteLog("生成遥信字符串错误:" + e);
            }
        }