public void Map(SimEvent se) { if (SimConnect != null) { this.SimConnect.MapClientEventToSimEvent((SimEvent.DEFINITIONS)se.Id, se.EventName); } }
public void OnEvent(SimulatedEngagement simulatedEngagement, SimEvent e) { if (e is SimInstantiationEvent) { SimInstantiationEvent simInstantiationEvent = e as SimInstantiationEvent; } }
public void SimEvent_Test_AddingInfo_ToString() { String log = "Test log"; SimEvent testEvent = new SimEvent(log, CubeSatCommSim.Model.EventSeverity.INFO); Assert.AreEqual("[" + CubeSatCommSim.Model.EventSeverity.INFO.ToString() + "] " + log, testEvent.ToString()); }
public bool LoadEventsFromFile(string filename) { if (File.Exists(filename)) { this.EventList.Clear(); string[] lines = File.ReadAllLines(filename); foreach (string l in lines) { string[] items = l.Split(','); if (items.Length >= 1) { //this.AddRequest(items[0], items[1], items[2]); SimEvent se = new SimEvent() { Id = this.EventList.Count + 1, EventName = items[0], //SerialTrigger = items[1] //Writable = items[2] }; this.EventList.Add(se); } } this.EventListModified = false; this.EventsFileName = filename; return(true); } else { MessageBox.Show($"The {filename} does not exists!"); } return(false); }
public static void LoadEvents(string filename) { if (File.Exists(filename)) { string[] lines = File.ReadAllLines(filename); foreach (string l in lines) { string[] items = l.Split(','); SimEvent se = new SimEvent() { }; string n = ""; if (items.Length == 2) { se.EventName = items[0]; SimEventList.Add(se); } if (items.Length > 2) { se.EventName = items[1]; SimEventList.Add(se); } } } }
public void AddEvent(string eventname) { SimEvent ev = this.EventList.Where(k => k.EventName == eventname).FirstOrDefault(); if (ev == null) { ev = new SimEvent() { Id = this.EventList.Count + 1, EventName = eventname }; Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { this.EventList.Add(ev); })); if (this.Connected) { this.Map(ev); } } else { MessageBox.Show($"Event already exists!\r\n\r\n{eventname}"); } }
protected override void processOtherEvent(SimEvent ev) { if (ev.getTag() == SimEventTags.PROCESS_OTHER_CLOUDLET) { foreach (var datacenterChar in JavaUtils.FromJavaList<DatacenterCharacteristics>(this.getDatacenterCharacteristicsList().values())) { this.sendNow(datacenterChar.getResourceName(), SimEventTags.PROCESS_OTHER_CLOUDLET, ev.getData()); } } }
public override void processEvent(SimEvent ev) { base.processEvent(ev); if (ev.getTag() == SimEventTags.PROCESS_OTHER_CLOUDLET) { processCloudlet(ev, SimEventTags.PROCESS_OTHER_CLOUDLET); } }
IEvents CustomEvaluator2_EventTrigger(SimEvent <object> ev1, SimEvent <object> ev2) { yield return(Env.Timeout(5)); ev1.Succeed(7); yield return(Env.Timeout(5)); ev2.Succeed(3); }
SimEvents Triggerer_UnusedInCondition(SimEvent <object> token, Action <SimEvent <object> > triggerer) { var ev = Env.Event(); Env.Process(Triggerer_UnusedInCondition_Aux(ev)); yield return(Env.AnyOf(token, ev)); triggerer(token); }
public void TestSetGetSeverity() { CubeSatCommSim.Model.EventSeverity expectedSeverity = CubeSatCommSim.Model.EventSeverity.WARNING; SimEvent newSimEvent = new SimEvent("log", CubeSatCommSim.Model.EventSeverity.INFO); newSimEvent.Severity = CubeSatCommSim.Model.EventSeverity.WARNING; EventSeverity actualSeverity = newSimEvent.Severity; Assert.AreEqual(expectedSeverity, actualSeverity); }
public void TestSetGetLog() { string expectedLog = "log"; SimEvent newSimEvent = new SimEvent("BadTest", CubeSatCommSim.Model.EventSeverity.INFO); newSimEvent.Log = expectedLog; string actualLog = newSimEvent.Log; Assert.AreEqual(expectedLog, actualLog); }
public void And_2SingleTimeouts_Operator_LeftToRight() { SimEvent t1 = Env.Timeout(1); SimEvent t2 = Env.Timeout(2); var finished = new BoolWrapper(); var cond = t1 & t2; Env.Process(AndConditionChecker(finished, cond, t1, t2)); Env.Run(); Assert.True(finished); }
public Client(SimEnvironment env, G g, int id) : base(env, g) { _id = id; for (var i = 1; i < G.MachineCount; ++i) { var index = (i + id) % G.MachineCount; _peers[i - 1] = new ServerInfo(index); } _packetConstructed = env.Event(); }
public void Execute() { while (Enemy.Health.CurrentAmount > 0) { SimEvent currentEvent = _eventList.First(); _eventList.AddRange(currentEvent.Process()); _eventHistory.Add(currentEvent); _eventList.Remove(currentEvent); _eventList = _eventList.OrderBy(x => x._activationTime).ToList(); } }
public void Or_3SingleTimeouts_Operator_RightToLeft() { SimEvent t1 = Env.Timeout(1); SimEvent t2 = Env.Timeout(2); SimEvent t3 = Env.Timeout(3); var finished = new BoolWrapper(); var cond = t1 | (t2 | (t3)); Env.Process(OrConditionChecker(finished, cond, t1, t2, t3)); Env.Run(); Assert.True(finished); }
public void EventLog_Test_AddEvent_ClearLog() { String log = "Test log"; SimEvent testEvent = new SimEvent(log, CubeSatCommSim.Model.EventSeverity.WARNING); int initNumOfEvents = EventLog.EventList.Count; EventLog.AddLog(testEvent); Assert.AreEqual(initNumOfEvents + 1, EventLog.EventList.Count); EventLog.ClearLog(); Assert.AreEqual(initNumOfEvents, EventLog.EventList.Count); }
public override bool Match(SimEvent simEvent) { int tag = simEvent.Tag; foreach (var t in _tags) { if (tag == t) { return(false); } } return(true); }
public void Or_4SingleTimeouts_Operator_LeftToRight() { SimEvent t1 = Env.Timeout(1); SimEvent t2 = Env.Timeout(2); SimEvent t3 = Env.Timeout(3); SimEvent t4 = Env.Timeout(4); var finished = new BoolWrapper(); var cond = t1 | t2 | t3 | t4; Env.Process(OrConditionChecker(finished, cond, t1, t2, t3, t4)); Env.Run(); Assert.True(finished); }
public void And_4SingleTimeouts_Operator_RightToLeft() { SimEvent t1 = Env.Timeout(1); SimEvent t2 = Env.Timeout(2); SimEvent t3 = Env.Timeout(3); SimEvent t4 = Env.Timeout(4); var finished = new BoolWrapper(); var cond = t1 & (t2 & (t3 & (t4))); Env.Process(AndConditionChecker(finished, cond, t1, t2, t3, t4)); Env.Run(); Assert.True(finished); }
public SimEvent UpsertSimEvent(SimEvent se) { if (se.Id == 0) { DB.SimEvents.Add(se); } else { DB.SimEvents.Update(se); } return(se); }
public override bool Match(SimEvent simEvent) { int src = simEvent.Source; foreach (var id in ids) { if (src == id) { return(true); } } return(false); }
public void And_5SingleTimeouts_Operator_LeftToRight() { SimEvent t1 = Env.Timeout(1); SimEvent t2 = Env.Timeout(2); SimEvent t3 = Env.Timeout(3); SimEvent t4 = Env.Timeout(4); SimEvent t5 = Env.Timeout(5); var finished = new BoolWrapper(); var cond = t1 & t2 & t3 & t4 & t5; Env.Process(AndConditionChecker(finished, cond, t1, t2, t3, t4, t5)); Env.Run(); Assert.True(finished); }
public static int SendEvent(string eventname, uint value) { if (!String.IsNullOrEmpty(eventname)) { SimEvent ev = Globals.MainWindow.SimConnectViewModel.EventList.Where(k => k.EventName == eventname).FirstOrDefault(); if (ev != null) { Globals.MainWindow.SimConnectViewModel.SendEvent(ev, value); return(1); } } return(0); }
// Logs the event. Will create a new one if th public void Log(SimEvent type, params string[] details) { // Creates a new event if all the placeholders are used. while (nextEvent >= typeList.Count) { createEvent(); } // Updates Type and details. typeList[nextEvent].setValue(type); detailList[nextEvent].getList().AddRange(details); detailList[nextEvent].updateValue(); nextEvent++; }
private void SendEvent(object p) { if (this.SimConnect != null) { //if (ev < EVENTS.KEY_NONE) //{ // this.SimConnect.TransmitClientEvent(0, ev, 1, SIMCONNECT_NOTIFICATION_GROUP_ID.SIMCONNECT_GROUP_PRIORITY_DEFAULT, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY); //} //else SimEvent ev = p as SimEvent; { this.SimConnect.TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, (SimEvent.DEFINITIONS)ev.Id, 0, (SimEvent.DEFINITIONS) 0, Microsoft.FlightSimulator.SimConnect.SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY); } } }
public void SendEvent(string cmd, uint data) { SimEvent ev = this.EventList.Where(k => k.EventName == cmd).FirstOrDefault(); if (ev != null) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { this.SendEvent(ev, data); })); Thread.Sleep(10); } else { ev = this.EventList.Where(k => k.EventName == cmd).FirstOrDefault(); if (ev == null) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { ev = new SimEvent() { EventName = cmd, Id = this.EventList.Count + 1 }; this.Map(ev); this.EventList.Add(ev); Thread.Sleep(50); this.SendEvent(ev, 0); })); } } //if (this.SimConnect != null) //{ // //if (ev < EVENTS.KEY_NONE) // //{ // // this.SimConnect.TransmitClientEvent(0, ev, 1, SIMCONNECT_NOTIFICATION_GROUP_ID.SIMCONNECT_GROUP_PRIORITY_DEFAULT, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY); // //} // //else // { // this.SimConnect.TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, (SimEvent.DEFINITIONS)ev.Id, data, (SimEvent.DEFINITIONS)0, Microsoft.FlightSimulator.SimConnect.SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY); // } //} }
public void SendEvent(SimEvent ev, uint data) { if (this.SimConnect != null) { //if (ev < EVENTS.KEY_NONE) //{ // this.SimConnect.TransmitClientEvent(0, ev, 1, SIMCONNECT_NOTIFICATION_GROUP_ID.SIMCONNECT_GROUP_PRIORITY_DEFAULT, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY); //} //else //m_simConnect.m_simConnect.TransmitClientEvent(0U, m_events[name], value, (Enum)NOTIFICATION_GROUPS.GENERIC, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY); try { this.SimConnect.TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, (SimEvent.DEFINITIONS)ev.Id, data, (SimEvent.DEFINITIONS) 0, Microsoft.FlightSimulator.SimConnect.SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
SimEvents Triggerer_UnusedInCondition_Aux(SimEvent <object> token) { yield return(Env.Timeout(5)); token.Succeed(); }
static IEnumerable <SimEvent> DoFail(SimEnvironment env, SimEvent <object> ev) { yield return(env.Timeout(5)); ev.Fail("NO :("); }
static IEnumerable <SimEvent> DoSucceed(SimEnvironment env, SimEvent <object> ev) { yield return(env.Timeout(5)); ev.Succeed("SI :)"); }
public override bool Match(SimEvent e) { return(false); }