Beispiel #1
0
 private void BTN_Add_Click(object sender, EventArgs e)
 {
     try
     {
         if (iplist.FirstOrDefault(x => x.IPAddress == TB_IP.Text) == null)
         {
             System.Collections.ObjectModel.ReadOnlyCollection <ConnectedApplianceInfo> cio = WifiLocal.ConnectedAppliances;
             ConnectedApplianceInfo cai = cio.FirstOrDefault(x => x.IPAddress == TB_IP.Text);
             if (cai != null)
             {
                 LB_IPs.Items.Add(cai.IPAddress);
                 IPData newip = new IPData(cai.IPAddress, cai.MacAddress);
                 iplist.Add(newip);
                 DataRow dr = results.NewRow();
                 dr["IP Address"]  = newip.IPAddress;
                 dr["MAC Address"] = newip.MACAddress;
                 results.Rows.Add(dr);
             }
         }
     }
     catch
     {
     }
 }
Beispiel #2
0
        private void SetText()
        {
            foreach (string s in responses)
            {
                string[] parts = s.Split('\t');
                IPData   ipd   = iplist.FirstOrDefault(x => x.IPAddress == parts[0]);
                listindex = iplist.IndexOf(ipd);
                int rtt = parts[1].EndsWith("ms") ? int.Parse(parts[1].Substring(0, parts[1].Length - 2)) : pingtimeout;
                iplist[listindex].AddReply(rtt);
                if (parts[2] == "FALSE" && iplist[listindex].LinkState != -1)
                {
                    iplist[listindex].LinkState = 0;
                }
                results.Rows[listindex]["Avg Resp Time"]             = iplist[listindex].Average;
                results.Rows[listindex]["# Missed Pings"]            = iplist[listindex].DropCount;
                results.Rows[listindex]["Ping Response %"]           = iplist[listindex].UptimePct;
                results.Rows[listindex]["Link State"]                = iplist[listindex].LinkState;
                results.Rows[listindex]["Claim State"]               = iplist[listindex].ClaimState;
                results.Rows[listindex]["Cloud Disconnect Count"]    = iplist[listindex].MQTTDropCount;
                results.Rows[listindex]["Current Connected Time"]    = iplist[listindex].ConnectedTime.ToString("g");
                results.Rows[listindex]["Current Disconnected Time"] = iplist[listindex].DisconnectedTime.ToString("g");
                results.Rows[listindex]["Wifi Resync Statistics"]    = iplist[listindex].WifiResyncStatistics;

                try
                {
                    using (StreamWriter sw = File.AppendText(curfilename))
                    {
                        sw.WriteLine(DateTime.Now.ToString("MM/dd/yy hh:mm:ss") + "," + parts[0] + "," +
                                     iplist[listindex].MACAddress + "," +
                                     rtt + "," +
                                     iplist[listindex].DropCount + "," +
                                     iplist[listindex].UptimePct + "," +
                                     iplist[listindex].LinkState + "," +
                                     iplist[listindex].ClaimState + "," +
                                     iplist[listindex].MQTTDropCount + "," +
                                     iplist[listindex].ConnectedTime.ToString("g") + "," +
                                     iplist[listindex].DisconnectedTime.ToString("g") + "," +
                                     iplist[listindex].WifiResyncStatistics);
                    }
                }
                catch { }
            }

            /*//LB_Response.Items.Add(pingresp);
             * string[] parts = pingresp.Split('\t');
             * int rtt = parts[1].EndsWith("ms") ? int.Parse(parts[1].Substring(0,parts[1].Length-2)) : pingtimeout;
             * iplist[listindex].AddReply(rtt,mqttresp);
             * results.Rows[listindex]["Avg Resp Time"] = iplist[listindex].Average;
             * results.Rows[listindex]["# Missed Packets"] = iplist[listindex].DropCount;
             * results.Rows[listindex]["Uptime %"] = iplist[listindex].Uptime;
             * results.Rows[listindex]["MQTT Drop Count"] = iplist[listindex].MQTTDropCount;
             * results.Rows[listindex]["MQTT Uptime %"] = iplist[listindex].MQTTUptime;*/

            DGV_Data.Refresh();
            responses.Clear();

            /*try
             * {
             *  sw.WriteLine(DateTime.Now.ToString("MM/dd/yy hh:mm:ss") + "," + parts[0] + "," + rtt + "," + mqttresp);
             * }
             * catch { }*/
        }