Ejemplo n.º 1
0
        private void XFSDevice_ExecuteEvent(ServiceTypes serviceType, int EventID, IntPtr obj)
        {
            L4Logger.Info("XFSDevice_ExecuteEvent");
            lock (syncObject)
            {
                try
                {
                    var math = XFS_DevicesCollection.Instance.GetValue(serviceType).GlobalEvents.FirstOrDefault(c => c.EventId == EventID);
                    if (math != null)
                    {
                        L4Logger.Info("Global Event Reaised");
                        object res = null;
                        res = Activator.CreateInstance(math.EventParamType);
                        XFSUtil.PtrToStructure(obj, math.EventParamType, ref res);
                        ExecuteEventBase eventBase = new ExecuteEventBase
                        {
                            EventID        = EventID,
                            EventParam     = res,
                            EventParamType = math.EventParamType
                        };
                        SendResponse(eventBase);
                    }
                    else if (XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.XfsCommand is ExecuteCommand)
                    {
                        L4Logger.Info("Command Event Reaised");
                        var    cmnd = (XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.XfsCommand as ExecuteCommand);
                        object res  = null;
                        if (cmnd != null && cmnd.EventParamType != null)
                        {
                            L4Logger.Info("Event hass response model");
                            res = Activator.CreateInstance(cmnd.EventParamType);
                            XFSUtil.PtrToStructure(obj, cmnd.EventParamType, ref res);

                            ExecuteEventBase eventBase = new ExecuteEventBase
                            {
                                EventID        = EventID,
                                EventParam     = res,
                                EventParamType = cmnd.EventParamType
                            };
                            SendResponse(eventBase);
                        }
                        else if (cmnd.EventParamType == null)
                        {
                            L4Logger.Info("Event not model");
                            ExecuteEventBase eventBase = new ExecuteEventBase
                            {
                                EventID        = EventID,
                                EventParam     = null,
                                EventParamType = null
                            };
                            SendResponse(eventBase);
                        }
                    }
                    else
                    {
                        L4Logger.Info("Un categoriezd Event");
                        ExecuteEventBase eventBase = new ExecuteEventBase
                        {
                            EventID        = EventID,
                            EventParam     = null,
                            EventParamType = null
                        };
                        SendResponse(eventBase);
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Ejemplo n.º 2
0
 private void ParsEvent(ExecuteEventBase eventBase)
 {
     switch (eventBase.EventID)
     {
     }
 }