Exemplo n.º 1
0
        private void cmb_ChooseChannel_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmb_ChooseChannel.Tag != null && cmb_chooseEquip.Tag != null)
            {
                //切换设备前需要保存当前设备所有通道信息
                int          index        = cmb_chooseEquip.SelectedItem.ToString().IndexOf(":");
                string       equipnum     = cmb_chooseEquip.SelectedItem.ToString().Substring(index + 1);
                string       channelnum   = cmb_ChooseChannel.SelectedItem.ToString();
                ChannelInfos ci           = ExistEquips[oldEquipNum].channelInfo.Find(delegate(ChannelInfos c) { return(c.ChannelNum == ushort.Parse(oldChannelNum)); });
                int          channelindex = ExistEquips[oldEquipNum].channelInfo.FindIndex(item => item.ChannelNum == ushort.Parse(oldChannelNum));
                if (ci != null)
                {
                    ZoneTempInfo zone;
                    int          zoneindex = -1;
                    ushort       zonenum   = 0;
                    for (int i = 0; i < DGV_ZoneInfos.RowCount; i++)
                    {
                        zonenum   = ushort.Parse(DGV_ZoneInfos.Rows[i].Cells[0].Value.ToString());
                        zone      = ci.ZoneTempInfos.Find(delegate(ZoneTempInfo c) { return(c.ZoneNumber == zonenum); });
                        zoneindex = ci.ZoneTempInfos.FindIndex(item => item.ZoneNumber == zonenum);
                        if (zoneindex != -1)
                        {
                            zone.ZoneName               = DGV_ZoneInfos.Rows[i].Cells[1].Value.ToString();
                            zone.StartPos               = float.Parse(DGV_ZoneInfos.Rows[i].Cells[2].Value.ToString());
                            zone.StopPos                = float.Parse(DGV_ZoneInfos.Rows[i].Cells[3].Value.ToString());
                            zone.TempRiseThreshold      = ushort.Parse(DGV_ZoneInfos.Rows[i].Cells[4].Value.ToString());
                            zone.ConsTempThreshold      = ushort.Parse(DGV_ZoneInfos.Rows[i].Cells[5].Value.ToString());
                            zone.RegionTempDifThreshold = ushort.Parse(DGV_ZoneInfos.Rows[i].Cells[6].Value.ToString());
                            ExistEquips[oldEquipNum].channelInfo[channelindex].ZoneTempInfos[zoneindex] = zone;
                        }
                    }
                }
                //更新配置文件
                //  EquipAllInfos.Create().RefreshZoneInfo(ReadChannelCfg.Create().ExistChannels, zoneInfos);
                ReadAlarmZoneCfg.Create().SetValue(ExistEquips);

                oldEquipNum   = equipnum;
                oldChannelNum = channelnum;

                //更新Datagridview
                DGV_ZoneInfos.Rows.Clear();
                List <ChannelInfos> channels1 = ExistEquips[oldEquipNum].channelInfo;
                ChannelInfos        channel1  = channels1.Find(delegate(ChannelInfos c) { return(c.ChannelNum == ushort.Parse(oldChannelNum)); });
                int channelindex1             = channels1.FindIndex(item => item.ChannelNum == ushort.Parse(oldChannelNum));
                if (channel1 != null)
                {
                    DGV_ZoneInfos.RowCount = channel1.ZoneCount;
                    for (int i = 0; i < DGV_ZoneInfos.RowCount; i++)
                    {
                        DGV_ZoneInfos.Rows[i].Cells[0].Value = channel1.ZoneTempInfos[i].ZoneNumber;
                        DGV_ZoneInfos.Rows[i].Cells[1].Value = channel1.ZoneTempInfos[i].ZoneName;
                        DGV_ZoneInfos.Rows[i].Cells[2].Value = channel1.ZoneTempInfos[i].StartPos;
                        DGV_ZoneInfos.Rows[i].Cells[3].Value = channel1.ZoneTempInfos[i].StopPos;
                        DGV_ZoneInfos.Rows[i].Cells[4].Value = channel1.ZoneTempInfos[i].ConsTempThreshold;
                        DGV_ZoneInfos.Rows[i].Cells[5].Value = channel1.ZoneTempInfos[i].ConsTempThreshold;
                        DGV_ZoneInfos.Rows[i].Cells[6].Value = channel1.ZoneTempInfos[i].RegionTempDifThreshold;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void AlarmZones_Load(object sender, EventArgs e)
        {
            cmb_chooseEquip.Tag = null;
            cmb_chooseEquip.Items.Clear();
            cmb_ChooseChannel.Tag = null;
            cmb_ChooseChannel.Items.Clear();

            tabControl.Enabled = false;
            //  EquipAllInfos.Create().ReadCfg();
            //  zoneInfos = EquipAllInfos.Create().ZoneInfos;
            ExistEquips = ReadAlarmZoneCfg.Create().ReadFile();
            foreach (KeyValuePair <string, DTSEquip> kvp in ExistEquips)
            {
                cmb_chooseEquip.Items.Add("DTS:" + kvp.Key);
            }
            if (cmb_chooseEquip.Items.Count > 0)
            {
                cmb_chooseEquip.SelectedIndex = 0;
                int index = cmb_chooseEquip.SelectedItem.ToString().IndexOf(":");
                oldEquipNum = cmb_chooseEquip.SelectedItem.ToString().Substring(index + 1);

                tabControl.Enabled      = true;
                tabControl.Tabs[0].Text = "DTS:" + oldEquipNum;
                List <ChannelInfos> channels = ExistEquips[oldEquipNum].channelInfo;
                for (int i = 0; i < channels.Count; i++)
                {
                    cmb_ChooseChannel.Items.Add(channels[i].ChannelNum.ToString());
                }
                if (cmb_ChooseChannel.Items.Count > 0)
                {
                    cmb_ChooseChannel.SelectedIndex = 0;
                    string channelnum = cmb_ChooseChannel.SelectedItem.ToString();
                    oldChannelNum = channelnum;
                    ChannelInfos channel = channels.Find(delegate(ChannelInfos c) { return(c.ChannelNum == ushort.Parse(channelnum)); });
                    if (channel != null)
                    {
                        DGV_ZoneInfos.RowCount = channel.ZoneTempInfos.Count;
                        for (int i = 0; i < channel.ZoneTempInfos.Count; i++)
                        {
                            DGV_ZoneInfos.Rows[i].Cells[0].Value = channel.ZoneTempInfos[i].ZoneNumber;
                            DGV_ZoneInfos.Rows[i].Cells[1].Value = channel.ZoneTempInfos[i].ZoneName;
                            DGV_ZoneInfos.Rows[i].Cells[2].Value = channel.ZoneTempInfos[i].StartPos;
                            DGV_ZoneInfos.Rows[i].Cells[3].Value = channel.ZoneTempInfos[i].StopPos;
                            DGV_ZoneInfos.Rows[i].Cells[4].Value = channel.ZoneTempInfos[i].TempRiseThreshold;
                            DGV_ZoneInfos.Rows[i].Cells[5].Value = channel.ZoneTempInfos[i].ConsTempThreshold;
                            DGV_ZoneInfos.Rows[i].Cells[6].Value = channel.ZoneTempInfos[i].RegionTempDifThreshold;
                        }
                    }
                }
            }
            cmb_chooseEquip.Tag   = 1;
            cmb_ChooseChannel.Tag = 1;
        }
Exemplo n.º 3
0
        private void AlarmZones_FormClosed(object sender, FormClosedEventArgs e)
        {
            //保持当前设备的通道信息
            int index = cmb_chooseEquip.SelectedItem.ToString().IndexOf(":");

            oldEquipNum   = cmb_chooseEquip.SelectedItem.ToString().Substring(index + 1);
            oldChannelNum = cmb_ChooseChannel.SelectedItem.ToString();
            ChannelInfos ci           = ExistEquips[oldEquipNum].channelInfo.Find(delegate(ChannelInfos c) { return(c.ChannelNum == ushort.Parse(oldChannelNum)); });
            int          channelindex = ExistEquips[oldEquipNum].channelInfo.FindIndex(item => item.ChannelNum == ushort.Parse(oldChannelNum));

            if (ci != null)
            {
                ZoneTempInfo zone;
                int          zoneindex = -1;
                ushort       zonenum   = 0;
                for (int i = 0; i < DGV_ZoneInfos.RowCount; i++)
                {
                    zonenum   = ushort.Parse(DGV_ZoneInfos.Rows[i].Cells[0].Value.ToString());
                    zone      = ci.ZoneTempInfos.Find(delegate(ZoneTempInfo c) { return(c.ZoneNumber == zonenum); });
                    zoneindex = ci.ZoneTempInfos.FindIndex(item => item.ZoneNumber == zonenum);
                    if (zoneindex != -1)
                    {
                        zone.ZoneNumber             = zonenum;
                        zone.ZoneName               = DGV_ZoneInfos.Rows[i].Cells[1].Value.ToString();
                        zone.StartPos               = float.Parse(DGV_ZoneInfos.Rows[i].Cells[2].Value.ToString());
                        zone.StopPos                = float.Parse(DGV_ZoneInfos.Rows[i].Cells[3].Value.ToString());
                        zone.TempRiseThreshold      = ushort.Parse(DGV_ZoneInfos.Rows[i].Cells[4].Value.ToString());
                        zone.ConsTempThreshold      = ushort.Parse(DGV_ZoneInfos.Rows[i].Cells[5].Value.ToString());
                        zone.RegionTempDifThreshold = ushort.Parse(DGV_ZoneInfos.Rows[i].Cells[6].Value.ToString());
                        ExistEquips[oldEquipNum].channelInfo[channelindex].ZoneTempInfos[zoneindex] = zone;
                    }
                }
            }

            //更新配置文件
            //   EquipAllInfos.Create().RefreshZoneInfo(ReadChannelCfg.Create().ExistChannels, zoneInfos);
            ReadAlarmZoneCfg.Create().SetValue(ExistEquips);
        }
Exemplo n.º 4
0
        private void bt_Revise_Click(object sender, EventArgs e)
        {
            int row = DGV_ZoneInfos.CurrentRow.Index;

            if (Txt_ZoneName.Text == "")
            {
                Txt_ZoneName.Text = DGV_ZoneInfos.Rows[row].Cells[0].Value.ToString();
            }

            int forwardstoppos   = -1;
            int backwardstartpos = -1;

            if (row > 0)
            {
                forwardstoppos = int.Parse(DGV_ZoneInfos.Rows[row - 1].Cells[3].Value.ToString());
            }
            if (row < DGV_ZoneInfos.RowCount - 1)
            {
                backwardstartpos = int.Parse(DGV_ZoneInfos.Rows[row + 1].Cells[2].Value.ToString());
            }
            int    startpos     = -1;
            int    stoppos      = -1;
            UInt16 risethres    = 0;
            UInt16 consthres    = 0;
            UInt16 tempdifthres = 0;
            bool   flag         = false;

            if (int.TryParse(Txt_StartPos.Text, out startpos))
            {
                if (int.TryParse(Txt_StopPos.Text, out stoppos))
                {
                    if (stoppos > startpos)
                    {
                        bool forward  = false;
                        bool backward = false;
                        if (forwardstoppos != -1)
                        {
                            if (startpos - forwardstoppos >= 0)
                            {
                                forward = true;
                            }
                        }
                        else
                        {
                            forward = true;
                        }

                        if (backwardstartpos != -1)
                        {
                            if (backwardstartpos - stoppos >= 0)
                            {
                                backward = true;
                            }
                        }
                        else
                        {
                            backward = true;
                        }

                        if (forward && backward)
                        {
                            flag = true;
                        }
                    }

                    if (flag)
                    {
                        //更新DataGridView
                        DGV_ZoneInfos.Rows[row].Cells[1].Value = Txt_ZoneName.Text;
                        DGV_ZoneInfos.Rows[row].Cells[2].Value = Txt_StartPos.Text;
                        DGV_ZoneInfos.Rows[row].Cells[3].Value = Txt_StopPos.Text;
                        //温升阈值
                        if (Txt_TempRiseThres.Text != "")
                        {
                            if (!UInt16.TryParse(Txt_TempRiseThres.Text, out risethres))
                            {
                                Txt_TempRiseThres.Text = DefaultTempRiseThres.ToString();
                            }
                        }
                        else
                        {
                            Txt_TempRiseThres.Text = DefaultTempRiseThres.ToString();
                        }

                        DGV_ZoneInfos.Rows[row].Cells[4].Value = Txt_TempRiseThres.Text;

                        //定温阈值
                        if (Txt_ConstTempThres.Text != "")
                        {
                            if (!UInt16.TryParse(Txt_ConstTempThres.Text, out consthres))
                            {
                                Txt_ConstTempThres.Text = DefaultConsTempThres.ToString();
                            }
                        }
                        else
                        {
                            Txt_ConstTempThres.Text = DefaultConsTempThres.ToString();
                        }

                        DGV_ZoneInfos.Rows[row].Cells[5].Value = Txt_ConstTempThres.Text;

                        //区域温差阈值
                        if (Txt_RegionTempDifThres.Text != "")
                        {
                            if (!UInt16.TryParse(Txt_RegionTempDifThres.Text, out tempdifthres))
                            {
                                Txt_RegionTempDifThres.Text = DefaultRegionTempDifThres.ToString();
                            }
                        }
                        else
                        {
                            Txt_RegionTempDifThres.Text = DefaultRegionTempDifThres.ToString();
                        }

                        DGV_ZoneInfos.Rows[row].Cells[6].Value = Txt_RegionTempDifThres.Text;


                        //更新字典
                        string channelnum    = cmb_ChooseChannel.SelectedItem.ToString();
                        float  startpos1     = float.Parse(DGV_ZoneInfos.Rows[row].Cells[2].Value.ToString());
                        float  stoppos1      = float.Parse(DGV_ZoneInfos.Rows[row].Cells[3].Value.ToString());
                        int    equipnumindex = cmb_chooseEquip.SelectedItem.ToString().IndexOf(":");
                        string equipnum      = cmb_chooseEquip.SelectedItem.ToString().Substring(equipnumindex + 1);

                        ChannelInfos channel      = ExistEquips[equipnum].channelInfo.Find(delegate(ChannelInfos c) { return(c.ChannelNum == ushort.Parse(channelnum)); });
                        int          channelindex = ExistEquips[equipnum].channelInfo.FindIndex(item => item.ChannelNum == ushort.Parse(channelnum));

                        string       zonenum   = DGV_ZoneInfos.Rows[row].Cells[0].Value.ToString();
                        ZoneTempInfo zone      = channel.ZoneTempInfos.Find(delegate(ZoneTempInfo z) { return(z.ZoneNumber == ushort.Parse(zonenum)); });
                        int          zoneindex = channel.ZoneTempInfos.FindIndex(item => item.ZoneNumber == ushort.Parse(zonenum));
                        if (zoneindex != -1)
                        {
                            zone.ZoneName               = Txt_ZoneName.Text;;
                            zone.StartPos               = float.Parse(Txt_StartPos.Text);
                            zone.StopPos                = float.Parse(Txt_StopPos.Text);
                            zone.TempRiseThreshold      = UInt16.Parse(Txt_TempRiseThres.Text);
                            zone.ConsTempThreshold      = UInt16.Parse(Txt_ConstTempThres.Text);
                            zone.RegionTempDifThreshold = UInt16.Parse(Txt_RegionTempDifThres.Text);
                            ExistEquips[equipnum].channelInfo[channelindex].ZoneTempInfos[zoneindex] = zone;
                        }

                        //更新配置文件
                        // EquipAllInfos.Create().RefreshZoneInfo(ReadChannelCfg.Create().ExistChannels, zoneInfos);
                        ReadAlarmZoneCfg.Create().SetValue(ExistEquips);
                    }
                }
            }
        }