Exemplo n.º 1
0
        private void LoadConditionEvent(ComAeClient client, int eventTypeId, int categoryId, string description, List <EventAttribute> attributes)
        {
            string[] conditionNames = null;

            try
            {
                client.GetConditionNames(categoryId, out conditionNames);
            }
            catch (Exception e)
            {
                Utils.Trace(e, "Unexpected error fetching condition names.");
                conditionNames = null;
            }

            if (conditionNames != null)
            {
                // create a condition class for the category.
                EventType eventType = new EventType();
                eventType.EventTypeId       = eventTypeId;
                eventType.CategoryId        = categoryId;
                eventType.Description       = description;
                eventType.ConditionName     = null;
                eventType.SubConditionNames = null;
                eventType.Attributes        = new List <EventAttribute>();
                DetermineMapping(eventType);
                EventTypes.Add(eventType);

                // create event types for each condition name.
                for (int ii = 0; ii < conditionNames.Length; ii++)
                {
                    eventType                   = new EventType();
                    eventType.EventTypeId       = eventTypeId;
                    eventType.CategoryId        = categoryId;
                    eventType.Description       = description;
                    eventType.ConditionName     = conditionNames[ii];
                    eventType.SubConditionNames = null;
                    eventType.Attributes        = attributes;
                    DetermineMapping(eventType);

                    string[] subConditionNames = null;

                    try
                    {
                        client.GetSubConditionNames(eventType.ConditionName, out subConditionNames);
                    }
                    catch (Exception e)
                    {
                        Utils.Trace(e, "Unexpected error fetching sub-condition names.");
                        subConditionNames = null;
                    }

                    if (subConditionNames != null)
                    {
                        eventType.SubConditionNames = new List <string>(subConditionNames);
                    }

                    EventTypes.Add(eventType);
                }
            }
        }
Exemplo n.º 2
0
        public LogViewerVM(GameVM gameVM)
        {
            _gameVM = gameVM;
            if (Game != null && Auth != null)
            {
                foreach (var item in Game.EventLog.GetAllEvents(Auth))
                {
                    EventsDict.Add(new EventVM(item, _gameVM.CurrentFaction, _gameVM));
                }
            }


            foreach (var kvp in gameVM.CurrentPlayer.HaltsOnEvent)
            {
                EventTypes.Add(new EventTypeBoolPair(gameVM.CurrentPlayer, kvp.Key));
            }


            _gameVM.Game.GameLoop.GameGlobalDateChangedEvent += GameLoop_GameGlobalDateChangedEvent;
        }
Exemplo n.º 3
0
 public bool CreateEventType(string eventTypeName, out string response)
 {
     if (EventTypes.ValueIsInUseByIdForExpression(x => x.EventTypeName == eventTypeName))
     {
         response = $"An Event Type with name {eventTypeName} already exists.";
         return(false);
     }
     try
     {
         EventType toAdd = new EventType(eventTypeName);
         EventTypes.Add(toAdd);
         Complete();
         response = "Event Type added.";
         return(true);
     }
     catch (Exception ex)
     {
         response = ex.Message;
         return(false);
     }
 }
Exemplo n.º 4
0
        public override void UpdateEventTypesAndTimers()
        {
            IEnumerable <EventType> dashboardtypes = new List <EventType> ();
            IEnumerable <EventType> timelinetypes;

            if (Dashboard != null)
            {
                /* Timers */
                IEnumerable <LMTimer> timers = Dashboard.List.OfType <TimerButton> ().Select(b => b.Timer).OfType <LMTimer> ();
                Timers.AddRange(timers.Except(Timers));

                /* Update event types list that changes when the user adds or remove a
                 * a new button to the dashboard or after importing a project with events
                 * tagged with a different dashboard */
                dashboardtypes = Dashboard.List.OfType <EventButton> ().Select(b => b.EventType);
            }

            /* Remove event types that have no events and are not in the dashboard anymore */
            foreach (EventType evt in EventTypes.Except(dashboardtypes).ToList())
            {
                if (evt == SubstitutionsEventType)
                {
                    continue;
                }
                if (Timeline.Count(e => e.EventType == evt) == 0)
                {
                    EventTypes.Remove(evt);
                }
            }
            EventTypes.AddRange(dashboardtypes.Except(EventTypes));
            timelinetypes = Timeline.Select(t => t.EventType).Distinct().Except(EventTypes);
            EventTypes.AddRange(timelinetypes.Except(EventTypes));
            if (!EventTypes.Contains(SubstitutionsEventType))
            {
                EventTypes.Add(SubstitutionsEventType);
            }

            /* Remove null EventTypes just in case */
            EventTypes = new RangeObservableCollection <EventType> (EventTypes.Where(e => e != null));
        }
Exemplo n.º 5
0
        private void AddEventTypeCommandExecuted()
        {
            var type = new EventType
            {
                ID            = Guid.NewGuid(),
                Name          = "New Event Type",
                Colour        = "#808080",
                PreferredName = "",
                Abbreviation  = ""
            };

            _adminDataUnit.EventTypesRepository.Add(type);
            _adminDataUnit.SaveChanges();

            var typeModel = new EventTypeModel(type);

            LoadEventTypeOptions(typeModel);

            EventTypes.Add(typeModel);

            SelectedObject = typeModel;
        }
Exemplo n.º 6
0
        public void Subscribe <TEvent, TEventHandler>()
            where TEvent : Domain.Core.Events.Event
            where TEventHandler : Domain.Core.Bus.IEventHandler <TEvent>
        {
            try
            {
                string      eventTypeName    = typeof(TEvent).Name;
                System.Type eventHandlerType = typeof(TEventHandler);

                if (EventTypes.Contains(typeof(TEvent)) == false)
                {
                    EventTypes.Add(typeof(TEvent));
                }

                if (EventHandlerTypes.ContainsKey(eventTypeName) == false)
                {
                    EventHandlerTypes.Add(eventTypeName,
                                          new System.Collections.Generic.List <System.Type>());
                }

                if (EventHandlerTypes[eventTypeName].Any(current => current.GetType() == eventHandlerType))
                {
                    string errorMessage =
                        $"Handler Type '{ eventHandlerType.Name }' already is registered for '{ eventTypeName }'!";

                    throw new System.ArgumentException
                              (message: errorMessage, paramName: nameof(eventHandlerType));
                }

                EventHandlerTypes[eventTypeName].Add(eventHandlerType);

                StartBasicConsume <TEvent>();
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Fetches the event categories for the specified event type.
        /// </summary>
        public void LoadEventType(ComAeClient client, int eventTypeId)
        {
            int[]    ids          = null;
            string[] descriptions = null;

            try
            {
                client.GetEventCategories(eventTypeId, out ids, out descriptions);
            }
            catch (Exception e)
            {
                Utils.Trace(e, "Unexpected error fetching event categories.");
            }

            if (ids != null)
            {
                for (int ii = 0; ii < ids.Length; ii++)
                {
                    List <EventAttribute> attributes = LoadEventAttributes(client, eventTypeId, ids[ii]);

                    if (eventTypeId == OpcRcw.Ae.Constants.CONDITION_EVENT)
                    {
                        LoadConditionEvent(client, eventTypeId, ids[ii], descriptions[ii], attributes);
                        continue;
                    }

                    EventType eventType = new EventType();
                    eventType.EventTypeId       = eventTypeId;
                    eventType.CategoryId        = ids[ii];
                    eventType.Description       = descriptions[ii];
                    eventType.ConditionName     = null;
                    eventType.SubConditionNames = null;
                    eventType.Attributes        = attributes;
                    DetermineMapping(eventType);
                    EventTypes.Add(eventType);
                }
            }
        }
Exemplo n.º 8
0
        public EvDevDevice(int fd, IntPtr dev)
        {
            Fd   = fd;
            _dev = dev;
            Name = Marshal.PtrToStringAnsi(NativeUnsafeMethods.libevdev_get_name(_dev));
            foreach (EvType type in Enum.GetValues(typeof(EvType)))
            {
                if (NativeUnsafeMethods.libevdev_has_event_type(dev, type) != 0)
                {
                    EventTypes.Add(type);
                }
            }
            var ptr = NativeUnsafeMethods.libevdev_get_abs_info(dev, (int)AbsAxis.ABS_X);

            if (ptr != null)
            {
                AbsX = *ptr;
            }
            ptr = NativeUnsafeMethods.libevdev_get_abs_info(dev, (int)AbsAxis.ABS_Y);
            if (ptr != null)
            {
                AbsY = *ptr;
            }
        }