private void CoSimulator_MSimulationEventHandler(object sender, MSimulationEvent e) { if (e.Reference == this.currentInstruction.ID && e.Type == mmiConstants.MSimulationEvent_End) { //Start the next instruction this.StartInstruction(); } }
/// <summary> /// Callback for the co-simulation event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CoSimulator_MSimulationEventHandler(object sender, MSimulationEvent e) { Debug.Log(e.Reference + " " + e.Name + " " + e.Type); //If Queue is finished abort all instructions and raise event if (e.Name.Equals("FinishedQueue")) { CoSimulator.Abort(); QueueFinished?.Invoke(); } }
/// <summary> /// Callback for the co-simulation event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CoSimulator_MSimulationEventHandler(object sender, MSimulationEvent e) { Debug.Log(e.Reference + " " + e.Name + " " + e.Type); }
private void ShowInstructionWindows() { GUIStyle guiStyle = new GUIStyle { padding = new RectOffset(0, 0, 0, 0) }; int totalWidth = Screen.width - (int)(sliderOffsetX * 2); int hierachyLevel = 1; //To do Check how many are simulatanously active foreach (InstructionWindow w in instructionWindows) { //-----------------Start events-------------------------------------------------------------------- GUI.color = Color.black; GUI.backgroundColor = Color.black; //Total height in pixels int height = 20; //Total width in pixel float width = 1f / (float)(this.record.Frames.Count) * (float)totalWidth; int index = 0; foreach (int eventIndex in w.Events) { //Adjust color depending on event type MSimulationEvent simEvent = w.RawEvents[index]; GUI.color = Color.black; GUI.backgroundColor = Color.black; if (simEvent.Type == mmiConstants.MSimulationEvent_Start) { GUI.color = Color.blue; } if (simEvent.Type == mmiConstants.MSimulationEvent_End) { GUI.color = Color.green; } //To do Texture2D texture = new Texture2D((int)width, height); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { texture.SetPixel(x, y, Color.black); } } float relCoord = (float)eventIndex / (float)this.record.Frames.Count; if (GUI.Button(new Rect(sliderOffsetX + relCoord * totalWidth - width / 2f, Screen.height - 60 - hierachyLevel * 20, width, height), texture, guiStyle)) { //Display the name of the event this.sliderValue = eventIndex; } index++; } //-----------------End events-------------------------------------------------------------------- GUI.color = Color.green; GUI.backgroundColor = Color.black; if (currentInstruction != null && currentInstruction.ID == w.Instruction.ID) { GUI.backgroundColor = Color.green; } float start = (float)w.StartIndex / (float)this.record.Frames.Count; float end = (float)w.EndIndex / (float)this.record.Frames.Count; float relativeWidth = end - start; if (GUI.Button(new Rect(sliderOffsetX + start * totalWidth, Screen.height - 60 - hierachyLevel * 20, relativeWidth * totalWidth, 20), w.Instruction.Name)) { this.sliderValue = w.StartIndex; } hierachyLevel++; } }