/// <summary> /// Compares the current knowledge of the pedestrian with ModeDB and updates the information. Takes also the next available mode from the ModeDB. /// </summary> public void UpdateKnowledgeFromModeDB() { if (mode == 1) { foreach (var m in currentModeInfoKnowledge) { ModeInfo modefromDB = mdb.GetBusInfoWithId(m.GetId()); if (modefromDB != null && !modefromDB.Equals(mdb)) { //Copy mode (not referencing!) currentModeInfoKnowledge[m.index] = new ModeInfo(modefromDB.GetId(), modefromDB.GetTimeOfArrival()); currentModeInfoKnowledge[m.index].SetStatus(modefromDB.GetStatus()); currentModeInfoKnowledge[m.index].index = m.index; } } } else { foreach (var m in currentModeInfoKnowledge) { ModeInfo modefromDB = mdb.GetMetroInfoWithId(m.GetId()); if (modefromDB != null && !modefromDB.Equals(mdb)) { //Copy mode (not referencing!) currentModeInfoKnowledge[m.index] = new ModeInfo(modefromDB.GetId(), modefromDB.GetTimeOfArrival()); currentModeInfoKnowledge[m.index].SetStatus(modefromDB.GetStatus()); currentModeInfoKnowledge[m.index].index = m.index; } } } GetNextModeFromDB(); }
private void SetMode(ModeInfo mode) { //Debug.Log("################# TEST MSetMode :" + mode.ToString()); ModeViewInfo = mode; switch (ModeViewInfo) { case ModeInfo.Person: //Debug.Log("TEST MSetMode : Person " + m_info); BorderIconTarget.SetActive(true); BorderIconAction.SetActive(true); //m_renderer.enabled = true; //m_renderer.color = Color.white; BorderIconAction.GetComponent <SpriteRenderer>().color = Color.white; break; case ModeInfo.Target: //TEST RayTargetClear(); //Debug.Log("TEST MSetMode : Target " + m_info); //m_renderer.enabled = false; //m_renderer.color = "#9900ff".ToColor(); BorderIconAction.GetComponent <SpriteRenderer>().color = Color.yellow; BorderIconTarget.SetActive(false); BorderIconAction.SetActive(false); break; } }
public SceneContextInstalledArgs(string name, DiContainer container, ModeInfo modeInfo, List <SceneDecoratorContext> decorators) { Name = name; ModeInfo = modeInfo; Container = container; Decorators = decorators; }
protected override void LoadContent() { base.LoadContent(); spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice)); font = Content.Load <SpriteFont>("CourierNew"); var sb = new StringBuilder(); // analyze first the current graphics adapter var currentAdapter = GraphicsDevice.Adapter; // store information about the initial mode currentMode = new ModeInfo(currentAdapter, graphicsDeviceManager.PreferredFullScreenOutputIndex, graphicsDeviceManager.IsFullScreen, graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight); availableModes.Clear(); // LoadContent can be called several times, clear the modes list availableModes.Add(currentMode); // append information about current graphics adapter sb.AppendLine("Current graphics adapter:"); AppendAdapterInfo(sb, currentAdapter); // check if we have more graphics adapters var otherGraphicsAdapters = GraphicsAdapter.Adapters.Where(x => x != currentAdapter).ToList(); if (otherGraphicsAdapters.Count > 0) { // iterate all available graphics adapters and append their information sb.AppendLine(); sb.AppendLine("Other graphics adapters:"); foreach (var adapter in otherGraphicsAdapters) { AppendAdapterInfo(sb, adapter); sb.AppendLine(); } } // append the information about available controls sb.AppendLine("Press:"); for (var i = 0; i < availableModes.Count; i++) { var mode = availableModes[i]; sb.AppendFormat(" {0} - {1}, Monitor {2}, {3}x{4}, {5}{6}", i, mode.Adapter.Description.Description, mode.OutputIndex, mode.Width, mode.Height, mode.IsFullScreen ? "Fullscreen" : "Windowed", Environment.NewLine); } sb.AppendLine(" ESC - to quit"); text = sb.ToString(); }
//below functions are for display pages public async Task <IActionResult> Show(Guid id) { //get session id (we will use it when updating data and handling errors) String sessionID_s = HttpContext.Session.GetString("Session"); Guid sessionID = Guid.Parse(sessionID_s); Data current = new Data(); Program.data.TryGetValue(sessionID, out current); if (current.Receiver != null) //means current!=null { //Get mode's informations and shows it in edit page Mode mod = await _session.Modes.Where(b => b.ID.Equals(id)).FirstOrDefaultAsync(); List <SubModeInfo> INFOLIST = new List <SubModeInfo>(); List <Submode> sbm_list = await _session.Submode.Where(b => b.mode_id.Equals(id)).ToListAsync(); foreach (Submode sbm in sbm_list) { Scan s = await _session.Scan.Where(b => b.ID.Equals(sbm.scan_id)).FirstOrDefaultAsync(); SubModeInfo subModeInfo = new SubModeInfo(sbm, s); INFOLIST.Add(subModeInfo); } ModeInfo INFO = new ModeInfo(); INFO.Mode = mod; INFO.ListOfSubmodes = INFOLIST; //it is necessary when we are going to submode pages current.LastMode = INFO; return(View(INFO)); } return(RedirectToAction("RadarList", "UserRadarList")); }
public bool Equals(ModeInfo obj) { return((this.id.Equals(obj.id)) && (this.timeOfArrival.Equals(obj.timeOfArrival)) && (this.timeCreated.Equals(obj.timeCreated)) && (this.status.Equals(obj.status))); }
/// <summary> /// Auxiliar method used from ModeDB through BroadcastMessage. Handles the reception of new ModeDB information in the pedestrian knowledge. /// </summary> /// <param name="information">Tuple containing the ModeInfo object and an integer indicating the mode.</param> public void NewMessagefromModeDBReceived(Tuple <ModeInfo, int> information) { if (tellMeWhatYouAreDoing) { Debug.Log("Got a message!"); } if (suscribedToModeDB && information.Item2 == mode) { ModeInfo mInfo = information.Item1; foreach (var m in currentModeInfoKnowledge) { if (mInfo.GetId().Equals(m.GetId()) && !mInfo.Equals(m) && mInfo.GetTimeCreated() > m.GetTimeCreated()) { if (tellMeWhatYouAreDoing) { Debug.Log("Message received from mode db: " + mInfo.ToString()); } //Copy mode (not referencing!) currentModeInfoKnowledge[m.index] = new ModeInfo(mInfo.GetId(), mInfo.GetTimeOfArrival()); currentModeInfoKnowledge[m.index].SetStatus(mInfo.GetStatus()); currentModeInfoKnowledge[m.index].index = m.index; } } RumourInfo rInfo = new RumourInfo("rumour" + mInfo.GetId(), mInfo, 1.0f); rumour = new Tuple <RumourInfo, int>(rInfo, information.Item2); InvokeRepeating("SpreadRumour", 1, 1.0f + Random.Range(0.0f, 1.0f)); newKnowledgeToBeCheckedbyController = true; } }
public readonly int Height; // resolution height in pixels // equality members were implemented to cover scenario when there are several GPUs and LoadContent was called // several times - this will avoid comparing ModeInfo by reference to ensure that correct mode was selected #region Equality members private bool Equals(ModeInfo other) { return ((Adapter)Adapter).NativePointer == ((Adapter)other.Adapter).NativePointer && OutputIndex == other.OutputIndex && IsFullScreen.Equals(other.IsFullScreen) && Width == other.Width && Height == other.Height; }
public readonly int Height; // resolution height in pixels // equality members were implemented to cover scenario when there are several GPUs and LoadContent was called // several times - this will avoid comparing ModeInfo by reference to ensure that correct mode was selected #region Equality members private bool Equals(ModeInfo other) { return(((Adapter)Adapter).NativePointer == ((Adapter)other.Adapter).NativePointer && OutputIndex == other.OutputIndex && IsFullScreen.Equals(other.IsFullScreen) && Width == other.Width && Height == other.Height); }
/// <summary> /// Appends the information about current graphics adapter and its output and adds it to the list of available graphics modes /// </summary> /// <param name="sb">Where to write the information</param> /// <param name="adapter">The adapter whose information needs to be analyzed</param> private void AppendAdapterInfo(StringBuilder sb, GraphicsAdapter adapter) { var adapterDescription = adapter.Description; // general adapter information sb.AppendLine(adapterDescription.Description); // onboard video RAM sb.AppendFormat("VRAM : {0}MiB{1}", ToMB(adapterDescription.DedicatedVideoMemory), Environment.NewLine); // OS RAM dedicated to the adapter (typical for integrated GPUs) sb.AppendFormat("Dedicated OS RAM : {0}MiB{1}", ToMB(adapterDescription.DedicatedSystemMemory), Environment.NewLine); // OS RAM that can be shared with the adapter (for example, 'Turbo Cache' for NVidia GPUs) sb.AppendFormat("Shared OS RAM : {0}MiB{1}", ToMB(adapterDescription.SharedSystemMemory), Environment.NewLine); // iterate trough all outputs attached to this adapter for (var i = 0; i < adapter.OutputsCount; i++) { // write its information var output = adapter.GetOutputAt(i); sb.AppendFormat("Output {0}; ", i); var description = ((Output)output).Description; var desktopBounds = description.DesktopBounds; sb.AppendFormat("{0}; Attached to desktop: {1}; Desktop bounds: ({2},{3}; {4},{5}); ", description.DeviceName, description.IsAttachedToDesktop, desktopBounds.Left, desktopBounds.Top, desktopBounds.Right, desktopBounds.Bottom); sb.AppendLine(); sb.Append("\tCurrent display mode: "); // if there is a display mode - write its information and add it in the list of available modes var currentDisplayMode = output.CurrentDisplayMode; if (currentDisplayMode != null) { if (availableModes.Count < 10) { var modeInfo = new ModeInfo(adapter, i, true, desktopBounds.Width, desktopBounds.Height); availableModes.Add(modeInfo); } sb.AppendFormat("{0}x{1}@{2}, {3}", currentDisplayMode.Width, currentDisplayMode.Height, currentDisplayMode.RefreshRate.Numerator / currentDisplayMode.RefreshRate.Denominator, currentDisplayMode.Format); } else { sb.Append("null"); } sb.AppendLine(); } }
protected override void OnSpawn() { base.OnSpawn(); techViewSound = KFMOD.CreateInstance(techViewSoundPath); techViewSoundPlaying = false; Shader.SetGlobalVector("_OverlayParams", Vector4.zero); RegisterModes(); currentModeInfo = modeInfos[OverlayModes.None.ID]; }
protected override void OnLoadLevel() { harvestableNotificationPrefab = null; powerLabelParent = null; Instance = null; OverlayModes.Mode.Clear(); modeInfos = null; currentModeInfo = default(ModeInfo); base.OnLoadLevel(); }
/// <summary> /// Private auxiliar method. From the knowledge of the pedestrian, checks if there is a mode available soon. /// </summary> /// <returns>True if there is a mode available soon, False otherwise.</returns> private bool IsModeAvailableSoon() { float distanceToMode; ModeInfo nextMode = knowledge.NextAvailableMode(); if (nextMode != null) { float timeOfArrival = nextMode.GetTimeOfArrival(); //Calculates the distance to the mode station if (knowledge.mode == 1) { distanceToMode = Vector3.Distance(this.transform.position, steering.busStation.position); } else if (knowledge.mode == 2) { distanceToMode = Vector3.Distance(this.transform.position, steering.metroStation.position); } else { return(true); } //Calculates the time remaining until the mode arrival float timeRemaining = timeOfArrival - (distanceToMode / steering.navAgent.speed) - Time.time; //Check if mode will be available soon depending on the pedestrian tolerance for waiting bool modeAvailableSoon = (timeRemaining > 0) && (timeOfArrival < (Time.time + knowledge.delayTolerance * 3600.0f)); //Mark mode as missed if the pedestrian cannot make it to the station in time if (!modeAvailableSoon) { knowledge.MarkModeAsMissed(nextMode.index); } if (tellMeWhatYouAreDoing) { Debug.Log("Time of arrival of next mode: " + timeOfArrival); Debug.Log("Time right now: " + Time.time); Debug.Log("My tolerance: " + knowledge.delayTolerance * 3600.0f); Debug.Log("Distance to mode: " + distanceToMode / steering.navAgent.speed); Debug.Log("Time I have to arrive there: " + timeRemaining); } return(modeAvailableSoon); } else { return(false); } }
public Exception Validate() { try { NativeMethods.SetDisplayConfig(PathInfo.ToArray(), ModeInfo.ToArray(), NativeMethods.SdcFlags.Validate | NativeMethods.SdcFlags.UseSuppliedDisplayConfig | NativeMethods.SdcFlags.AllowChanges); } catch (Exception ex) { return(ex); } return(null); }
void RebuildModels() { if (modesCount != 0) { for (int i = 0; i < modeInfoList.Count; i++) { if (modeInfoList[i].mMode != null) { GameObject.Destroy(modeInfoList[i].mMode); } } modeInfoList.Clear(); } modesCount = MLPlayerInfo.Instance.GetMaxRoleCount(); for (int i = 0; i < modesCount; i++) { ModeInfo modeinfo = new ModeInfo(); modeinfo.mRoleInfo = MLPlayerInfo.Instance.GetRoleInfo(i); if (modeinfo.mRoleInfo == null) { modeinfo.mModel = null; } else { bool bFemale = modeinfo.mRoleInfo.sex == 1; CustomCharactor.ESex sex = bFemale ? CustomCharactor.ESex.Female : CustomCharactor.ESex.Male; GameObject ob = GameObject.Instantiate(sex == CustomCharactor.ESex.Female ? ModePrefab[0] : ModePrefab[1]) as GameObject; modeinfo.mModel = ob.GetComponent <PlayerModel>(); modeinfo.mModel.mAppearData = new AppearBlendShape.AppearData(); modeinfo.mModel.mAppearData.Deserialize(modeinfo.mRoleInfo.mRoleInfo.appearData); modeinfo.mModel.mNude = new CustomCharactor.AvatarData(); modeinfo.mModel.mNude.Deserialize(modeinfo.mRoleInfo.mRoleInfo.nudeData); modeinfo.mModel.mClothed = bFemale ? mFemaleAvataData : mMaleAvataData; modeinfo.mMode.transform.parent = roleCompents[i].m_boxCollider.transform; modeinfo.mMode.transform.localPosition = bFemale ? new Vector3(mRoleModeLocalPos_Female.x, mRoleModeLocalPos_Female.y, mRoleModeLocalPos_Female.z) : new Vector3(mRoleModeLocalPos_Male.x, mRoleModeLocalPos_Male.y, mRoleModeLocalPos_Male.z); modeinfo.mMode.transform.localRotation = Quaternion.Euler(new Vector3(0, 90, 0)); modeinfo.mMode.transform.localScale = new Vector3(mRoleModeLocalScale.x, mRoleModeLocalScale.y, mRoleModeLocalScale.x); modeinfo.mMode.SetActive(true); modeinfo.mModel.BuildModel(); } modeInfoList.Add(modeinfo); } }
private static Mv MiMvPredQ4(ref ModeInfo mi, int idx) { Mv res = new Mv() { Row = (short)RoundMvCompQ4( mi.Bmi[0].Mv[idx].Row + mi.Bmi[1].Mv[idx].Row + mi.Bmi[2].Mv[idx].Row + mi.Bmi[3].Mv[idx].Row), Col = (short)RoundMvCompQ4( mi.Bmi[0].Mv[idx].Col + mi.Bmi[1].Mv[idx].Col + mi.Bmi[2].Mv[idx].Col + mi.Bmi[3].Mv[idx].Col) }; return(res); }
private static Mv MiMvPredQ2(ref ModeInfo mi, int idx, int block0, int block1) { Mv res = new Mv() { Row = (short)RoundMvCompQ2( mi.Bmi[block0].Mv[idx].Row + mi.Bmi[block1].Mv[idx].Row), Col = (short)RoundMvCompQ2( mi.Bmi[block0].Mv[idx].Col + mi.Bmi[block1].Mv[idx].Col) }; return(res); }
/// <summary> /// Private auxiliar method. Calculates the time to go to the mode station from the closest study point in order to arrive there in time. /// </summary> private void CalculateWhenToGoToMode() { ModeInfo m = knowledge.NextAvailableMode(); if (m != null) { knowledge.timeToGoToMode = m.GetTimeOfArrival() - (Vector3.Distance(steering.ChooseClosestStudyPoint(), steering.metroStation.position) / steering.navAgent.speed); knowledge.timeToGoToMode -= 600; //leave 10 min before } else { //There are no more modes so far, I'll stay at the library! knowledge.timeToGoToMode = float.MaxValue; } }
public static int GetReferenceModeContext(ref Vp9Common cm, ref MacroBlockD xd) { int ctx; // Note: // The mode info data structure has a one element border above and to the // left of the entries corresponding to real macroblocks. // The prediction flags in these dummy entries are initialized to 0. if (!xd.AboveMi.IsNull && !xd.LeftMi.IsNull) { // both edges available if (!xd.AboveMi.Value.HasSecondRef() && !xd.LeftMi.Value.HasSecondRef()) { // Neither edge uses comp pred (0/1) ctx = (xd.AboveMi.Value.RefFrame[0] == cm.CompFixedRef ? 1 : 0) ^ (xd.LeftMi.Value.RefFrame[0] == cm.CompFixedRef ? 1 : 0); } else if (!xd.AboveMi.Value.HasSecondRef()) { // One of two edges uses comp pred (2/3) ctx = 2 + (xd.AboveMi.Value.RefFrame[0] == cm.CompFixedRef || !xd.AboveMi.Value.IsInterBlock() ? 1 : 0); } else if (!xd.LeftMi.Value.HasSecondRef()) { // One of two edges uses comp pred (2/3) ctx = 2 + (xd.LeftMi.Value.RefFrame[0] == cm.CompFixedRef || !xd.LeftMi.Value.IsInterBlock() ? 1 : 0); } else // Both edges use comp pred (4) { ctx = 4; } } else if (!xd.AboveMi.IsNull || !xd.LeftMi.IsNull) { // One edge available ref ModeInfo edgeMi = ref !xd.AboveMi.IsNull ? ref xd.AboveMi.Value : ref xd.LeftMi.Value; if (!edgeMi.HasSecondRef()) { // Edge does not use comp pred (0/1) ctx = edgeMi.RefFrame[0] == cm.CompFixedRef ? 1 : 0; } else { // Edge uses comp pred (3) ctx = 3; } }
/// <summary> /// Applies the current render mode - fullscreen/windowed, resolution and monitor index /// </summary> /// <param name="mode"></param> private void ApplyMode(ModeInfo mode) { if (currentMode == mode) { return; } currentMode = mode; graphicsDeviceManager.PreferredBackBufferWidth = mode.Width; graphicsDeviceManager.PreferredBackBufferHeight = mode.Height; graphicsDeviceManager.IsFullScreen = mode.IsFullScreen; graphicsDeviceManager.PreferredFullScreenOutputIndex = mode.OutputIndex; // graphics adapter will be set during this call in a handler of the 'GraphicsDeviceManager.PreparingDeviceSettings' event. graphicsDeviceManager.ApplyChanges(); }
bool _configure_mode(MeasureMode mode) { ModeInfo modeInfo = new ModeInfo(); bool r = dictModeString.TryGetValue((int)mode, out modeInfo); // // switch mode // r = device.WriteLine(string.Format(":CONFigure:{0}", modeInfo.modeExpress)); if (!r) { return(false); } // // auto range // if (modeInfo.flagRange == true) { r = device.WriteLine(string.Format(":{0}:RANGe:AUTO 1", modeInfo.modeExpress)); if (!r) { return(false); } } // // resolution // if (modeInfo.flagResolution == true) { r = device.WriteLine(string.Format(":{0}:RESolution 0.0001", modeInfo.modeExpress)); if (!r) { return(false); } } device.Query(":CONFigure?"); //Wait mode is stable Thread.Sleep(100); return(r); }
//below functions are for edit pages public async Task <IActionResult> BeforeEdit(Guid id) { //get session id (we will use it when updating data and handling errors) String sessionID_s = HttpContext.Session.GetString("Session"); Guid sessionID = Guid.Parse(sessionID_s); Data current = new Data(); Program.data.TryGetValue(sessionID, out current); if (current != null) { //Because we use the same view before and after edit process we should handle the view messages with the following conditions if (current.edited) { ViewData["Message"] = "Update completed successfully"; current.edited = false; } if (current.message != null) { ViewData["Message"] = current.message; current.message = null; } //Get mode's informations and shows it in edit page Mode mod = await _session.Modes.Where(b => b.ID.Equals(id)).FirstOrDefaultAsync(); List <SubModeInfo> INFOLIST = new List <SubModeInfo>(); List <Submode> sbm_list = await _session.Submode.Where(b => b.mode_id.Equals(id)).ToListAsync(); foreach (Submode sbm in sbm_list) { Scan s = await _session.Scan.Where(b => b.ID.Equals(sbm.scan_id)).FirstOrDefaultAsync(); SubModeInfo subModeInfo = new SubModeInfo(sbm, s); INFOLIST.Add(subModeInfo); } ModeInfo INFO = new ModeInfo(); INFO.Mode = mod; INFO.ListOfSubmodes = INFOLIST; //it is necessary when we are going to submode pages current.LastMode = INFO; return(View(INFO)); } return(RedirectToAction("RadarList", "AdminRadarList")); }
public void ToggleOverlay(HashedString newMode, bool allowSound = true) { bool flag = allowSound && ((!(currentModeInfo.mode.ViewMode() == newMode)) ? true : false); if (newMode != OverlayModes.None.ID) { ManagementMenu.Instance.CloseAll(); } currentModeInfo.mode.Disable(); if (newMode != currentModeInfo.mode.ViewMode() && newMode == OverlayModes.None.ID) { ManagementMenu.Instance.CloseAll(); } ResourceCategoryScreen.Instance.Show(newMode == OverlayModes.None.ID && Game.Instance.GameStarted()); SimDebugView.Instance.SetMode(newMode); if (!modeInfos.TryGetValue(newMode, out currentModeInfo)) { currentModeInfo = modeInfos[OverlayModes.None.ID]; } currentModeInfo.mode.Enable(); if (flag) { UpdateOverlaySounds(); } if (OverlayModes.None.ID == currentModeInfo.mode.ViewMode()) { AudioMixer.instance.Stop(AudioMixerSnapshots.Get().TechFilterOnMigrated, STOP_MODE.ALLOWFADEOUT); MusicManager.instance.SetDynamicMusicOverlayInactive(); techViewSound.stop(STOP_MODE.ALLOWFADEOUT); techViewSoundPlaying = false; } else if (!techViewSoundPlaying) { AudioMixer.instance.Start(AudioMixerSnapshots.Get().TechFilterOnMigrated); MusicManager.instance.SetDynamicMusicOverlayActive(); techViewSound.start(); techViewSoundPlaying = true; } if (OnOverlayChanged != null) { OnOverlayChanged(currentModeInfo.mode.ViewMode()); } ActivateLegend(); }
public static Mv AverageSplitMvs(ref MacroBlockDPlane pd, ref ModeInfo mi, int refr, int block) { int ssIdx = ((pd.SubsamplingX > 0 ? 1 : 0) << 1) | (pd.SubsamplingY > 0 ? 1 : 0); Mv res = new Mv(); switch (ssIdx) { case 0: res = mi.Bmi[block].Mv[refr]; break; case 1: res = MiMvPredQ2(ref mi, refr, block, block + 2); break; case 2: res = MiMvPredQ2(ref mi, refr, block, block + 1); break; case 3: res = MiMvPredQ4(ref mi, refr); break; default: Debug.Assert(ssIdx <= 3 && ssIdx >= 0); break; } return(res); }
public override void OnTouchGesture() { if (timer >= Mathf.Epsilon) { return; } switch (controller.TouchpadGesture.Direction) { case MLInputControllerTouchpadGestureDirection.Up: if (currentInfo == ModeInfo.Credits) { currentInfo = ModeInfo.Info; } else { currentInfo++; } UpdateText(); break; case MLInputControllerTouchpadGestureDirection.Down: if (currentInfo == ModeInfo.Info) { currentInfo = ModeInfo.Credits; } else { currentInfo--; } UpdateText(); break; case MLInputControllerTouchpadGestureDirection.Left: userControl.SetState(new WaveViewState(userControl, header, columns)); break; case MLInputControllerTouchpadGestureDirection.Right: userControl.SetState(new RoomDimState(userControl, header, columns)); break; } }
public async System.Threading.Tasks.Task <IActionResult> Edit(Guid id) { Radar r = await _session.Radars.Where(b => b.ID.Equals(id)).FirstOrDefaultAsync(); Transmitter transmitter_temp = await _session.Transmitters.Where(b => b.ID.Equals(r.transmitter_id)).FirstOrDefaultAsync(); Receiver receiver_temp = await _session.Receivers.Where(b => b.ID.Equals(r.receiver_id)).FirstOrDefaultAsync(); Location location_temp = await _session.Location.Where(b => b.ID.Equals(r.location_id)).FirstOrDefaultAsync(); List <Antenna> AntennaList = await _session.Antennas.Where(b => (b.receiver_id != null && b.receiver_id.Value.Equals(receiver_temp.ID)) || (b.transmitter_id != null && b.transmitter_id.Value.Equals(transmitter_temp.ID))).ToListAsync(); List <Mode> ModeList = await _session.Modes.Where(b => b.radar_id.Equals(r.ID)).ToListAsync(); List <ModeInfo> Modes = new List <ModeInfo>(); foreach (Mode m in ModeList) { ModeInfo INFO = new ModeInfo(); INFO.Mode = m; Modes.Add(INFO); } //FILL THE DATA MODEL WITH NECESSARY VALUES so we can use DATA model in editing process //create new Data element for our current created radar Data radar = new Data(); radar.Transmitter = transmitter_temp; radar.Receiver = receiver_temp; radar.Radar = r; radar.Location = location_temp; radar.ListOfAntennas = AntennaList; radar.ListOfModes = Modes; sessionID_s = HttpContext.Session.GetString("Session"); sessionID = Guid.Parse(sessionID_s); Program.data.Remove(sessionID); Program.data.Add(sessionID, radar); return(View(radar)); }
/// <summary> /// Cancels the next upcoming metro in the schedule. /// </summary> public void CancelNextMetro() { ModeInfo mInfo = null; foreach (ModeInfo m in listOfMetros) { if (m.GetTimeOfArrival() > Time.time && !m.GetStatus().Equals(Status.OUT_OF_SCHEDULE)) { m.SetStatus(Status.OUT_OF_SCHEDULE); mInfo = m; break; } } if (notificatePedestriansSuscribed) { //Notifies about the cancellation to those pedestrians that are suscribed to the ModeDB. UnityEngine.Debug.Log("Broadcasting this message: " + mInfo.ToString()); pedestrians.BroadcastMessage("NewMessagefromModeDBReceived", new Tuple <ModeInfo, int>(mInfo, 2)); } }
public async Task <IActionResult> NewModeAsync(Mode mod) { Guid key = Guid.NewGuid(); //get session id (we will use it when updating data and handling errors) sessionID_s = HttpContext.Session.GetString("Session"); sessionID = Guid.Parse(sessionID_s); Data current = new Data(); Program.data.TryGetValue(sessionID, out current); Mode m = new Mode(key, mod.name, current.Radar.ID); ModeInfo mi = new ModeInfo(m); mi.ListOfSubmodes = new List <SubModeInfo>(); current.LastMode = mi; try { _session.BeginTransaction(); await _session.SaveMode(m); await _session.Commit(); current.message = "New Mode added"; } catch (Exception e) { // log exception here current.message = e.Message.ToString() + " Error"; await _session.Rollback(); return(View(mod)); } finally { _session.CloseTransaction(); } return(RedirectToAction("NewSubmode", "Submode")); }
public async Task <IActionResult> Edit(ModeInfo newValues) { //get session id (we will use it when updating data and handling errors) String sessionID_s = HttpContext.Session.GetString("Session"); Guid sessionID = Guid.Parse(sessionID_s); Data current = new Data(); Program.data.TryGetValue(sessionID, out current); if (current != null) { //update the class for (int i = 0; i < current.ListOfModes.Count; i++) { if (current.ListOfModes[i].Mode.ID.Equals(newValues.Mode.ID)) { current.ListOfModes[i].Mode = newValues.Mode; } } //update the db try { await _session.EditMode(newValues.Mode); } catch (Exception e) { // log exception here current.message = e.Message.ToString() + " Error"; await _session.Rollback(); } finally { _session.CloseTransaction(); } current.edited = true; } return(RedirectToAction("BeforeEdit", "Mode", new { id = newValues.Mode.ID })); }
/// <summary> /// Introduces a delay in all the buses of the schedule. /// </summary> /// <param name="delay">Float containing the amount of delay in seconds.</param> public void DelayBuses(float delay) { foreach (ModeInfo m in listOfBuses) { if (!m.GetStatus().Equals(Status.OUT_OF_SCHEDULE)) { m.DelayMode(delay); m.SetStatus(Status.DELAYED); } } if (notificatePedestriansSuscribed) { //Notifies about the delay to those pedestrians that are suscribed to the ModeDB. ModeInfo mInfo = GetNextBusInfo(); if (mInfo != null) { UnityEngine.Debug.Log("Broadcasting this message: " + mInfo.ToString()); pedestrians.BroadcastMessage("NewMessagefromModeDBReceived", new Tuple <ModeInfo, int>(mInfo, 1)); } } }
/// <summary> /// Gets the next mode from ModeDB and copy it to the pedestrian knowledge. /// </summary> private void GetNextModeFromDB() { ModeInfo m; if (mode == 1) { m = mdb.GetBusInfoWithIndex(currentIndex); } else { m = mdb.GetMetroInfoWithIndex(currentIndex); } if (m != null) { //Copy mode (not referencing!) ModeInfo mAux = new ModeInfo(m.GetId(), m.GetTimeOfArrival()); mAux.SetStatus(m.GetStatus()); mAux.index = currentIndex; currentModeInfoKnowledge.Add(mAux); currentIndex++; } }
protected override void LoadContent() { base.LoadContent(); spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice)); font = Content.Load<SpriteFont>("CourierNew"); var sb = new StringBuilder(); // analyze first the current graphics adapter var currentAdapter = GraphicsDevice.Adapter; // store information about the initial mode currentMode = new ModeInfo(currentAdapter, graphicsDeviceManager.PreferredFullScreenOutputIndex, graphicsDeviceManager.IsFullScreen, graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight); availableModes.Clear(); // LoadContent can be called several times, clear the modes list availableModes.Add(currentMode); // append information about current graphics adapter sb.AppendLine("Current graphics adapter:"); AppendAdapterInfo(sb, currentAdapter); // check if we have more graphics adapters var otherGraphicsAdapters = GraphicsAdapter.Adapters.Where(x => x != currentAdapter).ToList(); if (otherGraphicsAdapters.Count > 0) { // iterate all available graphics adapters and append their information sb.AppendLine(); sb.AppendLine("Other graphics adapters:"); foreach (var adapter in otherGraphicsAdapters) { AppendAdapterInfo(sb, adapter); sb.AppendLine(); } } // append the information about available controls sb.AppendLine("Press:"); for (var i = 0; i < availableModes.Count; i++) { var mode = availableModes[i]; sb.AppendFormat(" {0} - {1}, Monitor {2}, {3}x{4}, {5}{6}", i, mode.Adapter.Description.Description, mode.OutputIndex, mode.Width, mode.Height, mode.IsFullScreen ? "Fullscreen" : "Windowed", Environment.NewLine); } sb.AppendLine(" ESC - to quit"); text = sb.ToString(); }
/// <summary> /// Applies the current render mode - fullscreen/windowed, resolution and monitor index /// </summary> /// <param name="mode"></param> private void ApplyMode(ModeInfo mode) { if (currentMode == mode) return; currentMode = mode; graphicsDeviceManager.PreferredBackBufferWidth = mode.Width; graphicsDeviceManager.PreferredBackBufferHeight = mode.Height; graphicsDeviceManager.IsFullScreen = mode.IsFullScreen; graphicsDeviceManager.PreferredFullScreenOutputIndex = mode.OutputIndex; // graphics adapter will be set during this call in a handler of the 'GraphicsDeviceManager.PreparingDeviceSettings' event. graphicsDeviceManager.ApplyChanges(); }