private void LoadInterfaceAndList() { try { nData.Clear(); wifiList.Items.Clear(); foreach (WlanClient.WlanInterface wlanIface in wlanClient.Interfaces) { Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList(0); wifiList.Items.Add(wlanIface.NetworkInterface.Name.ToString()); nData.Add(new NData());//Add fake one First foreach (Wlan.WlanAvailableNetwork network in networks) { Wlan.Dot11Ssid ssid = network.dot11Ssid; String networkName = Encoding.ASCII.GetString(ssid.SSID, 0, (int)ssid.SSIDLength); NData nd = new NData(); nd.wlanIface = wlanIface; nd.Network = network; nData.Add(nd);//Add real one wifiList.Items.Add(" +" + networkName + " [" + network.flags.HasFlag(Wlan.WlanAvailableNetworkFlags.Connected) + "] " + network.wlanSignalQuality + "%"); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); Msg("ERROR", ex.ToString()); } }
private void wifiList_MouseDoubleClick(object sender, MouseEventArgs e) { try { NData nd = nData[wifiList.SelectedIndex]; if (nd.isNetwork) { Wlan.WlanAvailableNetwork network = nd.Network; WlanClient.WlanInterface wlanIface = nd.wlanIface; //------------------------------------------------ } Console.WriteLine("--------->"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Msg("ERROR", ex.ToString()); } }
public void SaveToXml(string path = "") { string xmlInput = "<configuration> \n <parallel> serial </parallel>"; xmlInput += AddNewPropertyValue("linearInput", LinearInput); xmlInput += AddNewPropertyValue("license", License); xmlInput += AddNewPropertyValue("entropyDir", InputEntropyDir); xmlInput += AddNewPropertyValue("objDir", InputObjDir); //population sizing xmlInput += AddNewPropertyValue("debug_mode", Debug); xmlInput += AddNewPropertyValue("use_hboa", Hboa); xmlInput += AddNewPropertyValue("initial_popsize", InitPop.ToString()); xmlInput += AddNewPropertyValue("min_popsize", MinPop.ToString()); xmlInput += AddNewPropertyValue("max_popsize", MaxPop.ToString()); xmlInput += AddNewPropertyValue("popsize_scheme", PopScheme); xmlInput += AddNewPropertyValue("pop_scaling_factor", PopFactor.ToString()); xmlInput += AddNewPropertyValue("max_gens", MaxGens.ToString()); //Design Objectives xmlInput += AddNewPropertyValue("test_problem", TestProblem); xmlInput += AddNewPropertyValue("nobj", NObj.ToString()); for (int i = 1; i <= NObj; i++) { xmlInput += AddNewPropertyValue("obj_tag" + i, ObjTags[i - 1].ToString()); xmlInput += AddNewPropertyValue("obj_val" + i, ObjVal[i - 1].ToString()); xmlInput += AddNewPropertyValue("obj_eps" + i, ObjEps[i - 1].ToString()); } xmlInput += AddNewPropertyValue("num_additional_objectives", NAObj.ToString()); for (int i = 1; i <= NAObj; i++) { xmlInput += AddNewPropertyValue("aobj1_" + i, AObj1[i - 1].ToString()); xmlInput += AddNewPropertyValue("aobj" + i + "_2", AObj2[i - 1].ToString()); } xmlInput += AddNewPropertyValue("ncons", NConst.ToString()); for (int i = 1; i <= NConst; i++) { xmlInput += AddNewPropertyValue("con_num" + i, ConNum[i - 1].ToString()); xmlInput += AddNewPropertyValue("con_tot" + i, ConTot[i - 1].ToString()); xmlInput += AddNewPropertyValue("con_ind" + i, ConInd[i - 1].ToString()); } //Real Decision Variables xmlInput += AddNewPropertyValue("nreal", NReal.ToString()); xmlInput += AddNewPropertyValue("real_pseudo_binary", PseudoBinary); xmlInput += AddNewPropertyValue("real_limits", RealLimits); if (RealTag != null) { for (int i = 1; i <= RealTag.Count(); i++) { xmlInput += AddNewPropertyValue("real_tag" + i, RealTag[i - 1].ToString()); xmlInput += AddNewPropertyValue("real_min" + i, RealMin[i - 1].ToString()); xmlInput += AddNewPropertyValue("real_max" + i, RealMax[i - 1].ToString()); } } xmlInput += AddNewPropertyValue("real_cross_prob", RealCrossProb.ToString()); xmlInput += AddNewPropertyValue("real_mut_prob", RealMutProb.ToString()); xmlInput += AddNewPropertyValue("dist_index_sbx", DistIndexSBX.ToString()); xmlInput += AddNewPropertyValue("dist_index_poly", DistIndexPoly.ToString()); //Binary Decision Variables xmlInput += AddNewPropertyValue("nbin", NBin.ToString()); xmlInput += AddNewPropertyValue("bin_limits", BinLimits == true ? " same " : " different "); for (int i = 1; i <= NBin; i++) { xmlInput += AddNewPropertyValue("bin_tag" + i, BinTag[i - 1].ToString()); xmlInput += AddNewPropertyValue("bin_bit" + i, BinBit[i - 1].ToString()); xmlInput += AddNewPropertyValue("bin_min" + i, RealMin[i - 1].ToString()); xmlInput += AddNewPropertyValue("bin_max" + i, RealMax[i - 1].ToString()); } xmlInput += AddNewPropertyValue("bin_cross_prob", BinCrossProb.ToString()); xmlInput += AddNewPropertyValue("bin_cross_type", BinCrossType); xmlInput += AddNewPropertyValue("bin_mut_prob", BinMutProb.ToString()); xmlInput += AddNewPropertyValue("bin_mut_type", BinMutType); //Soft Termination Criteria xmlInput += AddNewPropertyValue("inter_run", InterRun); xmlInput += AddNewPropertyValue("inter_delta", InterDelta.ToString()); xmlInput += AddNewPropertyValue("intra_run", IntraRun); xmlInput += AddNewPropertyValue("inter_delta", IntraDelta.ToString()); //Hard Termination Criteria xmlInput += AddNewPropertyValue("max_nfe", MaxNfe.ToString()); xmlInput += AddNewPropertyValue("max_time", MaxTime.ToString()); xmlInput += AddNewPropertyValue("max_eperf", MaxEperf.ToString()); //Performance Metrics xmlInput += AddNewPropertyValue("conv", Conv); xmlInput += AddNewPropertyValue("div", Div); xmlInput += AddNewPropertyValue("eperf", Eperf); xmlInput += AddNewPropertyValue("edom_eperf", EdomEperf); if (DivGrid != null) { for (int i = 1; i <= DivGrid.Count; i++) { xmlInput += AddNewPropertyValue("div_grid" + i, DivGrid[i - 1].ToString()); } } if (EperfEps != null) { for (int i = 1; i <= EperfEps.Count; i++) { xmlInput += AddNewPropertyValue("eperf_eps" + i, EperfEps[i - 1].ToString()); } } xmlInput += AddNewPropertyValue("eind", Eind); xmlInput += AddNewPropertyValue("eind_error", EindError.ToString()); xmlInput += AddNewPropertyValue("metric_ref", MetricRef); //Local File Output xmlInput += AddNewPropertyValue("out_dir", OutDir); xmlInput += AddNewPropertyValue("out_headers", OutHeaders); xmlInput += AddNewPropertyValue("out_all", OutAll ? OutInterval.ToString() : "0"); xmlInput += AddNewPropertyValue("out_nondom", Nondom ? NondomInterval.ToString() : "0"); xmlInput += AddNewPropertyValue("out_all_final", AllFinal ? "on" : "off"); xmlInput += AddNewPropertyValue("out_nondom_final", NondomFinal ? "on" : "off"); xmlInput += AddNewPropertyValue("out_stats", StatsInterval.ToString()); xmlInput += AddNewPropertyValue("out_rs", RsStats ? "on" : "off"); xmlInput += AddNewPropertyValue("out_timer", TimerInterval.ToString()); xmlInput += AddNewPropertyValue("out_vtk", VtkInterval.ToString()); xmlInput += AddNewPropertyValue("out_vtk_sflag", SmallFlag); //DEMO Parameters xmlInput += AddNewPropertyValue("ndata", NData.ToString()); //End Tag xmlInput += "\n </configuration>"; var doc = XDocument.Parse(xmlInput); xmlDoc = doc; if (path == string.Empty) { doc.Save(path + "configuration.xml"); } else { doc.Save(path); } }
public static NData Read() { // setup ole db connection string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath(@"~\App_Data\demographicData.xls") + ";Extended Properties=Excel 8.0;"; OleDbConnection oleDbConnection1 = new OleDbConnection(connectionString); OleDbCommand oleDbCommand1 = new OleDbCommand("SELECT * From [SHEET$]", oleDbConnection1); OleDbDataReader oleDbDataReader1 = null; ArrayList rows = new ArrayList(); try { // execute the select command oleDbConnection1.Open(); oleDbDataReader1 = oleDbCommand1.ExecuteReader(); while (oleDbDataReader1.Read()) { if (oleDbDataReader1["start age"] == DBNull.Value) { break; } Dictionary <string, int> row = new Dictionary <string, int>(); rows.Add(row); ReadField(oleDbDataReader1, row, "start age"); ReadField(oleDbDataReader1, row, "end age"); ReadField(oleDbDataReader1, row, "white male pop"); ReadField(oleDbDataReader1, row, "white male err"); ReadField(oleDbDataReader1, row, "white female pop"); ReadField(oleDbDataReader1, row, "white female err"); ReadField(oleDbDataReader1, row, "black male pop"); ReadField(oleDbDataReader1, row, "black male err"); ReadField(oleDbDataReader1, row, "black female pop"); ReadField(oleDbDataReader1, row, "black female err"); ReadField(oleDbDataReader1, row, "indian + alaska male pop"); ReadField(oleDbDataReader1, row, "indian + alaska male err"); ReadField(oleDbDataReader1, row, "indian + alaska female pop"); ReadField(oleDbDataReader1, row, "indian + alaska female err"); ReadField(oleDbDataReader1, row, "asian male pop"); ReadField(oleDbDataReader1, row, "asian male err"); ReadField(oleDbDataReader1, row, "asian female pop"); ReadField(oleDbDataReader1, row, "asian female err"); ReadField(oleDbDataReader1, row, "pacific male pop"); ReadField(oleDbDataReader1, row, "pacific male err"); ReadField(oleDbDataReader1, row, "pacific female pop"); ReadField(oleDbDataReader1, row, "pacific female err"); ReadField(oleDbDataReader1, row, "race male pop"); ReadField(oleDbDataReader1, row, "race male err"); ReadField(oleDbDataReader1, row, "race female pop"); ReadField(oleDbDataReader1, row, "race female err"); ReadField(oleDbDataReader1, row, "mixed male pop"); ReadField(oleDbDataReader1, row, "mixed male err"); ReadField(oleDbDataReader1, row, "mixed female pop"); ReadField(oleDbDataReader1, row, "mixed female err"); } } finally { if (oleDbDataReader1 != null) { oleDbDataReader1.Close(); } if (oleDbConnection1 != null) { oleDbConnection1.Close(); } } // build the data structures NData data = new NData(); data.ImportAgeRanges(rows); data.ImportRaces(rows); return(data); }
private void CreateData(CarAccHistoryModel model) { NData.Clear(); if (!model.Data.Any()) { return; } var width = stkX.ActualWidth; var step = width / 24 / 60; var minutesInStep = 1 / step; var w = (int)width; var graphHeight = 160; var nd = model.Data.Select(item => new NormalizedData { MaxZ = Math.Abs(item.MaxZ), MaxX = Math.Abs(item.MaxX), MaxY = Math.Abs(item.MaxY), DT = new DateTime(item.Date.Y, item.Date.M, item.Date.D, item.Date.hh, item.Date.mm, item.Date.ss) }).ToList(); var dt = new DateTime(model.Data[0].Date.Y, model.Data[0].Date.M, model.Data[0].Date.D); for (var i = 0; i < w; i++) { var dtTemp = dt + TimeSpan.FromMinutes(minutesInStep); var temp = new NormalizedData(); var models = nd.Where(p => p.DT > dt && p.DT <= dtTemp).ToList(); if (models.Any()) { temp.MaxX = models.Max(p => p.MaxX) / 100.0f; temp.MaxY = models.Max(p => p.MaxY) / 100.0f; temp.MaxZ = models.Max(p => p.MaxZ) / 100.0f; } NData.Add(temp); dt = dtTemp; } if (NData == null || !NData.Any()) { return; } //find min data double x = 0; if (NData.Any(p => p.MaxX > 0.1f)) { x = NData.Where(p => p.MaxX > 0.1f).Min(p => p.MaxX); } double y = 0; if (NData.Any(p => p.MaxY > 0.1f)) { y = NData.Where(p => p.MaxY > 0.1f).Min(p => p.MaxY); } double z = 0; if (NData.Any(p => p.MaxZ > 0.1f)) { z = NData.Where(p => p.MaxZ > 0.1f).Min(p => p.MaxZ); } foreach (var item in NData) { item.MaxX -= x; item.MaxY -= y; item.MaxZ -= z; } }