public Store(StoreParams sp) { Program.Debug("Creating Store..."); //Store params are the C-01 - C-12 variables _storeParams = sp; //Singleton Instance myInstance = this; //Has references to SP and SPQueues ServicePoint.resetCounter(); _spm = new ServicePointSystem(); //Main Customer Queue Customer.resetCounter(); _mainQueue = new Queue<Customer>(); //customer pool _customerPool = new List<Customer>(); //Manager if (StoreParams.ManagerPresent == true) { open = false; _manager = new Manager(); } else open = true; }
public static void randomSimulation(StoreParams sp) { Store store = new Store(sp); DateTime lastTick = DateTime.Now; while (true) { store.Simulate((DateTime.Now - lastTick).TotalMilliseconds); lastTick = DateTime.Now; //sleep it a bit to get a better sample from rand System.Threading.Thread.Sleep(10); } }
public static bool writeSettings(StoreParams sp, Stream stream) { try { float timescale = sp.TimeScale; sp.TimeScale = 1; StreamWriter f = new StreamWriter(stream); foreach (System.Reflection.PropertyInfo pi in sp.GetType().GetProperties()) { if(pi.Name == "TimeScale") f.WriteLine(pi.Name + " = " + timescale + ";"); else f.WriteLine(pi.Name + " = " + pi.GetValue(sp, null) + ";"); } f.Flush(); sp.TimeScale = timescale; return true; } catch (Exception e) { lastException = e; return false; } }
public static StoreParams createFromSettings(string settings) { //do awesome things with reflection StoreParams sp = new StoreParams(); string[] clauses = settings.Replace("\n", "").Replace(" ", "").Replace("\r", "").Split(';'); foreach (string clause in clauses) { if (clause.Equals("")) continue; string key = clause.Substring(0, clause.IndexOf("=")); string value = clause.Substring(clause.IndexOf("=") + 1); if (key.Equals("") || value.Equals("")) continue; sp.reflectionSet(key, value); } return sp; }