コード例 #1
0
ファイル: Main.cs プロジェクト: tyl-yofc/FPMS_Simulator
 private void DoJob(object sender, EventArgs e)
 {
     if (_isRunning)
     {
         string[] equipnums = existChannelInfos.Keys.ToArray();
         for (int i = 0; i < equipnums.Length; i++)
         {
             List <SectorInfo> sectors = channelZoneInfos[equipnums[i]];
             if (existChannelInfos[equipnums[i]].autoFlag)
             {
                 for (int j = 0; j < sectors.Count; j++)
                 {
                     if (sectors[j].touchFlag)
                     {
                         existChannelInfos[equipnums[i]].udpClient.SendAlarmMessage(Int16.Parse(equipnums[i]), Int16.Parse(sectors[j].sectorNum), AlarmType.Touch);
                     }
                     if (sectors[j].intrudeFlag)
                     {
                         existChannelInfos[equipnums[i]].udpClient.SendAlarmMessage(Int16.Parse(equipnums[i]), Int16.Parse(sectors[j].sectorNum), AlarmType.Intrude);
                     }
                     if (sectors[j].breakFlag)
                     {
                         existChannelInfos[equipnums[i]].udpClient.SendAlarmMessage(Int16.Parse(equipnums[i]), Int16.Parse(sectors[j].sectorNum), AlarmType.Break);
                     }
                 }
             }
         }
         existChannelInfos = ReadChannelCfg.Create().ExistChannels;
         channelZoneInfos  = ReadSectorCfg.Create().ChannelSectorInfos;
         //  Thread.Sleep(30000);
     }
 }
コード例 #2
0
ファイル: Main.cs プロジェクト: tyl-yofc/FPMS_Simulator
        private void Bt_Start_Click(object sender, EventArgs e)
        {
            int count = 0;

            existChannelInfos = ReadChannelCfg.Create().ExistChannels;
            channelZoneInfos  = ReadSectorCfg.Create().ChannelSectorInfos;
            string ip = ipAddressInput.Value;

            if (Bt_Start.Text == "启 动")
            {
                RefreshTableControl(existChannelInfos, channelZoneInfos);
                foreach (KeyValuePair <string, FPMS> kvp in existChannelInfos)
                {
                    if (kvp.Value.serverPort != -1)
                    {
                        kvp.Value.udpClient = new UDP(ip, kvp.Value.serverPort, kvp.Key);
                        kvp.Value.udpClient.StartThread();     //启动线程发送心跳包
                        count++;
                    }
                }
                _isRunning = true;
                sendTimer.Start();
                Bt_Start.Text         = "停 止";
                label_chanelNums.Text = count.ToString();
            }
            else
            {
                foreach (KeyValuePair <string, FPMS> kvp in existChannelInfos)
                {
                    if (kvp.Value.serverPort != -1 && kvp.Value.udpClient != null)
                    {
                        kvp.Value.udpClient.Disconnect();
                    }
                }
                _isRunning = false;
                sendTimer.Stop();
                Bt_Start.Text = "启 动";
            }
        }