IEnumerable <IEvent> Clock(SimContext e, TimeSpan ts) { for (;;) { yield return(new Timeout(ts)); _val = e.Now; } }
private static void SeedRoles(SimContext context, RoleManager <IdentityRole> roleManager) { if (!roleManager.RoleExistsAsync(ApplicationUserRoles.UserRole).Result) { roleManager.CreateAsync(new IdentityRole(ApplicationUserRoles.UserRole)).Wait(); } if (!roleManager.RoleExistsAsync(ApplicationUserRoles.AdminRole).Result) { roleManager.CreateAsync(new IdentityRole(ApplicationUserRoles.AdminRole)).Wait(); } }
public void A() { _context = new SimContext(); _counter = new SimpleResource(2); _context.Process(CustomerGenerator(2, 100)); for (int i = 0; i < 30; i++) { _context.Step(); } //todo }
private void BT_SaveOD_Click(object sender, EventArgs e) { ds = new DataSet(); ds.ReadXml(strFileName); this.DGV_ODData.DataSource = ds.Tables[1]; DGV_ODData.Show(); ISC = SimContext.GetInstance(); DataTable dt = ds.Tables[1]; DataColumnCollection dc = dt.Columns; try { dc.Add(new DataColumn("EntityID")); dc.Add(new DataColumn("iCarNum")); dc.Add(new DataColumn("iTimeStep")); dc.Add(new DataColumn("iPos")); dc.Add(new DataColumn("iSpeed")); int iMeters = SimSettings.iCellWidth; foreach (KeyValuePair <int, CarInfoDic> itemEntity in ISC.DataRecorder) { foreach (KeyValuePair <int, CarTrack> item in itemEntity.Value)//carinfo Queue { //同一辆车在不同的位置 foreach (var itemCarInfo in item.Value)//车辆信息 { DataRow dr = dt.NewRow(); dr["EntityID"] = itemEntity.Key; dr["iCarNum"] = itemCarInfo.iCarNum; dr["iTimeStep"] = itemCarInfo.iTimeStep; dr["iPos"] = itemCarInfo.iDrivedMileage * iMeters; dr["iSpeed"] = itemCarInfo.iSpeed * iMeters; dt.Rows.Add(dr); } } } ds.WriteXml(strFileName); MessageBox.Show("保存成功"); } catch (Exception eX) { MessageBox.Show("保存失败!" + eX.Message); } }
public void TestMethod1() { var c = new SimContext(); c.Process(Clock(c, 2.Seconds())); c.Process(Clock(c, 3.Seconds())); c.Step(); Assert.True(_val == 2.Seconds().From(new DateTime(0))); c.Step(); Assert.True(_val == 3.Seconds().From(new DateTime(0))); c.Step(); Assert.True(_val == 4.Seconds().From(new DateTime(0))); c.Step(); Assert.True(_val == 6.Seconds().From(new DateTime(0))); c.Step(); Assert.True(_val == 6.Seconds().From(new DateTime(0))); }
public override void DrawChart() { //for updating CHART_SpaceTime.ChartAreas.Clear(); //.Add(new ChartArea("TimeSpace")); CHART_SpaceTime.ChartAreas.Add(new ChartArea("TimeSpace")); SeriesCollection dataSRC = CHART_SpaceTime.Series; ChartArea st = CHART_SpaceTime.ChartAreas[0]; st.AxisX.MajorGrid.Enabled = false; st.AxisY.MajorGrid.Enabled = false; st.AxisY.Title = "速度(m/s)"; st.AxisX.Title = "时间(s)"; ISimContext ISC = SimContext.GetInstance(); int iSpeed; foreach (IDataRecorder <int, CarTrack> itemEntity in ISC.DataRecorder.Values) { foreach (KeyValuePair <int, CarTrack> item in itemEntity)//carinfo Queue { Series dataI = dataSRC.FindByName(item.Key.ToString()); //同一辆车在不同的位置 if (dataI == null) { dataI = new Series(item.Key.ToString()); dataI.MarkerStyle = MarkerStyle.Diamond; dataI.ChartType = SeriesChartType.Line; dataSRC.Add(dataI); } foreach (var itemCarInfo in item.Value)//车辆信息 { iSpeed = itemCarInfo.iSpeed * SimSettings.iCellWidth; dataI.Points.AddXY(itemCarInfo.iTimeStep, iSpeed); } } } CHART_SpaceTime.Show(); }
private static void SeedUsers(SimContext context, IUserService userService) { if (context.Users.Any()) { return; } userService.CreateUserAccount( new CreateUserViewModel { Username = "******", FirstName = "User", LastName = "User", Password = "******" }, ApplicationUserRoles.UserRole).Wait(); userService.CreateUserAccount( new CreateUserViewModel { Username = "******", FirstName = "Admin", LastName = "Admin", Password = "******" }, ApplicationUserRoles.AdminRole).Wait(); }
public SimulationHistoryRepository(SimContext db) { _db = db; }
public static void EnsureSeeds(this SimContext context, IUserService userService, RoleManager <IdentityRole> roleManager) { SeedRoles(context, roleManager); SeedUsers(context, userService); }
public ResourceParameterRepository(SimContext db) { _db = db; }
public ResourceCategoryRepository(SimContext db) { _db = db; }
public ResourceTypeRepository(SimContext db) { _db = db; }
public SimulationNameRepository(SimContext db) { _db = db; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IUserService userService, RoleManager <IdentityRole> roleManager, SimContext dbContext) { dbContext.EnsureSeeds(userService, roleManager); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); if (!env.IsDevelopment()) { app.UseSpaStaticFiles(); } app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { // To learn more about options for serving an Angular SPA from ASP.NET Core, // see https://go.microsoft.com/fwlink/?linkid=864501 spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } }); }