コード例 #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
ファイル: EventManager.cs プロジェクト: hircjusz/StateMachine
 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
ファイル: LogManager.cs プロジェクト: hircjusz/StateMachine
 public void Log(object sender, StateMachineEventArgs args)
 {
     Debug.Print(args.EventName);
 }