示例#1
0
 public void RaiseDeviceManagerNotification(string command, string info,string source)
 {
     var newDMArgs = new StateMachineEventArgs(command, "Device Manager Event" + info, source, "", StateMachineEventType.Notification);
     if (DeviceManagerNotification != null)
     {
         DeviceManagerNotification(this, newDMArgs);
     }
 }
示例#2
0
 public void RaiseDeviceManagerEvent(string p, string name)
 {
     var newDMArgs= new StateMachineEventArgs(name,"Device Manager Event"+ name,"Device Manager","",StateMachineEventType.System);
     if (DeviceManagerEvent != null)
     {
         DeviceManagerEvent(this, newDMArgs);
     }
 }
示例#3
0
 private void RaiseEventManagerEvent(string eventName,string eventInfo, StateMachineEventType eventType)
 {
     var newArgs=new StateMachineEventArgs(eventName,eventInfo,String.Empty, String.Empty, eventType);
     if (EventManagerEvent != null)
     {
         EventManagerEvent(this, newArgs);
     }
 }
示例#4
0
        public void DeviceCommandHandler(object sender, StateMachineEventArgs args)
        {
            if(args.EventType!=StateMachineEventType.Command) return;

            try
            {
                if(!DeviceList.ContainsKey(args.Target))return;
                var device = DeviceList[args.Target];
                var deviceMethod = device.GetType().GetMethod(args.EventName);
                deviceMethod.Invoke(device, new object[] {});

                RaiseDeviceManagerEvent("Device Command",args.Target);
            }
            catch (Exception ex)
            {
                RaiseDeviceManagerEvent("Device Command error", ex.ToString());
            }
        }
示例#5
0
        public void SystemEventHandler(object sender, StateMachineEventArgs args)
        {
            if (args.EventName == "OnInit" && args.EventType == StateMachineEventType.Command)
            {
                foreach (var dev in DeviceList)
                {

                    try
                    {
                        var initMethod = dev.Value.GetType().GetMethod("OnInit");
                        initMethod.Invoke(dev.Value, new object[] { });
                        RaiseDeviceManagerEvent("DeviceManager -Initialization device", dev.Key);
                    }
                    catch (Exception ex )
                    {

                        RaiseDeviceManagerEvent("DeviceManager -Initialization device exception", dev.Key);
                    }
                }

            }

            if (args.EventType == StateMachineEventType.Command)
            {

                if (args.EventName == "OnInit")
                {
                    return;
                }
                DeviceCommandHandler(this,args);

            }
        }
示例#6
0
 public void Log(object sender, StateMachineEventArgs args)
 {
     Debug.Print(args.EventName);
 }