public ServiceConfiguration() { TextAsset txt = Resources.Load("server_config") as TextAsset; INIReader reader = new INIReader(txt.text); foreach (INIReaderHeader header in reader.GetHeaders()) { if (header.Check("ServerConfig")) { foreach (INIReaderParameter parameter in header.parameters) { if (parameter.Check("maxclients")) { maxClients = parameter.GetInt(0); } else if (parameter.Check("login_server_port")) { loginServerPort = parameter.GetInt(0); } else if (parameter.Check("account_db_dir")) { accountDatabaseDir = parameter.GetString(0); } else if (parameter.Check("account_db_pass")) { accountDatabasePassword = parameter.GetString(0); } } } } }
static string FindMainINI(string name) { Func <Pointer <CCINIClass>, bool> IsMainINI = (Pointer <CCINIClass> pINI) => { string section = "#include"; int length = pINI.Ref.GetKeyCount(section); INIReader reader = new INIReader(pINI); for (int i = 0; i < length; i++) { string key = pINI.Ref.GetKeyName(section, i); string sub_name = null; if (reader.ReadNormal(section, key, ref sub_name)) { //Logger.Log("sub_name {0}", sub_name); if (string.Compare(sub_name, name, true) == 0) { return(true); } } } return(false); }; Dictionary <string, Pointer <CCINIClass> > inis = new() { { "Rulesmd.ini", CCINIClass.INI_Rules }, { "Artmd.ini", CCINIClass.INI_Art },
private void refreshList() { if (!File.Exists("servers.list")) { File.WriteAllText("servers.list", ""); } listView1.Items.Clear(); var servers = loadFromFile(); foreach (ServerInfo server in servers) { new Task(new Action(delegate { try { var request = HttpWebRequest.CreateHttp("http://" + server.IP + ":" + server.Port.ToString() + "/get_server_data"); var response = (HttpWebResponse)request.GetResponse(); string ini = new StreamReader(response.GetResponseStream()).ReadToEnd(); INIReader reader = new INIReader(ini.Split('\n')); response.Close(); server.GamePort = reader.getInt16("game_port"); ListViewItem item = createListItem(reader.getString("name"), server.IP, server.Port.ToString() + "." + server.GamePort.ToString(), reader.getString("players") + "/" + reader.getString("max_players")); item.Tag = server; listView1.Items.Add(item); } catch { ListViewItem item = createListItem("Offline", server.IP, server.Port.ToString() + "." + server.GamePort.ToString(), "-"); listView1.Items.Add(item); } })).Start(); } }
public void LoadINI(Pointer <CCINIClass> pINI) { INIReader reader = new INIReader(pINI); string section = OwnerObject.Ref.Base.Base.ID; reader.ReadSuperWeapon(section, nameof(FireSuperWeapon), ref FireSuperWeapon.Pointer); }
protected override void LoadFromINIFile(Pointer <CCINIClass> pINI) { INIReader reader = new INIReader(pINI); string section = OwnerObject.Ref.Base.Base.ID; reader.ReadScripts(section, "Scripts", ref Scripts); }
public void setProperty_Test() { var properties = new INIReader(); properties.setProperty("host", "localhost"); Assert.AreEqual(properties.getProperty("host"), "localhost"); }
public Server() { config = new INIReader(System.IO.File.ReadAllLines("config.ini")); chat = new ServerChat(); instance = this; vehicleController = new ServerVehicleController(); api = new ServerApi(this); gamemodeManager = new GamemodeManager(api); gamemodeManager.loadFromFile("gamemodes/" + config.getString("gamemode")); server = new TcpListener(IPAddress.Any, config.getInt("game_port")); server.Start(); server.BeginAcceptTcpClient(onIncomingConnection, null); playerpool = new List <ServerPlayer>(); Timer timer = new Timer(); timer.Elapsed += onBroadcastTimer; timer.Interval = config.getInt("broadcast_interval"); timer.Enabled = true; timer.Start(); UDPStartPort = config.getInt("udp_start_port"); Timer timer_slow = new Timer(); timer_slow.Elapsed += timer_slow_Elapsed; timer_slow.Interval = config.getInt("slow_interval"); timer_slow.Enabled = true; timer_slow.Start(); http_server = new HTTPServer(); Console.WriteLine("Started game server on port " + config.getInt("game_port").ToString()); Console.WriteLine("Started http server on port " + config.getInt("http_port").ToString()); }
public ServiceConfiguration() { TextAsset txt = Resources.Load("server_config") as TextAsset; INIReader reader = new INIReader(txt.text); foreach (INIReaderHeader header in reader.GetHeaders()) { if (header.Check("ServerConfig")) { foreach (INIReaderParameter parameter in header.parameters) { if (parameter.Check("maxclients")) { maxClients = parameter.GetInt(0); } else if (parameter.Check("login_server_port")) { loginServerPort = parameter.GetInt(0); } else if (parameter.Check("account_db_dir")) { accountDatabaseDir = parameter.GetString(0); } else if (parameter.Check("account_db_pass")) { accountDatabasePassword = parameter.GetString(0); } } } } }
private void loadConfiguration() { if (System.IO.File.Exists("miv_client_config.ini")) { var ini = new INIReader(System.IO.File.ReadAllLines("miv_client_config.ini")); textBox1.Text = ini.getString("nickname"); } }
public void INIReader_Test() { var filepath = "properties.ini"; var properties = new INIReader(filepath); Assert.AreEqual(properties.getProperty("host"), "localhost"); Assert.AreEqual(properties.getProperty("user"), "admin"); Assert.AreEqual(properties.getProperty("password"), "qwerty"); }
public void GetProperties_Test() { var filepath = "properties.ini"; var properties = INIReader.GetProperties(filepath); Assert.AreEqual(properties["host"], "localhost"); Assert.AreEqual(properties["user"], "admin"); Assert.AreEqual(properties["password"], "qwerty"); }
public static int LoadAll(IndexArchStorage <T> outVal, string dirPath, string masterSection) { UnityEngine.Object[] assets = Resources.LoadAll(dirPath, typeof(TextAsset)); int loaded = outVal.Count; foreach (UnityEngine.Object e in assets) { TextAsset txtAsset = e as TextAsset; if (e == null) { continue; } INIReader reader = new INIReader(txtAsset.text); T archObj = null; foreach (INIReaderHeader h in reader.GetHeaders()) { if ((h.nickname.CompareTo(masterSection) == 0) && (archObj == null)) { archObj = new T(); archObj.ReadHeader(h); } else if ((h.nickname.CompareTo(masterSection) != 0) && (archObj != null)) { archObj.ReadHeader(h); } else if ((h.nickname.CompareTo(masterSection) == 0) && (archObj != null)) { // Store previous if (archObj.id != 0) { outVal.Add(archObj); } // Create new and read current section archObj = new T(); archObj.ReadHeader(h); } } if (archObj != null && archObj.id != 0) { outVal.Add(archObj); } } outVal.BuildIndexData(); return(outVal.Count - loaded); }
private static void ReadINI() { INIReader reader = new INIReader(); using (FileStream s = File.OpenRead(System.IO.Directory.GetCurrentDirectory() + "/test.ini")) { _file = reader.Read(s); } Console.WriteLine("Attempting to read INI..."); Console.WriteLine(_file.ToString()); }
public void Awake() { #if WINDOWS_UWP var parser = new INIReader(Path.Combine(Application.persistentDataPath, "config.ini")); RosBridgeServerUrl = parser.getConfig("IP"); ConnectAndWait(); #else var parser = new INIReader(Path.Combine(Application.dataPath, "Config", "config.ini")); RosBridgeServerUrl = parser.getConfig("IP"); new Thread(ConnectAndWait).Start(); #endif }
/// <summary> /// 载入本地的ip配置 /// </summary> public static void loadConfig() { string path = Environment.CurrentDirectory + "\\setting.ini"; if (File.Exists(path)) { INIReader reader = new INIReader(); reader.LoadFromFile(path); myIP = reader.Serializal <MyIP>("sql"); } else { myIP = new MyIP(); } }
/// <summary> /// /// The main program executes the tests. Output may be routed to /// various locations, depending on the arguments passed. /// </summary> /// <remarks>Run with --help for a full list of arguments supported</remarks> /// <param name="args"></param> public static int Main(string[] args) { // set the system of physical units to SI INIReader.ClearSingleton(); UnitsConversionFactories.ClearSingleton(); var ini = INIReader.Instance(); ini.Values["UnitsSystem"] = "SI"; ini.Values["gravity"] = "10.0"; // run the tests var res = new AutoRun().Execute(args); Console.WriteLine("Press any key to close"); Console.ReadKey(); return res; }
public static CellularAutomataInitializationData Load(string file, CellularAutomataStateLoadingParameters loadingParameters) { INIData iniData = INIReader.Read(file); int seed = iniData.GetInt("Seed", "Initialization"); bool isTorus = iniData.GetBool("IsTorus", "Initialization"); string nbhMode_raw = iniData.GetString("NeighbourhoodMode", "Initialization"); NeighbourhoodMode nbhMode = (NeighbourhoodMode)Enum.Parse(typeof(NeighbourhoodMode), nbhMode_raw); bool hasData = iniData.GetBool("HasData", "Initialization"); int cellCount = iniData.GetInt("CellCount", "Initialization"); if (!hasData) { return(new CellularAutomataInitializationData(seed, cellCount, isTorus, nbhMode)); } (long state, float stateValue)[,] cellData = new(long state, float stateValue)[cellCount, cellCount];
public Client() { var startup = new Timer(6000); startup.Tick += (o, e) => { startup.Stop(); BindConsoleCommand("reconnect", (a) => { if (System.IO.File.Exists("miv_lastserver.ini")) { darkscreen = new ClientRectangleView(new System.Drawing.RectangleF(0, 0, 2000, 2000), System.Drawing.Color.Black); Game.FadeScreenOut(1); string[] lines = System.IO.File.ReadAllLines("miv_lastserver.ini"); INIReader reader = new INIReader(lines); initAndConnect(reader.getString("ip"), reader.getInt16("port"), reader.getString("nickname")); } }); if (System.IO.File.Exists("_serverinit.ini")) { darkscreen = new ClientRectangleView(new System.Drawing.RectangleF(0, 0, 2000, 2000), System.Drawing.Color.Black); string[] lines = System.IO.File.ReadAllLines("_serverinit.ini"); INIReader reader = new INIReader(lines); Int64 timestamp_saved = reader.getInt64("timestamp"); Int64 timestamp_now = System.Diagnostics.Stopwatch.GetTimestamp(); TimeSpan time_delta = new TimeSpan(timestamp_now - timestamp_saved); if (time_delta.Minutes < 5) { System.IO.File.Delete("_serverinit.ini"); System.IO.File.WriteAllLines("miv_lastserver.ini", lines); initAndConnect(reader.getString("ip"), reader.getInt16("port"), reader.getString("nickname")); } } else { FileSystemOverlay.crashIfSPPreparationFail(); } }; startup.Start(); // nope? nothing to do }
public void ModelMassImperialUnits() { // make temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactory.ClearSingleton(); var ini = INIReader.Instance(); ini.Values["UnitsSystem"] = "imperial"; ini.Values["gravity"] = "9.80665"; var k3d = new Toolkit(); var gamma = 1.0; // (kip/ft3) var unit_material = new FemMaterial_Isotrop("unit", "unit", 1, 0.5, 0.5, gamma, 1.0, -1.0, FemMaterial.FlowHypothesis.mises, 1.0, null); var b = 12; // (inch) var t = 6; // (inch) var unit_crosec = k3d.CroSec.Box(b, b, b, t, t, t, 0, 0, unit_material); var elems = new List <BuilderBeam>() { k3d.Part.IndexToBeam(0, 1, "A", unit_crosec), }; var L = 1.0; // in feet var points = new List <Point3> { new Point3(), new Point3(L, 0, 0) }; var model = k3d.Model.AssembleModel(elems, null, null, out var info, out var mass, out var cog, out var msg, out var runtimeWarning, new List <Joint>(), points); // clear temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactory.ClearSingleton(); ini = INIReader.Instance(); // switch back to SI units ini.Values["UnitsSystem"] = "SI"; Assert.AreEqual(mass, 1000, 1e-10); }
public void ImperialUnits() { var k3d = new Toolkit(); var logger = new MessageLogger(); // make temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactories.ClearSingleton(); var ini = INIReader.Instance(); ini.Values["UnitsSystem"] = "imperial"; var resourcePath = Path.Combine(Utils.PluginPathExe(), @"..\..\Resources\"); // get a cross section from the cross section table in the folder 'Resources' var crosecPath = Path.Combine(resourcePath, "CrossSectionValues.csv"); CroSecTable inCroSecs = k3d.CroSec.ReadCrossSectionTable(crosecPath, out var info); var crosec_family = inCroSecs.crosecs.FindAll(x => x.family == "W"); var crosec_initial = crosec_family.Find(x => x.name == "W12X26"); // clear temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactories.ClearSingleton(); var cs = crosec_initial as CroSec_I; var m2feet = 3.28084; var height_feet = 0.31 * m2feet; var width_feet = 0.165 * m2feet; Assert.AreEqual(cs._height, height_feet, 1e-5); Assert.AreEqual(cs.lf_width, width_feet, 1e-5); var feet42inch4 = Math.Pow(12.0, 4); var cm42inch4 = Math.Pow(1.0 / 2.54, 4); var Iyy_inch1 = 8491.12 * cm42inch4; var Iyy_inch2 = cs.Iyy * feet42inch4; Assert.AreEqual(Iyy_inch1, Iyy_inch2, 1e-1); }
/* This hasn't been tested with the INIReader code and * JSON and XML support hasn't been added. * So obviously it needs work. */ public static FileReader CreateReader(FRType type, string path) { FileReader reader = null; switch (type) { case FRType.INIReader: reader = new INIReader(path); break; case FRType.JSONReader: Console.WriteLine("Not Implemented yet, sorry."); //reader = new JSONReader(); break; case FRType.XMLReader: Console.WriteLine("Not Implemented yet, sorry."); //reader = new XMLReader(); break; } return(reader); }
public void CreateTestFile() { INIWriter builder = new INIWriter(); builder.AppendKVP("Int32TypeValue", 123); builder.AppendKVP("FloatTypeValue", -123.6F); builder.AppendKVP("DoubleTypeValue", 123.4); builder.AppendKVP("BooleanTypeValue", false); builder.AppendKVP("StringTypeValue", "123"); builder.AppendKVP("NullStringTypeValue", null); builder.AppendKVP("EmptyStringTypeValue", ""); builder.AppendKVP("SpaceStringTypeValue", " "); builder.AppendKVP("KVPPatternStringTypeValue", "(some text 1) = (some text 2)"); builder.AppendKVP("UnsupportedCharsStringTypeValue", "a" + Environment.NewLine + "b"); builder.AppendKVP("UnsupportedCharsStringTypeValue2", "|"); //builder.AppendKVP("Key with spaces", 999); // Исключение как и положено builder.Save(_testINIFilePath); _parser = new INIReader(_testINIFilePath); }
public void SinglemassEigenfrequency_SI() { // make temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactory.ClearSingleton(); var ini = INIReader.Instance(); ini.Values["UnitsSystem"] = "SI"; ini.Values["UnitsSystem"] = "SI"; var gravity = 9.81; // m/s2 ini.Values["gravity"] = gravity.ToString(CultureInfo.InvariantCulture); ini.Values["UnitLength"] = "ft"; ini.Values["UnitForce"] = "MN"; ini.Values["UnitMass"] = "t"; var uc = UnitsConversionFactory.Conv(); gravity = uc.gravity().toBase(); // cm/s2 var k3d = new Toolkit(); var E = uc["N/cm2"].toBase(70); var gamma = uc["N/cm3"].toBase(1.0); // input is not scaled to base units var unit_material = new FemMaterial_Isotrop("unit", "unit", E, 0.5 * E, 0.5 * E, gamma, 1.0, -1.0, FemMaterial.FlowHypothesis.mises, 1.0, null); var b = 6; // (cm) var t = 3; // (cm) // input is scaled to base units var unit_crosec = k3d.CroSec.Box(b, b, b, t, t, t, 0, 0, unit_material); var elems = new List <BuilderBeam>() { k3d.Part.IndexToBeam(0, 1, "A", unit_crosec), }; elems[0].bending_stiff = false; var L = uc["cm"].toBase(10.0); var points = new List <Point3> { new Point3(), new Point3(L, 0, 0) }; var supports = new List <Support> { k3d.Support.Support(0, k3d.Support.SupportFixedConditions), k3d.Support.Support(1, new List <bool>() { false, true, true, true, true, true }) }; var model = k3d.Model.AssembleModel(elems, supports, null, out var info, out var mass, out var cog, out var msg, out var runtimeWarning, new List <Joint>(), points); // calculate the natural vibrations int from_shape_ind = 1; int shapes_num = 1; int max_iter = 100; double eps = 1e-8; var disp_dummy = new List <double>(); var scaling = EigenShapesScalingType.matrix; model = k3d.Algorithms.NaturalVibes(model, from_shape_ind, shapes_num, max_iter, eps, disp_dummy, scaling, out var nat_frequencies, out var modal_masses, out var participation_facs, out var participation_facs_disp, out model); var E_ = E; // N/cm2 var A_ = unit_crosec.A; // cm2 var L_ = L; // cm; var gamma_ = unit_material.gamma(); // N/cm3 var c = E_ * A_ / L; // N / m var m = A_ * L_ * gamma_ / gravity * 0.5; // kg var omega0 = Math.Sqrt(c / m); // rad / sec var f0 = omega0 / 2.0 / Math.PI; // 1 / sec = Hz Assert.AreEqual(nat_frequencies[0], f0, 1e-2); // clear temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactory.ClearSingleton(); ini = INIReader.Instance(); // switch back to SI units ini.Values["UnitsSystem"] = "SI"; }
public void Start() { PlugLoader plugLoader = TempFactory.GetPlugLoader(); plugLoader.AppDomainLoaded += new AppDomainLoadedHandler(this.AppDomainLoaded); plugLoader.AppDomainUnloaded += new AppDomainUnloadedHandler(this.AppDomainUnloaded); plugLoader.LoadingAppDomain += new LoadingAppDomainHandler(this.LoadingAppDomain); plugLoader.LoadingPlug += new LoadingPlugHandler(this.LoadingPlug); plugLoader.PlugLoaded += new PlugLoadedHandler(this.PlugLoaded); plugLoader.PlugLoadException += new PlugLoadExceptionHandler(this.PlugLoadException); plugLoader.UnloadingAppDomain += new UnloadingAppDomainHandler(this.UnloadingAppDomainHandler); TestLoadInfo[] testholders = plugLoader.GetAllPlugs(TempFactory.GetLoadTestsInfo()); for (int i = 0; i < testholders.Length; i++) { Console.WriteLine(i + " : " + testholders[i]); } int inpi = 0; if (testholders.Length > 1) { Console.Write("Test#:"); string inps = Console.ReadLine(); inpi = Convert.ToInt32(inps); } TestLoadInfo tl = testholders[inpi]; ITest test = plugLoader.LoadPlug(tl.AppDomainName, tl.AssemblyName, tl.ClassName); ConsoleOutput cout = new ConsoleOutput(); test.SetOutput(cout); cout.WriteLine("Parameters..."); IParam[] tparams = test.GetParameters(); INIReader r = new INIReader(AppDomain.CurrentDomain.BaseDirectory + "AllTests.ini"); for (int y = 0; y < tparams.Length; y++) { IParam param = (tparams[y]); cout.WriteLine("Enter New Value for : " + param); if (param is NumberParam) { if (testholders.Length == 1) { ((NumberParam)param).Number = Convert.ToInt32(r.ReadValue(testholders[inpi].AssemblyName, "Param" + y)); } else { cout.Write("Number:"); ((NumberParam)param).Number = Convert.ToInt32(Get(param)); } } else if (param is TextParam) { if (testholders.Length == 1) { ((TextParam)param).TextValue = r.ReadValue(testholders[inpi].AssemblyName, "Param" + y); } else { cout.Write("Text:"); ((TextParam)param).TextValue = Get(param); } } else if (param is BoolParam) { if (testholders.Length == 1) { ((BoolParam)param).Value = Convert.ToBoolean(r.ReadValue(testholders[inpi].AssemblyName, "Param" + y)); } else { cout.Write("Bool:"); ((BoolParam)param).Value = Convert.ToBoolean(Get(param)); } } else if (param is KeyValueParam) { cout.Write("KeyVal:"); //((KeyValueParam)param).SelectedText = ((ComboBox)control).SelectedValue.ToString(); } else if (param is CoOrdinatesParam) { if (testholders.Length == 1) { ((CoOrdinatesParam)param).XParam.Number = Convert.ToInt32(r.ReadValue(testholders[inpi].AssemblyName, "ParamX" + y)); ((CoOrdinatesParam)param).XParam.Number = Convert.ToInt32(r.ReadValue(testholders[inpi].AssemblyName, "ParamY" + y)); } else { cout.Write("NumberX:"); ((CoOrdinatesParam)param).XParam.Number = Convert.ToInt32(Get(((CoOrdinatesParam)param).XParam)); cout.Write("NumberY:"); ((CoOrdinatesParam)param).YParam.Number = Convert.ToInt32(Get(((CoOrdinatesParam)param).YParam)); } } } cout.WriteLine("Enter to exec..."); Console.ReadLine(); test.ExecuteThis(); cout.WriteLine("Done."); Console.ReadLine(); }
void VersionCheck() { string dic = Application.persistentDataPath + "/"; string tempath = dic + "versions.ini"; INIReader ini = new INIReader(); ini.LoadFromFile(tempath); string key = "win"; if (Application.platform == RuntimePlatform.IPhonePlayer) { key = "ios"; } else if (Application.platform == RuntimePlatform.Android) { key = "and"; } var sec = ini.FindSection(key); var values = sec.values; for (int i = 0; i < values.Count; i++) { var kv = values[i]; string value = PlayerPrefs.GetString(kv.key); string path = dic + kv.key; if (value != kv.value | !File.Exists(path)) { OssMission mission = new OssMission(); mission.dir = Application.persistentDataPath + "/"; mission.Name = kv.key; mission.Version = kv.value; ossMissions.Add(mission); mission.Tip = (o) => { view.Tip.Text = "正在下载资源:" + o.Name; SetProgress(o.Progress); }; mission.Completed = (o) => { OssMission oss = o as OssMission; ossMissions.Remove(oss); PlayerPrefs.SetString(oss.Name, oss.Version); if (oss.Name.Contains(".lzma")) { if (oss.Done) { DecompressLZMA(oss.Name, oss.Version); } } }; } else if (kv.key.Contains(".lzma")) { string str = kv.key; str = str.Replace(".lzma", ""); value = PlayerPrefs.GetString(str); if (value != kv.value) { DecompressLZMA(kv.key, kv.value); } } } }
public static void Load(IndexArchStorage <T> outVal, string assetFile, string masterSection) { TextAsset txt = (TextAsset)Resources.Load(assetFile); if (txt == null) { Debug.Log("ArchLoader: failed to locate file - " + assetFile); return; } // now loop through all strings StringReader stringReader = new StringReader(txt.text); string currentLine; while ((currentLine = stringReader.ReadLine()) != null) { if (currentLine.StartsWith("//")) { continue; } if (currentLine.Length == 0) { continue; } // Load { TextAsset iniText = (TextAsset)Resources.Load(currentLine); if (iniText == null) { Debug.Log("ArchLoader: failed to locate listed file - " + currentLine); continue; } INIReader reader = new INIReader(iniText.text); T archObj = null; foreach (INIReaderHeader h in reader.GetHeaders()) { if ((h.nickname.CompareTo(masterSection) == 0) && (archObj == null)) { archObj = new T(); archObj.ReadHeader(h); } else if ((h.nickname.CompareTo(masterSection) != 0) && (archObj != null)) { archObj.ReadHeader(h); } else if ((h.nickname.CompareTo(masterSection) == 0) && (archObj != null)) { // Store previous outVal.Add(archObj); // Create new and read current section archObj = new T(); archObj.ReadHeader(h); } } if (archObj != null) { outVal.Add(archObj); } } } outVal.BuildIndexData(); }
public void PointMassOnSpring_SI() { // make temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactory.ClearSingleton(); var ini = INIReader.Instance(); ini.Values["UnitsSystem"] = "SI"; ini.Values["UnitsSystem"] = "SI"; var gravity = 9.81; // m/s2 ini.Values["gravity"] = gravity.ToString(CultureInfo.InvariantCulture); ini.Values["UnitLength"] = "cm"; ini.Values["UnitForce"] = "N"; ini.Values["UnitMass"] = "t"; var k3d = new Toolkit(); var uc = UnitsConversionFactory.Conv(); var c_trans = uc["N/cm"].toBase(50); var c_rot = uc["Ncm/rad"].toBase(50); var unitCrosec = k3d.CroSec.Spring(new double[] { c_trans, c_trans, c_trans, c_rot, c_rot, c_rot }); var elems = new List <BuilderBeam>() { k3d.Part.IndexToBeam(0, 1, "A", unitCrosec), }; elems[0].bending_stiff = false; var L = uc["cm"].toBase(10.0); var points = new List <Point3> { new Point3(), new Point3(L, 0, 0) }; var supports = new List <Support> { k3d.Support.Support(0, k3d.Support.SupportFixedConditions), k3d.Support.Support(1, new List <bool>() { false, true, true, true, true, true }) }; var m = uc["kg"].toBase(50); // kg var point_mass = new PointMass(1, m, 1); var model = k3d.Model.AssembleModel(elems, supports, new List <Load>() { point_mass }, out var info, out var mass, out var cog, out var msg, out var runtimeWarning, new List <Joint>(), points); // calculate the natural vibrations int from_shape_ind = 1; int shapes_num = 1; int max_iter = 100; double eps = 1e-8; var disp_dummy = new List <double>(); var scaling = EigenShapesScalingType.matrix; model = k3d.Algorithms.NaturalVibes(model, from_shape_ind, shapes_num, max_iter, eps, disp_dummy, scaling, out var nat_frequencies, out var modal_masses, out var participation_facs, out var participation_facs_disp, out model); var omega0 = Math.Sqrt(c_trans / m); // rad / sec var f0 = omega0 / 2.0 / Math.PI; // 1 / sec = Hz Assert.AreEqual(nat_frequencies[0], f0, 1e-2); // clear temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactory.ClearSingleton(); ini = INIReader.Instance(); // switch back to SI units ini.Values["UnitsSystem"] = "SI"; }
public void getProperty_NotFoundKey_Test() { var properties = new INIReader(); var property = properties.getProperty("key"); }
protected override void LoadFromINIFile(Pointer <CCINIClass> pINI) { INIReader reader = new INIReader(pINI); string section = OwnerObject.Ref.Base.Base.ID; }
public void CantileverEigenfrequency() { // make temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactory.ClearSingleton(); var ini = INIReader.Instance(); ini.Values["UnitsSystem"] = "imperial"; ini.Values["gravity"] = "9.80665"; var k3d = new Toolkit(); var E = 70000; // (kip/ft2) == 486111.1 (psi) var gamma = 1.0; // (kip/ft3) var unit_material = new FemMaterial_Isotrop("unit", "unit", E, 0.5 * E, 0.5 * E, gamma, 1.0, -1.0, FemMaterial.FlowHypothesis.mises, 1.0, null); var b = 6; // (inch) var t = 3; // (inch) // Iy = 108 inch^4 // g = 20.833 lb/inch var unit_crosec = k3d.CroSec.Box(b, b, b, t, t, t, 0, 0, unit_material); var elems = new List <BuilderBeam>() { k3d.Part.IndexToBeam(0, 1, "A", unit_crosec), }; var L = 10.0; // in feet var points = new List <Point3> { new Point3(), new Point3(L, 0, 0) }; var supports = new List <Support> { k3d.Support.Support(0, k3d.Support.SupportFixedConditions) }; var model = k3d.Model.AssembleModel(elems, supports, null, out var info, out var mass, out var cog, out var msg, out var runtimeWarning, new List <Joint>(), points); // calculate the natural vibrations int from_shape_ind = 1; int shapes_num = 1; int max_iter = 100; double eps = 1e-8; var disp_dummy = new List <double>(); var scaling = EigenShapesScalingType.matrix; model = k3d.Algorithms.NaturalVibes(model, from_shape_ind, shapes_num, max_iter, eps, disp_dummy, scaling, out var nat_frequencies, out var modal_masses, out var participation_facs, out var participation_facs_disp, out model); // calculate the expected value of the first eigen-frequency // see Young, W. C., Budynas, R. G.(2002). Roark's Formulas for Stress and Strain . // 7nd Edition, McGraw-Hill, Chapter 16 , pp 767 - 768 var E_ = E * 1000.0 * Math.Pow(UnitConversionCollection.inch_to_ft, 2); var I_ = unit_crosec.Iyy / Math.Pow(UnitConversionCollection.inch_to_ft, 4); var w_ = unit_crosec.A * gamma * 1000.0 * UnitConversionCollection.inch_to_ft; var g_ = UnitConversionCollection.g_IU / UnitConversionCollection.inch_to_ft; var L_ = L / UnitConversionCollection.inch_to_ft; var Kn = 3.52; var f1_expected = Kn / 2.0 / Math.PI * Math.Sqrt(E_ * I_ * g_ / w_ / Math.Pow(L_, 4)); Assert.AreEqual(nat_frequencies[0], f1_expected, 1e-2); // clear temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactory.ClearSingleton(); ini = INIReader.Instance(); // switch back to SI units ini.Values["UnitsSystem"] = "SI"; }
public PlugLoadInfo() { testsReader = new INIReader(AppDomain.CurrentDomain.BaseDirectory + "AllTests.ini"); }